Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.prerelease.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 10.4.0-alpha.2

- CLI: Use npm info to fetch versions in repro command - [#34214](https://github.com/storybookjs/storybook/pull/34214), thanks @yannbf!
- Core: Prevent story-local viewport from persisting in URL - [#34153](https://github.com/storybookjs/storybook/pull/34153), thanks @ghengeveld!
- Maintenance: Remove dead-code copy of wrap-getAbsolutePath-utils - [#34168](https://github.com/storybookjs/storybook/pull/34168), thanks @mixelburg!
- Security: Makes sure `serialize-javascript` is at latest version - [#34034](https://github.com/storybookjs/storybook/pull/34034), thanks @50bbx!

## 10.4.0-alpha.1

- Docs: Ensure unique control id attributes across multiple Controls blocks - [#34021](https://github.com/storybookjs/storybook/pull/34021), thanks @TheSeydiCharyyev!
Expand Down
2 changes: 1 addition & 1 deletion code/builders/builder-webpack5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"html-webpack-plugin": "^5.5.0",
"magic-string": "^0.30.5",
"style-loader": "^4.0.0",
"terser-webpack-plugin": "^5.3.14",
"terser-webpack-plugin": "^5.3.17",
"ts-dedent": "^2.0.0",
"webpack": "5",
"webpack-dev-middleware": "^6.1.2",
Expand Down
12 changes: 5 additions & 7 deletions code/core/src/manager-api/modules/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,22 +130,20 @@ export const init: ModuleFn<SubAPI, SubState> = ({ store, fullAPI, provider }) =
SET_GLOBALS,
function handleSetGlobals(this: any, { globals, globalTypes }: SetGlobalsPayload) {
const { ref } = getEventMetadata(this, fullAPI)!;
const currentGlobals = store.getState()?.globals;
const currentUserGlobals = store.getState()?.userGlobals;

if (!ref) {
store.setState({ globals, userGlobals: globals, globalTypes });
} else if (Object.keys(globals).length > 0) {
logger.warn('received globals from a non-local ref. This is not currently supported.');
}

// If we have stored globals different to what the preview just inited with,
// we should update it to those values
if (
currentGlobals &&
Object.keys(currentGlobals).length !== 0 &&
!deepEqual(globals, currentGlobals)
currentUserGlobals &&
Object.keys(currentUserGlobals).length !== 0 &&
!deepEqual(globals, currentUserGlobals)
) {
api.updateGlobals(currentGlobals);
api.updateGlobals(currentUserGlobals);
}
}
);
Expand Down
28 changes: 27 additions & 1 deletion code/core/src/manager-api/tests/globals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('globals API', () => {
});
});

it('emits UPDATE_GLOBALS if retains a globals value different to what receives on SET_GLOBALS', () => {
it('emits UPDATE_GLOBALS if retains a user globals value different to what receives on SET_GLOBALS', () => {
const channel = new EventEmitter();
const listener = vi.fn();
channel.on(UPDATE_GLOBALS, listener);
Expand All @@ -83,6 +83,7 @@ describe('globals API', () => {
} as unknown as ModuleArgs);
store.setState({
...state,
userGlobals: { a: 'c' },
globals: { a: 'c' },
});

Expand All @@ -103,6 +104,31 @@ describe('globals API', () => {
});
});

it('does not push story globals to preview when SET_GLOBALS fires with empty globals', () => {
const channel = new EventEmitter();
const listener = vi.fn();
channel.on(UPDATE_GLOBALS, listener);

const store = createMockStore();
const { state } = initModule({
store,
provider: { channel },
} as unknown as ModuleArgs);
store.setState({
...state,
userGlobals: {},
storyGlobals: { viewport: 'mobile1' },
globals: { viewport: 'mobile1' },
});

channel.emit(SET_GLOBALS, {
globals: {},
globalTypes: {},
} satisfies SetGlobalsPayload);

expect(listener).not.toHaveBeenCalled();
});

it('ignores SET_STORIES from other refs', () => {
const channel = new EventEmitter();
const api = { findRef: vi.fn() };
Expand Down

This file was deleted.

8 changes: 4 additions & 4 deletions code/lib/cli-storybook/src/sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { existsSync } from 'node:fs';
import { mkdir, readdir, rm } from 'node:fs/promises';
import { isAbsolute } from 'node:path';

import type { PackageManagerName } from 'storybook/internal/common';
import { PackageManagerName } from 'storybook/internal/common';
import {
JsPackageManagerFactory,
isCI,
Expand Down Expand Up @@ -42,10 +42,10 @@ export const sandbox = async ({
let selectedConfig: Template | undefined = TEMPLATES[filterValue as TemplateKey];
let templateId: Choice | null = selectedConfig ? (filterValue as TemplateKey) : null;

const { packageManager: pkgMgr } = options;

// Always use npm to fetch versions, as other package manager commands may fail when running in
// non-project directories (e.g. parent sandbox directory). We just need to use npm info for this use case.
const packageManager = JsPackageManagerFactory.getPackageManager({
force: pkgMgr,
force: PackageManagerName.NPM,
});
const latestVersion = (await packageManager.latestVersion('storybook'))!;
const nextVersion = (await packageManager.latestVersion('storybook@next')) ?? '0.0.0';
Expand Down
3 changes: 2 additions & 1 deletion code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,5 +209,6 @@
"Dependency Upgrades"
]
]
}
},
"deferredNextVersion": "10.4.0-alpha.2"
}
2 changes: 1 addition & 1 deletion docs/versions/next.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"10.4.0-alpha.1","info":{"plain":"- Docs: Ensure unique control id attributes across multiple Controls blocks - [#34021](https://github.com/storybookjs/storybook/pull/34021), thanks @TheSeydiCharyyev!"}}
{"version":"10.4.0-alpha.2","info":{"plain":"- CLI: Use npm info to fetch versions in repro command - [#34214](https://github.com/storybookjs/storybook/pull/34214), thanks @yannbf!\n- Core: Prevent story-local viewport from persisting in URL - [#34153](https://github.com/storybookjs/storybook/pull/34153), thanks @ghengeveld!\n- Maintenance: Remove dead-code copy of wrap-getAbsolutePath-utils - [#34168](https://github.com/storybookjs/storybook/pull/34168), thanks @mixelburg!\n- Security: Makes sure `serialize-javascript` is at latest version - [#34034](https://github.com/storybookjs/storybook/pull/34034), thanks @50bbx!"}}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
"playwright": "1.58.2",
"playwright-core": "1.58.2",
"react": "^18.2.0",
"serialize-javascript": "^3.1.0",
"type-fest": "~2.19",
"typescript": "^5.9.3"
},
Expand Down
1 change: 0 additions & 1 deletion scripts/ecosystem-ci/existing-resolutions.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export const EXISTING_RESOLUTIONS = new Set([
'playwright',
'playwright-core',
'react',
'serialize-javascript',
'type-fest',
'typescript',
]);
Loading
Loading