Skip to content

Commit

Permalink
Merge branch 'next' into my-first-storybook-contribution
Browse files Browse the repository at this point in the history
  • Loading branch information
ndelangen authored May 1, 2024
2 parents 3ed89f3 + 4537146 commit f4b07b5
Show file tree
Hide file tree
Showing 20 changed files with 125 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ jobs:
yarn docs:prettier:check
build:
executor:
class: large
class: xlarge
name: sb_node_16_classic
steps:
- git-shallow-clone/checkout_advanced:
Expand Down
2 changes: 1 addition & 1 deletion code/addons/actions/src/components/ActionLogger/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const ActionLogger = ({ actions, onClear }: ActionLoggerProps) => (
sortObjectKeys
showNonenumerable={false}
name={action.data.name}
data={action.data.args || action.data}
data={action.data.args ?? action.data}
/>
</InspectorContainer>
</Action>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default {
},
parameters: {
actions: { argTypesRegex: '^on[A-Z].*' },
chromatic: { disable: true },
},
};

Expand Down
2 changes: 1 addition & 1 deletion code/addons/links/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"prep": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/addon-bundle.ts"
},
"dependencies": {
"@storybook/csf": "^0.1.4",
"@storybook/csf": "^0.1.5",
"@storybook/global": "^5.0.0",
"ts-dedent": "^2.0.0"
},
Expand Down
15 changes: 15 additions & 0 deletions code/builders/builder-vite/src/assetsInclude.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { InlineConfig as ViteInlineConfig } from 'vite';

export function getAssetsInclude(config: ViteInlineConfig, newPath: string[]): (string | RegExp)[] {
const { assetsInclude } = config;

if (!assetsInclude) {
return newPath;
}

if (Array.isArray(assetsInclude)) {
return [...assetsInclude, ...newPath];
} else {
return [assetsInclude, ...newPath];
}
}
3 changes: 2 additions & 1 deletion code/builders/builder-vite/src/vite-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Options } from '@storybook/types';
import { commonConfig } from './vite-config';
import { getOptimizeDeps } from './optimizeDeps';
import { sanitizeEnvVars } from './envs';
import { getAssetsInclude } from './assetsInclude';

