Skip to content

Commit ec1c76f

Browse files
authored
Merge pull request #30466 from storybookjs/version-non-patch-from-8.6.0-alpha.4
Release: Prerelease 8.6.0-alpha.5
2 parents 48c2595 + 9f70a39 commit ec1c76f

File tree

112 files changed

+5223
-2105
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+5223
-2105
lines changed

.circleci/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ workflows:
846846
requires:
847847
- create-sandboxes
848848
- test-runner-production:
849-
parallelism: 9
849+
parallelism: 8
850850
requires:
851851
- create-sandboxes
852852
- vitest-integration:
@@ -918,7 +918,7 @@ workflows:
918918
requires:
919919
- create-sandboxes
920920
- test-runner-production:
921-
parallelism: 15
921+
parallelism: 14
922922
requires:
923923
- create-sandboxes
924924
- vitest-integration:
@@ -991,7 +991,7 @@ workflows:
991991
requires:
992992
- create-sandboxes
993993
- test-runner-production:
994-
parallelism: 32
994+
parallelism: 30
995995
requires:
996996
- create-sandboxes
997997
- vitest-integration:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ test-results
1616
.verdaccio-cache
1717
.next
1818
/.npmrc
19+
tsconfig.vitest-temp.json
1920

2021
# Yarn stuff
2122
/**/.yarn/*

CHANGELOG.prerelease.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 8.6.0-alpha.5
2+
3+
- Core: Add `UniversalStore` API to sync state/events between multiple environments - [#30445](https://github.com/storybookjs/storybook/pull/30445), thanks @JReinhold!
4+
- Core: Fix statically serving single files and multiple dirs on the same endpoint - [#30467](https://github.com/storybookjs/storybook/pull/30467), thanks @JReinhold!
5+
- Core: Move CSF to monorepo - [#30488](https://github.com/storybookjs/storybook/pull/30488), thanks @kasperpeulen!
6+
- React: Update react-docgen-typescript to fix CI hanging issues - [#30422](https://github.com/storybookjs/storybook/pull/30422), thanks @yannbf!
7+
18
## 8.6.0-alpha.4
29

310
- Addon A11y: Make Vitest Axe optional - [#30442](https://github.com/storybookjs/storybook/pull/30442), thanks @valentinpalkovic!

MIGRATION.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
- [From version 8.5.x to 8.6.x](#from-version-85x-to-86x)
44
- [Angular: Support experimental zoneless support](#angular-support-experimental-zoneless-support)
5+
- [From version 8.4.x to 8.5.x](#from-version-84x-to-85x)
6+
- [React Vite: react-docgen-typescript is updated](#react-vite-react-docgen-typescript-is-updated)
7+
- [Introducing features.developmentModeForBuild](#introducing-featuresdevelopmentmodeforbuild)
58
- [Added source code panel to docs](#added-source-code-panel-to-docs)
69
- [Addon-a11y: Component test integration](#addon-a11y-component-test-integration)
710
- [Addon-a11y: Changing the default element selector](#addon-a11y-changing-the-default-element-selector)
@@ -460,6 +463,26 @@ Storybook now supports [Angular's experimental zoneless mode](https://angular.de
460463

461464
## From version 8.4.x to 8.5.x
462465

466+
### React Vite: react-docgen-typescript is updated
467+
468+
Storybook now uses [react-docgen-typescript](https://github.com/joshwooding/vite-plugin-react-docgen-typescript) v0.5.0 which updates its internal logic on how it parses files, available under an experimental feature flag `EXPERIMENTAL_useWatchProgram`, which is disabled by default.
469+
470+
Previously, once you made changes to a component's props, the controls and args table would not update unless you restarted Storybook. With the `EXPERIMENTAL_useWatchProgram` flag, you do not need to restart Storybook anymore, however you do need to refresh the browser page. Keep in mind that this flag is experimental and also does not support the `references` field in tsconfig.json files. Depending on how big your codebase is, it might have performance issues.
471+
472+
```ts
473+
// .storybook/main.ts
474+
const config = {
475+
// ...
476+
typescript: {
477+
reactDocgen: "react-docgen-typescript",
478+
reactDocgenTypescriptOptions: {
479+
EXPERIMENTAL_useWatchProgram: true,
480+
},
481+
},
482+
};
483+
export default config;
484+
```
485+
463486
### Introducing features.developmentModeForBuild
464487

465488
As part of our ongoing efforts to improve the testability and debuggability of Storybook, we are introducing a new feature flag: `developmentModeForBuild`. This feature flag allows you to set `process.env.NODE_ENV` to `development` in built Storybooks, enabling development-related optimizations that are typically disabled in production builds.
@@ -473,7 +496,7 @@ export default {
473496
developmentModeForBuild: true,
474497
},
475498
};
476-
````
499+
```
477500

478501
### Added source code panel to docs
479502

code/.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ module.exports = {
9393
'**/__tests__/**',
9494
'**/__testfixtures__/**',
9595
'**/*.test.*',
96+
'**/*.test-d.*',
9697
'**/*.stories.*',
9798
'**/*.mockdata.*',
9899
'**/template/**/*',

