storybook 10.1.0-alpha.12 → 10.1.0-alpha.14
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/{chunk-74YHFU5B.js → chunk-2XZMBGTA.js} +1 -1
- package/dist/_browser-chunks/{chunk-EBHB6RPS.js → chunk-FQ7SLVLR.js} +6 -1
- package/dist/_browser-chunks/{chunk-X3DUQ5RA.js → chunk-GFY5R5EY.js} +1 -1
- package/dist/_browser-chunks/{chunk-WXP2XJ3O.js → chunk-P4F4UVXX.js} +1 -0
- package/dist/_browser-chunks/{chunk-BE2DAXKJ.js → chunk-SS2NHR7W.js} +4 -1
- package/dist/_browser-chunks/{syntaxhighlighter-WKBQ5RC7.js → syntaxhighlighter-IQDEPFLK.js} +1 -1
- package/dist/_node-chunks/{builder-manager-YUOHSIUB.js → builder-manager-FQ5J6V3U.js} +32 -22
- package/dist/_node-chunks/{chunk-B6JWY6PC.js → camelcase-VGUYV77Z.js} +8 -8
- package/dist/_node-chunks/{chunk-FZLRAH4N.js → chunk-2JR3QBT2.js} +7 -7
- package/dist/_node-chunks/chunk-3EBH66BB.js +23 -0
- package/dist/_node-chunks/{chunk-E5FJS66Z.js → chunk-4ZFHN3ZY.js} +6 -6
- package/dist/_node-chunks/{chunk-5HV3B5OP.js → chunk-63PL4NNE.js} +1104 -13
- package/dist/_node-chunks/{chunk-NAOYEL54.js → chunk-A4KENTXT.js} +7 -7
- package/dist/_node-chunks/{chunk-4FT2DHGE.js → chunk-ALIA3J6S.js} +44 -10
- package/dist/_node-chunks/{chunk-WFLWJO24.js → chunk-C2HKH2XQ.js} +5710 -2414
- package/dist/_node-chunks/{chunk-WA6KZQZ2.js → chunk-DQNBAQYT.js} +6 -6
- package/dist/_node-chunks/{chunk-JARUEMEP.js → chunk-F74UHHR6.js} +7 -7
- package/dist/_node-chunks/{chunk-WUXQMQCB.js → chunk-H5XWXVWR.js} +6 -6
- package/dist/_node-chunks/{chunk-OP3INKUD.js → chunk-JMP7YFX2.js} +6 -6
- package/dist/_node-chunks/{chunk-DWXTZT3D.js → chunk-JZR4DHG2.js} +19 -7
- package/dist/_node-chunks/{chunk-QCO2ZM7F.js → chunk-KEA7CVMZ.js} +122 -32
- package/dist/_node-chunks/{chunk-DUXPWBOK.js → chunk-KF3WTAEP.js} +7 -7
- package/dist/_node-chunks/{chunk-2D2IODUU.js → chunk-LPPM7L5D.js} +51 -71
- package/dist/_node-chunks/{chunk-2DMESZFJ.js → chunk-MJUDR7HQ.js} +7 -7
- package/dist/_node-chunks/chunk-NPB4THZQ.js +18 -0
- package/dist/_node-chunks/chunk-NZBK3DSJ.js +29 -0
- package/dist/_node-chunks/{chunk-5KLIDWFN.js → chunk-Q2QUNQK6.js} +7 -7
- package/dist/_node-chunks/{chunk-EZWWR7AR.js → chunk-TMCKISJR.js} +101 -118
- package/dist/_node-chunks/chunk-TWK7AR3U.js +6024 -0
- package/dist/_node-chunks/{chunk-CZ5GHJCC.js → chunk-V7CXWJXC.js} +7 -7
- package/dist/_node-chunks/chunk-W4F3T6CY.js +3781 -0
- package/dist/_node-chunks/{chunk-SEMIAAWG.js → chunk-WACDSFMO.js} +9 -9
- package/dist/_node-chunks/{chunk-A4APXFQ2.js → chunk-WVXZFQQU.js} +14 -8
- package/dist/_node-chunks/chunk-XBPE4PT7.js +78 -0
- package/dist/_node-chunks/chunk-YMM6BYF2.js +61 -0
- package/dist/_node-chunks/{chunk-XXPJ7XR3.js → chunk-ZGZKNZ5S.js} +6 -6
- package/dist/_node-chunks/{dist-DS2B5A3J.js → dist-DR3AP3RJ.js} +9 -9
- package/dist/_node-chunks/{globby-6THB7HVX.js → globby-D4FPSHY2.js} +9 -9
- package/dist/_node-chunks/{lib-5NKX4YGG.js → lib-ZEFOVNTK.js} +7 -7
- package/dist/_node-chunks/{mdx-N42X6CFJ-ZLT3QOFF.js → mdx-N42X6CFJ-PJF3ICCG.js} +8 -8
- package/dist/_node-chunks/{p-limit-PDMWNG7W.js → p-limit-CYQOFYPV.js} +7 -7
- package/dist/babel/index.js +10 -11
- package/dist/bin/core.js +33 -26
- package/dist/bin/dispatcher.js +31 -20
- package/dist/bin/loader.js +10 -13
- package/dist/cli/index.d.ts +1479 -133
- package/dist/cli/index.js +30 -5159
- package/dist/common/index.d.ts +139 -62
- package/dist/common/index.js +66 -51
- package/dist/components/index.d.ts +136 -26
- package/dist/components/index.js +3163 -2859
- package/dist/core-server/index.d.ts +3 -2
- package/dist/core-server/index.js +112 -1486
- package/dist/core-server/presets/common-manager.js +5 -5
- package/dist/core-server/presets/common-override-preset.js +9 -9
- package/dist/core-server/presets/common-preset.js +272 -81
- package/dist/csf/index.js +2 -2
- package/dist/csf-tools/index.js +9 -9
- package/dist/manager/globals-runtime.js +21557 -21133
- package/dist/manager/manager-stores.d.ts +1 -0
- package/dist/manager/manager-stores.js +23 -0
- package/dist/manager/runtime.js +6695 -720
- package/dist/manager-api/index.d.ts +1802 -1
- package/dist/manager-api/index.js +105 -11
- package/dist/manager-errors.d.ts +6 -0
- package/dist/manager-errors.js +2 -2
- package/dist/mocking-utils/index.d.ts +1126 -0
- package/dist/{_node-chunks/chunk-ZXSD6L3S.js → mocking-utils/index.js} +441 -16
- package/dist/node-logger/index.d.ts +192 -24
- package/dist/node-logger/index.js +23 -3148
- package/dist/preview/runtime.js +35 -3
- package/dist/preview-api/index.d.ts +69 -68
- package/dist/preview-api/index.js +2 -2
- package/dist/preview-errors.d.ts +6 -0
- package/dist/preview-errors.js +2 -2
- package/dist/server-errors.d.ts +31 -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/types/index.d.ts +71 -8
- package/dist/types/index.js +25 -1
- package/package.json +11 -9
- package/dist/_node-chunks/camelcase-JREIL7NV.js +0 -18
- package/dist/_node-chunks/chunk-FDXFVHIL.js +0 -1114
- package/dist/_node-chunks/chunk-HZG65SU3.js +0 -34
- package/dist/_node-chunks/chunk-IXVYNBMD.js +0 -18
- package/dist/_node-chunks/chunk-LIH7MTP7.js +0 -3214
- package/dist/_node-chunks/chunk-N5GIRUP5.js +0 -1047
- package/dist/_node-chunks/chunk-O5DA7YLO.js +0 -3171
- package/dist/_node-chunks/chunk-QYQIZBS6.js +0 -26
- package/dist/_node-chunks/chunk-TS2UUH2J.js +0 -301
- package/dist/_node-chunks/chunk-Y4E6IGQF.js +0 -61
- package/dist/_node-chunks/chunk-ZL3AFKRX.js +0 -1029
- package/dist/_node-chunks/plugin-6XMWOGPO.js +0 -123
- package/dist/_node-chunks/plugin-LTOXVT6A.js +0 -109
- package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-2SFE5LQS.js +0 -46582
- package/dist/_node-chunks/webpack-mock-plugin-CX5J2U56.js +0 -92
- package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +0 -32
- package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +0 -28
|
@@ -1,123 +0,0 @@
|
|
|
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
|
-
getAutomockCode
|
|
14
|
-
} from "./chunk-ZXSD6L3S.js";
|
|
15
|
-
import {
|
|
16
|
-
babelParser,
|
|
17
|
-
extractMockCalls,
|
|
18
|
-
getRealPath,
|
|
19
|
-
rewriteSbMockImportCalls
|
|
20
|
-
} from "./chunk-TS2UUH2J.js";
|
|
21
|
-
import {
|
|
22
|
-
normalize
|
|
23
|
-
} from "./chunk-WA6KZQZ2.js";
|
|
24
|
-
import "./chunk-OP3INKUD.js";
|
|
25
|
-
|
|
26
|
-
// src/core-server/presets/vitePlugins/vite-mock/plugin.ts
|
|
27
|
-
import { readFileSync } from "node:fs";
|
|
28
|
-
import { logger } from "storybook/internal/node-logger";
|
|
29
|
-
|
|
30
|
-
// src/core-server/presets/vitePlugins/vite-mock/utils.ts
|
|
31
|
-
function getCleanId(id) {
|
|
32
|
-
return id.replace(/^.*\/deps\//, "").replace(/\.js.*$/, "").replace(/_/g, "/");
|
|
33
|
-
}
|
|
34
|
-
function invalidateAllRelatedModules(server, absPath, pkgName) {
|
|
35
|
-
for (let mod of server.moduleGraph.idToModuleMap.values())
|
|
36
|
-
(mod.id === absPath || mod.id && getCleanId(mod.id) === pkgName) && server.moduleGraph.invalidateModule(mod);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// src/core-server/presets/vitePlugins/vite-mock/plugin.ts
|
|
40
|
-
function viteMockPlugin(options) {
|
|
41
|
-
let viteConfig, mockCalls = [], normalizedPreviewConfigPath = normalize(options.previewConfigPath);
|
|
42
|
-
return [
|
|
43
|
-
{
|
|
44
|
-
name: "storybook:mock-loader",
|
|
45
|
-
configResolved(config) {
|
|
46
|
-
viteConfig = config;
|
|
47
|
-
},
|
|
48
|
-
buildStart() {
|
|
49
|
-
mockCalls = extractMockCalls(options, babelParser, viteConfig.root);
|
|
50
|
-
},
|
|
51
|
-
configureServer(server) {
|
|
52
|
-
async function invalidateAffectedFiles(file) {
|
|
53
|
-
if (file === options.previewConfigPath || file.includes("__mocks__")) {
|
|
54
|
-
let oldMockCalls = mockCalls;
|
|
55
|
-
mockCalls = extractMockCalls(options, babelParser, viteConfig.root);
|
|
56
|
-
let previewMod = server.moduleGraph.getModuleById(options.previewConfigPath);
|
|
57
|
-
previewMod && server.moduleGraph.invalidateModule(previewMod);
|
|
58
|
-
for (let call of mockCalls)
|
|
59
|
-
invalidateAllRelatedModules(server, call.absolutePath, call.path);
|
|
60
|
-
let newAbsPaths = new Set(mockCalls.map((c) => c.absolutePath));
|
|
61
|
-
for (let oldCall of oldMockCalls)
|
|
62
|
-
newAbsPaths.has(oldCall.absolutePath) || invalidateAllRelatedModules(server, oldCall.absolutePath, oldCall.path);
|
|
63
|
-
return server.ws.send({ type: "full-reload" }), [];
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
server.watcher.on("change", invalidateAffectedFiles), server.watcher.on("add", invalidateAffectedFiles), server.watcher.on("unlink", invalidateAffectedFiles);
|
|
67
|
-
},
|
|
68
|
-
load: {
|
|
69
|
-
order: "pre",
|
|
70
|
-
handler(id) {
|
|
71
|
-
let preserveSymlinks = viteConfig.resolve.preserveSymlinks, idNorm = getRealPath(id, preserveSymlinks), cleanId = getCleanId(idNorm);
|
|
72
|
-
for (let call of mockCalls)
|
|
73
|
-
if (!(getRealPath(call.absolutePath, preserveSymlinks) !== idNorm && call.path !== cleanId) && call.redirectPath)
|
|
74
|
-
return this.addWatchFile(call.redirectPath), readFileSync(call.redirectPath, "utf-8");
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
transform: {
|
|
79
|
-
order: "pre",
|
|
80
|
-
handler(code, id) {
|
|
81
|
-
for (let call of mockCalls) {
|
|
82
|
-
let preserveSymlinks = viteConfig.resolve.preserveSymlinks, idNorm = getRealPath(id, preserveSymlinks), callNorm = getRealPath(call.absolutePath, preserveSymlinks);
|
|
83
|
-
if (viteConfig.command !== "serve") {
|
|
84
|
-
if (callNorm !== idNorm)
|
|
85
|
-
continue;
|
|
86
|
-
} else {
|
|
87
|
-
let cleanId = getCleanId(idNorm);
|
|
88
|
-
if (call.path !== cleanId && callNorm !== idNorm)
|
|
89
|
-
continue;
|
|
90
|
-
}
|
|
91
|
-
try {
|
|
92
|
-
if (!call.redirectPath) {
|
|
93
|
-
let automockedCode = getAutomockCode(code, call.spy, babelParser);
|
|
94
|
-
return {
|
|
95
|
-
code: automockedCode.toString(),
|
|
96
|
-
map: automockedCode.generateMap()
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
} catch (e) {
|
|
100
|
-
return logger.error(`Error automocking ${id}: ${e}`), null;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
name: "storybook:mock-loader-preview",
|
|
109
|
-
transform(code, id) {
|
|
110
|
-
if (id === normalizedPreviewConfigPath)
|
|
111
|
-
try {
|
|
112
|
-
return rewriteSbMockImportCalls(code);
|
|
113
|
-
} catch (e) {
|
|
114
|
-
return logger.debug(`Could not transform sb.mock(import(...)) calls in ${id}: ${e}`), null;
|
|
115
|
-
}
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
];
|
|
120
|
-
}
|
|
121
|
-
export {
|
|
122
|
-
viteMockPlugin
|
|
123
|
-
};
|
|
@@ -1,109 +0,0 @@
|
|
|
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
|
-
resolvePackageDir
|
|
14
|
-
} from "./chunk-A4APXFQ2.js";
|
|
15
|
-
import "./chunk-WA6KZQZ2.js";
|
|
16
|
-
import {
|
|
17
|
-
require_dist
|
|
18
|
-
} from "./chunk-DUXPWBOK.js";
|
|
19
|
-
import {
|
|
20
|
-
__toESM
|
|
21
|
-
} from "./chunk-OP3INKUD.js";
|
|
22
|
-
|
|
23
|
-
// src/core-server/presets/vitePlugins/vite-inject-mocker/plugin.ts
|
|
24
|
-
import { readFileSync } from "node:fs";
|
|
25
|
-
import { join } from "node:path";
|
|
26
|
-
import { fileURLToPath } from "node:url";
|
|
27
|
-
|
|
28
|
-
// ../node_modules/@rolldown/pluginutils/dist/index.js
|
|
29
|
-
function exactRegex(str, flags) {
|
|
30
|
-
return new RegExp(`^${escapeRegex(str)}$`, flags);
|
|
31
|
-
}
|
|
32
|
-
var escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
|
|
33
|
-
function escapeRegex(str) {
|
|
34
|
-
return str.replace(escapeRegexRE, "\\$&");
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// src/core-server/presets/vitePlugins/vite-inject-mocker/plugin.ts
|
|
38
|
-
var import_ts_dedent = __toESM(require_dist(), 1);
|
|
39
|
-
var entryPath = "/vite-inject-mocker-entry.js", entryCode = import_ts_dedent.dedent`
|
|
40
|
-
<script type="module" src=".${entryPath}"></script>
|
|
41
|
-
`, server, viteInjectMockerRuntime = (options) => {
|
|
42
|
-
let viteConfig;
|
|
43
|
-
return {
|
|
44
|
-
name: "vite:storybook-inject-mocker-runtime",
|
|
45
|
-
buildStart() {
|
|
46
|
-
viteConfig.command === "build" && this.emitFile({
|
|
47
|
-
type: "chunk",
|
|
48
|
-
id: join(
|
|
49
|
-
resolvePackageDir("storybook"),
|
|
50
|
-
"assets",
|
|
51
|
-
"server",
|
|
52
|
-
"mocker-runtime.template.js"
|
|
53
|
-
),
|
|
54
|
-
fileName: entryPath.slice(1)
|
|
55
|
-
});
|
|
56
|
-
},
|
|
57
|
-
config() {
|
|
58
|
-
return {
|
|
59
|
-
optimizeDeps: {
|
|
60
|
-
include: ["@vitest/mocker", "@vitest/mocker/browser"]
|
|
61
|
-
},
|
|
62
|
-
resolve: {
|
|
63
|
-
// Aliasing necessary for package managers like pnpm, since resolving modules from a virtual module
|
|
64
|
-
// leads to errors, if the imported module is not a dependency of the project.
|
|
65
|
-
// By resolving the module to the real path, we can avoid this issue.
|
|
66
|
-
alias: {
|
|
67
|
-
"@vitest/mocker/browser": fileURLToPath(import.meta.resolve("@vitest/mocker/browser")),
|
|
68
|
-
"@vitest/mocker": fileURLToPath(import.meta.resolve("@vitest/mocker"))
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
},
|
|
73
|
-
configResolved(config) {
|
|
74
|
-
viteConfig = config;
|
|
75
|
-
},
|
|
76
|
-
configureServer(server_) {
|
|
77
|
-
server = server_, options.previewConfigPath && server.watcher.on("change", (file) => {
|
|
78
|
-
file === options.previewConfigPath && server.ws.send({
|
|
79
|
-
type: "custom",
|
|
80
|
-
event: "invalidate-mocker"
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
},
|
|
84
|
-
resolveId: {
|
|
85
|
-
filter: {
|
|
86
|
-
id: [exactRegex(entryPath)]
|
|
87
|
-
},
|
|
88
|
-
handler(id) {
|
|
89
|
-
return exactRegex(id).test(entryPath) ? id : null;
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
async load(id) {
|
|
93
|
-
return exactRegex(id).test(entryPath) ? readFileSync(
|
|
94
|
-
join(resolvePackageDir("storybook"), "assets", "server", "mocker-runtime.template.js"),
|
|
95
|
-
"utf-8"
|
|
96
|
-
) : null;
|
|
97
|
-
},
|
|
98
|
-
transformIndexHtml(html) {
|
|
99
|
-
let headTag = html.match(/<head[^>]*>/);
|
|
100
|
-
if (headTag) {
|
|
101
|
-
let headTagIndex = html.indexOf(headTag[0]);
|
|
102
|
-
return html.slice(0, headTagIndex + headTag[0].length) + entryCode + html.slice(headTagIndex + headTag[0].length);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
export {
|
|
108
|
-
viteInjectMockerRuntime
|
|
109
|
-
};
|