@pierre/diffs 1.4.3 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/components/CodeView.d.ts +2 -4
  2. package/dist/components/CodeView.d.ts.map +1 -1
  3. package/dist/components/CodeView.js +23 -12
  4. package/dist/components/CodeView.js.map +1 -1
  5. package/dist/components/File.d.ts +2 -0
  6. package/dist/components/File.d.ts.map +1 -1
  7. package/dist/components/File.js +6 -0
  8. package/dist/components/File.js.map +1 -1
  9. package/dist/components/FileDiff.d.ts +18 -1
  10. package/dist/components/FileDiff.d.ts.map +1 -1
  11. package/dist/components/FileDiff.js +47 -15
  12. package/dist/components/FileDiff.js.map +1 -1
  13. package/dist/components/VirtualizedFile.d.ts.map +1 -1
  14. package/dist/components/VirtualizedFile.js +11 -11
  15. package/dist/components/VirtualizedFile.js.map +1 -1
  16. package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
  17. package/dist/components/VirtualizedFileDiff.js +18 -17
  18. package/dist/components/VirtualizedFileDiff.js.map +1 -1
  19. package/dist/constants.d.ts +1 -3
  20. package/dist/constants.d.ts.map +1 -1
  21. package/dist/constants.js +1 -3
  22. package/dist/constants.js.map +1 -1
  23. package/dist/editor/editor.d.ts.map +1 -1
  24. package/dist/editor/editor.js +16 -3
  25. package/dist/editor/editor.js.map +1 -1
  26. package/dist/editor/editor2.js +1 -1
  27. package/dist/index.d.ts +2 -2
  28. package/dist/index.js +2 -2
  29. package/dist/react/utils/useFileDiffInstance.d.ts.map +1 -1
  30. package/dist/react/utils/useFileDiffInstance.js +47 -11
  31. package/dist/react/utils/useFileDiffInstance.js.map +1 -1
  32. package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
  33. package/dist/renderers/DiffHunksRenderer.js +20 -13
  34. package/dist/renderers/DiffHunksRenderer.js.map +1 -1
  35. package/dist/renderers/FileRenderer.d.ts.map +1 -1
  36. package/dist/renderers/FileRenderer.js +30 -11
  37. package/dist/renderers/FileRenderer.js.map +1 -1
  38. package/dist/sprite.d.ts +2 -2
  39. package/dist/sprite.d.ts.map +1 -1
  40. package/dist/sprite.js +57 -0
  41. package/dist/sprite.js.map +1 -1
  42. package/dist/style.js +1 -1
  43. package/dist/types.d.ts +1 -1
  44. package/dist/types.d.ts.map +1 -1
  45. package/dist/utils/editSessionHunks.d.ts +5 -4
  46. package/dist/utils/editSessionHunks.d.ts.map +1 -1
  47. package/dist/utils/editSessionHunks.js +32 -9
  48. package/dist/utils/editSessionHunks.js.map +1 -1
  49. package/dist/utils/parsePatchFiles.d.ts.map +1 -1
  50. package/dist/utils/parsePatchFiles.js +21 -13
  51. package/dist/utils/parsePatchFiles.js.map +1 -1
  52. package/dist/utils/parseQuotedDiffFileName.d.ts +8 -0
  53. package/dist/utils/parseQuotedDiffFileName.d.ts.map +1 -0
  54. package/dist/utils/parseQuotedDiffFileName.js +54 -0
  55. package/dist/utils/parseQuotedDiffFileName.js.map +1 -0
  56. package/dist/utils/realignChangeContent.d.ts +13 -10
  57. package/dist/utils/realignChangeContent.d.ts.map +1 -1
  58. package/dist/utils/realignChangeContent.js +23 -19
  59. package/dist/utils/realignChangeContent.js.map +1 -1
  60. package/dist/utils/renderDiffWithHighlighter.js +39 -0
  61. package/dist/utils/renderDiffWithHighlighter.js.map +1 -1
  62. package/dist/worker/worker-portable.js +39 -0
  63. package/dist/worker/worker-portable.js.map +1 -1
  64. package/dist/worker/worker.js +39 -0
  65. package/dist/worker/worker.js.map +1 -1
  66. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  //#region src/editor/editor.css?inline
