wesl-link 0.6.1 → 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.
- package/bin/wesl-link +870 -578
- package/package.json +5 -5
package/bin/wesl-link
CHANGED
|
@@ -1634,223 +1634,258 @@ var esm_default = {
|
|
|
1634
1634
|
})
|
|
1635
1635
|
};
|
|
1636
1636
|
|
|
1637
|
-
//
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
if (
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
}
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
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
|
-
|
|
1675
|
+
return value;
|
|
1703
1676
|
}
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
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
|
-
|
|
1713
|
-
|
|
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
|
-
|
|
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 (!
|
|
1726
|
-
|
|
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
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
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
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
previousComponent:
|
|
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
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
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
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
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
|
-
|
|
1784
|
+
return left2 === right2 || !!options.ignoreCase && left2.toLowerCase() === right2.toLowerCase();
|
|
1841
1785
|
}
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
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
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
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
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
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
|
-
|
|
1972
|
-
}
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
}
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
}
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
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,
|
|
2089
|
+
dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, null);
|
|
2004
2090
|
}
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
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
|
|
2018
|
-
var oldWsSuffix = deletion.value
|
|
2019
|
-
var newWsPrefix = insertion.value
|
|
2020
|
-
var newWsSuffix = insertion.value
|
|
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
|
-
|
|
2117
|
+
var ws = leadingWs(insertion.value);
|
|
2118
|
+
insertion.value = insertion.value.substring(ws.length);
|
|
2036
2119
|
}
|
|
2037
2120
|
if (endKeep) {
|
|
2038
|
-
|
|
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
|
|
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
|
|
2050
|
-
var deletionWsSuffix = deletion.value
|
|
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
|
|
2055
|
-
var deletionWsPrefix = deletion.value
|
|
2056
|
-
var
|
|
2057
|
-
deletion.value = removePrefix(deletion.value,
|
|
2058
|
-
}
|
|
2059
|
-
}
|
|
2060
|
-
var
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
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
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
}
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
if (
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
}
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
return
|
|
2116
|
-
}
|
|
2117
|
-
|
|
2118
|
-
var
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
var
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
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,
|
|
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 (
|
|
2376
|
+
if (typeof obj === "object" && obj !== null) {
|
|
2158
2377
|
stack.push(obj);
|
|
2159
2378
|
canonicalizedObj = {};
|
|
2160
2379
|
replacementStack.push(canonicalizedObj);
|
|
2161
|
-
var sortedKeys = []
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
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
|
-
|
|
2170
|
-
canonicalizedObj[
|
|
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
|
-
//
|
|
2188
|
-
|
|
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) {
|
|
@@ -2302,12 +2553,10 @@ function logInternalSrc(log2, src, pos, ...msgs) {
|
|
|
2302
2553
|
log2(caret);
|
|
2303
2554
|
}
|
|
2304
2555
|
function carets(linePos, linePos2) {
|
|
2305
|
-
const
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
}
|
|
2310
|
-
return firstCaret + secondCaret;
|
|
2556
|
+
const indent = " ".repeat(linePos);
|
|
2557
|
+
const numCarets = linePos2 ? linePos2 - linePos : 1;
|
|
2558
|
+
const carets2 = "^".repeat(numCarets);
|
|
2559
|
+
return indent + carets2;
|
|
2311
2560
|
}
|
|
2312
2561
|
var startCache = /* @__PURE__ */ new Map();
|
|
2313
2562
|
function srcLine(src, position) {
|
|
@@ -2563,6 +2812,18 @@ function opt(arg) {
|
|
|
2563
2812
|
}
|
|
2564
2813
|
);
|
|
2565
2814
|
}
|
|
2815
|
+
function not(arg) {
|
|
2816
|
+
const p = parserArg(arg);
|
|
2817
|
+
return parser2("not", function _not(state) {
|
|
2818
|
+
const pos = state.stream.checkpoint();
|
|
2819
|
+
const result = p._run(state);
|
|
2820
|
+
if (result === null) {
|
|
2821
|
+
state.stream.reset(pos);
|
|
2822
|
+
return { value: true };
|
|
2823
|
+
}
|
|
2824
|
+
return null;
|
|
2825
|
+
});
|
|
2826
|
+
}
|
|
2566
2827
|
function repeat(arg) {
|
|
2567
2828
|
const p = parserArg(arg);
|
|
2568
2829
|
return parser2("repeat", repeatWhileFilter(p));
|
|
@@ -2704,7 +2965,7 @@ function parserArg(arg) {
|
|
|
2704
2965
|
function fn(fn2) {
|
|
2705
2966
|
const parser3 = new Parser2({
|
|
2706
2967
|
fn: function _fn(state) {
|
|
2707
|
-
|
|
2968
|
+
const generatedParser = fn2();
|
|
2708
2969
|
if (!fn2) {
|
|
2709
2970
|
const before = state.stream.checkpoint();
|
|
2710
2971
|
throw new ParseError(`fn parser called before definition`, [
|
|
@@ -3026,7 +3287,7 @@ function runParserWithTracing(debugName, fn2, context, traceInfo) {
|
|
|
3026
3287
|
parserLog(`..${debugName}`);
|
|
3027
3288
|
}
|
|
3028
3289
|
}
|
|
3029
|
-
|
|
3290
|
+
const result2 = fn2(ctx);
|
|
3030
3291
|
if (result2 === null) {
|
|
3031
3292
|
if (tracing) {
|
|
3032
3293
|
const traceSuccessOnly = ctx._trace?.successOnly;
|
|
@@ -3359,9 +3620,6 @@ function findGroupDex(indices) {
|
|
|
3359
3620
|
}
|
|
3360
3621
|
}
|
|
3361
3622
|
|
|
3362
|
-
// src/cli.ts
|
|
3363
|
-
import path from "path";
|
|
3364
|
-
|
|
3365
3623
|
// ../wesl/src/Assertions.ts
|
|
3366
3624
|
function assertThat2(condition, msg) {
|
|
3367
3625
|
if (!condition) {
|
|
@@ -3406,13 +3664,13 @@ function mapValues(obj, fn2) {
|
|
|
3406
3664
|
return Object.fromEntries(Object.entries(obj).map(([k, v]) => [k, fn2(v)]));
|
|
3407
3665
|
}
|
|
3408
3666
|
function offsetToLineNumber(offset, text2) {
|
|
3409
|
-
|
|
3667
|
+
const safeOffset = Math.min(text2.length, Math.max(0, offset));
|
|
3410
3668
|
let lineStartOffset = 0;
|
|
3411
3669
|
let lineNum = 1;
|
|
3412
3670
|
while (true) {
|
|
3413
3671
|
const lineEnd = text2.indexOf("\n", lineStartOffset);
|
|
3414
|
-
if (lineEnd === -1 ||
|
|
3415
|
-
const linePos = 1 + (
|
|
3672
|
+
if (lineEnd === -1 || safeOffset <= lineEnd) {
|
|
3673
|
+
const linePos = 1 + (safeOffset - lineStartOffset);
|
|
3416
3674
|
return [lineNum, linePos];
|
|
3417
3675
|
} else {
|
|
3418
3676
|
lineStartOffset = lineEnd + 1;
|
|
@@ -3438,6 +3696,111 @@ function errorHighlight(source, span2) {
|
|
|
3438
3696
|
];
|
|
3439
3697
|
}
|
|
3440
3698
|
|
|
3699
|
+
// ../wesl/src/vlq/vlq.ts
|
|
3700
|
+
var char_to_integer = {};
|
|
3701
|
+
var integer_to_char = {};
|
|
3702
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split("").forEach((char, i) => {
|
|
3703
|
+
char_to_integer[char] = i;
|
|
3704
|
+
integer_to_char[i] = char;
|
|
3705
|
+
});
|
|
3706
|
+
function encodeVlq(value) {
|
|
3707
|
+
if (typeof value === "number") {
|
|
3708
|
+
return encode_integer(value);
|
|
3709
|
+
}
|
|
3710
|
+
let result = "";
|
|
3711
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
3712
|
+
result += encode_integer(value[i]);
|
|
3713
|
+
}
|
|
3714
|
+
return result;
|
|
3715
|
+
}
|
|
3716
|
+
function encode_integer(num) {
|
|
3717
|
+
let result = "";
|
|
3718
|
+
let enc;
|
|
3719
|
+
if (num < 0) {
|
|
3720
|
+
enc = -num << 1 | 1;
|
|
3721
|
+
} else {
|
|
3722
|
+
enc = num << 1;
|
|
3723
|
+
}
|
|
3724
|
+
do {
|
|
3725
|
+
let clamped = enc & 31;
|
|
3726
|
+
enc >>>= 5;
|
|
3727
|
+
if (enc > 0) {
|
|
3728
|
+
clamped |= 32;
|
|
3729
|
+
}
|
|
3730
|
+
result += integer_to_char[clamped];
|
|
3731
|
+
} while (enc > 0);
|
|
3732
|
+
return result;
|
|
3733
|
+
}
|
|
3734
|
+
|
|
3735
|
+
// ../wesl/src/ClickableError.ts
|
|
3736
|
+
function throwClickableError(params) {
|
|
3737
|
+
const { url, text: text2, lineNumber, lineColumn, length, error } = params;
|
|
3738
|
+
const mappings = encodeVlq([
|
|
3739
|
+
0,
|
|
3740
|
+
0,
|
|
3741
|
+
Math.max(0, lineNumber - 1),
|
|
3742
|
+
Math.max(0, lineColumn - 1)
|
|
3743
|
+
]) + "," + // Sadly no browser makes use of this info to map the error properly
|
|
3744
|
+
encodeVlq([
|
|
3745
|
+
18,
|
|
3746
|
+
// Arbitrary number that is high enough
|
|
3747
|
+
0,
|
|
3748
|
+
Math.max(0, lineNumber - 1),
|
|
3749
|
+
Math.max(0, lineColumn - 1) + length
|
|
3750
|
+
]);
|
|
3751
|
+
const sourceMap = {
|
|
3752
|
+
version: 3,
|
|
3753
|
+
file: null,
|
|
3754
|
+
sources: [url],
|
|
3755
|
+
sourcesContent: [text2 ?? null],
|
|
3756
|
+
names: [],
|
|
3757
|
+
mappings
|
|
3758
|
+
};
|
|
3759
|
+
let generatedCode = `throw new Error(${JSON.stringify(error.message + "")})`;
|
|
3760
|
+
generatedCode += "\n//# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
|
|
3761
|
+
generatedCode += "\n//# sourceURL=" + sourceMap.sources[0];
|
|
3762
|
+
let oldLimit = 0;
|
|
3763
|
+
if ("stackTraceLimit" in Error) {
|
|
3764
|
+
oldLimit = Error.stackTraceLimit;
|
|
3765
|
+
Error.stackTraceLimit = 1;
|
|
3766
|
+
}
|
|
3767
|
+
try {
|
|
3768
|
+
(0, eval)(generatedCode);
|
|
3769
|
+
} catch (e) {
|
|
3770
|
+
if ("stackTraceLimit" in Error) {
|
|
3771
|
+
Error.stackTraceLimit = oldLimit;
|
|
3772
|
+
}
|
|
3773
|
+
error.message = "";
|
|
3774
|
+
if (tracing) e.cause = error;
|
|
3775
|
+
throw e;
|
|
3776
|
+
}
|
|
3777
|
+
}
|
|
3778
|
+
function failIdent(ident2, msg) {
|
|
3779
|
+
const { refIdentElem, originalName } = ident2;
|
|
3780
|
+
const baseMessage = msg ?? `'${originalName}'`;
|
|
3781
|
+
if (refIdentElem) {
|
|
3782
|
+
failIdentElem(refIdentElem, baseMessage);
|
|
3783
|
+
} else {
|
|
3784
|
+
throw new Error(baseMessage);
|
|
3785
|
+
}
|
|
3786
|
+
}
|
|
3787
|
+
function failIdentElem(identElem, msg = "") {
|
|
3788
|
+
const { srcModule, start, end } = identElem;
|
|
3789
|
+
const { debugFilePath, src } = srcModule;
|
|
3790
|
+
const detailedMessage = `${msg} in file: ${debugFilePath}`;
|
|
3791
|
+
srcLog(src, [start, end], detailedMessage);
|
|
3792
|
+
const [lineNumber, lineColumn] = offsetToLineNumber(start, src);
|
|
3793
|
+
const length = end - start;
|
|
3794
|
+
throwClickableError({
|
|
3795
|
+
url: debugFilePath,
|
|
3796
|
+
text: src,
|
|
3797
|
+
lineNumber,
|
|
3798
|
+
lineColumn,
|
|
3799
|
+
length,
|
|
3800
|
+
error: new Error(detailedMessage)
|
|
3801
|
+
});
|
|
3802
|
+
}
|
|
3803
|
+
|
|
3441
3804
|
// ../wesl/src/Conditions.ts
|
|
3442
3805
|
function elementValid(elem, conditions) {
|
|
3443
3806
|
const attributes = elem.attributes;
|
|
@@ -3460,10 +3823,10 @@ function evaluateIfAttribute(ifAttribute, conditions) {
|
|
|
3460
3823
|
}
|
|
3461
3824
|
function evaluateIfExpression(expression2, conditions) {
|
|
3462
3825
|
const { kind: kind2 } = expression2;
|
|
3463
|
-
if (kind2
|
|
3826
|
+
if (kind2 === "unary-expression") {
|
|
3464
3827
|
assertThatDebug(expression2.operator.value === "!");
|
|
3465
3828
|
return !evaluateIfExpression(expression2.expression, conditions);
|
|
3466
|
-
} else if (kind2
|
|
3829
|
+
} else if (kind2 === "binary-expression") {
|
|
3467
3830
|
const op = expression2.operator.value;
|
|
3468
3831
|
assertThatDebug(op === "||" || op === "&&");
|
|
3469
3832
|
const leftResult = evaluateIfExpression(expression2.left, conditions);
|
|
@@ -3474,11 +3837,11 @@ function evaluateIfExpression(expression2, conditions) {
|
|
|
3474
3837
|
} else {
|
|
3475
3838
|
assertUnreachable2(op);
|
|
3476
3839
|
}
|
|
3477
|
-
} else if (kind2
|
|
3840
|
+
} else if (kind2 === "literal") {
|
|
3478
3841
|
const { value } = expression2;
|
|
3479
3842
|
assertThatDebug(value === "true" || value === "false");
|
|
3480
3843
|
return value === "true";
|
|
3481
|
-
} else if (kind2
|
|
3844
|
+
} else if (kind2 === "parenthesized-expression") {
|
|
3482
3845
|
return evaluateIfExpression(expression2.expression, conditions);
|
|
3483
3846
|
} else if (kind2 === "translate-time-feature") {
|
|
3484
3847
|
return conditions[expression2.name];
|
|
@@ -3726,7 +4089,7 @@ function importElem(cc) {
|
|
|
3726
4089
|
function addToOpenElem(cc, elem) {
|
|
3727
4090
|
const weslContext = cc.app.context;
|
|
3728
4091
|
const { openElems } = weslContext;
|
|
3729
|
-
if (openElems
|
|
4092
|
+
if (openElems?.length) {
|
|
3730
4093
|
const open = openElems[openElems.length - 1];
|
|
3731
4094
|
open.contents.push(elem);
|
|
3732
4095
|
}
|
|
@@ -3888,7 +4251,7 @@ var fnCollect = collectElem(
|
|
|
3888
4251
|
mergeScope(mergedScope, bodyScope);
|
|
3889
4252
|
const filtered = [];
|
|
3890
4253
|
for (const e of fnScope.contents) {
|
|
3891
|
-
if (e === headerScope || e
|
|
4254
|
+
if (e === headerScope || e === returnScope) {
|
|
3892
4255
|
continue;
|
|
3893
4256
|
} else if (e === bodyScope) {
|
|
3894
4257
|
filtered.push(mergedScope);
|
|
@@ -3989,7 +4352,7 @@ var typeRefCollect = collectElem(
|
|
|
3989
4352
|
"type",
|
|
3990
4353
|
// @ts-ignore
|
|
3991
4354
|
(cc, openElem) => {
|
|
3992
|
-
|
|
4355
|
+
const templateParamsTemp = cc.tags.templateParam?.flat(3);
|
|
3993
4356
|
const typeRef = cc.tags.typeRefName?.[0];
|
|
3994
4357
|
const name2 = typeof typeRef === "string" ? typeRef : typeRef.ident;
|
|
3995
4358
|
const partElem = {
|
|
@@ -4024,7 +4387,7 @@ var memberRefCollect = collectElem(
|
|
|
4024
4387
|
"memberRef",
|
|
4025
4388
|
(cc, openElem) => {
|
|
4026
4389
|
const { component, structRef, extra_components } = cc.tags;
|
|
4027
|
-
const member = component[0];
|
|
4390
|
+
const member = component?.[0];
|
|
4028
4391
|
const name2 = structRef?.flat()[0];
|
|
4029
4392
|
const extraComponents = extra_components?.flat()[0];
|
|
4030
4393
|
const partElem = {
|
|
@@ -4037,7 +4400,7 @@ var memberRefCollect = collectElem(
|
|
|
4037
4400
|
}
|
|
4038
4401
|
);
|
|
4039
4402
|
function nameCollect(cc) {
|
|
4040
|
-
const { start, end, src
|
|
4403
|
+
const { start, end, src } = cc;
|
|
4041
4404
|
const name2 = src.slice(start, end);
|
|
4042
4405
|
const elem = { kind: "name", start, end, name: name2 };
|
|
4043
4406
|
addToOpenElem(cc, elem);
|
|
@@ -4120,7 +4483,10 @@ function coverWithText(cc, elem) {
|
|
|
4120
4483
|
// ../wesl/src/parse/WeslBaseGrammar.ts
|
|
4121
4484
|
var word = kind("word");
|
|
4122
4485
|
var keyword = kind("keyword");
|
|
4123
|
-
var qualified_ident = withSepPlus(
|
|
4486
|
+
var qualified_ident = withSepPlus(
|
|
4487
|
+
"::",
|
|
4488
|
+
or(word, keyword, "package", "super")
|
|
4489
|
+
);
|
|
4124
4490
|
var number = kind("number");
|
|
4125
4491
|
|
|
4126
4492
|
// ../wesl/src/parse/ImportGrammar.ts
|
|
@@ -4144,8 +4510,10 @@ function prependSegments(segments, statement2) {
|
|
|
4144
4510
|
return statement2;
|
|
4145
4511
|
}
|
|
4146
4512
|
var import_collection = null;
|
|
4513
|
+
var segment_blacklist = or("super", "package", "import", "as");
|
|
4514
|
+
var packageWord = preceded(not(segment_blacklist), or(word, keyword));
|
|
4147
4515
|
var import_path_or_item = seq(
|
|
4148
|
-
|
|
4516
|
+
packageWord,
|
|
4149
4517
|
or(
|
|
4150
4518
|
preceded(
|
|
4151
4519
|
"::",
|
|
@@ -4271,6 +4639,7 @@ var weslMatcher = new RegexMatchers({
|
|
|
4271
4639
|
blankspaces,
|
|
4272
4640
|
commentStart,
|
|
4273
4641
|
symbol: matchOneOf(symbolSet),
|
|
4642
|
+
// biome-ignore lint/correctness/noEmptyCharacterClassInRegex: TODO
|
|
4274
4643
|
invalid: /[^]/
|
|
4275
4644
|
});
|
|
4276
4645
|
function weslExtension(combinator) {
|
|
@@ -4305,7 +4674,7 @@ var WeslStream = class {
|
|
|
4305
4674
|
this.stream.reset(this.skipBlockComment(token2.span[1]));
|
|
4306
4675
|
}
|
|
4307
4676
|
} else if (kind2 === "word") {
|
|
4308
|
-
|
|
4677
|
+
const returnToken = token2;
|
|
4309
4678
|
if (keywordOrReserved.has(token2.text)) {
|
|
4310
4679
|
returnToken.kind = "keyword";
|
|
4311
4680
|
}
|
|
@@ -4326,7 +4695,8 @@ var WeslStream = class {
|
|
|
4326
4695
|
return this.eolPattern.lastIndex;
|
|
4327
4696
|
}
|
|
4328
4697
|
}
|
|
4329
|
-
skipBlockComment(
|
|
4698
|
+
skipBlockComment(start) {
|
|
4699
|
+
let position = start;
|
|
4330
4700
|
while (true) {
|
|
4331
4701
|
this.blockCommentPattern.lastIndex = position;
|
|
4332
4702
|
const result = this.blockCommentPattern.exec(this.src);
|
|
@@ -4393,7 +4763,7 @@ var WeslStream = class {
|
|
|
4393
4763
|
if (nextToken.text === "<") {
|
|
4394
4764
|
pendingCounter += 1;
|
|
4395
4765
|
} else if (nextToken.text[0] === ">") {
|
|
4396
|
-
if (nextToken.text === ">" || nextToken.text
|
|
4766
|
+
if (nextToken.text === ">" || nextToken.text === ">=") {
|
|
4397
4767
|
pendingCounter -= 1;
|
|
4398
4768
|
} else if (nextToken.text === ">>=" || nextToken.text === ">>") {
|
|
4399
4769
|
pendingCounter -= 2;
|
|
@@ -4633,11 +5003,25 @@ var special_attribute = tagScope(
|
|
|
4633
5003
|
"@",
|
|
4634
5004
|
or(
|
|
4635
5005
|
// These attributes have no arguments
|
|
4636
|
-
or("compute", "const", "fragment", "invariant", "must_use", "vertex").map(
|
|
5006
|
+
or("compute", "const", "fragment", "invariant", "must_use", "vertex").map(
|
|
5007
|
+
(name2) => makeStandardAttribute([name2, []])
|
|
5008
|
+
),
|
|
4637
5009
|
// These attributes have arguments, but the argument doesn't have any identifiers
|
|
4638
|
-
preceded(
|
|
4639
|
-
|
|
4640
|
-
|
|
5010
|
+
preceded(
|
|
5011
|
+
"interpolate",
|
|
5012
|
+
req(
|
|
5013
|
+
delimited("(", name_list, ")"),
|
|
5014
|
+
"invalid @interpolate, expected '('"
|
|
5015
|
+
)
|
|
5016
|
+
).map(makeInterpolateAttribute),
|
|
5017
|
+
preceded(
|
|
5018
|
+
"builtin",
|
|
5019
|
+
req(delimited("(", name, ")"), "invalid @builtin, expected '('")
|
|
5020
|
+
).map(makeBuiltinAttribute),
|
|
5021
|
+
preceded(
|
|
5022
|
+
"diagnostic",
|
|
5023
|
+
req(diagnostic_control, "invalid @diagnostic, expected '('")
|
|
5024
|
+
).map(makeDiagnosticAttribute)
|
|
4641
5025
|
).ptag("attr_variant")
|
|
4642
5026
|
).collect(specialAttribute)
|
|
4643
5027
|
);
|
|
@@ -4673,7 +5057,7 @@ var normal_attribute = tagScope(
|
|
|
4673
5057
|
),
|
|
4674
5058
|
// Everything else is also a normal attribute, optional expression list
|
|
4675
5059
|
seq(
|
|
4676
|
-
// we don't want this to interfere with if_attribute,
|
|
5060
|
+
// we don't want this to interfere with if_attribute,
|
|
4677
5061
|
// but not("if") isn't necessary for now, since 'if' is a keyword, not a word
|
|
4678
5062
|
word.ptag("name"),
|
|
4679
5063
|
opt(() => attribute_argument_list)
|
|
@@ -4690,10 +5074,9 @@ var attribute_argument_list = delimited(
|
|
|
4690
5074
|
),
|
|
4691
5075
|
req(")", "invalid attribute arguments, expected ')'")
|
|
4692
5076
|
);
|
|
4693
|
-
var attribute_no_if = or(
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
).ctag("attribute");
|
|
5077
|
+
var attribute_no_if = or(special_attribute, normal_attribute).ctag(
|
|
5078
|
+
"attribute"
|
|
5079
|
+
);
|
|
4697
5080
|
var attribute_incl_if = or(
|
|
4698
5081
|
if_attribute,
|
|
4699
5082
|
special_attribute,
|
|
@@ -4752,7 +5135,12 @@ var fnParam = tagScope(
|
|
|
4752
5135
|
seq(
|
|
4753
5136
|
opt_attributes.collect((cc) => cc.tags.attribute, "attributes"),
|
|
4754
5137
|
word.collect(declCollect, "decl_elem"),
|
|
4755
|
-
opt(
|
|
5138
|
+
opt(
|
|
5139
|
+
seq(
|
|
5140
|
+
":",
|
|
5141
|
+
req(type_specifier, "invalid fn parameter, expected type specifier")
|
|
5142
|
+
)
|
|
5143
|
+
).collect(typedDecl, "param_name")
|
|
4756
5144
|
).collect(collectFnParam)
|
|
4757
5145
|
).ctag("fn_param");
|
|
4758
5146
|
var fnParamList = seq("(", withSep(",", fnParam), ")");
|
|
@@ -4944,16 +5332,10 @@ var regular_statement = or(
|
|
|
4944
5332
|
)
|
|
4945
5333
|
);
|
|
4946
5334
|
var conditional_statement = tagScope(
|
|
4947
|
-
seq(
|
|
4948
|
-
opt_attributes,
|
|
4949
|
-
regular_statement
|
|
4950
|
-
).collect(statementCollect).collect(partialScopeCollect)
|
|
5335
|
+
seq(opt_attributes, regular_statement).collect(statementCollect).collect(partialScopeCollect)
|
|
4951
5336
|
);
|
|
4952
5337
|
var unconditional_statement = tagScope(
|
|
4953
|
-
seq(
|
|
4954
|
-
opt_attributes_no_if,
|
|
4955
|
-
regular_statement
|
|
4956
|
-
)
|
|
5338
|
+
seq(opt_attributes_no_if, regular_statement)
|
|
4957
5339
|
);
|
|
4958
5340
|
var statement = or(
|
|
4959
5341
|
compound_statement,
|
|
@@ -4962,10 +5344,7 @@ var statement = or(
|
|
|
4962
5344
|
);
|
|
4963
5345
|
var lhs_expression = or(
|
|
4964
5346
|
simple_component_reference,
|
|
4965
|
-
seq(
|
|
4966
|
-
qualified_ident.collect(refIdent),
|
|
4967
|
-
opt(component_or_swizzle)
|
|
4968
|
-
),
|
|
5347
|
+
seq(qualified_ident.collect(refIdent), opt(component_or_swizzle)),
|
|
4969
5348
|
seq(
|
|
4970
5349
|
"(",
|
|
4971
5350
|
() => lhs_expression,
|
|
@@ -4981,7 +5360,12 @@ var variable_or_value_statement = tagScope(
|
|
|
4981
5360
|
or(
|
|
4982
5361
|
// Also covers the = expression case
|
|
4983
5362
|
local_variable_decl,
|
|
4984
|
-
seq(
|
|
5363
|
+
seq(
|
|
5364
|
+
"const",
|
|
5365
|
+
req_optionally_typed_ident,
|
|
5366
|
+
req("=", "invalid const declaration, expected '='"),
|
|
5367
|
+
expression
|
|
5368
|
+
),
|
|
4985
5369
|
seq(
|
|
4986
5370
|
"let",
|
|
4987
5371
|
req_optionally_typed_ident,
|
|
@@ -5000,22 +5384,24 @@ var variable_updating_statement = or(
|
|
|
5000
5384
|
seq("_", "=", expression)
|
|
5001
5385
|
);
|
|
5002
5386
|
var fn_decl = seq(
|
|
5003
|
-
tagScope(
|
|
5004
|
-
|
|
5005
|
-
)
|
|
5387
|
+
tagScope(opt_attributes.collect((cc) => cc.tags.attribute || [])).ctag(
|
|
5388
|
+
"fn_attributes"
|
|
5389
|
+
),
|
|
5006
5390
|
text("fn"),
|
|
5007
5391
|
req(fnNameDecl, "invalid fn, expected function name"),
|
|
5008
5392
|
seq(
|
|
5009
|
-
req(fnParamList, "invalid fn, expected function parameters").collect(
|
|
5010
|
-
|
|
5011
|
-
"
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5393
|
+
req(fnParamList, "invalid fn, expected function parameters").collect(
|
|
5394
|
+
scopeCollect,
|
|
5395
|
+
"header_scope"
|
|
5396
|
+
),
|
|
5397
|
+
opt(
|
|
5398
|
+
seq(
|
|
5399
|
+
"->",
|
|
5400
|
+
opt_attributes.collect((cc) => cc.tags.attribute, "return_attributes"),
|
|
5401
|
+
type_specifier.ctag("return_type").collect(scopeCollect, "return_scope")
|
|
5402
|
+
)
|
|
5403
|
+
),
|
|
5404
|
+
req(unscoped_compound_statement, "invalid fn, expected function body").ctag("body_statement").collect(scopeCollect, "body_scope")
|
|
5019
5405
|
)
|
|
5020
5406
|
).collect(partialScopeCollect, "fn_partial_scope").collect(fnCollect);
|
|
5021
5407
|
var global_value_decl = or(
|
|
@@ -5038,9 +5424,15 @@ var global_value_decl = or(
|
|
|
5038
5424
|
var global_alias = seq(
|
|
5039
5425
|
weslExtension(opt_attributes).collect((cc) => cc.tags.attribute, "attributes"),
|
|
5040
5426
|
"alias",
|
|
5041
|
-
req(word, "invalid alias, expected name").collect(
|
|
5427
|
+
req(word, "invalid alias, expected name").collect(
|
|
5428
|
+
globalDeclCollect,
|
|
5429
|
+
"alias_name"
|
|
5430
|
+
),
|
|
5042
5431
|
req("=", "invalid alias, expected '='"),
|
|
5043
|
-
req(type_specifier, "invalid alias, expected type").collect(
|
|
5432
|
+
req(type_specifier, "invalid alias, expected type").collect(
|
|
5433
|
+
scopeCollect,
|
|
5434
|
+
"alias_scope"
|
|
5435
|
+
),
|
|
5044
5436
|
req(";", "invalid alias, expected ';'")
|
|
5045
5437
|
).collect(aliasCollect);
|
|
5046
5438
|
var const_assert = tagScope(
|
|
@@ -5255,91 +5647,6 @@ if (tracing) {
|
|
|
5255
5647
|
});
|
|
5256
5648
|
}
|
|
5257
5649
|
|
|
5258
|
-
// ../wesl/src/vlq/vlq.ts
|
|
5259
|
-
var char_to_integer = {};
|
|
5260
|
-
var integer_to_char = {};
|
|
5261
|
-
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split("").forEach(function(char, i) {
|
|
5262
|
-
char_to_integer[char] = i;
|
|
5263
|
-
integer_to_char[i] = char;
|
|
5264
|
-
});
|
|
5265
|
-
function encodeVlq(value) {
|
|
5266
|
-
if (typeof value === "number") {
|
|
5267
|
-
return encode_integer(value);
|
|
5268
|
-
}
|
|
5269
|
-
let result = "";
|
|
5270
|
-
for (let i = 0; i < value.length; i += 1) {
|
|
5271
|
-
result += encode_integer(value[i]);
|
|
5272
|
-
}
|
|
5273
|
-
return result;
|
|
5274
|
-
}
|
|
5275
|
-
function encode_integer(num) {
|
|
5276
|
-
let result = "";
|
|
5277
|
-
if (num < 0) {
|
|
5278
|
-
num = -num << 1 | 1;
|
|
5279
|
-
} else {
|
|
5280
|
-
num <<= 1;
|
|
5281
|
-
}
|
|
5282
|
-
do {
|
|
5283
|
-
let clamped = num & 31;
|
|
5284
|
-
num >>>= 5;
|
|
5285
|
-
if (num > 0) {
|
|
5286
|
-
clamped |= 32;
|
|
5287
|
-
}
|
|
5288
|
-
result += integer_to_char[clamped];
|
|
5289
|
-
} while (num > 0);
|
|
5290
|
-
return result;
|
|
5291
|
-
}
|
|
5292
|
-
|
|
5293
|
-
// ../wesl/src/WeslDevice.ts
|
|
5294
|
-
function throwClickableError({
|
|
5295
|
-
url,
|
|
5296
|
-
text: text2,
|
|
5297
|
-
lineNumber,
|
|
5298
|
-
lineColumn,
|
|
5299
|
-
length,
|
|
5300
|
-
error
|
|
5301
|
-
}) {
|
|
5302
|
-
let mappings = encodeVlq([
|
|
5303
|
-
0,
|
|
5304
|
-
0,
|
|
5305
|
-
Math.max(0, lineNumber - 1),
|
|
5306
|
-
Math.max(0, lineColumn - 1)
|
|
5307
|
-
]) + "," + // Sadly no browser makes use of this info to map the error properly
|
|
5308
|
-
encodeVlq([
|
|
5309
|
-
18,
|
|
5310
|
-
// Arbitrary number that is high enough
|
|
5311
|
-
0,
|
|
5312
|
-
Math.max(0, lineNumber - 1),
|
|
5313
|
-
Math.max(0, lineColumn - 1) + length
|
|
5314
|
-
]);
|
|
5315
|
-
const sourceMap = {
|
|
5316
|
-
version: 3,
|
|
5317
|
-
file: null,
|
|
5318
|
-
sources: [url],
|
|
5319
|
-
sourcesContent: [text2 ?? null],
|
|
5320
|
-
names: [],
|
|
5321
|
-
mappings
|
|
5322
|
-
};
|
|
5323
|
-
let generatedCode = `throw new Error(${JSON.stringify(error.message + "")})`;
|
|
5324
|
-
generatedCode += "\n//# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
|
|
5325
|
-
generatedCode += "\n//# sourceURL=" + sourceMap.sources[0];
|
|
5326
|
-
let oldLimit = 0;
|
|
5327
|
-
if ("stackTraceLimit" in Error) {
|
|
5328
|
-
oldLimit = Error.stackTraceLimit;
|
|
5329
|
-
Error.stackTraceLimit = 1;
|
|
5330
|
-
}
|
|
5331
|
-
try {
|
|
5332
|
-
(0, eval)(generatedCode);
|
|
5333
|
-
} catch (e) {
|
|
5334
|
-
if ("stackTraceLimit" in Error) {
|
|
5335
|
-
Error.stackTraceLimit = oldLimit;
|
|
5336
|
-
}
|
|
5337
|
-
error.message = "";
|
|
5338
|
-
e.cause = error;
|
|
5339
|
-
throw e;
|
|
5340
|
-
}
|
|
5341
|
-
}
|
|
5342
|
-
|
|
5343
5650
|
// ../wesl/src/ParseWESL.ts
|
|
5344
5651
|
var WeslParseError = class extends Error {
|
|
5345
5652
|
constructor(opts) {
|
|
@@ -5356,7 +5663,7 @@ var WeslParseError = class extends Error {
|
|
|
5356
5663
|
this.src = opts.src;
|
|
5357
5664
|
}
|
|
5358
5665
|
};
|
|
5359
|
-
function parseSrcModule(srcModule
|
|
5666
|
+
function parseSrcModule(srcModule) {
|
|
5360
5667
|
const stream = new WeslStream(srcModule.src);
|
|
5361
5668
|
const appState = blankWeslParseState(srcModule);
|
|
5362
5669
|
const init = { stream, appState };
|
|
@@ -5526,7 +5833,7 @@ function findValidRootDecls(rootScope, conditions) {
|
|
|
5526
5833
|
return found;
|
|
5527
5834
|
}
|
|
5528
5835
|
function bindIdentsRecursive(scope, bindContext, liveDecls, isRoot = false) {
|
|
5529
|
-
const {
|
|
5836
|
+
const { dontFollowDecls, foundScopes } = bindContext;
|
|
5530
5837
|
if (foundScopes.has(scope)) return [];
|
|
5531
5838
|
foundScopes.add(scope);
|
|
5532
5839
|
const newGlobals = [];
|
|
@@ -5546,7 +5853,12 @@ function bindIdentsRecursive(scope, bindContext, liveDecls, isRoot = false) {
|
|
|
5546
5853
|
}
|
|
5547
5854
|
}
|
|
5548
5855
|
});
|
|
5549
|
-
const newFromRefs = newGlobals
|
|
5856
|
+
const newFromRefs = dontFollowDecls ? [] : handleDecls(newGlobals, bindContext);
|
|
5857
|
+
return [newGlobals, newFromChildren, newFromRefs].flat();
|
|
5858
|
+
}
|
|
5859
|
+
function handleDecls(newGlobals, bindContext) {
|
|
5860
|
+
const { conditions } = bindContext;
|
|
5861
|
+
return newGlobals.flatMap((decl) => {
|
|
5550
5862
|
const foundsScope = decl.dependentScope;
|
|
5551
5863
|
if (foundsScope) {
|
|
5552
5864
|
const rootDecls = globalDeclToRootLiveDecls(decl, conditions);
|
|
@@ -5557,7 +5869,6 @@ function bindIdentsRecursive(scope, bindContext, liveDecls, isRoot = false) {
|
|
|
5557
5869
|
}
|
|
5558
5870
|
return [];
|
|
5559
5871
|
});
|
|
5560
|
-
return [newGlobals, newFromChildren, newFromRefs].flat();
|
|
5561
5872
|
}
|
|
5562
5873
|
function handleRef(ident2, liveDecls, bindContext) {
|
|
5563
5874
|
const { registry, conditions, unbound } = bindContext;
|
|
@@ -5570,7 +5881,7 @@ function handleRef(ident2, liveDecls, bindContext) {
|
|
|
5570
5881
|
} else if (stdWgsl(ident2.originalName)) {
|
|
5571
5882
|
ident2.std = true;
|
|
5572
5883
|
} else if (!unbound) {
|
|
5573
|
-
|
|
5884
|
+
failIdent(ident2, `unresolved identifier '${ident2.originalName}'`);
|
|
5574
5885
|
}
|
|
5575
5886
|
}
|
|
5576
5887
|
}
|
|
@@ -5619,16 +5930,6 @@ function globalDeclToRootLiveDecls(decl, conditions) {
|
|
|
5619
5930
|
root._scopeDecls = liveDecls;
|
|
5620
5931
|
return liveDecls;
|
|
5621
5932
|
}
|
|
5622
|
-
function failMissingIdent(ident2) {
|
|
5623
|
-
const { refIdentElem } = ident2;
|
|
5624
|
-
if (refIdentElem) {
|
|
5625
|
-
const { srcModule, start, end } = refIdentElem;
|
|
5626
|
-
const { debugFilePath: filePath } = srcModule;
|
|
5627
|
-
const msg = `unresolved identifier '${ident2.originalName}' in file: ${filePath}`;
|
|
5628
|
-
srcLog(srcModule.src, [start, end], msg);
|
|
5629
|
-
throw new Error(msg);
|
|
5630
|
-
}
|
|
5631
|
-
}
|
|
5632
5933
|
function setMangledName(proposedName, decl, globalNames, srcModule, mangler) {
|
|
5633
5934
|
if (!decl.mangledName) {
|
|
5634
5935
|
let mangledName;
|
|
@@ -5674,8 +5975,8 @@ function findQualifiedImport(refIdent2, parsed, conditions, virtuals, unbound) {
|
|
|
5674
5975
|
if (unbound) {
|
|
5675
5976
|
unbound.push(modulePathParts);
|
|
5676
5977
|
} else {
|
|
5677
|
-
const msg = `
|
|
5678
|
-
|
|
5978
|
+
const msg = `module not found for '${modulePathParts.join("::")}'`;
|
|
5979
|
+
failIdent(refIdent2, msg);
|
|
5679
5980
|
}
|
|
5680
5981
|
}
|
|
5681
5982
|
return result;
|
|
@@ -5753,16 +6054,21 @@ function lowerAndEmitElem(e, ctx) {
|
|
|
5753
6054
|
return;
|
|
5754
6055
|
// terminal elements copy strings to the output
|
|
5755
6056
|
case "text":
|
|
5756
|
-
|
|
6057
|
+
emitText(e, ctx);
|
|
6058
|
+
return;
|
|
5757
6059
|
case "name":
|
|
5758
|
-
|
|
6060
|
+
emitName(e, ctx);
|
|
6061
|
+
return;
|
|
5759
6062
|
case "synthetic":
|
|
5760
|
-
|
|
6063
|
+
emitSynthetic(e, ctx);
|
|
6064
|
+
return;
|
|
5761
6065
|
// identifiers are copied to the output, but with potentially mangled names
|
|
5762
6066
|
case "ref":
|
|
5763
|
-
|
|
6067
|
+
emitRefIdent(e, ctx);
|
|
6068
|
+
return;
|
|
5764
6069
|
case "decl":
|
|
5765
|
-
|
|
6070
|
+
emitDeclIdent(e, ctx);
|
|
6071
|
+
return;
|
|
5766
6072
|
// container elements just emit their child elements
|
|
5767
6073
|
case "param":
|
|
5768
6074
|
case "var":
|
|
@@ -5776,7 +6082,8 @@ function lowerAndEmitElem(e, ctx) {
|
|
|
5776
6082
|
case "statement":
|
|
5777
6083
|
case "stuff":
|
|
5778
6084
|
case "switch-clause":
|
|
5779
|
-
|
|
6085
|
+
emitContents(e, ctx);
|
|
6086
|
+
return;
|
|
5780
6087
|
// root level container elements get some extra newlines to make the output prettier
|
|
5781
6088
|
case "override":
|
|
5782
6089
|
case "const":
|
|
@@ -5784,17 +6091,22 @@ function lowerAndEmitElem(e, ctx) {
|
|
|
5784
6091
|
case "alias":
|
|
5785
6092
|
case "gvar":
|
|
5786
6093
|
emitRootElemNl(ctx);
|
|
5787
|
-
|
|
6094
|
+
emitContents(e, ctx);
|
|
6095
|
+
return;
|
|
5788
6096
|
case "fn":
|
|
5789
6097
|
emitRootElemNl(ctx);
|
|
5790
|
-
|
|
6098
|
+
emitFn(e, ctx);
|
|
6099
|
+
return;
|
|
5791
6100
|
case "struct":
|
|
5792
6101
|
emitRootElemNl(ctx);
|
|
5793
|
-
|
|
6102
|
+
emitStruct(e, ctx);
|
|
6103
|
+
return;
|
|
5794
6104
|
case "attribute":
|
|
5795
|
-
|
|
6105
|
+
emitAttribute(e, ctx);
|
|
6106
|
+
return;
|
|
5796
6107
|
case "directive":
|
|
5797
|
-
|
|
6108
|
+
emitDirective(e, ctx);
|
|
6109
|
+
return;
|
|
5798
6110
|
default:
|
|
5799
6111
|
assertUnreachable2(e);
|
|
5800
6112
|
}
|
|
@@ -5869,12 +6181,8 @@ function emitStruct(e, ctx) {
|
|
|
5869
6181
|
function warnEmptyStruct(e) {
|
|
5870
6182
|
const { name: name2, members } = e;
|
|
5871
6183
|
const condStr = members.length ? "(with current conditions)" : "";
|
|
5872
|
-
const
|
|
5873
|
-
|
|
5874
|
-
name2.srcModule.src,
|
|
5875
|
-
e.start,
|
|
5876
|
-
`struct ${name2.ident.originalName} in ${filePath} has no members ${condStr}`
|
|
5877
|
-
);
|
|
6184
|
+
const message = `struct '${name2.ident.originalName}' has no members ${condStr}`;
|
|
6185
|
+
failIdentElem(name2, message);
|
|
5878
6186
|
}
|
|
5879
6187
|
function emitSynthetic(e, ctx) {
|
|
5880
6188
|
const { text: text2 } = e;
|
|
@@ -6319,7 +6627,7 @@ var LinkedWesl = class {
|
|
|
6319
6627
|
code: this.dest
|
|
6320
6628
|
});
|
|
6321
6629
|
device.popErrorScope();
|
|
6322
|
-
|
|
6630
|
+
const { promise, resolve: resolve5 } = Promise.withResolvers();
|
|
6323
6631
|
device.injectError("validation", promise);
|
|
6324
6632
|
module.getCompilationInfo().then((compilationInfo) => {
|
|
6325
6633
|
if (compilationInfo.messages.length === 0) {
|
|
@@ -6363,7 +6671,7 @@ var LinkedWesl = class {
|
|
|
6363
6671
|
const srcPosition = srcMap.destToSrc(message.offset);
|
|
6364
6672
|
const srcEndPosition = message.length > 0 ? srcMap.destToSrc(message.offset + message.length) : srcPosition;
|
|
6365
6673
|
const length = srcEndPosition.position - srcPosition.position;
|
|
6366
|
-
|
|
6674
|
+
const [lineNum, linePos] = offsetToLineNumber(
|
|
6367
6675
|
srcPosition.position,
|
|
6368
6676
|
srcPosition.src.text
|
|
6369
6677
|
);
|
|
@@ -6386,7 +6694,7 @@ function compilationInfoToErrorMessage(compilationInfo, shaderModule) {
|
|
|
6386
6694
|
if (compilationInfo.messages.length === 0) return null;
|
|
6387
6695
|
let result = `Compilation log for [Invalid ShaderModule (${shaderModule.label || "unlabled"})]:
|
|
6388
6696
|
`;
|
|
6389
|
-
|
|
6697
|
+
const errorCount = compilationInfo.messages.filter(
|
|
6390
6698
|
(v) => v.type === "error"
|
|
6391
6699
|
).length;
|
|
6392
6700
|
if (errorCount > 0) {
|
|
@@ -6450,19 +6758,20 @@ function selectModule(parsed, selectPath, packageName = "package") {
|
|
|
6450
6758
|
return parsed.modules[modulePath];
|
|
6451
6759
|
}
|
|
6452
6760
|
function parseIntoRegistry(srcFiles, registry, packageName = "package", debugWeslRoot) {
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6761
|
+
let weslRoot2 = debugWeslRoot;
|
|
6762
|
+
if (weslRoot2 === void 0) {
|
|
6763
|
+
weslRoot2 = "";
|
|
6764
|
+
} else if (!weslRoot2.endsWith("/")) {
|
|
6765
|
+
weslRoot2 += "/";
|
|
6457
6766
|
}
|
|
6458
6767
|
const srcModules = Object.entries(srcFiles).map(
|
|
6459
6768
|
([filePath, src]) => {
|
|
6460
6769
|
const modulePath = fileToModulePath(filePath, packageName);
|
|
6461
|
-
return { modulePath, debugFilePath:
|
|
6770
|
+
return { modulePath, debugFilePath: weslRoot2 + filePath, src };
|
|
6462
6771
|
}
|
|
6463
6772
|
);
|
|
6464
6773
|
srcModules.forEach((mod) => {
|
|
6465
|
-
const parsed = parseSrcModule(mod
|
|
6774
|
+
const parsed = parseSrcModule(mod);
|
|
6466
6775
|
if (registry.modules[mod.modulePath]) {
|
|
6467
6776
|
throw new Error(`duplicate module path: '${mod.modulePath}'`);
|
|
6468
6777
|
}
|
|
@@ -6497,7 +6806,8 @@ async function link(params) {
|
|
|
6497
6806
|
const registry = parsedRegistry();
|
|
6498
6807
|
parseIntoRegistry(weslSrc, registry, "package", debugWeslRoot);
|
|
6499
6808
|
parseLibsIntoRegistry(libs, registry);
|
|
6500
|
-
|
|
6809
|
+
const srcMap = linkRegistry({ registry, ...params });
|
|
6810
|
+
return new LinkedWesl(srcMap);
|
|
6501
6811
|
}
|
|
6502
6812
|
function linkRegistry(params) {
|
|
6503
6813
|
const bound = bindAndTransform(params);
|
|
@@ -6521,7 +6831,7 @@ function bindAndTransform(params) {
|
|
|
6521
6831
|
if (constants) {
|
|
6522
6832
|
virtualLibs = { ...virtualLibs, constants: constantsGenerator(constants) };
|
|
6523
6833
|
}
|
|
6524
|
-
|
|
6834
|
+
const virtuals = virtualLibs && mapValues(virtualLibs, (fn2) => ({ fn: fn2 }));
|
|
6525
6835
|
const bindParams = { rootAst, registry, conditions, virtuals, mangler };
|
|
6526
6836
|
const bindResults = bindIdents(bindParams);
|
|
6527
6837
|
const { globalNames, decls: newDecls, newStatements } = bindResults;
|
|
@@ -9897,26 +10207,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
9897
10207
|
/*! Bundled license information:
|
|
9898
10208
|
|
|
9899
10209
|
yargs-parser/build/lib/string-utils.js:
|
|
9900
|
-
(**
|
|
9901
|
-
* @license
|
|
9902
|
-
* Copyright (c) 2016, Contributors
|
|
9903
|
-
* SPDX-License-Identifier: ISC
|
|
9904
|
-
*)
|
|
9905
|
-
|
|
9906
10210
|
yargs-parser/build/lib/tokenize-arg-string.js:
|
|
9907
|
-
(**
|
|
9908
|
-
* @license
|
|
9909
|
-
* Copyright (c) 2016, Contributors
|
|
9910
|
-
* SPDX-License-Identifier: ISC
|
|
9911
|
-
*)
|
|
9912
|
-
|
|
9913
10211
|
yargs-parser/build/lib/yargs-parser-types.js:
|
|
9914
|
-
(**
|
|
9915
|
-
* @license
|
|
9916
|
-
* Copyright (c) 2016, Contributors
|
|
9917
|
-
* SPDX-License-Identifier: ISC
|
|
9918
|
-
*)
|
|
9919
|
-
|
|
9920
10212
|
yargs-parser/build/lib/yargs-parser.js:
|
|
9921
10213
|
(**
|
|
9922
10214
|
* @license
|