@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/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-D2ayLJDJ.js"></script>
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
- createRange(oldContentLine, newContentLine) {
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
- startLine: newContentLine,
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
- range[this.currentHash].linesCount = range[this.currentHash].endLine - range[this.currentHash].startLine + 1;
3790
- range[this.comparedToHash].linesCount = range[this.comparedToHash].endLine - range[this.comparedToHash].startLine + 1;
3791
- for (let line = range[this.currentHash].startLine; line <= range[this.currentHash].endLine; line++) {
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
- calculateDiffs() {
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 eachChange of changes) {
3803
- if (!eachChange.added && !eachChange.removed) {
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 += eachChange.count;
3809
- newLine += eachChange.count;
3814
+ oldLine += change.count;
3815
+ newLine += change.count;
3810
3816
  continue;
3811
3817
  }
3812
- if (!currentRange) {
3813
- currentRange = this.createRange(oldLine, newLine);
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 + eachChange.count - 1,
3818
- oldContentLinesCount
3821
+ oldLine + change.count,
3822
+ this.oldContentLinesCount
3819
3823
  );
3820
- oldLine += eachChange.count;
3824
+ oldLine += change.count;
3821
3825
  }
3822
- if (eachChange.added) {
3826
+ if (change.added) {
3823
3827
  currentRange[this.currentHash].endLine = Math.min(
3824
- newLine + eachChange.count - 1,
3825
- newContentLinesCount
3828
+ newLine + change.count,
3829
+ this.newContentLinesCount
3826
3830
  );
3827
- newLine += eachChange.count;
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faiezhares/source-code-highlighter",
3
- "version": "0.0.16-beta",
3
+ "version": "0.0.17-beta",
4
4
  "license": "UNLICENSED",
5
5
  "type": "module",
6
6
  "bin": {