index.d.mts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import { CompareKeys } from "pretty-format";
  2. //#region src/cleanupSemantic.d.ts
  3. /**
  4. * Diff Match and Patch
  5. * Copyright 2018 The diff-match-patch Authors.
  6. * https://github.com/google/diff-match-patch
  7. *
  8. * Licensed under the Apache License, Version 2.0 (the "License");
  9. * you may not use this file except in compliance with the License.
  10. * You may obtain a copy of the License at
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. *
  14. * Unless required by applicable law or agreed to in writing, software
  15. * distributed under the License is distributed on an "AS IS" BASIS,
  16. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. */
  20. /**
  21. * @fileoverview Computes the difference between two texts to create a patch.
  22. * Applies the patch onto another text, allowing for errors.
  23. * @author fraser@google.com (Neil Fraser)
  24. */
  25. /**
  26. * CHANGES by pedrottimark to diff_match_patch_uncompressed.ts file:
  27. *
  28. * 1. Delete anything not needed to use diff_cleanupSemantic method
  29. * 2. Convert from prototype properties to var declarations
  30. * 3. Convert Diff to class from constructor and prototype
  31. * 4. Add type annotations for arguments and return values
  32. * 5. Add exports
  33. */
  34. /**
  35. * The data structure representing a diff is an array of tuples:
  36. * [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']]
  37. * which means: delete 'Hello', add 'Goodbye' and keep ' world.'
  38. */
  39. declare var DIFF_DELETE: number;
  40. declare var DIFF_INSERT: number;
  41. declare var DIFF_EQUAL: number;
  42. /**
  43. * Class representing one diff tuple.
  44. * Attempts to look like a two-element array (which is what this used to be).
  45. * @param {number} op Operation, one of: DIFF_DELETE, DIFF_INSERT, DIFF_EQUAL.
  46. * @param {string} text Text to be deleted, inserted, or retained.
  47. * @constructor
  48. */
  49. declare class Diff {
  50. 0: number;
  51. 1: string;
  52. constructor(op: number, text: string);
  53. }
  54. /**
  55. * Reduce the number of edits by eliminating semantically trivial equalities.
  56. * @param {!Array.<!diff_match_patch.Diff>} diffs Array of diff tuples.
  57. */
  58. //#endregion
  59. //#region src/types.d.ts
  60. type DiffOptionsColor = (arg: string) => string;
  61. type DiffOptions = {
  62. aAnnotation?: string;
  63. aColor?: DiffOptionsColor;
  64. aIndicator?: string;
  65. bAnnotation?: string;
  66. bColor?: DiffOptionsColor;
  67. bIndicator?: string;
  68. changeColor?: DiffOptionsColor;
  69. changeLineTrailingSpaceColor?: DiffOptionsColor;
  70. commonColor?: DiffOptionsColor;
  71. commonIndicator?: string;
  72. commonLineTrailingSpaceColor?: DiffOptionsColor;
  73. contextLines?: number;
  74. emptyFirstOrLastLinePlaceholder?: string;
  75. expand?: boolean;
  76. includeChangeCounts?: boolean;
  77. omitAnnotationLines?: boolean;
  78. patchColor?: DiffOptionsColor;
  79. compareKeys?: CompareKeys;
  80. };
  81. //#endregion
  82. //#region src/diffLines.d.ts
  83. declare const diffLinesUnified: (aLines: Array<string>, bLines: Array<string>, options?: DiffOptions) => string;
  84. declare const diffLinesUnified2: (aLinesDisplay: Array<string>, bLinesDisplay: Array<string>, aLinesCompare: Array<string>, bLinesCompare: Array<string>, options?: DiffOptions) => string;
  85. declare const diffLinesRaw: (aLines: Array<string>, bLines: Array<string>) => Array<Diff>;
  86. //#endregion
  87. //#region src/printDiffs.d.ts
  88. declare const diffStringsUnified: (a: string, b: string, options?: DiffOptions) => string;
  89. declare const diffStringsRaw: (a: string, b: string, cleanup: boolean) => Array<Diff>;
  90. //#endregion
  91. //#region src/index.d.ts
  92. declare function diff(a: any, b: any, options?: DiffOptions): string | null;
  93. //#endregion
  94. export { DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff, DiffOptions, DiffOptionsColor, diff, diffLinesRaw, diffLinesUnified, diffLinesUnified2, diffStringsRaw, diffStringsUnified };