storybook 10.1.0-alpha.1 → 10.1.0-alpha.11
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-L4RMQ7D7.js +223 -0
- 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-DK2ODWXH.js → syntaxhighlighter-WKBQ5RC7.js} +707 -1851
- package/dist/_node-chunks/{builder-manager-6UBDPV7P.js → builder-manager-PMPHOSM2.js} +495 -1013
- package/dist/_node-chunks/camelcase-K3IOOFQW.js +18 -0
- package/dist/_node-chunks/{chunk-QNUGJO6L.js → chunk-32NE3UE3.js} +15 -24
- package/dist/_node-chunks/chunk-4GZCFQFG.js +58 -0
- package/dist/_node-chunks/chunk-5QK5MSOI.js +943 -0
- package/dist/_node-chunks/{chunk-3FPF5Y2F.js → chunk-6ZOLETQK.js} +8 -10
- package/dist/_node-chunks/chunk-7I22Y76Z.js +1047 -0
- package/dist/_node-chunks/chunk-AKTRSR3O.js +72 -0
- package/dist/_node-chunks/chunk-BBOP3XCK.js +119 -0
- package/dist/_node-chunks/chunk-C2GQVDWI.js +34 -0
- package/dist/_node-chunks/{chunk-SCTKVDWR.js → chunk-GG2WQZSG.js} +4619 -7350
- package/dist/_node-chunks/chunk-GQJOWVVR.js +3214 -0
- package/dist/_node-chunks/chunk-JCRM2YVK.js +3009 -0
- package/dist/_node-chunks/chunk-KK4AT5F3.js +1029 -0
- package/dist/_node-chunks/chunk-L7MYXJUM.js +1114 -0
- package/dist/_node-chunks/{chunk-LAU7VVPC.js → chunk-LCZO45L7.js} +469 -983
- package/dist/_node-chunks/chunk-LR3QITDI.js +209 -0
- package/dist/_node-chunks/chunk-LXG4DK35.js +3171 -0
- package/dist/_node-chunks/chunk-MJ3WOS6F.js +37 -0
- package/dist/_node-chunks/chunk-PHOZWZZO.js +61 -0
- package/dist/_node-chunks/chunk-QECOQWRJ.js +936 -0
- package/dist/_node-chunks/chunk-QH4V5YDB.js +20 -0
- package/dist/_node-chunks/chunk-R6HWGZWD.js +26 -0
- package/dist/_node-chunks/chunk-SPQXMU2Q.js +759 -0
- package/dist/_node-chunks/chunk-TXZY6V6O.js +1564 -0
- package/dist/_node-chunks/chunk-UGDPX5LE.js +756 -0
- package/dist/_node-chunks/chunk-UY26MQLT.js +603 -0
- package/dist/_node-chunks/chunk-WK3EMYK6.js +61 -0
- package/dist/_node-chunks/{chunk-CJHAP7SE.js → chunk-WLHMN7AP.js} +292 -688
- package/dist/_node-chunks/chunk-XGVLB4UJ.js +54 -0
- package/dist/_node-chunks/{chunk-J7N7PD5Q.js → chunk-YHRFI6BE.js} +87 -227
- package/dist/_node-chunks/chunk-YK4KVMFW.js +18 -0
- package/dist/_node-chunks/chunk-ZZALGOA6.js +4523 -0
- package/dist/_node-chunks/chunk-ZZPBSYA5.js +301 -0
- package/dist/_node-chunks/chunk-ZZSRFAC6.js +45571 -0
- package/dist/_node-chunks/dist-4DWOCZUD.js +121 -0
- package/dist/_node-chunks/globby-AAARUKEU.js +3452 -0
- package/dist/_node-chunks/lib-HEUKGL62.js +366 -0
- package/dist/_node-chunks/mdx-N42X6CFJ-DCVRPS6N.js +14329 -0
- package/dist/_node-chunks/p-limit-F5ZKJ6WZ.js +116 -0
- package/dist/_node-chunks/plugin-7YY7JXCH.js +123 -0
- package/dist/_node-chunks/{plugin-HJLCLGNT.js → plugin-SZP3CW6W.js} +36 -56
- package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-TGKNDPO6.js +46623 -0
- package/dist/_node-chunks/webpack-mock-plugin-LNTZZFBE.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 +1966 -5347
- package/dist/client-logger/index.js +31 -61
- package/dist/common/index.d.ts +210 -3
- package/dist/common/index.js +28 -20
- package/dist/components/index.d.ts +472 -280
- package/dist/components/index.js +15992 -75
- package/dist/core-events/index.js +2 -66
- package/dist/core-server/index.js +3837 -7191
- package/dist/core-server/presets/common-manager.css +2 -2
- package/dist/core-server/presets/common-manager.js +2511 -5219
- 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 -1172
- package/dist/csf-tools/index.d.ts +15 -4
- 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 +47968 -56484
- package/dist/manager/globals.js +2 -3
- package/dist/manager/runtime.js +4901 -10318
- package/dist/manager-api/index.d.ts +11 -3
- package/dist/manager-api/index.js +1250 -2397
- package/dist/manager-errors.d.ts +3 -0
- package/dist/manager-errors.js +3 -3
- package/dist/node-logger/index.d.ts +1 -1
- package/dist/node-logger/index.js +1270 -2593
- package/dist/preview/globals.js +2 -3
- package/dist/preview/runtime.js +10767 -22386
- package/dist/preview-api/index.d.ts +67 -68
- package/dist/preview-api/index.js +15 -15
- 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 +6129 -11914
- package/dist/theming/create.d.ts +4 -2
- package/dist/theming/create.js +4 -4
- package/dist/theming/index.d.ts +3397 -2628
- package/dist/theming/index.js +502 -1091
- package/dist/types/index.d.ts +50 -5
- package/dist/types/index.js +2 -11
- package/dist/viewport/index.js +3 -3
- package/package.json +17 -9
- package/dist/_browser-chunks/Color-7ZNS6F6B.js +0 -1676
- package/dist/_browser-chunks/WithTooltip-SK46ZJ2J.js +0 -13
- package/dist/_browser-chunks/chunk-6A7OIVEL.js +0 -66
- package/dist/_browser-chunks/chunk-B4A3ADP3.js +0 -3816
- package/dist/_browser-chunks/chunk-BOOOPFZF.js +0 -2335
- package/dist/_browser-chunks/chunk-C4XOKMDU.js +0 -270
- 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-I74EUU5O.js +0 -5809
- 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-RNE2IUTB.js +0 -1300
- 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-W4QKLQSC.js +0 -4182
- 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-WKJOVNPM.js +0 -18
- package/dist/_node-chunks/chunk-2RIKHYCS.js +0 -304
- package/dist/_node-chunks/chunk-3JCSHYSU.js +0 -1657
- package/dist/_node-chunks/chunk-4GE6Q4MX.js +0 -1531
- package/dist/_node-chunks/chunk-5SEHHENC.js +0 -64656
- package/dist/_node-chunks/chunk-6GD23U64.js +0 -420
- package/dist/_node-chunks/chunk-6OAXYS5T.js +0 -1544
- package/dist/_node-chunks/chunk-7TNUMFKR.js +0 -4741
- package/dist/_node-chunks/chunk-BCDHUXAJ.js +0 -4272
- package/dist/_node-chunks/chunk-BYVQZ2HU.js +0 -220
- package/dist/_node-chunks/chunk-DAMVKHAC.js +0 -101
- package/dist/_node-chunks/chunk-FEOC7OX2.js +0 -1586
- package/dist/_node-chunks/chunk-FY7XZPLY.js +0 -2248
- package/dist/_node-chunks/chunk-GD2FXWDF.js +0 -697
- package/dist/_node-chunks/chunk-HM6B7FE5.js +0 -18
- package/dist/_node-chunks/chunk-HORWITP7.js +0 -90
- package/dist/_node-chunks/chunk-II4AFH3V.js +0 -28
- package/dist/_node-chunks/chunk-MF2PUEWG.js +0 -5029
- package/dist/_node-chunks/chunk-RVE4UTVQ.js +0 -1518
- package/dist/_node-chunks/chunk-TUFWZUTO.js +0 -69
- package/dist/_node-chunks/chunk-TXHNWNH4.js +0 -79
- package/dist/_node-chunks/chunk-ULWNTI6M.js +0 -1198
- package/dist/_node-chunks/chunk-VYRFXLRO.js +0 -6712
- package/dist/_node-chunks/chunk-WNOSTIYP.js +0 -34
- package/dist/_node-chunks/chunk-X67VGZN4.js +0 -1250
- package/dist/_node-chunks/chunk-XCEBYOA4.js +0 -61
- package/dist/_node-chunks/chunk-XW7YMR7I.js +0 -111
- package/dist/_node-chunks/chunk-ZRFYQ46H.js +0 -61
- package/dist/_node-chunks/dist-APCKHSY3.js +0 -175
- package/dist/_node-chunks/globby-TSGXGDA2.js +0 -5222
- package/dist/_node-chunks/lib-DZ5TVIU5.js +0 -518
- package/dist/_node-chunks/mdx-N42X6CFJ-Z6BYQCPN.js +0 -22017
- package/dist/_node-chunks/p-limit-MLJNGG2K.js +0 -168
- package/dist/_node-chunks/plugin-J3JI3ZKJ.js +0 -159
- package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-3QHNTM5B.js +0 -69102
- package/dist/_node-chunks/webpack-mock-plugin-4Y3MWPJ6.js +0 -124
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_843v2rliy1 from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_843v2rliy1 from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_843v2rliy1 from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_843v2rliy1.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_843v2rliy1.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_843v2rliy1.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-UY26MQLT.js";
|
|
15
|
+
import {
|
|
16
|
+
resolvePackageDir
|
|
17
|
+
} from "./chunk-SPQXMU2Q.js";
|
|
18
|
+
import {
|
|
19
|
+
require_prompts
|
|
20
|
+
} from "./chunk-GQJOWVVR.js";
|
|
21
|
+
import {
|
|
22
|
+
require_dist
|
|
23
|
+
} from "./chunk-PHOZWZZO.js";
|
|
24
|
+
import {
|
|
25
|
+
require_picocolors
|
|
26
|
+
} from "./chunk-32NE3UE3.js";
|
|
27
|
+
import {
|
|
28
|
+
__toESM
|
|
29
|
+
} from "./chunk-XGVLB4UJ.js";
|
|
30
|
+
|
|
31
|
+
// src/core-server/utils/server-statics.ts
|
|
32
|
+
var import_picocolors = __toESM(require_picocolors(), 1), import_sirv = __toESM(require_build(), 1), import_ts_dedent = __toESM(require_dist(), 1);
|
|
33
|
+
import { existsSync, statSync } from "node:fs";
|
|
34
|
+
import { readFile, stat } from "node:fs/promises";
|
|
35
|
+
import { basename, isAbsolute, join, posix, resolve, sep, win32 } from "node:path";
|
|
36
|
+
import { getDirectoryFromWorkingDir, resolvePathInStorybookCache } from "storybook/internal/common";
|
|
37
|
+
import { logger, once } from "storybook/internal/node-logger";
|
|
38
|
+
var cacheDir = resolvePathInStorybookCache("", "ignored-sub").split("ignored-sub")[0], files = /* @__PURE__ */ new Map(), readFileOnce = async (path) => {
|
|
39
|
+
if (files.has(path))
|
|
40
|
+
return files.get(path);
|
|
41
|
+
{
|
|
42
|
+
let [data, stats] = await Promise.all([readFile(path, "utf-8"), stat(path)]), result = { data, mtime: stats.mtimeMs };
|
|
43
|
+
return files.set(path, result), result;
|
|
44
|
+
}
|
|
45
|
+
}, faviconWrapperPath = join(
|
|
46
|
+
resolvePackageDir("storybook"),
|
|
47
|
+
"/assets/browser/favicon-wrapper.svg"
|
|
48
|
+
), prepareNestedSvg = (svg) => {
|
|
49
|
+
let [, openingTag, contents, closingTag] = svg?.match(/(<svg[^>]*>)(.*?)(<\/svg>)/s) ?? [];
|
|
50
|
+
if (!openingTag || !contents || !closingTag)
|
|
51
|
+
return svg;
|
|
52
|
+
let width, height, modifiedTag = openingTag.replace(/width=["']([^"']*)["']/g, (_, value) => (width = parseFloat(value), 'width="32px"')).replace(/height=["']([^"']*)["']/g, (_, value) => (height = parseFloat(value), 'height="32px"'));
|
|
53
|
+
return !/viewBox=["'][^"']*["']/.test(modifiedTag) && width && height && (modifiedTag = modifiedTag.replace(/>$/, ` viewBox="0 0 ${width} ${height}">`)), modifiedTag = modifiedTag.replace(/preserveAspectRatio=["'][^"']*["']/g, "").replace(/>$/, ' preserveAspectRatio="xMidYMid meet">'), modifiedTag + contents + closingTag;
|
|
54
|
+
};
|
|
55
|
+
async function useStatics(app, options) {
|
|
56
|
+
let staticDirs = await options.presets.apply("staticDirs") ?? [], faviconPath = await options.presets.apply("favicon"), faviconDir = resolve(faviconPath, ".."), faviconFile = basename(faviconPath);
|
|
57
|
+
app.use(`/${faviconFile}`, async (req, res, next) => {
|
|
58
|
+
let status = req.query.status;
|
|
59
|
+
if (status && faviconFile.endsWith(".svg") && ["active", "critical", "negative", "positive", "warning"].includes(status)) {
|
|
60
|
+
let [faviconInfo, faviconWrapperInfo] = await Promise.all([
|
|
61
|
+
readFileOnce(join(faviconDir, faviconFile)),
|
|
62
|
+
readFileOnce(faviconWrapperPath)
|
|
63
|
+
]).catch((e) => (e instanceof Error && once.warn(`Failed to read favicon: ${e.message}`), [null, null]));
|
|
64
|
+
if (faviconInfo && faviconWrapperInfo) {
|
|
65
|
+
let 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));
|
|
66
|
+
res.setHeader("Content-Type", "image/svg+xml"), res.setHeader("ETag", `"${faviconWrapperInfo.mtime}-${faviconInfo.mtime}"`), res.end(svg);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return req.url = `/${faviconFile}`, sirvWorkaround(faviconDir)(req, res, next);
|
|
71
|
+
}), staticDirs.map((dir) => {
|
|
72
|
+
try {
|
|
73
|
+
let { staticDir, staticPath, targetEndpoint } = mapStaticDir(dir, options.configDir);
|
|
74
|
+
if (!targetEndpoint.startsWith("/sb-") && !staticDir.startsWith(cacheDir) && logger.info(
|
|
75
|
+
`=> Serving static files from ${import_picocolors.default.cyan(staticDir)} at ${import_picocolors.default.cyan(targetEndpoint)}`
|
|
76
|
+
), existsSync(staticPath) && statSync(staticPath).isFile()) {
|
|
77
|
+
let staticPathDir = resolve(staticPath, ".."), staticPathFile = basename(staticPath);
|
|
78
|
+
app.use(targetEndpoint, (req, res, next) => {
|
|
79
|
+
req.url = `/${staticPathFile}`, sirvWorkaround(staticPathDir)(req, res, next);
|
|
80
|
+
});
|
|
81
|
+
} else
|
|
82
|
+
app.use(targetEndpoint, sirvWorkaround(staticPath));
|
|
83
|
+
} catch (e) {
|
|
84
|
+
e instanceof Error && logger.warn(e.message);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
var sirvWorkaround = (dir, opts = {}) => (req, res, next) => {
|
|
89
|
+
let originalParsedUrl = req._parsedUrl, maybeNext = next ? () => {
|
|
90
|
+
req._parsedUrl = originalParsedUrl, next();
|
|
91
|
+
} : void 0;
|
|
92
|
+
(0, import_sirv.default)(dir, { dev: !0, etag: !0, extensions: [], ...opts })(req, res, maybeNext);
|
|
93
|
+
}, parseStaticDir = (arg) => {
|
|
94
|
+
let lastColonIndex = arg.lastIndexOf(":"), isWindowsRawDirOnly = win32.isAbsolute(arg) && lastColonIndex === 1, splitIndex = lastColonIndex !== -1 && !isWindowsRawDirOnly ? lastColonIndex : arg.length, [from, to] = [arg.slice(0, splitIndex), arg.slice(splitIndex + 1)], staticDir = isAbsolute(from) ? from : `./${from}`, staticPath = resolve(staticDir);
|
|
95
|
+
if (!existsSync(staticPath))
|
|
96
|
+
throw new Error(
|
|
97
|
+
import_ts_dedent.dedent`
|
|
98
|
+
Failed to load static files, no such directory: ${import_picocolors.default.cyan(staticPath)}
|
|
99
|
+
Make sure this directory exists.
|
|
100
|
+
`
|
|
101
|
+
);
|
|
102
|
+
let targetDir = (to || (statSync(staticPath).isFile() ? basename(staticPath) : "/")).split(sep).join(posix.sep).replace(/^\/?/, "./"), targetEndpoint = targetDir.substring(1);
|
|
103
|
+
return { staticDir, staticPath, targetDir, targetEndpoint };
|
|
104
|
+
}, mapStaticDir = (staticDir, configDir) => {
|
|
105
|
+
let specifier = typeof staticDir == "string" ? staticDir : `${staticDir.from}:${staticDir.to}`, normalizedDir = isAbsolute(specifier) ? specifier : getDirectoryFromWorkingDir({ configDir, workingDir: process.cwd(), directory: specifier });
|
|
106
|
+
return parseStaticDir(normalizedDir);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// src/core-server/withTelemetry.ts
|
|
110
|
+
var import_prompts = __toESM(require_prompts(), 1);
|
|
111
|
+
import { HandledError, cache, isCI, loadAllPresets } from "storybook/internal/common";
|
|
112
|
+
import { logger as logger2 } from "storybook/internal/node-logger";
|
|
113
|
+
import { getPrecedingUpgrade, oneWayHash, telemetry } from "storybook/internal/telemetry";
|
|
114
|
+
var promptCrashReports = async () => {
|
|
115
|
+
if (isCI() || !process.stdout.isTTY)
|
|
116
|
+
return;
|
|
117
|
+
let { enableCrashReports } = await (0, import_prompts.default)({
|
|
118
|
+
type: "confirm",
|
|
119
|
+
name: "enableCrashReports",
|
|
120
|
+
message: "Would you like to help improve Storybook by sending anonymous crash reports?",
|
|
121
|
+
initial: !0
|
|
122
|
+
});
|
|
123
|
+
return await cache.set("enableCrashReports", enableCrashReports), enableCrashReports;
|
|
124
|
+
};
|
|
125
|
+
async function getErrorLevel({
|
|
126
|
+
cliOptions,
|
|
127
|
+
presetOptions,
|
|
128
|
+
skipPrompt
|
|
129
|
+
}) {
|
|
130
|
+
if (cliOptions.disableTelemetry)
|
|
131
|
+
return "none";
|
|
132
|
+
if (!presetOptions)
|
|
133
|
+
return "full";
|
|
134
|
+
let core = await (await loadAllPresets(presetOptions)).apply("core");
|
|
135
|
+
if (core?.enableCrashReports !== void 0)
|
|
136
|
+
return core.enableCrashReports ? "full" : "error";
|
|
137
|
+
if (core?.disableTelemetry)
|
|
138
|
+
return "none";
|
|
139
|
+
let valueFromCache = await cache.get("enableCrashReports") ?? await cache.get("enableCrashreports");
|
|
140
|
+
if (valueFromCache !== void 0)
|
|
141
|
+
return valueFromCache ? "full" : "error";
|
|
142
|
+
if (skipPrompt)
|
|
143
|
+
return "error";
|
|
144
|
+
let valueFromPrompt = await promptCrashReports();
|
|
145
|
+
return valueFromPrompt !== void 0 ? valueFromPrompt ? "full" : "error" : "full";
|
|
146
|
+
}
|
|
147
|
+
async function sendTelemetryError(_error, eventType, options) {
|
|
148
|
+
try {
|
|
149
|
+
let errorLevel = "error";
|
|
150
|
+
try {
|
|
151
|
+
errorLevel = await getErrorLevel(options);
|
|
152
|
+
} catch {
|
|
153
|
+
}
|
|
154
|
+
if (errorLevel !== "none") {
|
|
155
|
+
let precedingUpgrade = await getPrecedingUpgrade(), error = _error, errorHash;
|
|
156
|
+
"message" in error ? errorHash = error.message ? oneWayHash(error.message) : "EMPTY_MESSAGE" : errorHash = "NO_MESSAGE";
|
|
157
|
+
let { code, name, category } = error;
|
|
158
|
+
await telemetry(
|
|
159
|
+
"error",
|
|
160
|
+
{
|
|
161
|
+
code,
|
|
162
|
+
name,
|
|
163
|
+
category,
|
|
164
|
+
eventType,
|
|
165
|
+
precedingUpgrade,
|
|
166
|
+
error: errorLevel === "full" ? error : void 0,
|
|
167
|
+
errorHash,
|
|
168
|
+
// if we ever end up sending a non-error instance, we'd like to know
|
|
169
|
+
isErrorInstance: error instanceof Error
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
immediate: !0,
|
|
173
|
+
configDir: options.cliOptions.configDir || options.presetOptions?.configDir,
|
|
174
|
+
enableCrashReports: errorLevel === "full"
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
} catch {
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
async function withTelemetry(eventType, options, run) {
|
|
182
|
+
let enableTelemetry = !(options.cliOptions.disableTelemetry || options.cliOptions.test === !0), canceled = !1;
|
|
183
|
+
async function cancelTelemetry() {
|
|
184
|
+
canceled = !0, enableTelemetry && await telemetry("canceled", { eventType }, { stripMetadata: !0, immediate: !0 }), process.exit(0);
|
|
185
|
+
}
|
|
186
|
+
eventType === "init" && process.on("SIGINT", cancelTelemetry), enableTelemetry && telemetry("boot", { eventType }, { stripMetadata: !0 });
|
|
187
|
+
try {
|
|
188
|
+
return await run();
|
|
189
|
+
} catch (error) {
|
|
190
|
+
if (canceled)
|
|
191
|
+
return;
|
|
192
|
+
if (!(error instanceof HandledError)) {
|
|
193
|
+
let { printError = logger2.error } = options;
|
|
194
|
+
printError(error);
|
|
195
|
+
}
|
|
196
|
+
throw enableTelemetry && await sendTelemetryError(error, eventType, options), error;
|
|
197
|
+
} finally {
|
|
198
|
+
process.off("SIGINT", cancelTelemetry);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export {
|
|
203
|
+
useStatics,
|
|
204
|
+
parseStaticDir,
|
|
205
|
+
mapStaticDir,
|
|
206
|
+
getErrorLevel,
|
|
207
|
+
sendTelemetryError,
|
|
208
|
+
withTelemetry
|
|
209
|
+
};
|