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,936 @@
|
|
|
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
|
+
version
|
|
14
|
+
} from "./chunk-IXVYNBMD.js";
|
|
15
|
+
import {
|
|
16
|
+
createFileSystemCache,
|
|
17
|
+
resolvePathInStorybookCache,
|
|
18
|
+
up
|
|
19
|
+
} from "./chunk-WFLWJO24.js";
|
|
20
|
+
import {
|
|
21
|
+
globalSettings
|
|
22
|
+
} from "./chunk-4FT2DHGE.js";
|
|
23
|
+
import {
|
|
24
|
+
execaCommand,
|
|
25
|
+
getProjectRoot
|
|
26
|
+
} from "./chunk-O5DA7YLO.js";
|
|
27
|
+
import {
|
|
28
|
+
getSessionId,
|
|
29
|
+
nanoid,
|
|
30
|
+
set
|
|
31
|
+
} from "./chunk-WUXQMQCB.js";
|
|
32
|
+
import {
|
|
33
|
+
resolvePackageDir
|
|
34
|
+
} from "./chunk-A4APXFQ2.js";
|
|
35
|
+
import {
|
|
36
|
+
slash
|
|
37
|
+
} from "./chunk-E5FJS66Z.js";
|
|
38
|
+
import {
|
|
39
|
+
require_picocolors
|
|
40
|
+
} from "./chunk-NAOYEL54.js";
|
|
41
|
+
import {
|
|
42
|
+
__commonJS,
|
|
43
|
+
__toESM
|
|
44
|
+
} from "./chunk-OP3INKUD.js";
|
|
45
|
+
|
|
46
|
+
// ../node_modules/fetch-retry/index.js
|
|
47
|
+
var require_fetch_retry = __commonJS({
|
|
48
|
+
"../node_modules/fetch-retry/index.js"(exports, module) {
|
|
49
|
+
"use strict";
|
|
50
|
+
module.exports = function(fetch2, defaults) {
|
|
51
|
+
if (defaults = defaults || {}, typeof fetch2 != "function")
|
|
52
|
+
throw new ArgumentError("fetch must be a function");
|
|
53
|
+
if (typeof defaults != "object")
|
|
54
|
+
throw new ArgumentError("defaults must be an object");
|
|
55
|
+
if (defaults.retries !== void 0 && !isPositiveInteger(defaults.retries))
|
|
56
|
+
throw new ArgumentError("retries must be a positive integer");
|
|
57
|
+
if (defaults.retryDelay !== void 0 && !isPositiveInteger(defaults.retryDelay) && typeof defaults.retryDelay != "function")
|
|
58
|
+
throw new ArgumentError("retryDelay must be a positive integer or a function returning a positive integer");
|
|
59
|
+
if (defaults.retryOn !== void 0 && !Array.isArray(defaults.retryOn) && typeof defaults.retryOn != "function")
|
|
60
|
+
throw new ArgumentError("retryOn property expects an array or function");
|
|
61
|
+
var baseDefaults = {
|
|
62
|
+
retries: 3,
|
|
63
|
+
retryDelay: 1e3,
|
|
64
|
+
retryOn: []
|
|
65
|
+
};
|
|
66
|
+
return defaults = Object.assign(baseDefaults, defaults), function(input, init) {
|
|
67
|
+
var retries = defaults.retries, retryDelay = defaults.retryDelay, retryOn = defaults.retryOn;
|
|
68
|
+
if (init && init.retries !== void 0)
|
|
69
|
+
if (isPositiveInteger(init.retries))
|
|
70
|
+
retries = init.retries;
|
|
71
|
+
else
|
|
72
|
+
throw new ArgumentError("retries must be a positive integer");
|
|
73
|
+
if (init && init.retryDelay !== void 0)
|
|
74
|
+
if (isPositiveInteger(init.retryDelay) || typeof init.retryDelay == "function")
|
|
75
|
+
retryDelay = init.retryDelay;
|
|
76
|
+
else
|
|
77
|
+
throw new ArgumentError("retryDelay must be a positive integer or a function returning a positive integer");
|
|
78
|
+
if (init && init.retryOn)
|
|
79
|
+
if (Array.isArray(init.retryOn) || typeof init.retryOn == "function")
|
|
80
|
+
retryOn = init.retryOn;
|
|
81
|
+
else
|
|
82
|
+
throw new ArgumentError("retryOn property expects an array or function");
|
|
83
|
+
return new Promise(function(resolve, reject) {
|
|
84
|
+
var wrappedFetch = function(attempt) {
|
|
85
|
+
var _input = typeof Request < "u" && input instanceof Request ? input.clone() : input;
|
|
86
|
+
fetch2(_input, init).then(function(response) {
|
|
87
|
+
if (Array.isArray(retryOn) && retryOn.indexOf(response.status) === -1)
|
|
88
|
+
resolve(response);
|
|
89
|
+
else if (typeof retryOn == "function")
|
|
90
|
+
try {
|
|
91
|
+
return Promise.resolve(retryOn(attempt, null, response)).then(function(retryOnResponse) {
|
|
92
|
+
retryOnResponse ? retry2(attempt, null, response) : resolve(response);
|
|
93
|
+
}).catch(reject);
|
|
94
|
+
} catch (error) {
|
|
95
|
+
reject(error);
|
|
96
|
+
}
|
|
97
|
+
else
|
|
98
|
+
attempt < retries ? retry2(attempt, null, response) : resolve(response);
|
|
99
|
+
}).catch(function(error) {
|
|
100
|
+
if (typeof retryOn == "function")
|
|
101
|
+
try {
|
|
102
|
+
Promise.resolve(retryOn(attempt, error, null)).then(function(retryOnResponse) {
|
|
103
|
+
retryOnResponse ? retry2(attempt, error, null) : reject(error);
|
|
104
|
+
}).catch(function(error2) {
|
|
105
|
+
reject(error2);
|
|
106
|
+
});
|
|
107
|
+
} catch (error2) {
|
|
108
|
+
reject(error2);
|
|
109
|
+
}
|
|
110
|
+
else attempt < retries ? retry2(attempt, error, null) : reject(error);
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
function retry2(attempt, error, response) {
|
|
114
|
+
var delay = typeof retryDelay == "function" ? retryDelay(attempt, error, response) : retryDelay;
|
|
115
|
+
setTimeout(function() {
|
|
116
|
+
wrappedFetch(++attempt);
|
|
117
|
+
}, delay);
|
|
118
|
+
}
|
|
119
|
+
wrappedFetch(0);
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
function isPositiveInteger(value) {
|
|
124
|
+
return Number.isInteger(value) && value >= 0;
|
|
125
|
+
}
|
|
126
|
+
function ArgumentError(message) {
|
|
127
|
+
this.name = "ArgumentError", this.message = message;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// src/telemetry/index.ts
|
|
133
|
+
import { logger as logger2 } from "storybook/internal/node-logger";
|
|
134
|
+
|
|
135
|
+
// src/telemetry/notify.ts
|
|
136
|
+
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
137
|
+
import { cache } from "storybook/internal/common";
|
|
138
|
+
import { CLI_COLORS, logger } from "storybook/internal/node-logger";
|
|
139
|
+
var TELEMETRY_KEY_NOTIFY_DATE = "telemetry-notification-date", notify = async () => {
|
|
140
|
+
await cache.get(TELEMETRY_KEY_NOTIFY_DATE, null) || (cache.set(TELEMETRY_KEY_NOTIFY_DATE, Date.now()), logger.log(
|
|
141
|
+
`${CLI_COLORS.info("Attention:")} Storybook now collects completely anonymous telemetry regarding usage. This information is used to shape Storybook's roadmap and prioritize features.`
|
|
142
|
+
), logger.log(
|
|
143
|
+
"You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:"
|
|
144
|
+
), logger.log(import_picocolors.default.cyan("https://storybook.js.org/telemetry")), logger.log(""));
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// src/telemetry/sanitize.ts
|
|
148
|
+
import path from "node:path";
|
|
149
|
+
function regexpEscape(str) {
|
|
150
|
+
return str.replace(/[-[/{}()*+?.\\^$|]/g, "\\$&");
|
|
151
|
+
}
|
|
152
|
+
function removeAnsiEscapeCodes(input = "") {
|
|
153
|
+
return input.replace(/\u001B\[[0-9;]*m/g, "");
|
|
154
|
+
}
|
|
155
|
+
function cleanPaths(str, separator = path.sep) {
|
|
156
|
+
if (!str)
|
|
157
|
+
return str;
|
|
158
|
+
let stack = process.cwd().split(separator);
|
|
159
|
+
for (; stack.length > 1; ) {
|
|
160
|
+
let currentPath = stack.join(separator), currentRegex = new RegExp(regexpEscape(currentPath), "gi");
|
|
161
|
+
str = str.replace(currentRegex, "$SNIP");
|
|
162
|
+
let currentPath2 = stack.join(separator + separator), currentRegex2 = new RegExp(regexpEscape(currentPath2), "gi");
|
|
163
|
+
str = str.replace(currentRegex2, "$SNIP"), stack.pop();
|
|
164
|
+
}
|
|
165
|
+
return str;
|
|
166
|
+
}
|
|
167
|
+
function sanitizeError(error, pathSeparator = path.sep) {
|
|
168
|
+
try {
|
|
169
|
+
error = {
|
|
170
|
+
...JSON.parse(JSON.stringify(error)),
|
|
171
|
+
message: removeAnsiEscapeCodes(error.message),
|
|
172
|
+
stack: removeAnsiEscapeCodes(error.stack),
|
|
173
|
+
cause: error.cause,
|
|
174
|
+
name: error.name
|
|
175
|
+
};
|
|
176
|
+
let errorString = cleanPaths(JSON.stringify(error), pathSeparator);
|
|
177
|
+
return JSON.parse(errorString);
|
|
178
|
+
} catch (err) {
|
|
179
|
+
return `Sanitization error: ${err?.message}`;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// src/telemetry/storybook-metadata.ts
|
|
184
|
+
import { readFile } from "node:fs/promises";
|
|
185
|
+
import { dirname } from "node:path";
|
|
186
|
+
import {
|
|
187
|
+
getStorybookConfiguration,
|
|
188
|
+
getStorybookInfo,
|
|
189
|
+
isCI,
|
|
190
|
+
loadMainConfig,
|
|
191
|
+
versions
|
|
192
|
+
} from "storybook/internal/common";
|
|
193
|
+
import { readConfig } from "storybook/internal/csf-tools";
|
|
194
|
+
|
|
195
|
+
// src/telemetry/get-application-file-count.ts
|
|
196
|
+
import { sep } from "node:path";
|
|
197
|
+
|
|
198
|
+
// src/telemetry/exec-command-count-lines.ts
|
|
199
|
+
import { createInterface } from "node:readline";
|
|
200
|
+
async function execCommandCountLines(command, options) {
|
|
201
|
+
let process3 = execaCommand(command, { shell: !0, buffer: !1, ...options });
|
|
202
|
+
if (!process3.stdout)
|
|
203
|
+
throw new Error("Unexpected missing stdout");
|
|
204
|
+
let lineCount = 0, rl = createInterface(process3.stdout);
|
|
205
|
+
return rl.on("line", () => {
|
|
206
|
+
lineCount += 1;
|
|
207
|
+
}), await process3, rl.close(), lineCount;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// src/telemetry/run-telemetry-operation.ts
|
|
211
|
+
var cache2 = createFileSystemCache({
|
|
212
|
+
basePath: resolvePathInStorybookCache("telemetry"),
|
|
213
|
+
ns: "storybook",
|
|
214
|
+
ttl: 1440 * 60 * 1e3
|
|
215
|
+
// 24h
|
|
216
|
+
}), runTelemetryOperation = async (cacheKey, operation) => {
|
|
217
|
+
let cached = await cache2.get(cacheKey);
|
|
218
|
+
return cached === void 0 && (cached = await operation(), cached !== void 0 && await cache2.set(cacheKey, cached)), cached;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
// src/telemetry/get-application-file-count.ts
|
|
222
|
+
var nameMatches = ["page", "screen"], extensions = ["js", "jsx", "ts", "tsx"], getApplicationFilesCountUncached = async (basePath) => {
|
|
223
|
+
let globs = nameMatches.flatMap((match) => [
|
|
224
|
+
match,
|
|
225
|
+
[match[0].toUpperCase(), ...match.slice(1)].join("")
|
|
226
|
+
]).flatMap(
|
|
227
|
+
(match) => extensions.map((extension) => `"${basePath}${sep}*${match}*.${extension}"`)
|
|
228
|
+
);
|
|
229
|
+
try {
|
|
230
|
+
let command = `git ls-files -- ${globs.join(" ")}`;
|
|
231
|
+
return await execCommandCountLines(command);
|
|
232
|
+
} catch {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
}, getApplicationFileCount = async (path3) => runTelemetryOperation(
|
|
236
|
+
"applicationFiles",
|
|
237
|
+
async () => getApplicationFilesCountUncached(path3)
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
// src/telemetry/get-chromatic-version.ts
|
|
241
|
+
function getChromaticVersionSpecifier(packageJson) {
|
|
242
|
+
let dependency = packageJson.dependencies?.chromatic || packageJson.devDependencies?.chromatic || packageJson.peerDependencies?.chromatic;
|
|
243
|
+
return dependency || (packageJson.scripts && Object.values(packageJson.scripts).find((s) => s?.match(/chromatic/)) ? "latest" : void 0);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// src/telemetry/get-framework-info.ts
|
|
247
|
+
import { normalize } from "node:path";
|
|
248
|
+
import { frameworkPackages } from "storybook/internal/common";
|
|
249
|
+
|
|
250
|
+
// src/telemetry/package-json.ts
|
|
251
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
252
|
+
var getActualPackageVersions = async (packages) => {
|
|
253
|
+
let packageNames = Object.keys(packages);
|
|
254
|
+
return Promise.all(packageNames.map(getActualPackageVersion));
|
|
255
|
+
}, getActualPackageVersion = async (packageName) => {
|
|
256
|
+
try {
|
|
257
|
+
let packageJson = await getActualPackageJson(packageName);
|
|
258
|
+
return {
|
|
259
|
+
name: packageJson?.name || packageName,
|
|
260
|
+
version: packageJson?.version || null
|
|
261
|
+
};
|
|
262
|
+
} catch {
|
|
263
|
+
return {
|
|
264
|
+
name: packageName,
|
|
265
|
+
version: null
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
}, getActualPackageJson = async (packageName) => {
|
|
269
|
+
try {
|
|
270
|
+
let resolvedPackageJsonPath = up({
|
|
271
|
+
cwd: fileURLToPath(import.meta.resolve(packageName, process.cwd()))
|
|
272
|
+
});
|
|
273
|
+
resolvedPackageJsonPath || (resolvedPackageJsonPath = import.meta.resolve(`${packageName}/package.json`, process.cwd()));
|
|
274
|
+
let { default: packageJson } = await import(pathToFileURL(resolvedPackageJsonPath).href, {
|
|
275
|
+
with: { type: "json" }
|
|
276
|
+
});
|
|
277
|
+
return packageJson;
|
|
278
|
+
} catch {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
// src/telemetry/get-framework-info.ts
|
|
284
|
+
var knownRenderers = [
|
|
285
|
+
"html",
|
|
286
|
+
"react",
|
|
287
|
+
"svelte",
|
|
288
|
+
"vue3",
|
|
289
|
+
"preact",
|
|
290
|
+
"server",
|
|
291
|
+
"vue",
|
|
292
|
+
"web-components",
|
|
293
|
+
"angular",
|
|
294
|
+
"ember"
|
|
295
|
+
], knownBuilders = ["builder-webpack5", "builder-vite"];
|
|
296
|
+
function findMatchingPackage(packageJson, suffixes) {
|
|
297
|
+
let { name = "", version: version2, dependencies, devDependencies, peerDependencies } = packageJson, allDependencies = {
|
|
298
|
+
// We include the framework itself because it may be a renderer too (e.g. angular)
|
|
299
|
+
[name]: version2,
|
|
300
|
+
...dependencies,
|
|
301
|
+
...devDependencies,
|
|
302
|
+
...peerDependencies
|
|
303
|
+
};
|
|
304
|
+
return suffixes.map((suffix) => `@storybook/${suffix}`).find((pkg) => allDependencies[pkg]);
|
|
305
|
+
}
|
|
306
|
+
var getFrameworkPackageName = (packageNameOrPath) => {
|
|
307
|
+
let normalizedPath = normalize(packageNameOrPath).replace(new RegExp(/\\/, "g"), "/");
|
|
308
|
+
return Object.keys(frameworkPackages).find((pkg) => normalizedPath.endsWith(pkg)) || cleanPaths(packageNameOrPath).replace(/.*node_modules[\\/]/, "");
|
|
309
|
+
};
|
|
310
|
+
async function getFrameworkInfo(mainConfig) {
|
|
311
|
+
if (!mainConfig?.framework)
|
|
312
|
+
return {};
|
|
313
|
+
let rawName = typeof mainConfig.framework == "string" ? mainConfig.framework : mainConfig.framework?.name;
|
|
314
|
+
if (!rawName)
|
|
315
|
+
return {};
|
|
316
|
+
let frameworkPackageJson = await getActualPackageJson(rawName);
|
|
317
|
+
if (!frameworkPackageJson)
|
|
318
|
+
return {};
|
|
319
|
+
let builder = findMatchingPackage(frameworkPackageJson, knownBuilders), renderer = findMatchingPackage(frameworkPackageJson, knownRenderers), sanitizedFrameworkName = getFrameworkPackageName(rawName), frameworkOptions = typeof mainConfig.framework == "object" ? mainConfig.framework.options : {};
|
|
320
|
+
return {
|
|
321
|
+
framework: {
|
|
322
|
+
name: sanitizedFrameworkName,
|
|
323
|
+
options: frameworkOptions
|
|
324
|
+
},
|
|
325
|
+
builder,
|
|
326
|
+
renderer
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// src/telemetry/get-has-router-package.ts
|
|
331
|
+
var routerPackages = /* @__PURE__ */ new Set([
|
|
332
|
+
"react-router",
|
|
333
|
+
"react-router-dom",
|
|
334
|
+
"remix",
|
|
335
|
+
"@tanstack/react-router",
|
|
336
|
+
"expo-router",
|
|
337
|
+
"@reach/router",
|
|
338
|
+
"react-easy-router",
|
|
339
|
+
"@remix-run/router",
|
|
340
|
+
"wouter",
|
|
341
|
+
"wouter-preact",
|
|
342
|
+
"preact-router",
|
|
343
|
+
"vue-router",
|
|
344
|
+
"unplugin-vue-router",
|
|
345
|
+
"@angular/router",
|
|
346
|
+
"@solidjs/router",
|
|
347
|
+
// metaframeworks that imply routing
|
|
348
|
+
"next",
|
|
349
|
+
"react-scripts",
|
|
350
|
+
"gatsby",
|
|
351
|
+
"nuxt",
|
|
352
|
+
"@sveltejs/kit"
|
|
353
|
+
]);
|
|
354
|
+
function getHasRouterPackage(packageJson) {
|
|
355
|
+
return Object.keys(packageJson?.dependencies ?? {}).some(
|
|
356
|
+
(depName) => routerPackages.has(depName)
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// src/telemetry/get-monorepo-type.ts
|
|
361
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
362
|
+
import { join } from "node:path";
|
|
363
|
+
import { getProjectRoot as getProjectRoot2 } from "storybook/internal/common";
|
|
364
|
+
var monorepoConfigs = {
|
|
365
|
+
Nx: "nx.json",
|
|
366
|
+
Turborepo: "turbo.json",
|
|
367
|
+
Lerna: "lerna.json",
|
|
368
|
+
Rush: "rush.json",
|
|
369
|
+
Lage: "lage.config.json"
|
|
370
|
+
}, getMonorepoType = () => {
|
|
371
|
+
let monorepoType = Object.keys(monorepoConfigs).find((monorepo) => {
|
|
372
|
+
let configFile = join(getProjectRoot2(), monorepoConfigs[monorepo]);
|
|
373
|
+
return existsSync(configFile);
|
|
374
|
+
});
|
|
375
|
+
if (monorepoType)
|
|
376
|
+
return monorepoType;
|
|
377
|
+
if (!existsSync(join(getProjectRoot2(), "package.json")))
|
|
378
|
+
return;
|
|
379
|
+
if (JSON.parse(
|
|
380
|
+
readFileSync(join(getProjectRoot2(), "package.json"), { encoding: "utf8" })
|
|
381
|
+
)?.workspaces)
|
|
382
|
+
return "Workspaces";
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
// ../node_modules/package-manager-detector/dist/commands.mjs
|
|
386
|
+
function dashDashArg(agent, agentCommand) {
|
|
387
|
+
return (args) => args.length > 1 ? [agent, agentCommand, args[0], "--", ...args.slice(1)] : [agent, agentCommand, args[0]];
|
|
388
|
+
}
|
|
389
|
+
function denoExecute() {
|
|
390
|
+
return (args) => ["deno", "run", `npm:${args[0]}`, ...args.slice(1)];
|
|
391
|
+
}
|
|
392
|
+
var npm = {
|
|
393
|
+
agent: ["npm", 0],
|
|
394
|
+
run: dashDashArg("npm", "run"),
|
|
395
|
+
install: ["npm", "i", 0],
|
|
396
|
+
frozen: ["npm", "ci", 0],
|
|
397
|
+
global: ["npm", "i", "-g", 0],
|
|
398
|
+
add: ["npm", "i", 0],
|
|
399
|
+
upgrade: ["npm", "update", 0],
|
|
400
|
+
"upgrade-interactive": null,
|
|
401
|
+
dedupe: ["npm", "dedupe", 0],
|
|
402
|
+
execute: ["npx", 0],
|
|
403
|
+
"execute-local": ["npx", 0],
|
|
404
|
+
uninstall: ["npm", "uninstall", 0],
|
|
405
|
+
global_uninstall: ["npm", "uninstall", "-g", 0]
|
|
406
|
+
}, yarn = {
|
|
407
|
+
agent: ["yarn", 0],
|
|
408
|
+
run: ["yarn", "run", 0],
|
|
409
|
+
install: ["yarn", "install", 0],
|
|
410
|
+
frozen: ["yarn", "install", "--frozen-lockfile", 0],
|
|
411
|
+
global: ["yarn", "global", "add", 0],
|
|
412
|
+
add: ["yarn", "add", 0],
|
|
413
|
+
upgrade: ["yarn", "upgrade", 0],
|
|
414
|
+
"upgrade-interactive": ["yarn", "upgrade-interactive", 0],
|
|
415
|
+
dedupe: null,
|
|
416
|
+
execute: ["npx", 0],
|
|
417
|
+
"execute-local": dashDashArg("yarn", "exec"),
|
|
418
|
+
uninstall: ["yarn", "remove", 0],
|
|
419
|
+
global_uninstall: ["yarn", "global", "remove", 0]
|
|
420
|
+
}, yarnBerry = {
|
|
421
|
+
...yarn,
|
|
422
|
+
frozen: ["yarn", "install", "--immutable", 0],
|
|
423
|
+
upgrade: ["yarn", "up", 0],
|
|
424
|
+
"upgrade-interactive": ["yarn", "up", "-i", 0],
|
|
425
|
+
dedupe: ["yarn", "dedupe", 0],
|
|
426
|
+
execute: ["yarn", "dlx", 0],
|
|
427
|
+
"execute-local": ["yarn", "exec", 0],
|
|
428
|
+
// Yarn 2+ removed 'global', see https://github.com/yarnpkg/berry/issues/821
|
|
429
|
+
global: ["npm", "i", "-g", 0],
|
|
430
|
+
global_uninstall: ["npm", "uninstall", "-g", 0]
|
|
431
|
+
}, pnpm = {
|
|
432
|
+
agent: ["pnpm", 0],
|
|
433
|
+
run: ["pnpm", "run", 0],
|
|
434
|
+
install: ["pnpm", "i", 0],
|
|
435
|
+
frozen: ["pnpm", "i", "--frozen-lockfile", 0],
|
|
436
|
+
global: ["pnpm", "add", "-g", 0],
|
|
437
|
+
add: ["pnpm", "add", 0],
|
|
438
|
+
upgrade: ["pnpm", "update", 0],
|
|
439
|
+
"upgrade-interactive": ["pnpm", "update", "-i", 0],
|
|
440
|
+
dedupe: ["pnpm", "dedupe", 0],
|
|
441
|
+
execute: ["pnpm", "dlx", 0],
|
|
442
|
+
"execute-local": ["pnpm", "exec", 0],
|
|
443
|
+
uninstall: ["pnpm", "remove", 0],
|
|
444
|
+
global_uninstall: ["pnpm", "remove", "--global", 0]
|
|
445
|
+
}, bun = {
|
|
446
|
+
agent: ["bun", 0],
|
|
447
|
+
run: ["bun", "run", 0],
|
|
448
|
+
install: ["bun", "install", 0],
|
|
449
|
+
frozen: ["bun", "install", "--frozen-lockfile", 0],
|
|
450
|
+
global: ["bun", "add", "-g", 0],
|
|
451
|
+
add: ["bun", "add", 0],
|
|
452
|
+
upgrade: ["bun", "update", 0],
|
|
453
|
+
"upgrade-interactive": ["bun", "update", "-i", 0],
|
|
454
|
+
dedupe: null,
|
|
455
|
+
execute: ["bun", "x", 0],
|
|
456
|
+
"execute-local": ["bun", "x", 0],
|
|
457
|
+
uninstall: ["bun", "remove", 0],
|
|
458
|
+
global_uninstall: ["bun", "remove", "-g", 0]
|
|
459
|
+
}, deno = {
|
|
460
|
+
agent: ["deno", 0],
|
|
461
|
+
run: ["deno", "task", 0],
|
|
462
|
+
install: ["deno", "install", 0],
|
|
463
|
+
frozen: ["deno", "install", "--frozen", 0],
|
|
464
|
+
global: ["deno", "install", "-g", 0],
|
|
465
|
+
add: ["deno", "add", 0],
|
|
466
|
+
upgrade: ["deno", "outdated", "--update", 0],
|
|
467
|
+
"upgrade-interactive": ["deno", "outdated", "--update", 0],
|
|
468
|
+
dedupe: null,
|
|
469
|
+
execute: denoExecute(),
|
|
470
|
+
"execute-local": ["deno", "task", "--eval", 0],
|
|
471
|
+
uninstall: ["deno", "remove", 0],
|
|
472
|
+
global_uninstall: ["deno", "uninstall", "-g", 0]
|
|
473
|
+
}, COMMANDS = {
|
|
474
|
+
npm,
|
|
475
|
+
yarn,
|
|
476
|
+
"yarn@berry": yarnBerry,
|
|
477
|
+
pnpm,
|
|
478
|
+
// pnpm v6.x or below
|
|
479
|
+
"pnpm@6": {
|
|
480
|
+
...pnpm,
|
|
481
|
+
run: dashDashArg("pnpm", "run")
|
|
482
|
+
},
|
|
483
|
+
bun,
|
|
484
|
+
deno
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
// ../node_modules/package-manager-detector/dist/constants.mjs
|
|
488
|
+
var AGENTS = [
|
|
489
|
+
"npm",
|
|
490
|
+
"yarn",
|
|
491
|
+
"yarn@berry",
|
|
492
|
+
"pnpm",
|
|
493
|
+
"pnpm@6",
|
|
494
|
+
"bun",
|
|
495
|
+
"deno"
|
|
496
|
+
], LOCKS = {
|
|
497
|
+
"bun.lock": "bun",
|
|
498
|
+
"bun.lockb": "bun",
|
|
499
|
+
"deno.lock": "deno",
|
|
500
|
+
"pnpm-lock.yaml": "pnpm",
|
|
501
|
+
"pnpm-workspace.yaml": "pnpm",
|
|
502
|
+
"yarn.lock": "yarn",
|
|
503
|
+
"package-lock.json": "npm",
|
|
504
|
+
"npm-shrinkwrap.json": "npm"
|
|
505
|
+
}, INSTALL_METADATA = {
|
|
506
|
+
"node_modules/.deno/": "deno",
|
|
507
|
+
"node_modules/.pnpm/": "pnpm",
|
|
508
|
+
"node_modules/.yarn-state.yml": "yarn",
|
|
509
|
+
// yarn v2+ (node-modules)
|
|
510
|
+
"node_modules/.yarn_integrity": "yarn",
|
|
511
|
+
// yarn v1
|
|
512
|
+
"node_modules/.package-lock.json": "npm",
|
|
513
|
+
".pnp.cjs": "yarn",
|
|
514
|
+
// yarn v3+ (pnp)
|
|
515
|
+
".pnp.js": "yarn",
|
|
516
|
+
// yarn v2 (pnp)
|
|
517
|
+
"bun.lock": "bun",
|
|
518
|
+
"bun.lockb": "bun"
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
// ../node_modules/package-manager-detector/dist/detect.mjs
|
|
522
|
+
import fs from "node:fs/promises";
|
|
523
|
+
import path2 from "node:path";
|
|
524
|
+
import process2 from "node:process";
|
|
525
|
+
async function pathExists(path22, type) {
|
|
526
|
+
try {
|
|
527
|
+
let stat = await fs.stat(path22);
|
|
528
|
+
return type === "file" ? stat.isFile() : stat.isDirectory();
|
|
529
|
+
} catch {
|
|
530
|
+
return !1;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
function* lookup(cwd = process2.cwd()) {
|
|
534
|
+
let directory = path2.resolve(cwd), { root } = path2.parse(directory);
|
|
535
|
+
for (; directory && directory !== root; )
|
|
536
|
+
yield directory, directory = path2.dirname(directory);
|
|
537
|
+
}
|
|
538
|
+
async function parsePackageJson(filepath, onUnknown) {
|
|
539
|
+
return !filepath || !pathExists(filepath, "file") ? null : await handlePackageManager(filepath, onUnknown);
|
|
540
|
+
}
|
|
541
|
+
async function detect(options = {}) {
|
|
542
|
+
let {
|
|
543
|
+
cwd,
|
|
544
|
+
strategies = ["lockfile", "packageManager-field", "devEngines-field"],
|
|
545
|
+
onUnknown
|
|
546
|
+
} = options, stopDir;
|
|
547
|
+
if (typeof options.stopDir == "string") {
|
|
548
|
+
let resolved = path2.resolve(options.stopDir);
|
|
549
|
+
stopDir = (dir) => dir === resolved;
|
|
550
|
+
} else
|
|
551
|
+
stopDir = options.stopDir;
|
|
552
|
+
for (let directory of lookup(cwd)) {
|
|
553
|
+
for (let strategy of strategies)
|
|
554
|
+
switch (strategy) {
|
|
555
|
+
case "lockfile": {
|
|
556
|
+
for (let lock of Object.keys(LOCKS))
|
|
557
|
+
if (await pathExists(path2.join(directory, lock), "file")) {
|
|
558
|
+
let name = LOCKS[lock], result = await parsePackageJson(path2.join(directory, "package.json"), onUnknown);
|
|
559
|
+
return result || { name, agent: name };
|
|
560
|
+
}
|
|
561
|
+
break;
|
|
562
|
+
}
|
|
563
|
+
case "packageManager-field":
|
|
564
|
+
case "devEngines-field": {
|
|
565
|
+
let result = await parsePackageJson(path2.join(directory, "package.json"), onUnknown);
|
|
566
|
+
if (result)
|
|
567
|
+
return result;
|
|
568
|
+
break;
|
|
569
|
+
}
|
|
570
|
+
case "install-metadata": {
|
|
571
|
+
for (let metadata of Object.keys(INSTALL_METADATA)) {
|
|
572
|
+
let fileOrDir = metadata.endsWith("/") ? "dir" : "file";
|
|
573
|
+
if (await pathExists(path2.join(directory, metadata), fileOrDir)) {
|
|
574
|
+
let name = INSTALL_METADATA[metadata], agent = name === "yarn" ? isMetadataYarnClassic(metadata) ? "yarn" : "yarn@berry" : name;
|
|
575
|
+
return { name, agent };
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
break;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
if (stopDir?.(directory))
|
|
582
|
+
break;
|
|
583
|
+
}
|
|
584
|
+
return null;
|
|
585
|
+
}
|
|
586
|
+
function getNameAndVer(pkg) {
|
|
587
|
+
let handelVer = (version2) => version2?.match(/\d+(\.\d+){0,2}/)?.[0] ?? version2;
|
|
588
|
+
if (typeof pkg.packageManager == "string") {
|
|
589
|
+
let [name, ver] = pkg.packageManager.replace(/^\^/, "").split("@");
|
|
590
|
+
return { name, ver: handelVer(ver) };
|
|
591
|
+
}
|
|
592
|
+
if (typeof pkg.devEngines?.packageManager?.name == "string")
|
|
593
|
+
return {
|
|
594
|
+
name: pkg.devEngines.packageManager.name,
|
|
595
|
+
ver: handelVer(pkg.devEngines.packageManager.version)
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
async function handlePackageManager(filepath, onUnknown) {
|
|
599
|
+
try {
|
|
600
|
+
let pkg = JSON.parse(await fs.readFile(filepath, "utf8")), agent, nameAndVer = getNameAndVer(pkg);
|
|
601
|
+
if (nameAndVer) {
|
|
602
|
+
let name = nameAndVer.name, ver = nameAndVer.ver, version2 = ver;
|
|
603
|
+
return name === "yarn" && ver && Number.parseInt(ver) > 1 ? (agent = "yarn@berry", version2 = "berry", { name, agent, version: version2 }) : name === "pnpm" && ver && Number.parseInt(ver) < 7 ? (agent = "pnpm@6", { name, agent, version: version2 }) : AGENTS.includes(name) ? (agent = name, { name, agent, version: version2 }) : onUnknown?.(pkg.packageManager) ?? null;
|
|
604
|
+
}
|
|
605
|
+
} catch {
|
|
606
|
+
}
|
|
607
|
+
return null;
|
|
608
|
+
}
|
|
609
|
+
function isMetadataYarnClassic(metadataPath) {
|
|
610
|
+
return metadataPath.endsWith(".yarn_integrity");
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
// src/telemetry/get-package-manager-info.ts
|
|
614
|
+
var getPackageManagerInfo = async () => {
|
|
615
|
+
let packageManagerType = await detect({ cwd: getProjectRoot() });
|
|
616
|
+
if (!packageManagerType)
|
|
617
|
+
return;
|
|
618
|
+
let nodeLinker = "node_modules";
|
|
619
|
+
if (packageManagerType.name === "yarn")
|
|
620
|
+
try {
|
|
621
|
+
let { stdout } = await execaCommand("yarn config get nodeLinker", {
|
|
622
|
+
cwd: getProjectRoot()
|
|
623
|
+
});
|
|
624
|
+
nodeLinker = stdout.trim();
|
|
625
|
+
} catch {
|
|
626
|
+
}
|
|
627
|
+
if (packageManagerType.name === "pnpm")
|
|
628
|
+
try {
|
|
629
|
+
let { stdout } = await execaCommand("pnpm config get nodeLinker", {
|
|
630
|
+
cwd: getProjectRoot()
|
|
631
|
+
});
|
|
632
|
+
nodeLinker = stdout.trim() ?? "isolated";
|
|
633
|
+
} catch {
|
|
634
|
+
}
|
|
635
|
+
return {
|
|
636
|
+
type: packageManagerType.name,
|
|
637
|
+
version: packageManagerType.version,
|
|
638
|
+
agent: packageManagerType.agent,
|
|
639
|
+
nodeLinker
|
|
640
|
+
};
|
|
641
|
+
};
|
|
642
|
+
|
|
643
|
+
// src/telemetry/get-portable-stories-usage.ts
|
|
644
|
+
var getPortableStoriesFileCountUncached = async (path3) => {
|
|
645
|
+
try {
|
|
646
|
+
let command = "git grep -l composeStor" + (path3 ? ` -- ${path3}` : "");
|
|
647
|
+
return await execCommandCountLines(command);
|
|
648
|
+
} catch (err) {
|
|
649
|
+
return err.exitCode === 1 ? 0 : void 0;
|
|
650
|
+
}
|
|
651
|
+
}, getPortableStoriesFileCount = async (path3) => runTelemetryOperation(
|
|
652
|
+
"portableStories",
|
|
653
|
+
async () => getPortableStoriesFileCountUncached(path3)
|
|
654
|
+
);
|
|
655
|
+
|
|
656
|
+
// src/telemetry/storybook-metadata.ts
|
|
657
|
+
var metaFrameworks = {
|
|
658
|
+
next: "Next",
|
|
659
|
+
"react-scripts": "CRA",
|
|
660
|
+
gatsby: "Gatsby",
|
|
661
|
+
"@nuxtjs/storybook": "nuxt",
|
|
662
|
+
"@nrwl/storybook": "nx",
|
|
663
|
+
"@vue/cli-service": "vue-cli",
|
|
664
|
+
"@sveltejs/kit": "sveltekit",
|
|
665
|
+
"@tanstack/react-router": "tanstack-react",
|
|
666
|
+
"@react-router/dev": "react-router",
|
|
667
|
+
"@remix-run/dev": "remix"
|
|
668
|
+
}, sanitizeAddonName = (name) => cleanPaths(name).replace(/\/dist\/.*/, "").replace(/\.[mc]?[tj]?s[x]?$/, "").replace(/\/register$/, "").replace(/\/manager$/, "").replace(/\/preset$/, ""), computeStorybookMetadata = async ({
|
|
669
|
+
packageJsonPath,
|
|
670
|
+
packageJson,
|
|
671
|
+
mainConfig,
|
|
672
|
+
configDir
|
|
673
|
+
}) => {
|
|
674
|
+
let settings = isCI() ? void 0 : await globalSettings(), metadata = {
|
|
675
|
+
generatedAt: (/* @__PURE__ */ new Date()).getTime(),
|
|
676
|
+
userSince: settings?.value.userSince,
|
|
677
|
+
hasCustomBabel: !1,
|
|
678
|
+
hasCustomWebpack: !1,
|
|
679
|
+
hasStaticDirs: !1,
|
|
680
|
+
hasStorybookEslint: !1,
|
|
681
|
+
refCount: 0
|
|
682
|
+
}, allDependencies = {
|
|
683
|
+
...packageJson?.dependencies,
|
|
684
|
+
...packageJson?.devDependencies,
|
|
685
|
+
...packageJson?.peerDependencies
|
|
686
|
+
}, metaFramework = Object.keys(allDependencies).find((dep) => !!metaFrameworks[dep]);
|
|
687
|
+
if (metaFramework) {
|
|
688
|
+
let { version: version2 } = await getActualPackageVersion(metaFramework);
|
|
689
|
+
metadata.metaFramework = {
|
|
690
|
+
name: metaFrameworks[metaFramework],
|
|
691
|
+
packageName: metaFramework,
|
|
692
|
+
version: version2 || "unknown"
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
let testPackages = [
|
|
696
|
+
"playwright",
|
|
697
|
+
"vitest",
|
|
698
|
+
"jest",
|
|
699
|
+
"cypress",
|
|
700
|
+
"nightwatch",
|
|
701
|
+
"webdriver",
|
|
702
|
+
"@web/test-runner",
|
|
703
|
+
"puppeteer",
|
|
704
|
+
"karma",
|
|
705
|
+
"jasmine",
|
|
706
|
+
"chai",
|
|
707
|
+
"testing-library",
|
|
708
|
+
"@ngneat/spectator",
|
|
709
|
+
"wdio",
|
|
710
|
+
"msw",
|
|
711
|
+
"miragejs",
|
|
712
|
+
"sinon",
|
|
713
|
+
"chromatic"
|
|
714
|
+
], testPackageDeps = Object.keys(allDependencies).filter(
|
|
715
|
+
(dep) => testPackages.find((pkg) => dep.includes(pkg))
|
|
716
|
+
);
|
|
717
|
+
metadata.testPackages = Object.fromEntries(
|
|
718
|
+
await Promise.all(
|
|
719
|
+
testPackageDeps.map(async (dep) => [dep, (await getActualPackageVersion(dep))?.version])
|
|
720
|
+
)
|
|
721
|
+
), metadata.hasRouterPackage = getHasRouterPackage(packageJson);
|
|
722
|
+
let monorepoType = getMonorepoType();
|
|
723
|
+
monorepoType && (metadata.monorepo = monorepoType), metadata.packageManager = await getPackageManagerInfo();
|
|
724
|
+
let language = allDependencies.typescript ? "typescript" : "javascript";
|
|
725
|
+
if (!mainConfig)
|
|
726
|
+
return {
|
|
727
|
+
...metadata,
|
|
728
|
+
storybookVersionSpecifier: versions.storybook,
|
|
729
|
+
language
|
|
730
|
+
};
|
|
731
|
+
metadata.hasCustomBabel = !!mainConfig.babel, metadata.hasCustomWebpack = !!mainConfig.webpackFinal, metadata.hasStaticDirs = !!mainConfig.staticDirs, typeof mainConfig.typescript == "object" && (metadata.typescriptOptions = mainConfig.typescript);
|
|
732
|
+
let frameworkInfo = await getFrameworkInfo(mainConfig);
|
|
733
|
+
typeof mainConfig.refs == "object" && (metadata.refCount = Object.keys(mainConfig.refs).length), typeof mainConfig.features == "object" && (metadata.features = mainConfig.features);
|
|
734
|
+
let addons = {};
|
|
735
|
+
mainConfig.addons && mainConfig.addons.forEach((addon) => {
|
|
736
|
+
let addonName, options;
|
|
737
|
+
typeof addon == "string" ? addonName = sanitizeAddonName(addon) : (addon.name.includes("addon-essentials") && (options = addon.options), addonName = sanitizeAddonName(addon.name)), addons[addonName] = {
|
|
738
|
+
options,
|
|
739
|
+
version: void 0
|
|
740
|
+
};
|
|
741
|
+
});
|
|
742
|
+
let chromaticVersionSpecifier = getChromaticVersionSpecifier(packageJson);
|
|
743
|
+
chromaticVersionSpecifier && (addons.chromatic = {
|
|
744
|
+
version: void 0,
|
|
745
|
+
versionSpecifier: chromaticVersionSpecifier,
|
|
746
|
+
options: void 0
|
|
747
|
+
}), (await getActualPackageVersions(addons)).forEach(({ name, version: version2 }) => {
|
|
748
|
+
addons[name] = addons[name] || {
|
|
749
|
+
name,
|
|
750
|
+
version: version2
|
|
751
|
+
}, addons[name].version = version2 || void 0;
|
|
752
|
+
});
|
|
753
|
+
let addonNames = Object.keys(addons), storybookPackages = Object.keys(allDependencies).filter((dep) => dep.includes("storybook") && !addonNames.includes(dep)).reduce((acc, dep) => ({
|
|
754
|
+
...acc,
|
|
755
|
+
[dep]: { version: void 0 }
|
|
756
|
+
}), {});
|
|
757
|
+
(await getActualPackageVersions(storybookPackages)).forEach(({ name, version: version2 }) => {
|
|
758
|
+
storybookPackages[name] = storybookPackages[name] || {
|
|
759
|
+
name,
|
|
760
|
+
version: version2
|
|
761
|
+
}, storybookPackages[name].version = version2 || void 0;
|
|
762
|
+
});
|
|
763
|
+
let hasStorybookEslint = !!allDependencies["eslint-plugin-storybook"], storybookInfo = await getStorybookInfo(configDir);
|
|
764
|
+
try {
|
|
765
|
+
let { previewConfigPath: previewConfig } = storybookInfo;
|
|
766
|
+
if (previewConfig) {
|
|
767
|
+
let config = await readConfig(previewConfig), usesGlobals = !!(config.getFieldNode(["globals"]) || config.getFieldNode(["globalTypes"]));
|
|
768
|
+
metadata.preview = { ...metadata.preview, usesGlobals };
|
|
769
|
+
}
|
|
770
|
+
} catch {
|
|
771
|
+
}
|
|
772
|
+
let portableStoriesFileCount = await getPortableStoriesFileCount(), applicationFileCount = await getApplicationFileCount(dirname(packageJsonPath));
|
|
773
|
+
return {
|
|
774
|
+
...metadata,
|
|
775
|
+
...frameworkInfo,
|
|
776
|
+
portableStoriesFileCount,
|
|
777
|
+
applicationFileCount,
|
|
778
|
+
storybookVersion: version,
|
|
779
|
+
storybookVersionSpecifier: storybookInfo.version,
|
|
780
|
+
language,
|
|
781
|
+
storybookPackages,
|
|
782
|
+
addons,
|
|
783
|
+
hasStorybookEslint
|
|
784
|
+
};
|
|
785
|
+
};
|
|
786
|
+
async function getPackageJsonDetails() {
|
|
787
|
+
let packageJsonPath = up();
|
|
788
|
+
return packageJsonPath ? {
|
|
789
|
+
packageJsonPath,
|
|
790
|
+
packageJson: JSON.parse(await readFile(packageJsonPath, "utf8"))
|
|
791
|
+
} : {
|
|
792
|
+
packageJsonPath: process.cwd(),
|
|
793
|
+
packageJson: {}
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
var cachedMetadata, getStorybookMetadata = async (_configDir) => {
|
|
797
|
+
if (cachedMetadata)
|
|
798
|
+
return cachedMetadata;
|
|
799
|
+
let { packageJson, packageJsonPath } = await getPackageJsonDetails(), configDir = (_configDir || getStorybookConfiguration(
|
|
800
|
+
String(packageJson?.scripts?.storybook || ""),
|
|
801
|
+
"-c",
|
|
802
|
+
"--config-dir"
|
|
803
|
+
)) ?? ".storybook", mainConfig = await loadMainConfig({ configDir }).catch(() => {
|
|
804
|
+
});
|
|
805
|
+
return cachedMetadata = await computeStorybookMetadata({
|
|
806
|
+
mainConfig,
|
|
807
|
+
packageJson,
|
|
808
|
+
packageJsonPath,
|
|
809
|
+
configDir
|
|
810
|
+
}), cachedMetadata;
|
|
811
|
+
};
|
|
812
|
+
|
|
813
|
+
// src/telemetry/telemetry.ts
|
|
814
|
+
var import_fetch_retry = __toESM(require_fetch_retry(), 1);
|
|
815
|
+
import { readFileSync as readFileSync2 } from "node:fs";
|
|
816
|
+
import * as os from "node:os";
|
|
817
|
+
import { join as join2 } from "node:path";
|
|
818
|
+
import { isCI as isCI2 } from "storybook/internal/common";
|
|
819
|
+
|
|
820
|
+
// src/telemetry/anonymous-id.ts
|
|
821
|
+
import { relative } from "node:path";
|
|
822
|
+
import { getProjectRoot as getProjectRoot3 } from "storybook/internal/common";
|
|
823
|
+
import { execSync } from "child_process";
|
|
824
|
+
|
|
825
|
+
// src/telemetry/one-way-hash.ts
|
|
826
|
+
import { createHash } from "crypto";
|
|
827
|
+
var oneWayHash = (payload) => {
|
|
828
|
+
let hash = createHash("sha256");
|
|
829
|
+
return hash.update("storybook-telemetry-salt"), hash.update(payload), hash.digest("hex");
|
|
830
|
+
};
|
|
831
|
+
|
|
832
|
+
// src/telemetry/anonymous-id.ts
|
|
833
|
+
function normalizeGitUrl(rawUrl) {
|
|
834
|
+
let urlWithoutScheme = rawUrl.trim().replace(/#.*$/, "").replace(/^.*@/, "").replace(/^.*\/\//, "");
|
|
835
|
+
return (urlWithoutScheme.endsWith(".git") ? urlWithoutScheme : `${urlWithoutScheme}.git`).replace(":", "/");
|
|
836
|
+
}
|
|
837
|
+
function unhashedProjectId(remoteUrl, projectRootPath) {
|
|
838
|
+
return `${normalizeGitUrl(remoteUrl)}${slash(projectRootPath)}`;
|
|
839
|
+
}
|
|
840
|
+
var anonymousProjectId, getAnonymousProjectId = () => {
|
|
841
|
+
if (anonymousProjectId)
|
|
842
|
+
return anonymousProjectId;
|
|
843
|
+
try {
|
|
844
|
+
let projectRootPath = relative(getProjectRoot3(), process.cwd()), originBuffer = execSync("git config --local --get remote.origin.url", {
|
|
845
|
+
timeout: 1e3,
|
|
846
|
+
stdio: "pipe"
|
|
847
|
+
});
|
|
848
|
+
anonymousProjectId = oneWayHash(unhashedProjectId(String(originBuffer), projectRootPath));
|
|
849
|
+
} catch {
|
|
850
|
+
}
|
|
851
|
+
return anonymousProjectId;
|
|
852
|
+
};
|
|
853
|
+
|
|
854
|
+
// src/telemetry/fetch.ts
|
|
855
|
+
var fetch = global.fetch;
|
|
856
|
+
|
|
857
|
+
// src/telemetry/telemetry.ts
|
|
858
|
+
var retryingFetch = (0, import_fetch_retry.default)(fetch), URL = process.env.STORYBOOK_TELEMETRY_URL || "https://storybook.js.org/event-log", tasks = [], addToGlobalContext = (key, value) => {
|
|
859
|
+
globalContext[key] = value;
|
|
860
|
+
}, getOperatingSystem = () => {
|
|
861
|
+
try {
|
|
862
|
+
let platform2 = os.platform();
|
|
863
|
+
return platform2 === "win32" ? "Windows" : platform2 === "darwin" ? "macOS" : platform2 === "linux" ? "Linux" : `Other: ${platform2}`;
|
|
864
|
+
} catch {
|
|
865
|
+
return "Unknown";
|
|
866
|
+
}
|
|
867
|
+
}, globalContext = {
|
|
868
|
+
inCI: isCI2(),
|
|
869
|
+
isTTY: process.stdout.isTTY,
|
|
870
|
+
platform: getOperatingSystem(),
|
|
871
|
+
nodeVersion: process.versions.node,
|
|
872
|
+
storybookVersion: getVersionNumber()
|
|
873
|
+
}, prepareRequest = async (data, context, options) => {
|
|
874
|
+
let { eventType, payload, metadata, ...rest } = data, sessionId = await getSessionId(), eventId = nanoid(), body = { ...rest, eventType, eventId, sessionId, metadata, payload, context };
|
|
875
|
+
return retryingFetch(URL, {
|
|
876
|
+
method: "post",
|
|
877
|
+
body: JSON.stringify(body),
|
|
878
|
+
headers: { "Content-Type": "application/json" },
|
|
879
|
+
retries: 3,
|
|
880
|
+
retryOn: [503, 504],
|
|
881
|
+
retryDelay: (attempt) => 2 ** attempt * (typeof options?.retryDelay == "number" && !Number.isNaN(options?.retryDelay) ? options.retryDelay : 1e3)
|
|
882
|
+
});
|
|
883
|
+
};
|
|
884
|
+
function getVersionNumber() {
|
|
885
|
+
try {
|
|
886
|
+
return JSON.parse(readFileSync2(join2(resolvePackageDir("storybook"), "package.json"), "utf8")).version;
|
|
887
|
+
} catch {
|
|
888
|
+
return version;
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
async function sendTelemetry(data, options = { retryDelay: 1e3, immediate: !1 }) {
|
|
892
|
+
let { eventType, payload, metadata, ...rest } = data, context = options.stripMetadata ? globalContext : {
|
|
893
|
+
...globalContext,
|
|
894
|
+
anonymousId: getAnonymousProjectId()
|
|
895
|
+
}, request;
|
|
896
|
+
try {
|
|
897
|
+
request = prepareRequest(data, context, options), tasks.push(request);
|
|
898
|
+
let sessionId = await getSessionId(), eventId = nanoid(), body = { ...rest, eventType, eventId, sessionId, metadata, payload, context }, waitFor = options.immediate ? tasks : [request];
|
|
899
|
+
await Promise.all([...waitFor, set(eventType, body)]);
|
|
900
|
+
} catch {
|
|
901
|
+
} finally {
|
|
902
|
+
tasks = tasks.filter((task) => task !== request);
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
// src/telemetry/index.ts
|
|
907
|
+
var isExampleStoryId = (storyId) => storyId.startsWith("example-button--") || storyId.startsWith("example-header--") || storyId.startsWith("example-page--"), telemetry = async (eventType, payload = {}, options = {}) => {
|
|
908
|
+
eventType !== "boot" && options.notify !== !1 && await notify();
|
|
909
|
+
let telemetryData = {
|
|
910
|
+
eventType,
|
|
911
|
+
payload
|
|
912
|
+
};
|
|
913
|
+
try {
|
|
914
|
+
options?.stripMetadata || (telemetryData.metadata = await getStorybookMetadata(options?.configDir));
|
|
915
|
+
} catch (error) {
|
|
916
|
+
payload.metadataErrorMessage = sanitizeError(error).message, options?.enableCrashReports && (payload.metadataError = sanitizeError(error));
|
|
917
|
+
} finally {
|
|
918
|
+
let { error } = payload;
|
|
919
|
+
error && (payload.error = sanitizeError(error)), (!payload.error || options?.enableCrashReports) && (process.env?.STORYBOOK_TELEMETRY_DEBUG && (logger2.info(`
|
|
920
|
+
[telemetry]`), logger2.info(JSON.stringify(telemetryData, null, 2))), await sendTelemetry(telemetryData, options));
|
|
921
|
+
}
|
|
922
|
+
};
|
|
923
|
+
|
|
924
|
+
export {
|
|
925
|
+
removeAnsiEscapeCodes,
|
|
926
|
+
cleanPaths,
|
|
927
|
+
sanitizeError,
|
|
928
|
+
metaFrameworks,
|
|
929
|
+
sanitizeAddonName,
|
|
930
|
+
computeStorybookMetadata,
|
|
931
|
+
getStorybookMetadata,
|
|
932
|
+
oneWayHash,
|
|
933
|
+
addToGlobalContext,
|
|
934
|
+
isExampleStoryId,
|
|
935
|
+
telemetry
|
|
936
|
+
};
|