code/addons/a11y/src/preview.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @vitest-environment happy-dom
22
import { beforeEach, describe, expect, it, vi } from 'vitest';
33

4-
import type { StoryContext } from '@storybook/csf';
4+
import type { StoryContext } from 'storybook/internal/csf';
55

66
import { run } from './a11yRunner';
77
import { A11Y_TEST_TAG } from './constants';

code/addons/controls/src/manager.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type {
77
SaveStoryResponsePayload,
88
} from 'storybook/internal/core-events';
99
import { SAVE_STORY_REQUEST, SAVE_STORY_RESPONSE } from 'storybook/internal/core-events';
10+
import type { Args } from 'storybook/internal/csf';
1011
import {
1112
addons,
1213
experimental_requestResponse,
@@ -15,8 +16,6 @@ import {
1516
} from 'storybook/internal/manager-api';
1617
import { color } from 'storybook/internal/theming';
1718

18-
import type { Args } from '@storybook/csf';
19-
2019
import { dequal as deepEqual } from 'dequal';
2120

2221
import { ControlsPanel } from './ControlsPanel';

code/addons/docs/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@
106106
"@storybook/blocks": "workspace:*",
107107
"@storybook/csf-plugin": "workspace:*",
108108
"@storybook/react-dom-shim": "workspace:*",
109-
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
110-
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
109+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
110+
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
111111
"ts-dedent": "^2.0.0"
112112
},
113113
"devDependencies": {
114114
"@mdx-js/mdx": "^3.0.0",
115115
"@rollup/pluginutils": "^5.0.2",
116-
"@types/react": "^16.8.0 || ^17.0.0 || ^18.0.0",
116+
"@types/react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
117117
"react": "^18.2.0",
118118
"react-dom": "^18.2.0",
119119
"rehype-external-links": "^3.0.0",

code/addons/links/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
"prep": "jiti ../../../scripts/prepare/addon-bundle.ts"
6666
},
6767
"dependencies": {
68-
"@storybook/csf": "0.1.12",
6968
"@storybook/global": "^5.0.0",
7069
"ts-dedent": "^2.0.0"
7170
},

code/addons/links/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { SELECT_STORY, STORY_CHANGED } from 'storybook/internal/core-events';
2+
import { toId } from 'storybook/internal/csf';
23
import { addons, makeDecorator } from 'storybook/internal/preview-api';
34
import type { ComponentTitle, StoryId, StoryKind, StoryName } from 'storybook/internal/types';
45

5-
import { toId } from '@storybook/csf';
66
import { global } from '@storybook/global';
77

88
import { PARAM_KEY } from './constants';

