storybook 10.1.0-alpha.10 → 10.1.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_browser-chunks/Color-FTG7SQDA.js +1097 -0
- package/dist/_browser-chunks/WithTooltip-LMROHDUP.js +1651 -0
- package/dist/_browser-chunks/chunk-2FRVAXCZ.js +7 -0
- package/dist/_browser-chunks/chunk-3IAH5M2U.js +171 -0
- package/dist/_browser-chunks/chunk-3OXGAGBE.js +779 -0
- package/dist/_browser-chunks/{chunk-TMDZCWME.js → chunk-3PJE6VLG.js} +1 -3
- package/dist/_browser-chunks/{chunk-VAMFPZY3.js → chunk-45UGUKRX.js} +2 -7
- package/dist/_browser-chunks/chunk-6XWLIJQL.js +11 -0
- package/dist/_browser-chunks/{chunk-FDWKXLBI.js → chunk-74YHFU5B.js} +44 -109
- package/dist/_browser-chunks/{chunk-MM7DTO55.js → chunk-A242L54C.js} +10 -16
- package/dist/_browser-chunks/chunk-AIOS4NGK.js +252 -0
- package/dist/_browser-chunks/chunk-AS2HQEYC.js +14 -0
- package/dist/_browser-chunks/chunk-AXG2BOBL.js +836 -0
- package/dist/_browser-chunks/chunk-BE2DAXKJ.js +2966 -0
- package/dist/_browser-chunks/{chunk-MH6AXFXB.js → chunk-CHUV5WSW.js} +0 -5
- package/dist/_browser-chunks/chunk-EBHB6RPS.js +61 -0
- package/dist/_browser-chunks/chunk-EUVGDK4H.js +93 -0
- package/dist/_browser-chunks/chunk-EZSQOHRI.js +18 -0
- package/dist/_browser-chunks/{chunk-CADGRH3P.js → chunk-FNXWN6IK.js} +3 -8
- package/dist/_browser-chunks/chunk-GFLS4VP3.js +64 -0
- package/dist/_browser-chunks/{chunk-L2D73C6Z.js → chunk-H6XK3RSC.js} +13 -21
- package/dist/_browser-chunks/chunk-IPA5A322.js +71 -0
- package/dist/_browser-chunks/chunk-JP7NCOJX.js +37 -0
- package/dist/_browser-chunks/chunk-KJHJLCBK.js +11 -0
- package/dist/_browser-chunks/{chunk-QMY4G4R2.js → chunk-L4RMQ7D7.js} +17 -64
- package/dist/_browser-chunks/{chunk-AB7OOPUX.js → chunk-QKODTO7K.js} +0 -5
- package/dist/_browser-chunks/chunk-RP5RXKFU.js +2491 -0
- package/dist/_browser-chunks/chunk-SL75JR6Y.js +9 -0
- package/dist/_browser-chunks/chunk-UD6FQLAF.js +1481 -0
- package/dist/_browser-chunks/chunk-VYJQ7RU5.js +2853 -0
- package/dist/_browser-chunks/chunk-WJYERY3R.js +136 -0
- package/dist/_browser-chunks/chunk-WXP2XJ3O.js +950 -0
- package/dist/_browser-chunks/chunk-X3DUQ5RA.js +47 -0
- package/dist/_browser-chunks/chunk-XJNX76GA.js +85 -0
- package/dist/_browser-chunks/{chunk-F4Q6SGTB.js → chunk-YKE5S47A.js} +177 -399
- package/dist/_browser-chunks/{chunk-SN4J4IQ3.js → chunk-ZUWEVLDX.js} +1 -7
- package/dist/_browser-chunks/{formatter-OMEEQ6HG.js → formatter-QJ4M4OGQ.js} +4 -9
- package/dist/_browser-chunks/{syntaxhighlighter-RJZASWHL.js → syntaxhighlighter-WKBQ5RC7.js} +704 -1848
- package/dist/_node-chunks/{builder-manager-HA7CYFCK.js → builder-manager-YUOHSIUB.js} +475 -1013
- package/dist/_node-chunks/camelcase-JREIL7NV.js +18 -0
- package/dist/_node-chunks/{chunk-RMHAL25C.js → chunk-2D2IODUU.js} +88 -228
- package/dist/_node-chunks/chunk-2DMESZFJ.js +943 -0
- package/dist/_node-chunks/chunk-4FT2DHGE.js +3009 -0
- package/dist/_node-chunks/chunk-5HV3B5OP.js +45571 -0
- package/dist/_node-chunks/{chunk-OVXB5GGT.js → chunk-5KLIDWFN.js} +292 -688
- package/dist/_node-chunks/chunk-A4APXFQ2.js +759 -0
- package/dist/_node-chunks/chunk-B6JWY6PC.js +37 -0
- package/dist/_node-chunks/chunk-CZ5GHJCC.js +603 -0
- package/dist/_node-chunks/chunk-DUXPWBOK.js +61 -0
- package/dist/_node-chunks/chunk-DWXTZT3D.js +58 -0
- package/dist/_node-chunks/chunk-E5FJS66Z.js +20 -0
- package/dist/_node-chunks/chunk-EZWWR7AR.js +936 -0
- package/dist/_node-chunks/chunk-FDXFVHIL.js +1114 -0
- package/dist/_node-chunks/{chunk-F3XOPI6H.js → chunk-FZLRAH4N.js} +469 -983
- package/dist/_node-chunks/chunk-HZG65SU3.js +34 -0
- package/dist/_node-chunks/chunk-IXVYNBMD.js +18 -0
- package/dist/_node-chunks/chunk-JARUEMEP.js +4523 -0
- package/dist/_node-chunks/chunk-LIH7MTP7.js +3214 -0
- package/dist/_node-chunks/chunk-N5GIRUP5.js +1047 -0
- package/dist/_node-chunks/{chunk-X4XU27M6.js → chunk-NAOYEL54.js} +15 -24
- package/dist/_node-chunks/chunk-O5DA7YLO.js +3171 -0
- package/dist/_node-chunks/chunk-OP3INKUD.js +54 -0
- package/dist/_node-chunks/chunk-QCO2ZM7F.js +209 -0
- package/dist/_node-chunks/chunk-QYQIZBS6.js +26 -0
- package/dist/_node-chunks/chunk-SEMIAAWG.js +1564 -0
- package/dist/_node-chunks/chunk-TS2UUH2J.js +301 -0
- package/dist/_node-chunks/chunk-WA6KZQZ2.js +119 -0
- package/dist/_node-chunks/{chunk-ZHSCUGNP.js → chunk-WFLWJO24.js} +3799 -7849
- package/dist/_node-chunks/chunk-WUXQMQCB.js +72 -0
- package/dist/_node-chunks/{chunk-VPR5IBMG.js → chunk-XXPJ7XR3.js} +8 -10
- package/dist/_node-chunks/chunk-Y4E6IGQF.js +61 -0
- package/dist/_node-chunks/chunk-ZL3AFKRX.js +1029 -0
- package/dist/_node-chunks/chunk-ZXSD6L3S.js +756 -0
- package/dist/_node-chunks/dist-DS2B5A3J.js +121 -0
- package/dist/_node-chunks/globby-6THB7HVX.js +3452 -0
- package/dist/_node-chunks/lib-5NKX4YGG.js +366 -0
- package/dist/_node-chunks/mdx-N42X6CFJ-ZLT3QOFF.js +14329 -0
- package/dist/_node-chunks/p-limit-PDMWNG7W.js +116 -0
- package/dist/_node-chunks/plugin-6XMWOGPO.js +123 -0
- package/dist/_node-chunks/{plugin-6ZPCS4LI.js → plugin-LTOXVT6A.js} +36 -56
- package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-2SFE5LQS.js +46582 -0
- package/dist/_node-chunks/webpack-mock-plugin-CX5J2U56.js +92 -0
- package/dist/actions/decorator.js +21 -42
- package/dist/actions/index.js +3 -3
- package/dist/babel/index.d.ts +671 -335
- package/dist/babel/index.js +11 -11
- package/dist/bin/core.js +592 -1546
- package/dist/bin/dispatcher.js +26 -37
- package/dist/bin/loader.js +23 -34
- package/dist/channels/index.js +98 -234
- package/dist/cli/index.js +1951 -5308
- package/dist/client-logger/index.js +31 -61
- package/dist/common/index.js +20 -20
- package/dist/components/index.js +4211 -8586
- package/dist/core-events/index.js +2 -66
- package/dist/core-server/index.js +3054 -7290
- package/dist/core-server/presets/common-manager.css +2 -2
- package/dist/core-server/presets/common-manager.js +1806 -3427
- package/dist/core-server/presets/common-override-preset.js +31 -60
- package/dist/core-server/presets/common-preset.js +434 -924
- package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +15 -19
- package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +12 -17
- package/dist/csf/index.js +534 -1179
- package/dist/csf-tools/index.js +9 -9
- package/dist/docs-tools/index.js +6 -6
- package/dist/highlight/index.js +2 -2
- package/dist/instrumenter/index.js +199 -415
- package/dist/manager/globals-runtime.js +24150 -47364
- package/dist/manager/globals.js +2 -3
- package/dist/manager/runtime.js +3961 -8373
- package/dist/manager-api/index.js +1231 -2425
- package/dist/manager-errors.d.ts +3 -0
- package/dist/manager-errors.js +3 -3
- package/dist/node-logger/index.js +1253 -2601
- package/dist/preview/globals.js +2 -3
- package/dist/preview/runtime.js +10364 -21990
- package/dist/preview-api/index.d.ts +67 -68
- package/dist/preview-api/index.js +13 -13
- package/dist/preview-errors.d.ts +3 -0
- package/dist/preview-errors.js +4 -4
- package/dist/router/index.js +347 -899
- package/dist/server-errors.d.ts +3 -0
- package/dist/server-errors.js +10 -10
- package/dist/telemetry/index.js +24 -24
- package/dist/test/index.js +5860 -11645
- package/dist/theming/create.js +4 -4
- package/dist/theming/index.d.ts +3363 -2597
- package/dist/theming/index.js +490 -1086
- package/dist/types/index.js +2 -11
- package/dist/viewport/index.js +3 -3
- package/package.json +5 -5
- package/dist/_browser-chunks/Color-FQNEU7YS.js +0 -1695
- package/dist/_browser-chunks/WithTooltip-6NHN2GXF.js +0 -2343
- package/dist/_browser-chunks/chunk-6A7OIVEL.js +0 -66
- package/dist/_browser-chunks/chunk-AW46NMGV.js +0 -1308
- package/dist/_browser-chunks/chunk-B4A3ADP3.js +0 -3816
- package/dist/_browser-chunks/chunk-FSBVR7H5.js +0 -106
- package/dist/_browser-chunks/chunk-FUOHXXZT.js +0 -23
- package/dist/_browser-chunks/chunk-GTKOCWCT.js +0 -17
- package/dist/_browser-chunks/chunk-HHW4FUMO.js +0 -12
- package/dist/_browser-chunks/chunk-JVSKG4YS.js +0 -4052
- package/dist/_browser-chunks/chunk-LASUB7TL.js +0 -76
- package/dist/_browser-chunks/chunk-LYCSRYYR.js +0 -101
- package/dist/_browser-chunks/chunk-NVV6MIOE.js +0 -243
- package/dist/_browser-chunks/chunk-OBXWFEPB.js +0 -852
- package/dist/_browser-chunks/chunk-OPCDBBL3.js +0 -48
- package/dist/_browser-chunks/chunk-PB6FZ3WE.js +0 -130
- package/dist/_browser-chunks/chunk-RW5PKMWM.js +0 -4182
- package/dist/_browser-chunks/chunk-SYS437NN.js +0 -122
- package/dist/_browser-chunks/chunk-U46RQHA4.js +0 -12
- package/dist/_browser-chunks/chunk-UTNZYD2N.js +0 -311
- package/dist/_browser-chunks/chunk-VUAFL5XK.js +0 -20
- package/dist/_browser-chunks/chunk-XDGMHOV7.js +0 -2197
- package/dist/_browser-chunks/chunk-XW6KSYKF.js +0 -16
- package/dist/_browser-chunks/chunk-Y3M7TW6K.js +0 -1041
- package/dist/_browser-chunks/chunk-ZNRFDIVA.js +0 -233
- package/dist/_node-chunks/camelcase-QALD4XFE.js +0 -18
- package/dist/_node-chunks/chunk-2XY53ALL.js +0 -420
- package/dist/_node-chunks/chunk-3CBQMG2A.js +0 -6712
- package/dist/_node-chunks/chunk-3WDAPZYQ.js +0 -28
- package/dist/_node-chunks/chunk-4ZB555EJ.js +0 -697
- package/dist/_node-chunks/chunk-52DXKXY3.js +0 -4272
- package/dist/_node-chunks/chunk-5OVB4A6F.js +0 -69
- package/dist/_node-chunks/chunk-AGHGNXGH.js +0 -18
- package/dist/_node-chunks/chunk-B23X5ZCK.js +0 -1531
- package/dist/_node-chunks/chunk-B2DAHWJK.js +0 -220
- package/dist/_node-chunks/chunk-CC4PW5MJ.js +0 -34
- package/dist/_node-chunks/chunk-D7NIZELR.js +0 -2256
- package/dist/_node-chunks/chunk-DO5Q3H4L.js +0 -1250
- package/dist/_node-chunks/chunk-ECK7WVFX.js +0 -304
- package/dist/_node-chunks/chunk-EUH3NHXA.js +0 -79
- package/dist/_node-chunks/chunk-FOQHPHCV.js +0 -1657
- package/dist/_node-chunks/chunk-G6EL47NS.js +0 -111
- package/dist/_node-chunks/chunk-GFLS4TJB.js +0 -90
- package/dist/_node-chunks/chunk-J3XZKWHE.js +0 -1586
- package/dist/_node-chunks/chunk-LE63EHJ5.js +0 -1518
- package/dist/_node-chunks/chunk-M47XA42S.js +0 -4741
- package/dist/_node-chunks/chunk-OOI74AL3.js +0 -61
- package/dist/_node-chunks/chunk-PRJHT3GJ.js +0 -61
- package/dist/_node-chunks/chunk-Q52PVUSU.js +0 -101
- package/dist/_node-chunks/chunk-SDCF5RNN.js +0 -1198
- package/dist/_node-chunks/chunk-UJ5SJ23M.js +0 -5029
- package/dist/_node-chunks/chunk-UPHK4ETU.js +0 -64658
- package/dist/_node-chunks/chunk-V7VURIPB.js +0 -1544
- package/dist/_node-chunks/dist-6TXHNR5C.js +0 -175
- package/dist/_node-chunks/globby-PBTV6PX6.js +0 -5222
- package/dist/_node-chunks/lib-4RTDZVGX.js +0 -518
- package/dist/_node-chunks/mdx-N42X6CFJ-COWEH7KR.js +0 -22017
- package/dist/_node-chunks/p-limit-PBVZQOFY.js +0 -168
- package/dist/_node-chunks/plugin-EOZKYZAG.js +0 -159
- package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-35HMSMR5.js +0 -69102
- package/dist/_node-chunks/webpack-mock-plugin-GT3MA5E2.js +0 -124
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_57ru1wfqqjv from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_57ru1wfqqjv from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_57ru1wfqqjv from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_57ru1wfqqjv.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_57ru1wfqqjv.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_57ru1wfqqjv.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
basename,
|
|
14
|
+
dirname,
|
|
15
|
+
isAbsolute,
|
|
16
|
+
join,
|
|
17
|
+
normalize,
|
|
18
|
+
resolve
|
|
19
|
+
} from "./chunk-WA6KZQZ2.js";
|
|
20
|
+
|
|
21
|
+
// src/core-server/mocking-utils/resolve.ts
|
|
22
|
+
import { readFileSync as readFileSync2, realpathSync } from "node:fs";
|
|
23
|
+
import { createRequire } from "node:module";
|
|
24
|
+
import { findMockRedirect } from "@vitest/mocker/redirect";
|
|
25
|
+
|
|
26
|
+
// ../node_modules/resolve.exports/dist/index.mjs
|
|
27
|
+
function e(e2, n2, r2) {
|
|
28
|
+
throw new Error(r2 ? `No known conditions for "${n2}" specifier in "${e2}" package` : `Missing "${n2}" specifier in "${e2}" package`);
|
|
29
|
+
}
|
|
30
|
+
function n(n2, i, o2, f) {
|
|
31
|
+
let s, u, l = r(n2, o2), c = (function(e2) {
|
|
32
|
+
let n3 = /* @__PURE__ */ new Set(["default", ...e2.conditions || []]);
|
|
33
|
+
return e2.unsafe || n3.add(e2.require ? "require" : "import"), e2.unsafe || n3.add(e2.browser ? "browser" : "node"), n3;
|
|
34
|
+
})(f || {}), a = i[l];
|
|
35
|
+
if (a === void 0) {
|
|
36
|
+
let e2, n3, r2, t3;
|
|
37
|
+
for (t3 in i) n3 && t3.length < n3.length || (t3[t3.length - 1] === "/" && l.startsWith(t3) ? (u = l.substring(t3.length), n3 = t3) : t3.length > 1 && (r2 = t3.indexOf("*", 1), ~r2 && (e2 = RegExp("^" + t3.substring(0, r2) + "(.*)" + t3.substring(1 + r2) + "$").exec(l), e2 && e2[1] && (u = e2[1], n3 = t3))));
|
|
38
|
+
a = i[n3];
|
|
39
|
+
}
|
|
40
|
+
return a || e(n2, l), s = t(a, c), s || e(n2, l, 1), u && (function(e2, n3) {
|
|
41
|
+
let r2, t3 = 0, i2 = e2.length, o3 = /[*]/g, f2 = /[/]$/;
|
|
42
|
+
for (; t3 < i2; t3++) e2[t3] = o3.test(r2 = e2[t3]) ? r2.replace(o3, n3) : f2.test(r2) ? r2 + n3 : r2;
|
|
43
|
+
})(s, u), s;
|
|
44
|
+
}
|
|
45
|
+
function r(e2, n2, r2) {
|
|
46
|
+
if (e2 === n2 || n2 === ".") return ".";
|
|
47
|
+
let t3 = e2 + "/", i = t3.length, o2 = n2.slice(0, i) === t3, f = o2 ? n2.slice(i) : n2;
|
|
48
|
+
return f[0] === "#" ? f : o2 || !r2 ? f.slice(0, 2) === "./" ? f : "./" + f : f;
|
|
49
|
+
}
|
|
50
|
+
function t(e2, n2, r2) {
|
|
51
|
+
if (e2) {
|
|
52
|
+
if (typeof e2 == "string") return r2 && r2.add(e2), [e2];
|
|
53
|
+
let i, o2;
|
|
54
|
+
if (Array.isArray(e2)) {
|
|
55
|
+
for (o2 = r2 || /* @__PURE__ */ new Set(), i = 0; i < e2.length; i++) t(e2[i], n2, o2);
|
|
56
|
+
if (!r2 && o2.size) return [...o2];
|
|
57
|
+
} else for (i in e2) if (n2.has(i)) return t(e2[i], n2, r2);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function o(e2, r2, t3) {
|
|
61
|
+
let i, o2 = e2.exports;
|
|
62
|
+
if (o2) {
|
|
63
|
+
if (typeof o2 == "string") o2 = { ".": o2 };
|
|
64
|
+
else for (i in o2) {
|
|
65
|
+
i[0] !== "." && (o2 = { ".": o2 });
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
return n(e2.name, o2, r2 || ".", t3);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// src/core-server/mocking-utils/extract.ts
|
|
73
|
+
import { readFileSync } from "node:fs";
|
|
74
|
+
import { generate, parser, types as t2 } from "storybook/internal/babel";
|
|
75
|
+
import { logger } from "storybook/internal/node-logger";
|
|
76
|
+
import { telemetry } from "storybook/internal/telemetry";
|
|
77
|
+
import { transformSync } from "esbuild";
|
|
78
|
+
|
|
79
|
+
// ../node_modules/estree-walker/src/walker.js
|
|
80
|
+
var WalkerBase = class {
|
|
81
|
+
constructor() {
|
|
82
|
+
this.should_skip = !1, this.should_remove = !1, this.replacement = null, this.context = {
|
|
83
|
+
skip: () => this.should_skip = !0,
|
|
84
|
+
remove: () => this.should_remove = !0,
|
|
85
|
+
replace: (node) => this.replacement = node
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* @template {Node} Parent
|
|
90
|
+
* @param {Parent | null | undefined} parent
|
|
91
|
+
* @param {keyof Parent | null | undefined} prop
|
|
92
|
+
* @param {number | null | undefined} index
|
|
93
|
+
* @param {Node} node
|
|
94
|
+
*/
|
|
95
|
+
replace(parent, prop, index, node) {
|
|
96
|
+
parent && prop && (index != null ? parent[prop][index] = node : parent[prop] = node);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* @template {Node} Parent
|
|
100
|
+
* @param {Parent | null | undefined} parent
|
|
101
|
+
* @param {keyof Parent | null | undefined} prop
|
|
102
|
+
* @param {number | null | undefined} index
|
|
103
|
+
*/
|
|
104
|
+
remove(parent, prop, index) {
|
|
105
|
+
parent && prop && (index != null ? parent[prop].splice(index, 1) : delete parent[prop]);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// ../node_modules/estree-walker/src/sync.js
|
|
110
|
+
var SyncWalker = class extends WalkerBase {
|
|
111
|
+
/**
|
|
112
|
+
*
|
|
113
|
+
* @param {SyncHandler} [enter]
|
|
114
|
+
* @param {SyncHandler} [leave]
|
|
115
|
+
*/
|
|
116
|
+
constructor(enter, leave) {
|
|
117
|
+
super(), this.should_skip = !1, this.should_remove = !1, this.replacement = null, this.context = {
|
|
118
|
+
skip: () => this.should_skip = !0,
|
|
119
|
+
remove: () => this.should_remove = !0,
|
|
120
|
+
replace: (node) => this.replacement = node
|
|
121
|
+
}, this.enter = enter, this.leave = leave;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* @template {Node} Parent
|
|
125
|
+
* @param {Node} node
|
|
126
|
+
* @param {Parent | null} parent
|
|
127
|
+
* @param {keyof Parent} [prop]
|
|
128
|
+
* @param {number | null} [index]
|
|
129
|
+
* @returns {Node | null}
|
|
130
|
+
*/
|
|
131
|
+
visit(node, parent, prop, index) {
|
|
132
|
+
if (node) {
|
|
133
|
+
if (this.enter) {
|
|
134
|
+
let _should_skip = this.should_skip, _should_remove = this.should_remove, _replacement = this.replacement;
|
|
135
|
+
this.should_skip = !1, this.should_remove = !1, this.replacement = null, this.enter.call(this.context, node, parent, prop, index), this.replacement && (node = this.replacement, this.replace(parent, prop, index, node)), this.should_remove && this.remove(parent, prop, index);
|
|
136
|
+
let skipped = this.should_skip, removed = this.should_remove;
|
|
137
|
+
if (this.should_skip = _should_skip, this.should_remove = _should_remove, this.replacement = _replacement, skipped) return node;
|
|
138
|
+
if (removed) return null;
|
|
139
|
+
}
|
|
140
|
+
let key;
|
|
141
|
+
for (key in node) {
|
|
142
|
+
let value = node[key];
|
|
143
|
+
if (value && typeof value == "object")
|
|
144
|
+
if (Array.isArray(value)) {
|
|
145
|
+
let nodes = (
|
|
146
|
+
/** @type {Array<unknown>} */
|
|
147
|
+
value
|
|
148
|
+
);
|
|
149
|
+
for (let i = 0; i < nodes.length; i += 1) {
|
|
150
|
+
let item = nodes[i];
|
|
151
|
+
isNode(item) && (this.visit(item, node, key, i) || i--);
|
|
152
|
+
}
|
|
153
|
+
} else isNode(value) && this.visit(value, node, key, null);
|
|
154
|
+
}
|
|
155
|
+
if (this.leave) {
|
|
156
|
+
let _replacement = this.replacement, _should_remove = this.should_remove;
|
|
157
|
+
this.replacement = null, this.should_remove = !1, this.leave.call(this.context, node, parent, prop, index), this.replacement && (node = this.replacement, this.replace(parent, prop, index, node)), this.should_remove && this.remove(parent, prop, index);
|
|
158
|
+
let removed = this.should_remove;
|
|
159
|
+
if (this.replacement = _replacement, this.should_remove = _should_remove, removed) return null;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return node;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
function isNode(value) {
|
|
166
|
+
return value !== null && typeof value == "object" && "type" in value && typeof value.type == "string";
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// ../node_modules/estree-walker/src/index.js
|
|
170
|
+
function walk(ast, { enter, leave }) {
|
|
171
|
+
return new SyncWalker(enter, leave).visit(ast, null);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// src/core-server/mocking-utils/extract.ts
|
|
175
|
+
var DEFAULT_MODULE_DIRECTORIES = ["/node_modules/"];
|
|
176
|
+
function isModuleDirectory(path) {
|
|
177
|
+
let normalizedPath = normalize(path);
|
|
178
|
+
return DEFAULT_MODULE_DIRECTORIES.some((dir) => normalizedPath.includes(dir));
|
|
179
|
+
}
|
|
180
|
+
var babelParser = (code) => parser.parse(code, {
|
|
181
|
+
sourceType: "module",
|
|
182
|
+
// Enable plugins to handle modern JavaScript features, including TSX.
|
|
183
|
+
plugins: ["typescript", "jsx", "classProperties", "objectRestSpread"],
|
|
184
|
+
errorRecovery: !0
|
|
185
|
+
}).program;
|
|
186
|
+
function rewriteSbMockImportCalls(code) {
|
|
187
|
+
let ast = babelParser(code);
|
|
188
|
+
return walk(ast, {
|
|
189
|
+
enter(node) {
|
|
190
|
+
node.type === "CallExpression" && node.callee.type === "MemberExpression" && node.callee.object.type === "Identifier" && node.callee.object.name === "sb" && node.callee.property.type === "Identifier" && node.callee.property.name === "mock" && node.arguments.length > 0 && node.arguments[0].type === "CallExpression" && node.arguments[0].callee.type === "Import" && node.arguments[0].arguments.length === 1 && node.arguments[0].arguments[0].type === "StringLiteral" && (node.arguments[0] = t2.stringLiteral(node.arguments[0].arguments[0].value));
|
|
191
|
+
}
|
|
192
|
+
}), generate(ast, {}, code);
|
|
193
|
+
}
|
|
194
|
+
function extractMockCalls(options, parse, root) {
|
|
195
|
+
try {
|
|
196
|
+
let hasSpyTrue2 = function(objectExpression) {
|
|
197
|
+
if (!objectExpression || !objectExpression.properties)
|
|
198
|
+
return !1;
|
|
199
|
+
for (let prop of objectExpression.properties)
|
|
200
|
+
if (prop.type === "ObjectProperty" && (prop.key.type === "Identifier" && prop.key.name === "spy" || prop.key.type === "StringLiteral" && prop.key.value === "spy") && prop.value.type === "BooleanLiteral" && prop.value.value === !0)
|
|
201
|
+
return !0;
|
|
202
|
+
return !1;
|
|
203
|
+
};
|
|
204
|
+
var hasSpyTrue = hasSpyTrue2;
|
|
205
|
+
let previewConfigCode = readFileSync(options.previewConfigPath, "utf-8"), { code: jsCode } = transformSync(previewConfigCode, { loader: "tsx", format: "esm" }), ast = parse(jsCode), mocks = [];
|
|
206
|
+
return walk(ast, {
|
|
207
|
+
// @ts-expect-error - Node comes from babel
|
|
208
|
+
async enter(node) {
|
|
209
|
+
if (node.type !== "CallExpression" || node.callee.type !== "MemberExpression" || node.callee.object.type !== "Identifier" || node.callee.object.name !== "sb" || node.callee.property.type !== "Identifier" || node.callee.property.name !== "mock" || node.arguments.length === 0)
|
|
210
|
+
return;
|
|
211
|
+
let path;
|
|
212
|
+
if (node.arguments[0].type === "StringLiteral")
|
|
213
|
+
path = node.arguments[0].value;
|
|
214
|
+
else if (node.arguments[0].type === "CallExpression" && node.arguments[0].callee.type === "Import" && node.arguments[0].arguments[0].type === "StringLiteral")
|
|
215
|
+
path = node.arguments[0].arguments[0].value;
|
|
216
|
+
else
|
|
217
|
+
return;
|
|
218
|
+
let spy = node.arguments.length > 1 && node.arguments[1].type === "ObjectExpression" && hasSpyTrue2(node.arguments[1]), { absolutePath, redirectPath } = resolveMock(path, root, options.previewConfigPath), pathWithoutExtension = path.replace(/\.[^/.]+$/, ""), basenameAbsolutePath = basename(absolutePath), basenamePath = basename(path), pathWithoutExtensionAndBasename = basenameAbsolutePath === basenamePath ? pathWithoutExtension : path;
|
|
219
|
+
mocks.push({
|
|
220
|
+
path: pathWithoutExtensionAndBasename,
|
|
221
|
+
absolutePath,
|
|
222
|
+
redirectPath,
|
|
223
|
+
spy
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}), options.coreOptions?.disableTelemetry || telemetry(
|
|
227
|
+
"mocking",
|
|
228
|
+
{
|
|
229
|
+
modulesMocked: mocks.length,
|
|
230
|
+
modulesSpied: mocks.map((mock) => mock.spy).filter(Boolean).length,
|
|
231
|
+
modulesManuallyMocked: mocks.map((mock) => !!mock.redirectPath).filter(Boolean).length
|
|
232
|
+
},
|
|
233
|
+
{ configDir: options.configDir }
|
|
234
|
+
), mocks;
|
|
235
|
+
} catch (error) {
|
|
236
|
+
return logger.debug("Error extracting mock calls", error), [];
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// src/core-server/mocking-utils/resolve.ts
|
|
241
|
+
var require2 = createRequire(import.meta.url);
|
|
242
|
+
function findPackageJson(specifier, basedir) {
|
|
243
|
+
let packageJsonPath = require2.resolve(`${specifier}/package.json`, { paths: [basedir] });
|
|
244
|
+
return {
|
|
245
|
+
path: packageJsonPath,
|
|
246
|
+
data: JSON.parse(readFileSync2(packageJsonPath, "utf-8"))
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
function resolveExternalModule(path, root) {
|
|
250
|
+
let parts = path.split("/"), packageName = path.startsWith("@") ? `${parts[0]}/${parts[1]}` : parts[0], entry = `.${path.slice(packageName.length)}`, { path: packageJsonPath, data: pkg } = findPackageJson(packageName, root), packageDir = dirname(packageJsonPath);
|
|
251
|
+
if (pkg.exports) {
|
|
252
|
+
let result = o(pkg, entry, {
|
|
253
|
+
browser: !0
|
|
254
|
+
});
|
|
255
|
+
if (result)
|
|
256
|
+
return join(packageDir, result[0]);
|
|
257
|
+
}
|
|
258
|
+
return require2.resolve(path, { paths: [root] });
|
|
259
|
+
}
|
|
260
|
+
function getIsExternal(path, importer) {
|
|
261
|
+
try {
|
|
262
|
+
return !isAbsolute(path) && isModuleDirectory(require2.resolve(path, { paths: [importer] }));
|
|
263
|
+
} catch {
|
|
264
|
+
return !1;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
function resolveMock(path, root, importer) {
|
|
268
|
+
let isExternal = getIsExternal(path, root), externalPath = isExternal ? path : null, absolutePath = isExternal ? resolveExternalModule(path, root) : require2.resolve(path, { paths: [dirname(importer)] }), normalizedAbsolutePath = resolve(absolutePath), redirectPath = findMockRedirect(root, normalizedAbsolutePath, externalPath);
|
|
269
|
+
return {
|
|
270
|
+
absolutePath: normalizedAbsolutePath,
|
|
271
|
+
redirectPath
|
|
272
|
+
// will be null if no __mocks__ file is found
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
function getRealPath(path, preserveSymlinks) {
|
|
276
|
+
try {
|
|
277
|
+
return preserveSymlinks ? realpathSync(path) : path;
|
|
278
|
+
} catch {
|
|
279
|
+
return path;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
function resolveWithExtensions(path, from) {
|
|
283
|
+
let extensions = [".js", ".ts", ".tsx", ".mjs", ".cjs", ".svelte", ".vue"];
|
|
284
|
+
for (let extension of extensions)
|
|
285
|
+
try {
|
|
286
|
+
return require2.resolve(path + extension, { paths: [from] });
|
|
287
|
+
} catch {
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
return require2.resolve(path, { paths: [from] });
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export {
|
|
294
|
+
resolveExternalModule,
|
|
295
|
+
getIsExternal,
|
|
296
|
+
getRealPath,
|
|
297
|
+
resolveWithExtensions,
|
|
298
|
+
babelParser,
|
|
299
|
+
rewriteSbMockImportCalls,
|
|
300
|
+
extractMockCalls
|
|
301
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_57ru1wfqqjv from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_57ru1wfqqjv from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_57ru1wfqqjv from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_57ru1wfqqjv.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_57ru1wfqqjv.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_57ru1wfqqjv.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
// ../node_modules/pathe/dist/shared/pathe.ff20891b.mjs
|
|
14
|
+
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
15
|
+
function normalizeWindowsPath(input = "") {
|
|
16
|
+
return input && input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
17
|
+
}
|
|
18
|
+
var _UNC_REGEX = /^[/\\]{2}/, _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, _DRIVE_LETTER_RE = /^[A-Za-z]:$/, _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
|
|
19
|
+
var normalize = function(path2) {
|
|
20
|
+
if (path2.length === 0)
|
|
21
|
+
return ".";
|
|
22
|
+
path2 = normalizeWindowsPath(path2);
|
|
23
|
+
let isUNCPath = path2.match(_UNC_REGEX), isPathAbsolute = isAbsolute(path2), trailingSeparator = path2[path2.length - 1] === "/";
|
|
24
|
+
return path2 = normalizeString(path2, !isPathAbsolute), path2.length === 0 ? isPathAbsolute ? "/" : trailingSeparator ? "./" : "." : (trailingSeparator && (path2 += "/"), _DRIVE_LETTER_RE.test(path2) && (path2 += "/"), isUNCPath ? isPathAbsolute ? `//${path2}` : `//./${path2}` : isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2);
|
|
25
|
+
}, join = function(...arguments_) {
|
|
26
|
+
if (arguments_.length === 0)
|
|
27
|
+
return ".";
|
|
28
|
+
let joined;
|
|
29
|
+
for (let argument of arguments_)
|
|
30
|
+
argument && argument.length > 0 && (joined === void 0 ? joined = argument : joined += `/${argument}`);
|
|
31
|
+
return joined === void 0 ? "." : normalize(joined.replace(/\/\/+/g, "/"));
|
|
32
|
+
};
|
|
33
|
+
function cwd() {
|
|
34
|
+
return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
|
|
35
|
+
}
|
|
36
|
+
var resolve = function(...arguments_) {
|
|
37
|
+
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
38
|
+
let resolvedPath = "", resolvedAbsolute = !1;
|
|
39
|
+
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
40
|
+
let path2 = index >= 0 ? arguments_[index] : cwd();
|
|
41
|
+
!path2 || path2.length === 0 || (resolvedPath = `${path2}/${resolvedPath}`, resolvedAbsolute = isAbsolute(path2));
|
|
42
|
+
}
|
|
43
|
+
return resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute), resolvedAbsolute && !isAbsolute(resolvedPath) ? `/${resolvedPath}` : resolvedPath.length > 0 ? resolvedPath : ".";
|
|
44
|
+
};
|
|
45
|
+
function normalizeString(path2, allowAboveRoot) {
|
|
46
|
+
let res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, char = null;
|
|
47
|
+
for (let index = 0; index <= path2.length; ++index) {
|
|
48
|
+
if (index < path2.length)
|
|
49
|
+
char = path2[index];
|
|
50
|
+
else {
|
|
51
|
+
if (char === "/")
|
|
52
|
+
break;
|
|
53
|
+
char = "/";
|
|
54
|
+
}
|
|
55
|
+
if (char === "/") {
|
|
56
|
+
if (!(lastSlash === index - 1 || dots === 1)) if (dots === 2) {
|
|
57
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
58
|
+
if (res.length > 2) {
|
|
59
|
+
let lastSlashIndex = res.lastIndexOf("/");
|
|
60
|
+
lastSlashIndex === -1 ? (res = "", lastSegmentLength = 0) : (res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/")), lastSlash = index, dots = 0;
|
|
61
|
+
continue;
|
|
62
|
+
} else if (res.length > 0) {
|
|
63
|
+
res = "", lastSegmentLength = 0, lastSlash = index, dots = 0;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
allowAboveRoot && (res += res.length > 0 ? "/.." : "..", lastSegmentLength = 2);
|
|
68
|
+
} else
|
|
69
|
+
res.length > 0 ? res += `/${path2.slice(lastSlash + 1, index)}` : res = path2.slice(lastSlash + 1, index), lastSegmentLength = index - lastSlash - 1;
|
|
70
|
+
lastSlash = index, dots = 0;
|
|
71
|
+
} else char === "." && dots !== -1 ? ++dots : dots = -1;
|
|
72
|
+
}
|
|
73
|
+
return res;
|
|
74
|
+
}
|
|
75
|
+
var isAbsolute = function(p) {
|
|
76
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
77
|
+
};
|
|
78
|
+
var _EXTNAME_RE = /.(\.[^./]+)$/, extname = function(p) {
|
|
79
|
+
let match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
|
80
|
+
return match && match[1] || "";
|
|
81
|
+
}, relative = function(from, to) {
|
|
82
|
+
let _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/"), _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
83
|
+
if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0])
|
|
84
|
+
return _to.join("/");
|
|
85
|
+
let _fromCopy = [..._from];
|
|
86
|
+
for (let segment of _fromCopy) {
|
|
87
|
+
if (_to[0] !== segment)
|
|
88
|
+
break;
|
|
89
|
+
_from.shift(), _to.shift();
|
|
90
|
+
}
|
|
91
|
+
return [..._from.map(() => ".."), ..._to].join("/");
|
|
92
|
+
}, dirname = function(p) {
|
|
93
|
+
let segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
94
|
+
return segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0]) && (segments[0] += "/"), segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
95
|
+
};
|
|
96
|
+
var basename = function(p, extension) {
|
|
97
|
+
let lastSegment = normalizeWindowsPath(p).split("/").pop();
|
|
98
|
+
return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
|
|
99
|
+
}, parse = function(p) {
|
|
100
|
+
let root = normalizeWindowsPath(p).split("/").shift() || "/", base = basename(p), extension = extname(base);
|
|
101
|
+
return {
|
|
102
|
+
root,
|
|
103
|
+
dir: dirname(p),
|
|
104
|
+
base,
|
|
105
|
+
ext: extension,
|
|
106
|
+
name: base.slice(0, base.length - extension.length)
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export {
|
|
111
|
+
normalize,
|
|
112
|
+
join,
|
|
113
|
+
resolve,
|
|
114
|
+
isAbsolute,
|
|
115
|
+
relative,
|
|
116
|
+
dirname,
|
|
117
|
+
basename,
|
|
118
|
+
parse
|
|
119
|
+
};
|