@thxgg/steward 0.1.25 → 0.1.26

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 (187) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/_nuxt/{Bc2V3wPK.js → B2ow85x_.js} +2 -2
  3. package/.output/public/_nuxt/{U78rMDmo.js → B6CbIr08.js} +1 -1
  4. package/.output/public/_nuxt/{BknRrWsw.js → BLQAF8wp.js} +1 -1
  5. package/.output/public/_nuxt/BXuwtOqb.js +1 -0
  6. package/.output/public/_nuxt/CAMiEhze.js +1 -0
  7. package/.output/public/_nuxt/{BRQ9Cxaw.js → CIBCqZF5.js} +1 -1
  8. package/.output/public/_nuxt/Ce0-nlm9.js +1 -0
  9. package/.output/public/_nuxt/{T11EuTtn.js → ConzneVY.js} +1 -1
  10. package/.output/public/_nuxt/D0qxz_Pn.js +1310 -0
  11. package/.output/public/_nuxt/D3PDtLSF.js +3 -0
  12. package/.output/public/_nuxt/{C73kduX-.js → DdKC0UAK.js} +1 -1
  13. package/.output/public/_nuxt/Detail.BGdvrJGh.css +1 -0
  14. package/.output/public/_nuxt/{C53_p0K1.js → Dkh9ic1y.js} +1 -1
  15. package/.output/public/_nuxt/LEjJTR7-.js +1 -0
  16. package/.output/public/_nuxt/{BTmXUZ_s.js → UqZfMfrZ.js} +1 -1
  17. package/.output/public/_nuxt/builds/latest.json +1 -1
  18. package/.output/public/_nuxt/builds/meta/25438e34-19a2-421d-aede-53fd18f1ccd4.json +1 -0
  19. package/.output/public/_nuxt/dckrK0oj.js +1 -0
  20. package/.output/public/_nuxt/entry.DT4p6_uW.css +1 -0
  21. package/.output/public/_nuxt/pIWeVmPw.js +1 -0
  22. package/.output/public/_nuxt/xrHaPo1U.js +60 -0
  23. package/.output/server/chunks/build/{Detail-DMMUwTWr.mjs → Detail-rpcemNXe.mjs} +674 -481
  24. package/.output/server/chunks/build/Detail-rpcemNXe.mjs.map +1 -0
  25. package/.output/server/chunks/build/DiffViewer-styles.B1FB5NJj.mjs +8 -0
  26. package/.output/server/chunks/build/DiffViewer-styles.B1FB5NJj.mjs.map +1 -0
  27. package/.output/server/chunks/build/{_prd_-ByugK4Yi.mjs → _prd_-CeibvZOH.mjs} +67 -233
  28. package/.output/server/chunks/build/_prd_-CeibvZOH.mjs.map +1 -0
  29. package/.output/server/chunks/build/client.precomputed.mjs +1 -1
  30. package/.output/server/chunks/build/{default-BKKgG7HJ.mjs → default-iq8SaDDN.mjs} +3 -3
  31. package/.output/server/chunks/build/default-iq8SaDDN.mjs.map +1 -0
  32. package/.output/server/chunks/build/{error-404-Bf6kdO80.mjs → error-404-DFale9A5.mjs} +2 -2
  33. package/.output/server/chunks/build/error-404-DFale9A5.mjs.map +1 -0
  34. package/.output/server/chunks/build/{index-DE1tjHAd.mjs → index-Po00RvHm.mjs} +2 -2
  35. package/.output/server/chunks/build/index-Po00RvHm.mjs.map +1 -0
  36. package/.output/server/chunks/build/{nuxt-link-SvT1nf8Z.mjs → nuxt-link-B4oWFn7n.mjs} +2 -2
  37. package/.output/server/chunks/build/nuxt-link-B4oWFn7n.mjs.map +1 -0
  38. package/.output/server/chunks/build/{repo-graph-DzT45gSB.mjs → repo-graph-BQVFpA-w.mjs} +5 -4
  39. package/.output/server/chunks/build/repo-graph-BQVFpA-w.mjs.map +1 -0
  40. package/.output/server/chunks/build/server.mjs +7 -7
  41. package/.output/server/chunks/build/styles.mjs +4 -5
  42. package/.output/server/chunks/build/{usePrd-hXZOmvAv.mjs → usePrd-Bb6jlnNZ.mjs} +2 -2
  43. package/.output/server/chunks/build/usePrd-Bb6jlnNZ.mjs.map +1 -0
  44. package/.output/server/chunks/nitro/nitro.mjs +663 -660
  45. package/.output/server/node_modules/@pierre/diffs/dist/components/File.js +324 -0
  46. package/.output/server/node_modules/@pierre/diffs/dist/components/FileDiff.js +395 -0
  47. package/.output/server/node_modules/@pierre/diffs/dist/components/FileStream.js +161 -0
  48. package/.output/server/node_modules/@pierre/diffs/dist/components/web-components.js +25 -0
  49. package/.output/server/node_modules/@pierre/diffs/dist/constants.js +23 -0
  50. package/.output/server/node_modules/@pierre/diffs/dist/highlighter/languages/areLanguagesAttached.js +11 -0
  51. package/.output/server/node_modules/@pierre/diffs/dist/highlighter/languages/attachResolvedLanguages.js +20 -0
  52. package/.output/server/node_modules/@pierre/diffs/dist/highlighter/languages/cleanUpResolvedLanguages.js +11 -0
  53. package/.output/server/node_modules/@pierre/diffs/dist/highlighter/languages/constants.js +8 -0
  54. package/.output/server/node_modules/@pierre/diffs/dist/highlighter/languages/getResolvedLanguages.js +16 -0
  55. package/.output/server/node_modules/@pierre/diffs/dist/highlighter/languages/getResolvedOrResolveLanguage.js +11 -0
  56. package/.output/server/node_modules/@pierre/diffs/dist/highlighter/languages/hasResolvedLanguages.js +11 -0
  57. package/.output/server/node_modules/@pierre/diffs/dist/highlighter/languages/resolveLanguage.js +30 -0
  58. package/.output/server/node_modules/@pierre/diffs/dist/highlighter/languages/resolveLanguages.js +25 -0
  59. package/.output/server/node_modules/@pierre/diffs/dist/highlighter/shared_highlighter.js +71 -0
  60. package/.output/server/node_modules/@pierre/diffs/dist/highlighter/themes/areThemesAttached.js +12 -0
  61. package/.output/server/node_modules/@pierre/diffs/dist/highlighter/themes/attachResolvedThemes.js +24 -0
  62. package/.output/server/node_modules/@pierre/diffs/dist/highlighter/themes/cleanUpResolvedThemes.js +11 -0
  63. package/.output/server/node_modules/@pierre/diffs/dist/highlighter/themes/constants.js +9 -0
  64. package/.output/server/node_modules/@pierre/diffs/dist/highlighter/themes/getResolvedOrResolveTheme.js +11 -0
  65. package/.output/server/node_modules/@pierre/diffs/dist/highlighter/themes/getResolvedThemes.js +16 -0
  66. package/.output/server/node_modules/@pierre/diffs/dist/highlighter/themes/hasResolvedThemes.js +11 -0
  67. package/.output/server/node_modules/@pierre/diffs/dist/highlighter/themes/registerCustomCSSVariableTheme.js +18 -0
  68. package/.output/server/node_modules/@pierre/diffs/dist/highlighter/themes/registerCustomTheme.js +14 -0
  69. package/.output/server/node_modules/@pierre/diffs/dist/highlighter/themes/resolveTheme.js +35 -0
  70. package/.output/server/node_modules/@pierre/diffs/dist/highlighter/themes/resolveThemes.js +21 -0
  71. package/.output/server/node_modules/@pierre/diffs/dist/index.js +84 -0
  72. package/.output/server/node_modules/@pierre/diffs/dist/managers/LineSelectionManager.js +282 -0
  73. package/.output/server/node_modules/@pierre/diffs/dist/managers/MouseEventManager.js +244 -0
  74. package/.output/server/node_modules/@pierre/diffs/dist/managers/ResizeManager.js +132 -0
  75. package/.output/server/node_modules/@pierre/diffs/dist/managers/ScrollSyncManager.js +62 -0
  76. package/.output/server/node_modules/@pierre/diffs/dist/managers/UniversalRenderingManager.js +32 -0
  77. package/.output/server/node_modules/@pierre/diffs/dist/renderers/DiffHunksRenderer.js +655 -0
  78. package/.output/server/node_modules/@pierre/diffs/dist/renderers/FileRenderer.js +243 -0
  79. package/.output/server/node_modules/@pierre/diffs/dist/shiki-stream/stream.js +32 -0
  80. package/.output/server/node_modules/@pierre/diffs/dist/shiki-stream/tokenizer.js +71 -0
  81. package/.output/server/node_modules/@pierre/diffs/dist/sprite.js +55 -0
  82. package/.output/server/node_modules/@pierre/diffs/dist/style.js +6 -0
  83. package/.output/server/node_modules/@pierre/diffs/dist/themes/pierre-dark.js +1328 -0
  84. package/.output/server/node_modules/@pierre/diffs/dist/themes/pierre-light.js +1328 -0
  85. package/.output/server/node_modules/@pierre/diffs/dist/utils/areFilesEqual.js +8 -0
  86. package/.output/server/node_modules/@pierre/diffs/dist/utils/areObjectsEqual.js +18 -0
  87. package/.output/server/node_modules/@pierre/diffs/dist/utils/areOptionsEqual.js +12 -0
  88. package/.output/server/node_modules/@pierre/diffs/dist/utils/areSelectionsEqual.js +8 -0
  89. package/.output/server/node_modules/@pierre/diffs/dist/utils/areThemesEqual.js +9 -0
  90. package/.output/server/node_modules/@pierre/diffs/dist/utils/cleanLastNewline.js +8 -0
  91. package/.output/server/node_modules/@pierre/diffs/dist/utils/createAnnotationElement.js +21 -0
  92. package/.output/server/node_modules/@pierre/diffs/dist/utils/createAnnotationWrapperNode.js +12 -0
  93. package/.output/server/node_modules/@pierre/diffs/dist/utils/createCodeNode.js +12 -0
  94. package/.output/server/node_modules/@pierre/diffs/dist/utils/createEmptyRowBuffer.js +16 -0
  95. package/.output/server/node_modules/@pierre/diffs/dist/utils/createFileHeaderElement.js +84 -0
  96. package/.output/server/node_modules/@pierre/diffs/dist/utils/createHoverContentNode.js +15 -0
  97. package/.output/server/node_modules/@pierre/diffs/dist/utils/createNoNewlineElement.js +24 -0
  98. package/.output/server/node_modules/@pierre/diffs/dist/utils/createPreElement.js +28 -0
  99. package/.output/server/node_modules/@pierre/diffs/dist/utils/createRowNodes.js +20 -0
  100. package/.output/server/node_modules/@pierre/diffs/dist/utils/createSeparator.js +69 -0
  101. package/.output/server/node_modules/@pierre/diffs/dist/utils/createSpanNodeFromToken.js +13 -0
  102. package/.output/server/node_modules/@pierre/diffs/dist/utils/createStyleElement.js +19 -0
  103. package/.output/server/node_modules/@pierre/diffs/dist/utils/createTransformerWithState.js +56 -0
  104. package/.output/server/node_modules/@pierre/diffs/dist/utils/createUnsafeCSSStyleNode.js +12 -0
  105. package/.output/server/node_modules/@pierre/diffs/dist/utils/cssWrappers.js +21 -0
  106. package/.output/server/node_modules/@pierre/diffs/dist/utils/diffAcceptRejectHunk.js +82 -0
  107. package/.output/server/node_modules/@pierre/diffs/dist/utils/formatCSSVariablePrefix.js +8 -0
  108. package/.output/server/node_modules/@pierre/diffs/dist/utils/getFiletypeFromFileName.js +343 -0
  109. package/.output/server/node_modules/@pierre/diffs/dist/utils/getHighlighterOptions.js +13 -0
  110. package/.output/server/node_modules/@pierre/diffs/dist/utils/getHighlighterThemeStyles.js +40 -0
  111. package/.output/server/node_modules/@pierre/diffs/dist/utils/getHunkSeparatorSlotName.js +8 -0
  112. package/.output/server/node_modules/@pierre/diffs/dist/utils/getIconForType.js +15 -0
  113. package/.output/server/node_modules/@pierre/diffs/dist/utils/getLineAnnotationName.js +8 -0
  114. package/.output/server/node_modules/@pierre/diffs/dist/utils/getLineEndingType.js +11 -0
  115. package/.output/server/node_modules/@pierre/diffs/dist/utils/getLineNodes.js +15 -0
  116. package/.output/server/node_modules/@pierre/diffs/dist/utils/getSingularPatch.js +20 -0
  117. package/.output/server/node_modules/@pierre/diffs/dist/utils/getThemes.js +16 -0
  118. package/.output/server/node_modules/@pierre/diffs/dist/utils/getTotalLineCountFromHunks.js +10 -0
  119. package/.output/server/node_modules/@pierre/diffs/dist/utils/hast_utils.js +42 -0
  120. package/.output/server/node_modules/@pierre/diffs/dist/utils/isWorkerContext.js +8 -0
  121. package/.output/server/node_modules/@pierre/diffs/dist/utils/parseDiffDecorations.js +34 -0
  122. package/.output/server/node_modules/@pierre/diffs/dist/utils/parseDiffFromFile.js +23 -0
  123. package/.output/server/node_modules/@pierre/diffs/dist/utils/parseLineType.js +17 -0
  124. package/.output/server/node_modules/@pierre/diffs/dist/utils/parsePatchFiles.js +211 -0
  125. package/.output/server/node_modules/@pierre/diffs/dist/utils/prerenderHTMLIfNecessary.js +10 -0
  126. package/.output/server/node_modules/@pierre/diffs/dist/utils/processLine.js +42 -0
  127. package/.output/server/node_modules/@pierre/diffs/dist/utils/renderDiffWithHighlighter.js +339 -0
  128. package/.output/server/node_modules/@pierre/diffs/dist/utils/renderFileWithHighlighter.js +52 -0
  129. package/.output/server/node_modules/@pierre/diffs/dist/utils/setLanguageOverride.js +11 -0
  130. package/.output/server/node_modules/@pierre/diffs/dist/utils/setWrapperNodeProps.js +29 -0
  131. package/.output/server/node_modules/@pierre/diffs/package.json +89 -0
  132. package/.output/server/node_modules/@shikijs/transformers/dist/index.mjs +831 -0
  133. package/.output/server/node_modules/@shikijs/transformers/package.json +37 -0
  134. package/.output/server/node_modules/diff/libesm/convert/dmp.js +21 -0
  135. package/.output/server/node_modules/diff/libesm/convert/xml.js +31 -0
  136. package/.output/server/node_modules/diff/libesm/diff/array.js +16 -0
  137. package/.output/server/node_modules/diff/libesm/diff/base.js +253 -0
  138. package/.output/server/node_modules/diff/libesm/diff/character.js +7 -0
  139. package/.output/server/node_modules/diff/libesm/diff/css.js +10 -0
  140. package/.output/server/node_modules/diff/libesm/diff/json.js +78 -0
  141. package/.output/server/node_modules/diff/libesm/diff/line.js +65 -0
  142. package/.output/server/node_modules/diff/libesm/diff/sentence.js +43 -0
  143. package/.output/server/node_modules/diff/libesm/diff/word.js +296 -0
  144. package/.output/server/node_modules/diff/libesm/index.js +30 -0
  145. package/.output/server/node_modules/diff/libesm/package.json +1 -0
  146. package/.output/server/node_modules/diff/libesm/patch/apply.js +257 -0
  147. package/.output/server/node_modules/diff/libesm/patch/create.js +228 -0
  148. package/.output/server/node_modules/diff/libesm/patch/line-endings.js +44 -0
  149. package/.output/server/node_modules/diff/libesm/patch/parse.js +147 -0
  150. package/.output/server/node_modules/diff/libesm/patch/reverse.js +23 -0
  151. package/.output/server/node_modules/diff/libesm/util/distance-iterator.js +37 -0
  152. package/.output/server/node_modules/diff/libesm/util/params.js +14 -0
  153. package/.output/server/node_modules/diff/libesm/util/string.js +128 -0
  154. package/.output/server/node_modules/diff/package.json +132 -0
  155. package/.output/server/package.json +4 -1
  156. package/dist/server/utils/git.js +8 -6
  157. package/package.json +2 -1
  158. package/.output/public/_nuxt/6tINjQEd.js +0 -141
  159. package/.output/public/_nuxt/B2mIQf5X.js +0 -3
  160. package/.output/public/_nuxt/C0BBSDJ7.js +0 -1
  161. package/.output/public/_nuxt/CN46Bgts.js +0 -1
  162. package/.output/public/_nuxt/CTJgb0zb.js +0 -1
  163. package/.output/public/_nuxt/Cce168lk.js +0 -30
  164. package/.output/public/_nuxt/CyVSeLw5.js +0 -1
  165. package/.output/public/_nuxt/Detail.CYc96mGf.css +0 -1
  166. package/.output/public/_nuxt/ZNypZshD.js +0 -13
  167. package/.output/public/_nuxt/builds/meta/9ce7f1bc-d5e2-47bf-8026-f4910c257b2e.json +0 -1
  168. package/.output/public/_nuxt/entry.Bw0CE6Iz.css +0 -1
  169. package/.output/public/_nuxt/pYJYAY-W.js +0 -60
  170. package/.output/server/chunks/build/Detail-DMMUwTWr.mjs.map +0 -1
  171. package/.output/server/chunks/build/DiffViewer-styles-1.mjs-d2dQvARr.mjs +0 -4
  172. package/.output/server/chunks/build/DiffViewer-styles-1.mjs-d2dQvARr.mjs.map +0 -1
  173. package/.output/server/chunks/build/DiffViewer-styles-2.mjs-X6QKNjM0.mjs +0 -4
  174. package/.output/server/chunks/build/DiffViewer-styles-2.mjs-X6QKNjM0.mjs.map +0 -1
  175. package/.output/server/chunks/build/DiffViewer-styles.0AbHFl6N.mjs +0 -8
  176. package/.output/server/chunks/build/DiffViewer-styles.0AbHFl6N.mjs.map +0 -1
  177. package/.output/server/chunks/build/DiffViewer-styles.BDwAqkTk.mjs +0 -8
  178. package/.output/server/chunks/build/DiffViewer-styles.BDwAqkTk.mjs.map +0 -1
  179. package/.output/server/chunks/build/DiffViewer-styles.DRJh5Ui4.mjs +0 -10
  180. package/.output/server/chunks/build/DiffViewer-styles.DRJh5Ui4.mjs.map +0 -1
  181. package/.output/server/chunks/build/_prd_-ByugK4Yi.mjs.map +0 -1
  182. package/.output/server/chunks/build/default-BKKgG7HJ.mjs.map +0 -1
  183. package/.output/server/chunks/build/error-404-Bf6kdO80.mjs.map +0 -1
  184. package/.output/server/chunks/build/index-DE1tjHAd.mjs.map +0 -1
  185. package/.output/server/chunks/build/nuxt-link-SvT1nf8Z.mjs.map +0 -1
  186. package/.output/server/chunks/build/repo-graph-DzT45gSB.mjs.map +0 -1
  187. package/.output/server/chunks/build/usePrd-hXZOmvAv.mjs.map +0 -1
