vite-plugin-dts 0.8.3 → 0.9.0

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/dist/index.mjs CHANGED
@@ -1582,6 +1582,741 @@ var require_source = __commonJS({
1582
1582
  }
1583
1583
  });
1584
1584
 
1585
+ // node_modules/ms/index.js
1586
+ var require_ms = __commonJS({
1587
+ "node_modules/ms/index.js"(exports, module) {
1588
+ var s = 1e3;
1589
+ var m = s * 60;
1590
+ var h = m * 60;
1591
+ var d = h * 24;
1592
+ var w = d * 7;
1593
+ var y = d * 365.25;
1594
+ module.exports = function(val, options) {
1595
+ options = options || {};
1596
+ var type = typeof val;
1597
+ if (type === "string" && val.length > 0) {
1598
+ return parse(val);
1599
+ } else if (type === "number" && isFinite(val)) {
1600
+ return options.long ? fmtLong(val) : fmtShort(val);
1601
+ }
1602
+ throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val));
1603
+ };
1604
+ function parse(str) {
1605
+ str = String(str);
1606
+ if (str.length > 100) {
1607
+ return;
1608
+ }
1609
+ var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
1610
+ if (!match) {
1611
+ return;
1612
+ }
1613
+ var n = parseFloat(match[1]);
1614
+ var type = (match[2] || "ms").toLowerCase();
1615
+ switch (type) {
1616
+ case "years":
1617
+ case "year":
1618
+ case "yrs":
1619
+ case "yr":
1620
+ case "y":
1621
+ return n * y;
1622
+ case "weeks":
1623
+ case "week":
1624
+ case "w":
1625
+ return n * w;
1626
+ case "days":
1627
+ case "day":
1628
+ case "d":
1629
+ return n * d;
1630
+ case "hours":
1631
+ case "hour":
1632
+ case "hrs":
1633
+ case "hr":
1634
+ case "h":
1635
+ return n * h;
1636
+ case "minutes":
1637
+ case "minute":
1638
+ case "mins":
1639
+ case "min":
1640
+ case "m":
1641
+ return n * m;
1642
+ case "seconds":
1643
+ case "second":
1644
+ case "secs":
1645
+ case "sec":
1646
+ case "s":
1647
+ return n * s;
1648
+ case "milliseconds":
1649
+ case "millisecond":
1650
+ case "msecs":
1651
+ case "msec":
1652
+ case "ms":
1653
+ return n;
1654
+ default:
1655
+ return void 0;
1656
+ }
1657
+ }
1658
+ function fmtShort(ms) {
1659
+ var msAbs = Math.abs(ms);
1660
+ if (msAbs >= d) {
1661
+ return Math.round(ms / d) + "d";
1662
+ }
1663
+ if (msAbs >= h) {
1664
+ return Math.round(ms / h) + "h";
1665
+ }
1666
+ if (msAbs >= m) {
1667
+ return Math.round(ms / m) + "m";
1668
+ }
1669
+ if (msAbs >= s) {
1670
+ return Math.round(ms / s) + "s";
1671
+ }
1672
+ return ms + "ms";
1673
+ }
1674
+ function fmtLong(ms) {
1675
+ var msAbs = Math.abs(ms);
1676
+ if (msAbs >= d) {
1677
+ return plural(ms, msAbs, d, "day");
1678
+ }
1679
+ if (msAbs >= h) {
1680
+ return plural(ms, msAbs, h, "hour");
1681
+ }
1682
+ if (msAbs >= m) {
1683
+ return plural(ms, msAbs, m, "minute");
1684
+ }
1685
+ if (msAbs >= s) {
1686
+ return plural(ms, msAbs, s, "second");
1687
+ }
1688
+ return ms + " ms";
1689
+ }
1690
+ function plural(ms, msAbs, n, name) {
1691
+ var isPlural = msAbs >= n * 1.5;
1692
+ return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
1693
+ }
1694
+ }
1695
+ });
1696
+
1697
+ // node_modules/debug/src/common.js
1698
+ var require_common = __commonJS({
1699
+ "node_modules/debug/src/common.js"(exports, module) {
1700
+ function setup(env) {
1701
+ createDebug.debug = createDebug;
1702
+ createDebug.default = createDebug;
1703
+ createDebug.coerce = coerce;
1704
+ createDebug.disable = disable;
1705
+ createDebug.enable = enable;
1706
+ createDebug.enabled = enabled;
1707
+ createDebug.humanize = require_ms();
1708
+ createDebug.destroy = destroy;
1709
+ Object.keys(env).forEach((key) => {
1710
+ createDebug[key] = env[key];
1711
+ });
1712
+ createDebug.names = [];
1713
+ createDebug.skips = [];
1714
+ createDebug.formatters = {};
1715
+ function selectColor(namespace) {
1716
+ let hash = 0;
1717
+ for (let i = 0; i < namespace.length; i++) {
1718
+ hash = (hash << 5) - hash + namespace.charCodeAt(i);
1719
+ hash |= 0;
1720
+ }
1721
+ return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
1722
+ }
1723
+ createDebug.selectColor = selectColor;
1724
+ function createDebug(namespace) {
1725
+ let prevTime;
1726
+ let enableOverride = null;
1727
+ let namespacesCache;
1728
+ let enabledCache;
1729
+ function debug2(...args) {
1730
+ if (!debug2.enabled) {
1731
+ return;
1732
+ }
1733
+ const self = debug2;
1734
+ const curr = Number(new Date());
1735
+ const ms = curr - (prevTime || curr);
1736
+ self.diff = ms;
1737
+ self.prev = prevTime;
1738
+ self.curr = curr;
1739
+ prevTime = curr;
1740
+ args[0] = createDebug.coerce(args[0]);
1741
+ if (typeof args[0] !== "string") {
1742
+ args.unshift("%O");
1743
+ }
1744
+ let index2 = 0;
1745
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
1746
+ if (match === "%%") {
1747
+ return "%";
1748
+ }
1749
+ index2++;
1750
+ const formatter = createDebug.formatters[format];
1751
+ if (typeof formatter === "function") {
1752
+ const val = args[index2];
1753
+ match = formatter.call(self, val);
1754
+ args.splice(index2, 1);
1755
+ index2--;
1756
+ }
1757
+ return match;
1758
+ });
1759
+ createDebug.formatArgs.call(self, args);
1760
+ const logFn = self.log || createDebug.log;
1761
+ logFn.apply(self, args);
1762
+ }
1763
+ debug2.namespace = namespace;
1764
+ debug2.useColors = createDebug.useColors();
1765
+ debug2.color = createDebug.selectColor(namespace);
1766
+ debug2.extend = extend;
1767
+ debug2.destroy = createDebug.destroy;
1768
+ Object.defineProperty(debug2, "enabled", {
1769
+ enumerable: true,
1770
+ configurable: false,
1771
+ get: () => {
1772
+ if (enableOverride !== null) {
1773
+ return enableOverride;
1774
+ }
1775
+ if (namespacesCache !== createDebug.namespaces) {
1776
+ namespacesCache = createDebug.namespaces;
1777
+ enabledCache = createDebug.enabled(namespace);
1778
+ }
1779
+ return enabledCache;
1780
+ },
1781
+ set: (v) => {
1782
+ enableOverride = v;
1783
+ }
1784
+ });
1785
+ if (typeof createDebug.init === "function") {
1786
+ createDebug.init(debug2);
1787
+ }
1788
+ return debug2;
1789
+ }
1790
+ function extend(namespace, delimiter) {
1791
+ const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
1792
+ newDebug.log = this.log;
1793
+ return newDebug;
1794
+ }
1795
+ function enable(namespaces) {
1796
+ createDebug.save(namespaces);
1797
+ createDebug.namespaces = namespaces;
1798
+ createDebug.names = [];
1799
+ createDebug.skips = [];
1800
+ let i;
1801
+ const split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/);
1802
+ const len = split.length;
1803
+ for (i = 0; i < len; i++) {
1804
+ if (!split[i]) {
1805
+ continue;
1806
+ }
1807
+ namespaces = split[i].replace(/\*/g, ".*?");
1808
+ if (namespaces[0] === "-") {
1809
+ createDebug.skips.push(new RegExp("^" + namespaces.substr(1) + "$"));
1810
+ } else {
1811
+ createDebug.names.push(new RegExp("^" + namespaces + "$"));
1812
+ }
1813
+ }
1814
+ }
1815
+ function disable() {
1816
+ const namespaces = [
1817
+ ...createDebug.names.map(toNamespace),
1818
+ ...createDebug.skips.map(toNamespace).map((namespace) => "-" + namespace)
1819
+ ].join(",");
1820
+ createDebug.enable("");
1821
+ return namespaces;
1822
+ }
1823
+ function enabled(name) {
1824
+ if (name[name.length - 1] === "*") {
1825
+ return true;
1826
+ }
1827
+ let i;
1828
+ let len;
1829
+ for (i = 0, len = createDebug.skips.length; i < len; i++) {
1830
+ if (createDebug.skips[i].test(name)) {
1831
+ return false;
1832
+ }
1833
+ }
1834
+ for (i = 0, len = createDebug.names.length; i < len; i++) {
1835
+ if (createDebug.names[i].test(name)) {
1836
+ return true;
1837
+ }
1838
+ }
1839
+ return false;
1840
+ }
1841
+ function toNamespace(regexp) {
1842
+ return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*");
1843
+ }
1844
+ function coerce(val) {
1845
+ if (val instanceof Error) {
1846
+ return val.stack || val.message;
1847
+ }
1848
+ return val;
1849
+ }
1850
+ function destroy() {
1851
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
1852
+ }
1853
+ createDebug.enable(createDebug.load());
1854
+ return createDebug;
1855
+ }
1856
+ module.exports = setup;
1857
+ }
1858
+ });
1859
+
1860
+ // node_modules/debug/src/browser.js
1861
+ var require_browser = __commonJS({
1862
+ "node_modules/debug/src/browser.js"(exports, module) {
1863
+ exports.formatArgs = formatArgs;
1864
+ exports.save = save;
1865
+ exports.load = load;
1866
+ exports.useColors = useColors;
1867
+ exports.storage = localstorage();
1868
+ exports.destroy = (() => {
1869
+ let warned = false;
1870
+ return () => {
1871
+ if (!warned) {
1872
+ warned = true;
1873
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
1874
+ }
1875
+ };
1876
+ })();
1877
+ exports.colors = [
1878
+ "#0000CC",
1879
+ "#0000FF",
1880
+ "#0033CC",
1881
+ "#0033FF",
1882
+ "#0066CC",
1883
+ "#0066FF",
1884
+ "#0099CC",
1885
+ "#0099FF",
1886
+ "#00CC00",
1887
+ "#00CC33",
1888
+ "#00CC66",
1889
+ "#00CC99",
1890
+ "#00CCCC",
1891
+ "#00CCFF",
1892
+ "#3300CC",
1893
+ "#3300FF",
1894
+ "#3333CC",
1895
+ "#3333FF",
1896
+ "#3366CC",
1897
+ "#3366FF",
1898
+ "#3399CC",
1899
+ "#3399FF",
1900
+ "#33CC00",
1901
+ "#33CC33",
1902
+ "#33CC66",
1903
+ "#33CC99",
1904
+ "#33CCCC",
1905
+ "#33CCFF",
1906
+ "#6600CC",
1907
+ "#6600FF",
1908
+ "#6633CC",
1909
+ "#6633FF",
1910
+ "#66CC00",
1911
+ "#66CC33",
1912
+ "#9900CC",
1913
+ "#9900FF",
1914
+ "#9933CC",
1915
+ "#9933FF",
1916
+ "#99CC00",
1917
+ "#99CC33",
1918
+ "#CC0000",
1919
+ "#CC0033",
1920
+ "#CC0066",
1921
+ "#CC0099",
1922
+ "#CC00CC",
1923
+ "#CC00FF",
1924
+ "#CC3300",
1925
+ "#CC3333",
1926
+ "#CC3366",
1927
+ "#CC3399",
1928
+ "#CC33CC",
1929
+ "#CC33FF",
1930
+ "#CC6600",
1931
+ "#CC6633",
1932
+ "#CC9900",
1933
+ "#CC9933",
1934
+ "#CCCC00",
1935
+ "#CCCC33",
1936
+ "#FF0000",
1937
+ "#FF0033",
1938
+ "#FF0066",
1939
+ "#FF0099",
1940
+ "#FF00CC",
1941
+ "#FF00FF",
1942
+ "#FF3300",
1943
+ "#FF3333",
1944
+ "#FF3366",
1945
+ "#FF3399",
1946
+ "#FF33CC",
1947
+ "#FF33FF",
1948
+ "#FF6600",
1949
+ "#FF6633",
1950
+ "#FF9900",
1951
+ "#FF9933",
1952
+ "#FFCC00",
1953
+ "#FFCC33"
1954
+ ];
1955
+ function useColors() {
1956
+ if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
1957
+ return true;
1958
+ }
1959
+ if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
1960
+ return false;
1961
+ }
1962
+ return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
1963
+ }
1964
+ function formatArgs(args) {
1965
+ args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
1966
+ if (!this.useColors) {
1967
+ return;
1968
+ }
1969
+ const c = "color: " + this.color;
1970
+ args.splice(1, 0, c, "color: inherit");
1971
+ let index2 = 0;
1972
+ let lastC = 0;
1973
+ args[0].replace(/%[a-zA-Z%]/g, (match) => {
1974
+ if (match === "%%") {
1975
+ return;
1976
+ }
1977
+ index2++;
1978
+ if (match === "%c") {
1979
+ lastC = index2;
1980
+ }
1981
+ });
1982
+ args.splice(lastC, 0, c);
1983
+ }
1984
+ exports.log = console.debug || console.log || (() => {
1985
+ });
1986
+ function save(namespaces) {
1987
+ try {
1988
+ if (namespaces) {
1989
+ exports.storage.setItem("debug", namespaces);
1990
+ } else {
1991
+ exports.storage.removeItem("debug");
1992
+ }
1993
+ } catch (error) {
1994
+ }
1995
+ }
1996
+ function load() {
1997
+ let r;
1998
+ try {
1999
+ r = exports.storage.getItem("debug");
2000
+ } catch (error) {
2001
+ }
2002
+ if (!r && typeof process !== "undefined" && "env" in process) {
2003
+ r = process.env.DEBUG;
2004
+ }
2005
+ return r;
2006
+ }
2007
+ function localstorage() {
2008
+ try {
2009
+ return localStorage;
2010
+ } catch (error) {
2011
+ }
2012
+ }
2013
+ module.exports = require_common()(exports);
2014
+ var { formatters } = module.exports;
2015
+ formatters.j = function(v) {
2016
+ try {
2017
+ return JSON.stringify(v);
2018
+ } catch (error) {
2019
+ return "[UnexpectedJSONParseError]: " + error.message;
2020
+ }
2021
+ };
2022
+ }
2023
+ });
2024
+
2025
+ // node_modules/supports-color/index.js
2026
+ var require_supports_color2 = __commonJS({
2027
+ "node_modules/supports-color/index.js"(exports, module) {
2028
+ "use strict";
2029
+ var os2 = __require("os");
2030
+ var tty = __require("tty");
2031
+ var hasFlag = require_has_flag();
2032
+ var { env } = process;
2033
+ var flagForceColor;
2034
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
2035
+ flagForceColor = 0;
2036
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
2037
+ flagForceColor = 1;
2038
+ }
2039
+ function envForceColor() {
2040
+ if ("FORCE_COLOR" in env) {
2041
+ if (env.FORCE_COLOR === "true") {
2042
+ return 1;
2043
+ }
2044
+ if (env.FORCE_COLOR === "false") {
2045
+ return 0;
2046
+ }
2047
+ return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
2048
+ }
2049
+ }
2050
+ function translateLevel(level) {
2051
+ if (level === 0) {
2052
+ return false;
2053
+ }
2054
+ return {
2055
+ level,
2056
+ hasBasic: true,
2057
+ has256: level >= 2,
2058
+ has16m: level >= 3
2059
+ };
2060
+ }
2061
+ function supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
2062
+ const noFlagForceColor = envForceColor();
2063
+ if (noFlagForceColor !== void 0) {
2064
+ flagForceColor = noFlagForceColor;
2065
+ }
2066
+ const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
2067
+ if (forceColor === 0) {
2068
+ return 0;
2069
+ }
2070
+ if (sniffFlags) {
2071
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
2072
+ return 3;
2073
+ }
2074
+ if (hasFlag("color=256")) {
2075
+ return 2;
2076
+ }
2077
+ }
2078
+ if (haveStream && !streamIsTTY && forceColor === void 0) {
2079
+ return 0;
2080
+ }
2081
+ const min = forceColor || 0;
2082
+ if (env.TERM === "dumb") {
2083
+ return min;
2084
+ }
2085
+ if (process.platform === "win32") {
2086
+ const osRelease = os2.release().split(".");
2087
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
2088
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
2089
+ }
2090
+ return 1;
2091
+ }
2092
+ if ("CI" in env) {
2093
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
2094
+ return 1;
2095
+ }
2096
+ return min;
2097
+ }
2098
+ if ("TEAMCITY_VERSION" in env) {
2099
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
2100
+ }
2101
+ if (env.COLORTERM === "truecolor") {
2102
+ return 3;
2103
+ }
2104
+ if ("TERM_PROGRAM" in env) {
2105
+ const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
2106
+ switch (env.TERM_PROGRAM) {
2107
+ case "iTerm.app":
2108
+ return version >= 3 ? 3 : 2;
2109
+ case "Apple_Terminal":
2110
+ return 2;
2111
+ }
2112
+ }
2113
+ if (/-256(color)?$/i.test(env.TERM)) {
2114
+ return 2;
2115
+ }
2116
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
2117
+ return 1;
2118
+ }
2119
+ if ("COLORTERM" in env) {
2120
+ return 1;
2121
+ }
2122
+ return min;
2123
+ }
2124
+ function getSupportLevel(stream, options = {}) {
2125
+ const level = supportsColor(stream, __spreadValues({
2126
+ streamIsTTY: stream && stream.isTTY
2127
+ }, options));
2128
+ return translateLevel(level);
2129
+ }
2130
+ module.exports = {
2131
+ supportsColor: getSupportLevel,
2132
+ stdout: getSupportLevel({ isTTY: tty.isatty(1) }),
2133
+ stderr: getSupportLevel({ isTTY: tty.isatty(2) })
2134
+ };
2135
+ }
2136
+ });
2137
+
2138
+ // node_modules/debug/src/node.js
2139
+ var require_node = __commonJS({
2140
+ "node_modules/debug/src/node.js"(exports, module) {
2141
+ var tty = __require("tty");
2142
+ var util = __require("util");
2143
+ exports.init = init;
2144
+ exports.log = log;
2145
+ exports.formatArgs = formatArgs;
2146
+ exports.save = save;
2147
+ exports.load = load;
2148
+ exports.useColors = useColors;
2149
+ exports.destroy = util.deprecate(() => {
2150
+ }, "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
2151
+ exports.colors = [6, 2, 3, 4, 5, 1];
2152
+ try {
2153
+ const supportsColor = require_supports_color2();
2154
+ if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
2155
+ exports.colors = [
2156
+ 20,
2157
+ 21,
2158
+ 26,
2159
+ 27,
2160
+ 32,
2161
+ 33,
2162
+ 38,
2163
+ 39,
2164
+ 40,
2165
+ 41,
2166
+ 42,
2167
+ 43,
2168
+ 44,
2169
+ 45,
2170
+ 56,
2171
+ 57,
2172
+ 62,
2173
+ 63,
2174
+ 68,
2175
+ 69,
2176
+ 74,
2177
+ 75,
2178
+ 76,
2179
+ 77,
2180
+ 78,
2181
+ 79,
2182
+ 80,
2183
+ 81,
2184
+ 92,
2185
+ 93,
2186
+ 98,
2187
+ 99,
2188
+ 112,
2189
+ 113,
2190
+ 128,
2191
+ 129,
2192
+ 134,
2193
+ 135,
2194
+ 148,
2195
+ 149,
2196
+ 160,
2197
+ 161,
2198
+ 162,
2199
+ 163,
2200
+ 164,
2201
+ 165,
2202
+ 166,
2203
+ 167,
2204
+ 168,
2205
+ 169,
2206
+ 170,
2207
+ 171,
2208
+ 172,
2209
+ 173,
2210
+ 178,
2211
+ 179,
2212
+ 184,
2213
+ 185,
2214
+ 196,
2215
+ 197,
2216
+ 198,
2217
+ 199,
2218
+ 200,
2219
+ 201,
2220
+ 202,
2221
+ 203,
2222
+ 204,
2223
+ 205,
2224
+ 206,
2225
+ 207,
2226
+ 208,
2227
+ 209,
2228
+ 214,
2229
+ 215,
2230
+ 220,
2231
+ 221
2232
+ ];
2233
+ }
2234
+ } catch (error) {
2235
+ }
2236
+ exports.inspectOpts = Object.keys(process.env).filter((key) => {
2237
+ return /^debug_/i.test(key);
2238
+ }).reduce((obj, key) => {
2239
+ const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
2240
+ return k.toUpperCase();
2241
+ });
2242
+ let val = process.env[key];
2243
+ if (/^(yes|on|true|enabled)$/i.test(val)) {
2244
+ val = true;
2245
+ } else if (/^(no|off|false|disabled)$/i.test(val)) {
2246
+ val = false;
2247
+ } else if (val === "null") {
2248
+ val = null;
2249
+ } else {
2250
+ val = Number(val);
2251
+ }
2252
+ obj[prop] = val;
2253
+ return obj;
2254
+ }, {});
2255
+ function useColors() {
2256
+ return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
2257
+ }
2258
+ function formatArgs(args) {
2259
+ const { namespace: name, useColors: useColors2 } = this;
2260
+ if (useColors2) {
2261
+ const c = this.color;
2262
+ const colorCode = "[3" + (c < 8 ? c : "8;5;" + c);
2263
+ const prefix = ` ${colorCode};1m${name} `;
2264
+ args[0] = prefix + args[0].split("\n").join("\n" + prefix);
2265
+ args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "");
2266
+ } else {
2267
+ args[0] = getDate() + name + " " + args[0];
2268
+ }
2269
+ }
2270
+ function getDate() {
2271
+ if (exports.inspectOpts.hideDate) {
2272
+ return "";
2273
+ }
2274
+ return new Date().toISOString() + " ";
2275
+ }
2276
+ function log(...args) {
2277
+ return process.stderr.write(util.format(...args) + "\n");
2278
+ }
2279
+ function save(namespaces) {
2280
+ if (namespaces) {
2281
+ process.env.DEBUG = namespaces;
2282
+ } else {
2283
+ delete process.env.DEBUG;
2284
+ }
2285
+ }
2286
+ function load() {
2287
+ return process.env.DEBUG;
2288
+ }
2289
+ function init(debug2) {
2290
+ debug2.inspectOpts = {};
2291
+ const keys = Object.keys(exports.inspectOpts);
2292
+ for (let i = 0; i < keys.length; i++) {
2293
+ debug2.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
2294
+ }
2295
+ }
2296
+ module.exports = require_common()(exports);
2297
+ var { formatters } = module.exports;
2298
+ formatters.o = function(v) {
2299
+ this.inspectOpts.colors = this.useColors;
2300
+ return util.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
2301
+ };
2302
+ formatters.O = function(v) {
2303
+ this.inspectOpts.colors = this.useColors;
2304
+ return util.inspect(v, this.inspectOpts);
2305
+ };
2306
+ }
2307
+ });
2308
+
2309
+ // node_modules/debug/src/index.js
2310
+ var require_src = __commonJS({
2311
+ "node_modules/debug/src/index.js"(exports, module) {
2312
+ if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
2313
+ module.exports = require_browser();
2314
+ } else {
2315
+ module.exports = require_node();
2316
+ }
2317
+ }
2318
+ });
2319
+
1585
2320
  // node_modules/source-map/lib/base64.js