code/addons/test/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
"prep": "jiti ../../../scripts/prepare/addon-bundle.ts"
8282
},
8383
"dependencies": {
84-
"@storybook/csf": "0.1.12",
8584
"@storybook/global": "^5.0.0",
8685
"@storybook/icons": "^1.2.12",
8786
"@storybook/instrumenter": "workspace:*",

code/addons/test/src/components/TestProviderRender.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ import {
2020
type TestProviderConfig,
2121
type TestProviderState,
2222
} from 'storybook/internal/core-events';
23+
import type { Tag } from 'storybook/internal/csf';
2324
import { addons, useStorybookState } from 'storybook/internal/manager-api';
2425
import type { API } from 'storybook/internal/manager-api';
2526
import { styled, useTheme } from 'storybook/internal/theming';
2627

27-
import type { Tag } from '@storybook/csf';
2828
import {
2929
AccessibilityIcon,
3030
EditIcon,

code/addons/test/src/vitest-plugin/viewports.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/* eslint-disable no-underscore-dangle */
2+
import type { Globals, Parameters } from 'storybook/internal/csf';
23
import { UnsupportedViewportDimensionError } from 'storybook/internal/preview-errors';
34

4-
import type { Globals, Parameters } from '@storybook/csf';
5-
65
import { MINIMAL_VIEWPORTS } from '../../../viewport/src/defaults';
76
import type { ViewportMap, ViewportStyles } from '../../../viewport/src/types';
87

code/core/package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@
9797
"import": "./dist/csf-tools/index.js",
9898
"require": "./dist/csf-tools/index.cjs"
9999
},
100+
"./csf": {
101+
"types": "./dist/csf/index.d.ts",
102+
"import": "./dist/csf/index.js",
103+
"require": "./dist/csf/index.cjs"
104+
},
100105
"./common": {
101106
"types": "./dist/common/index.d.ts",
102107
"import": "./dist/common/index.js",
@@ -219,6 +224,9 @@
219224
"csf-tools": [
220225
"./dist/csf-tools/index.d.ts"
221226
],
227+
"csf": [
228+
"./dist/csf/index.d.ts"
229+
],
222230
"common": [
223231
"./dist/common/index.d.ts"
224232
],
@@ -274,7 +282,6 @@
274282
"prep": "jiti ./scripts/prep.ts"
275283
},
276284
"dependencies": {
277-
"@storybook/csf": "0.1.12",
278285
"@storybook/theming": "workspace:*",
279286
"better-opn": "^3.0.2",
280287
"browser-assert": "^1.2.1",
@@ -303,6 +310,7 @@
303310
"@emotion/use-insertion-effect-with-fallbacks": "^1.2.0",
304311
"@fal-works/esbuild-plugin-global-externals": "^2.1.2",
305312
"@ndelangen/get-tarball": "^3.0.7",
313+
"@ngard/tiny-isequal": "^1.1.0",
306314
"@polka/compression": "^1.0.0-next.28",
307315
"@popperjs/core": "^2.6.0",
308316
"@radix-ui/react-dialog": "^1.1.2",

code/core/scripts/entries.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const getEntries = (cwd: string) => {
2525
define('src/channels/index.ts', ['browser', 'node'], true),
2626
define('src/types/index.ts', ['browser', 'node'], true, ['react']),
2727
define('src/csf-tools/index.ts', ['node'], true),
28+
define('src/csf/index.ts', ['browser', 'node'], true),
2829
define('src/common/index.ts', ['node'], true),
2930
define('src/builder-manager/index.ts', ['node'], true),
3031
define('src/telemetry/index.ts', ['node'], true),

code/core/src/channels/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/// <reference path="../typings.d.ts" />
22
import { global } from '@storybook/global';
33

4+
import { UniversalStore } from '../shared/universal-store';
45
import { Channel } from './main';
56
import { PostMessageTransport } from './postmessage';
67
import type { ChannelTransport, Config } from './types';
@@ -39,7 +40,14 @@ export function createBrowserChannel({ page, extraTransports = [] }: Options): C
3940
transports.push(new WebsocketTransport({ url: channelUrl, onError: () => {}, page }));
4041
}
4142

42-
return new Channel({ transports });
43+
const channel = new Channel({ transports });
44+
// eslint-disable-next-line no-underscore-dangle
45+
UniversalStore.__prepare(
46+
channel,
47+
page === 'manager' ? UniversalStore.Environment.MANAGER : UniversalStore.Environment.PREVIEW
48+
);
49+
50+
return channel;
4351
}
4452

4553
export type { Listener, ChannelEvent, ChannelTransport, ChannelHandler } from './types';

code/core/src/common/utils/get-story-id.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { relative } from 'node:path';
22

33
import { normalizeStories, normalizeStoryPath } from '@storybook/core/common';
4+
import { sanitize, storyNameFromExport, toId } from '@storybook/core/csf';
45
import type { Options, StoriesEntry } from '@storybook/core/types';
5-
import { sanitize, storyNameFromExport, toId } from '@storybook/csf';
66

77
import { userOrAutoTitleFromSpecifier } from '@storybook/core/preview-api';
88

code/core/src/components/components/addon-panel/addon-panel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ReactNode } from 'react';
1+
import type { ReactElement } from 'react';
22
import React, { useEffect, useRef } from 'react';
33