2
- var editor_default = "::selection {\n background-color: #0000;\n}\n\n[data-deleted-text-selection] [data-deletions] ::selection, [data-deleted-text-selection] [data-line-type=\"change-deletion\"] ::selection {\n background-color: var(--diffs-editor-selection-bg);\n}\n\n@keyframes blinking {\n 0% {\n opacity: 1;\n }\n\n 50% {\n opacity: 0;\n }\n\n 100% {\n opacity: 1;\n }\n}\n\n:host, [data-code], [data-content], [data-diff-type=\"split\"][data-overflow=\"wrap\"] {\n position: relative;\n}\n\n[data-code] {\n container-type: inline-size;\n}\n\n[data-content] {\n cursor: text;\n caret-color: var(--diffs-bg-caret);\n background-color: #0000;\n outline: none;\n}\n\n[data-line] {\n cursor: text;\n background-color: #0000;\n}\n\n[data-line]:after {\n content: \"\";\n z-index: -20;\n background-color: var(--diffs-line-bg);\n pointer-events: none;\n position: absolute;\n inset: 0;\n}\n\n[data-line][data-editor-active-line]:after {\n box-shadow: inset 0 0 0 1px var(--diffs-editor-line-highlight-border);\n}\n\n[data-editor-overlay] {\n display: contents;\n}\n\n[data-caret], [data-edit-prediction], [data-selection-range], [data-match-range], [data-bracket-match-range], [data-edit-prediction-deletion-range], [data-edit-prediction-insertion-range], [data-edit-prediction-replacement-range], [data-marker-range], [data-remote-caret], [data-caret-highlight-range] {\n height: 1lh;\n line-height: var(--diffs-line-height);\n pointer-events: none;\n position: absolute;\n top: 0;\n left: 0;\n}\n\n[data-edit-prediction] {\n z-index: 1;\n user-select: none;\n width: max-content;\n height: auto;\n color: var(--diffs-editor-edit-prediction-fg, color-mix(in lab, var(--diffs-fg) 45%, transparent));\n overflow: visible;\n}\n\n[data-edit-prediction-line] {\n box-sizing: border-box;\n white-space: pre;\n width: max-content;\n min-height: 1lh;\n display: block;\n}\n\n[data-edit-prediction][data-replacement] [data-edit-prediction-line], [data-edit-prediction-insertion-range], [data-edit-prediction-replacement-range] {\n background-color: var(--diffs-edit-prediction-bg, var(--diffs-bg));\n}\n\n[data-edit-prediction-suffix] {\n color: var(--diffs-fg);\n}\n\n[data-edit-prediction][data-wrap] [data-edit-prediction-line] {\n overflow-wrap: anywhere;\n white-space: pre-wrap;\n max-width: 100%;\n}\n\n[data-edit-prediction-line][data-empty]:after {\n content: \"↵\";\n}\n\n[data-edit-prediction-spacer] {\n margin-block-end: var(--diffs-edit-prediction-spacer-height);\n}\n\n[data-code][data-deletions] [data-edit-prediction-spacer] {\n box-sizing: content-box;\n margin-block-end: 0;\n padding-block-end: var(--diffs-edit-prediction-spacer-height);\n}\n\n[data-edit-prediction-deletion-range] {\n --diffs-edit-prediction-deletion-color: var(--diffs-editor-edit-prediction-deletion-fg, color-mix(in lab, var(--diffs-deletion-base) 70%, transparent));\n z-index: 1;\n background: linear-gradient(to bottom,\n transparent calc(50% - .5px),\n var(--diffs-edit-prediction-deletion-color) calc(50% - .5px),\n var(--diffs-edit-prediction-deletion-color) calc(50% + .5px),\n transparent calc(50% + .5px));\n}\n\n[data-edit-prediction-insertion-range] {\n z-index: 0;\n}\n\n[data-edit-prediction-replacement-range] {\n z-index: 1;\n}\n\n[data-caret] {\n z-index: 2;\n background-color: var(--diffs-bg-caret-override, var(--diffs-editor-cursor-fg, light-dark(color-mix(in lab, var(--diffs-fg) 50%, var(--diffs-bg)), color-mix(in lab, var(--diffs-fg) 75%, var(--diffs-bg)))));\n visibility: hidden;\n width: 2px;\n}\n\n@media (prefers-reduced-motion: no-preference) {\n [data-caret] {\n animation: 1.2s .8s infinite blinking;\n }\n}\n\n[data-selection-range] {\n z-index: -10;\n background-color: var(--diffs-editor-selection-bg);\n}\n\n[data-caret-highlight-range] {\n z-index: -10;\n background-color: var(--diffs-caret-highlight-bg, var(--diffs-editor-selection-bg));\n}\n\n[data-selection-corner] {\n background-color: var(--diffs-selection-corner-bg, var(--diffs-bg));\n width: 100%;\n height: 100%;\n}\n\n[data-match-range] {\n z-index: -10;\n background-color: var(--diffs-editor-match-bg, var(--diffs-editor-selection-bg));\n}\n\n[data-match-range]:not([data-focus]) {\n background-color: var(--diffs-editor-match-highlight-bg, light-dark(#ff963288, #ff963266));\n}\n\n[data-bracket-match-range] {\n z-index: -9;\n box-sizing: border-box;\n border-bottom: 1px solid\n var(--diffs-editor-bracket-match-border, color-mix(in lab, var(--diffs-fg) 60%, transparent));\n background-color: var(--diffs-editor-bracket-match-bg, color-mix(in lab, var(--diffs-fg) 5%, transparent));\n}\n\n[data-rtl] {\n border-top-left-radius: 3px;\n}\n\n[data-rtr] {\n border-top-right-radius: 3px;\n}\n\n[data-rbl] {\n border-bottom-left-radius: 3px;\n}\n\n[data-rbr] {\n border-bottom-right-radius: 3px;\n}\n\n[data-marker-range] {\n z-index: 1;\n background-color: var(--diffs-marker-bg);\n mask-image: url(\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2IiBoZWlnaHQ9IjMiPjxwYXRoIGQ9Im0wIDIuNSBsMiAtMS41IGwxIDAgbDIgMS41IGwxIDAiIHN0cm9rZT0iI2ZmZiIgZmlsbD0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIi8+PC9zdmc+\");\n mask-position: 0 100%;\n mask-size: 6px 3px;\n mask-repeat: repeat-x;\n}\n\n[data-marker-error] {\n --diffs-marker-contrast: light-dark(#fff, #000);\n --diffs-marker-bg: var(--diffs-editor-error-fg, var(--diffs-deletion-base));\n}\n\n[data-marker-warning] {\n --diffs-marker-contrast: #000;\n --diffs-marker-bg: var(--diffs-editor-warning-fg, light-dark(var(--diffs-warning-light), var(--diffs-warning-dark)));\n}\n\n[data-marker-info] {\n --diffs-marker-contrast: #000;\n --diffs-marker-bg: var(--diffs-editor-info-fg, var(--diffs-modified-base));\n}\n\n[data-marker-hint] {\n --diffs-marker-contrast: light-dark(#fff, #000);\n --diffs-marker-bg: var(--diffs-editor-hint-fg, var(--diffs-fg-number));\n}\n\n@media (width >= 480px) {\n [data-content] {\n caret-color: #0000;\n }\n\n [data-content]:focus ~ [data-editor-overlay] [data-caret] {\n visibility: visible;\n }\n}\n\n[data-editor-widget] {\n --diffs-widget-fg: var(--diffs-fg);\n --diffs-widget-bg: color-mix(in lab, var(--diffs-fg) 4%, var(--diffs-bg));\n --diffs-widget-border: color-mix(in lab, var(--diffs-fg) 20%, transparent);\n --diffs-widget-shadow: inset 0 0 0 1px var(--diffs-bg), 0 4px 8px #00000013,\n 0 6px 18px #00000013;\n z-index: 100;\n width: fit-content;\n max-width: calc(100% - 24px);\n font: 14px/20px var(--diffs-header-font-fallback);\n border: 1px solid var(--diffs-widget-border);\n background-color: var(--diffs-widget-bg);\n box-shadow: var(--diffs-widget-shadow);\n background-clip: padding-box;\n border-radius: 9px;\n position: absolute;\n top: 0;\n left: 0;\n}\n\n[data-marker-popover], [data-selection-action-popover] {\n --popover-gap: var(--diffs-popover-gap, var(--diffs-gap-fallback, 8px));\n --popover-viewport-left: 0px;\n --popover-viewport-right: 100cqw;\n --popover-viewport-top: -99999px;\n --popover-viewport-bottom: 99999px;\n --popover-min-left: calc(var(--popover-viewport-left) + var(--gutter-width, 0px) + var(--popover-gap));\n --popover-available-width: max(0px,\n calc(var(--popover-viewport-right) - var(--popover-min-left) -\n var(--popover-gap)));\n max-width: min(640px, var(--popover-available-width));\n translate: clamp(var(--popover-min-left),\n var(--popover-x, var(--popover-min-left)),\n calc(var(--popover-viewport-right) - var(--popover-gap) - 100%))\n /* Clamp into the scrollport so a popover with no fitting side stays in view. */\n clamp(var(--popover-viewport-top),\n calc(var(--popover-y, 0px) + var(--popover-y-shift, 0px)),\n calc(var(--popover-viewport-bottom) - var(--popover-gap) - 100%));\n}\n\n[data-marker-popover] {\n --diffs-widget-bg: var(--diffs-marker-bg);\n --diffs-widget-shadow: 0 4px 8px #00000026, 0 6px 18px #00000026;\n min-width: min(180px, var(--popover-available-width));\n overflow-wrap: anywhere;\n color: var(--diffs-marker-contrast);\n white-space: normal;\n pointer-events: auto;\n border: 0;\n padding: 8px 12px;\n\n @supports (color: contrast-color(red)) {\n color: contrast-color(var(--diffs-marker-bg, var(--diffs-bg)));\n }\n\n & [data-marker-message] {\n white-space: normal;\n overflow-wrap: anywhere;\n\n & code {\n white-space: normal;\n color: inherit;\n background-color: #0000;\n display: inline;\n }\n }\n}\n\n[data-selection-action-popover] {\n pointer-events: auto;\n flex-wrap: wrap;\n align-items: center;\n gap: 4px;\n width: max-content;\n padding: 4px;\n display: flex;\n}\n\n[data-search-panel] {\n z-index: 100;\n flex-direction: column;\n justify-content: right;\n width: 100%;\n height: 0;\n display: flex;\n position: sticky;\n top: 16px;\n right: 16px;\n container: search-panel / inline-size;\n\n & [data-editor-widget] {\n z-index: 100;\n flex-shrink: 0;\n align-items: stretch;\n gap: 8px;\n min-width: 260px;\n max-width: 100%;\n margin-inline: auto 16px;\n padding: 4px;\n display: flex;\n position: relative;\n }\n\n & svg {\n fill: currentColor;\n width: 12px;\n height: 12px;\n display: block;\n }\n}\n\n[data-search-grid] {\n grid-template-columns: auto auto auto;\n grid-template-areas: \"find matches nav\"\n \"replace actions .\";\n align-items: center;\n gap: 4px 6px;\n width: 100%;\n display: grid;\n}\n\n[data-input-box][data-find] {\n grid-area: find;\n}\n\n[data-search-nav] {\n grid-area: nav;\n}\n\n[data-input-box][data-replace] {\n grid-area: replace;\n}\n\n[data-replace-actions] {\n grid-area: actions;\n}\n\n[data-search-grid][data-mode=\"find\"] {\n grid-template-areas: \"find matches nav\";\n}\n\n[data-search-grid][data-mode=\"find\"] [data-replace-cell] {\n display: none;\n}\n\n@container search-panel (width < 400px) {\n [data-search-panel] [data-editor-widget] {\n padding: 10px;\n }\n\n [data-search-grid][data-mode=\"replace\"] {\n grid-template-columns: auto 1fr auto;\n grid-template-areas: \"find find find\"\n \"replace replace replace\"\n \"nav matches actions\";\n }\n\n [data-search-grid][data-mode=\"find\"] {\n grid-template-columns: auto 1fr auto;\n grid-template-areas: \"find find find\"\n \"nav matches matches\";\n }\n\n [data-replace-actions] {\n justify-self: end;\n }\n\n [data-search-grid] [data-input-box] {\n width: auto;\n }\n}\n\n[data-input-box] {\n align-items: center;\n width: 200px;\n display: flex;\n position: relative;\n\n & input {\n width: 100%;\n min-width: 0;\n color: var(--diffs-fg);\n background-color: var(--diffs-bg);\n border: 1px solid color-mix(in lab, var(--diffs-fg) 12%, var(--diffs-bg));\n border-radius: 6px;\n outline: none;\n flex-grow: 1;\n padding-inline: 6px;\n font-size: 13px;\n line-height: 24px;\n\n &::selection {\n background-color: color-mix(in lab, var(--diffs-fg) 8%, var(--diffs-bg));\n }\n\n &:focus-visible {\n outline: 1px solid var(--diffs-modified-base);\n }\n }\n\n &[data-find] input {\n padding-inline-end: 72px;\n }\n\n & [data-search-icon] {\n --diffs-search-icon-size: 20px;\n }\n}\n\n[data-search-toggles] {\n align-items: center;\n gap: 1px;\n display: flex;\n position: absolute;\n top: 50%;\n right: 4px;\n transform: translateY(-50%);\n}\n\n[data-matches] {\n white-space: nowrap;\n min-width: 50px;\n color: color-mix(in lab, var(--diffs-fg) 50%, var(--diffs-bg));\n flex-shrink: 0;\n grid-area: matches;\n font-size: 12px;\n font-weight: 500;\n line-height: 20px;\n\n &[data-no-matches] {\n color: color-mix(in lab, var(--diffs-fg) 35%, var(--diffs-bg));\n }\n}\n\n[data-replace-actions], [data-search-nav] {\n align-items: center;\n display: flex;\n}\n\n[data-search-icon] {\n appearance: none;\n width: var(--diffs-search-icon-size, 24px);\n height: var(--diffs-search-icon-size, 24px);\n color: color-mix(in lab, var(--diffs-fg) 65%, var(--diffs-bg));\n border-radius: var(--diffs-search-icon-radius, 4px);\n cursor: pointer;\n background: none;\n border: 0;\n flex-shrink: 0;\n justify-content: center;\n align-items: center;\n margin: 0;\n padding: 0;\n transition: background-color .1s ease-in-out, color .1s ease-in-out;\n display: flex;\n\n &:disabled {\n opacity: .25;\n cursor: default;\n }\n\n &:not(:disabled):hover {\n color: var(--diffs-fg);\n }\n\n &:focus-visible {\n outline: 1px solid var(--diffs-modified-base);\n }\n\n &[aria-pressed=\"true\"] {\n color: var(--diffs-modified-base);\n }\n}\n\n[data-search-close] {\n --diffs-search-icon-size: 20px;\n --diffs-search-icon-radius: 50%;\n color: var(--diffs-widget-bg);\n background-color: color-mix(in lab,\n var(--diffs-widget-fg) 50%,\n var(--diffs-bg));\n position: absolute;\n top: 0;\n right: 0;\n transform: translate(50%, -50%);\n\n &:not(:disabled):hover {\n opacity: 1;\n color: var(--diffs-widget-bg);\n background-color: var(--diffs-widget-fg);\n }\n}\n";
2
+ var editor_default = "@layer base,theme,rendered,unsafe;::selection{background-color:#0000}[data-deleted-text-selection] [data-deletions] ::selection,[data-deleted-text-selection] [data-line-type=change-deletion] ::selection{background-color:var(--diffs-editor-selection-bg)}@keyframes blinking{0%{opacity:1}50%{opacity:0}to{opacity:1}}:host,[data-code],[data-content],[data-diff-type=split][data-overflow=wrap]{position:relative}[data-code]{container-type:inline-size}[data-content]{cursor:text;caret-color:var(--diffs-bg-caret);background-color:#0000;outline:none}[data-line]{cursor:text;background-color:#0000}[data-line]:after{content:\"\";z-index:-20;background-color:var(--diffs-line-bg);pointer-events:none;position:absolute;inset:0}[data-line][data-editor-active-line]:after{box-shadow:inset 0 0 0 1px var(--diffs-editor-line-highlight-border)}[data-editor-overlay]{display:contents}[data-caret],[data-edit-prediction],[data-selection-range],[data-match-range],[data-bracket-match-range],[data-edit-prediction-deletion-range],[data-edit-prediction-insertion-range],[data-edit-prediction-replacement-range],[data-marker-range],[data-remote-caret],[data-caret-highlight-range]{height:1lh;line-height:var(--diffs-line-height);pointer-events:none;position:absolute;top:0;left:0}[data-edit-prediction]{z-index:1;user-select:none;width:max-content;height:auto;color:var(--diffs-editor-edit-prediction-fg,color-mix(in lab, var(--diffs-fg) 45%, transparent));overflow:visible}[data-edit-prediction-line]{box-sizing:border-box;white-space:pre;width:max-content;min-height:1lh;display:block}[data-edit-prediction][data-replacement] [data-edit-prediction-line],[data-edit-prediction-insertion-range],[data-edit-prediction-replacement-range]{background-color:var(--diffs-edit-prediction-bg,var(--diffs-bg))}[data-edit-prediction-suffix]{color:var(--diffs-fg)}[data-edit-prediction][data-wrap] [data-edit-prediction-line]{overflow-wrap:anywhere;white-space:pre-wrap;max-width:100%}[data-edit-prediction-line][data-empty]:after{content:\"↵\"}[data-edit-prediction-spacer]{margin-block-end:var(--diffs-edit-prediction-spacer-height)}[data-code][data-deletions] [data-edit-prediction-spacer]{box-sizing:content-box;margin-block-end:0;padding-block-end:var(--diffs-edit-prediction-spacer-height)}[data-edit-prediction-deletion-range]{--diffs-edit-prediction-deletion-color:var(--diffs-editor-edit-prediction-deletion-fg,color-mix(in lab, var(--diffs-deletion-base) 70%, transparent));z-index:1;background:linear-gradient(to bottom, transparent calc(50% - .5px), var(--diffs-edit-prediction-deletion-color) calc(50% - .5px), var(--diffs-edit-prediction-deletion-color) calc(50% + .5px), transparent calc(50% + .5px))}[data-edit-prediction-insertion-range]{z-index:0}[data-edit-prediction-replacement-range]{z-index:1}[data-caret]{z-index:2;background-color:var(--diffs-bg-caret-override,var(--diffs-editor-cursor-fg,light-dark(color-mix(in lab, var(--diffs-fg) 50%, var(--diffs-bg)),color-mix(in lab, var(--diffs-fg) 75%, var(--diffs-bg)))));visibility:hidden;width:2px}@media (prefers-reduced-motion:no-preference){[data-caret]{animation:1.2s .8s infinite blinking}}[data-selection-range]{z-index:-10;background-color:var(--diffs-editor-selection-bg)}[data-caret-highlight-range]{z-index:-10;background-color:var(--diffs-caret-highlight-bg,var(--diffs-editor-selection-bg))}[data-selection-corner]{background-color:var(--diffs-selection-corner-bg,var(--diffs-bg));width:100%;height:100%}[data-match-range]{z-index:-10;background-color:var(--diffs-editor-match-bg,var(--diffs-editor-selection-bg))}[data-match-range]:not([data-focus]){background-color:var(--diffs-editor-match-highlight-bg,light-dark(#ff963288,#ff963266))}[data-bracket-match-range]{z-index:-9;box-sizing:border-box;border-bottom:1px solid var(--diffs-editor-bracket-match-border,color-mix(in lab, var(--diffs-fg) 60%, transparent));background-color:var(--diffs-editor-bracket-match-bg,color-mix(in lab, var(--diffs-fg) 5%, transparent))}[data-rtl]{border-top-left-radius:3px}[data-rtr]{border-top-right-radius:3px}[data-rbl]{border-bottom-left-radius:3px}[data-rbr]{border-bottom-right-radius:3px}[data-marker-range]{z-index:1;background-color:var(--diffs-marker-bg);mask-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2IiBoZWlnaHQ9IjMiPjxwYXRoIGQ9Im0wIDIuNSBsMiAtMS41IGwxIDAgbDIgMS41IGwxIDAiIHN0cm9rZT0iI2ZmZiIgZmlsbD0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIi8+PC9zdmc+);mask-position:0 100%;mask-size:6px 3px;mask-repeat:repeat-x}[data-marker-error]{--diffs-marker-contrast:light-dark(#fff,#000);--diffs-marker-bg:var(--diffs-editor-error-fg,var(--diffs-deletion-base))}[data-marker-warning]{--diffs-marker-contrast:#000;--diffs-marker-bg:var(--diffs-editor-warning-fg,light-dark(var(--diffs-warning-light),var(--diffs-warning-dark)))}[data-marker-info]{--diffs-marker-contrast:#000;--diffs-marker-bg:var(--diffs-editor-info-fg,var(--diffs-modified-base))}[data-marker-hint]{--diffs-marker-contrast:light-dark(#fff,#000);--diffs-marker-bg:var(--diffs-editor-hint-fg,var(--diffs-fg-number))}@media (width>=480px){[data-content]{caret-color:#0000}[data-content]:focus~[data-editor-overlay] [data-caret]{visibility:visible}}[data-editor-widget]{--diffs-widget-fg:var(--diffs-fg);--diffs-widget-bg:color-mix(in lab, var(--diffs-fg) 4%, var(--diffs-bg));--diffs-widget-border:color-mix(in lab, var(--diffs-fg) 20%, transparent);--diffs-widget-shadow:inset 0 0 0 1px var(--diffs-bg), 0 4px 8px #00000013, 0 6px 18px #00000013;z-index:100;width:fit-content;max-width:calc(100% - 24px);font:14px/20px var(--diffs-header-font-fallback);border:1px solid var(--diffs-widget-border);background-color:var(--diffs-widget-bg);box-shadow:var(--diffs-widget-shadow);background-clip:padding-box;border-radius:9px;position:absolute;top:0;left:0}[data-marker-popover],[data-selection-action-popover]{--popover-gap:var(--diffs-popover-gap,var(--diffs-gap-fallback,8px));--popover-viewport-left:0px;--popover-viewport-right:100cqw;--popover-viewport-top:-99999px;--popover-viewport-bottom:99999px;--popover-min-left:calc(var(--popover-viewport-left) + var(--gutter-width,0px) + var(--popover-gap));--popover-available-width:max(0px, calc(var(--popover-viewport-right) - var(--popover-min-left) - var(--popover-gap)));max-width:min(640px, var(--popover-available-width));translate:clamp(var(--popover-min-left), var(--popover-x,var(--popover-min-left)), calc(var(--popover-viewport-right) - var(--popover-gap) - 100%)) clamp(var(--popover-viewport-top), calc(var(--popover-y,0px) + var(--popover-y-shift,0px)), calc(var(--popover-viewport-bottom) - var(--popover-gap) - 100%))}[data-marker-popover]{--diffs-widget-bg:var(--diffs-marker-bg);--diffs-widget-shadow:0 4px 8px #00000026, 0 6px 18px #00000026;min-width:min(180px, var(--popover-available-width));overflow-wrap:anywhere;color:var(--diffs-marker-contrast);white-space:normal;pointer-events:auto;border:0;padding:8px 12px;@supports (color:contrast-color(red)){color:contrast-color(var(--diffs-marker-bg,var(--diffs-bg)))}& [data-marker-message]{white-space:normal;overflow-wrap:anywhere;& code{white-space:normal;color:inherit;background-color:#0000;display:inline}}}[data-selection-action-popover]{pointer-events:auto;flex-wrap:wrap;align-items:center;gap:4px;width:max-content;padding:4px;display:flex}[data-search-panel]{z-index:100;flex-direction:column;justify-content:right;width:100%;height:0;display:flex;position:sticky;top:16px;right:16px;container:search-panel/inline-size;& [data-editor-widget]{z-index:100;flex-shrink:0;align-items:stretch;gap:8px;min-width:260px;max-width:100%;margin-inline:auto 16px;padding:4px;display:flex;position:relative}& svg{fill:currentColor;width:12px;height:12px;display:block}}[data-search-grid]{grid-template-columns:auto auto auto;grid-template-areas:\"find matches nav\"\"replace actions.\";align-items:center;gap:4px 6px;width:100%;display:grid}[data-input-box][data-find]{grid-area:find}[data-search-nav]{grid-area:nav}[data-input-box][data-replace]{grid-area:replace}[data-replace-actions]{grid-area:actions}[data-search-grid][data-mode=find]{grid-template-areas:\"find matches nav\"}[data-search-grid][data-mode=find] [data-replace-cell]{display:none}@container search-panel (width<400px){[data-search-panel] [data-editor-widget]{padding:10px}[data-search-grid][data-mode=replace]{grid-template-columns:auto 1fr auto;grid-template-areas:\"find find find\"\"replace replace replace\"\"nav matches actions\"}[data-search-grid][data-mode=find]{grid-template-columns:auto 1fr auto;grid-template-areas:\"find find find\"\"nav matches matches\"}[data-replace-actions]{justify-self:end}[data-search-grid] [data-input-box]{width:auto}}[data-input-box]{align-items:center;width:200px;display:flex;position:relative;& input{width:100%;min-width:0;color:var(--diffs-fg);background-color:var(--diffs-bg);border:1px solid color-mix(in lab, var(--diffs-fg) 12%, var(--diffs-bg));border-radius:6px;outline:none;flex-grow:1;padding-inline:6px;font-size:13px;line-height:24px;&::selection{background-color:color-mix(in lab, var(--diffs-fg) 8%, var(--diffs-bg))}&:focus-visible{outline:1px solid var(--diffs-modified-base)}}&[data-find] input{padding-inline-end:72px}& [data-search-icon]{--diffs-search-icon-size:20px}}[data-search-toggles]{align-items:center;gap:1px;display:flex;position:absolute;top:50%;right:4px;transform:translateY(-50%)}[data-matches]{white-space:nowrap;min-width:50px;color:color-mix(in lab, var(--diffs-fg) 50%, var(--diffs-bg));flex-shrink:0;grid-area:matches;font-size:12px;font-weight:500;line-height:20px;&[data-no-matches]{color:color-mix(in lab, var(--diffs-fg) 35%, var(--diffs-bg))}}[data-replace-actions],[data-search-nav]{align-items:center;display:flex}[data-search-icon]{appearance:none;width:var(--diffs-search-icon-size,24px);height:var(--diffs-search-icon-size,24px);color:color-mix(in lab, var(--diffs-fg) 65%, var(--diffs-bg));border-radius:var(--diffs-search-icon-radius,4px);cursor:pointer;background:0 0;border:0;flex-shrink:0;justify-content:center;align-items:center;margin:0;padding:0;transition:background-color .1s ease-in-out,color .1s ease-in-out;display:flex;&:disabled{opacity:.25;cursor:default}&:not(:disabled):hover{color:var(--diffs-fg)}&:focus-visible{outline:1px solid var(--diffs-modified-base)}&[aria-pressed=true]{color:var(--diffs-modified-base)}}[data-search-close]{--diffs-search-icon-size:20px;--diffs-search-icon-radius:50%;color:var(--diffs-widget-bg);background-color:color-mix(in lab, var(--diffs-widget-fg) 50%, var(--diffs-bg));position:absolute;top:0;right:0;transform:translate(50%,-50%);&:not(:disabled):hover{opacity:1;color:var(--diffs-widget-bg);background-color:var(--diffs-widget-fg)}}\n";
3
3
  //#endregion
4
4
  export { editor_default as default };
5
5
 