1586
2321
  var require_base64 = __commonJS({
1587
2322
  "node_modules/source-map/lib/base64.js"(exports) {
@@ -137734,6 +138469,7 @@ var require_typescript = __commonJS({
137734
138469
 
137735
138470
  // src/index.ts
137736
138471
  var import_chalk = __toModule(require_source());
138472
+ var import_debug = __toModule(require_src());
137737
138473
  var import_typescript = __toModule(require_typescript());
137738
138474
  import { resolve as resolve2, dirname as dirname2, relative as relative2 } from "path";
137739
138475
  import fs from "fs-extra";
@@ -137896,6 +138632,7 @@ function transferSetupPosition(content) {
137896
138632
  }
137897
138633
 
137898
138634
  // src/compile.ts
138635
+ var exportDefaultRE = /export\s+default/;
137899
138636
  var exportDefaultClassRE = /(?:(?:^|\n|;)\s*)export\s+default\s+class\s+([\w$]+)/;
137900
138637
  var index = 1;
137901
138638
  var compiler;
@@ -137925,7 +138662,7 @@ function compileVueCode(code) {
137925
138662
  content = compiled.content.replace(exportDefaultClassRE, `
137926
138663
  class $1`) + `
137927
138664
  const _sfc_main = ${classMatch[1]}`;
137928
- if (/export\s+default/.test(content)) {
138665
+ if (exportDefaultRE.test(content)) {
137929
138666
  content = rewriteDefault(compiled.content, `_sfc_main`);
137930
138667
  }
137931
138668
  } else {
@@ -137944,9 +138681,17 @@ const _sfc_main = ${classMatch[1]}`;
137944
138681
 
137945
138682
  // src/index.ts
137946
138683
  var noneExport = "export {};\n";
138684
+ var vueRE = /\.vue$/;
138685
+ var tsRE = /\.tsx?$/;
138686
+ var jsRE = /\.jsx?$/;
138687
+ var dtsRE = /\.d\.tsx?$/;
138688
+ var tjsRE = /\.(t|j)sx?$/;
138689
+ var watchExtensionRE = /\.(vue|(t|j)sx?)$/;
137947
138690
  var noop = () => {
137948
138691
  };
138692
+ var bundleDebug = (0, import_debug.debug)("vite-plugin-dts:bundle");
137949
138693
  function dtsPlugin(options = {}) {
138694
+ var _a;
137950
138695
  const {
137951
138696
  tsConfigFilePath = "tsconfig.json",
137952
138697
  cleanVueFileName = false,
@@ -137954,11 +138699,12 @@ function dtsPlugin(options = {}) {
137954
138699
  clearPureImport = true,
137955
138700
  insertTypesEntry = false,
137956
138701
  noEmitOnError = false,
138702
+ skipDiagnostics = true,
137957
138703
  logDiagnostics = false,
137958
138704
  afterDiagnostic = noop,
137959
138705
  beforeWriteFile = noop
137960
138706
  } = options;
137961
- const compilerOptions = options.compilerOptions || {};
138707
+ const compilerOptions = (_a = options.compilerOptions) != null ? _a : {};
137962
138708
  let root;
137963
138709
  let aliases;
137964
138710
  let entries;
@@ -137975,9 +138721,10 @@ function dtsPlugin(options = {}) {
137975
138721
  apply: "build",
137976
138722
  enforce: "pre",
137977
138723
  config(config) {
138724
+ var _a2;
137978
138725
  if (isBundle)
137979
138726
  return;
137980
- const aliasOptions = config.resolve && config.resolve.alias || [];
138727
+ const aliasOptions = (_a2 = config.resolve && config.resolve.alias) != null ? _a2 : [];
137981
138728
  if (isNativeObj(aliasOptions)) {
137982
138729
  aliases = Object.entries(aliasOptions).map(([key, value]) => {
137983
138730
  return { find: key, replacement: value };
@@ -137987,7 +138734,7 @@ function dtsPlugin(options = {}) {
137987
138734
  }
137988
138735
  },
137989
138736
  configResolved(config) {
137990
- var _a;
138737
+ var _a2, _b;
137991
138738
  if (isBundle)
137992
138739
  return;
137993
138740
  logger = config.logger;
@@ -137996,7 +138743,7 @@ function dtsPlugin(options = {}) {
137996
138743
  ${import_chalk.default.cyan("[vite:dts]")} You building not a library that may not need to generate declaration files.
137997
138744
  `));
137998
138745
  }
137999
- root = ensureAbsolute(options.root || "", config.root);
138746
+ root = ensureAbsolute((_a2 = options.root) != null ? _a2 : "", config.root);
138000
138747
  tsConfigPath = ensureAbsolute(tsConfigFilePath, root);
138001
138748
  outputDir = options.outputDir ? ensureAbsolute(options.outputDir, root) : ensureAbsolute(config.build.outDir, root);
138002
138749
  if (!outputDir) {
@@ -138005,9 +138752,9 @@ ${import_chalk.default.cyan("[vite:dts]")} Can not resolve declaration directory
138005
138752
  `));
138006
138753
  return;
138007
138754
  }
138008
- compilerOptions.rootDir = compilerOptions.rootDir || root;
138755
+ compilerOptions.rootDir || (compilerOptions.rootDir = root);
138009
138756
  project = new Project({
138010
- compilerOptions: mergeObjects(compilerOptions || {}, {
138757
+ compilerOptions: mergeObjects(compilerOptions, {
138011
138758
  noEmitOnError,
138012
138759
  outDir: ".",
138013
138760
  declarationDir: null,
@@ -138018,49 +138765,59 @@ ${import_chalk.default.cyan("[vite:dts]")} Can not resolve declaration directory
138018
138765
  tsConfigFilePath: tsConfigPath,
138019
138766
  skipAddingFilesFromTsConfig: true
138020
138767
  });
138021
- allowJs = (_a = project.getCompilerOptions().allowJs) != null ? _a : false;
138768
+ allowJs = (_b = project.getCompilerOptions().allowJs) != null ? _b : false;
138022
138769
  },
138023
138770
  buildStart(inputOptions) {
138024
- entries = Array.isArray(inputOptions.input) ? inputOptions.input : Object.values(inputOptions.input);
138771
+ if (insertTypesEntry) {
138772
+ entries = Array.isArray(inputOptions.input) ? inputOptions.input : Object.values(inputOptions.input);
138773
+ }
138025
138774
  },
138026
138775
  transform(code, id) {
138027
- if (/\.vue$/.test(id)) {
138776
+ if (vueRE.test(id)) {
138028
138777
  const { content, ext } = compileVueCode(code);
138029
138778
  if (content) {
138030
138779
  if (ext === "js" || ext === "jsx")
138031
138780
  hasJsVue = true;
138032
138781
  project.createSourceFile(`${id}.${ext || "js"}`, content, { overwrite: true });
138033
138782
  }
138034
- } else if (!id.includes(".vue?vue") && (/\.tsx?$/.test(id) || allowJs && /\.jsx?$/.test(id))) {
138783
+ } else if (!id.includes(".vue?vue") && (tsRE.test(id) || allowJs && jsRE.test(id))) {
138035
138784
  project.addSourceFileAtPath(id);
138036
138785
  }
138037
138786
  return null;
138038
138787
  },
138039
138788
  watchChange(id) {
138040
- if (/\.(vue|(t|j)sx?)$/.test(id)) {
138789
+ if (watchExtensionRE.test(id)) {
138041
138790
  isBundle = false;
138791
+ if (project) {
138792
+ const sourceFile = project.getSourceFile(normalizePath2(id));
138793
+ sourceFile && project.removeSourceFile(sourceFile);
138794
+ }
138042
138795
  }
138043
138796
  },
138044
138797
  async closeBundle() {
138798
+ var _a2, _b, _c;
138045
138799
  if (!outputDir || !project || isBundle)
138046
138800
  return;
138047
138801
  logger.info(import_chalk.default.green(`
138048
- ${import_chalk.default.cyan("[vite:dts]")} Compiling source files...`));
138802
+ ${import_chalk.default.cyan("[vite:dts]")} Start generate declaration files...`));
138803
+ bundleDebug("start");
138049
138804
  isBundle = true;
138050
138805
  sourceDtsFiles.clear();
138051
- const tsConfig = (0, import_typescript.readConfigFile)(tsConfigPath, project.getFileSystem().readFileSync).config || {};
138052
- const include = options.include || tsConfig.include;
138053
- const exclude = options.exclude || tsConfig.exclude;
138806
+ const startTime = Date.now();
138807
+ const tsConfig = (_a2 = (0, import_typescript.readConfigFile)(tsConfigPath, project.getFileSystem().readFileSync).config) != null ? _a2 : {};
138808
+ const include = (_b = options.include) != null ? _b : tsConfig.include;
138809
+ const exclude = (_c = options.exclude) != null ? _c : tsConfig.exclude;
138810
+ bundleDebug("read config");
138054
138811
  const includedFileSet = new Set();
138055
138812
  if (include && include.length) {
138056
138813
  const files = await glob(ensureArray(include).map(normalizeGlob), {
138057
138814
  cwd: root,
138058
138815
  absolute: true,
138059
- ignore: ensureArray(exclude || ["node_modules/**"]).map(normalizeGlob)
138816
+ ignore: ensureArray(exclude != null ? exclude : ["node_modules/**"]).map(normalizeGlob)
138060
138817
  });
138061
138818
  files.forEach((file) => {
138062
- includedFileSet.add(/\.d\.tsx?$/.test(file) ? file : `${/\.(t|j)sx?$/.test(file) ? file.replace(/\.(t|j)sx?$/, "") : file}.d.ts`);
138063
- if (/\.d\.tsx?$/.test(file)) {
138819
+ includedFileSet.add(dtsRE.test(file) ? file : `${tjsRE.test(file) ? file.replace(tjsRE, "") : file}.d.ts`);
138820
+ if (dtsRE.test(file)) {
138064
138821
  sourceDtsFiles.add(file);
138065
138822
  }
138066
138823
  });
@@ -138070,19 +138827,29 @@ ${import_chalk.default.cyan("[vite:dts]")} Compiling source files...`));
138070
138827
  }
138071
138828
  project.compilerOptions.set({ allowJs: true });
138072
138829
  }
138830
+ bundleDebug("collect files");
138073
138831
  }
138074
138832
  project.resolveSourceFileDependencies();
138075
- const diagnostics = project.getPreEmitDiagnostics();
138076
- if ((diagnostics == null ? void 0 : diagnostics.length) && logDiagnostics) {
138077
- logger.warn(project.formatDiagnosticsWithColorAndContext(diagnostics));
138078
- }
138079
- if (typeof afterDiagnostic === "function") {
138080
- afterDiagnostic(diagnostics);
138081
- }
138082
- logger.info(import_chalk.default.green(`${import_chalk.default.cyan("[vite:dts]")} Generating declaration files...`));
138083
- await runParallel(os.cpus().length, project.emitToMemory().getFiles(), async (outputFile) => {
138084
- let filePath = outputFile.filePath;
138085
- let content = outputFile.text;
138833
+ bundleDebug("resolve");
138834
+ if (!skipDiagnostics) {
138835
+ const diagnostics = project.getPreEmitDiagnostics();
138836
+ if ((diagnostics == null ? void 0 : diagnostics.length) && logDiagnostics) {
138837
+ logger.warn(project.formatDiagnosticsWithColorAndContext(diagnostics));
138838
+ }
138839
+ if (typeof afterDiagnostic === "function") {
138840
+ afterDiagnostic(diagnostics);
138841
+ }
138842
+ bundleDebug("diagnostics");
138843
+ }
138844
+ const service = project.getLanguageService();
138845
+ const outputFiles = project.getSourceFiles().map((sourceFile) => {
138846
+ return service.getEmitOutput(sourceFile, true).getOutputFiles();
138847
+ }).flat();
138848
+ bundleDebug("emit");
138849
+ await runParallel(os.cpus().length, outputFiles, async (outputFile) => {
138850
+ var _a3, _b2;
138851
+ let filePath = outputFile.getFilePath();
138852
+ let content = outputFile.getText();
138086
138853
  const isMapFile = filePath.endsWith(".map");
138087
138854
  if (!includedFileSet.has(isMapFile ? filePath.slice(0, -4) : filePath) || clearPureImport && content === noneExport)
138088
138855
  return;
@@ -138095,18 +138862,20 @@ ${import_chalk.default.cyan("[vite:dts]")} Compiling source files...`));
138095
138862
  if (typeof beforeWriteFile === "function") {
138096
138863
  const result = beforeWriteFile(filePath, content);
138097
138864
  if (result && isNativeObj(result)) {
138098
- filePath = result.filePath || filePath;
138099
- content = result.content || content;
138865
+ filePath = (_a3 = result.filePath) != null ? _a3 : filePath;
138866
+ content = (_b2 = result.content) != null ? _b2 : content;
138100
138867
  }
138101
138868
  }
138102
138869
  await fs.mkdir(dirname2(filePath), { recursive: true });
138103
138870
  await fs.writeFile(filePath, cleanVueFileName ? content.replace(/['"](.+)\.vue['"]/g, '"$1"') : content, "utf8");
138104
138871
  });
138872
+ bundleDebug("output");
138105
138873
  await Promise.all(Array.from(sourceDtsFiles).map(async (filePath) => {
138106
138874
  const targetPath = resolve2(outputDir, relative2(root, filePath));
138107
138875
  await fs.mkdir(dirname2(targetPath), { recursive: true });
138108
138876
  await fs.copyFile(filePath, targetPath);
138109
138877
  }));
138878
+ bundleDebug("copy dts");
138110
138879
  if (insertTypesEntry) {
138111
138880
  const pkgPath = resolve2(root, "package.json");
138112
138881
  const pkg = fs.existsSync(pkgPath) ? JSON.parse(await fs.readFile(pkgPath, "utf-8")) : {};
@@ -138114,14 +138883,15 @@ ${import_chalk.default.cyan("[vite:dts]")} Compiling source files...`));
138114
138883
  if (!fs.existsSync(typesPath)) {
138115
138884
  const content = entries.map((entry) => {
138116
138885
  let filePath = normalizePath2(relative2(dirname2(typesPath), resolve2(outputDir, relative2(root, entry))));
138117
- filePath = filePath.replace(/\.tsx?$/, "");
138886
+ filePath = filePath.replace(tsRE, "");
138118
138887
  filePath = /^\.\.?\//.test(filePath) ? filePath : `./${filePath}`;
138119
138888
  return `export * from '${filePath}'`;
138120
138889
  }).join("\n") + "\n";
138121
138890
  await fs.writeFile(typesPath, content, "utf-8");
138122
138891
  }
138892
+ bundleDebug("insert index");
138123
138893
  }
138124
- logger.info(import_chalk.default.green(`${import_chalk.default.cyan("[vite:dts]")} Declaration files built.
138894
+ logger.info(import_chalk.default.green(`${import_chalk.default.cyan("[vite:dts]")} Declaration files built in ${Date.now() - startTime}ms.
138125
138895
  `));
138126
138896
  }
138127
138897
  };