@storybook/react 10.6.0-alpha.4 → 10.6.0-alpha.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/dist/_node-chunks/{chunk-V5DKJTFY.js → chunk-RATZ5JVF.js} +1051 -1468
- package/dist/docgen/docgen-worker.js +15 -24
- package/dist/preset.js +81 -23
- package/package.json +3 -8
- package/dist/playwright.d.ts +0 -2
- package/dist/playwright.js +0 -7
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_h2cb86pu2u from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_h2cb86pu2u from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_h2cb86pu2u from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_h2cb86pu2u.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_h2cb86pu2u.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_h2cb86pu2u.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -53,49 +53,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
53
53
|
mod
|
|
54
54
|
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
55
55
|
|
|
56
|
-
// ../../../node_modules/ts-dedent/dist/index.js
|
|
57
|
-
var require_dist = __commonJS({
|
|
58
|
-
"../../../node_modules/ts-dedent/dist/index.js"(exports) {
|
|
59
|
-
"use strict";
|
|
60
|
-
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
61
|
-
exports.dedent = void 0;
|
|
62
|
-
function dedent4(templ) {
|
|
63
|
-
for (var values = [], _i = 1; _i < arguments.length; _i++)
|
|
64
|
-
values[_i - 1] = arguments[_i];
|
|
65
|
-
var strings = Array.from(typeof templ == "string" ? [templ] : templ);
|
|
66
|
-
strings[strings.length - 1] = strings[strings.length - 1].replace(/\r?\n([\t ]*)$/, "");
|
|
67
|
-
var indentLengths = strings.reduce(function(arr, str) {
|
|
68
|
-
var matches = str.match(/\n([\t ]+|(?!\s).)/g);
|
|
69
|
-
return matches ? arr.concat(matches.map(function(match) {
|
|
70
|
-
var _a, _b;
|
|
71
|
-
return (_b = (_a = match.match(/[\t ]/g)) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
72
|
-
})) : arr;
|
|
73
|
-
}, []);
|
|
74
|
-
if (indentLengths.length) {
|
|
75
|
-
var pattern_1 = new RegExp(`
|
|
76
|
-
[ ]{` + Math.min.apply(Math, indentLengths) + "}", "g");
|
|
77
|
-
strings = strings.map(function(str) {
|
|
78
|
-
return str.replace(pattern_1, `
|
|
79
|
-
`);
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
strings[0] = strings[0].replace(/^\r?\n/, "");
|
|
83
|
-
var string = strings[0];
|
|
84
|
-
return values.forEach(function(value, i2) {
|
|
85
|
-
var endentations = string.match(/(?:^|\n)( *)$/), endentation = endentations ? endentations[1] : "", indentedValue = value;
|
|
86
|
-
typeof value == "string" && value.includes(`
|
|
87
|
-
`) && (indentedValue = String(value).split(`
|
|
88
|
-
`).map(function(str, i3) {
|
|
89
|
-
return i3 === 0 ? str : "" + endentation + str;
|
|
90
|
-
}).join(`
|
|
91
|
-
`)), string += indentedValue + strings[i2 + 1];
|
|
92
|
-
}), string;
|
|
93
|
-
}
|
|
94
|
-
exports.dedent = dedent4;
|
|
95
|
-
exports.default = dedent4;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
|
|
99
56
|
// ../../../node_modules/@volar/source-map/lib/binarySearch.js
|
|
100
57
|
var require_binarySearch = __commonJS({
|
|
101
58
|
"../../../node_modules/@volar/source-map/lib/binarySearch.js"(exports) {
|
|
@@ -653,8 +610,8 @@ var require_common = __commonJS({
|
|
|
653
610
|
"use strict";
|
|
654
611
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
655
612
|
exports.resolveFileLanguageId = resolveFileLanguageId2;
|
|
656
|
-
function resolveFileLanguageId2(
|
|
657
|
-
switch (
|
|
613
|
+
function resolveFileLanguageId2(path2) {
|
|
614
|
+
switch (path2.split(".").pop()) {
|
|
658
615
|
case "js":
|
|
659
616
|
return "javascript";
|
|
660
617
|
case "cjs":
|
|
@@ -799,11 +756,11 @@ var require_decorateLanguageServiceHost = __commonJS({
|
|
|
799
756
|
var resolveModuleName_1 = require_resolveModuleName(), utils_1 = require_utils2();
|
|
800
757
|
function decorateLanguageServiceHost(ts, language, languageServiceHost) {
|
|
801
758
|
let pluginExtensions = language.plugins.map((plugin) => plugin.typescript?.extraFileExtensions.map((ext) => "." + ext.extension) ?? []).flat(), scripts = /* @__PURE__ */ new Map(), crashFileNames = /* @__PURE__ */ new Set(), readDirectory = languageServiceHost.readDirectory?.bind(languageServiceHost), resolveModuleNameLiterals = languageServiceHost.resolveModuleNameLiterals?.bind(languageServiceHost), resolveModuleNames = languageServiceHost.resolveModuleNames?.bind(languageServiceHost), getScriptSnapshot = languageServiceHost.getScriptSnapshot.bind(languageServiceHost), getScriptKind = languageServiceHost.getScriptKind?.bind(languageServiceHost);
|
|
802
|
-
if (readDirectory && (languageServiceHost.readDirectory = (
|
|
759
|
+
if (readDirectory && (languageServiceHost.readDirectory = (path2, extensions, exclude, include, depth) => {
|
|
803
760
|
if (extensions)
|
|
804
761
|
for (let ext of pluginExtensions)
|
|
805
762
|
extensions.includes(ext) || (extensions = [...extensions, ext]);
|
|
806
|
-
return readDirectory(
|
|
763
|
+
return readDirectory(path2, extensions, exclude, include, depth);
|
|
807
764
|
}), pluginExtensions.length) {
|
|
808
765
|
let resolveModuleName = (0, resolveModuleName_1.createResolveModuleName)(ts, ts.sys.getFileSize, languageServiceHost, language.plugins, (fileName) => language.scripts.get(fileName)), moduleResolutionCache = languageServiceHost.getModuleResolutionCache?.();
|
|
809
766
|
resolveModuleNameLiterals && (languageServiceHost.resolveModuleNameLiterals = (moduleLiterals, containingFile, redirectedReference, options, containingSourceFile, ...rest) => {
|
|
@@ -1105,8 +1062,8 @@ var require_decorateProgram = __commonJS({
|
|
|
1105
1062
|
return getBindAndCheckDiagnostics(actualSourceFile, cancellationToken).map((d) => (0, transform_1.transformDiagnostic)(language, d, program, !0)).filter((d) => !!d).filter((d) => !serviceScript || language.scripts.get(d.file.fileName) === sourceScript);
|
|
1106
1063
|
} else
|
|
1107
1064
|
return getBindAndCheckDiagnostics(void 0, cancellationToken).map((d) => (0, transform_1.transformDiagnostic)(language, d, program, !0)).filter((d) => !!d);
|
|
1108
|
-
}, program.getSourceFileByPath = (
|
|
1109
|
-
let sourceFile = getSourceFileByPath(
|
|
1065
|
+
}, program.getSourceFileByPath = (path2) => {
|
|
1066
|
+
let sourceFile = getSourceFileByPath(path2);
|
|
1110
1067
|
return sourceFile && (0, transform_1.fillSourceFileText)(language, sourceFile), sourceFile;
|
|
1111
1068
|
};
|
|
1112
1069
|
}
|
|
@@ -1875,14 +1832,14 @@ var require_proxyLanguageService = __commonJS({
|
|
|
1875
1832
|
var require_path_browserify = __commonJS({
|
|
1876
1833
|
"../../../node_modules/path-browserify/index.js"(exports, module) {
|
|
1877
1834
|
"use strict";
|
|
1878
|
-
function assertPath(
|
|
1879
|
-
if (typeof
|
|
1880
|
-
throw new TypeError("Path must be a string. Received " + JSON.stringify(
|
|
1881
|
-
}
|
|
1882
|
-
function normalizeStringPosix(
|
|
1883
|
-
for (var res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, code, i2 = 0; i2 <=
|
|
1884
|
-
if (i2 <
|
|
1885
|
-
code =
|
|
1835
|
+
function assertPath(path2) {
|
|
1836
|
+
if (typeof path2 != "string")
|
|
1837
|
+
throw new TypeError("Path must be a string. Received " + JSON.stringify(path2));
|
|
1838
|
+
}
|
|
1839
|
+
function normalizeStringPosix(path2, allowAboveRoot) {
|
|
1840
|
+
for (var res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, code, i2 = 0; i2 <= path2.length; ++i2) {
|
|
1841
|
+
if (i2 < path2.length)
|
|
1842
|
+
code = path2.charCodeAt(i2);
|
|
1886
1843
|
else {
|
|
1887
1844
|
if (code === 47)
|
|
1888
1845
|
break;
|
|
@@ -1905,7 +1862,7 @@ var require_path_browserify = __commonJS({
|
|
|
1905
1862
|
}
|
|
1906
1863
|
allowAboveRoot && (res.length > 0 ? res += "/.." : res = "..", lastSegmentLength = 2);
|
|
1907
1864
|
} else
|
|
1908
|
-
res.length > 0 ? res += "/" +
|
|
1865
|
+
res.length > 0 ? res += "/" + path2.slice(lastSlash + 1, i2) : res = path2.slice(lastSlash + 1, i2), lastSegmentLength = i2 - lastSlash - 1;
|
|
1909
1866
|
lastSlash = i2, dots = 0;
|
|
1910
1867
|
} else code === 46 && dots !== -1 ? ++dots : dots = -1;
|
|
1911
1868
|
}
|
|
@@ -1915,22 +1872,22 @@ var require_path_browserify = __commonJS({
|
|
|
1915
1872
|
var dir = pathObject.dir || pathObject.root, base2 = pathObject.base || (pathObject.name || "") + (pathObject.ext || "");
|
|
1916
1873
|
return dir ? dir === pathObject.root ? dir + base2 : dir + sep3 + base2 : base2;
|
|
1917
1874
|
}
|
|
1918
|
-
var
|
|
1875
|
+
var posix2 = {
|
|
1919
1876
|
// path.resolve([from ...], to)
|
|
1920
1877
|
resolve: function() {
|
|
1921
1878
|
for (var resolvedPath = "", resolvedAbsolute = !1, cwd2, i2 = arguments.length - 1; i2 >= -1 && !resolvedAbsolute; i2--) {
|
|
1922
|
-
var
|
|
1923
|
-
i2 >= 0 ?
|
|
1879
|
+
var path2;
|
|
1880
|
+
i2 >= 0 ? path2 = arguments[i2] : (cwd2 === void 0 && (cwd2 = process.cwd()), path2 = cwd2), assertPath(path2), path2.length !== 0 && (resolvedPath = path2 + "/" + resolvedPath, resolvedAbsolute = path2.charCodeAt(0) === 47);
|
|
1924
1881
|
}
|
|
1925
1882
|
return resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute), resolvedAbsolute ? resolvedPath.length > 0 ? "/" + resolvedPath : "/" : resolvedPath.length > 0 ? resolvedPath : ".";
|
|
1926
1883
|
},
|
|
1927
|
-
normalize: function(
|
|
1928
|
-
if (assertPath(
|
|
1929
|
-
var
|
|
1930
|
-
return
|
|
1884
|
+
normalize: function(path2) {
|
|
1885
|
+
if (assertPath(path2), path2.length === 0) return ".";
|
|
1886
|
+
var isAbsolute3 = path2.charCodeAt(0) === 47, trailingSeparator = path2.charCodeAt(path2.length - 1) === 47;
|
|
1887
|
+
return path2 = normalizeStringPosix(path2, !isAbsolute3), path2.length === 0 && !isAbsolute3 && (path2 = "."), path2.length > 0 && trailingSeparator && (path2 += "/"), isAbsolute3 ? "/" + path2 : path2;
|
|
1931
1888
|
},
|
|
1932
|
-
isAbsolute: function(
|
|
1933
|
-
return assertPath(
|
|
1889
|
+
isAbsolute: function(path2) {
|
|
1890
|
+
return assertPath(path2), path2.length > 0 && path2.charCodeAt(0) === 47;
|
|
1934
1891
|
},
|
|
1935
1892
|
join: function() {
|
|
1936
1893
|
if (arguments.length === 0)
|
|
@@ -1939,10 +1896,10 @@ var require_path_browserify = __commonJS({
|
|
|
1939
1896
|
var arg = arguments[i2];
|
|
1940
1897
|
assertPath(arg), arg.length > 0 && (joined === void 0 ? joined = arg : joined += "/" + arg);
|
|
1941
1898
|
}
|
|
1942
|
-
return joined === void 0 ? "." :
|
|
1899
|
+
return joined === void 0 ? "." : posix2.normalize(joined);
|
|
1943
1900
|
},
|
|
1944
1901
|
relative: function(from, to) {
|
|
1945
|
-
if (assertPath(from), assertPath(to), from === to || (from =
|
|
1902
|
+
if (assertPath(from), assertPath(to), from === to || (from = posix2.resolve(from), to = posix2.resolve(to), from === to)) return "";
|
|
1946
1903
|
for (var fromStart = 1; fromStart < from.length && from.charCodeAt(fromStart) === 47; ++fromStart)
|
|
1947
1904
|
;
|
|
1948
1905
|
for (var fromEnd = from.length, fromLen = fromEnd - fromStart, toStart = 1; toStart < to.length && to.charCodeAt(toStart) === 47; ++toStart)
|
|
@@ -1967,30 +1924,30 @@ var require_path_browserify = __commonJS({
|
|
|
1967
1924
|
(i2 === fromEnd || from.charCodeAt(i2) === 47) && (out.length === 0 ? out += ".." : out += "/..");
|
|
1968
1925
|
return out.length > 0 ? out + to.slice(toStart + lastCommonSep) : (toStart += lastCommonSep, to.charCodeAt(toStart) === 47 && ++toStart, to.slice(toStart));
|
|
1969
1926
|
},
|
|
1970
|
-
_makeLong: function(
|
|
1971
|
-
return
|
|
1927
|
+
_makeLong: function(path2) {
|
|
1928
|
+
return path2;
|
|
1972
1929
|
},
|
|
1973
|
-
dirname: function(
|
|
1974
|
-
if (assertPath(
|
|
1975
|
-
for (var code =
|
|
1976
|
-
if (code =
|
|
1930
|
+
dirname: function(path2) {
|
|
1931
|
+
if (assertPath(path2), path2.length === 0) return ".";
|
|
1932
|
+
for (var code = path2.charCodeAt(0), hasRoot = code === 47, end = -1, matchedSlash = !0, i2 = path2.length - 1; i2 >= 1; --i2)
|
|
1933
|
+
if (code = path2.charCodeAt(i2), code === 47) {
|
|
1977
1934
|
if (!matchedSlash) {
|
|
1978
1935
|
end = i2;
|
|
1979
1936
|
break;
|
|
1980
1937
|
}
|
|
1981
1938
|
} else
|
|
1982
1939
|
matchedSlash = !1;
|
|
1983
|
-
return end === -1 ? hasRoot ? "/" : "." : hasRoot && end === 1 ? "//" :
|
|
1940
|
+
return end === -1 ? hasRoot ? "/" : "." : hasRoot && end === 1 ? "//" : path2.slice(0, end);
|
|
1984
1941
|
},
|
|
1985
|
-
basename: function(
|
|
1942
|
+
basename: function(path2, ext) {
|
|
1986
1943
|
if (ext !== void 0 && typeof ext != "string") throw new TypeError('"ext" argument must be a string');
|
|
1987
|
-
assertPath(
|
|
1944
|
+
assertPath(path2);
|
|
1988
1945
|
var start = 0, end = -1, matchedSlash = !0, i2;
|
|
1989
|
-
if (ext !== void 0 && ext.length > 0 && ext.length <=
|
|
1990
|
-
if (ext.length ===
|
|
1946
|
+
if (ext !== void 0 && ext.length > 0 && ext.length <= path2.length) {
|
|
1947
|
+
if (ext.length === path2.length && ext === path2) return "";
|
|
1991
1948
|
var extIdx = ext.length - 1, firstNonSlashEnd = -1;
|
|
1992
|
-
for (i2 =
|
|
1993
|
-
var code =
|
|
1949
|
+
for (i2 = path2.length - 1; i2 >= 0; --i2) {
|
|
1950
|
+
var code = path2.charCodeAt(i2);
|
|
1994
1951
|
if (code === 47) {
|
|
1995
1952
|
if (!matchedSlash) {
|
|
1996
1953
|
start = i2 + 1;
|
|
@@ -1999,22 +1956,22 @@ var require_path_browserify = __commonJS({
|
|
|
1999
1956
|
} else
|
|
2000
1957
|
firstNonSlashEnd === -1 && (matchedSlash = !1, firstNonSlashEnd = i2 + 1), extIdx >= 0 && (code === ext.charCodeAt(extIdx) ? --extIdx === -1 && (end = i2) : (extIdx = -1, end = firstNonSlashEnd));
|
|
2001
1958
|
}
|
|
2002
|
-
return start === end ? end = firstNonSlashEnd : end === -1 && (end =
|
|
1959
|
+
return start === end ? end = firstNonSlashEnd : end === -1 && (end = path2.length), path2.slice(start, end);
|
|
2003
1960
|
} else {
|
|
2004
|
-
for (i2 =
|
|
2005
|
-
if (
|
|
1961
|
+
for (i2 = path2.length - 1; i2 >= 0; --i2)
|
|
1962
|
+
if (path2.charCodeAt(i2) === 47) {
|
|
2006
1963
|
if (!matchedSlash) {
|
|
2007
1964
|
start = i2 + 1;
|
|
2008
1965
|
break;
|
|
2009
1966
|
}
|
|
2010
1967
|
} else end === -1 && (matchedSlash = !1, end = i2 + 1);
|
|
2011
|
-
return end === -1 ? "" :
|
|
1968
|
+
return end === -1 ? "" : path2.slice(start, end);
|
|
2012
1969
|
}
|
|
2013
1970
|
},
|
|
2014
|
-
extname: function(
|
|
2015
|
-
assertPath(
|
|
2016
|
-
for (var startDot = -1, startPart = 0, end = -1, matchedSlash = !0, preDotState = 0, i2 =
|
|
2017
|
-
var code =
|
|
1971
|
+
extname: function(path2) {
|
|
1972
|
+
assertPath(path2);
|
|
1973
|
+
for (var startDot = -1, startPart = 0, end = -1, matchedSlash = !0, preDotState = 0, i2 = path2.length - 1; i2 >= 0; --i2) {
|
|
1974
|
+
var code = path2.charCodeAt(i2);
|
|
2018
1975
|
if (code === 47) {
|
|
2019
1976
|
if (!matchedSlash) {
|
|
2020
1977
|
startPart = i2 + 1;
|
|
@@ -2026,21 +1983,21 @@ var require_path_browserify = __commonJS({
|
|
|
2026
1983
|
}
|
|
2027
1984
|
return startDot === -1 || end === -1 || // We saw a non-dot character immediately before the dot
|
|
2028
1985
|
preDotState === 0 || // The (right-most) trimmed path component is exactly '..'
|
|
2029
|
-
preDotState === 1 && startDot === end - 1 && startDot === startPart + 1 ? "" :
|
|
1986
|
+
preDotState === 1 && startDot === end - 1 && startDot === startPart + 1 ? "" : path2.slice(startDot, end);
|
|
2030
1987
|
},
|
|
2031
1988
|
format: function(pathObject) {
|
|
2032
1989
|
if (pathObject === null || typeof pathObject != "object")
|
|
2033
1990
|
throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
|
|
2034
1991
|
return _format("/", pathObject);
|
|
2035
1992
|
},
|
|
2036
|
-
parse: function(
|
|
2037
|
-
assertPath(
|
|
1993
|
+
parse: function(path2) {
|
|
1994
|
+
assertPath(path2);
|
|
2038
1995
|
var ret = { root: "", dir: "", base: "", ext: "", name: "" };
|
|
2039
|
-
if (
|
|
2040
|
-
var code =
|
|
2041
|
-
|
|
2042
|
-
for (var startDot = -1, startPart = 0, end = -1, matchedSlash = !0, i2 =
|
|
2043
|
-
if (code =
|
|
1996
|
+
if (path2.length === 0) return ret;
|
|
1997
|
+
var code = path2.charCodeAt(0), isAbsolute3 = code === 47, start;
|
|
1998
|
+
isAbsolute3 ? (ret.root = "/", start = 1) : start = 0;
|
|
1999
|
+
for (var startDot = -1, startPart = 0, end = -1, matchedSlash = !0, i2 = path2.length - 1, preDotState = 0; i2 >= start; --i2) {
|
|
2000
|
+
if (code = path2.charCodeAt(i2), code === 47) {
|
|
2044
2001
|
if (!matchedSlash) {
|
|
2045
2002
|
startPart = i2 + 1;
|
|
2046
2003
|
break;
|
|
@@ -2051,15 +2008,15 @@ var require_path_browserify = __commonJS({
|
|
|
2051
2008
|
}
|
|
2052
2009
|
return startDot === -1 || end === -1 || // We saw a non-dot character immediately before the dot
|
|
2053
2010
|
preDotState === 0 || // The (right-most) trimmed path component is exactly '..'
|
|
2054
|
-
preDotState === 1 && startDot === end - 1 && startDot === startPart + 1 ? end !== -1 && (startPart === 0 &&
|
|
2011
|
+
preDotState === 1 && startDot === end - 1 && startDot === startPart + 1 ? end !== -1 && (startPart === 0 && isAbsolute3 ? ret.base = ret.name = path2.slice(1, end) : ret.base = ret.name = path2.slice(startPart, end)) : (startPart === 0 && isAbsolute3 ? (ret.name = path2.slice(1, startDot), ret.base = path2.slice(1, end)) : (ret.name = path2.slice(startPart, startDot), ret.base = path2.slice(startPart, end)), ret.ext = path2.slice(startDot, end)), startPart > 0 ? ret.dir = path2.slice(0, startPart - 1) : isAbsolute3 && (ret.dir = "/"), ret;
|
|
2055
2012
|
},
|
|
2056
2013
|
sep: "/",
|
|
2057
2014
|
delimiter: ":",
|
|
2058
2015
|
win32: null,
|
|
2059
2016
|
posix: null
|
|
2060
2017
|
};
|
|
2061
|
-
|
|
2062
|
-
module.exports =
|
|
2018
|
+
posix2.posix = posix2;
|
|
2019
|
+
module.exports = posix2;
|
|
2063
2020
|
}
|
|
2064
2021
|
});
|
|
2065
2022
|
|
|
@@ -2069,7 +2026,7 @@ var require_createProject = __commonJS({
|
|
|
2069
2026
|
"use strict";
|
|
2070
2027
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
2071
2028
|
exports.createLanguageServiceHost = createLanguageServiceHost2;
|
|
2072
|
-
var language_core_1 = require_language_core(),
|
|
2029
|
+
var language_core_1 = require_language_core(), path2 = require_path_browserify(), utils_1 = require_utils2(), resolveModuleName_1 = require_resolveModuleName();
|
|
2073
2030
|
function createLanguageServiceHost2(ts, sys, language, asScriptId, projectHost) {
|
|
2074
2031
|
let pluginExtensions = language.plugins.map((plugin) => plugin.typescript?.extraFileExtensions.map((ext) => "." + ext.extension) ?? []).flat(), scriptVersions = new language_core_1.FileMap(sys.useCaseSensitiveFileNames), lastProjectVersion, tsProjectVersion = 0, tsFileRegistry = new language_core_1.FileMap(sys.useCaseSensitiveFileNames), tsFileDirRegistry = new language_core_1.FileMap(sys.useCaseSensitiveFileNames), extraScriptRegistry = new language_core_1.FileMap(sys.useCaseSensitiveFileNames), lastTsVirtualFileSnapshots = /* @__PURE__ */ new Set(), lastOtherVirtualFileSnapshots = /* @__PURE__ */ new Set(), languageServiceHost = {
|
|
2075
2032
|
...sys,
|
|
@@ -2131,7 +2088,7 @@ var require_createProject = __commonJS({
|
|
|
2131
2088
|
if (serviceScript)
|
|
2132
2089
|
return serviceScript.scriptKind;
|
|
2133
2090
|
}
|
|
2134
|
-
switch (
|
|
2091
|
+
switch (path2.extname(fileName)) {
|
|
2135
2092
|
case ".js":
|
|
2136
2093
|
case ".cjs":
|
|
2137
2094
|
case ".mjs":
|
|
@@ -2798,23 +2755,23 @@ var require_path = __commonJS({
|
|
|
2798
2755
|
function isAnyDirectorySeparator(charCode) {
|
|
2799
2756
|
return charCode === 47 || charCode === 92;
|
|
2800
2757
|
}
|
|
2801
|
-
function isRootedDiskPath(
|
|
2802
|
-
return getEncodedRootLength(
|
|
2758
|
+
function isRootedDiskPath(path2) {
|
|
2759
|
+
return getEncodedRootLength(path2) > 0;
|
|
2803
2760
|
}
|
|
2804
2761
|
function hasExtension(fileName) {
|
|
2805
2762
|
return (0, core_1.stringContains)(getBaseFileName(fileName), ".");
|
|
2806
2763
|
}
|
|
2807
|
-
function fileExtensionIs(
|
|
2808
|
-
return
|
|
2764
|
+
function fileExtensionIs(path2, extension) {
|
|
2765
|
+
return path2.length > extension.length && (0, core_1.endsWith)(path2, extension);
|
|
2809
2766
|
}
|
|
2810
|
-
function fileExtensionIsOneOf(
|
|
2767
|
+
function fileExtensionIsOneOf(path2, extensions) {
|
|
2811
2768
|
for (let extension of extensions)
|
|
2812
|
-
if (fileExtensionIs(
|
|
2769
|
+
if (fileExtensionIs(path2, extension))
|
|
2813
2770
|
return !0;
|
|
2814
2771
|
return !1;
|
|
2815
2772
|
}
|
|
2816
|
-
function hasTrailingDirectorySeparator(
|
|
2817
|
-
return
|
|
2773
|
+
function hasTrailingDirectorySeparator(path2) {
|
|
2774
|
+
return path2.length > 0 && isAnyDirectorySeparator(path2.charCodeAt(path2.length - 1));
|
|
2818
2775
|
}
|
|
2819
2776
|
function isVolumeCharacter(charCode) {
|
|
2820
2777
|
return charCode >= 97 && charCode <= 122 || charCode >= 65 && charCode <= 90;
|
|
@@ -2830,94 +2787,94 @@ var require_path = __commonJS({
|
|
|
2830
2787
|
}
|
|
2831
2788
|
return -1;
|
|
2832
2789
|
}
|
|
2833
|
-
function getEncodedRootLength(
|
|
2834
|
-
if (!
|
|
2790
|
+
function getEncodedRootLength(path2) {
|
|
2791
|
+
if (!path2)
|
|
2835
2792
|
return 0;
|
|
2836
|
-
let ch0 =
|
|
2793
|
+
let ch0 = path2.charCodeAt(0);
|
|
2837
2794
|
if (ch0 === 47 || ch0 === 92) {
|
|
2838
|
-
if (
|
|
2795
|
+
if (path2.charCodeAt(1) !== ch0)
|
|
2839
2796
|
return 1;
|
|
2840
|
-
let p1 =
|
|
2841
|
-
return p1 < 0 ?
|
|
2797
|
+
let p1 = path2.indexOf(ch0 === 47 ? exports.directorySeparator : altDirectorySeparator, 2);
|
|
2798
|
+
return p1 < 0 ? path2.length : p1 + 1;
|
|
2842
2799
|
}
|
|
2843
|
-
if (isVolumeCharacter(ch0) &&
|
|
2844
|
-
let ch2 =
|
|
2800
|
+
if (isVolumeCharacter(ch0) && path2.charCodeAt(1) === 58) {
|
|
2801
|
+
let ch2 = path2.charCodeAt(2);
|
|
2845
2802
|
if (ch2 === 47 || ch2 === 92)
|
|
2846
2803
|
return 3;
|
|
2847
|
-
if (
|
|
2804
|
+
if (path2.length === 2)
|
|
2848
2805
|
return 2;
|
|
2849
2806
|
}
|
|
2850
|
-
let schemeEnd =
|
|
2807
|
+
let schemeEnd = path2.indexOf(urlSchemeSeparator);
|
|
2851
2808
|
if (schemeEnd !== -1) {
|
|
2852
|
-
let authorityStart = schemeEnd + urlSchemeSeparator.length, authorityEnd =
|
|
2809
|
+
let authorityStart = schemeEnd + urlSchemeSeparator.length, authorityEnd = path2.indexOf(exports.directorySeparator, authorityStart);
|
|
2853
2810
|
if (authorityEnd !== -1) {
|
|
2854
|
-
let scheme =
|
|
2855
|
-
if (scheme === "file" && (authority === "" || authority === "localhost") && isVolumeCharacter(
|
|
2856
|
-
let volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(
|
|
2811
|
+
let scheme = path2.slice(0, schemeEnd), authority = path2.slice(authorityStart, authorityEnd);
|
|
2812
|
+
if (scheme === "file" && (authority === "" || authority === "localhost") && isVolumeCharacter(path2.charCodeAt(authorityEnd + 1))) {
|
|
2813
|
+
let volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path2, authorityEnd + 2);
|
|
2857
2814
|
if (volumeSeparatorEnd !== -1) {
|
|
2858
|
-
if (
|
|
2815
|
+
if (path2.charCodeAt(volumeSeparatorEnd) === 47)
|
|
2859
2816
|
return ~(volumeSeparatorEnd + 1);
|
|
2860
|
-
if (volumeSeparatorEnd ===
|
|
2817
|
+
if (volumeSeparatorEnd === path2.length)
|
|
2861
2818
|
return ~volumeSeparatorEnd;
|
|
2862
2819
|
}
|
|
2863
2820
|
}
|
|
2864
2821
|
return ~(authorityEnd + 1);
|
|
2865
2822
|
}
|
|
2866
|
-
return ~
|
|
2823
|
+
return ~path2.length;
|
|
2867
2824
|
}
|
|
2868
2825
|
return 0;
|
|
2869
2826
|
}
|
|
2870
|
-
function getRootLength(
|
|
2871
|
-
let rootLength = getEncodedRootLength(
|
|
2827
|
+
function getRootLength(path2) {
|
|
2828
|
+
let rootLength = getEncodedRootLength(path2);
|
|
2872
2829
|
return rootLength < 0 ? ~rootLength : rootLength;
|
|
2873
2830
|
}
|
|
2874
|
-
function getDirectoryPath(
|
|
2875
|
-
|
|
2876
|
-
let rootLength = getRootLength(
|
|
2877
|
-
return rootLength ===
|
|
2831
|
+
function getDirectoryPath(path2) {
|
|
2832
|
+
path2 = normalizeSlashes(path2);
|
|
2833
|
+
let rootLength = getRootLength(path2);
|
|
2834
|
+
return rootLength === path2.length ? path2 : (path2 = removeTrailingDirectorySeparator(path2), path2.slice(0, Math.max(rootLength, path2.lastIndexOf(exports.directorySeparator))));
|
|
2878
2835
|
}
|
|
2879
|
-
function getBaseFileName(
|
|
2880
|
-
if (
|
|
2836
|
+
function getBaseFileName(path2, extensions, ignoreCase) {
|
|
2837
|
+
if (path2 = normalizeSlashes(path2), getRootLength(path2) === path2.length)
|
|
2881
2838
|
return "";
|
|
2882
|
-
|
|
2883
|
-
let name =
|
|
2839
|
+
path2 = removeTrailingDirectorySeparator(path2);
|
|
2840
|
+
let name = path2.slice(Math.max(getRootLength(path2), path2.lastIndexOf(exports.directorySeparator) + 1)), extension = extensions !== void 0 && ignoreCase !== void 0 ? getAnyExtensionFromPath(name, extensions, ignoreCase) : void 0;
|
|
2884
2841
|
return extension ? name.slice(0, name.length - extension.length) : name;
|
|
2885
2842
|
}
|
|
2886
|
-
function tryGetExtensionFromPath(
|
|
2887
|
-
if ((0, core_1.startsWith)(extension, ".") || (extension = "." + extension),
|
|
2888
|
-
let pathExtension =
|
|
2843
|
+
function tryGetExtensionFromPath(path2, extension, stringEqualityComparer) {
|
|
2844
|
+
if ((0, core_1.startsWith)(extension, ".") || (extension = "." + extension), path2.length >= extension.length && path2.charCodeAt(path2.length - extension.length) === 46) {
|
|
2845
|
+
let pathExtension = path2.slice(path2.length - extension.length);
|
|
2889
2846
|
if (stringEqualityComparer(pathExtension, extension))
|
|
2890
2847
|
return pathExtension;
|
|
2891
2848
|
}
|
|
2892
2849
|
}
|
|
2893
|
-
function getAnyExtensionFromPathWorker(
|
|
2850
|
+
function getAnyExtensionFromPathWorker(path2, extensions, stringEqualityComparer) {
|
|
2894
2851
|
if (typeof extensions == "string")
|
|
2895
|
-
return tryGetExtensionFromPath(
|
|
2852
|
+
return tryGetExtensionFromPath(path2, extensions, stringEqualityComparer) || "";
|
|
2896
2853
|
for (let extension of extensions) {
|
|
2897
|
-
let result = tryGetExtensionFromPath(
|
|
2854
|
+
let result = tryGetExtensionFromPath(path2, extension, stringEqualityComparer);
|
|
2898
2855
|
if (result)
|
|
2899
2856
|
return result;
|
|
2900
2857
|
}
|
|
2901
2858
|
return "";
|
|
2902
2859
|
}
|
|
2903
|
-
function getAnyExtensionFromPath(
|
|
2860
|
+
function getAnyExtensionFromPath(path2, extensions, ignoreCase) {
|
|
2904
2861
|
if (extensions)
|
|
2905
|
-
return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(
|
|
2906
|
-
let baseFileName = getBaseFileName(
|
|
2862
|
+
return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path2), extensions, ignoreCase ? core_1.equateStringsCaseInsensitive : core_1.equateStringsCaseSensitive);
|
|
2863
|
+
let baseFileName = getBaseFileName(path2), extensionIndex = baseFileName.lastIndexOf(".");
|
|
2907
2864
|
return extensionIndex >= 0 ? baseFileName.substring(extensionIndex) : "";
|
|
2908
2865
|
}
|
|
2909
|
-
function pathComponents(
|
|
2910
|
-
let root =
|
|
2866
|
+
function pathComponents(path2, rootLength) {
|
|
2867
|
+
let root = path2.substring(0, rootLength), rest = path2.substring(rootLength).split(exports.directorySeparator);
|
|
2911
2868
|
return rest.length && !(0, core_1.lastOrUndefined)(rest) && rest.pop(), [root, ...rest];
|
|
2912
2869
|
}
|
|
2913
|
-
function getPathComponents(
|
|
2914
|
-
return
|
|
2870
|
+
function getPathComponents(path2, currentDirectory = "") {
|
|
2871
|
+
return path2 = combinePaths(currentDirectory, path2), pathComponents(path2, getRootLength(path2));
|
|
2915
2872
|
}
|
|
2916
2873
|
function getPathFromPathComponents(pathComponents2) {
|
|
2917
2874
|
return pathComponents2.length === 0 ? "" : (pathComponents2[0] && ensureTrailingDirectorySeparator(pathComponents2[0])) + pathComponents2.slice(1).join(exports.directorySeparator);
|
|
2918
2875
|
}
|
|
2919
|
-
function normalizeSlashes(
|
|
2920
|
-
return
|
|
2876
|
+
function normalizeSlashes(path2) {
|
|
2877
|
+
return path2.indexOf("\\") !== -1 ? path2.replace(backslashRegExp, exports.directorySeparator) : path2;
|
|
2921
2878
|
}
|
|
2922
2879
|
function reducePathComponents(components) {
|
|
2923
2880
|
if (!(0, core_1.some)(components))
|
|
@@ -2940,29 +2897,29 @@ var require_path = __commonJS({
|
|
|
2940
2897
|
}
|
|
2941
2898
|
return reduced;
|
|
2942
2899
|
}
|
|
2943
|
-
function combinePaths(
|
|
2944
|
-
|
|
2900
|
+
function combinePaths(path2, ...paths) {
|
|
2901
|
+
path2 && (path2 = normalizeSlashes(path2));
|
|
2945
2902
|
for (let relativePath of paths)
|
|
2946
|
-
relativePath && (relativePath = normalizeSlashes(relativePath), !
|
|
2947
|
-
return
|
|
2903
|
+
relativePath && (relativePath = normalizeSlashes(relativePath), !path2 || getRootLength(relativePath) !== 0 ? path2 = relativePath : path2 = ensureTrailingDirectorySeparator(path2) + relativePath);
|
|
2904
|
+
return path2;
|
|
2948
2905
|
}
|
|
2949
|
-
function getNormalizedPathComponents(
|
|
2950
|
-
return reducePathComponents(getPathComponents(
|
|
2906
|
+
function getNormalizedPathComponents(path2, currentDirectory) {
|
|
2907
|
+
return reducePathComponents(getPathComponents(path2, currentDirectory));
|
|
2951
2908
|
}
|
|
2952
|
-
function normalizePath(
|
|
2953
|
-
if (
|
|
2954
|
-
return
|
|
2955
|
-
let simplified =
|
|
2956
|
-
if (simplified !==
|
|
2957
|
-
return
|
|
2958
|
-
let normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(
|
|
2959
|
-
return normalized && hasTrailingDirectorySeparator(
|
|
2909
|
+
function normalizePath(path2) {
|
|
2910
|
+
if (path2 = normalizeSlashes(path2), !relativePathSegmentRegExp.test(path2))
|
|
2911
|
+
return path2;
|
|
2912
|
+
let simplified = path2.replace(/\/\.\//g, "/").replace(/^\.\//, "");
|
|
2913
|
+
if (simplified !== path2 && (path2 = simplified, !relativePathSegmentRegExp.test(path2)))
|
|
2914
|
+
return path2;
|
|
2915
|
+
let normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path2)));
|
|
2916
|
+
return normalized && hasTrailingDirectorySeparator(path2) ? ensureTrailingDirectorySeparator(normalized) : normalized;
|
|
2960
2917
|
}
|
|
2961
|
-
function removeTrailingDirectorySeparator(
|
|
2962
|
-
return hasTrailingDirectorySeparator(
|
|
2918
|
+
function removeTrailingDirectorySeparator(path2) {
|
|
2919
|
+
return hasTrailingDirectorySeparator(path2) ? path2.substr(0, path2.length - 1) : path2;
|
|
2963
2920
|
}
|
|
2964
|
-
function ensureTrailingDirectorySeparator(
|
|
2965
|
-
return hasTrailingDirectorySeparator(
|
|
2921
|
+
function ensureTrailingDirectorySeparator(path2) {
|
|
2922
|
+
return hasTrailingDirectorySeparator(path2) ? path2 : path2 + exports.directorySeparator;
|
|
2966
2923
|
}
|
|
2967
2924
|
var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/;
|
|
2968
2925
|
function containsPath(parent, child, currentDirectory, ignoreCase) {
|
|
@@ -3057,34 +3014,34 @@ var require_utilities = __commonJS({
|
|
|
3057
3014
|
function replaceWildcardCharacter(match, singleAsteriskRegexFragment) {
|
|
3058
3015
|
return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match;
|
|
3059
3016
|
}
|
|
3060
|
-
function getFileMatcherPatterns(
|
|
3061
|
-
|
|
3062
|
-
let absolutePath = (0, path_1.combinePaths)(currentDirectory,
|
|
3017
|
+
function getFileMatcherPatterns(path2, excludes, includes, useCaseSensitiveFileNames, currentDirectory) {
|
|
3018
|
+
path2 = (0, path_1.normalizePath)(path2), currentDirectory = (0, path_1.normalizePath)(currentDirectory);
|
|
3019
|
+
let absolutePath = (0, path_1.combinePaths)(currentDirectory, path2);
|
|
3063
3020
|
return {
|
|
3064
3021
|
includeFilePatterns: (0, core_1.map)(getRegularExpressionsForWildcards(includes, absolutePath, "files"), (pattern) => `^${pattern}$`),
|
|
3065
3022
|
includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"),
|
|
3066
3023
|
includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"),
|
|
3067
3024
|
excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"),
|
|
3068
|
-
basePaths: getBasePaths(
|
|
3025
|
+
basePaths: getBasePaths(path2, includes, useCaseSensitiveFileNames)
|
|
3069
3026
|
};
|
|
3070
3027
|
}
|
|
3071
3028
|
function getRegexFromPattern(pattern, useCaseSensitiveFileNames) {
|
|
3072
3029
|
return new RegExp(pattern, useCaseSensitiveFileNames ? "" : "i");
|
|
3073
3030
|
}
|
|
3074
|
-
function matchFiles(
|
|
3075
|
-
|
|
3076
|
-
let patterns = getFileMatcherPatterns(
|
|
3031
|
+
function matchFiles(path2, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath) {
|
|
3032
|
+
path2 = (0, path_1.normalizePath)(path2), currentDirectory = (0, path_1.normalizePath)(currentDirectory);
|
|
3033
|
+
let patterns = getFileMatcherPatterns(path2, excludes, includes, useCaseSensitiveFileNames, currentDirectory), includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map((pattern) => getRegexFromPattern(pattern, useCaseSensitiveFileNames)), includeDirectoryRegex = patterns.includeDirectoryPattern && getRegexFromPattern(patterns.includeDirectoryPattern, useCaseSensitiveFileNames), excludeRegex = patterns.excludePattern && getRegexFromPattern(patterns.excludePattern, useCaseSensitiveFileNames), results = includeFileRegexes ? includeFileRegexes.map(() => []) : [[]], visited = /* @__PURE__ */ new Map(), toCanonical = (0, core_1.createGetCanonicalFileName)(useCaseSensitiveFileNames);
|
|
3077
3034
|
for (let basePath of patterns.basePaths)
|
|
3078
3035
|
visitDirectory(basePath, (0, path_1.combinePaths)(currentDirectory, basePath), depth);
|
|
3079
3036
|
return (0, core_1.flatten)(results);
|
|
3080
|
-
function visitDirectory(
|
|
3037
|
+
function visitDirectory(path3, absolutePath, depth2) {
|
|
3081
3038
|
let canonicalPath = toCanonical(realpath(absolutePath));
|
|
3082
3039
|
if (visited.has(canonicalPath))
|
|
3083
3040
|
return;
|
|
3084
3041
|
visited.set(canonicalPath, !0);
|
|
3085
|
-
let { files, directories } = getFileSystemEntries(
|
|
3042
|
+
let { files, directories } = getFileSystemEntries(path3);
|
|
3086
3043
|
for (let current2 of (0, core_1.sort)(files, core_1.compareStringsCaseSensitive)) {
|
|
3087
|
-
let name = (0, path_1.combinePaths)(
|
|
3044
|
+
let name = (0, path_1.combinePaths)(path3, current2), absoluteName = (0, path_1.combinePaths)(absolutePath, current2);
|
|
3088
3045
|
if (!(extensions && !(0, path_1.fileExtensionIsOneOf)(name, extensions)) && !(excludeRegex && excludeRegex.test(absoluteName)))
|
|
3089
3046
|
if (!includeFileRegexes)
|
|
3090
3047
|
results[0].push(name);
|
|
@@ -3095,22 +3052,22 @@ var require_utilities = __commonJS({
|
|
|
3095
3052
|
}
|
|
3096
3053
|
if (!(depth2 !== void 0 && (depth2--, depth2 === 0)))
|
|
3097
3054
|
for (let current2 of (0, core_1.sort)(directories, core_1.compareStringsCaseSensitive)) {
|
|
3098
|
-
let name = (0, path_1.combinePaths)(
|
|
3055
|
+
let name = (0, path_1.combinePaths)(path3, current2), absoluteName = (0, path_1.combinePaths)(absolutePath, current2);
|
|
3099
3056
|
(!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) && (!excludeRegex || !excludeRegex.test(absoluteName)) && visitDirectory(name, absoluteName, depth2);
|
|
3100
3057
|
}
|
|
3101
3058
|
}
|
|
3102
3059
|
}
|
|
3103
|
-
function getBasePaths(
|
|
3104
|
-
let basePaths = [
|
|
3060
|
+
function getBasePaths(path2, includes, useCaseSensitiveFileNames) {
|
|
3061
|
+
let basePaths = [path2];
|
|
3105
3062
|
if (includes) {
|
|
3106
3063
|
let includeBasePaths = [];
|
|
3107
3064
|
for (let include of includes) {
|
|
3108
|
-
let absolute2 = (0, path_1.isRootedDiskPath)(include) ? include : (0, path_1.normalizePath)((0, path_1.combinePaths)(
|
|
3065
|
+
let absolute2 = (0, path_1.isRootedDiskPath)(include) ? include : (0, path_1.normalizePath)((0, path_1.combinePaths)(path2, include));
|
|
3109
3066
|
includeBasePaths.push(getIncludeBasePath(absolute2));
|
|
3110
3067
|
}
|
|
3111
3068
|
includeBasePaths.sort((0, core_1.getStringComparer)(!useCaseSensitiveFileNames));
|
|
3112
3069
|
for (let includeBasePath of includeBasePaths)
|
|
3113
|
-
(0, core_1.every)(basePaths, (basePath) => !(0, path_1.containsPath)(basePath, includeBasePath,
|
|
3070
|
+
(0, core_1.every)(basePaths, (basePath) => !(0, path_1.containsPath)(basePath, includeBasePath, path2, !useCaseSensitiveFileNames)) && basePaths.push(includeBasePath);
|
|
3114
3071
|
}
|
|
3115
3072
|
return basePaths;
|
|
3116
3073
|
}
|
|
@@ -3127,7 +3084,7 @@ var require_createSys = __commonJS({
|
|
|
3127
3084
|
"use strict";
|
|
3128
3085
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3129
3086
|
exports.createSys = createSys;
|
|
3130
|
-
var
|
|
3087
|
+
var path2 = require_path_browserify(), vscode_uri_1 = require_umd(), utilities_1 = require_utilities(), currentCwd = "";
|
|
3131
3088
|
function createSys(sys, env, getCurrentDirectory, uriConverter) {
|
|
3132
3089
|
let version2 = 0, caseSensitive = sys?.useCaseSensitiveFileNames ?? !1, root = {
|
|
3133
3090
|
name: "",
|
|
@@ -3137,7 +3094,7 @@ var require_createSys = __commonJS({
|
|
|
3137
3094
|
}, promises = /* @__PURE__ */ new Set(), fileWatcher = env.onDidChangeWatchedFiles?.(({ changes }) => {
|
|
3138
3095
|
version2++;
|
|
3139
3096
|
for (let change of changes) {
|
|
3140
|
-
let changeUri = vscode_uri_1.URI.parse(change.uri), fileName = uriConverter.asFileName(changeUri), dirName =
|
|
3097
|
+
let changeUri = vscode_uri_1.URI.parse(change.uri), fileName = uriConverter.asFileName(changeUri), dirName = path2.dirname(fileName), baseName = path2.basename(fileName), fileExists2 = change.type === 1 || change.type === 2;
|
|
3141
3098
|
getDir(dirName, fileExists2).files.set(normalizeFileId(baseName), fileExists2 ? {
|
|
3142
3099
|
name: baseName,
|
|
3143
3100
|
stat: {
|
|
@@ -3202,11 +3159,11 @@ var require_createSys = __commonJS({
|
|
|
3202
3159
|
}
|
|
3203
3160
|
return sys.resolvePath(fsPath).replace(/\\/g, "/");
|
|
3204
3161
|
}
|
|
3205
|
-
return
|
|
3162
|
+
return path2.resolve(fsPath).replace(/\\/g, "/");
|
|
3206
3163
|
}
|
|
3207
3164
|
function readFile(fileName, encoding) {
|
|
3208
3165
|
fileName = resolvePath(fileName);
|
|
3209
|
-
let dirPath =
|
|
3166
|
+
let dirPath = path2.dirname(fileName), dir = getDir(dirPath), name = path2.basename(fileName);
|
|
3210
3167
|
return readFileWorker(fileName, encoding, dir), dir.files.get(normalizeFileId(name))?.text;
|
|
3211
3168
|
}
|
|
3212
3169
|
function directoryExists(dirName) {
|
|
@@ -3247,7 +3204,7 @@ var require_createSys = __commonJS({
|
|
|
3247
3204
|
}
|
|
3248
3205
|
function getFile(fileName) {
|
|
3249
3206
|
fileName = resolvePath(fileName);
|
|
3250
|
-
let dirPath =
|
|
3207
|
+
let dirPath = path2.dirname(fileName), baseName = path2.basename(fileName), dir = getDir(dirPath), file = dir.files.get(normalizeFileId(baseName));
|
|
3251
3208
|
return file || dir.files.set(normalizeFileId(baseName), file = {
|
|
3252
3209
|
name: baseName,
|
|
3253
3210
|
requestedStat: !1,
|
|
@@ -3266,11 +3223,11 @@ var require_createSys = __commonJS({
|
|
|
3266
3223
|
files: [...dir.files.values()].filter((file) => file.stat?.type === 1).map((file) => file.name),
|
|
3267
3224
|
directories: [...dir.dirs.values()].filter((dir2) => dir2.exists).map((dir2) => dir2.name)
|
|
3268
3225
|
};
|
|
3269
|
-
}, sys?.realpath ? ((
|
|
3226
|
+
}, sys?.realpath ? ((path3) => sys.realpath(path3)) : ((path3) => path3));
|
|
3270
3227
|
return [...new Set(matches)];
|
|
3271
3228
|
}
|
|
3272
3229
|
function readFileWorker(fileName, encoding, dir) {
|
|
3273
|
-
let name =
|
|
3230
|
+
let name = path2.basename(fileName), file = dir.files.get(normalizeFileId(name));
|
|
3274
3231
|
if (file || dir.files.set(normalizeFileId(name), file = {
|
|
3275
3232
|
name,
|
|
3276
3233
|
requestedStat: !1,
|
|
@@ -3344,9 +3301,9 @@ var require_createSys = __commonJS({
|
|
|
3344
3301
|
return updated;
|
|
3345
3302
|
}
|
|
3346
3303
|
function getDir(dirName, markExists = !1) {
|
|
3347
|
-
let dirNames = [], currentDirPath = dirName, currentDirName =
|
|
3304
|
+
let dirNames = [], currentDirPath = dirName, currentDirName = path2.basename(currentDirPath), lastDirPath;
|
|
3348
3305
|
for (; lastDirPath !== currentDirPath; )
|
|
3349
|
-
lastDirPath = currentDirPath, dirNames.push(currentDirName), currentDirPath =
|
|
3306
|
+
lastDirPath = currentDirPath, dirNames.push(currentDirName), currentDirPath = path2.dirname(currentDirPath), currentDirName = path2.basename(currentDirPath);
|
|
3350
3307
|
let currentDir = root;
|
|
3351
3308
|
for (let i2 = dirNames.length - 1; i2 >= 0; i2--) {
|
|
3352
3309
|
let nextDirName = dirNames[i2];
|
|
@@ -3586,19 +3543,19 @@ var require_estraverse = __commonJS({
|
|
|
3586
3543
|
}, Reference.prototype.remove = function() {
|
|
3587
3544
|
return Array.isArray(this.parent) ? (this.parent.splice(this.key, 1), !0) : (this.replace(null), !1);
|
|
3588
3545
|
};
|
|
3589
|
-
function Element(node,
|
|
3590
|
-
this.node = node, this.path =
|
|
3546
|
+
function Element(node, path2, wrap, ref2) {
|
|
3547
|
+
this.node = node, this.path = path2, this.wrap = wrap, this.ref = ref2;
|
|
3591
3548
|
}
|
|
3592
3549
|
function Controller() {
|
|
3593
3550
|
}
|
|
3594
3551
|
Controller.prototype.path = function() {
|
|
3595
3552
|
var i2, iz, j, jz, result, element;
|
|
3596
|
-
function addToPath(result2,
|
|
3597
|
-
if (Array.isArray(
|
|
3598
|
-
for (j = 0, jz =
|
|
3599
|
-
result2.push(
|
|
3553
|
+
function addToPath(result2, path3) {
|
|
3554
|
+
if (Array.isArray(path3))
|
|
3555
|
+
for (j = 0, jz = path3.length; j < jz; ++j)
|
|
3556
|
+
result2.push(path3[j]);
|
|
3600
3557
|
else
|
|
3601
|
-
result2.push(
|
|
3558
|
+
result2.push(path3);
|
|
3602
3559
|
}
|
|
3603
3560
|
if (!this.__current.path)
|
|
3604
3561
|
return null;
|
|
@@ -4176,15 +4133,15 @@ var require_util = __commonJS({
|
|
|
4176
4133
|
}
|
|
4177
4134
|
exports.urlGenerate = urlGenerate;
|
|
4178
4135
|
function normalize2(aPath) {
|
|
4179
|
-
var
|
|
4136
|
+
var path2 = aPath, url = urlParse(aPath);
|
|
4180
4137
|
if (url) {
|
|
4181
4138
|
if (!url.path)
|
|
4182
4139
|
return aPath;
|
|
4183
|
-
|
|
4140
|
+
path2 = url.path;
|
|
4184
4141
|
}
|
|
4185
|
-
for (var
|
|
4142
|
+
for (var isAbsolute3 = exports.isAbsolute(path2), parts = path2.split(/\/+/), part, up3 = 0, i2 = parts.length - 1; i2 >= 0; i2--)
|
|
4186
4143
|
part = parts[i2], part === "." ? parts.splice(i2, 1) : part === ".." ? up3++ : up3 > 0 && (part === "" ? (parts.splice(i2 + 1, up3), up3 = 0) : (parts.splice(i2, 2), up3--));
|
|
4187
|
-
return
|
|
4144
|
+
return path2 = parts.join("/"), path2 === "" && (path2 = isAbsolute3 ? "/" : "."), url ? (url.path = path2, urlGenerate(url)) : path2;
|
|
4188
4145
|
}
|
|
4189
4146
|
exports.normalize = normalize2;
|
|
4190
4147
|
function join5(aRoot, aPath) {
|
|
@@ -4203,7 +4160,7 @@ var require_util = __commonJS({
|
|
|
4203
4160
|
exports.isAbsolute = function(aPath) {
|
|
4204
4161
|
return aPath.charAt(0) === "/" || urlRegexp.test(aPath);
|
|
4205
4162
|
};
|
|
4206
|
-
function
|
|
4163
|
+
function relative2(aRoot, aPath) {
|
|
4207
4164
|
aRoot === "" && (aRoot = "."), aRoot = aRoot.replace(/\/$/, "");
|
|
4208
4165
|
for (var level = 0; aPath.indexOf(aRoot + "/") !== 0; ) {
|
|
4209
4166
|
var index = aRoot.lastIndexOf("/");
|
|
@@ -4213,7 +4170,7 @@ var require_util = __commonJS({
|
|
|
4213
4170
|
}
|
|
4214
4171
|
return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
|
|
4215
4172
|
}
|
|
4216
|
-
exports.relative =
|
|
4173
|
+
exports.relative = relative2;
|
|
4217
4174
|
var supportsNullProto = (function() {
|
|
4218
4175
|
var obj = /* @__PURE__ */ Object.create(null);
|
|
4219
4176
|
return !("__proto__" in obj);
|
|
@@ -6148,6 +6105,49 @@ var require_escodegen = __commonJS({
|
|
|
6148
6105
|
}
|
|
6149
6106
|
});
|
|
6150
6107
|
|
|
6108
|
+
// ../../../node_modules/ts-dedent/dist/index.js
|
|
6109
|
+
var require_dist = __commonJS({
|
|
6110
|
+
"../../../node_modules/ts-dedent/dist/index.js"(exports) {
|
|
6111
|
+
"use strict";
|
|
6112
|
+
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
6113
|
+
exports.dedent = void 0;
|
|
6114
|
+
function dedent3(templ) {
|
|
6115
|
+
for (var values = [], _i = 1; _i < arguments.length; _i++)
|
|
6116
|
+
values[_i - 1] = arguments[_i];
|
|
6117
|
+
var strings = Array.from(typeof templ == "string" ? [templ] : templ);
|
|
6118
|
+
strings[strings.length - 1] = strings[strings.length - 1].replace(/\r?\n([\t ]*)$/, "");
|
|
6119
|
+
var indentLengths = strings.reduce(function(arr, str) {
|
|
6120
|
+
var matches = str.match(/\n([\t ]+|(?!\s).)/g);
|
|
6121
|
+
return matches ? arr.concat(matches.map(function(match) {
|
|
6122
|
+
var _a, _b;
|
|
6123
|
+
return (_b = (_a = match.match(/[\t ]/g)) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
6124
|
+
})) : arr;
|
|
6125
|
+
}, []);
|
|
6126
|
+
if (indentLengths.length) {
|
|
6127
|
+
var pattern_1 = new RegExp(`
|
|
6128
|
+
[ ]{` + Math.min.apply(Math, indentLengths) + "}", "g");
|
|
6129
|
+
strings = strings.map(function(str) {
|
|
6130
|
+
return str.replace(pattern_1, `
|
|
6131
|
+
`);
|
|
6132
|
+
});
|
|
6133
|
+
}
|
|
6134
|
+
strings[0] = strings[0].replace(/^\r?\n/, "");
|
|
6135
|
+
var string = strings[0];
|
|
6136
|
+
return values.forEach(function(value, i2) {
|
|
6137
|
+
var endentations = string.match(/(?:^|\n)( *)$/), endentation = endentations ? endentations[1] : "", indentedValue = value;
|
|
6138
|
+
typeof value == "string" && value.includes(`
|
|
6139
|
+
`) && (indentedValue = String(value).split(`
|
|
6140
|
+
`).map(function(str, i3) {
|
|
6141
|
+
return i3 === 0 ? str : "" + endentation + str;
|
|
6142
|
+
}).join(`
|
|
6143
|
+
`)), string += indentedValue + strings[i2 + 1];
|
|
6144
|
+
}), string;
|
|
6145
|
+
}
|
|
6146
|
+
exports.dedent = dedent3;
|
|
6147
|
+
exports.default = dedent3;
|
|
6148
|
+
}
|
|
6149
|
+
});
|
|
6150
|
+
|
|
6151
6151
|
// ../../../node_modules/acorn/dist/acorn.mjs
|
|
6152
6152
|
var acorn_exports = {};
|
|
6153
6153
|
__export(acorn_exports, {
|
|
@@ -6167,7 +6167,7 @@ __export(acorn_exports, {
|
|
|
6167
6167
|
lineBreak: () => lineBreak,
|
|
6168
6168
|
lineBreakG: () => lineBreakG,
|
|
6169
6169
|
nonASCIIwhitespace: () => nonASCIIwhitespace,
|
|
6170
|
-
parse: () =>
|
|
6170
|
+
parse: () => parse3,
|
|
6171
6171
|
parseExpressionAt: () => parseExpressionAt2,
|
|
6172
6172
|
tokContexts: () => types,
|
|
6173
6173
|
tokTypes: () => types$1,
|
|
@@ -6335,7 +6335,7 @@ function stringToNumber(str, isLegacyOctalNumericLiteral) {
|
|
|
6335
6335
|
function stringToBigInt(str) {
|
|
6336
6336
|
return typeof BigInt != "function" ? null : BigInt(str.replace(/_/g, ""));
|
|
6337
6337
|
}
|
|
6338
|
-
function
|
|
6338
|
+
function parse3(input, options) {
|
|
6339
6339
|
return Parser.parse(input, options);
|
|
6340
6340
|
}
|
|
6341
6341
|
function parseExpressionAt2(input, pos, options) {
|
|
@@ -6629,8 +6629,8 @@ var astralIdentifierCodes, astralIdentifierStartCodes, nonASCIIidentifierChars,
|
|
|
6629
6629
|
return new this(options, input).parse();
|
|
6630
6630
|
};
|
|
6631
6631
|
Parser.parseExpressionAt = function(input, pos, options) {
|
|
6632
|
-
var
|
|
6633
|
-
return
|
|
6632
|
+
var parser = new this(options, input, pos);
|
|
6633
|
+
return parser.nextToken(), parser.parseExpression();
|
|
6634
6634
|
};
|
|
6635
6635
|
Parser.tokenizer = function(input, options) {
|
|
6636
6636
|
return new this(options, input);
|
|
@@ -7958,8 +7958,8 @@ var astralIdentifierCodes, astralIdentifierStartCodes, nonASCIIidentifierChars,
|
|
|
7958
7958
|
return scope;
|
|
7959
7959
|
}
|
|
7960
7960
|
};
|
|
7961
|
-
Node = function(
|
|
7962
|
-
this.type = "", this.start = pos, this.end = 0,
|
|
7961
|
+
Node = function(parser, pos, loc) {
|
|
7962
|
+
this.type = "", this.start = pos, this.end = 0, parser.options.locations && (this.loc = new SourceLocation(parser, loc)), parser.options.directSourceFile && (this.sourceFile = parser.options.directSourceFile), parser.options.ranges && (this.range = [pos, 0]);
|
|
7963
7963
|
}, pp$2 = Parser.prototype;
|
|
7964
7964
|
pp$2.startNode = function() {
|
|
7965
7965
|
return new Node(this, this.start, this.startLoc);
|
|
@@ -8016,8 +8016,8 @@ var astralIdentifierCodes, astralIdentifierStartCodes, nonASCIIidentifierChars,
|
|
|
8016
8016
|
BranchID.prototype.sibling = function() {
|
|
8017
8017
|
return new BranchID(this.parent, this.base);
|
|
8018
8018
|
};
|
|
8019
|
-
RegExpValidationState = function(
|
|
8020
|
-
this.parser =
|
|
8019
|
+
RegExpValidationState = function(parser) {
|
|
8020
|
+
this.parser = parser, this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "") + (parser.options.ecmaVersion >= 13 ? "d" : "") + (parser.options.ecmaVersion >= 15 ? "v" : ""), this.unicodeProperties = data[parser.options.ecmaVersion >= 14 ? 14 : parser.options.ecmaVersion], this.source = "", this.flags = "", this.start = 0, this.switchU = !1, this.switchV = !1, this.switchN = !1, this.pos = 0, this.lastIntValue = 0, this.lastStringValue = "", this.lastAssertionIsQuantifiable = !1, this.numCapturingParens = 0, this.maxBackReference = 0, this.groupNames = /* @__PURE__ */ Object.create(null), this.backReferenceNames = [], this.branchID = null;
|
|
8021
8021
|
};
|
|
8022
8022
|
RegExpValidationState.prototype.reset = function(start, pattern, flags) {
|
|
8023
8023
|
var unicodeSets = flags.indexOf("v") !== -1, unicode = flags.indexOf("u") !== -1;
|
|
@@ -10534,11 +10534,11 @@ var require_filesystem = __commonJS({
|
|
|
10534
10534
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
10535
10535
|
exports.removeExtension = exports.fileExistsAsync = exports.readJsonFromDiskAsync = exports.readJsonFromDiskSync = exports.fileExistsSync = void 0;
|
|
10536
10536
|
var fs = __require("fs");
|
|
10537
|
-
function fileExistsSync(
|
|
10538
|
-
if (!fs.existsSync(
|
|
10537
|
+
function fileExistsSync(path2) {
|
|
10538
|
+
if (!fs.existsSync(path2))
|
|
10539
10539
|
return !1;
|
|
10540
10540
|
try {
|
|
10541
|
-
var stats = fs.statSync(
|
|
10541
|
+
var stats = fs.statSync(path2);
|
|
10542
10542
|
return stats.isFile();
|
|
10543
10543
|
} catch {
|
|
10544
10544
|
return !1;
|
|
@@ -10550,8 +10550,8 @@ var require_filesystem = __commonJS({
|
|
|
10550
10550
|
return __require(packageJsonPath);
|
|
10551
10551
|
}
|
|
10552
10552
|
exports.readJsonFromDiskSync = readJsonFromDiskSync;
|
|
10553
|
-
function readJsonFromDiskAsync(
|
|
10554
|
-
fs.readFile(
|
|
10553
|
+
function readJsonFromDiskAsync(path2, callback) {
|
|
10554
|
+
fs.readFile(path2, "utf8", function(err, result) {
|
|
10555
10555
|
if (err || !result)
|
|
10556
10556
|
return callback();
|
|
10557
10557
|
var json = JSON.parse(result);
|
|
@@ -10559,16 +10559,16 @@ var require_filesystem = __commonJS({
|
|
|
10559
10559
|
});
|
|
10560
10560
|
}
|
|
10561
10561
|
exports.readJsonFromDiskAsync = readJsonFromDiskAsync;
|
|
10562
|
-
function fileExistsAsync(
|
|
10563
|
-
fs.stat(
|
|
10562
|
+
function fileExistsAsync(path2, callback2) {
|
|
10563
|
+
fs.stat(path2, function(err, stats) {
|
|
10564
10564
|
if (err)
|
|
10565
10565
|
return callback2(void 0, !1);
|
|
10566
10566
|
callback2(void 0, stats ? stats.isFile() : !1);
|
|
10567
10567
|
});
|
|
10568
10568
|
}
|
|
10569
10569
|
exports.fileExistsAsync = fileExistsAsync;
|
|
10570
|
-
function removeExtension(
|
|
10571
|
-
return
|
|
10570
|
+
function removeExtension(path2) {
|
|
10571
|
+
return path2.substring(0, path2.lastIndexOf(".")) || path2;
|
|
10572
10572
|
}
|
|
10573
10573
|
exports.removeExtension = removeExtension;
|
|
10574
10574
|
}
|
|
@@ -10580,14 +10580,14 @@ var require_mapping_entry = __commonJS({
|
|
|
10580
10580
|
"use strict";
|
|
10581
10581
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
10582
10582
|
exports.getAbsoluteMappingEntries = void 0;
|
|
10583
|
-
var
|
|
10583
|
+
var path2 = __require("path");
|
|
10584
10584
|
function getAbsoluteMappingEntries(absoluteBaseUrl, paths, addMatchAll) {
|
|
10585
10585
|
for (var sortedKeys = sortByLongestPrefix(Object.keys(paths)), absolutePaths = [], _i = 0, sortedKeys_1 = sortedKeys; _i < sortedKeys_1.length; _i++) {
|
|
10586
10586
|
var key = sortedKeys_1[_i];
|
|
10587
10587
|
absolutePaths.push({
|
|
10588
10588
|
pattern: key,
|
|
10589
10589
|
paths: paths[key].map(function(pathToResolve) {
|
|
10590
|
-
return
|
|
10590
|
+
return path2.resolve(absoluteBaseUrl, pathToResolve);
|
|
10591
10591
|
})
|
|
10592
10592
|
});
|
|
10593
10593
|
}
|
|
@@ -10615,7 +10615,7 @@ var require_try_path = __commonJS({
|
|
|
10615
10615
|
"use strict";
|
|
10616
10616
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
10617
10617
|
exports.exhaustiveTypeException = exports.getStrippedPath = exports.getPathsToTry = void 0;
|
|
10618
|
-
var
|
|
10618
|
+
var path2 = __require("path"), path_1 = __require("path"), filesystem_1 = require_filesystem();
|
|
10619
10619
|
function getPathsToTry(extensions, absolutePathMappings, requestedModule) {
|
|
10620
10620
|
if (!(!absolutePathMappings || !requestedModule || requestedModule[0] === ".")) {
|
|
10621
10621
|
for (var pathsToTry = [], _i = 0, absolutePathMappings_1 = absolutePathMappings; _i < absolutePathMappings_1.length; _i++) {
|
|
@@ -10627,9 +10627,9 @@ var require_try_path = __commonJS({
|
|
|
10627
10627
|
return { type: "extension", path: physicalPath + e };
|
|
10628
10628
|
})), pathsToTry.push({
|
|
10629
10629
|
type: "package",
|
|
10630
|
-
path:
|
|
10630
|
+
path: path2.join(physicalPath, "/package.json")
|
|
10631
10631
|
});
|
|
10632
|
-
var indexPath =
|
|
10632
|
+
var indexPath = path2.join(physicalPath, "/index");
|
|
10633
10633
|
pathsToTry.push.apply(pathsToTry, extensions.map(function(e) {
|
|
10634
10634
|
return { type: "index", path: indexPath + e };
|
|
10635
10635
|
}));
|
|
@@ -10671,7 +10671,7 @@ var require_match_path_sync = __commonJS({
|
|
|
10671
10671
|
"use strict";
|
|
10672
10672
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
10673
10673
|
exports.matchFromAbsolutePaths = exports.createMatchPath = void 0;
|
|
10674
|
-
var
|
|
10674
|
+
var path2 = __require("path"), Filesystem = require_filesystem(), MappingEntry = require_mapping_entry(), TryPath = require_try_path();
|
|
10675
10675
|
function createMatchPath2(absoluteBaseUrl, paths, mainFields, addMatchAll) {
|
|
10676
10676
|
mainFields === void 0 && (mainFields = ["main"]), addMatchAll === void 0 && (addMatchAll = !0);
|
|
10677
10677
|
var absolutePaths = MappingEntry.getAbsoluteMappingEntries(absoluteBaseUrl, paths, addMatchAll);
|
|
@@ -10693,7 +10693,7 @@ var require_match_path_sync = __commonJS({
|
|
|
10693
10693
|
return obj[key];
|
|
10694
10694
|
}, packageJson);
|
|
10695
10695
|
if (candidateMapping && typeof candidateMapping == "string") {
|
|
10696
|
-
var candidateFilePath =
|
|
10696
|
+
var candidateFilePath = path2.join(path2.dirname(packageJsonPath), candidateMapping);
|
|
10697
10697
|
if (fileExists(candidateFilePath))
|
|
10698
10698
|
return candidateFilePath;
|
|
10699
10699
|
}
|
|
@@ -10726,7 +10726,7 @@ var require_match_path_async = __commonJS({
|
|
|
10726
10726
|
"use strict";
|
|
10727
10727
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
10728
10728
|
exports.matchFromAbsolutePathsAsync = exports.createMatchPathAsync = void 0;
|
|
10729
|
-
var
|
|
10729
|
+
var path2 = __require("path"), TryPath = require_try_path(), MappingEntry = require_mapping_entry(), Filesystem = require_filesystem();
|
|
10730
10730
|
function createMatchPathAsync(absoluteBaseUrl, paths, mainFields, addMatchAll) {
|
|
10731
10731
|
mainFields === void 0 && (mainFields = ["main"]), addMatchAll === void 0 && (addMatchAll = !0);
|
|
10732
10732
|
var absolutePaths = MappingEntry.getAbsoluteMappingEntries(absoluteBaseUrl, paths, addMatchAll);
|
|
@@ -10753,7 +10753,7 @@ var require_match_path_async = __commonJS({
|
|
|
10753
10753
|
}, packageJson);
|
|
10754
10754
|
if (typeof mainFieldMapping != "string")
|
|
10755
10755
|
return tryNext();
|
|
10756
|
-
var mappedFilePath =
|
|
10756
|
+
var mappedFilePath = path2.join(path2.dirname(packageJsonPath), mainFieldMapping);
|
|
10757
10757
|
fileExistsAsync(mappedFilePath, function(err, exists) {
|
|
10758
10758
|
return err ? doneCallback(err) : exists ? doneCallback(void 0, mappedFilePath) : tryNext();
|
|
10759
10759
|
});
|
|
@@ -11665,7 +11665,7 @@ var require_tsconfig_loader = __commonJS({
|
|
|
11665
11665
|
};
|
|
11666
11666
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
11667
11667
|
exports.loadTsconfig = exports.walkForTsConfig = exports.tsConfigLoader = void 0;
|
|
11668
|
-
var
|
|
11668
|
+
var path2 = __require("path"), fs = __require("fs"), JSON5 = require_lib(), StripBom = require_strip_bom();
|
|
11669
11669
|
function tsConfigLoader(_a) {
|
|
11670
11670
|
var getEnv = _a.getEnv, cwd2 = _a.cwd, _b = _a.loadSync, loadSync = _b === void 0 ? loadSyncDefault : _b, TS_NODE_PROJECT = getEnv("TS_NODE_PROJECT"), TS_NODE_BASEURL = getEnv("TS_NODE_BASEURL"), loadResult = loadSync(cwd2, TS_NODE_PROJECT, TS_NODE_BASEURL);
|
|
11671
11671
|
return loadResult;
|
|
@@ -11688,30 +11688,30 @@ var require_tsconfig_loader = __commonJS({
|
|
|
11688
11688
|
}
|
|
11689
11689
|
function resolveConfigPath(cwd2, filename) {
|
|
11690
11690
|
if (filename) {
|
|
11691
|
-
var absolutePath = fs.lstatSync(filename).isDirectory() ?
|
|
11691
|
+
var absolutePath = fs.lstatSync(filename).isDirectory() ? path2.resolve(filename, "./tsconfig.json") : path2.resolve(cwd2, filename);
|
|
11692
11692
|
return absolutePath;
|
|
11693
11693
|
}
|
|
11694
11694
|
if (fs.statSync(cwd2).isFile())
|
|
11695
|
-
return
|
|
11695
|
+
return path2.resolve(cwd2);
|
|
11696
11696
|
var configAbsolutePath = walkForTsConfig(cwd2);
|
|
11697
|
-
return configAbsolutePath ?
|
|
11697
|
+
return configAbsolutePath ? path2.resolve(configAbsolutePath) : void 0;
|
|
11698
11698
|
}
|
|
11699
11699
|
function walkForTsConfig(directory, readdirSync) {
|
|
11700
11700
|
readdirSync === void 0 && (readdirSync = fs.readdirSync);
|
|
11701
11701
|
for (var files = readdirSync(directory), filesToCheck = ["tsconfig.json", "jsconfig.json"], _i = 0, filesToCheck_1 = filesToCheck; _i < filesToCheck_1.length; _i++) {
|
|
11702
11702
|
var fileToCheck = filesToCheck_1[_i];
|
|
11703
11703
|
if (files.indexOf(fileToCheck) !== -1)
|
|
11704
|
-
return
|
|
11704
|
+
return path2.join(directory, fileToCheck);
|
|
11705
11705
|
}
|
|
11706
|
-
var parentDirectory =
|
|
11706
|
+
var parentDirectory = path2.dirname(directory);
|
|
11707
11707
|
if (directory !== parentDirectory)
|
|
11708
11708
|
return walkForTsConfig(parentDirectory, readdirSync);
|
|
11709
11709
|
}
|
|
11710
11710
|
exports.walkForTsConfig = walkForTsConfig;
|
|
11711
|
-
function loadTsconfig(configFilePath,
|
|
11712
|
-
if (
|
|
11711
|
+
function loadTsconfig(configFilePath, existsSync3, readFileSync2) {
|
|
11712
|
+
if (existsSync3 === void 0 && (existsSync3 = fs.existsSync), readFileSync2 === void 0 && (readFileSync2 = function(filename) {
|
|
11713
11713
|
return fs.readFileSync(filename, "utf8");
|
|
11714
|
-
}), !!
|
|
11714
|
+
}), !!existsSync3(configFilePath)) {
|
|
11715
11715
|
var configString = readFileSync2(configFilePath), cleanedJson = StripBom(configString), config;
|
|
11716
11716
|
try {
|
|
11717
11717
|
config = JSON5.parse(cleanedJson);
|
|
@@ -11722,22 +11722,22 @@ var require_tsconfig_loader = __commonJS({
|
|
|
11722
11722
|
if (extendedConfig) {
|
|
11723
11723
|
var base2 = void 0;
|
|
11724
11724
|
return Array.isArray(extendedConfig) ? base2 = extendedConfig.reduce(function(currBase, extendedConfigElement) {
|
|
11725
|
-
return mergeTsconfigs(currBase, loadTsconfigFromExtends(configFilePath, extendedConfigElement,
|
|
11726
|
-
}, {}) : base2 = loadTsconfigFromExtends(configFilePath, extendedConfig,
|
|
11725
|
+
return mergeTsconfigs(currBase, loadTsconfigFromExtends(configFilePath, extendedConfigElement, existsSync3, readFileSync2));
|
|
11726
|
+
}, {}) : base2 = loadTsconfigFromExtends(configFilePath, extendedConfig, existsSync3, readFileSync2), mergeTsconfigs(base2, config);
|
|
11727
11727
|
}
|
|
11728
11728
|
return config;
|
|
11729
11729
|
}
|
|
11730
11730
|
}
|
|
11731
11731
|
exports.loadTsconfig = loadTsconfig;
|
|
11732
|
-
function loadTsconfigFromExtends(configFilePath, extendedConfigValue,
|
|
11732
|
+
function loadTsconfigFromExtends(configFilePath, extendedConfigValue, existsSync3, readFileSync2) {
|
|
11733
11733
|
var _a;
|
|
11734
11734
|
typeof extendedConfigValue == "string" && extendedConfigValue.indexOf(".json") === -1 && (extendedConfigValue += ".json");
|
|
11735
|
-
var currentDir =
|
|
11736
|
-
extendedConfigValue.indexOf("/") !== -1 && extendedConfigValue.indexOf(".") !== -1 && !
|
|
11737
|
-
var config = loadTsconfig(extendedConfigPath,
|
|
11735
|
+
var currentDir = path2.dirname(configFilePath), extendedConfigPath = path2.join(currentDir, extendedConfigValue);
|
|
11736
|
+
extendedConfigValue.indexOf("/") !== -1 && extendedConfigValue.indexOf(".") !== -1 && !existsSync3(extendedConfigPath) && (extendedConfigPath = path2.join(currentDir, "node_modules", extendedConfigValue));
|
|
11737
|
+
var config = loadTsconfig(extendedConfigPath, existsSync3, readFileSync2) || {};
|
|
11738
11738
|
if (!((_a = config.compilerOptions) === null || _a === void 0) && _a.baseUrl) {
|
|
11739
|
-
var extendsDir =
|
|
11740
|
-
config.compilerOptions.baseUrl =
|
|
11739
|
+
var extendsDir = path2.dirname(extendedConfigValue);
|
|
11740
|
+
config.compilerOptions.baseUrl = path2.join(extendsDir, config.compilerOptions.baseUrl);
|
|
11741
11741
|
}
|
|
11742
11742
|
return config;
|
|
11743
11743
|
}
|
|
@@ -11753,7 +11753,7 @@ var require_config_loader = __commonJS({
|
|
|
11753
11753
|
"use strict";
|
|
11754
11754
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
11755
11755
|
exports.configLoader = exports.loadConfig = void 0;
|
|
11756
|
-
var TsConfigLoader2 = require_tsconfig_loader(),
|
|
11756
|
+
var TsConfigLoader2 = require_tsconfig_loader(), path2 = __require("path");
|
|
11757
11757
|
function loadConfig2(cwd2) {
|
|
11758
11758
|
return cwd2 === void 0 && (cwd2 = process.cwd()), configLoader({ cwd: cwd2 });
|
|
11759
11759
|
}
|
|
@@ -11761,7 +11761,7 @@ var require_config_loader = __commonJS({
|
|
|
11761
11761
|
function configLoader(_a) {
|
|
11762
11762
|
var cwd2 = _a.cwd, explicitParams = _a.explicitParams, _b = _a.tsConfigLoader, tsConfigLoader = _b === void 0 ? TsConfigLoader2.tsConfigLoader : _b;
|
|
11763
11763
|
if (explicitParams) {
|
|
11764
|
-
var absoluteBaseUrl =
|
|
11764
|
+
var absoluteBaseUrl = path2.isAbsolute(explicitParams.baseUrl) ? explicitParams.baseUrl : path2.join(cwd2, explicitParams.baseUrl);
|
|
11765
11765
|
return {
|
|
11766
11766
|
resultType: "success",
|
|
11767
11767
|
configFileAbsolutePath: "",
|
|
@@ -11782,7 +11782,7 @@ var require_config_loader = __commonJS({
|
|
|
11782
11782
|
resultType: "success",
|
|
11783
11783
|
configFileAbsolutePath: loadResult.tsConfigPath,
|
|
11784
11784
|
baseUrl: loadResult.baseUrl,
|
|
11785
|
-
absoluteBaseUrl:
|
|
11785
|
+
absoluteBaseUrl: path2.resolve(path2.dirname(loadResult.tsConfigPath), loadResult.baseUrl || ""),
|
|
11786
11786
|
paths: loadResult.paths || {},
|
|
11787
11787
|
addMatchAll: loadResult.baseUrl !== void 0
|
|
11788
11788
|
} : {
|
|
@@ -12073,11 +12073,11 @@ var require_caller = __commonJS({
|
|
|
12073
12073
|
var require_path_parse = __commonJS({
|
|
12074
12074
|
"../../../node_modules/path-parse/index.js"(exports, module) {
|
|
12075
12075
|
"use strict";
|
|
12076
|
-
var isWindows = process.platform === "win32", splitWindowsRe = /^(((?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?[\\\/]?)(?:[^\\\/]*[\\\/])*)((\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))[\\\/]*$/,
|
|
12076
|
+
var isWindows = process.platform === "win32", splitWindowsRe = /^(((?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?[\\\/]?)(?:[^\\\/]*[\\\/])*)((\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))[\\\/]*$/, win322 = {};
|
|
12077
12077
|
function win32SplitPath(filename) {
|
|
12078
12078
|
return splitWindowsRe.exec(filename).slice(1);
|
|
12079
12079
|
}
|
|
12080
|
-
|
|
12080
|
+
win322.parse = function(pathString) {
|
|
12081
12081
|
if (typeof pathString != "string")
|
|
12082
12082
|
throw new TypeError(
|
|
12083
12083
|
"Parameter 'pathString' must be a string, not " + typeof pathString
|
|
@@ -12093,11 +12093,11 @@ var require_path_parse = __commonJS({
|
|
|
12093
12093
|
name: allParts[3]
|
|
12094
12094
|
};
|
|
12095
12095
|
};
|
|
12096
|
-
var splitPathRe = /^((\/?)(?:[^\/]*\/)*)((\.{1,2}|[^\/]+?|)(\.[^.\/]*|))[\/]*$/,
|
|
12096
|
+
var splitPathRe = /^((\/?)(?:[^\/]*\/)*)((\.{1,2}|[^\/]+?|)(\.[^.\/]*|))[\/]*$/, posix2 = {};
|
|
12097
12097
|
function posixSplitPath(filename) {
|
|
12098
12098
|
return splitPathRe.exec(filename).slice(1);
|
|
12099
12099
|
}
|
|
12100
|
-
|
|
12100
|
+
posix2.parse = function(pathString) {
|
|
12101
12101
|
if (typeof pathString != "string")
|
|
12102
12102
|
throw new TypeError(
|
|
12103
12103
|
"Parameter 'pathString' must be a string, not " + typeof pathString
|
|
@@ -12113,16 +12113,16 @@ var require_path_parse = __commonJS({
|
|
|
12113
12113
|
name: allParts[3]
|
|
12114
12114
|
};
|
|
12115
12115
|
};
|
|
12116
|
-
isWindows ? module.exports =
|
|
12117
|
-
module.exports.posix =
|
|
12118
|
-
module.exports.win32 =
|
|
12116
|
+
isWindows ? module.exports = win322.parse : module.exports = posix2.parse;
|
|
12117
|
+
module.exports.posix = posix2.parse;
|
|
12118
|
+
module.exports.win32 = win322.parse;
|
|
12119
12119
|
}
|
|
12120
12120
|
});
|
|
12121
12121
|
|
|
12122
12122
|
// ../../../node_modules/resolve/lib/node-modules-paths.js
|
|
12123
12123
|
var require_node_modules_paths = __commonJS({
|
|
12124
12124
|
"../../../node_modules/resolve/lib/node-modules-paths.js"(exports, module) {
|
|
12125
|
-
var
|
|
12125
|
+
var path2 = __require("path"), parse7 = path2.parse || require_path_parse(), driveLetterRegex = /^([A-Za-z]:)/, uncPathRegex = /^\\\\/;
|
|
12126
12126
|
function getNodeModulesDirs(absoluteStart, modules) {
|
|
12127
12127
|
var prefix = "/";
|
|
12128
12128
|
driveLetterRegex.test(absoluteStart) ? prefix = "" : uncPathRegex.test(absoluteStart) && (prefix = "\\\\");
|
|
@@ -12130,7 +12130,7 @@ var require_node_modules_paths = __commonJS({
|
|
|
12130
12130
|
paths.push(parsed.dir), parsed = parse7(parsed.dir);
|
|
12131
12131
|
return paths.reduce(function(dirs, aPath) {
|
|
12132
12132
|
return dirs.concat(modules.map(function(moduleDir) {
|
|
12133
|
-
return
|
|
12133
|
+
return path2.resolve(prefix, aPath, moduleDir);
|
|
12134
12134
|
}));
|
|
12135
12135
|
}, []);
|
|
12136
12136
|
}
|
|
@@ -12154,7 +12154,7 @@ var require_node_modules_paths = __commonJS({
|
|
|
12154
12154
|
// ../../../node_modules/resolve/lib/normalize-options.js
|
|
12155
12155
|
var require_normalize_options = __commonJS({
|
|
12156
12156
|
"../../../node_modules/resolve/lib/normalize-options.js"(exports, module) {
|
|
12157
|
-
var
|
|
12157
|
+
var path2 = __require("path");
|
|
12158
12158
|
module.exports = function(_, opts) {
|
|
12159
12159
|
if (opts = opts || {}, opts.forceNodeResolution || !process.versions.pnp)
|
|
12160
12160
|
return opts;
|
|
@@ -12162,7 +12162,7 @@ var require_normalize_options = __commonJS({
|
|
|
12162
12162
|
let parts = request.match(/^((?:@[^/]+\/)?[^/]+)(\/.*)?/);
|
|
12163
12163
|
if (!parts)
|
|
12164
12164
|
throw new Error(`Assertion failed: Expected the "resolve" package to call the "paths" callback with package names only (got "${request}")`);
|
|
12165
|
-
basedir.charAt(basedir.length - 1) !== "/" && (basedir =
|
|
12165
|
+
basedir.charAt(basedir.length - 1) !== "/" && (basedir = path2.join(basedir, "/"));
|
|
12166
12166
|
let api = findPnpApi(basedir);
|
|
12167
12167
|
if (api === null)
|
|
12168
12168
|
return;
|
|
@@ -12174,7 +12174,7 @@ var require_normalize_options = __commonJS({
|
|
|
12174
12174
|
}
|
|
12175
12175
|
if (manifestPath === null)
|
|
12176
12176
|
throw new Error(`Assertion failed: The resolution thinks that "${parts[1]}" is a Node builtin`);
|
|
12177
|
-
let packagePath =
|
|
12177
|
+
let packagePath = path2.dirname(manifestPath), unqualifiedPath = typeof parts[2] < "u" ? path2.join(packagePath, parts[2]) : packagePath;
|
|
12178
12178
|
return { packagePath, unqualifiedPath };
|
|
12179
12179
|
}, runPnpResolutionOnArray = (request, paths2) => {
|
|
12180
12180
|
for (let i2 = 0; i2 < paths2.length; i2++) {
|
|
@@ -12190,8 +12190,8 @@ var require_normalize_options = __commonJS({
|
|
|
12190
12190
|
let pathsToTest = [basedir].concat(originalPaths), resolution = runPnpResolutionOnArray(request, pathsToTest);
|
|
12191
12191
|
if (resolution == null)
|
|
12192
12192
|
return getNodeModulePaths().concat(originalPaths);
|
|
12193
|
-
let nodeModules =
|
|
12194
|
-
return request.match(/^@[^/]+\//) && (nodeModules =
|
|
12193
|
+
let nodeModules = path2.dirname(resolution.packagePath);
|
|
12194
|
+
return request.match(/^@[^/]+\//) && (nodeModules = path2.dirname(nodeModules)), [nodeModules];
|
|
12195
12195
|
}, isInsideIterator = !1;
|
|
12196
12196
|
return opts.__skipPackageIterator || (opts.packageIterator = function(request, basedir, getCandidates, opts2) {
|
|
12197
12197
|
isInsideIterator = !0;
|
|
@@ -12494,11 +12494,11 @@ var require_type = __commonJS({
|
|
|
12494
12494
|
// ../../../node_modules/resolve/lib/async.js
|
|
12495
12495
|
var require_async = __commonJS({
|
|
12496
12496
|
"../../../node_modules/resolve/lib/async.js"(exports, module) {
|
|
12497
|
-
var fs = __require("fs"), getHomedir = require_homedir(),
|
|
12497
|
+
var fs = __require("fs"), getHomedir = require_homedir(), path2 = __require("path"), caller = require_caller(), nodeModulesPaths = require_node_modules_paths(), normalizeOptions = require_normalize_options(), isCore = require_is_core_module(), $Error = require_es_errors(), $TypeError = require_type(), realpathFS = process.platform !== "win32" && fs.realpath && typeof fs.realpath.native == "function" ? fs.realpath.native : fs.realpath, relativePathRegex = /^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/, windowsDriveRegex = /^\w:[/\\]*$/, nodeModulesRegex = /[/\\]node_modules[/\\]*$/, homedir = getHomedir();
|
|
12498
12498
|
function defaultPaths() {
|
|
12499
12499
|
return homedir ? [
|
|
12500
|
-
|
|
12501
|
-
|
|
12500
|
+
path2.join(homedir, ".node_modules"),
|
|
12501
|
+
path2.join(homedir, ".node_libraries")
|
|
12502
12502
|
] : [];
|
|
12503
12503
|
}
|
|
12504
12504
|
var defaultIsFile = function(file, cb) {
|
|
@@ -12531,7 +12531,7 @@ var require_async = __commonJS({
|
|
|
12531
12531
|
}
|
|
12532
12532
|
function getPackageCandidates(x, start, opts) {
|
|
12533
12533
|
for (var dirs = nodeModulesPaths(start, opts, x), i2 = 0; i2 < dirs.length; i2++)
|
|
12534
|
-
dirs[i2] =
|
|
12534
|
+
dirs[i2] = path2.join(dirs[i2], x);
|
|
12535
12535
|
return dirs;
|
|
12536
12536
|
}
|
|
12537
12537
|
module.exports = function(x, options, callback) {
|
|
@@ -12550,9 +12550,9 @@ var require_async = __commonJS({
|
|
|
12550
12550
|
cb(conflictErr);
|
|
12551
12551
|
});
|
|
12552
12552
|
}
|
|
12553
|
-
var packageIterator = opts.packageIterator, extensions = opts.extensions || [".js"], includeCoreModules = opts.includeCoreModules !== !1, basedir = opts.basedir ||
|
|
12553
|
+
var packageIterator = opts.packageIterator, extensions = opts.extensions || [".js"], includeCoreModules = opts.includeCoreModules !== !1, basedir = opts.basedir || path2.dirname(caller()), parent = opts.filename || basedir;
|
|
12554
12554
|
opts.paths = opts.paths || defaultPaths();
|
|
12555
|
-
var absoluteStart =
|
|
12555
|
+
var absoluteStart = path2.resolve(basedir);
|
|
12556
12556
|
maybeRealpath(
|
|
12557
12557
|
realpath,
|
|
12558
12558
|
absoluteStart,
|
|
@@ -12564,7 +12564,7 @@ var require_async = __commonJS({
|
|
|
12564
12564
|
var res;
|
|
12565
12565
|
function init(basedir2) {
|
|
12566
12566
|
if (relativePathRegex.test(x))
|
|
12567
|
-
res =
|
|
12567
|
+
res = path2.resolve(basedir2, x), (x === "." || x === ".." || x.slice(-1) === "/") && (res += "/"), x.slice(-1) === "/" && res === basedir2 ? loadAsDirectory(res, opts.package, onfile) : loadAsFile(res, opts.package, onfile);
|
|
12568
12568
|
else {
|
|
12569
12569
|
if (includeCoreModules && isCore(x))
|
|
12570
12570
|
return cb(null, x);
|
|
@@ -12602,14 +12602,14 @@ var require_async = __commonJS({
|
|
|
12602
12602
|
function load(exts2, x3, loadPackage) {
|
|
12603
12603
|
if (exts2.length === 0) return cb2(null, void 0, loadPackage);
|
|
12604
12604
|
var file = x3 + exts2[0], pkg = loadPackage;
|
|
12605
|
-
pkg ? onpkg(null, pkg) : loadpkg(
|
|
12605
|
+
pkg ? onpkg(null, pkg) : loadpkg(path2.dirname(file), onpkg);
|
|
12606
12606
|
function onpkg(err2, pkg_, dir) {
|
|
12607
12607
|
if (pkg = pkg_, err2) return cb2(err2);
|
|
12608
12608
|
if (dir && pkg && opts.pathFilter) {
|
|
12609
|
-
var rfile =
|
|
12609
|
+
var rfile = path2.relative(dir, file), rel = rfile.slice(0, rfile.length - exts2[0].length), r = opts.pathFilter(pkg, x3, rel);
|
|
12610
12610
|
if (r) return load(
|
|
12611
12611
|
[""].concat(extensions),
|
|
12612
|
-
|
|
12612
|
+
path2.resolve(dir, r),
|
|
12613
12613
|
pkg
|
|
12614
12614
|
);
|
|
12615
12615
|
}
|
|
@@ -12625,10 +12625,10 @@ var require_async = __commonJS({
|
|
|
12625
12625
|
function loadpkg(dir, cb2) {
|
|
12626
12626
|
if (dir === "" || dir === "/" || process.platform === "win32" && windowsDriveRegex.test(dir) || nodeModulesRegex.test(dir)) return cb2(null);
|
|
12627
12627
|
maybeRealpath(realpath, dir, opts, function(unwrapErr, pkgdir) {
|
|
12628
|
-
if (unwrapErr) return loadpkg(
|
|
12629
|
-
var pkgfile =
|
|
12628
|
+
if (unwrapErr) return loadpkg(path2.dirname(dir), cb2);
|
|
12629
|
+
var pkgfile = path2.join(pkgdir, "package.json");
|
|
12630
12630
|
isFile2(pkgfile, function(err2, ex) {
|
|
12631
|
-
if (!ex) return loadpkg(
|
|
12631
|
+
if (!ex) return loadpkg(path2.dirname(dir), cb2);
|
|
12632
12632
|
readPackage(readFile, pkgfile, function(err3, pkgParam) {
|
|
12633
12633
|
if (err3)
|
|
12634
12634
|
return cb2(err3);
|
|
@@ -12642,10 +12642,10 @@ var require_async = __commonJS({
|
|
|
12642
12642
|
var cb2 = callback2, fpkg = loadAsDirectoryPackage;
|
|
12643
12643
|
typeof fpkg == "function" && (cb2 = fpkg, fpkg = opts.package), maybeRealpath(realpath, x2, opts, function(unwrapErr, pkgdir) {
|
|
12644
12644
|
if (unwrapErr) return cb2(unwrapErr);
|
|
12645
|
-
var pkgfile =
|
|
12645
|
+
var pkgfile = path2.join(pkgdir, "package.json");
|
|
12646
12646
|
isFile2(pkgfile, function(err2, ex) {
|
|
12647
12647
|
if (err2) return cb2(err2);
|
|
12648
|
-
if (!ex) return loadAsFile(
|
|
12648
|
+
if (!ex) return loadAsFile(path2.join(x2, "index"), fpkg, cb2);
|
|
12649
12649
|
readPackage(readFile, pkgfile, function(err3, pkgParam) {
|
|
12650
12650
|
if (err3) return cb2(err3);
|
|
12651
12651
|
var pkg = pkgParam;
|
|
@@ -12654,20 +12654,20 @@ var require_async = __commonJS({
|
|
|
12654
12654
|
var mainError = new $TypeError("package \u201C" + pkg.name + "\u201D `main` must be a string");
|
|
12655
12655
|
return mainError.code = "INVALID_PACKAGE_MAIN", cb2(mainError);
|
|
12656
12656
|
}
|
|
12657
|
-
(pkg.main === "." || pkg.main === "./") && (pkg.main = "index"), loadAsFile(
|
|
12657
|
+
(pkg.main === "." || pkg.main === "./") && (pkg.main = "index"), loadAsFile(path2.resolve(x2, pkg.main), pkg, function(err4, m, pkg2) {
|
|
12658
12658
|
if (err4) return cb2(err4);
|
|
12659
12659
|
if (m) return cb2(null, m, pkg2);
|
|
12660
|
-
if (!pkg2) return loadAsFile(
|
|
12661
|
-
var dir =
|
|
12660
|
+
if (!pkg2) return loadAsFile(path2.join(x2, "index"), pkg2, cb2);
|
|
12661
|
+
var dir = path2.resolve(x2, pkg2.main);
|
|
12662
12662
|
loadAsDirectory(dir, pkg2, function(err5, n, pkg3) {
|
|
12663
12663
|
if (err5) return cb2(err5);
|
|
12664
12664
|
if (n) return cb2(null, n, pkg3);
|
|
12665
|
-
loadAsFile(
|
|
12665
|
+
loadAsFile(path2.join(x2, "index"), pkg3, cb2);
|
|
12666
12666
|
});
|
|
12667
12667
|
});
|
|
12668
12668
|
return;
|
|
12669
12669
|
}
|
|
12670
|
-
loadAsFile(
|
|
12670
|
+
loadAsFile(path2.join(x2, "/index"), pkg, cb2);
|
|
12671
12671
|
});
|
|
12672
12672
|
});
|
|
12673
12673
|
});
|
|
@@ -12675,7 +12675,7 @@ var require_async = __commonJS({
|
|
|
12675
12675
|
function processDirs(cb2, dirs) {
|
|
12676
12676
|
if (dirs.length === 0) return cb2(null, void 0);
|
|
12677
12677
|
var dir = dirs[0];
|
|
12678
|
-
isDirectory(
|
|
12678
|
+
isDirectory(path2.dirname(dir), isdir);
|
|
12679
12679
|
function isdir(err2, isdir2) {
|
|
12680
12680
|
if (err2) return cb2(err2);
|
|
12681
12681
|
if (!isdir2) return processDirs(cb2, dirs.slice(1));
|
|
@@ -12898,11 +12898,11 @@ var require_is_core = __commonJS({
|
|
|
12898
12898
|
// ../../../node_modules/resolve/lib/sync.js
|
|
12899
12899
|
var require_sync = __commonJS({
|
|
12900
12900
|
"../../../node_modules/resolve/lib/sync.js"(exports, module) {
|
|
12901
|
-
var isCore = require_is_core_module(), fs = __require("fs"),
|
|
12901
|
+
var isCore = require_is_core_module(), fs = __require("fs"), path2 = __require("path"), $Error = require_es_errors(), $TypeError = require_type(), getHomedir = require_homedir(), caller = require_caller(), nodeModulesPaths = require_node_modules_paths(), normalizeOptions = require_normalize_options(), realpathFS = process.platform !== "win32" && fs.realpathSync && typeof fs.realpathSync.native == "function" ? fs.realpathSync.native : fs.realpathSync, relativePathRegex = /^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/, windowsDriveRegex = /^\w:[/\\]*$/, nodeModulesRegex = /[/\\]node_modules[/\\]*$/, homedir = getHomedir();
|
|
12902
12902
|
function defaultPaths() {
|
|
12903
12903
|
return homedir ? [
|
|
12904
|
-
|
|
12905
|
-
|
|
12904
|
+
path2.join(homedir, ".node_modules"),
|
|
12905
|
+
path2.join(homedir, ".node_libraries")
|
|
12906
12906
|
] : [];
|
|
12907
12907
|
}
|
|
12908
12908
|
var defaultIsFile = function(file) {
|
|
@@ -12943,7 +12943,7 @@ var require_sync = __commonJS({
|
|
|
12943
12943
|
}
|
|
12944
12944
|
function getPackageCandidates(x, start, opts) {
|
|
12945
12945
|
for (var dirs = nodeModulesPaths(start, opts, x), i2 = 0; i2 < dirs.length; i2++)
|
|
12946
|
-
dirs[i2] =
|
|
12946
|
+
dirs[i2] = path2.join(dirs[i2], x);
|
|
12947
12947
|
return dirs;
|
|
12948
12948
|
}
|
|
12949
12949
|
module.exports = function(x, options) {
|
|
@@ -12952,11 +12952,11 @@ var require_sync = __commonJS({
|
|
|
12952
12952
|
var opts = normalizeOptions(x, options), isFile2 = opts.isFile || defaultIsFile, readFileSync2 = opts.readFileSync || fs.readFileSync, isDirectory = opts.isDirectory || defaultIsDir, realpathSync = opts.realpathSync || defaultRealpathSync, readPackageSync = opts.readPackageSync || defaultReadPackageSync;
|
|
12953
12953
|
if (opts.readFileSync && opts.readPackageSync)
|
|
12954
12954
|
throw new $TypeError("`readFileSync` and `readPackageSync` are mutually exclusive.");
|
|
12955
|
-
var packageIterator = opts.packageIterator, extensions = opts.extensions || [".js"], includeCoreModules = opts.includeCoreModules !== !1, basedir = opts.basedir ||
|
|
12955
|
+
var packageIterator = opts.packageIterator, extensions = opts.extensions || [".js"], includeCoreModules = opts.includeCoreModules !== !1, basedir = opts.basedir || path2.dirname(caller()), parent = opts.filename || basedir;
|
|
12956
12956
|
opts.paths = opts.paths || defaultPaths();
|
|
12957
|
-
var absoluteStart = maybeRealpathSync(realpathSync,
|
|
12957
|
+
var absoluteStart = maybeRealpathSync(realpathSync, path2.resolve(basedir), opts);
|
|
12958
12958
|
if (relativePathRegex.test(x)) {
|
|
12959
|
-
var res =
|
|
12959
|
+
var res = path2.resolve(absoluteStart, x);
|
|
12960
12960
|
(x === "." || x === ".." || x.slice(-1) === "/") && (res += "/");
|
|
12961
12961
|
var m = loadAsFileSync(res) || loadAsDirectorySync(res);
|
|
12962
12962
|
if (m) return maybeRealpathSync(realpathSync, m, opts);
|
|
@@ -12969,10 +12969,10 @@ var require_sync = __commonJS({
|
|
|
12969
12969
|
var err = new $Error("Cannot find module '" + x + "' from '" + parent + "'");
|
|
12970
12970
|
throw err.code = "MODULE_NOT_FOUND", err;
|
|
12971
12971
|
function loadAsFileSync(x2) {
|
|
12972
|
-
var pkg = loadpkg(
|
|
12972
|
+
var pkg = loadpkg(path2.dirname(x2));
|
|
12973
12973
|
if (pkg && pkg.dir && pkg.pkg && opts.pathFilter) {
|
|
12974
|
-
var rfile =
|
|
12975
|
-
r && (x2 =
|
|
12974
|
+
var rfile = path2.relative(pkg.dir, x2), r = opts.pathFilter(pkg.pkg, x2, rfile);
|
|
12975
|
+
r && (x2 = path2.resolve(pkg.dir, r));
|
|
12976
12976
|
}
|
|
12977
12977
|
if (isFile2(x2))
|
|
12978
12978
|
return x2;
|
|
@@ -12984,9 +12984,9 @@ var require_sync = __commonJS({
|
|
|
12984
12984
|
}
|
|
12985
12985
|
function loadpkg(dir) {
|
|
12986
12986
|
if (!(dir === "" || dir === "/") && !(process.platform === "win32" && windowsDriveRegex.test(dir)) && !nodeModulesRegex.test(dir)) {
|
|
12987
|
-
var pkgfile =
|
|
12987
|
+
var pkgfile = path2.join(maybeRealpathSync(realpathSync, dir, opts), "package.json");
|
|
12988
12988
|
if (!isFile2(pkgfile))
|
|
12989
|
-
return loadpkg(
|
|
12989
|
+
return loadpkg(path2.dirname(dir));
|
|
12990
12990
|
var pkg = readPackageSync(readFileSync2, pkgfile);
|
|
12991
12991
|
return pkg && opts.packageFilter && (pkg = opts.packageFilter(
|
|
12992
12992
|
pkg,
|
|
@@ -12996,7 +12996,7 @@ var require_sync = __commonJS({
|
|
|
12996
12996
|
}
|
|
12997
12997
|
}
|
|
12998
12998
|
function loadAsDirectorySync(x2) {
|
|
12999
|
-
var pkgfile =
|
|
12999
|
+
var pkgfile = path2.join(maybeRealpathSync(realpathSync, x2, opts), "/package.json");
|
|
13000
13000
|
if (isFile2(pkgfile)) {
|
|
13001
13001
|
try {
|
|
13002
13002
|
var pkg = readPackageSync(readFileSync2, pkgfile);
|
|
@@ -13013,22 +13013,22 @@ var require_sync = __commonJS({
|
|
|
13013
13013
|
}
|
|
13014
13014
|
(pkg.main === "." || pkg.main === "./") && (pkg.main = "index");
|
|
13015
13015
|
try {
|
|
13016
|
-
var m2 = loadAsFileSync(
|
|
13016
|
+
var m2 = loadAsFileSync(path2.resolve(x2, pkg.main));
|
|
13017
13017
|
if (m2) return m2;
|
|
13018
|
-
var n2 = loadAsDirectorySync(
|
|
13018
|
+
var n2 = loadAsDirectorySync(path2.resolve(x2, pkg.main));
|
|
13019
13019
|
if (n2) return n2;
|
|
13020
13020
|
} catch {
|
|
13021
13021
|
}
|
|
13022
13022
|
}
|
|
13023
13023
|
}
|
|
13024
|
-
return loadAsFileSync(
|
|
13024
|
+
return loadAsFileSync(path2.join(x2, "/index"));
|
|
13025
13025
|
}
|
|
13026
13026
|
function loadNodeModulesSync(x2, start) {
|
|
13027
13027
|
for (var thunk = function() {
|
|
13028
13028
|
return getPackageCandidates(x2, start, opts);
|
|
13029
13029
|
}, dirs = packageIterator ? packageIterator(x2, start, thunk, opts) : thunk(), i2 = 0; i2 < dirs.length; i2++) {
|
|
13030
13030
|
var dir = dirs[i2];
|
|
13031
|
-
if (isDirectory(
|
|
13031
|
+
if (isDirectory(path2.dirname(dir))) {
|
|
13032
13032
|
var m2 = loadAsFileSync(dir);
|
|
13033
13033
|
if (m2) return m2;
|
|
13034
13034
|
var n2 = loadAsDirectorySync(dir);
|
|
@@ -13052,15 +13052,18 @@ var require_resolve = __commonJS({
|
|
|
13052
13052
|
});
|
|
13053
13053
|
|
|
13054
13054
|
// src/componentManifest/componentMeta/ComponentMetaManager.ts
|
|
13055
|
-
|
|
13056
|
-
|
|
13057
|
-
|
|
13058
|
-
|
|
13059
|
-
import
|
|
13055
|
+
import {
|
|
13056
|
+
ComponentMetaManager as BaseComponentMetaManager,
|
|
13057
|
+
parseTsconfigCommandLine
|
|
13058
|
+
} from "storybook/internal/component-meta";
|
|
13059
|
+
import { logger as logger2 } from "storybook/internal/node-logger";
|
|
13060
13060
|
|
|
13061
13061
|
// src/componentManifest/utils.ts
|
|
13062
13062
|
import { readFileSync, statSync as statSync2 } from "node:fs";
|
|
13063
|
-
import {
|
|
13063
|
+
import {
|
|
13064
|
+
findTsconfigPath as findTsconfigPathCommon,
|
|
13065
|
+
resolveImport
|
|
13066
|
+
} from "storybook/internal/common";
|
|
13064
13067
|
import { logger } from "storybook/internal/node-logger";
|
|
13065
13068
|
|
|
13066
13069
|
// ../../../node_modules/empathic/find.mjs
|
|
@@ -13160,20 +13163,19 @@ var memoStore = /* @__PURE__ */ new WeakMap(), asyncMemoStore = /* @__PURE__ */
|
|
|
13160
13163
|
return mtimeMs !== void 0 && textFileCache.set(filePath, { mtimeMs, content }), content;
|
|
13161
13164
|
}, cachedFindUp = cached(up2, { name: "findUp" }), cachedResolveImport = cached(resolveImport, {
|
|
13162
13165
|
name: "resolveImport"
|
|
13163
|
-
}),
|
|
13164
|
-
(cwd2) =>
|
|
13165
|
-
|
|
13166
|
-
|
|
13167
|
-
|
|
13168
|
-
if (found)
|
|
13169
|
-
return found;
|
|
13170
|
-
}
|
|
13171
|
-
},
|
|
13172
|
-
{ name: "findTsconfigPath" }
|
|
13166
|
+
}), findTsconfigPath = cached(
|
|
13167
|
+
(cwd2) => findTsconfigPathCommon(cwd2),
|
|
13168
|
+
{
|
|
13169
|
+
name: "findTsconfigPath"
|
|
13170
|
+
}
|
|
13173
13171
|
);
|
|
13174
13172
|
|
|
13175
13173
|
// src/componentManifest/componentMeta/ComponentMetaProject.ts
|
|
13176
13174
|
var import_language_core = __toESM(require_language_core(), 1), import_typescript = __toESM(require_typescript(), 1);
|
|
13175
|
+
import {
|
|
13176
|
+
ProgramBackedProject,
|
|
13177
|
+
ProjectFileTracker
|
|
13178
|
+
} from "storybook/internal/component-meta";
|
|
13177
13179
|
import * as path from "path";
|
|
13178
13180
|
|
|
13179
13181
|
// src/componentManifest/componentMeta/componentMetaExtractor.ts
|
|
@@ -13869,112 +13871,68 @@ function hasExportModifier(typescript, node) {
|
|
|
13869
13871
|
}
|
|
13870
13872
|
|
|
13871
13873
|
// src/componentManifest/componentMeta/ComponentMetaProject.ts
|
|
13872
|
-
var ComponentMetaProject = class {
|
|
13873
|
-
constructor(typescript, commandLine, configFileName, fsFileSnapshots = /* @__PURE__ */ new Map(), getCommandLineFn) {
|
|
13874
|
+
var ComponentMetaProject = class extends ProgramBackedProject {
|
|
13875
|
+
constructor(typescript, commandLine, configFileName, fsFileSnapshots = /* @__PURE__ */ new Map(), getCommandLineFn, documentRegistry) {
|
|
13876
|
+
super();
|
|
13874
13877
|
this.typescript = typescript;
|
|
13875
13878
|
this.commandLine = commandLine;
|
|
13876
13879
|
this.configFileName = configFileName;
|
|
13877
|
-
this.
|
|
13878
|
-
|
|
13879
|
-
this.projectVersion = 0;
|
|
13880
|
-
this.shouldCheckRootFiles = !1;
|
|
13881
|
-
/** Entries to extract — set by the generator, replayed during warmup for targeted type resolution. */
|
|
13880
|
+
this.documentRegistry = documentRegistry;
|
|
13881
|
+
/** Entries to extract - set by the generator, replayed during warmup for targeted type resolution. */
|
|
13882
13882
|
this.entries = [];
|
|
13883
|
+
this.files = new ProjectFileTracker(
|
|
13884
|
+
typescript,
|
|
13885
|
+
commandLine,
|
|
13886
|
+
fsFileSnapshots,
|
|
13887
|
+
(text) => typescript.ScriptSnapshot.fromString(text),
|
|
13888
|
+
getCommandLineFn
|
|
13889
|
+
);
|
|
13883
13890
|
let language = (0, import_language_core.createLanguage)(
|
|
13884
13891
|
[{ getLanguageId: (fileName) => (0, import_typescript.resolveFileLanguageId)(fileName) }],
|
|
13885
13892
|
new import_language_core.FileMap(typescript.sys.useCaseSensitiveFileNames),
|
|
13886
13893
|
(fileName, includeFsFiles) => {
|
|
13887
13894
|
if (!includeFsFiles)
|
|
13888
13895
|
return;
|
|
13889
|
-
let
|
|
13890
|
-
if (!cache || cache[0] !== modifiedTime)
|
|
13891
|
-
if (typescript.sys.fileExists(fileName)) {
|
|
13892
|
-
let text = typescript.sys.readFile(fileName), snapshot2 = text !== void 0 ? typescript.ScriptSnapshot.fromString(text) : void 0;
|
|
13893
|
-
fsFileSnapshots.set(fileName, [modifiedTime, snapshot2]);
|
|
13894
|
-
} else
|
|
13895
|
-
fsFileSnapshots.set(fileName, [modifiedTime, void 0]);
|
|
13896
|
-
let snapshot = fsFileSnapshots.get(fileName)?.[1];
|
|
13896
|
+
let snapshot = this.files.getSnapshot(fileName);
|
|
13897
13897
|
snapshot ? language.scripts.set(fileName, snapshot) : language.scripts.delete(fileName);
|
|
13898
13898
|
}
|
|
13899
13899
|
), projectHost = {
|
|
13900
13900
|
getCurrentDirectory: () => configFileName ? path.dirname(configFileName) : commandLine.options.rootDir ?? process.cwd(),
|
|
13901
13901
|
getCompilationSettings: () => this.commandLine.options,
|
|
13902
13902
|
getProjectReferences: () => this.commandLine.projectReferences,
|
|
13903
|
-
getProjectVersion
|
|
13904
|
-
|
|
13903
|
+
// getProjectVersion gates the language service's host re-sync; the tracker funnels every
|
|
13904
|
+
// invalidation into it.
|
|
13905
|
+
getProjectVersion: () => this.files.getProjectVersion(),
|
|
13906
|
+
getScriptFileNames: () => this.files.getScriptFileNames()
|
|
13905
13907
|
}, { languageServiceHost } = (0, import_typescript.createLanguageServiceHost)(
|
|
13906
13908
|
typescript,
|
|
13907
13909
|
typescript.sys,
|
|
13908
13910
|
language,
|
|
13909
13911
|
(s) => s,
|
|
13910
|
-
// asScriptId
|
|
13912
|
+
// asScriptId - identity for React (no URI mapping needed)
|
|
13911
13913
|
projectHost
|
|
13912
13914
|
);
|
|
13913
|
-
this.
|
|
13915
|
+
this.service = typescript.createLanguageService(languageServiceHost, this.documentRegistry);
|
|
13914
13916
|
}
|
|
13915
13917
|
getCommandLine() {
|
|
13916
13918
|
return this.commandLine;
|
|
13917
13919
|
}
|
|
13918
|
-
dispose() {
|
|
13919
|
-
clearTimeout(this.warmupTimer), this.ls.dispose();
|
|
13920
|
-
}
|
|
13921
13920
|
// ---------------------------------------------------------------------------
|
|
13922
13921
|
// Project management
|
|
13923
13922
|
// ---------------------------------------------------------------------------
|
|
13924
|
-
/**
|
|
13925
|
-
|
|
13926
|
-
|
|
13927
|
-
*/
|
|
13928
|
-
ensureFiles(fileNames) {
|
|
13929
|
-
let added = !1;
|
|
13930
|
-
for (let fileName of fileNames)
|
|
13931
|
-
this.commandLine.fileNames.includes(fileName) || (this.commandLine.fileNames.push(fileName), added = !0);
|
|
13932
|
-
added && this.projectVersion++;
|
|
13933
|
-
}
|
|
13934
|
-
/**
|
|
13935
|
-
* Adapted from:
|
|
13936
|
-
* https://github.com/volarjs/volar.js/blob/882cd56d46a13d272f34e451f495d3d62251969a/packages/kit/lib/createChecker.ts#L436-L447
|
|
13937
|
-
*/
|
|
13938
|
-
checkRootFilesUpdate() {
|
|
13939
|
-
if (!this.shouldCheckRootFiles || (this.shouldCheckRootFiles = !1, !this.getCommandLineFn))
|
|
13940
|
-
return;
|
|
13941
|
-
let newCommandLine = this.getCommandLineFn();
|
|
13942
|
-
arrayItemsEqual(newCommandLine.fileNames, this.commandLine.fileNames) || (this.commandLine.fileNames = newCommandLine.fileNames, this.projectVersion++);
|
|
13943
|
-
}
|
|
13944
|
-
hasSourceFile(fileName) {
|
|
13945
|
-
return !!this.ls.getProgram()?.getSourceFile(fileName);
|
|
13923
|
+
/** Cancels the warmup the base does not know about. */
|
|
13924
|
+
dispose() {
|
|
13925
|
+
clearTimeout(this.warmupTimer), super.dispose();
|
|
13946
13926
|
}
|
|
13947
|
-
|
|
13948
|
-
|
|
13949
|
-
* watch directories for file changes.
|
|
13950
|
-
*/
|
|
13951
|
-
getSourceFilePaths() {
|
|
13952
|
-
let program = this.ls.getProgram();
|
|
13953
|
-
return program ? program.getSourceFiles().map((sf) => sf.fileName.replace(/\\/g, "/")).filter((f) => !f.includes("node_modules")) : [];
|
|
13927
|
+
getSourceFile(fileName) {
|
|
13928
|
+
return this.service.getProgram()?.getSourceFile(fileName);
|
|
13954
13929
|
}
|
|
13955
|
-
/**
|
|
13956
|
-
* Adapted from:
|
|
13957
|
-
* https://github.com/volarjs/volar.js/blob/882cd56d46a13d272f34e451f495d3d62251969a/packages/kit/lib/createChecker.ts#L409-L432
|
|
13958
|
-
*
|
|
13959
|
-
* Created events only set shouldCheckRootFiles (version bump happens in checkRootFilesUpdate if
|
|
13960
|
-
* the file list actually changed). Deleted/created break early since they trigger a full config
|
|
13961
|
-
* reparse — processing remaining changes is unnecessary.
|
|
13962
|
-
*/
|
|
13963
13930
|
onFilesChanged(changes) {
|
|
13964
|
-
|
|
13965
|
-
|
|
13966
|
-
|
|
13967
|
-
|
|
13968
|
-
|
|
13969
|
-
program?.getSourceFile(filePath) && this.projectVersion++;
|
|
13970
|
-
else if (type === "deleted") {
|
|
13971
|
-
program?.getSourceFile(filePath) && this.projectVersion++, this.shouldCheckRootFiles = !0;
|
|
13972
|
-
break;
|
|
13973
|
-
} else if (type === "created") {
|
|
13974
|
-
this.shouldCheckRootFiles = !0;
|
|
13975
|
-
break;
|
|
13976
|
-
}
|
|
13977
|
-
this.projectVersion !== oldVersion && this.entries.length > 0 && (clearTimeout(this.warmupTimer), this.warmupTimer = setTimeout(() => {
|
|
13931
|
+
let program = this.service.getProgram();
|
|
13932
|
+
this.files.onFilesChanged(
|
|
13933
|
+
changes,
|
|
13934
|
+
(fileName) => !!program?.getSourceFile(fileName)
|
|
13935
|
+
) && this.entries.length > 0 && (clearTimeout(this.warmupTimer), this.warmupTimer = setTimeout(() => {
|
|
13978
13936
|
try {
|
|
13979
13937
|
this.extractPropsFromStories(this.entries);
|
|
13980
13938
|
} catch {
|
|
@@ -13982,15 +13940,15 @@ var ComponentMetaProject = class {
|
|
|
13982
13940
|
}, 100), this.warmupTimer?.unref?.());
|
|
13983
13941
|
}
|
|
13984
13942
|
// ---------------------------------------------------------------------------
|
|
13985
|
-
// Primary extraction method
|
|
13943
|
+
// Primary extraction method - probe-free
|
|
13986
13944
|
// ---------------------------------------------------------------------------
|
|
13987
13945
|
extractPropsFromStories(entries) {
|
|
13988
13946
|
this.entries = entries;
|
|
13989
13947
|
let allFiles = entries.flatMap(
|
|
13990
13948
|
(entry) => entry.component?.path ? [entry.storyPath, entry.component.path] : [entry.storyPath]
|
|
13991
13949
|
);
|
|
13992
|
-
this.ensureFiles(allFiles), this.ensureFresh(allFiles);
|
|
13993
|
-
let program = this.
|
|
13950
|
+
this.files.ensureFiles(allFiles), this.files.ensureFresh(allFiles);
|
|
13951
|
+
let program = this.service.getProgram();
|
|
13994
13952
|
if (!program)
|
|
13995
13953
|
return;
|
|
13996
13954
|
let checker = program.getTypeChecker(), serializationContextByComponentPath = /* @__PURE__ */ new Map();
|
|
@@ -14047,31 +14005,12 @@ var ComponentMetaProject = class {
|
|
|
14047
14005
|
continue;
|
|
14048
14006
|
}
|
|
14049
14007
|
}
|
|
14050
|
-
/**
|
|
14051
|
-
* Check mtime for specific files and bump projectVersion if any changed.
|
|
14052
|
-
*
|
|
14053
|
-
* This bypasses the sync() gate in createLanguageServiceHost — sync() only runs when
|
|
14054
|
-
* projectVersion changes, so mtime-based cache alone can't detect stale files. We do a targeted
|
|
14055
|
-
* mtime check for the files we're about to extract from, ensuring freshness even when the
|
|
14056
|
-
* fs.watch event hasn't arrived yet (race with HMR) or was missed entirely.
|
|
14057
|
-
*/
|
|
14058
|
-
ensureFresh(fileNames) {
|
|
14059
|
-
let stale = !1;
|
|
14060
|
-
for (let fileName of fileNames) {
|
|
14061
|
-
let cache = this.fsFileSnapshots.get(fileName);
|
|
14062
|
-
if (!cache)
|
|
14063
|
-
continue;
|
|
14064
|
-
let currentMtime = this.typescript.sys.getModifiedTime?.(fileName)?.valueOf();
|
|
14065
|
-
cache[0] !== currentMtime && (this.fsFileSnapshots.delete(fileName), stale = !0);
|
|
14066
|
-
}
|
|
14067
|
-
stale && this.projectVersion++;
|
|
14068
|
-
}
|
|
14069
14008
|
// ---------------------------------------------------------------------------
|
|
14070
14009
|
// Internal helpers
|
|
14071
14010
|
// ---------------------------------------------------------------------------
|
|
14072
14011
|
/**
|
|
14073
14012
|
* Path 2 fallback: resolve the component type from the story file's `meta.component` property.
|
|
14074
|
-
* Only works when the user explicitly set `component:` in the meta
|
|
14013
|
+
* Only works when the user explicitly set `component:` in the meta - no node means no
|
|
14075
14014
|
* extraction.
|
|
14076
14015
|
*/
|
|
14077
14016
|
resolveFromMetaComponent(checker, storySourceFile, componentRef) {
|
|
@@ -14093,7 +14032,7 @@ var ComponentMetaProject = class {
|
|
|
14093
14032
|
metaComponentInitializer
|
|
14094
14033
|
))
|
|
14095
14034
|
return;
|
|
14096
|
-
let componentType = checker.getTypeOfSymbol(componentProp), selectedSymbol =
|
|
14035
|
+
let componentType = checker.getTypeOfSymbol(componentProp), selectedSymbol = checker.getSymbolAtLocation(metaComponentInitializer);
|
|
14097
14036
|
if (memberAccess) {
|
|
14098
14037
|
let prop = componentType.getProperty(memberAccess);
|
|
14099
14038
|
if (prop)
|
|
@@ -14110,54 +14049,62 @@ var ComponentMetaProject = class {
|
|
|
14110
14049
|
};
|
|
14111
14050
|
}
|
|
14112
14051
|
};
|
|
14113
|
-
function arrayItemsEqual(a, b) {
|
|
14114
|
-
if (a.length !== b.length)
|
|
14115
|
-
return !1;
|
|
14116
|
-
let set = new Set(a);
|
|
14117
|
-
for (let file of b)
|
|
14118
|
-
if (!set.has(file))
|
|
14119
|
-
return !1;
|
|
14120
|
-
return !0;
|
|
14121
|
-
}
|
|
14122
14052
|
|
|
14123
14053
|
// src/componentManifest/componentMeta/ComponentMetaManager.ts
|
|
14124
|
-
|
|
14054
|
+
import { isFileInDir, sortTSConfigs } from "storybook/internal/component-meta";
|
|
14055
|
+
var DEFAULT_INFERRED_OPTIONS = {
|
|
14125
14056
|
strict: !0,
|
|
14126
14057
|
esModuleInterop: !0,
|
|
14127
14058
|
allowJs: !0,
|
|
14128
14059
|
skipLibCheck: !0
|
|
14129
|
-
}
|
|
14060
|
+
};
|
|
14061
|
+
function createReactProjectFactory(typescript) {
|
|
14062
|
+
let fsFileSnapshots = /* @__PURE__ */ new Map(), documentRegistry = typescript.createDocumentRegistry(
|
|
14063
|
+
typescript.sys.useCaseSensitiveFileNames
|
|
14064
|
+
);
|
|
14065
|
+
return {
|
|
14066
|
+
fsFileSnapshots,
|
|
14067
|
+
factory: {
|
|
14068
|
+
parseCommandLine: (tsconfig) => parseTsconfigCommandLine(typescript, tsconfig),
|
|
14069
|
+
createConfiguredProject: (commandLine, tsconfig, getCommandLine) => new ComponentMetaProject(
|
|
14070
|
+
typescript,
|
|
14071
|
+
commandLine,
|
|
14072
|
+
tsconfig,
|
|
14073
|
+
fsFileSnapshots,
|
|
14074
|
+
getCommandLine,
|
|
14075
|
+
documentRegistry
|
|
14076
|
+
),
|
|
14077
|
+
createInferredProject: () => new ComponentMetaProject(
|
|
14078
|
+
typescript,
|
|
14079
|
+
{
|
|
14080
|
+
options: {
|
|
14081
|
+
...DEFAULT_INFERRED_OPTIONS,
|
|
14082
|
+
target: typescript.ScriptTarget.Latest,
|
|
14083
|
+
module: typescript.ModuleKind.ESNext,
|
|
14084
|
+
moduleResolution: typescript.ModuleResolutionKind.Bundler,
|
|
14085
|
+
jsx: typescript.JsxEmit.ReactJSX
|
|
14086
|
+
},
|
|
14087
|
+
fileNames: [],
|
|
14088
|
+
errors: []
|
|
14089
|
+
},
|
|
14090
|
+
void 0,
|
|
14091
|
+
fsFileSnapshots,
|
|
14092
|
+
void 0,
|
|
14093
|
+
documentRegistry
|
|
14094
|
+
),
|
|
14095
|
+
dispose: () => fsFileSnapshots.clear()
|
|
14096
|
+
}
|
|
14097
|
+
};
|
|
14098
|
+
}
|
|
14099
|
+
var ComponentMetaManager = class extends BaseComponentMetaManager {
|
|
14130
14100
|
/**
|
|
14131
|
-
* @param recycleHeapPressureRatio Fraction of the V8 heap limit at which the shared program(s)
|
|
14132
|
-
* recycled
|
|
14133
|
-
*
|
|
14134
|
-
* without the fix. Defaults to {@link RECYCLE_HEAP_PRESSURE_RATIO}.
|
|
14101
|
+
* @param recycleHeapPressureRatio Fraction of the V8 heap limit at which the shared program(s)
|
|
14102
|
+
* are recycled. Exposed for tuning and for the memory regression gate, which passes `Infinity`
|
|
14103
|
+
* to disable recycling and assert the OOM still happens without the fix.
|
|
14135
14104
|
*/
|
|
14136
|
-
constructor(typescript, recycleHeapPressureRatio
|
|
14137
|
-
|
|
14138
|
-
|
|
14139
|
-
// https://github.com/volarjs/volar.js/blob/882cd56d46a13d272f34e451f495d3d62251969a/packages/language-server/lib/project/typescriptProject.ts#L34-L37
|
|
14140
|
-
this.configProjects = /* @__PURE__ */ new Map();
|
|
14141
|
-
this.rootTsConfigs = /* @__PURE__ */ new Set();
|
|
14142
|
-
this.searchedDirs = /* @__PURE__ */ new Set();
|
|
14143
|
-
// Our own file watching layer
|
|
14144
|
-
this.watching = !1;
|
|
14145
|
-
this.watchersByDir = /* @__PURE__ */ new Map();
|
|
14146
|
-
this.pendingEvents = /* @__PURE__ */ new Map();
|
|
14147
|
-
// Adapted from:
|
|
14148
|
-
// https://github.com/volarjs/volar.js/blob/882cd56d46a13d272f34e451f495d3d62251969a/packages/kit/lib/createChecker.ts#L83
|
|
14149
|
-
this.fsFileSnapshots = /* @__PURE__ */ new Map();
|
|
14150
|
-
this.heapRecycleThresholdBytes = Math.floor(
|
|
14151
|
-
v8.getHeapStatistics().heap_size_limit * recycleHeapPressureRatio
|
|
14152
|
-
);
|
|
14153
|
-
}
|
|
14154
|
-
// ---------------------------------------------------------------------------
|
|
14155
|
-
// Adapted from:
|
|
14156
|
-
// https://github.com/volarjs/volar.js/blob/882cd56d46a13d272f34e451f495d3d62251969a/packages/language-server/lib/project/typescriptProject.ts#L70-L79
|
|
14157
|
-
// ---------------------------------------------------------------------------
|
|
14158
|
-
getProjectForFile(fileName) {
|
|
14159
|
-
let tsconfig = this.findMatchTSConfig(fileName);
|
|
14160
|
-
return tsconfig ? this.getOrCreateConfiguredProject(tsconfig) ?? this.getOrCreateInferredProject(fileName) : this.getOrCreateInferredProject(fileName);
|
|
14105
|
+
constructor(typescript, recycleHeapPressureRatio) {
|
|
14106
|
+
let { factory, fsFileSnapshots } = createReactProjectFactory(typescript);
|
|
14107
|
+
super(typescript, factory, recycleHeapPressureRatio), this.fsFileSnapshots = fsFileSnapshots;
|
|
14161
14108
|
}
|
|
14162
14109
|
/**
|
|
14163
14110
|
* Batch-extract component props across all entries, grouping by tsconfig project so each project
|
|
@@ -14178,487 +14125,59 @@ var rootTsConfigNames = ["tsconfig.json", "jsconfig.json"], DEFAULT_INFERRED_OPT
|
|
|
14178
14125
|
}
|
|
14179
14126
|
this.recycleProjectsIfHeapPressured();
|
|
14180
14127
|
}
|
|
14181
|
-
|
|
14182
|
-
* Reclaim the shared program(s)' resident type-resolution cache when heap usage approaches the V8
|
|
14183
|
-
* limit, preventing the next extraction's spike from OOMing the dev server.
|
|
14184
|
-
*/
|
|
14185
|
-
recycleProjectsIfHeapPressured() {
|
|
14186
|
-
if (this.configProjects.size === 0 && !this.inferredProject || process.memoryUsage().heapUsed < this.heapRecycleThresholdBytes)
|
|
14187
|
-
return;
|
|
14188
|
-
let heapLimitMb = Math.round(v8.getHeapStatistics().heap_size_limit / (1024 * 1024));
|
|
14189
|
-
once.warn(import_ts_dedent.dedent`
|
|
14190
|
-
Storybook's experimental docgen server is nearing the Node.js memory limit (~${heapLimitMb} MB) while extracting component types, and recycled its TypeScript program to avoid an out-of-memory crash. This can briefly slow down the docs and Controls panels.
|
|
14128
|
+
};
|
|
14191
14129
|
|
|
14192
|
-
|
|
14193
|
-
|
|
14194
|
-
|
|
14195
|
-
|
|
14196
|
-
|
|
14197
|
-
|
|
14198
|
-
|
|
14199
|
-
|
|
14200
|
-
|
|
14201
|
-
|
|
14202
|
-
|
|
14203
|
-
|
|
14204
|
-
|
|
14205
|
-
|
|
14206
|
-
|
|
14207
|
-
|
|
14208
|
-
|
|
14209
|
-
|
|
14210
|
-
|
|
14211
|
-
|
|
14212
|
-
|
|
14213
|
-
|
|
14214
|
-
|
|
14215
|
-
|
|
14216
|
-
|
|
14217
|
-
|
|
14218
|
-
let prepareClosestRootCommandLine = () => {
|
|
14219
|
-
let matches = [];
|
|
14220
|
-
for (let rootTsConfig of this.rootTsConfigs)
|
|
14221
|
-
isFileInDir(fileName, path2.dirname(rootTsConfig)) && matches.push(rootTsConfig);
|
|
14222
|
-
matches = matches.sort((a, b) => sortTSConfigs(fileName, a, b)), matches.length && getCommandLine(matches[0]);
|
|
14223
|
-
}, findIndirectReferenceTsconfig = () => findTSConfig((tsconfig) => !!this.configProjects.get(tsconfig)?.hasSourceFile(fileName)), findDirectIncludeTsconfig = () => findTSConfig((tsconfig) => {
|
|
14224
|
-
let commandLine = getCommandLine(tsconfig);
|
|
14225
|
-
return new Set(commandLine?.fileNames ?? []).has(fileName);
|
|
14226
|
-
}), findTSConfig = (match) => {
|
|
14227
|
-
let checked = /* @__PURE__ */ new Set();
|
|
14228
|
-
for (let rootTsConfig of [...this.rootTsConfigs].sort(
|
|
14229
|
-
(a, b) => sortTSConfigs(fileName, a, b)
|
|
14230
|
-
)) {
|
|
14231
|
-
let project = this.configProjects.get(rootTsConfig);
|
|
14232
|
-
if (project) {
|
|
14233
|
-
let chains = getReferencesChains(project.getCommandLine(), rootTsConfig, []);
|
|
14234
|
-
chains = chains.reverse();
|
|
14235
|
-
for (let chain of chains)
|
|
14236
|
-
for (let i2 = chain.length - 1; i2 >= 0; i2--) {
|
|
14237
|
-
let tsconfig = chain[i2];
|
|
14238
|
-
if (!checked.has(tsconfig) && (checked.add(tsconfig), match(tsconfig)))
|
|
14239
|
-
return tsconfig;
|
|
14240
|
-
}
|
|
14241
|
-
}
|
|
14242
|
-
}
|
|
14243
|
-
return null;
|
|
14244
|
-
}, getReferencesChains = (commandLine, tsConfig, before) => {
|
|
14245
|
-
if (commandLine.projectReferences?.length) {
|
|
14246
|
-
let newChains = [];
|
|
14247
|
-
for (let projectReference of commandLine.projectReferences) {
|
|
14248
|
-
let tsConfigPath = projectReference.path.replace(/\\/g, "/");
|
|
14249
|
-
if (this.typescript.sys.directoryExists(tsConfigPath)) {
|
|
14250
|
-
let newTsConfigPath = path2.join(tsConfigPath, "tsconfig.json"), newJsConfigPath = path2.join(tsConfigPath, "jsconfig.json");
|
|
14251
|
-
this.typescript.sys.fileExists(newTsConfigPath) ? tsConfigPath = newTsConfigPath : this.typescript.sys.fileExists(newJsConfigPath) && (tsConfigPath = newJsConfigPath);
|
|
14252
|
-
}
|
|
14253
|
-
let beforeIndex = before.indexOf(tsConfigPath);
|
|
14254
|
-
if (beforeIndex >= 0)
|
|
14255
|
-
newChains.push(before.slice(0, Math.max(beforeIndex, 1)));
|
|
14256
|
-
else {
|
|
14257
|
-
let referenceCommandLine = getCommandLine(tsConfigPath);
|
|
14258
|
-
if (referenceCommandLine)
|
|
14259
|
-
for (let chain of getReferencesChains(referenceCommandLine, tsConfigPath, [
|
|
14260
|
-
...before,
|
|
14261
|
-
tsConfig
|
|
14262
|
-
]))
|
|
14263
|
-
newChains.push(chain);
|
|
14264
|
-
}
|
|
14265
|
-
}
|
|
14266
|
-
return newChains;
|
|
14267
|
-
} else
|
|
14268
|
-
return [[...before, tsConfig]];
|
|
14269
|
-
}, getCommandLine = (tsConfig) => this.getOrCreateConfiguredProject(tsConfig)?.getCommandLine();
|
|
14270
|
-
return prepareClosestRootCommandLine(), findDirectIncludeTsconfig() ?? findIndirectReferenceTsconfig();
|
|
14271
|
-
}
|
|
14272
|
-
// ---------------------------------------------------------------------------
|
|
14273
|
-
// Adapted from:
|
|
14274
|
-
// https://github.com/volarjs/volar.js/blob/882cd56d46a13d272f34e451f495d3d62251969a/packages/language-server/lib/project/typescriptProject.ts#L236-L256
|
|
14275
|
-
// ---------------------------------------------------------------------------
|
|
14276
|
-
getOrCreateConfiguredProject(tsconfig) {
|
|
14277
|
-
tsconfig = tsconfig.replace(/\\/g, "/");
|
|
14278
|
-
let project = this.configProjects.get(tsconfig);
|
|
14279
|
-
if (!project)
|
|
14280
|
-
try {
|
|
14281
|
-
let getCommandLine = () => this.parseConfigWorker(tsconfig);
|
|
14282
|
-
project = new ComponentMetaProject(
|
|
14283
|
-
this.typescript,
|
|
14284
|
-
getCommandLine(),
|
|
14285
|
-
tsconfig,
|
|
14286
|
-
this.fsFileSnapshots,
|
|
14287
|
-
getCommandLine
|
|
14288
|
-
), this.configProjects.set(tsconfig, project), this.watching && (this.watchDirectory(path2.dirname(tsconfig)), this.watchProgramSourceDirs(project));
|
|
14289
|
-
} catch (err) {
|
|
14290
|
-
return logger2.debug(`[reactComponentMeta] Failed to parse tsconfig ${tsconfig}: ${err}`), null;
|
|
14291
|
-
}
|
|
14292
|
-
return project;
|
|
14293
|
-
}
|
|
14294
|
-
// ---------------------------------------------------------------------------
|
|
14295
|
-
// Adapted from:
|
|
14296
|
-
// https://github.com/volarjs/volar.js/blob/882cd56d46a13d272f34e451f495d3d62251969a/packages/language-server/lib/project/typescriptProject.ts#L258-L284
|
|
14297
|
-
// ---------------------------------------------------------------------------
|
|
14298
|
-
getOrCreateInferredProject(fileName) {
|
|
14299
|
-
return this.inferredProject || (this.inferredProject = new ComponentMetaProject(
|
|
14300
|
-
this.typescript,
|
|
14301
|
-
{
|
|
14302
|
-
options: {
|
|
14303
|
-
...DEFAULT_INFERRED_OPTIONS,
|
|
14304
|
-
target: this.typescript.ScriptTarget.Latest,
|
|
14305
|
-
module: this.typescript.ModuleKind.ESNext,
|
|
14306
|
-
moduleResolution: this.typescript.ModuleResolutionKind.Bundler,
|
|
14307
|
-
jsx: this.typescript.JsxEmit.ReactJSX
|
|
14308
|
-
},
|
|
14309
|
-
fileNames: [],
|
|
14310
|
-
errors: []
|
|
14311
|
-
},
|
|
14312
|
-
void 0,
|
|
14313
|
-
this.fsFileSnapshots
|
|
14314
|
-
)), this.inferredProject.ensureFiles([fileName]), this.inferredProject;
|
|
14315
|
-
}
|
|
14316
|
-
// ---------------------------------------------------------------------------
|
|
14317
|
-
// Adapted from:
|
|
14318
|
-
// https://github.com/volarjs/volar.js/blob/882cd56d46a13d272f34e451f495d3d62251969a/packages/language-server/lib/project/typescriptProjectLs.ts#L262-L353
|
|
14319
|
-
// ---------------------------------------------------------------------------
|
|
14320
|
-
parseConfigWorker(tsconfig) {
|
|
14321
|
-
let config = this.typescript.readJsonConfigFile(tsconfig, this.typescript.sys.readFile), content = this.typescript.parseJsonSourceFileConfigFileContent(
|
|
14322
|
-
config,
|
|
14323
|
-
this.typescript.sys,
|
|
14324
|
-
path2.dirname(tsconfig),
|
|
14325
|
-
{},
|
|
14326
|
-
tsconfig
|
|
14327
|
-
);
|
|
14328
|
-
return content.options.outDir = void 0, content.fileNames = content.fileNames.map((fileName) => fileName.replace(/\\/g, "/")), content;
|
|
14329
|
-
}
|
|
14330
|
-
// ---------------------------------------------------------------------------
|
|
14331
|
-
// File events
|
|
14332
|
-
// ---------------------------------------------------------------------------
|
|
14333
|
-
/**
|
|
14334
|
-
* Broadcast file changes to all projects. Each project selectively bumps projectVersion.
|
|
14335
|
-
*
|
|
14336
|
-
* Adapted from:
|
|
14337
|
-
* https://github.com/volarjs/volar.js/blob/882cd56d46a13d272f34e451f495d3d62251969a/packages/kit/lib/createChecker.ts#L409-L432
|
|
14338
|
-
*/
|
|
14339
|
-
onFilesChanged(changes) {
|
|
14340
|
-
for (let project of this.configProjects.values())
|
|
14341
|
-
project.onFilesChanged(changes);
|
|
14342
|
-
this.inferredProject?.onFilesChanged(changes);
|
|
14343
|
-
}
|
|
14344
|
-
/**
|
|
14345
|
-
* Adapted from:
|
|
14346
|
-
* https://github.com/volarjs/volar.js/blob/882cd56d46a13d272f34e451f495d3d62251969a/packages/language-server/lib/project/typescriptProject.ts#L43-L68
|
|
14347
|
-
*/
|
|
14348
|
-
onConfigChanged(configPath, type) {
|
|
14349
|
-
if (configPath = configPath.replace(/\\/g, "/"), type === "created")
|
|
14350
|
-
this.rootTsConfigs.add(configPath);
|
|
14351
|
-
else if ((type === "changed" || type === "deleted") && this.configProjects.has(configPath)) {
|
|
14352
|
-
type === "deleted" && this.rootTsConfigs.delete(configPath);
|
|
14353
|
-
let project = this.configProjects.get(configPath);
|
|
14354
|
-
this.configProjects.delete(configPath), project?.dispose();
|
|
14355
|
-
}
|
|
14356
|
-
this.searchedDirs.clear();
|
|
14357
|
-
}
|
|
14358
|
-
// ---------------------------------------------------------------------------
|
|
14359
|
-
// Our own file watching layer (no Volar equivalent — we're standalone)
|
|
14360
|
-
// ---------------------------------------------------------------------------
|
|
14361
|
-
startWatching() {
|
|
14362
|
-
if (!this.watching) {
|
|
14363
|
-
this.watching = !0;
|
|
14364
|
-
for (let tsconfig of this.configProjects.keys())
|
|
14365
|
-
this.watchDirectory(path2.dirname(tsconfig));
|
|
14366
|
-
this.watchProgramSourceDirs();
|
|
14367
|
-
}
|
|
14368
|
-
}
|
|
14369
|
-
/**
|
|
14370
|
-
* Watch directories that contain source files from all TS programs. This covers monorepo setups
|
|
14371
|
-
* where stories import components via path aliases (e.g. apps/storybook/ imports from
|
|
14372
|
-
* packages/ui/ via tsconfig paths).
|
|
14373
|
-
*/
|
|
14374
|
-
watchProgramSourceDirs(singleProject) {
|
|
14375
|
-
let dirs = /* @__PURE__ */ new Set();
|
|
14376
|
-
if (singleProject)
|
|
14377
|
-
for (let filePath of singleProject.getSourceFilePaths())
|
|
14378
|
-
dirs.add(path2.dirname(filePath));
|
|
14379
|
-
else {
|
|
14380
|
-
for (let project of this.configProjects.values())
|
|
14381
|
-
for (let filePath of project.getSourceFilePaths())
|
|
14382
|
-
dirs.add(path2.dirname(filePath));
|
|
14383
|
-
if (this.inferredProject)
|
|
14384
|
-
for (let filePath of this.inferredProject.getSourceFilePaths())
|
|
14385
|
-
dirs.add(path2.dirname(filePath));
|
|
14386
|
-
}
|
|
14387
|
-
let roots = /* @__PURE__ */ new Set();
|
|
14388
|
-
for (let dir of dirs) {
|
|
14389
|
-
let candidate = dir;
|
|
14390
|
-
for (; candidate !== path2.dirname(candidate); ) {
|
|
14391
|
-
let normalized = candidate.replace(/\\/g, "/"), alreadyWatched = !1;
|
|
14392
|
-
for (let watched of this.watchersByDir.keys())
|
|
14393
|
-
if (normalized === watched || normalized.startsWith(watched + "/")) {
|
|
14394
|
-
alreadyWatched = !0;
|
|
14395
|
-
break;
|
|
14396
|
-
}
|
|
14397
|
-
if (alreadyWatched)
|
|
14398
|
-
break;
|
|
14399
|
-
if (this.typescript.sys.fileExists(path2.join(candidate, "package.json")) || this.typescript.sys.fileExists(path2.join(candidate, "tsconfig.json"))) {
|
|
14400
|
-
roots.add(candidate);
|
|
14401
|
-
break;
|
|
14402
|
-
}
|
|
14403
|
-
candidate = path2.dirname(candidate);
|
|
14404
|
-
}
|
|
14405
|
-
}
|
|
14406
|
-
for (let root of roots)
|
|
14407
|
-
this.watchDirectory(root);
|
|
14408
|
-
}
|
|
14409
|
-
watchDirectory(dir) {
|
|
14410
|
-
if (!this.watching)
|
|
14411
|
-
return;
|
|
14412
|
-
let normalized = dir.replace(/\\/g, "/");
|
|
14413
|
-
for (let watched of this.watchersByDir.keys())
|
|
14414
|
-
if (normalized === watched || normalized.startsWith(watched + "/"))
|
|
14415
|
-
return;
|
|
14416
|
-
for (let [watched, watcher] of this.watchersByDir)
|
|
14417
|
-
watched.startsWith(normalized + "/") && (watcher.close(), this.watchersByDir.delete(watched));
|
|
14418
|
-
try {
|
|
14419
|
-
let watcher = watch(dir, { recursive: !0 }, (eventType, filename) => {
|
|
14420
|
-
if (!filename)
|
|
14421
|
-
return;
|
|
14422
|
-
let filePath = path2.resolve(dir, filename).replace(/\\/g, "/");
|
|
14423
|
-
if (filePath.includes("/node_modules/") || filePath.includes("/.git/"))
|
|
14424
|
-
return;
|
|
14425
|
-
let existing = this.pendingEvents.get(filePath);
|
|
14426
|
-
existing && clearTimeout(existing), this.pendingEvents.set(
|
|
14427
|
-
filePath,
|
|
14428
|
-
setTimeout(() => {
|
|
14429
|
-
this.pendingEvents.delete(filePath), eventType === "rename" ? existsSync2(filePath) ? this.handleFileEvent(filePath, "created") : this.handleFileEvent(filePath, "deleted") : this.handleFileEvent(filePath, "changed");
|
|
14430
|
-
}, 50)
|
|
14431
|
-
);
|
|
14432
|
-
});
|
|
14433
|
-
watcher.unref(), this.watchersByDir.set(normalized, watcher);
|
|
14434
|
-
} catch (err) {
|
|
14435
|
-
logger2.debug(`[reactComponentMeta] Failed to watch directory ${normalized}: ${err}`);
|
|
14436
|
-
}
|
|
14437
|
-
}
|
|
14438
|
-
stopWatching() {
|
|
14439
|
-
for (let timeout of this.pendingEvents.values())
|
|
14440
|
-
clearTimeout(timeout);
|
|
14441
|
-
this.pendingEvents.clear();
|
|
14442
|
-
for (let watcher of this.watchersByDir.values())
|
|
14443
|
-
watcher.close();
|
|
14444
|
-
this.watchersByDir.clear(), this.watching = !1;
|
|
14445
|
-
}
|
|
14446
|
-
/**
|
|
14447
|
-
* Map raw fs.watch events to LSP-style FileChangeType before broadcasting.
|
|
14448
|
-
*
|
|
14449
|
-
* Fs.watch reports atomic saves (sed -i, editors) as `rename` → we classify as `created` (file
|
|
14450
|
-
* exists after rename). But an IDE/LSP would report an atomic save of an _existing_ file as
|
|
14451
|
-
* `Changed`, not `Created`.
|
|
14452
|
-
*
|
|
14453
|
-
* We reclassify here so that onFilesChanged stays 1:1 with Volar Kit.
|
|
14454
|
-
*/
|
|
14455
|
-
handleFileEvent(filePath, type) {
|
|
14456
|
-
if (type === "created") {
|
|
14457
|
-
for (let project of this.configProjects.values())
|
|
14458
|
-
if (project.hasSourceFile(filePath)) {
|
|
14459
|
-
type = "changed";
|
|
14460
|
-
break;
|
|
14461
|
-
}
|
|
14462
|
-
type === "created" && this.inferredProject?.hasSourceFile(filePath) && (type = "changed");
|
|
14463
|
-
}
|
|
14464
|
-
let basename3 = path2.basename(filePath);
|
|
14465
|
-
if (rootTsConfigNames.includes(basename3)) {
|
|
14466
|
-
this.onConfigChanged(filePath, type);
|
|
14467
|
-
return;
|
|
14468
|
-
}
|
|
14469
|
-
this.onFilesChanged([{ filePath, type }]);
|
|
14130
|
+
// src/extractProps.ts
|
|
14131
|
+
import {
|
|
14132
|
+
TypeSystem,
|
|
14133
|
+
extractComponentProps,
|
|
14134
|
+
hasDocgen
|
|
14135
|
+
} from "storybook/internal/docs-tools";
|
|
14136
|
+
|
|
14137
|
+
// src/docs/lib/componentTypes.ts
|
|
14138
|
+
var isMemo = (component) => component.$$typeof === /* @__PURE__ */ Symbol.for("react.memo");
|
|
14139
|
+
|
|
14140
|
+
// src/docs/lib/defaultValues/createDefaultValue.ts
|
|
14141
|
+
import {
|
|
14142
|
+
createSummaryValue as createSummaryValue3,
|
|
14143
|
+
isTooLongForDefaultValueSummary as isTooLongForDefaultValueSummary3
|
|
14144
|
+
} from "storybook/internal/docs-tools";
|
|
14145
|
+
|
|
14146
|
+
// src/docs/lib/captions.ts
|
|
14147
|
+
var CUSTOM_CAPTION = "custom", OBJECT_CAPTION = "object", ARRAY_CAPTION = "array", CLASS_CAPTION = "class", FUNCTION_CAPTION = "func", ELEMENT_CAPTION = "element";
|
|
14148
|
+
|
|
14149
|
+
// src/docs/lib/generateCode.ts
|
|
14150
|
+
var import_escodegen = __toESM(require_escodegen(), 1), import_ts_dedent = __toESM(require_dist(), 1), BASIC_OPTIONS = {
|
|
14151
|
+
format: {
|
|
14152
|
+
indent: {
|
|
14153
|
+
style: " "
|
|
14154
|
+
},
|
|
14155
|
+
semicolons: !1
|
|
14470
14156
|
}
|
|
14471
|
-
|
|
14472
|
-
|
|
14473
|
-
|
|
14474
|
-
|
|
14475
|
-
this.inferredProject?.dispose(), this.configProjects.clear(), this.inferredProject = void 0, this.fsFileSnapshots.clear(), this.searchedDirs.clear(), this.rootTsConfigs.clear();
|
|
14157
|
+
}, COMPACT_OPTIONS = {
|
|
14158
|
+
...BASIC_OPTIONS,
|
|
14159
|
+
format: {
|
|
14160
|
+
newline: ""
|
|
14476
14161
|
}
|
|
14162
|
+
}, PRETTY_OPTIONS = {
|
|
14163
|
+
...BASIC_OPTIONS
|
|
14477
14164
|
};
|
|
14478
|
-
function
|
|
14479
|
-
|
|
14480
|
-
if (inA !== inB)
|
|
14481
|
-
return (inB ? 1 : 0) - (inA ? 1 : 0);
|
|
14482
|
-
let aLength = a.split("/").length, bLength = b.split("/").length;
|
|
14483
|
-
if (aLength === bLength) {
|
|
14484
|
-
let aWeight = path2.basename(a) === "tsconfig.json" ? 1 : 0;
|
|
14485
|
-
return (path2.basename(b) === "tsconfig.json" ? 1 : 0) - aWeight;
|
|
14486
|
-
}
|
|
14487
|
-
return bLength - aLength;
|
|
14165
|
+
function generateCode(ast, compact = !1) {
|
|
14166
|
+
return (0, import_escodegen.generate)(ast, compact ? COMPACT_OPTIONS : PRETTY_OPTIONS);
|
|
14488
14167
|
}
|
|
14489
|
-
function
|
|
14490
|
-
|
|
14491
|
-
return !!relative3 && !relative3.startsWith("..") && !path2.isAbsolute(relative3);
|
|
14168
|
+
function generateObjectCode(ast, compact = !1) {
|
|
14169
|
+
return compact ? generateCompactObjectCode(ast) : generateCode(ast);
|
|
14492
14170
|
}
|
|
14493
|
-
|
|
14494
|
-
|
|
14495
|
-
|
|
14496
|
-
function normalizeWindowsPath(input = "") {
|
|
14497
|
-
return input && input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
14498
|
-
}
|
|
14499
|
-
var _UNC_REGEX = /^[/\\]{2}/, _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, _DRIVE_LETTER_RE = /^[A-Za-z]:$/, _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/, sep = "/", delimiter = ":", normalize = function(path4) {
|
|
14500
|
-
if (path4.length === 0)
|
|
14501
|
-
return ".";
|
|
14502
|
-
path4 = normalizeWindowsPath(path4);
|
|
14503
|
-
let isUNCPath = path4.match(_UNC_REGEX), isPathAbsolute = isAbsolute3(path4), trailingSeparator = path4[path4.length - 1] === "/";
|
|
14504
|
-
return path4 = normalizeString(path4, !isPathAbsolute), path4.length === 0 ? isPathAbsolute ? "/" : trailingSeparator ? "./" : "." : (trailingSeparator && (path4 += "/"), _DRIVE_LETTER_RE.test(path4) && (path4 += "/"), isUNCPath ? isPathAbsolute ? `//${path4}` : `//./${path4}` : isPathAbsolute && !isAbsolute3(path4) ? `/${path4}` : path4);
|
|
14505
|
-
}, join4 = function(...arguments_) {
|
|
14506
|
-
if (arguments_.length === 0)
|
|
14507
|
-
return ".";
|
|
14508
|
-
let joined;
|
|
14509
|
-
for (let argument of arguments_)
|
|
14510
|
-
argument && argument.length > 0 && (joined === void 0 ? joined = argument : joined += `/${argument}`);
|
|
14511
|
-
return joined === void 0 ? "." : normalize(joined.replace(/\/\/+/g, "/"));
|
|
14512
|
-
};
|
|
14513
|
-
function cwd() {
|
|
14514
|
-
return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
|
|
14515
|
-
}
|
|
14516
|
-
var resolve3 = function(...arguments_) {
|
|
14517
|
-
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
14518
|
-
let resolvedPath = "", resolvedAbsolute = !1;
|
|
14519
|
-
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
14520
|
-
let path4 = index >= 0 ? arguments_[index] : cwd();
|
|
14521
|
-
!path4 || path4.length === 0 || (resolvedPath = `${path4}/${resolvedPath}`, resolvedAbsolute = isAbsolute3(path4));
|
|
14522
|
-
}
|
|
14523
|
-
return resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute), resolvedAbsolute && !isAbsolute3(resolvedPath) ? `/${resolvedPath}` : resolvedPath.length > 0 ? resolvedPath : ".";
|
|
14524
|
-
};
|
|
14525
|
-
function normalizeString(path4, allowAboveRoot) {
|
|
14526
|
-
let res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, char = null;
|
|
14527
|
-
for (let index = 0; index <= path4.length; ++index) {
|
|
14528
|
-
if (index < path4.length)
|
|
14529
|
-
char = path4[index];
|
|
14530
|
-
else {
|
|
14531
|
-
if (char === "/")
|
|
14532
|
-
break;
|
|
14533
|
-
char = "/";
|
|
14534
|
-
}
|
|
14535
|
-
if (char === "/") {
|
|
14536
|
-
if (!(lastSlash === index - 1 || dots === 1)) if (dots === 2) {
|
|
14537
|
-
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
14538
|
-
if (res.length > 2) {
|
|
14539
|
-
let lastSlashIndex = res.lastIndexOf("/");
|
|
14540
|
-
lastSlashIndex === -1 ? (res = "", lastSegmentLength = 0) : (res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/")), lastSlash = index, dots = 0;
|
|
14541
|
-
continue;
|
|
14542
|
-
} else if (res.length > 0) {
|
|
14543
|
-
res = "", lastSegmentLength = 0, lastSlash = index, dots = 0;
|
|
14544
|
-
continue;
|
|
14545
|
-
}
|
|
14546
|
-
}
|
|
14547
|
-
allowAboveRoot && (res += res.length > 0 ? "/.." : "..", lastSegmentLength = 2);
|
|
14548
|
-
} else
|
|
14549
|
-
res.length > 0 ? res += `/${path4.slice(lastSlash + 1, index)}` : res = path4.slice(lastSlash + 1, index), lastSegmentLength = index - lastSlash - 1;
|
|
14550
|
-
lastSlash = index, dots = 0;
|
|
14551
|
-
} else char === "." && dots !== -1 ? ++dots : dots = -1;
|
|
14552
|
-
}
|
|
14553
|
-
return res;
|
|
14554
|
-
}
|
|
14555
|
-
var isAbsolute3 = function(p) {
|
|
14556
|
-
return _IS_ABSOLUTE_RE.test(p);
|
|
14557
|
-
}, toNamespacedPath = function(p) {
|
|
14558
|
-
return normalizeWindowsPath(p);
|
|
14559
|
-
}, _EXTNAME_RE = /.(\.[^./]+)$/, extname = function(p) {
|
|
14560
|
-
let match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
|
14561
|
-
return match && match[1] || "";
|
|
14562
|
-
}, relative2 = function(from, to) {
|
|
14563
|
-
let _from = resolve3(from).replace(_ROOT_FOLDER_RE, "$1").split("/"), _to = resolve3(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
14564
|
-
if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0])
|
|
14565
|
-
return _to.join("/");
|
|
14566
|
-
let _fromCopy = [..._from];
|
|
14567
|
-
for (let segment of _fromCopy) {
|
|
14568
|
-
if (_to[0] !== segment)
|
|
14569
|
-
break;
|
|
14570
|
-
_from.shift(), _to.shift();
|
|
14571
|
-
}
|
|
14572
|
-
return [..._from.map(() => ".."), ..._to].join("/");
|
|
14573
|
-
}, dirname4 = function(p) {
|
|
14574
|
-
let segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
14575
|
-
return segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0]) && (segments[0] += "/"), segments.join("/") || (isAbsolute3(p) ? "/" : ".");
|
|
14576
|
-
}, format = function(p) {
|
|
14577
|
-
let segments = [p.root, p.dir, p.base ?? p.name + p.ext].filter(Boolean);
|
|
14578
|
-
return normalizeWindowsPath(
|
|
14579
|
-
p.root ? resolve3(...segments) : segments.join("/")
|
|
14580
|
-
);
|
|
14581
|
-
}, basename2 = function(p, extension) {
|
|
14582
|
-
let lastSegment = normalizeWindowsPath(p).split("/").pop();
|
|
14583
|
-
return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
|
|
14584
|
-
}, parse = function(p) {
|
|
14585
|
-
let root = normalizeWindowsPath(p).split("/").shift() || "/", base2 = basename2(p), extension = extname(base2);
|
|
14586
|
-
return {
|
|
14587
|
-
root,
|
|
14588
|
-
dir: dirname4(p),
|
|
14589
|
-
base: base2,
|
|
14590
|
-
ext: extension,
|
|
14591
|
-
name: base2.slice(0, base2.length - extension.length)
|
|
14592
|
-
};
|
|
14593
|
-
}, path3 = {
|
|
14594
|
-
__proto__: null,
|
|
14595
|
-
basename: basename2,
|
|
14596
|
-
delimiter,
|
|
14597
|
-
dirname: dirname4,
|
|
14598
|
-
extname,
|
|
14599
|
-
format,
|
|
14600
|
-
isAbsolute: isAbsolute3,
|
|
14601
|
-
join: join4,
|
|
14602
|
-
normalize,
|
|
14603
|
-
normalizeString,
|
|
14604
|
-
parse,
|
|
14605
|
-
relative: relative2,
|
|
14606
|
-
resolve: resolve3,
|
|
14607
|
-
sep,
|
|
14608
|
-
toNamespacedPath
|
|
14609
|
-
};
|
|
14610
|
-
|
|
14611
|
-
// src/extractProps.ts
|
|
14612
|
-
import {
|
|
14613
|
-
TypeSystem,
|
|
14614
|
-
extractComponentProps,
|
|
14615
|
-
hasDocgen
|
|
14616
|
-
} from "storybook/internal/docs-tools";
|
|
14617
|
-
|
|
14618
|
-
// src/docs/lib/componentTypes.ts
|
|
14619
|
-
var isMemo = (component) => component.$$typeof === /* @__PURE__ */ Symbol.for("react.memo");
|
|
14620
|
-
|
|
14621
|
-
// src/docs/lib/defaultValues/createDefaultValue.ts
|
|
14622
|
-
import {
|
|
14623
|
-
createSummaryValue as createSummaryValue3,
|
|
14624
|
-
isTooLongForDefaultValueSummary as isTooLongForDefaultValueSummary3
|
|
14625
|
-
} from "storybook/internal/docs-tools";
|
|
14626
|
-
|
|
14627
|
-
// src/docs/lib/captions.ts
|
|
14628
|
-
var CUSTOM_CAPTION = "custom", OBJECT_CAPTION = "object", ARRAY_CAPTION = "array", CLASS_CAPTION = "class", FUNCTION_CAPTION = "func", ELEMENT_CAPTION = "element";
|
|
14629
|
-
|
|
14630
|
-
// src/docs/lib/generateCode.ts
|
|
14631
|
-
var import_escodegen = __toESM(require_escodegen(), 1), import_ts_dedent2 = __toESM(require_dist(), 1), BASIC_OPTIONS = {
|
|
14632
|
-
format: {
|
|
14633
|
-
indent: {
|
|
14634
|
-
style: " "
|
|
14635
|
-
},
|
|
14636
|
-
semicolons: !1
|
|
14637
|
-
}
|
|
14638
|
-
}, COMPACT_OPTIONS = {
|
|
14639
|
-
...BASIC_OPTIONS,
|
|
14640
|
-
format: {
|
|
14641
|
-
newline: ""
|
|
14642
|
-
}
|
|
14643
|
-
}, PRETTY_OPTIONS = {
|
|
14644
|
-
...BASIC_OPTIONS
|
|
14645
|
-
};
|
|
14646
|
-
function generateCode(ast, compact = !1) {
|
|
14647
|
-
return (0, import_escodegen.generate)(ast, compact ? COMPACT_OPTIONS : PRETTY_OPTIONS);
|
|
14648
|
-
}
|
|
14649
|
-
function generateObjectCode(ast, compact = !1) {
|
|
14650
|
-
return compact ? generateCompactObjectCode(ast) : generateCode(ast);
|
|
14651
|
-
}
|
|
14652
|
-
function generateCompactObjectCode(ast) {
|
|
14653
|
-
let result = generateCode(ast, !0);
|
|
14654
|
-
return result.endsWith(" }") || (result = `${result.slice(0, -1)} }`), result;
|
|
14171
|
+
function generateCompactObjectCode(ast) {
|
|
14172
|
+
let result = generateCode(ast, !0);
|
|
14173
|
+
return result.endsWith(" }") || (result = `${result.slice(0, -1)} }`), result;
|
|
14655
14174
|
}
|
|
14656
14175
|
function generateArrayCode(ast, compact = !1) {
|
|
14657
14176
|
return compact ? generateCompactArrayCode(ast) : generateMultilineArrayCode(ast);
|
|
14658
14177
|
}
|
|
14659
14178
|
function generateMultilineArrayCode(ast) {
|
|
14660
14179
|
let result = generateCode(ast);
|
|
14661
|
-
return result.endsWith(" }]") && (result = (0,
|
|
14180
|
+
return result.endsWith(" }]") && (result = (0, import_ts_dedent.dedent)(result)), result;
|
|
14662
14181
|
}
|
|
14663
14182
|
function generateCompactArrayCode(ast) {
|
|
14664
14183
|
let result = generateCode(ast, !0);
|
|
@@ -14800,7 +14319,7 @@ function parseExpression(expression) {
|
|
|
14800
14319
|
return null;
|
|
14801
14320
|
}
|
|
14802
14321
|
}
|
|
14803
|
-
function
|
|
14322
|
+
function parse4(value) {
|
|
14804
14323
|
let ast = acornParser.parse(`(${value})`, { ecmaVersion: 2020 }), parsingResult = {
|
|
14805
14324
|
inferredType: { type: "Unknown" /* UNKNOWN */ },
|
|
14806
14325
|
ast
|
|
@@ -14818,7 +14337,7 @@ function parse5(value) {
|
|
|
14818
14337
|
// src/docs/lib/inspection/inspectValue.ts
|
|
14819
14338
|
function inspectValue(value) {
|
|
14820
14339
|
try {
|
|
14821
|
-
return { ...
|
|
14340
|
+
return { ...parse4(value) };
|
|
14822
14341
|
} catch {
|
|
14823
14342
|
}
|
|
14824
14343
|
return { inferredType: { type: "Unknown" /* UNKNOWN */ } };
|
|
@@ -15797,18 +15316,18 @@ var extractArgTypes = (component) => {
|
|
|
15797
15316
|
};
|
|
15798
15317
|
|
|
15799
15318
|
// src/componentManifest/reactDocgen.ts
|
|
15800
|
-
var
|
|
15801
|
-
import { existsSync as
|
|
15802
|
-
import { dirname as
|
|
15319
|
+
var import_ts_dedent2 = __toESM(require_dist(), 1), TsconfigPaths = __toESM(require_lib2(), 1);
|
|
15320
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
15321
|
+
import { dirname as dirname3, sep } from "node:path";
|
|
15803
15322
|
import { babelParse, types as t } from "storybook/internal/babel";
|
|
15804
|
-
import { supportedExtensions as supportedExtensions2 } from "storybook/internal/common";
|
|
15323
|
+
import { findTsconfigPathForPath, supportedExtensions as supportedExtensions2 } from "storybook/internal/common";
|
|
15805
15324
|
import { extractJSDocInfo } from "storybook/internal/csf-tools";
|
|
15806
15325
|
import { logger as logger3 } from "storybook/internal/node-logger";
|
|
15807
15326
|
import {
|
|
15808
15327
|
builtinHandlers as docgenHandlers,
|
|
15809
15328
|
builtinResolvers as docgenResolver,
|
|
15810
15329
|
makeFsImporter,
|
|
15811
|
-
parse as
|
|
15330
|
+
parse as parse5
|
|
15812
15331
|
} from "react-docgen";
|
|
15813
15332
|
|
|
15814
15333
|
// src/componentManifest/reactDocgen/actualNameHandler.ts
|
|
@@ -15853,16 +15372,16 @@ var ReactDocgenResolveError = class extends Error {
|
|
|
15853
15372
|
// src/componentManifest/reactDocgen/exportNameHandler.ts
|
|
15854
15373
|
import { utils as utils2 } from "react-docgen";
|
|
15855
15374
|
var { isReactForwardRefCall: isReactForwardRefCall2 } = utils2;
|
|
15856
|
-
function nameFromId(
|
|
15857
|
-
if (
|
|
15858
|
-
if (
|
|
15859
|
-
return
|
|
15860
|
-
if (
|
|
15861
|
-
return
|
|
15375
|
+
function nameFromId(path2) {
|
|
15376
|
+
if (path2) {
|
|
15377
|
+
if (path2.isIdentifier())
|
|
15378
|
+
return path2.node.name;
|
|
15379
|
+
if (path2.isStringLiteral())
|
|
15380
|
+
return path2.node.value;
|
|
15862
15381
|
}
|
|
15863
15382
|
}
|
|
15864
|
-
function isInlineDefaultExport(
|
|
15865
|
-
let p =
|
|
15383
|
+
function isInlineDefaultExport(path2) {
|
|
15384
|
+
let p = path2;
|
|
15866
15385
|
for (; p && p.parentPath; ) {
|
|
15867
15386
|
if (p.parentPath.isExportDefaultDeclaration())
|
|
15868
15387
|
return !0;
|
|
@@ -15870,8 +15389,8 @@ function isInlineDefaultExport(path4) {
|
|
|
15870
15389
|
}
|
|
15871
15390
|
return !1;
|
|
15872
15391
|
}
|
|
15873
|
-
function findProgram(
|
|
15874
|
-
let found =
|
|
15392
|
+
function findProgram(path2) {
|
|
15393
|
+
let found = path2.findParent((p) => p.isProgram());
|
|
15875
15394
|
return found && found.isProgram() ? found : void 0;
|
|
15876
15395
|
}
|
|
15877
15396
|
function getLocalName(componentDefinition, fallback) {
|
|
@@ -15968,9 +15487,9 @@ function getMatchingDocgen(docgens, component) {
|
|
|
15968
15487
|
)
|
|
15969
15488
|
) ?? docgens[0];
|
|
15970
15489
|
}
|
|
15971
|
-
function matchPath(id,
|
|
15972
|
-
|
|
15973
|
-
let tsconfig = getTsConfig(
|
|
15490
|
+
function matchPath(id, importerPath) {
|
|
15491
|
+
importerPath ??= process.cwd();
|
|
15492
|
+
let tsconfig = getTsConfig(importerPath);
|
|
15974
15493
|
return tsconfig.resultType === "success" ? TsconfigPaths.createMatchPath(tsconfig.absoluteBaseUrl, tsconfig.paths, [
|
|
15975
15494
|
"browser",
|
|
15976
15495
|
"module",
|
|
@@ -15978,19 +15497,19 @@ function matchPath(id, basedir) {
|
|
|
15978
15497
|
])(id, void 0, void 0, supportedExtensions2) ?? id : id;
|
|
15979
15498
|
}
|
|
15980
15499
|
var getTsConfig = cached(
|
|
15981
|
-
(
|
|
15982
|
-
let tsconfigPath =
|
|
15983
|
-
return TsconfigPaths.loadConfig(tsconfigPath);
|
|
15500
|
+
(path2) => {
|
|
15501
|
+
let tsconfigPath = findTsconfigPathForPath(path2);
|
|
15502
|
+
return tsconfigPath ? TsconfigPaths.loadConfig(tsconfigPath) : { resultType: "failed", message: "Couldn't find tsconfig.json" };
|
|
15984
15503
|
},
|
|
15985
15504
|
{ name: "getTsConfig" }
|
|
15986
15505
|
), parseWithReactDocgen = cached(
|
|
15987
|
-
(code,
|
|
15506
|
+
(code, path2) => parse5(code, {
|
|
15988
15507
|
resolver: defaultResolver2,
|
|
15989
15508
|
handlers,
|
|
15990
15509
|
importer: getReactDocgenImporter(),
|
|
15991
|
-
filename:
|
|
15510
|
+
filename: path2
|
|
15992
15511
|
}),
|
|
15993
|
-
{ key: (code,
|
|
15512
|
+
{ key: (code, path2) => path2, name: "parseWithReactDocgen" }
|
|
15994
15513
|
), getExportPaths = cached(
|
|
15995
15514
|
(code, filePath) => {
|
|
15996
15515
|
let ast;
|
|
@@ -15999,10 +15518,10 @@ var getTsConfig = cached(
|
|
|
15999
15518
|
} catch {
|
|
16000
15519
|
return [];
|
|
16001
15520
|
}
|
|
16002
|
-
let basedir =
|
|
15521
|
+
let basedir = dirname3(filePath);
|
|
16003
15522
|
return ast.program.body.flatMap(
|
|
16004
15523
|
(statement) => t.isExportAllDeclaration(statement) ? [statement.source.value] : t.isExportNamedDeclaration(statement) && statement.source && !statement.declaration ? [statement.source.value] : []
|
|
16005
|
-
).map((id) => matchPath(id,
|
|
15524
|
+
).map((id) => matchPath(id, filePath)).flatMap((id) => {
|
|
16006
15525
|
try {
|
|
16007
15526
|
return [cachedResolveImport(id, { basedir })];
|
|
16008
15527
|
} catch (e) {
|
|
@@ -16012,16 +15531,16 @@ var getTsConfig = cached(
|
|
|
16012
15531
|
},
|
|
16013
15532
|
{ name: "getExportPaths" }
|
|
16014
15533
|
), gatherDocgensForPath = cached(
|
|
16015
|
-
(
|
|
16016
|
-
if (
|
|
15534
|
+
(path2, depth) => {
|
|
15535
|
+
if (path2.includes("node_modules"))
|
|
16017
15536
|
return {
|
|
16018
15537
|
docgens: [],
|
|
16019
15538
|
errors: [
|
|
16020
15539
|
{
|
|
16021
|
-
path:
|
|
15540
|
+
path: path2,
|
|
16022
15541
|
code: "/* File in node_modules */",
|
|
16023
15542
|
name: "Component file in node_modules",
|
|
16024
|
-
message:
|
|
15543
|
+
message: import_ts_dedent2.dedent`
|
|
16025
15544
|
Component files in node_modules are not supported.
|
|
16026
15545
|
The distributed files in node_modules usually don't contain the necessary comments or types needed to analyze component information.
|
|
16027
15546
|
Configure TypeScript path aliases to map your package name to the source file instead.
|
|
@@ -16047,16 +15566,16 @@ var getTsConfig = cached(
|
|
|
16047
15566
|
};
|
|
16048
15567
|
let code;
|
|
16049
15568
|
try {
|
|
16050
|
-
code = cachedReadFileSync(
|
|
15569
|
+
code = cachedReadFileSync(path2, "utf-8");
|
|
16051
15570
|
} catch {
|
|
16052
15571
|
return {
|
|
16053
15572
|
docgens: [],
|
|
16054
15573
|
errors: [
|
|
16055
15574
|
{
|
|
16056
|
-
path:
|
|
15575
|
+
path: path2,
|
|
16057
15576
|
code: "/* File not found or unreadable */",
|
|
16058
15577
|
name: "Component file could not be read",
|
|
16059
|
-
message: `Could not read the component file located at "${
|
|
15578
|
+
message: `Could not read the component file located at "${path2}".
|
|
16060
15579
|
Prefer relative imports if possible.`
|
|
16061
15580
|
}
|
|
16062
15581
|
]
|
|
@@ -16067,10 +15586,10 @@ Prefer relative imports if possible.`
|
|
|
16067
15586
|
docgens: [],
|
|
16068
15587
|
errors: [
|
|
16069
15588
|
{
|
|
16070
|
-
path:
|
|
15589
|
+
path: path2,
|
|
16071
15590
|
code,
|
|
16072
15591
|
name: "Max re-export depth exceeded",
|
|
16073
|
-
message:
|
|
15592
|
+
message: import_ts_dedent2.dedent`
|
|
16074
15593
|
Traversal stopped after 5 steps while following re-exports starting from this file.
|
|
16075
15594
|
This usually indicates a deep or circular re-export chain. Try one of the following:
|
|
16076
15595
|
- Import the component file directly (e.g., src/components/Button.tsx),
|
|
@@ -16079,10 +15598,10 @@ Prefer relative imports if possible.`
|
|
|
16079
15598
|
}
|
|
16080
15599
|
]
|
|
16081
15600
|
};
|
|
16082
|
-
let exportPaths = getExportPaths(code,
|
|
15601
|
+
let exportPaths = getExportPaths(code, path2).map((p) => gatherDocgensForPath(p, depth + 1)), docgens = exportPaths.flatMap((r) => r.docgens), errors = exportPaths.flatMap((r) => r.errors);
|
|
16083
15602
|
try {
|
|
16084
15603
|
return {
|
|
16085
|
-
docgens: [...parseWithReactDocgen(code,
|
|
15604
|
+
docgens: [...parseWithReactDocgen(code, path2), ...docgens],
|
|
16086
15605
|
errors
|
|
16087
15606
|
};
|
|
16088
15607
|
} catch (e) {
|
|
@@ -16091,10 +15610,10 @@ Prefer relative imports if possible.`
|
|
|
16091
15610
|
docgens,
|
|
16092
15611
|
errors: [
|
|
16093
15612
|
{
|
|
16094
|
-
path:
|
|
15613
|
+
path: path2,
|
|
16095
15614
|
code,
|
|
16096
15615
|
name: "No component definition found",
|
|
16097
|
-
message:
|
|
15616
|
+
message: import_ts_dedent2.dedent`
|
|
16098
15617
|
${message}
|
|
16099
15618
|
You can debug your component file in this playground: https://react-docgen.dev/playground
|
|
16100
15619
|
`
|
|
@@ -16106,12 +15625,12 @@ Prefer relative imports if possible.`
|
|
|
16106
15625
|
},
|
|
16107
15626
|
{ name: "gatherDocgensWithTrace", key: (filePath) => filePath }
|
|
16108
15627
|
), getReactDocgen = cached(
|
|
16109
|
-
(
|
|
16110
|
-
let { docgens, errors } = gatherDocgensForPath(
|
|
15628
|
+
(path2, component) => {
|
|
15629
|
+
let { docgens, errors } = gatherDocgensForPath(path2, 0), docgen = getMatchingDocgen(docgens, component);
|
|
16111
15630
|
return docgen ? { type: "success", data: docgen } : { type: "error", error: {
|
|
16112
15631
|
name: errors.at(-1)?.name ?? "No component definition found",
|
|
16113
15632
|
message: errors.map(
|
|
16114
|
-
(e) =>
|
|
15633
|
+
(e) => import_ts_dedent2.dedent`
|
|
16115
15634
|
File: ${e.path}
|
|
16116
15635
|
Error:
|
|
16117
15636
|
${e.message}
|
|
@@ -16122,17 +15641,17 @@ Prefer relative imports if possible.`
|
|
|
16122
15641
|
`)
|
|
16123
15642
|
} };
|
|
16124
15643
|
},
|
|
16125
|
-
{ name: "getReactDocgen", key: (
|
|
15644
|
+
{ name: "getReactDocgen", key: (path2, component) => path2 + JSON.stringify(component) }
|
|
16126
15645
|
);
|
|
16127
15646
|
function getReactDocgenImporter() {
|
|
16128
15647
|
return makeFsImporter((filename, basedir) => {
|
|
16129
15648
|
let mappedFilenameByPaths = matchPath(filename, basedir), result = cachedResolveImport(mappedFilenameByPaths, { basedir });
|
|
16130
|
-
if (result.includes(`${
|
|
15649
|
+
if (result.includes(`${sep}react-native${sep}index.js`)) {
|
|
16131
15650
|
let replaced = result.replace(
|
|
16132
|
-
`${
|
|
16133
|
-
`${
|
|
15651
|
+
`${sep}react-native${sep}index.js`,
|
|
15652
|
+
`${sep}react-native-web${sep}dist${sep}index.js`
|
|
16134
15653
|
);
|
|
16135
|
-
if (
|
|
15654
|
+
if (existsSync2(replaced) && supportedExtensions2.find((ext) => result.endsWith(ext)))
|
|
16136
15655
|
return replaced;
|
|
16137
15656
|
}
|
|
16138
15657
|
if (supportedExtensions2.find((ext) => result.endsWith(ext)))
|
|
@@ -16145,221 +15664,322 @@ function getImportTag(docgen) {
|
|
|
16145
15664
|
return (jsdocComment ? extractJSDocInfo(jsdocComment).tags : void 0)?.import?.[0];
|
|
16146
15665
|
}
|
|
16147
15666
|
|
|
16148
|
-
//
|
|
16149
|
-
|
|
16150
|
-
|
|
16151
|
-
var
|
|
16152
|
-
|
|
16153
|
-
|
|
16154
|
-
|
|
16155
|
-
|
|
16156
|
-
|
|
16157
|
-
|
|
16158
|
-
|
|
16159
|
-
|
|
16160
|
-
|
|
15667
|
+
// ../../../node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
15668
|
+
var _lazyMatch = () => {
|
|
15669
|
+
var __lib__ = (() => {
|
|
15670
|
+
var m = Object.defineProperty, V = Object.getOwnPropertyDescriptor, G = Object.getOwnPropertyNames, T = Object.prototype.hasOwnProperty, q = (r, e) => {
|
|
15671
|
+
for (var n in e) m(r, n, { get: e[n], enumerable: !0 });
|
|
15672
|
+
}, H = (r, e, n, a) => {
|
|
15673
|
+
if (e && typeof e == "object" || typeof e == "function") for (let t5 of G(e)) !T.call(r, t5) && t5 !== n && m(r, t5, { get: () => e[t5], enumerable: !(a = V(e, t5)) || a.enumerable });
|
|
15674
|
+
return r;
|
|
15675
|
+
}, J = (r) => H(m({}, "__esModule", { value: !0 }), r), w = {};
|
|
15676
|
+
q(w, { default: () => re });
|
|
15677
|
+
var A = (r) => Array.isArray(r), d = (r) => typeof r == "function", Q = (r) => r.length === 0, W = (r) => typeof r == "number", K = (r) => typeof r == "object" && r !== null, X = (r) => r instanceof RegExp, b = (r) => typeof r == "string", h = (r) => r === void 0, Y = (r) => {
|
|
15678
|
+
let e = /* @__PURE__ */ new Map();
|
|
15679
|
+
return (n) => {
|
|
15680
|
+
let a = e.get(n);
|
|
15681
|
+
if (a) return a;
|
|
15682
|
+
let t5 = r(n);
|
|
15683
|
+
return e.set(n, t5), t5;
|
|
15684
|
+
};
|
|
15685
|
+
}, rr = (r, e, n = {}) => {
|
|
15686
|
+
let a = { cache: {}, input: r, index: 0, indexMax: 0, options: n, output: [] };
|
|
15687
|
+
if (v(e)(a) && a.index === r.length) return a.output;
|
|
15688
|
+
throw new Error(`Failed to parse at index ${a.indexMax}`);
|
|
15689
|
+
}, i2 = (r, e) => A(r) ? er(r, e) : b(r) ? ar(r, e) : nr(r, e), er = (r, e) => {
|
|
15690
|
+
let n = {};
|
|
15691
|
+
for (let a of r) {
|
|
15692
|
+
if (a.length !== 1) throw new Error(`Invalid character: "${a}"`);
|
|
15693
|
+
let t5 = a.charCodeAt(0);
|
|
15694
|
+
n[t5] = !0;
|
|
15695
|
+
}
|
|
15696
|
+
return (a) => {
|
|
15697
|
+
let t5 = a.index, o = a.input;
|
|
15698
|
+
for (; a.index < o.length && o.charCodeAt(a.index) in n; ) a.index += 1;
|
|
15699
|
+
let u = a.index;
|
|
15700
|
+
if (u > t5) {
|
|
15701
|
+
if (!h(e) && !a.options.silent) {
|
|
15702
|
+
let s = a.input.slice(t5, u), c = d(e) ? e(s, o, String(t5)) : e;
|
|
15703
|
+
h(c) || a.output.push(c);
|
|
15704
|
+
}
|
|
15705
|
+
a.indexMax = Math.max(a.indexMax, a.index);
|
|
15706
|
+
}
|
|
15707
|
+
return !0;
|
|
15708
|
+
};
|
|
15709
|
+
}, nr = (r, e) => {
|
|
15710
|
+
let n = r.source, a = r.flags.replace(/y|$/, "y"), t5 = new RegExp(n, a);
|
|
15711
|
+
return g((o) => {
|
|
15712
|
+
t5.lastIndex = o.index;
|
|
15713
|
+
let u = t5.exec(o.input);
|
|
15714
|
+
if (u) {
|
|
15715
|
+
if (!h(e) && !o.options.silent) {
|
|
15716
|
+
let s = d(e) ? e(...u, o.input, String(o.index)) : e;
|
|
15717
|
+
h(s) || o.output.push(s);
|
|
15718
|
+
}
|
|
15719
|
+
return o.index += u[0].length, o.indexMax = Math.max(o.indexMax, o.index), !0;
|
|
15720
|
+
} else return !1;
|
|
15721
|
+
});
|
|
15722
|
+
}, ar = (r, e) => (n) => {
|
|
15723
|
+
if (n.input.startsWith(r, n.index)) {
|
|
15724
|
+
if (!h(e) && !n.options.silent) {
|
|
15725
|
+
let t5 = d(e) ? e(r, n.input, String(n.index)) : e;
|
|
15726
|
+
h(t5) || n.output.push(t5);
|
|
15727
|
+
}
|
|
15728
|
+
return n.index += r.length, n.indexMax = Math.max(n.indexMax, n.index), !0;
|
|
15729
|
+
} else return !1;
|
|
15730
|
+
}, C = (r, e, n, a) => {
|
|
15731
|
+
let t5 = v(r);
|
|
15732
|
+
return g(_(M((o) => {
|
|
15733
|
+
let u = 0;
|
|
15734
|
+
for (; u < n; ) {
|
|
15735
|
+
let s = o.index;
|
|
15736
|
+
if (!t5(o) || (u += 1, o.index === s)) break;
|
|
15737
|
+
}
|
|
15738
|
+
return u >= e;
|
|
15739
|
+
})));
|
|
15740
|
+
}, tr = (r, e) => C(r, 0, 1), f = (r, e) => C(r, 0, 1 / 0), x = (r, e) => {
|
|
15741
|
+
let n = r.map(v);
|
|
15742
|
+
return g(_(M((a) => {
|
|
15743
|
+
for (let t5 = 0, o = n.length; t5 < o; t5++) if (!n[t5](a)) return !1;
|
|
15744
|
+
return !0;
|
|
15745
|
+
})));
|
|
15746
|
+
}, l = (r, e) => {
|
|
15747
|
+
let n = r.map(v);
|
|
15748
|
+
return g(_((a) => {
|
|
15749
|
+
for (let t5 = 0, o = n.length; t5 < o; t5++) if (n[t5](a)) return !0;
|
|
15750
|
+
return !1;
|
|
15751
|
+
}));
|
|
15752
|
+
}, M = (r, e = !1) => {
|
|
15753
|
+
let n = v(r);
|
|
15754
|
+
return (a) => {
|
|
15755
|
+
let t5 = a.index, o = a.output.length, u = n(a);
|
|
15756
|
+
return (!u || e) && (a.index = t5, a.output.length !== o && (a.output.length = o)), u;
|
|
15757
|
+
};
|
|
15758
|
+
}, _ = (r, e) => v(r), g = /* @__PURE__ */ (() => {
|
|
15759
|
+
let r = 0;
|
|
15760
|
+
return (e) => {
|
|
15761
|
+
let n = v(e), a = r += 1;
|
|
15762
|
+
return (t5) => {
|
|
15763
|
+
var o;
|
|
15764
|
+
if (t5.options.memoization === !1) return n(t5);
|
|
15765
|
+
let u = t5.index, s = (o = t5.cache)[a] || (o[a] = /* @__PURE__ */ new Map()), c = s.get(u);
|
|
15766
|
+
if (c === !1) return !1;
|
|
15767
|
+
if (W(c)) return t5.index = c, !0;
|
|
15768
|
+
if (c) return t5.index = c.index, c.output?.length && t5.output.push(...c.output), !0;
|
|
15769
|
+
{
|
|
15770
|
+
let Z = t5.output.length;
|
|
15771
|
+
if (n(t5)) {
|
|
15772
|
+
let D = t5.index, U = t5.output.length;
|
|
15773
|
+
if (U > Z) {
|
|
15774
|
+
let ee = t5.output.slice(Z, U);
|
|
15775
|
+
s.set(u, { index: D, output: ee });
|
|
15776
|
+
} else s.set(u, D);
|
|
15777
|
+
return !0;
|
|
15778
|
+
} else return s.set(u, !1), !1;
|
|
15779
|
+
}
|
|
15780
|
+
};
|
|
15781
|
+
};
|
|
15782
|
+
})(), E = (r) => {
|
|
15783
|
+
let e;
|
|
15784
|
+
return (n) => (e || (e = v(r())), e(n));
|
|
15785
|
+
}, v = Y((r) => {
|
|
15786
|
+
if (d(r)) return Q(r) ? E(r) : r;
|
|
15787
|
+
if (b(r) || X(r)) return i2(r);
|
|
15788
|
+
if (A(r)) return x(r);
|
|
15789
|
+
if (K(r)) return l(Object.values(r));
|
|
15790
|
+
throw new Error("Invalid rule");
|
|
15791
|
+
}), P = "abcdefghijklmnopqrstuvwxyz", ir = (r) => {
|
|
15792
|
+
let e = "";
|
|
15793
|
+
for (; r > 0; ) {
|
|
15794
|
+
let n = (r - 1) % 26;
|
|
15795
|
+
e = P[n] + e, r = Math.floor((r - 1) / 26);
|
|
15796
|
+
}
|
|
15797
|
+
return e;
|
|
15798
|
+
}, O = (r) => {
|
|
15799
|
+
let e = 0;
|
|
15800
|
+
for (let n = 0, a = r.length; n < a; n++) e = e * 26 + P.indexOf(r[n]) + 1;
|
|
15801
|
+
return e;
|
|
15802
|
+
}, S = (r, e) => {
|
|
15803
|
+
if (e < r) return S(e, r);
|
|
15804
|
+
let n = [];
|
|
15805
|
+
for (; r <= e; ) n.push(r++);
|
|
15806
|
+
return n;
|
|
15807
|
+
}, or = (r, e, n) => S(r, e).map((a) => String(a).padStart(n, "0")), R = (r, e) => S(O(r), O(e)).map(ir), p = (r) => r, z = (r) => ur((e) => rr(e, r, { memoization: !1 }).join("")), ur = (r) => {
|
|
15808
|
+
let e = {};
|
|
15809
|
+
return (n) => e[n] ?? (e[n] = r(n));
|
|
15810
|
+
}, sr = i2(/^\*\*\/\*$/, ".*"), cr = i2(/^\*\*\/(\*)?([ a-zA-Z0-9._-]+)$/, (r, e, n) => `.*${e ? "" : "(?:^|/)"}${n.replaceAll(".", "\\.")}`), lr = i2(/^\*\*\/(\*)?([ a-zA-Z0-9._-]*)\{([ a-zA-Z0-9._-]+(?:,[ a-zA-Z0-9._-]+)*)\}$/, (r, e, n, a) => `.*${e ? "" : "(?:^|/)"}${n.replaceAll(".", "\\.")}(?:${a.replaceAll(",", "|").replaceAll(".", "\\.")})`), y = i2(/\\./, p), pr = i2(/[$.*+?^(){}[\]\|]/, (r) => `\\${r}`), vr = i2(/./, p), hr = i2(/^(?:!!)*!(.*)$/, (r, e) => `(?!^${L(e)}$).*?`), dr = i2(/^(!!)+/, ""), fr = l([hr, dr]), xr = i2(/\/(\*\*\/)+/, "(?:/.+/|/)"), gr = i2(/^(\*\*\/)+/, "(?:^|.*/)"), mr = i2(/\/(\*\*)$/, "(?:/.*|$)"), _r = i2(/\*\*/, ".*"), j = l([xr, gr, mr, _r]), Sr = i2(/\*\/(?!\*\*\/)/, "[^/]*/"), yr = i2(/\*/, "[^/]*"), N = l([Sr, yr]), k = i2("?", "[^/]"), $r = i2("[", p), wr = i2("]", p), Ar = i2(/[!^]/, "^/"), br = i2(/[a-z]-[a-z]|[0-9]-[0-9]/i, p), Cr = i2(/[$.*+?^(){}[\|]/, (r) => `\\${r}`), Mr = i2(/[^\]]/, p), Er = l([y, Cr, br, Mr]), B = x([$r, tr(Ar), f(Er), wr]), Pr = i2("{", "(?:"), Or = i2("}", ")"), Rr = i2(/(\d+)\.\.(\d+)/, (r, e, n) => or(+e, +n, Math.min(e.length, n.length)).join("|")), zr = i2(/([a-z]+)\.\.([a-z]+)/, (r, e, n) => R(e, n).join("|")), jr = i2(/([A-Z]+)\.\.([A-Z]+)/, (r, e, n) => R(e.toLowerCase(), n.toLowerCase()).join("|").toUpperCase()), Nr = l([Rr, zr, jr]), I = x([Pr, Nr, Or]), kr = i2("{", "(?:"), Br = i2("}", ")"), Ir = i2(",", "|"), Fr = i2(/[$.*+?^(){[\]\|]/, (r) => `\\${r}`), Lr = i2(/[^}]/, p), Zr = E(() => F), Dr = l([j, N, k, B, I, Zr, y, Fr, Ir, Lr]), F = x([kr, f(Dr), Br]), Ur = f(l([sr, cr, lr, fr, j, N, k, B, I, F, y, pr, vr])), Vr = Ur, Gr = z(Vr), L = Gr, Tr = i2(/\\./, p), qr = i2(/./, p), Hr = i2(/\*\*\*+/, "*"), Jr = i2(/([^/{[(!])\*\*/, (r, e) => `${e}*`), Qr = i2(/(^|.)\*\*(?=[^*/)\]}])/, (r, e) => `${e}*`), Wr = f(l([Tr, Hr, Jr, Qr, qr])), Kr = Wr, Xr = z(Kr), Yr = Xr, $ = (r, e) => {
|
|
15811
|
+
let n = Array.isArray(r) ? r : [r];
|
|
15812
|
+
if (!n.length) return !1;
|
|
15813
|
+
let a = n.map($.compile), t5 = n.every((s) => /(\/(?:\*\*)?|\[\/\])$/.test(s)), o = e.replace(/[\\\/]+/g, "/").replace(/\/$/, t5 ? "/" : "");
|
|
15814
|
+
return a.some((s) => s.test(o));
|
|
15815
|
+
};
|
|
15816
|
+
$.compile = (r) => new RegExp(`^${L(Yr(r))}$`, "s");
|
|
15817
|
+
var re = $;
|
|
15818
|
+
return J(w);
|
|
15819
|
+
})();
|
|
15820
|
+
return __lib__.default || __lib__;
|
|
15821
|
+
}, _match, zeptomatch = (path2, pattern) => (_match || (_match = _lazyMatch(), _lazyMatch = null), _match(path2, pattern)), _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
15822
|
+
function normalizeWindowsPath(input = "") {
|
|
15823
|
+
return input && input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
15824
|
+
}
|
|
15825
|
+
var _UNC_REGEX = /^[/\\]{2}/, _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, _DRIVE_LETTER_RE = /^[A-Za-z]:$/, _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/, _EXTNAME_RE = /.(\.[^./]+|\.)$/, _PATH_ROOT_RE = /^[/\\]|^[a-zA-Z]:[/\\]/, sep2 = "/", normalize = function(path2) {
|
|
15826
|
+
if (path2.length === 0)
|
|
15827
|
+
return ".";
|
|
15828
|
+
path2 = normalizeWindowsPath(path2);
|
|
15829
|
+
let isUNCPath = path2.match(_UNC_REGEX), isPathAbsolute = isAbsolute2(path2), trailingSeparator = path2[path2.length - 1] === "/";
|
|
15830
|
+
return path2 = normalizeString(path2, !isPathAbsolute), path2.length === 0 ? isPathAbsolute ? "/" : trailingSeparator ? "./" : "." : (trailingSeparator && (path2 += "/"), _DRIVE_LETTER_RE.test(path2) && (path2 += "/"), isUNCPath ? isPathAbsolute ? `//${path2}` : `//./${path2}` : isPathAbsolute && !isAbsolute2(path2) ? `/${path2}` : path2);
|
|
15831
|
+
}, join3 = function(...segments) {
|
|
15832
|
+
let path2 = "";
|
|
15833
|
+
for (let seg of segments)
|
|
15834
|
+
if (seg)
|
|
15835
|
+
if (path2.length > 0) {
|
|
15836
|
+
let pathTrailing = path2[path2.length - 1] === "/", segLeading = seg[0] === "/";
|
|
15837
|
+
pathTrailing && segLeading ? path2 += seg.slice(1) : path2 += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
15838
|
+
} else
|
|
15839
|
+
path2 += seg;
|
|
15840
|
+
return normalize(path2);
|
|
16161
15841
|
};
|
|
16162
|
-
function
|
|
16163
|
-
|
|
16164
|
-
if (!typescript.isExpressionStatement(statement))
|
|
16165
|
-
continue;
|
|
16166
|
-
let expr = statement.expression;
|
|
16167
|
-
if (typescript.isBinaryExpression(expr) && expr.operatorToken.kind === typescript.SyntaxKind.EqualsToken && typescript.isPropertyAccessExpression(expr.left) && expr.left.name.text === "displayName" && typescript.isIdentifier(expr.left.expression) && expr.left.expression.text === identifierName && typescript.isStringLiteral(expr.right))
|
|
16168
|
-
return expr.right.text;
|
|
16169
|
-
}
|
|
15842
|
+
function cwd() {
|
|
15843
|
+
return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
|
|
16170
15844
|
}
|
|
16171
|
-
|
|
16172
|
-
|
|
16173
|
-
|
|
16174
|
-
|
|
16175
|
-
|
|
16176
|
-
|
|
16177
|
-
|
|
16178
|
-
|
|
16179
|
-
|
|
16180
|
-
|
|
16181
|
-
|
|
16182
|
-
|
|
16183
|
-
|
|
16184
|
-
|
|
16185
|
-
|
|
16186
|
-
|
|
16187
|
-
|
|
16188
|
-
|
|
16189
|
-
let displayNameValue = findDisplayNameAssignment(typescript, sourceFile, resolvedName);
|
|
16190
|
-
displayNameValue && result.set(displayNameValue, exportName);
|
|
15845
|
+
var resolve3 = function(...arguments_) {
|
|
15846
|
+
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
15847
|
+
let resolvedPath = "", resolvedAbsolute = !1;
|
|
15848
|
+
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
15849
|
+
let path2 = index >= 0 ? arguments_[index] : cwd();
|
|
15850
|
+
!path2 || path2.length === 0 || (resolvedPath = `${path2}/${resolvedPath}`, resolvedAbsolute = isAbsolute2(path2));
|
|
15851
|
+
}
|
|
15852
|
+
return resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute), resolvedAbsolute && !isAbsolute2(resolvedPath) ? `/${resolvedPath}` : resolvedPath.length > 0 ? resolvedPath : ".";
|
|
15853
|
+
};
|
|
15854
|
+
function normalizeString(path2, allowAboveRoot) {
|
|
15855
|
+
let res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, char = null;
|
|
15856
|
+
for (let index = 0; index <= path2.length; ++index) {
|
|
15857
|
+
if (index < path2.length)
|
|
15858
|
+
char = path2[index];
|
|
15859
|
+
else {
|
|
15860
|
+
if (char === "/")
|
|
15861
|
+
break;
|
|
15862
|
+
char = "/";
|
|
16191
15863
|
}
|
|
15864
|
+
if (char === "/") {
|
|
15865
|
+
if (!(lastSlash === index - 1 || dots === 1)) if (dots === 2) {
|
|
15866
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
15867
|
+
if (res.length > 2) {
|
|
15868
|
+
let lastSlashIndex = res.lastIndexOf("/");
|
|
15869
|
+
lastSlashIndex === -1 ? (res = "", lastSegmentLength = 0) : (res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/")), lastSlash = index, dots = 0;
|
|
15870
|
+
continue;
|
|
15871
|
+
} else if (res.length > 0) {
|
|
15872
|
+
res = "", lastSegmentLength = 0, lastSlash = index, dots = 0;
|
|
15873
|
+
continue;
|
|
15874
|
+
}
|
|
15875
|
+
}
|
|
15876
|
+
allowAboveRoot && (res += res.length > 0 ? "/.." : "..", lastSegmentLength = 2);
|
|
15877
|
+
} else
|
|
15878
|
+
res.length > 0 ? res += `/${path2.slice(lastSlash + 1, index)}` : res = path2.slice(lastSlash + 1, index), lastSegmentLength = index - lastSlash - 1;
|
|
15879
|
+
lastSlash = index, dots = 0;
|
|
15880
|
+
} else char === "." && dots !== -1 ? ++dots : dots = -1;
|
|
16192
15881
|
}
|
|
16193
|
-
return
|
|
16194
|
-
}
|
|
16195
|
-
var cachedCompilerOptions, cachedFileNames, previousProgram, parser, cachedParserOptionsKey;
|
|
16196
|
-
function invalidateParser() {
|
|
16197
|
-
parser = void 0, cachedCompilerOptions = void 0, cachedFileNames = void 0, cachedParserOptionsKey = void 0;
|
|
15882
|
+
return res;
|
|
16198
15883
|
}
|
|
16199
|
-
|
|
16200
|
-
|
|
16201
|
-
|
|
16202
|
-
|
|
16203
|
-
|
|
16204
|
-
if (
|
|
16205
|
-
|
|
16206
|
-
|
|
16207
|
-
|
|
16208
|
-
|
|
16209
|
-
|
|
16210
|
-
|
|
16211
|
-
|
|
16212
|
-
|
|
16213
|
-
|
|
16214
|
-
|
|
16215
|
-
|
|
16216
|
-
);
|
|
16217
|
-
let program = typescript.createProgram(
|
|
16218
|
-
cachedFileNames ?? [],
|
|
16219
|
-
cachedCompilerOptions,
|
|
16220
|
-
void 0,
|
|
16221
|
-
previousProgram
|
|
16222
|
-
);
|
|
16223
|
-
previousProgram = program;
|
|
16224
|
-
let parserOptions = {
|
|
16225
|
-
shouldExtractLiteralValuesFromEnum: !0,
|
|
16226
|
-
shouldRemoveUndefinedFromOptional: !0,
|
|
16227
|
-
...userOptions,
|
|
16228
|
-
// Always force savePropValueAsString so default values are in a consistent format
|
|
16229
|
-
savePropValueAsString: !0
|
|
16230
|
-
};
|
|
16231
|
-
parser = {
|
|
16232
|
-
program,
|
|
16233
|
-
fileParser: reactDocgenTypescript.withCompilerOptions(cachedCompilerOptions, parserOptions)
|
|
16234
|
-
}, cachedParserOptionsKey = optionsKey;
|
|
15884
|
+
var isAbsolute2 = function(p) {
|
|
15885
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
15886
|
+
}, toNamespacedPath = function(p) {
|
|
15887
|
+
return normalizeWindowsPath(p);
|
|
15888
|
+
}, extname = function(p) {
|
|
15889
|
+
if (p === "..") return "";
|
|
15890
|
+
let match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
|
15891
|
+
return match && match[1] || "";
|
|
15892
|
+
}, relative = function(from, to) {
|
|
15893
|
+
let _from = resolve3(from).replace(_ROOT_FOLDER_RE, "$1").split("/"), _to = resolve3(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
15894
|
+
if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0])
|
|
15895
|
+
return _to.join("/");
|
|
15896
|
+
let _fromCopy = [..._from];
|
|
15897
|
+
for (let segment of _fromCopy) {
|
|
15898
|
+
if (_to[0] !== segment)
|
|
15899
|
+
break;
|
|
15900
|
+
_from.shift(), _to.shift();
|
|
16235
15901
|
}
|
|
16236
|
-
return
|
|
16237
|
-
}
|
|
16238
|
-
|
|
16239
|
-
|
|
16240
|
-
|
|
16241
|
-
|
|
16242
|
-
|
|
16243
|
-
|
|
16244
|
-
|
|
16245
|
-
|
|
16246
|
-
|
|
16247
|
-
}
|
|
16248
|
-
|
|
16249
|
-
|
|
16250
|
-
|
|
16251
|
-
|
|
16252
|
-
|
|
16253
|
-
|
|
16254
|
-
|
|
16255
|
-
|
|
16256
|
-
|
|
16257
|
-
|
|
16258
|
-
|
|
16259
|
-
|
|
16260
|
-
|
|
16261
|
-
|
|
16262
|
-
|
|
16263
|
-
|
|
16264
|
-
|
|
16265
|
-
`Looked for: componentName=${componentName}, localImportName=${localImportName ?? "<none>"}, importName=${importName ?? "<none>"}.`
|
|
16266
|
-
].join(`
|
|
16267
|
-
`)
|
|
15902
|
+
return [..._from.map(() => ".."), ..._to].join("/");
|
|
15903
|
+
}, dirname4 = function(p) {
|
|
15904
|
+
let segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
15905
|
+
return segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0]) && (segments[0] += "/"), segments.join("/") || (isAbsolute2(p) ? "/" : ".");
|
|
15906
|
+
}, format = function(p) {
|
|
15907
|
+
let ext = p.ext ? p.ext.startsWith(".") ? p.ext : `.${p.ext}` : "", segments = [p.root, p.dir, p.base ?? (p.name ?? "") + ext].filter(
|
|
15908
|
+
Boolean
|
|
15909
|
+
);
|
|
15910
|
+
return normalizeWindowsPath(
|
|
15911
|
+
p.root ? resolve3(...segments) : segments.join("/")
|
|
15912
|
+
);
|
|
15913
|
+
}, basename = function(p, extension) {
|
|
15914
|
+
let segments = normalizeWindowsPath(p).split("/"), lastSegment = "";
|
|
15915
|
+
for (let i2 = segments.length - 1; i2 >= 0; i2--) {
|
|
15916
|
+
let val = segments[i2];
|
|
15917
|
+
if (val) {
|
|
15918
|
+
lastSegment = val;
|
|
15919
|
+
break;
|
|
15920
|
+
}
|
|
15921
|
+
}
|
|
15922
|
+
return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
|
|
15923
|
+
}, parse6 = function(p) {
|
|
15924
|
+
let root = _PATH_ROOT_RE.exec(p)?.[0]?.replace(/\\/g, "/") || "", base2 = basename(p), extension = extname(base2);
|
|
15925
|
+
return {
|
|
15926
|
+
root,
|
|
15927
|
+
dir: dirname4(p),
|
|
15928
|
+
base: base2,
|
|
15929
|
+
ext: extension,
|
|
15930
|
+
name: base2.slice(0, base2.length - extension.length)
|
|
16268
15931
|
};
|
|
16269
|
-
}
|
|
16270
|
-
|
|
16271
|
-
|
|
16272
|
-
|
|
16273
|
-
|
|
16274
|
-
|
|
16275
|
-
|
|
16276
|
-
|
|
16277
|
-
|
|
16278
|
-
|
|
16279
|
-
|
|
16280
|
-
|
|
16281
|
-
|
|
16282
|
-
|
|
16283
|
-
|
|
16284
|
-
|
|
16285
|
-
|
|
16286
|
-
|
|
16287
|
-
|
|
16288
|
-
|
|
16289
|
-
|
|
16290
|
-
|
|
16291
|
-
|
|
15932
|
+
}, matchesGlob = (path2, pattern) => zeptomatch(pattern, normalize(path2)), _path = {
|
|
15933
|
+
__proto__: null,
|
|
15934
|
+
basename,
|
|
15935
|
+
dirname: dirname4,
|
|
15936
|
+
extname,
|
|
15937
|
+
format,
|
|
15938
|
+
isAbsolute: isAbsolute2,
|
|
15939
|
+
join: join3,
|
|
15940
|
+
matchesGlob,
|
|
15941
|
+
normalize,
|
|
15942
|
+
normalizeString,
|
|
15943
|
+
parse: parse6,
|
|
15944
|
+
relative,
|
|
15945
|
+
resolve: resolve3,
|
|
15946
|
+
sep: sep2,
|
|
15947
|
+
toNamespacedPath
|
|
15948
|
+
};
|
|
15949
|
+
|
|
15950
|
+
// ../../../node_modules/pathe/dist/index.mjs
|
|
15951
|
+
var delimiter = globalThis.process?.platform === "win32" ? ";" : ":", _platforms = { posix: void 0, win32: void 0 }, mix = (del = delimiter) => new Proxy(_path, {
|
|
15952
|
+
get(_, prop) {
|
|
15953
|
+
return prop === "delimiter" ? del : prop === "posix" ? posix : prop === "win32" ? win32 : _platforms[prop] || _path[prop];
|
|
15954
|
+
}
|
|
15955
|
+
}), posix = mix(":"), win32 = mix(";");
|
|
16292
15956
|
|
|
16293
15957
|
// src/componentManifest/generateCodeSnippet.ts
|
|
16294
15958
|
import { types as t2 } from "storybook/internal/babel";
|
|
15959
|
+
import {
|
|
15960
|
+
argsRecordFromObjectPath,
|
|
15961
|
+
keyOf,
|
|
15962
|
+
metaObjectPath,
|
|
15963
|
+
mergeArgsRecords,
|
|
15964
|
+
metaArgsRecord,
|
|
15965
|
+
normalizeStoryDeclaration,
|
|
15966
|
+
resolveRenderFunction,
|
|
15967
|
+
storyAssignedArgsPath
|
|
15968
|
+
} from "storybook/internal/csf-tools";
|
|
16295
15969
|
function getCodeSnippet(csf, storyName, componentName) {
|
|
16296
15970
|
let storyDeclaration = csf._storyDeclarationPath[storyName], metaObj = csf._metaNode;
|
|
16297
15971
|
if (!storyDeclaration) {
|
|
16298
15972
|
let message = "Expected story to be a function or variable declaration";
|
|
16299
15973
|
throw csf._storyPaths[storyName]?.buildCodeFrameError(message) ?? message;
|
|
16300
15974
|
}
|
|
16301
|
-
let
|
|
16302
|
-
|
|
16303
|
-
|
|
16304
|
-
else if (storyDeclaration.isVariableDeclarator()) {
|
|
16305
|
-
let init = storyDeclaration.get("init");
|
|
16306
|
-
invariant(
|
|
16307
|
-
init.isExpression(),
|
|
16308
|
-
() => storyDeclaration.buildCodeFrameError("Expected story initializer to be an expression").message
|
|
16309
|
-
), storyPath = init;
|
|
16310
|
-
} else
|
|
16311
|
-
throw storyDeclaration.buildCodeFrameError(
|
|
16312
|
-
"Expected story to be a function or variable declaration"
|
|
16313
|
-
);
|
|
16314
|
-
let normalizedPath = storyPath;
|
|
16315
|
-
if (storyPath.isCallExpression()) {
|
|
16316
|
-
let callee = storyPath.get("callee");
|
|
16317
|
-
if (callee.isMemberExpression()) {
|
|
16318
|
-
let obj = callee.get("object"), prop = callee.get("property"), isBind = prop.isIdentifier() && prop.node.name === "bind" || t2.isStringLiteral(prop.node) && prop.node.value === "bind";
|
|
16319
|
-
if (obj.isIdentifier() && isBind) {
|
|
16320
|
-
let resolved = resolveIdentifierInit(storyDeclaration, obj);
|
|
16321
|
-
resolved && (normalizedPath = resolved);
|
|
16322
|
-
}
|
|
16323
|
-
}
|
|
16324
|
-
if (storyPath === normalizedPath) {
|
|
16325
|
-
let args = storyPath.get("arguments");
|
|
16326
|
-
if (args.length !== 0) {
|
|
16327
|
-
invariant(
|
|
16328
|
-
args.length === 1,
|
|
16329
|
-
() => storyPath.buildCodeFrameError("Could not evaluate story expression").message
|
|
16330
|
-
);
|
|
16331
|
-
let storyArg = args[0];
|
|
16332
|
-
invariant(
|
|
16333
|
-
storyArg.isExpression(),
|
|
16334
|
-
() => storyPath.buildCodeFrameError("Could not evaluate story expression").message
|
|
16335
|
-
), normalizedPath = storyArg;
|
|
16336
|
-
}
|
|
16337
|
-
}
|
|
16338
|
-
}
|
|
16339
|
-
normalizedPath = normalizedPath.isTSSatisfiesExpression() || normalizedPath.isTSAsExpression() ? normalizedPath.get("expression") : normalizedPath;
|
|
16340
|
-
let storyFn;
|
|
16341
|
-
if (normalizedPath.isArrowFunctionExpression() || normalizedPath.isFunctionExpression() || normalizedPath.isFunctionDeclaration())
|
|
16342
|
-
storyFn = normalizedPath;
|
|
16343
|
-
else if (!normalizedPath.isObjectExpression() && !(normalizedPath.isCallExpression() && Array.isArray(normalizedPath.node.arguments) && normalizedPath.node.arguments.length === 0))
|
|
16344
|
-
throw normalizedPath.buildCodeFrameError(
|
|
16345
|
-
"Expected story to be csf factory, function or an object expression"
|
|
16346
|
-
);
|
|
16347
|
-
let storyProps = normalizedPath.isObjectExpression() ? normalizedPath.get("properties").filter((p) => p.isObjectProperty()) : [], metaPath = pathForNode(csf._file.path, metaObj), metaProps = metaPath?.isObjectExpression() ? metaPath.get("properties").filter((p) => p.isObjectProperty()) : [], getRenderPath = (object) => {
|
|
16348
|
-
let renderPath = object.find((p) => keyOf(p.node) === "render")?.get("value");
|
|
16349
|
-
if (!renderPath)
|
|
16350
|
-
return { kind: "missing" };
|
|
16351
|
-
if (renderPath.isIdentifier()) {
|
|
16352
|
-
let resolved = resolveIdentifierInit(storyDeclaration, renderPath);
|
|
16353
|
-
return resolved && (resolved.isArrowFunctionExpression() || resolved.isFunctionExpression() || resolved.isFunctionDeclaration()) ? { kind: "resolved", path: resolved } : { kind: "unresolved" };
|
|
16354
|
-
}
|
|
16355
|
-
if (!(renderPath.isArrowFunctionExpression() || renderPath.isFunctionExpression()))
|
|
16356
|
-
throw renderPath.buildCodeFrameError(
|
|
16357
|
-
"Expected render to be an arrow function or function expression"
|
|
16358
|
-
);
|
|
16359
|
-
return { kind: "resolved", path: renderPath };
|
|
16360
|
-
}, metaRender = getRenderPath(metaProps), storyRender = getRenderPath(storyProps);
|
|
15975
|
+
let normalizedStory = normalizeStoryDeclaration(storyDeclaration), storyFn;
|
|
15976
|
+
normalizedStory.type === "fn" && (storyFn = normalizedStory.path);
|
|
15977
|
+
let storyProps = normalizedStory.type === "config" ? normalizedStory.path.get("properties").filter((p) => p.isObjectProperty()) : [], metaProps = metaObjectPath(csf)?.get("properties").filter((p) => p.isObjectProperty()) ?? [], metaRender = resolveRenderFunction(metaProps, storyDeclaration), storyRender = resolveRenderFunction(storyProps, storyDeclaration);
|
|
16361
15978
|
storyFn || (storyFn = storyRender.kind === "resolved" ? storyRender.path : storyRender.kind === "missing" && metaRender.kind === "resolved" ? metaRender.path : void 0);
|
|
16362
|
-
let metaArgs = metaArgsRecord(metaObj ?? null), storyArgsPath = storyProps.filter((p) => keyOf(p.node) === "args").map((p) => p.get("value")).find((v) => v.isObjectExpression()), storyArgs = argsRecordFromObjectPath(storyArgsPath),
|
|
15979
|
+
let metaArgs = metaArgsRecord(metaObj ?? null), storyArgsPath = storyProps.filter((p) => keyOf(p.node) === "args").map((p) => p.get("value")).find((v) => v.isObjectExpression()), storyArgs = argsRecordFromObjectPath(storyArgsPath), assignedArgsPath = storyAssignedArgsPath(csf._file.path, storyName), storyAssignedArgs = argsRecordFromObjectPath(assignedArgsPath), merged = {
|
|
15980
|
+
...mergeArgsRecords(metaArgs, storyArgs),
|
|
15981
|
+
...storyAssignedArgs
|
|
15982
|
+
}, entries = Object.entries(merged).filter(([k]) => k !== "children"), validEntries = entries.filter(([k, v]) => isValidJsxAttrName(k) && v != null), invalidEntries = entries.filter(([k, v]) => !isValidJsxAttrName(k) && v != null), injectedAttrs = validEntries.map(([k, v]) => toAttr(k, v)).filter((a) => a != null);
|
|
16363
15983
|
if (storyFn) {
|
|
16364
15984
|
let fn = storyFn.node;
|
|
16365
15985
|
if (t2.isArrowFunctionExpression(fn) && (t2.isJSXElement(fn.body) || t2.isJSXFragment(fn.body))) {
|
|
@@ -16417,31 +16037,7 @@ function buildInvalidSpread(entries) {
|
|
|
16417
16037
|
);
|
|
16418
16038
|
return t2.jsxSpreadAttribute(t2.objectExpression(objectProps));
|
|
16419
16039
|
}
|
|
16420
|
-
var
|
|
16421
|
-
objPath.get("properties").filter((p) => p.isObjectProperty()).map((p) => [keyOf(p.node), p.get("value").node]).filter((e) => !!e[0])
|
|
16422
|
-
) : {};
|
|
16423
|
-
function storyArgsAssignmentPath(program, storyName) {
|
|
16424
|
-
let found = null;
|
|
16425
|
-
return program.traverse({
|
|
16426
|
-
AssignmentExpression(p) {
|
|
16427
|
-
let left = p.get("left"), right = p.get("right");
|
|
16428
|
-
if (left.isMemberExpression()) {
|
|
16429
|
-
let obj = left.get("object"), prop = left.get("property"), isStoryIdent = obj.isIdentifier() && obj.node.name === storyName, isArgsProp = prop.isIdentifier() && prop.node.name === "args" && !left.node.computed || t2.isStringLiteral(prop.node) && left.node.computed && prop.node.value === "args";
|
|
16430
|
-
isStoryIdent && isArgsProp && right.isObjectExpression() && (found = right);
|
|
16431
|
-
}
|
|
16432
|
-
}
|
|
16433
|
-
}), found;
|
|
16434
|
-
}
|
|
16435
|
-
var argsRecordFromObjectNode = (obj) => obj ? Object.fromEntries(
|
|
16436
|
-
obj.properties.filter((p) => t2.isObjectProperty(p)).map((p) => [keyOf(p), p.value]).filter((e) => !!e[0])
|
|
16437
|
-
) : {}, metaArgsRecord = (meta) => {
|
|
16438
|
-
if (!meta)
|
|
16439
|
-
return {};
|
|
16440
|
-
let argsProp = meta.properties.find(
|
|
16441
|
-
(p) => t2.isObjectProperty(p) && keyOf(p) === "args"
|
|
16442
|
-
);
|
|
16443
|
-
return argsProp && t2.isObjectExpression(argsProp.value) ? argsRecordFromObjectNode(argsProp.value) : {};
|
|
16444
|
-
}, toAttr = (key, value) => t2.isBooleanLiteral(value) ? value.value ? t2.jsxAttribute(t2.jsxIdentifier(key), null) : t2.jsxAttribute(t2.jsxIdentifier(key), t2.jsxExpressionContainer(value)) : t2.isStringLiteral(value) ? t2.jsxAttribute(t2.jsxIdentifier(key), t2.stringLiteral(value.value)) : t2.isExpression(value) ? t2.jsxAttribute(t2.jsxIdentifier(key), t2.jsxExpressionContainer(value)) : null, toJsxChildren = (node) => node ? t2.isStringLiteral(node) ? [t2.jsxText(node.value)] : t2.isJSXElement(node) || t2.isJSXFragment(node) ? [node] : t2.isExpression(node) ? [t2.jsxExpressionContainer(node)] : [] : [];
|
|
16040
|
+
var isValidJsxAttrName = (n) => /^[A-Za-z_][A-Za-z0-9_:-]*$/.test(n), toAttr = (key, value) => t2.isBooleanLiteral(value) ? value.value ? t2.jsxAttribute(t2.jsxIdentifier(key), null) : t2.jsxAttribute(t2.jsxIdentifier(key), t2.jsxExpressionContainer(value)) : t2.isStringLiteral(value) ? t2.jsxAttribute(t2.jsxIdentifier(key), t2.stringLiteral(value.value)) : t2.isExpression(value) ? t2.jsxAttribute(t2.jsxIdentifier(key), t2.jsxExpressionContainer(value)) : null, toJsxChildren = (node) => node ? t2.isStringLiteral(node) ? [t2.jsxText(node.value)] : t2.isJSXElement(node) || t2.isJSXFragment(node) ? [node] : t2.isExpression(node) ? [t2.jsxExpressionContainer(node)] : [] : [];
|
|
16445
16041
|
function getArgsMemberKey(expr) {
|
|
16446
16042
|
if (t2.isMemberExpression(expr) && t2.isIdentifier(expr.object) && expr.object.name === "args") {
|
|
16447
16043
|
if (t2.isIdentifier(expr.property) && !expr.computed)
|
|
@@ -16539,67 +16135,234 @@ function transformArgsSpreadsInJsx(node, merged) {
|
|
|
16539
16135
|
});
|
|
16540
16136
|
return { node: t2.jsxFragment(node.openingFragment, node.closingFragment, fragChildren), changed };
|
|
16541
16137
|
}
|
|
16542
|
-
|
|
16543
|
-
|
|
16544
|
-
|
|
16545
|
-
|
|
16546
|
-
|
|
16547
|
-
|
|
16548
|
-
|
|
16549
|
-
|
|
16550
|
-
|
|
16551
|
-
if (decl.isFunctionDeclaration() && decl.node.id?.name === identifier.node.name)
|
|
16552
|
-
return decl;
|
|
16553
|
-
}
|
|
16138
|
+
|
|
16139
|
+
// src/componentManifest/reactDocgenTypescript.ts
|
|
16140
|
+
import { dirname as dirname5, join as join4, resolve as resolve4 } from "node:path";
|
|
16141
|
+
import { logger as logger4 } from "storybook/internal/node-logger";
|
|
16142
|
+
var typeScriptPromise, reactDocgenTypescriptPromise, loadTypeScript = () => typeScriptPromise ??= import("typescript"), loadReactDocgenTypescript = () => reactDocgenTypescriptPromise ??= import("react-docgen-typescript"), LARGE_NON_USER_SOURCE_THRESHOLD = 30, getPropSource = (prop) => prop.parent?.fileName ?? prop.declarations?.[0]?.fileName, getLargeNonUserPropSources = (props) => {
|
|
16143
|
+
let countBySource = /* @__PURE__ */ new Map();
|
|
16144
|
+
for (let prop of Object.values(props)) {
|
|
16145
|
+
let source = getPropSource(prop);
|
|
16146
|
+
(source?.includes("node_modules") || source?.endsWith(".d.ts")) && countBySource.set(source, (countBySource.get(source) ?? 0) + 1);
|
|
16554
16147
|
}
|
|
16555
|
-
let
|
|
16556
|
-
|
|
16557
|
-
|
|
16558
|
-
|
|
16559
|
-
|
|
16560
|
-
|
|
16561
|
-
|
|
16148
|
+
let largeNonUserSources = /* @__PURE__ */ new Set();
|
|
16149
|
+
for (let [source, count] of countBySource)
|
|
16150
|
+
count > LARGE_NON_USER_SOURCE_THRESHOLD && largeNonUserSources.add(source);
|
|
16151
|
+
return largeNonUserSources;
|
|
16152
|
+
};
|
|
16153
|
+
function findDisplayNameAssignment(typescript, sourceFile, identifierName) {
|
|
16154
|
+
for (let statement of sourceFile.statements) {
|
|
16155
|
+
if (!typescript.isExpressionStatement(statement))
|
|
16156
|
+
continue;
|
|
16157
|
+
let expr = statement.expression;
|
|
16158
|
+
if (typescript.isBinaryExpression(expr) && expr.operatorToken.kind === typescript.SyntaxKind.EqualsToken && typescript.isPropertyAccessExpression(expr.left) && expr.left.name.text === "displayName" && typescript.isIdentifier(expr.left.expression) && expr.left.expression.text === identifierName && typescript.isStringLiteral(expr.right))
|
|
16159
|
+
return expr.right.text;
|
|
16160
|
+
}
|
|
16161
|
+
}
|
|
16162
|
+
function getExportNameMap(typescript, checker, sourceFile) {
|
|
16163
|
+
let moduleSymbol = checker.getSymbolAtLocation(sourceFile);
|
|
16164
|
+
if (!moduleSymbol)
|
|
16165
|
+
return /* @__PURE__ */ new Map();
|
|
16166
|
+
let result = /* @__PURE__ */ new Map(), fileName = sourceFile.fileName.replace(/.*\//, "").replace(/\.[^.]+$/, "");
|
|
16167
|
+
for (let exportSymbol of checker.getExportsOfModule(moduleSymbol)) {
|
|
16168
|
+
let resolved = exportSymbol.flags & typescript.SymbolFlags.Alias ? checker.getAliasedSymbol(exportSymbol) : exportSymbol, declaration = resolved.valueDeclaration ?? resolved.getDeclarations()?.[0];
|
|
16169
|
+
if (!declaration)
|
|
16170
|
+
continue;
|
|
16171
|
+
let type = checker.getTypeOfSymbolAtLocation(resolved, declaration), isStateless = type.getCallSignatures().some((sig) => {
|
|
16172
|
+
let params = sig.getParameters();
|
|
16173
|
+
return params.length === 1 || params.length > 0 && params[0].getName() === "props";
|
|
16174
|
+
}), isStateful = type.getConstructSignatures().some(
|
|
16175
|
+
(sig) => sig.getReturnType().getProperty("props") !== void 0
|
|
16176
|
+
);
|
|
16177
|
+
if (isStateless || isStateful) {
|
|
16178
|
+
let exportName = exportSymbol.getName(), resolvedName = resolved.getName();
|
|
16179
|
+
result.set(resolvedName, exportName), exportName === "default" && result.set(fileName, "default");
|
|
16180
|
+
let displayNameValue = findDisplayNameAssignment(typescript, sourceFile, resolvedName);
|
|
16181
|
+
displayNameValue && result.set(displayNameValue, exportName);
|
|
16562
16182
|
}
|
|
16563
|
-
|
|
16564
|
-
|
|
16565
|
-
|
|
16566
|
-
|
|
16567
|
-
|
|
16568
|
-
|
|
16569
|
-
return null;
|
|
16570
|
-
let init = match.get("init");
|
|
16571
|
-
return init && init.isExpression() ? init : null;
|
|
16183
|
+
}
|
|
16184
|
+
return result;
|
|
16185
|
+
}
|
|
16186
|
+
var previousProgramsByConfigKey = /* @__PURE__ */ new Map(), parserCache = /* @__PURE__ */ new Map(), parserBuilds = /* @__PURE__ */ new Map();
|
|
16187
|
+
function invalidateParser() {
|
|
16188
|
+
parserCache = /* @__PURE__ */ new Map(), parserBuilds = /* @__PURE__ */ new Map(), previousProgramsByConfigKey.clear();
|
|
16572
16189
|
}
|
|
16573
|
-
function
|
|
16574
|
-
|
|
16190
|
+
async function getParser(filePath, userOptions) {
|
|
16191
|
+
let [typescript, reactDocgenTypescript] = await Promise.all([
|
|
16192
|
+
loadTypeScript(),
|
|
16193
|
+
loadReactDocgenTypescript()
|
|
16194
|
+
]), optionsKey = JSON.stringify(userOptions ?? {}), configPath = findOwningTsconfigPath(typescript, process.cwd(), filePath) ?? findTsconfigPath(process.cwd()), configKey = configPath ?? "<no-tsconfig>", parserKey = `${configKey}::${optionsKey}`, cachedParser = parserCache.get(parserKey);
|
|
16195
|
+
if (cachedParser)
|
|
16196
|
+
return { ...cachedParser, typescript };
|
|
16197
|
+
let pendingParser = parserBuilds.get(parserKey);
|
|
16198
|
+
if (pendingParser)
|
|
16199
|
+
return { ...await pendingParser, typescript };
|
|
16200
|
+
let buildParser = (async () => {
|
|
16201
|
+
let compilerOptions = { noErrorTruncation: !0, strict: !0 }, fileNames = [];
|
|
16202
|
+
if (configPath) {
|
|
16203
|
+
let parsed = parseTsconfig(typescript, configPath);
|
|
16204
|
+
compilerOptions = { ...parsed.options, noErrorTruncation: !0 }, fileNames = parsed.fileNames;
|
|
16205
|
+
} else
|
|
16206
|
+
logger4.warn(
|
|
16207
|
+
"No tsconfig.json (or tsconfig.base.json / tsconfig.app.json) found. TypeScript component props will not be documented by react-docgen-typescript. Create a tsconfig.json in your project root to enable automatic controls."
|
|
16208
|
+
);
|
|
16209
|
+
let program = typescript.createProgram(
|
|
16210
|
+
fileNames,
|
|
16211
|
+
compilerOptions,
|
|
16212
|
+
void 0,
|
|
16213
|
+
previousProgramsByConfigKey.get(configKey)
|
|
16214
|
+
);
|
|
16215
|
+
previousProgramsByConfigKey.set(configKey, program);
|
|
16216
|
+
let parserOptions = {
|
|
16217
|
+
shouldExtractLiteralValuesFromEnum: !0,
|
|
16218
|
+
shouldRemoveUndefinedFromOptional: !0,
|
|
16219
|
+
...userOptions,
|
|
16220
|
+
// Always force savePropValueAsString so default values are in a consistent format
|
|
16221
|
+
savePropValueAsString: !0
|
|
16222
|
+
}, state = {
|
|
16223
|
+
program,
|
|
16224
|
+
fileParser: reactDocgenTypescript.withCompilerOptions(compilerOptions, parserOptions)
|
|
16225
|
+
};
|
|
16226
|
+
return parserCache.set(parserKey, state), state;
|
|
16227
|
+
})();
|
|
16228
|
+
parserBuilds.set(parserKey, buildParser);
|
|
16229
|
+
try {
|
|
16230
|
+
return { ...await buildParser, typescript };
|
|
16231
|
+
} finally {
|
|
16232
|
+
parserBuilds.delete(parserKey);
|
|
16233
|
+
}
|
|
16234
|
+
}
|
|
16235
|
+
function matchComponentDoc(docs, {
|
|
16236
|
+
importName,
|
|
16237
|
+
localImportName,
|
|
16238
|
+
componentName
|
|
16239
|
+
}) {
|
|
16240
|
+
if (docs.length !== 0)
|
|
16241
|
+
return docs.length === 1 ? docs[0] : docs.find(
|
|
16242
|
+
(doc) => doc.exportName === importName || doc.exportName === localImportName || doc.displayName === importName || doc.displayName === localImportName || doc.displayName === componentName
|
|
16243
|
+
);
|
|
16244
|
+
}
|
|
16245
|
+
function getReactDocgenTypescriptError(path2, {
|
|
16246
|
+
importName,
|
|
16247
|
+
localImportName,
|
|
16248
|
+
componentName
|
|
16249
|
+
}, docs) {
|
|
16250
|
+
return docs.length === 0 ? {
|
|
16251
|
+
name: "react-docgen-typescript found no component docs",
|
|
16252
|
+
message: [
|
|
16253
|
+
`File: ${path2}`,
|
|
16254
|
+
"react-docgen-typescript did not return any component docs for this file."
|
|
16255
|
+
].join(`
|
|
16256
|
+
`)
|
|
16257
|
+
} : {
|
|
16258
|
+
name: "react-docgen-typescript could not match component docs",
|
|
16259
|
+
message: [
|
|
16260
|
+
`File: ${path2}`,
|
|
16261
|
+
"react-docgen-typescript returned component docs for this file, but none matched the story's component import.",
|
|
16262
|
+
`Looked for: componentName=${componentName}, localImportName=${localImportName ?? "<none>"}, importName=${importName ?? "<none>"}.`
|
|
16263
|
+
].join(`
|
|
16264
|
+
`)
|
|
16265
|
+
};
|
|
16266
|
+
}
|
|
16267
|
+
var parseWithReactDocgenTypescript = asyncCache(
|
|
16268
|
+
async (filePath, userOptions) => {
|
|
16269
|
+
let { program, fileParser, typescript } = await getParser(filePath, userOptions), checker = program.getTypeChecker(), sourceFile = program.getSourceFile(filePath), docs = fileParser.parseWithProgramProvider(filePath, () => program), exportNameMap = sourceFile ? getExportNameMap(typescript, checker, sourceFile) : /* @__PURE__ */ new Map();
|
|
16270
|
+
return docs.map((doc) => {
|
|
16271
|
+
let largeNonUserSources = getLargeNonUserPropSources(doc.props);
|
|
16272
|
+
return {
|
|
16273
|
+
...doc,
|
|
16274
|
+
// Use name-based lookup: displayName is the resolved symbol name, so look it up in the
|
|
16275
|
+
// export map to get the public export name. Falls back to displayName when not aliased.
|
|
16276
|
+
exportName: exportNameMap.get(doc.displayName) ?? doc.displayName,
|
|
16277
|
+
// Filter out bulk props from non-user sources (React built-ins, DOM, CSS-in-JS system props)
|
|
16278
|
+
props: Object.fromEntries(
|
|
16279
|
+
Object.entries(doc.props).filter(([, prop]) => {
|
|
16280
|
+
let source = getPropSource(prop);
|
|
16281
|
+
return !source || !largeNonUserSources.has(source);
|
|
16282
|
+
})
|
|
16283
|
+
)
|
|
16284
|
+
};
|
|
16285
|
+
});
|
|
16286
|
+
},
|
|
16287
|
+
{ name: "parseWithReactDocgenTypescript" }
|
|
16288
|
+
), findOwningTsconfigPath = cached(
|
|
16289
|
+
(typescript, cwd2, filePath) => {
|
|
16290
|
+
let configPath = findTsconfigPath(cwd2);
|
|
16291
|
+
if (configPath)
|
|
16292
|
+
return findTsconfigPathIncludingFile(typescript, configPath, filePath, /* @__PURE__ */ new Set()) ?? configPath;
|
|
16293
|
+
},
|
|
16294
|
+
{
|
|
16295
|
+
key: (typescript, cwd2, filePath) => `${normalizeFileName(typescript, resolve4(cwd2))}::${normalizeFileName(
|
|
16296
|
+
typescript,
|
|
16297
|
+
resolve4(filePath)
|
|
16298
|
+
)}`,
|
|
16299
|
+
name: "findOwningTsconfigPath"
|
|
16300
|
+
}
|
|
16301
|
+
);
|
|
16302
|
+
function findTsconfigPathIncludingFile(typescript, configPath, filePath, seenConfigPaths) {
|
|
16303
|
+
let normalizedConfigPath = normalizeFileName(typescript, configPath);
|
|
16304
|
+
if (seenConfigPaths.has(normalizedConfigPath))
|
|
16575
16305
|
return;
|
|
16576
|
-
|
|
16577
|
-
|
|
16578
|
-
|
|
16579
|
-
|
|
16580
|
-
|
|
16581
|
-
|
|
16306
|
+
seenConfigPaths.add(normalizedConfigPath);
|
|
16307
|
+
let { config, parsed } = readTsconfig(typescript, configPath);
|
|
16308
|
+
if (parsed.fileNames.some((name) => isSameFileName(typescript, name, filePath)))
|
|
16309
|
+
return configPath;
|
|
16310
|
+
for (let referencedConfigPath of getReferencedTsconfigPaths(typescript, configPath, config)) {
|
|
16311
|
+
let matchingConfigPath = findTsconfigPathIncludingFile(
|
|
16312
|
+
typescript,
|
|
16313
|
+
referencedConfigPath,
|
|
16314
|
+
filePath,
|
|
16315
|
+
seenConfigPaths
|
|
16316
|
+
);
|
|
16317
|
+
if (matchingConfigPath)
|
|
16318
|
+
return matchingConfigPath;
|
|
16319
|
+
}
|
|
16320
|
+
}
|
|
16321
|
+
function getReferencedTsconfigPaths(typescript, configPath, config) {
|
|
16322
|
+
return (Array.isArray(config?.references) ? config.references : []).map((reference) => reference.path).filter((referencePath) => typeof referencePath == "string").map((referencePath) => resolve4(dirname5(configPath), referencePath)).map(
|
|
16323
|
+
(referencePath) => referencePath.endsWith(".json") ? referencePath : join4(referencePath, "tsconfig.json")
|
|
16324
|
+
).filter((referencePath) => typescript.sys.fileExists(referencePath));
|
|
16325
|
+
}
|
|
16326
|
+
function parseTsconfig(typescript, configPath) {
|
|
16327
|
+
return readTsconfig(typescript, configPath).parsed;
|
|
16328
|
+
}
|
|
16329
|
+
function readTsconfig(typescript, configPath) {
|
|
16330
|
+
let { config } = typescript.readConfigFile(configPath, typescript.sys.readFile);
|
|
16331
|
+
return {
|
|
16332
|
+
config,
|
|
16333
|
+
parsed: typescript.parseJsonConfigFileContent(config, typescript.sys, dirname5(configPath))
|
|
16334
|
+
};
|
|
16335
|
+
}
|
|
16336
|
+
function isSameFileName(typescript, left, right) {
|
|
16337
|
+
return normalizeFileName(typescript, left) === normalizeFileName(typescript, right);
|
|
16338
|
+
}
|
|
16339
|
+
function normalizeFileName(typescript, fileName) {
|
|
16340
|
+
let normalized = resolve4(fileName).replace(/\\/g, "/");
|
|
16341
|
+
return typescript.sys.useCaseSensitiveFileNames ? normalized : normalized.toLowerCase();
|
|
16582
16342
|
}
|
|
16583
16343
|
|
|
16584
16344
|
// src/componentManifest/resolveComponents.ts
|
|
16585
|
-
import { recast
|
|
16345
|
+
import { recast } from "storybook/internal/babel";
|
|
16586
16346
|
import { storyNameFromExport } from "storybook/internal/csf";
|
|
16587
|
-
import {
|
|
16347
|
+
import { extractStoryJSDocInfo, loadCsf } from "storybook/internal/csf-tools";
|
|
16588
16348
|
|
|
16589
16349
|
// src/componentManifest/getComponentImports.ts
|
|
16590
|
-
import { dirname as
|
|
16591
|
-
import {
|
|
16350
|
+
import { dirname as dirname6 } from "node:path";
|
|
16351
|
+
import { types as t3 } from "storybook/internal/babel";
|
|
16352
|
+
import {
|
|
16353
|
+
buildImportStatements,
|
|
16354
|
+
collectImportBindings,
|
|
16355
|
+
resolveComponentImport
|
|
16356
|
+
} from "storybook/internal/csf-tools";
|
|
16592
16357
|
import { logger as logger5 } from "storybook/internal/node-logger";
|
|
16593
|
-
var baseIdentifier = (component) => component.split(".")[0] ?? component,
|
|
16594
|
-
arr.find(eq2) || arr.push(item);
|
|
16595
|
-
}, getComponents = async ({
|
|
16358
|
+
var baseIdentifier = (component) => component.split(".")[0] ?? component, getComponents = async ({
|
|
16596
16359
|
csf,
|
|
16597
16360
|
storyFilePath,
|
|
16598
16361
|
typescriptOptions = {},
|
|
16599
16362
|
docgenEngine,
|
|
16600
16363
|
additionalComponentNames = []
|
|
16601
16364
|
}) => {
|
|
16602
|
-
let { reactDocgenTypescriptOptions } = typescriptOptions, program = csf._file.path, componentSet = /* @__PURE__ */ new Set(), componentDepth = /* @__PURE__ */ new Map(), localToImport =
|
|
16365
|
+
let { reactDocgenTypescriptOptions } = typescriptOptions, program = csf._file.path, componentSet = /* @__PURE__ */ new Set(), componentDepth = /* @__PURE__ */ new Map(), localToImport = collectImportBindings(program), jsxDepth = 0;
|
|
16603
16366
|
program.traverse({
|
|
16604
16367
|
JSXElement: {
|
|
16605
16368
|
enter() {
|
|
@@ -16627,30 +16390,7 @@ var baseIdentifier = (component) => component.split(".")[0] ?? component, isType
|
|
|
16627
16390
|
metaComp && componentSet.add(metaComp);
|
|
16628
16391
|
for (let componentName of additionalComponentNames)
|
|
16629
16392
|
componentSet.add(componentName);
|
|
16630
|
-
let components = Array.from(componentSet).sort((a, b) => a.localeCompare(b)),
|
|
16631
|
-
for (let stmt of body) {
|
|
16632
|
-
if (!stmt.isImportDeclaration())
|
|
16633
|
-
continue;
|
|
16634
|
-
let decl = stmt.node;
|
|
16635
|
-
if (decl.importKind === "type")
|
|
16636
|
-
continue;
|
|
16637
|
-
let specifiers = decl.specifiers ?? [];
|
|
16638
|
-
if (specifiers.length !== 0)
|
|
16639
|
-
for (let s of specifiers) {
|
|
16640
|
-
if (!("local" in s) || !s.local || isTypeSpecifier(s))
|
|
16641
|
-
continue;
|
|
16642
|
-
let importId = decl.source.value;
|
|
16643
|
-
if (t3.isImportDefaultSpecifier(s))
|
|
16644
|
-
localToImport.set(s.local.name, { importId, importName: "default" });
|
|
16645
|
-
else if (t3.isImportNamespaceSpecifier(s))
|
|
16646
|
-
localToImport.set(s.local.name, { importId, importName: "*" });
|
|
16647
|
-
else if (t3.isImportSpecifier(s)) {
|
|
16648
|
-
let imported = importedName(s.imported);
|
|
16649
|
-
localToImport.set(s.local.name, { importId, importName: imported });
|
|
16650
|
-
}
|
|
16651
|
-
}
|
|
16652
|
-
}
|
|
16653
|
-
let isLocallyDefinedWithoutImport = (base2) => {
|
|
16393
|
+
let components = Array.from(componentSet).sort((a, b) => a.localeCompare(b)), isLocallyDefinedWithoutImport = (base2) => {
|
|
16654
16394
|
let binding = program.scope.getBinding(base2);
|
|
16655
16395
|
return binding ? !!!(binding.path.isImportSpecifier?.() || binding.path.isImportDefaultSpecifier?.() || binding.path.isImportNamespaceSpecifier?.()) : !1;
|
|
16656
16396
|
}, filteredComponents = components.filter(
|
|
@@ -16658,74 +16398,50 @@ var baseIdentifier = (component) => component.split(".")[0] ?? component, isType
|
|
|
16658
16398
|
);
|
|
16659
16399
|
return (await Promise.all(
|
|
16660
16400
|
filteredComponents.map(async (c) => {
|
|
16661
|
-
let
|
|
16662
|
-
|
|
16663
|
-
|
|
16664
|
-
|
|
16665
|
-
localImportName: ns,
|
|
16666
|
-
importId: direct.importId,
|
|
16667
|
-
importName: mem,
|
|
16668
|
-
namespace: ns,
|
|
16669
|
-
member: mem,
|
|
16670
|
-
jsxDepth: depth
|
|
16671
|
-
} : {
|
|
16672
|
-
componentName: c,
|
|
16673
|
-
localImportName: ns,
|
|
16674
|
-
importId: direct.importId,
|
|
16675
|
-
importName: direct.importName,
|
|
16676
|
-
member: mem,
|
|
16677
|
-
jsxDepth: depth
|
|
16678
|
-
} : { componentName: c, member: mem, jsxDepth: depth };
|
|
16679
|
-
})() : (() => {
|
|
16680
|
-
let direct = localToImport.get(c);
|
|
16681
|
-
return direct ? {
|
|
16682
|
-
componentName: c,
|
|
16683
|
-
localImportName: c,
|
|
16684
|
-
importId: direct.importId,
|
|
16685
|
-
importName: direct.importName,
|
|
16686
|
-
jsxDepth: depth
|
|
16687
|
-
} : { componentName: c, jsxDepth: depth };
|
|
16688
|
-
})(), path4, isPackage = !1;
|
|
16401
|
+
let component = {
|
|
16402
|
+
...resolveComponentImport(c, localToImport),
|
|
16403
|
+
jsxDepth: componentDepth.get(c)
|
|
16404
|
+
}, path2, isPackage = !1;
|
|
16689
16405
|
try {
|
|
16690
|
-
component.importId && storyFilePath && (
|
|
16691
|
-
basedir:
|
|
16406
|
+
component.importId && storyFilePath && (path2 = cachedResolveImport(matchPath(component.importId, dirname6(storyFilePath)), {
|
|
16407
|
+
basedir: dirname6(storyFilePath)
|
|
16692
16408
|
}));
|
|
16693
16409
|
} catch (e) {
|
|
16694
16410
|
logger5.debug(e);
|
|
16695
16411
|
}
|
|
16696
16412
|
try {
|
|
16697
|
-
component.importId && !component.importId.startsWith(".") && storyFilePath && (cachedResolveImport(component.importId, { basedir:
|
|
16413
|
+
component.importId && !component.importId.startsWith(".") && storyFilePath && (cachedResolveImport(component.importId, { basedir: dirname6(storyFilePath) }), isPackage = !0);
|
|
16698
16414
|
} catch {
|
|
16699
16415
|
}
|
|
16700
16416
|
let componentWithPackage = { ...component, isPackage };
|
|
16701
|
-
if (
|
|
16417
|
+
if (path2) {
|
|
16702
16418
|
if (docgenEngine === "react-docgen-typescript") {
|
|
16703
16419
|
let reactDocgenTypescript, reactDocgenTypescriptError;
|
|
16704
16420
|
try {
|
|
16705
|
-
let docs = await parseWithReactDocgenTypescript(
|
|
16706
|
-
reactDocgenTypescript = matchComponentDoc(docs, component), reactDocgenTypescript || (reactDocgenTypescriptError = getReactDocgenTypescriptError(
|
|
16421
|
+
let docs = await parseWithReactDocgenTypescript(path2, reactDocgenTypescriptOptions);
|
|
16422
|
+
reactDocgenTypescript = matchComponentDoc(docs, component), reactDocgenTypescript || (reactDocgenTypescriptError = getReactDocgenTypescriptError(path2, component, docs));
|
|
16707
16423
|
} catch (e) {
|
|
16708
16424
|
let message = e instanceof Error ? e.message : String(e);
|
|
16709
|
-
logger5.debug(`react-docgen-typescript failed for ${
|
|
16425
|
+
logger5.debug(`react-docgen-typescript failed for ${path2}: ${message}`), reactDocgenTypescriptError = {
|
|
16710
16426
|
name: "react-docgen-typescript parse error",
|
|
16711
|
-
message: `File: ${
|
|
16427
|
+
message: `File: ${path2}
|
|
16712
16428
|
${message}`
|
|
16713
16429
|
};
|
|
16714
16430
|
}
|
|
16715
16431
|
let importOverride = reactDocgenTypescript ? getImportTag(reactDocgenTypescript) : void 0;
|
|
16716
16432
|
return {
|
|
16717
16433
|
...componentWithPackage,
|
|
16718
|
-
path:
|
|
16434
|
+
path: path2,
|
|
16719
16435
|
...reactDocgenTypescript ? { reactDocgenTypescript } : {},
|
|
16720
16436
|
...reactDocgenTypescriptError ? { reactDocgenTypescriptError } : {},
|
|
16721
16437
|
importOverride
|
|
16722
16438
|
};
|
|
16723
16439
|
}
|
|
16724
16440
|
if (docgenEngine === "react-docgen") {
|
|
16725
|
-
let reactDocgen = getReactDocgen(
|
|
16441
|
+
let reactDocgen = getReactDocgen(path2, componentWithPackage);
|
|
16726
16442
|
return {
|
|
16727
16443
|
...componentWithPackage,
|
|
16728
|
-
path:
|
|
16444
|
+
path: path2,
|
|
16729
16445
|
reactDocgen,
|
|
16730
16446
|
importOverride: reactDocgen.type === "success" ? getImportTag(reactDocgen.data) : void 0
|
|
16731
16447
|
};
|
|
@@ -16733,151 +16449,12 @@ ${message}`
|
|
|
16733
16449
|
if (docgenEngine === "react-component-meta")
|
|
16734
16450
|
return {
|
|
16735
16451
|
...componentWithPackage,
|
|
16736
|
-
path:
|
|
16452
|
+
path: path2
|
|
16737
16453
|
};
|
|
16738
16454
|
}
|
|
16739
16455
|
return componentWithPackage;
|
|
16740
16456
|
})
|
|
16741
16457
|
)).sort((a, b) => a.componentName.localeCompare(b.componentName));
|
|
16742
|
-
}, getImports = ({
|
|
16743
|
-
components,
|
|
16744
|
-
packageName
|
|
16745
|
-
}) => {
|
|
16746
|
-
let withSource = components.filter((c) => !!c.importId).map((c, idx) => {
|
|
16747
|
-
let importId = c.importId, overrideSource = (() => {
|
|
16748
|
-
if (c.importOverride)
|
|
16749
|
-
try {
|
|
16750
|
-
let src = babelParse2(c.importOverride).program.body.find((n) => t3.isImportDeclaration(n))?.source?.value;
|
|
16751
|
-
return typeof src == "string" ? src : void 0;
|
|
16752
|
-
} catch {
|
|
16753
|
-
return;
|
|
16754
|
-
}
|
|
16755
|
-
})(), rewritten = overrideSource !== void 0 ? overrideSource : (
|
|
16756
|
-
// only rewrite to the package name it the import id is not already a valid package
|
|
16757
|
-
// tsconfig paths such as ~/components/Button and components/Button are not seen as packages
|
|
16758
|
-
packageName && !c.isPackage ? packageName : importId
|
|
16759
|
-
);
|
|
16760
|
-
return { c, src: t3.stringLiteral(rewritten), key: rewritten, ord: idx };
|
|
16761
|
-
}), orderOfSource = {};
|
|
16762
|
-
for (let w of withSource)
|
|
16763
|
-
orderOfSource[w.key] === void 0 && (orderOfSource[w.key] = w.ord);
|
|
16764
|
-
let buckets = /* @__PURE__ */ new Map(), ensureBucket = (key, src) => {
|
|
16765
|
-
let prev = buckets.get(key);
|
|
16766
|
-
if (prev)
|
|
16767
|
-
return prev;
|
|
16768
|
-
let b = {
|
|
16769
|
-
source: src,
|
|
16770
|
-
defaults: [],
|
|
16771
|
-
namespaces: [],
|
|
16772
|
-
named: [],
|
|
16773
|
-
order: orderOfSource[key] ?? 0
|
|
16774
|
-
};
|
|
16775
|
-
return buckets.set(key, b), b;
|
|
16776
|
-
};
|
|
16777
|
-
for (let { c, src, key } of withSource) {
|
|
16778
|
-
let b = ensureBucket(key, src), rewritten = src.value !== c.importId, overrideSpec = (() => {
|
|
16779
|
-
if (c.importOverride)
|
|
16780
|
-
try {
|
|
16781
|
-
let decl = babelParse2(c.importOverride).program.body.find((n) => t3.isImportDeclaration(n));
|
|
16782
|
-
if (!decl)
|
|
16783
|
-
return;
|
|
16784
|
-
let spec = (decl.specifiers ?? []).find((s) => !isTypeSpecifier(s));
|
|
16785
|
-
return spec ? t3.isImportNamespaceSpecifier(spec) ? { kind: "namespace", local: spec.local.name } : t3.isImportDefaultSpecifier(spec) ? { kind: "default" } : t3.isImportSpecifier(spec) ? { kind: "named", imported: t3.isIdentifier(spec.imported) ? spec.imported.name : spec.imported.value } : void 0 : void 0;
|
|
16786
|
-
} catch {
|
|
16787
|
-
return;
|
|
16788
|
-
}
|
|
16789
|
-
})();
|
|
16790
|
-
if (overrideSpec) {
|
|
16791
|
-
if (overrideSpec.kind === "namespace") {
|
|
16792
|
-
let ns = t3.identifier(overrideSpec.local);
|
|
16793
|
-
addUniqueBy(b.namespaces, ns, (n) => n.name === ns.name);
|
|
16794
|
-
continue;
|
|
16795
|
-
}
|
|
16796
|
-
if (!c.localImportName)
|
|
16797
|
-
continue;
|
|
16798
|
-
if (overrideSpec.kind === "default") {
|
|
16799
|
-
let id = t3.identifier(c.localImportName);
|
|
16800
|
-
addUniqueBy(b.defaults, id, (d) => d.name === id.name);
|
|
16801
|
-
continue;
|
|
16802
|
-
}
|
|
16803
|
-
if (overrideSpec.kind === "named") {
|
|
16804
|
-
let local = t3.identifier(c.localImportName), imported = t3.identifier(overrideSpec.imported);
|
|
16805
|
-
addUniqueBy(
|
|
16806
|
-
b.named,
|
|
16807
|
-
t3.importSpecifier(local, imported),
|
|
16808
|
-
(n) => n.local.name === local.name && importedName(n.imported) === imported.name
|
|
16809
|
-
);
|
|
16810
|
-
continue;
|
|
16811
|
-
}
|
|
16812
|
-
}
|
|
16813
|
-
if (c.namespace) {
|
|
16814
|
-
if (rewritten) {
|
|
16815
|
-
if (!c.importName)
|
|
16816
|
-
continue;
|
|
16817
|
-
let member = c.importName, id = t3.identifier(member);
|
|
16818
|
-
addUniqueBy(
|
|
16819
|
-
b.named,
|
|
16820
|
-
t3.importSpecifier(id, id),
|
|
16821
|
-
(n) => n.local.name === member && importedName(n.imported) === member
|
|
16822
|
-
);
|
|
16823
|
-
} else {
|
|
16824
|
-
let ns = t3.identifier(c.namespace);
|
|
16825
|
-
addUniqueBy(b.namespaces, ns, (n) => n.name === ns.name);
|
|
16826
|
-
}
|
|
16827
|
-
continue;
|
|
16828
|
-
}
|
|
16829
|
-
if (c.importName === "default") {
|
|
16830
|
-
if (!c.localImportName)
|
|
16831
|
-
continue;
|
|
16832
|
-
if (rewritten) {
|
|
16833
|
-
let id = t3.identifier(c.localImportName);
|
|
16834
|
-
addUniqueBy(
|
|
16835
|
-
b.named,
|
|
16836
|
-
t3.importSpecifier(id, id),
|
|
16837
|
-
(n) => n.local.name === id.name && importedName(n.imported) === id.name
|
|
16838
|
-
);
|
|
16839
|
-
} else {
|
|
16840
|
-
let id = t3.identifier(c.localImportName);
|
|
16841
|
-
addUniqueBy(b.defaults, id, (d) => d.name === id.name);
|
|
16842
|
-
}
|
|
16843
|
-
continue;
|
|
16844
|
-
}
|
|
16845
|
-
if (c.importName) {
|
|
16846
|
-
if (!c.localImportName)
|
|
16847
|
-
continue;
|
|
16848
|
-
let local = t3.identifier(c.localImportName), imported = t3.identifier(c.importName);
|
|
16849
|
-
addUniqueBy(
|
|
16850
|
-
b.named,
|
|
16851
|
-
t3.importSpecifier(local, imported),
|
|
16852
|
-
(n) => n.local.name === local.name && importedName(n.imported) === imported.name
|
|
16853
|
-
);
|
|
16854
|
-
continue;
|
|
16855
|
-
}
|
|
16856
|
-
}
|
|
16857
|
-
let merged = [], printDecl = (specs, src) => {
|
|
16858
|
-
let node = t3.importDeclaration(specs, src), code = recast.print(node, {}).code;
|
|
16859
|
-
merged.push(code);
|
|
16860
|
-
}, sortedBuckets = Array.from(buckets.values()).sort((a, b) => a.order - b.order);
|
|
16861
|
-
for (let bucket of sortedBuckets) {
|
|
16862
|
-
let { source, defaults, namespaces, named } = bucket;
|
|
16863
|
-
if (!(defaults.length === 0 && namespaces.length === 0 && named.length === 0))
|
|
16864
|
-
if (namespaces.length > 0) {
|
|
16865
|
-
let firstSpecs = [];
|
|
16866
|
-
defaults[0] && firstSpecs.push(t3.importDefaultSpecifier(defaults[0])), firstSpecs.push(t3.importNamespaceSpecifier(namespaces[0])), printDecl(firstSpecs, source), named.length > 0 && printDecl(named, source);
|
|
16867
|
-
for (let d of defaults.slice(1))
|
|
16868
|
-
printDecl([t3.importDefaultSpecifier(d)], source);
|
|
16869
|
-
for (let ns of namespaces.slice(1))
|
|
16870
|
-
printDecl([t3.importNamespaceSpecifier(ns)], source);
|
|
16871
|
-
} else {
|
|
16872
|
-
if (defaults.length > 0 || named.length > 0) {
|
|
16873
|
-
let specs = [];
|
|
16874
|
-
defaults[0] && specs.push(t3.importDefaultSpecifier(defaults[0])), specs.push(...named), printDecl(specs, source);
|
|
16875
|
-
}
|
|
16876
|
-
for (let d of defaults.slice(1))
|
|
16877
|
-
printDecl([t3.importDefaultSpecifier(d)], source);
|
|
16878
|
-
}
|
|
16879
|
-
}
|
|
16880
|
-
return merged;
|
|
16881
16458
|
};
|
|
16882
16459
|
|
|
16883
16460
|
// src/componentManifest/subcomponents.ts
|
|
@@ -16977,13 +16554,13 @@ function extractStorySnippets(csf, componentName, filterStoryIds) {
|
|
|
16977
16554
|
return Object.entries(csf._stories).filter(([, story]) => !filterStoryIds || filterStoryIds.has(story.id)).map(([storyExport, story]) => {
|
|
16978
16555
|
let name = story.name ?? storyNameFromExport(storyExport);
|
|
16979
16556
|
try {
|
|
16980
|
-
let
|
|
16557
|
+
let { description, summary } = extractStoryJSDocInfo(csf._storyStatements[storyExport]);
|
|
16981
16558
|
return {
|
|
16982
16559
|
id: story.id,
|
|
16983
16560
|
name,
|
|
16984
|
-
snippet:
|
|
16985
|
-
description
|
|
16986
|
-
summary
|
|
16561
|
+
snippet: recast.print(getCodeSnippet(csf, storyExport, componentName)).code,
|
|
16562
|
+
description,
|
|
16563
|
+
summary
|
|
16987
16564
|
};
|
|
16988
16565
|
} catch (e) {
|
|
16989
16566
|
let err = e instanceof Error ? e : new Error(String(e));
|
|
@@ -16994,10 +16571,14 @@ function extractStorySnippets(csf, componentName, filterStoryIds) {
|
|
|
16994
16571
|
|
|
16995
16572
|
// src/componentManifest/buildReactComponentDocgen.ts
|
|
16996
16573
|
import { getComponentIdFromEntry } from "storybook/internal/common";
|
|
16997
|
-
import {
|
|
16574
|
+
import {
|
|
16575
|
+
buildImportStatements as buildImportStatements2,
|
|
16576
|
+
extractComponentDescription,
|
|
16577
|
+
extractDescription
|
|
16578
|
+
} from "storybook/internal/csf-tools";
|
|
16998
16579
|
function getPackageInfo(componentPath, fallbackPath) {
|
|
16999
16580
|
let nearestPkg = cachedFindUp("package.json", {
|
|
17000
|
-
cwd:
|
|
16581
|
+
cwd: posix.dirname(componentPath ?? fallbackPath)
|
|
17001
16582
|
});
|
|
17002
16583
|
try {
|
|
17003
16584
|
if (!nearestPkg)
|
|
@@ -17010,10 +16591,13 @@ function getPackageInfo(componentPath, fallbackPath) {
|
|
|
17010
16591
|
}
|
|
17011
16592
|
function getFallbackImport(packageName, componentName) {
|
|
17012
16593
|
let exportName = componentName?.split(".").at(-1);
|
|
17013
|
-
return packageName && exportName ?
|
|
16594
|
+
return packageName && exportName ? buildImportStatements2({
|
|
16595
|
+
refs: [{ importId: packageName, importName: exportName, localImportName: exportName }]
|
|
16596
|
+
}).join(`
|
|
16597
|
+
`) : "";
|
|
17014
16598
|
}
|
|
17015
16599
|
function relativizeComponentMetaPaths(doc) {
|
|
17016
|
-
let relativize = (fileName) =>
|
|
16600
|
+
let relativize = (fileName) => posix.relative(process.cwd(), fileName), relativizeProp = (prop) => ({
|
|
17017
16601
|
...prop,
|
|
17018
16602
|
parent: prop.parent ? { ...prop.parent, fileName: relativize(prop.parent.fileName) } : prop.parent,
|
|
17019
16603
|
declarations: prop.declarations?.map((declaration) => ({
|
|
@@ -17050,7 +16634,7 @@ function createSubcomponentDocgen({
|
|
|
17050
16634
|
packageName,
|
|
17051
16635
|
storyFilePath
|
|
17052
16636
|
}) {
|
|
17053
|
-
let imports =
|
|
16637
|
+
let imports = buildImportStatements2({ refs: component ? [component] : [], packageName }).join(`
|
|
17054
16638
|
`).trim() || getFallbackImport(packageName, component?.componentName), {
|
|
17055
16639
|
reactDocgen,
|
|
17056
16640
|
reactDocgenTypescript,
|
|
@@ -17089,7 +16673,7 @@ function buildStoryDocsFromResolved({
|
|
|
17089
16673
|
allComponents,
|
|
17090
16674
|
filterStoryIds
|
|
17091
16675
|
}) {
|
|
17092
|
-
let id = getComponentIdFromEntry(entry), title = entry.title.split("/").at(-1).replace(/\s+/g, ""), packageName = getPackageInfo(component?.path, storyPath), fallbackImport = getFallbackImport(packageName, componentName), imports =
|
|
16676
|
+
let id = getComponentIdFromEntry(entry), title = entry.title.split("/").at(-1).replace(/\s+/g, ""), packageName = getPackageInfo(component?.path, storyPath), fallbackImport = getFallbackImport(packageName, componentName), imports = buildImportStatements2({ refs: allComponents, packageName }).join(`
|
|
17093
16677
|
`).trim() || fallbackImport, storyEntries = extractStorySnippets(csf, component?.componentName, filterStoryIds);
|
|
17094
16678
|
return {
|
|
17095
16679
|
id,
|
|
@@ -17143,7 +16727,7 @@ ${storyFile}`
|
|
|
17143
16727
|
}
|
|
17144
16728
|
};
|
|
17145
16729
|
}
|
|
17146
|
-
let metaJsDoc =
|
|
16730
|
+
let metaJsDoc = extractDescription(csf._metaStatement) || void 0, { description, summary, jsDocTags } = extractComponentDescription(
|
|
17147
16731
|
metaJsDoc,
|
|
17148
16732
|
docgenDescription,
|
|
17149
16733
|
docgenJsDocTags
|
|
@@ -17213,15 +16797,14 @@ function buildReactComponentDocgenFromResolved({
|
|
|
17213
16797
|
}
|
|
17214
16798
|
|
|
17215
16799
|
export {
|
|
17216
|
-
join4 as join,
|
|
17217
|
-
dirname4 as dirname,
|
|
17218
|
-
path3 as path,
|
|
17219
16800
|
extractArgTypes,
|
|
17220
16801
|
invalidateCache,
|
|
17221
16802
|
cachedReadFileSync,
|
|
17222
16803
|
parseWithReactDocgen,
|
|
17223
|
-
|
|
16804
|
+
join3 as join,
|
|
16805
|
+
posix,
|
|
17224
16806
|
getCodeSnippet,
|
|
16807
|
+
invalidateParser,
|
|
17225
16808
|
resolveStoryFileComponents,
|
|
17226
16809
|
buildStoryDocsFromResolved,
|
|
17227
16810
|
buildComponentDocgenFromResolved,
|