package/dist/index.d.ts CHANGED
@@ -11,7 +11,7 @@ import { Virtualizer, VirtualizerConfig, VirtualizerScrollOptions } from "./comp
11
11
  import { VirtualizedFile } from "./components/VirtualizedFile.js";
12
12
  import { VIRTUALIZED_FILE_DIFF_LAYOUT_CHECKPOINT_INTERVAL, VirtualizedFileDiff } from "./components/VirtualizedFileDiff.js";
13
13
  import { CODE_VIEW_DIFF_OPTION_KEYS, CODE_VIEW_FILE_OPTION_KEYS, CodeView, CodeViewCoordinator, CodeViewCreateEditorOptions, CodeViewItemEditCompleteEventMap, CodeViewItemEditCompleteHandler, CodeViewLineSelection, CodeViewMode, CodeViewModeItemMap, CodeViewOptions, CodeViewRenderedDiffItem, CodeViewRenderedFileItem, CodeViewRenderedItem, CodeViewScrollListener, CodeViewSlotSnapshot } from "./components/CodeView.js";
14
- import { ALTERNATE_FILE_NAMES_GIT, CODE_VIEW_FOOTER_ATTRIBUTE, CODE_VIEW_HEADER_ATTRIBUTE, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, CUSTOM_HEADER_SLOT_ID, DEFAULT_CODE_VIEW_FILE_METRICS, DEFAULT_CODE_VIEW_LAYOUT, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_SMOOTH_SCROLL_SETTINGS, DEFAULT_THEMES, DEFAULT_TOKENIZE_MAX_LENGTH, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_DEVELOPMENT_BUILD, DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY, DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE, DIFFS_TAG_NAME, EMPTY_RENDER_RANGE, FILENAME_HEADER_REGEX, FILENAME_HEADER_REGEX_GIT, FILE_CONTEXT_BLOB, GIT_DIFF_FILE_BREAK_REGEX, HEADER_FILENAME_SUFFIX_SLOT_ID, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, INDEX_LINE_METADATA, MERGE_CONFLICT_BASE_MARKER_REGEX, MERGE_CONFLICT_END_MARKER_REGEX, MERGE_CONFLICT_SEPARATOR_MARKER_REGEX, MERGE_CONFLICT_START_MARKER_REGEX, SPLIT_WITH_NEWLINES, THEME_CSS_ATTRIBUTE, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE } from "./constants.js";
14
+ import { CODE_VIEW_FOOTER_ATTRIBUTE, CODE_VIEW_HEADER_ATTRIBUTE, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, CUSTOM_HEADER_SLOT_ID, DEFAULT_CODE_VIEW_FILE_METRICS, DEFAULT_CODE_VIEW_LAYOUT, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_SMOOTH_SCROLL_SETTINGS, DEFAULT_THEMES, DEFAULT_TOKENIZE_MAX_LENGTH, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_DEVELOPMENT_BUILD, DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY, DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE, DIFFS_TAG_NAME, EMPTY_RENDER_RANGE, FILENAME_HEADER_REGEX, FILE_CONTEXT_BLOB, GIT_DIFF_FILE_BREAK_REGEX, HEADER_FILENAME_SUFFIX_SLOT_ID, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, INDEX_LINE_METADATA, MERGE_CONFLICT_BASE_MARKER_REGEX, MERGE_CONFLICT_END_MARKER_REGEX, MERGE_CONFLICT_SEPARATOR_MARKER_REGEX, MERGE_CONFLICT_START_MARKER_REGEX, SPLIT_WITH_NEWLINES, THEME_CSS_ATTRIBUTE, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE } from "./constants.js";
15
15
  import { CodeToTokenTransformStreamOptions, RecallToken, ShikiStreamTokenizerEnqueueResult, ShikiStreamTokenizerOptions } from "./shiki-stream/types.js";
16
16
  import { ShikiStreamTokenizer } from "./shiki-stream/tokenizer.js";
17
17
  import { CodeToTokenTransformStream } from "./shiki-stream/stream.js";
@@ -111,4 +111,4 @@ import { setLanguageOverride } from "./utils/setLanguageOverride.js";
111
111
  import { setPreNodeProperties } from "./utils/setWrapperNodeProps.js";
112
112
  import { trimPatchContext } from "./utils/trimPatchContext.js";
113
113
  import { codeToHtml, createCssVariablesTheme as createCSSVariablesTheme } from "shiki";
114
- export { ALTERNATE_FILE_NAMES_GIT, type AnnotationLineMap, type AnnotationSide, type AnnotationSpan, type AppliedThemeStyleCache, AttachedLanguages, AttachedThemes, type BaseCodeOptions, type BaseDiffOptions, type BaseDiffOptionsWithDefaults, type BundledLanguage, CODE_VIEW_DIFF_OPTION_KEYS, CODE_VIEW_FILE_OPTION_KEYS, CODE_VIEW_FOOTER_ATTRIBUTE, CODE_VIEW_HEADER_ATTRIBUTE, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, CUSTOM_HEADER_SLOT_ID, type ChangeContent, type ChangeTypes, type CodeColumnType, type CodeToHastOptions, CodeToTokenTransformStream, CodeToTokenTransformStreamOptions, CodeView, CodeViewCoordinator, CodeViewCreateEditorOptions, type CodeViewDiffItem, type CodeViewFileItem, type CodeViewItem, CodeViewItemEditCompleteEventMap, CodeViewItemEditCompleteHandler, type CodeViewItemScrollTarget, type CodeViewLayout, type CodeViewLineScrollTarget, CodeViewLineSelection, CodeViewMode, CodeViewModeItemMap, CodeViewOptions, type CodeViewPositionScrollTarget, type CodeViewRangeScrollTarget, CodeViewRenderedDiffItem, CodeViewRenderedFileItem, CodeViewRenderedItem, type CodeViewScrollBehavior, CodeViewScrollListener, type CodeViewScrollTarget, CodeViewSlotSnapshot, type ConflictResolverTypes, type ContextContent, CreateFileHeaderElementProps, type CreatePatchOptionsNonabortable, type CustomPreProperties, CustomThemeLoader, DEFAULT_CODE_VIEW_FILE_METRICS, DEFAULT_CODE_VIEW_LAYOUT, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_SMOOTH_SCROLL_SETTINGS, DEFAULT_THEMES, DEFAULT_TOKENIZE_MAX_LENGTH, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_DEVELOPMENT_BUILD, DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY, DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE, DIFFS_TAG_NAME, type DecorationItem, type DiffAcceptRejectHunkConfig, type DiffAcceptRejectHunkType, type DiffFileInput, DiffHunksRenderer, DiffHunksRendererOptions, DiffHunksRendererOptionsWithDefaults, type DiffIndicators, type DiffLineAnnotation, type DiffLineEventBaseProps, type DiffTokenEventBaseProps, type DiffsHighlighter, type DiffsThemeNames, EMPTY_RENDER_RANGE, EXTENSION_TO_FILE_FORMAT, type ExpansionDirections, type ExtensionFormatMap, FILENAME_HEADER_REGEX, FILENAME_HEADER_REGEX_GIT, FILE_CONTEXT_BLOB, File, type FileContents, FileDiff, type FileDiffContentsLoader, FileDiffEditChangeHandler, type FileDiffEditCompleteEvent, FileDiffEditCompleteHandler, FileDiffHydrationProps, type FileDiffLoadedChangedFiles, type FileDiffLoadedFiles, type FileDiffLoadedPureRenamedFile, type FileDiffMetadata, FileDiffOptions, FileDiffRenderBaseProps, FileDiffRenderProps, FileDiffType, FileEditChangeHandler, type FileEditCompleteEvent, FileEditCompleteHandler, type FileHeaderRenderMode, FileHydrateProps, FileOptions, FileRenderProps, FileRenderResult, FileRenderer, FileRendererOptions, FileStream, FileStreamOptions, type ForceDiffPlainTextOptions, type ForceFilePlainTextOptions, GIT_DIFF_FILE_BREAK_REGEX, type GapSpan, GetHoveredLineResult, GetLineIndexUtility, HEADER_FILENAME_SUFFIX_SLOT_ID, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, type HighlightedToken, type HighlighterTypes, type Hunk, type HunkData, type HunkExpansionRegion, type HunkLineType, type HunkSeparators, HunksRenderResult, INDEX_LINE_METADATA, InjectedRow, InteractionManager, InteractionManagerBaseOptions, InteractionManagerMode, InteractionManagerOptions, type LanguageRegistration, type LineAnnotation, LineAnnotationPosition, LineDecoration, type LineDiffTypes, type LineEventBaseProps, type LineInfo, type LineSpans, type LineTypes, LogTypes, MERGE_CONFLICT_BASE_MARKER_REGEX, MERGE_CONFLICT_END_MARKER_REGEX, MERGE_CONFLICT_SEPARATOR_MARKER_REGEX, MERGE_CONFLICT_START_MARKER_REGEX, type MaybeDiffFileInput, type MergeConflictActionPayload, MergeConflictActionTarget, MergeConflictActionsTypeOption, type MergeConflictMarkerRow, type MergeConflictMarkerRowType, type MergeConflictRegion, type MergeConflictResolution, type NumericScrollLineAnchor, type ObservedAnnotationNodes, type ObservedGridNodes, OnDiffLineClickProps, OnDiffLineEnterLeaveProps, OnLineClickProps, OnLineEnterLeaveProps, OnTokenEventProps, ParsedLine, type ParsedPatch, type PendingCodeViewLayoutReset, type PostRenderPhase, type PrePropertiesConfig, type ProcessFileConflictData, RecallToken, RegisteredCustomLanguages, type RenderDiffFilesResult, type RenderDiffOptions, type RenderDiffResult, type RenderFileMetadata, type RenderFileOptions, type RenderFileResult, type RenderHeaderFilenameSuffixCallback, type RenderHeaderMetadataCallback, type RenderHeaderPrefixCallback, RenderMergeConflictActions, type RenderRange, type RenderWindow, type RenderedDiffASTCache, type RenderedFileASTCache, RenderedLineContext, ResizeManager, ResizeManagerColumnVariableMode, ResizeManagerSetupOptions, ResolvedLanguages, ResolvingLanguages, SPLIT_WITH_NEWLINES, SVGSpriteNames, SVGSpriteSheet, ScrollSyncManager, type SelectedLineRange, type SelectionPoint, type SelectionSide, SelectionWriteOptions, type SharedRenderState, ShikiStreamTokenizer, ShikiStreamTokenizerEnqueueResult, ShikiStreamTokenizerOptions, type ShikiTransformer, type SmoothScrollSettings, SplitInjectedRow, SplitInjectedRowPlacement, SplitLineDecorationProps, type StickySpecs, type SupportedLanguages, THEME_CSS_ATTRIBUTE, type ThemeRegistration, type ThemeRegistrationResolved, type ThemeTypes, type ThemedDiffResult, type ThemedFileResult, type ThemedToken, type ThemesType, type TokenEventBase, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE, UnifiedInjectedRowPlacement, UnifiedLineDecorationProps, UnresolvedFile, UnresolvedFileHydrationProps, UnresolvedFileOptions, UnresolvedFileRenderProps, VIRTUALIZED_FILE_DIFF_LAYOUT_CHECKPOINT_INTERVAL, type VirtualFileMetrics, type VirtualWindowSpecs, VirtualizedFile, VirtualizedFileDiff, Virtualizer, VirtualizerConfig, VirtualizerScrollOptions, areDiffLineAnnotationsEqual, areDiffRenderOptionsEqual, areDiffTargetsEqual, areFileRenderOptionsEqual, areFilesEqual, areHunkDataEqual, areLanguagesAttached, areLineAnnotationsEqual, areObjectsEqual, areOptionsEqual, arePrePropertiesEqual, areRenderRangesEqual, areSelectionsEqual, areThemesAttached, areThemesEqual, areVirtualWindowSpecsEqual, areWorkerStatsEqual, attachResolvedLanguages, attachResolvedThemes, cleanLastNewline, cleanUpResolvedLanguages, cleanUpResolvedThemes, clearRenderQueue, cloneFileDiffMetadata, cloneHunks, codeToHtml, createAnnotationElement, createAnnotationWrapperNode, createCSSVariablesTheme, createDiffSpanDecoration, createEmptyRowBuffer, createFileHeaderElement, createGutterGap, createGutterItem, createGutterUtilityContentNode, createGutterUtilityElement, createGutterWrapper, createHastElement, createIconElement, createNoNewlineElement, createPreElement, createPreWrapperProperties, createRowNodes, createSeparator, createSpanFromToken, createStyleElement, createTextNodeElement, createThemeStyleElement, createTransformerWithState, createUnsafeCSSStyleNode, createWindowFromScrollPosition, dequeueRender, detachString, diffAcceptRejectHunk, disposeHighlighter, findCodeElement, formatCSSVariablePrefix, getCustomExtensionsMap, getCustomExtensionsVersion, getFiletypeFromFileName, getHighlighterIfLoaded, getHighlighterOptions, getHighlighterThemeStyles, getHunkSeparatorSlotName, getIconForType, getLineAnnotationName, getLineAnnotationSource, getLineEndingType, getLineNodes, getOrCreateCodeNode, getResolvedLanguages, getResolvedOrResolveLanguage, getResolvedOrResolveTheme, getResolvedThemes, getSharedHighlighter, getSingularPatch, getThemes, getTotalLineCountFromHunks, getUnresolvedDiffHunksRendererOptions, hasResolvedLanguages, hasResolvedThemes, hydratePartialDiff, isDefaultRenderRange, isDiffAnnotation, isDiffAnnotationCollection, isFileAnnotation, isFileAnnotationCollection, isHighlighterLoaded, isHighlighterLoading, isHighlighterNull, isWorkerContext, parseDiffFromFile, parseLineType, parsePatchFiles, patchScrollbarGutterSize, pluckInteractionOptions, prefersReducedMotion, preloadHighlighter, prerenderHTMLIfNecessary, processFile, processLine, processPatch, pushOrJoinSpan, queueRender, recordLineAnnotationSource, registerCustomCSSVariableTheme, registerCustomLanguage, registerCustomTheme, releaseStringDetachBuffer, renderDiffWithHighlighter, renderFileWithHighlighter, replaceCustomExtensions, resolveConflict, resolveLanguage, resolveLanguages, resolveRegion, resolveTheme, resolveThemes, setCustomExtension, setLanguageOverride, setPreNodeProperties, trimPatchContext, wrapCoreCSS, wrapThemeCSS, wrapUnsafeCSS };
114
+ export { type AnnotationLineMap, type AnnotationSide, type AnnotationSpan, type AppliedThemeStyleCache, AttachedLanguages, AttachedThemes, type BaseCodeOptions, type BaseDiffOptions, type BaseDiffOptionsWithDefaults, type BundledLanguage, CODE_VIEW_DIFF_OPTION_KEYS, CODE_VIEW_FILE_OPTION_KEYS, CODE_VIEW_FOOTER_ATTRIBUTE, CODE_VIEW_HEADER_ATTRIBUTE, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, CUSTOM_HEADER_SLOT_ID, type ChangeContent, type ChangeTypes, type CodeColumnType, type CodeToHastOptions, CodeToTokenTransformStream, CodeToTokenTransformStreamOptions, CodeView, CodeViewCoordinator, CodeViewCreateEditorOptions, type CodeViewDiffItem, type CodeViewFileItem, type CodeViewItem, CodeViewItemEditCompleteEventMap, CodeViewItemEditCompleteHandler, type CodeViewItemScrollTarget, type CodeViewLayout, type CodeViewLineScrollTarget, CodeViewLineSelection, CodeViewMode, CodeViewModeItemMap, CodeViewOptions, type CodeViewPositionScrollTarget, type CodeViewRangeScrollTarget, CodeViewRenderedDiffItem, CodeViewRenderedFileItem, CodeViewRenderedItem, type CodeViewScrollBehavior, CodeViewScrollListener, type CodeViewScrollTarget, CodeViewSlotSnapshot, type ConflictResolverTypes, type ContextContent, CreateFileHeaderElementProps, type CreatePatchOptionsNonabortable, type CustomPreProperties, CustomThemeLoader, DEFAULT_CODE_VIEW_FILE_METRICS, DEFAULT_CODE_VIEW_LAYOUT, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_SMOOTH_SCROLL_SETTINGS, DEFAULT_THEMES, DEFAULT_TOKENIZE_MAX_LENGTH, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_DEVELOPMENT_BUILD, DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY, DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE, DIFFS_TAG_NAME, type DecorationItem, type DiffAcceptRejectHunkConfig, type DiffAcceptRejectHunkType, type DiffFileInput, DiffHunksRenderer, DiffHunksRendererOptions, DiffHunksRendererOptionsWithDefaults, type DiffIndicators, type DiffLineAnnotation, type DiffLineEventBaseProps, type DiffTokenEventBaseProps, type DiffsHighlighter, type DiffsThemeNames, EMPTY_RENDER_RANGE, EXTENSION_TO_FILE_FORMAT, type ExpansionDirections, type ExtensionFormatMap, FILENAME_HEADER_REGEX, FILE_CONTEXT_BLOB, File, type FileContents, FileDiff, type FileDiffContentsLoader, FileDiffEditChangeHandler, type FileDiffEditCompleteEvent, FileDiffEditCompleteHandler, FileDiffHydrationProps, type FileDiffLoadedChangedFiles, type FileDiffLoadedFiles, type FileDiffLoadedPureRenamedFile, type FileDiffMetadata, FileDiffOptions, FileDiffRenderBaseProps, FileDiffRenderProps, FileDiffType, FileEditChangeHandler, type FileEditCompleteEvent, FileEditCompleteHandler, type FileHeaderRenderMode, FileHydrateProps, FileOptions, FileRenderProps, FileRenderResult, FileRenderer, FileRendererOptions, FileStream, FileStreamOptions, type ForceDiffPlainTextOptions, type ForceFilePlainTextOptions, GIT_DIFF_FILE_BREAK_REGEX, type GapSpan, GetHoveredLineResult, GetLineIndexUtility, HEADER_FILENAME_SUFFIX_SLOT_ID, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, type HighlightedToken, type HighlighterTypes, type Hunk, type HunkData, type HunkExpansionRegion, type HunkLineType, type HunkSeparators, HunksRenderResult, INDEX_LINE_METADATA, InjectedRow, InteractionManager, InteractionManagerBaseOptions, InteractionManagerMode, InteractionManagerOptions, type LanguageRegistration, type LineAnnotation, LineAnnotationPosition, LineDecoration, type LineDiffTypes, type LineEventBaseProps, type LineInfo, type LineSpans, type LineTypes, LogTypes, MERGE_CONFLICT_BASE_MARKER_REGEX, MERGE_CONFLICT_END_MARKER_REGEX, MERGE_CONFLICT_SEPARATOR_MARKER_REGEX, MERGE_CONFLICT_START_MARKER_REGEX, type MaybeDiffFileInput, type MergeConflictActionPayload, MergeConflictActionTarget, MergeConflictActionsTypeOption, type MergeConflictMarkerRow, type MergeConflictMarkerRowType, type MergeConflictRegion, type MergeConflictResolution, type NumericScrollLineAnchor, type ObservedAnnotationNodes, type ObservedGridNodes, OnDiffLineClickProps, OnDiffLineEnterLeaveProps, OnLineClickProps, OnLineEnterLeaveProps, OnTokenEventProps, ParsedLine, type ParsedPatch, type PendingCodeViewLayoutReset, type PostRenderPhase, type PrePropertiesConfig, type ProcessFileConflictData, RecallToken, RegisteredCustomLanguages, type RenderDiffFilesResult, type RenderDiffOptions, type RenderDiffResult, type RenderFileMetadata, type RenderFileOptions, type RenderFileResult, type RenderHeaderFilenameSuffixCallback, type RenderHeaderMetadataCallback, type RenderHeaderPrefixCallback, RenderMergeConflictActions, type RenderRange, type RenderWindow, type RenderedDiffASTCache, type RenderedFileASTCache, RenderedLineContext, ResizeManager, ResizeManagerColumnVariableMode, ResizeManagerSetupOptions, ResolvedLanguages, ResolvingLanguages, SPLIT_WITH_NEWLINES, SVGSpriteNames, SVGSpriteSheet, ScrollSyncManager, type SelectedLineRange, type SelectionPoint, type SelectionSide, SelectionWriteOptions, type SharedRenderState, ShikiStreamTokenizer, ShikiStreamTokenizerEnqueueResult, ShikiStreamTokenizerOptions, type ShikiTransformer, type SmoothScrollSettings, SplitInjectedRow, SplitInjectedRowPlacement, SplitLineDecorationProps, type StickySpecs, type SupportedLanguages, THEME_CSS_ATTRIBUTE, type ThemeRegistration, type ThemeRegistrationResolved, type ThemeTypes, type ThemedDiffResult, type ThemedFileResult, type ThemedToken, type ThemesType, type TokenEventBase, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE, UnifiedInjectedRowPlacement, UnifiedLineDecorationProps, UnresolvedFile, UnresolvedFileHydrationProps, UnresolvedFileOptions, UnresolvedFileRenderProps, VIRTUALIZED_FILE_DIFF_LAYOUT_CHECKPOINT_INTERVAL, type VirtualFileMetrics, type VirtualWindowSpecs, VirtualizedFile, VirtualizedFileDiff, Virtualizer, VirtualizerConfig, VirtualizerScrollOptions, areDiffLineAnnotationsEqual, areDiffRenderOptionsEqual, areDiffTargetsEqual, areFileRenderOptionsEqual, areFilesEqual, areHunkDataEqual, areLanguagesAttached, areLineAnnotationsEqual, areObjectsEqual, areOptionsEqual, arePrePropertiesEqual, areRenderRangesEqual, areSelectionsEqual, areThemesAttached, areThemesEqual, areVirtualWindowSpecsEqual, areWorkerStatsEqual, attachResolvedLanguages, attachResolvedThemes, cleanLastNewline, cleanUpResolvedLanguages, cleanUpResolvedThemes, clearRenderQueue, cloneFileDiffMetadata, cloneHunks, codeToHtml, createAnnotationElement, createAnnotationWrapperNode, createCSSVariablesTheme, createDiffSpanDecoration, createEmptyRowBuffer, createFileHeaderElement, createGutterGap, createGutterItem, createGutterUtilityContentNode, createGutterUtilityElement, createGutterWrapper, createHastElement, createIconElement, createNoNewlineElement, createPreElement, createPreWrapperProperties, createRowNodes, createSeparator, createSpanFromToken, createStyleElement, createTextNodeElement, createThemeStyleElement, createTransformerWithState, createUnsafeCSSStyleNode, createWindowFromScrollPosition, dequeueRender, detachString, diffAcceptRejectHunk, disposeHighlighter, findCodeElement, formatCSSVariablePrefix, getCustomExtensionsMap, getCustomExtensionsVersion, getFiletypeFromFileName, getHighlighterIfLoaded, getHighlighterOptions, getHighlighterThemeStyles, getHunkSeparatorSlotName, getIconForType, getLineAnnotationName, getLineAnnotationSource, getLineEndingType, getLineNodes, getOrCreateCodeNode, getResolvedLanguages, getResolvedOrResolveLanguage, getResolvedOrResolveTheme, getResolvedThemes, getSharedHighlighter, getSingularPatch, getThemes, getTotalLineCountFromHunks, getUnresolvedDiffHunksRendererOptions, hasResolvedLanguages, hasResolvedThemes, hydratePartialDiff, isDefaultRenderRange, isDiffAnnotation, isDiffAnnotationCollection, isFileAnnotation, isFileAnnotationCollection, isHighlighterLoaded, isHighlighterLoading, isHighlighterNull, isWorkerContext, parseDiffFromFile, parseLineType, parsePatchFiles, patchScrollbarGutterSize, pluckInteractionOptions, prefersReducedMotion, preloadHighlighter, prerenderHTMLIfNecessary, processFile, processLine, processPatch, pushOrJoinSpan, queueRender, recordLineAnnotationSource, registerCustomCSSVariableTheme, registerCustomLanguage, registerCustomTheme, releaseStringDetachBuffer, renderDiffWithHighlighter, renderFileWithHighlighter, replaceCustomExtensions, resolveConflict, resolveLanguage, resolveLanguages, resolveRegion, resolveTheme, resolveThemes, setCustomExtension, setLanguageOverride, setPreNodeProperties, trimPatchContext, wrapCoreCSS, wrapThemeCSS, wrapUnsafeCSS };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ALTERNATE_FILE_NAMES_GIT, CODE_VIEW_FOOTER_ATTRIBUTE, CODE_VIEW_HEADER_ATTRIBUTE, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, CUSTOM_HEADER_SLOT_ID, DEFAULT_CODE_VIEW_FILE_METRICS, DEFAULT_CODE_VIEW_LAYOUT, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_SMOOTH_SCROLL_SETTINGS, DEFAULT_THEMES, DEFAULT_TOKENIZE_MAX_LENGTH, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_DEVELOPMENT_BUILD, DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY, DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE, DIFFS_TAG_NAME, EMPTY_RENDER_RANGE, FILENAME_HEADER_REGEX, FILENAME_HEADER_REGEX_GIT, FILE_CONTEXT_BLOB, GIT_DIFF_FILE_BREAK_REGEX, HEADER_FILENAME_SUFFIX_SLOT_ID, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, INDEX_LINE_METADATA, MERGE_CONFLICT_BASE_MARKER_REGEX, MERGE_CONFLICT_END_MARKER_REGEX, MERGE_CONFLICT_SEPARATOR_MARKER_REGEX, MERGE_CONFLICT_START_MARKER_REGEX, SPLIT_WITH_NEWLINES, THEME_CSS_ATTRIBUTE, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE } from "./constants.js";
1
+ import { CODE_VIEW_FOOTER_ATTRIBUTE, CODE_VIEW_HEADER_ATTRIBUTE, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, CUSTOM_HEADER_SLOT_ID, DEFAULT_CODE_VIEW_FILE_METRICS, DEFAULT_CODE_VIEW_LAYOUT, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_SMOOTH_SCROLL_SETTINGS, DEFAULT_THEMES, DEFAULT_TOKENIZE_MAX_LENGTH, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_DEVELOPMENT_BUILD, DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY, DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE, DIFFS_TAG_NAME, EMPTY_RENDER_RANGE, FILENAME_HEADER_REGEX, FILE_CONTEXT_BLOB, GIT_DIFF_FILE_BREAK_REGEX, HEADER_FILENAME_SUFFIX_SLOT_ID, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, INDEX_LINE_METADATA, MERGE_CONFLICT_BASE_MARKER_REGEX, MERGE_CONFLICT_END_MARKER_REGEX, MERGE_CONFLICT_SEPARATOR_MARKER_REGEX, MERGE_CONFLICT_START_MARKER_REGEX, SPLIT_WITH_NEWLINES, THEME_CSS_ATTRIBUTE, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE } from "./constants.js";
2
2
  import { AttachedLanguages, RegisteredCustomLanguages, ResolvedLanguages, ResolvingLanguages } from "./highlighter/languages/constants.js";