export async function createViteServer(options: Options, devServer: Server) {
const { presets } = options;
Expand All @@ -12,7 +13,7 @@ export async function createViteServer(options: Options, devServer: Server) {
const config = {
...commonCfg,
// Needed in Vite 5: https://github.com/storybookjs/storybook/issues/25256
assetsInclude: ['/sb-preview/**'],
assetsInclude: getAssetsInclude(commonCfg, ['/sb-preview/**']),
// Set up dev server
server: {
middlewareMode: true,
Expand Down
2 changes: 1 addition & 1 deletion code/lib/codemod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@babel/core": "^7.23.2",
"@babel/preset-env": "^7.23.2",
"@babel/types": "^7.23.0",
"@storybook/csf": "^0.1.4",
"@storybook/csf": "^0.1.5",
"@storybook/csf-tools": "workspace:*",
"@storybook/node-logger": "workspace:*",
"@storybook/types": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion code/lib/core-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"@storybook/channels": "workspace:*",
"@storybook/core-common": "workspace:*",
"@storybook/core-events": "workspace:*",
"@storybook/csf": "^0.1.4",
"@storybook/csf": "^0.1.5",
"@storybook/csf-tools": "workspace:*",
"@storybook/docs-mdx": "3.0.0",
"@storybook/global": "^5.0.0",
Expand Down
2 changes: 1 addition & 1 deletion code/lib/csf-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@babel/parser": "^7.23.0",
"@babel/traverse": "^7.23.2",
"@babel/types": "^7.23.0",
"@storybook/csf": "^0.1.4",
"@storybook/csf": "^0.1.5",
"@storybook/types": "workspace:*",
"fs-extra": "^11.1.0",
"recast": "^0.23.5",
Expand Down
2 changes: 1 addition & 1 deletion code/lib/manager-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@storybook/channels": "workspace:*",
"@storybook/client-logger": "workspace:*",
"@storybook/core-events": "workspace:*",
"@storybook/csf": "^0.1.4",
"@storybook/csf": "^0.1.5",
"@storybook/global": "^5.0.0",
"@storybook/icons": "^1.2.5",
"@storybook/router": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion code/lib/preview-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@storybook/channels": "workspace:*",
"@storybook/client-logger": "workspace:*",
"@storybook/core-events": "workspace:*",
"@storybook/csf": "^0.1.4",
"@storybook/csf": "^0.1.5",
"@storybook/global": "^5.0.0",
"@storybook/types": "workspace:*",
"@types/qs": "^6.9.5",
Expand Down
54 changes: 54 additions & 0 deletions code/lib/preview-api/src/modules/preview-web/PreviewWeb.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2735,6 +2735,60 @@ describe('PreviewWeb', () => {
});
});

describe('if called twice simultaneously', () => {
it('does not get renders confused', async () => {
const [blockImportFnGate, openBlockImportFnGate] = createGate();
const [importFnCalledGate, openImportFnCalledGate] = createGate();
const newImportFn = vi.fn(async (path) => {
openImportFnCalledGate();
await blockImportFnGate;
return importFn(path);
});

document.location.search = '?id=component-one--a';
const preview = await createAndRenderPreview();
mockChannel.emit.mockClear();

preview.onStoriesChanged({ importFn: newImportFn });
await importFnCalledGate;
preview.onStoriesChanged({ importFn });

openBlockImportFnGate();
await waitForRender();

expect(preview.storyRenders.length).toEqual(1);
});

it('renders the second importFn', async () => {
const [importGate, openImportGate] = createGate();
const [importedGate, openImportedGate] = createGate();
const secondImportFn = vi.fn(async (path) => {
openImportedGate();
await importGate;
return importFn(path);
});

const thirdImportFn = vi.fn(async (path) => {
openImportedGate();
await importGate;
return importFn(path);
});

document.location.search = '?id=component-one--a';
const preview = await createAndRenderPreview();
mockChannel.emit.mockClear();

preview.onStoriesChanged({ importFn: secondImportFn });
await importedGate;
preview.onStoriesChanged({ importFn: thirdImportFn });

openImportGate();
await waitForRender();

expect(thirdImportFn).toHaveBeenCalled();
});
});

describe('when the current story changes', () => {
const newComponentOneExports = merge({}, componentOneExports, {
a: { args: { foo: 'edited' } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,8 @@ export class PreviewWithSelection<TRenderer extends Renderer> extends Preview<TR
try {
await render.prepare();
} catch (err) {
if (err !== PREPARE_ABORTED) {
// We are about to render an error so make sure the previous story is
// no longer rendered.
if (lastRender) await this.teardownRender(lastRender);
this.renderStoryLoadingException(storyId, err as Error);
}
if (lastRender) await this.teardownRender(lastRender);
if (err !== PREPARE_ABORTED) this.renderStoryLoadingException(storyId, err as Error);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion code/lib/source-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"prep": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/bundle.ts"
},
"dependencies": {
"@storybook/csf": "^0.1.4",
"@storybook/csf": "^0.1.5",
"@storybook/types": "workspace:*",
"estraverse": "^5.2.0",
"lodash": "^4.17.21",
Expand Down
2 changes: 1 addition & 1 deletion code/lib/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"file-system-cache": "2.3.0"
},
"devDependencies": {
"@storybook/csf": "^0.1.4",
"@storybook/csf": "^0.1.5",
"@types/fs-extra": "^11.0.1",
"@types/node": "^18.0.0",
"typescript": "^5.3.2"
Expand Down
2 changes: 1 addition & 1 deletion code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
"@storybook/core-events": "workspace:*",
"@storybook/core-server": "workspace:*",
"@storybook/core-webpack": "workspace:*",
"@storybook/csf": "^0.1.4",
"@storybook/csf": "^0.1.5",
"@storybook/csf-plugin": "workspace:*",
"@storybook/csf-tools": "workspace:*",
"@storybook/docs-tools": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion code/renderers/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"prep": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/bundle.ts"
},
"dependencies": {
"@storybook/csf": "^0.1.4",
"@storybook/csf": "^0.1.5",
"@storybook/csf-tools": "workspace:*",
"@storybook/global": "^5.0.0",
"@storybook/preview-api": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion code/ui/blocks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"@storybook/client-logger": "workspace:*",
"@storybook/components": "workspace:*",
"@storybook/core-events": "workspace:*",
"@storybook/csf": "^0.1.4",
"@storybook/csf": "^0.1.5",
"@storybook/docs-tools": "workspace:*",
"@storybook/global": "^5.0.0",
"@storybook/icons": "^1.2.5",
Expand Down
2 changes: 1 addition & 1 deletion code/ui/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"dependencies": {
"@radix-ui/react-slot": "^1.0.2",
"@storybook/client-logger": "workspace:*",
"@storybook/csf": "^0.1.4",
"@storybook/csf": "^0.1.5",
"@storybook/global": "^5.0.0",
"@storybook/icons": "^1.2.5",
"@storybook/theming": "workspace:*",
Expand Down
Loading

0 comments on commit f4b07b5

Please sign in to comment.