@@ -0,0 +1,655 @@
1
+ import { DEFAULT_THEMES } from "../constants.js";
2
+ import { areLanguagesAttached } from "../highlighter/languages/areLanguagesAttached.js";
3
+ import { getHighlighterIfLoaded, getSharedHighlighter } from "../highlighter/shared_highlighter.js";
4
+ import { areThemesAttached } from "../highlighter/themes/areThemesAttached.js";
5
+ import { areThemesEqual } from "../utils/areThemesEqual.js";
6
+ import { createHastElement } from "../utils/hast_utils.js";
7
+ import { createAnnotationElement } from "../utils/createAnnotationElement.js";
8
+ import { createFileHeaderElement } from "../utils/createFileHeaderElement.js";
9
+ import { createPreElement } from "../utils/createPreElement.js";
10
+ import { getFiletypeFromFileName } from "../utils/getFiletypeFromFileName.js";
11
+ import { getHighlighterOptions } from "../utils/getHighlighterOptions.js";
12
+ import { getLineAnnotationName } from "../utils/getLineAnnotationName.js";
13
+ import { createEmptyRowBuffer } from "../utils/createEmptyRowBuffer.js";
14
+ import { createNoNewlineElement } from "../utils/createNoNewlineElement.js";
15
+ import { createSeparator } from "../utils/createSeparator.js";
16
+ import { getHunkSeparatorSlotName } from "../utils/getHunkSeparatorSlotName.js";
17
+ import { getTotalLineCountFromHunks } from "../utils/getTotalLineCountFromHunks.js";
18
+ import { renderDiffWithHighlighter } from "../utils/renderDiffWithHighlighter.js";
19
+ import { toHtml } from "hast-util-to-html";
20
+
21
+ //#region src/renderers/DiffHunksRenderer.ts
22
+ const EXPANDED_REGION = {
23
+ fromStart: 0,
24
+ fromEnd: 0
25
+ };
26
+ var DiffHunksRenderer = class {
27
+ highlighter;
28
+ diff;
29
+ expandedHunks = /* @__PURE__ */ new Map();
30
+ deletionAnnotations = {};
31
+ additionAnnotations = {};
32
+ computedLang = "text";
33
+ renderCache;
34
+ constructor(options = { theme: DEFAULT_THEMES }, onRenderUpdate, workerManager) {
35
+ this.options = options;
36
+ this.onRenderUpdate = onRenderUpdate;
37
+ this.workerManager = workerManager;
38
+ if (workerManager?.isWorkingPool() !== true) this.highlighter = areThemesAttached(options.theme ?? DEFAULT_THEMES) ? getHighlighterIfLoaded() : void 0;
39
+ }
40
+ cleanUp() {
41
+ this.highlighter = void 0;
42
+ this.diff = void 0;
43
+ this.renderCache = void 0;
44
+ this.workerManager = void 0;
45
+ this.onRenderUpdate = void 0;
46
+ }
47
+ setOptions(options) {
48
+ this.options = options;
49
+ }
50
+ mergeOptions(options) {
51
+ this.options = {
52
+ ...this.options,
53
+ ...options
54
+ };
55
+ }
56
+ setThemeType(themeType) {
57
+ if (this.getOptionsWithDefaults().themeType === themeType) return;
58
+ this.mergeOptions({ themeType });
59
+ }
60
+ expandHunk(index, direction) {
61
+ const { expansionLineCount } = this.getOptionsWithDefaults();
62
+ const region = this.expandedHunks.get(index) ?? {
63
+ fromStart: 0,
64
+ fromEnd: 0
65
+ };
66
+ if (direction === "up" || direction === "both") region.fromStart += expansionLineCount;
67
+ if (direction === "down" || direction === "both") region.fromEnd += expansionLineCount;
68
+ this.expandedHunks.set(index, region);
69
+ }
70
+ setLineAnnotations(lineAnnotations) {
71
+ this.additionAnnotations = {};
72
+ this.deletionAnnotations = {};
73
+ for (const annotation of lineAnnotations) {
74
+ const map = (() => {
75
+ switch (annotation.side) {
76
+ case "deletions": return this.deletionAnnotations;
77
+ case "additions": return this.additionAnnotations;
78
+ }
79
+ })();
80
+ const arr = map[annotation.lineNumber] ?? [];
81
+ map[annotation.lineNumber] = arr;
82
+ arr.push(annotation);
83
+ }
84
+ }
85
+ getOptionsWithDefaults() {
86
+ const { diffIndicators = "bars", diffStyle = "split", disableBackground = false, disableFileHeader = false, disableLineNumbers = false, expandUnchanged = false, expansionLineCount = 100, hunkSeparators = "line-info", lineDiffType = "word-alt", maxLineDiffLength = 1e3, overflow = "scroll", theme = DEFAULT_THEMES, themeType = "system", tokenizeMaxLineLength = 1e3, useCSSClasses = false } = this.options;
87
+ return {
88
+ diffIndicators,
89
+ diffStyle,
90
+ disableBackground,
91
+ disableFileHeader,
92
+ disableLineNumbers,
93
+ expandUnchanged,
94
+ expansionLineCount,
95
+ hunkSeparators,
96
+ lineDiffType,
97
+ maxLineDiffLength,
98
+ overflow,
99
+ theme: this.workerManager?.getDiffRenderOptions().theme ?? theme,
100
+ themeType,
101
+ tokenizeMaxLineLength,
102
+ useCSSClasses
103
+ };
104
+ }
105
+ async initializeHighlighter() {
106
+ this.highlighter = await getSharedHighlighter(getHighlighterOptions(this.computedLang, this.options));
107
+ return this.highlighter;
108
+ }
109
+ hydrate(diff) {
110
+ if (diff == null) return;
111
+ this.diff = diff;
112
+ const { options } = this.getRenderOptions(diff);
113
+ let cache = this.workerManager?.getDiffResultCache(diff);
114
+ if (cache != null && !areRenderOptionsEqual(options, cache.options)) cache = void 0;
115
+ this.renderCache ??= {
116
+ diff,
117
+ highlighted: true,
118
+ options,
119
+ result: cache?.result
120
+ };
121
+ if (this.workerManager?.isWorkingPool() === true && this.renderCache.result == null) this.workerManager.highlightDiffAST(this, this.diff);
122
+ else this.asyncHighlight(diff).then(({ result, options: options$1 }) => {
123
+ this.onHighlightSuccess(diff, result, options$1);
124
+ });
125
+ }
126
+ getRenderOptions(diff) {
127
+ const options = (() => {
128
+ if (this.workerManager?.isWorkingPool() === true) return this.workerManager.getDiffRenderOptions();
129
+ const { theme, tokenizeMaxLineLength, lineDiffType } = this.getOptionsWithDefaults();
130
+ return {
131
+ theme,
132
+ tokenizeMaxLineLength,
133
+ lineDiffType
134
+ };
135
+ })();
136
+ this.getOptionsWithDefaults();
137
+ const { renderCache } = this;
138
+ if (renderCache?.result == null) return {
139
+ options,
140
+ forceRender: true
141
+ };
142
+ if (diff !== renderCache.diff || !areRenderOptionsEqual(options, renderCache.options)) return {
143
+ options,
144
+ forceRender: true
145
+ };
146
+ return {
147
+ options,
148
+ forceRender: false
149
+ };
150
+ }
151
+ renderDiff(diff = this.renderCache?.diff) {
152
+ if (diff == null) return;
153
+ const cache = this.workerManager?.getDiffResultCache(diff);
154
+ if (cache != null && this.renderCache == null) this.renderCache = {
155
+ diff,
156
+ highlighted: true,
157
+ ...cache
158
+ };
159
+ const { options, forceRender } = this.getRenderOptions(diff);
160
+ this.renderCache ??= {
161
+ diff,
162
+ highlighted: false,
163
+ options,
164
+ result: void 0
165
+ };
166
+ if (this.workerManager?.isWorkingPool() === true) {
167
+ this.renderCache.result ??= this.workerManager.getPlainDiffAST(diff);
168
+ if (!this.renderCache.highlighted || forceRender) this.workerManager.highlightDiffAST(this, diff);
169
+ } else {
170
+ this.computedLang = diff.lang ?? getFiletypeFromFileName(diff.name);
171
+ const hasThemes = this.highlighter != null && areThemesAttached(options.theme);
172
+ const hasLangs = this.highlighter != null && areLanguagesAttached(this.computedLang);
173
+ if (this.highlighter != null && hasThemes && (forceRender || !this.renderCache.highlighted && hasLangs || this.renderCache.result == null)) {
174
+ const { result, options: options$1 } = this.renderDiffWithHighlighter(diff, this.highlighter, !hasLangs);
175
+ this.renderCache = {
176
+ diff,
177
+ options: options$1,
178
+ highlighted: hasLangs,
179
+ result
180
+ };
181
+ }
182
+ if (!hasThemes || !hasLangs) this.asyncHighlight(diff).then(({ result, options: options$1 }) => {
183
+ this.onHighlightSuccess(diff, result, options$1);
184
+ });
185
+ }
186
+ return this.renderCache.result != null ? this.processDiffResult(this.renderCache.diff, this.renderCache.result) : void 0;
187
+ }
188
+ async asyncRender(diff) {
189
+ const { result } = await this.asyncHighlight(diff);
190
+ return this.processDiffResult(diff, result);
191
+ }
192
+ createPreElement(split, totalLines, themeStyles, baseThemeType) {
193
+ const { diffIndicators, disableBackground, disableLineNumbers, overflow, themeType } = this.getOptionsWithDefaults();
194
+ return createPreElement({
195
+ diffIndicators,
196
+ disableBackground,
197
+ disableLineNumbers,
198
+ overflow,
199
+ themeStyles,
200
+ split,
201
+ themeType: baseThemeType ?? themeType,
202
+ totalLines
203
+ });
204
+ }
205
+ async asyncHighlight(diff) {
206
+ this.computedLang = diff.lang ?? getFiletypeFromFileName(diff.name);
207
+ const hasThemes = this.highlighter != null && areThemesAttached(this.options.theme ?? DEFAULT_THEMES);
208
+ const hasLangs = this.highlighter != null && areLanguagesAttached(this.computedLang);
209
+ if (this.highlighter == null || !hasThemes || !hasLangs) this.highlighter = await this.initializeHighlighter();
210
+ return this.renderDiffWithHighlighter(diff, this.highlighter);
211
+ }
212
+ renderDiffWithHighlighter(diff, highlighter, plainText = false) {
213
+ const { options } = this.getRenderOptions(diff);
214
+ return {
215
+ result: renderDiffWithHighlighter(diff, highlighter, options, plainText),
216
+ options
217
+ };
218
+ }
219
+ onHighlightSuccess(diff, result, options) {
220
+ if (this.renderCache == null) return;
221
+ const triggerRenderUpdate = this.renderCache.diff !== diff || !this.renderCache.highlighted || !areRenderOptionsEqual(this.renderCache.options, options);
222
+ this.renderCache = {
223
+ diff,
224
+ options,
225
+ highlighted: true,
226
+ result
227
+ };
228
+ if (triggerRenderUpdate) this.onRenderUpdate?.();
229
+ }
230
+ onHighlightError(error) {
231
+ console.error(error);
232
+ }
233
+ processDiffResult(fileDiff, { code, themeStyles, baseThemeType }) {
234
+ const { diffStyle, disableFileHeader } = this.getOptionsWithDefaults();
235
+ this.diff = fileDiff;
236
+ const unified = diffStyle === "unified";
237
+ let additionsAST = [];
238
+ let deletionsAST = [];
239
+ let unifiedAST = [];
240
+ let hunkIndex = 0;
241
+ const hunkData = [];
242
+ let prevHunk;
243
+ let lineIndex = 0;
244
+ for (const hunk of fileDiff.hunks) {
245
+ lineIndex += hunk.collapsedBefore;
246
+ lineIndex = this.renderHunks({
247
+ ast: code,
248
+ hunk,
249
+ prevHunk,
250
+ hunkIndex,
251
+ isLastHunk: hunkIndex === fileDiff.hunks.length - 1,
252
+ additionsAST,
253
+ deletionsAST,
254
+ unifiedAST,
255
+ hunkData,
256
+ lineIndex
257
+ });
258
+ hunkIndex++;
259
+ prevHunk = hunk;
260
+ }
261
+ const totalLines = Math.max(getTotalLineCountFromHunks(fileDiff.hunks), fileDiff.newLines?.length ?? 0, fileDiff.oldLines?.length ?? 0);
262
+ additionsAST = !unified && (code.hunks != null || code.newLines.length > 0) ? additionsAST : void 0;
263
+ deletionsAST = !unified && (code.hunks != null || code.oldLines.length > 0) ? deletionsAST : void 0;
264
+ unifiedAST = unifiedAST.length > 0 ? unifiedAST : void 0;
265
+ const preNode = this.createPreElement(deletionsAST != null && additionsAST != null, totalLines, themeStyles, baseThemeType);
266
+ return {
267
+ additionsAST,
268
+ deletionsAST,
269
+ unifiedAST,
270
+ hunkData,
271
+ preNode,
272
+ themeStyles,
273
+ baseThemeType,
274
+ headerElement: !disableFileHeader ? this.renderHeader(this.diff, themeStyles, baseThemeType) : void 0,
275
+ totalLines,
276
+ css: ""
277
+ };
278
+ }
279
+ renderFullAST(result, children = []) {
280
+ if (result.unifiedAST != null) children.push(createHastElement({
281
+ tagName: "code",
282
+ children: result.unifiedAST,
283
+ properties: {
284
+ "data-code": "",
285
+ "data-unified": ""
286
+ }
287
+ }));
288
+ if (result.deletionsAST != null) children.push(createHastElement({
289
+ tagName: "code",
290
+ children: result.deletionsAST,
291
+ properties: {
292
+ "data-code": "",
293
+ "data-deletions": ""
294
+ }
295
+ }));
296
+ if (result.additionsAST != null) children.push(createHastElement({
297
+ tagName: "code",
298
+ children: result.additionsAST,
299
+ properties: {
300
+ "data-code": "",
301
+ "data-additions": ""
302
+ }
303
+ }));
304
+ return {
305
+ ...result.preNode,
306
+ children
307
+ };
308
+ }
309
+ renderFullHTML(result, tempChildren = []) {
310
+ return toHtml(this.renderFullAST(result, tempChildren));
311
+ }
312
+ renderPartialHTML(children, columnType) {
313
+ if (columnType == null) return toHtml(children);
314
+ return toHtml(createHastElement({
315
+ tagName: "code",
316
+ children,
317
+ properties: {
318
+ "data-code": "",
319
+ [`data-${columnType}`]: ""
320
+ }
321
+ }));
322
+ }
323
+ renderCollapsedHunks({ ast, hunkData, hunkIndex, hunkSpecs, isFirstHunk, isLastHunk, rangeSize, lineIndex, additionLineNumber, deletionLineNumber, unifiedAST, deletionsAST, additionsAST }) {
324
+ if (rangeSize <= 0) return;
325
+ const { hunkSeparators, expandUnchanged, diffStyle, expansionLineCount } = this.getOptionsWithDefaults();
326
+ const expandable = ast.hunks == null && ast.newLines.length > 0 && ast.oldLines.length > 0;
327
+ const expandedRegion = this.expandedHunks.get(hunkIndex) ?? EXPANDED_REGION;
328
+ const chunked = rangeSize > expansionLineCount;
329
+ const collapsedLines = Math.max(!expandUnchanged ? rangeSize - (expandedRegion.fromEnd + expandedRegion.fromStart) : 0, 0);
330
+ const pushHunkSeparator = ({ type, linesAST }) => {
331
+ if (hunkSeparators === "line-info" || hunkSeparators === "custom") {
332
+ const slotName = getHunkSeparatorSlotName(type, hunkIndex);
333
+ linesAST.push(createSeparator({
334
+ type: hunkSeparators,
335
+ content: getModifiedLinesString(collapsedLines),
336
+ expandIndex: expandable ? hunkIndex : void 0,
337
+ chunked,
338
+ slotName,
339
+ isFirstHunk,
340
+ isLastHunk
341
+ }));
342
+ hunkData.push({
343
+ slotName,
344
+ hunkIndex,
345
+ lines: collapsedLines,
346
+ type,
347
+ expandable: expandable ? {
348
+ up: expandable && !isFirstHunk,
349
+ down: expandable,
350
+ chunked
351
+ } : void 0
352
+ });
353
+ } else if (hunkSeparators === "metadata" && hunkSpecs != null) linesAST.push(createSeparator({
354
+ type: "metadata",
355
+ content: hunkSpecs,
356
+ isFirstHunk,
357
+ isLastHunk
358
+ }));
359
+ else if (hunkSeparators === "simple" && hunkIndex > 0) linesAST.push(createSeparator({
360
+ type: "simple",
361
+ isFirstHunk,
362
+ isLastHunk: false
363
+ }));
364
+ };
365
+ const renderRange = ({ rangeLen, fromStart }) => {
366
+ if (ast.newLines == null || ast.oldLines == null) return;
367
+ const offset = isLastHunk ? 0 : fromStart ? rangeSize : rangeLen;
368
+ let dLineNumber = deletionLineNumber - offset;
369
+ let aLineNumber = additionLineNumber - offset;
370
+ let lIndex = lineIndex - offset;
371
+ for (let i = 0; i < rangeLen; i++) {
372
+ const oldLine = ast.oldLines[dLineNumber];
373
+ const newLine = ast.newLines[aLineNumber];
374
+ if (oldLine == null || newLine == null) {
375
+ console.error({
376
+ aLineNumber,
377
+ dLineNumber,
378
+ ast
379
+ });
380
+ throw new Error("DiffHunksRenderer.renderHunks prefill context invalid. Must include data for old and new lines");
381
+ }
382
+ dLineNumber++;
383
+ aLineNumber++;
384
+ if (diffStyle === "unified") this.pushLineWithAnnotation({
385
+ newLine,
386
+ unifiedAST,
387
+ unifiedSpan: this.getAnnotations("unified", dLineNumber, aLineNumber, hunkIndex, lIndex)
388
+ });
389
+ else this.pushLineWithAnnotation({
390
+ newLine,
391
+ oldLine,
392
+ additionsAST,
393
+ deletionsAST,
394
+ ...this.getAnnotations("split", dLineNumber, aLineNumber, hunkIndex, lIndex)
395
+ });
396
+ lIndex++;
397
+ }
398
+ };
399
+ if (expandable) renderRange({
400
+ rangeLen: Math.min(collapsedLines === 0 || expandUnchanged ? rangeSize : expandedRegion.fromStart, rangeSize),
401
+ fromStart: true
402
+ });
403
+ if (collapsedLines > 0) if (diffStyle === "unified") pushHunkSeparator({
404
+ type: "unified",
405
+ linesAST: unifiedAST
406
+ });
407
+ else {
408
+ pushHunkSeparator({
409
+ type: "deletions",
410
+ linesAST: deletionsAST
411
+ });
412
+ pushHunkSeparator({
413
+ type: "additions",
414
+ linesAST: additionsAST
415
+ });
416
+ }
417
+ if (collapsedLines > 0 && expandedRegion.fromEnd > 0 && !isLastHunk) renderRange({
418
+ rangeLen: Math.min(expandedRegion.fromEnd, rangeSize),
419
+ fromStart: false
420
+ });
421
+ }
422
+ renderHunks({ hunk, hunkData, hunkIndex, lineIndex, isLastHunk, prevHunk, ast, deletionsAST, additionsAST, unifiedAST }) {
423
+ const { diffStyle } = this.getOptionsWithDefaults();
424
+ const unified = diffStyle === "unified";
425
+ let additionLineNumber = hunk.additionStart - 1;
426
+ let deletionLineNumber = hunk.deletionStart - 1;
427
+ this.renderCollapsedHunks({
428
+ additionLineNumber,
429
+ additionsAST,
430
+ ast,
431
+ deletionLineNumber,
432
+ deletionsAST,
433
+ hunkData,
434
+ hunkIndex,
435
+ hunkSpecs: hunk.hunkSpecs,
436
+ isFirstHunk: prevHunk == null,
437
+ isLastHunk: false,
438
+ lineIndex,
439
+ rangeSize: Math.max(hunk.collapsedBefore, 0),
440
+ unifiedAST
441
+ });
442
+ let { oldLines, newLines, oldIndex, newIndex } = (() => {
443
+ if (ast.hunks != null) {
444
+ const lineHunk = ast.hunks[hunkIndex];
445
+ if (lineHunk == null) {
446
+ console.error({
447
+ ast,
448
+ hunkIndex
449
+ });
450
+ throw new Error(`DiffHunksRenderer.renderHunks: lineHunk doesn't exist`);
451
+ }
452
+ return {
453
+ oldLines: lineHunk.oldLines,
454
+ newLines: lineHunk.newLines,
455
+ oldIndex: 0,
456
+ newIndex: 0
457
+ };
458
+ }
459
+ return {
460
+ oldLines: ast.oldLines,
461
+ newLines: ast.newLines,
462
+ oldIndex: deletionLineNumber,
463
+ newIndex: additionLineNumber
464
+ };
465
+ })();
466
+ for (const hunkContent of hunk.hunkContent) if (hunkContent.type === "context") {
467
+ const { length: len } = hunkContent.lines;
468
+ for (let i = 0; i < len; i++) {
469
+ const oldLine = oldLines[oldIndex];
470
+ const newLine = newLines[newIndex];
471
+ oldIndex++;
472
+ newIndex++;
473
+ additionLineNumber++;
474
+ deletionLineNumber++;
475
+ if (unified) {
476
+ if (newLine == null) throw new Error("DiffHunksRenderer.renderHunks: newLine doesnt exist for context...");
477
+ this.pushLineWithAnnotation({
478
+ newLine,
479
+ unifiedAST,
480
+ unifiedSpan: this.getAnnotations("unified", deletionLineNumber, additionLineNumber, hunkIndex, lineIndex)
481
+ });
482
+ } else {
483
+ if (newLine == null || oldLine == null) throw new Error("DiffHunksRenderer.renderHunks: newLine or oldLine doesnt exist for context...");
484
+ this.pushLineWithAnnotation({
485
+ oldLine,
486
+ newLine,
487
+ deletionsAST,
488
+ additionsAST,
489
+ ...this.getAnnotations("split", deletionLineNumber, additionLineNumber, hunkIndex, lineIndex)
490
+ });
491
+ }
492
+ lineIndex++;
493
+ }
494
+ if (hunkContent.noEOFCR) {
495
+ const node = createNoNewlineElement("context");
496
+ if (unified) unifiedAST.push(node);
497
+ else {
498
+ deletionsAST.push(node);
499
+ additionsAST.push(node);
500
+ }
501
+ }
502
+ } else {
503
+ const { length: dLen } = hunkContent.deletions;
504
+ const { length: aLen } = hunkContent.additions;
505
+ const len = unified ? dLen + aLen : Math.max(dLen, aLen);
506
+ let spanSize = 0;
507
+ for (let i = 0; i < len; i++) {
508
+ const { oldLine, newLine } = (() => {
509
+ let oldLine$1 = oldLines[oldIndex];
510
+ let newLine$1 = newLines[newIndex];
511
+ if (unified) if (i < dLen) newLine$1 = void 0;
512
+ else oldLine$1 = void 0;
513
+ else {
514
+ if (i >= dLen) oldLine$1 = void 0;
515
+ if (i >= aLen) newLine$1 = void 0;
516
+ }
517
+ if (oldLine$1 == null && newLine$1 == null) {
518
+ console.error({
519
+ i,
520
+ len,
521
+ ast,
522
+ hunkContent
523
+ });
524
+ throw new Error("renderHunks: oldLine and newLine are null, something is wrong");
525
+ }
526
+ return {
527
+ oldLine: oldLine$1,
528
+ newLine: newLine$1
529
+ };
530
+ })();
531
+ if (oldLine != null) {
532
+ oldIndex++;
533
+ deletionLineNumber++;
534
+ }
535
+ if (newLine != null) {
536
+ newIndex++;
537
+ additionLineNumber++;
538
+ }
539
+ if (unified) {
540
+ this.pushLineWithAnnotation({
541
+ oldLine,
542
+ newLine,
543
+ unifiedAST,
544
+ unifiedSpan: this.getAnnotations("unified", oldLine != null ? deletionLineNumber : void 0, newLine != null ? additionLineNumber : void 0, hunkIndex, lineIndex)
545
+ });
546
+ lineIndex++;
547
+ } else {
548
+ if (oldLine == null || newLine == null) spanSize++;
549
+ const annotationSpans = this.getAnnotations("split", oldLine != null ? deletionLineNumber : void 0, newLine != null ? additionLineNumber : void 0, hunkIndex, lineIndex);
550
+ if (annotationSpans != null) {
551
+ if (spanSize > 0) {
552
+ if (aLen > dLen) deletionsAST.push(createEmptyRowBuffer(spanSize));
553
+ else additionsAST.push(createEmptyRowBuffer(spanSize));
554
+ spanSize = 0;
555
+ }
556
+ }
557
+ this.pushLineWithAnnotation({
558
+ newLine,
559
+ oldLine,
560
+ deletionsAST,
561
+ additionsAST,
562
+ ...annotationSpans
563
+ });
564
+ lineIndex++;
565
+ }
566
+ }
567
+ if (!unified) {
568
+ if (spanSize > 0) {
569
+ if (aLen > dLen) deletionsAST.push(createEmptyRowBuffer(spanSize));
570
+ else additionsAST.push(createEmptyRowBuffer(spanSize));
571
+ spanSize = 0;
572
+ }
573
+ if (hunkContent.noEOFCRDeletions) {
574
+ deletionsAST.push(createNoNewlineElement("change-deletion"));
575
+ if (!hunkContent.noEOFCRAdditions) additionsAST.push(createEmptyRowBuffer(1));
576
+ }
577
+ if (hunkContent.noEOFCRAdditions) {
578
+ additionsAST.push(createNoNewlineElement("change-addition"));
579
+ if (!hunkContent.noEOFCRDeletions) deletionsAST.push(createEmptyRowBuffer(1));
580
+ }
581
+ }
582
+ }
583
+ if (isLastHunk && ast.newLines != null && ast.newLines.length > 0) this.renderCollapsedHunks({
584
+ additionLineNumber,
585
+ additionsAST,
586
+ ast,
587
+ deletionLineNumber,
588
+ deletionsAST,
589
+ hunkData,
590
+ hunkIndex: hunkIndex + 1,
591
+ hunkSpecs: void 0,
592
+ isFirstHunk: false,
593
+ isLastHunk: true,
594
+ lineIndex,
595
+ rangeSize: Math.max(ast.newLines.length - Math.max(hunk.additionStart + hunk.additionCount - 1, 0), 0),
596
+ unifiedAST
597
+ });
598
+ return lineIndex;
599
+ }
600
+ pushLineWithAnnotation({ newLine, oldLine, unifiedAST, additionsAST, deletionsAST, unifiedSpan, deletionSpan, additionSpan }) {
601
+ if (unifiedAST != null) {
602
+ if (oldLine != null) unifiedAST.push(oldLine);
603
+ else if (newLine != null) unifiedAST.push(newLine);
604
+ if (unifiedSpan != null) unifiedAST.push(createAnnotationElement(unifiedSpan));
605
+ } else if (deletionsAST != null && additionsAST != null) {
606
+ if (oldLine != null) deletionsAST.push(oldLine);
607
+ if (newLine != null) additionsAST.push(newLine);
608
+ if (deletionSpan != null) deletionsAST.push(createAnnotationElement(deletionSpan));
609
+ if (additionSpan != null) additionsAST.push(createAnnotationElement(additionSpan));
610
+ }
611
+ }
612
+ getAnnotations(type, oldLineNumber, newLineNumber, hunkIndex, lineIndex) {
613
+ const deletionSpan = {
614
+ type: "annotation",
615
+ hunkIndex,
616
+ lineIndex,
617
+ annotations: []
618
+ };
619
+ if (oldLineNumber != null) for (const anno of this.deletionAnnotations[oldLineNumber] ?? []) deletionSpan.annotations.push(getLineAnnotationName(anno));
620
+ const additionSpan = {
621
+ type: "annotation",
622
+ hunkIndex,
623
+ lineIndex,
624
+ annotations: []
625
+ };
626
+ if (newLineNumber != null) for (const anno of this.additionAnnotations[newLineNumber] ?? []) (type === "unified" ? deletionSpan : additionSpan).annotations.push(getLineAnnotationName(anno));
627
+ if (type === "unified") {
628
+ if (deletionSpan.annotations.length > 0) return deletionSpan;
629
+ return;
630
+ }
631
+ if (additionSpan.annotations.length === 0 && deletionSpan.annotations.length === 0) return;
632
+ return {
633
+ deletionSpan,
634
+ additionSpan
635
+ };
636
+ }
637
+ renderHeader(diff, themeStyles, baseThemeType) {
638
+ const { themeType } = this.getOptionsWithDefaults();
639
+ return createFileHeaderElement({
640
+ fileOrDiff: diff,
641
+ themeStyles,
642
+ themeType: baseThemeType ?? themeType
643
+ });
644
+ }
645
+ };
646
+ function areRenderOptionsEqual(optionsA, optionsB) {
647
+ return areThemesEqual(optionsA.theme, optionsB.theme) && optionsA.tokenizeMaxLineLength === optionsB.tokenizeMaxLineLength && optionsA.lineDiffType === optionsB.lineDiffType;
648
+ }
649
+ function getModifiedLinesString(lines) {
650
+ return `${lines} unmodified line${lines > 1 ? "s" : ""}`;
651
+ }
652
+
653
+ //#endregion
654
+ export { DiffHunksRenderer };
655
+ //# sourceMappingURL=DiffHunksRenderer.js.map