svelte-highlight 7.23.2 → 7.24.0

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 (94) hide show
  1. package/AnsiOutput.svelte +33 -6
  2. package/AnsiOutput.svelte.d.ts +8 -0
  3. package/CodeToolbar.svelte +144 -0
  4. package/CodeToolbar.svelte.d.ts +125 -0
  5. package/CodeWindow.svelte +19 -0
  6. package/CodeWindow.svelte.d.ts +10 -0
  7. package/CopyButton.svelte +107 -3
  8. package/CopyButton.svelte.d.ts +17 -1
  9. package/DiffFileList.svelte +523 -0
  10. package/DiffFileList.svelte.d.ts +94 -0
  11. package/DiffFileListItem.svelte +44 -0
  12. package/DiffMinimap.svelte +99 -0
  13. package/DiffMinimap.svelte.d.ts +17 -0
  14. package/DiffStats.svelte +43 -0
  15. package/DiffStats.svelte.d.ts +17 -0
  16. package/DiffView.svelte +1213 -0
  17. package/DiffView.svelte.d.ts +76 -0
  18. package/FileTabs.svelte +2 -5
  19. package/Highlight.svelte +158 -2
  20. package/Highlight.svelte.d.ts +50 -2
  21. package/HighlightAuto.svelte.d.ts +3 -2
  22. package/HighlightAutoLazy.svelte +112 -0
  23. package/HighlightAutoLazy.svelte.d.ts +66 -0
  24. package/HighlightDiff.svelte +162 -0
  25. package/HighlightDiff.svelte.d.ts +102 -0
  26. package/HighlightEditable.svelte +65 -756
  27. package/HighlightEditable.svelte.d.ts +15 -5
  28. package/HighlightStream.svelte +117 -218
  29. package/HighlightStream.svelte.d.ts +8 -0
  30. package/HighlightSvelte.svelte.d.ts +3 -2
  31. package/HighlightVirtual.svelte +41 -8
  32. package/HighlightVirtual.svelte.d.ts +8 -0
  33. package/LangTag.svelte +33 -4
  34. package/LangTag.svelte.d.ts +6 -2
  35. package/LineNumbers.svelte +25 -4
  36. package/LineNumbers.svelte.d.ts +8 -0
  37. package/MarkdownStream.svelte +1 -0
  38. package/README.md +735 -18
  39. package/ToolbarButton.svelte +90 -0
  40. package/ToolbarButton.svelte.d.ts +106 -0
  41. package/Typewriter.svelte +59 -10
  42. package/Typewriter.svelte.d.ts +7 -0
  43. package/WrapToggle.svelte +34 -0
  44. package/WrapToggle.svelte.d.ts +39 -0
  45. package/action.js +7 -3
  46. package/ansi.d.ts +1 -3
  47. package/auto-detect.d.ts +52 -0
  48. package/auto-detect.js +208 -0
  49. package/code-region.d.ts +7 -0
  50. package/code-region.js +20 -0
  51. package/css-highlights.js +115 -0
  52. package/css-walk.js +50 -0
  53. package/diff-controller.d.ts +120 -0
  54. package/diff-controller.js +721 -0
  55. package/diff-edits.d.ts +101 -0
  56. package/diff-edits.js +890 -0
  57. package/diff-html.d.ts +8 -0
  58. package/diff-html.js +60 -0
  59. package/diff-languages.d.ts +4 -0
  60. package/diff-languages.js +73 -0
  61. package/diff.d.ts +161 -0
  62. package/diff.js +1111 -0
  63. package/editable-commands.js +81 -0
  64. package/editable-css-paint.js +5 -3
  65. package/editable-dom-paint.js +1 -1
  66. package/editable-history.js +199 -0
  67. package/editable-line-dom.js +176 -1
  68. package/editable-painter.js +356 -0
  69. package/editable.d.ts +118 -0
  70. package/editable.js +513 -0
  71. package/engine.d.ts +1 -1
  72. package/fence.js +1 -1
  73. package/highlight-cascade.js +679 -0
  74. package/highlight-theme.js +6 -47
  75. package/incremental-tokenize.js +1 -1
  76. package/index.d.ts +39 -6
  77. package/index.js +30 -0
  78. package/languages/detect-index.d.ts +16 -0
  79. package/languages/detect-index.js +6 -0
  80. package/languages/loaders.d.ts +8 -0
  81. package/languages/loaders.js +370 -0
  82. package/package.json +50 -2
  83. package/preprocessor.js +20 -5
  84. package/search.js +2 -2
  85. package/stream-highlighter.js +198 -0
  86. package/stream.css +16 -0
  87. package/stream.d.ts +60 -0
  88. package/stream.js +283 -0
  89. package/style-registry.js +34 -3
  90. package/themes/_base-css.d.ts +1 -0
  91. package/themes/_base-css.js +1 -0
  92. package/typewriter-units.d.ts +3 -0
  93. package/typewriter-units.js +43 -0
  94. package/virtual-window.js +9 -4
