wesl-link 0.6.2 → 0.6.6

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 (2) hide show
  1. package/bin/wesl-link +642 -398
  2. package/package.json +5 -5
package/bin/wesl-link CHANGED
@@ -1634,223 +1634,258 @@ var esm_default = {
1634
1634
  })
1635
1635
  };
1636
1636
 
1637
- // ../../node_modules/.pnpm/diff@7.0.0/node_modules/diff/lib/index.mjs
1638
- function Diff() {
1639
- }
1640
- Diff.prototype = {
1641
- diff: function diff(oldString, newString) {
1642
- var _options$timeout;
1643
- var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
1644
- var callback = options.callback;
1645
- if (typeof options === "function") {
1646
- callback = options;
1647
- options = {};
1648
- }
1649
- var self = this;
1650
- function done(value) {
1651
- value = self.postProcess(value, options);
1652
- if (callback) {
1653
- setTimeout(function() {
1654
- callback(value);
1655
- }, 0);
1656
- return true;
1657
- } else {
1658
- return value;
1659
- }
1660
- }
1661
- oldString = this.castInput(oldString, options);
1662
- newString = this.castInput(newString, options);
1663
- oldString = this.removeEmpty(this.tokenize(oldString, options));
1664
- newString = this.removeEmpty(this.tokenize(newString, options));
1665
- var newLen = newString.length, oldLen = oldString.length;
1666
- var editLength = 1;
1667
- var maxEditLength = newLen + oldLen;
1668
- if (options.maxEditLength != null) {
1669
- maxEditLength = Math.min(maxEditLength, options.maxEditLength);
1670
- }
1671
- var maxExecutionTime = (_options$timeout = options.timeout) !== null && _options$timeout !== void 0 ? _options$timeout : Infinity;
1672
- var abortAfterTimestamp = Date.now() + maxExecutionTime;
1673
- var bestPath = [{
1674
- oldPos: -1,
1675
- lastComponent: void 0
1676
- }];
1677
- var newPos = this.extractCommon(bestPath[0], newString, oldString, 0, options);
1678
- if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
1679
- return done(buildValues(self, bestPath[0].lastComponent, newString, oldString, self.useLongestToken));
1680
- }
1681
- var minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
1682
- function execEditLength() {
1683
- for (var diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
1684
- var basePath = void 0;
1685
- var removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
1686
- if (removePath) {
1687
- bestPath[diagonalPath - 1] = void 0;
1688
- }
1689
- var canAdd = false;
1690
- if (addPath) {
1691
- var addPathNewPos = addPath.oldPos - diagonalPath;
1692
- canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
1693
- }
1694
- var canRemove = removePath && removePath.oldPos + 1 < oldLen;
1695
- if (!canAdd && !canRemove) {
1696
- bestPath[diagonalPath] = void 0;
1697
- continue;
1698
- }
1699
- if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
1700
- basePath = self.addToPath(addPath, true, false, 0, options);
1637
+ // src/cli.ts
1638
+ import fs from "node:fs";
1639
+ import path from "node:path";
1640
+
1641
+ // ../../node_modules/.pnpm/diff@8.0.1/node_modules/diff/libesm/diff/base.js
1642
+ var Diff = (
1643
+ /** @class */
1644
+ function() {
1645
+ function Diff2() {
1646
+ }
1647
+ Diff2.prototype.diff = function(oldStr, newStr, options) {
1648
+ if (options === void 0) {
1649
+ options = {};
1650
+ }
1651
+ var callback;
1652
+ if (typeof options === "function") {
1653
+ callback = options;
1654
+ options = {};
1655
+ } else if ("callback" in options) {
1656
+ callback = options.callback;
1657
+ }
1658
+ var oldString = this.castInput(oldStr, options);
1659
+ var newString = this.castInput(newStr, options);
1660
+ var oldTokens = this.removeEmpty(this.tokenize(oldString, options));
1661
+ var newTokens = this.removeEmpty(this.tokenize(newString, options));
1662
+ return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
1663
+ };
1664
+ Diff2.prototype.diffWithOptionsObj = function(oldTokens, newTokens, options, callback) {
1665
+ var _this = this;
1666
+ var _a2;
1667
+ var done = function(value) {
1668
+ value = _this.postProcess(value, options);
1669
+ if (callback) {
1670
+ setTimeout(function() {
1671
+ callback(value);
1672
+ }, 0);
1673
+ return void 0;
1701
1674
  } else {
1702
- basePath = self.addToPath(removePath, false, true, 1, options);
1675
+ return value;
1703
1676
  }
1704
- newPos = self.extractCommon(basePath, newString, oldString, diagonalPath, options);
1705
- if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
1706
- return done(buildValues(self, basePath.lastComponent, newString, oldString, self.useLongestToken));
1707
- } else {
1708
- bestPath[diagonalPath] = basePath;
1709
- if (basePath.oldPos + 1 >= oldLen) {
1710
- maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
1677
+ };
1678
+ var newLen = newTokens.length, oldLen = oldTokens.length;
1679
+ var editLength = 1;
1680
+ var maxEditLength = newLen + oldLen;
1681
+ if (options.maxEditLength != null) {
1682
+ maxEditLength = Math.min(maxEditLength, options.maxEditLength);
1683
+ }
1684
+ var maxExecutionTime = (_a2 = options.timeout) !== null && _a2 !== void 0 ? _a2 : Infinity;
1685
+ var abortAfterTimestamp = Date.now() + maxExecutionTime;
1686
+ var bestPath = [{ oldPos: -1, lastComponent: void 0 }];
1687
+ var newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
1688
+ if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
1689
+ return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
1690
+ }
1691
+ var minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
1692
+ var execEditLength = function() {
1693
+ for (var diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
1694
+ var basePath = void 0;
1695
+ var removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
1696
+ if (removePath) {
1697
+ bestPath[diagonalPath - 1] = void 0;
1711
1698
  }
1712
- if (newPos + 1 >= newLen) {
1713
- minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
1699
+ var canAdd = false;
1700
+ if (addPath) {
1701
+ var addPathNewPos = addPath.oldPos - diagonalPath;
1702
+ canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
1714
1703
  }
1715
- }
1716
- }
1717
- editLength++;
1718
- }
1719
- if (callback) {
1720
- (function exec() {
1721
- setTimeout(function() {
1722
- if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
1723
- return callback();
1704
+ var canRemove = removePath && removePath.oldPos + 1 < oldLen;
1705
+ if (!canAdd && !canRemove) {
1706
+ bestPath[diagonalPath] = void 0;
1707
+ continue;
1724
1708
  }
1725
- if (!execEditLength()) {
1726
- exec();
1709
+ if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
1710
+ basePath = _this.addToPath(addPath, true, false, 0, options);
1711
+ } else {
1712
+ basePath = _this.addToPath(removePath, false, true, 1, options);
1713
+ }
1714
+ newPos = _this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
1715
+ if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
1716
+ return done(_this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
1717
+ } else {
1718
+ bestPath[diagonalPath] = basePath;
1719
+ if (basePath.oldPos + 1 >= oldLen) {
1720
+ maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
1721
+ }
1722
+ if (newPos + 1 >= newLen) {
1723
+ minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
1724
+ }
1727
1725
  }
1728
- }, 0);
1729
- })();
1730
- } else {
1731
- while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
1732
- var ret = execEditLength();
1733
- if (ret) {
1734
- return ret;
1735
- }
1736
- }
1737
- }
1738
- },
1739
- addToPath: function addToPath(path2, added, removed, oldPosInc, options) {
1740
- var last3 = path2.lastComponent;
1741
- if (last3 && !options.oneChangePerToken && last3.added === added && last3.removed === removed) {
1742
- return {
1743
- oldPos: path2.oldPos + oldPosInc,
1744
- lastComponent: {
1745
- count: last3.count + 1,
1746
- added,
1747
- removed,
1748
- previousComponent: last3.previousComponent
1749
1726
  }
1727
+ editLength++;
1750
1728
  };
1751
- } else {
1752
- return {
1753
- oldPos: path2.oldPos + oldPosInc,
1754
- lastComponent: {
1755
- count: 1,
1756
- added,
1757
- removed,
1758
- previousComponent: last3
1729
+ if (callback) {
1730
+ (function exec() {
1731
+ setTimeout(function() {
1732
+ if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
1733
+ return callback(void 0);
1734
+ }
1735
+ if (!execEditLength()) {
1736
+ exec();
1737
+ }
1738
+ }, 0);
1739
+ })();
1740
+ } else {
1741
+ while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
1742
+ var ret = execEditLength();
1743
+ if (ret) {
1744
+ return ret;
1745
+ }
1759
1746
  }
1760
- };
1761
- }
1762
- },
1763
- extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath, options) {
1764
- var newLen = newString.length, oldLen = oldString.length, oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
1765
- while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldString[oldPos + 1], newString[newPos + 1], options)) {
1766
- newPos++;
1767
- oldPos++;
1768
- commonCount++;
1769
- if (options.oneChangePerToken) {
1770
- basePath.lastComponent = {
1771
- count: 1,
1772
- previousComponent: basePath.lastComponent,
1773
- added: false,
1774
- removed: false
1747
+ }
1748
+ };
1749
+ Diff2.prototype.addToPath = function(path2, added, removed, oldPosInc, options) {
1750
+ var last3 = path2.lastComponent;
1751
+ if (last3 && !options.oneChangePerToken && last3.added === added && last3.removed === removed) {
1752
+ return {
1753
+ oldPos: path2.oldPos + oldPosInc,
1754
+ lastComponent: { count: last3.count + 1, added, removed, previousComponent: last3.previousComponent }
1755
+ };
1756
+ } else {
1757
+ return {
1758
+ oldPos: path2.oldPos + oldPosInc,
1759
+ lastComponent: { count: 1, added, removed, previousComponent: last3 }
1775
1760
  };
1776
1761
  }
1777
- }
1778
- if (commonCount && !options.oneChangePerToken) {
1779
- basePath.lastComponent = {
1780
- count: commonCount,
1781
- previousComponent: basePath.lastComponent,
1782
- added: false,
1783
- removed: false
1784
- };
1785
- }
1786
- basePath.oldPos = oldPos;
1787
- return newPos;
1788
- },
1789
- equals: function equals(left2, right2, options) {
1790
- if (options.comparator) {
1791
- return options.comparator(left2, right2);
1792
- } else {
1793
- return left2 === right2 || options.ignoreCase && left2.toLowerCase() === right2.toLowerCase();
1794
- }
1795
- },
1796
- removeEmpty: function removeEmpty(array) {
1797
- var ret = [];
1798
- for (var i = 0; i < array.length; i++) {
1799
- if (array[i]) {
1800
- ret.push(array[i]);
1762
+ };
1763
+ Diff2.prototype.extractCommon = function(basePath, newTokens, oldTokens, diagonalPath, options) {
1764
+ var newLen = newTokens.length, oldLen = oldTokens.length;
1765
+ var oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
1766
+ while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
1767
+ newPos++;
1768
+ oldPos++;
1769
+ commonCount++;
1770
+ if (options.oneChangePerToken) {
1771
+ basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };
1772
+ }
1801
1773
  }
1802
- }
1803
- return ret;
1804
- },
1805
- castInput: function castInput(value) {
1806
- return value;
1807
- },
1808
- tokenize: function tokenize(value) {
1809
- return Array.from(value);
1810
- },
1811
- join: function join(chars) {
1812
- return chars.join("");
1813
- },
1814
- postProcess: function postProcess(changeObjects) {
1815
- return changeObjects;
1816
- }
1817
- };
1818
- function buildValues(diff2, lastComponent, newString, oldString, useLongestToken) {
1819
- var components = [];
1820
- var nextComponent;
1821
- while (lastComponent) {
1822
- components.push(lastComponent);
1823
- nextComponent = lastComponent.previousComponent;
1824
- delete lastComponent.previousComponent;
1825
- lastComponent = nextComponent;
1826
- }
1827
- components.reverse();
1828
- var componentPos = 0, componentLen = components.length, newPos = 0, oldPos = 0;
1829
- for (; componentPos < componentLen; componentPos++) {
1830
- var component = components[componentPos];
1831
- if (!component.removed) {
1832
- if (!component.added && useLongestToken) {
1833
- var value = newString.slice(newPos, newPos + component.count);
1834
- value = value.map(function(value2, i) {
1835
- var oldValue = oldString[oldPos + i];
1836
- return oldValue.length > value2.length ? oldValue : value2;
1837
- });
1838
- component.value = diff2.join(value);
1774
+ if (commonCount && !options.oneChangePerToken) {
1775
+ basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };
1776
+ }
1777
+ basePath.oldPos = oldPos;
1778
+ return newPos;
1779
+ };
1780
+ Diff2.prototype.equals = function(left2, right2, options) {
1781
+ if (options.comparator) {
1782
+ return options.comparator(left2, right2);
1839
1783
  } else {
1840
- component.value = diff2.join(newString.slice(newPos, newPos + component.count));
1784
+ return left2 === right2 || !!options.ignoreCase && left2.toLowerCase() === right2.toLowerCase();
1841
1785
  }
1842
- newPos += component.count;
1843
- if (!component.added) {
1844
- oldPos += component.count;
1786
+ };
1787
+ Diff2.prototype.removeEmpty = function(array) {
1788
+ var ret = [];
1789
+ for (var i = 0; i < array.length; i++) {
1790
+ if (array[i]) {
1791
+ ret.push(array[i]);
1792
+ }
1845
1793
  }
1846
- } else {
1847
- component.value = diff2.join(oldString.slice(oldPos, oldPos + component.count));
1848
- oldPos += component.count;
1849
- }
1850
- }
1851
- return components;
1852
- }
1853
- var characterDiff = new Diff();
1794
+ return ret;
1795
+ };
1796
+ Diff2.prototype.castInput = function(value, options) {
1797
+ return value;
1798
+ };
1799
+ Diff2.prototype.tokenize = function(value, options) {
1800
+ return Array.from(value);
1801
+ };
1802
+ Diff2.prototype.join = function(chars) {
1803
+ return chars.join("");
1804
+ };
1805
+ Diff2.prototype.postProcess = function(changeObjects, options) {
1806
+ return changeObjects;
1807
+ };
1808
+ Object.defineProperty(Diff2.prototype, "useLongestToken", {
1809
+ get: function() {
1810
+ return false;
1811
+ },
1812
+ enumerable: false,
1813
+ configurable: true
1814
+ });
1815
+ Diff2.prototype.buildValues = function(lastComponent, newTokens, oldTokens) {
1816
+ var components = [];
1817
+ var nextComponent;
1818
+ while (lastComponent) {
1819
+ components.push(lastComponent);
1820
+ nextComponent = lastComponent.previousComponent;
1821
+ delete lastComponent.previousComponent;
1822
+ lastComponent = nextComponent;
1823
+ }
1824
+ components.reverse();
1825
+ var componentLen = components.length;
1826
+ var componentPos = 0, newPos = 0, oldPos = 0;
1827
+ for (; componentPos < componentLen; componentPos++) {
1828
+ var component = components[componentPos];
1829
+ if (!component.removed) {
1830
+ if (!component.added && this.useLongestToken) {
1831
+ var value = newTokens.slice(newPos, newPos + component.count);
1832
+ value = value.map(function(value2, i) {
1833
+ var oldValue = oldTokens[oldPos + i];
1834
+ return oldValue.length > value2.length ? oldValue : value2;
1835
+ });
1836
+ component.value = this.join(value);
1837
+ } else {
1838
+ component.value = this.join(newTokens.slice(newPos, newPos + component.count));
1839
+ }
1840
+ newPos += component.count;
1841
+ if (!component.added) {
1842
+ oldPos += component.count;
1843
+ }
1844
+ } else {
1845
+ component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
1846
+ oldPos += component.count;
1847
+ }
1848
+ }
1849
+ return components;
1850
+ };
1851
+ return Diff2;
1852
+ }()
1853
+ );
1854
+ var base_default = Diff;
1855
+
1856
+ // ../../node_modules/.pnpm/diff@8.0.1/node_modules/diff/libesm/diff/character.js
1857
+ var __extends = /* @__PURE__ */ function() {
1858
+ var extendStatics = function(d, b) {
1859
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
1860
+ d2.__proto__ = b2;
1861
+ } || function(d2, b2) {
1862
+ for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p];
1863
+ };
1864
+ return extendStatics(d, b);
1865
+ };
1866
+ return function(d, b) {
1867
+ if (typeof b !== "function" && b !== null)
1868
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
1869
+ extendStatics(d, b);
1870
+ function __() {
1871
+ this.constructor = d;
1872
+ }
1873
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1874
+ };
1875
+ }();
1876
+ var CharacterDiff = (
1877
+ /** @class */
1878
+ function(_super) {
1879
+ __extends(CharacterDiff2, _super);
1880
+ function CharacterDiff2() {
1881
+ return _super !== null && _super.apply(this, arguments) || this;
1882
+ }
1883
+ return CharacterDiff2;
1884
+ }(base_default)
1885
+ );
1886
+ var characterDiff = new CharacterDiff();
1887
+
1888
+ // ../../node_modules/.pnpm/diff@8.0.1/node_modules/diff/libesm/util/string.js
1854
1889
  function longestCommonPrefix(str1, str2) {
1855
1890
  var i;
1856
1891
  for (i = 0; i < str1.length && i < str2.length; i++) {
@@ -1932,92 +1967,139 @@ function overlapCount(a, b) {
1932
1967
  }
1933
1968
  return k;
1934
1969
  }
1970
+ function trailingWs(string) {
1971
+ var i;
1972
+ for (i = string.length - 1; i >= 0; i--) {
1973
+ if (!string[i].match(/\s/)) {
1974
+ break;
1975
+ }
1976
+ }
1977
+ return string.substring(i + 1);
1978
+ }
1979
+ function leadingWs(string) {
1980
+ var match = string.match(/^\s*/);
1981
+ return match ? match[0] : "";
1982
+ }
1983
+
1984
+ // ../../node_modules/.pnpm/diff@8.0.1/node_modules/diff/libesm/diff/word.js
1985
+ var __extends2 = /* @__PURE__ */ function() {
1986
+ var extendStatics = function(d, b) {
1987
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
1988
+ d2.__proto__ = b2;
1989
+ } || function(d2, b2) {
1990
+ for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p];
1991
+ };
1992
+ return extendStatics(d, b);
1993
+ };
1994
+ return function(d, b) {
1995
+ if (typeof b !== "function" && b !== null)
1996
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
1997
+ extendStatics(d, b);
1998
+ function __() {
1999
+ this.constructor = d;
2000
+ }
2001
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2002
+ };
2003
+ }();
1935
2004
  var extendedWordChars = "a-zA-Z0-9_\\u{C0}-\\u{FF}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";
