@faiezhares/source-code-highlighter 0.0.16-beta → 0.0.17-beta
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.
- package/assets/index-DnI2uFeM.js +135 -0
- package/index.html +1 -1
- package/index.js +38 -38
- package/package.json +1 -1
- package/assets/index-D2ayLJDJ.js +0 -135
package/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-DnI2uFeM.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/assets/index-CIfVvUo9.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
package/index.js
CHANGED
|
@@ -3764,77 +3764,77 @@ var ParseFileControllerAsync = class {
|
|
|
3764
3764
|
// server/controllers/DiffController.js
|
|
3765
3765
|
import { diffLines } from "diff";
|
|
3766
3766
|
var DiffController = class {
|
|
3767
|
+
oldContent = null;
|
|
3768
|
+
newContent = null;
|
|
3769
|
+
changes = null;
|
|
3770
|
+
oldContentLinesCount = null;
|
|
3771
|
+
newContentLinesCount = null;
|
|
3772
|
+
ranges = /* @__PURE__ */ new Map();
|
|
3767
3773
|
constructor(fileReader2, absoluteFilePath, comparedToHash, currentHash) {
|
|
3768
3774
|
this.fileReader = fileReader2;
|
|
3769
3775
|
this.absoluteFilePath = absoluteFilePath;
|
|
3770
3776
|
this.comparedToHash = comparedToHash;
|
|
3771
3777
|
this.currentHash = currentHash;
|
|
3772
|
-
this.oldContent = null;
|
|
3773
|
-
this.newContent = null;
|
|
3774
|
-
this.ranges = /* @__PURE__ */ new Map();
|
|
3775
3778
|
}
|
|
3776
|
-
|
|
3779
|
+
readContent() {
|
|
3780
|
+
this.oldContent = this.fileReader.fileContent(this.absoluteFilePath, this.comparedToHash);
|
|
3781
|
+
this.newContent = this.fileReader.fileContent(this.absoluteFilePath, this.currentHash);
|
|
3782
|
+
}
|
|
3783
|
+
calculateDiffs() {
|
|
3784
|
+
this.changes = diffLines(this.oldContent, this.newContent);
|
|
3785
|
+
this.oldContentLinesCount = this.oldContent.split("\n").length;
|
|
3786
|
+
this.newContentLinesCount = this.newContent.split("\n").length;
|
|
3787
|
+
this.putChangedRanges();
|
|
3788
|
+
}
|
|
3789
|
+
createRange(oldLine, newLine) {
|
|
3777
3790
|
return {
|
|
3778
|
-
[this.currentHash]: {
|
|
3779
|
-
|
|
3780
|
-
endLine: newContentLine
|
|
3781
|
-
},
|
|
3782
|
-
[this.comparedToHash]: {
|
|
3783
|
-
startLine: oldContentLine,
|
|
3784
|
-
endLine: oldContentLine
|
|
3785
|
-
}
|
|
3791
|
+
[this.currentHash]: { startLine: newLine, endLine: newLine },
|
|
3792
|
+
[this.comparedToHash]: { startLine: oldLine, endLine: oldLine }
|
|
3786
3793
|
};
|
|
3787
3794
|
}
|
|
3788
3795
|
put(range) {
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3796
|
+
const cur = this.currentHash;
|
|
3797
|
+
const comp = this.comparedToHash;
|
|
3798
|
+
range[cur].linesCount = range[cur].endLine - range[cur].startLine + 1;
|
|
3799
|
+
range[comp].linesCount = range[comp].endLine - range[comp].startLine + 1;
|
|
3800
|
+
for (let line = range[cur].startLine; line <= range[cur].endLine; line++) {
|
|
3792
3801
|
this.ranges.set(line, range);
|
|
3793
3802
|
}
|
|
3794
3803
|
}
|
|
3795
|
-
|
|
3796
|
-
const changes = diffLines(this.oldContent, this.newContent);
|
|
3797
|
-
const oldContentLinesCount = this.oldContent.split("\n").length;
|
|
3798
|
-
const newContentLinesCount = this.newContent.split("\n").length;
|
|
3804
|
+
putChangedRanges() {
|
|
3799
3805
|
let currentRange = null;
|
|
3800
3806
|
let oldLine = 1;
|
|
3801
3807
|
let newLine = 1;
|
|
3802
|
-
for (const
|
|
3803
|
-
if (!
|
|
3808
|
+
for (const change of this.changes) {
|
|
3809
|
+
if (!change.added && !change.removed) {
|
|
3804
3810
|
if (currentRange) {
|
|
3805
3811
|
this.put(currentRange);
|
|
3806
3812
|
currentRange = null;
|
|
3807
3813
|
}
|
|
3808
|
-
oldLine +=
|
|
3809
|
-
newLine +=
|
|
3814
|
+
oldLine += change.count;
|
|
3815
|
+
newLine += change.count;
|
|
3810
3816
|
continue;
|
|
3811
3817
|
}
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
}
|
|
3815
|
-
if (eachChange.removed) {
|
|
3818
|
+
currentRange ??= this.createRange(oldLine, newLine);
|
|
3819
|
+
if (change.removed) {
|
|
3816
3820
|
currentRange[this.comparedToHash].endLine = Math.min(
|
|
3817
|
-
oldLine +
|
|
3818
|
-
oldContentLinesCount
|
|
3821
|
+
oldLine + change.count,
|
|
3822
|
+
this.oldContentLinesCount
|
|
3819
3823
|
);
|
|
3820
|
-
oldLine +=
|
|
3824
|
+
oldLine += change.count;
|
|
3821
3825
|
}
|
|
3822
|
-
if (
|
|
3826
|
+
if (change.added) {
|
|
3823
3827
|
currentRange[this.currentHash].endLine = Math.min(
|
|
3824
|
-
newLine +
|
|
3825
|
-
newContentLinesCount
|
|
3828
|
+
newLine + change.count,
|
|
3829
|
+
this.newContentLinesCount
|
|
3826
3830
|
);
|
|
3827
|
-
newLine +=
|
|
3831
|
+
newLine += change.count;
|
|
3828
3832
|
}
|
|
3829
3833
|
}
|
|
3830
3834
|
if (currentRange) {
|
|
3831
3835
|
this.put(currentRange);
|
|
3832
3836
|
}
|
|
3833
3837
|
}
|
|
3834
|
-
readContent() {
|
|
3835
|
-
this.oldContent = this.fileReader.fileContent(this.absoluteFilePath, this.comparedToHash);
|
|
3836
|
-
this.newContent = this.fileReader.fileContent(this.absoluteFilePath, this.currentHash);
|
|
3837
|
-
}
|
|
3838
3838
|
};
|
|
3839
3839
|
|
|
3840
3840
|
// server/controllers/ai/CheckAiServerController.js
|