storybook 10.1.0-alpha.10 → 10.1.0-alpha.12
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-FTG7SQDA.js +1097 -0
- package/dist/_browser-chunks/WithTooltip-LMROHDUP.js +1651 -0
- package/dist/_browser-chunks/chunk-2FRVAXCZ.js +7 -0
- package/dist/_browser-chunks/chunk-3IAH5M2U.js +171 -0
- package/dist/_browser-chunks/chunk-3OXGAGBE.js +779 -0
- package/dist/_browser-chunks/{chunk-TMDZCWME.js → chunk-3PJE6VLG.js} +1 -3
- package/dist/_browser-chunks/{chunk-VAMFPZY3.js → chunk-45UGUKRX.js} +2 -7
- package/dist/_browser-chunks/chunk-6XWLIJQL.js +11 -0
- package/dist/_browser-chunks/{chunk-FDWKXLBI.js → chunk-74YHFU5B.js} +44 -109
- package/dist/_browser-chunks/{chunk-MM7DTO55.js → chunk-A242L54C.js} +10 -16
- package/dist/_browser-chunks/chunk-AIOS4NGK.js +252 -0
- package/dist/_browser-chunks/chunk-AS2HQEYC.js +14 -0
- package/dist/_browser-chunks/chunk-AXG2BOBL.js +836 -0
- package/dist/_browser-chunks/chunk-BE2DAXKJ.js +2966 -0
- package/dist/_browser-chunks/{chunk-MH6AXFXB.js → chunk-CHUV5WSW.js} +0 -5
- package/dist/_browser-chunks/chunk-EBHB6RPS.js +61 -0
- package/dist/_browser-chunks/chunk-EUVGDK4H.js +93 -0
- package/dist/_browser-chunks/chunk-EZSQOHRI.js +18 -0
- package/dist/_browser-chunks/{chunk-CADGRH3P.js → chunk-FNXWN6IK.js} +3 -8
- package/dist/_browser-chunks/chunk-GFLS4VP3.js +64 -0
- package/dist/_browser-chunks/{chunk-L2D73C6Z.js → chunk-H6XK3RSC.js} +13 -21
- package/dist/_browser-chunks/chunk-IPA5A322.js +71 -0
- package/dist/_browser-chunks/chunk-JP7NCOJX.js +37 -0
- package/dist/_browser-chunks/chunk-KJHJLCBK.js +11 -0
- package/dist/_browser-chunks/{chunk-QMY4G4R2.js → chunk-L4RMQ7D7.js} +17 -64
- package/dist/_browser-chunks/{chunk-AB7OOPUX.js → chunk-QKODTO7K.js} +0 -5
- package/dist/_browser-chunks/chunk-RP5RXKFU.js +2491 -0
- package/dist/_browser-chunks/chunk-SL75JR6Y.js +9 -0
- package/dist/_browser-chunks/chunk-UD6FQLAF.js +1481 -0
- package/dist/_browser-chunks/chunk-VYJQ7RU5.js +2853 -0
- package/dist/_browser-chunks/chunk-WJYERY3R.js +136 -0
- package/dist/_browser-chunks/chunk-WXP2XJ3O.js +950 -0
- package/dist/_browser-chunks/chunk-X3DUQ5RA.js +47 -0
- package/dist/_browser-chunks/chunk-XJNX76GA.js +85 -0
- package/dist/_browser-chunks/{chunk-F4Q6SGTB.js → chunk-YKE5S47A.js} +177 -399
- package/dist/_browser-chunks/{chunk-SN4J4IQ3.js → chunk-ZUWEVLDX.js} +1 -7
- package/dist/_browser-chunks/{formatter-OMEEQ6HG.js → formatter-QJ4M4OGQ.js} +4 -9
- package/dist/_browser-chunks/{syntaxhighlighter-RJZASWHL.js → syntaxhighlighter-WKBQ5RC7.js} +704 -1848
- package/dist/_node-chunks/{builder-manager-HA7CYFCK.js → builder-manager-YUOHSIUB.js} +475 -1013
- package/dist/_node-chunks/camelcase-JREIL7NV.js +18 -0
- package/dist/_node-chunks/{chunk-RMHAL25C.js → chunk-2D2IODUU.js} +88 -228
- package/dist/_node-chunks/chunk-2DMESZFJ.js +943 -0
- package/dist/_node-chunks/chunk-4FT2DHGE.js +3009 -0
- package/dist/_node-chunks/chunk-5HV3B5OP.js +45571 -0
- package/dist/_node-chunks/{chunk-OVXB5GGT.js → chunk-5KLIDWFN.js} +292 -688
- package/dist/_node-chunks/chunk-A4APXFQ2.js +759 -0
- package/dist/_node-chunks/chunk-B6JWY6PC.js +37 -0
- package/dist/_node-chunks/chunk-CZ5GHJCC.js +603 -0
- package/dist/_node-chunks/chunk-DUXPWBOK.js +61 -0
- package/dist/_node-chunks/chunk-DWXTZT3D.js +58 -0
- package/dist/_node-chunks/chunk-E5FJS66Z.js +20 -0
- package/dist/_node-chunks/chunk-EZWWR7AR.js +936 -0
- package/dist/_node-chunks/chunk-FDXFVHIL.js +1114 -0
- package/dist/_node-chunks/{chunk-F3XOPI6H.js → chunk-FZLRAH4N.js} +469 -983
- package/dist/_node-chunks/chunk-HZG65SU3.js +34 -0
- package/dist/_node-chunks/chunk-IXVYNBMD.js +18 -0
- package/dist/_node-chunks/chunk-JARUEMEP.js +4523 -0
- package/dist/_node-chunks/chunk-LIH7MTP7.js +3214 -0
- package/dist/_node-chunks/chunk-N5GIRUP5.js +1047 -0
- package/dist/_node-chunks/{chunk-X4XU27M6.js → chunk-NAOYEL54.js} +15 -24
- package/dist/_node-chunks/chunk-O5DA7YLO.js +3171 -0
- package/dist/_node-chunks/chunk-OP3INKUD.js +54 -0
- package/dist/_node-chunks/chunk-QCO2ZM7F.js +209 -0
- package/dist/_node-chunks/chunk-QYQIZBS6.js +26 -0
- package/dist/_node-chunks/chunk-SEMIAAWG.js +1564 -0
- package/dist/_node-chunks/chunk-TS2UUH2J.js +301 -0
- package/dist/_node-chunks/chunk-WA6KZQZ2.js +119 -0
- package/dist/_node-chunks/{chunk-ZHSCUGNP.js → chunk-WFLWJO24.js} +3799 -7849
- package/dist/_node-chunks/chunk-WUXQMQCB.js +72 -0
- package/dist/_node-chunks/{chunk-VPR5IBMG.js → chunk-XXPJ7XR3.js} +8 -10
- package/dist/_node-chunks/chunk-Y4E6IGQF.js +61 -0
- package/dist/_node-chunks/chunk-ZL3AFKRX.js +1029 -0
- package/dist/_node-chunks/chunk-ZXSD6L3S.js +756 -0
- package/dist/_node-chunks/dist-DS2B5A3J.js +121 -0
- package/dist/_node-chunks/globby-6THB7HVX.js +3452 -0
- package/dist/_node-chunks/lib-5NKX4YGG.js +366 -0
- package/dist/_node-chunks/mdx-N42X6CFJ-ZLT3QOFF.js +14329 -0
- package/dist/_node-chunks/p-limit-PDMWNG7W.js +116 -0
- package/dist/_node-chunks/plugin-6XMWOGPO.js +123 -0
- package/dist/_node-chunks/{plugin-6ZPCS4LI.js → plugin-LTOXVT6A.js} +36 -56
- package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-2SFE5LQS.js +46582 -0
- package/dist/_node-chunks/webpack-mock-plugin-CX5J2U56.js +92 -0
- package/dist/actions/decorator.js +21 -42
- package/dist/actions/index.js +3 -3
- package/dist/babel/index.d.ts +671 -335
- package/dist/babel/index.js +11 -11
- package/dist/bin/core.js +592 -1546
- package/dist/bin/dispatcher.js +26 -37
- package/dist/bin/loader.js +23 -34
- package/dist/channels/index.js +98 -234
- package/dist/cli/index.js +1951 -5308
- package/dist/client-logger/index.js +31 -61
- package/dist/common/index.js +20 -20
- package/dist/components/index.js +4211 -8586
- package/dist/core-events/index.js +2 -66
- package/dist/core-server/index.js +3054 -7290
- package/dist/core-server/presets/common-manager.css +2 -2
- package/dist/core-server/presets/common-manager.js +1806 -3427
- package/dist/core-server/presets/common-override-preset.js +31 -60
- package/dist/core-server/presets/common-preset.js +434 -924
- package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +15 -19
- package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +12 -17
- package/dist/csf/index.js +534 -1179
- package/dist/csf-tools/index.js +9 -9
- package/dist/docs-tools/index.js +6 -6
- package/dist/highlight/index.js +2 -2
- package/dist/instrumenter/index.js +199 -415
- package/dist/manager/globals-runtime.js +24150 -47364
- package/dist/manager/globals.js +2 -3
- package/dist/manager/runtime.js +3961 -8373
- package/dist/manager-api/index.js +1231 -2425
- package/dist/manager-errors.d.ts +3 -0
- package/dist/manager-errors.js +3 -3
- package/dist/node-logger/index.js +1253 -2601
- package/dist/preview/globals.js +2 -3
- package/dist/preview/runtime.js +10364 -21990
- package/dist/preview-api/index.d.ts +67 -68
- package/dist/preview-api/index.js +13 -13
- package/dist/preview-errors.d.ts +3 -0
- package/dist/preview-errors.js +4 -4
- package/dist/router/index.js +347 -899
- package/dist/server-errors.d.ts +3 -0
- package/dist/server-errors.js +10 -10
- package/dist/telemetry/index.js +24 -24
- package/dist/test/index.js +5860 -11645
- package/dist/theming/create.js +4 -4
- package/dist/theming/index.d.ts +3363 -2597
- package/dist/theming/index.js +490 -1086
- package/dist/types/index.js +2 -11
- package/dist/viewport/index.js +3 -3
- package/package.json +5 -5
- package/dist/_browser-chunks/Color-FQNEU7YS.js +0 -1695
- package/dist/_browser-chunks/WithTooltip-6NHN2GXF.js +0 -2343
- package/dist/_browser-chunks/chunk-6A7OIVEL.js +0 -66
- package/dist/_browser-chunks/chunk-AW46NMGV.js +0 -1308
- package/dist/_browser-chunks/chunk-B4A3ADP3.js +0 -3816
- package/dist/_browser-chunks/chunk-FSBVR7H5.js +0 -106
- package/dist/_browser-chunks/chunk-FUOHXXZT.js +0 -23
- package/dist/_browser-chunks/chunk-GTKOCWCT.js +0 -17
- package/dist/_browser-chunks/chunk-HHW4FUMO.js +0 -12
- package/dist/_browser-chunks/chunk-JVSKG4YS.js +0 -4052
- package/dist/_browser-chunks/chunk-LASUB7TL.js +0 -76
- package/dist/_browser-chunks/chunk-LYCSRYYR.js +0 -101
- package/dist/_browser-chunks/chunk-NVV6MIOE.js +0 -243
- package/dist/_browser-chunks/chunk-OBXWFEPB.js +0 -852
- package/dist/_browser-chunks/chunk-OPCDBBL3.js +0 -48
- package/dist/_browser-chunks/chunk-PB6FZ3WE.js +0 -130
- package/dist/_browser-chunks/chunk-RW5PKMWM.js +0 -4182
- package/dist/_browser-chunks/chunk-SYS437NN.js +0 -122
- package/dist/_browser-chunks/chunk-U46RQHA4.js +0 -12
- package/dist/_browser-chunks/chunk-UTNZYD2N.js +0 -311
- package/dist/_browser-chunks/chunk-VUAFL5XK.js +0 -20
- package/dist/_browser-chunks/chunk-XDGMHOV7.js +0 -2197
- package/dist/_browser-chunks/chunk-XW6KSYKF.js +0 -16
- package/dist/_browser-chunks/chunk-Y3M7TW6K.js +0 -1041
- package/dist/_browser-chunks/chunk-ZNRFDIVA.js +0 -233
- package/dist/_node-chunks/camelcase-QALD4XFE.js +0 -18
- package/dist/_node-chunks/chunk-2XY53ALL.js +0 -420
- package/dist/_node-chunks/chunk-3CBQMG2A.js +0 -6712
- package/dist/_node-chunks/chunk-3WDAPZYQ.js +0 -28
- package/dist/_node-chunks/chunk-4ZB555EJ.js +0 -697
- package/dist/_node-chunks/chunk-52DXKXY3.js +0 -4272
- package/dist/_node-chunks/chunk-5OVB4A6F.js +0 -69
- package/dist/_node-chunks/chunk-AGHGNXGH.js +0 -18
- package/dist/_node-chunks/chunk-B23X5ZCK.js +0 -1531
- package/dist/_node-chunks/chunk-B2DAHWJK.js +0 -220
- package/dist/_node-chunks/chunk-CC4PW5MJ.js +0 -34
- package/dist/_node-chunks/chunk-D7NIZELR.js +0 -2256
- package/dist/_node-chunks/chunk-DO5Q3H4L.js +0 -1250
- package/dist/_node-chunks/chunk-ECK7WVFX.js +0 -304
- package/dist/_node-chunks/chunk-EUH3NHXA.js +0 -79
- package/dist/_node-chunks/chunk-FOQHPHCV.js +0 -1657
- package/dist/_node-chunks/chunk-G6EL47NS.js +0 -111
- package/dist/_node-chunks/chunk-GFLS4TJB.js +0 -90
- package/dist/_node-chunks/chunk-J3XZKWHE.js +0 -1586
- package/dist/_node-chunks/chunk-LE63EHJ5.js +0 -1518
- package/dist/_node-chunks/chunk-M47XA42S.js +0 -4741
- package/dist/_node-chunks/chunk-OOI74AL3.js +0 -61
- package/dist/_node-chunks/chunk-PRJHT3GJ.js +0 -61
- package/dist/_node-chunks/chunk-Q52PVUSU.js +0 -101
- package/dist/_node-chunks/chunk-SDCF5RNN.js +0 -1198
- package/dist/_node-chunks/chunk-UJ5SJ23M.js +0 -5029
- package/dist/_node-chunks/chunk-UPHK4ETU.js +0 -64658
- package/dist/_node-chunks/chunk-V7VURIPB.js +0 -1544
- package/dist/_node-chunks/dist-6TXHNR5C.js +0 -175
- package/dist/_node-chunks/globby-PBTV6PX6.js +0 -5222
- package/dist/_node-chunks/lib-4RTDZVGX.js +0 -518
- package/dist/_node-chunks/mdx-N42X6CFJ-COWEH7KR.js +0 -22017
- package/dist/_node-chunks/p-limit-PBVZQOFY.js +0 -168
- package/dist/_node-chunks/plugin-EOZKYZAG.js +0 -159
- package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-35HMSMR5.js +0 -69102
- package/dist/_node-chunks/webpack-mock-plugin-GT3MA5E2.js +0 -124
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_8vqew0zn9si from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_8vqew0zn9si from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_8vqew0zn9si from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_8vqew0zn9si.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_8vqew0zn9si.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_8vqew0zn9si.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
|
-
import {
|
|
13
|
-
require_build
|
|
14
|
-
} from "./chunk-4ZB555EJ.js";
|
|
15
|
-
import {
|
|
16
|
-
resolvePackageDir
|
|
17
|
-
} from "./chunk-V7VURIPB.js";
|
|
18
|
-
import {
|
|
19
|
-
require_prompts
|
|
20
|
-
} from "./chunk-UJ5SJ23M.js";
|
|
21
|
-
import {
|
|
22
|
-
require_dist
|
|
23
|
-
} from "./chunk-5OVB4A6F.js";
|
|
24
|
-
import {
|
|
25
|
-
require_picocolors
|
|
26
|
-
} from "./chunk-X4XU27M6.js";
|
|
27
|
-
import {
|
|
28
|
-
__name,
|
|
29
|
-
__toESM
|
|
30
|
-
} from "./chunk-OOI74AL3.js";
|
|
31
|
-
|
|
32
|
-
// src/core-server/utils/server-statics.ts
|
|
33
|
-
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
34
|
-
var import_sirv = __toESM(require_build(), 1);
|
|
35
|
-
var import_ts_dedent = __toESM(require_dist(), 1);
|
|
36
|
-
import { existsSync, statSync } from "node:fs";
|
|
37
|
-
import { readFile, stat } from "node:fs/promises";
|
|
38
|
-
import { basename, isAbsolute, join, posix, resolve, sep, win32 } from "node:path";
|
|
39
|
-
import { getDirectoryFromWorkingDir, resolvePathInStorybookCache } from "storybook/internal/common";
|
|
40
|
-
import { logger, once } from "storybook/internal/node-logger";
|
|
41
|
-
var cacheDir = resolvePathInStorybookCache("", "ignored-sub").split("ignored-sub")[0];
|
|
42
|
-
var files = /* @__PURE__ */ new Map();
|
|
43
|
-
var readFileOnce = /* @__PURE__ */ __name(async (path) => {
|
|
44
|
-
if (files.has(path)) {
|
|
45
|
-
return files.get(path);
|
|
46
|
-
} else {
|
|
47
|
-
const [data, stats] = await Promise.all([readFile(path, "utf-8"), stat(path)]);
|
|
48
|
-
const result = { data, mtime: stats.mtimeMs };
|
|
49
|
-
files.set(path, result);
|
|
50
|
-
return result;
|
|
51
|
-
}
|
|
52
|
-
}, "readFileOnce");
|
|
53
|
-
var faviconWrapperPath = join(
|
|
54
|
-
resolvePackageDir("storybook"),
|
|
55
|
-
"/assets/browser/favicon-wrapper.svg"
|
|
56
|
-
);
|
|
57
|
-
var prepareNestedSvg = /* @__PURE__ */ __name((svg) => {
|
|
58
|
-
const [, openingTag, contents, closingTag] = svg?.match(/(<svg[^>]*>)(.*?)(<\/svg>)/s) ?? [];
|
|
59
|
-
if (!openingTag || !contents || !closingTag) {
|
|
60
|
-
return svg;
|
|
61
|
-
}
|
|
62
|
-
let width;
|
|
63
|
-
let height;
|
|
64
|
-
let modifiedTag = openingTag.replace(/width=["']([^"']*)["']/g, (_, value) => {
|
|
65
|
-
width = parseFloat(value);
|
|
66
|
-
return 'width="32px"';
|
|
67
|
-
}).replace(/height=["']([^"']*)["']/g, (_, value) => {
|
|
68
|
-
height = parseFloat(value);
|
|
69
|
-
return 'height="32px"';
|
|
70
|
-
});
|
|
71
|
-
const hasViewBox = /viewBox=["'][^"']*["']/.test(modifiedTag);
|
|
72
|
-
if (!hasViewBox && width && height) {
|
|
73
|
-
modifiedTag = modifiedTag.replace(/>$/, ` viewBox="0 0 ${width} ${height}">`);
|
|
74
|
-
}
|
|
75
|
-
modifiedTag = modifiedTag.replace(/preserveAspectRatio=["'][^"']*["']/g, "").replace(/>$/, ' preserveAspectRatio="xMidYMid meet">');
|
|
76
|
-
return modifiedTag + contents + closingTag;
|
|
77
|
-
}, "prepareNestedSvg");
|
|
78
|
-
async function useStatics(app, options) {
|
|
79
|
-
const staticDirs = await options.presets.apply("staticDirs") ?? [];
|
|
80
|
-
const faviconPath = await options.presets.apply("favicon");
|
|
81
|
-
const faviconDir = resolve(faviconPath, "..");
|
|
82
|
-
const faviconFile = basename(faviconPath);
|
|
83
|
-
app.use(`/${faviconFile}`, async (req, res, next) => {
|
|
84
|
-
const status = req.query.status;
|
|
85
|
-
if (status && faviconFile.endsWith(".svg") && ["active", "critical", "negative", "positive", "warning"].includes(status)) {
|
|
86
|
-
const [faviconInfo, faviconWrapperInfo] = await Promise.all([
|
|
87
|
-
readFileOnce(join(faviconDir, faviconFile)),
|
|
88
|
-
readFileOnce(faviconWrapperPath)
|
|
89
|
-
]).catch((e) => {
|
|
90
|
-
if (e instanceof Error) {
|
|
91
|
-
once.warn(`Failed to read favicon: ${e.message}`);
|
|
92
|
-
}
|
|
93
|
-
return [null, null];
|
|
94
|
-
});
|
|
95
|
-
if (faviconInfo && faviconWrapperInfo) {
|
|
96
|
-
const svg = faviconWrapperInfo.data.replace('<g id="mask"', `<g mask="url(#${status}-mask)"`).replace('<use id="status"', `<use href="#${status}"`).replace('<use id="icon" />', prepareNestedSvg(faviconInfo.data));
|
|
97
|
-
res.setHeader("Content-Type", "image/svg+xml");
|
|
98
|
-
res.setHeader("ETag", `"${faviconWrapperInfo.mtime}-${faviconInfo.mtime}"`);
|
|
99
|
-
res.end(svg);
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
req.url = `/${faviconFile}`;
|
|
104
|
-
return sirvWorkaround(faviconDir)(req, res, next);
|
|
105
|
-
});
|
|
106
|
-
staticDirs.map((dir) => {
|
|
107
|
-
try {
|
|
108
|
-
const { staticDir, staticPath, targetEndpoint } = mapStaticDir(dir, options.configDir);
|
|
109
|
-
if (!targetEndpoint.startsWith("/sb-") && !staticDir.startsWith(cacheDir)) {
|
|
110
|
-
logger.info(
|
|
111
|
-
`=> Serving static files from ${import_picocolors.default.cyan(staticDir)} at ${import_picocolors.default.cyan(targetEndpoint)}`
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
if (existsSync(staticPath) && statSync(staticPath).isFile()) {
|
|
115
|
-
const staticPathDir = resolve(staticPath, "..");
|
|
116
|
-
const staticPathFile = basename(staticPath);
|
|
117
|
-
app.use(targetEndpoint, (req, res, next) => {
|
|
118
|
-
req.url = `/${staticPathFile}`;
|
|
119
|
-
sirvWorkaround(staticPathDir)(req, res, next);
|
|
120
|
-
});
|
|
121
|
-
} else {
|
|
122
|
-
app.use(targetEndpoint, sirvWorkaround(staticPath));
|
|
123
|
-
}
|
|
124
|
-
} catch (e) {
|
|
125
|
-
if (e instanceof Error) {
|
|
126
|
-
logger.warn(e.message);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
__name(useStatics, "useStatics");
|
|
132
|
-
var sirvWorkaround = /* @__PURE__ */ __name((dir, opts = {}) => (req, res, next) => {
|
|
133
|
-
const originalParsedUrl = req._parsedUrl;
|
|
134
|
-
const maybeNext = next ? () => {
|
|
135
|
-
req._parsedUrl = originalParsedUrl;
|
|
136
|
-
next();
|
|
137
|
-
} : void 0;
|
|
138
|
-
(0, import_sirv.default)(dir, { dev: true, etag: true, extensions: [], ...opts })(req, res, maybeNext);
|
|
139
|
-
}, "sirvWorkaround");
|
|
140
|
-
var parseStaticDir = /* @__PURE__ */ __name((arg) => {
|
|
141
|
-
const lastColonIndex = arg.lastIndexOf(":");
|
|
142
|
-
const isWindowsAbsolute = win32.isAbsolute(arg);
|
|
143
|
-
const isWindowsRawDirOnly = isWindowsAbsolute && lastColonIndex === 1;
|
|
144
|
-
const splitIndex = lastColonIndex !== -1 && !isWindowsRawDirOnly ? lastColonIndex : arg.length;
|
|
145
|
-
const [from, to] = [arg.slice(0, splitIndex), arg.slice(splitIndex + 1)];
|
|
146
|
-
const staticDir = isAbsolute(from) ? from : `./${from}`;
|
|
147
|
-
const staticPath = resolve(staticDir);
|
|
148
|
-
if (!existsSync(staticPath)) {
|
|
149
|
-
throw new Error(
|
|
150
|
-
import_ts_dedent.dedent`
|
|
151
|
-
Failed to load static files, no such directory: ${import_picocolors.default.cyan(staticPath)}
|
|
152
|
-
Make sure this directory exists.
|
|
153
|
-
`
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
const targetRaw = to || (statSync(staticPath).isFile() ? basename(staticPath) : "/");
|
|
157
|
-
const target = targetRaw.split(sep).join(posix.sep);
|
|
158
|
-
const targetDir = target.replace(/^\/?/, "./");
|
|
159
|
-
const targetEndpoint = targetDir.substring(1);
|
|
160
|
-
return { staticDir, staticPath, targetDir, targetEndpoint };
|
|
161
|
-
}, "parseStaticDir");
|
|
162
|
-
var mapStaticDir = /* @__PURE__ */ __name((staticDir, configDir) => {
|
|
163
|
-
const specifier = typeof staticDir === "string" ? staticDir : `${staticDir.from}:${staticDir.to}`;
|
|
164
|
-
const normalizedDir = isAbsolute(specifier) ? specifier : getDirectoryFromWorkingDir({ configDir, workingDir: process.cwd(), directory: specifier });
|
|
165
|
-
return parseStaticDir(normalizedDir);
|
|
166
|
-
}, "mapStaticDir");
|
|
167
|
-
|
|
168
|
-
// src/core-server/withTelemetry.ts
|
|
169
|
-
var import_prompts = __toESM(require_prompts(), 1);
|
|
170
|
-
import { HandledError, cache, isCI, loadAllPresets } from "storybook/internal/common";
|
|
171
|
-
import { logger as logger2 } from "storybook/internal/node-logger";
|
|
172
|
-
import { getPrecedingUpgrade, oneWayHash, telemetry } from "storybook/internal/telemetry";
|
|
173
|
-
var promptCrashReports = /* @__PURE__ */ __name(async () => {
|
|
174
|
-
if (isCI() || !process.stdout.isTTY) {
|
|
175
|
-
return void 0;
|
|
176
|
-
}
|
|
177
|
-
const { enableCrashReports } = await (0, import_prompts.default)({
|
|
178
|
-
type: "confirm",
|
|
179
|
-
name: "enableCrashReports",
|
|
180
|
-
message: `Would you like to help improve Storybook by sending anonymous crash reports?`,
|
|
181
|
-
initial: true
|
|
182
|
-
});
|
|
183
|
-
await cache.set("enableCrashReports", enableCrashReports);
|
|
184
|
-
return enableCrashReports;
|
|
185
|
-
}, "promptCrashReports");
|
|
186
|
-
async function getErrorLevel({
|
|
187
|
-
cliOptions,
|
|
188
|
-
presetOptions,
|
|
189
|
-
skipPrompt
|
|
190
|
-
}) {
|
|
191
|
-
if (cliOptions.disableTelemetry) {
|
|
192
|
-
return "none";
|
|
193
|
-
}
|
|
194
|
-
if (!presetOptions) {
|
|
195
|
-
return "full";
|
|
196
|
-
}
|
|
197
|
-
const presets = await loadAllPresets(presetOptions);
|
|
198
|
-
const core = await presets.apply("core");
|
|
199
|
-
if (core?.enableCrashReports !== void 0) {
|
|
200
|
-
return core.enableCrashReports ? "full" : "error";
|
|
201
|
-
}
|
|
202
|
-
if (core?.disableTelemetry) {
|
|
203
|
-
return "none";
|
|
204
|
-
}
|
|
205
|
-
const valueFromCache = await cache.get("enableCrashReports") ?? await cache.get("enableCrashreports");
|
|
206
|
-
if (valueFromCache !== void 0) {
|
|
207
|
-
return valueFromCache ? "full" : "error";
|
|
208
|
-
}
|
|
209
|
-
if (skipPrompt) {
|
|
210
|
-
return "error";
|
|
211
|
-
}
|
|
212
|
-
const valueFromPrompt = await promptCrashReports();
|
|
213
|
-
if (valueFromPrompt !== void 0) {
|
|
214
|
-
return valueFromPrompt ? "full" : "error";
|
|
215
|
-
}
|
|
216
|
-
return "full";
|
|
217
|
-
}
|
|
218
|
-
__name(getErrorLevel, "getErrorLevel");
|
|
219
|
-
async function sendTelemetryError(_error, eventType, options) {
|
|
220
|
-
try {
|
|
221
|
-
let errorLevel = "error";
|
|
222
|
-
try {
|
|
223
|
-
errorLevel = await getErrorLevel(options);
|
|
224
|
-
} catch (err) {
|
|
225
|
-
}
|
|
226
|
-
if (errorLevel !== "none") {
|
|
227
|
-
const precedingUpgrade = await getPrecedingUpgrade();
|
|
228
|
-
const error = _error;
|
|
229
|
-
let errorHash;
|
|
230
|
-
if ("message" in error) {
|
|
231
|
-
errorHash = error.message ? oneWayHash(error.message) : "EMPTY_MESSAGE";
|
|
232
|
-
} else {
|
|
233
|
-
errorHash = "NO_MESSAGE";
|
|
234
|
-
}
|
|
235
|
-
const { code, name, category } = error;
|
|
236
|
-
await telemetry(
|
|
237
|
-
"error",
|
|
238
|
-
{
|
|
239
|
-
code,
|
|
240
|
-
name,
|
|
241
|
-
category,
|
|
242
|
-
eventType,
|
|
243
|
-
precedingUpgrade,
|
|
244
|
-
error: errorLevel === "full" ? error : void 0,
|
|
245
|
-
errorHash,
|
|
246
|
-
// if we ever end up sending a non-error instance, we'd like to know
|
|
247
|
-
isErrorInstance: error instanceof Error
|
|
248
|
-
},
|
|
249
|
-
{
|
|
250
|
-
immediate: true,
|
|
251
|
-
configDir: options.cliOptions.configDir || options.presetOptions?.configDir,
|
|
252
|
-
enableCrashReports: errorLevel === "full"
|
|
253
|
-
}
|
|
254
|
-
);
|
|
255
|
-
}
|
|
256
|
-
} catch (err) {
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
__name(sendTelemetryError, "sendTelemetryError");
|
|
260
|
-
async function withTelemetry(eventType, options, run) {
|
|
261
|
-
const enableTelemetry = !(options.cliOptions.disableTelemetry || options.cliOptions.test === true);
|
|
262
|
-
let canceled = false;
|
|
263
|
-
async function cancelTelemetry() {
|
|
264
|
-
canceled = true;
|
|
265
|
-
if (enableTelemetry) {
|
|
266
|
-
await telemetry("canceled", { eventType }, { stripMetadata: true, immediate: true });
|
|
267
|
-
}
|
|
268
|
-
process.exit(0);
|
|
269
|
-
}
|
|
270
|
-
__name(cancelTelemetry, "cancelTelemetry");
|
|
271
|
-
if (eventType === "init") {
|
|
272
|
-
process.on("SIGINT", cancelTelemetry);
|
|
273
|
-
}
|
|
274
|
-
if (enableTelemetry) {
|
|
275
|
-
telemetry("boot", { eventType }, { stripMetadata: true });
|
|
276
|
-
}
|
|
277
|
-
try {
|
|
278
|
-
return await run();
|
|
279
|
-
} catch (error) {
|
|
280
|
-
if (canceled) {
|
|
281
|
-
return void 0;
|
|
282
|
-
}
|
|
283
|
-
if (!(error instanceof HandledError)) {
|
|
284
|
-
const { printError = logger2.error } = options;
|
|
285
|
-
printError(error);
|
|
286
|
-
}
|
|
287
|
-
if (enableTelemetry) {
|
|
288
|
-
await sendTelemetryError(error, eventType, options);
|
|
289
|
-
}
|
|
290
|
-
throw error;
|
|
291
|
-
} finally {
|
|
292
|
-
process.off("SIGINT", cancelTelemetry);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
__name(withTelemetry, "withTelemetry");
|
|
296
|
-
|
|
297
|
-
export {
|
|
298
|
-
useStatics,
|
|
299
|
-
parseStaticDir,
|
|
300
|
-
mapStaticDir,
|
|
301
|
-
getErrorLevel,
|
|
302
|
-
sendTelemetryError,
|
|
303
|
-
withTelemetry
|
|
304
|
-
};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_8vqew0zn9si from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_8vqew0zn9si from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_8vqew0zn9si from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_8vqew0zn9si.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_8vqew0zn9si.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_8vqew0zn9si.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
|
-
import {
|
|
13
|
-
__name
|
|
14
|
-
} from "./chunk-OOI74AL3.js";
|
|
15
|
-
|
|
16
|
-
// ../node_modules/empathic/resolve.mjs
|
|
17
|
-
import { createRequire } from "node:module";
|
|
18
|
-
import { isAbsolute, join, resolve } from "node:path";
|
|
19
|
-
import { fileURLToPath } from "node:url";
|
|
20
|
-
function absolute(input, root) {
|
|
21
|
-
return isAbsolute(input) ? input : resolve(root || ".", input);
|
|
22
|
-
}
|
|
23
|
-
__name(absolute, "absolute");
|
|
24
|
-
function from(root, ident, silent) {
|
|
25
|
-
try {
|
|
26
|
-
let r = root instanceof URL || root.startsWith("file://") ? join(fileURLToPath(root), "noop.js") : join(absolute(root), "noop.js");
|
|
27
|
-
return createRequire(r).resolve(ident);
|
|
28
|
-
} catch (err) {
|
|
29
|
-
if (!silent) throw err;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
__name(from, "from");
|
|
33
|
-
|
|
34
|
-
// ../node_modules/empathic/walk.mjs
|
|
35
|
-
import { dirname } from "node:path";
|
|
36
|
-
function up(base, options) {
|
|
37
|
-
let { last, cwd } = options || {};
|
|
38
|
-
let tmp = absolute(base, cwd);
|
|
39
|
-
let root = absolute(last || "/", cwd);
|
|
40
|
-
let prev, arr = [];
|
|
41
|
-
while (prev !== root) {
|
|
42
|
-
arr.push(tmp);
|
|
43
|
-
tmp = dirname(prev = tmp);
|
|
44
|
-
if (tmp === prev) break;
|
|
45
|
-
}
|
|
46
|
-
return arr;
|
|
47
|
-
}
|
|
48
|
-
__name(up, "up");
|
|
49
|
-
|
|
50
|
-
// ../node_modules/empathic/find.mjs
|
|
51
|
-
import { join as join2 } from "node:path";
|
|
52
|
-
import { existsSync, statSync } from "node:fs";
|
|
53
|
-
function up2(name, options) {
|
|
54
|
-
let dir, tmp;
|
|
55
|
-
let start = options && options.cwd || "";
|
|
56
|
-
for (dir of up(start, options)) {
|
|
57
|
-
tmp = join2(dir, name);
|
|
58
|
-
if (existsSync(tmp)) return tmp;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
__name(up2, "up");
|
|
62
|
-
function any(names, options) {
|
|
63
|
-
let dir, start = options && options.cwd || "";
|
|
64
|
-
let j = 0, len = names.length, tmp;
|
|
65
|
-
for (dir of up(start, options)) {
|
|
66
|
-
for (j = 0; j < len; j++) {
|
|
67
|
-
tmp = join2(dir, names[j]);
|
|
68
|
-
if (existsSync(tmp)) return tmp;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
__name(any, "any");
|
|
73
|
-
|
|
74
|
-
export {
|
|
75
|
-
from,
|
|
76
|
-
up,
|
|
77
|
-
up2,
|
|
78
|
-
any
|
|
79
|
-
};
|