44
const usePrevious = (value: any) => {
@@ -20,7 +20,7 @@ const useUpdate = (update: boolean, value: any) => {
2020

2121
export interface AddonPanelProps {
2222
active: boolean;
23-
children: ReactNode;
23+
children: ReactElement;
2424
}
2525

2626
export const AddonPanel = ({ active, children }: AddonPanelProps) => {

code/core/src/components/components/tabs/tabs.hooks.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useCallback, useLayoutEffect, useRef, useState } from 'react';
22

3+
import { sanitize } from '@storybook/core/csf';
34
import { styled } from '@storybook/core/theming';
4-
import { sanitize } from '@storybook/csf';
55

66
import useResizeObserver from 'use-resize-observer';
77

code/core/src/components/components/tabs/tabs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type { FC, PropsWithChildren, ReactElement, ReactNode, SyntheticEvent } from 'react';
22
import React, { Component, memo, useMemo } from 'react';
33

4+
import { sanitize } from '@storybook/core/csf';
45
import { styled } from '@storybook/core/theming';
56
import type { Addon_RenderOptions } from '@storybook/core/types';
6-
import { sanitize } from '@storybook/csf';
77

88
import { FlexBar } from '../bar/bar';
99
import { TabButton } from '../bar/button';

code/core/src/core-events/data/argtypes-info.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ArgTypes } from '@storybook/csf';
1+
import type { ArgTypes } from '@storybook/core/csf';
22

33
export interface ArgTypesRequestPayload {
44
storyId: string;

code/core/src/core-server/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ export { mapStaticDir } from './utils/server-statics';
1010
export { StoryIndexGenerator } from './utils/StoryIndexGenerator';
1111

1212
export { loadStorybook as experimental_loadStorybook } from './load';
13+
14+
export { UniversalStore as experimental_UniversalStore } from '../shared/universal-store';

code/core/src/core-server/utils/StoryIndexGenerator.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { join } from 'node:path';
44
import { beforeEach, describe, expect, it, vi } from 'vitest';
55

66
import { normalizeStoriesEntry } from '@storybook/core/common';
7+
import { toId } from '@storybook/core/csf';
78
import type { NormalizedStoriesSpecifier, StoryIndexEntry } from '@storybook/core/types';
8-
import { toId } from '@storybook/csf';
99

1010
import { getStorySortParameter, readCsf } from '@storybook/core/csf-tools';
1111
import { logger, once } from '@storybook/core/node-logger';
@@ -14,8 +14,8 @@ import { csfIndexer } from '../presets/common-preset';
1414
import type { StoryIndexGeneratorOptions } from './StoryIndexGenerator';
1515
import { StoryIndexGenerator } from './StoryIndexGenerator';
1616

17-
vi.mock('@storybook/csf', async (importOriginal) => {
18-
const csf = await importOriginal<typeof import('@storybook/csf')>();
17+
vi.mock('@storybook/core/csf', async (importOriginal) => {
18+
const csf = await importOriginal<typeof import('@storybook/core/csf')>();
1919
return {
2020
...csf,
2121
toId: vi.fn(csf.toId),

code/core/src/core-server/utils/StoryIndexGenerator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { readFile } from 'node:fs/promises';
44
import { dirname, extname, join, normalize, relative, resolve, sep } from 'node:path';
55

66
import { commonGlobOptions, normalizeStoryPath } from '@storybook/core/common';
7+
import { combineTags, storyNameFromExport, toId } from '@storybook/core/csf';
78
import type {
89
DocsIndexEntry,
910
DocsOptions,
@@ -17,7 +18,6 @@ import type {
1718
StorybookConfigRaw,
1819
Tag,
1920
} from '@storybook/core/types';
20-
import { combineTags, storyNameFromExport, toId } from '@storybook/csf';
2121

2222
import { getStorySortParameter, loadConfig } from '@storybook/core/csf-tools';
2323
import { logger, once } from '@storybook/core/node-logger';

code/core/src/core-server/utils/get-server-channel.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { Channel, HEARTBEAT_INTERVAL } from '@storybook/core/channels';
44
import { isJSON, parse, stringify } from 'telejson';
55
import WebSocket, { WebSocketServer } from 'ws';
66

7+
import { UniversalStore } from '../../shared/universal-store';
8+
79
type Server = NonNullable<NonNullable<ConstructorParameters<typeof WebSocketServer>[0]>['server']>;
810

911
/**
@@ -72,7 +74,12 @@ export class ServerChannelTransport {
7274
export function getServerChannel(server: Server) {
7375
const transports = [new ServerChannelTransport(server)];
7476

75-
return new Channel({ transports, async: true });
77+
const channel = new Channel({ transports, async: true });
78+
79+
// eslint-disable-next-line no-underscore-dangle
80+
UniversalStore.__prepare(channel, UniversalStore.Environment.SERVER);
81+
82+
return channel;
7683
}
7784

7885
// for backwards compatibility

code/core/src/core-server/utils/save-story/save-story.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { basename, join } from 'node:path';
44

55
import type { Channel } from '@storybook/core/channels';
66
import { formatFileContent } from '@storybook/core/common';
7+
import { storyNameFromExport, toId } from '@storybook/core/csf';
78
import { isExampleStoryId, telemetry } from '@storybook/core/telemetry';
89
import type { CoreConfig, Options } from '@storybook/core/types';
9-
import { storyNameFromExport, toId } from '@storybook/csf';
1010

1111
import type {
1212
RequestData,

0 commit comments

Comments
 (0)