3
3
  import { areLanguagesAttached } from "./highlighter/languages/areLanguagesAttached.js";
4
4
  import { attachResolvedLanguages } from "./highlighter/languages/attachResolvedLanguages.js";
@@ -107,4 +107,4 @@ import { parseLineType } from "./utils/parseLineType.js";
107
107
  import { setLanguageOverride } from "./utils/setLanguageOverride.js";
108
108
  import { trimPatchContext } from "./utils/trimPatchContext.js";
109
109
  import { codeToHtml, createCssVariablesTheme as createCSSVariablesTheme } from "shiki";
110
- export { ALTERNATE_FILE_NAMES_GIT, AttachedLanguages, AttachedThemes, CODE_VIEW_DIFF_OPTION_KEYS, CODE_VIEW_FILE_OPTION_KEYS, CODE_VIEW_FOOTER_ATTRIBUTE, CODE_VIEW_HEADER_ATTRIBUTE, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, CUSTOM_HEADER_SLOT_ID, CodeToTokenTransformStream, CodeView, DEFAULT_CODE_VIEW_FILE_METRICS, DEFAULT_CODE_VIEW_LAYOUT, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_SMOOTH_SCROLL_SETTINGS, DEFAULT_THEMES, DEFAULT_TOKENIZE_MAX_LENGTH, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_DEVELOPMENT_BUILD, DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY, DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE, DIFFS_TAG_NAME, DiffHunksRenderer, EMPTY_RENDER_RANGE, EXTENSION_TO_FILE_FORMAT, FILENAME_HEADER_REGEX, FILENAME_HEADER_REGEX_GIT, FILE_CONTEXT_BLOB, File, FileDiff, FileRenderer, FileStream, GIT_DIFF_FILE_BREAK_REGEX, HEADER_FILENAME_SUFFIX_SLOT_ID, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, INDEX_LINE_METADATA, InteractionManager, MERGE_CONFLICT_BASE_MARKER_REGEX, MERGE_CONFLICT_END_MARKER_REGEX, MERGE_CONFLICT_SEPARATOR_MARKER_REGEX, MERGE_CONFLICT_START_MARKER_REGEX, RegisteredCustomLanguages, ResizeManager, ResolvedLanguages, ResolvingLanguages, SPLIT_WITH_NEWLINES, SVGSpriteSheet, ScrollSyncManager, ShikiStreamTokenizer, THEME_CSS_ATTRIBUTE, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE, UnresolvedFile, VIRTUALIZED_FILE_DIFF_LAYOUT_CHECKPOINT_INTERVAL, VirtualizedFile, VirtualizedFileDiff, Virtualizer, areDiffLineAnnotationsEqual, areDiffRenderOptionsEqual, areDiffTargetsEqual, areFileRenderOptionsEqual, areFilesEqual, areHunkDataEqual, areLanguagesAttached, areLineAnnotationsEqual, areObjectsEqual, areOptionsEqual, arePrePropertiesEqual, areRenderRangesEqual, areSelectionsEqual, areThemesAttached, areThemesEqual, areVirtualWindowSpecsEqual, areWorkerStatsEqual, attachResolvedLanguages, attachResolvedThemes, cleanLastNewline, cleanUpResolvedLanguages, cleanUpResolvedThemes, clearRenderQueue, cloneFileDiffMetadata, cloneHunks, codeToHtml, createAnnotationElement, createAnnotationWrapperNode, createCSSVariablesTheme, createDiffSpanDecoration, createEmptyRowBuffer, createFileHeaderElement, createGutterGap, createGutterItem, createGutterUtilityContentNode, createGutterUtilityElement, createGutterWrapper, createHastElement, createIconElement, createNoNewlineElement, createPreElement, createPreWrapperProperties, createRowNodes, createSeparator, createSpanFromToken, createStyleElement, createTextNodeElement, createThemeStyleElement, createTransformerWithState, createUnsafeCSSStyleNode, createWindowFromScrollPosition, dequeueRender, detachString, diffAcceptRejectHunk, disposeHighlighter, findCodeElement, formatCSSVariablePrefix, getCustomExtensionsMap, getCustomExtensionsVersion, getFiletypeFromFileName, getHighlighterIfLoaded, getHighlighterOptions, getHighlighterThemeStyles, getHunkSeparatorSlotName, getIconForType, getLineAnnotationName, getLineAnnotationSource, getLineEndingType, getLineNodes, getOrCreateCodeNode, getResolvedLanguages, getResolvedOrResolveLanguage, getResolvedOrResolveTheme, getResolvedThemes, getSharedHighlighter, getSingularPatch, getThemes, getTotalLineCountFromHunks, getUnresolvedDiffHunksRendererOptions, hasResolvedLanguages, hasResolvedThemes, hydratePartialDiff, isDefaultRenderRange, isDiffAnnotation, isDiffAnnotationCollection, isFileAnnotation, isFileAnnotationCollection, isHighlighterLoaded, isHighlighterLoading, isHighlighterNull, isWorkerContext, parseDiffFromFile, parseLineType, parsePatchFiles, patchScrollbarGutterSize, pluckInteractionOptions, prefersReducedMotion, preloadHighlighter, prerenderHTMLIfNecessary, processFile, processLine, processPatch, pushOrJoinSpan, queueRender, recordLineAnnotationSource, registerCustomCSSVariableTheme, registerCustomLanguage, registerCustomTheme, releaseStringDetachBuffer, renderDiffWithHighlighter, renderFileWithHighlighter, replaceCustomExtensions, resolveConflict, resolveLanguage, resolveLanguages, resolveRegion, resolveTheme, resolveThemes, setCustomExtension, setLanguageOverride, setPreNodeProperties, trimPatchContext, wrapCoreCSS, wrapThemeCSS, wrapUnsafeCSS };
110
+ export { AttachedLanguages, AttachedThemes, CODE_VIEW_DIFF_OPTION_KEYS, CODE_VIEW_FILE_OPTION_KEYS, CODE_VIEW_FOOTER_ATTRIBUTE, CODE_VIEW_HEADER_ATTRIBUTE, COMMIT_METADATA_SPLIT, CORE_CSS_ATTRIBUTE, CUSTOM_HEADER_SLOT_ID, CodeToTokenTransformStream, CodeView, DEFAULT_CODE_VIEW_FILE_METRICS, DEFAULT_CODE_VIEW_LAYOUT, DEFAULT_COLLAPSED_CONTEXT_THRESHOLD, DEFAULT_EXPANDED_REGION, DEFAULT_RENDER_RANGE, DEFAULT_SMOOTH_SCROLL_SETTINGS, DEFAULT_THEMES, DEFAULT_TOKENIZE_MAX_LENGTH, DEFAULT_VIRTUAL_FILE_METRICS, DIFFS_DEVELOPMENT_BUILD, DIFFS_SCROLLBAR_GUTTER_MEASURED_PROPERTY, DIFFS_SCROLLBAR_MEASURE_ATTRIBUTE, DIFFS_TAG_NAME, DiffHunksRenderer, EMPTY_RENDER_RANGE, EXTENSION_TO_FILE_FORMAT, FILENAME_HEADER_REGEX, FILE_CONTEXT_BLOB, File, FileDiff, FileRenderer, FileStream, GIT_DIFF_FILE_BREAK_REGEX, HEADER_FILENAME_SUFFIX_SLOT_ID, HEADER_METADATA_SLOT_ID, HEADER_PREFIX_SLOT_ID, HUNK_HEADER, INDEX_LINE_METADATA, InteractionManager, MERGE_CONFLICT_BASE_MARKER_REGEX, MERGE_CONFLICT_END_MARKER_REGEX, MERGE_CONFLICT_SEPARATOR_MARKER_REGEX, MERGE_CONFLICT_START_MARKER_REGEX, RegisteredCustomLanguages, ResizeManager, ResolvedLanguages, ResolvingLanguages, SPLIT_WITH_NEWLINES, SVGSpriteSheet, ScrollSyncManager, ShikiStreamTokenizer, THEME_CSS_ATTRIBUTE, UNIFIED_DIFF_FILE_BREAK_REGEX, UNSAFE_CSS_ATTRIBUTE, UnresolvedFile, VIRTUALIZED_FILE_DIFF_LAYOUT_CHECKPOINT_INTERVAL, VirtualizedFile, VirtualizedFileDiff, Virtualizer, areDiffLineAnnotationsEqual, areDiffRenderOptionsEqual, areDiffTargetsEqual, areFileRenderOptionsEqual, areFilesEqual, areHunkDataEqual, areLanguagesAttached, areLineAnnotationsEqual, areObjectsEqual, areOptionsEqual, arePrePropertiesEqual, areRenderRangesEqual, areSelectionsEqual, areThemesAttached, areThemesEqual, areVirtualWindowSpecsEqual, areWorkerStatsEqual, attachResolvedLanguages, attachResolvedThemes, cleanLastNewline, cleanUpResolvedLanguages, cleanUpResolvedThemes, clearRenderQueue, cloneFileDiffMetadata, cloneHunks, codeToHtml, createAnnotationElement, createAnnotationWrapperNode, createCSSVariablesTheme, createDiffSpanDecoration, createEmptyRowBuffer, createFileHeaderElement, createGutterGap, createGutterItem, createGutterUtilityContentNode, createGutterUtilityElement, createGutterWrapper, createHastElement, createIconElement, createNoNewlineElement, createPreElement, createPreWrapperProperties, createRowNodes, createSeparator, createSpanFromToken, createStyleElement, createTextNodeElement, createThemeStyleElement, createTransformerWithState, createUnsafeCSSStyleNode, createWindowFromScrollPosition, dequeueRender, detachString, diffAcceptRejectHunk, disposeHighlighter, findCodeElement, formatCSSVariablePrefix, getCustomExtensionsMap, getCustomExtensionsVersion, getFiletypeFromFileName, getHighlighterIfLoaded, getHighlighterOptions, getHighlighterThemeStyles, getHunkSeparatorSlotName, getIconForType, getLineAnnotationName, getLineAnnotationSource, getLineEndingType, getLineNodes, getOrCreateCodeNode, getResolvedLanguages, getResolvedOrResolveLanguage, getResolvedOrResolveTheme, getResolvedThemes, getSharedHighlighter, getSingularPatch, getThemes, getTotalLineCountFromHunks, getUnresolvedDiffHunksRendererOptions, hasResolvedLanguages, hasResolvedThemes, hydratePartialDiff, isDefaultRenderRange, isDiffAnnotation, isDiffAnnotationCollection, isFileAnnotation, isFileAnnotationCollection, isHighlighterLoaded, isHighlighterLoading, isHighlighterNull, isWorkerContext, parseDiffFromFile, parseLineType, parsePatchFiles, patchScrollbarGutterSize, pluckInteractionOptions, prefersReducedMotion, preloadHighlighter, prerenderHTMLIfNecessary, processFile, processLine, processPatch, pushOrJoinSpan, queueRender, recordLineAnnotationSource, registerCustomCSSVariableTheme, registerCustomLanguage, registerCustomTheme, releaseStringDetachBuffer, renderDiffWithHighlighter, renderFileWithHighlighter, replaceCustomExtensions, resolveConflict, resolveLanguage, resolveLanguages, resolveRegion, resolveTheme, resolveThemes, setCustomExtension, setLanguageOverride, setPreNodeProperties, trimPatchContext, wrapCoreCSS, wrapThemeCSS, wrapUnsafeCSS };
@@ -1 +1 @@
1
- {"version":3,"file":"useFileDiffInstance.d.ts","names":[],"sources":["../../../src/react/utils/useFileDiffInstance.ts"],"mappings":";;;;;;UA8DU,yBAAyB,aAAa;EAC9C,WAAW;EACX,UAAU;EACV,UAAU;EACV,SAAS,gBAAgB,aAAa;EACtC,eAAe,2BAA2B,aAAa;EACvD;EACA,iBAAiB,mBAAmB;EACpC,eAAe;EACf;EACA,UAAU;EACV;EACA;EACA;EACA;EACA,eAAe,0BAA0B,aAAa;EACtD,iBAAiB,4BAA4B,aAAa;;UAGlD,0BAA0B;EAClC,UAAU;EACV,IAAI,MAAM;EACV,kBAAkB;EAClB,sBAAsB,YAAY,mBAAmB;;iBAGvC,oBAAoB,aAAa,SAC/C,UACA,SACA,SACA,SACA,eACA,cACA,iBACA,eACA,iBACA,SACA,wBACA,iBACA,mBACA,MACA,cAAc,eACd,gBAAgB,mBACf,yBACD,aACA,SACE,0BAA0B"}
1
+ {"version":3,"file":"useFileDiffInstance.d.ts","names":[],"sources":["../../../src/react/utils/useFileDiffInstance.ts"],"mappings":";;;;;;UA+DU,yBAAyB,aAAa;EAC9C,WAAW;EACX,UAAU;EACV,UAAU;EACV,SAAS,gBAAgB,aAAa;EACtC,eAAe,2BAA2B,aAAa;EACvD;EACA,iBAAiB,mBAAmB;EACpC,eAAe;EACf;EACA,UAAU;EACV;EACA;EACA;EACA;EACA,eAAe,0BAA0B,aAAa;EACtD,iBAAiB,4BAA4B,aAAa;;UAGlD,0BAA0B;EAClC,UAAU;EACV,IAAI,MAAM;EACV,kBAAkB;EAClB,sBAAsB,YAAY,mBAAmB;;iBAGvC,oBAAoB,aAAa,SAC/C,UACA,SACA,SACA,SACA,eACA,cACA,iBACA,eACA,iBACA,SACA,wBACA,iBACA,mBACA,MACA,cAAc,eACd,gBAAgB,mBACf,yBACD,aACA,SACE,0BAA0B"}
@@ -10,7 +10,7 @@ import { useCreateEditor } from "../EditContext.js";
10
10
  import { noopRender } from "../constants.js";