@@ -0,0 +1,101 @@
1
+ import type { DiffState } from "./diff";
2
+
3
+ export interface Edit {
4
+ search: string;
5
+ replace: string;
6
+ path?: string | undefined;
7
+ /** The search text is complete (a streamed edit may still be arriving). */
8
+ searchComplete: boolean;
9
+ /** The whole edit is complete. */
10
+ complete: boolean;
11
+ /** Replaces the whole file. */
12
+ whole?: boolean;
13
+ }
14
+
15
+ export type EditFormat =
16
+ | "search-replace"
17
+ | "unified-diff"
18
+ | "str-replace"
19
+ | "apply-patch"
20
+ | "whole-file"
21
+ | "unknown";
22
+
23
+ export function detectEditFormat(text: string): EditFormat;
24
+
25
+ /** Parses model output into edits, tolerating a truncated last edit. */
26
+ export function parseEdits(text: string): { format: EditFormat; edits: Edit[] };
27
+
28
+ /**
29
+ * Finds `search` in `lines`: exactly, then ignoring trailing whitespace,
30
+ * then indentation, then by fuzzy line similarity (score ≥ 0.8).
31
+ */
32
+ export function locate(
33
+ lines: string[],
34
+ search: string[],
35
+ from?: number,
36
+ ): {
37
+ start: number;
38
+ strategy: "exact" | "trailing-whitespace" | "indentation" | "fuzzy";
39
+ score: number;
40
+ } | null;
41
+
42
+ export interface EditResult {
43
+ edit: Edit;
44
+ status: "applied" | "failed";
45
+ strategy?:
46
+ | "exact"
47
+ | "trailing-whitespace"
48
+ | "indentation"
49
+ | "fuzzy"
50
+ | "whole-file"
51
+ | "append";
52
+ score?: number;
53
+ /** Matched lines `[start, end)` in the source. */
54
+ start?: number;
55
+ end?: number;
56
+ reason?: string;
57
+ }
58
+
59
+ /** Applies complete edits. Unmatched or overlapping edits are reported and skipped. */
60
+ export function applyEdits(
61
+ source: string,
62
+ edits: Edit[],
63
+ ): { text: string; results: EditResult[] };
64
+
65
+ /**
66
+ * The prefix of the edited file that streamed model output has settled.
67
+ * It grows append-only while edits arrive in file order.
68
+ */
69
+ export function streamEditPrefix(
70
+ source: string,
71
+ partialOutput: string,
72
+ options?: { done?: boolean },
73
+ ): { after: string; format: EditFormat; edits: Edit[]; done: boolean };
74
+
75
+ export interface FilePatch {
76
+ oldPath: string;
77
+ newPath: string;
78
+ status: "modified" | "added" | "deleted" | "renamed" | "binary";
79
+ hunks: Array<{
80
+ oldStart: number;
81
+ oldLines: number;
82
+ newStart: number;
83
+ newLines: number;
84
+ /** Text after the second `@@`, often the enclosing function. */
85
+ section: string;
86
+ lines: Array<{ type: " " | "-" | "+"; text: string }>;
87
+ }>;
88
+ additions: number;
89
+ deletions: number;
90
+ }
91
+
92
+ /** Parses a (possibly multi-file) git or unified patch. */
93
+ export function parsePatch(text: string): FilePatch[];
94
+
95
+ /**
96
+ * A diff state for a patch alone. Lines between hunks are unknown: they
97
+ * become blank filler inside folds that can't expand.
98
+ */
99
+ export function patchToState(
100
+ file: FilePatch,
101
+ ): DiffState & { beforeText: string; afterText: string };