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
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_57ru1wfqqjv from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_57ru1wfqqjv from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_57ru1wfqqjv from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_57ru1wfqqjv.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_57ru1wfqqjv.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_57ru1wfqqjv.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
var __create = Object.create;
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
14
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
15
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
16
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
17
|
+
var __require = /* @__PURE__ */ ((x) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(x, {
|
|
18
|
+
get: (a, b) => (typeof require < "u" ? require : a)[b]
|
|
19
|
+
}) : x)(function(x) {
|
|
20
|
+
if (typeof require < "u") return require.apply(this, arguments);
|
|
21
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
22
|
+
});
|
|
23
|
+
var __esm = (fn, res) => function() {
|
|
24
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
25
|
+
};
|
|
26
|
+
var __commonJS = (cb, mod) => function() {
|
|
27
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
28
|
+
};
|
|
29
|
+
var __export = (target, all) => {
|
|
30
|
+
for (var name in all)
|
|
31
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
32
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
33
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
34
|
+
for (let key of __getOwnPropNames(from))
|
|
35
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
36
|
+
return to;
|
|
37
|
+
};
|
|
38
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
39
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
40
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
41
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
42
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
43
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
44
|
+
mod
|
|
45
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
__require,
|
|
49
|
+
__esm,
|
|
50
|
+
__commonJS,
|
|
51
|
+
__export,
|
|
52
|
+
__toESM,
|
|
53
|
+
__toCommonJS
|
|
54
|
+
};
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_57ru1wfqqjv from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_57ru1wfqqjv from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_57ru1wfqqjv from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_57ru1wfqqjv.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_57ru1wfqqjv.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_57ru1wfqqjv.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-CZ5GHJCC.js";
|
|
15
|
+
import {
|
|
16
|
+
resolvePackageDir
|
|
17
|
+
} from "./chunk-A4APXFQ2.js";
|
|
18
|
+
import {
|
|
19
|
+
require_prompts
|
|
20
|
+
} from "./chunk-LIH7MTP7.js";
|
|
21
|
+
import {
|
|
22
|
+
require_dist
|
|
23
|
+
} from "./chunk-DUXPWBOK.js";
|
|
24
|
+
import {
|
|
25
|
+
require_picocolors
|
|
26
|
+
} from "./chunk-NAOYEL54.js";
|
|
27
|
+
import {
|
|
28
|
+
__toESM
|
|
29
|
+
} from "./chunk-OP3INKUD.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
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_57ru1wfqqjv from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_57ru1wfqqjv from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_57ru1wfqqjv from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_57ru1wfqqjv.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_57ru1wfqqjv.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_57ru1wfqqjv.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
// ../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
|
14
|
+
var isProduction = process.env.NODE_ENV === "production", prefix = "Invariant failed";
|
|
15
|
+
function invariant(condition, message) {
|
|
16
|
+
if (!condition) {
|
|
17
|
+
if (isProduction)
|
|
18
|
+
throw new Error(prefix);
|
|
19
|
+
var provided = typeof message == "function" ? message() : message, value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
|
20
|
+
throw new Error(value);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
invariant
|
|
26
|
+
};
|