storybook 10.2.0-alpha.9 → 10.2.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_browser-chunks/{Color-E5XDEOX4.js → Color-XESOIGZP.js} +57 -3
- package/dist/_browser-chunks/chunk-AFVOZMXQ.js +23 -0
- package/dist/_browser-chunks/{chunk-3PJE6VLG.js → chunk-ASKQZAOS.js} +1 -12
- package/dist/_browser-chunks/chunk-IYCKG66Y.js +171 -0
- package/dist/_browser-chunks/chunk-LCHBOIHN.js +64 -0
- package/dist/_browser-chunks/{chunk-IPA5A322.js → chunk-MEXTPDJG.js} +1 -1
- package/dist/_browser-chunks/{chunk-54PNNATT.js → chunk-NQJGOFZV.js} +18 -1
- package/dist/_browser-chunks/{chunk-VUZYLZ4B.js → chunk-QOXZ7W26.js} +31 -15
- package/dist/_browser-chunks/{chunk-LOTN4ZCW.js → chunk-SI6AKD4S.js} +2 -2
- package/dist/_browser-chunks/chunk-YK43Z22A.js +263 -0
- package/dist/_node-chunks/{builder-manager-FTCODGJP.js → builder-manager-JEJE63VV.js} +15 -12
- package/dist/_node-chunks/camelcase-HALRJETF.js +62 -0
- package/dist/_node-chunks/{chunk-3Y5VHKPI.js → chunk-3SKE4CCB.js} +9 -9
- package/dist/_node-chunks/chunk-4UYAC7Y2.js +18 -0
- package/dist/_node-chunks/{chunk-NYUFS6LX.js → chunk-6UAQEBJX.js} +10 -10
- package/dist/_node-chunks/{chunk-SPOUBCPJ.js → chunk-72K4WVI5.js} +18 -14
- package/dist/_node-chunks/{chunk-FGI35IGB.js → chunk-7ZX5CX6B.js} +15 -69
- package/dist/_node-chunks/{chunk-6SH5SI6S.js → chunk-ADTWC7QJ.js} +7 -7
- package/dist/_node-chunks/{chunk-OUDQWDHY.js → chunk-APUXGW3Y.js} +7 -7
- package/dist/_node-chunks/{chunk-PZCWRKQE.js → chunk-AXDM43NU.js} +6 -6
- package/dist/_node-chunks/{chunk-73GYSTNZ.js → chunk-B422K4XV.js} +6 -6
- package/dist/_node-chunks/{chunk-WTQGSYRO.js → chunk-BJOXVTWM.js} +12 -571
- package/dist/_node-chunks/{chunk-LRBEW57O.js → chunk-BLGRU6F5.js} +7 -7
- package/dist/_node-chunks/{chunk-6ABJZZWS.js → chunk-CG47ALAV.js} +7 -7
- package/dist/_node-chunks/chunk-FH4FRUMP.js +23 -0
- package/dist/_node-chunks/{chunk-RF3L36MK.js → chunk-GBZ23FIZ.js} +125 -73
- package/dist/_node-chunks/{chunk-MWWAQ5S4.js → chunk-IZ3ATSWZ.js} +5262 -1480
- package/dist/_node-chunks/{chunk-SBPB3VWI.js → chunk-IZFEBWVB.js} +6 -6
- package/dist/_node-chunks/{chunk-33XC4R6P.js → chunk-KL5CKFPT.js} +9 -9
- package/dist/_node-chunks/{chunk-D4TCQXIF.js → chunk-MLXCYULR.js} +7 -7
- package/dist/_node-chunks/{chunk-LB74XOLW.js → chunk-MV2QM7P3.js} +6 -6
- package/dist/_node-chunks/chunk-PHX5XNP7.js +144 -0
- package/dist/_node-chunks/{chunk-XZ6V3G6J.js → chunk-QL6L57W7.js} +533 -143
- package/dist/_node-chunks/{chunk-IIBBQZLT.js → chunk-RPBXVPRB.js} +6 -6
- package/dist/_node-chunks/{chunk-BQX766MA.js → chunk-UH2GWMFP.js} +260 -162
- package/dist/_node-chunks/chunk-WNGL2VRJ.js +126 -0
- package/dist/_node-chunks/{chunk-CO7N5AG7.js → chunk-XAL452XB.js} +36 -14
- package/dist/_node-chunks/{chunk-YN6FEZAF.js → chunk-YVXXMWQO.js} +7 -7
- package/dist/_node-chunks/chunk-YYDL7JOC.js +61 -0
- package/dist/_node-chunks/{chunk-3DPKKQ6P.js → chunk-Z7FLE2TR.js} +6 -6
- package/dist/_node-chunks/{globby-AXGFF6I5.js → globby-4D4NBVG7.js} +11 -20
- package/dist/_node-chunks/{lib-ESB7KQ6D.js → lib-RM2DWHZQ.js} +7 -7
- package/dist/_node-chunks/{mdx-N42X6CFJ-XXQ6YIDF.js → mdx-N42X6CFJ-RAL72UTP.js} +8 -8
- package/dist/_node-chunks/{p-limit-P6ND7SUA.js → p-limit-6PUJQL5X.js} +18 -14
- package/dist/babel/index.js +10 -10
- package/dist/bin/core.js +12 -12
- package/dist/bin/dispatcher.js +11 -11
- package/dist/bin/loader.js +9 -9
- package/dist/cli/index.d.ts +1504 -424
- package/dist/cli/index.js +18 -18
- package/dist/common/index.d.ts +1319 -271
- package/dist/common/index.js +19 -19
- package/dist/components/index.d.ts +4 -1
- package/dist/components/index.js +228 -227
- package/dist/core-events/index.d.ts +23 -7
- package/dist/core-events/index.js +5 -1
- package/dist/core-server/index.d.ts +105 -3
- package/dist/core-server/index.js +992 -613
- package/dist/core-server/presets/common-manager.js +208 -160
- package/dist/core-server/presets/common-override-preset.js +11 -11
- package/dist/core-server/presets/common-preset.js +558 -4534
- package/dist/csf/index.d.ts +147 -15
- package/dist/csf/index.js +52 -23
- package/dist/csf-tools/index.d.ts +19 -1
- package/dist/csf-tools/index.js +11 -9
- package/dist/docs-tools/index.d.ts +2 -2
- package/dist/docs-tools/index.js +4 -5
- package/dist/manager/globals-runtime.js +2749 -6907
- package/dist/manager/runtime.js +2939 -2295
- package/dist/manager-api/index.d.ts +89 -21
- package/dist/manager-api/index.js +82 -23
- package/dist/mocking-utils/index.js +8 -8
- package/dist/node-logger/index.d.ts +1453 -108
- package/dist/node-logger/index.js +9 -9
- package/dist/preview/runtime.js +784 -5059
- package/dist/preview-api/index.d.ts +26 -1
- package/dist/preview-api/index.js +11 -8
- package/dist/router/index.js +5 -4
- package/dist/server-errors.js +11 -11
- package/dist/telemetry/index.d.ts +14 -2
- package/dist/telemetry/index.js +23 -22
- package/dist/theming/index.d.ts +5 -5
- package/dist/theming/index.js +21 -2
- package/dist/types/index.d.ts +21 -9
- package/dist/viewport/index.d.ts +5 -3
- package/dist/viewport/index.js +12 -3
- package/package.json +27 -26
- package/dist/_browser-chunks/chunk-2NDLAB5X.js +0 -363
- package/dist/_browser-chunks/chunk-CLSHX4VX.js +0 -4140
- package/dist/_browser-chunks/chunk-HPYUT3WS.js +0 -199
- package/dist/_browser-chunks/chunk-XCZK5QUJ.js +0 -0
- package/dist/_node-chunks/camelcase-5XDKQT3J.js +0 -37
- package/dist/_node-chunks/chunk-GXQRT5M6.js +0 -61
- package/dist/_node-chunks/chunk-MOQRBTWA.js +0 -70
- package/dist/_node-chunks/chunk-PRNP2HO6.js +0 -23
- package/dist/_node-chunks/chunk-VKMYOVNS.js +0 -18
- package/dist/_node-chunks/dist-YRSVYE5A.js +0 -121
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_phceqgr585q from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_phceqgr585q from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_phceqgr585q from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_phceqgr585q.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_phceqgr585q.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_phceqgr585q.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
toEstree
|
|
14
|
+
} from "../_node-chunks/chunk-YVXXMWQO.js";
|
|
12
15
|
import {
|
|
13
16
|
StatusTypeIdMismatchError
|
|
14
|
-
} from "../_node-chunks/chunk-
|
|
17
|
+
} from "../_node-chunks/chunk-6UAQEBJX.js";
|
|
15
18
|
import {
|
|
16
19
|
debounce,
|
|
20
|
+
generateStoryFile,
|
|
17
21
|
getErrorLevel,
|
|
18
22
|
isTelemetryEnabled,
|
|
19
23
|
mapStaticDir,
|
|
@@ -21,65 +25,197 @@ import {
|
|
|
21
25
|
sendTelemetryError,
|
|
22
26
|
useStatics,
|
|
23
27
|
withTelemetry
|
|
24
|
-
} from "../_node-chunks/chunk-
|
|
28
|
+
} from "../_node-chunks/chunk-UH2GWMFP.js";
|
|
25
29
|
import {
|
|
26
30
|
detectPnp
|
|
27
|
-
} from "../_node-chunks/chunk-
|
|
28
|
-
import "../_node-chunks/chunk-
|
|
31
|
+
} from "../_node-chunks/chunk-FH4FRUMP.js";
|
|
32
|
+
import "../_node-chunks/chunk-ADTWC7QJ.js";
|
|
29
33
|
import {
|
|
30
34
|
StorybookError
|
|
31
|
-
} from "../_node-chunks/chunk-
|
|
35
|
+
} from "../_node-chunks/chunk-RPBXVPRB.js";
|
|
32
36
|
import {
|
|
33
37
|
telemetry
|
|
34
|
-
} from "../_node-chunks/chunk-
|
|
35
|
-
import "../_node-chunks/chunk-
|
|
38
|
+
} from "../_node-chunks/chunk-GBZ23FIZ.js";
|
|
39
|
+
import "../_node-chunks/chunk-4UYAC7Y2.js";
|
|
36
40
|
import {
|
|
37
41
|
optionalEnvToBoolean,
|
|
38
42
|
require_cross_spawn,
|
|
39
43
|
resolveImport,
|
|
40
44
|
supportedExtensions,
|
|
41
45
|
userOrAutoTitleFromSpecifier
|
|
42
|
-
} from "../_node-chunks/chunk-
|
|
43
|
-
import "../_node-chunks/chunk-
|
|
44
|
-
import "../_node-chunks/chunk-
|
|
46
|
+
} from "../_node-chunks/chunk-IZ3ATSWZ.js";
|
|
47
|
+
import "../_node-chunks/chunk-YYDL7JOC.js";
|
|
48
|
+
import "../_node-chunks/chunk-XAL452XB.js";
|
|
45
49
|
import {
|
|
46
50
|
require_pretty_hrtime
|
|
47
|
-
} from "../_node-chunks/chunk-
|
|
48
|
-
import "../_node-chunks/chunk-
|
|
51
|
+
} from "../_node-chunks/chunk-72K4WVI5.js";
|
|
52
|
+
import "../_node-chunks/chunk-PHX5XNP7.js";
|
|
53
|
+
import "../_node-chunks/chunk-3SKE4CCB.js";
|
|
49
54
|
import {
|
|
50
55
|
invariant,
|
|
51
56
|
up2 as up
|
|
52
|
-
} from "../_node-chunks/chunk-
|
|
53
|
-
import "../_node-chunks/chunk-
|
|
57
|
+
} from "../_node-chunks/chunk-WNGL2VRJ.js";
|
|
58
|
+
import "../_node-chunks/chunk-Z7FLE2TR.js";
|
|
54
59
|
import {
|
|
55
60
|
importModule,
|
|
56
61
|
resolvePackageDir
|
|
57
|
-
} from "../_node-chunks/chunk-
|
|
62
|
+
} from "../_node-chunks/chunk-APUXGW3Y.js";
|
|
58
63
|
import {
|
|
59
64
|
dirname,
|
|
60
65
|
join,
|
|
61
66
|
relative,
|
|
62
67
|
resolve
|
|
63
|
-
} from "../_node-chunks/chunk-
|
|
64
|
-
import "../_node-chunks/chunk-WTQGSYRO.js";
|
|
68
|
+
} from "../_node-chunks/chunk-MV2QM7P3.js";
|
|
65
69
|
import {
|
|
66
70
|
slash
|
|
67
|
-
} from "../_node-chunks/chunk-
|
|
71
|
+
} from "../_node-chunks/chunk-B422K4XV.js";
|
|
72
|
+
import "../_node-chunks/chunk-BJOXVTWM.js";
|
|
73
|
+
import {
|
|
74
|
+
Tag
|
|
75
|
+
} from "../_node-chunks/chunk-QL6L57W7.js";
|
|
68
76
|
import {
|
|
69
77
|
require_dist
|
|
70
|
-
} from "../_node-chunks/chunk-
|
|
78
|
+
} from "../_node-chunks/chunk-BLGRU6F5.js";
|
|
71
79
|
import {
|
|
72
80
|
require_lib,
|
|
73
81
|
require_src
|
|
74
|
-
} from "../_node-chunks/chunk-
|
|
82
|
+
} from "../_node-chunks/chunk-MLXCYULR.js";
|
|
75
83
|
import {
|
|
76
84
|
require_picocolors
|
|
77
|
-
} from "../_node-chunks/chunk-
|
|
85
|
+
} from "../_node-chunks/chunk-CG47ALAV.js";
|
|
78
86
|
import {
|
|
79
87
|
__commonJS,
|
|
80
88
|
__require,
|
|
81
89
|
__toESM
|
|
82
|
-
} from "../_node-chunks/chunk-
|
|
90
|
+
} from "../_node-chunks/chunk-AXDM43NU.js";
|
|
91
|
+
|
|
92
|
+
// ../../node_modules/glob-to-regexp/index.js
|
|
93
|
+
var require_glob_to_regexp = __commonJS({
|
|
94
|
+
"../../node_modules/glob-to-regexp/index.js"(exports, module) {
|
|
95
|
+
module.exports = function(glob, opts) {
|
|
96
|
+
if (typeof glob != "string")
|
|
97
|
+
throw new TypeError("Expected a string");
|
|
98
|
+
for (var str = String(glob), reStr = "", extended = opts ? !!opts.extended : !1, globstar = opts ? !!opts.globstar : !1, inGroup = !1, flags = opts && typeof opts.flags == "string" ? opts.flags : "", c, i = 0, len = str.length; i < len; i++)
|
|
99
|
+
switch (c = str[i], c) {
|
|
100
|
+
case "/":
|
|
101
|
+
case "$":
|
|
102
|
+
case "^":
|
|
103
|
+
case "+":
|
|
104
|
+
case ".":
|
|
105
|
+
case "(":
|
|
106
|
+
case ")":
|
|
107
|
+
case "=":
|
|
108
|
+
case "!":
|
|
109
|
+
case "|":
|
|
110
|
+
reStr += "\\" + c;
|
|
111
|
+
break;
|
|
112
|
+
case "?":
|
|
113
|
+
if (extended) {
|
|
114
|
+
reStr += ".";
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
case "[":
|
|
118
|
+
case "]":
|
|
119
|
+
if (extended) {
|
|
120
|
+
reStr += c;
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
case "{":
|
|
124
|
+
if (extended) {
|
|
125
|
+
inGroup = !0, reStr += "(";
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
case "}":
|
|
129
|
+
if (extended) {
|
|
130
|
+
inGroup = !1, reStr += ")";
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
case ",":
|
|
134
|
+
if (inGroup) {
|
|
135
|
+
reStr += "|";
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
reStr += "\\" + c;
|
|
139
|
+
break;
|
|
140
|
+
case "*":
|
|
141
|
+
for (var prevChar = str[i - 1], starCount = 1; str[i + 1] === "*"; )
|
|
142
|
+
starCount++, i++;
|
|
143
|
+
var nextChar = str[i + 1];
|
|
144
|
+
if (!globstar)
|
|
145
|
+
reStr += ".*";
|
|
146
|
+
else {
|
|
147
|
+
var isGlobstar = starCount > 1 && (prevChar === "/" || prevChar === void 0) && (nextChar === "/" || nextChar === void 0);
|
|
148
|
+
isGlobstar ? (reStr += "((?:[^/]*(?:/|$))*)", i++) : reStr += "([^/]*)";
|
|
149
|
+
}
|
|
150
|
+
break;
|
|
151
|
+
default:
|
|
152
|
+
reStr += c;
|
|
153
|
+
}
|
|
154
|
+
return (!flags || !~flags.indexOf("g")) && (reStr = "^" + reStr + "$"), new RegExp(reStr, flags);
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// ../../node_modules/watchpack/lib/LinkResolver.js
|
|
160
|
+
var require_LinkResolver = __commonJS({
|
|
161
|
+
"../../node_modules/watchpack/lib/LinkResolver.js"(exports, module) {
|
|
162
|
+
"use strict";
|
|
163
|
+
var fs = __require("fs"), path2 = __require("path"), EXPECTED_ERRORS = /* @__PURE__ */ new Set(["EINVAL", "ENOENT"]);
|
|
164
|
+
process.platform === "win32" && EXPECTED_ERRORS.add("UNKNOWN");
|
|
165
|
+
var LinkResolver = class {
|
|
166
|
+
constructor() {
|
|
167
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* @param {string} file path to file or directory
|
|
171
|
+
* @returns {readonly string[]} array of file and all symlinks contributed in the resolving process (first item is the resolved file)
|
|
172
|
+
*/
|
|
173
|
+
resolve(file) {
|
|
174
|
+
let cacheEntry = this.cache.get(file);
|
|
175
|
+
if (cacheEntry !== void 0)
|
|
176
|
+
return cacheEntry;
|
|
177
|
+
let parent = path2.dirname(file);
|
|
178
|
+
if (parent === file) {
|
|
179
|
+
let result = Object.freeze([file]);
|
|
180
|
+
return this.cache.set(file, result), result;
|
|
181
|
+
}
|
|
182
|
+
let parentResolved = this.resolve(parent), realFile = file;
|
|
183
|
+
if (parentResolved[0] !== parent) {
|
|
184
|
+
let basename4 = path2.basename(file);
|
|
185
|
+
realFile = path2.resolve(parentResolved[0], basename4);
|
|
186
|
+
}
|
|
187
|
+
try {
|
|
188
|
+
let linkContent = fs.readlinkSync(realFile), resolvedLink = path2.resolve(parentResolved[0], linkContent), linkResolved = this.resolve(resolvedLink), result;
|
|
189
|
+
if (linkResolved.length > 1 && parentResolved.length > 1) {
|
|
190
|
+
let resultSet = new Set(linkResolved);
|
|
191
|
+
resultSet.add(realFile);
|
|
192
|
+
for (let i = 1; i < parentResolved.length; i++)
|
|
193
|
+
resultSet.add(parentResolved[i]);
|
|
194
|
+
result = Object.freeze([...resultSet]);
|
|
195
|
+
} else parentResolved.length > 1 ? (result = [...parentResolved], result[0] = linkResolved[0], result.push(realFile), Object.freeze(result)) : linkResolved.length > 1 ? (result = [...linkResolved], result.push(realFile), Object.freeze(result)) : result = Object.freeze([
|
|
196
|
+
// the resolve real location
|
|
197
|
+
linkResolved[0],
|
|
198
|
+
// add the link
|
|
199
|
+
realFile
|
|
200
|
+
]);
|
|
201
|
+
return this.cache.set(file, result), result;
|
|
202
|
+
} catch (err) {
|
|
203
|
+
if (
|
|
204
|
+
/** @type {NodeJS.ErrnoException} */
|
|
205
|
+
err.code && !EXPECTED_ERRORS.has(
|
|
206
|
+
/** @type {NodeJS.ErrnoException} */
|
|
207
|
+
err.code
|
|
208
|
+
)
|
|
209
|
+
)
|
|
210
|
+
throw err;
|
|
211
|
+
let result = [...parentResolved];
|
|
212
|
+
return result[0] = realFile, Object.freeze(result), this.cache.set(file, result), result;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
module.exports = LinkResolver;
|
|
217
|
+
}
|
|
218
|
+
});
|
|
83
219
|
|
|
84
220
|
// ../../node_modules/graceful-fs/polyfills.js
|
|
85
221
|
var require_polyfills = __commonJS({
|
|
@@ -594,9 +730,9 @@ var require_reducePlan = __commonJS({
|
|
|
594
730
|
var path2 = __require("path");
|
|
595
731
|
module.exports = (plan, limit) => {
|
|
596
732
|
let treeMap = /* @__PURE__ */ new Map();
|
|
597
|
-
for (let [
|
|
598
|
-
treeMap.set(
|
|
599
|
-
|
|
733
|
+
for (let [target, value] of plan)
|
|
734
|
+
treeMap.set(target, {
|
|
735
|
+
target,
|
|
600
736
|
parent: void 0,
|
|
601
737
|
children: void 0,
|
|
602
738
|
entries: 1,
|
|
@@ -605,12 +741,12 @@ var require_reducePlan = __commonJS({
|
|
|
605
741
|
});
|
|
606
742
|
let currentCount = treeMap.size;
|
|
607
743
|
for (let node of treeMap.values()) {
|
|
608
|
-
let parentPath = path2.dirname(node.
|
|
609
|
-
if (parentPath !== node.
|
|
744
|
+
let parentPath = path2.dirname(node.target);
|
|
745
|
+
if (parentPath !== node.target) {
|
|
610
746
|
let parent = treeMap.get(parentPath);
|
|
611
747
|
if (parent === void 0)
|
|
612
748
|
parent = {
|
|
613
|
-
|
|
749
|
+
target: parentPath,
|
|
614
750
|
parent: void 0,
|
|
615
751
|
children: [node],
|
|
616
752
|
entries: node.entries,
|
|
@@ -635,7 +771,7 @@ var require_reducePlan = __commonJS({
|
|
|
635
771
|
if (!bestNode) break;
|
|
636
772
|
let reduction = bestNode.entries - 1;
|
|
637
773
|
bestNode.active = !0, bestNode.entries = 1, currentCount -= reduction;
|
|
638
|
-
let parent = bestNode
|
|
774
|
+
let { parent } = bestNode;
|
|
639
775
|
for (; parent; )
|
|
640
776
|
parent.entries -= reduction, parent = parent.parent;
|
|
641
777
|
let queue = new Set(bestNode.children);
|
|
@@ -652,14 +788,14 @@ var require_reducePlan = __commonJS({
|
|
|
652
788
|
if (node.value)
|
|
653
789
|
if (Array.isArray(node.value))
|
|
654
790
|
for (let item of node.value)
|
|
655
|
-
map.set(item, node.
|
|
791
|
+
map.set(item, node.target);
|
|
656
792
|
else
|
|
657
|
-
map.set(node.value, node.
|
|
793
|
+
map.set(node.value, node.target);
|
|
658
794
|
if (node.children)
|
|
659
795
|
for (let child of node.children)
|
|
660
796
|
queue.add(child);
|
|
661
797
|
}
|
|
662
|
-
newPlan.set(rootNode.
|
|
798
|
+
newPlan.set(rootNode.target, map);
|
|
663
799
|
}
|
|
664
800
|
return newPlan;
|
|
665
801
|
};
|
|
@@ -668,11 +804,17 @@ var require_reducePlan = __commonJS({
|
|
|
668
804
|
|
|
669
805
|
// ../../node_modules/watchpack/lib/watchEventSource.js
|
|
670
806
|
var require_watchEventSource = __commonJS({
|
|
671
|
-
"../../node_modules/watchpack/lib/watchEventSource.js"(exports) {
|
|
807
|
+
"../../node_modules/watchpack/lib/watchEventSource.js"(exports, module) {
|
|
672
808
|
"use strict";
|
|
673
|
-
var
|
|
809
|
+
var { EventEmitter } = __require("events"), fs = __require("fs"), path2 = __require("path"), reducePlan = require_reducePlan(), IS_OSX = __require("os").platform() === "darwin", IS_WIN = __require("os").platform() === "win32", SUPPORTS_RECURSIVE_WATCHING = IS_OSX || IS_WIN, watcherLimit = (
|
|
810
|
+
// @ts-expect-error avoid additional checks
|
|
811
|
+
+process.env.WATCHPACK_WATCHER_LIMIT || (IS_OSX ? 20 : 1e4)
|
|
812
|
+
), recursiveWatcherLogging = !!process.env.WATCHPACK_RECURSIVE_WATCHER_LOGGING, isBatch = !1, watcherCount = 0, pendingWatchers = /* @__PURE__ */ new Map(), recursiveWatchers = /* @__PURE__ */ new Map(), directWatchers = /* @__PURE__ */ new Map(), underlyingWatcher = /* @__PURE__ */ new Map();
|
|
674
813
|
function createEPERMError(filePath) {
|
|
675
|
-
let error =
|
|
814
|
+
let error = (
|
|
815
|
+
/** @type {NodeJS.ErrnoException} */
|
|
816
|
+
new Error(`Operation not permitted: ${filePath}`)
|
|
817
|
+
);
|
|
676
818
|
return error.code = "EPERM", error;
|
|
677
819
|
}
|
|
678
820
|
function createHandleChangeEvent(watcher, filePath, handleChangeEvent) {
|
|
@@ -685,6 +827,9 @@ var require_watchEventSource = __commonJS({
|
|
|
685
827
|
};
|
|
686
828
|
}
|
|
687
829
|
var DirectWatcher = class {
|
|
830
|
+
/**
|
|
831
|
+
* @param {string} filePath file path
|
|
832
|
+
*/
|
|
688
833
|
constructor(filePath) {
|
|
689
834
|
this.filePath = filePath, this.watchers = /* @__PURE__ */ new Set(), this.watcher = void 0;
|
|
690
835
|
try {
|
|
@@ -710,9 +855,15 @@ var require_watchEventSource = __commonJS({
|
|
|
710
855
|
}
|
|
711
856
|
watcherCount++;
|
|
712
857
|
}
|
|
858
|
+
/**
|
|
859
|
+
* @param {Watcher} watcher a watcher
|
|
860
|
+
*/
|
|
713
861
|
add(watcher) {
|
|
714
862
|
underlyingWatcher.set(watcher, this), this.watchers.add(watcher);
|
|
715
863
|
}
|
|
864
|
+
/**
|
|
865
|
+
* @param {Watcher} watcher a watcher
|
|
866
|
+
*/
|
|
716
867
|
remove(watcher) {
|
|
717
868
|
this.watchers.delete(watcher), this.watchers.size === 0 && (directWatchers.delete(this.filePath), watcherCount--, this.watcher && this.watcher.close());
|
|
718
869
|
}
|
|
@@ -720,6 +871,9 @@ var require_watchEventSource = __commonJS({
|
|
|
720
871
|
return this.watchers;
|
|
721
872
|
}
|
|
722
873
|
}, RecursiveWatcher = class {
|
|
874
|
+
/**
|
|
875
|
+
* @param {string} rootPath a root path
|
|
876
|
+
*/
|
|
723
877
|
constructor(rootPath) {
|
|
724
878
|
this.rootPath = rootPath, this.mapWatcherToPath = /* @__PURE__ */ new Map(), this.mapPathToWatchers = /* @__PURE__ */ new Map(), this.watcher = void 0;
|
|
725
879
|
try {
|
|
@@ -728,20 +882,35 @@ var require_watchEventSource = __commonJS({
|
|
|
728
882
|
});
|
|
729
883
|
this.watcher = watcher, watcher.on("change", (type, filename) => {
|
|
730
884
|
if (filename) {
|
|
731
|
-
let dir = path2.dirname(
|
|
885
|
+
let dir = path2.dirname(
|
|
886
|
+
/** @type {string} */
|
|
887
|
+
filename
|
|
888
|
+
), watchers = this.mapPathToWatchers.get(dir);
|
|
732
889
|
if (recursiveWatcherLogging && process.stderr.write(
|
|
733
890
|
`[watchpack] dispatch ${type} event in recursive watcher (${this.rootPath}) for '${filename}' to ${watchers ? watchers.size : 0} watchers
|
|
734
891
|
`
|
|
735
892
|
), watchers === void 0) return;
|
|
736
893
|
for (let w of watchers)
|
|
737
|
-
w.emit(
|
|
894
|
+
w.emit(
|
|
895
|
+
"change",
|
|
896
|
+
/** @type {EventType} */
|
|
897
|
+
type,
|
|
898
|
+
path2.basename(
|
|
899
|
+
/** @type {string} */
|
|
900
|
+
filename
|
|
901
|
+
)
|
|
902
|
+
);
|
|
738
903
|
} else {
|
|
739
904
|
recursiveWatcherLogging && process.stderr.write(
|
|
740
905
|
`[watchpack] dispatch ${type} event in recursive watcher (${this.rootPath}) to all watchers
|
|
741
906
|
`
|
|
742
907
|
);
|
|
743
908
|
for (let w of this.mapWatcherToPath.keys())
|
|
744
|
-
w.emit(
|
|
909
|
+
w.emit(
|
|
910
|
+
"change",
|
|
911
|
+
/** @type {EventType} */
|
|
912
|
+
type
|
|
913
|
+
);
|
|
745
914
|
}
|
|
746
915
|
}), watcher.on("error", (error) => {
|
|
747
916
|
for (let w of this.mapWatcherToPath.keys())
|
|
@@ -758,6 +927,10 @@ var require_watchEventSource = __commonJS({
|
|
|
758
927
|
`
|
|
759
928
|
);
|
|
760
929
|
}
|
|
930
|
+
/**
|
|
931
|
+
* @param {string} filePath a file path
|
|
932
|
+
* @param {Watcher} watcher a watcher
|
|
933
|
+
*/
|
|
761
934
|
add(filePath, watcher) {
|
|
762
935
|
underlyingWatcher.set(watcher, this);
|
|
763
936
|
let subpath = filePath.slice(this.rootPath.length + 1) || ".";
|
|
@@ -769,11 +942,17 @@ var require_watchEventSource = __commonJS({
|
|
|
769
942
|
} else
|
|
770
943
|
set.add(watcher);
|
|
771
944
|
}
|
|
945
|
+
/**
|
|
946
|
+
* @param {Watcher} watcher a watcher
|
|
947
|
+
*/
|
|
772
948
|
remove(watcher) {
|
|
773
949
|
let subpath = this.mapWatcherToPath.get(watcher);
|
|
774
950
|
if (!subpath) return;
|
|
775
951
|
this.mapWatcherToPath.delete(watcher);
|
|
776
|
-
let set =
|
|
952
|
+
let set = (
|
|
953
|
+
/** @type {WatcherSet} */
|
|
954
|
+
this.mapPathToWatchers.get(subpath)
|
|
955
|
+
);
|
|
777
956
|
set.delete(watcher), set.size === 0 && this.mapPathToWatchers.delete(subpath), this.mapWatcherToPath.size === 0 && (recursiveWatchers.delete(this.rootPath), watcherCount--, this.watcher && this.watcher.close(), recursiveWatcherLogging && process.stderr.write(
|
|
778
957
|
`[watchpack] closed recursive watcher at ${this.rootPath}
|
|
779
958
|
`
|
|
@@ -783,6 +962,9 @@ var require_watchEventSource = __commonJS({
|
|
|
783
962
|
return this.mapWatcherToPath;
|
|
784
963
|
}
|
|
785
964
|
}, Watcher = class extends EventEmitter {
|
|
965
|
+
constructor() {
|
|
966
|
+
super();
|
|
967
|
+
}
|
|
786
968
|
close() {
|
|
787
969
|
if (pendingWatchers.has(this)) {
|
|
788
970
|
pendingWatchers.delete(this);
|
|
@@ -848,7 +1030,18 @@ var require_watchEventSource = __commonJS({
|
|
|
848
1030
|
}
|
|
849
1031
|
}
|
|
850
1032
|
};
|
|
851
|
-
exports.
|
|
1033
|
+
module.exports.Watcher = Watcher;
|
|
1034
|
+
module.exports.batch = (fn) => {
|
|
1035
|
+
isBatch = !0;
|
|
1036
|
+
try {
|
|
1037
|
+
fn();
|
|
1038
|
+
} finally {
|
|
1039
|
+
isBatch = !1, execute();
|
|
1040
|
+
}
|
|
1041
|
+
};
|
|
1042
|
+
module.exports.createHandleChangeEvent = createHandleChangeEvent;
|
|
1043
|
+
module.exports.getNumberOfWatchers = () => watcherCount;
|
|
1044
|
+
module.exports.watch = (filePath) => {
|
|
852
1045
|
let watcher = new Watcher(), directWatcher = directWatchers.get(filePath);
|
|
853
1046
|
if (directWatcher !== void 0)
|
|
854
1047
|
return directWatcher.add(watcher), watcher;
|
|
@@ -863,17 +1056,7 @@ var require_watchEventSource = __commonJS({
|
|
|
863
1056
|
}
|
|
864
1057
|
return pendingWatchers.set(watcher, filePath), isBatch || execute(), watcher;
|
|
865
1058
|
};
|
|
866
|
-
exports.
|
|
867
|
-
isBatch = !0;
|
|
868
|
-
try {
|
|
869
|
-
fn();
|
|
870
|
-
} finally {
|
|
871
|
-
isBatch = !1, execute();
|
|
872
|
-
}
|
|
873
|
-
};
|
|
874
|
-
exports.getNumberOfWatchers = () => watcherCount;
|
|
875
|
-
exports.createHandleChangeEvent = createHandleChangeEvent;
|
|
876
|
-
exports.watcherLimit = watcherLimit;
|
|
1059
|
+
module.exports.watcherLimit = watcherLimit;
|
|
877
1060
|
}
|
|
878
1061
|
});
|
|
879
1062
|
|
|
@@ -881,7 +1064,10 @@ var require_watchEventSource = __commonJS({
|
|
|
881
1064
|
var require_DirectoryWatcher = __commonJS({
|
|
882
1065
|
"../../node_modules/watchpack/lib/DirectoryWatcher.js"(exports, module) {
|
|
883
1066
|
"use strict";
|
|
884
|
-
var EventEmitter = __require("events")
|
|
1067
|
+
var { EventEmitter } = __require("events"), path2 = __require("path"), fs = require_graceful_fs(), watchEventSource = require_watchEventSource(), EXISTANCE_ONLY_TIME_ENTRY = Object.freeze({}), FS_ACCURACY = 2e3, IS_OSX = __require("os").platform() === "darwin", IS_WIN = __require("os").platform() === "win32", { WATCHPACK_POLLING } = process.env, FORCE_POLLING = (
|
|
1068
|
+
// @ts-expect-error avoid additional checks
|
|
1069
|
+
`${+WATCHPACK_POLLING}` === WATCHPACK_POLLING ? +WATCHPACK_POLLING : !!WATCHPACK_POLLING && WATCHPACK_POLLING !== "false"
|
|
1070
|
+
);
|
|
885
1071
|
function withoutCase(str) {
|
|
886
1072
|
return str.toLowerCase();
|
|
887
1073
|
}
|
|
@@ -891,38 +1077,71 @@ var require_DirectoryWatcher = __commonJS({
|
|
|
891
1077
|
return callback();
|
|
892
1078
|
};
|
|
893
1079
|
}
|
|
1080
|
+
function fixupEntryAccuracy(entry) {
|
|
1081
|
+
entry.accuracy > FS_ACCURACY && (entry.safeTime = entry.safeTime - entry.accuracy + FS_ACCURACY, entry.accuracy = FS_ACCURACY);
|
|
1082
|
+
}
|
|
1083
|
+
function ensureFsAccuracy(mtime) {
|
|
1084
|
+
mtime && (FS_ACCURACY > 1 && mtime % 1 !== 0 ? FS_ACCURACY = 1 : FS_ACCURACY > 10 && mtime % 10 !== 0 ? FS_ACCURACY = 10 : FS_ACCURACY > 100 && mtime % 100 !== 0 ? FS_ACCURACY = 100 : FS_ACCURACY > 1e3 && mtime % 1e3 !== 0 && (FS_ACCURACY = 1e3));
|
|
1085
|
+
}
|
|
894
1086
|
var Watcher = class extends EventEmitter {
|
|
895
|
-
|
|
896
|
-
|
|
1087
|
+
/**
|
|
1088
|
+
* @param {DirectoryWatcher} directoryWatcher a directory watcher
|
|
1089
|
+
* @param {string} target a target to watch
|
|
1090
|
+
* @param {number=} startTime start time
|
|
1091
|
+
*/
|
|
1092
|
+
constructor(directoryWatcher, target, startTime) {
|
|
1093
|
+
super(), this.directoryWatcher = directoryWatcher, this.path = target, this.startTime = startTime && +startTime;
|
|
897
1094
|
}
|
|
1095
|
+
/**
|
|
1096
|
+
* @param {number} mtime mtime
|
|
1097
|
+
* @param {boolean} initial true when initial, otherwise false
|
|
1098
|
+
* @returns {boolean} true of start time less than mtile, otherwise false
|
|
1099
|
+
*/
|
|
898
1100
|
checkStartTime(mtime, initial) {
|
|
899
|
-
let startTime = this
|
|
1101
|
+
let { startTime } = this;
|
|
900
1102
|
return typeof startTime != "number" ? !initial : startTime <= mtime;
|
|
901
1103
|
}
|
|
902
1104
|
close() {
|
|
903
1105
|
this.emit("closed");
|
|
904
1106
|
}
|
|
905
1107
|
}, DirectoryWatcher = class extends EventEmitter {
|
|
906
|
-
|
|
1108
|
+
/**
|
|
1109
|
+
* @param {WatcherManager} watcherManager a watcher manager
|
|
1110
|
+
* @param {string} directoryPath directory path
|
|
1111
|
+
* @param {DirectoryWatcherOptions=} options options
|
|
1112
|
+
*/
|
|
1113
|
+
constructor(watcherManager, directoryPath, options = {}) {
|
|
907
1114
|
super(), FORCE_POLLING && (options.poll = FORCE_POLLING), this.watcherManager = watcherManager, this.options = options, this.path = directoryPath, this.files = /* @__PURE__ */ new Map(), this.filesWithoutCase = /* @__PURE__ */ new Map(), this.directories = /* @__PURE__ */ new Map(), this.lastWatchEvent = 0, this.initialScan = !0, this.ignored = options.ignored || (() => !1), this.nestedWatching = !1, this.polledWatching = typeof options.poll == "number" ? options.poll : options.poll ? 5007 : !1, this.timeout = void 0, this.initialScanRemoved = /* @__PURE__ */ new Set(), this.initialScanFinished = void 0, this.watchers = /* @__PURE__ */ new Map(), this.parentWatcher = null, this.refs = 0, this._activeEvents = /* @__PURE__ */ new Map(), this.closed = !1, this.scanning = !1, this.scanAgain = !1, this.scanAgainInitial = !1, this.createWatcher(), this.doScan(!0);
|
|
908
1115
|
}
|
|
909
1116
|
createWatcher() {
|
|
910
1117
|
try {
|
|
911
|
-
this.polledWatching ? this.watcher = {
|
|
1118
|
+
this.polledWatching ? this.watcher = /** @type {EventSourceWatcher} */
|
|
1119
|
+
{
|
|
912
1120
|
close: () => {
|
|
913
1121
|
this.timeout && (clearTimeout(this.timeout), this.timeout = void 0);
|
|
914
1122
|
}
|
|
915
|
-
} : (IS_OSX && this.watchInParentDirectory(), this.watcher =
|
|
1123
|
+
} : (IS_OSX && this.watchInParentDirectory(), this.watcher = /** @type {EventSourceWatcher} */
|
|
1124
|
+
watchEventSource.watch(this.path), this.watcher.on("change", this.onWatchEvent.bind(this)), this.watcher.on("error", this.onWatcherError.bind(this)));
|
|
916
1125
|
} catch (err) {
|
|
917
1126
|
this.onWatcherError(err);
|
|
918
1127
|
}
|
|
919
1128
|
}
|
|
1129
|
+
/**
|
|
1130
|
+
* @template {(watcher: Watcher<EventMap>) => void} T
|
|
1131
|
+
* @param {string} path path
|
|
1132
|
+
* @param {T} fn function
|
|
1133
|
+
*/
|
|
920
1134
|
forEachWatcher(path3, fn) {
|
|
921
1135
|
let watchers = this.watchers.get(withoutCase(path3));
|
|
922
1136
|
if (watchers !== void 0)
|
|
923
1137
|
for (let w of watchers)
|
|
924
1138
|
fn(w);
|
|
925
1139
|
}
|
|
1140
|
+
/**
|
|
1141
|
+
* @param {string} itemPath an item path
|
|
1142
|
+
* @param {boolean} initial true when initial, otherwise false
|
|
1143
|
+
* @param {EventType} type even type
|
|
1144
|
+
*/
|
|
926
1145
|
setMissing(itemPath, initial, type) {
|
|
927
1146
|
this.initialScan && this.initialScanRemoved.add(itemPath);
|
|
928
1147
|
let oldDirectory = this.directories.get(itemPath);
|
|
@@ -931,39 +1150,55 @@ var require_DirectoryWatcher = __commonJS({
|
|
|
931
1150
|
(w) => w.emit("change", itemPath, null, type, initial)
|
|
932
1151
|
)), this.files.get(itemPath)) {
|
|
933
1152
|
this.files.delete(itemPath);
|
|
934
|
-
let key = withoutCase(itemPath), count =
|
|
1153
|
+
let key = withoutCase(itemPath), count = (
|
|
1154
|
+
/** @type {number} */
|
|
1155
|
+
this.filesWithoutCase.get(key) - 1
|
|
1156
|
+
);
|
|
935
1157
|
count <= 0 ? (this.filesWithoutCase.delete(key), this.forEachWatcher(itemPath, (w) => w.emit("remove", type))) : this.filesWithoutCase.set(key, count), initial || this.forEachWatcher(
|
|
936
1158
|
this.path,
|
|
937
1159
|
(w) => w.emit("change", itemPath, null, type, initial)
|
|
938
1160
|
);
|
|
939
1161
|
}
|
|
940
1162
|
}
|
|
941
|
-
|
|
1163
|
+
/**
|
|
1164
|
+
* @param {string} target a target to set file time
|
|
1165
|
+
* @param {number} mtime mtime
|
|
1166
|
+
* @param {boolean} initial true when initial, otherwise false
|
|
1167
|
+
* @param {boolean} ignoreWhenEqual true to ignore when equal, otherwise false
|
|
1168
|
+
* @param {EventType} type type
|
|
1169
|
+
*/
|
|
1170
|
+
setFileTime(target, mtime, initial, ignoreWhenEqual, type) {
|
|
942
1171
|
let now = Date.now();
|
|
943
|
-
if (this.ignored(
|
|
944
|
-
let old = this.files.get(
|
|
1172
|
+
if (this.ignored(target)) return;
|
|
1173
|
+
let old = this.files.get(target), safeTime, accuracy;
|
|
945
1174
|
if (initial)
|
|
946
1175
|
safeTime = Math.min(now, mtime) + FS_ACCURACY, accuracy = FS_ACCURACY;
|
|
947
1176
|
else if (safeTime = now, accuracy = 0, old && old.timestamp === mtime && mtime + FS_ACCURACY < now)
|
|
948
1177
|
return;
|
|
949
1178
|
if (!(ignoreWhenEqual && old && old.timestamp === mtime)) {
|
|
950
|
-
if (this.files.set(
|
|
1179
|
+
if (this.files.set(target, {
|
|
951
1180
|
safeTime,
|
|
952
1181
|
accuracy,
|
|
953
1182
|
timestamp: mtime
|
|
954
1183
|
}), old)
|
|
955
|
-
initial || this.forEachWatcher(
|
|
1184
|
+
initial || this.forEachWatcher(target, (w) => w.emit("change", mtime, type));
|
|
956
1185
|
else {
|
|
957
|
-
let key = withoutCase(
|
|
958
|
-
this.filesWithoutCase.set(key, (count || 0) + 1), count !== void 0 && this.doScan(!1), this.forEachWatcher(
|
|
1186
|
+
let key = withoutCase(target), count = this.filesWithoutCase.get(key);
|
|
1187
|
+
this.filesWithoutCase.set(key, (count || 0) + 1), count !== void 0 && this.doScan(!1), this.forEachWatcher(target, (w) => {
|
|
959
1188
|
(!initial || w.checkStartTime(safeTime, initial)) && w.emit("change", mtime, type);
|
|
960
1189
|
});
|
|
961
1190
|
}
|
|
962
1191
|
this.forEachWatcher(this.path, (w) => {
|
|
963
|
-
(!initial || w.checkStartTime(safeTime, initial)) && w.emit("change",
|
|
1192
|
+
(!initial || w.checkStartTime(safeTime, initial)) && w.emit("change", target, safeTime, type, initial);
|
|
964
1193
|
});
|
|
965
1194
|
}
|
|
966
1195
|
}
|
|
1196
|
+
/**
|
|
1197
|
+
* @param {string} directoryPath directory path
|
|
1198
|
+
* @param {number} birthtime birthtime
|
|
1199
|
+
* @param {boolean} initial true when initial, otherwise false
|
|
1200
|
+
* @param {EventType} type even type
|
|
1201
|
+
*/
|
|
967
1202
|
setDirectory(directoryPath, birthtime, initial, type) {
|
|
968
1203
|
if (!this.ignored(directoryPath)) {
|
|
969
1204
|
if (directoryPath === this.path)
|
|
@@ -974,8 +1209,8 @@ var require_DirectoryWatcher = __commonJS({
|
|
|
974
1209
|
else if (!this.directories.get(directoryPath)) {
|
|
975
1210
|
let now = Date.now();
|
|
976
1211
|
this.nestedWatching ? this.createNestedWatcher(directoryPath) : this.directories.set(directoryPath, !0);
|
|
977
|
-
let safeTime;
|
|
978
|
-
|
|
1212
|
+
let safeTime = initial ? Math.min(now, birthtime) + FS_ACCURACY : now;
|
|
1213
|
+
this.forEachWatcher(directoryPath, (w) => {
|
|
979
1214
|
(!initial || w.checkStartTime(safeTime, !1)) && w.emit("change", birthtime, type);
|
|
980
1215
|
}), this.forEachWatcher(this.path, (w) => {
|
|
981
1216
|
(!initial || w.checkStartTime(safeTime, initial)) && w.emit("change", directoryPath, safeTime, type, initial);
|
|
@@ -983,14 +1218,20 @@ var require_DirectoryWatcher = __commonJS({
|
|
|
983
1218
|
}
|
|
984
1219
|
}
|
|
985
1220
|
}
|
|
1221
|
+
/**
|
|
1222
|
+
* @param {string} directoryPath directory path
|
|
1223
|
+
*/
|
|
986
1224
|
createNestedWatcher(directoryPath) {
|
|
987
1225
|
let watcher = this.watcherManager.watchDirectory(directoryPath, 1);
|
|
988
|
-
watcher.on("change", (
|
|
1226
|
+
watcher.on("change", (target, mtime, type, initial) => {
|
|
989
1227
|
this.forEachWatcher(this.path, (w) => {
|
|
990
|
-
(!initial || w.checkStartTime(mtime, initial)) && w.emit("change",
|
|
1228
|
+
(!initial || w.checkStartTime(mtime, initial)) && w.emit("change", target, mtime, type, initial);
|
|
991
1229
|
});
|
|
992
1230
|
}), this.directories.set(directoryPath, watcher);
|
|
993
1231
|
}
|
|
1232
|
+
/**
|
|
1233
|
+
* @param {boolean} flag true when nested, otherwise false
|
|
1234
|
+
*/
|
|
994
1235
|
setNestedWatching(flag) {
|
|
995
1236
|
if (this.nestedWatching !== !!flag)
|
|
996
1237
|
if (this.nestedWatching = !!flag, this.nestedWatching)
|
|
@@ -1000,30 +1241,38 @@ var require_DirectoryWatcher = __commonJS({
|
|
|
1000
1241
|
for (let [directory, watcher] of this.directories)
|
|
1001
1242
|
watcher.close(), this.directories.set(directory, !0);
|
|
1002
1243
|
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1244
|
+
/**
|
|
1245
|
+
* @param {string} target a target to watch
|
|
1246
|
+
* @param {number=} startTime start time
|
|
1247
|
+
* @returns {Watcher<DirectoryWatcherEvents> | Watcher<FileWatcherEvents>} watcher
|
|
1248
|
+
*/
|
|
1249
|
+
watch(target, startTime) {
|
|
1250
|
+
let key = withoutCase(target), watchers = this.watchers.get(key);
|
|
1005
1251
|
watchers === void 0 && (watchers = /* @__PURE__ */ new Set(), this.watchers.set(key, watchers)), this.refs++;
|
|
1006
|
-
let watcher =
|
|
1252
|
+
let watcher = (
|
|
1253
|
+
/** @type {Watcher<DirectoryWatcherEvents> | Watcher<FileWatcherEvents>} */
|
|
1254
|
+
new Watcher(this, target, startTime)
|
|
1255
|
+
);
|
|
1007
1256
|
watcher.on("closed", () => {
|
|
1008
1257
|
if (--this.refs <= 0) {
|
|
1009
1258
|
this.close();
|
|
1010
1259
|
return;
|
|
1011
1260
|
}
|
|
1012
|
-
watchers.delete(watcher), watchers.size === 0 && (this.watchers.delete(key), this.path ===
|
|
1261
|
+
watchers.delete(watcher), watchers.size === 0 && (this.watchers.delete(key), this.path === target && this.setNestedWatching(!1));
|
|
1013
1262
|
}), watchers.add(watcher);
|
|
1014
1263
|
let safeTime;
|
|
1015
|
-
if (
|
|
1264
|
+
if (target === this.path) {
|
|
1016
1265
|
this.setNestedWatching(!0), safeTime = this.lastWatchEvent;
|
|
1017
1266
|
for (let entry of this.files.values())
|
|
1018
1267
|
fixupEntryAccuracy(entry), safeTime = Math.max(safeTime, entry.safeTime);
|
|
1019
1268
|
} else {
|
|
1020
|
-
let entry = this.files.get(
|
|
1269
|
+
let entry = this.files.get(target);
|
|
1021
1270
|
entry ? (fixupEntryAccuracy(entry), safeTime = entry.safeTime) : safeTime = 0;
|
|
1022
1271
|
}
|
|
1023
|
-
return safeTime ? safeTime >= startTime && process.nextTick(() => {
|
|
1024
|
-
this.closed || (
|
|
1272
|
+
return safeTime ? startTime && safeTime >= startTime && process.nextTick(() => {
|
|
1273
|
+
this.closed || (target === this.path ? watcher.emit(
|
|
1025
1274
|
"change",
|
|
1026
|
-
|
|
1275
|
+
target,
|
|
1027
1276
|
safeTime,
|
|
1028
1277
|
"watch (outdated on attach)",
|
|
1029
1278
|
!0
|
|
@@ -1033,41 +1282,48 @@ var require_DirectoryWatcher = __commonJS({
|
|
|
1033
1282
|
"watch (outdated on attach)",
|
|
1034
1283
|
!0
|
|
1035
1284
|
));
|
|
1036
|
-
}) : this.initialScan ?
|
|
1037
|
-
|
|
1038
|
-
|
|
1285
|
+
}) : this.initialScan ? (
|
|
1286
|
+
/** @type {InitialScanRemoved} */
|
|
1287
|
+
this.initialScanRemoved.has(target) && process.nextTick(() => {
|
|
1288
|
+
this.closed || watcher.emit("remove");
|
|
1289
|
+
})
|
|
1290
|
+
) : target !== this.path && !this.directories.has(target) && watcher.checkStartTime(
|
|
1291
|
+
/** @type {number} */
|
|
1292
|
+
this.initialScanFinished,
|
|
1293
|
+
!1
|
|
1294
|
+
) && process.nextTick(() => {
|
|
1039
1295
|
this.closed || watcher.emit("initial-missing", "watch (missing on attach)");
|
|
1040
1296
|
}), watcher;
|
|
1041
1297
|
}
|
|
1298
|
+
/**
|
|
1299
|
+
* @param {EventType} eventType event type
|
|
1300
|
+
* @param {string=} filename filename
|
|
1301
|
+
*/
|
|
1042
1302
|
onWatchEvent(eventType, filename) {
|
|
1043
1303
|
if (this.closed) return;
|
|
1044
1304
|
if (!filename) {
|
|
1045
1305
|
this.doScan(!1);
|
|
1046
1306
|
return;
|
|
1047
1307
|
}
|
|
1048
|
-
let
|
|
1049
|
-
if (!this.ignored(
|
|
1308
|
+
let target = path2.join(this.path, filename);
|
|
1309
|
+
if (!this.ignored(target))
|
|
1050
1310
|
if (this._activeEvents.get(filename) === void 0) {
|
|
1051
1311
|
this._activeEvents.set(filename, !1);
|
|
1052
1312
|
let checkStats = () => {
|
|
1053
|
-
this.closed || (this._activeEvents.set(filename, !1), fs.lstat(
|
|
1313
|
+
this.closed || (this._activeEvents.set(filename, !1), fs.lstat(target, (err, stats) => {
|
|
1054
1314
|
if (!this.closed) {
|
|
1055
1315
|
if (this._activeEvents.get(filename) === !0) {
|
|
1056
1316
|
process.nextTick(checkStats);
|
|
1057
1317
|
return;
|
|
1058
1318
|
}
|
|
1059
|
-
this._activeEvents.delete(filename), err && (err.code !== "ENOENT" && err.code !== "EPERM" && err.code !== "EBUSY" ? this.onStatsError(err) : filename === path2.basename(this.path) &&
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
!1,
|
|
1063
|
-
eventType
|
|
1064
|
-
) : (stats.isFile() || stats.isSymbolicLink()) && (stats.mtime && ensureFsAccuracy(stats.mtime), this.setFileTime(
|
|
1065
|
-
filePath,
|
|
1319
|
+
this._activeEvents.delete(filename), err && (err.code !== "ENOENT" && err.code !== "EPERM" && err.code !== "EBUSY" ? this.onStatsError(err) : filename === path2.basename(this.path) && // This may indicate that the directory itself was removed
|
|
1320
|
+
!fs.existsSync(this.path) && this.onDirectoryRemoved("stat failed")), this.lastWatchEvent = Date.now(), stats ? stats.isDirectory() ? this.setDirectory(target, +stats.birthtime || 1, !1, eventType) : (stats.isFile() || stats.isSymbolicLink()) && (stats.mtime && ensureFsAccuracy(+stats.mtime), this.setFileTime(
|
|
1321
|
+
target,
|
|
1066
1322
|
+stats.mtime || +stats.ctime || 1,
|
|
1067
1323
|
!1,
|
|
1068
1324
|
!1,
|
|
1069
1325
|
eventType
|
|
1070
|
-
)) : this.setMissing(
|
|
1326
|
+
)) : this.setMissing(target, !1, eventType);
|
|
1071
1327
|
}
|
|
1072
1328
|
}));
|
|
1073
1329
|
};
|
|
@@ -1075,27 +1331,44 @@ var require_DirectoryWatcher = __commonJS({
|
|
|
1075
1331
|
} else
|
|
1076
1332
|
this._activeEvents.set(filename, !0);
|
|
1077
1333
|
}
|
|
1334
|
+
/**
|
|
1335
|
+
* @param {unknown=} err error
|
|
1336
|
+
*/
|
|
1078
1337
|
onWatcherError(err) {
|
|
1079
|
-
this.closed || err &&
|
|
1338
|
+
this.closed || err && /** @type {NodeJS.ErrnoException} */
|
|
1339
|
+
(err.code !== "EPERM" && /** @type {NodeJS.ErrnoException} */
|
|
1340
|
+
err.code !== "ENOENT" && console.error(`Watchpack Error (watcher): ${err}`), this.onDirectoryRemoved("watch error"));
|
|
1080
1341
|
}
|
|
1342
|
+
/**
|
|
1343
|
+
* @param {Error | NodeJS.ErrnoException=} err error
|
|
1344
|
+
*/
|
|
1081
1345
|
onStatsError(err) {
|
|
1082
|
-
err && console.error(
|
|
1346
|
+
err && console.error(`Watchpack Error (stats): ${err}`);
|
|
1083
1347
|
}
|
|
1348
|
+
/**
|
|
1349
|
+
* @param {Error | NodeJS.ErrnoException=} err error
|
|
1350
|
+
*/
|
|
1084
1351
|
onScanError(err) {
|
|
1085
|
-
err && console.error(
|
|
1352
|
+
err && console.error(`Watchpack Error (initial scan): ${err}`), this.onScanFinished();
|
|
1086
1353
|
}
|
|
1087
1354
|
onScanFinished() {
|
|
1088
1355
|
this.polledWatching && (this.timeout = setTimeout(() => {
|
|
1089
1356
|
this.closed || this.doScan(!1);
|
|
1090
1357
|
}, this.polledWatching));
|
|
1091
1358
|
}
|
|
1359
|
+
/**
|
|
1360
|
+
* @param {string} reason a reason
|
|
1361
|
+
*/
|
|
1092
1362
|
onDirectoryRemoved(reason) {
|
|
1093
1363
|
this.watcher && (this.watcher.close(), this.watcher = null), this.watchInParentDirectory();
|
|
1094
|
-
let type =
|
|
1364
|
+
let type = (
|
|
1365
|
+
/** @type {EventType} */
|
|
1366
|
+
`directory-removed (${reason})`
|
|
1367
|
+
);
|
|
1095
1368
|
for (let directory of this.directories.keys())
|
|
1096
|
-
this.setMissing(directory,
|
|
1369
|
+
this.setMissing(directory, !1, type);
|
|
1097
1370
|
for (let file of this.files.keys())
|
|
1098
|
-
this.setMissing(file,
|
|
1371
|
+
this.setMissing(file, !1, type);
|
|
1099
1372
|
}
|
|
1100
1373
|
watchInParentDirectory() {
|
|
1101
1374
|
if (!this.parentWatcher) {
|
|
@@ -1111,6 +1384,9 @@ var require_DirectoryWatcher = __commonJS({
|
|
|
1111
1384
|
});
|
|
1112
1385
|
}
|
|
1113
1386
|
}
|
|
1387
|
+
/**
|
|
1388
|
+
* @param {boolean} initial true when initial, otherwise false
|
|
1389
|
+
*/
|
|
1114
1390
|
doScan(initial) {
|
|
1115
1391
|
if (this.scanning) {
|
|
1116
1392
|
this.scanAgain ? initial || (this.scanAgainInitial = !1) : (this.scanAgain = !0, this.scanAgainInitial = initial);
|
|
@@ -1163,10 +1439,10 @@ var require_DirectoryWatcher = __commonJS({
|
|
|
1163
1439
|
if (!this.closed) {
|
|
1164
1440
|
if (err2) {
|
|
1165
1441
|
err2.code === "ENOENT" || err2.code === "EPERM" || err2.code === "EACCES" || err2.code === "EBUSY" || // TODO https://github.com/libuv/libuv/pull/4566
|
|
1166
|
-
err2.code === "EINVAL" && IS_WIN ? this.setMissing(itemPath, initial,
|
|
1442
|
+
err2.code === "EINVAL" && IS_WIN ? this.setMissing(itemPath, initial, `scan (${err2.code})`) : this.onScanError(err2), itemFinished();
|
|
1167
1443
|
return;
|
|
1168
1444
|
}
|
|
1169
|
-
stats.isFile() || stats.isSymbolicLink() ? (stats.mtime && ensureFsAccuracy(stats.mtime), this.setFileTime(
|
|
1445
|
+
stats.isFile() || stats.isSymbolicLink() ? (stats.mtime && ensureFsAccuracy(+stats.mtime), this.setFileTime(
|
|
1170
1446
|
itemPath,
|
|
1171
1447
|
+stats.mtime || +stats.ctime || 1,
|
|
1172
1448
|
initial,
|
|
@@ -1184,13 +1460,19 @@ var require_DirectoryWatcher = __commonJS({
|
|
|
1184
1460
|
});
|
|
1185
1461
|
});
|
|
1186
1462
|
}
|
|
1463
|
+
/**
|
|
1464
|
+
* @returns {Record<string, number>} times
|
|
1465
|
+
*/
|
|
1187
1466
|
getTimes() {
|
|
1188
1467
|
let obj = /* @__PURE__ */ Object.create(null), safeTime = this.lastWatchEvent;
|
|
1189
1468
|
for (let [file, entry] of this.files)
|
|
1190
1469
|
fixupEntryAccuracy(entry), safeTime = Math.max(safeTime, entry.safeTime), obj[file] = Math.max(entry.safeTime, entry.timestamp);
|
|
1191
1470
|
if (this.nestedWatching) {
|
|
1192
1471
|
for (let w of this.directories.values()) {
|
|
1193
|
-
let times =
|
|
1472
|
+
let times = (
|
|
1473
|
+
/** @type {Watcher<DirectoryWatcherEvents>} */
|
|
1474
|
+
w.directoryWatcher.getTimes()
|
|
1475
|
+
);
|
|
1194
1476
|
for (let file of Object.keys(times)) {
|
|
1195
1477
|
let time = times[file];
|
|
1196
1478
|
safeTime = Math.max(safeTime, time), obj[file] = time;
|
|
@@ -1201,11 +1483,16 @@ var require_DirectoryWatcher = __commonJS({
|
|
|
1201
1483
|
if (!this.initialScan)
|
|
1202
1484
|
for (let watchers of this.watchers.values())
|
|
1203
1485
|
for (let watcher of watchers) {
|
|
1204
|
-
let path3 = watcher
|
|
1486
|
+
let { path: path3 } = watcher;
|
|
1205
1487
|
Object.prototype.hasOwnProperty.call(obj, path3) || (obj[path3] = null);
|
|
1206
1488
|
}
|
|
1207
1489
|
return obj;
|
|
1208
1490
|
}
|
|
1491
|
+
/**
|
|
1492
|
+
* @param {TimeInfoEntries} fileTimestamps file timestamps
|
|
1493
|
+
* @param {TimeInfoEntries} directoryTimestamps directory timestamps
|
|
1494
|
+
* @returns {number} safe time
|
|
1495
|
+
*/
|
|
1209
1496
|
collectTimeInfoEntries(fileTimestamps, directoryTimestamps) {
|
|
1210
1497
|
let safeTime = this.lastWatchEvent;
|
|
1211
1498
|
for (let [file, entry] of this.files)
|
|
@@ -1214,6 +1501,7 @@ var require_DirectoryWatcher = __commonJS({
|
|
|
1214
1501
|
for (let w of this.directories.values())
|
|
1215
1502
|
safeTime = Math.max(
|
|
1216
1503
|
safeTime,
|
|
1504
|
+
/** @type {Watcher<DirectoryWatcherEvents>} */
|
|
1217
1505
|
w.directoryWatcher.collectTimeInfoEntries(
|
|
1218
1506
|
fileTimestamps,
|
|
1219
1507
|
directoryTimestamps
|
|
@@ -1230,7 +1518,7 @@ var require_DirectoryWatcher = __commonJS({
|
|
|
1230
1518
|
if (!this.initialScan)
|
|
1231
1519
|
for (let watchers of this.watchers.values())
|
|
1232
1520
|
for (let watcher of watchers) {
|
|
1233
|
-
let path3 = watcher
|
|
1521
|
+
let { path: path3 } = watcher;
|
|
1234
1522
|
fileTimestamps.has(path3) || fileTimestamps.set(path3, null);
|
|
1235
1523
|
}
|
|
1236
1524
|
return safeTime;
|
|
@@ -1246,178 +1534,68 @@ var require_DirectoryWatcher = __commonJS({
|
|
|
1246
1534
|
};
|
|
1247
1535
|
module.exports = DirectoryWatcher;
|
|
1248
1536
|
module.exports.EXISTANCE_ONLY_TIME_ENTRY = EXISTANCE_ONLY_TIME_ENTRY;
|
|
1249
|
-
|
|
1250
|
-
entry.accuracy > FS_ACCURACY && (entry.safeTime = entry.safeTime - entry.accuracy + FS_ACCURACY, entry.accuracy = FS_ACCURACY);
|
|
1251
|
-
}
|
|
1252
|
-
function ensureFsAccuracy(mtime) {
|
|
1253
|
-
mtime && (FS_ACCURACY > 1 && mtime % 1 !== 0 ? FS_ACCURACY = 1 : FS_ACCURACY > 10 && mtime % 10 !== 0 ? FS_ACCURACY = 10 : FS_ACCURACY > 100 && mtime % 100 !== 0 ? FS_ACCURACY = 100 : FS_ACCURACY > 1e3 && mtime % 1e3 !== 0 && (FS_ACCURACY = 1e3));
|
|
1254
|
-
}
|
|
1537
|
+
module.exports.Watcher = Watcher;
|
|
1255
1538
|
}
|
|
1256
1539
|
});
|
|
1257
1540
|
|
|
1258
1541
|
// ../../node_modules/watchpack/lib/getWatcherManager.js
|
|
1259
|
-
var require_getWatcherManager = __commonJS({
|
|
1260
|
-
"../../node_modules/watchpack/lib/getWatcherManager.js"(exports, module) {
|
|
1261
|
-
"use strict";
|
|
1262
|
-
var path2 = __require("path"), DirectoryWatcher = require_DirectoryWatcher(), WatcherManager = class {
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
watchDirectory(directory, startTime) {
|
|
1281
|
-
return this.getDirectoryWatcher(directory).watch(directory, startTime);
|
|
1282
|
-
}
|
|
1283
|
-
}, watcherManagers = /* @__PURE__ */ new WeakMap();
|
|
1284
|
-
module.exports = (options) => {
|
|
1285
|
-
let watcherManager = watcherManagers.get(options);
|
|
1286
|
-
if (watcherManager !== void 0) return watcherManager;
|
|
1287
|
-
let newWatcherManager = new WatcherManager(options);
|
|
1288
|
-
return watcherManagers.set(options, newWatcherManager), newWatcherManager;
|
|
1289
|
-
};
|
|
1290
|
-
module.exports.WatcherManager = WatcherManager;
|
|
1291
|
-
}
|
|
1292
|
-
});
|
|
1293
|
-
|
|
1294
|
-
// ../../node_modules/watchpack/lib/LinkResolver.js
|
|
1295
|
-
var require_LinkResolver = __commonJS({
|
|
1296
|
-
"../../node_modules/watchpack/lib/LinkResolver.js"(exports, module) {
|
|
1297
|
-
"use strict";
|
|
1298
|
-
var fs = __require("fs"), path2 = __require("path"), EXPECTED_ERRORS = /* @__PURE__ */ new Set(["EINVAL", "ENOENT"]);
|
|
1299
|
-
process.platform === "win32" && EXPECTED_ERRORS.add("UNKNOWN");
|
|
1300
|
-
var LinkResolver = class {
|
|
1301
|
-
constructor() {
|
|
1302
|
-
this.cache = /* @__PURE__ */ new Map();
|
|
1303
|
-
}
|
|
1304
|
-
/**
|
|
1305
|
-
* @param {string} file path to file or directory
|
|
1306
|
-
* @returns {string[]} array of file and all symlinks contributed in the resolving process (first item is the resolved file)
|
|
1307
|
-
*/
|
|
1308
|
-
resolve(file) {
|
|
1309
|
-
let cacheEntry = this.cache.get(file);
|
|
1310
|
-
if (cacheEntry !== void 0)
|
|
1311
|
-
return cacheEntry;
|
|
1312
|
-
let parent = path2.dirname(file);
|
|
1313
|
-
if (parent === file) {
|
|
1314
|
-
let result = Object.freeze([file]);
|
|
1315
|
-
return this.cache.set(file, result), result;
|
|
1316
|
-
}
|
|
1317
|
-
let parentResolved = this.resolve(parent), realFile = file;
|
|
1318
|
-
if (parentResolved[0] !== parent) {
|
|
1319
|
-
let basename4 = path2.basename(file);
|
|
1320
|
-
realFile = path2.resolve(parentResolved[0], basename4);
|
|
1321
|
-
}
|
|
1322
|
-
try {
|
|
1323
|
-
let linkContent = fs.readlinkSync(realFile), resolvedLink = path2.resolve(parentResolved[0], linkContent), linkResolved = this.resolve(resolvedLink), result;
|
|
1324
|
-
if (linkResolved.length > 1 && parentResolved.length > 1) {
|
|
1325
|
-
let resultSet = new Set(linkResolved);
|
|
1326
|
-
resultSet.add(realFile);
|
|
1327
|
-
for (let i = 1; i < parentResolved.length; i++)
|
|
1328
|
-
resultSet.add(parentResolved[i]);
|
|
1329
|
-
result = Object.freeze(Array.from(resultSet));
|
|
1330
|
-
} else parentResolved.length > 1 ? (result = parentResolved.slice(), result[0] = linkResolved[0], result.push(realFile), Object.freeze(result)) : linkResolved.length > 1 ? (result = linkResolved.slice(), result.push(realFile), Object.freeze(result)) : result = Object.freeze([
|
|
1331
|
-
// the resolve real location
|
|
1332
|
-
linkResolved[0],
|
|
1333
|
-
// add the link
|
|
1334
|
-
realFile
|
|
1335
|
-
]);
|
|
1336
|
-
return this.cache.set(file, result), result;
|
|
1337
|
-
} catch (e) {
|
|
1338
|
-
if (!EXPECTED_ERRORS.has(e.code))
|
|
1339
|
-
throw e;
|
|
1340
|
-
let result = parentResolved.slice();
|
|
1341
|
-
return result[0] = realFile, Object.freeze(result), this.cache.set(file, result), result;
|
|
1342
|
-
}
|
|
1343
|
-
}
|
|
1344
|
-
};
|
|
1345
|
-
module.exports = LinkResolver;
|
|
1346
|
-
}
|
|
1347
|
-
});
|
|
1348
|
-
|
|
1349
|
-
// ../../node_modules/glob-to-regexp/index.js
|
|
1350
|
-
var require_glob_to_regexp = __commonJS({
|
|
1351
|
-
"../../node_modules/glob-to-regexp/index.js"(exports, module) {
|
|
1352
|
-
module.exports = function(glob, opts) {
|
|
1353
|
-
if (typeof glob != "string")
|
|
1354
|
-
throw new TypeError("Expected a string");
|
|
1355
|
-
for (var str = String(glob), reStr = "", extended = opts ? !!opts.extended : !1, globstar = opts ? !!opts.globstar : !1, inGroup = !1, flags = opts && typeof opts.flags == "string" ? opts.flags : "", c, i = 0, len = str.length; i < len; i++)
|
|
1356
|
-
switch (c = str[i], c) {
|
|
1357
|
-
case "/":
|
|
1358
|
-
case "$":
|
|
1359
|
-
case "^":
|
|
1360
|
-
case "+":
|
|
1361
|
-
case ".":
|
|
1362
|
-
case "(":
|
|
1363
|
-
case ")":
|
|
1364
|
-
case "=":
|
|
1365
|
-
case "!":
|
|
1366
|
-
case "|":
|
|
1367
|
-
reStr += "\\" + c;
|
|
1368
|
-
break;
|
|
1369
|
-
case "?":
|
|
1370
|
-
if (extended) {
|
|
1371
|
-
reStr += ".";
|
|
1372
|
-
break;
|
|
1373
|
-
}
|
|
1374
|
-
case "[":
|
|
1375
|
-
case "]":
|
|
1376
|
-
if (extended) {
|
|
1377
|
-
reStr += c;
|
|
1378
|
-
break;
|
|
1379
|
-
}
|
|
1380
|
-
case "{":
|
|
1381
|
-
if (extended) {
|
|
1382
|
-
inGroup = !0, reStr += "(";
|
|
1383
|
-
break;
|
|
1384
|
-
}
|
|
1385
|
-
case "}":
|
|
1386
|
-
if (extended) {
|
|
1387
|
-
inGroup = !1, reStr += ")";
|
|
1388
|
-
break;
|
|
1389
|
-
}
|
|
1390
|
-
case ",":
|
|
1391
|
-
if (inGroup) {
|
|
1392
|
-
reStr += "|";
|
|
1393
|
-
break;
|
|
1394
|
-
}
|
|
1395
|
-
reStr += "\\" + c;
|
|
1396
|
-
break;
|
|
1397
|
-
case "*":
|
|
1398
|
-
for (var prevChar = str[i - 1], starCount = 1; str[i + 1] === "*"; )
|
|
1399
|
-
starCount++, i++;
|
|
1400
|
-
var nextChar = str[i + 1];
|
|
1401
|
-
if (!globstar)
|
|
1402
|
-
reStr += ".*";
|
|
1403
|
-
else {
|
|
1404
|
-
var isGlobstar = starCount > 1 && (prevChar === "/" || prevChar === void 0) && (nextChar === "/" || nextChar === void 0);
|
|
1405
|
-
isGlobstar ? (reStr += "((?:[^/]*(?:/|$))*)", i++) : reStr += "([^/]*)";
|
|
1406
|
-
}
|
|
1407
|
-
break;
|
|
1408
|
-
default:
|
|
1409
|
-
reStr += c;
|
|
1542
|
+
var require_getWatcherManager = __commonJS({
|
|
1543
|
+
"../../node_modules/watchpack/lib/getWatcherManager.js"(exports, module) {
|
|
1544
|
+
"use strict";
|
|
1545
|
+
var path2 = __require("path"), DirectoryWatcher = require_DirectoryWatcher(), WatcherManager = class {
|
|
1546
|
+
/**
|
|
1547
|
+
* @param {DirectoryWatcherOptions=} options options
|
|
1548
|
+
*/
|
|
1549
|
+
constructor(options = {}) {
|
|
1550
|
+
this.options = options, this.directoryWatchers = /* @__PURE__ */ new Map();
|
|
1551
|
+
}
|
|
1552
|
+
/**
|
|
1553
|
+
* @param {string} directory a directory
|
|
1554
|
+
* @returns {DirectoryWatcher} a directory watcher
|
|
1555
|
+
*/
|
|
1556
|
+
getDirectoryWatcher(directory) {
|
|
1557
|
+
let watcher = this.directoryWatchers.get(directory);
|
|
1558
|
+
if (watcher === void 0) {
|
|
1559
|
+
let newWatcher = new DirectoryWatcher(this, directory, this.options);
|
|
1560
|
+
return this.directoryWatchers.set(directory, newWatcher), newWatcher.on("closed", () => {
|
|
1561
|
+
this.directoryWatchers.delete(directory);
|
|
1562
|
+
}), newWatcher;
|
|
1410
1563
|
}
|
|
1411
|
-
|
|
1564
|
+
return watcher;
|
|
1565
|
+
}
|
|
1566
|
+
/**
|
|
1567
|
+
* @param {string} file file
|
|
1568
|
+
* @param {number=} startTime start time
|
|
1569
|
+
* @returns {Watcher<FileWatcherEvents> | null} watcher or null if file has no directory
|
|
1570
|
+
*/
|
|
1571
|
+
watchFile(file, startTime) {
|
|
1572
|
+
let directory = path2.dirname(file);
|
|
1573
|
+
return directory === file ? null : this.getDirectoryWatcher(directory).watch(file, startTime);
|
|
1574
|
+
}
|
|
1575
|
+
/**
|
|
1576
|
+
* @param {string} directory directory
|
|
1577
|
+
* @param {number=} startTime start time
|
|
1578
|
+
* @returns {Watcher<DirectoryWatcherEvents>} watcher
|
|
1579
|
+
*/
|
|
1580
|
+
watchDirectory(directory, startTime) {
|
|
1581
|
+
return this.getDirectoryWatcher(directory).watch(directory, startTime);
|
|
1582
|
+
}
|
|
1583
|
+
}, watcherManagers = /* @__PURE__ */ new WeakMap();
|
|
1584
|
+
module.exports = (options) => {
|
|
1585
|
+
let watcherManager = watcherManagers.get(options);
|
|
1586
|
+
if (watcherManager !== void 0) return watcherManager;
|
|
1587
|
+
let newWatcherManager = new WatcherManager(options);
|
|
1588
|
+
return watcherManagers.set(options, newWatcherManager), newWatcherManager;
|
|
1412
1589
|
};
|
|
1590
|
+
module.exports.WatcherManager = WatcherManager;
|
|
1413
1591
|
}
|
|
1414
1592
|
});
|
|
1415
1593
|
|
|
1416
|
-
// ../../node_modules/watchpack/lib/
|
|
1417
|
-
var
|
|
1418
|
-
"../../node_modules/watchpack/lib/
|
|
1594
|
+
// ../../node_modules/watchpack/lib/index.js
|
|
1595
|
+
var require_lib2 = __commonJS({
|
|
1596
|
+
"../../node_modules/watchpack/lib/index.js"(exports, module) {
|
|
1419
1597
|
"use strict";
|
|
1420
|
-
var
|
|
1598
|
+
var { EventEmitter } = __require("events"), globToRegExp = require_glob_to_regexp(), LinkResolver = require_LinkResolver(), getWatcherManager = require_getWatcherManager(), watchEventSource = require_watchEventSource();
|
|
1421
1599
|
function addWatchersToSet(watchers, set) {
|
|
1422
1600
|
for (let ww of watchers) {
|
|
1423
1601
|
let w = ww.watcher;
|
|
@@ -1427,25 +1605,25 @@ var require_watchpack = __commonJS({
|
|
|
1427
1605
|
var stringToRegexp = (ignored) => {
|
|
1428
1606
|
if (ignored.length === 0)
|
|
1429
1607
|
return;
|
|
1430
|
-
let source = globToRegExp(ignored, { globstar: !0, extended: !0 })
|
|
1431
|
-
return source.slice(0,
|
|
1608
|
+
let { source } = globToRegExp(ignored, { globstar: !0, extended: !0 });
|
|
1609
|
+
return `${source.slice(0, -1)}(?:$|\\/)`;
|
|
1432
1610
|
}, ignoredToFunction = (ignored) => {
|
|
1433
1611
|
if (Array.isArray(ignored)) {
|
|
1434
1612
|
let stringRegexps = ignored.map((i) => stringToRegexp(i)).filter(Boolean);
|
|
1435
1613
|
if (stringRegexps.length === 0)
|
|
1436
1614
|
return () => !1;
|
|
1437
1615
|
let regexp = new RegExp(stringRegexps.join("|"));
|
|
1438
|
-
return (
|
|
1616
|
+
return (item) => regexp.test(item.replace(/\\/g, "/"));
|
|
1439
1617
|
} else if (typeof ignored == "string") {
|
|
1440
1618
|
let stringRegexp = stringToRegexp(ignored);
|
|
1441
1619
|
if (!stringRegexp)
|
|
1442
1620
|
return () => !1;
|
|
1443
1621
|
let regexp = new RegExp(stringRegexp);
|
|
1444
|
-
return (
|
|
1622
|
+
return (item) => regexp.test(item.replace(/\\/g, "/"));
|
|
1445
1623
|
} else {
|
|
1446
1624
|
if (ignored instanceof RegExp)
|
|
1447
|
-
return (
|
|
1448
|
-
if (ignored
|
|
1625
|
+
return (item) => ignored.test(item.replace(/\\/g, "/"));
|
|
1626
|
+
if (typeof ignored == "function")
|
|
1449
1627
|
return ignored;
|
|
1450
1628
|
if (ignored)
|
|
1451
1629
|
throw new Error(`Invalid option for 'ignored': ${ignored}`);
|
|
@@ -1461,11 +1639,16 @@ var require_watchpack = __commonJS({
|
|
|
1461
1639
|
let normalized = normalizeOptions(options);
|
|
1462
1640
|
return normalizeCache.set(options, normalized), normalized;
|
|
1463
1641
|
}, WatchpackFileWatcher = class {
|
|
1642
|
+
/**
|
|
1643
|
+
* @param {Watchpack} watchpack watchpack
|
|
1644
|
+
* @param {Watcher<FileWatcherEvents>} watcher watcher
|
|
1645
|
+
* @param {string | string[]} files files
|
|
1646
|
+
*/
|
|
1464
1647
|
constructor(watchpack, watcher, files) {
|
|
1465
1648
|
this.files = Array.isArray(files) ? files : [files], this.watcher = watcher, watcher.on("initial-missing", (type) => {
|
|
1466
1649
|
for (let file of this.files)
|
|
1467
1650
|
watchpack._missing.has(file) || watchpack._onRemove(file, file, type);
|
|
1468
|
-
}), watcher.on("change", (mtime, type) => {
|
|
1651
|
+
}), watcher.on("change", (mtime, type, _initial) => {
|
|
1469
1652
|
for (let file of this.files)
|
|
1470
1653
|
watchpack._onChange(file, mtime, file, type);
|
|
1471
1654
|
}), watcher.on("remove", (type) => {
|
|
@@ -1473,6 +1656,9 @@ var require_watchpack = __commonJS({
|
|
|
1473
1656
|
watchpack._onRemove(file, file, type);
|
|
1474
1657
|
});
|
|
1475
1658
|
}
|
|
1659
|
+
/**
|
|
1660
|
+
* @param {string | string[]} files files
|
|
1661
|
+
*/
|
|
1476
1662
|
update(files) {
|
|
1477
1663
|
Array.isArray(files) ? this.files = files : this.files.length !== 1 ? this.files = [files] : this.files[0] !== files && (this.files[0] = files);
|
|
1478
1664
|
}
|
|
@@ -1480,11 +1666,16 @@ var require_watchpack = __commonJS({
|
|
|
1480
1666
|
this.watcher.close();
|
|
1481
1667
|
}
|
|
1482
1668
|
}, WatchpackDirectoryWatcher = class {
|
|
1669
|
+
/**
|
|
1670
|
+
* @param {Watchpack} watchpack watchpack
|
|
1671
|
+
* @param {Watcher<DirectoryWatcherEvents>} watcher watcher
|
|
1672
|
+
* @param {string} directories directories
|
|
1673
|
+
*/
|
|
1483
1674
|
constructor(watchpack, watcher, directories) {
|
|
1484
1675
|
this.directories = Array.isArray(directories) ? directories : [directories], this.watcher = watcher, watcher.on("initial-missing", (type) => {
|
|
1485
1676
|
for (let item of this.directories)
|
|
1486
1677
|
watchpack._onRemove(item, item, type);
|
|
1487
|
-
}), watcher.on("change", (file, mtime, type) => {
|
|
1678
|
+
}), watcher.on("change", (file, mtime, type, _initial) => {
|
|
1488
1679
|
for (let item of this.directories)
|
|
1489
1680
|
watchpack._onChange(item, mtime, file, type);
|
|
1490
1681
|
}), watcher.on("remove", (type) => {
|
|
@@ -1492,6 +1683,9 @@ var require_watchpack = __commonJS({
|
|
|
1492
1683
|
watchpack._onRemove(item, item, type);
|
|
1493
1684
|
});
|
|
1494
1685
|
}
|
|
1686
|
+
/**
|
|
1687
|
+
* @param {string | string[]} directories directories
|
|
1688
|
+
*/
|
|
1495
1689
|
update(directories) {
|
|
1496
1690
|
Array.isArray(directories) ? this.directories = directories : this.directories.length !== 1 ? this.directories = [directories] : this.directories[0] !== directories && (this.directories[0] = directories);
|
|
1497
1691
|
}
|
|
@@ -1499,18 +1693,43 @@ var require_watchpack = __commonJS({
|
|
|
1499
1693
|
this.watcher.close();
|
|
1500
1694
|
}
|
|
1501
1695
|
}, Watchpack3 = class extends EventEmitter {
|
|
1502
|
-
|
|
1503
|
-
|
|
1696
|
+
/**
|
|
1697
|
+
* @param {WatchOptions=} options options
|
|
1698
|
+
*/
|
|
1699
|
+
constructor(options = {}) {
|
|
1700
|
+
super(), options || (options = {}), this.options = options, this.aggregateTimeout = typeof options.aggregateTimeout == "number" ? options.aggregateTimeout : 200, this.watcherOptions = cachedNormalizeOptions(options), this.watcherManager = getWatcherManager(this.watcherOptions), this.fileWatchers = /* @__PURE__ */ new Map(), this.directoryWatchers = /* @__PURE__ */ new Map(), this._missing = /* @__PURE__ */ new Set(), this.startTime = void 0, this.paused = !1, this.aggregatedChanges = /* @__PURE__ */ new Set(), this.aggregatedRemovals = /* @__PURE__ */ new Set(), this.aggregateTimer = void 0, this._onTimeout = this._onTimeout.bind(this);
|
|
1504
1701
|
}
|
|
1702
|
+
/**
|
|
1703
|
+
* @overload
|
|
1704
|
+
* @param {Iterable<string>} arg1 files
|
|
1705
|
+
* @param {Iterable<string>} arg2 directories
|
|
1706
|
+
* @param {number=} arg3 startTime
|
|
1707
|
+
* @returns {void}
|
|
1708
|
+
*/
|
|
1709
|
+
/**
|
|
1710
|
+
* @overload
|
|
1711
|
+
* @param {WatchMethodOptions} arg1 watch options
|
|
1712
|
+
* @returns {void}
|
|
1713
|
+
*/
|
|
1714
|
+
/**
|
|
1715
|
+
* @param {Iterable<string> | WatchMethodOptions} arg1 files
|
|
1716
|
+
* @param {Iterable<string>=} arg2 directories
|
|
1717
|
+
* @param {number=} arg3 startTime
|
|
1718
|
+
* @returns {void}
|
|
1719
|
+
*/
|
|
1505
1720
|
watch(arg1, arg2, arg3) {
|
|
1506
1721
|
let files, directories, missing, startTime;
|
|
1507
|
-
arg2 ? (files =
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1722
|
+
arg2 ? (files = /** @type {Iterable<string>} */
|
|
1723
|
+
arg1, directories = /** @type {Iterable<string>} */
|
|
1724
|
+
arg2, missing = [], startTime = /** @type {number} */
|
|
1725
|
+
arg3) : {
|
|
1726
|
+
files = [],
|
|
1727
|
+
directories = [],
|
|
1728
|
+
missing = [],
|
|
1511
1729
|
startTime
|
|
1512
|
-
} =
|
|
1513
|
-
|
|
1730
|
+
} = /** @type {WatchMethodOptions} */
|
|
1731
|
+
arg1, this.paused = !1;
|
|
1732
|
+
let { fileWatchers, directoryWatchers } = this, { ignored } = this.watcherOptions, filter = (path2) => !ignored(path2), addToMap = (map, key, item) => {
|
|
1514
1733
|
let list = map.get(key);
|
|
1515
1734
|
list === void 0 ? map.set(key, item) : Array.isArray(list) ? list.push(item) : map.set(key, [list, item]);
|
|
1516
1735
|
}, fileWatchersNeeded = /* @__PURE__ */ new Map(), directoryWatchersNeeded = /* @__PURE__ */ new Map(), missingFiles = /* @__PURE__ */ new Set();
|
|
@@ -1573,6 +1792,9 @@ var require_watchpack = __commonJS({
|
|
|
1573
1792
|
pause() {
|
|
1574
1793
|
this.paused = !0, this.aggregateTimer && clearTimeout(this.aggregateTimer);
|
|
1575
1794
|
}
|
|
1795
|
+
/**
|
|
1796
|
+
* @returns {Record<string, number>} times
|
|
1797
|
+
*/
|
|
1576
1798
|
getTimes() {
|
|
1577
1799
|
let directoryWatchers = /* @__PURE__ */ new Set();
|
|
1578
1800
|
addWatchersToSet(this.fileWatchers.values(), directoryWatchers), addWatchersToSet(this.directoryWatchers.values(), directoryWatchers);
|
|
@@ -1583,25 +1805,45 @@ var require_watchpack = __commonJS({
|
|
|
1583
1805
|
}
|
|
1584
1806
|
return obj;
|
|
1585
1807
|
}
|
|
1808
|
+
/**
|
|
1809
|
+
* @returns {TimeInfoEntries} time info entries
|
|
1810
|
+
*/
|
|
1586
1811
|
getTimeInfoEntries() {
|
|
1587
1812
|
let map = /* @__PURE__ */ new Map();
|
|
1588
1813
|
return this.collectTimeInfoEntries(map, map), map;
|
|
1589
1814
|
}
|
|
1815
|
+
/**
|
|
1816
|
+
* @param {TimeInfoEntries} fileTimestamps file timestamps
|
|
1817
|
+
* @param {TimeInfoEntries} directoryTimestamps directory timestamps
|
|
1818
|
+
*/
|
|
1590
1819
|
collectTimeInfoEntries(fileTimestamps, directoryTimestamps) {
|
|
1591
1820
|
let allWatchers = /* @__PURE__ */ new Set();
|
|
1592
1821
|
addWatchersToSet(this.fileWatchers.values(), allWatchers), addWatchersToSet(this.directoryWatchers.values(), allWatchers);
|
|
1593
|
-
let safeTime = { value: 0 };
|
|
1594
1822
|
for (let w of allWatchers)
|
|
1595
|
-
w.collectTimeInfoEntries(fileTimestamps, directoryTimestamps
|
|
1823
|
+
w.collectTimeInfoEntries(fileTimestamps, directoryTimestamps);
|
|
1596
1824
|
}
|
|
1825
|
+
/**
|
|
1826
|
+
* @returns {Aggregated} aggregated info
|
|
1827
|
+
*/
|
|
1597
1828
|
getAggregated() {
|
|
1598
1829
|
this.aggregateTimer && (clearTimeout(this.aggregateTimer), this.aggregateTimer = void 0);
|
|
1599
1830
|
let changes = this.aggregatedChanges, removals = this.aggregatedRemovals;
|
|
1600
1831
|
return this.aggregatedChanges = /* @__PURE__ */ new Set(), this.aggregatedRemovals = /* @__PURE__ */ new Set(), { changes, removals };
|
|
1601
1832
|
}
|
|
1833
|
+
/**
|
|
1834
|
+
* @param {string} item item
|
|
1835
|
+
* @param {number} mtime mtime
|
|
1836
|
+
* @param {string} file file
|
|
1837
|
+
* @param {EventType} type type
|
|
1838
|
+
*/
|
|
1602
1839
|
_onChange(item, mtime, file, type) {
|
|
1603
1840
|
file = file || item, this.paused || (this.emit("change", file, mtime, type), this.aggregateTimer && clearTimeout(this.aggregateTimer), this.aggregateTimer = setTimeout(this._onTimeout, this.aggregateTimeout)), this.aggregatedRemovals.delete(item), this.aggregatedChanges.add(item);
|
|
1604
1841
|
}
|
|
1842
|
+
/**
|
|
1843
|
+
* @param {string} item item
|
|
1844
|
+
* @param {string} file file
|
|
1845
|
+
* @param {EventType} type type
|
|
1846
|
+
*/
|
|
1605
1847
|
_onRemove(item, file, type) {
|
|
1606
1848
|
file = file || item, this.paused || (this.emit("remove", file, type), this.aggregateTimer && clearTimeout(this.aggregateTimer), this.aggregateTimer = setTimeout(this._onTimeout, this.aggregateTimeout)), this.aggregatedChanges.delete(item), this.aggregatedRemovals.add(item);
|
|
1607
1849
|
}
|
|
@@ -2900,7 +3142,7 @@ var require_register = __commonJS({
|
|
|
2900
3142
|
});
|
|
2901
3143
|
|
|
2902
3144
|
// ../../node_modules/tsconfig-paths/lib/index.js
|
|
2903
|
-
var
|
|
3145
|
+
var require_lib3 = __commonJS({
|
|
2904
3146
|
"../../node_modules/tsconfig-paths/lib/index.js"(exports) {
|
|
2905
3147
|
"use strict";
|
|
2906
3148
|
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
@@ -4241,24 +4483,211 @@ var require_detect_port2 = __commonJS({
|
|
|
4241
4483
|
// src/core-server/index.ts
|
|
4242
4484
|
import { getPreviewHeadTemplate, getPreviewBodyTemplate } from "storybook/internal/common";
|
|
4243
4485
|
|
|
4244
|
-
// src/core-server/build-static.ts
|
|
4245
|
-
import { cp as cp2, mkdir
|
|
4246
|
-
import { rm } from "node:fs/promises";
|
|
4247
|
-
import {
|
|
4248
|
-
loadAllPresets,
|
|
4249
|
-
loadMainConfig,
|
|
4250
|
-
logConfig,
|
|
4251
|
-
resolveAddonName
|
|
4252
|
-
} from "storybook/internal/common";
|
|
4253
|
-
import { logger as
|
|
4254
|
-
import { getPrecedingUpgrade, telemetry as telemetry2 } from "storybook/internal/telemetry";
|
|
4255
|
-
import { global as global2 } from "@storybook/global";
|
|
4256
|
-
var import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
4486
|
+
// src/core-server/build-static.ts
|
|
4487
|
+
import { cp as cp2, mkdir as mkdir2 } from "node:fs/promises";
|
|
4488
|
+
import { rm } from "node:fs/promises";
|
|
4489
|
+
import {
|
|
4490
|
+
loadAllPresets,
|
|
4491
|
+
loadMainConfig,
|
|
4492
|
+
logConfig,
|
|
4493
|
+
resolveAddonName
|
|
4494
|
+
} from "storybook/internal/common";
|
|
4495
|
+
import { logger as logger5 } from "storybook/internal/node-logger";
|
|
4496
|
+
import { getPrecedingUpgrade, telemetry as telemetry2 } from "storybook/internal/telemetry";
|
|
4497
|
+
import { global as global2 } from "@storybook/global";
|
|
4498
|
+
var import_picocolors4 = __toESM(require_picocolors(), 1);
|
|
4499
|
+
|
|
4500
|
+
// src/core-server/utils/build-or-throw.ts
|
|
4501
|
+
import { NoMatchingExportError } from "storybook/internal/server-errors";
|
|
4502
|
+
async function buildOrThrow(callback) {
|
|
4503
|
+
try {
|
|
4504
|
+
return await callback();
|
|
4505
|
+
} catch (err) {
|
|
4506
|
+
let builderErrors = err.errors;
|
|
4507
|
+
throw builderErrors && builderErrors.find(
|
|
4508
|
+
(er) => er.text?.includes("No matching export")
|
|
4509
|
+
) ? new NoMatchingExportError(err) : err;
|
|
4510
|
+
}
|
|
4511
|
+
}
|
|
4512
|
+
|
|
4513
|
+
// src/core-server/utils/copy-all-static-files.ts
|
|
4514
|
+
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
4515
|
+
import { cp } from "node:fs/promises";
|
|
4516
|
+
import { join as join2, relative as relative2 } from "node:path";
|
|
4517
|
+
import { getDirectoryFromWorkingDir } from "storybook/internal/common";
|
|
4518
|
+
import { logger } from "storybook/internal/node-logger";
|
|
4519
|
+
async function copyAllStaticFilesRelativeToMain(staticDirs, outputDir, configDir) {
|
|
4520
|
+
let workingDir = process.cwd();
|
|
4521
|
+
return staticDirs?.reduce(async (acc, dir) => {
|
|
4522
|
+
await acc;
|
|
4523
|
+
let staticDirAndTarget = typeof dir == "string" ? dir : `${dir.from}:${dir.to}`, { staticPath: from, targetEndpoint: to } = parseStaticDir(
|
|
4524
|
+
getDirectoryFromWorkingDir({
|
|
4525
|
+
configDir,
|
|
4526
|
+
workingDir,
|
|
4527
|
+
directory: staticDirAndTarget
|
|
4528
|
+
})
|
|
4529
|
+
), targetPath = join2(outputDir, to), skipPaths = ["index.html", "iframe.html"].map((f) => join2(outputDir, f));
|
|
4530
|
+
from.includes("node_modules") || logger.info(
|
|
4531
|
+
`Copying static files: ${import_picocolors.default.cyan(print(from))} at ${import_picocolors.default.cyan(print(targetPath))}`
|
|
4532
|
+
), await cp(from, targetPath, {
|
|
4533
|
+
dereference: !0,
|
|
4534
|
+
preserveTimestamps: !0,
|
|
4535
|
+
filter: (_, dest) => !skipPaths.includes(dest),
|
|
4536
|
+
recursive: !0
|
|
4537
|
+
});
|
|
4538
|
+
}, Promise.resolve());
|
|
4539
|
+
}
|
|
4540
|
+
function print(p) {
|
|
4541
|
+
return relative2(process.cwd(), p);
|
|
4542
|
+
}
|
|
4543
|
+
|
|
4544
|
+
// src/core-server/utils/get-builders.ts
|
|
4545
|
+
import { MissingBuilderError } from "storybook/internal/server-errors";
|
|
4546
|
+
async function getManagerBuilder() {
|
|
4547
|
+
return await import("../_node-chunks/builder-manager-JEJE63VV.js");
|
|
4548
|
+
}
|
|
4549
|
+
async function getPreviewBuilder(resolvedPreviewBuilder) {
|
|
4550
|
+
return await importModule(resolvedPreviewBuilder);
|
|
4551
|
+
}
|
|
4552
|
+
async function getBuilders({ presets }) {
|
|
4553
|
+
let { builder } = await presets.apply("core", {});
|
|
4554
|
+
if (!builder)
|
|
4555
|
+
throw new MissingBuilderError();
|
|
4556
|
+
let resolvedPreviewBuilder = typeof builder == "string" ? builder : builder.name;
|
|
4557
|
+
return Promise.all([getPreviewBuilder(resolvedPreviewBuilder), getManagerBuilder()]);
|
|
4558
|
+
}
|
|
4559
|
+
|
|
4560
|
+
// src/core-server/utils/index-json.ts
|
|
4561
|
+
import { writeFile } from "node:fs/promises";
|
|
4562
|
+
import { basename as basename2 } from "node:path";
|
|
4563
|
+
import { STORY_INDEX_INVALIDATED } from "storybook/internal/core-events";
|
|
4564
|
+
|
|
4565
|
+
// src/core-server/utils/watch-story-specifiers.ts
|
|
4566
|
+
import { lstatSync, readdirSync } from "node:fs";
|
|
4567
|
+
import { basename, join as join3, relative as relative3, resolve as resolve2 } from "node:path";
|
|
4568
|
+
import { commonGlobOptions } from "storybook/internal/common";
|
|
4569
|
+
var import_watchpack = __toESM(require_lib2(), 1), isDirectory = (directory) => {
|
|
4570
|
+
try {
|
|
4571
|
+
return lstatSync(directory).isDirectory();
|
|
4572
|
+
} catch {
|
|
4573
|
+
return !1;
|
|
4574
|
+
}
|
|
4575
|
+
};
|
|
4576
|
+
function getNestedFilesAndDirectories(directories) {
|
|
4577
|
+
let traversedDirectories = /* @__PURE__ */ new Set(), files = /* @__PURE__ */ new Set(), traverse = (directory) => {
|
|
4578
|
+
traversedDirectories.has(directory) || (readdirSync(directory, { withFileTypes: !0 }).forEach((ent) => {
|
|
4579
|
+
ent.isDirectory() ? traverse(join3(directory, ent.name)) : ent.isFile() && files.add(join3(directory, ent.name));
|
|
4580
|
+
}), traversedDirectories.add(directory));
|
|
4581
|
+
};
|
|
4582
|
+
return directories.filter(isDirectory).forEach(traverse), { files: Array.from(files), directories: Array.from(traversedDirectories) };
|
|
4583
|
+
}
|
|
4584
|
+
function watchStorySpecifiers(specifiers, options, onInvalidate) {
|
|
4585
|
+
let { files, directories } = getNestedFilesAndDirectories(
|
|
4586
|
+
specifiers.map((ns) => resolve2(options.workingDir, ns.directory))
|
|
4587
|
+
), wp = new import_watchpack.default({
|
|
4588
|
+
// poll: true, // Slow!!! Enable only in special cases
|
|
4589
|
+
followSymlinks: !1,
|
|
4590
|
+
ignored: ["**/.git", "**/node_modules"]
|
|
4591
|
+
});
|
|
4592
|
+
wp.watch({ files, directories });
|
|
4593
|
+
let toImportPath = (absolutePath) => {
|
|
4594
|
+
let relativePath = relative3(options.workingDir, absolutePath);
|
|
4595
|
+
return slash(relativePath.startsWith(".") ? relativePath : `./${relativePath}`);
|
|
4596
|
+
};
|
|
4597
|
+
async function onChangeOrRemove(absolutePath, removed) {
|
|
4598
|
+
let importPath = toImportPath(absolutePath);
|
|
4599
|
+
if (specifiers.find((ns) => ns.importPathMatcher.exec(importPath))) {
|
|
4600
|
+
onInvalidate(importPath, removed);
|
|
4601
|
+
return;
|
|
4602
|
+
}
|
|
4603
|
+
!removed && isDirectory(absolutePath) && await Promise.all(
|
|
4604
|
+
specifiers.filter((specifier) => importPath.startsWith(specifier.directory)).map(async (specifier) => {
|
|
4605
|
+
let dirGlob = join3(
|
|
4606
|
+
absolutePath,
|
|
4607
|
+
"**",
|
|
4608
|
+
// files can be e.g. '**/foo/*/*.js' so we just want the last bit,
|
|
4609
|
+
// because the directory could already be within the files part (e.g. './x/foo/bar')
|
|
4610
|
+
basename(specifier.files)
|
|
4611
|
+
), { globby } = await import("../_node-chunks/globby-4D4NBVG7.js");
|
|
4612
|
+
(await globby(slash(dirGlob), commonGlobOptions(dirGlob))).forEach((filePath) => {
|
|
4613
|
+
let fileImportPath = toImportPath(filePath);
|
|
4614
|
+
specifier.importPathMatcher.exec(fileImportPath) && onInvalidate(fileImportPath, removed);
|
|
4615
|
+
});
|
|
4616
|
+
})
|
|
4617
|
+
);
|
|
4618
|
+
}
|
|
4619
|
+
let pendingEvents = /* @__PURE__ */ new Map(), batchTimeout;
|
|
4620
|
+
function queueEvent(absolutePath, removed) {
|
|
4621
|
+
pendingEvents.set(absolutePath, { removed }), batchTimeout && clearTimeout(batchTimeout), batchTimeout = setTimeout(async () => {
|
|
4622
|
+
batchTimeout = void 0;
|
|
4623
|
+
let events = new Map(pendingEvents);
|
|
4624
|
+
pendingEvents.clear(), await Promise.all(
|
|
4625
|
+
Array.from(events.entries()).map(([path2, { removed: removed2 }]) => onChangeOrRemove(path2, removed2))
|
|
4626
|
+
);
|
|
4627
|
+
}, 100);
|
|
4628
|
+
}
|
|
4629
|
+
return wp.on("change", (filePath, mtime, explanation) => {
|
|
4630
|
+
queueEvent(filePath, !mtime);
|
|
4631
|
+
}), wp.on("remove", (filePath) => {
|
|
4632
|
+
queueEvent(filePath, !0);
|
|
4633
|
+
}), () => wp.close();
|
|
4634
|
+
}
|
|
4635
|
+
|
|
4636
|
+
// src/core-server/utils/watchConfig.ts
|
|
4637
|
+
var import_watchpack2 = __toESM(require_lib2(), 1);
|
|
4638
|
+
function watchConfig(configDir, onInvalidate) {
|
|
4639
|
+
let wp = new import_watchpack2.default({
|
|
4640
|
+
followSymlinks: !1,
|
|
4641
|
+
ignored: ["**/.git", "**/node_modules"]
|
|
4642
|
+
});
|
|
4643
|
+
return wp.watch({
|
|
4644
|
+
directories: [configDir]
|
|
4645
|
+
}), wp.on("change", async (filePath, mtime, explanation) => {
|
|
4646
|
+
await onInvalidate(filePath, !mtime);
|
|
4647
|
+
}), wp.on("remove", async (filePath, explanation) => {
|
|
4648
|
+
await onInvalidate(filePath, !0);
|
|
4649
|
+
}), () => wp.close();
|
|
4650
|
+
}
|
|
4651
|
+
|
|
4652
|
+
// src/core-server/utils/index-json.ts
|
|
4653
|
+
var DEBOUNCE = 100;
|
|
4654
|
+
async function writeIndexJson(outputFile, initializedStoryIndexGenerator) {
|
|
4655
|
+
let storyIndex = await (await initializedStoryIndexGenerator).getIndex();
|
|
4656
|
+
await writeFile(outputFile, JSON.stringify(storyIndex));
|
|
4657
|
+
}
|
|
4658
|
+
function registerIndexJsonRoute({
|
|
4659
|
+
app,
|
|
4660
|
+
storyIndexGeneratorPromise,
|
|
4661
|
+
workingDir = process.cwd(),
|
|
4662
|
+
configDir,
|
|
4663
|
+
serverChannel,
|
|
4664
|
+
normalizedStories
|
|
4665
|
+
}) {
|
|
4666
|
+
let maybeInvalidate = debounce(() => serverChannel.emit(STORY_INDEX_INVALIDATED), DEBOUNCE, {
|
|
4667
|
+
edges: ["leading", "trailing"]
|
|
4668
|
+
});
|
|
4669
|
+
watchStorySpecifiers(normalizedStories, { workingDir }, async (path2, removed) => {
|
|
4670
|
+
(await storyIndexGeneratorPromise).invalidate(path2, removed), maybeInvalidate();
|
|
4671
|
+
}), configDir && watchConfig(configDir, async (filePath) => {
|
|
4672
|
+
basename2(filePath).startsWith("preview") && ((await storyIndexGeneratorPromise).invalidateAll(), maybeInvalidate());
|
|
4673
|
+
}), app.use("/index.json", async (req, res) => {
|
|
4674
|
+
try {
|
|
4675
|
+
let index = await (await storyIndexGeneratorPromise).getIndex();
|
|
4676
|
+
res.setHeader("Content-Type", "application/json"), res.end(JSON.stringify(index));
|
|
4677
|
+
} catch (err) {
|
|
4678
|
+
res.statusCode = 500, res.end(err instanceof Error ? err.toString() : String(err));
|
|
4679
|
+
}
|
|
4680
|
+
});
|
|
4681
|
+
}
|
|
4682
|
+
|
|
4683
|
+
// src/core-server/utils/manifests/manifests.ts
|
|
4684
|
+
import { mkdir, writeFile as writeFile2 } from "node:fs/promises";
|
|
4685
|
+
import { logger as logger2 } from "storybook/internal/node-logger";
|
|
4257
4686
|
|
|
4258
|
-
// src/core-server/manifest.ts
|
|
4687
|
+
// src/core-server/utils/manifests/render-components-manifest.ts
|
|
4259
4688
|
import path from "node:path";
|
|
4260
4689
|
import { groupBy } from "storybook/internal/common";
|
|
4261
|
-
function
|
|
4690
|
+
function renderComponentsManifest(manifest) {
|
|
4262
4691
|
let entries = Object.entries(manifest?.components ?? {}).sort(
|
|
4263
4692
|
(a, b) => (a[1].name || a[0]).localeCompare(b[1].name || b[0])
|
|
4264
4693
|
), analyses = entries.map(([, c]) => analyzeComponent(c)), totals = {
|
|
@@ -5000,195 +5429,62 @@ function serializeTsType(tsType) {
|
|
|
5000
5429
|
}
|
|
5001
5430
|
}
|
|
5002
5431
|
|
|
5003
|
-
// src/core-server/utils/
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
}
|
|
5014
|
-
}
|
|
5015
|
-
|
|
5016
|
-
// src/core-server/utils/copy-all-static-files.ts
|
|
5017
|
-
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
5018
|
-
import { cp } from "node:fs/promises";
|
|
5019
|
-
import { join as join2, relative as relative2 } from "node:path";
|
|
5020
|
-
import { getDirectoryFromWorkingDir } from "storybook/internal/common";
|
|
5021
|
-
import { logger } from "storybook/internal/node-logger";
|
|
5022
|
-
async function copyAllStaticFilesRelativeToMain(staticDirs, outputDir, configDir) {
|
|
5023
|
-
let workingDir = process.cwd();
|
|
5024
|
-
return staticDirs?.reduce(async (acc, dir) => {
|
|
5025
|
-
await acc;
|
|
5026
|
-
let staticDirAndTarget = typeof dir == "string" ? dir : `${dir.from}:${dir.to}`, { staticPath: from, targetEndpoint: to } = parseStaticDir(
|
|
5027
|
-
getDirectoryFromWorkingDir({
|
|
5028
|
-
configDir,
|
|
5029
|
-
workingDir,
|
|
5030
|
-
directory: staticDirAndTarget
|
|
5031
|
-
})
|
|
5032
|
-
), targetPath = join2(outputDir, to), skipPaths = ["index.html", "iframe.html"].map((f) => join2(outputDir, f));
|
|
5033
|
-
from.includes("node_modules") || logger.info(
|
|
5034
|
-
`Copying static files: ${import_picocolors.default.cyan(print(from))} at ${import_picocolors.default.cyan(print(targetPath))}`
|
|
5035
|
-
), await cp(from, targetPath, {
|
|
5036
|
-
dereference: !0,
|
|
5037
|
-
preserveTimestamps: !0,
|
|
5038
|
-
filter: (_, dest) => !skipPaths.includes(dest),
|
|
5039
|
-
recursive: !0
|
|
5040
|
-
});
|
|
5041
|
-
}, Promise.resolve());
|
|
5042
|
-
}
|
|
5043
|
-
function print(p) {
|
|
5044
|
-
return relative2(process.cwd(), p);
|
|
5045
|
-
}
|
|
5046
|
-
|
|
5047
|
-
// src/core-server/utils/get-builders.ts
|
|
5048
|
-
import { MissingBuilderError } from "storybook/internal/server-errors";
|
|
5049
|
-
async function getManagerBuilder() {
|
|
5050
|
-
return await import("../_node-chunks/builder-manager-FTCODGJP.js");
|
|
5051
|
-
}
|
|
5052
|
-
async function getPreviewBuilder(resolvedPreviewBuilder) {
|
|
5053
|
-
return await importModule(resolvedPreviewBuilder);
|
|
5054
|
-
}
|
|
5055
|
-
async function getBuilders({ presets }) {
|
|
5056
|
-
let { builder } = await presets.apply("core", {});
|
|
5057
|
-
if (!builder)
|
|
5058
|
-
throw new MissingBuilderError();
|
|
5059
|
-
let resolvedPreviewBuilder = typeof builder == "string" ? builder : builder.name;
|
|
5060
|
-
return Promise.all([getPreviewBuilder(resolvedPreviewBuilder), getManagerBuilder()]);
|
|
5432
|
+
// src/core-server/utils/manifests/manifests.ts
|
|
5433
|
+
async function getManifests(presets) {
|
|
5434
|
+
let generator = await presets.apply("storyIndexGenerator");
|
|
5435
|
+
invariant(generator, "storyIndexGenerator must be configured");
|
|
5436
|
+
let index = await generator.getIndex(), manifestEntries = Object.values(index.entries).filter(
|
|
5437
|
+
(entry) => entry.tags?.includes(Tag.MANIFEST) ?? !1
|
|
5438
|
+
);
|
|
5439
|
+
return await presets.apply("experimental_manifests", void 0, {
|
|
5440
|
+
manifestEntries
|
|
5441
|
+
}) ?? {};
|
|
5061
5442
|
}
|
|
5062
|
-
|
|
5063
|
-
// src/core-server/utils/index-json.ts
|
|
5064
|
-
import { writeFile } from "node:fs/promises";
|
|
5065
|
-
import { basename as basename2 } from "node:path";
|
|
5066
|
-
import { STORY_INDEX_INVALIDATED } from "storybook/internal/core-events";
|
|
5067
|
-
|
|
5068
|
-
// src/core-server/utils/watch-story-specifiers.ts
|
|
5069
|
-
import { lstatSync, readdirSync } from "node:fs";
|
|
5070
|
-
import { basename, join as join3, relative as relative3, resolve as resolve2 } from "node:path";
|
|
5071
|
-
import { commonGlobOptions } from "storybook/internal/common";
|
|
5072
|
-
var import_watchpack = __toESM(require_watchpack(), 1), isDirectory = (directory) => {
|
|
5443
|
+
async function writeManifests(outputDir, presets) {
|
|
5073
5444
|
try {
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
return !1;
|
|
5077
|
-
}
|
|
5078
|
-
};
|
|
5079
|
-
function getNestedFilesAndDirectories(directories) {
|
|
5080
|
-
let traversedDirectories = /* @__PURE__ */ new Set(), files = /* @__PURE__ */ new Set(), traverse = (directory) => {
|
|
5081
|
-
traversedDirectories.has(directory) || (readdirSync(directory, { withFileTypes: !0 }).forEach((ent) => {
|
|
5082
|
-
ent.isDirectory() ? traverse(join3(directory, ent.name)) : ent.isFile() && files.add(join3(directory, ent.name));
|
|
5083
|
-
}), traversedDirectories.add(directory));
|
|
5084
|
-
};
|
|
5085
|
-
return directories.filter(isDirectory).forEach(traverse), { files: Array.from(files), directories: Array.from(traversedDirectories) };
|
|
5086
|
-
}
|
|
5087
|
-
function watchStorySpecifiers(specifiers, options, onInvalidate) {
|
|
5088
|
-
let { files, directories } = getNestedFilesAndDirectories(
|
|
5089
|
-
specifiers.map((ns) => resolve2(options.workingDir, ns.directory))
|
|
5090
|
-
), wp = new import_watchpack.default({
|
|
5091
|
-
// poll: true, // Slow!!! Enable only in special cases
|
|
5092
|
-
followSymlinks: !1,
|
|
5093
|
-
ignored: ["**/.git", "**/node_modules"]
|
|
5094
|
-
});
|
|
5095
|
-
wp.watch({ files, directories });
|
|
5096
|
-
let toImportPath = (absolutePath) => {
|
|
5097
|
-
let relativePath = relative3(options.workingDir, absolutePath);
|
|
5098
|
-
return slash(relativePath.startsWith(".") ? relativePath : `./${relativePath}`);
|
|
5099
|
-
};
|
|
5100
|
-
async function onChangeOrRemove(absolutePath, removed) {
|
|
5101
|
-
let importPath = toImportPath(absolutePath);
|
|
5102
|
-
if (specifiers.find((ns) => ns.importPathMatcher.exec(importPath))) {
|
|
5103
|
-
onInvalidate(importPath, removed);
|
|
5445
|
+
let manifests = await getManifests(presets);
|
|
5446
|
+
if (Object.keys(manifests).length === 0)
|
|
5104
5447
|
return;
|
|
5105
|
-
}
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
// because the directory could already be within the files part (e.g. './x/foo/bar')
|
|
5113
|
-
basename(specifier.files)
|
|
5114
|
-
), { globby } = await import("../_node-chunks/globby-AXGFF6I5.js");
|
|
5115
|
-
(await globby(slash(dirGlob), commonGlobOptions(dirGlob))).forEach((filePath) => {
|
|
5116
|
-
let fileImportPath = toImportPath(filePath);
|
|
5117
|
-
specifier.importPathMatcher.exec(fileImportPath) && onInvalidate(fileImportPath, removed);
|
|
5118
|
-
});
|
|
5119
|
-
})
|
|
5448
|
+
await mkdir(join(outputDir, "manifests"), { recursive: !0 }), await Promise.all(
|
|
5449
|
+
Object.entries(manifests).map(
|
|
5450
|
+
([name, content]) => writeFile2(join(outputDir, "manifests", `${name}.json`), JSON.stringify(content))
|
|
5451
|
+
)
|
|
5452
|
+
), "components" in manifests && await writeFile2(
|
|
5453
|
+
join(outputDir, "manifests", "components.html"),
|
|
5454
|
+
renderComponentsManifest(manifests.components)
|
|
5120
5455
|
);
|
|
5456
|
+
} catch (e) {
|
|
5457
|
+
logger2.error("Failed to generate manifests"), logger2.error(e instanceof Error ? e : String(e));
|
|
5121
5458
|
}
|
|
5122
|
-
let pendingEvents = /* @__PURE__ */ new Map(), batchTimeout;
|
|
5123
|
-
function queueEvent(absolutePath, removed) {
|
|
5124
|
-
pendingEvents.set(absolutePath, { removed }), batchTimeout && clearTimeout(batchTimeout), batchTimeout = setTimeout(async () => {
|
|
5125
|
-
batchTimeout = void 0;
|
|
5126
|
-
let events = new Map(pendingEvents);
|
|
5127
|
-
pendingEvents.clear(), await Promise.all(
|
|
5128
|
-
Array.from(events.entries()).map(([path2, { removed: removed2 }]) => onChangeOrRemove(path2, removed2))
|
|
5129
|
-
);
|
|
5130
|
-
}, 100);
|
|
5131
|
-
}
|
|
5132
|
-
return wp.on("change", (filePath, mtime, explanation) => {
|
|
5133
|
-
queueEvent(filePath, !mtime);
|
|
5134
|
-
}), wp.on("remove", (filePath) => {
|
|
5135
|
-
queueEvent(filePath, !0);
|
|
5136
|
-
}), () => wp.close();
|
|
5137
|
-
}
|
|
5138
|
-
|
|
5139
|
-
// src/core-server/utils/watchConfig.ts
|
|
5140
|
-
var import_watchpack2 = __toESM(require_watchpack(), 1);
|
|
5141
|
-
function watchConfig(configDir, onInvalidate) {
|
|
5142
|
-
let wp = new import_watchpack2.default({
|
|
5143
|
-
followSymlinks: !1,
|
|
5144
|
-
ignored: ["**/.git", "**/node_modules"]
|
|
5145
|
-
});
|
|
5146
|
-
return wp.watch({
|
|
5147
|
-
directories: [configDir]
|
|
5148
|
-
}), wp.on("change", async (filePath, mtime, explanation) => {
|
|
5149
|
-
await onInvalidate(filePath, !mtime);
|
|
5150
|
-
}), wp.on("remove", async (filePath, explanation) => {
|
|
5151
|
-
await onInvalidate(filePath, !0);
|
|
5152
|
-
}), () => wp.close();
|
|
5153
|
-
}
|
|
5154
|
-
|
|
5155
|
-
// src/core-server/utils/index-json.ts
|
|
5156
|
-
var DEBOUNCE = 100;
|
|
5157
|
-
async function writeIndexJson(outputFile, initializedStoryIndexGenerator) {
|
|
5158
|
-
let storyIndex = await (await initializedStoryIndexGenerator).getIndex();
|
|
5159
|
-
await writeFile(outputFile, JSON.stringify(storyIndex));
|
|
5160
5459
|
}
|
|
5161
|
-
function
|
|
5162
|
-
app,
|
|
5163
|
-
storyIndexGeneratorPromise,
|
|
5164
|
-
workingDir = process.cwd(),
|
|
5165
|
-
configDir,
|
|
5166
|
-
serverChannel,
|
|
5167
|
-
normalizedStories
|
|
5168
|
-
}) {
|
|
5169
|
-
let maybeInvalidate = debounce(() => serverChannel.emit(STORY_INDEX_INVALIDATED), DEBOUNCE, {
|
|
5170
|
-
edges: ["leading", "trailing"]
|
|
5171
|
-
});
|
|
5172
|
-
watchStorySpecifiers(normalizedStories, { workingDir }, async (path2, removed) => {
|
|
5173
|
-
(await storyIndexGeneratorPromise).invalidate(path2, removed), maybeInvalidate();
|
|
5174
|
-
}), configDir && watchConfig(configDir, async (filePath) => {
|
|
5175
|
-
basename2(filePath).startsWith("preview") && ((await storyIndexGeneratorPromise).invalidateAll(), maybeInvalidate());
|
|
5176
|
-
}), app.use("/index.json", async (req, res) => {
|
|
5460
|
+
function registerManifests({ app, presets }) {
|
|
5461
|
+
app.get("/manifests/:name.json", async (req, res) => {
|
|
5177
5462
|
try {
|
|
5178
|
-
let
|
|
5179
|
-
res.setHeader("Content-Type", "application/json"), res.end(JSON.stringify(
|
|
5180
|
-
} catch (
|
|
5181
|
-
res.statusCode = 500, res.end(
|
|
5463
|
+
let manifest = (await getManifests(presets))[req.params.name];
|
|
5464
|
+
manifest ? (res.setHeader("Content-Type", "application/json"), res.end(JSON.stringify(manifest))) : (res.statusCode = 404, res.end(`Manifest "${req.params.name}" not found`));
|
|
5465
|
+
} catch (e) {
|
|
5466
|
+
logger2.error(e instanceof Error ? e : String(e)), res.statusCode = 500, res.end(e instanceof Error ? e.toString() : String(e));
|
|
5467
|
+
}
|
|
5468
|
+
}), app.get("/manifests/components.html", async (req, res) => {
|
|
5469
|
+
try {
|
|
5470
|
+
let manifest = (await getManifests(presets)).components;
|
|
5471
|
+
if (!manifest) {
|
|
5472
|
+
res.statusCode = 404, res.setHeader("Content-Type", "text/html; charset=utf-8"), res.end("<pre>No components manifest configured.</pre>");
|
|
5473
|
+
return;
|
|
5474
|
+
}
|
|
5475
|
+
res.setHeader("Content-Type", "text/html; charset=utf-8"), res.end(renderComponentsManifest(manifest));
|
|
5476
|
+
} catch (e) {
|
|
5477
|
+
res.statusCode = 500, res.setHeader("Content-Type", "text/html; charset=utf-8"), res.end(`<pre>${e instanceof Error ? e.stack : String(e)}</pre>`);
|
|
5182
5478
|
}
|
|
5183
5479
|
});
|
|
5184
5480
|
}
|
|
5185
5481
|
|
|
5186
5482
|
// src/core-server/utils/metadata.ts
|
|
5187
|
-
import { writeFile as
|
|
5483
|
+
import { writeFile as writeFile3 } from "node:fs/promises";
|
|
5188
5484
|
import { getStorybookMetadata } from "storybook/internal/telemetry";
|
|
5189
5485
|
async function extractStorybookMetadata(outputFile, configDir) {
|
|
5190
5486
|
let storybookMetadata = await getStorybookMetadata(configDir);
|
|
5191
|
-
await
|
|
5487
|
+
await writeFile3(outputFile, JSON.stringify(storybookMetadata));
|
|
5192
5488
|
}
|
|
5193
5489
|
function useStorybookMetadata(app, configDir) {
|
|
5194
5490
|
app.use("/project.json", async (req, res) => {
|
|
@@ -5201,15 +5497,15 @@ function useStorybookMetadata(app, configDir) {
|
|
|
5201
5497
|
var import_json_ext = __toESM(require_src2(), 1), import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
5202
5498
|
import { createWriteStream } from "node:fs";
|
|
5203
5499
|
import { join as join4 } from "node:path";
|
|
5204
|
-
import { logger as
|
|
5500
|
+
import { logger as logger3 } from "storybook/internal/node-logger";
|
|
5205
5501
|
async function outputStats(directory, previewStats, managerStats) {
|
|
5206
5502
|
if (previewStats) {
|
|
5207
5503
|
let filePath = await writeStats(directory, "preview", previewStats);
|
|
5208
|
-
|
|
5504
|
+
logger3.info(`Preview stats written to ${import_picocolors2.default.cyan(filePath)}`);
|
|
5209
5505
|
}
|
|
5210
5506
|
if (managerStats) {
|
|
5211
5507
|
let filePath = await writeStats(directory, "manager", managerStats);
|
|
5212
|
-
|
|
5508
|
+
logger3.info(`Manager stats written to ${import_picocolors2.default.cyan(filePath)}`);
|
|
5213
5509
|
}
|
|
5214
5510
|
}
|
|
5215
5511
|
var writeStats = async (directory, name, stats) => {
|
|
@@ -5229,10 +5525,119 @@ import { dirname as dirname2, extname, join as join5, normalize, relative as rel
|
|
|
5229
5525
|
import { commonGlobOptions as commonGlobOptions2, getProjectRoot, normalizeStoryPath } from "storybook/internal/common";
|
|
5230
5526
|
import { combineTags, storyNameFromExport, toId } from "storybook/internal/csf";
|
|
5231
5527
|
import { getStorySortParameter, loadConfig } from "storybook/internal/csf-tools";
|
|
5232
|
-
import { logger as
|
|
5528
|
+
import { logger as logger4, once } from "storybook/internal/node-logger";
|
|
5233
5529
|
import { isExampleStoryId } from "storybook/internal/telemetry";
|
|
5530
|
+
|
|
5531
|
+
// ../../node_modules/@storybook/docs-mdx/dist/index.js
|
|
5532
|
+
var getAttr = (elt, what) => elt.attributes.find((n) => n.type === "JSXAttribute" && n.name.name === what), getAttrValue = (elt, what) => getAttr(elt, what)?.value, getAttrLiteral = (elt, what) => {
|
|
5533
|
+
let attrValue = getAttrValue(elt, what);
|
|
5534
|
+
if (attrValue) {
|
|
5535
|
+
if (attrValue.type === "Literal")
|
|
5536
|
+
return attrValue.value;
|
|
5537
|
+
throw new Error(`Expected string literal ${what}, received ${attrValue.type}`);
|
|
5538
|
+
}
|
|
5539
|
+
}, getOf = (elt, varToImport) => {
|
|
5540
|
+
let ofAttrValue = getAttrValue(elt, "of");
|
|
5541
|
+
if (ofAttrValue)
|
|
5542
|
+
if (ofAttrValue.type === "JSXExpressionContainer") {
|
|
5543
|
+
let of = ofAttrValue.expression;
|
|
5544
|
+
if (of?.type === "Identifier") {
|
|
5545
|
+
let importName = varToImport[of.name];
|
|
5546
|
+
if (importName)
|
|
5547
|
+
return importName;
|
|
5548
|
+
throw new Error(`Unknown identifier ${of.name}`);
|
|
5549
|
+
} else
|
|
5550
|
+
throw new Error(`Expected identifier, received ${of.type}`);
|
|
5551
|
+
} else
|
|
5552
|
+
throw new Error(`Expected JSX expression, received ${ofAttrValue.type}`);
|
|
5553
|
+
}, getTags = (elt) => {
|
|
5554
|
+
let tagsAttr = getAttr(elt, "tags");
|
|
5555
|
+
if (!tagsAttr)
|
|
5556
|
+
return;
|
|
5557
|
+
let tagsContainer = tagsAttr.value;
|
|
5558
|
+
if (tagsContainer.type === "JSXExpressionContainer") {
|
|
5559
|
+
let tagsArray = tagsContainer.expression;
|
|
5560
|
+
if (tagsArray.type === "ArrayExpression")
|
|
5561
|
+
return tagsArray.elements.map((tag) => {
|
|
5562
|
+
if (tag.type === "Literal" && typeof tag.value == "string")
|
|
5563
|
+
return tag.value;
|
|
5564
|
+
throw new Error(`Expected string literal tag, received ${tag.type}`);
|
|
5565
|
+
});
|
|
5566
|
+
throw new Error(`Expected tags array, received ${tagsArray.type}`);
|
|
5567
|
+
} else
|
|
5568
|
+
throw new Error(`Expected JSX expression tags, received ${tagsContainer.type}`);
|
|
5569
|
+
}, getIsTemplate = (elt) => {
|
|
5570
|
+
let isTemplateAttr = getAttr(elt, "isTemplate");
|
|
5571
|
+
if (!isTemplateAttr)
|
|
5572
|
+
return !1;
|
|
5573
|
+
let isTemplate = isTemplateAttr.value;
|
|
5574
|
+
if (isTemplate == null)
|
|
5575
|
+
return !0;
|
|
5576
|
+
if (isTemplate.type === "JSXExpressionContainer") {
|
|
5577
|
+
let expression = isTemplate.expression;
|
|
5578
|
+
if (expression.type === "Literal" && typeof expression.value == "boolean")
|
|
5579
|
+
return expression.value;
|
|
5580
|
+
throw new Error(`Expected boolean isTemplate, received ${typeof expression.value}`);
|
|
5581
|
+
} else
|
|
5582
|
+
throw new Error(`Expected expression isTemplate, received ${isTemplate.type}`);
|
|
5583
|
+
}, extractTitle = (root, varToImport) => {
|
|
5584
|
+
let result = {
|
|
5585
|
+
title: void 0,
|
|
5586
|
+
of: void 0,
|
|
5587
|
+
name: void 0,
|
|
5588
|
+
summary: void 0,
|
|
5589
|
+
isTemplate: !1
|
|
5590
|
+
}, fragments = root.body.filter(
|
|
5591
|
+
(child) => child.type === "ExpressionStatement" && child.expression.type === "JSXFragment"
|
|
5592
|
+
);
|
|
5593
|
+
if (fragments.length > 1)
|
|
5594
|
+
throw new Error("duplicate contents");
|
|
5595
|
+
return fragments.length === 0 || fragments[0].expression.children.forEach((child) => {
|
|
5596
|
+
if (child.type === "JSXElement") {
|
|
5597
|
+
let { openingElement } = child;
|
|
5598
|
+
if (openingElement.name.name === "Meta") {
|
|
5599
|
+
if (result.title || result.name || result.of)
|
|
5600
|
+
throw new Error("Meta can only be declared once");
|
|
5601
|
+
result.title = getAttrLiteral(openingElement, "title"), result.name = getAttrLiteral(openingElement, "name"), result.summary = getAttrLiteral(openingElement, "summary"), result.of = getOf(openingElement, varToImport), result.isTemplate = getIsTemplate(openingElement), result.metaTags = getTags(openingElement);
|
|
5602
|
+
}
|
|
5603
|
+
} else if (child.type !== "JSXExpressionContainer")
|
|
5604
|
+
throw new Error(`Unexpected JSX child: ${child.type}`);
|
|
5605
|
+
}), result;
|
|
5606
|
+
}, extractImports = (root) => {
|
|
5607
|
+
let varToImport = {};
|
|
5608
|
+
return root.body.forEach((child) => {
|
|
5609
|
+
if (child.type === "ImportDeclaration") {
|
|
5610
|
+
let { source, specifiers } = child;
|
|
5611
|
+
if (source.type === "Literal")
|
|
5612
|
+
specifiers.forEach((s) => {
|
|
5613
|
+
varToImport[s.local.name] = source.value.toString();
|
|
5614
|
+
});
|
|
5615
|
+
else
|
|
5616
|
+
throw new Error("MDX: unexpected import source");
|
|
5617
|
+
}
|
|
5618
|
+
}), varToImport;
|
|
5619
|
+
}, plugin = (store) => (root) => {
|
|
5620
|
+
let estree = toEstree(root), varToImport = extractImports(estree), { title, of, name, summary, isTemplate, metaTags } = extractTitle(estree, varToImport);
|
|
5621
|
+
return store.title = title, store.of = of, store.name = name, store.summary = summary, store.isTemplate = isTemplate, store.metaTags = metaTags, store.imports = Array.from(new Set(Object.values(varToImport))), root;
|
|
5622
|
+
}, analyze = async (code) => {
|
|
5623
|
+
let store = {
|
|
5624
|
+
title: void 0,
|
|
5625
|
+
of: void 0,
|
|
5626
|
+
name: void 0,
|
|
5627
|
+
isTemplate: !1,
|
|
5628
|
+
metaTags: void 0,
|
|
5629
|
+
imports: void 0
|
|
5630
|
+
}, { compile } = await import("../_node-chunks/mdx-N42X6CFJ-RAL72UTP.js");
|
|
5631
|
+
await compile(code, {
|
|
5632
|
+
rehypePlugins: [[plugin, store]]
|
|
5633
|
+
});
|
|
5634
|
+
let { title, of, name, summary, isTemplate, metaTags, imports = [] } = store;
|
|
5635
|
+
return { title, of, name, summary, isTemplate, metaTags, imports };
|
|
5636
|
+
};
|
|
5637
|
+
|
|
5638
|
+
// src/core-server/utils/StoryIndexGenerator.ts
|
|
5234
5639
|
var import_picocolors3 = __toESM(require_picocolors(), 1);
|
|
5235
|
-
var import_ts_dedent2 = __toESM(require_dist(), 1), TsconfigPaths = __toESM(
|
|
5640
|
+
var import_ts_dedent2 = __toESM(require_dist(), 1), TsconfigPaths = __toESM(require_lib3(), 1);
|
|
5236
5641
|
|
|
5237
5642
|
// src/preview-api/modules/store/sortStories.ts
|
|
5238
5643
|
var import_ts_dedent = __toESM(require_dist(), 1);
|
|
@@ -5336,9 +5741,8 @@ var addStats = (stat, acc) => {
|
|
|
5336
5741
|
};
|
|
5337
5742
|
|
|
5338
5743
|
// src/core-server/utils/StoryIndexGenerator.ts
|
|
5339
|
-
var AUTODOCS_TAG = "autodocs", ATTACHED_MDX_TAG = "attached-mdx", UNATTACHED_MDX_TAG = "unattached-mdx", PLAY_FN_TAG = "play-fn", TEST_FN_TAG = "test-fn";
|
|
5340
5744
|
function isMdxEntry({ tags }) {
|
|
5341
|
-
return tags?.includes(
|
|
5745
|
+
return tags?.includes(Tag.UNATTACHED_MDX) || tags?.includes(Tag.ATTACHED_MDX);
|
|
5342
5746
|
}
|
|
5343
5747
|
var makeAbsolute = (otherImport, normalizedPath, workingDir) => otherImport.startsWith(".") ? slash(resolve3(workingDir, normalizeStoryPath(join5(dirname2(normalizedPath), otherImport)))) : otherImport, StoryIndexGenerator = class _StoryIndexGenerator {
|
|
5344
5748
|
constructor(specifiers, options) {
|
|
@@ -5368,7 +5772,7 @@ var makeAbsolute = (otherImport, normalizedPath, workingDir) => otherImport.star
|
|
|
5368
5772
|
let cacheKey = this.getFindMatchingFilesCacheKey(specifier, workingDir, ignoreWarnings), cached = this.findMatchingFilesCache.get(cacheKey);
|
|
5369
5773
|
if (cached)
|
|
5370
5774
|
return cached;
|
|
5371
|
-
let pathToSubIndex = {}, globCwd = slash(resolve3(workingDir, specifier.directory)), globPattern = specifier.files.startsWith("!") ? `./${specifier.files}` : specifier.files, { globby } = await import("../_node-chunks/globby-
|
|
5775
|
+
let pathToSubIndex = {}, globCwd = slash(resolve3(workingDir, specifier.directory)), globPattern = specifier.files.startsWith("!") ? `./${specifier.files}` : specifier.files, { globby } = await import("../_node-chunks/globby-4D4NBVG7.js"), files = await globby(globPattern, {
|
|
5372
5776
|
absolute: !0,
|
|
5373
5777
|
cwd: globCwd,
|
|
5374
5778
|
...commonGlobOptions2(globPattern)
|
|
@@ -5381,7 +5785,7 @@ var makeAbsolute = (otherImport, normalizedPath, workingDir) => otherImport.star
|
|
|
5381
5785
|
let ext = extname(absolutePath);
|
|
5382
5786
|
if (ext === ".storyshot") {
|
|
5383
5787
|
let relativePath = relative4(workingDir, absolutePath);
|
|
5384
|
-
|
|
5788
|
+
logger4.info(`Skipping ${ext} file ${relativePath}`);
|
|
5385
5789
|
return;
|
|
5386
5790
|
}
|
|
5387
5791
|
pathToSubIndex[absolutePath] = !1;
|
|
@@ -5530,7 +5934,7 @@ var makeAbsolute = (otherImport, normalizedPath, workingDir) => otherImport.star
|
|
|
5530
5934
|
};
|
|
5531
5935
|
return subtype === "test" && (entry.parent = input.parent, entry.parentName = input.parentName), input.exportName && (entry.exportName = input.exportName), entry;
|
|
5532
5936
|
});
|
|
5533
|
-
if (storyEntries.some((entry) => entry.tags.includes(
|
|
5937
|
+
if (storyEntries.some((entry) => entry.tags.includes(Tag.AUTODOCS)) && !!this.options.docs && this.options.build?.test?.disableAutoDocs !== !0) {
|
|
5534
5938
|
let name = this.options.docs?.defaultName ?? "Docs", { metaId } = indexInputs[0], entry = storyEntries[0], id = toId(metaId ?? entry.title, name), tags = combineTags(...projectTags, ...indexInputs[0].tags ?? []);
|
|
5535
5939
|
return {
|
|
5536
5940
|
entries: [{
|
|
@@ -5555,7 +5959,7 @@ var makeAbsolute = (otherImport, normalizedPath, workingDir) => otherImport.star
|
|
|
5555
5959
|
async extractDocs(specifier, absolutePath, projectTags = []) {
|
|
5556
5960
|
let relativePath = relative4(this.options.workingDir, absolutePath);
|
|
5557
5961
|
try {
|
|
5558
|
-
let normalizedPath = normalizeStoryPath(relativePath), importPath = slash(normalizedPath), content = await readFile(absolutePath, { encoding: "utf8" }),
|
|
5962
|
+
let normalizedPath = normalizeStoryPath(relativePath), importPath = slash(normalizedPath), content = await readFile(absolutePath, { encoding: "utf8" }), result = await analyze(content);
|
|
5559
5963
|
if (result.isTemplate)
|
|
5560
5964
|
return !1;
|
|
5561
5965
|
let absoluteImports = result.imports.map(
|
|
@@ -5595,7 +5999,7 @@ var makeAbsolute = (otherImport, normalizedPath, workingDir) => otherImport.star
|
|
|
5595
5999
|
...projectTags,
|
|
5596
6000
|
...csfEntry?.tags ?? [],
|
|
5597
6001
|
...result.metaTags ?? [],
|
|
5598
|
-
csfEntry ?
|
|
6002
|
+
csfEntry ? Tag.ATTACHED_MDX : Tag.UNATTACHED_MDX
|
|
5599
6003
|
);
|
|
5600
6004
|
return {
|
|
5601
6005
|
id,
|
|
@@ -5607,7 +6011,7 @@ var makeAbsolute = (otherImport, normalizedPath, workingDir) => otherImport.star
|
|
|
5607
6011
|
tags
|
|
5608
6012
|
};
|
|
5609
6013
|
} catch (err) {
|
|
5610
|
-
throw err && err.source?.match(/mdast-util-mdx-jsx/g) &&
|
|
6014
|
+
throw err && err.source?.match(/mdast-util-mdx-jsx/g) && logger4.warn(
|
|
5611
6015
|
`\u{1F4A1} This seems to be an MDX2 syntax error. Please refer to the MDX section in the following resource for assistance on how to fix this: ${import_picocolors3.default.yellow(
|
|
5612
6016
|
"https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#mdx2-upgrade"
|
|
5613
6017
|
)}`
|
|
@@ -5640,9 +6044,9 @@ var makeAbsolute = (otherImport, normalizedPath, workingDir) => otherImport.star
|
|
|
5640
6044
|
`You have two component docs pages with the same name ${betterEntry.title}:${betterEntry.name}. ${changeDocsName}`,
|
|
5641
6045
|
[firstEntry.importPath, secondEntry.importPath]
|
|
5642
6046
|
);
|
|
5643
|
-
if (worseEntry.tags?.includes(
|
|
6047
|
+
if (worseEntry.tags?.includes(Tag.AUTODOCS) && !projectTags?.includes(Tag.AUTODOCS))
|
|
5644
6048
|
throw new IndexingError(
|
|
5645
|
-
`You created a component docs page for '${worseEntry.title}', but also tagged the CSF file with '${
|
|
6049
|
+
`You created a component docs page for '${worseEntry.title}', but also tagged the CSF file with '${Tag.AUTODOCS}'. This is probably a mistake.`,
|
|
5646
6050
|
[betterEntry.importPath, worseEntry.importPath]
|
|
5647
6051
|
);
|
|
5648
6052
|
} else
|
|
@@ -5695,7 +6099,7 @@ var makeAbsolute = (otherImport, normalizedPath, workingDir) => otherImport.star
|
|
|
5695
6099
|
entries: sorted
|
|
5696
6100
|
}, { storyIndex: this.lastIndex, stats: this.lastStats };
|
|
5697
6101
|
} catch (err) {
|
|
5698
|
-
throw this.lastError = err == null || err instanceof Error ? err : void 0, invariant(this.lastError),
|
|
6102
|
+
throw this.lastError = err == null || err instanceof Error ? err : void 0, invariant(this.lastError), logger4.warn(`\u{1F6A8} ${this.lastError.toString()}`), this.lastError;
|
|
5699
6103
|
}
|
|
5700
6104
|
}
|
|
5701
6105
|
invalidateAll() {
|
|
@@ -5751,7 +6155,7 @@ var makeAbsolute = (otherImport, normalizedPath, workingDir) => otherImport.star
|
|
|
5751
6155
|
return previewFile && (await readFile(previewFile, { encoding: "utf8" })).toString();
|
|
5752
6156
|
}
|
|
5753
6157
|
getProjectTags(previewCode) {
|
|
5754
|
-
let projectTags = [], defaultTags = [
|
|
6158
|
+
let projectTags = [], defaultTags = [Tag.DEV, Tag.TEST, Tag.MANIFEST];
|
|
5755
6159
|
if (previewCode)
|
|
5756
6160
|
try {
|
|
5757
6161
|
projectTags = loadConfig(previewCode).parse().getFieldValue(["tags"]) ?? [];
|
|
@@ -5779,8 +6183,7 @@ var makeAbsolute = (otherImport, normalizedPath, workingDir) => otherImport.star
|
|
|
5779
6183
|
};
|
|
5780
6184
|
|
|
5781
6185
|
// src/core-server/utils/summarizeIndex.ts
|
|
5782
|
-
var PAGE_REGEX = /(page|screen)/i
|
|
5783
|
-
var isPageStory = (storyId) => PAGE_REGEX.test(storyId), isCLIExampleEntry = (entry) => [
|
|
6186
|
+
var PAGE_REGEX = /(page|screen)/i, isPageStory = (storyId) => PAGE_REGEX.test(storyId), isCLIExampleEntry = (entry) => [
|
|
5784
6187
|
"example-introduction--docs",
|
|
5785
6188
|
"configure-your-project--docs",
|
|
5786
6189
|
"example-button--docs",
|
|
@@ -5797,7 +6200,7 @@ var isPageStory = (storyId) => PAGE_REGEX.test(storyId), isCLIExampleEntry = (en
|
|
|
5797
6200
|
function summarizeIndex(storyIndex) {
|
|
5798
6201
|
let storyCount = 0, componentTitles = /* @__PURE__ */ new Set(), exampleStoryCount = 0, onboardingStoryCount = 0, onboardingDocsCount = 0, exampleDocsCount = 0, pageStoryCount = 0, playStoryCount = 0, testStoryCount = 0, autodocsCount = 0, mdxCount = 0, svelteCsfV4Count = 0, svelteCsfV5Count = 0, testsPerParentStory = /* @__PURE__ */ new Map();
|
|
5799
6202
|
Object.values(storyIndex.entries).forEach((entry) => {
|
|
5800
|
-
isCLIExampleEntry(entry) ? (entry.type === "story" && (exampleStoryCount += 1), entry.type === "docs" && (exampleDocsCount += 1)) : isExampleStoryId2(entry.id) ? (entry.type === "story" && (onboardingStoryCount += 1), entry.type === "docs" && (onboardingDocsCount += 1)) : entry.type === "story" ? (storyCount += 1, componentTitles.add(entry.title), isPageStory(entry.title) && (pageStoryCount += 1), entry.tags?.includes(
|
|
6203
|
+
isCLIExampleEntry(entry) ? (entry.type === "story" && (exampleStoryCount += 1), entry.type === "docs" && (exampleDocsCount += 1)) : isExampleStoryId2(entry.id) ? (entry.type === "story" && (onboardingStoryCount += 1), entry.type === "docs" && (onboardingDocsCount += 1)) : entry.type === "story" ? (storyCount += 1, componentTitles.add(entry.title), isPageStory(entry.title) && (pageStoryCount += 1), entry.tags?.includes(Tag.PLAY_FN) && (playStoryCount += 1), entry.tags?.includes(Tag.TEST_FN) && entry.parent && (testStoryCount += 1, testsPerParentStory.set(entry.parent, (testsPerParentStory.get(entry.parent) ?? 0) + 1)), entry.tags?.includes("svelte-csf-v4") ? svelteCsfV4Count += 1 : entry.tags?.includes("svelte-csf-v5") && (svelteCsfV5Count += 1)) : entry.type === "docs" && (isMdxEntry(entry) ? mdxCount += 1 : entry.tags?.includes(Tag.AUTODOCS) && (autodocsCount += 1));
|
|
5801
6204
|
});
|
|
5802
6205
|
let componentCount = componentTitles.size, maxTestsPerStory = 0, singleTestStoryCount = 0;
|
|
5803
6206
|
return testsPerParentStory.forEach((count) => {
|
|
@@ -5826,19 +6229,17 @@ function summarizeIndex(storyIndex) {
|
|
|
5826
6229
|
async function buildStaticStandalone(options) {
|
|
5827
6230
|
if (options.configType = "PRODUCTION", options.outputDir === "")
|
|
5828
6231
|
throw new Error("Won't remove current directory. Check your outputDir!");
|
|
5829
|
-
if (options.outputDir = resolve(options.outputDir), options.configDir = resolve(options.configDir),
|
|
6232
|
+
if (options.outputDir = resolve(options.outputDir), options.configDir = resolve(options.configDir), logger5.step(`Cleaning outputDir: ${import_picocolors4.default.cyan(relative(process.cwd(), options.outputDir))}`), options.outputDir === "/")
|
|
5830
6233
|
throw new Error("Won't remove directory '/'. Check your outputDir!");
|
|
5831
6234
|
await rm(options.outputDir, { recursive: !0, force: !0 }).catch(() => {
|
|
5832
|
-
}), await
|
|
6235
|
+
}), await mkdir2(options.outputDir, { recursive: !0 });
|
|
5833
6236
|
let config = await loadMainConfig(options), { framework } = config, corePresets = [], frameworkName = typeof framework == "string" ? framework : framework?.name;
|
|
5834
|
-
frameworkName ? corePresets.push(join(frameworkName, "preset")) : options.ignorePreview ||
|
|
6237
|
+
frameworkName ? corePresets.push(join(frameworkName, "preset")) : options.ignorePreview || logger5.warn(`you have not specified a framework in your ${options.configDir}/main.js`);
|
|
5835
6238
|
let commonPreset = join(
|
|
5836
6239
|
resolvePackageDir("storybook"),
|
|
5837
6240
|
"dist/core-server/presets/common-preset.js"
|
|
5838
|
-
), commonOverridePreset = import.meta.resolve(
|
|
5839
|
-
|
|
5840
|
-
);
|
|
5841
|
-
logger4.step("Loading presets");
|
|
6241
|
+
), commonOverridePreset = import.meta.resolve("storybook/internal/core-server/presets/common-override-preset");
|
|
6242
|
+
logger5.step("Loading presets");
|
|
5842
6243
|
let presets = await loadAllPresets({
|
|
5843
6244
|
corePresets: [commonPreset, ...corePresets],
|
|
5844
6245
|
overridePresets: [commonOverridePreset],
|
|
@@ -5877,34 +6278,14 @@ async function buildStaticStandalone(options) {
|
|
|
5877
6278
|
let coreServerPublicDir = join(resolvePackageDir("storybook"), "assets/browser");
|
|
5878
6279
|
effects.push(cp2(coreServerPublicDir, options.outputDir, { recursive: !0 }));
|
|
5879
6280
|
let storyIndexGeneratorPromise = Promise.resolve(void 0);
|
|
5880
|
-
|
|
6281
|
+
options.ignorePreview || (storyIndexGeneratorPromise = presets.apply("storyIndexGenerator"), effects.push(
|
|
5881
6282
|
writeIndexJson(
|
|
5882
6283
|
join(options.outputDir, "index.json"),
|
|
5883
6284
|
storyIndexGeneratorPromise
|
|
5884
6285
|
)
|
|
5885
|
-
), features?.experimentalComponentsManifest))
|
|
5886
|
-
let componentManifestGenerator = await presets.apply(
|
|
5887
|
-
"experimental_componentManifestGenerator"
|
|
5888
|
-
), indexGenerator = await storyIndexGeneratorPromise;
|
|
5889
|
-
if (componentManifestGenerator && indexGenerator)
|
|
5890
|
-
try {
|
|
5891
|
-
let manifests = await componentManifestGenerator(
|
|
5892
|
-
indexGenerator
|
|
5893
|
-
);
|
|
5894
|
-
await mkdir(join(options.outputDir, "manifests"), { recursive: !0 }), await writeFile3(
|
|
5895
|
-
join(options.outputDir, "manifests", "components.json"),
|
|
5896
|
-
JSON.stringify(manifests)
|
|
5897
|
-
), await writeFile3(
|
|
5898
|
-
join(options.outputDir, "manifests", "components.html"),
|
|
5899
|
-
renderManifestComponentsPage(manifests)
|
|
5900
|
-
);
|
|
5901
|
-
} catch (e) {
|
|
5902
|
-
logger4.error("Failed to generate manifests/components.json"), logger4.error(e instanceof Error ? e : String(e));
|
|
5903
|
-
}
|
|
5904
|
-
}
|
|
5905
|
-
core2?.disableProjectJson || effects.push(
|
|
6286
|
+
), features?.experimentalComponentsManifest && effects.push(writeManifests(options.outputDir, presets))), core2?.disableProjectJson || effects.push(
|
|
5906
6287
|
extractStorybookMetadata(join(options.outputDir, "project.json"), options.configDir)
|
|
5907
|
-
), options.debugWebpack && logConfig("Preview webpack config", await previewBuilder.getConfig(fullOptions)), options.ignorePreview ?
|
|
6288
|
+
), options.debugWebpack && logConfig("Preview webpack config", await previewBuilder.getConfig(fullOptions)), options.ignorePreview ? logger5.info("Not building preview") : logger5.info("Building preview..");
|
|
5908
6289
|
let startTime = process.hrtime();
|
|
5909
6290
|
if (await Promise.all([
|
|
5910
6291
|
...options.ignorePreview ? [] : [
|
|
@@ -5912,14 +6293,14 @@ async function buildStaticStandalone(options) {
|
|
|
5912
6293
|
startTime,
|
|
5913
6294
|
options: fullOptions
|
|
5914
6295
|
}).then(async (previewStats) => {
|
|
5915
|
-
|
|
6296
|
+
logger5.trace({ message: "Preview built", time: process.hrtime(startTime) });
|
|
5916
6297
|
let statsOption = options.webpackStatsJson || options.statsJson;
|
|
5917
6298
|
if (statsOption) {
|
|
5918
6299
|
let target = statsOption === !0 ? options.outputDir : statsOption;
|
|
5919
6300
|
await outputStats(target, previewStats);
|
|
5920
6301
|
}
|
|
5921
6302
|
}).catch((error) => {
|
|
5922
|
-
throw
|
|
6303
|
+
throw logger5.error("Failed to build the preview"), process.exitCode = 1, error;
|
|
5923
6304
|
})
|
|
5924
6305
|
],
|
|
5925
6306
|
...effects
|
|
@@ -5932,9 +6313,9 @@ async function buildStaticStandalone(options) {
|
|
|
5932
6313
|
storyIndex: summarizeIndex(storyIndex)
|
|
5933
6314
|
}), await telemetry2("build", payload, { configDir: options.configDir });
|
|
5934
6315
|
} catch (e) {
|
|
5935
|
-
|
|
6316
|
+
logger5.debug?.(`Build telemetry failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
5936
6317
|
}
|
|
5937
|
-
|
|
6318
|
+
logger5.step(`Output directory: ${options.outputDir}`);
|
|
5938
6319
|
}
|
|
5939
6320
|
|
|
5940
6321
|
// src/core-server/build-dev.ts
|
|
@@ -5951,7 +6332,7 @@ import {
|
|
|
5951
6332
|
validateFrameworkName,
|
|
5952
6333
|
versions
|
|
5953
6334
|
} from "storybook/internal/common";
|
|
5954
|
-
import { deprecate, logger as
|
|
6335
|
+
import { deprecate, logger as logger14, prompt } from "storybook/internal/node-logger";
|
|
5955
6336
|
import { MissingBuilderError as MissingBuilderError3, NoStatsForViteDevError } from "storybook/internal/server-errors";
|
|
5956
6337
|
import { oneWayHash, telemetry as telemetry4 } from "storybook/internal/telemetry";
|
|
5957
6338
|
import { global as global3 } from "@storybook/global";
|
|
@@ -5959,7 +6340,7 @@ var import_ts_dedent8 = __toESM(require_dist(), 1);
|
|
|
5959
6340
|
|
|
5960
6341
|
// src/core-server/dev-server.ts
|
|
5961
6342
|
import { logConfig as logConfig2, normalizeStories as normalizeStories2 } from "storybook/internal/common";
|
|
5962
|
-
import { logger as
|
|
6343
|
+
import { logger as logger10 } from "storybook/internal/node-logger";
|
|
5963
6344
|
import { MissingBuilderError as MissingBuilderError2 } from "storybook/internal/server-errors";
|
|
5964
6345
|
|
|
5965
6346
|
// ../../node_modules/@polka/compression/build.mjs
|
|
@@ -6616,33 +6997,57 @@ async function getMiddleware(configDir) {
|
|
|
6616
6997
|
|
|
6617
6998
|
// src/core-server/utils/open-browser/open-in-browser.ts
|
|
6618
6999
|
var import_ts_dedent4 = __toESM(require_dist(), 1);
|
|
6619
|
-
import { logger as
|
|
7000
|
+
import { logger as logger7 } from "storybook/internal/node-logger";
|
|
6620
7001
|
import open2 from "open";
|
|
6621
7002
|
|
|
6622
7003
|
// src/core-server/utils/open-browser/opener.ts
|
|
6623
7004
|
var import_cross_spawn = __toESM(require_cross_spawn(), 1), import_picocolors5 = __toESM(require_picocolors(), 1);
|
|
6624
7005
|
import { execSync } from "node:child_process";
|
|
6625
7006
|
import { join as join6 } from "node:path";
|
|
7007
|
+
import { logger as logger6 } from "storybook/internal/node-logger";
|
|
6626
7008
|
import open from "open";
|
|
6627
|
-
var OSX_CHROME = "google chrome"
|
|
6628
|
-
NONE: 0,
|
|
6629
|
-
BROWSER: 1,
|
|
6630
|
-
SCRIPT: 2
|
|
6631
|
-
});
|
|
7009
|
+
var OSX_CHROME = "google chrome";
|
|
6632
7010
|
function getBrowserEnv() {
|
|
6633
|
-
let value = process.env.BROWSER, args = process.env.BROWSER_ARGS ? process.env.BROWSER_ARGS.split(" ") : []
|
|
6634
|
-
return value ? value.toLowerCase().endsWith(".js") ? action
|
|
7011
|
+
let value = process.env.BROWSER, args = process.env.BROWSER_ARGS ? process.env.BROWSER_ARGS.split(" ") : [];
|
|
7012
|
+
return value ? value.toLowerCase() === "none" ? { action: 0 /* NONE */ } : value.toLowerCase().endsWith(".js") || value.toLowerCase().endsWith(".mjs") || value.toLowerCase().endsWith(".cjs") || value.toLowerCase().endsWith(".ts") ? { action: 2 /* SCRIPT */, value, args } : value.toLowerCase().endsWith(".sh") ? { action: 3 /* SHELL_SCRIPT */, value, args } : { action: 1 /* BROWSER */, value, args } : { action: 1 /* BROWSER */, args };
|
|
6635
7013
|
}
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
|
|
6639
|
-
|
|
6640
|
-
|
|
7014
|
+
var BrowserEnvError = class extends StorybookError {
|
|
7015
|
+
constructor(message) {
|
|
7016
|
+
super({
|
|
7017
|
+
category: "CORE_SERVER",
|
|
7018
|
+
code: 1,
|
|
7019
|
+
message,
|
|
7020
|
+
name: "BrowserEnvError"
|
|
7021
|
+
});
|
|
7022
|
+
}
|
|
7023
|
+
};
|
|
7024
|
+
function attachEventHandlers(child, scriptPath) {
|
|
7025
|
+
child.on("error", (error) => {
|
|
7026
|
+
logger6.error(
|
|
7027
|
+
`Failed to run script specified in BROWSER.
|
|
7028
|
+
${import_picocolors5.default.cyan(scriptPath)}: ${error.message}`
|
|
7029
|
+
);
|
|
7030
|
+
}), child.on("close", (code) => {
|
|
6641
7031
|
if (code !== 0) {
|
|
6642
|
-
|
|
7032
|
+
logger6.error(
|
|
7033
|
+
`The script specified as BROWSER environment variable failed.
|
|
7034
|
+
${import_picocolors5.default.cyan(scriptPath)} exited with code ${code}.`
|
|
7035
|
+
);
|
|
6643
7036
|
return;
|
|
6644
7037
|
}
|
|
6645
|
-
})
|
|
7038
|
+
});
|
|
7039
|
+
}
|
|
7040
|
+
function executeNodeScript(scriptPath, url) {
|
|
7041
|
+
let extraArgs = process.argv.slice(2), child = (0, import_cross_spawn.default)(process.execPath, [scriptPath, ...extraArgs, url], {
|
|
7042
|
+
stdio: "inherit"
|
|
7043
|
+
});
|
|
7044
|
+
return attachEventHandlers(child, scriptPath), !0;
|
|
7045
|
+
}
|
|
7046
|
+
function executeShellScript(scriptPath, url) {
|
|
7047
|
+
let extraArgs = process.argv.slice(2), child = (0, import_cross_spawn.default)("sh", [scriptPath, ...extraArgs, url], {
|
|
7048
|
+
stdio: "inherit"
|
|
7049
|
+
});
|
|
7050
|
+
return attachEventHandlers(child, scriptPath), !0;
|
|
6646
7051
|
}
|
|
6647
7052
|
function startBrowserProcess(browser, url, args) {
|
|
6648
7053
|
if (process.platform === "darwin" && (typeof browser != "string" || browser === OSX_CHROME)) {
|
|
@@ -6683,19 +7088,23 @@ function startBrowserProcess(browser, url, args) {
|
|
|
6683
7088
|
}
|
|
6684
7089
|
}
|
|
6685
7090
|
function openBrowser(url) {
|
|
6686
|
-
let { action, value, args } = getBrowserEnv();
|
|
7091
|
+
let { action, value, args } = getBrowserEnv(), canRunShell = process.platform !== "win32", browserTarget = value;
|
|
6687
7092
|
switch (action) {
|
|
6688
|
-
case
|
|
7093
|
+
case 0 /* NONE */:
|
|
6689
7094
|
return !1;
|
|
6690
|
-
case
|
|
6691
|
-
if (!value)
|
|
6692
|
-
throw new Error("BROWSER environment variable is not set.");
|
|
7095
|
+
case 2 /* SCRIPT */:
|
|
6693
7096
|
return executeNodeScript(value, url);
|
|
7097
|
+
case 3 /* SHELL_SCRIPT */: {
|
|
7098
|
+
if (canRunShell)
|
|
7099
|
+
return executeShellScript(value, url);
|
|
7100
|
+
throw new BrowserEnvError(
|
|
7101
|
+
"Shell scripts are not supported on Windows PowerShell. Use WSL instead."
|
|
7102
|
+
);
|
|
6694
7103
|
}
|
|
6695
|
-
case
|
|
6696
|
-
return startBrowserProcess(
|
|
7104
|
+
case 1 /* BROWSER */:
|
|
7105
|
+
return startBrowserProcess(browserTarget, url, args);
|
|
6697
7106
|
default:
|
|
6698
|
-
throw new
|
|
7107
|
+
throw new BrowserEnvError("Not implemented.");
|
|
6699
7108
|
}
|
|
6700
7109
|
}
|
|
6701
7110
|
|
|
@@ -6712,7 +7121,7 @@ async function openInBrowser(address) {
|
|
|
6712
7121
|
} catch {
|
|
6713
7122
|
errorOccured = !0;
|
|
6714
7123
|
}
|
|
6715
|
-
errorOccured &&
|
|
7124
|
+
errorOccured && logger7.error(import_ts_dedent4.dedent`
|
|
6716
7125
|
Could not open ${address} inside a browser. If you're running this command inside a
|
|
6717
7126
|
docker container or on a CI, you need to pass the '--ci' flag to prevent opening a
|
|
6718
7127
|
browser by default.
|
|
@@ -6722,7 +7131,7 @@ async function openInBrowser(address) {
|
|
|
6722
7131
|
// src/core-server/utils/server-address.ts
|
|
6723
7132
|
var import_detect_port = __toESM(require_detect_port2(), 1);
|
|
6724
7133
|
import os from "node:os";
|
|
6725
|
-
import { logger as
|
|
7134
|
+
import { logger as logger8 } from "storybook/internal/node-logger";
|
|
6726
7135
|
function getServerAddresses(port, host, proto, initialPath) {
|
|
6727
7136
|
let address = new URL(`${proto}://localhost:${port}/`), networkAddress = new URL(`${proto}://${host || getLocalIp()}:${port}/`);
|
|
6728
7137
|
if (initialPath) {
|
|
@@ -6737,7 +7146,7 @@ function getServerAddresses(port, host, proto, initialPath) {
|
|
|
6737
7146
|
};
|
|
6738
7147
|
}
|
|
6739
7148
|
var getServerPort = (port, { exactPort } = {}) => (0, import_detect_port.default)(port).then((freePort) => (freePort !== port && exactPort && process.exit(-1), freePort)).catch((error) => {
|
|
6740
|
-
|
|
7149
|
+
logger8.error(error), process.exit(-1);
|
|
6741
7150
|
}), getServerChannelUrl = (port, { https: https2 }) => `${https2 ? "wss" : "ws"}://localhost:${port}/storybook-server-channel`, getLocalIp = () => {
|
|
6742
7151
|
let allFilteredIps = Object.values(os.networkInterfaces()).flat().filter((ip) => ip && ip.family === "IPv4" && !ip.internal);
|
|
6743
7152
|
return allFilteredIps.length ? allFilteredIps[0]?.address : "0.0.0.0";
|
|
@@ -6745,13 +7154,13 @@ var getServerPort = (port, { exactPort } = {}) => (0, import_detect_port.default
|
|
|
6745
7154
|
|
|
6746
7155
|
// src/core-server/utils/server-init.ts
|
|
6747
7156
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
6748
|
-
import { logger as
|
|
7157
|
+
import { logger as logger9 } from "storybook/internal/node-logger";
|
|
6749
7158
|
import http2 from "http";
|
|
6750
7159
|
import https from "https";
|
|
6751
7160
|
async function getServer(options) {
|
|
6752
7161
|
if (!options.https)
|
|
6753
7162
|
return http2.createServer();
|
|
6754
|
-
options.sslCert || (
|
|
7163
|
+
options.sslCert || (logger9.error("Error: --ssl-cert is required with --https"), process.exit(-1)), options.sslKey || (logger9.error("Error: --ssl-key is required with --https"), process.exit(-1));
|
|
6755
7164
|
let sslOptions = {
|
|
6756
7165
|
ca: await Promise.all((options.sslCa || []).map((ca) => readFile2(ca, { encoding: "utf8" }))),
|
|
6757
7166
|
cert: await readFile2(options.sslCert, { encoding: "utf8" }),
|
|
@@ -6795,14 +7204,14 @@ async function storybookDevServer(options) {
|
|
|
6795
7204
|
server,
|
|
6796
7205
|
channel: serverChannel
|
|
6797
7206
|
}), previewResult = await Promise.resolve();
|
|
6798
|
-
options.ignorePreview || (
|
|
7207
|
+
options.ignorePreview || (logger10.debug("Starting preview.."), previewResult = await previewBuilder.start({
|
|
6799
7208
|
startTime: process.hrtime(),
|
|
6800
7209
|
options,
|
|
6801
7210
|
router: app,
|
|
6802
7211
|
server,
|
|
6803
7212
|
channel: serverChannel
|
|
6804
7213
|
}).catch(async (e) => {
|
|
6805
|
-
throw
|
|
7214
|
+
throw logger10.error("Failed to build the preview"), process.exitCode = 1, await managerBuilder?.bail().catch(), await previewBuilder?.bail().catch(), e;
|
|
6806
7215
|
}));
|
|
6807
7216
|
let listening = new Promise((resolve4, reject) => {
|
|
6808
7217
|
server.once("error", reject), app.listen({ port, host }, resolve4);
|
|
@@ -6817,41 +7226,7 @@ async function storybookDevServer(options) {
|
|
|
6817
7226
|
} catch (e) {
|
|
6818
7227
|
throw await managerBuilder?.bail().catch(), await previewBuilder?.bail().catch(), e;
|
|
6819
7228
|
}
|
|
6820
|
-
(await options.presets.apply("features"))?.experimentalComponentsManifest && (app.
|
|
6821
|
-
try {
|
|
6822
|
-
let componentManifestGenerator = await options.presets.apply(
|
|
6823
|
-
"experimental_componentManifestGenerator"
|
|
6824
|
-
), indexGenerator = await storyIndexGeneratorPromise;
|
|
6825
|
-
if (componentManifestGenerator && indexGenerator) {
|
|
6826
|
-
let manifest = await componentManifestGenerator(
|
|
6827
|
-
indexGenerator
|
|
6828
|
-
);
|
|
6829
|
-
res.setHeader("Content-Type", "application/json"), res.end(JSON.stringify(manifest));
|
|
6830
|
-
return;
|
|
6831
|
-
}
|
|
6832
|
-
res.statusCode = 400, res.end("No component manifest generator configured.");
|
|
6833
|
-
return;
|
|
6834
|
-
} catch (e) {
|
|
6835
|
-
logger8.error(e instanceof Error ? e : String(e)), res.statusCode = 500, res.end(e instanceof Error ? e.toString() : String(e));
|
|
6836
|
-
return;
|
|
6837
|
-
}
|
|
6838
|
-
}), app.get("/manifests/components.html", async (req, res) => {
|
|
6839
|
-
try {
|
|
6840
|
-
let componentManifestGenerator = await options.presets.apply(
|
|
6841
|
-
"experimental_componentManifestGenerator"
|
|
6842
|
-
), indexGenerator = await storyIndexGeneratorPromise;
|
|
6843
|
-
if (!componentManifestGenerator || !indexGenerator) {
|
|
6844
|
-
res.statusCode = 400, res.setHeader("Content-Type", "text/html; charset=utf-8"), res.end("<pre>No component manifest generator configured.</pre>");
|
|
6845
|
-
return;
|
|
6846
|
-
}
|
|
6847
|
-
let manifest = await componentManifestGenerator(
|
|
6848
|
-
indexGenerator
|
|
6849
|
-
);
|
|
6850
|
-
res.setHeader("Content-Type", "text/html; charset=utf-8"), res.end(renderManifestComponentsPage(manifest));
|
|
6851
|
-
} catch (e) {
|
|
6852
|
-
res.statusCode = 500, res.setHeader("Content-Type", "text/html; charset=utf-8"), invariant(e instanceof Error), res.end(`<pre>${e.stack}</pre>`);
|
|
6853
|
-
}
|
|
6854
|
-
})), doTelemetry(app, core2, storyIndexGeneratorPromise, options);
|
|
7229
|
+
(await options.presets.apply("features"))?.experimentalComponentsManifest && registerManifests({ app, presets: options.presets }), doTelemetry(app, core2, storyIndexGeneratorPromise, options);
|
|
6855
7230
|
async function cancelTelemetry() {
|
|
6856
7231
|
let payload = { eventType: "dev" };
|
|
6857
7232
|
try {
|
|
@@ -6869,7 +7244,7 @@ async function storybookDevServer(options) {
|
|
|
6869
7244
|
|
|
6870
7245
|
// src/core-server/utils/output-startup-information.ts
|
|
6871
7246
|
var import_picocolors7 = __toESM(require_picocolors(), 1), import_pretty_hrtime = __toESM(require_pretty_hrtime(), 1), import_ts_dedent6 = __toESM(require_dist(), 1);
|
|
6872
|
-
import { CLI_COLORS, logger as
|
|
7247
|
+
import { CLI_COLORS, logger as logger11 } from "storybook/internal/node-logger";
|
|
6873
7248
|
|
|
6874
7249
|
// src/core-server/utils/update-check.ts
|
|
6875
7250
|
var import_picocolors6 = __toESM(require_picocolors(), 1), import_ts_dedent5 = __toESM(require_dist(), 1);
|
|
@@ -6917,7 +7292,7 @@ function outputStartupInformation(options) {
|
|
|
6917
7292
|
`- Local: ${address}`,
|
|
6918
7293
|
`- On your network: ${networkAddress}`
|
|
6919
7294
|
];
|
|
6920
|
-
|
|
7295
|
+
logger11.logBox(
|
|
6921
7296
|
import_ts_dedent6.dedent`
|
|
6922
7297
|
Storybook ready!
|
|
6923
7298
|
|
|
@@ -6936,16 +7311,16 @@ ${updateMessage}` : ""}
|
|
|
6936
7311
|
managerTotalTime && `${import_picocolors7.default.underline((0, import_pretty_hrtime.default)(managerTotalTime))} for manager`,
|
|
6937
7312
|
previewTotalTime && `${import_picocolors7.default.underline((0, import_pretty_hrtime.default)(previewTotalTime))} for preview`
|
|
6938
7313
|
].filter(Boolean).join(" and ");
|
|
6939
|
-
|
|
7314
|
+
logger11.info(timeStatement);
|
|
6940
7315
|
}
|
|
6941
7316
|
|
|
6942
7317
|
// src/core-server/utils/warnOnIncompatibleAddons.ts
|
|
6943
|
-
import { logger as
|
|
7318
|
+
import { logger as logger13 } from "storybook/internal/node-logger";
|
|
6944
7319
|
|
|
6945
7320
|
// ../lib/cli-storybook/src/doctor/getIncompatibleStorybookPackages.ts
|
|
6946
7321
|
var import_picocolors8 = __toESM(require_picocolors(), 1);
|
|
6947
7322
|
import { versions as storybookCorePackages } from "storybook/internal/common";
|
|
6948
|
-
import { logger as
|
|
7323
|
+
import { logger as logger12 } from "storybook/internal/node-logger";
|
|
6949
7324
|
import semver2 from "semver";
|
|
6950
7325
|
|
|
6951
7326
|
// ../lib/cli-storybook/src/automigrate/helpers/consolidated-packages.ts
|
|
@@ -7005,7 +7380,7 @@ var checkPackageCompatibility = async (dependency, context) => {
|
|
|
7005
7380
|
availableCoreUpdate
|
|
7006
7381
|
};
|
|
7007
7382
|
} catch (err) {
|
|
7008
|
-
return skipErrors ||
|
|
7383
|
+
return skipErrors || logger12.log(
|
|
7009
7384
|
`Error checking compatibility for ${dependency}, please report an issue:
|
|
7010
7385
|
` + String(err)
|
|
7011
7386
|
), { packageName: dependency };
|
|
@@ -7075,7 +7450,7 @@ var warnOnIncompatibleAddons = async (currentStorybookVersion, packageManager) =
|
|
|
7075
7450
|
incompatiblePackagesList,
|
|
7076
7451
|
currentStorybookVersion
|
|
7077
7452
|
);
|
|
7078
|
-
incompatiblePackagesMessage &&
|
|
7453
|
+
incompatiblePackagesMessage && logger13.warn(incompatiblePackagesMessage);
|
|
7079
7454
|
};
|
|
7080
7455
|
|
|
7081
7456
|
// src/core-server/utils/warnWhenUsingArgTypesRegex.ts
|
|
@@ -7148,7 +7523,7 @@ async function buildDevStandalone(options) {
|
|
|
7148
7523
|
try {
|
|
7149
7524
|
await warnOnIncompatibleAddons(storybookVersion, packageManager);
|
|
7150
7525
|
} catch (e) {
|
|
7151
|
-
|
|
7526
|
+
logger14.warn("Storybook failed to check addon compatibility"), logger14.debug(`${e instanceof Error ? e.stack : String(e)}`);
|
|
7152
7527
|
}
|
|
7153
7528
|
try {
|
|
7154
7529
|
await warnWhenUsingArgTypesRegex(previewConfigPath, config);
|
|
@@ -7218,7 +7593,7 @@ async function buildDevStandalone(options) {
|
|
|
7218
7593
|
let problems = warnings.filter((warning) => !warning.message.includes("export 'useInsertionEffect'")).filter((warning) => !warning.message.includes("compilation but it's unused")).filter(
|
|
7219
7594
|
(warning) => !warning.message.includes("Conflicting values for 'process.env.NODE_ENV'")
|
|
7220
7595
|
);
|
|
7221
|
-
|
|
7596
|
+
logger14.log(problems.map((p) => p.stack).join(`
|
|
7222
7597
|
`)), process.exit(problems.length > 0 ? 1 : 0);
|
|
7223
7598
|
} else {
|
|
7224
7599
|
let name = frameworkName.split("@storybook/").length > 1 ? frameworkName.split("@storybook/")[1] : frameworkName;
|
|
@@ -7238,7 +7613,7 @@ async function buildDevStandalone(options) {
|
|
|
7238
7613
|
// src/core-server/build-index.ts
|
|
7239
7614
|
import { writeFile as writeFile4 } from "node:fs/promises";
|
|
7240
7615
|
import { normalizeStories as normalizeStories3 } from "storybook/internal/common";
|
|
7241
|
-
import { logger as
|
|
7616
|
+
import { logger as logger15 } from "storybook/internal/node-logger";
|
|
7242
7617
|
|
|
7243
7618
|
// src/core-server/load.ts
|
|
7244
7619
|
import {
|
|
@@ -7300,7 +7675,7 @@ var buildIndex = async (options) => {
|
|
|
7300
7675
|
return await generator.initialize(), generator.getIndex();
|
|
7301
7676
|
}, buildIndexStandalone = async (options) => {
|
|
7302
7677
|
let index = await buildIndex(options);
|
|
7303
|
-
|
|
7678
|
+
logger15.info(`Writing index to ${options.outputFile}`), await writeFile4(options.outputFile, JSON.stringify(index));
|
|
7304
7679
|
};
|
|
7305
7680
|
|
|
7306
7681
|
// src/core-server/standalone.ts
|
|
@@ -7597,6 +7972,8 @@ var testProviderStore = createTestProviderStore({
|
|
|
7597
7972
|
}), { fullTestProviderStore, getTestProviderStoreById, universalTestProviderStore } = testProviderStore;
|
|
7598
7973
|
export {
|
|
7599
7974
|
StoryIndexGenerator,
|
|
7975
|
+
Tag,
|
|
7976
|
+
analyze as analyzeMdx,
|
|
7600
7977
|
standalone_default as build,
|
|
7601
7978
|
buildDevStandalone,
|
|
7602
7979
|
buildIndex,
|
|
@@ -7607,9 +7984,11 @@ export {
|
|
|
7607
7984
|
getStatusStoreByTypeId as experimental_getStatusStore,
|
|
7608
7985
|
getTestProviderStoreById as experimental_getTestProviderStore,
|
|
7609
7986
|
loadStorybook as experimental_loadStorybook,
|
|
7987
|
+
generateStoryFile,
|
|
7610
7988
|
getErrorLevel,
|
|
7611
7989
|
getPreviewBodyTemplate,
|
|
7612
7990
|
getPreviewHeadTemplate,
|
|
7991
|
+
getServerPort,
|
|
7613
7992
|
fullStatusStore as internal_fullStatusStore,
|
|
7614
7993
|
fullTestProviderStore as internal_fullTestProviderStore,
|
|
7615
7994
|
universalStatusStore as internal_universalStatusStore,
|