@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,37 @@
1
+ {
2
+ "name": "@shikijs/transformers",
3
+ "type": "module",
4
+ "version": "3.23.0",
5
+ "description": "Collective of common transformers transformers for Shiki",
6
+ "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
+ "license": "MIT",
8
+ "homepage": "https://github.com/shikijs/shiki#readme",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/shikijs/shiki.git",
12
+ "directory": "packages/transformers"
13
+ },
14
+ "bugs": "https://github.com/shikijs/shiki/issues",
15
+ "keywords": [
16
+ "shiki",
17
+ "@shikijs/transformers"
18
+ ],
19
+ "sideEffects": false,
20
+ "exports": {
21
+ ".": "./dist/index.mjs"
22
+ },
23
+ "main": "./dist/index.mjs",
24
+ "module": "./dist/index.mjs",
25
+ "types": "./dist/index.d.mts",
26
+ "files": [
27
+ "dist"
28
+ ],
29
+ "dependencies": {
30
+ "@shikijs/core": "3.23.0",
31
+ "@shikijs/types": "3.23.0"
32
+ },
33
+ "scripts": {
34
+ "build": "unbuild",
35
+ "dev": "unbuild --stub"
36
+ }
37
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * converts a list of change objects to the format returned by Google's [diff-match-patch](https://github.com/google/diff-match-patch) library
3
+ */
4
+ export function convertChangesToDMP(changes) {
5
+ const ret = [];
6
+ let change, operation;
7
+ for (let i = 0; i < changes.length; i++) {
8
+ change = changes[i];
9
+ if (change.added) {
10
+ operation = 1;
11
+ }
12
+ else if (change.removed) {
13
+ operation = -1;
14
+ }
15
+ else {
16
+ operation = 0;
17
+ }
18
+ ret.push([operation, change.value]);
19
+ }
20
+ return ret;
21
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * converts a list of change objects to a serialized XML format
3
+ */
4
+ export function convertChangesToXML(changes) {
5
+ const ret = [];
6
+ for (let i = 0; i < changes.length; i++) {
7
+ const change = changes[i];
8
+ if (change.added) {
9
+ ret.push('<ins>');
10
+ }
11
+ else if (change.removed) {
12
+ ret.push('<del>');
13
+ }
14
+ ret.push(escapeHTML(change.value));
15
+ if (change.added) {
16
+ ret.push('</ins>');
17
+ }
18
+ else if (change.removed) {
19
+ ret.push('</del>');
20
+ }
21
+ }
22
+ return ret.join('');
23
+ }
24
+ function escapeHTML(s) {
25
+ let n = s;
26
+ n = n.replace(/&/g, '&amp;');
27
+ n = n.replace(/</g, '&lt;');
28
+ n = n.replace(/>/g, '&gt;');
29
+ n = n.replace(/"/g, '&quot;');
30
+ return n;
31
+ }
@@ -0,0 +1,16 @@
1
+ import Diff from './base.js';
2
+ class ArrayDiff extends Diff {
3
+ tokenize(value) {
4
+ return value.slice();
5
+ }
6
+ join(value) {
7
+ return value;
8
+ }
9
+ removeEmpty(value) {
10
+ return value;
11
+ }
12
+ }
13
+ export const arrayDiff = new ArrayDiff();
14
+ export function diffArrays(oldArr, newArr, options) {
15
+ return arrayDiff.diff(oldArr, newArr, options);
16
+ }
@@ -0,0 +1,253 @@
1
+ export default class Diff {
2
+ diff(oldStr, newStr,
3
+ // Type below is not accurate/complete - see above for full possibilities - but it compiles
4
+ options = {}) {
5
+ let callback;
6
+ if (typeof options === 'function') {
7
+ callback = options;
8
+ options = {};
9
+ }
10
+ else if ('callback' in options) {
11
+ callback = options.callback;
12
+ }
13
+ // Allow subclasses to massage the input prior to running
14
+ const oldString = this.castInput(oldStr, options);
15
+ const newString = this.castInput(newStr, options);
16
+ const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
17
+ const newTokens = this.removeEmpty(this.tokenize(newString, options));
18
+ return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
19
+ }
20
+ diffWithOptionsObj(oldTokens, newTokens, options, callback) {
21
+ var _a;
22
+ const done = (value) => {
23
+ value = this.postProcess(value, options);
24
+ if (callback) {
25
+ setTimeout(function () { callback(value); }, 0);
26
+ return undefined;
27
+ }
28
+ else {
29
+ return value;
30
+ }
31
+ };
32
+ const newLen = newTokens.length, oldLen = oldTokens.length;
33
+ let editLength = 1;
34
+ let maxEditLength = newLen + oldLen;
35
+ if (options.maxEditLength != null) {
36
+ maxEditLength = Math.min(maxEditLength, options.maxEditLength);
37
+ }
38
+ const maxExecutionTime = (_a = options.timeout) !== null && _a !== void 0 ? _a : Infinity;
39
+ const abortAfterTimestamp = Date.now() + maxExecutionTime;
40
+ const bestPath = [{ oldPos: -1, lastComponent: undefined }];
41
+ // Seed editLength = 0, i.e. the content starts with the same values
42
+ let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
43
+ if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
44
+ // Identity per the equality and tokenizer
45
+ return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
46
+ }
47
+ // Once we hit the right edge of the edit graph on some diagonal k, we can
48
+ // definitely reach the end of the edit graph in no more than k edits, so
49
+ // there's no point in considering any moves to diagonal k+1 any more (from
50
+ // which we're guaranteed to need at least k+1 more edits).
51
+ // Similarly, once we've reached the bottom of the edit graph, there's no
52
+ // point considering moves to lower diagonals.
53
+ // We record this fact by setting minDiagonalToConsider and
54
+ // maxDiagonalToConsider to some finite value once we've hit the edge of
55
+ // the edit graph.
56
+ // This optimization is not faithful to the original algorithm presented in
57
+ // Myers's paper, which instead pointlessly extends D-paths off the end of
58
+ // the edit graph - see page 7 of Myers's paper which notes this point
59
+ // explicitly and illustrates it with a diagram. This has major performance
60
+ // implications for some common scenarios. For instance, to compute a diff
61
+ // where the new text simply appends d characters on the end of the
62
+ // original text of length n, the true Myers algorithm will take O(n+d^2)
63
+ // time while this optimization needs only O(n+d) time.
64
+ let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
65
+ // Main worker method. checks all permutations of a given edit length for acceptance.
66
+ const execEditLength = () => {
67
+ for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
68
+ let basePath;
69
+ const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
70
+ if (removePath) {
71
+ // No one else is going to attempt to use this value, clear it
72
+ // @ts-expect-error - perf optimisation. This type-violating value will never be read.
73
+ bestPath[diagonalPath - 1] = undefined;
74
+ }
75
+ let canAdd = false;
76
+ if (addPath) {
77
+ // what newPos will be after we do an insertion:
78
+ const addPathNewPos = addPath.oldPos - diagonalPath;
79
+ canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
80
+ }
81
+ const canRemove = removePath && removePath.oldPos + 1 < oldLen;
82
+ if (!canAdd && !canRemove) {
83
+ // If this path is a terminal then prune
84
+ // @ts-expect-error - perf optimisation. This type-violating value will never be read.
85
+ bestPath[diagonalPath] = undefined;
86
+ continue;
87
+ }
88
+ // Select the diagonal that we want to branch from. We select the prior
89
+ // path whose position in the old string is the farthest from the origin
90
+ // and does not pass the bounds of the diff graph
91
+ if (!canRemove || (canAdd && removePath.oldPos < addPath.oldPos)) {
92
+ basePath = this.addToPath(addPath, true, false, 0, options);
93
+ }
94
+ else {
95
+ basePath = this.addToPath(removePath, false, true, 1, options);
96
+ }
97
+ newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
98
+ if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
99
+ // If we have hit the end of both strings, then we are done
100
+ return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
101
+ }
102
+ else {
103
+ bestPath[diagonalPath] = basePath;
104
+ if (basePath.oldPos + 1 >= oldLen) {
105
+ maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
106
+ }
107
+ if (newPos + 1 >= newLen) {
108
+ minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
109
+ }
110
+ }
111
+ }
112
+ editLength++;
113
+ };
114
+ // Performs the length of edit iteration. Is a bit fugly as this has to support the
115
+ // sync and async mode which is never fun. Loops over execEditLength until a value
116
+ // is produced, or until the edit length exceeds options.maxEditLength (if given),
117
+ // in which case it will return undefined.
118
+ if (callback) {
119
+ (function exec() {
120
+ setTimeout(function () {
121
+ if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
122
+ return callback(undefined);
123
+ }
124
+ if (!execEditLength()) {
125
+ exec();
126
+ }
127
+ }, 0);
128
+ }());
129
+ }
130
+ else {
131
+ while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
132
+ const ret = execEditLength();
133
+ if (ret) {
134
+ return ret;
135
+ }
136
+ }
137
+ }
138
+ }
139
+ addToPath(path, added, removed, oldPosInc, options) {
140
+ const last = path.lastComponent;
141
+ if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
142
+ return {
143
+ oldPos: path.oldPos + oldPosInc,
144
+ lastComponent: { count: last.count + 1, added: added, removed: removed, previousComponent: last.previousComponent }
145
+ };
146
+ }
147
+ else {
148
+ return {
149
+ oldPos: path.oldPos + oldPosInc,
150
+ lastComponent: { count: 1, added: added, removed: removed, previousComponent: last }
151
+ };
152
+ }
153
+ }
154
+ extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
155
+ const newLen = newTokens.length, oldLen = oldTokens.length;
156
+ let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
157
+ while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
158
+ newPos++;
159
+ oldPos++;
160
+ commonCount++;
161
+ if (options.oneChangePerToken) {
162
+ basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };
163
+ }
164
+ }
165
+ if (commonCount && !options.oneChangePerToken) {
166
+ basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };
167
+ }
168
+ basePath.oldPos = oldPos;
169
+ return newPos;
170
+ }
171
+ equals(left, right, options) {
172
+ if (options.comparator) {
173
+ return options.comparator(left, right);
174
+ }
175
+ else {
176
+ return left === right
177
+ || (!!options.ignoreCase && left.toLowerCase() === right.toLowerCase());
178
+ }
179
+ }
180
+ removeEmpty(array) {
181
+ const ret = [];
182
+ for (let i = 0; i < array.length; i++) {
183
+ if (array[i]) {
184
+ ret.push(array[i]);
185
+ }
186
+ }
187
+ return ret;
188
+ }
189
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
190
+ castInput(value, options) {
191
+ return value;
192
+ }
193
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
194
+ tokenize(value, options) {
195
+ return Array.from(value);
196
+ }
197
+ join(chars) {
198
+ // Assumes ValueT is string, which is the case for most subclasses.
199
+ // When it's false, e.g. in diffArrays, this method needs to be overridden (e.g. with a no-op)
200
+ // Yes, the casts are verbose and ugly, because this pattern - of having the base class SORT OF
201
+ // assume tokens and values are strings, but not completely - is weird and janky.
202
+ return chars.join('');
203
+ }
204
+ postProcess(changeObjects,
205
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
206
+ options) {
207
+ return changeObjects;
208
+ }
209
+ get useLongestToken() {
210
+ return false;
211
+ }
212
+ buildValues(lastComponent, newTokens, oldTokens) {
213
+ // First we convert our linked list of components in reverse order to an
214
+ // array in the right order:
215
+ const components = [];
216
+ let nextComponent;
217
+ while (lastComponent) {
218
+ components.push(lastComponent);
219
+ nextComponent = lastComponent.previousComponent;
220
+ delete lastComponent.previousComponent;
221
+ lastComponent = nextComponent;
222
+ }
223
+ components.reverse();
224
+ const componentLen = components.length;
225
+ let componentPos = 0, newPos = 0, oldPos = 0;
226
+ for (; componentPos < componentLen; componentPos++) {
227
+ const component = components[componentPos];
228
+ if (!component.removed) {
229
+ if (!component.added && this.useLongestToken) {
230
+ let value = newTokens.slice(newPos, newPos + component.count);
231
+ value = value.map(function (value, i) {
232
+ const oldValue = oldTokens[oldPos + i];
233
+ return oldValue.length > value.length ? oldValue : value;
234
+ });
235
+ component.value = this.join(value);
236
+ }
237
+ else {
238
+ component.value = this.join(newTokens.slice(newPos, newPos + component.count));
239
+ }
240
+ newPos += component.count;
241
+ // Common case
242
+ if (!component.added) {
243
+ oldPos += component.count;
244
+ }
245
+ }
246
+ else {
247
+ component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
248
+ oldPos += component.count;
249
+ }
250
+ }
251
+ return components;
252
+ }
253
+ }
@@ -0,0 +1,7 @@
1
+ import Diff from './base.js';
2
+ class CharacterDiff extends Diff {
3
+ }
4
+ export const characterDiff = new CharacterDiff();
5
+ export function diffChars(oldStr, newStr, options) {
6
+ return characterDiff.diff(oldStr, newStr, options);
7
+ }
@@ -0,0 +1,10 @@
1
+ import Diff from './base.js';
2
+ class CssDiff extends Diff {
3
+ tokenize(value) {
4
+ return value.split(/([{}:;,]|\s+)/);
5
+ }
6
+ }
7
+ export const cssDiff = new CssDiff();
8
+ export function diffCss(oldStr, newStr, options) {
9
+ return cssDiff.diff(oldStr, newStr, options);
10
+ }
@@ -0,0 +1,78 @@
1
+ import Diff from './base.js';
2
+ import { tokenize } from './line.js';
3
+ class JsonDiff extends Diff {
4
+ constructor() {
5
+ super(...arguments);
6
+ this.tokenize = tokenize;
7
+ }
8
+ get useLongestToken() {
9
+ // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
10
+ // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
11
+ return true;
12
+ }
13
+ castInput(value, options) {
14
+ const { undefinedReplacement, stringifyReplacer = (k, v) => typeof v === 'undefined' ? undefinedReplacement : v } = options;
15
+ return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), null, ' ');
16
+ }
17
+ equals(left, right, options) {
18
+ return super.equals(left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'), options);
19
+ }
20
+ }
21
+ export const jsonDiff = new JsonDiff();
22
+ export function diffJson(oldStr, newStr, options) {
23
+ return jsonDiff.diff(oldStr, newStr, options);
24
+ }
25
+ // This function handles the presence of circular references by bailing out when encountering an
26
+ // object that is already on the "stack" of items being processed. Accepts an optional replacer
27
+ export function canonicalize(obj, stack, replacementStack, replacer, key) {
28
+ stack = stack || [];
29
+ replacementStack = replacementStack || [];
30
+ if (replacer) {
31
+ obj = replacer(key === undefined ? '' : key, obj);
32
+ }
33
+ let i;
34
+ for (i = 0; i < stack.length; i += 1) {
35
+ if (stack[i] === obj) {
36
+ return replacementStack[i];
37
+ }
38
+ }
39
+ let canonicalizedObj;
40
+ if ('[object Array]' === Object.prototype.toString.call(obj)) {
41
+ stack.push(obj);
42
+ canonicalizedObj = new Array(obj.length);
43
+ replacementStack.push(canonicalizedObj);
44
+ for (i = 0; i < obj.length; i += 1) {
45
+ canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, String(i));
46
+ }
47
+ stack.pop();
48
+ replacementStack.pop();
49
+ return canonicalizedObj;
50
+ }
51
+ if (obj && obj.toJSON) {
52
+ obj = obj.toJSON();
53
+ }
54
+ if (typeof obj === 'object' && obj !== null) {
55
+ stack.push(obj);
56
+ canonicalizedObj = {};
57
+ replacementStack.push(canonicalizedObj);
58
+ const sortedKeys = [];
59
+ let key;
60
+ for (key in obj) {
61
+ /* istanbul ignore else */
62
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
63
+ sortedKeys.push(key);
64
+ }
65
+ }
66
+ sortedKeys.sort();
67
+ for (i = 0; i < sortedKeys.length; i += 1) {
68
+ key = sortedKeys[i];
69
+ canonicalizedObj[key] = canonicalize(obj[key], stack, replacementStack, replacer, key);
70
+ }
71
+ stack.pop();
72
+ replacementStack.pop();
73
+ }
74
+ else {
75
+ canonicalizedObj = obj;
76
+ }
77
+ return canonicalizedObj;
78
+ }
@@ -0,0 +1,65 @@
1
+ import Diff from './base.js';
2
+ import { generateOptions } from '../util/params.js';
3
+ class LineDiff extends Diff {
4
+ constructor() {
5
+ super(...arguments);
6
+ this.tokenize = tokenize;
7
+ }
8
+ equals(left, right, options) {
9
+ // If we're ignoring whitespace, we need to normalise lines by stripping
10
+ // whitespace before checking equality. (This has an annoying interaction
11
+ // with newlineIsToken that requires special handling: if newlines get their
12
+ // own token, then we DON'T want to trim the *newline* tokens down to empty
13
+ // strings, since this would cause us to treat whitespace-only line content
14
+ // as equal to a separator between lines, which would be weird and
15
+ // inconsistent with the documented behavior of the options.)
16
+ if (options.ignoreWhitespace) {
17
+ if (!options.newlineIsToken || !left.includes('\n')) {
18
+ left = left.trim();
19
+ }
20
+ if (!options.newlineIsToken || !right.includes('\n')) {
21
+ right = right.trim();
22
+ }
23
+ }
24
+ else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
25
+ if (left.endsWith('\n')) {
26
+ left = left.slice(0, -1);
27
+ }
28
+ if (right.endsWith('\n')) {
29
+ right = right.slice(0, -1);
30
+ }
31
+ }
32
+ return super.equals(left, right, options);
33
+ }
34
+ }
35
+ export const lineDiff = new LineDiff();
36
+ export function diffLines(oldStr, newStr, options) {
37
+ return lineDiff.diff(oldStr, newStr, options);
38
+ }
39
+ export function diffTrimmedLines(oldStr, newStr, options) {
40
+ options = generateOptions(options, { ignoreWhitespace: true });
41
+ return lineDiff.diff(oldStr, newStr, options);
42
+ }
43
+ // Exported standalone so it can be used from jsonDiff too.
44
+ export function tokenize(value, options) {
45
+ if (options.stripTrailingCr) {
46
+ // remove one \r before \n to match GNU diff's --strip-trailing-cr behavior
47
+ value = value.replace(/\r\n/g, '\n');
48
+ }
49
+ const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
50
+ // Ignore the final empty token that occurs if the string ends with a new line
51
+ if (!linesAndNewlines[linesAndNewlines.length - 1]) {
52
+ linesAndNewlines.pop();
53
+ }
54
+ // Merge the content and line separators into single tokens
55
+ for (let i = 0; i < linesAndNewlines.length; i++) {
56
+ const line = linesAndNewlines[i];
57
+ if (i % 2 && !options.newlineIsToken) {
58
+ retLines[retLines.length - 1] += line;
59
+ }
60
+ else {
61
+ retLines.push(line);
62
+ }
63
+ }
64
+ return retLines;
65
+ }
@@ -0,0 +1,43 @@
1
+ import Diff from './base.js';
2
+ function isSentenceEndPunct(char) {
3
+ return char == '.' || char == '!' || char == '?';
4
+ }
5
+ class SentenceDiff extends Diff {
6
+ tokenize(value) {
7
+ var _a;
8
+ // If in future we drop support for environments that don't support lookbehinds, we can replace
9
+ // this entire function with:
10
+ // return value.split(/(?<=[.!?])(\s+|$)/);
11
+ // but until then, for similar reasons to the trailingWs function in string.ts, we are forced
12
+ // to do this verbosely "by hand" instead of using a regex.
13
+ const result = [];
14
+ let tokenStartI = 0;
15
+ for (let i = 0; i < value.length; i++) {
16
+ if (i == value.length - 1) {
17
+ result.push(value.slice(tokenStartI));
18
+ break;
19
+ }
20
+ if (isSentenceEndPunct(value[i]) && value[i + 1].match(/\s/)) {
21
+ // We've hit a sentence break - i.e. a punctuation mark followed by whitespace.
22
+ // We now want to push TWO tokens to the result:
23
+ // 1. the sentence
24
+ result.push(value.slice(tokenStartI, i + 1));
25
+ // 2. the whitespace
26
+ i = tokenStartI = i + 1;
27
+ while ((_a = value[i + 1]) === null || _a === void 0 ? void 0 : _a.match(/\s/)) {
28
+ i++;
29
+ }
30
+ result.push(value.slice(tokenStartI, i + 1));
31
+ // Then the next token (a sentence) starts on the character after the whitespace.
32
+ // (It's okay if this is off the end of the string - then the outer loop will terminate
33
+ // here anyway.)
34
+ tokenStartI = i + 1;
35
+ }
36
+ }
37
+ return result;
38
+ }
39
+ }
40
+ export const sentenceDiff = new SentenceDiff();
41
+ export function diffSentences(oldStr, newStr, options) {
42
+ return sentenceDiff.diff(oldStr, newStr, options);
43
+ }