Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 9.0.13

- Core: Gracefully handle disallowed cross-origin clipboard access - [#31834](https://github.com/storybookjs/storybook/pull/31834), thanks @ghengeveld!
- Core: Support array-based catch-all Next.js route segments in AppRouterProvider - [#31524](https://github.com/storybookjs/storybook/pull/31524), thanks @yatishgoel!
- Next.js-Vite: Support Next.js v15.4 - [#31828](https://github.com/storybookjs/storybook/pull/31828), thanks @valentinpalkovic!
- React Native Web: Fix shift spread operator in react-native-web-vite presets - [#31804](https://github.com/storybookjs/storybook/pull/31804), thanks @xlecunff-pass!
- Telemetry: Fix prompting without checking isTTY - [#31781](https://github.com/storybookjs/storybook/pull/31781), thanks @Synar!
- Vite: Remove addon-themes and theming from optimized deps list - [#31833](https://github.com/storybookjs/storybook/pull/31833), thanks @ghengeveld!

## 9.0.12

- Addon Vitest: Support init in Vitest >= 3.2 - [#31715](https://github.com/storybookjs/storybook/pull/31715), thanks @valentinpalkovic!
Expand Down
2 changes: 0 additions & 2 deletions code/builders/builder-vite/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export const INCLUDE_CANDIDATES = [
'@storybook/addon-docs/blocks',
'@storybook/addon-docs/preview',
'@storybook/addon-links/preview',
'@storybook/addon-themes',
'@storybook/addon-themes/preview',
'@storybook/html',
'@storybook/html/dist/entry-preview-docs.mjs',
Expand Down Expand Up @@ -136,7 +135,6 @@ export const INCLUDE_CANDIDATES = [
'storybook/internal/preview-api',
'storybook/internal/preview/runtime',
'storybook/preview-api',
'storybook/theming',
'storybook/viewport',
'synchronous-promise',
'telejson',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import type {
SyntaxHighlighterRendererProps,
} from './syntaxhighlighter-types';

const { navigator, document, window: globalWindow } = global;
const { document, window: globalWindow } = global;

export const supportedLanguages = {
jsextra: jsExtras,
Expand All @@ -59,9 +59,14 @@ const themedSyntax = memoize(2)((theme) =>
const copyToClipboard: (text: string) => Promise<void> = createCopyToClipboardFunction();

export function createCopyToClipboardFunction() {
if (globalWindow.top?.navigator?.clipboard) {
const clipboard = globalWindow.top.navigator.clipboard;
return async (text: string) => clipboard.writeText(text);
if (globalWindow.navigator?.clipboard) {
return async (text: string) => {
try {
await globalWindow.top?.navigator.clipboard.writeText(text);
} catch {
await globalWindow.navigator.clipboard.writeText(text);
}
};
}
return async (text: string) => {
const tmp = document.createElement('TEXTAREA') as HTMLTextAreaElement;
Expand Down
4 changes: 2 additions & 2 deletions code/core/src/core-server/withTelemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type TelemetryOptions = {
};

const promptCrashReports = async () => {
if (process.env.CI) {
if (process.env.CI || !process.stdout.isTTY) {
return undefined;
}

Expand Down Expand Up @@ -179,6 +179,6 @@ export async function withTelemetry<T>(

throw error;
} finally {
process.off('SIGINIT', cancelTelemetry);
process.off('SIGINT', cancelTelemetry);
}
}
2 changes: 1 addition & 1 deletion code/frameworks/nextjs-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"@storybook/react": "workspace:*",
"@storybook/react-vite": "workspace:*",
"styled-jsx": "5.1.6",
"vite-plugin-storybook-nextjs": "2.0.2"
"vite-plugin-storybook-nextjs": "^2.0.3"
},
"devDependencies": {
"@types/node": "^22.0.0",
Expand Down
31 changes: 28 additions & 3 deletions code/frameworks/nextjs-vite/src/routing/app-router-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function getSelectedParams(currentTree: FlightRouterState, params: Params = {}):
const isCatchAll = isDynamicParameter && (segment[2] === 'c' || segment[2] === 'oc');

if (isCatchAll) {
params[segment[0]] = segment[1].split('/');
params[segment[0]] = Array.isArray(segment[1]) ? segment[1] : segment[1].split('/');
} else if (isDynamicParameter) {
params[segment[0]] = segment[1];
}
Expand Down Expand Up @@ -77,8 +77,33 @@ export const AppRouterProvider: React.FC<React.PropsWithChildren<AppRouterProvid

const tree: FlightRouterState = [pathname, { children: getParallelRoutes([...segments]) }];
const pathParams = useMemo(() => {
return getSelectedParams(tree);
}, [tree]);
const params: Params = {};
const currentSegments = routeParams.segments;

if (currentSegments) {
if (Array.isArray(currentSegments)) {
for (const segmentEntry of currentSegments) {
if (
Array.isArray(segmentEntry) &&
segmentEntry.length === 2 &&
typeof segmentEntry[0] === 'string'
) {
const key: string = segmentEntry[0];
const value = segmentEntry[1] as string | string[] | undefined;
params[key] = value;
}
}
} else if (typeof currentSegments === 'object' && !Array.isArray(currentSegments)) {
const segmentObject = currentSegments as Record<string, string | string[] | undefined>;
for (const key in segmentObject) {
if (Object.prototype.hasOwnProperty.call(segmentObject, key)) {
params[key] = segmentObject[key];
}
}
}
}
return params;
}, [routeParams.segments]);

const newLazyCacheNode = {
lazyData: null,
Expand Down
31 changes: 28 additions & 3 deletions code/frameworks/nextjs/src/routing/app-router-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function getSelectedParams(currentTree: FlightRouterState, params: Params = {}):
const isCatchAll = isDynamicParameter && (segment[2] === 'c' || segment[2] === 'oc');

if (isCatchAll) {
params[segment[0]] = segment[1].split('/');
params[segment[0]] = Array.isArray(segment[1]) ? segment[1] : segment[1].split('/');
} else if (isDynamicParameter) {
params[segment[0]] = segment[1];
}
Expand Down Expand Up @@ -77,8 +77,33 @@ export const AppRouterProvider: React.FC<React.PropsWithChildren<AppRouterProvid

const tree: FlightRouterState = [pathname, { children: getParallelRoutes([...segments]) }];
const pathParams = useMemo(() => {
return getSelectedParams(tree);
}, [tree]);
const params: Params = {};
const currentSegments = routeParams.segments;

if (currentSegments) {
if (Array.isArray(currentSegments)) {
for (const segmentEntry of currentSegments) {
if (
Array.isArray(segmentEntry) &&
segmentEntry.length === 2 &&
typeof segmentEntry[0] === 'string'
) {
const key: string = segmentEntry[0];
const value = segmentEntry[1] as string | string[] | undefined;
params[key] = value;
}
}
} else if (typeof currentSegments === 'object' && !Array.isArray(currentSegments)) {
const segmentObject = currentSegments as Record<string, string | string[] | undefined>;
for (const key in segmentObject) {
if (Object.prototype.hasOwnProperty.call(segmentObject, key)) {
params[key] = segmentObject[key];
}
}
}
}
return params;
}, [routeParams.segments]);

const newLazyCacheNode = {
lazyData: null,
Expand Down
2 changes: 1 addition & 1 deletion code/frameworks/react-native-web-vite/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ export const viteFinal: StorybookConfig['viteFinal'] = async (config, options) =
],
exclude: pluginBabelOptions.exclude,
babelConfig: {
...pluginBabelOptions.babelConfig,
babelrc: false,
configFile: false,
...pluginBabelOptions.babelConfig,
presets: [
[
'@babel/preset-react',
Expand Down
3 changes: 2 additions & 1 deletion code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,5 +283,6 @@
"Dependency Upgrades"
]
]
}
},
"deferredNextVersion": "9.0.13"
}
10 changes: 5 additions & 5 deletions code/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6523,7 +6523,7 @@ __metadata:
postcss-load-config: "npm:^6.0.1"
styled-jsx: "npm:5.1.6"
typescript: "npm:^5.8.3"
vite-plugin-storybook-nextjs: "npm:2.0.2"
vite-plugin-storybook-nextjs: "npm:^2.0.3"
peerDependencies:
next: ^14.1.0 || ^15.0.0
react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta
Expand Down Expand Up @@ -26919,9 +26919,9 @@ __metadata:
languageName: node
linkType: hard

"vite-plugin-storybook-nextjs@npm:2.0.2":
version: 2.0.2
resolution: "vite-plugin-storybook-nextjs@npm:2.0.2"
"vite-plugin-storybook-nextjs@npm:^2.0.3":
version: 2.0.3
resolution: "vite-plugin-storybook-nextjs@npm:2.0.3"
dependencies:
"@next/env": "npm:^15.0.3"
image-size: "npm:^2.0.0"
Expand All @@ -26933,7 +26933,7 @@ __metadata:
next: ^14.1.0 || ^15.0.0
storybook: ^0.0.0-0 || ^9.0.0 || ^9.1.0-0
vite: ^5.0.0 || ^6.0.0
checksum: 10c0/52db273d836bc5f8d9e7bcd61ee7560acf6499bf041306e9574e009b0d3388fa690379d6c56299ad4870867318716832d2c4cd93a34bb87d565f36abee18d4bb
checksum: 10c0/ab4e87bf6e95fa76046120705a7d8b41c5cf4b266a3a75d0187112e2598e6b7fb624d4bdaa794ce749f4792d6d296e4fba1148bddf21085aa52f58c7c6b98aa3
languageName: node
linkType: hard

Expand Down
6 changes: 6 additions & 0 deletions docs/_snippets/vitest-plugin-vitest-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default mergeConfig(
viteConfig,
defineConfig({
test: {
extends: true,
// Use `workspace` field in Vitest < 3.2
projects: [{
plugins: [
Expand All @@ -25,6 +26,7 @@ export default mergeConfig(
})
],
test: {
name: 'storybook',
// Enable browser mode
browser: {
enabled: true,
Expand Down Expand Up @@ -56,6 +58,7 @@ export default mergeConfig(
viteConfig,
defineConfig({
test: {
extends: true,
// Use `workspace` field in Vitest < 3.2
projects: [{
plugins: [
Expand All @@ -68,6 +71,7 @@ export default mergeConfig(
})
],
test: {
name: 'storybook',
// Enable browser mode
browser: {
enabled: true,
Expand Down Expand Up @@ -99,6 +103,7 @@ export default mergeConfig(
viteConfig,
defineConfig({
test: {
extends: true,
// Use `workspace` field in Vitest < 3.2
projects: [{
plugins: [
Expand All @@ -111,6 +116,7 @@ export default mergeConfig(
})
],
test: {
name: 'storybook',
// Enable browser mode
browser: {
enabled: true,
Expand Down
2 changes: 1 addition & 1 deletion docs/versions/latest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"9.0.12","info":{"plain":"- Addon Vitest: Support init in Vitest >= 3.2 - [#31715](https://github.com/storybookjs/storybook/pull/31715), thanks @valentinpalkovic!\n- CLI: Fix package manager instantiation in empty directories - [#31743](https://github.com/storybookjs/storybook/pull/31743), thanks @yannbf!\n- CLI: Improve support for upgrading Storybook in monorepos - [#31557](https://github.com/storybookjs/storybook/pull/31557), thanks @yannbf!\n- CLI: Show Storybook version in the upgrade command - [#31774](https://github.com/storybookjs/storybook/pull/31774), thanks @yannbf!\n- Core: Enhance package manager install methods to support optional force flag - [#31796](https://github.com/storybookjs/storybook/pull/31796), thanks @valentinpalkovic!"}}
{"version":"9.0.13","info":{"plain":"- Core: Gracefully handle disallowed cross-origin clipboard access - [#31834](https://github.com/storybookjs/storybook/pull/31834), thanks @ghengeveld!\n- Core: Support array-based catch-all Next.js route segments in AppRouterProvider - [#31524](https://github.com/storybookjs/storybook/pull/31524), thanks @yatishgoel!\n- Next.js-Vite: Support Next.js v15.4 - [#31828](https://github.com/storybookjs/storybook/pull/31828), thanks @valentinpalkovic!\n- React Native Web: Fix shift spread operator in react-native-web-vite presets - [#31804](https://github.com/storybookjs/storybook/pull/31804), thanks @xlecunff-pass!\n- Telemetry: Fix prompting without checking isTTY - [#31781](https://github.com/storybookjs/storybook/pull/31781), thanks @Synar!\n- Vite: Remove addon-themes and theming from optimized deps list - [#31833](https://github.com/storybookjs/storybook/pull/31833), thanks @ghengeveld!"}}