From 48202bd94967f3aa25b95456d4f6ada4e4c4512e Mon Sep 17 00:00:00 2001 From: storybook-bot <32066757+storybook-bot@users.noreply.github.com> Date: Wed, 10 Jul 2024 08:48:28 +0000 Subject: [PATCH 1/4] Update ./docs/versions/next.json for v8.3.0-alpha.0 --- docs/versions/next.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/versions/next.json b/docs/versions/next.json index b160c6c0c8e3..5ca4ed6ffcb7 100644 --- a/docs/versions/next.json +++ b/docs/versions/next.json @@ -1 +1 @@ -{"version":"8.2.0-beta.3","info":{"plain":"- Addon Controls: Fix saving on Windows - [#28485](https://github.com/storybookjs/storybook/pull/28485), thanks @ghengeveld!\n- React: Export ButtonProps and HeaderProps in CLI templates - [#28487](https://github.com/storybookjs/storybook/pull/28487), thanks @valentinpalkovic!"}} +{"version":"8.3.0-alpha.0","info":{"plain":""}} From ffe743f76177b855a4759e3dcfe231b6736974a1 Mon Sep 17 00:00:00 2001 From: Valentin Palkovic Date: Wed, 10 Jul 2024 12:13:28 +0200 Subject: [PATCH 2/4] Merge pull request #28503 from storybookjs/valentin/fix-core-dist-type-creation Types: Update type signatures of objects and functions (cherry picked from commit 6598f73019b1af30a753347302afb07d090f9ef6) --- .../frameworks/nextjs/src/portable-stories.ts | 3 ++- .../react/src/docs/extractArgTypes.ts | 2 +- .../renderers/react/src/entry-preview-docs.ts | 11 +++++++++- code/renderers/react/src/portable-stories.tsx | 3 ++- .../svelte/src/docs/extractArgTypes.ts | 4 +++- .../svelte/src/entry-preview-docs.ts | 11 +++++++++- code/renderers/svelte/src/portable-stories.ts | 2 +- .../vue3/src/docs/extractArgTypes.ts | 2 +- code/renderers/vue3/src/entry-preview-docs.ts | 11 +++++++++- code/renderers/vue3/src/portable-stories.ts | 3 ++- .../web-components/src/entry-preview-docs.ts | 21 +++++++++++++++++-- 11 files changed, 61 insertions(+), 12 deletions(-) diff --git a/code/frameworks/nextjs/src/portable-stories.ts b/code/frameworks/nextjs/src/portable-stories.ts index 52aacbb592bc..bc00b0ba9f18 100644 --- a/code/frameworks/nextjs/src/portable-stories.ts +++ b/code/frameworks/nextjs/src/portable-stories.ts @@ -11,6 +11,7 @@ import type { Store_CSFExports, StoriesWithPartialProps, NamedOrDefaultProjectAnnotations, + ComposedStoryFn, } from 'storybook/internal/types'; // ! ATTENTION: This needs to be a relative import so it gets prebundled. This is to avoid ESM issues in Nextjs + Jest setups @@ -80,7 +81,7 @@ export function composeStory( componentAnnotations: Meta, projectAnnotations?: ProjectAnnotations, exportsName?: string -) { +): ComposedStoryFn> { return originalComposeStory( story as StoryAnnotationsOrFn, componentAnnotations, diff --git a/code/renderers/react/src/docs/extractArgTypes.ts b/code/renderers/react/src/docs/extractArgTypes.ts index c7cac4c96a81..efa23a7df28c 100644 --- a/code/renderers/react/src/docs/extractArgTypes.ts +++ b/code/renderers/react/src/docs/extractArgTypes.ts @@ -2,7 +2,7 @@ import type { StrictArgTypes } from 'storybook/internal/types'; import type { PropDef, ArgTypesExtractor } from 'storybook/internal/docs-tools'; import { extractProps } from './extractProps'; -export const extractArgTypes: ArgTypesExtractor = (component) => { +export const extractArgTypes: ArgTypesExtractor = (component): StrictArgTypes | null => { if (component) { const { rows } = extractProps(component); if (rows) { diff --git a/code/renderers/react/src/entry-preview-docs.ts b/code/renderers/react/src/entry-preview-docs.ts index 5bdcd7f2c40f..ad3146a94fe5 100644 --- a/code/renderers/react/src/entry-preview-docs.ts +++ b/code/renderers/react/src/entry-preview-docs.ts @@ -1,11 +1,20 @@ import type { ArgTypesEnhancer, DecoratorFunction } from 'storybook/internal/types'; +import type { ArgTypesExtractor } from 'storybook/internal/docs-tools'; import { extractComponentDescription, enhanceArgTypes } from 'storybook/internal/docs-tools'; import { extractArgTypes } from './docs/extractArgTypes'; import { jsxDecorator } from './docs/jsxDecorator'; import type { ReactRenderer } from './types'; -export const parameters = { +export const parameters: { + docs: { + story: { + inline: boolean; + }; + extractArgTypes: ArgTypesExtractor; + extractComponentDescription: (component?: any) => string; + }; +} = { docs: { story: { inline: true }, extractArgTypes, diff --git a/code/renderers/react/src/portable-stories.tsx b/code/renderers/react/src/portable-stories.tsx index e562d68963d4..b8058deb4571 100644 --- a/code/renderers/react/src/portable-stories.tsx +++ b/code/renderers/react/src/portable-stories.tsx @@ -10,6 +10,7 @@ import type { Store_CSFExports, StoriesWithPartialProps, ProjectAnnotations, + ComposedStoryFn, } from 'storybook/internal/types'; import * as reactProjectAnnotations from './entry-preview'; @@ -85,7 +86,7 @@ export function composeStory( componentAnnotations: Meta, projectAnnotations?: ProjectAnnotations, exportsName?: string -) { +): ComposedStoryFn> { return originalComposeStory( story as StoryAnnotationsOrFn, componentAnnotations, diff --git a/code/renderers/svelte/src/docs/extractArgTypes.ts b/code/renderers/svelte/src/docs/extractArgTypes.ts index a81539bd1b4b..aeb719884f93 100644 --- a/code/renderers/svelte/src/docs/extractArgTypes.ts +++ b/code/renderers/svelte/src/docs/extractArgTypes.ts @@ -17,7 +17,9 @@ function hasKeyword(keyword: string, keywords: JSDocKeyword[]): boolean { return keywords ? keywords.find((k) => k.name === keyword) != null : false; } -export const extractArgTypes: ArgTypesExtractor = (component: ComponentWithDocgen) => { +export const extractArgTypes: ArgTypesExtractor = ( + component: ComponentWithDocgen +): StrictArgTypes | null => { try { // eslint-disable-next-line no-underscore-dangle const docgen = component.__docgen; diff --git a/code/renderers/svelte/src/entry-preview-docs.ts b/code/renderers/svelte/src/entry-preview-docs.ts index fff20c3523ff..a1abf3504a53 100644 --- a/code/renderers/svelte/src/entry-preview-docs.ts +++ b/code/renderers/svelte/src/entry-preview-docs.ts @@ -1,11 +1,20 @@ import type { ArgTypesEnhancer, DecoratorFunction } from 'storybook/internal/types'; +import type { ArgTypesExtractor } from 'storybook/internal/docs-tools'; import { enhanceArgTypes } from 'storybook/internal/docs-tools'; import { extractArgTypes } from './docs/extractArgTypes'; import { extractComponentDescription } from './docs/extractComponentDescription'; import { sourceDecorator } from './docs/sourceDecorator'; import type { SvelteRenderer } from './types'; -export const parameters = { +export const parameters: { + docs: { + story: { + inline: boolean; + }; + extractArgTypes: ArgTypesExtractor; + extractComponentDescription: (component?: any) => string; + }; +} = { docs: { story: { inline: true }, extractArgTypes, diff --git a/code/renderers/svelte/src/portable-stories.ts b/code/renderers/svelte/src/portable-stories.ts index 51c4ed0d6c82..a3c2e54336e2 100644 --- a/code/renderers/svelte/src/portable-stories.ts +++ b/code/renderers/svelte/src/portable-stories.ts @@ -103,7 +103,7 @@ export function composeStory( componentAnnotations: Meta, projectAnnotations?: ProjectAnnotations, exportsName?: string -) { +): ComposedStory { const composedStory = originalComposeStory( story as StoryAnnotationsOrFn, // @ts-expect-error Fix this later: Type 'Partial<{ [x: string]: any; }>' is not assignable to type 'Partial>' diff --git a/code/renderers/vue3/src/docs/extractArgTypes.ts b/code/renderers/vue3/src/docs/extractArgTypes.ts index 30fda1267c40..76c52cc755a7 100644 --- a/code/renderers/vue3/src/docs/extractArgTypes.ts +++ b/code/renderers/vue3/src/docs/extractArgTypes.ts @@ -13,7 +13,7 @@ type PropertyMetaSchema = VueDocgenInfoEntry<'vue-component-meta', 'props'>['sch // "exposed" is used by the vue-component-meta plugin while "expose" is used by vue-docgen-api const ARG_TYPE_SECTIONS = ['props', 'events', 'slots', 'exposed', 'expose'] as const; -export const extractArgTypes: ArgTypesExtractor = (component) => { +export const extractArgTypes: ArgTypesExtractor = (component): StrictArgTypes | null => { if (!hasDocgen>(component)) { return null; } diff --git a/code/renderers/vue3/src/entry-preview-docs.ts b/code/renderers/vue3/src/entry-preview-docs.ts index 4965fc9356b7..66e848f2bc12 100644 --- a/code/renderers/vue3/src/entry-preview-docs.ts +++ b/code/renderers/vue3/src/entry-preview-docs.ts @@ -1,10 +1,19 @@ import type { ArgTypesEnhancer, DecoratorFunction } from 'storybook/internal/types'; +import type { ArgTypesExtractor } from 'storybook/internal/docs-tools'; import { extractComponentDescription, enhanceArgTypes } from 'storybook/internal/docs-tools'; import { extractArgTypes } from './docs/extractArgTypes'; import { sourceDecorator } from './docs/sourceDecorator'; import type { VueRenderer } from './types'; -export const parameters = { +export const parameters: { + docs: { + story: { + inline: boolean; + }; + extractArgTypes: ArgTypesExtractor; + extractComponentDescription: (component?: any) => string; + }; +} = { docs: { story: { inline: true }, extractArgTypes, diff --git a/code/renderers/vue3/src/portable-stories.ts b/code/renderers/vue3/src/portable-stories.ts index 5965da3dd63b..7e1e64c6f458 100644 --- a/code/renderers/vue3/src/portable-stories.ts +++ b/code/renderers/vue3/src/portable-stories.ts @@ -10,6 +10,7 @@ import type { StoryAnnotationsOrFn, Store_CSFExports, StoriesWithPartialProps, + ComposedStoryFn, } from 'storybook/internal/types'; import { TestingLibraryMustBeConfiguredError } from 'storybook/internal/preview-errors'; import { h } from 'vue'; @@ -91,7 +92,7 @@ export function composeStory( componentAnnotations: Meta, projectAnnotations?: ProjectAnnotations, exportsName?: string -) { +): JSXAble>> { const composedStory = originalComposeStory( story as StoryAnnotationsOrFn, componentAnnotations, diff --git a/code/renderers/web-components/src/entry-preview-docs.ts b/code/renderers/web-components/src/entry-preview-docs.ts index 489c91bbd2d3..c6c441644e4d 100644 --- a/code/renderers/web-components/src/entry-preview-docs.ts +++ b/code/renderers/web-components/src/entry-preview-docs.ts @@ -1,4 +1,4 @@ -import type { ArgTypesEnhancer, DecoratorFunction } from 'storybook/internal/types'; +import type { ArgTypesEnhancer, DecoratorFunction, InputType } from 'storybook/internal/types'; import { SourceType, enhanceArgTypes } from 'storybook/internal/docs-tools'; import { extractArgTypes, extractComponentDescription } from './docs/custom-elements'; import { sourceDecorator } from './docs/sourceDecorator'; @@ -6,7 +6,24 @@ import type { WebComponentsRenderer } from './types'; export const decorators: DecoratorFunction[] = [sourceDecorator]; -export const parameters = { +export const parameters: { + docs: { + extractArgTypes: (tagName: string) => + | { + [x: string]: InputType; + } + | null + | undefined; + extractComponentDescription: (tagName: string) => string | null | undefined; + story: { + inline: true; + }; + source: { + type: SourceType; + language: string; + }; + }; +} = { docs: { extractArgTypes, extractComponentDescription, From 64fc03146ea99ba0503084edec4eb3d1287fe9f9 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Wed, 10 Jul 2024 12:20:37 +0200 Subject: [PATCH 3/4] Merge pull request #28507 from storybookjs/norbert/apply-fixes-on-incorrect-types-due-to-cpc CPC: Fix type generation (cherry picked from commit a937895ce21ec774bd6696750f9e64ab491d3ce5) --- scripts/prepare/addon-bundle.ts | 15 ++++++++++++++- scripts/prepare/bundle.ts | 12 ++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/scripts/prepare/addon-bundle.ts b/scripts/prepare/addon-bundle.ts index 8b1aeb79bf96..f6d15a2ce377 100755 --- a/scripts/prepare/addon-bundle.ts +++ b/scripts/prepare/addon-bundle.ts @@ -10,6 +10,7 @@ import { exec } from '../utils/exec'; import { globalPackages as globalPreviewPackages } from '../../code/core/src/preview/globals/globals'; import { globalPackages as globalManagerPackages } from '../../code/core/src/manager/globals/globals'; +import { glob } from 'glob'; /* TYPES */ @@ -62,8 +63,9 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => { const tasks: Promise[] = []; + const outDir = join(process.cwd(), 'dist'); const commonOptions: Options = { - outDir: join(process.cwd(), 'dist'), + outDir, silent: true, treeshake: true, shims: false, @@ -190,6 +192,17 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => { await Promise.all(tasks); + const dtsFiles = await glob(outDir + '/**/*.d.ts'); + await Promise.all( + dtsFiles.map(async (file) => { + const content = await fs.readFile(file, 'utf-8'); + await fs.writeFile( + file, + content.replace(/from \'core\/dist\/(.*)\'/g, `from 'storybook/internal/$1'`) + ); + }) + ); + if (post) { await exec(`bun ${post}`, { cwd }, { debug: true }); } diff --git a/scripts/prepare/bundle.ts b/scripts/prepare/bundle.ts index 1ff5b793af20..28e994773c29 100755 --- a/scripts/prepare/bundle.ts +++ b/scripts/prepare/bundle.ts @@ -7,6 +7,7 @@ import aliasPlugin from 'esbuild-plugin-alias'; import { dedent } from 'ts-dedent'; import slash from 'slash'; import { exec } from '../utils/exec'; +import { glob } from 'glob'; /* TYPES */ @@ -147,6 +148,17 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => { await Promise.all(tasks); + const dtsFiles = await glob(outDir + '/**/*.d.ts'); + await Promise.all( + dtsFiles.map(async (file) => { + const content = await fs.readFile(file, 'utf-8'); + await fs.writeFile( + file, + content.replace(/from \'core\/dist\/(.*)\'/g, `from 'storybook/internal/$1'`) + ); + }) + ); + if (post) { await exec(`bun ${post}`, { cwd }, { debug: true }); } From 87afb231be82e2f82236f70b5598f594694ef588 Mon Sep 17 00:00:00 2001 From: storybook-bot <32066757+storybook-bot@users.noreply.github.com> Date: Wed, 10 Jul 2024 10:23:27 +0000 Subject: [PATCH 4/4] Write changelog for 8.2.1 [skip ci] --- CHANGELOG.md | 5 +++++ code/package.json | 3 ++- docs/versions/latest.json | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd04f45b3c5d..f2a07504e271 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 8.2.1 + +- CPC: Fix type generation - [#28507](https://github.com/storybookjs/storybook/pull/28507), thanks @ndelangen! +- Types: Update type signatures of objects and functions - [#28503](https://github.com/storybookjs/storybook/pull/28503), thanks @valentinpalkovic! + ## 8.2.0 Hold onto your hats! Storybook 8.2 has dropped, packed with a treasure trove of new features and bug fixes: diff --git a/code/package.json b/code/package.json index 6cc291f0e192..84d9b030894e 100644 --- a/code/package.json +++ b/code/package.json @@ -278,5 +278,6 @@ "Dependency Upgrades" ] ] - } + }, + "deferredNextVersion": "8.2.1" } diff --git a/docs/versions/latest.json b/docs/versions/latest.json index bc9c7b4e27d2..23863f25bcb1 100644 --- a/docs/versions/latest.json +++ b/docs/versions/latest.json @@ -1 +1 @@ -{"version":"8.2.0","info":{"plain":""}} +{"version":"8.2.1","info":{"plain":"- CPC: Fix type generation - [#28507](https://github.com/storybookjs/storybook/pull/28507), thanks @ndelangen!\n- Types: Update type signatures of objects and functions - [#28503](https://github.com/storybookjs/storybook/pull/28503), thanks @valentinpalkovic!"}}