1936
2005
  var tokenizeIncludingWhitespace = new RegExp("[".concat(extendedWordChars, "]+|\\s+|[^").concat(extendedWordChars, "]"), "ug");
1937
- var wordDiff = new Diff();
1938
- wordDiff.equals = function(left2, right2, options) {
1939
- if (options.ignoreCase) {
1940
- left2 = left2.toLowerCase();
1941
- right2 = right2.toLowerCase();
1942
- }
1943
- return left2.trim() === right2.trim();
1944
- };
1945
- wordDiff.tokenize = function(value) {
1946
- var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1947
- var parts;
1948
- if (options.intlSegmenter) {
1949
- if (options.intlSegmenter.resolvedOptions().granularity != "word") {
1950
- throw new Error('The segmenter passed must have a granularity of "word"');
1951
- }
1952
- parts = Array.from(options.intlSegmenter.segment(value), function(segment) {
1953
- return segment.segment;
1954
- });
1955
- } else {
1956
- parts = value.match(tokenizeIncludingWhitespace) || [];
1957
- }
1958
- var tokens = [];
1959
- var prevPart = null;
1960
- parts.forEach(function(part) {
1961
- if (/\s/.test(part)) {
1962
- if (prevPart == null) {
1963
- tokens.push(part);
1964
- } else {
1965
- tokens.push(tokens.pop() + part);
1966
- }
1967
- } else if (/\s/.test(prevPart)) {
1968
- if (tokens[tokens.length - 1] == prevPart) {
1969
- tokens.push(tokens.pop() + part);
2006
+ var WordDiff = (
2007
+ /** @class */
2008
+ function(_super) {
2009
+ __extends2(WordDiff2, _super);
2010
+ function WordDiff2() {
2011
+ return _super !== null && _super.apply(this, arguments) || this;
2012
+ }
2013
+ WordDiff2.prototype.equals = function(left2, right2, options) {
2014
+ if (options.ignoreCase) {
2015
+ left2 = left2.toLowerCase();
2016
+ right2 = right2.toLowerCase();
2017
+ }
2018
+ return left2.trim() === right2.trim();
2019
+ };
2020
+ WordDiff2.prototype.tokenize = function(value, options) {
2021
+ if (options === void 0) {
2022
+ options = {};
2023
+ }
2024
+ var parts;
2025
+ if (options.intlSegmenter) {
2026
+ var segmenter = options.intlSegmenter;
2027
+ if (segmenter.resolvedOptions().granularity != "word") {
2028
+ throw new Error('The segmenter passed must have a granularity of "word"');
2029
+ }
2030
+ parts = Array.from(segmenter.segment(value), function(segment) {
2031
+ return segment.segment;
2032
+ });
1970
2033
  } else {
1971
- tokens.push(prevPart + part);
1972
- }
1973
- } else {
1974
- tokens.push(part);
1975
- }
1976
- prevPart = part;
1977
- });
1978
- return tokens;
1979
- };
1980
- wordDiff.join = function(tokens) {
1981
- return tokens.map(function(token2, i) {
1982
- if (i == 0) {
1983
- return token2;
1984
- } else {
1985
- return token2.replace(/^\s+/, "");
1986
- }
1987
- }).join("");
1988
- };
1989
- wordDiff.postProcess = function(changes, options) {
1990
- if (!changes || options.oneChangePerToken) {
1991
- return changes;
1992
- }
1993
- var lastKeep = null;
1994
- var insertion = null;
1995
- var deletion = null;
1996
- changes.forEach(function(change) {
1997
- if (change.added) {
1998
- insertion = change;
1999
- } else if (change.removed) {
2000
- deletion = change;
2001
- } else {
2034
+ parts = value.match(tokenizeIncludingWhitespace) || [];
2035
+ }
2036
+ var tokens = [];
2037
+ var prevPart = null;
2038
+ parts.forEach(function(part) {
2039
+ if (/\s/.test(part)) {
2040
+ if (prevPart == null) {
2041
+ tokens.push(part);
2042
+ } else {
2043
+ tokens.push(tokens.pop() + part);
2044
+ }
2045
+ } else if (prevPart != null && /\s/.test(prevPart)) {
2046
+ if (tokens[tokens.length - 1] == prevPart) {
2047
+ tokens.push(tokens.pop() + part);
2048
+ } else {
2049
+ tokens.push(prevPart + part);
2050
+ }
2051
+ } else {
2052
+ tokens.push(part);
2053
+ }
2054
+ prevPart = part;
2055
+ });
2056
+ return tokens;
2057
+ };
2058
+ WordDiff2.prototype.join = function(tokens) {
2059
+ return tokens.map(function(token2, i) {
2060
+ if (i == 0) {
2061
+ return token2;
2062
+ } else {
2063
+ return token2.replace(/^\s+/, "");
2064
+ }
2065
+ }).join("");
2066
+ };
2067
+ WordDiff2.prototype.postProcess = function(changes, options) {
2068
+ if (!changes || options.oneChangePerToken) {
2069
+ return changes;
2070
+ }
2071
+ var lastKeep = null;
2072
+ var insertion = null;
2073
+ var deletion = null;
2074
+ changes.forEach(function(change) {
2075
+ if (change.added) {
2076
+ insertion = change;
2077
+ } else if (change.removed) {
2078
+ deletion = change;
2079
+ } else {
2080
+ if (insertion || deletion) {
2081
+ dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, change);
2082
+ }
2083
+ lastKeep = change;
2084
+ insertion = null;
2085
+ deletion = null;
2086
+ }
2087
+ });
2002
2088
  if (insertion || deletion) {
2003
- dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, change);
2089
+ dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, null);
2004
2090
  }
2005
- lastKeep = change;
2006
- insertion = null;
2007
- deletion = null;
2008
- }
2009
- });
2010
- if (insertion || deletion) {
2011
- dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, null);
2012
- }
2013
- return changes;
2014
- };
2091
+ return changes;
2092
+ };
2093
+ return WordDiff2;
2094
+ }(base_default)
2095
+ );
2096
+ var wordDiff = new WordDiff();
2015
2097
  function dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep) {
2016
2098
  if (deletion && insertion) {
2017
- var oldWsPrefix = deletion.value.match(/^\s*/)[0];
2018
- var oldWsSuffix = deletion.value.match(/\s*$/)[0];
2019
- var newWsPrefix = insertion.value.match(/^\s*/)[0];
2020
- var newWsSuffix = insertion.value.match(/\s*$/)[0];
2099
+ var oldWsPrefix = leadingWs(deletion.value);
2100
+ var oldWsSuffix = trailingWs(deletion.value);
2101
+ var newWsPrefix = leadingWs(insertion.value);
2102
+ var newWsSuffix = trailingWs(insertion.value);
2021
2103
  if (startKeep) {
2022
2104
  var commonWsPrefix = longestCommonPrefix(oldWsPrefix, newWsPrefix);
2023
2105
  startKeep.value = replaceSuffix(startKeep.value, newWsPrefix, commonWsPrefix);
@@ -2032,13 +2114,15 @@ function dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep
2032
2114
  }
2033
2115
  } else if (insertion) {
2034
2116
  if (startKeep) {
2035
- insertion.value = insertion.value.replace(/^\s*/, "");
2117
+ var ws = leadingWs(insertion.value);
2118
+ insertion.value = insertion.value.substring(ws.length);
2036
2119
  }
2037
2120
  if (endKeep) {
2038
- endKeep.value = endKeep.value.replace(/^\s*/, "");
2121
+ var ws = leadingWs(endKeep.value);
2122
+ endKeep.value = endKeep.value.substring(ws.length);
2039
2123
  }
2040
2124
  } else if (startKeep && endKeep) {
2041
- var newWsFull = endKeep.value.match(/^\s*/)[0], delWsStart = deletion.value.match(/^\s*/)[0], delWsEnd = deletion.value.match(/\s*$/)[0];
2125
+ var newWsFull = leadingWs(endKeep.value), delWsStart = leadingWs(deletion.value), delWsEnd = trailingWs(deletion.value);
2042
2126
  var newWsStart = longestCommonPrefix(newWsFull, delWsStart);
2043
2127
  deletion.value = removePrefix(deletion.value, newWsStart);
2044
2128
  var newWsEnd = longestCommonSuffix(removePrefix(newWsFull, newWsStart), delWsEnd);
@@ -2046,24 +2130,85 @@ function dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep
2046
2130
  endKeep.value = replacePrefix(endKeep.value, newWsFull, newWsEnd);
2047
2131
  startKeep.value = replaceSuffix(startKeep.value, newWsFull, newWsFull.slice(0, newWsFull.length - newWsEnd.length));
2048
2132
  } else if (endKeep) {
2049
- var endKeepWsPrefix = endKeep.value.match(/^\s*/)[0];
2050
- var deletionWsSuffix = deletion.value.match(/\s*$/)[0];
2133
+ var endKeepWsPrefix = leadingWs(endKeep.value);
2134
+ var deletionWsSuffix = trailingWs(deletion.value);
2051
2135
  var overlap = maximumOverlap(deletionWsSuffix, endKeepWsPrefix);
2052
2136
  deletion.value = removeSuffix(deletion.value, overlap);
2053
2137
  } else if (startKeep) {
2054
- var startKeepWsSuffix = startKeep.value.match(/\s*$/)[0];
2055
- var deletionWsPrefix = deletion.value.match(/^\s*/)[0];
2056
- var _overlap = maximumOverlap(startKeepWsSuffix, deletionWsPrefix);
2057
- deletion.value = removePrefix(deletion.value, _overlap);
2058
- }
2059
- }
2060
- var wordWithSpaceDiff = new Diff();
2061
- wordWithSpaceDiff.tokenize = function(value) {
2062
- var regex = new RegExp("(\\r?\\n)|[".concat(extendedWordChars, "]+|[^\\S\\n\\r]+|[^").concat(extendedWordChars, "]"), "ug");
2063
- return value.match(regex) || [];
2064
- };
2065
- var lineDiff = new Diff();
2066
- lineDiff.tokenize = function(value, options) {
2138
+ var startKeepWsSuffix = trailingWs(startKeep.value);
2139
+ var deletionWsPrefix = leadingWs(deletion.value);
2140
+ var overlap = maximumOverlap(startKeepWsSuffix, deletionWsPrefix);
2141
+ deletion.value = removePrefix(deletion.value, overlap);
2142
+ }
2143
+ }
2144
+ var WordsWithSpaceDiff = (
2145
+ /** @class */
2146
+ function(_super) {
2147
+ __extends2(WordsWithSpaceDiff2, _super);
2148
+ function WordsWithSpaceDiff2() {
2149
+ return _super !== null && _super.apply(this, arguments) || this;
2150
+ }
2151
+ WordsWithSpaceDiff2.prototype.tokenize = function(value) {
2152
+ var regex = new RegExp("(\\r?\\n)|[".concat(extendedWordChars, "]+|[^\\S\\n\\r]+|[^").concat(extendedWordChars, "]"), "ug");
2153
+ return value.match(regex) || [];
2154
+ };
2155
+ return WordsWithSpaceDiff2;
2156
+ }(base_default)
2157
+ );
2158
+ var wordsWithSpaceDiff = new WordsWithSpaceDiff();
2159
+
2160
+ // ../../node_modules/.pnpm/diff@8.0.1/node_modules/diff/libesm/diff/line.js
2161
+ var __extends3 = /* @__PURE__ */ function() {
2162
+ var extendStatics = function(d, b) {
2163
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
2164
+ d2.__proto__ = b2;
2165
+ } || function(d2, b2) {
2166
+ for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p];
2167
+ };
2168
+ return extendStatics(d, b);
2169
+ };
2170
+ return function(d, b) {
2171
+ if (typeof b !== "function" && b !== null)
2172
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
2173
+ extendStatics(d, b);
2174
+ function __() {
2175
+ this.constructor = d;
2176
+ }
2177
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2178
+ };
2179
+ }();
2180
+ var LineDiff = (
2181
+ /** @class */
2182
+ function(_super) {
2183
+ __extends3(LineDiff2, _super);
2184
+ function LineDiff2() {
2185
+ var _this = _super !== null && _super.apply(this, arguments) || this;
2186
+ _this.tokenize = tokenize;
2187
+ return _this;
2188
+ }
2189
+ LineDiff2.prototype.equals = function(left2, right2, options) {
2190
+ if (options.ignoreWhitespace) {
2191
+ if (!options.newlineIsToken || !left2.includes("\n")) {
2192
+ left2 = left2.trim();
2193
+ }
2194
+ if (!options.newlineIsToken || !right2.includes("\n")) {
2195
+ right2 = right2.trim();
2196
+ }
2197
+ } else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
2198
+ if (left2.endsWith("\n")) {
2199
+ left2 = left2.slice(0, -1);
2200
+ }
2201
+ if (right2.endsWith("\n")) {
2202
+ right2 = right2.slice(0, -1);
2203
+ }
2204
+ }
2205
+ return _super.prototype.equals.call(this, left2, right2, options);
2206
+ };
2207
+ return LineDiff2;
2208
+ }(base_default)
2209
+ );
2210
+ var lineDiff = new LineDiff();
2211
+ function tokenize(value, options) {
2067
2212
  if (options.stripTrailingCr) {
2068
2213
  value = value.replace(/\r\n/g, "\n");
2069
2214
  }
@@ -2080,58 +2225,132 @@ lineDiff.tokenize = function(value, options) {
2080
2225
  }
2081
2226
  }
