11<script setup lang="ts">
22import { ref , computed , watch } from " vue" ;
3- import * as diff from " diff" ;
3+ import { diffLines , diffWords , diffWordsWithSpace , diffChars , diffTrimmedLines , diffSentences , diffCss } from " diff" ;
44
55// Types needed for the diff viewer
66interface DiffChange {
@@ -67,7 +67,7 @@ const props = withDefaults(defineProps<Props>(), {
6767
6868// Component state
6969const lineInformation = ref <LineInformation []>([]);
70- const diffLines = ref <number []>([]);
70+ const diffLineIndexes = ref <number []>([]);
7171const expandedBlocks = ref <number []>([]);
7272
7373// Compute diff when inputs change
@@ -92,34 +92,34 @@ const computeDiff = (): void => {
9292 });
9393
9494 lineInformation .value = result ;
95- diffLines .value = [];
95+ diffLineIndexes .value = [];
9696 return ;
9797 }
9898
9999 // Generate diff based on selected method
100100 let diffOutput: DiffChange [];
101101 switch (compareMethod ) {
102102 case " diffChars" :
103- diffOutput = diff . diffChars (oldValue , newValue );
103+ diffOutput = diffChars (oldValue , newValue );
104104 break ;
105105 case " diffWords" :
106- diffOutput = diff . diffWords (oldValue , newValue );
106+ diffOutput = diffWords (oldValue , newValue );
107107 break ;
108108 case " diffWordsWithSpace" :
109- diffOutput = diff . diffWordsWithSpace (oldValue , newValue );
109+ diffOutput = diffWordsWithSpace (oldValue , newValue );
110110 break ;
111111 case " diffTrimmedLines" :
112- diffOutput = diff . diffTrimmedLines (oldValue , newValue );
112+ diffOutput = diffTrimmedLines (oldValue , newValue );
113113 break ;
114114 case " diffSentences" :
115- diffOutput = diff . diffSentences (oldValue , newValue );
115+ diffOutput = diffSentences (oldValue , newValue );
116116 break ;
117117 case " diffCss" :
118- diffOutput = diff . diffCss (oldValue , newValue );
118+ diffOutput = diffCss (oldValue , newValue );
119119 break ;
120120 case " diffLines" :
121121 default :
122- diffOutput = diff . diffLines (oldValue , newValue );
122+ diffOutput = diffLines (oldValue , newValue );
123123 break ;
124124 }
125125
@@ -170,7 +170,7 @@ const computeDiff = (): void => {
170170 });
171171
172172 lineInformation .value = result ;
173- diffLines .value = diffLinesArray ;
173+ diffLineIndexes .value = diffLinesArray ;
174174
175175 // Reset expanded blocks when diff changes
176176 expandedBlocks .value = [];
@@ -194,7 +194,7 @@ const renderDiff = computed<DiffItem[]>(() => {
194194 const result: DiffItem [] = [];
195195
196196 // Create a mutable copy of diffLines for manipulation in the loop
197- const currentDiffLines = [... diffLines .value ];
197+ const currentDiffLines = [... diffLineIndexes .value ];
198198
199199 lineInformation .value .forEach ((line , i ) => {
200200 const diffBlockStart = currentDiffLines [0 ];
0 commit comments