11
11
  import { WorkerPoolContext } from "../WorkerPoolContext.js";
12
12
  import { useVirtualizer } from "../Virtualizer.js";
13
- import { useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef } from "react";
13
+ import { useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
14
14
  //#region src/react/utils/useFileDiffInstance.ts
15
15
  const useIsomorphicLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
16
16
  function useFileDiffInstance({ fileDiff, oldFile, newFile, options, editorOptions, editStateKey, lineAnnotations, selectedLines, prerenderedHTML, metrics, hasGutterRenderUtility, hasCustomHeader, disableWorkerPool, edit, onEditChange: _onEditChange, onEditComplete: _onEditComplete }) {
@@ -18,6 +18,7 @@ function useFileDiffInstance({ fileDiff, oldFile, newFile, options, editorOption
18
18
  const controlledSelection = selectedLines !== void 0;
19
19
  const poolManager = useContext(WorkerPoolContext);
20
20
  const createEditor = useCreateEditor();
21
+ const [asyncAttachError, setAsyncAttachError] = useState();
21
22
  const handleOnEditChange = useStableCallback((event) => _onEditChange?.(event));
22
23
  const onEditChange = _onEditChange != null ? handleOnEditChange : void 0;
23
24
  const acceptedCache = useRef(null);
@@ -56,6 +57,7 @@ function useFileDiffInstance({ fileDiff, oldFile, newFile, options, editorOption
56
57
  });
57
58
  const instanceRef = useRef(null);
58
59
  const disposeEditorRef = useRef(null);
60
+ const pendingAttachRef = useRef(null);
59
61
  const getEditor = useStableCallback(() => {
60
62
  if (createEditor == null) throw new Error("FileDiff: EditContext is not attached");
61
63
  return createEditor("file-diff", editorOptions ?? {}, editStateKey);
@@ -79,7 +81,6 @@ function useFileDiffInstance({ fileDiff, oldFile, newFile, options, editorOption
79
81
  onEditComplete,
80
82
  options
81
83
  }), !disableWorkerPool ? poolManager : void 0, true);
82
- if (edit && disposeEditorRef.current == null) disposeEditorRef.current = applyEdit(instanceRef.current, getEditor);
83
84
  instanceRef.current.hydrate({
84
85
  fileDiff: effectiveFileDiff,
85
86
  fileContainer,
@@ -88,6 +89,7 @@ function useFileDiffInstance({ fileDiff, oldFile, newFile, options, editorOption
88
89
  });
89
90
  } else {
90
91
  if (instanceRef.current == null) throw new Error("useFileDiffInstance: A FileDiff instance should exist when unmounting");
92
+ pendingAttachRef.current = null;
91
93
  instanceRef.current.cleanUp();
92
94
  instanceRef.current = null;
93
95
  disposeEditorRef.current = null;
@@ -106,10 +108,13 @@ function useFileDiffInstance({ fileDiff, oldFile, newFile, options, editorOption
106
108
  });
107
109
  const forceRender = newOptions !== void 0 && !areOptionsEqual(instance.options, newOptions);
108
110
  instance.setOptions(newOptions);
109
- if (!edit && disposeEditorRef.current != null) {
110
- const { current: disposeEditor } = disposeEditorRef;
111
- disposeEditorRef.current = null;
112
- disposeEditor();
111
+ if (!edit) {
112
+ pendingAttachRef.current = null;
113
+ if (disposeEditorRef.current != null) {
114
+ const { current: disposeEditor } = disposeEditorRef;
115
+ disposeEditorRef.current = null;
116
+ disposeEditor();
117
+ }
113
118
  }
114
119
  const resolved = resolveAcceptedValues(effectiveFileDiff, lineAnnotations, acceptedCache);
115
120
  instance.render({
@@ -118,15 +123,46 @@ function useFileDiffInstance({ fileDiff, oldFile, newFile, options, editorOption
118
123
  lineAnnotations: resolved.lineAnnotations
119
124
  });
120
125
  if (selectedLines !== void 0) instance.setSelectedLines(selectedLines);
121
- if (edit && disposeEditorRef.current == null) disposeEditorRef.current = applyEdit(instance, getEditor);
126
+ if (!edit || disposeEditorRef.current != null) return;
127
+ if (createEditor == null) throw new Error("FileDiff: EditContext is not attached");
128
+ const attach = () => {
129
+ if (instanceRef.current !== instance || disposeEditorRef.current != null || !instance.__canAttachEditor()) return;
130
+ disposeEditorRef.current = applyEdit(instance, getEditor);
131
+ };
132
+ if (instance.__canAttachEditor()) {
133
+ pendingAttachRef.current = null;
134
+ attach();
135
+ return;
136
+ }
137
+ const promise = instance.__prepareForEditing();
138
+ if (promise == null) {
139
+ pendingAttachRef.current = null;
140
+ return;
141
+ }
142
+ if (pendingAttachRef.current?.promise === promise) return;
143
+ const pending = { promise };
144
+ pendingAttachRef.current = pending;
145
+ promise.then(() => {
146
+ if (pendingAttachRef.current !== pending) return;
147
+ attach();
148
+ pendingAttachRef.current = null;
149
+ }).catch((error) => {
150
+ if (pendingAttachRef.current === pending) {
151
+ pendingAttachRef.current = null;
152
+ setAsyncAttachError(error);
153
+ }
154
+ });
122
155
  });
156
+ const getHoveredLine = useCallback(() => {
157
+ return instanceRef.current?.getHoveredLine();
158
+ }, []);
159
+ const getAnnotationSlotName = useCallback((annotation) => instanceRef.current?.getAnnotationSlotName(annotation) ?? getLineAnnotationName(annotation), []);
160
+ if (asyncAttachError != null) throw asyncAttachError;
123
161
  return {
124
162
  fileDiff: effectiveFileDiff,
125
163
  ref,
126
- getHoveredLine: useCallback(() => {
127
- return instanceRef.current?.getHoveredLine();
128
- }, []),
129
- getAnnotationSlotName: useCallback((annotation) => instanceRef.current?.getAnnotationSlotName(annotation) ?? getLineAnnotationName(annotation), [])
164
+ getHoveredLine,
165
+ getAnnotationSlotName
130
166
  };
131
167
  }
132
168
  function useEffectiveFileDiff({ acceptedCache, fileDiff, newFile, oldFile, parseDiffOptions }) {
@@ -1 +1 @@
1
- {"version":3,"file":"useFileDiffInstance.js","names":[],"sources":["../../../src/react/utils/useFileDiffInstance.ts"],"sourcesContent":["import {\n type RefObject,\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n} from 'react';\n\nimport {\n FileDiff,\n type FileDiffEditChangeHandler,\n type FileDiffEditCompleteEvent,\n type FileDiffEditCompleteHandler,\n type FileDiffOptions,\n} from '../../components/FileDiff';\nimport { VirtualizedFileDiff } from '../../components/VirtualizedFileDiff';\nimport type { Editor, EditorChangeEvent, EditorOptions } from '../../edit';\nimport type { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type {\n DiffLineAnnotation,\n FileContents,\n FileDiffMetadata,\n SelectedLineRange,\n VirtualFileMetrics,\n} from '../../types';\nimport { areDiffTargetsEqual } from '../../utils/areDiffTargetsEqual';\nimport { areFileTargetsEqual } from '../../utils/areFileTargetsEqual';\nimport { areOptionsEqual } from '../../utils/areOptionsEqual';\nimport { getLineAnnotationName } from '../../utils/getLineAnnotationName';\nimport { parseDiffFromFile } from '../../utils/parseDiffFromFile';\nimport { noopRender } from '../constants';\nimport { useCreateEditor } from '../EditContext';\nimport { useVirtualizer } from '../Virtualizer';\nimport { WorkerPoolContext } from '../WorkerPoolContext';\nimport { useStableCallback } from './useStableCallback';\n\nconst useIsomorphicLayoutEffect =\n typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\ninterface AcceptedFilePair {\n oldFile: FileContents | null;\n newFile: FileContents | null;\n}\n\ninterface AcceptedCompletion<LAnnotation> {\n fileDiff: {\n installed: FileDiffMetadata;\n stale: FileDiffMetadata;\n } | null;\n filePair: {\n fileDiff: FileDiffMetadata;\n installed: AcceptedFilePair;\n stale: AcceptedFilePair;\n } | null;\n annotations: {\n installed: DiffLineAnnotation<LAnnotation>[] | undefined;\n stale: DiffLineAnnotation<LAnnotation>[];\n } | null;\n}\n\ninterface UseFileDiffInstanceProps<LAnnotation, Caret> {\n fileDiff?: FileDiffMetadata;\n oldFile?: FileContents | null;\n newFile?: FileContents | null;\n options: FileDiffOptions<LAnnotation, Caret> | undefined;\n editorOptions: EditorOptions<'file-diff', LAnnotation, Caret> | undefined;\n editStateKey: string | undefined;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n metrics?: VirtualFileMetrics;\n hasGutterRenderUtility: boolean;\n hasCustomHeader: boolean;\n disableWorkerPool: boolean;\n edit: boolean;\n onEditChange?: FileDiffEditChangeHandler<LAnnotation, Caret>;\n onEditComplete?: FileDiffEditCompleteHandler<LAnnotation, Caret>;\n}\n\ninterface UseFileDiffInstanceReturn<LAnnotation> {\n fileDiff: FileDiffMetadata;\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n getAnnotationSlotName(annotation: DiffLineAnnotation<LAnnotation>): string;\n}\n\nexport function useFileDiffInstance<LAnnotation, Caret>({\n fileDiff,\n oldFile,\n newFile,\n options,\n editorOptions,\n editStateKey,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n metrics,\n hasGutterRenderUtility,\n hasCustomHeader,\n disableWorkerPool,\n edit,\n onEditChange: _onEditChange,\n onEditComplete: _onEditComplete,\n}: UseFileDiffInstanceProps<\n LAnnotation,\n Caret\n>): UseFileDiffInstanceReturn<LAnnotation> {\n const simpleVirtualizer = useVirtualizer();\n const controlledSelection = selectedLines !== undefined;\n const poolManager = useContext(WorkerPoolContext);\n const createEditor = useCreateEditor<LAnnotation, Caret>();\n const handleOnEditChange = useStableCallback(\n (event: EditorChangeEvent<'file-diff', LAnnotation, Caret>) =>\n _onEditChange?.(event)\n );\n const onEditChange = _onEditChange != null ? handleOnEditChange : undefined;\n // An accepted completion installs its diff on the instance immediately,\n // but the fileDiff/lineAnnotations props stay pre-edit until the owner's\n // state update lands. This holds the accepted values so the renders in\n // between do not repaint pre-edit state.\n const acceptedCache = useRef<AcceptedCompletion<LAnnotation> | null>(null);\n const handleOnEditComplete = useStableCallback(\n (event: FileDiffEditCompleteEvent<LAnnotation, Caret>) => {\n const decision = _onEditComplete?.(event) ?? 'reject';\n if (decision === 'accept') {\n acceptedCache.current = {\n fileDiff: {\n installed: event.fileDiff,\n stale: event.originalFileDiff,\n },\n filePair:\n fileDiff == null\n ? {\n fileDiff: event.fileDiff,\n installed: { oldFile: event.oldFile, newFile: event.newFile },\n stale: { oldFile: oldFile ?? null, newFile: newFile ?? null },\n }\n : null,\n annotations: {\n installed: event.lineAnnotations,\n stale: event.originalLineAnnotations,\n },\n };\n }\n return decision;\n }\n );\n const onEditComplete =\n _onEditComplete != null ? handleOnEditComplete : undefined;\n // File-pair inputs parse here. While the file props still match the pair\n // from acceptance time (stale) or the completion event's files (installed),\n // the parse is the accepted diff itself; any other pair clears the record\n // and parses fresh.\n const effectiveFileDiff = useEffectiveFileDiff({\n acceptedCache,\n fileDiff,\n newFile,\n oldFile,\n parseDiffOptions: options?.parseDiffOptions,\n });\n const instanceRef = useRef<\n | FileDiff<LAnnotation, Caret>\n | VirtualizedFileDiff<LAnnotation, Caret>\n | null\n >(null);\n const disposeEditorRef = useRef<() => void>(null);\n const getEditor = useStableCallback(() => {\n if (createEditor == null) {\n throw new Error('FileDiff: EditContext is not attached');\n }\n return createEditor('file-diff', editorOptions ?? {}, editStateKey);\n });\n const ref = useStableCallback((fileContainer: HTMLElement | null) => {\n if (fileContainer != null) {\n if (instanceRef.current != null) {\n throw new Error(\n 'useFileDiffInstance: An instance should not already exist when a node is created'\n );\n }\n if (simpleVirtualizer != null) {\n instanceRef.current = new VirtualizedFileDiff(\n mergeFileDiffOptions({\n controlledSelection,\n hasCustomHeader,\n hasGutterRenderUtility,\n onEditChange,\n onEditComplete,\n options,\n }),\n simpleVirtualizer,\n metrics,\n !disableWorkerPool ? poolManager : undefined,\n true\n );\n } else {\n instanceRef.current = new FileDiff(\n mergeFileDiffOptions({\n controlledSelection,\n hasCustomHeader,\n hasGutterRenderUtility,\n onEditChange,\n onEditComplete,\n options,\n }),\n !disableWorkerPool ? poolManager : undefined,\n true\n );\n }\n if (edit && disposeEditorRef.current == null) {\n disposeEditorRef.current = applyEdit(instanceRef.current, getEditor);\n }\n void instanceRef.current.hydrate({\n fileDiff: effectiveFileDiff,\n fileContainer,\n lineAnnotations,\n prerenderedHTML,\n });\n } else {\n if (instanceRef.current == null) {\n throw new Error(\n 'useFileDiffInstance: A FileDiff instance should exist when unmounting'\n );\n }\n instanceRef.current.cleanUp();\n instanceRef.current = null;\n disposeEditorRef.current = null;\n }\n });\n\n useIsomorphicLayoutEffect(() => {\n const { current: instance } = instanceRef;\n if (instance == null) return;\n const newOptions = mergeFileDiffOptions({\n controlledSelection,\n hasCustomHeader,\n hasGutterRenderUtility,\n onEditChange,\n onEditComplete,\n options,\n });\n // setOptions(undefined) is a no-op, so an undefined merge result never\n // requires a forced render — comparing it against the instance's\n // constructor-default options would force a full render on every commit.\n const forceRender =\n newOptions !== undefined &&\n !areOptionsEqual(instance.options, newOptions);\n instance.setOptions(newOptions);\n // Detach editor before rendering if required\n if (!edit && disposeEditorRef.current != null) {\n const { current: disposeEditor } = disposeEditorRef;\n disposeEditorRef.current = null;\n disposeEditor();\n }\n const resolved = resolveAcceptedValues(\n effectiveFileDiff,\n lineAnnotations,\n acceptedCache\n );\n void instance.render({\n forceRender,\n fileDiff: resolved.fileDiff,\n lineAnnotations: resolved.lineAnnotations,\n });\n if (selectedLines !== undefined) {\n instance.setSelectedLines(selectedLines);\n }\n // Attach editor after rendering if required\n if (edit && disposeEditorRef.current == null) {\n disposeEditorRef.current = applyEdit(instance, getEditor);\n }\n });\n\n const getHoveredLine = useCallback(():\n | GetHoveredLineResult<'diff'>\n | undefined => {\n return instanceRef.current?.getHoveredLine();\n }, []);\n const getAnnotationSlotName = useCallback(\n (annotation: DiffLineAnnotation<LAnnotation>): string =>\n instanceRef.current?.getAnnotationSlotName(annotation) ??\n getLineAnnotationName(annotation),\n []\n );\n\n return {\n fileDiff: effectiveFileDiff,\n ref,\n getHoveredLine,\n getAnnotationSlotName,\n };\n}\n\ninterface UseEffectiveFileDiffProps<LAnnotation, Caret> {\n acceptedCache: RefObject<AcceptedCompletion<LAnnotation> | null>;\n fileDiff: FileDiffMetadata | undefined;\n newFile: FileContents | null | undefined;\n oldFile: FileContents | null | undefined;\n parseDiffOptions: FileDiffOptions<LAnnotation, Caret>['parseDiffOptions'];\n}\n\n// Resolves the diff the instance renders: the `fileDiff` prop when given;\n// otherwise the accepted edit's cached diff while the file props still name the\n// pair it was accepted against; otherwise a fresh parse of the file props. A\n// cached pair that no longer matches is dropped on the way. Kept in its own hook\n// because the render-time ref read and write are deliberate; the boundary lets\n// the calling hook stay compilable.\nfunction useEffectiveFileDiff<LAnnotation, Caret>({\n acceptedCache,\n fileDiff,\n newFile,\n oldFile,\n parseDiffOptions,\n}: UseEffectiveFileDiffProps<LAnnotation, Caret>): FileDiffMetadata {\n /* oxlint-disable react/immutability react/refs -- accepted edit output must\n * replace stale file-pair props during render */\n const effectiveFileDiff = useMemo(() => {\n if (fileDiff != null) {\n return fileDiff;\n }\n const { current: accepted } = acceptedCache;\n const filePair = accepted?.filePair;\n if (accepted != null && filePair != null) {\n if (\n isSameFilePair(oldFile, newFile, filePair.stale) ||\n isSameFilePair(oldFile, newFile, filePair.installed)\n ) {\n return filePair.fileDiff;\n }\n accepted.filePair = null;\n }\n return parseDiffFromFile(\n oldFile ?? null,\n newFile ?? null,\n parseDiffOptions\n );\n }, [acceptedCache, fileDiff, oldFile, newFile, parseDiffOptions]);\n /* oxlint-enable react/immutability react/refs */\n\n return effectiveFileDiff;\n}\n\n// Whether the file props name the same files as a recorded pair.\nfunction isSameFilePair(\n oldFile: FileContents | null | undefined,\n newFile: FileContents | null | undefined,\n filePair: AcceptedFilePair\n): boolean {\n return (\n areFileTargetsEqual(oldFile ?? undefined, filePair.oldFile ?? undefined) &&\n areFileTargetsEqual(newFile ?? undefined, filePair.newFile ?? undefined)\n );\n}\n\n// Render the installed values in place of props that still match their stale\n// counterparts. Any other prop value clears its slot — filePair settles in\n// the parse memo instead — and the ref clears once all three have.\nfunction resolveAcceptedValues<LAnnotation>(\n fileDiff: FileDiffMetadata,\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined,\n acceptedCache: RefObject<AcceptedCompletion<LAnnotation> | null>\n): {\n fileDiff: FileDiffMetadata;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n} {\n const { current: accepted } = acceptedCache;\n if (accepted == null) {\n return { fileDiff, lineAnnotations };\n }\n const { fileDiff: acceptedDiff, annotations: acceptedAnnotations } = accepted;\n let resolvedFileDiff = fileDiff;\n if (acceptedDiff != null) {\n if (areDiffTargetsEqual(fileDiff, acceptedDiff.stale)) {\n resolvedFileDiff = acceptedDiff.installed;\n } else {\n accepted.fileDiff = null;\n }\n }\n let resolvedAnnotations = lineAnnotations;\n if (acceptedAnnotations != null) {\n if (lineAnnotations === acceptedAnnotations.stale) {\n resolvedAnnotations = acceptedAnnotations.installed;\n } else {\n accepted.annotations = null;\n }\n }\n if (\n accepted.fileDiff == null &&\n accepted.annotations == null &&\n accepted.filePair == null\n ) {\n acceptedCache.current = null;\n }\n return { fileDiff: resolvedFileDiff, lineAnnotations: resolvedAnnotations };\n}\n\ninterface MergeFileDiffOptionsProps<LAnnotation, Caret> {\n controlledSelection: boolean;\n hasCustomHeader: boolean;\n hasGutterRenderUtility: boolean;\n onEditChange?: FileDiffEditChangeHandler<LAnnotation, Caret>;\n onEditComplete?: FileDiffEditCompleteHandler<LAnnotation, Caret>;\n options: FileDiffOptions<LAnnotation, Caret> | undefined;\n}\n\nfunction mergeFileDiffOptions<LAnnotation, Caret>({\n options,\n controlledSelection,\n hasCustomHeader,\n hasGutterRenderUtility,\n onEditChange,\n onEditComplete,\n}: MergeFileDiffOptionsProps<LAnnotation, Caret>):\n | FileDiffOptions<LAnnotation, Caret>\n | undefined {\n const needsReactOverrides =\n controlledSelection ||\n hasGutterRenderUtility ||\n hasCustomHeader ||\n onEditChange != null ||\n onEditComplete != null;\n\n if (!needsReactOverrides) {\n return options;\n }\n\n return {\n ...options,\n controlledSelection,\n renderCustomHeader: hasCustomHeader\n ? noopRender\n : options?.renderCustomHeader,\n renderGutterUtility: hasGutterRenderUtility\n ? noopRender\n : options?.renderGutterUtility,\n onEditChange,\n onEditComplete,\n };\n}\n\nfunction applyEdit<LAnnotation, Caret>(\n instance: FileDiff<LAnnotation, Caret>,\n getEditor: () => Editor<'file-diff', LAnnotation, Caret>\n): () => void {\n const editor = getEditor();\n try {\n return editor.edit(instance);\n } catch (error) {\n editor.cleanUp();\n throw error;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAsCA,MAAM,4BACJ,OAAO,WAAW,cAAc,YAAY;AAiD9C,SAAgB,oBAAwC,EACtD,UACA,SACA,SACA,SACA,eACA,cACA,iBACA,eACA,iBACA,SACA,wBACA,iBACA,mBACA,MACA,cAAc,eACd,gBAAgB,mBAIyB;CACzC,MAAM,oBAAoB,eAAe;CACzC,MAAM,sBAAsB,kBAAkB,KAAA;CAC9C,MAAM,cAAc,WAAW,iBAAiB;CAChD,MAAM,eAAe,gBAAoC;CACzD,MAAM,qBAAqB,mBACxB,UACC,gBAAgB,KAAK,CACzB;CACA,MAAM,eAAe,iBAAiB,OAAO,qBAAqB,KAAA;CAKlE,MAAM,gBAAgB,OAA+C,IAAI;CACzE,MAAM,uBAAuB,mBAC1B,UAAyD;EACxD,MAAM,WAAW,kBAAkB,KAAK,KAAK;EAC7C,IAAI,aAAa,UACf,cAAc,UAAU;GACtB,UAAU;IACR,WAAW,MAAM;IACjB,OAAO,MAAM;GACf;GACA,UACE,YAAY,OACR;IACE,UAAU,MAAM;IAChB,WAAW;KAAE,SAAS,MAAM;KAAS,SAAS,MAAM;IAAQ;IAC5D,OAAO;KAAE,SAAS,WAAW;KAAM,SAAS,WAAW;IAAK;GAC9D,IACA;GACN,aAAa;IACX,WAAW,MAAM;IACjB,OAAO,MAAM;GACf;EACF;EAEF,OAAO;CACT,CACF;CACA,MAAM,iBACJ,mBAAmB,OAAO,uBAAuB,KAAA;CAKnD,MAAM,o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M,EAAE,UAAU,cAAc,aAAa,wBAAwB;CACrE,IAAI,mBAAmB;CACvB,IAAI,gBAAgB,MAAM;EACxB,IAAI,oBAAoB,UAAU,aAAa,KAAK,GAClD,mBAAmB,aAAa;OAEhC,SAAS,WAAW;CAExB;CACA,IAAI,sBAAsB;CAC1B,IAAI,uBAAuB,MAAM;EAC/B,IAAI,oBAAoB,oBAAoB,OAC1C,sBAAsB,oBAAoB;OAE1C,SAAS,cAAc;CAE3B;CACA,IACE,SAAS,YAAY,QACrB,SAAS,eAAe,QACxB,SAAS,YAAY,MAErB,cAAc,UAAU;CAE1B,OAAO;EAAE,UAAU;EAAkB,iBAAiB;CAAoB;AAC5E;AAWA,SAAS,qBAAyC,EAChD,SACA,qBACA,iBACA,wBACA,cACA,kBAGY;CAQZ,IAAI,EANF,uBACA,0BACA,mBACA,gBAAgB,QAChB,kBAAkB,OAGlB,OAAO;CAGT,OAAO;EACL,GAAG;EACH;EACA,oBAAoB,kBAChB,aACA,SAAS;EACb,qBAAqB,yBACjB,aACA,SAAS;EACb;EACA;CACF;AACF;AAEA,SAAS,UACP,UACA,WACY;CACZ,MAAM,SAAS,UAAU;CACzB,IAAI;EACF,OAAO,OAAO,KAAK,QAAQ;CAC7B,SAAS,OAAO;EACd,OAAO,QAAQ;EACf,MAAM;CACR;AACF"}
1
+ {"version":3,"file":"useFileDiffInstance.js","names":[],"sources":["../../../src/react/utils/useFileDiffInstance.ts"],"sourcesContent":["import {\n type RefObject,\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport {\n FileDiff,\n type FileDiffEditChangeHandler,\n type FileDiffEditCompleteEvent,\n type FileDiffEditCompleteHandler,\n type FileDiffOptions,\n} from '../../components/FileDiff';\nimport { VirtualizedFileDiff } from '../../components/VirtualizedFileDiff';\nimport type { Editor, EditorChangeEvent, EditorOptions } from '../../edit';\nimport type { GetHoveredLineResult } from '../../managers/InteractionManager';\nimport type {\n DiffLineAnnotation,\n FileContents,\n FileDiffMetadata,\n SelectedLineRange,\n VirtualFileMetrics,\n} from '../../types';\nimport { areDiffTargetsEqual } from '../../utils/areDiffTargetsEqual';\nimport { areFileTargetsEqual } from '../../utils/areFileTargetsEqual';\nimport { areOptionsEqual } from '../../utils/areOptionsEqual';\nimport { getLineAnnotationName } from '../../utils/getLineAnnotationName';\nimport { parseDiffFromFile } from '../../utils/parseDiffFromFile';\nimport { noopRender } from '../constants';\nimport { useCreateEditor } from '../EditContext';\nimport { useVirtualizer } from '../Virtualizer';\nimport { WorkerPoolContext } from '../WorkerPoolContext';\nimport { useStableCallback } from './useStableCallback';\n\nconst useIsomorphicLayoutEffect =\n typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\ninterface AcceptedFilePair {\n oldFile: FileContents | null;\n newFile: FileContents | null;\n}\n\ninterface AcceptedCompletion<LAnnotation> {\n fileDiff: {\n installed: FileDiffMetadata;\n stale: FileDiffMetadata;\n } | null;\n filePair: {\n fileDiff: FileDiffMetadata;\n installed: AcceptedFilePair;\n stale: AcceptedFilePair;\n } | null;\n annotations: {\n installed: DiffLineAnnotation<LAnnotation>[] | undefined;\n stale: DiffLineAnnotation<LAnnotation>[];\n } | null;\n}\n\ninterface UseFileDiffInstanceProps<LAnnotation, Caret> {\n fileDiff?: FileDiffMetadata;\n oldFile?: FileContents | null;\n newFile?: FileContents | null;\n options: FileDiffOptions<LAnnotation, Caret> | undefined;\n editorOptions: EditorOptions<'file-diff', LAnnotation, Caret> | undefined;\n editStateKey: string | undefined;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n selectedLines: SelectedLineRange | null | undefined;\n prerenderedHTML: string | undefined;\n metrics?: VirtualFileMetrics;\n hasGutterRenderUtility: boolean;\n hasCustomHeader: boolean;\n disableWorkerPool: boolean;\n edit: boolean;\n onEditChange?: FileDiffEditChangeHandler<LAnnotation, Caret>;\n onEditComplete?: FileDiffEditCompleteHandler<LAnnotation, Caret>;\n}\n\ninterface UseFileDiffInstanceReturn<LAnnotation> {\n fileDiff: FileDiffMetadata;\n ref(node: HTMLElement | null): void;\n getHoveredLine(): GetHoveredLineResult<'diff'> | undefined;\n getAnnotationSlotName(annotation: DiffLineAnnotation<LAnnotation>): string;\n}\n\nexport function useFileDiffInstance<LAnnotation, Caret>({\n fileDiff,\n oldFile,\n newFile,\n options,\n editorOptions,\n editStateKey,\n lineAnnotations,\n selectedLines,\n prerenderedHTML,\n metrics,\n hasGutterRenderUtility,\n hasCustomHeader,\n disableWorkerPool,\n edit,\n onEditChange: _onEditChange,\n onEditComplete: _onEditComplete,\n}: UseFileDiffInstanceProps<\n LAnnotation,\n Caret\n>): UseFileDiffInstanceReturn<LAnnotation> {\n const simpleVirtualizer = useVirtualizer();\n const controlledSelection = selectedLines !== undefined;\n const poolManager = useContext(WorkerPoolContext);\n const createEditor = useCreateEditor<LAnnotation, Caret>();\n const [asyncAttachError, setAsyncAttachError] = useState<unknown>();\n const handleOnEditChange = useStableCallback(\n (event: EditorChangeEvent<'file-diff', LAnnotation, Caret>) =>\n _onEditChange?.(event)\n );\n const onEditChange = _onEditChange != null ? handleOnEditChange : undefined;\n // An accepted completion installs its diff on the instance immediately,\n // but the fileDiff/lineAnnotations props stay pre-edit until the owner's\n // state update lands. This holds the accepted values so the renders in\n // between do not repaint pre-edit state.\n const acceptedCache = useRef<AcceptedCompletion<LAnnotation> | null>(null);\n const handleOnEditComplete = useStableCallback(\n (event: FileDiffEditCompleteEvent<LAnnotation, Caret>) => {\n const decision = _onEditComplete?.(event) ?? 'reject';\n if (decision === 'accept') {\n acceptedCache.current = {\n fileDiff: {\n installed: event.fileDiff,\n stale: event.originalFileDiff,\n },\n filePair:\n fileDiff == null\n ? {\n fileDiff: event.fileDiff,\n installed: { oldFile: event.oldFile, newFile: event.newFile },\n stale: { oldFile: oldFile ?? null, newFile: newFile ?? null },\n }\n : null,\n annotations: {\n installed: event.lineAnnotations,\n stale: event.originalLineAnnotations,\n },\n };\n }\n return decision;\n }\n );\n const onEditComplete =\n _onEditComplete != null ? handleOnEditComplete : undefined;\n // File-pair inputs parse here. While the file props still match the pair\n // from acceptance time (stale) or the completion event's files (installed),\n // the parse is the accepted diff itself; any other pair clears the record\n // and parses fresh.\n const effectiveFileDiff = useEffectiveFileDiff({\n acceptedCache,\n fileDiff,\n newFile,\n oldFile,\n parseDiffOptions: options?.parseDiffOptions,\n });\n const instanceRef = useRef<\n | FileDiff<LAnnotation, Caret>\n | VirtualizedFileDiff<LAnnotation, Caret>\n | null\n >(null);\n const disposeEditorRef = useRef<() => void>(null);\n const pendingAttachRef = useRef<{ promise: Promise<void> } | null>(null);\n const getEditor = useStableCallback(() => {\n if (createEditor == null) {\n throw new Error('FileDiff: EditContext is not attached');\n }\n return createEditor('file-diff', editorOptions ?? {}, editStateKey);\n });\n const ref = useStableCallback((fileContainer: HTMLElement | null) => {\n if (fileContainer != null) {\n if (instanceRef.current != null) {\n throw new Error(\n 'useFileDiffInstance: An instance should not already exist when a node is created'\n );\n }\n if (simpleVirtualizer != null) {\n instanceRef.current = new VirtualizedFileDiff(\n mergeFileDiffOptions({\n controlledSelection,\n hasCustomHeader,\n hasGutterRenderUtility,\n onEditChange,\n onEditComplete,\n options,\n }),\n simpleVirtualizer,\n metrics,\n !disableWorkerPool ? poolManager : undefined,\n true\n );\n } else {\n instanceRef.current = new FileDiff(\n mergeFileDiffOptions({\n controlledSelection,\n hasCustomHeader,\n hasGutterRenderUtility,\n onEditChange,\n onEditComplete,\n options,\n }),\n !disableWorkerPool ? poolManager : undefined,\n true\n );\n }\n void instanceRef.current.hydrate({\n fileDiff: effectiveFileDiff,\n fileContainer,\n lineAnnotations,\n prerenderedHTML,\n });\n } else {\n if (instanceRef.current == null) {\n throw new Error(\n 'useFileDiffInstance: A FileDiff instance should exist when unmounting'\n );\n }\n pendingAttachRef.current = null;\n instanceRef.current.cleanUp();\n instanceRef.current = null;\n disposeEditorRef.current = null;\n }\n });\n\n useIsomorphicLayoutEffect(() => {\n const { current: instance } = instanceRef;\n if (instance == null) return;\n const newOptions = mergeFileDiffOptions({\n controlledSelection,\n hasCustomHeader,\n hasGutterRenderUtility,\n onEditChange,\n onEditComplete,\n options,\n });\n // setOptions(undefined) is a no-op, so an undefined merge result never\n // requires a forced render — comparing it against the instance's\n // constructor-default options would force a full render on every commit.\n const forceRender =\n newOptions !== undefined &&\n !areOptionsEqual(instance.options, newOptions);\n instance.setOptions(newOptions);\n // Detach editor before rendering if required\n if (!edit) {\n pendingAttachRef.current = null;\n if (disposeEditorRef.current != null) {\n const { current: disposeEditor } = disposeEditorRef;\n disposeEditorRef.current = null;\n disposeEditor();\n }\n }\n const resolved = resolveAcceptedValues(\n effectiveFileDiff,\n lineAnnotations,\n acceptedCache\n );\n void instance.render({\n forceRender,\n fileDiff: resolved.fileDiff,\n lineAnnotations: resolved.lineAnnotations,\n });\n if (selectedLines !== undefined) {\n instance.setSelectedLines(selectedLines);\n }\n if (!edit || disposeEditorRef.current != null) {\n return;\n }\n if (createEditor == null) {\n throw new Error('FileDiff: EditContext is not attached');\n }\n\n const attach = (): void => {\n if (\n instanceRef.current !== instance ||\n disposeEditorRef.current != null ||\n !instance.__canAttachEditor()\n ) {\n return;\n }\n disposeEditorRef.current = applyEdit(instance, getEditor);\n };\n // If we're all ready to attach the editor, lets go ahead\n // and do that synchronously\n if (instance.__canAttachEditor()) {\n pendingAttachRef.current = null;\n attach();\n return;\n }\n const promise = instance.__prepareForEditing();\n // If we can't hydrate the files... this will come back undefined,\n // which means there's nothing we can do\n if (promise == null) {\n pendingAttachRef.current = null;\n return;\n }\n // If we are already waiting on a hydration to finish, then there's nothing\n // we need to do\n if (pendingAttachRef.current?.promise === promise) {\n return;\n }\n const pending = { promise };\n pendingAttachRef.current = pending;\n void promise\n .then(() => {\n if (pendingAttachRef.current !== pending) {\n return;\n }\n attach();\n pendingAttachRef.current = null;\n })\n .catch((error: unknown) => {\n if (pendingAttachRef.current === pending) {\n pendingAttachRef.current = null;\n setAsyncAttachError(error);\n }\n });\n });\n\n const getHoveredLine = useCallback(():\n | GetHoveredLineResult<'diff'>\n | undefined => {\n return instanceRef.current?.getHoveredLine();\n }, []);\n const getAnnotationSlotName = useCallback(\n (annotation: DiffLineAnnotation<LAnnotation>): string =>\n instanceRef.current?.getAnnotationSlotName(annotation) ??\n getLineAnnotationName(annotation),\n []\n );\n\n if (asyncAttachError != null) {\n throw asyncAttachError;\n }\n\n return {\n fileDiff: effectiveFileDiff,\n ref,\n getHoveredLine,\n getAnnotationSlotName,\n };\n}\n\ninterface UseEffectiveFileDiffProps<LAnnotation, Caret> {\n acceptedCache: RefObject<AcceptedCompletion<LAnnotation> | null>;\n fileDiff: FileDiffMetadata | undefined;\n newFile: FileContents | null | undefined;\n oldFile: FileContents | null | undefined;\n parseDiffOptions: FileDiffOptions<LAnnotation, Caret>['parseDiffOptions'];\n}\n\n// Resolves the diff the instance renders: the `fileDiff` prop when given;\n// otherwise the accepted edit's cached diff while the file props still name the\n// pair it was accepted against; otherwise a fresh parse of the file props. A\n// cached pair that no longer matches is dropped on the way. Kept in its own hook\n// because the render-time ref read and write are deliberate; the boundary lets\n// the calling hook stay compilable.\nfunction useEffectiveFileDiff<LAnnotation, Caret>({\n acceptedCache,\n fileDiff,\n newFile,\n oldFile,\n parseDiffOptions,\n}: UseEffectiveFileDiffProps<LAnnotation, Caret>): FileDiffMetadata {\n /* oxlint-disable react/immutability react/refs -- accepted edit output must\n * replace stale file-pair props during render */\n const effectiveFileDiff = useMemo(() => {\n if (fileDiff != null) {\n return fileDiff;\n }\n const { current: accepted } = acceptedCache;\n const filePair = accepted?.filePair;\n if (accepted != null && filePair != null) {\n if (\n isSameFilePair(oldFile, newFile, filePair.stale) ||\n isSameFilePair(oldFile, newFile, filePair.installed)\n ) {\n return filePair.fileDiff;\n }\n accepted.filePair = null;\n }\n return parseDiffFromFile(\n oldFile ?? null,\n newFile ?? null,\n parseDiffOptions\n );\n }, [acceptedCache, fileDiff, oldFile, newFile, parseDiffOptions]);\n /* oxlint-enable react/immutability react/refs */\n\n return effectiveFileDiff;\n}\n\n// Whether the file props name the same files as a recorded pair.\nfunction isSameFilePair(\n oldFile: FileContents | null | undefined,\n newFile: FileContents | null | undefined,\n filePair: AcceptedFilePair\n): boolean {\n return (\n areFileTargetsEqual(oldFile ?? undefined, filePair.oldFile ?? undefined) &&\n areFileTargetsEqual(newFile ?? undefined, filePair.newFile ?? undefined)\n );\n}\n\n// Render the installed values in place of props that still match their stale\n// counterparts. Any other prop value clears its slot — filePair settles in\n// the parse memo instead — and the ref clears once all three have.\nfunction resolveAcceptedValues<LAnnotation>(\n fileDiff: FileDiffMetadata,\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined,\n acceptedCache: RefObject<AcceptedCompletion<LAnnotation> | null>\n): {\n fileDiff: FileDiffMetadata;\n lineAnnotations: DiffLineAnnotation<LAnnotation>[] | undefined;\n} {\n const { current: accepted } = acceptedCache;\n if (accepted == null) {\n return { fileDiff, lineAnnotations };\n }\n const { fileDiff: acceptedDiff, annotations: acceptedAnnotations } = accepted;\n let resolvedFileDiff = fileDiff;\n if (acceptedDiff != null) {\n if (areDiffTargetsEqual(fileDiff, acceptedDiff.stale)) {\n resolvedFileDiff = acceptedDiff.installed;\n } else {\n accepted.fileDiff = null;\n }\n }\n let resolvedAnnotations = lineAnnotations;\n if (acceptedAnnotations != null) {\n if (lineAnnotations === acceptedAnnotations.stale) {\n resolvedAnnotations = acceptedAnnotations.installed;\n } else {\n accepted.annotations = null;\n }\n }\n if (\n accepted.fileDiff == null &&\n accepted.annotations == null &&\n accepted.filePair == null\n ) {\n acceptedCache.current = null;\n }\n return { fileDiff: resolvedFileDiff, lineAnnotations: resolvedAnnotations };\n}\n\ninterface MergeFileDiffOptionsProps<LAnnotation, Caret> {\n controlledSelection: boolean;\n hasCustomHeader: boolean;\n hasGutterRenderUtility: boolean;\n onEditChange?: FileDiffEditChangeHandler<LAnnotation, Caret>;\n onEditComplete?: FileDiffEditCompleteHandler<LAnnotation, Caret>;\n options: FileDiffOptions<LAnnotation, Caret> | undefined;\n}\n\nfunction mergeFileDiffOptions<LAnnotation, Caret>({\n options,\n controlledSelection,\n hasCustomHeader,\n hasGutterRenderUtility,\n onEditChange,\n onEditComplete,\n}: MergeFileDiffOptionsProps<LAnnotation, Caret>):\n | FileDiffOptions<LAnnotation, Caret>\n | undefined {\n const needsReactOverrides =\n controlledSelection ||\n hasGutterRenderUtility ||\n hasCustomHeader ||\n onEditChange != null ||\n onEditComplete != null;\n\n if (!needsReactOverrides) {\n return options;\n }\n\n return {\n ...options,\n controlledSelection,\n renderCustomHeader: hasCustomHeader\n ? noopRender\n : options?.renderCustomHeader,\n renderGutterUtility: hasGutterRenderUtility\n ? noopRender\n : options?.renderGutterUtility,\n onEditChange,\n onEditComplete,\n };\n}\n\nfunction applyEdit<LAnnotation, Caret>(\n instance: FileDiff<LAnnotation, Caret>,\n getEditor: () => Editor<'file-diff', LAnnotation, Caret>\n): () => void {\n const editor = getEditor();\n try {\n return editor.edit(instance);\n } catch (error) {\n editor.cleanUp();\n throw error;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAuCA,MAAM,4BACJ,OAAO,WAAW,cAAc,YAAY;AAiD9C,SAAgB,oBAAwC,EACtD,UACA,SACA,SACA,SACA,eACA,cACA,iBACA,eACA,iBACA,SACA,wBACA,iBACA,mBACA,MACA,cAAc,eACd,gBAAgB,mBAIyB;CACzC,MAAM,oBAAoB,eAAe;CACzC,MAAM,sBAAsB,kBAAkB,KAAA;CAC9C,MAAM,cAAc,WAAW,iBAAiB;CAChD,MAAM,eAAe,gBAAoC;CACzD,MAAM,CAAC,kBAAkB,uBAAuB,SAAkB;CAClE,MAAM,qBAAqB,mBACxB,UACC,gBAAgB,KAAK,CACzB;CACA,MAAM,eAAe,iBAAiB,OAAO,qBAAqB,KAAA;CAKlE,MAAM,gBAAgB,OAA+C,IAAI;CACzE,MAAM,uBAAuB,mBAC1B,UAAyD;EACxD,MAAM,WAAW,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mBAAmB,aAAa;OAEhC,SAAS,WAAW;CAExB;CACA,IAAI,sBAAsB;CAC1B,IAAI,uBAAuB,MAAM;EAC/B,IAAI,oBAAoB,oBAAoB,OAC1C,sBAAsB,oBAAoB;OAE1C,SAAS,cAAc;CAE3B;CACA,IACE,SAAS,YAAY,QACrB,SAAS,eAAe,QACxB,SAAS,YAAY,MAErB,cAAc,UAAU;CAE1B,OAAO;EAAE,UAAU;EAAkB,iBAAiB;CAAoB;AAC5E;AAWA,SAAS,qBAAyC,EAChD,SACA,qBACA,iBACA,wBACA,cACA,kBAGY;CAQZ,IAAI,EANF,uBACA,0BACA,mBACA,gBAAgB,QAChB,kBAAkB,OAGlB,OAAO;CAGT,OAAO;EACL,GAAG;EACH;EACA,oBAAoB,kBAChB,aACA,SAAS;EACb,qBAAqB,yBACjB,aACA,SAAS;EACb;EACA;CACF;AACF;AAEA,SAAS,UACP,UACA,WACY;CACZ,MAAM,SAAS,UAAU;CACzB,IAAI;EACF,OAAO,OAAO,KAAK,QAAQ;CAC7B,SAAS,OAAO;EACd,OAAO,QAAQ;EACf,MAAM;CACR;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"DiffHunksRenderer.d.ts","names":[],"sources":["../../src/renderers/DiffHunksRenderer.ts"],"mappings":";;;;;;;UAoJiB,iCAAiC;EAChD,mBAAmB;;UAGJ,6CAA6C,KAC5D;EAGA,kBAAkB;;UAGH;EACf;EACA,UAAU;EACV;EACA;;UAGe;EACf;EACA;EACA;;UAGe;EACf,gBAAgB;EAChB,mBAAmB;EACnB,oBAAoB;;UAUL;EACf;EACA;EACA;EACA;EACA;EACA,eAAe;EACf,eAAe;;UAGA;EACf,SAAS;EACT,QAAQ;;UAGO;EACf,UAAU;EACV,UAAU;;UAGK;EACf,SAAS;EACT,QAAQ;;UAGO;EACf,SAAS;EACT,QAAQ;;UAGO;EACf,UAAU;EACV,kBAAkB;EAClB,mBAAmB;EACnB,oBAAoB;EACpB,qBAAqB;EACrB,oBAAoB;E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L,QAAQ,mBACR,eAAc;EAKT,kBACL,UAAU,kBACV;UAqBM;UAiEA;UA+DA;UASA"}
1
+ {"version":3,"file":"DiffHunksRenderer.d.ts","names":[],"sources":["../../src/renderers/DiffHunksRenderer.ts"],"mappings":";;;;;;;UAoJiB,iCAAiC;EAChD,mBAAmB;;UAGJ,6CAA6C,KAC5D;EAGA,kBAAkB;;UAGH;EACf;EACA,UAAU;EACV;EACA;;UAGe;EACf;EACA;EACA;;UAGe;EACf,gBAAgB;EAChB,mBAAmB;EACnB,oBAAoB;;UAUL;EACf;EACA;EACA;EACA;EACA;EACA,eAAe;EACf,eAAe;;UAGA;EACf,SAAS;EACT,QAAQ;;UAGO;EACf,UAAU;EACV,UAAU;;UAGK;EACf,SAAS;EACT,QAAQ;;UAGO;EACf,SAAS;EACT,QAAQ;;UAGO;EACf,UAAU;EACV,kBAAkB;EAClB,mBAAmB;EACnB,oBAAoB;EACpB,qBAAqB;EACrB,oBAAoB;EACpB,qBAAqB;EACrB,UAAU;EACV;EACA,SAAS;EACT,eAAe;EACf;EACA;EACA;EACA;EACA;EACA;;cAKW,kBAAkB;EAgCpB,SAAS;UACR;UAGA;UACA;WApCD;UAED;UAIA;UAEA;UAEA;UACA;UAEA;UACA;UAGA;UAGA;UAQA;EAER,YACS,UAAS,0BACR,sBACN,YAAY,mBAAmB,yBAEzB,8CACA,gBAAgB;EASnB;EAQA;;;;;;;;;;EA4BA,iBACL,MAAM,kBACN,eAAe;;EA0EV;;;;EAWA;;;;;;;;;;EAiBA,4BAA4B;UAqC3B;MA4BG,aAAa;EAIjB;EAMA,WAAW,SAAS;EAIpB,aAAa,SAAS,QAAQ;EAI9B,WACL,eACA,WAAW,qBACX;EA0BK,gBAAgB,oBAAoB;EAIpC,uBAAuB,YAAY;;EAKnC,oBACL,eAAe,YAAY;EAKtB,mBACL,iBAAiB,mBAAmB;;;;;;;EAyB/B,kBACL,YAAY,YAAY,MAAM,oBAC9B,6BACA;UA+HM;EAWD,oBACL,cAAc,0BAA0B;UAkElC;UAwBA;UAaA;YAOE,2BACR,YACC,6BAA6B;YAStB,yBACR,MACA,QACC,2BAA2B;UAetB;YAKU,iCAChB,KAAK,wBACF;YAGa,+BAChB,KAAK,wBACF;YAEK,0BAA0B;EAiDvB,yBAAyB,QAAQ;EAYvC,QAAQ,MAAM;UAmCb;EAQD,2BAA2B,KAChC;UAeM;;;;;;EA2CD,qBAAqB,MAAM,mBAAmB;UAwB7C;EAiCD,WACL,OAAM,8BACN,cAAa,cACZ;EAiJU,YACX,MAAM,kBACN,cAAa,cACZ,QAAQ;YAMD,iBACR,gBACA,oBACA,mBAAmB,sBAClB;UAeW;UAuBN;EA2CD,mBACL,MAAM,kBACN,QAAQ,kBACR,SAAS,mBACT;UAQM;UAqCA;UAgBA;UAuBA;EAaD,iBAAiB;UAIhB;UAIA;EAgjBD,cACL,6CACA,QAAQ,oBACP;EAyBI,cACL,QAAQ,mBACR,WAAU,mBACT;EAkDI,eACL,QAAQ,mBACR,eAAc;EAKT,kBACL,UAAU,kBACV;UAqBM;UAiEA;UA+DA;UASA"}
@@ -55,6 +55,7 @@ var DiffHunksRenderer = class {
55
55
  if (workerManager?.isWorkingPool() !== true) this.highlighter = areThemesAttached(options.theme ?? DEFAULT_THEMES) ? getHighlighterIfLoaded() : void 0;
56
56
  }
57
57
  cleanUp() {
58
+ this.endEditSession();
58
59
  this.recycle();
59
60
  this.expandedHunks.clear();
60
61
  this.workerManager = void 0;
@@ -63,11 +64,14 @@ var DiffHunksRenderer = class {
63
64
  recycle() {
64
65
  this.highlighter = void 0;
65
66
  this.diff = void 0;
66
- this.clearRenderCache();
67
+ if (this.editSessionActive) {
68
+ if (this.renderCache != null) this.renderCache.renderRange = void 0;
69
+ this.pendingHighlightResult = void 0;
70
+ this.pendingStructuralRows = void 0;
71
+ } else this.clearRenderCache();
67
72
  this.additionAnnotations = {};
68
73
  this.deletionAnnotations = {};
69
74
  this.workerManager?.cleanUpTasks(this);
70
- this.endEditSession();
71
75
  }
72
76
  /**
73
77
  * Enter edit-session mode: hunk updates preserve the current region
@@ -79,10 +83,12 @@ var DiffHunksRenderer = class {
79
83
  * empty additions document gets one row for the editor's caret.
80
84
  */
81
85
  beginEditSession(diff, externalDiff) {
82
- const { editSessionActive: wasAlreadyActive, renderCache } = this;
86
+ const { editSessionActive: wasAlreadyActive } = this;
83
87
  this.editSessionActive = true;
84
88
  if (!wasAlreadyActive) this.pendingHighlightResult = void 0;
85
89
  this.diff = diff;
90
+ if (wasAlreadyActive && this.renderCache != null && this.renderCache.diff !== diff) this.clearRenderCache();
91
+ const { renderCache } = this;
86
92
  if (!diff.isPartial && diff.additionLines.length === 0) {
87
93
  Object.assign(diff, recomputeEmptyDocumentDiff(diff, this.options.parseDiffOptions));
88
94
  this.markEditSessionPass(diff);
@@ -118,6 +124,7 @@ var DiffHunksRenderer = class {
118
124
  endEditSession() {
119
125
  this.editSessionActive = false;
120
126
  this.pendingHighlightResult = void 0;
127
+ if (this.diff == null) this.clearRenderCache();
121
128
  }
122
129
  /**
123
130
  * Ensures that the DOM is compatible with editor render updates
@@ -304,31 +311,31 @@ var DiffHunksRenderer = class {
304
311
  applyDocumentChange(textDocument) {
305
312
  const { pendingStructuralRows, renderCache } = this;
306
313
  this.pendingStructuralRows = void 0;
307
- if (renderCache == null) return;
308
- const { diff, result } = renderCache;
309
- if (result == null) return;
314
+ const diff = this.diff ?? renderCache?.diff;
315
+ if (diff == null) return;
316
+ const result = renderCache?.result;
310
317
  if (diff.isPartial) throw new Error("Could not apply document change for partial diff");
311
318
  const { additionLines: previousAdditionLines } = diff;
312
319
  diff.additionLines = getEditorDocumentLines(textDocument);
313
- result.code.additionLines = realignAdditionHastLines(previousAdditionLines, diff.additionLines, result.code.additionLines, textDocument);
320
+ if (result != null) result.code.additionLines = realignAdditionHastLines(previousAdditionLines, diff.additionLines, result.code.additionLines, textDocument);
314
321
  if (diff.additionLines.length <= 1 && diff.additionLines.join("") === "") {
315
322
  this.applyRecomputePreservingSessionType(diff, recomputeEmptyDocumentDiff(diff, this.options.parseDiffOptions));
316
- result.code.additionLines[0] = createPlainAdditionLineElement(0, textDocument.getLineText(0));
317
- } else if (this.editSessionActive) this.applySessionDocumentChange(diff);
323
+ if (result != null) result.code.additionLines[0] = createPlainAdditionLineElement(0, textDocument.getLineText(0));
324
+ } else if (this.editSessionActive) this.applySessionDocumentChange(diff, previousAdditionLines);
318
325
  else Object.assign(diff, recomputeDiffHunksForEdit(diff, this.options.parseDiffOptions));
319
- if (pendingStructuralRows != null) {
326
+ if (pendingStructuralRows != null && result != null) {
320
327
  for (const [line, row] of pendingStructuralRows) if (line < result.code.additionLines.length) result.code.additionLines[line] = row;
321
328
  }
322
- renderCache.isDirty = true;
329
+ if (renderCache != null) renderCache.isDirty = true;
323
330
  }
324
- applySessionDocumentChange(diff) {
331
+ applySessionDocumentChange(diff, previousAdditionLines) {
325
332
  const { parseDiffOptions } = this.options;
326
333
  const rawLines = diff.additionLines;
327
334
  if (shouldTopAlignAdditionRecompute(diff, rawLines)) {
328
335
  this.applyRecomputePreservingSessionType(diff, recomputeTopAlignedAdditionDiff(diff, rawLines, parseDiffOptions));
329
336
  return;
330
337
  }
331
- this.applyExpansionRemap(rebuildSessionHunks(diff, parseDiffOptions));
338
+ this.applyExpansionRemap(rebuildSessionHunks(diff, parseDiffOptions, (index) => previousAdditionLines[index]));
332
339
  }
333
340
  applyRecomputePreservingSessionType(diff, update) {
334
341
  const sessionType = this.editSessionActive ? diff.type : void 0;