storybook 9.1.0-alpha.7 → 9.1.0-alpha.9
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/bin/index.cjs +43 -43
- package/dist/bin/index.js +43 -43
- package/dist/cli/bin/index.cjs +69 -69
- package/dist/cli/bin/index.js +61 -61
- package/dist/common/index.cjs +43 -43
- package/dist/common/index.js +43 -43
- package/dist/components/index.cjs +4140 -3977
- package/dist/components/index.d.ts +8 -11
- package/dist/components/index.js +2741 -2574
- package/dist/core-server/index.cjs +4 -1
- package/dist/core-server/index.js +4 -1
- package/dist/core-server/presets/common-manager.js +307 -300
- package/dist/core-server/presets/common-preset.cjs +85031 -5227
- package/dist/core-server/presets/common-preset.js +85102 -5288
- package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.cjs +28727 -0
- package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +28728 -0
- package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.cjs +29339 -0
- package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +29340 -0
- package/dist/csf-tools/index.cjs +319 -321
- package/dist/csf-tools/index.js +239 -241
- package/dist/manager/globals-module-info.cjs +1 -1
- package/dist/manager/globals-module-info.js +1 -1
- package/dist/manager/globals-runtime.js +15073 -14903
- package/dist/manager/runtime.js +103 -103
- package/dist/manager-api/index.cjs +1 -1
- package/dist/manager-api/index.d.ts +534 -8
- package/dist/manager-api/index.js +1 -1
- package/dist/preview/runtime.js +572 -568
- package/dist/telemetry/index.cjs +1733 -1642
- package/dist/telemetry/index.d.ts +2 -1
- package/dist/telemetry/index.js +1727 -1637
- package/dist/test/index.cjs +284 -280
- package/dist/test/index.d.ts +8 -1
- package/dist/test/index.js +5 -1
- package/package.json +14 -1
- package/templates/mocker-runtime.template.js +89 -0
package/dist/test/index.d.ts
CHANGED
|
@@ -1368,5 +1368,12 @@ declare module 'storybook/internal/csf' {
|
|
|
1368
1368
|
}
|
|
1369
1369
|
}
|
|
1370
1370
|
declare const expect: Expect;
|
|
1371
|
+
type ModuleMockOptions = {
|
|
1372
|
+
spy?: boolean;
|
|
1373
|
+
};
|
|
1374
|
+
type ReturnTypeOfModuleMocker = (path: string | Promise<unknown>, factory?: ModuleMockOptions) => void;
|
|
1375
|
+
declare const sb: {
|
|
1376
|
+
mock: ReturnTypeOfModuleMocker;
|
|
1377
|
+
};
|
|
1371
1378
|
|
|
1372
|
-
export { type UserEvent, type UserEventObject, buildQueries, clearAllMocks, configure, createEvent, expect, findAllByAltText, findAllByDisplayValue, findAllByLabelText, findAllByPlaceholderText, findAllByRole, findAllByTestId, findAllByText, findAllByTitle, findByAltText, findByDisplayValue, findByLabelText, findByPlaceholderText, findByRole, findByTestId, findByText, findByTitle, fireEvent, fn, getAllByAltText, getAllByDisplayValue, getAllByLabelText, getAllByPlaceholderText, getAllByRole, getAllByTestId, getAllByText, getAllByTitle, getByAltText, getByDisplayValue, getByLabelText, getByPlaceholderText, getByRole, getByTestId, getByText, getByTitle, getConfig, getDefaultNormalizer, getElementError, getNodeText, getQueriesForElement, getRoles, getSuggestedQuery, isInaccessible, logDOM, logRoles, mocked, onMockCall, prettyDOM, prettyFormat, queries, queryAllByAltText, queryAllByAttribute, queryAllByDisplayValue, queryAllByLabelText, queryAllByPlaceholderText, queryAllByRole, queryAllByTestId, queryAllByText, queryAllByTitle, queryByAltText, queryByAttribute, queryByDisplayValue, queryByLabelText, queryByPlaceholderText, queryByRole, queryByTestId, queryByText, queryByTitle, queryHelpers, resetAllMocks, restoreAllMocks, screen, spyOn, uninstrumentedUserEvent, userEvent, waitFor, waitForElementToBeRemoved, within };
|
|
1379
|
+
export { type UserEvent, type UserEventObject, buildQueries, clearAllMocks, configure, createEvent, expect, findAllByAltText, findAllByDisplayValue, findAllByLabelText, findAllByPlaceholderText, findAllByRole, findAllByTestId, findAllByText, findAllByTitle, findByAltText, findByDisplayValue, findByLabelText, findByPlaceholderText, findByRole, findByTestId, findByText, findByTitle, fireEvent, fn, getAllByAltText, getAllByDisplayValue, getAllByLabelText, getAllByPlaceholderText, getAllByRole, getAllByTestId, getAllByText, getAllByTitle, getByAltText, getByDisplayValue, getByLabelText, getByPlaceholderText, getByRole, getByTestId, getByText, getByTitle, getConfig, getDefaultNormalizer, getElementError, getNodeText, getQueriesForElement, getRoles, getSuggestedQuery, isInaccessible, logDOM, logRoles, mocked, onMockCall, prettyDOM, prettyFormat, queries, queryAllByAltText, queryAllByAttribute, queryAllByDisplayValue, queryAllByLabelText, queryAllByPlaceholderText, queryAllByRole, queryAllByTestId, queryAllByText, queryAllByTitle, queryByAltText, queryByAttribute, queryByDisplayValue, queryByLabelText, queryByPlaceholderText, queryByRole, queryByTestId, queryByText, queryByTitle, queryHelpers, resetAllMocks, restoreAllMocks, sb, screen, spyOn, uninstrumentedUserEvent, userEvent, waitFor, waitForElementToBeRemoved, within };
|
package/dist/test/index.js
CHANGED
|
@@ -33017,7 +33017,10 @@ var { expect: nOe } = xne(
|
|
|
33017
33017
|
mutate: !0,
|
|
33018
33018
|
intercept: /* @__PURE__ */ o((e) => e !== "expect", "intercept")
|
|
33019
33019
|
}
|
|
33020
|
-
)
|
|
33020
|
+
), oOe = {
|
|
33021
|
+
mock: /* @__PURE__ */ o(() => {
|
|
33022
|
+
}, "mock")
|
|
33023
|
+
};
|
|
33021
33024
|
export {
|
|
33022
33025
|
ARe as buildQueries,
|
|
33023
33026
|
ube as clearAllMocks,
|
|
@@ -33096,6 +33099,7 @@ export {
|
|
|
33096
33099
|
VTe as queryHelpers,
|
|
33097
33100
|
cbe as resetAllMocks,
|
|
33098
33101
|
dbe as restoreAllMocks,
|
|
33102
|
+
oOe as sb,
|
|
33099
33103
|
zTe as screen,
|
|
33100
33104
|
sbe as spyOn,
|
|
33101
33105
|
XTe as uninstrumentedUserEvent,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "storybook",
|
|
3
|
-
"version": "9.1.0-alpha.
|
|
3
|
+
"version": "9.1.0-alpha.9",
|
|
4
4
|
"description": "Storybook framework-agnostic API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -83,6 +83,14 @@
|
|
|
83
83
|
"import": "./dist/core-server/presets/common-override-preset.js",
|
|
84
84
|
"require": "./dist/core-server/presets/common-override-preset.cjs"
|
|
85
85
|
},
|
|
86
|
+
"./internal/core-server/presets/webpack/loaders/webpack-automock-loader": {
|
|
87
|
+
"import": "./dist/core-server/presets/webpack/loaders/webpack-automock-loader.js",
|
|
88
|
+
"require": "./dist/core-server/presets/webpack/loaders/webpack-automock-loader.cjs"
|
|
89
|
+
},
|
|
90
|
+
"./internal/core-server/presets/webpack/loaders/storybook-mock-transform-loader": {
|
|
91
|
+
"import": "./dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js",
|
|
92
|
+
"require": "./dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.cjs"
|
|
93
|
+
},
|
|
86
94
|
"./internal/highlight": {
|
|
87
95
|
"types": "./dist/highlight/index.d.ts",
|
|
88
96
|
"import": "./dist/highlight/index.js",
|
|
@@ -424,6 +432,7 @@
|
|
|
424
432
|
"files": [
|
|
425
433
|
"dist/**/*",
|
|
426
434
|
"assets/**/*",
|
|
435
|
+
"templates/**/*",
|
|
427
436
|
"README.md",
|
|
428
437
|
"!src/**/*"
|
|
429
438
|
],
|
|
@@ -439,6 +448,7 @@
|
|
|
439
448
|
"@testing-library/jest-dom": "^6.6.3",
|
|
440
449
|
"@testing-library/user-event": "^14.6.1",
|
|
441
450
|
"@vitest/expect": "3.2.4",
|
|
451
|
+
"@vitest/mocker": "3.2.4",
|
|
442
452
|
"@vitest/spy": "3.2.4",
|
|
443
453
|
"better-opn": "^3.0.2",
|
|
444
454
|
"esbuild": "^0.18.0 || ^0.19.0 || ^0.20.0 || ^0.21.0 || ^0.22.0 || ^0.23.0 || ^0.24.0 || ^0.25.0",
|
|
@@ -468,6 +478,7 @@
|
|
|
468
478
|
"@radix-ui/react-dialog": "^1.1.2",
|
|
469
479
|
"@radix-ui/react-scroll-area": "1.2.0-rc.7",
|
|
470
480
|
"@radix-ui/react-slot": "^1.0.2",
|
|
481
|
+
"@rolldown/pluginutils": "1.0.0-beta.18",
|
|
471
482
|
"@storybook/docs-mdx": "4.0.0-next.1",
|
|
472
483
|
"@storybook/icons": "^1.4.0",
|
|
473
484
|
"@tanstack/react-virtual": "^3.3.0",
|
|
@@ -479,6 +490,7 @@
|
|
|
479
490
|
"@types/ejs": "^3.1.1",
|
|
480
491
|
"@types/find-cache-dir": "^5.0.0",
|
|
481
492
|
"@types/js-yaml": "^4.0.5",
|
|
493
|
+
"@types/lodash": "^4.17.13",
|
|
482
494
|
"@types/node": "^22.0.0",
|
|
483
495
|
"@types/npmlog": "^7.0.0",
|
|
484
496
|
"@types/picomatch": "^2.3.0",
|
|
@@ -528,6 +540,7 @@
|
|
|
528
540
|
"jsdoc-type-pratt-parser": "^4.0.0",
|
|
529
541
|
"lazy-universal-dotenv": "^4.0.0",
|
|
530
542
|
"leven": "^4.0.0",
|
|
543
|
+
"lodash": "^4.17.21",
|
|
531
544
|
"memfs": "^4.11.1",
|
|
532
545
|
"memoizerific": "^1.11.3",
|
|
533
546
|
"nanoid": "^4.0.2",
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { MockerRegistry } from '@vitest/mocker';
|
|
2
|
+
import { ModuleMocker, createCompilerHints } from '@vitest/mocker/browser';
|
|
3
|
+
|
|
4
|
+
/** An interceptor for module mocking. */
|
|
5
|
+
export class ModuleMockerInterceptor {
|
|
6
|
+
// A registry for runtime mocks (e.g., `sb.mock('path', () => ({}))`)
|
|
7
|
+
mocks = new MockerRegistry();
|
|
8
|
+
|
|
9
|
+
constructor() {}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Called by ModuleMocker when `sb.mock()` is executed. We just store the mock in our registry.
|
|
13
|
+
* The dynamic MSW handler will pick it up on the next relevant network request. Currently, we
|
|
14
|
+
* don't use this.mocks in any way. Mocks will be registered in the user's preview file and live
|
|
15
|
+
* until the end. There is no way to invalidate or delete them.
|
|
16
|
+
*/
|
|
17
|
+
async register(module) {
|
|
18
|
+
this.mocks.add(module);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async delete(url) {
|
|
22
|
+
this.mocks.delete(url);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async invalidate() {
|
|
26
|
+
this.mocks.clear();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Dummy implementation of the RPC interface, since it is not used in build mode.
|
|
31
|
+
const rpc = (method) => {
|
|
32
|
+
switch (method) {
|
|
33
|
+
case 'resolveId':
|
|
34
|
+
return Promise.resolve({
|
|
35
|
+
id: '',
|
|
36
|
+
url: '',
|
|
37
|
+
optimized: false,
|
|
38
|
+
});
|
|
39
|
+
case 'resolveMock':
|
|
40
|
+
return Promise.resolve({
|
|
41
|
+
mockType: 'dummy',
|
|
42
|
+
resolvedId: '',
|
|
43
|
+
resolvedUrl: '',
|
|
44
|
+
redirectUrl: '',
|
|
45
|
+
needsInterop: false,
|
|
46
|
+
});
|
|
47
|
+
case 'invalidate':
|
|
48
|
+
return Promise.resolve();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// In build mode, we don't need runtime handling of mocks.
|
|
53
|
+
// Everything is handled at build time and via the MSW interceptor.
|
|
54
|
+
class BuildModuleMocker extends ModuleMocker {
|
|
55
|
+
queueMock() {
|
|
56
|
+
// noop
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function registerModuleMocker(interceptor) {
|
|
61
|
+
const mocker = new BuildModuleMocker(
|
|
62
|
+
interceptor('__vitest_mocker__'),
|
|
63
|
+
{
|
|
64
|
+
resolveId(id, importer) {
|
|
65
|
+
return rpc('resolveId', { id, importer });
|
|
66
|
+
},
|
|
67
|
+
resolveMock(id, importer, options) {
|
|
68
|
+
return rpc('resolveMock', { id, importer, options });
|
|
69
|
+
},
|
|
70
|
+
async invalidate(ids) {
|
|
71
|
+
return rpc('invalidate', { ids });
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
(...args) => {
|
|
75
|
+
return globalThis.__STORYBOOK_MODULE_TEST__.spyOn(...args);
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
root: '',
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
globalThis['__vitest_mocker__'] = mocker;
|
|
83
|
+
|
|
84
|
+
return createCompilerHints({
|
|
85
|
+
globalThisKey: '__vitest_mocker__',
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
globalThis.__STORYBOOK_MOCKER__ = registerModuleMocker(() => new ModuleMockerInterceptor());
|