2082
2227
  return retLines;
2083
- };
2084
- lineDiff.equals = function(left2, right2, options) {
2085
- if (options.ignoreWhitespace) {
2086
- if (!options.newlineIsToken || !left2.includes("\n")) {
2087
- left2 = left2.trim();
2088
- }
2089
- if (!options.newlineIsToken || !right2.includes("\n")) {
2090
- right2 = right2.trim();
2091
- }
2092
- } else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
2093
- if (left2.endsWith("\n")) {
2094
- left2 = left2.slice(0, -1);
2095
- }
2096
- if (right2.endsWith("\n")) {
2097
- right2 = right2.slice(0, -1);
2098
- }
2099
- }
2100
- return Diff.prototype.equals.call(this, left2, right2, options);
2101
- };
2102
- var sentenceDiff = new Diff();
2103
- sentenceDiff.tokenize = function(value) {
2104
- return value.split(/(\S.+?[.!?])(?=\s+|$)/);
2105
- };
2106
- var cssDiff = new Diff();
2107
- cssDiff.tokenize = function(value) {
2108
- return value.split(/([{}:;,]|\s+)/);
2109
- };
2110
- function _typeof(o) {
2111
- "@babel/helpers - typeof";
2112
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
2113
- return typeof o2;
2114
- } : function(o2) {
2115
- return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
2116
- }, _typeof(o);
2117
- }
2118
- var jsonDiff = new Diff();
2119
- jsonDiff.useLongestToken = true;
2120
- jsonDiff.tokenize = lineDiff.tokenize;
2121
- jsonDiff.castInput = function(value, options) {
2122
- var undefinedReplacement = options.undefinedReplacement, _options$stringifyRep = options.stringifyReplacer, stringifyReplacer = _options$stringifyRep === void 0 ? function(k, v) {
2123
- return typeof v === "undefined" ? undefinedReplacement : v;
2124
- } : _options$stringifyRep;
2125
- return typeof value === "string" ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, " ");
2126
- };
2127
- jsonDiff.equals = function(left2, right2, options) {
2128
- return Diff.prototype.equals.call(jsonDiff, left2.replace(/,([\r\n])/g, "$1"), right2.replace(/,([\r\n])/g, "$1"), options);
2129
- };
2228
+ }
2229
+
2230
+ // ../../node_modules/.pnpm/diff@8.0.1/node_modules/diff/libesm/diff/sentence.js
2231
+ var __extends4 = /* @__PURE__ */ function() {
2232
+ var extendStatics = function(d, b) {
2233
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
2234
+ d2.__proto__ = b2;
2235
+ } || function(d2, b2) {
2236
+ for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p];
2237
+ };
2238
+ return extendStatics(d, b);
2239
+ };
2240
+ return function(d, b) {
2241
+ if (typeof b !== "function" && b !== null)
2242
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
2243
+ extendStatics(d, b);
2244
+ function __() {
2245
+ this.constructor = d;
2246
+ }
2247
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2248
+ };
2249
+ }();
2250
+ var SentenceDiff = (
2251
+ /** @class */
2252
+ function(_super) {
2253
+ __extends4(SentenceDiff2, _super);
2254
+ function SentenceDiff2() {
2255
+ return _super !== null && _super.apply(this, arguments) || this;
2256
+ }
2257
+ SentenceDiff2.prototype.tokenize = function(value) {
2258
+ return value.split(/(?<=[.!?])(\s+|$)/);
2259
+ };
2260
+ return SentenceDiff2;
2261
+ }(base_default)
2262
+ );
2263
+ var sentenceDiff = new SentenceDiff();
2264
+
2265
+ // ../../node_modules/.pnpm/diff@8.0.1/node_modules/diff/libesm/diff/css.js
2266
+ var __extends5 = /* @__PURE__ */ function() {
2267
+ var extendStatics = function(d, b) {
2268
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
2269
+ d2.__proto__ = b2;
2270
+ } || function(d2, b2) {
2271
+ for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p];
2272
+ };
2273
+ return extendStatics(d, b);
2274
+ };
2275
+ return function(d, b) {
2276
+ if (typeof b !== "function" && b !== null)
2277
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
2278
+ extendStatics(d, b);
2279
+ function __() {
2280
+ this.constructor = d;
2281
+ }
2282
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2283
+ };
2284
+ }();
2285
+ var CssDiff = (
2286
+ /** @class */
2287
+ function(_super) {
2288
+ __extends5(CssDiff2, _super);
2289
+ function CssDiff2() {
2290
+ return _super !== null && _super.apply(this, arguments) || this;
2291
+ }
2292
+ CssDiff2.prototype.tokenize = function(value) {
2293
+ return value.split(/([{}:;,]|\s+)/);
2294
+ };
2295
+ return CssDiff2;
2296
+ }(base_default)
2297
+ );
2298
+ var cssDiff = new CssDiff();
2299
+
2300
+ // ../../node_modules/.pnpm/diff@8.0.1/node_modules/diff/libesm/diff/json.js
2301
+ var __extends6 = /* @__PURE__ */ function() {
2302
+ var extendStatics = function(d, b) {
2303
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
2304
+ d2.__proto__ = b2;
2305
+ } || function(d2, b2) {
2306
+ for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p];
2307
+ };
2308
+ return extendStatics(d, b);
2309
+ };
2310
+ return function(d, b) {
2311
+ if (typeof b !== "function" && b !== null)
2312
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
2313
+ extendStatics(d, b);
2314
+ function __() {
2315
+ this.constructor = d;
2316
+ }
2317
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2318
+ };
2319
+ }();
2320
+ var JsonDiff = (
2321
+ /** @class */
2322
+ function(_super) {
2323
+ __extends6(JsonDiff2, _super);
2324
+ function JsonDiff2() {
2325
+ var _this = _super !== null && _super.apply(this, arguments) || this;
2326
+ _this.tokenize = tokenize;
2327
+ return _this;
2328
+ }
2329
+ Object.defineProperty(JsonDiff2.prototype, "useLongestToken", {
2330
+ get: function() {
2331
+ return true;
2332
+ },
2333
+ enumerable: false,
2334
+ configurable: true
2335
+ });
2336
+ JsonDiff2.prototype.castInput = function(value, options) {
2337
+ var undefinedReplacement = options.undefinedReplacement, _a2 = options.stringifyReplacer, stringifyReplacer = _a2 === void 0 ? function(k, v) {
2338
+ return typeof v === "undefined" ? undefinedReplacement : v;
2339
+ } : _a2;
2340
+ return typeof value === "string" ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), null, " ");
2341
+ };
2342
+ JsonDiff2.prototype.equals = function(left2, right2, options) {
2343
+ return _super.prototype.equals.call(this, left2.replace(/,([\r\n])/g, "$1"), right2.replace(/,([\r\n])/g, "$1"), options);
2344
+ };
2345
+ return JsonDiff2;
2346
+ }(base_default)
2347
+ );
2348
+ var jsonDiff = new JsonDiff();
2130
2349
  function canonicalize(obj, stack, replacementStack, replacer, key) {
2131
2350
  stack = stack || [];
2132
2351
  replacementStack = replacementStack || [];
2133
2352
  if (replacer) {
2134
- obj = replacer(key, obj);
2353
+ obj = replacer(key === void 0 ? "" : key, obj);
2135
2354
  }
2136
2355
  var i;
2137
2356
  for (i = 0; i < stack.length; i += 1) {
@@ -2145,7 +2364,7 @@ function canonicalize(obj, stack, replacementStack, replacer, key) {
2145
2364
  canonicalizedObj = new Array(obj.length);
2146
2365
  replacementStack.push(canonicalizedObj);
2147
2366
  for (i = 0; i < obj.length; i += 1) {
2148
- canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key);
2367
+ canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, String(i));
2149
2368
  }
2150
2369
  stack.pop();
2151
2370
  replacementStack.pop();
@@ -2154,20 +2373,21 @@ function canonicalize(obj, stack, replacementStack, replacer, key) {
2154
2373
  if (obj && obj.toJSON) {
2155
2374
  obj = obj.toJSON();
2156
2375
  }
2157
- if (_typeof(obj) === "object" && obj !== null) {
2376
+ if (typeof obj === "object" && obj !== null) {
2158
2377
  stack.push(obj);
2159
2378
  canonicalizedObj = {};
2160
2379
  replacementStack.push(canonicalizedObj);
2161
- var sortedKeys = [], _key;
2162
- for (_key in obj) {
2163
- if (Object.prototype.hasOwnProperty.call(obj, _key)) {
2164
- sortedKeys.push(_key);
2380
+ var sortedKeys = [];
2381
+ var key_1;
2382
+ for (key_1 in obj) {
2383
+ if (Object.prototype.hasOwnProperty.call(obj, key_1)) {
2384
+ sortedKeys.push(key_1);
2165
2385
  }
2166
2386
  }
2167
2387
  sortedKeys.sort();
2168
2388
  for (i = 0; i < sortedKeys.length; i += 1) {
2169
- _key = sortedKeys[i];
2170
- canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
2389
+ key_1 = sortedKeys[i];
2390
+ canonicalizedObj[key_1] = canonicalize(obj[key_1], stack, replacementStack, replacer, key_1);
2171
2391
  }
2172
2392
  stack.pop();
2173
2393
  replacementStack.pop();
@@ -2176,16 +2396,47 @@ function canonicalize(obj, stack, replacementStack, replacer, key) {
2176
2396
  }
2177
2397
  return canonicalizedObj;
2178
2398
  }
2179
- var arrayDiff = new Diff();
2180
- arrayDiff.tokenize = function(value) {
2181
- return value.slice();
2182
- };
2183
- arrayDiff.join = arrayDiff.removeEmpty = function(value) {
2184
- return value;
2185
- };
2186
2399
 
2187
- // src/cli.ts
2188
- import fs from "fs";
2400
+ // ../../node_modules/.pnpm/diff@8.0.1/node_modules/diff/libesm/diff/array.js
2401
+ var __extends7 = /* @__PURE__ */ function() {
2402
+ var extendStatics = function(d, b) {
2403
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
2404
+ d2.__proto__ = b2;
2405
+ } || function(d2, b2) {
2406
+ for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p];
2407
+ };
2408
+ return extendStatics(d, b);
2409
+ };
2410
+ return function(d, b) {
2411
+ if (typeof b !== "function" && b !== null)
2412
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
2413
+ extendStatics(d, b);
2414
+ function __() {
2415
+ this.constructor = d;
2416
+ }
2417
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2418
+ };
2419
+ }();
2420
+ var ArrayDiff = (
2421
+ /** @class */
2422
+ function(_super) {
2423
+ __extends7(ArrayDiff2, _super);
2424
+ function ArrayDiff2() {
2425
+ return _super !== null && _super.apply(this, arguments) || this;
2426
+ }
2427
+ ArrayDiff2.prototype.tokenize = function(value) {
2428
+ return value.slice();
2429
+ };
2430
+ ArrayDiff2.prototype.join = function(value) {
2431
+ return value;
2432
+ };
2433
+ ArrayDiff2.prototype.removeEmpty = function(value) {
2434
+ return value;
2435
+ };
2436
+ return ArrayDiff2;
2437
+ }(base_default)
2438
+ );
2439
+ var arrayDiff = new ArrayDiff();
2189
2440
 
2190
2441
  // ../mini-parse/src/Assertions.ts
2191
2442
  function assertThat(condition, msg) {
@@ -2714,7 +2965,7 @@ function parserArg(arg) {
2714
2965
  function fn(fn2) {
2715
2966
  const parser3 = new Parser2({
2716
2967
  fn: function _fn(state) {
2717
- let generatedParser = fn2();
2968
+ const generatedParser = fn2();
2718
2969
  if (!fn2) {
2719
2970
  const before = state.stream.checkpoint();
2720
2971
  throw new ParseError(`fn parser called before definition`, [
@@ -3036,7 +3287,7 @@ function runParserWithTracing(debugName, fn2, context, traceInfo) {
3036
3287
  parserLog(`..${debugName}`);
3037
3288
  }
3038
3289
  }
3039
- let result2 = fn2(ctx);
3290
+ const result2 = fn2(ctx);
3040
3291
  if (result2 === null) {
3041
3292
  if (tracing) {
3042
3293
  const traceSuccessOnly = ctx._trace?.successOnly;
@@ -3369,9 +3620,6 @@ function findGroupDex(indices) {
3369
3620
  }
3370
3621
  }
3371
3622
 
3372
- // src/cli.ts
3373
- import path from "path";
3374
-
3375
3623
  // ../wesl/src/Assertions.ts
3376
3624
  function assertThat2(condition, msg) {
3377
3625
  if (!condition) {
@@ -3416,13 +3664,13 @@ function mapValues(obj, fn2) {
3416
3664
  return Object.fromEntries(Object.entries(obj).map(([k, v]) => [k, fn2(v)]));
3417
3665
  }
3418
3666
  function offsetToLineNumber(offset, text2) {
3419
- offset = Math.min(text2.length, Math.max(0, offset));
3667
+ const safeOffset = Math.min(text2.length, Math.max(0, offset));
3420
3668
  let lineStartOffset = 0;
3421
3669
  let lineNum = 1;
3422
3670
  while (true) {
3423
3671
  const lineEnd = text2.indexOf("\n", lineStartOffset);
3424
- if (lineEnd === -1 || offset <= lineEnd) {
3425
- const linePos = 1 + (offset - lineStartOffset);
3672
+ if (lineEnd === -1 || safeOffset <= lineEnd) {
3673
+ const linePos = 1 + (safeOffset - lineStartOffset);
3426
3674
  return [lineNum, linePos];
3427
3675
  } else {
3428
3676
  lineStartOffset = lineEnd + 1;
@@ -3467,19 +3715,20 @@ function encodeVlq(value) {
3467
3715
  }
3468
3716
  function encode_integer(num) {
3469
3717
  let result = "";
3718
+ let enc;
3470
3719
  if (num < 0) {
3471
- num = -num << 1 | 1;
3720
+ enc = -num << 1 | 1;
3472
3721
  } else {
3473
- num <<= 1;
3722
+ enc = num << 1;
3474
3723
  }
3475
3724
  do {
3476
- let clamped = num & 31;
3477
- num >>>= 5;
3478
- if (num > 0) {
3725
+ let clamped = enc & 31;
3726
+ enc >>>= 5;
3727
+ if (enc > 0) {
3479
3728
  clamped |= 32;
3480
3729
  }
3481
3730
  result += integer_to_char[clamped];
3482
- } while (num > 0);
3731
+ } while (enc > 0);
3483
3732
  return result;
3484
3733
  }
3485
3734
 
@@ -4151,7 +4400,7 @@ var memberRefCollect = collectElem(
4151
4400
  }
4152
4401
  );
4153
4402
  function nameCollect(cc) {
4154
- const { start, end, src, app } = cc;
4403
+ const { start, end, src } = cc;
4155
4404
  const name2 = src.slice(start, end);
4156
4405
  const elem = { kind: "name", start, end, name: name2 };
4157
4406
  addToOpenElem(cc, elem);
@@ -4390,6 +4639,7 @@ var weslMatcher = new RegexMatchers({
4390
4639
  blankspaces,
4391
4640
  commentStart,
4392
4641
  symbol: matchOneOf(symbolSet),
4642
+ // biome-ignore lint/correctness/noEmptyCharacterClassInRegex: TODO
4393
4643
  invalid: /[^]/
4394
4644
  });
4395
4645
  function weslExtension(combinator) {
@@ -4445,7 +4695,8 @@ var WeslStream = class {
4445
4695
  return this.eolPattern.lastIndex;
4446
4696
  }
4447
4697
  }
4448
- skipBlockComment(position) {
4698
+ skipBlockComment(start) {
4699
+ let position = start;
4449
4700
  while (true) {
4450
4701
  this.blockCommentPattern.lastIndex = position;
4451
4702
  const result = this.blockCommentPattern.exec(this.src);
@@ -4866,10 +5117,7 @@ var struct_member = tagScope(
4866
5117
  ).collect(collectStructMember)
4867
5118
  ).ctag("members");
4868
5119
  var struct_decl = seq(
4869
- weslExtension(opt_attributes).collect(
4870
- (cc) => cc.tags.attribute,
4871
- "attributes"
4872
- ),
5120
+ weslExtension(opt_attributes).collect((cc) => cc.tags.attribute, "attributes"),
4873
5121
  "struct",
4874
5122
  req(globalTypeNameDecl, "invalid struct, expected name"),
4875
5123
  seq(
@@ -5174,10 +5422,7 @@ var global_value_decl = or(
5174
5422
  ).collect(collectVarLike("const"))
5175
5423
  ).collect(partialScopeCollect);
5176
5424
  var global_alias = seq(
5177
- weslExtension(opt_attributes).collect(
5178
- (cc) => cc.tags.attribute,
5179
- "attributes"
5180
- ),
5425
+ weslExtension(opt_attributes).collect((cc) => cc.tags.attribute, "attributes"),
5181
5426
  "alias",
5182
5427
  req(word, "invalid alias, expected name").collect(
5183
5428
  globalDeclCollect,
@@ -5418,7 +5663,7 @@ var WeslParseError = class extends Error {
5418
5663
  this.src = opts.src;
5419
5664
  }
5420
5665
  };
5421
- function parseSrcModule(srcModule, srcMap) {
5666
+ function parseSrcModule(srcModule) {
5422
5667
  const stream = new WeslStream(srcModule.src);
5423
5668
  const appState = blankWeslParseState(srcModule);
5424
5669
  const init = { stream, appState };
@@ -5910,9 +6155,7 @@ function emitAttributes(attributes, ctx) {
5910
6155
  function emitStruct(e, ctx) {
5911
6156
  const { name: name2, members, start, end } = e;
5912
6157
  const { srcBuilder } = ctx;
5913
- const validMembers = members.filter(
5914
- (m) => conditionsValid(m, ctx.conditions)
5915
- );
6158
+ const validMembers = members.filter((m) => conditionsValid(m, ctx.conditions));
5916
6159
  const validLength = validMembers.length;
5917
6160
  if (validLength === 0) {
5918
6161
  warnEmptyStruct(e);
@@ -6515,19 +6758,20 @@ function selectModule(parsed, selectPath, packageName = "package") {
6515
6758
  return parsed.modules[modulePath];
6516
6759
  }
6517
6760
  function parseIntoRegistry(srcFiles, registry, packageName = "package", debugWeslRoot) {
6518
- if (debugWeslRoot === void 0) {
6519
- debugWeslRoot = "";
6520
- } else if (!debugWeslRoot.endsWith("/")) {
6521
- debugWeslRoot += "/";
6761
+ let weslRoot2 = debugWeslRoot;
6762
+ if (weslRoot2 === void 0) {
6763
+ weslRoot2 = "";
6764
+ } else if (!weslRoot2.endsWith("/")) {
6765
+ weslRoot2 += "/";
6522
6766
  }
6523
6767
  const srcModules = Object.entries(srcFiles).map(
6524
6768
  ([filePath, src]) => {
6525
6769
  const modulePath = fileToModulePath(filePath, packageName);
6526
- return { modulePath, debugFilePath: debugWeslRoot + filePath, src };
6770
+ return { modulePath, debugFilePath: weslRoot2 + filePath, src };
6527
6771
  }
6528
6772
  );
6529
6773
  srcModules.forEach((mod) => {
6530
- const parsed = parseSrcModule(mod, void 0);
6774
+ const parsed = parseSrcModule(mod);
6531
6775
  if (registry.modules[mod.modulePath]) {
6532
6776
  throw new Error(`duplicate module path: '${mod.modulePath}'`);
6533
6777
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wesl-link",
3
- "version": "0.6.2",
3
+ "version": "0.6.6",
4
4
  "type": "module",
5
5
  "repository": "https://github.com/wgsl-tooling-wg/wesl-js/tree/main/packages/cli",
6
6
  "homepage": "https://github.com/wgsl-tooling-wg/wesl-js/tree/main/packages/cli#readme",
@@ -9,12 +9,12 @@
9
9
  ],
10
10
  "bin": "bin/wesl-link",
11
11
  "dependencies": {
12
- "@types/diff": "^7.0.2",
13
- "diff": "^7.0.0",
14
- "wesl": "0.6.2"
12
+ "@types/diff": "^8.0.0",
13
+ "diff": "^8.0.1",
14
+ "wesl": "0.6.6"
15
15
  },
16
16
  "devDependencies": {
17
- "mini-parse": "0.6.2"
17
+ "mini-parse": "0.6.6"
18
18
  },
19
19
  "scripts": {
20
20
  "echo": "echo",