storybook 10.1.0-alpha.9 → 10.1.0-beta.1
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-FDWKXLBI.js → chunk-2XZMBGTA.js} +44 -109
- 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-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-MH6AXFXB.js → chunk-CHUV5WSW.js} +0 -5
- 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-FQ7SLVLR.js +66 -0
- package/dist/_browser-chunks/chunk-GFLS4VP3.js +64 -0
- package/dist/_browser-chunks/chunk-GFY5R5EY.js +47 -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-OWPZQM2D.js → chunk-L4RMQ7D7.js} +60 -110
- package/dist/_browser-chunks/chunk-P4F4UVXX.js +951 -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-SS2NHR7W.js +2969 -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-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-CAVLW7PM.js → syntaxhighlighter-IQDEPFLK.js} +704 -1848
- package/dist/_node-chunks/{builder-manager-SM3UWERX.js → builder-manager-FTVC2JL7.js} +510 -1019
- package/dist/_node-chunks/camelcase-3SMT5WKC.js +37 -0
- package/dist/_node-chunks/chunk-2OVULPK3.js +54 -0
- package/dist/_node-chunks/chunk-3JJPSDXI.js +3043 -0
- package/dist/_node-chunks/chunk-54NMJ4II.js +1564 -0
- package/dist/_node-chunks/chunk-5V4A6MSI.js +943 -0
- package/dist/_node-chunks/chunk-6DEMT5VX.js +299 -0
- package/dist/_node-chunks/{chunk-HHSTA6QS.js → chunk-6L7FFBOW.js} +8 -10
- package/dist/_node-chunks/chunk-6ULDIDXV.js +46662 -0
- package/dist/_node-chunks/chunk-AREL5IXS.js +603 -0
- package/dist/_node-chunks/chunk-DWA53E73.js +23 -0
- package/dist/_node-chunks/chunk-FNYKBULZ.js +765 -0
- package/dist/_node-chunks/chunk-IUYZQKSX.js +70 -0
- package/dist/_node-chunks/{chunk-F6EFOEC7.js → chunk-K673CX4Q.js} +469 -983
- package/dist/_node-chunks/chunk-KJAFCNZ3.js +61 -0
- package/dist/_node-chunks/chunk-N3BJOOY5.js +78 -0
- package/dist/_node-chunks/{chunk-EBUEXRH5.js → chunk-O5FMCQHP.js} +116 -276
- package/dist/_node-chunks/chunk-RIKQZHV3.js +29 -0
- package/dist/_node-chunks/chunk-RURZIE3W.js +3780 -0
- package/dist/_node-chunks/chunk-RVII4SK6.js +919 -0
- package/dist/_node-chunks/chunk-S3PBHOVC.js +6024 -0
- package/dist/_node-chunks/chunk-SQSFX47N.js +61 -0
- package/dist/_node-chunks/{chunk-SGM3ZCCT.js → chunk-TURUTKVH.js} +292 -688
- package/dist/_node-chunks/chunk-VRICJPXY.js +72 -0
- package/dist/_node-chunks/chunk-WIWWMCEU.js +119 -0
- package/dist/_node-chunks/{chunk-ATDHMMIZ.js → chunk-XGNRK7QB.js} +15 -24
- package/dist/_node-chunks/chunk-Y2FOTPAE.js +4523 -0
- package/dist/_node-chunks/{chunk-GHIBZRKD.js → chunk-Y4UYN72K.js} +8133 -8887
- package/dist/_node-chunks/chunk-Z4BMBA5L.js +18 -0
- package/dist/_node-chunks/chunk-ZMCJS2GU.js +20 -0
- package/dist/_node-chunks/dist-TZLZ3T6L.js +121 -0
- package/dist/_node-chunks/globby-22GFCZQD.js +3452 -0
- package/dist/_node-chunks/lib-37NQ4ZIJ.js +366 -0
- package/dist/_node-chunks/mdx-N42X6CFJ-2TRB7OEH.js +14329 -0
- package/dist/_node-chunks/p-limit-UD7TYFDW.js +116 -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 +10 -11
- package/dist/bin/core.js +602 -1549
- package/dist/bin/dispatcher.js +36 -36
- package/dist/bin/loader.js +24 -38
- package/dist/channels/index.js +98 -234
- package/dist/cli/index.d.ts +1479 -133
- package/dist/cli/index.js +30 -8540
- package/dist/client-logger/index.js +31 -61
- package/dist/common/index.d.ts +139 -62
- package/dist/common/index.js +66 -51
- package/dist/components/index.d.ts +575 -273
- package/dist/components/index.js +14863 -4313
- package/dist/core-events/index.js +2 -66
- package/dist/core-server/index.d.ts +3 -2
- package/dist/core-server/index.js +2911 -8519
- package/dist/core-server/presets/common-manager.css +2 -2
- package/dist/core-server/presets/common-manager.js +2521 -5233
- package/dist/core-server/presets/common-override-preset.js +31 -60
- package/dist/core-server/presets/common-preset.js +663 -962
- 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 +59044 -67141
- package/dist/manager/globals.js +2 -3
- package/dist/manager/manager-stores.d.ts +1 -0
- package/dist/manager/manager-stores.js +23 -0
- package/dist/manager/runtime.js +11569 -10953
- package/dist/manager-api/index.d.ts +1813 -2
- package/dist/manager-api/index.js +1348 -2401
- package/dist/manager-errors.d.ts +9 -0
- package/dist/manager-errors.js +3 -3
- package/dist/mocking-utils/index.d.ts +1126 -0
- package/dist/mocking-utils/index.js +1181 -0
- package/dist/node-logger/index.d.ts +192 -24
- package/dist/node-logger/index.js +23 -4471
- package/dist/preview/globals.js +2 -3
- package/dist/preview/runtime.js +10799 -22393
- package/dist/preview-api/index.d.ts +1 -1
- package/dist/preview-api/index.js +13 -13
- package/dist/preview-errors.d.ts +9 -0
- package/dist/preview-errors.js +4 -4
- package/dist/router/index.js +347 -899
- package/dist/server-errors.d.ts +34 -1
- package/dist/server-errors.js +17 -10
- package/dist/telemetry/index.d.ts +24 -3
- package/dist/telemetry/index.js +25 -24
- package/dist/test/index.js +6131 -11916
- package/dist/theming/create.d.ts +1 -0
- package/dist/theming/create.js +4 -4
- package/dist/theming/index.d.ts +3366 -2599
- package/dist/theming/index.js +501 -1091
- package/dist/types/index.d.ts +72 -8
- package/dist/types/index.js +27 -12
- package/dist/viewport/index.js +3 -3
- package/package.json +26 -17
- 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-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-RNE2IUTB.js +0 -1300
- 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-H5QSGQLK.js +0 -18
- package/dist/_node-chunks/chunk-3THWHQOC.js +0 -61
- package/dist/_node-chunks/chunk-45YUOLTU.js +0 -69
- package/dist/_node-chunks/chunk-4QSNCPAU.js +0 -64656
- package/dist/_node-chunks/chunk-744PQSOU.js +0 -79
- package/dist/_node-chunks/chunk-74Z2U7QG.js +0 -1544
- package/dist/_node-chunks/chunk-7MB7TFPO.js +0 -1198
- package/dist/_node-chunks/chunk-A7GS4RFT.js +0 -697
- package/dist/_node-chunks/chunk-BIA3A5UM.js +0 -61
- package/dist/_node-chunks/chunk-C5G7CLWX.js +0 -1657
- package/dist/_node-chunks/chunk-DLFUKMYJ.js +0 -1531
- package/dist/_node-chunks/chunk-EMRGRXKT.js +0 -111
- package/dist/_node-chunks/chunk-EX46EHHY.js +0 -420
- package/dist/_node-chunks/chunk-F76QKNOJ.js +0 -304
- package/dist/_node-chunks/chunk-HDCRUTEF.js +0 -220
- package/dist/_node-chunks/chunk-HUYAOIPH.js +0 -90
- package/dist/_node-chunks/chunk-IBJZQZJC.js +0 -101
- package/dist/_node-chunks/chunk-KZN2RDDT.js +0 -6712
- package/dist/_node-chunks/chunk-LYUNFU3F.js +0 -4741
- package/dist/_node-chunks/chunk-N44SIS6K.js +0 -28
- package/dist/_node-chunks/chunk-NILZM6KR.js +0 -18
- package/dist/_node-chunks/chunk-PC4ZRP6W.js +0 -34
- package/dist/_node-chunks/chunk-TJNGOQUH.js +0 -4272
- package/dist/_node-chunks/chunk-UBSYLHIL.js +0 -1250
- package/dist/_node-chunks/chunk-UTCLXPOC.js +0 -1518
- package/dist/_node-chunks/chunk-WOXXODXP.js +0 -5029
- package/dist/_node-chunks/chunk-XC4MEUA6.js +0 -1586
- package/dist/_node-chunks/chunk-YRXXMKRR.js +0 -2256
- package/dist/_node-chunks/dist-SL73W244.js +0 -175
- package/dist/_node-chunks/globby-ZSHAUQZ5.js +0 -5222
- package/dist/_node-chunks/lib-U2VIPUTI.js +0 -518
- package/dist/_node-chunks/mdx-N42X6CFJ-ZLHD33JK.js +0 -22017
- package/dist/_node-chunks/p-limit-K5BS5MSV.js +0 -168
- package/dist/_node-chunks/plugin-5PD4YIUH.js +0 -129
- package/dist/_node-chunks/plugin-MONDT2WL.js +0 -159
- package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-EUZJRG3W.js +0 -69102
- package/dist/_node-chunks/webpack-mock-plugin-T4LDXEHE.js +0 -124
- package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +0 -36
- package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +0 -33
|
@@ -1,71 +1,67 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_jdojl2z4eei from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_jdojl2z4eei from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_jdojl2z4eei from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_jdojl2z4eei.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_jdojl2z4eei.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_jdojl2z4eei.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
|
+
import "../../_node-chunks/chunk-S3PBHOVC.js";
|
|
12
13
|
import {
|
|
13
14
|
parseStaticDir,
|
|
14
|
-
sendTelemetryError
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
sendTelemetryError,
|
|
16
|
+
throttle
|
|
17
|
+
} from "../../_node-chunks/chunk-6DEMT5VX.js";
|
|
18
|
+
import "../../_node-chunks/chunk-AREL5IXS.js";
|
|
19
|
+
import "../../_node-chunks/chunk-DWA53E73.js";
|
|
20
|
+
import "../../_node-chunks/chunk-N3BJOOY5.js";
|
|
17
21
|
import {
|
|
18
22
|
getLastEvents,
|
|
19
23
|
getSessionId
|
|
20
|
-
} from "../../_node-chunks/chunk-
|
|
24
|
+
} from "../../_node-chunks/chunk-VRICJPXY.js";
|
|
25
|
+
import {
|
|
26
|
+
globalSettings
|
|
27
|
+
} from "../../_node-chunks/chunk-3JJPSDXI.js";
|
|
21
28
|
import {
|
|
22
29
|
invariant
|
|
23
|
-
} from "../../_node-chunks/chunk-
|
|
30
|
+
} from "../../_node-chunks/chunk-IUYZQKSX.js";
|
|
24
31
|
import {
|
|
25
32
|
resolvePackageDir
|
|
26
|
-
} from "../../_node-chunks/chunk-
|
|
33
|
+
} from "../../_node-chunks/chunk-FNYKBULZ.js";
|
|
34
|
+
import "../../_node-chunks/chunk-RIKQZHV3.js";
|
|
27
35
|
import {
|
|
28
36
|
isAbsolute,
|
|
29
37
|
join
|
|
30
|
-
} from "../../_node-chunks/chunk-
|
|
31
|
-
import "../../_node-chunks/chunk-WOXXODXP.js";
|
|
38
|
+
} from "../../_node-chunks/chunk-WIWWMCEU.js";
|
|
32
39
|
import {
|
|
33
40
|
loadConfig
|
|
34
|
-
} from "../../_node-chunks/chunk-
|
|
41
|
+
} from "../../_node-chunks/chunk-54NMJ4II.js";
|
|
35
42
|
import {
|
|
36
43
|
require_dist
|
|
37
|
-
} from "../../_node-chunks/chunk-
|
|
44
|
+
} from "../../_node-chunks/chunk-SQSFX47N.js";
|
|
45
|
+
import "../../_node-chunks/chunk-6ULDIDXV.js";
|
|
46
|
+
import "../../_node-chunks/chunk-K673CX4Q.js";
|
|
38
47
|
import {
|
|
39
48
|
require_picocolors
|
|
40
|
-
} from "../../_node-chunks/chunk-
|
|
49
|
+
} from "../../_node-chunks/chunk-XGNRK7QB.js";
|
|
41
50
|
import {
|
|
42
51
|
__commonJS,
|
|
43
|
-
__name,
|
|
44
52
|
__require,
|
|
45
53
|
__toESM
|
|
46
|
-
} from "../../_node-chunks/chunk-
|
|
54
|
+
} from "../../_node-chunks/chunk-2OVULPK3.js";
|
|
47
55
|
|
|
48
56
|
// ../node_modules/shell-quote/quote.js
|
|
49
57
|
var require_quote = __commonJS({
|
|
50
58
|
"../node_modules/shell-quote/quote.js"(exports, module) {
|
|
51
59
|
"use strict";
|
|
52
|
-
module.exports =
|
|
60
|
+
module.exports = function(xs) {
|
|
53
61
|
return xs.map(function(s) {
|
|
54
|
-
|
|
55
|
-
return "''";
|
|
56
|
-
}
|
|
57
|
-
if (s && typeof s === "object") {
|
|
58
|
-
return s.op.replace(/(.)/g, "\\$1");
|
|
59
|
-
}
|
|
60
|
-
if (/["\s\\]/.test(s) && !/'/.test(s)) {
|
|
61
|
-
return "'" + s.replace(/(['])/g, "\\$1") + "'";
|
|
62
|
-
}
|
|
63
|
-
if (/["'\s]/.test(s)) {
|
|
64
|
-
return '"' + s.replace(/(["\\$`!])/g, "\\$1") + '"';
|
|
65
|
-
}
|
|
66
|
-
return String(s).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}])/g, "$1\\$2");
|
|
62
|
+
return s === "" ? "''" : s && typeof s == "object" ? s.op.replace(/(.)/g, "\\$1") : /["\s\\]/.test(s) && !/'/.test(s) ? "'" + s.replace(/(['])/g, "\\$1") + "'" : /["'\s]/.test(s) ? '"' + s.replace(/(["\\$`!])/g, "\\$1") + '"' : String(s).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}])/g, "$1\\$2");
|
|
67
63
|
}).join(" ");
|
|
68
|
-
}
|
|
64
|
+
};
|
|
69
65
|
}
|
|
70
66
|
});
|
|
71
67
|
|
|
@@ -84,189 +80,88 @@ var require_parse = __commonJS({
|
|
|
84
80
|
">\\&",
|
|
85
81
|
"<\\&",
|
|
86
82
|
"[&;()|<>]"
|
|
87
|
-
].join("|") + ")";
|
|
88
|
-
|
|
89
|
-
var META = "|&;()<> \\t";
|
|
90
|
-
var SINGLE_QUOTE = '"((\\\\"|[^"])*?)"';
|
|
91
|
-
var DOUBLE_QUOTE = "'((\\\\'|[^'])*?)'";
|
|
92
|
-
var hash = /^#$/;
|
|
93
|
-
var SQ = "'";
|
|
94
|
-
var DQ = '"';
|
|
95
|
-
var DS = "$";
|
|
96
|
-
var TOKEN = "";
|
|
97
|
-
var mult = 4294967296;
|
|
98
|
-
for (i = 0; i < 4; i++) {
|
|
83
|
+
].join("|") + ")", controlRE = new RegExp("^" + CONTROL + "$"), META = "|&;()<> \\t", SINGLE_QUOTE = '"((\\\\"|[^"])*?)"', DOUBLE_QUOTE = "'((\\\\'|[^'])*?)'", hash = /^#$/, SQ = "'", DQ = '"', DS = "$", TOKEN = "", mult = 4294967296;
|
|
84
|
+
for (i = 0; i < 4; i++)
|
|
99
85
|
TOKEN += (mult * Math.random()).toString(16);
|
|
100
|
-
|
|
101
|
-
var i;
|
|
102
|
-
var startsWithToken = new RegExp("^" + TOKEN);
|
|
86
|
+
var i, startsWithToken = new RegExp("^" + TOKEN);
|
|
103
87
|
function matchAll(s, r) {
|
|
104
|
-
var origIndex = r.lastIndex;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
while (matchObj = r.exec(s)) {
|
|
108
|
-
matches.push(matchObj);
|
|
109
|
-
if (r.lastIndex === matchObj.index) {
|
|
110
|
-
r.lastIndex += 1;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
r.lastIndex = origIndex;
|
|
114
|
-
return matches;
|
|
88
|
+
for (var origIndex = r.lastIndex, matches = [], matchObj; matchObj = r.exec(s); )
|
|
89
|
+
matches.push(matchObj), r.lastIndex === matchObj.index && (r.lastIndex += 1);
|
|
90
|
+
return r.lastIndex = origIndex, matches;
|
|
115
91
|
}
|
|
116
|
-
__name(matchAll, "matchAll");
|
|
117
92
|
function getVar(env2, pre, key) {
|
|
118
|
-
var r = typeof env2
|
|
119
|
-
|
|
120
|
-
r = "";
|
|
121
|
-
} else if (typeof r === "undefined") {
|
|
122
|
-
r = "$";
|
|
123
|
-
}
|
|
124
|
-
if (typeof r === "object") {
|
|
125
|
-
return pre + TOKEN + JSON.stringify(r) + TOKEN;
|
|
126
|
-
}
|
|
127
|
-
return pre + r;
|
|
93
|
+
var r = typeof env2 == "function" ? env2(key) : env2[key];
|
|
94
|
+
return typeof r > "u" && key != "" ? r = "" : typeof r > "u" && (r = "$"), typeof r == "object" ? pre + TOKEN + JSON.stringify(r) + TOKEN : pre + r;
|
|
128
95
|
}
|
|
129
|
-
__name(getVar, "getVar");
|
|
130
96
|
function parseInternal(string, env2, opts) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
var BS = opts.escape || "\\";
|
|
135
|
-
var BAREWORD = "(\\" + BS + `['"` + META + `]|[^\\s'"` + META + "])+";
|
|
136
|
-
var chunker = new RegExp([
|
|
97
|
+
opts || (opts = {});
|
|
98
|
+
var BS = opts.escape || "\\", BAREWORD = "(\\" + BS + `['"` + META + `]|[^\\s'"` + META + "])+", chunker = new RegExp([
|
|
137
99
|
"(" + CONTROL + ")",
|
|
138
100
|
// control chars
|
|
139
101
|
"(" + BAREWORD + "|" + SINGLE_QUOTE + "|" + DOUBLE_QUOTE + ")+"
|
|
140
|
-
].join("|"), "g");
|
|
141
|
-
|
|
142
|
-
if (matches.length === 0) {
|
|
102
|
+
].join("|"), "g"), matches = matchAll(string, chunker);
|
|
103
|
+
if (matches.length === 0)
|
|
143
104
|
return [];
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
env2 = {};
|
|
147
|
-
}
|
|
148
|
-
var commented = false;
|
|
105
|
+
env2 || (env2 = {});
|
|
106
|
+
var commented = !1;
|
|
149
107
|
return matches.map(function(match) {
|
|
150
108
|
var s = match[0];
|
|
151
|
-
if (!s || commented)
|
|
152
|
-
return
|
|
153
|
-
|
|
154
|
-
if (controlRE.test(s)) {
|
|
109
|
+
if (!s || commented)
|
|
110
|
+
return;
|
|
111
|
+
if (controlRE.test(s))
|
|
155
112
|
return { op: s };
|
|
156
|
-
|
|
157
|
-
var quote = false;
|
|
158
|
-
var esc = false;
|
|
159
|
-
var out = "";
|
|
160
|
-
var isGlob = false;
|
|
161
|
-
var i2;
|
|
113
|
+
var quote = !1, esc = !1, out = "", isGlob = !1, i2;
|
|
162
114
|
function parseEnvVar() {
|
|
163
115
|
i2 += 1;
|
|
164
|
-
var varend;
|
|
165
|
-
var varname;
|
|
166
|
-
var char = s.charAt(i2);
|
|
116
|
+
var varend, varname, char = s.charAt(i2);
|
|
167
117
|
if (char === "{") {
|
|
168
|
-
i2 += 1
|
|
169
|
-
if (s.charAt(i2) === "}") {
|
|
118
|
+
if (i2 += 1, s.charAt(i2) === "}")
|
|
170
119
|
throw new Error("Bad substitution: " + s.slice(i2 - 2, i2 + 1));
|
|
171
|
-
}
|
|
172
|
-
varend = s.indexOf("}", i2);
|
|
173
|
-
if (varend < 0) {
|
|
120
|
+
if (varend = s.indexOf("}", i2), varend < 0)
|
|
174
121
|
throw new Error("Bad substitution: " + s.slice(i2));
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
varname = char;
|
|
180
|
-
i2 += 1;
|
|
181
|
-
} else {
|
|
122
|
+
varname = s.slice(i2, varend), i2 = varend;
|
|
123
|
+
} else if (/[*@#?$!_-]/.test(char))
|
|
124
|
+
varname = char, i2 += 1;
|
|
125
|
+
else {
|
|
182
126
|
var slicedFromI = s.slice(i2);
|
|
183
|
-
varend = slicedFromI.match(/[^\w\d_]/);
|
|
184
|
-
if (!varend) {
|
|
185
|
-
varname = slicedFromI;
|
|
186
|
-
i2 = s.length;
|
|
187
|
-
} else {
|
|
188
|
-
varname = slicedFromI.slice(0, varend.index);
|
|
189
|
-
i2 += varend.index - 1;
|
|
190
|
-
}
|
|
127
|
+
varend = slicedFromI.match(/[^\w\d_]/), varend ? (varname = slicedFromI.slice(0, varend.index), i2 += varend.index - 1) : (varname = slicedFromI, i2 = s.length);
|
|
191
128
|
}
|
|
192
129
|
return getVar(env2, "", varname);
|
|
193
130
|
}
|
|
194
|
-
__name(parseEnvVar, "parseEnvVar");
|
|
195
131
|
for (i2 = 0; i2 < s.length; i2++) {
|
|
196
132
|
var c = s.charAt(i2);
|
|
197
|
-
isGlob = isGlob || !quote && (c === "*" || c === "?")
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
if (c === quote) {
|
|
203
|
-
quote = false;
|
|
204
|
-
} else if (quote == SQ) {
|
|
205
|
-
out += c;
|
|
206
|
-
} else {
|
|
207
|
-
if (c === BS) {
|
|
208
|
-
i2 += 1;
|
|
209
|
-
c = s.charAt(i2);
|
|
210
|
-
if (c === DQ || c === BS || c === DS) {
|
|
211
|
-
out += c;
|
|
212
|
-
} else {
|
|
213
|
-
out += BS + c;
|
|
214
|
-
}
|
|
215
|
-
} else if (c === DS) {
|
|
216
|
-
out += parseEnvVar();
|
|
217
|
-
} else {
|
|
218
|
-
out += c;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
} else if (c === DQ || c === SQ) {
|
|
133
|
+
if (isGlob = isGlob || !quote && (c === "*" || c === "?"), esc)
|
|
134
|
+
out += c, esc = !1;
|
|
135
|
+
else if (quote)
|
|
136
|
+
c === quote ? quote = !1 : quote == SQ ? out += c : c === BS ? (i2 += 1, c = s.charAt(i2), c === DQ || c === BS || c === DS ? out += c : out += BS + c) : c === DS ? out += parseEnvVar() : out += c;
|
|
137
|
+
else if (c === DQ || c === SQ)
|
|
222
138
|
quote = c;
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
return [out, commentObj];
|
|
230
|
-
}
|
|
231
|
-
return [commentObj];
|
|
232
|
-
} else if (c === BS) {
|
|
233
|
-
esc = true;
|
|
234
|
-
} else if (c === DS) {
|
|
235
|
-
out += parseEnvVar();
|
|
236
|
-
} else {
|
|
237
|
-
out += c;
|
|
139
|
+
else {
|
|
140
|
+
if (controlRE.test(c))
|
|
141
|
+
return { op: s };
|
|
142
|
+
if (hash.test(c)) {
|
|
143
|
+
commented = !0;
|
|
144
|
+
var commentObj = { comment: string.slice(match.index + i2 + 1) };
|
|
145
|
+
return out.length ? [out, commentObj] : [commentObj];
|
|
146
|
+
} else c === BS ? esc = !0 : c === DS ? out += parseEnvVar() : out += c;
|
|
238
147
|
}
|
|
239
148
|
}
|
|
240
|
-
|
|
241
|
-
return { op: "glob", pattern: out };
|
|
242
|
-
}
|
|
243
|
-
return out;
|
|
149
|
+
return isGlob ? { op: "glob", pattern: out } : out;
|
|
244
150
|
}).reduce(function(prev, arg) {
|
|
245
|
-
return typeof arg
|
|
151
|
+
return typeof arg > "u" ? prev : prev.concat(arg);
|
|
246
152
|
}, []);
|
|
247
153
|
}
|
|
248
|
-
|
|
249
|
-
module.exports = /* @__PURE__ */ __name(function parse(s, env2, opts) {
|
|
154
|
+
module.exports = function(s, env2, opts) {
|
|
250
155
|
var mapped = parseInternal(s, env2, opts);
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
}
|
|
254
|
-
return mapped.reduce(function(acc, s2) {
|
|
255
|
-
if (typeof s2 === "object") {
|
|
156
|
+
return typeof env2 != "function" ? mapped : mapped.reduce(function(acc, s2) {
|
|
157
|
+
if (typeof s2 == "object")
|
|
256
158
|
return acc.concat(s2);
|
|
257
|
-
}
|
|
258
159
|
var xs = s2.split(RegExp("(" + TOKEN + ".*?" + TOKEN + ")", "g"));
|
|
259
|
-
|
|
260
|
-
return
|
|
261
|
-
}
|
|
262
|
-
return acc.concat(xs.filter(Boolean).map(function(x) {
|
|
263
|
-
if (startsWithToken.test(x)) {
|
|
264
|
-
return JSON.parse(x.split(TOKEN)[1]);
|
|
265
|
-
}
|
|
266
|
-
return x;
|
|
160
|
+
return xs.length === 1 ? acc.concat(xs[0]) : acc.concat(xs.filter(Boolean).map(function(x) {
|
|
161
|
+
return startsWithToken.test(x) ? JSON.parse(x.split(TOKEN)[1]) : x;
|
|
267
162
|
}));
|
|
268
163
|
}, []);
|
|
269
|
-
}
|
|
164
|
+
};
|
|
270
165
|
}
|
|
271
166
|
});
|
|
272
167
|
|
|
@@ -323,6 +218,7 @@ var require_linux = __commonJS({
|
|
|
323
218
|
code: "code",
|
|
324
219
|
vscodium: "vscodium",
|
|
325
220
|
codium: "codium",
|
|
221
|
+
cursor: "cursor",
|
|
326
222
|
trae: "trae",
|
|
327
223
|
emacs: "emacs",
|
|
328
224
|
gvim: "gvim",
|
|
@@ -383,81 +279,60 @@ var require_windows = __commonJS({
|
|
|
383
279
|
// ../node_modules/launch-editor/guess.js
|
|
384
280
|
var require_guess = __commonJS({
|
|
385
281
|
"../node_modules/launch-editor/guess.js"(exports, module) {
|
|
386
|
-
var path = __require("path");
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
var COMMON_EDITORS_MACOS = require_macos();
|
|
390
|
-
var COMMON_EDITORS_LINUX = require_linux();
|
|
391
|
-
var COMMON_EDITORS_WIN = require_windows();
|
|
392
|
-
module.exports = /* @__PURE__ */ __name(function guessEditor(specifiedEditor) {
|
|
393
|
-
if (specifiedEditor) {
|
|
282
|
+
var path = __require("path"), shellQuote = require_shell_quote(), childProcess = __require("child_process"), COMMON_EDITORS_MACOS = require_macos(), COMMON_EDITORS_LINUX = require_linux(), COMMON_EDITORS_WIN = require_windows();
|
|
283
|
+
module.exports = function(specifiedEditor) {
|
|
284
|
+
if (specifiedEditor)
|
|
394
285
|
return shellQuote.parse(specifiedEditor);
|
|
395
|
-
|
|
396
|
-
if (process.env.LAUNCH_EDITOR) {
|
|
286
|
+
if (process.env.LAUNCH_EDITOR)
|
|
397
287
|
return [process.env.LAUNCH_EDITOR];
|
|
398
|
-
|
|
399
|
-
if (process.versions.webcontainer) {
|
|
288
|
+
if (process.versions.webcontainer)
|
|
400
289
|
return [process.env.EDITOR || "code"];
|
|
401
|
-
}
|
|
402
290
|
try {
|
|
403
291
|
if (process.platform === "darwin") {
|
|
404
|
-
|
|
292
|
+
let output = childProcess.execSync("ps x -o comm=", {
|
|
405
293
|
stdio: ["pipe", "pipe", "ignore"]
|
|
406
|
-
}).toString()
|
|
407
|
-
|
|
408
|
-
const processList = output.split("\n");
|
|
294
|
+
}).toString(), processNames = Object.keys(COMMON_EDITORS_MACOS), processList = output.split(`
|
|
295
|
+
`);
|
|
409
296
|
for (let i = 0; i < processNames.length; i++) {
|
|
410
|
-
|
|
411
|
-
if (processList.includes(processName))
|
|
297
|
+
let processName = processNames[i];
|
|
298
|
+
if (processList.includes(processName))
|
|
412
299
|
return [COMMON_EDITORS_MACOS[processName]];
|
|
413
|
-
|
|
414
|
-
const processNameWithoutApplications = processName.replace("/Applications", "");
|
|
300
|
+
let processNameWithoutApplications = processName.replace("/Applications", "");
|
|
415
301
|
if (output.indexOf(processNameWithoutApplications) !== -1) {
|
|
416
|
-
if (processName !== COMMON_EDITORS_MACOS[processName])
|
|
302
|
+
if (processName !== COMMON_EDITORS_MACOS[processName])
|
|
417
303
|
return [COMMON_EDITORS_MACOS[processName]];
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
if (runningProcess !== void 0) {
|
|
304
|
+
let runningProcess = processList.find((procName) => procName.endsWith(processNameWithoutApplications));
|
|
305
|
+
if (runningProcess !== void 0)
|
|
421
306
|
return [runningProcess];
|
|
422
|
-
}
|
|
423
307
|
}
|
|
424
308
|
}
|
|
425
309
|
} else if (process.platform === "win32") {
|
|
426
|
-
|
|
310
|
+
let runningProcesses = childProcess.execSync(
|
|
427
311
|
'powershell -NoProfile -Command "[Console]::OutputEncoding=[Text.Encoding]::UTF8;Get-CimInstance -Query \\"select executablepath from win32_process where executablepath is not null\\" | % { $_.ExecutablePath }"',
|
|
428
312
|
{
|
|
429
313
|
stdio: ["pipe", "pipe", "ignore"]
|
|
430
314
|
}
|
|
431
|
-
).toString()
|
|
432
|
-
|
|
315
|
+
).toString().split(`\r
|
|
316
|
+
`);
|
|
433
317
|
for (let i = 0; i < runningProcesses.length; i++) {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
if (COMMON_EDITORS_WIN.indexOf(shortProcessName) !== -1) {
|
|
318
|
+
let fullProcessPath = runningProcesses[i].trim(), shortProcessName = path.basename(fullProcessPath);
|
|
319
|
+
if (COMMON_EDITORS_WIN.indexOf(shortProcessName) !== -1)
|
|
437
320
|
return [fullProcessPath];
|
|
438
|
-
}
|
|
439
321
|
}
|
|
440
322
|
} else if (process.platform === "linux") {
|
|
441
|
-
|
|
323
|
+
let output = childProcess.execSync("ps x --no-heading -o comm --sort=comm", {
|
|
442
324
|
stdio: ["pipe", "pipe", "ignore"]
|
|
443
|
-
}).toString();
|
|
444
|
-
const processNames = Object.keys(COMMON_EDITORS_LINUX);
|
|
325
|
+
}).toString(), processNames = Object.keys(COMMON_EDITORS_LINUX);
|
|
445
326
|
for (let i = 0; i < processNames.length; i++) {
|
|
446
|
-
|
|
447
|
-
if (output.indexOf(processName) !== -1)
|
|
327
|
+
let processName = processNames[i];
|
|
328
|
+
if (output.indexOf(processName) !== -1)
|
|
448
329
|
return [COMMON_EDITORS_LINUX[processName]];
|
|
449
|
-
}
|
|
450
330
|
}
|
|
451
331
|
}
|
|
452
|
-
} catch
|
|
453
|
-
}
|
|
454
|
-
if (process.env.VISUAL) {
|
|
455
|
-
return [process.env.VISUAL];
|
|
456
|
-
} else if (process.env.EDITOR) {
|
|
457
|
-
return [process.env.EDITOR];
|
|
332
|
+
} catch {
|
|
458
333
|
}
|
|
459
|
-
return [null];
|
|
460
|
-
}
|
|
334
|
+
return process.env.VISUAL ? [process.env.VISUAL] : process.env.EDITOR ? [process.env.EDITOR] : [null];
|
|
335
|
+
};
|
|
461
336
|
}
|
|
462
337
|
});
|
|
463
338
|
|
|
@@ -465,9 +340,8 @@ var require_guess = __commonJS({
|
|
|
465
340
|
var require_get_args = __commonJS({
|
|
466
341
|
"../node_modules/launch-editor/get-args.js"(exports, module) {
|
|
467
342
|
var path = __require("path");
|
|
468
|
-
module.exports =
|
|
469
|
-
|
|
470
|
-
switch (editorBasename) {
|
|
343
|
+
module.exports = function(editor, fileName, lineNumber, columnNumber = 1) {
|
|
344
|
+
switch (path.basename(editor).replace(/\.(exe|cmd|bat)$/i, "")) {
|
|
471
345
|
case "atom":
|
|
472
346
|
case "Atom":
|
|
473
347
|
case "Atom Beta":
|
|
@@ -522,136 +396,80 @@ var require_get_args = __commonJS({
|
|
|
522
396
|
case "rider64":
|
|
523
397
|
return ["--line", lineNumber, "--column", columnNumber, fileName];
|
|
524
398
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
}
|
|
528
|
-
return [fileName];
|
|
529
|
-
}, "getArgumentsForPosition");
|
|
399
|
+
return process.env.LAUNCH_EDITOR ? [fileName, lineNumber, columnNumber] : [fileName];
|
|
400
|
+
};
|
|
530
401
|
}
|
|
531
402
|
});
|
|
532
403
|
|
|
533
404
|
// ../node_modules/launch-editor/index.js
|
|
534
405
|
var require_launch_editor = __commonJS({
|
|
535
406
|
"../node_modules/launch-editor/index.js"(exports, module) {
|
|
536
|
-
var fs = __require("fs");
|
|
537
|
-
var os = __require("os");
|
|
538
|
-
var path = __require("path");
|
|
539
|
-
var colors = require_picocolors();
|
|
540
|
-
var childProcess = __require("child_process");
|
|
541
|
-
var guessEditor = require_guess();
|
|
542
|
-
var getArgumentsForPosition = require_get_args();
|
|
407
|
+
var fs = __require("fs"), os = __require("os"), path = __require("path"), colors = require_picocolors(), childProcess = __require("child_process"), guessEditor = require_guess(), getArgumentsForPosition = require_get_args();
|
|
543
408
|
function wrapErrorCallback(cb) {
|
|
544
409
|
return (fileName, errorMessage) => {
|
|
545
|
-
console.log()
|
|
546
|
-
console.log(
|
|
410
|
+
console.log(), console.log(
|
|
547
411
|
colors.red("Could not open " + path.basename(fileName) + " in the editor.")
|
|
548
|
-
)
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
errorMessage += ".";
|
|
552
|
-
}
|
|
553
|
-
console.log(
|
|
554
|
-
colors.red("The editor process exited with an error: " + errorMessage)
|
|
555
|
-
);
|
|
556
|
-
}
|
|
557
|
-
console.log();
|
|
558
|
-
if (cb) cb(fileName, errorMessage);
|
|
412
|
+
), errorMessage && (errorMessage[errorMessage.length - 1] !== "." && (errorMessage += "."), console.log(
|
|
413
|
+
colors.red("The editor process exited with an error: " + errorMessage)
|
|
414
|
+
)), console.log(), cb && cb(fileName, errorMessage);
|
|
559
415
|
};
|
|
560
416
|
}
|
|
561
|
-
__name(wrapErrorCallback, "wrapErrorCallback");
|
|
562
417
|
function isTerminalEditor(editor) {
|
|
563
418
|
switch (editor) {
|
|
564
419
|
case "vim":
|
|
565
420
|
case "emacs":
|
|
566
421
|
case "nano":
|
|
567
|
-
return
|
|
422
|
+
return !0;
|
|
568
423
|
}
|
|
569
|
-
return
|
|
424
|
+
return !1;
|
|
570
425
|
}
|
|
571
|
-
__name(isTerminalEditor, "isTerminalEditor");
|
|
572
426
|
var positionRE = /:(\d+)(:(\d+))?$/;
|
|
573
427
|
function parseFile(file) {
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
}
|
|
577
|
-
const fileName = file.replace(positionRE, "");
|
|
578
|
-
const match = file.match(positionRE);
|
|
579
|
-
const lineNumber = match && match[1];
|
|
580
|
-
const columnNumber = match && match[3];
|
|
428
|
+
file.startsWith("file://") && (file = __require("url").fileURLToPath(file));
|
|
429
|
+
let fileName = file.replace(positionRE, ""), match = file.match(positionRE), lineNumber = match && match[1], columnNumber = match && match[3];
|
|
581
430
|
return {
|
|
582
431
|
fileName,
|
|
583
432
|
lineNumber,
|
|
584
433
|
columnNumber
|
|
585
434
|
};
|
|
586
435
|
}
|
|
587
|
-
__name(parseFile, "parseFile");
|
|
588
436
|
var _childProcess = null;
|
|
589
437
|
function launchEditor(file, specifiedEditor, onErrorCallback) {
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
const { lineNumber, columnNumber } = parsed;
|
|
593
|
-
if (!fs.existsSync(fileName)) {
|
|
438
|
+
let parsed = parseFile(file), { fileName } = parsed, { lineNumber, columnNumber } = parsed;
|
|
439
|
+
if (!fs.existsSync(fileName))
|
|
594
440
|
return;
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
onErrorCallback = specifiedEditor;
|
|
598
|
-
specifiedEditor = void 0;
|
|
599
|
-
}
|
|
600
|
-
onErrorCallback = wrapErrorCallback(onErrorCallback);
|
|
601
|
-
const [editor, ...args] = guessEditor(specifiedEditor);
|
|
441
|
+
typeof specifiedEditor == "function" && (onErrorCallback = specifiedEditor, specifiedEditor = void 0), onErrorCallback = wrapErrorCallback(onErrorCallback);
|
|
442
|
+
let [editor, ...args] = guessEditor(specifiedEditor);
|
|
602
443
|
if (!editor) {
|
|
603
444
|
onErrorCallback(fileName, null);
|
|
604
445
|
return;
|
|
605
446
|
}
|
|
606
|
-
if (process.platform === "linux" && fileName.startsWith("/mnt/") && /Microsoft/i.test(os.release())) {
|
|
607
|
-
|
|
608
|
-
}
|
|
609
|
-
if (lineNumber) {
|
|
610
|
-
const extraArgs = getArgumentsForPosition(editor, fileName, lineNumber, columnNumber);
|
|
447
|
+
if (process.platform === "linux" && fileName.startsWith("/mnt/") && /Microsoft/i.test(os.release()) && (fileName = path.relative("", fileName)), lineNumber) {
|
|
448
|
+
let extraArgs = getArgumentsForPosition(editor, fileName, lineNumber, columnNumber);
|
|
611
449
|
args.push.apply(args, extraArgs);
|
|
612
|
-
} else
|
|
450
|
+
} else
|
|
613
451
|
args.push(fileName);
|
|
614
|
-
|
|
615
|
-
if (_childProcess && isTerminalEditor(editor)) {
|
|
616
|
-
_childProcess.kill("SIGKILL");
|
|
617
|
-
}
|
|
618
|
-
if (process.platform === "win32") {
|
|
452
|
+
if (_childProcess && isTerminalEditor(editor) && _childProcess.kill("SIGKILL"), process.platform === "win32") {
|
|
619
453
|
let escapeCmdArgs2 = function(cmdArgs) {
|
|
620
454
|
return cmdArgs.replace(/([&|<>,;=^])/g, "^$1");
|
|
621
455
|
}, doubleQuoteIfNeeded2 = function(str) {
|
|
622
|
-
|
|
623
|
-
return `^"${str}^"`;
|
|
624
|
-
} else if (str.includes(" ")) {
|
|
625
|
-
return `"${str}"`;
|
|
626
|
-
}
|
|
627
|
-
return str;
|
|
456
|
+
return str.includes("^") ? `^"${str}^"` : str.includes(" ") ? `"${str}"` : str;
|
|
628
457
|
};
|
|
629
458
|
var escapeCmdArgs = escapeCmdArgs2, doubleQuoteIfNeeded = doubleQuoteIfNeeded2;
|
|
630
|
-
|
|
631
|
-
__name(doubleQuoteIfNeeded2, "doubleQuoteIfNeeded");
|
|
632
|
-
const launchCommand = [editor, ...args.map(escapeCmdArgs2)].map(doubleQuoteIfNeeded2).join(" ");
|
|
459
|
+
let launchCommand = [editor, ...args.map(escapeCmdArgs2)].map(doubleQuoteIfNeeded2).join(" ");
|
|
633
460
|
_childProcess = childProcess.exec(launchCommand, {
|
|
634
461
|
stdio: "inherit",
|
|
635
|
-
shell:
|
|
462
|
+
shell: !0
|
|
636
463
|
});
|
|
637
|
-
} else
|
|
464
|
+
} else
|
|
638
465
|
_childProcess = childProcess.spawn(editor, args, { stdio: "inherit" });
|
|
639
|
-
}
|
|
640
466
|
_childProcess.on("exit", function(errorCode) {
|
|
641
|
-
_childProcess = null;
|
|
642
|
-
|
|
643
|
-
onErrorCallback(fileName, "(code " + errorCode + ")");
|
|
644
|
-
}
|
|
645
|
-
});
|
|
646
|
-
_childProcess.on("error", function(error) {
|
|
467
|
+
_childProcess = null, errorCode && onErrorCallback(fileName, "(code " + errorCode + ")");
|
|
468
|
+
}), _childProcess.on("error", function(error) {
|
|
647
469
|
let { code, message } = error;
|
|
648
|
-
|
|
649
|
-
message = `${message} ('${editor}' command does not exist in 'PATH')`;
|
|
650
|
-
}
|
|
651
|
-
onErrorCallback(fileName, message);
|
|
470
|
+
code === "ENOENT" && (message = `${message} ('${editor}' command does not exist in 'PATH')`), onErrorCallback(fileName, message);
|
|
652
471
|
});
|
|
653
472
|
}
|
|
654
|
-
__name(launchEditor, "launchEditor");
|
|
655
473
|
module.exports = launchEditor;
|
|
656
474
|
}
|
|
657
475
|
});
|
|
@@ -659,11 +477,9 @@ var require_launch_editor = __commonJS({
|
|
|
659
477
|
// src/core-server/presets/common-preset.ts
|
|
660
478
|
import { existsSync as existsSync3 } from "node:fs";
|
|
661
479
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
662
|
-
import { fileURLToPath } from "node:url";
|
|
663
480
|
import { optionalEnvToBoolean } from "storybook/internal/common";
|
|
664
481
|
import {
|
|
665
482
|
JsPackageManagerFactory,
|
|
666
|
-
findConfigFile as findConfigFile3,
|
|
667
483
|
getDirectoryFromWorkingDir,
|
|
668
484
|
getPreviewBodyTemplate,
|
|
669
485
|
getPreviewHeadTemplate,
|
|
@@ -671,8 +487,8 @@ import {
|
|
|
671
487
|
removeAddon as removeAddonBase
|
|
672
488
|
} from "storybook/internal/common";
|
|
673
489
|
import { readCsf as readCsf2 } from "storybook/internal/csf-tools";
|
|
674
|
-
import { logger as
|
|
675
|
-
import { telemetry as
|
|
490
|
+
import { logger as logger4 } from "storybook/internal/node-logger";
|
|
491
|
+
import { telemetry as telemetry8 } from "storybook/internal/telemetry";
|
|
676
492
|
var import_ts_dedent4 = __toESM(require_dist(), 1);
|
|
677
493
|
|
|
678
494
|
// src/core-server/server-channel/create-new-story-channel.ts
|
|
@@ -691,7 +507,7 @@ import { existsSync } from "node:fs";
|
|
|
691
507
|
import { readFile } from "node:fs/promises";
|
|
692
508
|
import { basename, dirname, extname, join as join2 } from "node:path";
|
|
693
509
|
import {
|
|
694
|
-
|
|
510
|
+
extractFrameworkPackageName,
|
|
695
511
|
findConfigFile,
|
|
696
512
|
getFrameworkName,
|
|
697
513
|
getProjectRoot
|
|
@@ -702,20 +518,13 @@ import { isCsfFactoryPreview } from "storybook/internal/csf-tools";
|
|
|
702
518
|
var import_ts_dedent = __toESM(require_dist(), 1);
|
|
703
519
|
|
|
704
520
|
// src/core-server/utils/get-component-variable-name.ts
|
|
705
|
-
var getComponentVariableName =
|
|
706
|
-
const camelCase = await import("../../_node-chunks/camelcase-H5QSGQLK.js");
|
|
707
|
-
const camelCased = camelCase.default(name.replace(/^[^a-zA-Z_$]*/, ""), { pascalCase: true });
|
|
708
|
-
const sanitized = camelCased.replace(/[^a-zA-Z_$]+/, "");
|
|
709
|
-
return sanitized;
|
|
710
|
-
}, "getComponentVariableName");
|
|
521
|
+
var getComponentVariableName = async (name) => (await import("../../_node-chunks/camelcase-3SMT5WKC.js")).default(name.replace(/^[^a-zA-Z_$]*/, ""), { pascalCase: !0 }).replace(/[^a-zA-Z_$]+/, "");
|
|
711
522
|
|
|
712
523
|
// src/core-server/utils/new-story-templates/csf-factory-template.ts
|
|
713
524
|
async function getCsfFactoryTemplateForNewStoryFile(data) {
|
|
714
|
-
|
|
715
|
-
const importStatement = data.componentIsDefaultExport ? `import ${importName} from './${data.basenameWithoutExtension}';` : `import { ${importName} } from './${data.basenameWithoutExtension}';`;
|
|
716
|
-
const previewImport = `import preview from '#.storybook/preview';`;
|
|
525
|
+
let importName = data.componentIsDefaultExport ? await getComponentVariableName(data.basenameWithoutExtension) : data.componentExportName, importStatement = data.componentIsDefaultExport ? `import ${importName} from './${data.basenameWithoutExtension}';` : `import { ${importName} } from './${data.basenameWithoutExtension}';`;
|
|
717
526
|
return import_ts_dedent.dedent`
|
|
718
|
-
${
|
|
527
|
+
${"import preview from '#.storybook/preview';"}
|
|
719
528
|
|
|
720
529
|
${importStatement}
|
|
721
530
|
|
|
@@ -726,13 +535,11 @@ async function getCsfFactoryTemplateForNewStoryFile(data) {
|
|
|
726
535
|
export const ${data.exportedStoryName} = meta.story({});
|
|
727
536
|
`;
|
|
728
537
|
}
|
|
729
|
-
__name(getCsfFactoryTemplateForNewStoryFile, "getCsfFactoryTemplateForNewStoryFile");
|
|
730
538
|
|
|
731
539
|
// src/core-server/utils/new-story-templates/javascript.ts
|
|
732
540
|
var import_ts_dedent2 = __toESM(require_dist(), 1);
|
|
733
541
|
async function getJavaScriptTemplateForNewStoryFile(data) {
|
|
734
|
-
|
|
735
|
-
const importStatement = data.componentIsDefaultExport ? `import ${importName} from './${data.basenameWithoutExtension}';` : `import { ${importName} } from './${data.basenameWithoutExtension}';`;
|
|
542
|
+
let importName = data.componentIsDefaultExport ? await getComponentVariableName(data.basenameWithoutExtension) : data.componentExportName, importStatement = data.componentIsDefaultExport ? `import ${importName} from './${data.basenameWithoutExtension}';` : `import { ${importName} } from './${data.basenameWithoutExtension}';`;
|
|
736
543
|
return import_ts_dedent2.dedent`
|
|
737
544
|
${importStatement}
|
|
738
545
|
|
|
@@ -745,13 +552,11 @@ async function getJavaScriptTemplateForNewStoryFile(data) {
|
|
|
745
552
|
export const ${data.exportedStoryName} = {};
|
|
746
553
|
`;
|
|
747
554
|
}
|
|
748
|
-
__name(getJavaScriptTemplateForNewStoryFile, "getJavaScriptTemplateForNewStoryFile");
|
|
749
555
|
|
|
750
556
|
// src/core-server/utils/new-story-templates/typescript.ts
|
|
751
557
|
var import_ts_dedent3 = __toESM(require_dist(), 1);
|
|
752
558
|
async function getTypeScriptTemplateForNewStoryFile(data) {
|
|
753
|
-
|
|
754
|
-
const importStatement = data.componentIsDefaultExport ? `import ${importName} from './${data.basenameWithoutExtension}'` : `import { ${importName} } from './${data.basenameWithoutExtension}'`;
|
|
559
|
+
let importName = data.componentIsDefaultExport ? await getComponentVariableName(data.basenameWithoutExtension) : data.componentExportName, importStatement = data.componentIsDefaultExport ? `import ${importName} from './${data.basenameWithoutExtension}'` : `import { ${importName} } from './${data.basenameWithoutExtension}'`;
|
|
755
560
|
return import_ts_dedent3.dedent`
|
|
756
561
|
import type { Meta, StoryObj } from '${data.frameworkPackage}';
|
|
757
562
|
|
|
@@ -768,7 +573,6 @@ async function getTypeScriptTemplateForNewStoryFile(data) {
|
|
|
768
573
|
export const ${data.exportedStoryName}: Story = {};
|
|
769
574
|
`;
|
|
770
575
|
}
|
|
771
|
-
__name(getTypeScriptTemplateForNewStoryFile, "getTypeScriptTemplateForNewStoryFile");
|
|
772
576
|
|
|
773
577
|
// src/core-server/utils/get-new-story-file.ts
|
|
774
578
|
async function getNewStoryFile({
|
|
@@ -777,100 +581,70 @@ async function getNewStoryFile({
|
|
|
777
581
|
componentIsDefaultExport,
|
|
778
582
|
componentExportCount
|
|
779
583
|
}, options) {
|
|
780
|
-
|
|
781
|
-
const sanitizedFrameworkPackageName = extractProperFrameworkName(frameworkPackageName);
|
|
782
|
-
const base = basename(componentFilePath);
|
|
783
|
-
const extension = extname(componentFilePath);
|
|
784
|
-
const basenameWithoutExtension = base.replace(extension, "");
|
|
785
|
-
const dir = dirname(componentFilePath);
|
|
786
|
-
const { storyFileName, isTypescript, storyFileExtension } = getStoryMetadata(componentFilePath);
|
|
787
|
-
const storyFileNameWithExtension = `${storyFileName}.${storyFileExtension}`;
|
|
788
|
-
const alternativeStoryFileNameWithExtension = `${basenameWithoutExtension}.${componentExportName}.stories.${storyFileExtension}`;
|
|
789
|
-
const exportedStoryName = "Default";
|
|
790
|
-
let useCsfFactory = false;
|
|
584
|
+
let frameworkPackageName = await getFrameworkName(options), sanitizedFrameworkPackageName = extractFrameworkPackageName(frameworkPackageName), base = basename(componentFilePath), extension = extname(componentFilePath), basenameWithoutExtension = base.replace(extension, ""), dir = dirname(componentFilePath), { storyFileName, isTypescript, storyFileExtension } = getStoryMetadata(componentFilePath), storyFileNameWithExtension = `${storyFileName}.${storyFileExtension}`, alternativeStoryFileNameWithExtension = `${basenameWithoutExtension}.${componentExportName}.stories.${storyFileExtension}`, exportedStoryName = "Default", useCsfFactory = !1;
|
|
791
585
|
try {
|
|
792
|
-
|
|
586
|
+
let previewConfig = findConfigFile("preview", options.configDir);
|
|
793
587
|
if (previewConfig) {
|
|
794
|
-
|
|
588
|
+
let previewContent = await readFile(previewConfig, "utf-8");
|
|
795
589
|
useCsfFactory = isCsfFactoryPreview(loadConfig(previewContent));
|
|
796
590
|
}
|
|
797
|
-
} catch
|
|
591
|
+
} catch {
|
|
798
592
|
}
|
|
799
593
|
let storyFileContent = "";
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
componentIsDefaultExport,
|
|
818
|
-
exportedStoryName
|
|
819
|
-
});
|
|
820
|
-
}
|
|
821
|
-
const storyFilePath = doesStoryFileExist(join2(getProjectRoot(), dir), storyFileName) && componentExportCount > 1 ? join2(getProjectRoot(), dir, alternativeStoryFileNameWithExtension) : join2(getProjectRoot(), dir, storyFileNameWithExtension);
|
|
822
|
-
return { storyFilePath, exportedStoryName, storyFileContent, dirname };
|
|
594
|
+
return useCsfFactory ? storyFileContent = await getCsfFactoryTemplateForNewStoryFile({
|
|
595
|
+
basenameWithoutExtension,
|
|
596
|
+
componentExportName,
|
|
597
|
+
componentIsDefaultExport,
|
|
598
|
+
exportedStoryName
|
|
599
|
+
}) : storyFileContent = isTypescript && frameworkPackageName ? await getTypeScriptTemplateForNewStoryFile({
|
|
600
|
+
basenameWithoutExtension,
|
|
601
|
+
componentExportName,
|
|
602
|
+
componentIsDefaultExport,
|
|
603
|
+
frameworkPackage: sanitizedFrameworkPackageName,
|
|
604
|
+
exportedStoryName
|
|
605
|
+
}) : await getJavaScriptTemplateForNewStoryFile({
|
|
606
|
+
basenameWithoutExtension,
|
|
607
|
+
componentExportName,
|
|
608
|
+
componentIsDefaultExport,
|
|
609
|
+
exportedStoryName
|
|
610
|
+
}), { storyFilePath: doesStoryFileExist(join2(getProjectRoot(), dir), storyFileName) && componentExportCount > 1 ? join2(getProjectRoot(), dir, alternativeStoryFileNameWithExtension) : join2(getProjectRoot(), dir, storyFileNameWithExtension), exportedStoryName, storyFileContent, dirname };
|
|
823
611
|
}
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
const isTypescript = /\.(ts|tsx|mts|cts)$/.test(componentFilePath);
|
|
827
|
-
const base = basename(componentFilePath);
|
|
828
|
-
const extension = extname(componentFilePath);
|
|
829
|
-
const basenameWithoutExtension = base.replace(extension, "");
|
|
830
|
-
const storyFileExtension = isTypescript ? "tsx" : "jsx";
|
|
612
|
+
var getStoryMetadata = (componentFilePath) => {
|
|
613
|
+
let isTypescript = /\.(ts|tsx|mts|cts)$/.test(componentFilePath), base = basename(componentFilePath), extension = extname(componentFilePath), basenameWithoutExtension = base.replace(extension, ""), storyFileExtension = isTypescript ? "tsx" : "jsx";
|
|
831
614
|
return {
|
|
832
615
|
storyFileName: `${basenameWithoutExtension}.stories`,
|
|
833
616
|
storyFileExtension,
|
|
834
617
|
isTypescript
|
|
835
618
|
};
|
|
836
|
-
},
|
|
837
|
-
var doesStoryFileExist = /* @__PURE__ */ __name((parentFolder, storyFileName) => {
|
|
838
|
-
return existsSync(join2(parentFolder, `${storyFileName}.ts`)) || existsSync(join2(parentFolder, `${storyFileName}.tsx`)) || existsSync(join2(parentFolder, `${storyFileName}.js`)) || existsSync(join2(parentFolder, `${storyFileName}.jsx`));
|
|
839
|
-
}, "doesStoryFileExist");
|
|
619
|
+
}, doesStoryFileExist = (parentFolder, storyFileName) => existsSync(join2(parentFolder, `${storyFileName}.ts`)) || existsSync(join2(parentFolder, `${storyFileName}.tsx`)) || existsSync(join2(parentFolder, `${storyFileName}.js`)) || existsSync(join2(parentFolder, `${storyFileName}.jsx`));
|
|
840
620
|
|
|
841
621
|
// src/core-server/server-channel/create-new-story-channel.ts
|
|
842
622
|
function initCreateNewStoryChannel(channel, options, coreOptions) {
|
|
843
|
-
channel.on(
|
|
623
|
+
return channel.on(
|
|
844
624
|
CREATE_NEW_STORYFILE_REQUEST,
|
|
845
625
|
async (data) => {
|
|
846
626
|
try {
|
|
847
|
-
|
|
627
|
+
let { storyFilePath, exportedStoryName, storyFileContent } = await getNewStoryFile(
|
|
848
628
|
data.payload,
|
|
849
629
|
options
|
|
850
|
-
);
|
|
851
|
-
const relativeStoryFilePath = relative(process.cwd(), storyFilePath);
|
|
852
|
-
const { storyId, kind } = await getStoryId({ storyFilePath, exportedStoryName }, options);
|
|
630
|
+
), relativeStoryFilePath = relative(process.cwd(), storyFilePath), { storyId, kind } = await getStoryId({ storyFilePath, exportedStoryName }, options);
|
|
853
631
|
if (existsSync2(storyFilePath)) {
|
|
854
632
|
channel.emit(CREATE_NEW_STORYFILE_RESPONSE, {
|
|
855
|
-
success:
|
|
633
|
+
success: !1,
|
|
856
634
|
id: data.id,
|
|
857
635
|
payload: {
|
|
858
636
|
type: "STORY_FILE_EXISTS",
|
|
859
637
|
kind
|
|
860
638
|
},
|
|
861
639
|
error: `A story file already exists at ${relativeStoryFilePath}`
|
|
640
|
+
}), coreOptions.disableTelemetry || telemetry("create-new-story-file", {
|
|
641
|
+
success: !1,
|
|
642
|
+
error: "STORY_FILE_EXISTS"
|
|
862
643
|
});
|
|
863
|
-
if (!coreOptions.disableTelemetry) {
|
|
864
|
-
telemetry("create-new-story-file", {
|
|
865
|
-
success: false,
|
|
866
|
-
error: "STORY_FILE_EXISTS"
|
|
867
|
-
});
|
|
868
|
-
}
|
|
869
644
|
return;
|
|
870
645
|
}
|
|
871
|
-
await writeFile(storyFilePath, storyFileContent, "utf-8")
|
|
872
|
-
|
|
873
|
-
success: true,
|
|
646
|
+
await writeFile(storyFilePath, storyFileContent, "utf-8"), channel.emit(CREATE_NEW_STORYFILE_RESPONSE, {
|
|
647
|
+
success: !0,
|
|
874
648
|
id: data.id,
|
|
875
649
|
payload: {
|
|
876
650
|
storyId,
|
|
@@ -878,39 +652,27 @@ function initCreateNewStoryChannel(channel, options, coreOptions) {
|
|
|
878
652
|
exportedStoryName
|
|
879
653
|
},
|
|
880
654
|
error: null
|
|
655
|
+
}), coreOptions.disableTelemetry || telemetry("create-new-story-file", {
|
|
656
|
+
success: !0
|
|
881
657
|
});
|
|
882
|
-
if (!coreOptions.disableTelemetry) {
|
|
883
|
-
telemetry("create-new-story-file", {
|
|
884
|
-
success: true
|
|
885
|
-
});
|
|
886
|
-
}
|
|
887
658
|
} catch (e) {
|
|
888
659
|
channel.emit(CREATE_NEW_STORYFILE_RESPONSE, {
|
|
889
|
-
success:
|
|
660
|
+
success: !1,
|
|
890
661
|
id: data.id,
|
|
891
662
|
error: e?.message
|
|
663
|
+
}), coreOptions.disableTelemetry || await telemetry("create-new-story-file", {
|
|
664
|
+
success: !1,
|
|
665
|
+
error: e
|
|
892
666
|
});
|
|
893
|
-
if (!coreOptions.disableTelemetry) {
|
|
894
|
-
await telemetry("create-new-story-file", {
|
|
895
|
-
success: false,
|
|
896
|
-
error: e
|
|
897
|
-
});
|
|
898
|
-
}
|
|
899
667
|
}
|
|
900
668
|
}
|
|
901
|
-
);
|
|
902
|
-
return channel;
|
|
669
|
+
), channel;
|
|
903
670
|
}
|
|
904
|
-
__name(initCreateNewStoryChannel, "initCreateNewStoryChannel");
|
|
905
671
|
|
|
906
672
|
// src/core-server/server-channel/file-search-channel.ts
|
|
907
673
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
908
674
|
import { dirname as dirname2, join as join3 } from "node:path";
|
|
909
|
-
import {
|
|
910
|
-
extractProperRendererNameFromFramework,
|
|
911
|
-
getFrameworkName as getFrameworkName2,
|
|
912
|
-
getProjectRoot as getProjectRoot2
|
|
913
|
-
} from "storybook/internal/common";
|
|
675
|
+
import { extractRenderer, getFrameworkName as getFrameworkName2, getProjectRoot as getProjectRoot2 } from "storybook/internal/common";
|
|
914
676
|
import {
|
|
915
677
|
FILE_COMPONENT_SEARCH_REQUEST,
|
|
916
678
|
FILE_COMPONENT_SEARCH_RESPONSE
|
|
@@ -920,9 +682,6 @@ import { telemetry as telemetry2 } from "storybook/internal/telemetry";
|
|
|
920
682
|
// src/core-server/utils/parser/generic-parser.ts
|
|
921
683
|
import { parser, types as t } from "storybook/internal/babel";
|
|
922
684
|
var GenericParser = class {
|
|
923
|
-
static {
|
|
924
|
-
__name(this, "GenericParser");
|
|
925
|
-
}
|
|
926
685
|
/**
|
|
927
686
|
* Parse the content of a file and return the exports
|
|
928
687
|
*
|
|
@@ -930,12 +689,12 @@ var GenericParser = class {
|
|
|
930
689
|
* @returns The exports of the file
|
|
931
690
|
*/
|
|
932
691
|
async parse(content) {
|
|
933
|
-
|
|
934
|
-
allowImportExportEverywhere:
|
|
935
|
-
allowAwaitOutsideFunction:
|
|
936
|
-
allowNewTargetOutsideFunction:
|
|
937
|
-
allowReturnOutsideFunction:
|
|
938
|
-
allowUndeclaredExports:
|
|
692
|
+
let ast = parser.parse(content, {
|
|
693
|
+
allowImportExportEverywhere: !0,
|
|
694
|
+
allowAwaitOutsideFunction: !0,
|
|
695
|
+
allowNewTargetOutsideFunction: !0,
|
|
696
|
+
allowReturnOutsideFunction: !0,
|
|
697
|
+
allowUndeclaredExports: !0,
|
|
939
698
|
plugins: [
|
|
940
699
|
// Language features
|
|
941
700
|
"typescript",
|
|
@@ -979,65 +738,39 @@ var GenericParser = class {
|
|
|
979
738
|
"sourcePhaseImports",
|
|
980
739
|
"throwExpressions"
|
|
981
740
|
]
|
|
982
|
-
});
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
name: node.declaration.id.name,
|
|
995
|
-
default: false
|
|
996
|
-
});
|
|
997
|
-
}
|
|
998
|
-
if (node.declaration === null && node.specifiers.length > 0) {
|
|
999
|
-
node.specifiers.forEach((specifier) => {
|
|
1000
|
-
if (t.isExportSpecifier(specifier) && t.isIdentifier(specifier.exported)) {
|
|
1001
|
-
exports.push({
|
|
1002
|
-
name: specifier.exported.name,
|
|
1003
|
-
default: false
|
|
1004
|
-
});
|
|
1005
|
-
}
|
|
1006
|
-
});
|
|
1007
|
-
}
|
|
1008
|
-
if (t.isVariableDeclaration(node.declaration)) {
|
|
1009
|
-
node.declaration.declarations.forEach((declaration) => {
|
|
1010
|
-
if (t.isVariableDeclarator(declaration) && t.isIdentifier(declaration.id)) {
|
|
1011
|
-
exports.push({
|
|
1012
|
-
name: declaration.id.name,
|
|
1013
|
-
default: false
|
|
1014
|
-
});
|
|
1015
|
-
}
|
|
1016
|
-
});
|
|
1017
|
-
}
|
|
1018
|
-
} else if (t.isExportDefaultDeclaration(node)) {
|
|
1019
|
-
exports.push({
|
|
1020
|
-
name: "default",
|
|
1021
|
-
default: true
|
|
741
|
+
}), exports = [];
|
|
742
|
+
return ast.program.body.forEach(function(node) {
|
|
743
|
+
t.isExportNamedDeclaration(node) ? (t.isFunctionDeclaration(node.declaration) && t.isIdentifier(node.declaration.id) && exports.push({
|
|
744
|
+
name: node.declaration.id.name,
|
|
745
|
+
default: !1
|
|
746
|
+
}), t.isClassDeclaration(node.declaration) && t.isIdentifier(node.declaration.id) && exports.push({
|
|
747
|
+
name: node.declaration.id.name,
|
|
748
|
+
default: !1
|
|
749
|
+
}), node.declaration === null && node.specifiers.length > 0 && node.specifiers.forEach((specifier) => {
|
|
750
|
+
t.isExportSpecifier(specifier) && t.isIdentifier(specifier.exported) && exports.push({
|
|
751
|
+
name: specifier.exported.name,
|
|
752
|
+
default: !1
|
|
1022
753
|
});
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
|
|
754
|
+
}), t.isVariableDeclaration(node.declaration) && node.declaration.declarations.forEach((declaration) => {
|
|
755
|
+
t.isVariableDeclarator(declaration) && t.isIdentifier(declaration.id) && exports.push({
|
|
756
|
+
name: declaration.id.name,
|
|
757
|
+
default: !1
|
|
758
|
+
});
|
|
759
|
+
})) : t.isExportDefaultDeclaration(node) && exports.push({
|
|
760
|
+
name: "default",
|
|
761
|
+
default: !0
|
|
762
|
+
});
|
|
763
|
+
}), { exports };
|
|
1026
764
|
}
|
|
1027
765
|
};
|
|
1028
766
|
|
|
1029
767
|
// src/core-server/utils/parser/index.ts
|
|
1030
768
|
function getParser(renderer) {
|
|
1031
|
-
|
|
1032
|
-
default:
|
|
1033
|
-
return new GenericParser();
|
|
1034
|
-
}
|
|
769
|
+
return new GenericParser();
|
|
1035
770
|
}
|
|
1036
|
-
__name(getParser, "getParser");
|
|
1037
771
|
|
|
1038
772
|
// src/core-server/utils/search-files.ts
|
|
1039
|
-
var FILE_EXTENSIONS = ["js", "mjs", "cjs", "jsx", "mts", "ts", "tsx", "cts"]
|
|
1040
|
-
var IGNORED_FILES = [
|
|
773
|
+
var FILE_EXTENSIONS = ["js", "mjs", "cjs", "jsx", "mts", "ts", "tsx", "cts"], IGNORED_FILES = [
|
|
1041
774
|
"**/node_modules/**",
|
|
1042
775
|
"**/*.spec.*",
|
|
1043
776
|
"**/*.test.*",
|
|
@@ -1050,81 +783,58 @@ async function searchFiles({
|
|
|
1050
783
|
ignoredFiles = IGNORED_FILES,
|
|
1051
784
|
fileExtensions = FILE_EXTENSIONS
|
|
1052
785
|
}) {
|
|
1053
|
-
|
|
1054
|
-
const hasSearchSpecialGlobChars = isDynamicPattern(searchQuery, { cwd });
|
|
1055
|
-
const hasFileExtensionRegex = /(\.[a-z]+)$/i;
|
|
1056
|
-
const searchQueryHasExtension = hasFileExtensionRegex.test(searchQuery);
|
|
1057
|
-
const fileExtensionsPattern = `{${fileExtensions.join(",")}}`;
|
|
1058
|
-
const globbedSearchQuery = hasSearchSpecialGlobChars ? searchQuery : searchQueryHasExtension ? [`**/*${searchQuery}*`, `**/*${searchQuery}*/**`] : [
|
|
786
|
+
let { globby, isDynamicPattern } = await import("../../_node-chunks/globby-22GFCZQD.js"), hasSearchSpecialGlobChars = isDynamicPattern(searchQuery, { cwd }), searchQueryHasExtension = /(\.[a-z]+)$/i.test(searchQuery), fileExtensionsPattern = `{${fileExtensions.join(",")}}`, globbedSearchQuery = hasSearchSpecialGlobChars ? searchQuery : searchQueryHasExtension ? [`**/*${searchQuery}*`, `**/*${searchQuery}*/**`] : [
|
|
1059
787
|
`**/*${searchQuery}*.${fileExtensionsPattern}`,
|
|
1060
788
|
`**/*${searchQuery}*/**/*.${fileExtensionsPattern}`
|
|
1061
789
|
];
|
|
1062
|
-
|
|
790
|
+
return (await globby(globbedSearchQuery, {
|
|
1063
791
|
ignore: ignoredFiles,
|
|
1064
|
-
gitignore:
|
|
1065
|
-
caseSensitiveMatch:
|
|
792
|
+
gitignore: !0,
|
|
793
|
+
caseSensitiveMatch: !1,
|
|
1066
794
|
cwd,
|
|
1067
|
-
objectMode:
|
|
1068
|
-
});
|
|
1069
|
-
return entries.map((entry) => entry.path).filter((entry) => fileExtensions.some((ext) => entry.endsWith(`.${ext}`)));
|
|
795
|
+
objectMode: !0
|
|
796
|
+
})).map((entry) => entry.path).filter((entry) => fileExtensions.some((ext) => entry.endsWith(`.${ext}`)));
|
|
1070
797
|
}
|
|
1071
|
-
__name(searchFiles, "searchFiles");
|
|
1072
798
|
|
|
1073
799
|
// src/core-server/server-channel/file-search-channel.ts
|
|
1074
800
|
async function initFileSearchChannel(channel, options, coreOptions) {
|
|
1075
|
-
channel.on(
|
|
801
|
+
return channel.on(
|
|
1076
802
|
FILE_COMPONENT_SEARCH_REQUEST,
|
|
1077
803
|
async (data) => {
|
|
1078
|
-
|
|
804
|
+
let searchQuery = data.id;
|
|
1079
805
|
try {
|
|
1080
|
-
if (!searchQuery)
|
|
806
|
+
if (!searchQuery)
|
|
1081
807
|
return;
|
|
1082
|
-
|
|
1083
|
-
const frameworkName = await getFrameworkName2(options);
|
|
1084
|
-
const rendererName = await extractProperRendererNameFromFramework(
|
|
1085
|
-
frameworkName
|
|
1086
|
-
);
|
|
1087
|
-
const files = await searchFiles({
|
|
808
|
+
let frameworkName = await getFrameworkName2(options), rendererName = await extractRenderer(frameworkName), entries = (await searchFiles({
|
|
1088
809
|
searchQuery,
|
|
1089
810
|
cwd: getProjectRoot2()
|
|
1090
|
-
})
|
|
1091
|
-
|
|
1092
|
-
const parser3 = getParser(rendererName);
|
|
811
|
+
})).map(async (file) => {
|
|
812
|
+
let parser3 = getParser(rendererName);
|
|
1093
813
|
try {
|
|
1094
|
-
|
|
1095
|
-
const { storyFileName } = getStoryMetadata(join3(getProjectRoot2(), file));
|
|
1096
|
-
const dir = dirname2(file);
|
|
1097
|
-
const storyFileExists = doesStoryFileExist(join3(getProjectRoot2(), dir), storyFileName);
|
|
1098
|
-
const info = await parser3.parse(content);
|
|
814
|
+
let content = await readFile2(join3(getProjectRoot2(), file), "utf-8"), { storyFileName } = getStoryMetadata(join3(getProjectRoot2(), file)), dir = dirname2(file), storyFileExists = doesStoryFileExist(join3(getProjectRoot2(), dir), storyFileName), info = await parser3.parse(content);
|
|
1099
815
|
return {
|
|
1100
816
|
filepath: file,
|
|
1101
817
|
exportedComponents: info.exports,
|
|
1102
818
|
storyFileExists
|
|
1103
819
|
};
|
|
1104
820
|
} catch (e) {
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
});
|
|
1110
|
-
}
|
|
1111
|
-
return {
|
|
821
|
+
return coreOptions.disableTelemetry || telemetry2("create-new-story-file-search", {
|
|
822
|
+
success: !1,
|
|
823
|
+
error: `Could not parse file: ${e}`
|
|
824
|
+
}), {
|
|
1112
825
|
filepath: file,
|
|
1113
|
-
storyFileExists:
|
|
826
|
+
storyFileExists: !1,
|
|
1114
827
|
exportedComponents: null
|
|
1115
828
|
};
|
|
1116
829
|
}
|
|
1117
830
|
});
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
}
|
|
1126
|
-
channel.emit(FILE_COMPONENT_SEARCH_RESPONSE, {
|
|
1127
|
-
success: true,
|
|
831
|
+
coreOptions.disableTelemetry || telemetry2("create-new-story-file-search", {
|
|
832
|
+
success: !0,
|
|
833
|
+
payload: {
|
|
834
|
+
fileCount: entries.length
|
|
835
|
+
}
|
|
836
|
+
}), channel.emit(FILE_COMPONENT_SEARCH_RESPONSE, {
|
|
837
|
+
success: !0,
|
|
1128
838
|
id: searchQuery,
|
|
1129
839
|
payload: {
|
|
1130
840
|
files: await Promise.all(entries)
|
|
@@ -1133,104 +843,299 @@ async function initFileSearchChannel(channel, options, coreOptions) {
|
|
|
1133
843
|
});
|
|
1134
844
|
} catch (e) {
|
|
1135
845
|
channel.emit(FILE_COMPONENT_SEARCH_RESPONSE, {
|
|
1136
|
-
success:
|
|
846
|
+
success: !1,
|
|
1137
847
|
id: searchQuery ?? "",
|
|
1138
848
|
error: `An error occurred while searching for components in the project.
|
|
1139
849
|
${e?.message}`
|
|
850
|
+
}), coreOptions.disableTelemetry || telemetry2("create-new-story-file-search", {
|
|
851
|
+
success: !1,
|
|
852
|
+
error: `An error occured while searching for components: ${e}`
|
|
1140
853
|
});
|
|
1141
|
-
if (!coreOptions.disableTelemetry) {
|
|
1142
|
-
telemetry2("create-new-story-file-search", {
|
|
1143
|
-
success: false,
|
|
1144
|
-
error: `An error occured while searching for components: ${e}`
|
|
1145
|
-
});
|
|
1146
|
-
}
|
|
1147
854
|
}
|
|
1148
855
|
}
|
|
1149
|
-
);
|
|
1150
|
-
return channel;
|
|
856
|
+
), channel;
|
|
1151
857
|
}
|
|
1152
|
-
__name(initFileSearchChannel, "initFileSearchChannel");
|
|
1153
858
|
|
|
1154
859
|
// src/core-server/server-channel/open-in-editor-channel.ts
|
|
1155
860
|
var import_launch_editor = __toESM(require_launch_editor(), 1);
|
|
1156
861
|
import { OPEN_IN_EDITOR_REQUEST, OPEN_IN_EDITOR_RESPONSE } from "storybook/internal/core-events";
|
|
1157
862
|
import { telemetry as telemetry3 } from "storybook/internal/telemetry";
|
|
1158
863
|
async function initOpenInEditorChannel(channel, _options, coreOptions) {
|
|
1159
|
-
channel.on(OPEN_IN_EDITOR_REQUEST, async (payload) => {
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
}
|
|
1164
|
-
}, "sendTelemetry");
|
|
864
|
+
return channel.on(OPEN_IN_EDITOR_REQUEST, async (payload) => {
|
|
865
|
+
let sendTelemetry = (data) => {
|
|
866
|
+
coreOptions.disableTelemetry || telemetry3("open-in-editor", data);
|
|
867
|
+
};
|
|
1165
868
|
try {
|
|
1166
|
-
|
|
1167
|
-
if (!targetFile)
|
|
869
|
+
let { file: targetFile, line, column } = payload;
|
|
870
|
+
if (!targetFile)
|
|
1168
871
|
throw new Error("No file was provided to open");
|
|
1169
|
-
}
|
|
1170
|
-
const location = typeof line === "number" ? `${targetFile}:${line}${typeof column === "number" ? `:${column}` : ""}` : targetFile;
|
|
872
|
+
let location = typeof line == "number" ? `${targetFile}:${line}${typeof column == "number" ? `:${column}` : ""}` : targetFile;
|
|
1171
873
|
await new Promise((resolve, reject) => {
|
|
1172
874
|
(0, import_launch_editor.default)(location, void 0, (_fileName, errorMessage) => {
|
|
1173
|
-
|
|
1174
|
-
reject(new Error(errorMessage));
|
|
1175
|
-
} else {
|
|
1176
|
-
resolve();
|
|
1177
|
-
}
|
|
875
|
+
errorMessage ? reject(new Error(errorMessage)) : resolve();
|
|
1178
876
|
});
|
|
1179
|
-
})
|
|
1180
|
-
channel.emit(OPEN_IN_EDITOR_RESPONSE, {
|
|
877
|
+
}), channel.emit(OPEN_IN_EDITOR_RESPONSE, {
|
|
1181
878
|
file: targetFile,
|
|
1182
879
|
line,
|
|
1183
880
|
column,
|
|
1184
881
|
error: null
|
|
1185
|
-
});
|
|
1186
|
-
sendTelemetry({ success: true });
|
|
882
|
+
}), sendTelemetry({ success: !0 });
|
|
1187
883
|
} catch (e) {
|
|
1188
|
-
|
|
884
|
+
let error = e?.message || "Failed to open in editor";
|
|
1189
885
|
channel.emit(OPEN_IN_EDITOR_RESPONSE, {
|
|
1190
886
|
error,
|
|
1191
887
|
...payload
|
|
1192
|
-
});
|
|
1193
|
-
sendTelemetry({ success: false, error });
|
|
888
|
+
}), sendTelemetry({ success: !1, error });
|
|
1194
889
|
}
|
|
1195
|
-
});
|
|
1196
|
-
return channel;
|
|
890
|
+
}), channel;
|
|
1197
891
|
}
|
|
1198
|
-
__name(initOpenInEditorChannel, "initOpenInEditorChannel");
|
|
1199
892
|
|
|
1200
893
|
// src/core-server/server-channel/preview-initialized-channel.ts
|
|
1201
894
|
import { PREVIEW_INITIALIZED } from "storybook/internal/core-events";
|
|
1202
895
|
import { telemetry as telemetry4 } from "storybook/internal/telemetry";
|
|
1203
|
-
var makePayload =
|
|
1204
|
-
let
|
|
1205
|
-
const payload = {
|
|
896
|
+
var makePayload = (userAgent, lastInit, sessionId) => {
|
|
897
|
+
let payload = {
|
|
1206
898
|
userAgent,
|
|
1207
|
-
isNewUser:
|
|
1208
|
-
timeSinceInit
|
|
899
|
+
isNewUser: !1,
|
|
900
|
+
timeSinceInit: void 0
|
|
1209
901
|
};
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
payload.isNewUser = !!lastInit.body.payload.newUser;
|
|
1213
|
-
}
|
|
1214
|
-
return payload;
|
|
1215
|
-
}, "makePayload");
|
|
902
|
+
return sessionId && lastInit?.body?.sessionId === sessionId && (payload.timeSinceInit = Date.now() - lastInit.timestamp, payload.isNewUser = !!lastInit.body.payload.newUser), payload;
|
|
903
|
+
};
|
|
1216
904
|
function initPreviewInitializedChannel(channel, options, _coreConfig) {
|
|
1217
905
|
channel.on(PREVIEW_INITIALIZED, async ({ userAgent }) => {
|
|
1218
|
-
if (!options.disableTelemetry)
|
|
906
|
+
if (!options.disableTelemetry)
|
|
1219
907
|
try {
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
const lastPreviewFirstLoad = lastEvents["preview-first-load"];
|
|
1224
|
-
if (!lastPreviewFirstLoad) {
|
|
1225
|
-
const payload = makePayload(userAgent, lastInit, sessionId);
|
|
908
|
+
let sessionId = await getSessionId(), lastEvents = await getLastEvents(), lastInit = lastEvents.init;
|
|
909
|
+
if (!lastEvents["preview-first-load"]) {
|
|
910
|
+
let payload = makePayload(userAgent, lastInit, sessionId);
|
|
1226
911
|
telemetry4("preview-first-load", payload);
|
|
1227
912
|
}
|
|
1228
|
-
} catch
|
|
913
|
+
} catch {
|
|
1229
914
|
}
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
// src/core-server/utils/checklist.ts
|
|
919
|
+
import { createFileSystemCache, resolvePathInStorybookCache } from "storybook/internal/common";
|
|
920
|
+
import { experimental_UniversalStore } from "storybook/internal/core-server";
|
|
921
|
+
import { logger } from "storybook/internal/node-logger";
|
|
922
|
+
import { telemetry as telemetry5 } from "storybook/internal/telemetry";
|
|
923
|
+
|
|
924
|
+
// ../node_modules/dequal/dist/index.mjs
|
|
925
|
+
var has = Object.prototype.hasOwnProperty;
|
|
926
|
+
function find(iter, tar, key) {
|
|
927
|
+
for (key of iter.keys())
|
|
928
|
+
if (dequal(key, tar)) return key;
|
|
929
|
+
}
|
|
930
|
+
function dequal(foo, bar) {
|
|
931
|
+
var ctor, len, tmp;
|
|
932
|
+
if (foo === bar) return !0;
|
|
933
|
+
if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
|
|
934
|
+
if (ctor === Date) return foo.getTime() === bar.getTime();
|
|
935
|
+
if (ctor === RegExp) return foo.toString() === bar.toString();
|
|
936
|
+
if (ctor === Array) {
|
|
937
|
+
if ((len = foo.length) === bar.length)
|
|
938
|
+
for (; len-- && dequal(foo[len], bar[len]); ) ;
|
|
939
|
+
return len === -1;
|
|
940
|
+
}
|
|
941
|
+
if (ctor === Set) {
|
|
942
|
+
if (foo.size !== bar.size)
|
|
943
|
+
return !1;
|
|
944
|
+
for (len of foo)
|
|
945
|
+
if (tmp = len, tmp && typeof tmp == "object" && (tmp = find(bar, tmp), !tmp) || !bar.has(tmp)) return !1;
|
|
946
|
+
return !0;
|
|
947
|
+
}
|
|
948
|
+
if (ctor === Map) {
|
|
949
|
+
if (foo.size !== bar.size)
|
|
950
|
+
return !1;
|
|
951
|
+
for (len of foo)
|
|
952
|
+
if (tmp = len[0], tmp && typeof tmp == "object" && (tmp = find(bar, tmp), !tmp) || !dequal(len[1], bar.get(tmp)))
|
|
953
|
+
return !1;
|
|
954
|
+
return !0;
|
|
955
|
+
}
|
|
956
|
+
if (ctor === ArrayBuffer)
|
|
957
|
+
foo = new Uint8Array(foo), bar = new Uint8Array(bar);
|
|
958
|
+
else if (ctor === DataView) {
|
|
959
|
+
if ((len = foo.byteLength) === bar.byteLength)
|
|
960
|
+
for (; len-- && foo.getInt8(len) === bar.getInt8(len); ) ;
|
|
961
|
+
return len === -1;
|
|
962
|
+
}
|
|
963
|
+
if (ArrayBuffer.isView(foo)) {
|
|
964
|
+
if ((len = foo.byteLength) === bar.byteLength)
|
|
965
|
+
for (; len-- && foo[len] === bar[len]; ) ;
|
|
966
|
+
return len === -1;
|
|
967
|
+
}
|
|
968
|
+
if (!ctor || typeof foo == "object") {
|
|
969
|
+
len = 0;
|
|
970
|
+
for (ctor in foo)
|
|
971
|
+
if (has.call(foo, ctor) && ++len && !has.call(bar, ctor) || !(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return !1;
|
|
972
|
+
return Object.keys(bar).length === len;
|
|
1230
973
|
}
|
|
974
|
+
}
|
|
975
|
+
return foo !== foo && bar !== bar;
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
// ../node_modules/es-toolkit/dist/predicate/isPrimitive.mjs
|
|
979
|
+
function isPrimitive(value) {
|
|
980
|
+
return value == null || typeof value != "object" && typeof value != "function";
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
// ../node_modules/es-toolkit/dist/predicate/isTypedArray.mjs
|
|
984
|
+
function isTypedArray(x) {
|
|
985
|
+
return ArrayBuffer.isView(x) && !(x instanceof DataView);
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
// ../node_modules/es-toolkit/dist/object/clone.mjs
|
|
989
|
+
function clone(obj) {
|
|
990
|
+
if (isPrimitive(obj))
|
|
991
|
+
return obj;
|
|
992
|
+
if (Array.isArray(obj) || isTypedArray(obj) || obj instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && obj instanceof SharedArrayBuffer)
|
|
993
|
+
return obj.slice(0);
|
|
994
|
+
let prototype = Object.getPrototypeOf(obj), Constructor = prototype.constructor;
|
|
995
|
+
if (obj instanceof Date || obj instanceof Map || obj instanceof Set)
|
|
996
|
+
return new Constructor(obj);
|
|
997
|
+
if (obj instanceof RegExp) {
|
|
998
|
+
let newRegExp = new Constructor(obj);
|
|
999
|
+
return newRegExp.lastIndex = obj.lastIndex, newRegExp;
|
|
1000
|
+
}
|
|
1001
|
+
if (obj instanceof DataView)
|
|
1002
|
+
return new Constructor(obj.buffer.slice(0));
|
|
1003
|
+
if (obj instanceof Error) {
|
|
1004
|
+
let newError = new Constructor(obj.message);
|
|
1005
|
+
return newError.stack = obj.stack, newError.name = obj.name, newError.cause = obj.cause, newError;
|
|
1006
|
+
}
|
|
1007
|
+
if (typeof File < "u" && obj instanceof File)
|
|
1008
|
+
return new Constructor([obj], obj.name, { type: obj.type, lastModified: obj.lastModified });
|
|
1009
|
+
if (typeof obj == "object") {
|
|
1010
|
+
let newObject = Object.create(prototype);
|
|
1011
|
+
return Object.assign(newObject, obj);
|
|
1012
|
+
}
|
|
1013
|
+
return obj;
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
// ../node_modules/es-toolkit/dist/predicate/isPlainObject.mjs
|
|
1017
|
+
function isPlainObject(value) {
|
|
1018
|
+
if (!value || typeof value != "object")
|
|
1019
|
+
return !1;
|
|
1020
|
+
let proto = Object.getPrototypeOf(value);
|
|
1021
|
+
return proto === null || proto === Object.prototype || Object.getPrototypeOf(proto) === null ? Object.prototype.toString.call(value) === "[object Object]" : !1;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
// ../node_modules/es-toolkit/dist/_internal/isUnsafeProperty.mjs
|
|
1025
|
+
function isUnsafeProperty(key) {
|
|
1026
|
+
return key === "__proto__";
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
// ../node_modules/es-toolkit/dist/object/mergeWith.mjs
|
|
1030
|
+
function mergeWith(target, source, merge2) {
|
|
1031
|
+
let sourceKeys = Object.keys(source);
|
|
1032
|
+
for (let i = 0; i < sourceKeys.length; i++) {
|
|
1033
|
+
let key = sourceKeys[i];
|
|
1034
|
+
if (isUnsafeProperty(key))
|
|
1035
|
+
continue;
|
|
1036
|
+
let sourceValue = source[key], targetValue = target[key], merged = merge2(targetValue, sourceValue, key, target, source);
|
|
1037
|
+
merged !== void 0 ? target[key] = merged : Array.isArray(sourceValue) ? Array.isArray(targetValue) ? target[key] = mergeWith(targetValue, sourceValue, merge2) : target[key] = mergeWith([], sourceValue, merge2) : isPlainObject(sourceValue) ? isPlainObject(targetValue) ? target[key] = mergeWith(targetValue, sourceValue, merge2) : target[key] = mergeWith({}, sourceValue, merge2) : (targetValue === void 0 || sourceValue !== void 0) && (target[key] = sourceValue);
|
|
1038
|
+
}
|
|
1039
|
+
return target;
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
// ../node_modules/es-toolkit/dist/string/words.mjs
|
|
1043
|
+
var CASE_SPLIT_PATTERN = new RegExp("\\p{Lu}?\\p{Ll}+|[0-9]+|\\p{Lu}+(?!\\p{Ll})|\\p{Emoji_Presentation}|\\p{Extended_Pictographic}|\\p{L}+", "gu");
|
|
1044
|
+
|
|
1045
|
+
// ../node_modules/es-toolkit/dist/object/toMerged.mjs
|
|
1046
|
+
function toMerged(target, source) {
|
|
1047
|
+
return mergeWith(clone(target), source, function mergeRecursively(targetValue, sourceValue) {
|
|
1048
|
+
if (Array.isArray(sourceValue))
|
|
1049
|
+
return Array.isArray(targetValue) ? mergeWith(clone(targetValue), sourceValue, mergeRecursively) : mergeWith([], sourceValue, mergeRecursively);
|
|
1050
|
+
if (isPlainObject(sourceValue))
|
|
1051
|
+
return isPlainObject(targetValue) ? mergeWith(clone(targetValue), sourceValue, mergeRecursively) : mergeWith({}, sourceValue, mergeRecursively);
|
|
1231
1052
|
});
|
|
1232
1053
|
}
|
|
1233
|
-
|
|
1054
|
+
|
|
1055
|
+
// src/shared/checklist-store/checklistData.state.ts
|
|
1056
|
+
var initialState = {
|
|
1057
|
+
items: {
|
|
1058
|
+
accessibilityTests: { status: "open" },
|
|
1059
|
+
autodocs: { status: "open" },
|
|
1060
|
+
ciTests: { status: "open" },
|
|
1061
|
+
controls: { status: "open" },
|
|
1062
|
+
coverage: { status: "open" },
|
|
1063
|
+
guidedTour: { status: "open" },
|
|
1064
|
+
installA11y: { status: "open" },
|
|
1065
|
+
installChromatic: { status: "open" },
|
|
1066
|
+
installDocs: { status: "open" },
|
|
1067
|
+
installVitest: { status: "open" },
|
|
1068
|
+
mdxDocs: { status: "open" },
|
|
1069
|
+
moreComponents: { status: "open" },
|
|
1070
|
+
moreStories: { status: "open" },
|
|
1071
|
+
onboardingSurvey: { status: "open" },
|
|
1072
|
+
organizeStories: { status: "open" },
|
|
1073
|
+
publishStorybook: { status: "open" },
|
|
1074
|
+
renderComponent: { status: "open" },
|
|
1075
|
+
runTests: { status: "open" },
|
|
1076
|
+
viewports: { status: "open" },
|
|
1077
|
+
visualTests: { status: "open" },
|
|
1078
|
+
whatsNewStorybook10: { status: "open" },
|
|
1079
|
+
writeInteractions: { status: "open" }
|
|
1080
|
+
},
|
|
1081
|
+
widget: {}
|
|
1082
|
+
};
|
|
1083
|
+
|
|
1084
|
+
// src/shared/checklist-store/index.ts
|
|
1085
|
+
var UNIVERSAL_CHECKLIST_STORE_OPTIONS = {
|
|
1086
|
+
id: "storybook/checklist",
|
|
1087
|
+
initialState
|
|
1088
|
+
};
|
|
1089
|
+
|
|
1090
|
+
// src/core-server/utils/checklist.ts
|
|
1091
|
+
async function initializeChecklist() {
|
|
1092
|
+
try {
|
|
1093
|
+
let store = experimental_UniversalStore.create({
|
|
1094
|
+
...UNIVERSAL_CHECKLIST_STORE_OPTIONS,
|
|
1095
|
+
leader: !0
|
|
1096
|
+
}), cache = createFileSystemCache({
|
|
1097
|
+
basePath: resolvePathInStorybookCache("checklist"),
|
|
1098
|
+
ns: "storybook"
|
|
1099
|
+
}), [[userState, saveUserState], [projectState, saveProjectState]] = await Promise.all([
|
|
1100
|
+
globalSettings().then((settings) => {
|
|
1101
|
+
let save = throttle(() => settings.save(), 1e3), state = {
|
|
1102
|
+
items: settings.value.checklist?.items ?? {},
|
|
1103
|
+
widget: settings.value.checklist?.widget ?? {}
|
|
1104
|
+
};
|
|
1105
|
+
return [state, ({
|
|
1106
|
+
items = state.items,
|
|
1107
|
+
widget = state.widget
|
|
1108
|
+
}) => {
|
|
1109
|
+
settings.value.checklist = { items, widget }, save();
|
|
1110
|
+
}];
|
|
1111
|
+
}),
|
|
1112
|
+
cache.get("state").then((cachedState) => [{ items: cachedState?.items ?? {} }, ({ items }) => cache.set("state", { items })])
|
|
1113
|
+
]);
|
|
1114
|
+
store.setState(
|
|
1115
|
+
(value) => ({
|
|
1116
|
+
...toMerged(value, toMerged(userState, projectState)),
|
|
1117
|
+
loaded: !0
|
|
1118
|
+
})
|
|
1119
|
+
), store.onStateChange((state, previousState) => {
|
|
1120
|
+
let projectValues = {}, userValues = {};
|
|
1121
|
+
Object.entries(state.items).forEach(([id, { status, mutedAt }]) => {
|
|
1122
|
+
status === "done" ? projectValues[id] = { status } : (status === "accepted" || status === "skipped") && (userValues[id] = { status }), mutedAt && (userValues[id] = {
|
|
1123
|
+
...userValues[id],
|
|
1124
|
+
mutedAt
|
|
1125
|
+
});
|
|
1126
|
+
}), saveProjectState({ items: projectValues }), saveUserState({ items: userValues, widget: state.widget });
|
|
1127
|
+
let changedValues = Object.entries(state.items).filter(
|
|
1128
|
+
([key, value]) => value !== previousState.items[key]
|
|
1129
|
+
);
|
|
1130
|
+
telemetry5("onboarding-checklist", {
|
|
1131
|
+
...changedValues.length > 0 ? { items: Object.fromEntries(changedValues) } : {},
|
|
1132
|
+
...dequal(state.widget, previousState.widget) ? {} : { widget: state.widget }
|
|
1133
|
+
});
|
|
1134
|
+
});
|
|
1135
|
+
} catch (err) {
|
|
1136
|
+
logger.error("Failed to initialize checklist"), logger.error(err);
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1234
1139
|
|
|
1235
1140
|
// src/core-server/utils/constants.ts
|
|
1236
1141
|
var defaultStaticDirs = [
|
|
@@ -1238,8 +1143,7 @@ var defaultStaticDirs = [
|
|
|
1238
1143
|
from: join(resolvePackageDir("storybook"), "assets/browser"),
|
|
1239
1144
|
to: "/sb-common-assets"
|
|
1240
1145
|
}
|
|
1241
|
-
];
|
|
1242
|
-
var defaultFavicon = join(resolvePackageDir("storybook"), "assets/browser/favicon.svg");
|
|
1146
|
+
], defaultFavicon = join(resolvePackageDir("storybook"), "assets/browser/favicon.svg");
|
|
1243
1147
|
|
|
1244
1148
|
// src/core-server/utils/save-story/save-story.ts
|
|
1245
1149
|
import { writeFile as writeFile2 } from "node:fs/promises";
|
|
@@ -1252,59 +1156,42 @@ import {
|
|
|
1252
1156
|
} from "storybook/internal/core-events";
|
|
1253
1157
|
import { storyNameFromExport, toId } from "storybook/internal/csf";
|
|
1254
1158
|
import { printCsf, readCsf } from "storybook/internal/csf-tools";
|
|
1255
|
-
import { logger } from "storybook/internal/node-logger";
|
|
1256
|
-
import { isExampleStoryId, telemetry as
|
|
1159
|
+
import { logger as logger2 } from "storybook/internal/node-logger";
|
|
1160
|
+
import { isExampleStoryId, telemetry as telemetry6 } from "storybook/internal/telemetry";
|
|
1257
1161
|
|
|
1258
1162
|
// src/core-server/utils/save-story/duplicate-story-with-new-name.ts
|
|
1259
1163
|
import { types as t2, traverse } from "storybook/internal/babel";
|
|
1260
1164
|
|
|
1261
1165
|
// src/core-server/utils/save-story/utils.ts
|
|
1262
1166
|
var SaveStoryError = class extends Error {
|
|
1263
|
-
static {
|
|
1264
|
-
__name(this, "SaveStoryError");
|
|
1265
|
-
}
|
|
1266
1167
|
};
|
|
1267
1168
|
|
|
1268
1169
|
// src/core-server/utils/save-story/duplicate-story-with-new-name.ts
|
|
1269
|
-
var duplicateStoryWithNewName =
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
let found = false;
|
|
1276
|
-
traverse(cloned, {
|
|
1170
|
+
var duplicateStoryWithNewName = (csfFile, storyName, newStoryName) => {
|
|
1171
|
+
let node = csfFile._storyExports[storyName], cloned = t2.cloneNode(node);
|
|
1172
|
+
if (!cloned)
|
|
1173
|
+
throw new SaveStoryError("cannot clone Node");
|
|
1174
|
+
let found = !1;
|
|
1175
|
+
if (traverse(cloned, {
|
|
1277
1176
|
Identifier(path) {
|
|
1278
|
-
|
|
1279
|
-
return;
|
|
1280
|
-
}
|
|
1281
|
-
if (path.node.name === storyName) {
|
|
1282
|
-
found = true;
|
|
1283
|
-
path.node.name = newStoryName;
|
|
1284
|
-
}
|
|
1177
|
+
found || path.node.name === storyName && (found = !0, path.node.name = newStoryName);
|
|
1285
1178
|
},
|
|
1286
1179
|
ObjectProperty(path) {
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
path.remove();
|
|
1290
|
-
}
|
|
1180
|
+
let key = path.get("key");
|
|
1181
|
+
key.isIdentifier() && key.node.name === "args" && path.remove();
|
|
1291
1182
|
},
|
|
1292
|
-
noScope:
|
|
1293
|
-
})
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
throw new SaveStoryError(`Creating a new story based on a CSF2 story is not supported`);
|
|
1297
|
-
}
|
|
1298
|
-
traverse(csfFile._ast, {
|
|
1183
|
+
noScope: !0
|
|
1184
|
+
}), !(t2.isCallExpression(cloned.init) && t2.isMemberExpression(cloned.init.callee) && t2.isIdentifier(cloned.init.callee.property) && cloned.init.callee.property.name === "story") && (t2.isArrowFunctionExpression(cloned.init) || t2.isCallExpression(cloned.init)))
|
|
1185
|
+
throw new SaveStoryError("Creating a new story based on a CSF2 story is not supported");
|
|
1186
|
+
return traverse(csfFile._ast, {
|
|
1299
1187
|
Program(path) {
|
|
1300
1188
|
path.pushContainer(
|
|
1301
1189
|
"body",
|
|
1302
1190
|
t2.exportNamedDeclaration(t2.variableDeclaration("const", [cloned]))
|
|
1303
1191
|
);
|
|
1304
1192
|
}
|
|
1305
|
-
});
|
|
1306
|
-
|
|
1307
|
-
}, "duplicateStoryWithNewName");
|
|
1193
|
+
}), cloned;
|
|
1194
|
+
};
|
|
1308
1195
|
|
|
1309
1196
|
// src/core-server/utils/save-story/update-args-in-csf-file.ts
|
|
1310
1197
|
import { types as t4, traverse as traverse2 } from "storybook/internal/babel";
|
|
@@ -1312,16 +1199,14 @@ import { types as t4, traverse as traverse2 } from "storybook/internal/babel";
|
|
|
1312
1199
|
// src/core-server/utils/save-story/valueToAST.ts
|
|
1313
1200
|
import { parser as parser2, types as t3 } from "storybook/internal/babel";
|
|
1314
1201
|
function valueToAST(literal) {
|
|
1315
|
-
if (literal === null)
|
|
1202
|
+
if (literal === null)
|
|
1316
1203
|
return t3.nullLiteral();
|
|
1317
|
-
}
|
|
1318
1204
|
switch (typeof literal) {
|
|
1319
1205
|
case "function":
|
|
1320
|
-
|
|
1321
|
-
allowReturnOutsideFunction:
|
|
1322
|
-
allowSuperOutsideMethod:
|
|
1323
|
-
});
|
|
1324
|
-
return ast.program.body[0]?.expression;
|
|
1206
|
+
return parser2.parse(literal.toString(), {
|
|
1207
|
+
allowReturnOutsideFunction: !0,
|
|
1208
|
+
allowSuperOutsideMethod: !0
|
|
1209
|
+
}).program.body[0]?.expression;
|
|
1325
1210
|
case "number":
|
|
1326
1211
|
return t3.numericLiteral(literal);
|
|
1327
1212
|
case "string":
|
|
@@ -1331,65 +1216,47 @@ function valueToAST(literal) {
|
|
|
1331
1216
|
case "undefined":
|
|
1332
1217
|
return t3.identifier("undefined");
|
|
1333
1218
|
default:
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
return t3.objectExpression(
|
|
1338
|
-
Object.keys(literal).filter((k) => {
|
|
1339
|
-
const value = literal[k];
|
|
1340
|
-
return typeof value !== "undefined";
|
|
1341
|
-
}).map((k) => {
|
|
1342
|
-
const value = literal[k];
|
|
1219
|
+
return Array.isArray(literal) ? t3.arrayExpression(literal.map(valueToAST)) : t3.objectExpression(
|
|
1220
|
+
Object.keys(literal).filter((k) => typeof literal[k] < "u").map((k) => {
|
|
1221
|
+
let value = literal[k];
|
|
1343
1222
|
return t3.objectProperty(t3.stringLiteral(k), valueToAST(value));
|
|
1344
1223
|
})
|
|
1345
1224
|
);
|
|
1346
1225
|
}
|
|
1347
1226
|
}
|
|
1348
|
-
__name(valueToAST, "valueToAST");
|
|
1349
1227
|
|
|
1350
1228
|
// src/core-server/utils/save-story/update-args-in-csf-file.ts
|
|
1351
|
-
var updateArgsInCsfFile =
|
|
1352
|
-
let found =
|
|
1353
|
-
|
|
1354
|
-
Object.entries(input).map(([k, v]) => {
|
|
1355
|
-
return [k, valueToAST(v)];
|
|
1356
|
-
})
|
|
1229
|
+
var updateArgsInCsfFile = async (node, input) => {
|
|
1230
|
+
let found = !1, args = Object.fromEntries(
|
|
1231
|
+
Object.entries(input).map(([k, v]) => [k, valueToAST(v)])
|
|
1357
1232
|
);
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
throw new SaveStoryError(`Updating a CSF2 story is not supported`);
|
|
1361
|
-
}
|
|
1233
|
+
if (!(t4.isCallExpression(node) && t4.isMemberExpression(node.callee) && t4.isIdentifier(node.callee.property) && node.callee.property.name === "story") && (t4.isArrowFunctionExpression(node) || t4.isCallExpression(node)))
|
|
1234
|
+
throw new SaveStoryError("Updating a CSF2 story is not supported");
|
|
1362
1235
|
if (t4.isObjectExpression(node)) {
|
|
1363
|
-
|
|
1364
|
-
const argsProperty = properties.find((property) => {
|
|
1236
|
+
let properties = node.properties, argsProperty = properties.find((property) => {
|
|
1365
1237
|
if (t4.isObjectProperty(property)) {
|
|
1366
|
-
|
|
1238
|
+
let key = property.key;
|
|
1367
1239
|
return t4.isIdentifier(key) && key.name === "args";
|
|
1368
1240
|
}
|
|
1369
|
-
return
|
|
1241
|
+
return !1;
|
|
1370
1242
|
});
|
|
1371
1243
|
if (argsProperty) {
|
|
1372
1244
|
if (t4.isObjectProperty(argsProperty)) {
|
|
1373
|
-
|
|
1245
|
+
let a = argsProperty.value;
|
|
1374
1246
|
if (t4.isObjectExpression(a)) {
|
|
1375
1247
|
a.properties.forEach((p) => {
|
|
1376
1248
|
if (t4.isObjectProperty(p)) {
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
p.value = args[key.name];
|
|
1380
|
-
delete args[key.name];
|
|
1381
|
-
}
|
|
1249
|
+
let key = p.key;
|
|
1250
|
+
t4.isIdentifier(key) && key.name in args && (p.value = args[key.name], delete args[key.name]);
|
|
1382
1251
|
}
|
|
1383
1252
|
});
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
});
|
|
1389
|
-
}
|
|
1253
|
+
let remainder = Object.entries(args);
|
|
1254
|
+
Object.keys(args).length && remainder.forEach(([key, value]) => {
|
|
1255
|
+
a.properties.push(t4.objectProperty(t4.identifier(key), value));
|
|
1256
|
+
});
|
|
1390
1257
|
}
|
|
1391
1258
|
}
|
|
1392
|
-
} else
|
|
1259
|
+
} else
|
|
1393
1260
|
properties.unshift(
|
|
1394
1261
|
t4.objectProperty(
|
|
1395
1262
|
t4.identifier("args"),
|
|
@@ -1398,46 +1265,38 @@ var updateArgsInCsfFile = /* @__PURE__ */ __name(async (node, input) => {
|
|
|
1398
1265
|
)
|
|
1399
1266
|
)
|
|
1400
1267
|
);
|
|
1401
|
-
}
|
|
1402
1268
|
return;
|
|
1403
1269
|
}
|
|
1404
1270
|
traverse2(node, {
|
|
1405
1271
|
ObjectExpression(path) {
|
|
1406
|
-
if (found)
|
|
1272
|
+
if (found)
|
|
1407
1273
|
return;
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
const properties = path.get("properties");
|
|
1411
|
-
const argsProperty = properties.find((property) => {
|
|
1274
|
+
found = !0;
|
|
1275
|
+
let argsProperty = path.get("properties").find((property) => {
|
|
1412
1276
|
if (property.isObjectProperty()) {
|
|
1413
|
-
|
|
1277
|
+
let key = property.get("key");
|
|
1414
1278
|
return key.isIdentifier() && key.node.name === "args";
|
|
1415
1279
|
}
|
|
1416
|
-
return
|
|
1280
|
+
return !1;
|
|
1417
1281
|
});
|
|
1418
1282
|
if (argsProperty) {
|
|
1419
1283
|
if (argsProperty.isObjectProperty()) {
|
|
1420
|
-
|
|
1284
|
+
let a = argsProperty.get("value");
|
|
1421
1285
|
if (a.isObjectExpression()) {
|
|
1422
1286
|
a.traverse({
|
|
1423
1287
|
ObjectProperty(p) {
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
p.get("value").replaceWith(args[key.node.name]);
|
|
1427
|
-
delete args[key.node.name];
|
|
1428
|
-
}
|
|
1288
|
+
let key = p.get("key");
|
|
1289
|
+
key.isIdentifier() && key.node.name in args && (p.get("value").replaceWith(args[key.node.name]), delete args[key.node.name]);
|
|
1429
1290
|
},
|
|
1430
|
-
noScope:
|
|
1291
|
+
noScope: !0
|
|
1292
|
+
});
|
|
1293
|
+
let remainder = Object.entries(args);
|
|
1294
|
+
Object.keys(args).length && remainder.forEach(([key, value]) => {
|
|
1295
|
+
a.pushContainer("properties", t4.objectProperty(t4.identifier(key), value));
|
|
1431
1296
|
});
|
|
1432
|
-
const remainder = Object.entries(args);
|
|
1433
|
-
if (Object.keys(args).length) {
|
|
1434
|
-
remainder.forEach(([key, value]) => {
|
|
1435
|
-
a.pushContainer("properties", t4.objectProperty(t4.identifier(key), value));
|
|
1436
|
-
});
|
|
1437
|
-
}
|
|
1438
1297
|
}
|
|
1439
1298
|
}
|
|
1440
|
-
} else
|
|
1299
|
+
} else
|
|
1441
1300
|
path.unshiftContainer(
|
|
1442
1301
|
"properties",
|
|
1443
1302
|
t4.objectProperty(
|
|
@@ -1447,77 +1306,51 @@ var updateArgsInCsfFile = /* @__PURE__ */ __name(async (node, input) => {
|
|
|
1447
1306
|
)
|
|
1448
1307
|
)
|
|
1449
1308
|
);
|
|
1450
|
-
}
|
|
1451
1309
|
},
|
|
1452
|
-
noScope:
|
|
1310
|
+
noScope: !0
|
|
1453
1311
|
});
|
|
1454
|
-
}
|
|
1312
|
+
};
|
|
1455
1313
|
|
|
1456
1314
|
// src/core-server/utils/save-story/save-story.ts
|
|
1457
|
-
var parseArgs =
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
};
|
|
1461
|
-
}
|
|
1462
|
-
return value;
|
|
1463
|
-
}), "parseArgs");
|
|
1464
|
-
var removeExtraNewlines = /* @__PURE__ */ __name((code, name) => {
|
|
1465
|
-
const anything = "([\\s\\S])";
|
|
1466
|
-
const newline = "(\\r\\n|\\r|\\n)";
|
|
1467
|
-
const closing = newline + "};" + newline;
|
|
1468
|
-
const regex = new RegExp(
|
|
1315
|
+
var parseArgs = (args) => JSON.parse(args, (_, value) => value === "__sb_empty_function_arg__" ? () => {
|
|
1316
|
+
} : value), removeExtraNewlines = (code, name) => {
|
|
1317
|
+
let anything = "([\\s\\S])", newline = "(\\r\\n|\\r|\\n)", closing = newline + "};" + newline, regex = new RegExp(
|
|
1469
1318
|
// Looks for an export by the given name, considers the first closing brace on its own line
|
|
1470
1319
|
// to be the end of the story definition.
|
|
1471
1320
|
`^(?<before>${anything}*)(?<story>export const ${name} =${anything}+?${closing})(?<after>${anything}*)$`
|
|
1472
|
-
);
|
|
1473
|
-
const { before, story, after } = code.match(regex)?.groups || {};
|
|
1321
|
+
), { before, story, after } = code.match(regex)?.groups || {};
|
|
1474
1322
|
return story ? before + story.replaceAll(/(\r\n|\r|\n)(\r\n|\r|\n)([ \t]*[a-z0-9_]+): /gi, "$2$3:") + after : code;
|
|
1475
|
-
}
|
|
1323
|
+
};
|
|
1476
1324
|
function initializeSaveStory(channel, options, coreConfig) {
|
|
1477
1325
|
channel.on(SAVE_STORY_REQUEST, async ({ id, payload }) => {
|
|
1478
|
-
|
|
1479
|
-
let newStoryId;
|
|
1480
|
-
let newStoryName;
|
|
1481
|
-
let sourceFileName;
|
|
1482
|
-
let sourceFilePath;
|
|
1483
|
-
let sourceStoryName;
|
|
1326
|
+
let { csfId, importPath, args, name } = payload, newStoryId, newStoryName, sourceFileName, sourceFilePath, sourceStoryName;
|
|
1484
1327
|
try {
|
|
1485
|
-
sourceFileName = basename2(importPath);
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
if (!storyName) {
|
|
1497
|
-
throw new SaveStoryError(`Source story not found.`);
|
|
1498
|
-
}
|
|
1499
|
-
if (name && csf.getStoryExport(name)) {
|
|
1500
|
-
throw new SaveStoryError(`Story already exists.`);
|
|
1501
|
-
}
|
|
1502
|
-
sourceStoryName = storyNameFromExport(storyName);
|
|
1503
|
-
await updateArgsInCsfFile(
|
|
1328
|
+
sourceFileName = basename2(importPath), sourceFilePath = join4(process.cwd(), importPath);
|
|
1329
|
+
let csf = await readCsf(sourceFilePath, {
|
|
1330
|
+
makeTitle: (userTitle) => userTitle || "myTitle"
|
|
1331
|
+
}), parsed = csf.parse(), stories = Object.entries(parsed._stories), [componentId, storyId] = csfId.split("--");
|
|
1332
|
+
newStoryName = name && storyNameFromExport(name), newStoryId = newStoryName && toId(componentId, newStoryName);
|
|
1333
|
+
let [storyName] = stories.find(([key, value]) => value.id.endsWith(`--${storyId}`)) || [];
|
|
1334
|
+
if (!storyName)
|
|
1335
|
+
throw new SaveStoryError("Source story not found.");
|
|
1336
|
+
if (name && csf.getStoryExport(name))
|
|
1337
|
+
throw new SaveStoryError("Story already exists.");
|
|
1338
|
+
sourceStoryName = storyNameFromExport(storyName), await updateArgsInCsfFile(
|
|
1504
1339
|
name ? duplicateStoryWithNewName(parsed, storyName, name) : csf.getStoryExport(storyName),
|
|
1505
1340
|
args ? parseArgs(args) : {}
|
|
1506
1341
|
);
|
|
1507
|
-
|
|
1342
|
+
let code = await formatFileContent(
|
|
1508
1343
|
sourceFilePath,
|
|
1509
1344
|
removeExtraNewlines(printCsf(csf).code, name || storyName)
|
|
1510
1345
|
);
|
|
1511
1346
|
await Promise.all([
|
|
1512
1347
|
new Promise((resolve) => {
|
|
1513
|
-
channel.on(STORY_RENDERED, resolve);
|
|
1514
|
-
setTimeout(() => resolve(channel.off(STORY_RENDERED, resolve)), 3e3);
|
|
1348
|
+
channel.on(STORY_RENDERED, resolve), setTimeout(() => resolve(channel.off(STORY_RENDERED, resolve)), 3e3);
|
|
1515
1349
|
}),
|
|
1516
1350
|
writeFile2(sourceFilePath, code)
|
|
1517
|
-
])
|
|
1518
|
-
channel.emit(SAVE_STORY_RESPONSE, {
|
|
1351
|
+
]), channel.emit(SAVE_STORY_RESPONSE, {
|
|
1519
1352
|
id,
|
|
1520
|
-
success:
|
|
1353
|
+
success: !0,
|
|
1521
1354
|
payload: {
|
|
1522
1355
|
csfId,
|
|
1523
1356
|
newStoryId,
|
|
@@ -1530,34 +1363,27 @@ function initializeSaveStory(channel, options, coreConfig) {
|
|
|
1530
1363
|
},
|
|
1531
1364
|
error: null
|
|
1532
1365
|
});
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
});
|
|
1539
|
-
}
|
|
1366
|
+
let isCLIExample = isExampleStoryId(newStoryId ?? csfId);
|
|
1367
|
+
!coreConfig.disableTelemetry && !isCLIExample && await telemetry6("save-story", {
|
|
1368
|
+
action: name ? "createStory" : "updateStory",
|
|
1369
|
+
success: !0
|
|
1370
|
+
});
|
|
1540
1371
|
} catch (error) {
|
|
1541
1372
|
channel.emit(SAVE_STORY_RESPONSE, {
|
|
1542
1373
|
id,
|
|
1543
|
-
success:
|
|
1374
|
+
success: !1,
|
|
1544
1375
|
error: error instanceof SaveStoryError ? error.message : "Unknown error"
|
|
1545
|
-
})
|
|
1546
|
-
logger.error(
|
|
1376
|
+
}), logger2.error(
|
|
1547
1377
|
`Error writing to ${sourceFilePath}:
|
|
1548
1378
|
${error.stack || error.message || error.toString()}`
|
|
1549
|
-
)
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
error
|
|
1555
|
-
});
|
|
1556
|
-
}
|
|
1379
|
+
), !coreConfig.disableTelemetry && !(error instanceof SaveStoryError) && await telemetry6("save-story", {
|
|
1380
|
+
action: name ? "createStory" : "updateStory",
|
|
1381
|
+
success: !1,
|
|
1382
|
+
error
|
|
1383
|
+
});
|
|
1557
1384
|
}
|
|
1558
1385
|
});
|
|
1559
1386
|
}
|
|
1560
|
-
__name(initializeSaveStory, "initializeSaveStory");
|
|
1561
1387
|
|
|
1562
1388
|
// src/core-server/utils/whats-new.ts
|
|
1563
1389
|
import { writeFile as writeFile3 } from "node:fs/promises";
|
|
@@ -1570,30 +1396,20 @@ import {
|
|
|
1570
1396
|
TOGGLE_WHATS_NEW_NOTIFICATIONS
|
|
1571
1397
|
} from "storybook/internal/core-events";
|
|
1572
1398
|
import { printConfig, readConfig } from "storybook/internal/csf-tools";
|
|
1573
|
-
import { logger as
|
|
1574
|
-
import { telemetry as
|
|
1575
|
-
var WHATS_NEW_CACHE = "whats-new-cache";
|
|
1576
|
-
var WHATS_NEW_URL = "https://storybook.js.org/whats-new/v1";
|
|
1399
|
+
import { logger as logger3 } from "storybook/internal/node-logger";
|
|
1400
|
+
import { telemetry as telemetry7 } from "storybook/internal/telemetry";
|
|
1401
|
+
var WHATS_NEW_CACHE = "whats-new-cache", WHATS_NEW_URL = "https://storybook.js.org/whats-new/v1";
|
|
1577
1402
|
function initializeWhatsNew(channel, options, coreOptions) {
|
|
1578
1403
|
channel.on(SET_WHATS_NEW_CACHE, async (data) => {
|
|
1579
|
-
|
|
1580
|
-
logger2.verbose(e);
|
|
1581
|
-
return {};
|
|
1582
|
-
});
|
|
1404
|
+
let cache = await options.cache.get(WHATS_NEW_CACHE).catch((e) => (logger3.verbose(e), {}));
|
|
1583
1405
|
await options.cache.set(WHATS_NEW_CACHE, { ...cache, ...data });
|
|
1584
|
-
})
|
|
1585
|
-
channel.on(REQUEST_WHATS_NEW_DATA, async () => {
|
|
1406
|
+
}), channel.on(REQUEST_WHATS_NEW_DATA, async () => {
|
|
1586
1407
|
try {
|
|
1587
|
-
|
|
1588
|
-
if (response.ok)
|
|
1408
|
+
let post = await fetch(WHATS_NEW_URL).then(async (response) => {
|
|
1409
|
+
if (response.ok)
|
|
1589
1410
|
return response.json();
|
|
1590
|
-
}
|
|
1591
1411
|
throw response;
|
|
1592
|
-
})
|
|
1593
|
-
const main = await loadMainConfig({ configDir: options.configDir });
|
|
1594
|
-
const disableWhatsNewNotifications = main.core?.disableWhatsNewNotifications === true;
|
|
1595
|
-
const cache = await options.cache.get(WHATS_NEW_CACHE) ?? {};
|
|
1596
|
-
const data = {
|
|
1412
|
+
}), disableWhatsNewNotifications = (await loadMainConfig({ configDir: options.configDir })).core?.disableWhatsNewNotifications === !0, cache = await options.cache.get(WHATS_NEW_CACHE) ?? {}, data = {
|
|
1597
1413
|
...post,
|
|
1598
1414
|
status: "SUCCESS",
|
|
1599
1415
|
postIsRead: post.url === cache.lastReadPost,
|
|
@@ -1602,96 +1418,62 @@ function initializeWhatsNew(channel, options, coreOptions) {
|
|
|
1602
1418
|
};
|
|
1603
1419
|
channel.emit(RESULT_WHATS_NEW_DATA, { data });
|
|
1604
1420
|
} catch (e) {
|
|
1605
|
-
|
|
1606
|
-
channel.emit(RESULT_WHATS_NEW_DATA, {
|
|
1421
|
+
logger3.verbose(e instanceof Error ? e.message : String(e)), channel.emit(RESULT_WHATS_NEW_DATA, {
|
|
1607
1422
|
data: { status: "ERROR" }
|
|
1608
1423
|
});
|
|
1609
1424
|
}
|
|
1610
|
-
})
|
|
1611
|
-
channel.on(
|
|
1425
|
+
}), channel.on(
|
|
1612
1426
|
TOGGLE_WHATS_NEW_NOTIFICATIONS,
|
|
1613
1427
|
async ({ disableWhatsNewNotifications }) => {
|
|
1614
|
-
|
|
1428
|
+
let isTelemetryEnabled = coreOptions.disableTelemetry !== !0;
|
|
1615
1429
|
try {
|
|
1616
|
-
|
|
1430
|
+
let mainPath = findConfigFile2("main", options.configDir);
|
|
1617
1431
|
invariant(mainPath, `unable to find Storybook main file in ${options.configDir}`);
|
|
1618
|
-
|
|
1619
|
-
if (!main._exportsObject)
|
|
1432
|
+
let main = await readConfig(mainPath);
|
|
1433
|
+
if (!main._exportsObject)
|
|
1620
1434
|
throw new Error(
|
|
1621
|
-
|
|
1435
|
+
"Unable to parse Storybook main file while trying to read 'core' property"
|
|
1622
1436
|
);
|
|
1623
|
-
}
|
|
1624
|
-
main.setFieldValue(["core", "disableWhatsNewNotifications"], disableWhatsNewNotifications);
|
|
1625
|
-
await writeFile3(mainPath, printConfig(main).code);
|
|
1626
|
-
if (isTelemetryEnabled) {
|
|
1627
|
-
await telemetry6("core-config", { disableWhatsNewNotifications });
|
|
1628
|
-
}
|
|
1437
|
+
main.setFieldValue(["core", "disableWhatsNewNotifications"], disableWhatsNewNotifications), await writeFile3(mainPath, printConfig(main).code), isTelemetryEnabled && await telemetry7("core-config", { disableWhatsNewNotifications });
|
|
1629
1438
|
} catch (error) {
|
|
1630
|
-
invariant(error instanceof Error)
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
skipPrompt: true
|
|
1636
|
-
});
|
|
1637
|
-
}
|
|
1439
|
+
invariant(error instanceof Error), isTelemetryEnabled && await sendTelemetryError(error, "core-config", {
|
|
1440
|
+
cliOptions: options,
|
|
1441
|
+
presetOptions: { ...options, corePresets: [], overridePresets: [] },
|
|
1442
|
+
skipPrompt: !0
|
|
1443
|
+
});
|
|
1638
1444
|
}
|
|
1639
1445
|
}
|
|
1640
|
-
)
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
presetOptions: { ...options, corePresets: [], overridePresets: [] },
|
|
1647
|
-
skipPrompt: true
|
|
1648
|
-
});
|
|
1649
|
-
}
|
|
1446
|
+
), channel.on(TELEMETRY_ERROR, async (error) => {
|
|
1447
|
+
coreOptions.disableTelemetry !== !0 && await sendTelemetryError(error, "browser", {
|
|
1448
|
+
cliOptions: options,
|
|
1449
|
+
presetOptions: { ...options, corePresets: [], overridePresets: [] },
|
|
1450
|
+
skipPrompt: !0
|
|
1451
|
+
});
|
|
1650
1452
|
});
|
|
1651
1453
|
}
|
|
1652
|
-
__name(initializeWhatsNew, "initializeWhatsNew");
|
|
1653
1454
|
|
|
1654
1455
|
// src/core-server/presets/common-preset.ts
|
|
1655
|
-
var interpolate =
|
|
1656
|
-
var staticDirs = /* @__PURE__ */ __name(async (values = []) => [
|
|
1456
|
+
var interpolate = (string, data = {}) => Object.entries(data).reduce((acc, [k, v]) => acc.replace(new RegExp(`%${k}%`, "g"), v), string), staticDirs = async (values = []) => [
|
|
1657
1457
|
...defaultStaticDirs,
|
|
1658
1458
|
...values
|
|
1659
|
-
],
|
|
1660
|
-
|
|
1661
|
-
if (value) {
|
|
1459
|
+
], favicon = async (value, options) => {
|
|
1460
|
+
if (value)
|
|
1662
1461
|
return value;
|
|
1663
|
-
}
|
|
1664
|
-
|
|
1665
|
-
const statics = staticDirsValue ? staticDirsValue.map((dir) => typeof dir === "string" ? dir : `${dir.from}:${dir.to}`) : [];
|
|
1666
|
-
const faviconPaths = statics.map((dir) => {
|
|
1667
|
-
const results = [];
|
|
1668
|
-
const normalizedDir = staticDirsValue && !isAbsolute(dir) ? getDirectoryFromWorkingDir({
|
|
1462
|
+
let staticDirsValue = await options.presets.apply("staticDirs"), faviconPaths = (staticDirsValue ? staticDirsValue.map((dir) => typeof dir == "string" ? dir : `${dir.from}:${dir.to}`) : []).map((dir) => {
|
|
1463
|
+
let results = [], normalizedDir = staticDirsValue && !isAbsolute(dir) ? getDirectoryFromWorkingDir({
|
|
1669
1464
|
configDir: options.configDir,
|
|
1670
1465
|
workingDir: process.cwd(),
|
|
1671
1466
|
directory: dir
|
|
1672
|
-
}) : dir;
|
|
1673
|
-
|
|
1674
|
-
if (["/favicon.svg", "/favicon.ico"].includes(targetEndpoint)) {
|
|
1675
|
-
results.push(staticPath);
|
|
1676
|
-
}
|
|
1677
|
-
if (targetEndpoint === "/") {
|
|
1678
|
-
results.push(join(staticPath, "favicon.svg"));
|
|
1679
|
-
results.push(join(staticPath, "favicon.ico"));
|
|
1680
|
-
}
|
|
1681
|
-
return results.filter((path) => existsSync3(path));
|
|
1467
|
+
}) : dir, { staticPath, targetEndpoint } = parseStaticDir(normalizedDir);
|
|
1468
|
+
return ["/favicon.svg", "/favicon.ico"].includes(targetEndpoint) && results.push(staticPath), targetEndpoint === "/" && (results.push(join(staticPath, "favicon.svg")), results.push(join(staticPath, "favicon.ico"))), results.filter((path) => existsSync3(path));
|
|
1682
1469
|
}).reduce((l1, l2) => l1.concat(l2), []);
|
|
1683
|
-
|
|
1684
|
-
logger3.warn(import_ts_dedent4.dedent`
|
|
1470
|
+
return faviconPaths.length > 1 && logger4.warn(import_ts_dedent4.dedent`
|
|
1685
1471
|
Looks like multiple favicons were detected. Using the first one.
|
|
1686
1472
|
|
|
1687
1473
|
${faviconPaths.join(", ")}
|
|
1688
|
-
`);
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
}, "favicon");
|
|
1692
|
-
var babel = /* @__PURE__ */ __name(async (_, options) => {
|
|
1693
|
-
const { presets } = options;
|
|
1694
|
-
const babelDefault = await presets.apply("babelDefault", {}, options) ?? {};
|
|
1474
|
+
`), faviconPaths[0] || defaultFavicon;
|
|
1475
|
+
}, babel = async (_, options) => {
|
|
1476
|
+
let { presets } = options, babelDefault = await presets.apply("babelDefault", {}, options) ?? {};
|
|
1695
1477
|
return {
|
|
1696
1478
|
...babelDefault,
|
|
1697
1479
|
// This override makes sure that we will never transpile babel further down then the browsers that storybook supports.
|
|
@@ -1705,7 +1487,7 @@ var babel = /* @__PURE__ */ __name(async (_, options) => {
|
|
|
1705
1487
|
[
|
|
1706
1488
|
"@babel/preset-env",
|
|
1707
1489
|
{
|
|
1708
|
-
bugfixes:
|
|
1490
|
+
bugfixes: !0,
|
|
1709
1491
|
targets: {
|
|
1710
1492
|
// This is the same browser supports that we use to bundle our manager and preview code.
|
|
1711
1493
|
chrome: 100,
|
|
@@ -1718,157 +1500,78 @@ var babel = /* @__PURE__ */ __name(async (_, options) => {
|
|
|
1718
1500
|
}
|
|
1719
1501
|
]
|
|
1720
1502
|
};
|
|
1721
|
-
}, "
|
|
1722
|
-
|
|
1723
|
-
var logLevel = /* @__PURE__ */ __name((previous, options) => previous || options.loglevel || "info", "logLevel");
|
|
1724
|
-
var previewHead = /* @__PURE__ */ __name(async (base, { configDir, presets }) => {
|
|
1725
|
-
const interpolations = await presets.apply("env");
|
|
1503
|
+
}, title = (previous, options) => previous || options.packageJson?.name || !1, logLevel = (previous, options) => previous || options.loglevel || "info", previewHead = async (base, { configDir, presets }) => {
|
|
1504
|
+
let interpolations = await presets.apply("env");
|
|
1726
1505
|
return getPreviewHeadTemplate(configDir, interpolations);
|
|
1727
|
-
},
|
|
1728
|
-
|
|
1729
|
-
const { raw } = await loadEnvs({ production: true });
|
|
1506
|
+
}, env = async () => {
|
|
1507
|
+
let { raw } = await loadEnvs({ production: !0 });
|
|
1730
1508
|
return raw;
|
|
1731
|
-
},
|
|
1732
|
-
|
|
1733
|
-
const interpolations = await presets.apply("env");
|
|
1509
|
+
}, previewBody = async (base, { configDir, presets }) => {
|
|
1510
|
+
let interpolations = await presets.apply("env");
|
|
1734
1511
|
return getPreviewBodyTemplate(configDir, interpolations);
|
|
1735
|
-
},
|
|
1736
|
-
|
|
1737
|
-
check: false,
|
|
1512
|
+
}, typescript = () => ({
|
|
1513
|
+
check: !1,
|
|
1738
1514
|
// 'react-docgen' faster than `react-docgen-typescript` but produces lower quality results
|
|
1739
1515
|
reactDocgen: "react-docgen",
|
|
1740
1516
|
reactDocgenTypescriptOptions: {
|
|
1741
|
-
shouldExtractLiteralValuesFromEnum:
|
|
1742
|
-
shouldRemoveUndefinedFromOptional:
|
|
1743
|
-
propFilter:
|
|
1517
|
+
shouldExtractLiteralValuesFromEnum: !0,
|
|
1518
|
+
shouldRemoveUndefinedFromOptional: !0,
|
|
1519
|
+
propFilter: (prop) => prop.parent ? !/node_modules/.test(prop.parent.fileName) : !0,
|
|
1744
1520
|
// NOTE: this default cannot be changed
|
|
1745
|
-
savePropValueAsString:
|
|
1521
|
+
savePropValueAsString: !0
|
|
1746
1522
|
}
|
|
1747
|
-
}),
|
|
1748
|
-
|
|
1749
|
-
let removeAddon = removeAddonBase;
|
|
1750
|
-
const packageManager = JsPackageManagerFactory.getPackageManager({
|
|
1523
|
+
}), experimental_serverAPI = (extension, options) => {
|
|
1524
|
+
let removeAddon = removeAddonBase, packageManager = JsPackageManagerFactory.getPackageManager({
|
|
1751
1525
|
configDir: options.configDir
|
|
1752
1526
|
});
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
await telemetry7("remove", { addon: id, source: "api" });
|
|
1756
|
-
return removeAddonBase(id, { ...opts, packageManager });
|
|
1757
|
-
}, "removeAddon");
|
|
1758
|
-
}
|
|
1759
|
-
return { ...extension, removeAddon };
|
|
1760
|
-
}, "experimental_serverAPI");
|
|
1761
|
-
var core = /* @__PURE__ */ __name(async (existing, options) => ({
|
|
1527
|
+
return options.disableTelemetry || (removeAddon = async (id, opts) => (await telemetry8("remove", { addon: id, source: "api" }), removeAddonBase(id, { ...opts, packageManager }))), { ...extension, removeAddon };
|
|
1528
|
+
}, core = async (existing, options) => ({
|
|
1762
1529
|
...existing,
|
|
1763
|
-
disableTelemetry: options.disableTelemetry ===
|
|
1530
|
+
disableTelemetry: options.disableTelemetry === !0,
|
|
1764
1531
|
enableCrashReports: options.enableCrashReports || optionalEnvToBoolean(process.env.STORYBOOK_ENABLE_CRASH_REPORTS)
|
|
1765
|
-
}),
|
|
1766
|
-
var features = /* @__PURE__ */ __name(async (existing) => ({
|
|
1532
|
+
}), features = async (existing) => ({
|
|
1767
1533
|
...existing,
|
|
1768
|
-
argTypeTargetsV7:
|
|
1769
|
-
legacyDecoratorFileOrder:
|
|
1770
|
-
disallowImplicitActionsInRenderV8:
|
|
1771
|
-
viewport:
|
|
1772
|
-
highlight:
|
|
1773
|
-
controls:
|
|
1774
|
-
interactions:
|
|
1775
|
-
actions:
|
|
1776
|
-
backgrounds:
|
|
1777
|
-
outline:
|
|
1778
|
-
measure:
|
|
1779
|
-
}),
|
|
1780
|
-
var csfIndexer = {
|
|
1534
|
+
argTypeTargetsV7: !0,
|
|
1535
|
+
legacyDecoratorFileOrder: !1,
|
|
1536
|
+
disallowImplicitActionsInRenderV8: !0,
|
|
1537
|
+
viewport: !0,
|
|
1538
|
+
highlight: !0,
|
|
1539
|
+
controls: !0,
|
|
1540
|
+
interactions: !0,
|
|
1541
|
+
actions: !0,
|
|
1542
|
+
backgrounds: !0,
|
|
1543
|
+
outline: !0,
|
|
1544
|
+
measure: !0
|
|
1545
|
+
}), csfIndexer = {
|
|
1781
1546
|
test: /(stories|story)\.(m?js|ts)x?$/,
|
|
1782
|
-
createIndex:
|
|
1783
|
-
}
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
return {};
|
|
1789
|
-
}
|
|
1790
|
-
if (typeof config === "undefined") {
|
|
1791
|
-
return null;
|
|
1792
|
-
}
|
|
1793
|
-
return config.options;
|
|
1794
|
-
}, "frameworkOptions");
|
|
1795
|
-
var managerHead = /* @__PURE__ */ __name(async (_, options) => {
|
|
1796
|
-
const location = join(options.configDir, "manager-head.html");
|
|
1547
|
+
createIndex: async (fileName, options) => (await readCsf2(fileName, options)).parse().indexInputs
|
|
1548
|
+
}, experimental_indexers = (existingIndexers) => [csfIndexer].concat(existingIndexers || []), frameworkOptions = async (_, options) => {
|
|
1549
|
+
let config = await options.presets.apply("framework");
|
|
1550
|
+
return typeof config == "string" ? {} : typeof config > "u" ? null : config.options;
|
|
1551
|
+
}, managerHead = async (_, options) => {
|
|
1552
|
+
let location = join(options.configDir, "manager-head.html");
|
|
1797
1553
|
if (existsSync3(location)) {
|
|
1798
|
-
|
|
1799
|
-
const interpolations = options.presets.apply("env");
|
|
1554
|
+
let contents = readFile3(location, { encoding: "utf8" }), interpolations = options.presets.apply("env");
|
|
1800
1555
|
return interpolate(await contents, await interpolations);
|
|
1801
1556
|
}
|
|
1802
1557
|
return "";
|
|
1803
|
-
},
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
initializeSaveStory(channel, options, coreOptions);
|
|
1808
|
-
initFileSearchChannel(channel, options, coreOptions);
|
|
1809
|
-
initCreateNewStoryChannel(channel, options, coreOptions);
|
|
1810
|
-
initOpenInEditorChannel(channel, options, coreOptions);
|
|
1811
|
-
initPreviewInitializedChannel(channel, options, coreOptions);
|
|
1812
|
-
return channel;
|
|
1813
|
-
}, "experimental_serverChannel");
|
|
1814
|
-
var resolvedReact = /* @__PURE__ */ __name(async (existing) => {
|
|
1558
|
+
}, experimental_serverChannel = async (channel, options) => {
|
|
1559
|
+
let coreOptions = await options.presets.apply("core");
|
|
1560
|
+
return initializeChecklist(), initializeWhatsNew(channel, options, coreOptions), initializeSaveStory(channel, options, coreOptions), initFileSearchChannel(channel, options, coreOptions), initCreateNewStoryChannel(channel, options, coreOptions), initOpenInEditorChannel(channel, options, coreOptions), initPreviewInitializedChannel(channel, options, coreOptions), channel;
|
|
1561
|
+
}, resolvedReact = async (existing) => {
|
|
1815
1562
|
try {
|
|
1816
1563
|
return {
|
|
1817
1564
|
...existing,
|
|
1818
1565
|
react: resolvePackageDir("react"),
|
|
1819
1566
|
reactDom: resolvePackageDir("react-dom")
|
|
1820
1567
|
};
|
|
1821
|
-
} catch
|
|
1822
|
-
return existing;
|
|
1823
|
-
}
|
|
1824
|
-
}, "resolvedReact");
|
|
1825
|
-
var managerEntries = /* @__PURE__ */ __name(async (existing) => {
|
|
1826
|
-
return [
|
|
1827
|
-
join(resolvePackageDir("storybook"), "dist/core-server/presets/common-manager.js"),
|
|
1828
|
-
...existing || []
|
|
1829
|
-
];
|
|
1830
|
-
}, "managerEntries");
|
|
1831
|
-
var viteFinal = /* @__PURE__ */ __name(async (existing, options) => {
|
|
1832
|
-
const previewConfigPath = findConfigFile3("preview", options.configDir);
|
|
1833
|
-
if (!previewConfigPath) {
|
|
1568
|
+
} catch {
|
|
1834
1569
|
return existing;
|
|
1835
1570
|
}
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
...existing,
|
|
1841
|
-
plugins: [
|
|
1842
|
-
...existing.plugins ?? [],
|
|
1843
|
-
...previewConfigPath ? [
|
|
1844
|
-
viteInjectMockerRuntime({ previewConfigPath }),
|
|
1845
|
-
viteMockPlugin({ previewConfigPath, coreOptions, configDir: options.configDir })
|
|
1846
|
-
] : []
|
|
1847
|
-
]
|
|
1848
|
-
};
|
|
1849
|
-
}, "viteFinal");
|
|
1850
|
-
var webpackFinal = /* @__PURE__ */ __name(async (config, options) => {
|
|
1851
|
-
const previewConfigPath = findConfigFile3("preview", options.configDir);
|
|
1852
|
-
if (!previewConfigPath) {
|
|
1853
|
-
return config;
|
|
1854
|
-
}
|
|
1855
|
-
const { WebpackMockPlugin } = await import("../../_node-chunks/webpack-mock-plugin-T4LDXEHE.js");
|
|
1856
|
-
const { WebpackInjectMockerRuntimePlugin } = await import("../../_node-chunks/webpack-inject-mocker-runtime-plugin-EUZJRG3W.js");
|
|
1857
|
-
config.plugins = config.plugins || [];
|
|
1858
|
-
config.module.rules.push({
|
|
1859
|
-
test: /preview\.(t|j)sx?$/,
|
|
1860
|
-
use: [
|
|
1861
|
-
{
|
|
1862
|
-
loader: fileURLToPath(
|
|
1863
|
-
import.meta.resolve("storybook/webpack/loaders/storybook-mock-transform-loader")
|
|
1864
|
-
)
|
|
1865
|
-
}
|
|
1866
|
-
]
|
|
1867
|
-
});
|
|
1868
|
-
config.plugins.push(new WebpackMockPlugin({ previewConfigPath }));
|
|
1869
|
-
config.plugins.push(new WebpackInjectMockerRuntimePlugin());
|
|
1870
|
-
return config;
|
|
1871
|
-
}, "webpackFinal");
|
|
1571
|
+
}, managerEntries = async (existing) => [
|
|
1572
|
+
join(resolvePackageDir("storybook"), "dist/core-server/presets/common-manager.js"),
|
|
1573
|
+
...existing || []
|
|
1574
|
+
];
|
|
1872
1575
|
export {
|
|
1873
1576
|
babel,
|
|
1874
1577
|
core,
|
|
@@ -1888,7 +1591,5 @@ export {
|
|
|
1888
1591
|
resolvedReact,
|
|
1889
1592
|
staticDirs,
|
|
1890
1593
|
title,
|
|
1891
|
-
typescript
|
|
1892
|
-
viteFinal,
|
|
1893
|
-
webpackFinal
|
|
1594
|
+
typescript
|
|
1894
1595
|
};
|