From 4f174f2c594157aa75233b815623c14a04e335c9 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 20 Oct 2022 12:25:33 +0200 Subject: [PATCH 01/38] add package --- code/lib/types/README.md | 5 ++++ code/lib/types/package.json | 54 ++++++++++++++++++++++++++++++++++++ code/lib/types/src/index.ts | 1 + code/lib/types/tsconfig.json | 12 ++++++++ code/yarn.lock | 8 ++++++ 5 files changed, 80 insertions(+) create mode 100644 code/lib/types/README.md create mode 100644 code/lib/types/package.json create mode 100644 code/lib/types/src/index.ts create mode 100644 code/lib/types/tsconfig.json diff --git a/code/lib/types/README.md b/code/lib/types/README.md new file mode 100644 index 000000000000..d820bd39f10c --- /dev/null +++ b/code/lib/types/README.md @@ -0,0 +1,5 @@ +# Storybook Router + +Storybook Router is a wrapper library for react-router. +It ensures a single version of the router is used everywhere. +It also includes some ready to use utils to read the path, query, viewMode and storyId from location. diff --git a/code/lib/types/package.json b/code/lib/types/package.json new file mode 100644 index 000000000000..71d58e3ca909 --- /dev/null +++ b/code/lib/types/package.json @@ -0,0 +1,54 @@ +{ + "name": "@storybook/types", + "version": "7.0.0-alpha.40", + "description": "Core Storybook Types", + "keywords": [ + "storybook" + ], + "homepage": "https://github.com/storybookjs/storybook/tree/main/code/lib/types", + "bugs": { + "url": "https://github.com/storybookjs/storybook/issues" + }, + "repository": { + "type": "git", + "url": "https://github.com/storybookjs/storybook.git", + "directory": "code/lib/types" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/storybook" + }, + "license": "MIT", + "sideEffects": false, + "exports": { + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + }, + "./package.json": "./package.json" + }, + "main": "dist/index.js", + "module": "dist/index.mjs", + "types": "dist/index.d.ts", + "files": [ + "dist/**/*", + "README.md" + ], + "scripts": { + "check": "../../../scripts/node_modules/.bin/tsc --noEmit", + "prep": "../../../scripts/prepare/bundle.ts" + }, + "devDependencies": { + "typescript": "~4.6.3" + }, + "publishConfig": { + "access": "public" + }, + "bundler": { + "entries": [ + "./src/index.ts" + ] + }, + "gitHead": "8f6d8629f1ad7e776c39e2c7621f4a0d538aa93c" +} diff --git a/code/lib/types/src/index.ts b/code/lib/types/src/index.ts new file mode 100644 index 000000000000..8337712ea57f --- /dev/null +++ b/code/lib/types/src/index.ts @@ -0,0 +1 @@ +// diff --git a/code/lib/types/tsconfig.json b/code/lib/types/tsconfig.json new file mode 100644 index 000000000000..d23f9a406fc2 --- /dev/null +++ b/code/lib/types/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../../tsconfig.json", + "include": ["src/**/*"], + "exclude": [ + "src/**/*.test.*", + "src/**/tests/**/*", + "src/**/__tests__/**/*", + "src/**/*.stories.*", + "src/**/*.mockdata.*", + "src/**/__testfixtures__/**" + ] +} diff --git a/code/yarn.lock b/code/yarn.lock index d972961d22a2..3b8d5f7067f8 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -8684,6 +8684,14 @@ __metadata: languageName: node linkType: hard +"@storybook/types@workspace:lib/types": + version: 0.0.0-use.local + resolution: "@storybook/types@workspace:lib/types" + dependencies: + typescript: ~4.6.3 + languageName: unknown + linkType: soft + "@storybook/ui@7.0.0-alpha.40, @storybook/ui@workspace:*, @storybook/ui@workspace:ui/manager": version: 0.0.0-use.local resolution: "@storybook/ui@workspace:ui/manager" From 11a73d4c104d26f2817d24e182fd59c8bc0ad33b Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 20 Oct 2022 13:20:09 +0200 Subject: [PATCH 02/38] fix --- code/lib/types/README.md | 10 ++++++---- code/lib/types/package.json | 1 + code/lib/types/src/index.ts | 3 ++- code/lib/types/tsconfig.json | 10 +--------- code/yarn.lock | 1 + 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/code/lib/types/README.md b/code/lib/types/README.md index d820bd39f10c..9bbfbbfdf026 100644 --- a/code/lib/types/README.md +++ b/code/lib/types/README.md @@ -1,5 +1,7 @@ -# Storybook Router +# Storybook Types -Storybook Router is a wrapper library for react-router. -It ensures a single version of the router is used everywhere. -It also includes some ready to use utils to read the path, query, viewMode and storyId from location. +Storybook types exports only typescript types for storybook usage. + +It has no runtime implementations. + +It also has no dependencies, all the types it exports are bundled in. diff --git a/code/lib/types/package.json b/code/lib/types/package.json index 71d58e3ca909..42fe4ac708fb 100644 --- a/code/lib/types/package.json +++ b/code/lib/types/package.json @@ -40,6 +40,7 @@ "prep": "../../../scripts/prepare/bundle.ts" }, "devDependencies": { + "@storybook/csf": "0.0.2--canary.49.258942b.0", "typescript": "~4.6.3" }, "publishConfig": { diff --git a/code/lib/types/src/index.ts b/code/lib/types/src/index.ts index 8337712ea57f..79be869edb0b 100644 --- a/code/lib/types/src/index.ts +++ b/code/lib/types/src/index.ts @@ -1 +1,2 @@ -// +/* eslint-disable import/no-extraneous-dependencies */ +export * from '@storybook/csf'; diff --git a/code/lib/types/tsconfig.json b/code/lib/types/tsconfig.json index d23f9a406fc2..52d43eaaa9b9 100644 --- a/code/lib/types/tsconfig.json +++ b/code/lib/types/tsconfig.json @@ -1,12 +1,4 @@ { "extends": "../../tsconfig.json", - "include": ["src/**/*"], - "exclude": [ - "src/**/*.test.*", - "src/**/tests/**/*", - "src/**/__tests__/**/*", - "src/**/*.stories.*", - "src/**/*.mockdata.*", - "src/**/__testfixtures__/**" - ] + "include": ["src/**/*"] } diff --git a/code/yarn.lock b/code/yarn.lock index 3b8d5f7067f8..ea3ca4724ef2 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -8688,6 +8688,7 @@ __metadata: version: 0.0.0-use.local resolution: "@storybook/types@workspace:lib/types" dependencies: + "@storybook/csf": 0.0.2--canary.49.258942b.0 typescript: ~4.6.3 languageName: unknown linkType: soft From a899800ec82d766d5948a18954247b895614867d Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 20 Oct 2022 16:21:26 +0200 Subject: [PATCH 03/38] import all csf types through types package --- code/addons/a11y/package.json | 2 +- code/addons/actions/package.json | 2 +- code/addons/actions/src/addArgsHelpers.ts | 2 +- code/addons/backgrounds/package.json | 2 +- .../src/decorators/withBackground.ts | 2 +- .../backgrounds/src/decorators/withGrid.ts | 2 +- code/addons/controls/package.json | 2 +- code/addons/docs/package.json | 2 +- code/addons/docs/src/DocsRenderer.tsx | 2 +- code/addons/interactions/package.json | 2 +- .../addons/interactions/src/preset/preview.ts | 2 +- code/addons/links/package.json | 2 +- code/addons/links/src/utils.ts | 4 +- code/addons/measure/package.json | 2 +- code/addons/measure/src/withMeasure.ts | 2 +- code/addons/outline/package.json | 2 +- code/addons/outline/src/withOutline.ts | 2 +- .../storyshots/storyshots-core/package.json | 2 +- .../storyshots-core/src/frameworks/Loader.ts | 2 +- .../src/frameworks/configure.ts | 2 +- .../storyshots-puppeteer/package.json | 2 +- .../src/__tests__/url.test.ts | 2 +- code/examples/external-docs/package.json | 2 +- code/frameworks/angular/package.json | 2 +- .../angular/src/client/angular/helpers.ts | 2 +- .../angular/src/client/decorateStory.ts | 2 +- .../angular/src/client/decorators.ts | 2 +- .../src/client/docs/sourceDecorator.ts | 2 +- .../angular/src/client/public-types.ts | 4 +- code/frameworks/angular/src/client/render.ts | 2 +- code/frameworks/angular/src/client/types.ts | 2 +- code/lib/addons/package.json | 2 +- code/lib/addons/src/hooks.ts | 2 +- code/lib/addons/src/types.ts | 4 +- code/lib/api/package.json | 1 + code/lib/api/src/index.tsx | 2 +- code/lib/api/src/lib/stories.ts | 2 +- code/lib/api/src/modules/globals.ts | 2 +- code/lib/blocks/package.json | 2 +- code/lib/blocks/src/blocks/ArgsTable.tsx | 2 +- code/lib/blocks/src/blocks/Canvas.tsx | 2 +- code/lib/blocks/src/blocks/Docs.tsx | 2 +- code/lib/blocks/src/blocks/DocsContainer.tsx | 2 +- code/lib/blocks/src/blocks/DocsContext.ts | 2 +- code/lib/blocks/src/blocks/Meta.tsx | 2 +- code/lib/blocks/src/blocks/Story.tsx | 2 +- code/lib/blocks/src/blocks/Title.tsx | 2 +- .../blocks/src/blocks/enhanceSource.test.ts | 2 +- code/lib/blocks/src/blocks/enhanceSource.ts | 2 +- .../src/blocks/external/ExternalDocs.tsx | 2 +- .../blocks/external/ExternalDocsContainer.tsx | 2 +- .../blocks/external/ExternalDocsContext.ts | 2 +- .../src/blocks/external/ExternalPreview.ts | 2 +- code/lib/blocks/src/blocks/useStory.ts | 2 +- .../src/components/ArgsTable/ArgsTable.tsx | 2 +- .../blocks/src/components/ArgsTable/types.ts | 2 +- code/lib/blocks/src/components/Story.tsx | 2 +- code/lib/builder-vite/src/optimizeDeps.ts | 2 +- code/lib/cli/src/window.d.ts | 2 +- code/lib/client-api/package.json | 1 + code/lib/client-api/src/ClientApi.ts | 5 +- code/lib/client-api/src/StoryStoreFacade.ts | 13 +- code/lib/client-api/src/types.ts | 4 +- code/lib/codemod/package.json | 1 + code/lib/components/package.json | 1 + code/lib/core-client/package.json | 1 + code/lib/core-client/src/preview/start.ts | 2 +- code/lib/core-common/package.json | 2 +- code/lib/core-common/src/types.ts | 2 +- code/lib/core-server/package.json | 1 + .../src/utils/StoryIndexGenerator.test.ts | 6 +- .../src/utils/StoryIndexGenerator.ts | 2 +- code/lib/csf-tools/package.json | 1 + code/lib/docs-tools/package.json | 2 +- .../src/argTypes/convert/flow/convert.ts | 2 +- .../src/argTypes/convert/proptypes/convert.ts | 2 +- .../argTypes/convert/typescript/convert.ts | 2 +- .../docs-tools/src/argTypes/docgen/types.ts | 2 +- .../src/argTypes/enhanceArgTypes.test.ts | 2 +- .../src/argTypes/enhanceArgTypes.ts | 2 +- code/lib/preview-web/package.json | 2 +- code/lib/preview-web/src/Preview.tsx | 2 +- code/lib/preview-web/src/PreviewWeb.test.ts | 2 +- code/lib/preview-web/src/PreviewWeb.tsx | 9 +- .../src/docs-context/DocsContext.ts | 2 +- .../src/docs-context/DocsContextProps.ts | 2 +- .../src/docs-context/DocsRenderFunction.ts | 2 +- code/lib/preview-web/src/render/Render.ts | 2 +- .../src/render/StandaloneDocsRender.test.ts | 2 +- .../src/render/StandaloneDocsRender.ts | 2 +- .../src/render/StoryRender.test.ts | 2 +- .../lib/preview-web/src/render/StoryRender.ts | 2 +- .../src/render/TemplateDocsRender.test.ts | 2 +- .../src/render/TemplateDocsRender.ts | 2 +- code/lib/source-loader/package.json | 1 + code/lib/store/package.json | 1 + code/lib/store/src/ArgsStore.ts | 2 +- code/lib/store/src/GlobalsStore.ts | 2 +- code/lib/store/src/StoryIndexStore.ts | 2 +- code/lib/store/src/StoryStore.test.ts | 2 +- code/lib/store/src/StoryStore.ts | 2 +- code/lib/store/src/args.test.ts | 2 +- code/lib/store/src/args.ts | 9 +- code/lib/store/src/csf/composeConfigs.ts | 2 +- .../store/src/csf/getValuesFromArgTypes.ts | 2 +- .../src/csf/normalizeComponentAnnotations.ts | 2 +- code/lib/store/src/csf/normalizeInputTypes.ts | 2 +- .../src/csf/normalizeProjectAnnotations.ts | 2 +- code/lib/store/src/csf/normalizeStory.test.ts | 2 +- code/lib/store/src/csf/normalizeStory.ts | 2 +- code/lib/store/src/csf/prepareStory.test.ts | 2 +- code/lib/store/src/csf/prepareStory.ts | 2 +- code/lib/store/src/csf/processCSFFile.ts | 2 +- code/lib/store/src/csf/stepRunners.test.ts | 2 +- code/lib/store/src/csf/stepRunners.ts | 2 +- code/lib/store/src/csf/testing-utils/index.ts | 4 +- code/lib/store/src/csf/testing-utils/types.ts | 2 +- code/lib/store/src/decorators.test.ts | 2 +- code/lib/store/src/decorators.ts | 2 +- code/lib/store/src/filterArgTypes.ts | 2 +- code/lib/store/src/hooks.test.ts | 2 +- code/lib/store/src/inferArgTypes.ts | 2 +- code/lib/store/src/inferControls.test.ts | 2 +- code/lib/store/src/inferControls.ts | 2 +- code/lib/store/src/storySort.test.ts | 2 +- code/lib/store/src/types.ts | 2 +- code/lib/store/template/stories/preview.ts | 2 +- code/lib/types/src/index.ts | 115 +++++- code/package.json | 1 + code/renderers/html/package.json | 2 +- .../html/src/docs/sourceDecorator.ts | 2 +- code/renderers/html/src/public-types.ts | 4 +- code/renderers/html/src/render.ts | 2 +- code/renderers/html/src/types.ts | 2 +- code/renderers/preact/package.json | 2 +- code/renderers/preact/src/public-types.ts | 4 +- code/renderers/preact/src/render.tsx | 2 +- code/renderers/react/package.json | 2 +- .../react/src/__test__/CSF3.test.tsx | 2 +- .../react/src/docs/extractArgTypes.test.ts | 2 +- .../react/src/docs/extractArgTypes.ts | 2 +- .../renderers/react/src/docs/jsxDecorator.tsx | 2 +- code/renderers/react/src/public-api.tsx | 2 +- code/renderers/react/src/public-types.ts | 2 +- code/renderers/react/src/render.tsx | 2 +- code/renderers/react/src/testing-api.ts | 2 +- code/renderers/react/src/types.ts | 4 +- code/renderers/server/package.json | 2 +- code/renderers/server/src/public-types.ts | 4 +- code/renderers/server/src/types.ts | 2 +- code/renderers/svelte/package.json | 2 +- code/renderers/svelte/src/decorators.ts | 2 +- .../svelte/src/docs/extractArgTypes.ts | 2 +- .../svelte/src/docs/sourceDecorator.ts | 2 +- code/renderers/svelte/src/public-types.ts | 4 +- code/renderers/svelte/src/render.ts | 2 +- code/renderers/svelte/src/types.ts | 2 +- code/renderers/vue/package.json | 2 +- code/renderers/vue/src/decorateStory.ts | 2 +- .../renderers/vue/src/docs/extractArgTypes.ts | 2 +- code/renderers/vue/src/public-types.ts | 4 +- code/renderers/vue/src/render.ts | 2 +- code/renderers/vue/src/types.ts | 2 +- code/renderers/vue3/package.json | 2 +- code/renderers/vue3/src/decorateStory.ts | 2 +- .../vue3/src/docs/extractArgTypes.ts | 2 +- code/renderers/vue3/src/public-types.ts | 4 +- code/renderers/vue3/src/render.ts | 2 +- code/renderers/vue3/src/types.ts | 2 +- code/renderers/web-components/package.json | 2 +- .../src/docs/sourceDecorator.ts | 2 +- .../web-components/src/public-types.ts | 2 +- code/renderers/web-components/src/render.ts | 2 +- code/renderers/web-components/src/types.ts | 2 +- code/ui/manager/package.json | 2 +- .../src/components/preview/utils/types.tsx | 2 +- code/workspace.json | 367 +++++++++--------- code/yarn.lock | 66 ++-- scripts/verdaccio.yaml | 2 +- 179 files changed, 549 insertions(+), 397 deletions(-) diff --git a/code/addons/a11y/package.json b/code/addons/a11y/package.json index 08ff6f076ff1..f647421e0f40 100644 --- a/code/addons/a11y/package.json +++ b/code/addons/a11y/package.json @@ -69,8 +69,8 @@ "@storybook/client-logger": "7.0.0-alpha.40", "@storybook/components": "7.0.0-alpha.40", "@storybook/core-events": "7.0.0-alpha.40", - "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/theming": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "axe-core": "^4.2.0", "global": "^4.4.0", "lodash": "^4.17.21", diff --git a/code/addons/actions/package.json b/code/addons/actions/package.json index 7471cd3d01de..b8cfde3e08b4 100644 --- a/code/addons/actions/package.json +++ b/code/addons/actions/package.json @@ -63,8 +63,8 @@ "@storybook/client-logger": "7.0.0-alpha.40", "@storybook/components": "7.0.0-alpha.40", "@storybook/core-events": "7.0.0-alpha.40", - "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/theming": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "dequal": "^2.0.2", "global": "^4.4.0", "lodash": "^4.17.21", diff --git a/code/addons/actions/src/addArgsHelpers.ts b/code/addons/actions/src/addArgsHelpers.ts index c375c03fdb12..dcc8d5504631 100644 --- a/code/addons/actions/src/addArgsHelpers.ts +++ b/code/addons/actions/src/addArgsHelpers.ts @@ -1,4 +1,4 @@ -import type { Args, AnyFramework, ArgsEnhancer } from '@storybook/csf'; +import type { Args, AnyFramework, ArgsEnhancer } from '@storybook/types'; import { action } from './runtime/action'; // interface ActionsParameter { diff --git a/code/addons/backgrounds/package.json b/code/addons/backgrounds/package.json index 456945ebc1ca..4b62fe9202af 100644 --- a/code/addons/backgrounds/package.json +++ b/code/addons/backgrounds/package.json @@ -67,8 +67,8 @@ "@storybook/client-logger": "7.0.0-alpha.40", "@storybook/components": "7.0.0-alpha.40", "@storybook/core-events": "7.0.0-alpha.40", - "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/theming": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "global": "^4.4.0", "memoizerific": "^1.11.3", "ts-dedent": "^2.0.0" diff --git a/code/addons/backgrounds/src/decorators/withBackground.ts b/code/addons/backgrounds/src/decorators/withBackground.ts index 391ecb0e28a2..306f06398a3e 100644 --- a/code/addons/backgrounds/src/decorators/withBackground.ts +++ b/code/addons/backgrounds/src/decorators/withBackground.ts @@ -1,5 +1,5 @@ import { useMemo, useEffect } from '@storybook/addons'; -import type { AnyFramework, PartialStoryFn as StoryFunction, StoryContext } from '@storybook/csf'; +import type { AnyFramework, PartialStoryFn as StoryFunction, StoryContext } from '@storybook/types'; import { PARAM_KEY as BACKGROUNDS_PARAM_KEY } from '../constants'; import { diff --git a/code/addons/backgrounds/src/decorators/withGrid.ts b/code/addons/backgrounds/src/decorators/withGrid.ts index e4f9cdc33b99..2aafc186c1ef 100644 --- a/code/addons/backgrounds/src/decorators/withGrid.ts +++ b/code/addons/backgrounds/src/decorators/withGrid.ts @@ -1,5 +1,5 @@ import { useMemo, useEffect } from '@storybook/addons'; -import type { AnyFramework, PartialStoryFn as StoryFunction, StoryContext } from '@storybook/csf'; +import type { AnyFramework, PartialStoryFn as StoryFunction, StoryContext } from '@storybook/types'; import { clearStyles, addGridStyle } from '../helpers'; import { PARAM_KEY as BACKGROUNDS_PARAM_KEY } from '../constants'; diff --git a/code/addons/controls/package.json b/code/addons/controls/package.json index 97ac20a207c2..f00de63c60ef 100644 --- a/code/addons/controls/package.json +++ b/code/addons/controls/package.json @@ -63,10 +63,10 @@ "@storybook/client-logger": "7.0.0-alpha.40", "@storybook/components": "7.0.0-alpha.40", "@storybook/core-common": "7.0.0-alpha.40", - "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/node-logger": "7.0.0-alpha.40", "@storybook/store": "7.0.0-alpha.40", "@storybook/theming": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "lodash": "^4.17.21", "ts-dedent": "^2.0.0" }, diff --git a/code/addons/docs/package.json b/code/addons/docs/package.json index bf2d30f99172..f1c8f384bc3d 100644 --- a/code/addons/docs/package.json +++ b/code/addons/docs/package.json @@ -58,7 +58,6 @@ "@storybook/components": "7.0.0-alpha.40", "@storybook/core-common": "7.0.0-alpha.40", "@storybook/core-events": "7.0.0-alpha.40", - "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/csf-tools": "7.0.0-alpha.40", "@storybook/docs-tools": "7.0.0-alpha.40", "@storybook/mdx2-csf": "0.1.0-next.0", @@ -68,6 +67,7 @@ "@storybook/source-loader": "7.0.0-alpha.40", "@storybook/store": "7.0.0-alpha.40", "@storybook/theming": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "dequal": "^2.0.2", "fs-extra": "^9.0.1", "global": "^4.4.0", diff --git a/code/addons/docs/src/DocsRenderer.tsx b/code/addons/docs/src/DocsRenderer.tsx index 08af79dde02c..1591d12d6e55 100644 --- a/code/addons/docs/src/DocsRenderer.tsx +++ b/code/addons/docs/src/DocsRenderer.tsx @@ -1,6 +1,6 @@ import React from 'react'; import ReactDOM from 'react-dom'; -import { AnyFramework, Parameters } from '@storybook/csf'; +import { AnyFramework, Parameters } from '@storybook/types'; import { DocsContextProps, DocsRenderFunction } from '@storybook/preview-web'; import { components as htmlComponents } from '@storybook/components'; import { Docs, CodeOrSourceMdx, AnchorMdx, HeadersMdx } from '@storybook/blocks'; diff --git a/code/addons/interactions/package.json b/code/addons/interactions/package.json index ea141df0a30d..8f0a44c38620 100644 --- a/code/addons/interactions/package.json +++ b/code/addons/interactions/package.json @@ -65,9 +65,9 @@ "@storybook/components": "7.0.0-alpha.40", "@storybook/core-common": "7.0.0-alpha.40", "@storybook/core-events": "7.0.0-alpha.40", - "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/instrumenter": "7.0.0-alpha.40", "@storybook/theming": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "global": "^4.4.0", "jest-mock": "^27.0.6", "polished": "^4.2.2", diff --git a/code/addons/interactions/src/preset/preview.ts b/code/addons/interactions/src/preset/preview.ts index ac81f57af181..9faae0eefe73 100644 --- a/code/addons/interactions/src/preset/preview.ts +++ b/code/addons/interactions/src/preset/preview.ts @@ -8,7 +8,7 @@ import type { PlayFunction, PlayFunctionContext, StepLabel, -} from '@storybook/csf'; +} from '@storybook/types'; import { instrument } from '@storybook/instrumenter'; import { ModuleMocker } from 'jest-mock'; diff --git a/code/addons/links/package.json b/code/addons/links/package.json index 0794cf62d663..2b4abc68ec90 100644 --- a/code/addons/links/package.json +++ b/code/addons/links/package.json @@ -66,8 +66,8 @@ "@storybook/addons": "7.0.0-alpha.40", "@storybook/client-logger": "7.0.0-alpha.40", "@storybook/core-events": "7.0.0-alpha.40", - "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/router": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "global": "^4.4.0", "prop-types": "^15.7.2", "ts-dedent": "^2.0.0" diff --git a/code/addons/links/src/utils.ts b/code/addons/links/src/utils.ts index 6c8785c0baae..cc932afabf94 100644 --- a/code/addons/links/src/utils.ts +++ b/code/addons/links/src/utils.ts @@ -1,8 +1,8 @@ import global from 'global'; import { addons, makeDecorator } from '@storybook/addons'; import { STORY_CHANGED, SELECT_STORY } from '@storybook/core-events'; -import type { StoryId, StoryName, ComponentTitle } from '@storybook/csf'; -import { toId } from '@storybook/csf'; +import type { StoryId, StoryName, ComponentTitle } from '@storybook/types'; +import { toId } from '@storybook/types'; import { PARAM_KEY } from './constants'; const { document, HTMLElement } = global; diff --git a/code/addons/measure/package.json b/code/addons/measure/package.json index 706afa988f52..398a03d6d1ed 100644 --- a/code/addons/measure/package.json +++ b/code/addons/measure/package.json @@ -66,7 +66,7 @@ "@storybook/client-logger": "7.0.0-alpha.40", "@storybook/components": "7.0.0-alpha.40", "@storybook/core-events": "7.0.0-alpha.40", - "@storybook/csf": "0.0.2--canary.49.258942b.0", + "@storybook/types": "7.0.0-alpha.40", "global": "^4.4.0" }, "devDependencies": { diff --git a/code/addons/measure/src/withMeasure.ts b/code/addons/measure/src/withMeasure.ts index 867ac58f1728..e68e8f4d79ee 100644 --- a/code/addons/measure/src/withMeasure.ts +++ b/code/addons/measure/src/withMeasure.ts @@ -1,6 +1,6 @@ /* eslint-env browser */ import { useEffect } from '@storybook/addons'; -import type { AnyFramework, PartialStoryFn as StoryFunction, StoryContext } from '@storybook/csf'; +import type { AnyFramework, PartialStoryFn as StoryFunction, StoryContext } from '@storybook/types'; import { drawSelectedElement } from './box-model/visualizer'; import { init, rescale, destroy } from './box-model/canvas'; import { deepElementFromPoint } from './util'; diff --git a/code/addons/outline/package.json b/code/addons/outline/package.json index 5e455447aeba..f8020e099f62 100644 --- a/code/addons/outline/package.json +++ b/code/addons/outline/package.json @@ -69,7 +69,7 @@ "@storybook/client-logger": "7.0.0-alpha.40", "@storybook/components": "7.0.0-alpha.40", "@storybook/core-events": "7.0.0-alpha.40", - "@storybook/csf": "0.0.2--canary.49.258942b.0", + "@storybook/types": "7.0.0-alpha.40", "global": "^4.4.0", "ts-dedent": "^2.0.0" }, diff --git a/code/addons/outline/src/withOutline.ts b/code/addons/outline/src/withOutline.ts index 05ca6d45a5aa..037c8eb090e0 100644 --- a/code/addons/outline/src/withOutline.ts +++ b/code/addons/outline/src/withOutline.ts @@ -1,5 +1,5 @@ import { useMemo, useEffect } from '@storybook/addons'; -import type { AnyFramework, PartialStoryFn as StoryFunction, StoryContext } from '@storybook/csf'; +import type { AnyFramework, PartialStoryFn as StoryFunction, StoryContext } from '@storybook/types'; import { clearStyles, addOutlineStyles } from './helpers'; import { PARAM_KEY } from './constants'; diff --git a/code/addons/storyshots/storyshots-core/package.json b/code/addons/storyshots/storyshots-core/package.json index 95a7e29b7deb..9649098cc80d 100644 --- a/code/addons/storyshots/storyshots-core/package.json +++ b/code/addons/storyshots/storyshots-core/package.json @@ -44,7 +44,7 @@ "@storybook/core-client": "7.0.0-alpha.40", "@storybook/core-common": "7.0.0-alpha.40", "@storybook/core-webpack": "7.0.0-alpha.40", - "@storybook/csf": "0.0.2--canary.49.258942b.0", + "@storybook/types": "7.0.0-alpha.40", "@types/glob": "^7.1.3", "@types/jest": "^26.0.16", "@types/jest-specific-snapshot": "^0.5.3", diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/Loader.ts b/code/addons/storyshots/storyshots-core/src/frameworks/Loader.ts index 5eb8c592dff1..3ce703fc4553 100644 --- a/code/addons/storyshots/storyshots-core/src/frameworks/Loader.ts +++ b/code/addons/storyshots/storyshots-core/src/frameworks/Loader.ts @@ -1,4 +1,4 @@ -import type { AnyFramework } from '@storybook/csf'; +import type { AnyFramework } from '@storybook/types'; import type { Loadable } from '@storybook/addons'; import { ClientApi as ClientApiClass } from '@storybook/client-api'; import type { StoryshotsOptions } from '../api/StoryshotsOptions'; diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/configure.ts b/code/addons/storyshots/storyshots-core/src/frameworks/configure.ts index eef5a9767cc5..20eba79c775a 100644 --- a/code/addons/storyshots/storyshots-core/src/frameworks/configure.ts +++ b/code/addons/storyshots/storyshots-core/src/frameworks/configure.ts @@ -10,7 +10,7 @@ import type { ArgsEnhancer, ArgTypesEnhancer, DecoratorFunction, -} from '@storybook/csf'; +} from '@storybook/types'; import { ClientApi } from './Loader'; import type { StoryshotsOptions } from '../api/StoryshotsOptions'; diff --git a/code/addons/storyshots/storyshots-puppeteer/package.json b/code/addons/storyshots/storyshots-puppeteer/package.json index f82fdcdb3909..158fc7fcf810 100644 --- a/code/addons/storyshots/storyshots-puppeteer/package.json +++ b/code/addons/storyshots/storyshots-puppeteer/package.json @@ -34,8 +34,8 @@ }, "dependencies": { "@axe-core/puppeteer": "^4.2.0", - "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/node-logger": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "@types/jest-image-snapshot": "^4.1.3", "jest-image-snapshot": "^4.3.0" }, diff --git a/code/addons/storyshots/storyshots-puppeteer/src/__tests__/url.test.ts b/code/addons/storyshots/storyshots-puppeteer/src/__tests__/url.test.ts index cf36929dee62..c5d9b2ce187e 100644 --- a/code/addons/storyshots/storyshots-puppeteer/src/__tests__/url.test.ts +++ b/code/addons/storyshots/storyshots-puppeteer/src/__tests__/url.test.ts @@ -1,4 +1,4 @@ -import { toId } from '@storybook/csf'; +import { toId } from '@storybook/types'; import { constructUrl } from '../url'; diff --git a/code/examples/external-docs/package.json b/code/examples/external-docs/package.json index 63c1047ad310..3a77ac04aa8e 100644 --- a/code/examples/external-docs/package.json +++ b/code/examples/external-docs/package.json @@ -15,11 +15,11 @@ "@storybook/addon-essentials": "7.0.0-alpha.40", "@storybook/blocks": "7.0.0-alpha.40", "@storybook/components": "7.0.0-alpha.40", - "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/preview-web": "7.0.0-alpha.40", "@storybook/react": "7.0.0-alpha.40", "@storybook/react-webpack5": "7.0.0-alpha.40", "@storybook/theming": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "formik": "^2.2.9", "next": "^12.1.0", "nextra": "^1.1.0", diff --git a/code/frameworks/angular/package.json b/code/frameworks/angular/package.json index bf6ec6741018..cbb50291328f 100644 --- a/code/frameworks/angular/package.json +++ b/code/frameworks/angular/package.json @@ -43,10 +43,10 @@ "@storybook/core-events": "7.0.0-alpha.40", "@storybook/core-server": "7.0.0-alpha.40", "@storybook/core-webpack": "7.0.0-alpha.40", - "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/docs-tools": "7.0.0-alpha.40", "@storybook/node-logger": "7.0.0-alpha.40", "@storybook/store": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "@types/node": "^16.0.0", "@types/react": "^16.14.23", "@types/react-dom": "^16.9.14", diff --git a/code/frameworks/angular/src/client/angular/helpers.ts b/code/frameworks/angular/src/client/angular/helpers.ts index a75f1c7d2a7c..5e370010ecfb 100644 --- a/code/frameworks/angular/src/client/angular/helpers.ts +++ b/code/frameworks/angular/src/client/angular/helpers.ts @@ -4,7 +4,7 @@ import { FormsModule } from '@angular/forms'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { BrowserModule } from '@angular/platform-browser'; import { Observable, ReplaySubject, Subscriber } from 'rxjs'; -import type { PartialStoryFn } from '@storybook/csf'; +import type { PartialStoryFn } from '@storybook/types'; import { AppComponent } from './app.component'; import { STORY } from './app.token'; import type { NgModuleMetadata, StoryFnAngularReturnType, AngularFramework } from '../types'; diff --git a/code/frameworks/angular/src/client/decorateStory.ts b/code/frameworks/angular/src/client/decorateStory.ts index 39237c2b2fb5..835bdfaf31df 100644 --- a/code/frameworks/angular/src/client/decorateStory.ts +++ b/code/frameworks/angular/src/client/decorateStory.ts @@ -1,4 +1,4 @@ -import type { DecoratorFunction, LegacyStoryFn, StoryContext } from '@storybook/csf'; +import type { DecoratorFunction, LegacyStoryFn, StoryContext } from '@storybook/types'; import { sanitizeStoryContextUpdate } from '@storybook/store'; import { computesTemplateFromComponent } from './angular-beta/ComputesTemplateFromComponent'; diff --git a/code/frameworks/angular/src/client/decorators.ts b/code/frameworks/angular/src/client/decorators.ts index edbf5bc8a757..411bce4c8fd3 100644 --- a/code/frameworks/angular/src/client/decorators.ts +++ b/code/frameworks/angular/src/client/decorators.ts @@ -1,6 +1,6 @@ /* eslint-disable no-param-reassign */ import type { Type } from '@angular/core'; -import type { DecoratorFunction, StoryContext } from '@storybook/csf'; +import type { DecoratorFunction, StoryContext } from '@storybook/types'; import { computesTemplateFromComponent } from './angular-beta/ComputesTemplateFromComponent'; import { isComponent } from './angular-beta/utils/NgComponentAnalyzer'; import type { ICollection, NgModuleMetadata, AngularFramework } from './types'; diff --git a/code/frameworks/angular/src/client/docs/sourceDecorator.ts b/code/frameworks/angular/src/client/docs/sourceDecorator.ts index 4a36d8725869..3671baae71f5 100644 --- a/code/frameworks/angular/src/client/docs/sourceDecorator.ts +++ b/code/frameworks/angular/src/client/docs/sourceDecorator.ts @@ -1,5 +1,5 @@ import { addons, useEffect } from '@storybook/addons'; -import type { PartialStoryFn } from '@storybook/csf'; +import type { PartialStoryFn } from '@storybook/types'; import { SNIPPET_RENDERED, SourceType } from '@storybook/docs-tools'; import { StoryContext, AngularFramework } from '../types'; import { computesTemplateSourceFromComponent } from '../../renderer'; diff --git a/code/frameworks/angular/src/client/public-types.ts b/code/frameworks/angular/src/client/public-types.ts index 27409d4841a0..8220623431cc 100644 --- a/code/frameworks/angular/src/client/public-types.ts +++ b/code/frameworks/angular/src/client/public-types.ts @@ -3,10 +3,10 @@ import type { ComponentAnnotations, StoryAnnotations, AnnotatedStoryFn, -} from '@storybook/csf'; +} from '@storybook/types'; import { AngularFramework } from './types'; -export type { Args, ArgTypes } from '@storybook/csf'; +export type { Args, ArgTypes } from '@storybook/types'; /** * Metadata to configure the stories for a component. diff --git a/code/frameworks/angular/src/client/render.ts b/code/frameworks/angular/src/client/render.ts index 9517d29f17f1..a0b711035610 100644 --- a/code/frameworks/angular/src/client/render.ts +++ b/code/frameworks/angular/src/client/render.ts @@ -1,5 +1,5 @@ import type { RenderContext } from '@storybook/store'; -import type { ArgsStoryFn } from '@storybook/csf'; +import type { ArgsStoryFn } from '@storybook/types'; import { renderNgApp } from './angular/helpers'; import type { AngularFramework } from './types'; diff --git a/code/frameworks/angular/src/client/types.ts b/code/frameworks/angular/src/client/types.ts index 4062eb60abc6..106d02f74d01 100644 --- a/code/frameworks/angular/src/client/types.ts +++ b/code/frameworks/angular/src/client/types.ts @@ -1,7 +1,7 @@ import type { Parameters as DefaultParameters, StoryContext as DefaultStoryContext, -} from '@storybook/csf'; +} from '@storybook/types'; export interface NgModuleMetadata { declarations?: any[]; diff --git a/code/lib/addons/package.json b/code/lib/addons/package.json index ddfc82b21fd7..45048de7198e 100644 --- a/code/lib/addons/package.json +++ b/code/lib/addons/package.json @@ -46,9 +46,9 @@ "@storybook/channels": "7.0.0-alpha.40", "@storybook/client-logger": "7.0.0-alpha.40", "@storybook/core-events": "7.0.0-alpha.40", - "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/router": "7.0.0-alpha.40", "@storybook/theming": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "global": "^4.4.0" }, "peerDependencies": { diff --git a/code/lib/addons/src/hooks.ts b/code/lib/addons/src/hooks.ts index f6b711184778..7c2771ef9aed 100644 --- a/code/lib/addons/src/hooks.ts +++ b/code/lib/addons/src/hooks.ts @@ -8,7 +8,7 @@ import type { StoryId, Args, LegacyStoryFn, -} from '@storybook/csf'; +} from '@storybook/types'; import { FORCE_RE_RENDER, STORY_RENDERED, diff --git a/code/lib/addons/src/types.ts b/code/lib/addons/src/types.ts index 18b0478fc6b4..cdf9aee897cd 100644 --- a/code/lib/addons/src/types.ts +++ b/code/lib/addons/src/types.ts @@ -13,7 +13,7 @@ import type { StoryName, Args, ComponentTitle, -} from '@storybook/csf'; +} from '@storybook/types'; import { Addon } from './index'; @@ -28,7 +28,7 @@ export type { StoryIdentifier, ViewMode, Args, -} from '@storybook/csf'; +} from '@storybook/types'; export interface ArgType extends InputType { defaultValue?: TArg; diff --git a/code/lib/api/package.json b/code/lib/api/package.json index e919035cf3d8..23ed468c530d 100644 --- a/code/lib/api/package.json +++ b/code/lib/api/package.json @@ -51,6 +51,7 @@ "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/router": "7.0.0-alpha.40", "@storybook/theming": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "dequal": "^2.0.2", "global": "^4.4.0", "lodash": "^4.17.21", diff --git a/code/lib/api/src/index.tsx b/code/lib/api/src/index.tsx index 4c72559ce955..c8443c3cb5a3 100644 --- a/code/lib/api/src/index.tsx +++ b/code/lib/api/src/index.tsx @@ -11,7 +11,7 @@ import React, { useRef, } from 'react'; import mergeWith from 'lodash/mergeWith'; -import { Conditional } from '@storybook/csf'; +import { Conditional } from '@storybook/types'; import { STORY_CHANGED, diff --git a/code/lib/api/src/lib/stories.ts b/code/lib/api/src/lib/stories.ts index 4d07501514fa..a9284e6c54ff 100644 --- a/code/lib/api/src/lib/stories.ts +++ b/code/lib/api/src/lib/stories.ts @@ -13,7 +13,7 @@ import type { ArgTypes, Parameters, ComponentId, -} from '@storybook/csf'; +} from '@storybook/types'; import type { DocsOptions } from '@storybook/core-common'; import { combineParameters } from '../index'; diff --git a/code/lib/api/src/modules/globals.ts b/code/lib/api/src/modules/globals.ts index db9cfd5ea149..1ff0689850ed 100644 --- a/code/lib/api/src/modules/globals.ts +++ b/code/lib/api/src/modules/globals.ts @@ -1,7 +1,7 @@ import { SET_GLOBALS, UPDATE_GLOBALS, GLOBALS_UPDATED } from '@storybook/core-events'; import { logger } from '@storybook/client-logger'; import { dequal as deepEqual } from 'dequal'; -import type { Globals, GlobalTypes } from '@storybook/csf'; +import type { Globals, GlobalTypes } from '@storybook/types'; import type { ModuleFn } from '../index'; diff --git a/code/lib/blocks/package.json b/code/lib/blocks/package.json index f17e2abba06f..ec1a27671011 100644 --- a/code/lib/blocks/package.json +++ b/code/lib/blocks/package.json @@ -46,11 +46,11 @@ "@storybook/client-logger": "7.0.0-alpha.40", "@storybook/components": "7.0.0-alpha.40", "@storybook/core-events": "7.0.0-alpha.40", - "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/docs-tools": "7.0.0-alpha.40", "@storybook/preview-web": "7.0.0-alpha.40", "@storybook/store": "7.0.0-alpha.40", "@storybook/theming": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "@types/lodash": "^4.14.167", "color-convert": "^2.0.1", "dequal": "^2.0.2", diff --git a/code/lib/blocks/src/blocks/ArgsTable.tsx b/code/lib/blocks/src/blocks/ArgsTable.tsx index 7a2ee32f7b5a..369b7fa803fc 100644 --- a/code/lib/blocks/src/blocks/ArgsTable.tsx +++ b/code/lib/blocks/src/blocks/ArgsTable.tsx @@ -8,7 +8,7 @@ import { RESET_STORY_ARGS, GLOBALS_UPDATED, } from '@storybook/core-events'; -import { StrictArgTypes, Args, Globals } from '@storybook/csf'; +import { StrictArgTypes, Args, Globals } from '@storybook/types'; import { ArgsTable as PureArgsTable, ArgsTableProps as PureArgsTableProps, diff --git a/code/lib/blocks/src/blocks/Canvas.tsx b/code/lib/blocks/src/blocks/Canvas.tsx index a094c10481e5..cdb542e847d4 100644 --- a/code/lib/blocks/src/blocks/Canvas.tsx +++ b/code/lib/blocks/src/blocks/Canvas.tsx @@ -1,5 +1,5 @@ import React, { FC, ReactElement, ReactNode, ReactNodeArray, useContext } from 'react'; -import { AnyFramework } from '@storybook/csf'; +import { AnyFramework } from '@storybook/types'; import { Preview as PurePreview, PreviewProps as PurePreviewProps, diff --git a/code/lib/blocks/src/blocks/Docs.tsx b/code/lib/blocks/src/blocks/Docs.tsx index ba591fc2ffcb..d630bdcf2c38 100644 --- a/code/lib/blocks/src/blocks/Docs.tsx +++ b/code/lib/blocks/src/blocks/Docs.tsx @@ -1,6 +1,6 @@ import React from 'react'; import type { FunctionComponent, ComponentType } from 'react'; -import type { AnyFramework, Parameters } from '@storybook/csf'; +import type { AnyFramework, Parameters } from '@storybook/types'; import type { Theme } from '@storybook/theming'; import type { DocsContextProps } from './DocsContext'; diff --git a/code/lib/blocks/src/blocks/DocsContainer.tsx b/code/lib/blocks/src/blocks/DocsContainer.tsx index 500ff32ca49d..d7556e1eb969 100644 --- a/code/lib/blocks/src/blocks/DocsContainer.tsx +++ b/code/lib/blocks/src/blocks/DocsContainer.tsx @@ -2,7 +2,7 @@ import React, { FunctionComponent, useEffect, ReactNode } from 'react'; import global from 'global'; import type { ThemeVars } from '@storybook/theming'; import { ThemeProvider, ensure as ensureTheme } from '@storybook/theming'; -import { AnyFramework } from '@storybook/csf'; +import { AnyFramework } from '@storybook/types'; import { DocsWrapper, DocsContent } from '../components'; import { DocsContextProps, DocsContext } from './DocsContext'; import { SourceContainer } from './SourceContainer'; diff --git a/code/lib/blocks/src/blocks/DocsContext.ts b/code/lib/blocks/src/blocks/DocsContext.ts index 86d483eabaae..f6c4a9fd70ac 100644 --- a/code/lib/blocks/src/blocks/DocsContext.ts +++ b/code/lib/blocks/src/blocks/DocsContext.ts @@ -2,7 +2,7 @@ import { Context, createContext } from 'react'; import { window as globalWindow } from 'global'; import type { DocsContextProps } from '@storybook/preview-web'; -import type { AnyFramework } from '@storybook/csf'; +import type { AnyFramework } from '@storybook/types'; export type { DocsContextProps }; diff --git a/code/lib/blocks/src/blocks/Meta.tsx b/code/lib/blocks/src/blocks/Meta.tsx index 2d86eb13a44e..7ae67746bfe1 100644 --- a/code/lib/blocks/src/blocks/Meta.tsx +++ b/code/lib/blocks/src/blocks/Meta.tsx @@ -1,5 +1,5 @@ import React, { FC, useContext } from 'react'; -import { BaseAnnotations } from '@storybook/csf'; +import { BaseAnnotations } from '@storybook/types'; import type { ModuleExports } from '@storybook/store'; import { Anchor } from './Anchor'; diff --git a/code/lib/blocks/src/blocks/Story.tsx b/code/lib/blocks/src/blocks/Story.tsx index e177bff68c70..c3ad03adb776 100644 --- a/code/lib/blocks/src/blocks/Story.tsx +++ b/code/lib/blocks/src/blocks/Story.tsx @@ -8,7 +8,7 @@ import React, { useEffect, useState, } from 'react'; -import { StoryId, StoryAnnotations, AnyFramework } from '@storybook/csf'; +import { StoryId, StoryAnnotations, AnyFramework } from '@storybook/types'; import type { ModuleExport, ModuleExports, Story as StoryType } from '@storybook/store'; import { Story as PureStory, StorySkeleton } from '../components'; diff --git a/code/lib/blocks/src/blocks/Title.tsx b/code/lib/blocks/src/blocks/Title.tsx index 8893719731aa..d2edfa9bbe98 100644 --- a/code/lib/blocks/src/blocks/Title.tsx +++ b/code/lib/blocks/src/blocks/Title.tsx @@ -1,4 +1,4 @@ -import { ComponentTitle } from '@storybook/csf'; +import { ComponentTitle } from '@storybook/types'; import React, { useContext, FunctionComponent } from 'react'; import { Title as PureTitle } from '../components'; import { DocsContext } from './DocsContext'; diff --git a/code/lib/blocks/src/blocks/enhanceSource.test.ts b/code/lib/blocks/src/blocks/enhanceSource.test.ts index f0010c10bdab..4ec16f0fe29e 100644 --- a/code/lib/blocks/src/blocks/enhanceSource.test.ts +++ b/code/lib/blocks/src/blocks/enhanceSource.test.ts @@ -1,4 +1,4 @@ -import type { StoryContext } from '@storybook/csf'; +import type { StoryContext } from '@storybook/types'; import { enhanceSource } from './enhanceSource'; const emptyContext: StoryContext = { diff --git a/code/lib/blocks/src/blocks/enhanceSource.ts b/code/lib/blocks/src/blocks/enhanceSource.ts index f2c799648d23..704d36abdba9 100644 --- a/code/lib/blocks/src/blocks/enhanceSource.ts +++ b/code/lib/blocks/src/blocks/enhanceSource.ts @@ -1,4 +1,4 @@ -import type { Parameters } from '@storybook/csf'; +import type { Parameters } from '@storybook/types'; import type { Story } from '@storybook/store'; import { combineParameters } from '@storybook/store'; diff --git a/code/lib/blocks/src/blocks/external/ExternalDocs.tsx b/code/lib/blocks/src/blocks/external/ExternalDocs.tsx index 0c95663fee9b..a9227fa9c491 100644 --- a/code/lib/blocks/src/blocks/external/ExternalDocs.tsx +++ b/code/lib/blocks/src/blocks/external/ExternalDocs.tsx @@ -1,5 +1,5 @@ import React, { FunctionComponent, useRef } from 'react'; -import { AnyFramework, ProjectAnnotations } from '@storybook/csf'; +import { AnyFramework, ProjectAnnotations } from '@storybook/types'; import { composeConfigs } from '@storybook/store'; import { Docs } from '../Docs'; diff --git a/code/lib/blocks/src/blocks/external/ExternalDocsContainer.tsx b/code/lib/blocks/src/blocks/external/ExternalDocsContainer.tsx index 1b272ff6deac..156c512e31fc 100644 --- a/code/lib/blocks/src/blocks/external/ExternalDocsContainer.tsx +++ b/code/lib/blocks/src/blocks/external/ExternalDocsContainer.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { ThemeProvider, themes, ensure } from '@storybook/theming'; -import { AnyFramework } from '@storybook/csf'; +import { AnyFramework } from '@storybook/types'; import { DocsContext } from '../DocsContext'; import { ExternalPreview } from './ExternalPreview'; diff --git a/code/lib/blocks/src/blocks/external/ExternalDocsContext.ts b/code/lib/blocks/src/blocks/external/ExternalDocsContext.ts index 13a2cd3503aa..96c748a58756 100644 --- a/code/lib/blocks/src/blocks/external/ExternalDocsContext.ts +++ b/code/lib/blocks/src/blocks/external/ExternalDocsContext.ts @@ -1,4 +1,4 @@ -import { AnyFramework } from '@storybook/csf'; +import { AnyFramework } from '@storybook/types'; import { DocsContext } from '@storybook/preview-web'; import { StoryStore } from '@storybook/store'; import type { DocsContextProps } from '@storybook/preview-web'; diff --git a/code/lib/blocks/src/blocks/external/ExternalPreview.ts b/code/lib/blocks/src/blocks/external/ExternalPreview.ts index bf0fcc48f5de..de095f8195b8 100644 --- a/code/lib/blocks/src/blocks/external/ExternalPreview.ts +++ b/code/lib/blocks/src/blocks/external/ExternalPreview.ts @@ -1,6 +1,6 @@ import { Preview } from '@storybook/preview-web'; import { Path, ModuleExports, StoryIndex, composeConfigs } from '@storybook/store'; -import { AnyFramework, ComponentTitle, ProjectAnnotations } from '@storybook/csf'; +import { AnyFramework, ComponentTitle, ProjectAnnotations } from '@storybook/types'; import { Channel } from '@storybook/channels'; import { ExternalDocsContext } from './ExternalDocsContext'; diff --git a/code/lib/blocks/src/blocks/useStory.ts b/code/lib/blocks/src/blocks/useStory.ts index 6c56b6955705..7c0e7d998a22 100644 --- a/code/lib/blocks/src/blocks/useStory.ts +++ b/code/lib/blocks/src/blocks/useStory.ts @@ -1,5 +1,5 @@ import { useState, useEffect } from 'react'; -import type { StoryId, AnyFramework } from '@storybook/csf'; +import type { StoryId, AnyFramework } from '@storybook/types'; import type { Story } from '@storybook/store'; import { DocsContextProps } from './DocsContext'; diff --git a/code/lib/blocks/src/components/ArgsTable/ArgsTable.tsx b/code/lib/blocks/src/components/ArgsTable/ArgsTable.tsx index 2b34084eebf1..82f58ac95dd6 100644 --- a/code/lib/blocks/src/components/ArgsTable/ArgsTable.tsx +++ b/code/lib/blocks/src/components/ArgsTable/ArgsTable.tsx @@ -2,7 +2,7 @@ import React, { FC } from 'react'; import pickBy from 'lodash/pickBy'; import { styled } from '@storybook/theming'; import { opacify, transparentize, darken, lighten } from 'polished'; -import { includeConditionalArg } from '@storybook/csf'; +import { includeConditionalArg } from '@storybook/types'; import { once } from '@storybook/client-logger'; import { IconButton, Icons, Link, ResetWrapper } from '@storybook/components'; import { ArgRow } from './ArgRow'; diff --git a/code/lib/blocks/src/components/ArgsTable/types.ts b/code/lib/blocks/src/components/ArgsTable/types.ts index 5b97d7cb8053..648268f26b54 100644 --- a/code/lib/blocks/src/components/ArgsTable/types.ts +++ b/code/lib/blocks/src/components/ArgsTable/types.ts @@ -1,4 +1,4 @@ -import type { Conditional } from '@storybook/csf'; +import type { Conditional } from '@storybook/types'; export interface JsDocParam { name: string; diff --git a/code/lib/blocks/src/components/Story.tsx b/code/lib/blocks/src/components/Story.tsx index 4e2a2ac3fc95..704d06b373fe 100644 --- a/code/lib/blocks/src/components/Story.tsx +++ b/code/lib/blocks/src/components/Story.tsx @@ -1,6 +1,6 @@ import global from 'global'; import React, { createElement, ElementType, FunctionComponent, Fragment } from 'react'; -import type { Parameters } from '@storybook/csf'; +import type { Parameters } from '@storybook/types'; import { Loader, getStoryHref } from '@storybook/components'; import { EmptyBlock } from '.'; import { IFrame } from './IFrame'; diff --git a/code/lib/builder-vite/src/optimizeDeps.ts b/code/lib/builder-vite/src/optimizeDeps.ts index 1ee4070dff6a..c9f1bf398e73 100644 --- a/code/lib/builder-vite/src/optimizeDeps.ts +++ b/code/lib/builder-vite/src/optimizeDeps.ts @@ -19,7 +19,7 @@ const INCLUDE_CANDIDATES = [ '@storybook/client-api', '@storybook/client-logger', '@storybook/core/client', - '@storybook/csf', + '@storybook/types', '@storybook/preview-web', '@storybook/react > acorn-jsx', '@storybook/react', diff --git a/code/lib/cli/src/window.d.ts b/code/lib/cli/src/window.d.ts index 7b53422ce936..64dda386a29c 100644 --- a/code/lib/cli/src/window.d.ts +++ b/code/lib/cli/src/window.d.ts @@ -1,4 +1,4 @@ -import type { AnyFramework } from '@storybook/csf'; +import type { AnyFramework } from '@storybook/types'; import type { StoryStore } from '@storybook/client-api'; declare global { diff --git a/code/lib/client-api/package.json b/code/lib/client-api/package.json index c839eacd9b9c..288f2fb4ab9c 100644 --- a/code/lib/client-api/package.json +++ b/code/lib/client-api/package.json @@ -46,6 +46,7 @@ "@storybook/client-logger": "7.0.0-alpha.40", "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/store": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "@types/qs": "^6.9.5", "@types/webpack-env": "^1.16.4", "global": "^4.4.0", diff --git a/code/lib/client-api/src/ClientApi.ts b/code/lib/client-api/src/ClientApi.ts index 35ee1170af2a..1938fbd82807 100644 --- a/code/lib/client-api/src/ClientApi.ts +++ b/code/lib/client-api/src/ClientApi.ts @@ -3,9 +3,10 @@ import { dedent } from 'ts-dedent'; import global from 'global'; import { logger } from '@storybook/client-logger'; -import { toId, sanitize, StepRunner } from '@storybook/csf'; +import { toId, sanitize } from '@storybook/csf'; import type { Args, + StepRunner, ArgTypes, AnyFramework, DecoratorFunction, @@ -17,7 +18,7 @@ import type { Globals, GlobalTypes, LegacyStoryFn, -} from '@storybook/csf'; +} from '@storybook/types'; import { combineParameters, composeStepRunners, diff --git a/code/lib/client-api/src/StoryStoreFacade.ts b/code/lib/client-api/src/StoryStoreFacade.ts index 87ad62aa8624..b658ec837b73 100644 --- a/code/lib/client-api/src/StoryStoreFacade.ts +++ b/code/lib/client-api/src/StoryStoreFacade.ts @@ -2,14 +2,15 @@ import global from 'global'; import { dedent } from 'ts-dedent'; import { SynchronousPromise } from 'synchronous-promise'; -import { - toId, - isExportStory, - storyNameFromExport, +import { toId, isExportStory, storyNameFromExport } from '@storybook/csf'; +import type { ComponentTitle, ComponentId, -} from '@storybook/csf'; -import type { StoryId, AnyFramework, Parameters, StoryFn } from '@storybook/csf'; + StoryId, + AnyFramework, + Parameters, + StoryFn, +} from '@storybook/types'; import { StoryStore, userOrAutoTitle, sortStoriesV6 } from '@storybook/store'; import type { NormalizedProjectAnnotations, diff --git a/code/lib/client-api/src/types.ts b/code/lib/client-api/src/types.ts index 25934b585c82..7d71a8cf45fa 100644 --- a/code/lib/client-api/src/types.ts +++ b/code/lib/client-api/src/types.ts @@ -13,7 +13,7 @@ import type { LoaderFunction, StoryContext, } from '@storybook/addons'; -import { AnyFramework, StoryIdentifier, ProjectAnnotations } from '@storybook/csf'; +import { AnyFramework, StoryIdentifier, ProjectAnnotations } from '@storybook/types'; import type { RenderContext } from '@storybook/store'; import { StoryStore, HooksContext } from '@storybook/store'; @@ -26,7 +26,7 @@ export type { SBIntersectionType, SBUnionType, SBOtherType, -} from '@storybook/csf'; +} from '@storybook/types'; // NOTE: these types are really just here for back-compat. Many of them don't have much meaning // Remove in 7.0 diff --git a/code/lib/codemod/package.json b/code/lib/codemod/package.json index c70264408e62..9b787ba1726c 100644 --- a/code/lib/codemod/package.json +++ b/code/lib/codemod/package.json @@ -41,6 +41,7 @@ "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/csf-tools": "7.0.0-alpha.40", "@storybook/node-logger": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "cross-spawn": "^7.0.3", "globby": "^11.0.2", "jscodeshift": "^0.13.1", diff --git a/code/lib/components/package.json b/code/lib/components/package.json index f969186f1683..24b71c5994ce 100644 --- a/code/lib/components/package.json +++ b/code/lib/components/package.json @@ -54,6 +54,7 @@ "@storybook/client-logger": "7.0.0-alpha.40", "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/theming": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "memoizerific": "^1.11.3", "util-deprecate": "^1.0.2" }, diff --git a/code/lib/core-client/package.json b/code/lib/core-client/package.json index 47001418cf67..ec165f6e7b64 100644 --- a/code/lib/core-client/package.json +++ b/code/lib/core-client/package.json @@ -44,6 +44,7 @@ "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/preview-web": "7.0.0-alpha.40", "@storybook/store": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "@storybook/ui": "7.0.0-alpha.40", "global": "^4.4.0", "regenerator-runtime": "^0.13.7", diff --git a/code/lib/core-client/src/preview/start.ts b/code/lib/core-client/src/preview/start.ts index df83e5a254fe..52facd56e8e9 100644 --- a/code/lib/core-client/src/preview/start.ts +++ b/code/lib/core-client/src/preview/start.ts @@ -1,7 +1,7 @@ import global from 'global'; import { ClientApi } from '@storybook/client-api'; import { PreviewWeb } from '@storybook/preview-web'; -import type { AnyFramework, ArgsStoryFn } from '@storybook/csf'; +import type { AnyFramework, ArgsStoryFn } from '@storybook/types'; import { createChannel } from '@storybook/channel-postmessage'; import { addons } from '@storybook/addons'; import { FORCE_RE_RENDER } from '@storybook/core-events'; diff --git a/code/lib/core-common/package.json b/code/lib/core-common/package.json index 9d7e85766199..b35a89c752b9 100644 --- a/code/lib/core-common/package.json +++ b/code/lib/core-common/package.json @@ -47,8 +47,8 @@ }, "dependencies": { "@babel/core": "^7.12.10", - "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/node-logger": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "@types/babel__core": "^7.0.0", "@types/express": "^4.7.0", "@types/node": "^16.0.0", diff --git a/code/lib/core-common/src/types.ts b/code/lib/core-common/src/types.ts index 73925b769293..0659f0e835f0 100644 --- a/code/lib/core-common/src/types.ts +++ b/code/lib/core-common/src/types.ts @@ -2,7 +2,7 @@ import type { Options as TelejsonOptions } from 'telejson'; import type { TransformOptions } from '@babel/core'; import { Router } from 'express'; import { Server } from 'http'; -import type { Parameters } from '@storybook/csf'; +import type { Parameters } from '@storybook/types'; import type { PackageJson as PackageJsonFromTypeFest } from 'type-fest'; import type { FileSystemCache } from './utils/file-cache'; diff --git a/code/lib/core-server/package.json b/code/lib/core-server/package.json index 8a43df7075d5..37706d670d8d 100644 --- a/code/lib/core-server/package.json +++ b/code/lib/core-server/package.json @@ -45,6 +45,7 @@ "@storybook/node-logger": "7.0.0-alpha.40", "@storybook/store": "7.0.0-alpha.40", "@storybook/telemetry": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "@types/node": "^16.0.0", "@types/node-fetch": "^2.5.7", "@types/pretty-hrtime": "^1.0.0", diff --git a/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts b/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts index cae6ef1110ab..f4804e332ff1 100644 --- a/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts +++ b/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts @@ -5,15 +5,15 @@ import fs from 'fs-extra'; import { normalizeStoriesEntry } from '@storybook/core-common'; import type { NormalizedStoriesSpecifier } from '@storybook/core-common'; import { loadCsf, getStorySortParameter } from '@storybook/csf-tools'; -import { toId } from '@storybook/csf'; +import { toId } from '@storybook/types'; import { logger } from '@storybook/node-logger'; import { mocked } from 'ts-jest/utils'; import { StoryIndexGenerator } from './StoryIndexGenerator'; jest.mock('@storybook/csf-tools'); -jest.mock('@storybook/csf', () => { - const csf = jest.requireActual('@storybook/csf'); +jest.mock('@storybook/types', () => { + const csf = jest.requireActual('@storybook/types'); return { ...csf, toId: jest.fn(csf.toId), diff --git a/code/lib/core-server/src/utils/StoryIndexGenerator.ts b/code/lib/core-server/src/utils/StoryIndexGenerator.ts index 101c149210ca..aab41e2445f6 100644 --- a/code/lib/core-server/src/utils/StoryIndexGenerator.ts +++ b/code/lib/core-server/src/utils/StoryIndexGenerator.ts @@ -18,7 +18,7 @@ import type { StoryIndexer, NormalizedStoriesSpecifier, DocsOptions } from '@sto import { normalizeStoryPath } from '@storybook/core-common'; import { logger } from '@storybook/node-logger'; import { getStorySortParameter, NoMetaError } from '@storybook/csf-tools'; -import type { ComponentTitle, StoryName } from '@storybook/csf'; +import type { ComponentTitle, StoryName } from '@storybook/types'; import { toId } from '@storybook/csf'; /** A .mdx file will produce a "standalone" docs entry */ diff --git a/code/lib/csf-tools/package.json b/code/lib/csf-tools/package.json index 348b8c50141e..235734fb0c8a 100644 --- a/code/lib/csf-tools/package.json +++ b/code/lib/csf-tools/package.json @@ -47,6 +47,7 @@ "@babel/traverse": "^7.12.11", "@babel/types": "^7.12.11", "@storybook/csf": "0.0.2--canary.49.258942b.0", + "@storybook/types": "7.0.0-alpha.40", "fs-extra": "^9.0.1", "ts-dedent": "^2.0.0" }, diff --git a/code/lib/docs-tools/package.json b/code/lib/docs-tools/package.json index 3edb2c460d35..f62e1f1ae2a9 100644 --- a/code/lib/docs-tools/package.json +++ b/code/lib/docs-tools/package.json @@ -44,8 +44,8 @@ "dependencies": { "@babel/core": "^7.12.10", "@storybook/core-common": "7.0.0-alpha.40", - "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/store": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "doctrine": "^3.0.0", "lodash": "^4.17.21" }, diff --git a/code/lib/docs-tools/src/argTypes/convert/flow/convert.ts b/code/lib/docs-tools/src/argTypes/convert/flow/convert.ts index 5eb262e75fbd..0917998b1033 100644 --- a/code/lib/docs-tools/src/argTypes/convert/flow/convert.ts +++ b/code/lib/docs-tools/src/argTypes/convert/flow/convert.ts @@ -1,5 +1,5 @@ /* eslint-disable no-case-declarations */ -import type { SBType } from '@storybook/csf'; +import type { SBType } from '@storybook/types'; import type { FlowType, FlowSigType, FlowLiteralType } from './types'; const isLiteral = (type: FlowType) => type.name === 'literal'; diff --git a/code/lib/docs-tools/src/argTypes/convert/proptypes/convert.ts b/code/lib/docs-tools/src/argTypes/convert/proptypes/convert.ts index 277b3e464799..1c4b28832c43 100644 --- a/code/lib/docs-tools/src/argTypes/convert/proptypes/convert.ts +++ b/code/lib/docs-tools/src/argTypes/convert/proptypes/convert.ts @@ -1,6 +1,6 @@ /* eslint-disable no-case-declarations */ import mapValues from 'lodash/mapValues'; -import type { SBType } from '@storybook/csf'; +import type { SBType } from '@storybook/types'; import type { PTType } from './types'; import { includesQuotes, trimQuotes } from '../utils'; diff --git a/code/lib/docs-tools/src/argTypes/convert/typescript/convert.ts b/code/lib/docs-tools/src/argTypes/convert/typescript/convert.ts index 6bfc3d3eac16..4683b933f845 100644 --- a/code/lib/docs-tools/src/argTypes/convert/typescript/convert.ts +++ b/code/lib/docs-tools/src/argTypes/convert/typescript/convert.ts @@ -1,5 +1,5 @@ /* eslint-disable no-case-declarations */ -import type { SBType } from '@storybook/csf'; +import type { SBType } from '@storybook/types'; import type { TSType, TSSigType } from './types'; const convertSig = (type: TSSigType) => { diff --git a/code/lib/docs-tools/src/argTypes/docgen/types.ts b/code/lib/docs-tools/src/argTypes/docgen/types.ts index 3f6cd1d30204..498daee4ac58 100644 --- a/code/lib/docs-tools/src/argTypes/docgen/types.ts +++ b/code/lib/docs-tools/src/argTypes/docgen/types.ts @@ -1,4 +1,4 @@ -import type { StrictArgTypes } from '@storybook/csf'; +import type { StrictArgTypes } from '@storybook/types'; import type { PropDef } from './PropDef'; import type { Component } from '../types'; diff --git a/code/lib/docs-tools/src/argTypes/enhanceArgTypes.test.ts b/code/lib/docs-tools/src/argTypes/enhanceArgTypes.test.ts index 5380ac6a4efc..5c0e0cb5ca66 100644 --- a/code/lib/docs-tools/src/argTypes/enhanceArgTypes.test.ts +++ b/code/lib/docs-tools/src/argTypes/enhanceArgTypes.test.ts @@ -1,5 +1,5 @@ import type { ArgTypes } from '@storybook/api'; -import type { StrictInputType } from '@storybook/csf'; +import type { StrictInputType } from '@storybook/types'; import { enhanceArgTypes } from './enhanceArgTypes'; expect.addSnapshotSerializer({ diff --git a/code/lib/docs-tools/src/argTypes/enhanceArgTypes.ts b/code/lib/docs-tools/src/argTypes/enhanceArgTypes.ts index 783b6af57d92..8b23552e5f82 100644 --- a/code/lib/docs-tools/src/argTypes/enhanceArgTypes.ts +++ b/code/lib/docs-tools/src/argTypes/enhanceArgTypes.ts @@ -1,4 +1,4 @@ -import { AnyFramework, StoryContextForEnhancers } from '@storybook/csf'; +import { AnyFramework, StoryContextForEnhancers } from '@storybook/types'; import { combineParameters } from '@storybook/store'; export const enhanceArgTypes = ( diff --git a/code/lib/preview-web/package.json b/code/lib/preview-web/package.json index e899e3e398a0..d42ef429d34a 100644 --- a/code/lib/preview-web/package.json +++ b/code/lib/preview-web/package.json @@ -38,8 +38,8 @@ "@storybook/channels": "7.0.0-alpha.40", "@storybook/client-logger": "7.0.0-alpha.40", "@storybook/core-events": "7.0.0-alpha.40", - "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/store": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "ansi-to-html": "^0.6.11", "global": "^4.4.0", "lodash": "^4.17.21", diff --git a/code/lib/preview-web/src/Preview.tsx b/code/lib/preview-web/src/Preview.tsx index c17ca1fa131b..8787772170f7 100644 --- a/code/lib/preview-web/src/Preview.tsx +++ b/code/lib/preview-web/src/Preview.tsx @@ -15,7 +15,7 @@ import { } from '@storybook/core-events'; import { logger } from '@storybook/client-logger'; import { addons, Channel } from '@storybook/addons'; -import { AnyFramework, StoryId, ProjectAnnotations, Args, Globals } from '@storybook/csf'; +import { AnyFramework, StoryId, ProjectAnnotations, Args, Globals } from '@storybook/types'; import { ModuleImportFn, Story, diff --git a/code/lib/preview-web/src/PreviewWeb.test.ts b/code/lib/preview-web/src/PreviewWeb.test.ts index 35d88acd75c9..757b78e8aad0 100644 --- a/code/lib/preview-web/src/PreviewWeb.test.ts +++ b/code/lib/preview-web/src/PreviewWeb.test.ts @@ -29,7 +29,7 @@ import { } from '@storybook/core-events'; import { logger } from '@storybook/client-logger'; import { addons, mockChannel as createMockChannel } from '@storybook/addons'; -import type { AnyFramework } from '@storybook/csf'; +import type { AnyFramework } from '@storybook/types'; import type { ModuleImportFn, WebProjectAnnotations } from '@storybook/store'; import { mocked } from 'ts-jest/utils'; diff --git a/code/lib/preview-web/src/PreviewWeb.tsx b/code/lib/preview-web/src/PreviewWeb.tsx index f11f67600746..6ecc261e3acf 100644 --- a/code/lib/preview-web/src/PreviewWeb.tsx +++ b/code/lib/preview-web/src/PreviewWeb.tsx @@ -18,7 +18,14 @@ import { UPDATE_QUERY_PARAMS, } from '@storybook/core-events'; import { logger } from '@storybook/client-logger'; -import { AnyFramework, StoryId, ProjectAnnotations, Args, Globals, ViewMode } from '@storybook/csf'; +import { + AnyFramework, + StoryId, + ProjectAnnotations, + Args, + Globals, + ViewMode, +} from '@storybook/types'; import type { ModuleImportFn, Selection, diff --git a/code/lib/preview-web/src/docs-context/DocsContext.ts b/code/lib/preview-web/src/docs-context/DocsContext.ts index ae1aa3e8b260..2f1aa015567d 100644 --- a/code/lib/preview-web/src/docs-context/DocsContext.ts +++ b/code/lib/preview-web/src/docs-context/DocsContext.ts @@ -1,4 +1,4 @@ -import type { AnyFramework, StoryContextForLoaders, StoryId, StoryName } from '@storybook/csf'; +import type { AnyFramework, StoryContextForLoaders, StoryId, StoryName } from '@storybook/types'; import type { CSFFile, ModuleExport, ModuleExports, Story, StoryStore } from '@storybook/store'; import type { Channel } from '@storybook/channels'; diff --git a/code/lib/preview-web/src/docs-context/DocsContextProps.ts b/code/lib/preview-web/src/docs-context/DocsContextProps.ts index a82b2ee7f9aa..979810bc6aca 100644 --- a/code/lib/preview-web/src/docs-context/DocsContextProps.ts +++ b/code/lib/preview-web/src/docs-context/DocsContextProps.ts @@ -1,4 +1,4 @@ -import type { StoryId, StoryName, AnyFramework, StoryContextForLoaders } from '@storybook/csf'; +import type { StoryId, StoryName, AnyFramework, StoryContextForLoaders } from '@storybook/types'; import type { ModuleExport, ModuleExports, Story } from '@storybook/store'; import type { Channel } from '@storybook/channels'; diff --git a/code/lib/preview-web/src/docs-context/DocsRenderFunction.ts b/code/lib/preview-web/src/docs-context/DocsRenderFunction.ts index b453943311e4..b5afef5d9d6d 100644 --- a/code/lib/preview-web/src/docs-context/DocsRenderFunction.ts +++ b/code/lib/preview-web/src/docs-context/DocsRenderFunction.ts @@ -1,4 +1,4 @@ -import type { AnyFramework, Parameters } from '@storybook/csf'; +import type { AnyFramework, Parameters } from '@storybook/types'; import { DocsContextProps } from './DocsContextProps'; export type DocsRenderFunction = ( diff --git a/code/lib/preview-web/src/render/Render.ts b/code/lib/preview-web/src/render/Render.ts index 95d15245336d..7dd3b796bde0 100644 --- a/code/lib/preview-web/src/render/Render.ts +++ b/code/lib/preview-web/src/render/Render.ts @@ -1,4 +1,4 @@ -import { StoryId, AnyFramework } from '@storybook/csf'; +import { StoryId, AnyFramework } from '@storybook/types'; export type RenderType = 'story' | 'docs'; diff --git a/code/lib/preview-web/src/render/StandaloneDocsRender.test.ts b/code/lib/preview-web/src/render/StandaloneDocsRender.test.ts index 492f33dc0bd2..531ce49986c0 100644 --- a/code/lib/preview-web/src/render/StandaloneDocsRender.test.ts +++ b/code/lib/preview-web/src/render/StandaloneDocsRender.test.ts @@ -1,6 +1,6 @@ import { jest, describe, it, expect } from '@jest/globals'; import { Channel } from '@storybook/channels'; -import { AnyFramework } from '@storybook/csf'; +import { AnyFramework } from '@storybook/types'; import { StoryStore } from '@storybook/store'; import type { StandaloneDocsIndexEntry } from '@storybook/store'; import { PREPARE_ABORTED } from './Render'; diff --git a/code/lib/preview-web/src/render/StandaloneDocsRender.ts b/code/lib/preview-web/src/render/StandaloneDocsRender.ts index 27581c2ad9b3..08d624cba2e5 100644 --- a/code/lib/preview-web/src/render/StandaloneDocsRender.ts +++ b/code/lib/preview-web/src/render/StandaloneDocsRender.ts @@ -1,4 +1,4 @@ -import { AnyFramework, StoryId } from '@storybook/csf'; +import { AnyFramework, StoryId } from '@storybook/types'; import { CSFFile, ModuleExports, StoryStore } from '@storybook/store'; import { Channel, IndexEntry } from '@storybook/addons'; import { DOCS_RENDERED } from '@storybook/core-events'; diff --git a/code/lib/preview-web/src/render/StoryRender.test.ts b/code/lib/preview-web/src/render/StoryRender.test.ts index 7ec87a7d1506..91514526f391 100644 --- a/code/lib/preview-web/src/render/StoryRender.test.ts +++ b/code/lib/preview-web/src/render/StoryRender.test.ts @@ -1,6 +1,6 @@ import { jest, describe, it, expect } from '@jest/globals'; import { Channel } from '@storybook/channels'; -import { AnyFramework } from '@storybook/csf'; +import { AnyFramework } from '@storybook/types'; import { StoryStore } from '@storybook/store'; import type { StoryIndexEntry } from '@storybook/store'; import { PREPARE_ABORTED } from './Render'; diff --git a/code/lib/preview-web/src/render/StoryRender.ts b/code/lib/preview-web/src/render/StoryRender.ts index f8349ba4d48a..5f5360ee67be 100644 --- a/code/lib/preview-web/src/render/StoryRender.ts +++ b/code/lib/preview-web/src/render/StoryRender.ts @@ -5,7 +5,7 @@ import { ViewMode, StoryContextForLoaders, StoryContext, -} from '@storybook/csf'; +} from '@storybook/types'; import { Story, RenderContext, diff --git a/code/lib/preview-web/src/render/TemplateDocsRender.test.ts b/code/lib/preview-web/src/render/TemplateDocsRender.test.ts index 572fb3541b9a..806b00df7883 100644 --- a/code/lib/preview-web/src/render/TemplateDocsRender.test.ts +++ b/code/lib/preview-web/src/render/TemplateDocsRender.test.ts @@ -1,6 +1,6 @@ import { jest, describe, it, expect } from '@jest/globals'; import { Channel } from '@storybook/channels'; -import { AnyFramework } from '@storybook/csf'; +import { AnyFramework } from '@storybook/types'; import { StoryStore } from '@storybook/store'; import type { TemplateDocsIndexEntry } from '@storybook/store'; import { PREPARE_ABORTED } from './Render'; diff --git a/code/lib/preview-web/src/render/TemplateDocsRender.ts b/code/lib/preview-web/src/render/TemplateDocsRender.ts index 1d3be018ae83..02a05e351ce5 100644 --- a/code/lib/preview-web/src/render/TemplateDocsRender.ts +++ b/code/lib/preview-web/src/render/TemplateDocsRender.ts @@ -1,4 +1,4 @@ -import { AnyFramework, StoryId } from '@storybook/csf'; +import { AnyFramework, StoryId } from '@storybook/types'; import { CSFFile, Story, StoryStore } from '@storybook/store'; import { Channel, IndexEntry } from '@storybook/addons'; import { DOCS_RENDERED } from '@storybook/core-events'; diff --git a/code/lib/source-loader/package.json b/code/lib/source-loader/package.json index d6e7ba4b4618..34723e569581 100644 --- a/code/lib/source-loader/package.json +++ b/code/lib/source-loader/package.json @@ -44,6 +44,7 @@ }, "dependencies": { "@storybook/csf": "0.0.2--canary.49.258942b.0", + "@storybook/types": "7.0.0-alpha.40", "estraverse": "^5.2.0", "lodash": "^4.17.21", "prettier": ">=2.2.1 <=2.3.0" diff --git a/code/lib/store/package.json b/code/lib/store/package.json index f3b9cae68383..623e61e925e3 100644 --- a/code/lib/store/package.json +++ b/code/lib/store/package.json @@ -46,6 +46,7 @@ "@storybook/client-logger": "7.0.0-alpha.40", "@storybook/core-events": "7.0.0-alpha.40", "@storybook/csf": "0.0.2--canary.49.258942b.0", + "@storybook/types": "7.0.0-alpha.40", "dequal": "^2.0.2", "global": "^4.4.0", "lodash": "^4.17.21", diff --git a/code/lib/store/src/ArgsStore.ts b/code/lib/store/src/ArgsStore.ts index eb7c85004050..7efed70a4494 100644 --- a/code/lib/store/src/ArgsStore.ts +++ b/code/lib/store/src/ArgsStore.ts @@ -1,4 +1,4 @@ -import type { StoryId, Args } from '@storybook/csf'; +import type { StoryId, Args } from '@storybook/types'; import type { Story } from './types'; import { combineArgs, mapArgsToTypes, validateOptions, deepDiff, DEEPLY_EQUAL } from './args'; diff --git a/code/lib/store/src/GlobalsStore.ts b/code/lib/store/src/GlobalsStore.ts index 657eac39f276..97085edc3461 100644 --- a/code/lib/store/src/GlobalsStore.ts +++ b/code/lib/store/src/GlobalsStore.ts @@ -1,4 +1,4 @@ -import type { Globals, GlobalTypes } from '@storybook/csf'; +import type { Globals, GlobalTypes } from '@storybook/types'; import { deepDiff, DEEPLY_EQUAL } from './args'; import { getValuesFromArgTypes } from './csf/getValuesFromArgTypes'; diff --git a/code/lib/store/src/StoryIndexStore.ts b/code/lib/store/src/StoryIndexStore.ts index 1633549d7b3a..7e4b6e059b67 100644 --- a/code/lib/store/src/StoryIndexStore.ts +++ b/code/lib/store/src/StoryIndexStore.ts @@ -1,5 +1,5 @@ import { dedent } from 'ts-dedent'; -import type { StoryId } from '@storybook/csf'; +import type { StoryId } from '@storybook/types'; import memoize from 'memoizerific'; import type { StorySpecifier, StoryIndex, IndexEntry, Path } from './types'; diff --git a/code/lib/store/src/StoryStore.test.ts b/code/lib/store/src/StoryStore.test.ts index 6ca4c653672a..0d73fd5e2497 100644 --- a/code/lib/store/src/StoryStore.test.ts +++ b/code/lib/store/src/StoryStore.test.ts @@ -1,4 +1,4 @@ -import type { AnyFramework, ProjectAnnotations } from '@storybook/csf'; +import type { AnyFramework, ProjectAnnotations } from '@storybook/types'; import global from 'global'; import { expect } from '@jest/globals'; diff --git a/code/lib/store/src/StoryStore.ts b/code/lib/store/src/StoryStore.ts index 43d37866efb1..9da263c52543 100644 --- a/code/lib/store/src/StoryStore.ts +++ b/code/lib/store/src/StoryStore.ts @@ -8,7 +8,7 @@ import type { ComponentTitle, StoryContextForEnhancers, StoryContext, -} from '@storybook/csf'; +} from '@storybook/types'; import mapValues from 'lodash/mapValues'; import pick from 'lodash/pick'; import { SynchronousPromise } from 'synchronous-promise'; diff --git a/code/lib/store/src/args.test.ts b/code/lib/store/src/args.test.ts index c3adf885f3f2..ec5ab1388c9c 100644 --- a/code/lib/store/src/args.test.ts +++ b/code/lib/store/src/args.test.ts @@ -1,6 +1,6 @@ import { once } from '@storybook/client-logger'; import { expect } from '@jest/globals'; -import { SBType } from '@storybook/csf'; +import { SBType } from '@storybook/types'; import { combineArgs, diff --git a/code/lib/store/src/args.ts b/code/lib/store/src/args.ts index ddcc41baeec6..b32be8bbbcd8 100644 --- a/code/lib/store/src/args.ts +++ b/code/lib/store/src/args.ts @@ -1,5 +1,12 @@ import { dequal as deepEqual } from 'dequal'; -import type { SBType, Args, InputType, ArgTypes, StoryContext, AnyFramework } from '@storybook/csf'; +import type { + SBType, + Args, + InputType, + ArgTypes, + StoryContext, + AnyFramework, +} from '@storybook/types'; import { once } from '@storybook/client-logger'; import isPlainObject from 'lodash/isPlainObject'; import { dedent } from 'ts-dedent'; diff --git a/code/lib/store/src/csf/composeConfigs.ts b/code/lib/store/src/csf/composeConfigs.ts index f43aed164704..9b231d660f7d 100644 --- a/code/lib/store/src/csf/composeConfigs.ts +++ b/code/lib/store/src/csf/composeConfigs.ts @@ -1,4 +1,4 @@ -import type { AnyFramework } from '@storybook/csf'; +import type { AnyFramework } from '@storybook/types'; import type { ModuleExports, WebProjectAnnotations } from '../types'; import { combineParameters } from '../parameters'; diff --git a/code/lib/store/src/csf/getValuesFromArgTypes.ts b/code/lib/store/src/csf/getValuesFromArgTypes.ts index 62960971968f..72a1f213be7e 100644 --- a/code/lib/store/src/csf/getValuesFromArgTypes.ts +++ b/code/lib/store/src/csf/getValuesFromArgTypes.ts @@ -1,4 +1,4 @@ -import type { ArgTypes } from '@storybook/csf'; +import type { ArgTypes } from '@storybook/types'; export const getValuesFromArgTypes = (argTypes: ArgTypes = {}) => Object.entries(argTypes).reduce((acc, [arg, { defaultValue }]) => { diff --git a/code/lib/store/src/csf/normalizeComponentAnnotations.ts b/code/lib/store/src/csf/normalizeComponentAnnotations.ts index 88de4e6cccbe..f20212d5cef8 100644 --- a/code/lib/store/src/csf/normalizeComponentAnnotations.ts +++ b/code/lib/store/src/csf/normalizeComponentAnnotations.ts @@ -1,5 +1,5 @@ import { sanitize } from '@storybook/csf'; -import type { AnyFramework } from '@storybook/csf'; +import type { AnyFramework } from '@storybook/types'; import type { ModuleExports, NormalizedComponentAnnotations } from '../types'; import { normalizeInputTypes } from './normalizeInputTypes'; diff --git a/code/lib/store/src/csf/normalizeInputTypes.ts b/code/lib/store/src/csf/normalizeInputTypes.ts index 0aea0a875f14..e4ca3ed23fa0 100644 --- a/code/lib/store/src/csf/normalizeInputTypes.ts +++ b/code/lib/store/src/csf/normalizeInputTypes.ts @@ -6,7 +6,7 @@ import type { StrictArgTypes, StrictGlobalTypes, StrictInputType, -} from '@storybook/csf'; +} from '@storybook/types'; const normalizeType = (type: InputType['type']): StrictInputType['type'] => { return typeof type === 'string' ? { name: type } : type; diff --git a/code/lib/store/src/csf/normalizeProjectAnnotations.ts b/code/lib/store/src/csf/normalizeProjectAnnotations.ts index b443f2a75c17..91f486521cc5 100644 --- a/code/lib/store/src/csf/normalizeProjectAnnotations.ts +++ b/code/lib/store/src/csf/normalizeProjectAnnotations.ts @@ -1,4 +1,4 @@ -import type { AnyFramework, ArgTypes, ProjectAnnotations } from '@storybook/csf'; +import type { AnyFramework, ArgTypes, ProjectAnnotations } from '@storybook/types'; import { inferArgTypes } from '../inferArgTypes'; import { inferControls } from '../inferControls'; diff --git a/code/lib/store/src/csf/normalizeStory.test.ts b/code/lib/store/src/csf/normalizeStory.test.ts index a05675acae5e..ce78bc1a3b97 100644 --- a/code/lib/store/src/csf/normalizeStory.test.ts +++ b/code/lib/store/src/csf/normalizeStory.test.ts @@ -1,5 +1,5 @@ import { expect } from '@jest/globals'; -import { AnyFramework, StoryAnnotationsOrFn } from '@storybook/csf'; +import { AnyFramework, StoryAnnotationsOrFn } from '@storybook/types'; import { normalizeStory } from './normalizeStory'; diff --git a/code/lib/store/src/csf/normalizeStory.ts b/code/lib/store/src/csf/normalizeStory.ts index 13401e3a627e..1938d38618dc 100644 --- a/code/lib/store/src/csf/normalizeStory.ts +++ b/code/lib/store/src/csf/normalizeStory.ts @@ -5,7 +5,7 @@ import type { StoryAnnotations, StoryFn, ArgTypes, -} from '@storybook/csf'; +} from '@storybook/types'; import { storyNameFromExport, toId } from '@storybook/csf'; import { dedent } from 'ts-dedent'; import { logger } from '@storybook/client-logger'; diff --git a/code/lib/store/src/csf/prepareStory.test.ts b/code/lib/store/src/csf/prepareStory.test.ts index 81ae1314eab3..aa28424ca3ce 100644 --- a/code/lib/store/src/csf/prepareStory.test.ts +++ b/code/lib/store/src/csf/prepareStory.test.ts @@ -7,7 +7,7 @@ import type { PlayFunctionContext, SBObjectType, SBScalarType, -} from '@storybook/csf'; +} from '@storybook/types'; import { NO_TARGET_NAME } from '../args'; import { prepareStory } from './prepareStory'; diff --git a/code/lib/store/src/csf/prepareStory.ts b/code/lib/store/src/csf/prepareStory.ts index 92f8ce6e3e71..3d6b0db2f045 100644 --- a/code/lib/store/src/csf/prepareStory.ts +++ b/code/lib/store/src/csf/prepareStory.ts @@ -15,7 +15,7 @@ import type { PlayFunctionContext, StepLabel, PlayFunction, -} from '@storybook/csf'; +} from '@storybook/types'; import { includeConditionalArg } from '@storybook/csf'; import type { diff --git a/code/lib/store/src/csf/processCSFFile.ts b/code/lib/store/src/csf/processCSFFile.ts index ff082349dcf1..3ce8f794947f 100644 --- a/code/lib/store/src/csf/processCSFFile.ts +++ b/code/lib/store/src/csf/processCSFFile.ts @@ -1,4 +1,4 @@ -import type { Parameters, AnyFramework, ComponentTitle } from '@storybook/csf'; +import type { Parameters, AnyFramework, ComponentTitle } from '@storybook/types'; import { isExportStory } from '@storybook/csf'; import { logger } from '@storybook/client-logger'; diff --git a/code/lib/store/src/csf/stepRunners.test.ts b/code/lib/store/src/csf/stepRunners.test.ts index 5a65b59acab6..071e8cde9e47 100644 --- a/code/lib/store/src/csf/stepRunners.test.ts +++ b/code/lib/store/src/csf/stepRunners.test.ts @@ -1,4 +1,4 @@ -import { PlayFunctionContext, StepRunner } from '@storybook/csf'; +import { PlayFunctionContext, StepRunner } from '@storybook/types'; import { composeStepRunners } from './stepRunners'; describe('stepRunners', () => { diff --git a/code/lib/store/src/csf/stepRunners.ts b/code/lib/store/src/csf/stepRunners.ts index af12acd12d4d..806a12bcc810 100644 --- a/code/lib/store/src/csf/stepRunners.ts +++ b/code/lib/store/src/csf/stepRunners.ts @@ -1,4 +1,4 @@ -import { AnyFramework, StepRunner } from '@storybook/csf'; +import { AnyFramework, StepRunner } from '@storybook/types'; /** * Compose step runners to create a single step runner that applies each step runner in order. diff --git a/code/lib/store/src/csf/testing-utils/index.ts b/code/lib/store/src/csf/testing-utils/index.ts index 253a6d9820e7..8656bafe3f59 100644 --- a/code/lib/store/src/csf/testing-utils/index.ts +++ b/code/lib/store/src/csf/testing-utils/index.ts @@ -1,5 +1,5 @@ +import { isExportStory } from '@storybook/csf'; import { - isExportStory, AnyFramework, AnnotatedStoryFn, StoryAnnotations, @@ -9,7 +9,7 @@ import { StoryContext, Parameters, LegacyStoryAnnotationsOrFn, -} from '@storybook/csf'; +} from '@storybook/types'; import { composeConfigs } from '../composeConfigs'; import { prepareStory } from '../prepareStory'; diff --git a/code/lib/store/src/csf/testing-utils/types.ts b/code/lib/store/src/csf/testing-utils/types.ts index ad627ef7c618..459cd9e1fb92 100644 --- a/code/lib/store/src/csf/testing-utils/types.ts +++ b/code/lib/store/src/csf/testing-utils/types.ts @@ -5,7 +5,7 @@ import type { ComponentAnnotations, Args, StoryContext, -} from '@storybook/csf'; +} from '@storybook/types'; export type CSFExports = { default: ComponentAnnotations; diff --git a/code/lib/store/src/decorators.test.ts b/code/lib/store/src/decorators.test.ts index c576d03a548b..5739dd5f28df 100644 --- a/code/lib/store/src/decorators.test.ts +++ b/code/lib/store/src/decorators.test.ts @@ -1,5 +1,5 @@ import { expect } from '@jest/globals'; -import type { AnyFramework, StoryContext } from '@storybook/csf'; +import type { AnyFramework, StoryContext } from '@storybook/types'; import { defaultDecorateStory } from './decorators'; diff --git a/code/lib/store/src/decorators.ts b/code/lib/store/src/decorators.ts index 5c77411b1621..7605cb6904c0 100644 --- a/code/lib/store/src/decorators.ts +++ b/code/lib/store/src/decorators.ts @@ -5,7 +5,7 @@ import type { PartialStoryFn, LegacyStoryFn, AnyFramework, -} from '@storybook/csf'; +} from '@storybook/types'; export function decorateStory( storyFn: LegacyStoryFn, diff --git a/code/lib/store/src/filterArgTypes.ts b/code/lib/store/src/filterArgTypes.ts index c07450df2eba..c28c2f99491f 100644 --- a/code/lib/store/src/filterArgTypes.ts +++ b/code/lib/store/src/filterArgTypes.ts @@ -1,4 +1,4 @@ -import type { StrictArgTypes } from '@storybook/csf'; +import type { StrictArgTypes } from '@storybook/types'; import pickBy from 'lodash/pickBy'; export type PropDescriptor = string[] | RegExp; diff --git a/code/lib/store/src/hooks.test.ts b/code/lib/store/src/hooks.test.ts index 1be7c41a9c61..3b0526eec09c 100644 --- a/code/lib/store/src/hooks.test.ts +++ b/code/lib/store/src/hooks.test.ts @@ -7,7 +7,7 @@ import { UPDATE_GLOBALS, } from '@storybook/core-events'; import { addons } from '@storybook/addons'; -import { DecoratorFunction, StoryContext } from '@storybook/csf'; +import { DecoratorFunction, StoryContext } from '@storybook/types'; import { defaultDecorateStory } from './decorators'; import { diff --git a/code/lib/store/src/inferArgTypes.ts b/code/lib/store/src/inferArgTypes.ts index 3cdb5433666e..66531c2691b5 100644 --- a/code/lib/store/src/inferArgTypes.ts +++ b/code/lib/store/src/inferArgTypes.ts @@ -1,7 +1,7 @@ import mapValues from 'lodash/mapValues'; import { dedent } from 'ts-dedent'; import { logger } from '@storybook/client-logger'; -import type { AnyFramework, SBType, ArgTypesEnhancer } from '@storybook/csf'; +import type { AnyFramework, SBType, ArgTypesEnhancer } from '@storybook/types'; import { combineParameters } from './parameters'; const inferType = (value: any, name: string, visited: Set): SBType => { diff --git a/code/lib/store/src/inferControls.test.ts b/code/lib/store/src/inferControls.test.ts index 79c916e3c208..1231d544c8f6 100644 --- a/code/lib/store/src/inferControls.test.ts +++ b/code/lib/store/src/inferControls.test.ts @@ -1,6 +1,6 @@ import { expect } from '@jest/globals'; import { logger } from '@storybook/client-logger'; -import { StoryContextForEnhancers } from '@storybook/csf'; +import { StoryContextForEnhancers } from '@storybook/types'; import { argTypesEnhancers } from './inferControls'; diff --git a/code/lib/store/src/inferControls.ts b/code/lib/store/src/inferControls.ts index fce183337d32..93b31e1882be 100644 --- a/code/lib/store/src/inferControls.ts +++ b/code/lib/store/src/inferControls.ts @@ -1,6 +1,6 @@ import mapValues from 'lodash/mapValues'; import { logger } from '@storybook/client-logger'; -import type { AnyFramework, SBEnumType, StrictInputType, ArgTypesEnhancer } from '@storybook/csf'; +import type { AnyFramework, SBEnumType, StrictInputType, ArgTypesEnhancer } from '@storybook/types'; import { filterArgTypes } from './filterArgTypes'; import { combineParameters } from './parameters'; diff --git a/code/lib/store/src/storySort.test.ts b/code/lib/store/src/storySort.test.ts index 1efe4a2b4117..c26033476686 100644 --- a/code/lib/store/src/storySort.test.ts +++ b/code/lib/store/src/storySort.test.ts @@ -1,5 +1,5 @@ import { expect } from '@jest/globals'; -import { StoryId } from '@storybook/csf'; +import { StoryId } from '@storybook/types'; import { StoryIndexEntry } from '@storybook/store'; import { storySort } from './storySort'; diff --git a/code/lib/store/src/types.ts b/code/lib/store/src/types.ts index d816fab56a2f..e4cb5e107ba1 100644 --- a/code/lib/store/src/types.ts +++ b/code/lib/store/src/types.ts @@ -21,7 +21,7 @@ import type { ComponentId, PartialStoryFn, Parameters, -} from '@storybook/csf'; +} from '@storybook/types'; import type { StoryIndexEntry, DocsIndexEntry, diff --git a/code/lib/store/template/stories/preview.ts b/code/lib/store/template/stories/preview.ts index 56852e2fc6e2..43fd9b08cda2 100644 --- a/code/lib/store/template/stories/preview.ts +++ b/code/lib/store/template/stories/preview.ts @@ -1,4 +1,4 @@ -import { PartialStoryFn, StoryContext } from '@storybook/csf'; +import { PartialStoryFn, StoryContext } from '@storybook/types'; export const parameters = { projectParameter: 'projectParameter', diff --git a/code/lib/types/src/index.ts b/code/lib/types/src/index.ts index 79be869edb0b..fa290b3b32a7 100644 --- a/code/lib/types/src/index.ts +++ b/code/lib/types/src/index.ts @@ -1,2 +1,113 @@ -/* eslint-disable import/no-extraneous-dependencies */ -export * from '@storybook/csf'; +import type { + ViewMode, + AnnotatedStoryFn, + AnyFramework, + ArgTypes, + ArgTypesEnhancer, + Args, + ArgsEnhancer, + ArgsStoryFn, + BaseAnnotations, + ComponentAnnotations, + ComponentId, + ComponentTitle, + Conditional, + DecoratorApplicator, + DecoratorFunction, + GlobalTypes, + Globals, + IncludeExcludeOptions, + InputType, + LegacyAnnotatedStoryFn, + LegacyStoryAnnotationsOrFn, + LegacyStoryFn, + LoaderFunction, + Parameters, + PartialStoryFn, + PlayFunction, + PlayFunctionContext, + ProjectAnnotations, + SBArrayType, + SBEnumType, + SBIntersectionType, + SBObjectType, + SBOtherType, + SBScalarType, + SBType, + SBUnionType, + SeparatorOptions, + StepFunction, + StepLabel, + StepRunner, + StoryAnnotations, + StoryAnnotationsOrFn, + StoryContext, + StoryContextForEnhancers, + StoryContextForLoaders, + StoryContextUpdate, + StoryFn, + StoryId, + StoryIdentifier, + StoryKind, + StoryName, + StrictArgTypes, + StrictGlobalTypes, + StrictInputType, +} from '@storybook/csf'; + +export { + ViewMode, + AnnotatedStoryFn, + AnyFramework, + ArgTypes, + ArgTypesEnhancer, + Args, + ArgsEnhancer, + ArgsStoryFn, + BaseAnnotations, + ComponentAnnotations, + ComponentId, + ComponentTitle, + Conditional, + DecoratorApplicator, + DecoratorFunction, + GlobalTypes, + Globals, + IncludeExcludeOptions, + InputType, + LegacyAnnotatedStoryFn, + LegacyStoryAnnotationsOrFn, + LegacyStoryFn, + LoaderFunction, + Parameters, + PartialStoryFn, + PlayFunction, + PlayFunctionContext, + ProjectAnnotations, + SBArrayType, + SBEnumType, + SBIntersectionType, + SBObjectType, + SBOtherType, + SBScalarType, + SBType, + SBUnionType, + SeparatorOptions, + StepFunction, + StepLabel, + StepRunner, + StoryAnnotations, + StoryAnnotationsOrFn, + StoryContext, + StoryContextForEnhancers, + StoryContextForLoaders, + StoryContextUpdate, + StoryFn, + StoryId, + StoryIdentifier, + StoryKind, + StoryName, + StrictArgTypes, + StrictGlobalTypes, + StrictInputType, +}; diff --git a/code/package.json b/code/package.json index 38a3dce0a374..2fe6799ed315 100644 --- a/code/package.json +++ b/code/package.json @@ -220,6 +220,7 @@ "@storybook/telemetry": "workspace:*", "@storybook/testing-library": "0.0.14-next.0", "@storybook/theming": "workspace:*", + "@storybook/types": "workspace:*", "@storybook/ui": "workspace:*", "@storybook/vue": "workspace:*", "@storybook/vue-webpack5": "workspace:*", diff --git a/code/renderers/html/package.json b/code/renderers/html/package.json index 96ee953e9d8b..4334df2c62e4 100644 --- a/code/renderers/html/package.json +++ b/code/renderers/html/package.json @@ -52,10 +52,10 @@ "dependencies": { "@storybook/addons": "7.0.0-alpha.40", "@storybook/core-client": "7.0.0-alpha.40", - "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/docs-tools": "7.0.0-alpha.40", "@storybook/preview-web": "7.0.0-alpha.40", "@storybook/store": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "global": "^4.4.0", "react": "16.14.0", "react-dom": "16.14.0", diff --git a/code/renderers/html/src/docs/sourceDecorator.ts b/code/renderers/html/src/docs/sourceDecorator.ts index fc247fff84f1..21854cd6d1e3 100644 --- a/code/renderers/html/src/docs/sourceDecorator.ts +++ b/code/renderers/html/src/docs/sourceDecorator.ts @@ -2,7 +2,7 @@ /* global window */ import { SNIPPET_RENDERED, SourceType } from '@storybook/docs-tools'; import { addons, useEffect } from '@storybook/addons'; -import type { PartialStoryFn } from '@storybook/csf'; +import type { PartialStoryFn } from '@storybook/types'; import { dedent } from 'ts-dedent'; import { HtmlFramework, StoryContext } from '../types'; import { StoryFn } from '../public-types'; diff --git a/code/renderers/html/src/public-types.ts b/code/renderers/html/src/public-types.ts index b449ec6263ac..ba30b00eaf1a 100644 --- a/code/renderers/html/src/public-types.ts +++ b/code/renderers/html/src/public-types.ts @@ -3,10 +3,10 @@ import type { ComponentAnnotations, StoryAnnotations, AnnotatedStoryFn, -} from '@storybook/csf'; +} from '@storybook/types'; import { HtmlFramework } from './types'; -export type { Args, ArgTypes, Parameters } from '@storybook/csf'; +export type { Args, ArgTypes, Parameters } from '@storybook/types'; /** * Metadata to configure the stories for a component. diff --git a/code/renderers/html/src/render.ts b/code/renderers/html/src/render.ts index 7dc568763373..fa92b430df50 100644 --- a/code/renderers/html/src/render.ts +++ b/code/renderers/html/src/render.ts @@ -5,7 +5,7 @@ import global from 'global'; import { dedent } from 'ts-dedent'; import { simulatePageLoad, simulateDOMContentLoaded } from '@storybook/preview-web'; import type { RenderContext } from '@storybook/store'; -import { ArgsStoryFn } from '@storybook/csf'; +import { ArgsStoryFn } from '@storybook/types'; import type { HtmlFramework } from './types'; const { Node } = global; diff --git a/code/renderers/html/src/types.ts b/code/renderers/html/src/types.ts index 68d1adf8ca1d..58e24cd5fe23 100644 --- a/code/renderers/html/src/types.ts +++ b/code/renderers/html/src/types.ts @@ -1,4 +1,4 @@ -import type { ArgsStoryFn, StoryContext as DefaultStoryContext } from '@storybook/csf'; +import type { ArgsStoryFn, StoryContext as DefaultStoryContext } from '@storybook/types'; import { parameters } from './config'; export type { RenderContext } from '@storybook/core-client'; diff --git a/code/renderers/preact/package.json b/code/renderers/preact/package.json index 768f00ff9c39..473473ca2e49 100644 --- a/code/renderers/preact/package.json +++ b/code/renderers/preact/package.json @@ -52,8 +52,8 @@ "dependencies": { "@storybook/addons": "7.0.0-alpha.40", "@storybook/core-client": "7.0.0-alpha.40", - "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/store": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "global": "^4.4.0", "react": "16.14.0", "react-dom": "16.14.0", diff --git a/code/renderers/preact/src/public-types.ts b/code/renderers/preact/src/public-types.ts index f82e3f821325..3d220fcd00db 100644 --- a/code/renderers/preact/src/public-types.ts +++ b/code/renderers/preact/src/public-types.ts @@ -3,10 +3,10 @@ import type { ComponentAnnotations, StoryAnnotations, AnnotatedStoryFn, -} from '@storybook/csf'; +} from '@storybook/types'; import { PreactFramework } from './types'; -export type { Args, ArgTypes, Parameters, StoryContext } from '@storybook/csf'; +export type { Args, ArgTypes, Parameters, StoryContext } from '@storybook/types'; /** * Metadata to configure the stories for a component. diff --git a/code/renderers/preact/src/render.tsx b/code/renderers/preact/src/render.tsx index a3328dac2577..3d83b4b9dd94 100644 --- a/code/renderers/preact/src/render.tsx +++ b/code/renderers/preact/src/render.tsx @@ -2,7 +2,7 @@ import * as preact from 'preact'; import { dedent } from 'ts-dedent'; import type { RenderContext } from '@storybook/store'; -import { ArgsStoryFn } from '@storybook/csf'; +import { ArgsStoryFn } from '@storybook/types'; import type { StoryFnPreactReturnType, PreactFramework } from './types'; diff --git a/code/renderers/react/package.json b/code/renderers/react/package.json index 82eede93b3b7..76bf2c4c275a 100644 --- a/code/renderers/react/package.json +++ b/code/renderers/react/package.json @@ -54,9 +54,9 @@ "@storybook/addons": "7.0.0-alpha.40", "@storybook/client-logger": "7.0.0-alpha.40", "@storybook/core-client": "7.0.0-alpha.40", - "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/docs-tools": "7.0.0-alpha.40", "@storybook/store": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "@types/estree": "^0.0.51", "@types/node": "^16.0.0", "acorn": "^7.4.1", diff --git a/code/renderers/react/src/__test__/CSF3.test.tsx b/code/renderers/react/src/__test__/CSF3.test.tsx index 89bbb79aa3ea..b53d0ac680a9 100644 --- a/code/renderers/react/src/__test__/CSF3.test.tsx +++ b/code/renderers/react/src/__test__/CSF3.test.tsx @@ -1,7 +1,7 @@ import React, { KeyboardEventHandler, ReactNode } from 'react'; import { expectTypeOf } from 'expect-type'; import { describe, test } from '@jest/globals'; -import { StoryAnnotations } from '@storybook/csf'; +import { StoryAnnotations } from '@storybook/types'; import { SetOptional } from 'type-fest'; import { Meta, StoryObj } from '../public-types'; diff --git a/code/renderers/react/src/docs/extractArgTypes.test.ts b/code/renderers/react/src/docs/extractArgTypes.test.ts index 1906485c26a8..65783cf1d107 100644 --- a/code/renderers/react/src/docs/extractArgTypes.test.ts +++ b/code/renderers/react/src/docs/extractArgTypes.test.ts @@ -5,7 +5,7 @@ import requireFromString from 'require-from-string'; import { transformFileSync, transformSync } from '@babel/core'; import { inferControls } from '@storybook/store'; -import type { AnyFramework } from '@storybook/csf'; +import type { AnyFramework } from '@storybook/types'; import { normalizeNewlines } from '@storybook/docs-tools'; import type { StoryContext } from '../types'; diff --git a/code/renderers/react/src/docs/extractArgTypes.ts b/code/renderers/react/src/docs/extractArgTypes.ts index 333052be43e1..2da2e2724e7d 100644 --- a/code/renderers/react/src/docs/extractArgTypes.ts +++ b/code/renderers/react/src/docs/extractArgTypes.ts @@ -1,4 +1,4 @@ -import type { StrictArgTypes } from '@storybook/csf'; +import type { StrictArgTypes } from '@storybook/types'; import type { PropDef, ArgTypesExtractor } from '@storybook/docs-tools'; import { extractProps } from './extractProps'; diff --git a/code/renderers/react/src/docs/jsxDecorator.tsx b/code/renderers/react/src/docs/jsxDecorator.tsx index 343c30de9d95..b0fda7e927d1 100644 --- a/code/renderers/react/src/docs/jsxDecorator.tsx +++ b/code/renderers/react/src/docs/jsxDecorator.tsx @@ -3,7 +3,7 @@ import React, { createElement, ReactElement } from 'react'; import reactElementToJSXString, { Options } from 'react-element-to-jsx-string'; import { addons, useEffect } from '@storybook/addons'; -import { StoryContext, ArgsStoryFn, PartialStoryFn } from '@storybook/csf'; +import { StoryContext, ArgsStoryFn, PartialStoryFn } from '@storybook/types'; import { SourceType, SNIPPET_RENDERED, getDocgenSection } from '@storybook/docs-tools'; import { logger } from '@storybook/client-logger'; diff --git a/code/renderers/react/src/public-api.tsx b/code/renderers/react/src/public-api.tsx index aabd6a287648..754c3466221b 100644 --- a/code/renderers/react/src/public-api.tsx +++ b/code/renderers/react/src/public-api.tsx @@ -1,7 +1,7 @@ /* eslint-disable prefer-destructuring */ import { start } from '@storybook/core-client'; import type { ClientStoryApi, Loadable } from '@storybook/addons'; -import { Args, DecoratorFunction } from '@storybook/csf'; +import { Args, DecoratorFunction } from '@storybook/types'; import { renderToDOM, render } from './render'; import type { ReactFramework } from './types'; diff --git a/code/renderers/react/src/public-types.ts b/code/renderers/react/src/public-types.ts index d724fc681c73..97fee5a1b8e0 100644 --- a/code/renderers/react/src/public-types.ts +++ b/code/renderers/react/src/public-types.ts @@ -5,7 +5,7 @@ import type { ComponentAnnotations, LoaderFunction, StoryAnnotations, -} from '@storybook/csf'; +} from '@storybook/types'; import { SetOptional, Simplify, UnionToIntersection } from 'type-fest'; import { ComponentProps, ComponentType, JSXElementConstructor } from 'react'; diff --git a/code/renderers/react/src/render.tsx b/code/renderers/react/src/render.tsx index 9ec2fffd5264..75f517c1662d 100644 --- a/code/renderers/react/src/render.tsx +++ b/code/renderers/react/src/render.tsx @@ -14,7 +14,7 @@ import ReactDOM, { version as reactDomVersion } from 'react-dom'; import type { Root as ReactRoot } from 'react-dom/client'; import type { RenderContext } from '@storybook/store'; -import { ArgsStoryFn } from '@storybook/csf'; +import { ArgsStoryFn } from '@storybook/types'; import type { ReactFramework, StoryContext } from './types'; diff --git a/code/renderers/react/src/testing-api.ts b/code/renderers/react/src/testing-api.ts index b22a72a72a39..4c0399c2fcd5 100644 --- a/code/renderers/react/src/testing-api.ts +++ b/code/renderers/react/src/testing-api.ts @@ -4,7 +4,7 @@ import { setProjectAnnotations as originalSetProjectAnnotations, } from '@storybook/store'; import type { CSFExports, ComposedStory, StoriesWithPartialProps } from '@storybook/store'; -import { ProjectAnnotations, Args } from '@storybook/csf'; +import { ProjectAnnotations, Args } from '@storybook/types'; import { deprecate } from '@storybook/client-logger'; import { render } from './render'; diff --git a/code/renderers/react/src/types.ts b/code/renderers/react/src/types.ts index 1c07a654ab5f..0fdbdb992551 100644 --- a/code/renderers/react/src/types.ts +++ b/code/renderers/react/src/types.ts @@ -1,8 +1,8 @@ import type { ComponentType, ReactElement } from 'react'; -import type { AnyFramework } from '@storybook/csf'; +import type { AnyFramework } from '@storybook/types'; export type { RenderContext } from '@storybook/store'; -export type { StoryContext } from '@storybook/csf'; +export type { StoryContext } from '@storybook/types'; export interface ReactFramework extends AnyFramework { component: ComponentType; diff --git a/code/renderers/server/package.json b/code/renderers/server/package.json index d8d8b40afaa8..db267504130f 100644 --- a/code/renderers/server/package.json +++ b/code/renderers/server/package.json @@ -52,9 +52,9 @@ "dependencies": { "@storybook/addons": "7.0.0-alpha.40", "@storybook/core-client": "7.0.0-alpha.40", - "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/preview-web": "7.0.0-alpha.40", "@storybook/store": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "global": "^4.4.0", "react": "16.14.0", "react-dom": "16.14.0", diff --git a/code/renderers/server/src/public-types.ts b/code/renderers/server/src/public-types.ts index 7beaae35903d..601933e7d49d 100644 --- a/code/renderers/server/src/public-types.ts +++ b/code/renderers/server/src/public-types.ts @@ -3,10 +3,10 @@ import type { ComponentAnnotations, StoryAnnotations, AnnotatedStoryFn, -} from '@storybook/csf'; +} from '@storybook/types'; import { ServerFramework } from './types'; -export type { Args, ArgTypes, Parameters, StoryContext } from '@storybook/csf'; +export type { Args, ArgTypes, Parameters, StoryContext } from '@storybook/types'; /** * Metadata to configure the stories for a component. diff --git a/code/renderers/server/src/types.ts b/code/renderers/server/src/types.ts index a55d6f3129ea..32f6644027a1 100644 --- a/code/renderers/server/src/types.ts +++ b/code/renderers/server/src/types.ts @@ -1,4 +1,4 @@ -import type { StoryContext as StoryContextBase } from '@storybook/csf'; +import type { StoryContext as StoryContextBase } from '@storybook/types'; export type { RenderContext } from '@storybook/core-client'; diff --git a/code/renderers/svelte/package.json b/code/renderers/svelte/package.json index 3f71a294599c..77edb4ed43f6 100644 --- a/code/renderers/svelte/package.json +++ b/code/renderers/svelte/package.json @@ -57,9 +57,9 @@ "@storybook/addons": "7.0.0-alpha.40", "@storybook/client-logger": "7.0.0-alpha.40", "@storybook/core-client": "7.0.0-alpha.40", - "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/docs-tools": "7.0.0-alpha.40", "@storybook/store": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "global": "^4.4.0", "react": "16.14.0", "react-dom": "16.14.0", diff --git a/code/renderers/svelte/src/decorators.ts b/code/renderers/svelte/src/decorators.ts index 09165817a17a..b79aa9cc55ff 100644 --- a/code/renderers/svelte/src/decorators.ts +++ b/code/renderers/svelte/src/decorators.ts @@ -1,4 +1,4 @@ -import type { DecoratorFunction, StoryContext, LegacyStoryFn } from '@storybook/csf'; +import type { DecoratorFunction, StoryContext, LegacyStoryFn } from '@storybook/types'; import { sanitizeStoryContextUpdate } from '@storybook/store'; // eslint-disable-next-line import/no-extraneous-dependencies import SlotDecorator from '@storybook/svelte/templates/SlotDecorator.svelte'; diff --git a/code/renderers/svelte/src/docs/extractArgTypes.ts b/code/renderers/svelte/src/docs/extractArgTypes.ts index 900d55b336a2..9ad9cb5dbc88 100644 --- a/code/renderers/svelte/src/docs/extractArgTypes.ts +++ b/code/renderers/svelte/src/docs/extractArgTypes.ts @@ -1,4 +1,4 @@ -import type { SBScalarType, StrictArgTypes } from '@storybook/csf'; +import type { SBScalarType, StrictArgTypes } from '@storybook/types'; import { logger } from '@storybook/client-logger'; import type { SvelteComponentDoc, diff --git a/code/renderers/svelte/src/docs/sourceDecorator.ts b/code/renderers/svelte/src/docs/sourceDecorator.ts index 846a63c0b730..dd0bd12976bd 100644 --- a/code/renderers/svelte/src/docs/sourceDecorator.ts +++ b/code/renderers/svelte/src/docs/sourceDecorator.ts @@ -1,7 +1,7 @@ /* eslint-disable no-underscore-dangle */ import { addons, useEffect } from '@storybook/addons'; import { deprecate } from '@storybook/client-logger'; -import type { ArgTypes, Args, StoryContext, AnyFramework } from '@storybook/csf'; +import type { ArgTypes, Args, StoryContext, AnyFramework } from '@storybook/types'; import { SourceType, SNIPPET_RENDERED } from '@storybook/docs-tools'; diff --git a/code/renderers/svelte/src/public-types.ts b/code/renderers/svelte/src/public-types.ts index d3d0eb46616b..e9b3c0f76227 100644 --- a/code/renderers/svelte/src/public-types.ts +++ b/code/renderers/svelte/src/public-types.ts @@ -3,10 +3,10 @@ import type { ComponentAnnotations, StoryAnnotations, AnnotatedStoryFn, -} from '@storybook/csf'; +} from '@storybook/types'; import { SvelteFramework } from './types'; -export type { Args, ArgTypes, Parameters, StoryContext } from '@storybook/csf'; +export type { Args, ArgTypes, Parameters, StoryContext } from '@storybook/types'; /** * Metadata to configure the stories for a component. diff --git a/code/renderers/svelte/src/render.ts b/code/renderers/svelte/src/render.ts index e436d26b41f0..16dcbdb22fc6 100644 --- a/code/renderers/svelte/src/render.ts +++ b/code/renderers/svelte/src/render.ts @@ -1,7 +1,7 @@ // @ts-expect-error (Converted from ts-ignore) import global from 'global'; -import type { ArgsStoryFn } from '@storybook/csf'; +import type { ArgsStoryFn } from '@storybook/types'; import type { RenderContext } from '@storybook/store'; // eslint-disable-next-line import/no-extraneous-dependencies import PreviewRender from '@storybook/svelte/templates/PreviewRender.svelte'; diff --git a/code/renderers/svelte/src/types.ts b/code/renderers/svelte/src/types.ts index d4c7d2b2cc32..058c6ff7398e 100644 --- a/code/renderers/svelte/src/types.ts +++ b/code/renderers/svelte/src/types.ts @@ -1,4 +1,4 @@ -import type { StoryContext as StoryContextBase } from '@storybook/csf'; +import type { StoryContext as StoryContextBase } from '@storybook/types'; export type { RenderContext } from '@storybook/core-client'; diff --git a/code/renderers/vue/package.json b/code/renderers/vue/package.json index e66c9d7dd572..d2762b37782a 100644 --- a/code/renderers/vue/package.json +++ b/code/renderers/vue/package.json @@ -53,9 +53,9 @@ "@storybook/addons": "7.0.0-alpha.40", "@storybook/client-logger": "7.0.0-alpha.40", "@storybook/core-client": "7.0.0-alpha.40", - "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/docs-tools": "7.0.0-alpha.40", "@storybook/store": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "global": "^4.4.0", "react": "16.14.0", "react-dom": "16.14.0", diff --git a/code/renderers/vue/src/decorateStory.ts b/code/renderers/vue/src/decorateStory.ts index 534d525374b5..05037907ce99 100644 --- a/code/renderers/vue/src/decorateStory.ts +++ b/code/renderers/vue/src/decorateStory.ts @@ -1,5 +1,5 @@ import Vue, { VueConstructor, ComponentOptions } from 'vue'; -import type { DecoratorFunction, StoryContext, LegacyStoryFn } from '@storybook/csf'; +import type { DecoratorFunction, StoryContext, LegacyStoryFn } from '@storybook/types'; import { sanitizeStoryContextUpdate } from '@storybook/store'; import type { StoryFnVueReturnType, VueFramework } from './types'; diff --git a/code/renderers/vue/src/docs/extractArgTypes.ts b/code/renderers/vue/src/docs/extractArgTypes.ts index 509b1439d3a4..f214d9f7c7b0 100644 --- a/code/renderers/vue/src/docs/extractArgTypes.ts +++ b/code/renderers/vue/src/docs/extractArgTypes.ts @@ -1,4 +1,4 @@ -import type { StrictArgTypes } from '@storybook/csf'; +import type { StrictArgTypes } from '@storybook/types'; import type { ArgTypesExtractor, DocgenInfo, PropDef } from '@storybook/docs-tools'; import { hasDocgen, extractComponentProps, convert } from '@storybook/docs-tools'; diff --git a/code/renderers/vue/src/public-types.ts b/code/renderers/vue/src/public-types.ts index 7d1185e6ca6f..526743a0791f 100644 --- a/code/renderers/vue/src/public-types.ts +++ b/code/renderers/vue/src/public-types.ts @@ -3,10 +3,10 @@ import type { ComponentAnnotations, StoryAnnotations, AnnotatedStoryFn, -} from '@storybook/csf'; +} from '@storybook/types'; import { VueFramework } from './types'; -export type { Args, ArgTypes, Parameters, StoryContext } from '@storybook/csf'; +export type { Args, ArgTypes, Parameters, StoryContext } from '@storybook/types'; /** * Metadata to configure the stories for a component. diff --git a/code/renderers/vue/src/render.ts b/code/renderers/vue/src/render.ts index aa011a7dd93a..7a72723fca31 100644 --- a/code/renderers/vue/src/render.ts +++ b/code/renderers/vue/src/render.ts @@ -2,7 +2,7 @@ import { dedent } from 'ts-dedent'; import Vue from 'vue'; import type { RenderContext } from '@storybook/store'; -import type { ArgsStoryFn } from '@storybook/csf'; +import type { ArgsStoryFn } from '@storybook/types'; import { CombinedVueInstance } from 'vue/types/vue'; import type { VueFramework } from './types'; diff --git a/code/renderers/vue/src/types.ts b/code/renderers/vue/src/types.ts index 6cb4fb3ea340..0522fcfc0e6a 100644 --- a/code/renderers/vue/src/types.ts +++ b/code/renderers/vue/src/types.ts @@ -1,4 +1,4 @@ -import type { StoryContext as StoryContextBase } from '@storybook/csf'; +import type { StoryContext as StoryContextBase } from '@storybook/types'; import type { Component, AsyncComponent } from 'vue'; export type { RenderContext } from '@storybook/core-client'; diff --git a/code/renderers/vue3/package.json b/code/renderers/vue3/package.json index a726fa59407d..1beb6c979150 100644 --- a/code/renderers/vue3/package.json +++ b/code/renderers/vue3/package.json @@ -52,9 +52,9 @@ "dependencies": { "@storybook/addons": "7.0.0-alpha.40", "@storybook/core-client": "7.0.0-alpha.40", - "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/docs-tools": "7.0.0-alpha.40", "@storybook/store": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "global": "^4.4.0", "react": "16.14.0", "react-dom": "16.14.0", diff --git a/code/renderers/vue3/src/decorateStory.ts b/code/renderers/vue3/src/decorateStory.ts index 7cbbe47b7b90..b5fddb1b572f 100644 --- a/code/renderers/vue3/src/decorateStory.ts +++ b/code/renderers/vue3/src/decorateStory.ts @@ -1,6 +1,6 @@ import type { ConcreteComponent, Component, ComponentOptions } from 'vue'; import { h } from 'vue'; -import type { DecoratorFunction, StoryContext, LegacyStoryFn } from '@storybook/csf'; +import type { DecoratorFunction, StoryContext, LegacyStoryFn } from '@storybook/types'; import { sanitizeStoryContextUpdate } from '@storybook/store'; import type { VueFramework } from './types'; diff --git a/code/renderers/vue3/src/docs/extractArgTypes.ts b/code/renderers/vue3/src/docs/extractArgTypes.ts index 9a26e308afc8..8c8b5f221638 100644 --- a/code/renderers/vue3/src/docs/extractArgTypes.ts +++ b/code/renderers/vue3/src/docs/extractArgTypes.ts @@ -1,4 +1,4 @@ -import type { StrictArgTypes } from '@storybook/csf'; +import type { StrictArgTypes } from '@storybook/types'; import type { ArgTypesExtractor } from '@storybook/docs-tools'; import { hasDocgen, extractComponentProps, convert } from '@storybook/docs-tools'; diff --git a/code/renderers/vue3/src/public-types.ts b/code/renderers/vue3/src/public-types.ts index 7d1185e6ca6f..526743a0791f 100644 --- a/code/renderers/vue3/src/public-types.ts +++ b/code/renderers/vue3/src/public-types.ts @@ -3,10 +3,10 @@ import type { ComponentAnnotations, StoryAnnotations, AnnotatedStoryFn, -} from '@storybook/csf'; +} from '@storybook/types'; import { VueFramework } from './types'; -export type { Args, ArgTypes, Parameters, StoryContext } from '@storybook/csf'; +export type { Args, ArgTypes, Parameters, StoryContext } from '@storybook/types'; /** * Metadata to configure the stories for a component. diff --git a/code/renderers/vue3/src/render.ts b/code/renderers/vue3/src/render.ts index f6e08da07c64..291746304a6a 100644 --- a/code/renderers/vue3/src/render.ts +++ b/code/renderers/vue3/src/render.ts @@ -1,7 +1,7 @@ import { dedent } from 'ts-dedent'; import { createApp, h } from 'vue'; import type { RenderContext } from '@storybook/store'; -import type { ArgsStoryFn } from '@storybook/csf'; +import type { ArgsStoryFn } from '@storybook/types'; import { StoryFnVueReturnType, VueFramework } from './types'; diff --git a/code/renderers/vue3/src/types.ts b/code/renderers/vue3/src/types.ts index 1a7f5ee9500c..1082586f06f6 100644 --- a/code/renderers/vue3/src/types.ts +++ b/code/renderers/vue3/src/types.ts @@ -1,4 +1,4 @@ -import type { StoryContext as StoryContextBase } from '@storybook/csf'; +import type { StoryContext as StoryContextBase } from '@storybook/types'; import type { ConcreteComponent } from 'vue'; export type { RenderContext } from '@storybook/core-client'; diff --git a/code/renderers/web-components/package.json b/code/renderers/web-components/package.json index 946e4a453686..1f5fb63eac9c 100644 --- a/code/renderers/web-components/package.json +++ b/code/renderers/web-components/package.json @@ -56,10 +56,10 @@ "@storybook/api": "7.0.0-alpha.40", "@storybook/client-logger": "7.0.0-alpha.40", "@storybook/core-client": "7.0.0-alpha.40", - "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/docs-tools": "7.0.0-alpha.40", "@storybook/preview-web": "7.0.0-alpha.40", "@storybook/store": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "global": "^4.4.0", "react": "16.14.0", "react-dom": "16.14.0", diff --git a/code/renderers/web-components/src/docs/sourceDecorator.ts b/code/renderers/web-components/src/docs/sourceDecorator.ts index da298cc94cc8..ec3c971e75aa 100644 --- a/code/renderers/web-components/src/docs/sourceDecorator.ts +++ b/code/renderers/web-components/src/docs/sourceDecorator.ts @@ -1,7 +1,7 @@ /* eslint-disable no-underscore-dangle */ /* global window */ import { render } from 'lit-html'; -import type { ArgsStoryFn, PartialStoryFn, StoryContext } from '@storybook/csf'; +import type { ArgsStoryFn, PartialStoryFn, StoryContext } from '@storybook/types'; import { addons, useEffect } from '@storybook/addons'; import { SNIPPET_RENDERED, SourceType } from '@storybook/docs-tools'; diff --git a/code/renderers/web-components/src/public-types.ts b/code/renderers/web-components/src/public-types.ts index e6a9d7b707eb..17daf7bd088e 100644 --- a/code/renderers/web-components/src/public-types.ts +++ b/code/renderers/web-components/src/public-types.ts @@ -3,7 +3,7 @@ import type { StoryAnnotations, AnnotatedStoryFn, Args, -} from '@storybook/csf'; +} from '@storybook/types'; import { WebComponentsFramework } from './types'; /** diff --git a/code/renderers/web-components/src/render.ts b/code/renderers/web-components/src/render.ts index 07f11762b0d9..fdada72c3847 100644 --- a/code/renderers/web-components/src/render.ts +++ b/code/renderers/web-components/src/render.ts @@ -9,7 +9,7 @@ import { render as litRender } from 'lit-html'; import { isTemplateResult } from 'lit-html/directive-helpers.js'; import { simulatePageLoad, simulateDOMContentLoaded } from '@storybook/preview-web'; import type { RenderContext } from '@storybook/store'; -import { ArgsStoryFn } from '@storybook/csf'; +import { ArgsStoryFn } from '@storybook/types'; import { WebComponentsFramework } from './types'; const { Node } = global; diff --git a/code/renderers/web-components/src/types.ts b/code/renderers/web-components/src/types.ts index 75c5391aad79..3c01fc6f0a23 100644 --- a/code/renderers/web-components/src/types.ts +++ b/code/renderers/web-components/src/types.ts @@ -1,4 +1,4 @@ -import type { StoryContext as StoryContextBase } from '@storybook/csf'; +import type { StoryContext as StoryContextBase } from '@storybook/types'; import type { TemplateResult, SVGTemplateResult } from 'lit-html'; export type StoryFnHtmlReturnType = string | Node | TemplateResult | SVGTemplateResult; diff --git a/code/ui/manager/package.json b/code/ui/manager/package.json index ce17d4eefdfd..04e1c1825041 100644 --- a/code/ui/manager/package.json +++ b/code/ui/manager/package.json @@ -61,9 +61,9 @@ "@storybook/client-logger": "7.0.0-alpha.40", "@storybook/components": "7.0.0-alpha.40", "@storybook/core-events": "7.0.0-alpha.40", - "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/router": "7.0.0-alpha.40", "@storybook/theming": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "@testing-library/react": "^11.2.2", "@types/semver": "^7.3.4", "copy-to-clipboard": "^3.3.1", diff --git a/code/ui/manager/src/components/preview/utils/types.tsx b/code/ui/manager/src/components/preview/utils/types.tsx index fe74d6ef76be..25af5f96cff9 100644 --- a/code/ui/manager/src/components/preview/utils/types.tsx +++ b/code/ui/manager/src/components/preview/utils/types.tsx @@ -1,6 +1,6 @@ import { FunctionComponent, ReactNode } from 'react'; import type { State, API, LeafEntry } from '@storybook/api'; -import { StoryId } from '@storybook/csf'; +import { StoryId } from '@storybook/types'; export type ViewMode = State['viewMode']; diff --git a/code/workspace.json b/code/workspace.json index d6697a33e062..4db29dd38131 100644 --- a/code/workspace.json +++ b/code/workspace.json @@ -2,449 +2,454 @@ "version": 2, "projects": { "@storybook/addon-a11y": { + "implicitDependencies": [], "root": "addons/a11y", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/addon-actions": { + "implicitDependencies": [], "root": "addons/actions", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/addon-backgrounds": { + "implicitDependencies": [], "root": "addons/backgrounds", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/addon-controls": { + "implicitDependencies": [], "root": "addons/controls", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/addon-docs": { + "implicitDependencies": [], "root": "addons/docs", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/addon-essentials": { + "implicitDependencies": [], "root": "addons/essentials", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/addon-highlight": { + "implicitDependencies": [], "root": "addons/highlight", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/addon-interactions": { + "implicitDependencies": [], "root": "addons/interactions", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/addon-jest": { + "implicitDependencies": [], "root": "addons/jest", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/addon-links": { + "implicitDependencies": [], "root": "addons/links", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/addon-measure": { + "implicitDependencies": [], "root": "addons/measure", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/addon-outline": { + "implicitDependencies": [], "root": "addons/outline", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/addon-storyshots": { + "implicitDependencies": [], "root": "addons/storyshots/storyshots-core", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/addon-storyshots-puppeteer": { + "implicitDependencies": [], "root": "addons/storyshots/storyshots-puppeteer", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/addon-storysource": { + "implicitDependencies": [], "root": "addons/storysource", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/addon-toolbars": { + "implicitDependencies": [], "root": "addons/toolbars", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/addon-viewport": { + "implicitDependencies": [], "root": "addons/viewport", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/addons": { + "implicitDependencies": [], "root": "lib/addons", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/angular": { + "implicitDependencies": [], "root": "frameworks/angular", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/api": { + "implicitDependencies": [], "root": "lib/api", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/blocks": { + "implicitDependencies": [], "root": "lib/blocks", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/builder-manager": { + "implicitDependencies": [], "root": "lib/builder-manager", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/builder-vite": { + "implicitDependencies": [], "root": "lib/builder-vite", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/builder-webpack5": { + "implicitDependencies": [], "root": "lib/builder-webpack5", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/channel-postmessage": { + "implicitDependencies": [], "root": "lib/channel-postmessage", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/channel-websocket": { + "implicitDependencies": [], "root": "lib/channel-websocket", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/channels": { + "implicitDependencies": [], "root": "lib/channels", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/cli": { + "implicitDependencies": [], "root": "lib/cli", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/client-api": { + "implicitDependencies": [], "root": "lib/client-api", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/client-logger": { + "implicitDependencies": [], "root": "lib/client-logger", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/codemod": { + "implicitDependencies": [], "root": "lib/codemod", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/components": { + "implicitDependencies": [], "root": "lib/components", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/core-client": { + "implicitDependencies": [], "root": "lib/core-client", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/core-common": { + "implicitDependencies": [], "root": "lib/core-common", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/core-events": { + "implicitDependencies": [], "root": "lib/core-events", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/core-server": { + "implicitDependencies": [], "root": "lib/core-server", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/core-vite": { + "implicitDependencies": [], "root": "lib/core-vite", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/core-webpack": { + "implicitDependencies": [], "root": "lib/core-webpack", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/csf-tools": { + "implicitDependencies": [], "root": "lib/csf-tools", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/docs-tools": { + "implicitDependencies": [], "root": "lib/docs-tools", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/ember": { + "implicitDependencies": [], "root": "frameworks/ember", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/example-doc-blocks": { + "implicitDependencies": [], "root": "examples/doc-blocks", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/external-docs": { + "implicitDependencies": [], "root": "examples/external-docs", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/html": { + "implicitDependencies": [], "root": "renderers/html", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/html-webpack5": { + "implicitDependencies": [], "root": "frameworks/html-webpack5", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/instrumenter": { + "implicitDependencies": [], "root": "lib/instrumenter", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/node-logger": { + "implicitDependencies": [], "root": "lib/node-logger", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/postinstall": { + "implicitDependencies": [], "root": "lib/postinstall", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/preact": { + "implicitDependencies": [], "root": "renderers/preact", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/preact-webpack5": { + "implicitDependencies": [], "root": "frameworks/preact-webpack5", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/preset-html-webpack": { + "implicitDependencies": [], "root": "presets/html-webpack", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/preset-preact-webpack": { + "implicitDependencies": [], "root": "presets/preact-webpack", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/preset-react-webpack": { + "implicitDependencies": [], "root": "presets/react-webpack", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/preset-server-webpack": { + "implicitDependencies": [], "root": "presets/server-webpack", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/preset-svelte-webpack": { + "implicitDependencies": [], "root": "presets/svelte-webpack", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/preset-vue-webpack": { + "implicitDependencies": [], "root": "presets/vue-webpack", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/preset-vue3-webpack": { + "implicitDependencies": [], "root": "presets/vue3-webpack", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/preset-web-components-webpack": { + "implicitDependencies": [], "root": "presets/web-components-webpack", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/preview-web": { + "implicitDependencies": [], "root": "lib/preview-web", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/react": { + "implicitDependencies": [], "root": "renderers/react", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/react-vite": { + "implicitDependencies": [], "root": "frameworks/react-vite", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/react-webpack5": { + "implicitDependencies": [], "root": "frameworks/react-webpack5", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/router": { + "implicitDependencies": [], "root": "lib/router", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/server": { + "implicitDependencies": [], "root": "renderers/server", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/server-webpack5": { + "implicitDependencies": [], "root": "frameworks/server-webpack5", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/source-loader": { + "implicitDependencies": [], "root": "lib/source-loader", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/store": { + "implicitDependencies": [], "root": "lib/store", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/svelte": { + "implicitDependencies": [], "root": "renderers/svelte", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/svelte-vite": { + "implicitDependencies": [], "root": "frameworks/svelte-vite", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/svelte-webpack5": { + "implicitDependencies": [], "root": "frameworks/svelte-webpack5", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/telemetry": { + "implicitDependencies": [], "root": "lib/telemetry", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/theming": { + "implicitDependencies": [], "root": "lib/theming", - "type": "library", - "implicitDependencies": [] + "type": "library" + }, + "@storybook/types": { + "implicitDependencies": [], + "root": "lib/channels", + "type": "library" }, "@storybook/ui": { + "implicitDependencies": [], "root": "ui/manager", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/vue": { + "implicitDependencies": [], "root": "renderers/vue", - "type": "library", - "implicitDependencies": [] - }, - "@storybook/vue-webpack5": { - "root": "frameworks/vue-webpack5", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/vue-vite": { + "implicitDependencies": [], "root": "frameworks/vue-vite", - "type": "library", - "implicitDependencies": [] + "type": "library" + }, + "@storybook/vue-webpack5": { + "implicitDependencies": [], + "root": "frameworks/vue-webpack5", + "type": "library" }, "@storybook/vue3": { + "implicitDependencies": [], "root": "renderers/vue3", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/vue3-vite": { + "implicitDependencies": [], "root": "frameworks/vue3-vite", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/vue3-webpack5": { + "implicitDependencies": [], "root": "frameworks/vue3-webpack5", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/web-components": { + "implicitDependencies": [], "root": "renderers/web-components", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/web-components-vite": { + "implicitDependencies": [], "root": "frameworks/web-components-vite", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "@storybook/web-components-webpack5": { + "implicitDependencies": [], "root": "frameworks/web-components-webpack5", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "ember-example": { + "implicitDependencies": [], "root": "examples/ember-cli", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "sb": { + "implicitDependencies": [], "root": "lib/cli-sb", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "server-kitchen-sink": { + "implicitDependencies": [], "root": "examples/server-kitchen-sink", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "standalone-preview": { + "implicitDependencies": [], "root": "examples/standalone-preview", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "storybook": { + "implicitDependencies": [], "root": "lib/cli-storybook", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "svelte-example": { + "implicitDependencies": [], "root": "examples/svelte-kitchen-sink", - "type": "library", - "implicitDependencies": [] + "type": "library" }, "vue-3-cli-example": { + "implicitDependencies": [], "root": "examples/vue-3-cli", - "type": "library", - "implicitDependencies": [] + "type": "library" } } } diff --git a/code/yarn.lock b/code/yarn.lock index ea3ca4724ef2..3b45351f923c 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -6265,8 +6265,8 @@ __metadata: "@storybook/client-logger": 7.0.0-alpha.40 "@storybook/components": 7.0.0-alpha.40 "@storybook/core-events": 7.0.0-alpha.40 - "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/theming": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 "@testing-library/react": ^11.2.2 axe-core: ^4.2.0 global: ^4.4.0 @@ -6293,8 +6293,8 @@ __metadata: "@storybook/client-logger": 7.0.0-alpha.40 "@storybook/components": 7.0.0-alpha.40 "@storybook/core-events": 7.0.0-alpha.40 - "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/theming": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 "@types/lodash": ^4.14.167 dequal: ^2.0.2 global: ^4.4.0 @@ -6327,8 +6327,8 @@ __metadata: "@storybook/client-logger": 7.0.0-alpha.40 "@storybook/components": 7.0.0-alpha.40 "@storybook/core-events": 7.0.0-alpha.40 - "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/theming": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 global: ^4.4.0 memoizerific: ^1.11.3 ts-dedent: ^2.0.0 @@ -6354,10 +6354,10 @@ __metadata: "@storybook/client-logger": 7.0.0-alpha.40 "@storybook/components": 7.0.0-alpha.40 "@storybook/core-common": 7.0.0-alpha.40 - "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/node-logger": 7.0.0-alpha.40 "@storybook/store": 7.0.0-alpha.40 "@storybook/theming": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 lodash: ^4.17.21 ts-dedent: ^2.0.0 peerDependencies: @@ -6385,7 +6385,6 @@ __metadata: "@storybook/components": 7.0.0-alpha.40 "@storybook/core-common": 7.0.0-alpha.40 "@storybook/core-events": 7.0.0-alpha.40 - "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/csf-tools": 7.0.0-alpha.40 "@storybook/docs-tools": 7.0.0-alpha.40 "@storybook/mdx2-csf": 0.1.0-next.0 @@ -6395,6 +6394,7 @@ __metadata: "@storybook/source-loader": 7.0.0-alpha.40 "@storybook/store": 7.0.0-alpha.40 "@storybook/theming": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 dequal: ^2.0.2 fs-extra: ^9.0.1 global: ^4.4.0 @@ -6488,11 +6488,11 @@ __metadata: "@storybook/components": 7.0.0-alpha.40 "@storybook/core-common": 7.0.0-alpha.40 "@storybook/core-events": 7.0.0-alpha.40 - "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/instrumenter": 7.0.0-alpha.40 "@storybook/jest": ^0.0.10 "@storybook/testing-library": 0.0.14-next.0 "@storybook/theming": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 "@types/node": ^16.0.0 formik: ^2.2.9 global: ^4.4.0 @@ -6543,8 +6543,8 @@ __metadata: "@storybook/addons": 7.0.0-alpha.40 "@storybook/client-logger": 7.0.0-alpha.40 "@storybook/core-events": 7.0.0-alpha.40 - "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/router": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 global: ^4.4.0 prop-types: ^15.7.2 ts-dedent: ^2.0.0 @@ -6569,7 +6569,7 @@ __metadata: "@storybook/client-logger": 7.0.0-alpha.40 "@storybook/components": 7.0.0-alpha.40 "@storybook/core-events": 7.0.0-alpha.40 - "@storybook/csf": 0.0.2--canary.49.258942b.0 + "@storybook/types": 7.0.0-alpha.40 global: ^4.4.0 typescript: ~4.6.3 peerDependencies: @@ -6592,7 +6592,7 @@ __metadata: "@storybook/client-logger": 7.0.0-alpha.40 "@storybook/components": 7.0.0-alpha.40 "@storybook/core-events": 7.0.0-alpha.40 - "@storybook/csf": 0.0.2--canary.49.258942b.0 + "@storybook/types": 7.0.0-alpha.40 global: ^4.4.0 ts-dedent: ^2.0.0 typescript: ~4.6.3 @@ -6612,8 +6612,8 @@ __metadata: resolution: "@storybook/addon-storyshots-puppeteer@workspace:addons/storyshots/storyshots-puppeteer" dependencies: "@axe-core/puppeteer": ^4.2.0 - "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/node-logger": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 "@types/jest-image-snapshot": ^4.1.3 "@types/puppeteer": ^5.4.0 jest-image-snapshot: ^4.3.0 @@ -6643,8 +6643,8 @@ __metadata: "@storybook/core-client": 7.0.0-alpha.40 "@storybook/core-common": 7.0.0-alpha.40 "@storybook/core-webpack": 7.0.0-alpha.40 - "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/react": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 "@storybook/vue": 7.0.0-alpha.40 "@storybook/vue3": 7.0.0-alpha.40 "@types/glob": ^7.1.3 @@ -6815,9 +6815,9 @@ __metadata: "@storybook/channels": 7.0.0-alpha.40 "@storybook/client-logger": 7.0.0-alpha.40 "@storybook/core-events": 7.0.0-alpha.40 - "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/router": 7.0.0-alpha.40 "@storybook/theming": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 global: ^4.4.0 peerDependencies: react: ^16.8.0 || ^17.0.0 || ^18.0.0 @@ -6872,10 +6872,10 @@ __metadata: "@storybook/core-events": 7.0.0-alpha.40 "@storybook/core-server": 7.0.0-alpha.40 "@storybook/core-webpack": 7.0.0-alpha.40 - "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/docs-tools": 7.0.0-alpha.40 "@storybook/node-logger": 7.0.0-alpha.40 "@storybook/store": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 "@types/node": ^16.0.0 "@types/react": ^16.14.23 "@types/react-dom": ^16.9.14 @@ -6937,6 +6937,7 @@ __metadata: "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/router": 7.0.0-alpha.40 "@storybook/theming": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 "@types/lodash": ^4.14.167 "@types/qs": ^6 dequal: ^2.0.2 @@ -7003,11 +7004,11 @@ __metadata: "@storybook/client-logger": 7.0.0-alpha.40 "@storybook/components": 7.0.0-alpha.40 "@storybook/core-events": 7.0.0-alpha.40 - "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/docs-tools": 7.0.0-alpha.40 "@storybook/preview-web": 7.0.0-alpha.40 "@storybook/store": 7.0.0-alpha.40 "@storybook/theming": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 "@types/color-convert": ^2.0.0 "@types/lodash": ^4.14.167 color-convert: ^2.0.1 @@ -7237,6 +7238,7 @@ __metadata: "@storybook/core-common": 7.0.0-alpha.40 "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/store": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 "@types/qs": ^6.9.5 "@types/webpack-env": ^1.16.4 global: ^4.4.0 @@ -7278,6 +7280,7 @@ __metadata: "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/csf-tools": 7.0.0-alpha.40 "@storybook/node-logger": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 cross-spawn: ^7.0.3 globby: ^11.0.2 jest: ^26.6.3 @@ -7299,6 +7302,7 @@ __metadata: "@storybook/client-logger": 7.0.0-alpha.40 "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/theming": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 "@types/overlayscrollbars": ^1.12.0 "@types/react-syntax-highlighter": 11.0.5 "@types/util-deprecate": ^1.0.0 @@ -7333,6 +7337,7 @@ __metadata: "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/preview-web": 7.0.0-alpha.40 "@storybook/store": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 "@storybook/ui": 7.0.0-alpha.40 global: ^4.4.0 regenerator-runtime: ^0.13.7 @@ -7349,8 +7354,8 @@ __metadata: resolution: "@storybook/core-common@workspace:lib/core-common" dependencies: "@babel/core": ^7.12.10 - "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/node-logger": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 "@types/babel__core": ^7.0.0 "@types/express": ^4.7.0 "@types/mock-fs": ^4.13.0 @@ -7421,6 +7426,7 @@ __metadata: "@storybook/node-logger": 7.0.0-alpha.40 "@storybook/store": 7.0.0-alpha.40 "@storybook/telemetry": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 "@types/compression": ^1.7.0 "@types/ip": ^1.1.0 "@types/node": ^16.0.0 @@ -7492,6 +7498,7 @@ __metadata: "@babel/traverse": ^7.12.11 "@babel/types": ^7.12.11 "@storybook/csf": 0.0.2--canary.49.258942b.0 + "@storybook/types": 7.0.0-alpha.40 "@types/fs-extra": ^9.0.6 fs-extra: ^9.0.1 js-yaml: ^3.14.1 @@ -7545,8 +7552,8 @@ __metadata: dependencies: "@babel/core": ^7.12.10 "@storybook/core-common": 7.0.0-alpha.40 - "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/store": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 doctrine: ^3.0.0 jest-specific-snapshot: ^4.0.0 lodash: ^4.17.21 @@ -7646,11 +7653,11 @@ __metadata: "@storybook/addon-essentials": 7.0.0-alpha.40 "@storybook/blocks": 7.0.0-alpha.40 "@storybook/components": 7.0.0-alpha.40 - "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/preview-web": 7.0.0-alpha.40 "@storybook/react": 7.0.0-alpha.40 "@storybook/react-webpack5": 7.0.0-alpha.40 "@storybook/theming": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 "@testing-library/dom": ^7.31.2 "@testing-library/user-event": ^13.1.9 "@types/babel__preset-env": ^7 @@ -7696,10 +7703,10 @@ __metadata: dependencies: "@storybook/addons": 7.0.0-alpha.40 "@storybook/core-client": 7.0.0-alpha.40 - "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/docs-tools": 7.0.0-alpha.40 "@storybook/preview-web": 7.0.0-alpha.40 "@storybook/store": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 global: ^4.4.0 react: 16.14.0 react-dom: 16.14.0 @@ -7841,8 +7848,8 @@ __metadata: dependencies: "@storybook/addons": 7.0.0-alpha.40 "@storybook/core-client": 7.0.0-alpha.40 - "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/store": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 global: ^4.4.0 preact: ^10.5.13 react: 16.14.0 @@ -8045,8 +8052,8 @@ __metadata: "@storybook/channels": 7.0.0-alpha.40 "@storybook/client-logger": 7.0.0-alpha.40 "@storybook/core-events": 7.0.0-alpha.40 - "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/store": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 ansi-to-html: ^0.6.11 global: ^4.4.0 lodash: ^4.17.21 @@ -8135,9 +8142,9 @@ __metadata: "@storybook/addons": 7.0.0-alpha.40 "@storybook/client-logger": 7.0.0-alpha.40 "@storybook/core-client": 7.0.0-alpha.40 - "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/docs-tools": 7.0.0-alpha.40 "@storybook/store": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 "@types/estree": ^0.0.51 "@types/node": ^16.0.0 "@types/util-deprecate": ^1.0.0 @@ -8268,6 +8275,7 @@ __metadata: "@storybook/telemetry": "workspace:*" "@storybook/testing-library": 0.0.14-next.0 "@storybook/theming": "workspace:*" + "@storybook/types": "workspace:*" "@storybook/ui": "workspace:*" "@storybook/vue": "workspace:*" "@storybook/vue-webpack5": "workspace:*" @@ -8494,9 +8502,9 @@ __metadata: dependencies: "@storybook/addons": 7.0.0-alpha.40 "@storybook/core-client": 7.0.0-alpha.40 - "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/preview-web": 7.0.0-alpha.40 "@storybook/store": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 global: ^4.4.0 react: 16.14.0 react-dom: 16.14.0 @@ -8510,6 +8518,7 @@ __metadata: resolution: "@storybook/source-loader@workspace:lib/source-loader" dependencies: "@storybook/csf": 0.0.2--canary.49.258942b.0 + "@storybook/types": 7.0.0-alpha.40 estraverse: ^5.2.0 jest-specific-snapshot: ^4.0.0 lodash: ^4.17.21 @@ -8529,6 +8538,7 @@ __metadata: "@storybook/client-logger": 7.0.0-alpha.40 "@storybook/core-events": 7.0.0-alpha.40 "@storybook/csf": 0.0.2--canary.49.258942b.0 + "@storybook/types": 7.0.0-alpha.40 dequal: ^2.0.2 global: ^4.4.0 lodash: ^4.17.21 @@ -8599,9 +8609,9 @@ __metadata: "@storybook/addons": 7.0.0-alpha.40 "@storybook/client-logger": 7.0.0-alpha.40 "@storybook/core-client": 7.0.0-alpha.40 - "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/docs-tools": 7.0.0-alpha.40 "@storybook/store": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 global: ^4.4.0 react: 16.14.0 react-dom: 16.14.0 @@ -8684,7 +8694,7 @@ __metadata: languageName: node linkType: hard -"@storybook/types@workspace:lib/types": +"@storybook/types@7.0.0-alpha.40, @storybook/types@workspace:*, @storybook/types@workspace:lib/types": version: 0.0.0-use.local resolution: "@storybook/types@workspace:lib/types" dependencies: @@ -8706,9 +8716,9 @@ __metadata: "@storybook/client-logger": 7.0.0-alpha.40 "@storybook/components": 7.0.0-alpha.40 "@storybook/core-events": 7.0.0-alpha.40 - "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/router": 7.0.0-alpha.40 "@storybook/theming": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 "@testing-library/react": ^11.2.2 "@types/semver": ^7.3.4 copy-to-clipboard: ^3.3.1 @@ -8834,9 +8844,9 @@ __metadata: "@digitak/esrun": ^3.2.2 "@storybook/addons": 7.0.0-alpha.40 "@storybook/core-client": 7.0.0-alpha.40 - "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/docs-tools": 7.0.0-alpha.40 "@storybook/store": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 global: ^4.4.0 react: 16.14.0 react-dom: 16.14.0 @@ -8860,9 +8870,9 @@ __metadata: "@storybook/addons": 7.0.0-alpha.40 "@storybook/client-logger": 7.0.0-alpha.40 "@storybook/core-client": 7.0.0-alpha.40 - "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/docs-tools": 7.0.0-alpha.40 "@storybook/store": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 global: ^4.4.0 react: 16.14.0 react-dom: 16.14.0 @@ -8928,10 +8938,10 @@ __metadata: "@storybook/api": 7.0.0-alpha.40 "@storybook/client-logger": 7.0.0-alpha.40 "@storybook/core-client": 7.0.0-alpha.40 - "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/docs-tools": 7.0.0-alpha.40 "@storybook/preview-web": 7.0.0-alpha.40 "@storybook/store": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 global: ^4.4.0 lit: 2.3.1 lit-html: 2.0.2 diff --git a/scripts/verdaccio.yaml b/scripts/verdaccio.yaml index 92011f313490..2177322c9024 100644 --- a/scripts/verdaccio.yaml +++ b/scripts/verdaccio.yaml @@ -27,7 +27,7 @@ packages: proxy: npmjs # storybook's packages not hosted in this monorepo - '@storybook/csf': + '@storybook/types': access: $all publish: $all proxy: npmjs From 5f1551727b2488484709e81c8260e32598d09a4e Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 21 Oct 2022 22:04:42 +0200 Subject: [PATCH 04/38] step 1 --- code/addons/a11y/src/manager.tsx | 2 +- .../addons/actions/src/addArgsHelpers.test.ts | 2 +- code/addons/actions/src/manager.tsx | 2 +- code/addons/backgrounds/src/manager.tsx | 2 +- code/addons/controls/src/manager.tsx | 2 +- code/addons/interactions/src/manager.tsx | 2 +- code/addons/jest/src/shared.ts | 2 +- code/addons/measure/src/manager.tsx | 2 +- code/addons/outline/src/manager.tsx | 2 +- .../storyshots-core/src/frameworks/Loader.ts | 10 +- code/addons/toolbars/src/manager.tsx | 2 +- code/addons/viewport/src/manager.tsx | 2 +- .../angular/src/client/decorateStory.test.ts | 2 +- .../angular/src/client/public-api.ts | 8 +- code/lib/addons/src/index.ts | 1 - code/lib/addons/src/main.ts | 75 ++-- code/lib/addons/src/make-decorator.ts | 32 +- code/lib/addons/src/types.ts | 328 ---------------- .../lib/blocks/src/blocks/SourceContainer.tsx | 2 +- code/lib/client-api/src/ClientApi.ts | 10 +- code/lib/client-api/src/StoryStoreFacade.ts | 7 +- code/lib/client-api/src/types.ts | 17 +- code/lib/core-client/package.json | 1 + code/lib/core-client/src/manager/provider.ts | 8 +- .../src/utils/StoryIndexGenerator.ts | 33 +- code/lib/instrumenter/package.json | 1 + code/lib/instrumenter/src/instrumenter.ts | 5 +- code/lib/instrumenter/src/types.ts | 2 +- code/lib/preview-web/src/Preview.tsx | 7 +- code/lib/preview-web/src/UrlStore.ts | 2 +- code/lib/preview-web/src/parseArgsParam.ts | 2 +- .../src/render/StandaloneDocsRender.ts | 7 +- .../lib/preview-web/src/render/StoryRender.ts | 10 +- .../src/render/TemplateDocsRender.ts | 8 +- code/lib/store/src/StoryIndexStore.ts | 11 +- code/lib/store/src/StoryStore.ts | 5 +- code/lib/store/src/parameters.ts | 2 +- code/lib/store/src/sortStories.ts | 42 ++- code/lib/store/src/storySort.ts | 12 +- code/lib/store/src/types.ts | 27 +- code/lib/types/src/index.ts | 115 +----- code/lib/types/src/modules/addons.ts | 351 ++++++++++++++++++ code/lib/types/src/modules/csf.ts | 113 ++++++ code/renderers/html/src/public-api.ts | 8 +- code/renderers/preact/src/public-api.ts | 8 +- code/renderers/react/src/public-api.tsx | 8 +- code/renderers/server/src/public-api.ts | 7 +- code/renderers/vue/src/public-api.ts | 8 +- code/renderers/vue3/src/public-api.ts | 7 +- .../web-components/src/public-api.ts | 8 +- .../src/components/layout/app.mockdata.tsx | 5 +- code/ui/manager/src/globals/exports.ts | 1 - code/ui/manager/src/runtime.ts | 8 +- .../my-addon-initial-panel-state.js.mdx | 2 +- .../storybook-addon-panel-example.js.mdx | 2 +- .../storybook-addon-panel-initial.js.mdx | 2 +- .../common/storybook-addon-tab-example.js.mdx | 2 +- .../storybook-addon-toolbar-example.js.mdx | 2 +- 58 files changed, 695 insertions(+), 661 deletions(-) delete mode 100644 code/lib/addons/src/types.ts create mode 100644 code/lib/types/src/modules/addons.ts create mode 100644 code/lib/types/src/modules/csf.ts diff --git a/code/addons/a11y/src/manager.tsx b/code/addons/a11y/src/manager.tsx index ce24d1c9cafd..455ee88ccdfb 100644 --- a/code/addons/a11y/src/manager.tsx +++ b/code/addons/a11y/src/manager.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { addons, types } from '@storybook/addons'; +import { addons, type types } from '@storybook/addons'; import { ADDON_ID, PANEL_ID, PARAM_KEY } from './constants'; import { VisionSimulator } from './components/VisionSimulator'; import { A11YPanel } from './components/A11YPanel'; diff --git a/code/addons/actions/src/addArgsHelpers.test.ts b/code/addons/actions/src/addArgsHelpers.test.ts index 487dab330305..46318534b132 100644 --- a/code/addons/actions/src/addArgsHelpers.test.ts +++ b/code/addons/actions/src/addArgsHelpers.test.ts @@ -1,4 +1,4 @@ -import type { StoryContext } from '@storybook/addons'; +import type { StoryContext } from '@storybook/types'; import { inferActionsFromArgTypesRegex, addActionsFromArgTypes } from './addArgsHelpers'; describe('actions parameter enhancers', () => { diff --git a/code/addons/actions/src/manager.tsx b/code/addons/actions/src/manager.tsx index bd024620ac5e..8aa8d33c3353 100644 --- a/code/addons/actions/src/manager.tsx +++ b/code/addons/actions/src/manager.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect } from 'react'; -import { addons, types } from '@storybook/addons'; +import { addons, type types } from '@storybook/addons'; import { STORY_CHANGED } from '@storybook/core-events'; import ActionLogger from './containers/ActionLogger'; import { ADDON_ID, EVENT_ID, PANEL_ID, PARAM_KEY } from './constants'; diff --git a/code/addons/backgrounds/src/manager.tsx b/code/addons/backgrounds/src/manager.tsx index d3b8d095ec97..fd494dc6a282 100644 --- a/code/addons/backgrounds/src/manager.tsx +++ b/code/addons/backgrounds/src/manager.tsx @@ -1,5 +1,5 @@ import React, { Fragment } from 'react'; -import { addons, types } from '@storybook/addons'; +import { addons, type types } from '@storybook/addons'; import { ADDON_ID } from './constants'; import { BackgroundSelector } from './containers/BackgroundSelector'; diff --git a/code/addons/controls/src/manager.tsx b/code/addons/controls/src/manager.tsx index eb34e690b656..f7aaa6125978 100644 --- a/code/addons/controls/src/manager.tsx +++ b/code/addons/controls/src/manager.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { addons, types } from '@storybook/addons'; +import { addons, type types } from '@storybook/addons'; import { AddonPanel } from '@storybook/components'; import { API, useArgTypes } from '@storybook/api'; import { ControlsPanel } from './ControlsPanel'; diff --git a/code/addons/interactions/src/manager.tsx b/code/addons/interactions/src/manager.tsx index 454945d6c44a..8a63871ab569 100644 --- a/code/addons/interactions/src/manager.tsx +++ b/code/addons/interactions/src/manager.tsx @@ -1,4 +1,4 @@ -import { addons, types } from '@storybook/addons'; +import { addons, type types } from '@storybook/addons'; import { ADDON_ID, PANEL_ID } from './constants'; import { Panel } from './Panel'; diff --git a/code/addons/jest/src/shared.ts b/code/addons/jest/src/shared.ts index 1fdda0b4a243..9b761e1d9dec 100644 --- a/code/addons/jest/src/shared.ts +++ b/code/addons/jest/src/shared.ts @@ -1,4 +1,4 @@ -import type { Parameters } from '@storybook/addons'; +import type { Parameters } from '@storybook/types'; // addons, panels and events get unique names using a prefix export const PARAM_KEY = 'test'; diff --git a/code/addons/measure/src/manager.tsx b/code/addons/measure/src/manager.tsx index 162e7ce43ecd..054279073967 100644 --- a/code/addons/measure/src/manager.tsx +++ b/code/addons/measure/src/manager.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { addons, types } from '@storybook/addons'; +import { addons, type types } from '@storybook/addons'; import { ADDON_ID, TOOL_ID } from './constants'; import { Tool } from './Tool'; diff --git a/code/addons/outline/src/manager.tsx b/code/addons/outline/src/manager.tsx index 3f3f96ae3b06..5837ed744d06 100644 --- a/code/addons/outline/src/manager.tsx +++ b/code/addons/outline/src/manager.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { addons, types } from '@storybook/addons'; +import { addons, type types } from '@storybook/addons'; import { ADDON_ID } from './constants'; import { OutlineSelector } from './OutlineSelector'; diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/Loader.ts b/code/addons/storyshots/storyshots-core/src/frameworks/Loader.ts index 3ce703fc4553..0f77fea0ce3b 100644 --- a/code/addons/storyshots/storyshots-core/src/frameworks/Loader.ts +++ b/code/addons/storyshots/storyshots-core/src/frameworks/Loader.ts @@ -1,5 +1,5 @@ -import type { AnyFramework } from '@storybook/types'; -import type { Loadable } from '@storybook/addons'; +/* eslint-disable camelcase */ +import type { AnyFramework, Addon_Loadable } from '@storybook/types'; import { ClientApi as ClientApiClass } from '@storybook/client-api'; import type { StoryshotsOptions } from '../api/StoryshotsOptions'; import type { SupportedFramework } from './SupportedFramework'; @@ -7,7 +7,11 @@ import type { SupportedFramework } from './SupportedFramework'; export type RenderTree = (story: any, context?: any, options?: any) => any; export interface ClientApi extends ClientApiClass { - configure(loader: Loadable, module: NodeModule | false, showDeprecationWarning?: boolean): void; + configure( + loader: Addon_Loadable, + module: NodeModule | false, + showDeprecationWarning?: boolean + ): void; forceReRender(): void; } diff --git a/code/addons/toolbars/src/manager.tsx b/code/addons/toolbars/src/manager.tsx index c6681e989354..bc1fbe98c038 100644 --- a/code/addons/toolbars/src/manager.tsx +++ b/code/addons/toolbars/src/manager.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { addons, types } from '@storybook/addons'; +import { addons, type types } from '@storybook/addons'; import { ToolbarManager } from './components/ToolbarManager'; import { ADDON_ID } from './constants'; diff --git a/code/addons/viewport/src/manager.tsx b/code/addons/viewport/src/manager.tsx index 81b1b17e588c..abf47da815d2 100644 --- a/code/addons/viewport/src/manager.tsx +++ b/code/addons/viewport/src/manager.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { addons, types } from '@storybook/addons'; +import { addons, type types } from '@storybook/addons'; import { ADDON_ID } from './constants'; diff --git a/code/frameworks/angular/src/client/decorateStory.test.ts b/code/frameworks/angular/src/client/decorateStory.test.ts index 69243b14a74f..55467d9053f3 100644 --- a/code/frameworks/angular/src/client/decorateStory.test.ts +++ b/code/frameworks/angular/src/client/decorateStory.test.ts @@ -1,5 +1,5 @@ import { Component, Input, Output } from '@angular/core'; -import type { DecoratorFunction, StoryContext } from '@storybook/addons'; +import type { DecoratorFunction, StoryContext } from '@storybook/types'; import { componentWrapperDecorator } from './decorators'; import decorateStory from './decorateStory'; diff --git a/code/frameworks/angular/src/client/public-api.ts b/code/frameworks/angular/src/client/public-api.ts index 98b614df58ab..e265aa6825cd 100644 --- a/code/frameworks/angular/src/client/public-api.ts +++ b/code/frameworks/angular/src/client/public-api.ts @@ -1,5 +1,5 @@ -/* eslint-disable prefer-destructuring */ -import type { ClientStoryApi, Loadable } from '@storybook/addons'; +/* eslint-disable camelcase, prefer-destructuring */ +import type { Addon_ClientStoryApi, Addon_Loadable } from '@storybook/types'; import { start } from '@storybook/core-client'; import { renderToDOM, render } from './render'; import decorateStory from './decorateStory'; @@ -9,8 +9,8 @@ export * from './public-types'; const FRAMEWORK = 'angular'; -interface ClientApi extends ClientStoryApi { - configure(loader: Loadable, module: NodeModule): void; +interface ClientApi extends Addon_ClientStoryApi { + configure(loader: Addon_Loadable, module: NodeModule): void; forceReRender(): void; raw: () => any; // todo add type load: (...args: any[]) => void; diff --git a/code/lib/addons/src/index.ts b/code/lib/addons/src/index.ts index 4315865de896..3bc9cc612583 100644 --- a/code/lib/addons/src/index.ts +++ b/code/lib/addons/src/index.ts @@ -9,7 +9,6 @@ import { addons } from './main'; export * from './make-decorator'; export * from './main'; -export * from './types'; export * from './storybook-channel-mock'; export * from './hooks'; diff --git a/code/lib/addons/src/main.ts b/code/lib/addons/src/main.ts index ac37b2f2e060..85742cbe027d 100644 --- a/code/lib/addons/src/main.ts +++ b/code/lib/addons/src/main.ts @@ -1,56 +1,37 @@ +/* eslint-disable camelcase */ import global from 'global'; -import type { ReactElement } from 'react'; import { Channel } from '@storybook/channels'; import { SET_CONFIG } from '@storybook/core-events'; import type { API } from '@storybook/api'; -import type { RenderData as RouterData } from '@storybook/router'; +import type { + Addon_Collection, + Addon_Config, + Addon_Elements, + Addon_Loaders, + Addon_Type, + Addon_Types, +} from '@storybook/types'; import { logger } from '@storybook/client-logger'; -import type { ThemeVars } from '@storybook/theming'; import { mockChannel } from './storybook-channel-mock'; -import { types, Types } from './types'; -export { Channel }; - -export interface RenderOptions { - active?: boolean; - key?: string; -} - -export interface Addon { - title: (() => string) | string; - type?: Types; - id?: string; - route?: (routeOptions: RouterData) => string; - match?: (matchOptions: RouterData) => boolean; - render: (renderOptions: RenderOptions) => ReactElement | null; - paramKey?: string; - disabled?: boolean; - hidden?: boolean; +export enum types { + TAB = 'tab', + PANEL = 'panel', + TOOL = 'tool', + TOOLEXTRA = 'toolextra', + PREVIEW = 'preview', + NOTES_ELEMENT = 'notes-element', } -export type Loader = (api: API) => void; +export { Addon_Type as Addon }; -interface Loaders { - [key: string]: Loader; -} -export interface Collection { - [key: string]: Addon; -} -interface Elements { - [key: string]: Collection; -} -interface ToolbarConfig { - hidden?: boolean; -} -export interface Config { - theme?: ThemeVars; - toolbar?: { - [id: string]: ToolbarConfig; - }; - [key: string]: any; +export function isSupportedType(type: Addon_Types): boolean { + return !!Object.values(types).find((typeVal) => typeVal === type); } +export type Types = types | string; + export class AddonStore { constructor() { this.promise = new Promise((res) => { @@ -58,11 +39,11 @@ export class AddonStore { }) as Promise; } - private loaders: Loaders = {}; + private loaders: Addon_Loaders = {}; - private elements: Elements = {}; + private elements: Addon_Elements = {}; - private config: Config = {}; + private config: Addon_Config = {}; private channel: Channel | undefined; @@ -104,27 +85,27 @@ export class AddonStore { this.serverChannel = channel; }; - getElements = (type: Types): Collection => { + getElements = (type: Types): Addon_Collection => { if (!this.elements[type]) { this.elements[type] = {}; } return this.elements[type]; }; - addPanel = (name: string, options: Addon): void => { + addPanel = (name: string, options: Addon_Type): void => { this.add(name, { type: types.PANEL, ...options, }); }; - add = (name: string, addon: Addon) => { + add = (name: string, addon: Addon_Type) => { const { type } = addon; const collection = this.getElements(type); collection[name] = { id: name, ...addon }; }; - setConfig = (value: Config) => { + setConfig = (value: Addon_Config) => { Object.assign(this.config, value); if (this.hasChannel()) { this.getChannel().emit(SET_CONFIG, value); diff --git a/code/lib/addons/src/make-decorator.ts b/code/lib/addons/src/make-decorator.ts index 683bc59b1fdb..c5d7fa0b9d0c 100644 --- a/code/lib/addons/src/make-decorator.ts +++ b/code/lib/addons/src/make-decorator.ts @@ -1,4 +1,5 @@ -import { StoryWrapper, LegacyStoryFn, StoryContext } from './types'; +/* eslint-disable camelcase */ +import type { Addon_StoryWrapper, Addon_LegacyStoryFn, Addon_StoryContext } from '@storybook/types'; type MakeDecoratorResult = (...args: any) => any; @@ -6,7 +7,7 @@ interface MakeDecoratorOptions { name: string; parameterName: string; skipIfNoParametersOrOptions?: boolean; - wrapper: StoryWrapper; + wrapper: Addon_StoryWrapper; } export const makeDecorator = ({ @@ -15,22 +16,23 @@ export const makeDecorator = ({ wrapper, skipIfNoParametersOrOptions = false, }: MakeDecoratorOptions): MakeDecoratorResult => { - const decorator: any = (options: object) => (storyFn: LegacyStoryFn, context: StoryContext) => { - const parameters = context.parameters && context.parameters[parameterName]; + const decorator: any = + (options: object) => (storyFn: Addon_LegacyStoryFn, context: Addon_StoryContext) => { + const parameters = context.parameters && context.parameters[parameterName]; - if (parameters && parameters.disable) { - return storyFn(context); - } + if (parameters && parameters.disable) { + return storyFn(context); + } - if (skipIfNoParametersOrOptions && !options && !parameters) { - return storyFn(context); - } + if (skipIfNoParametersOrOptions && !options && !parameters) { + return storyFn(context); + } - return wrapper(storyFn, context, { - options, - parameters, - }); - }; + return wrapper(storyFn, context, { + options, + parameters, + }); + }; return (...args: any) => { // Used without options as .addDecorator(decorator) diff --git a/code/lib/addons/src/types.ts b/code/lib/addons/src/types.ts deleted file mode 100644 index cdf9aee897cd..000000000000 --- a/code/lib/addons/src/types.ts +++ /dev/null @@ -1,328 +0,0 @@ -import type { - AnyFramework, - InputType, - StoryContext as StoryContextForFramework, - LegacyStoryFn as LegacyStoryFnForFramework, - PartialStoryFn as PartialStoryFnForFramework, - ArgsStoryFn as ArgsStoryFnForFramework, - StoryFn as StoryFnForFramework, - DecoratorFunction as DecoratorFunctionForFramework, - LoaderFunction as LoaderFunctionForFramework, - StoryId, - StoryKind, - StoryName, - Args, - ComponentTitle, -} from '@storybook/types'; - -import { Addon } from './index'; - -// NOTE: The types exported from this file are simplified versions of the types exported -// by @storybook/csf, with the simpler form retained for backwards compatibility. -// We will likely start exporting the more complex based types in 7.0 - -export type { - StoryId, - StoryKind, - StoryName, - StoryIdentifier, - ViewMode, - Args, -} from '@storybook/types'; - -export interface ArgType extends InputType { - defaultValue?: TArg; -} - -export type ArgTypes = { - [key in keyof Partial]: ArgType; -} & { - // for custom defined args - [key in string]: ArgType; -}; - -export type Comparator = ((a: T, b: T) => boolean) | ((a: T, b: T) => number); -export type StorySortMethod = 'configure' | 'alphabetical'; -export interface StorySortObjectParameter { - method?: StorySortMethod; - order?: any[]; - locales?: string; - includeNames?: boolean; -} - -type Path = string; -interface BaseIndexEntry { - id: StoryId; - name: StoryName; - title: ComponentTitle; - importPath: Path; -} -export type StoryIndexEntry = BaseIndexEntry & { - type: 'story'; -}; - -export type DocsIndexEntry = BaseIndexEntry & { - storiesImports: Path[]; - type: 'docs'; - standalone: boolean; -}; - -/** A StandaloneDocsIndexExtry represents a file who's default export is directly renderable */ -export type StandaloneDocsIndexEntry = DocsIndexEntry & { standalone: true }; -/** A TemplateDocsIndexEntry represents a stories file that gets rendered in "docs" mode */ -export type TemplateDocsIndexEntry = DocsIndexEntry & { standalone: false }; - -export type IndexEntry = StoryIndexEntry | DocsIndexEntry; - -// The `any` here is the story store's `StoreItem` record. Ideally we should probably only -// pass a defined subset of that full data, but we pass it all so far :shrug: -export type IndexEntryLegacy = [StoryId, any, Parameters, Parameters]; -export type StorySortComparator = Comparator; -export type StorySortParameter = StorySortComparator | StorySortObjectParameter; -export type StorySortComparatorV7 = Comparator; -export type StorySortParameterV7 = StorySortComparatorV7 | StorySortObjectParameter; - -// TODO: remove all these types, they belong in the renderer and csf-package - -export interface OptionsParameter extends Object { - storySort?: StorySortParameter; - theme?: { - base: string; - brandTitle?: string; - }; - [key: string]: any; -} - -export interface Parameters { - fileName?: string; - options?: OptionsParameter; - /** The layout property defines basic styles added to the preview body where the story is rendered. If you pass 'none', no styles are applied. */ - layout?: 'centered' | 'fullscreen' | 'padded' | 'none'; - docsOnly?: boolean; - [key: string]: any; -} - -export type StoryContext = - StoryContextForFramework; -export type StoryContextUpdate = Partial; - -type ReturnTypeFramework = { component: any; storyResult: ReturnType }; -export type PartialStoryFn = PartialStoryFnForFramework< - ReturnTypeFramework ->; -export type LegacyStoryFn = LegacyStoryFnForFramework< - ReturnTypeFramework ->; -export type ArgsStoryFn = ArgsStoryFnForFramework< - ReturnTypeFramework ->; -export type StoryFn = StoryFnForFramework>; - -export type DecoratorFunction = DecoratorFunctionForFramework< - ReturnTypeFramework ->; -export type LoaderFunction = LoaderFunctionForFramework>; - -export enum types { - TAB = 'tab', - PANEL = 'panel', - TOOL = 'tool', - TOOLEXTRA = 'toolextra', - PREVIEW = 'preview', - NOTES_ELEMENT = 'notes-element', -} - -export type Types = types | string; - -export function isSupportedType(type: Types): boolean { - return !!Object.values(types).find((typeVal) => typeVal === type); -} - -export interface WrapperSettings { - options: object; - parameters: { - [key: string]: any; - }; -} - -export type StoryWrapper = ( - storyFn: LegacyStoryFn, - context: StoryContext, - settings: WrapperSettings -) => any; - -export type MakeDecoratorResult = (...args: any) => any; - -export interface AddStoryArgs { - id: StoryId; - kind: StoryKind; - name: StoryName; - storyFn: StoryFn; - parameters: Parameters; -} - -export interface ClientApiAddon extends Addon { - apply: (a: StoryApi, b: any[]) => any; -} -export interface ClientApiAddons { - [key: string]: ClientApiAddon; -} - -export type ClientApiReturnFn = ( - ...args: any[] -) => StoryApi; - -export interface StoryApi { - kind: StoryKind; - add: ( - storyName: StoryName, - storyFn: StoryFn, - parameters?: Parameters - ) => StoryApi; - addDecorator: (decorator: DecoratorFunction) => StoryApi; - addLoader: (decorator: LoaderFunction) => StoryApi; - addParameters: (parameters: Parameters) => StoryApi; - [k: string]: string | ClientApiReturnFn; -} - -export interface ClientStoryApi { - storiesOf(kind: StoryKind, module: any): StoryApi; -} - -type LoadFn = () => any; -type RequireContext = any; // FIXME -export type Loadable = RequireContext | [RequireContext] | LoadFn; - -// CSF types, to be re-org'ed in 6.1 - -export type BaseDecorators = Array< - (story: () => StoryFnReturnType, context: StoryContext) => StoryFnReturnType ->; - -export interface BaseAnnotations { - /** - * Dynamic data that are provided (and possibly updated by) Storybook and its addons. - * @see [Arg story inputs](https://storybook.js.org/docs/react/api/csf#args-story-inputs) - */ - args?: Partial; - - /** - * ArgTypes encode basic metadata for args, such as `name`, `description`, `defaultValue` for an arg. These get automatically filled in by Storybook Docs. - * @see [Control annotations](https://github.com/storybookjs/storybook/blob/91e9dee33faa8eff0b342a366845de7100415367/addons/controls/README.md#control-annotations) - */ - argTypes?: ArgTypes; - - /** - * Custom metadata for a story. - * @see [Parameters](https://storybook.js.org/docs/basics/writing-stories/#parameters) - */ - parameters?: Parameters; - - /** - * Wrapper components or Storybook decorators that wrap a story. - * - * Decorators defined in Meta will be applied to every story variation. - * @see [Decorators](https://storybook.js.org/docs/addons/introduction/#1-decorators) - */ - decorators?: BaseDecorators; - - /** - * Define a custom render function for the story(ies). If not passed, a default render function by the framework will be used. - */ - render?: (args: Args, context: StoryContext) => StoryFnReturnType; - - /** - * Function that is executed after the story is rendered. - */ - play?: (context: StoryContext) => Promise | void; -} - -export interface Annotations - extends BaseAnnotations { - /** - * Used to only include certain named exports as stories. Useful when you want to have non-story exports such as mock data or ignore a few stories. - * @example - * includeStories: ['SimpleStory', 'ComplexStory'] - * includeStories: /.*Story$/ - * - * @see [Non-story exports](https://storybook.js.org/docs/formats/component-story-format/#non-story-exports) - */ - includeStories?: string[] | RegExp; - - /** - * Used to exclude certain named exports. Useful when you want to have non-story exports such as mock data or ignore a few stories. - * @example - * excludeStories: ['simpleData', 'complexData'] - * excludeStories: /.*Data$/ - * - * @see [Non-story exports](https://storybook.js.org/docs/formats/component-story-format/#non-story-exports) - */ - excludeStories?: string[] | RegExp; -} - -export interface BaseMeta { - /** - * Title of the story which will be presented in the navigation. **Should be unique.** - * - * Stories can be organized in a nested structure using "/" as a separator. - * - * Since CSF 3.0 this property is optional. - * - * @example - * export default { - * ... - * title: 'Design System/Atoms/Button' - * } - * - * @see [Story Hierarchy](https://storybook.js.org/docs/basics/writing-stories/#story-hierarchy) - */ - title?: string; - - /** - * Manually set the id of a story, which in particular is useful if you want to rename stories without breaking permalinks. - * - * Storybook will prioritize the id over the title for ID generation, if provided, and will prioritize the story.storyName over the export key for display. - * - * @see [Sidebar and URLs](https://storybook.js.org/docs/react/configure/sidebar-and-urls#permalinking-to-stories) - */ - id?: string; - - /** - * The primary component for your story. - * - * Used by addons for automatic prop table generation and display of other component metadata. - */ - component?: ComponentType; - - /** - * Auxiliary subcomponents that are part of the stories. - * - * Used by addons for automatic prop table generation and display of other component metadata. - * - * @example - * import { Button, ButtonGroup } from './components'; - * - * export default { - * ... - * subcomponents: { Button, ButtonGroup } - * } - * - * By defining them each component will have its tab in the args table. - */ - subcomponents?: Record; -} - -export type BaseStoryObject = { - /** - * Override the display name in the UI - */ - storyName?: string; -}; - -export type BaseStoryFn = { - (args: Args, context: StoryContext): StoryFnReturnType; -} & BaseStoryObject; - -export type BaseStory = - | BaseStoryFn - | BaseStoryObject; diff --git a/code/lib/blocks/src/blocks/SourceContainer.tsx b/code/lib/blocks/src/blocks/SourceContainer.tsx index 09634240b0af..6c3ebc77b5d1 100644 --- a/code/lib/blocks/src/blocks/SourceContainer.tsx +++ b/code/lib/blocks/src/blocks/SourceContainer.tsx @@ -1,7 +1,7 @@ import React, { FC, Context, createContext, useEffect, useState } from 'react'; import { dequal as deepEqual } from 'dequal'; -import type { Channel } from '@storybook/addons'; +import type { Channel } from '@storybook/channels'; import { SNIPPET_RENDERED } from '@storybook/docs-tools'; import type { SyntaxHighlighterFormatTypes } from '@storybook/components'; diff --git a/code/lib/client-api/src/ClientApi.ts b/code/lib/client-api/src/ClientApi.ts index 1938fbd82807..162befde882a 100644 --- a/code/lib/client-api/src/ClientApi.ts +++ b/code/lib/client-api/src/ClientApi.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ /// import { dedent } from 'ts-dedent'; @@ -18,6 +19,8 @@ import type { Globals, GlobalTypes, LegacyStoryFn, + Addon_ClientApiAddons, + Addon_StoryApi, } from '@storybook/types'; import { combineParameters, @@ -26,7 +29,6 @@ import { normalizeInputTypes, } from '@storybook/store'; import type { NormalizedComponentAnnotations, Path, ModuleImportFn } from '@storybook/store'; -import type { ClientApiAddons, StoryApi } from '@storybook/addons'; import { StoryStoreFacade } from './StoryStoreFacade'; @@ -128,7 +130,7 @@ export class ClientApi { storyStore?: StoryStore; - private addons: ClientApiAddons; + private addons: Addon_ClientApiAddons; onImportFnChanged?: ({ importFn }: { importFn: ModuleImportFn }) => void; @@ -218,7 +220,7 @@ export class ClientApi { }; // what are the occasions that "m" is a boolean vs an obj - storiesOf = (kind: string, m?: NodeModule): StoryApi => { + storiesOf = (kind: string, m?: NodeModule): Addon_StoryApi => { if (!kind && typeof kind !== 'string') { throw new Error('Invalid or missing kind provided for stories, should be a string'); } @@ -273,7 +275,7 @@ export class ClientApi { } let hasAdded = false; - const api: StoryApi = { + const api: Addon_StoryApi = { kind: kind.toString(), add: () => api, addDecorator: () => api, diff --git a/code/lib/client-api/src/StoryStoreFacade.ts b/code/lib/client-api/src/StoryStoreFacade.ts index b658ec837b73..e7d518478534 100644 --- a/code/lib/client-api/src/StoryStoreFacade.ts +++ b/code/lib/client-api/src/StoryStoreFacade.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ /* eslint-disable no-underscore-dangle */ import global from 'global'; import { dedent } from 'ts-dedent'; @@ -10,6 +11,7 @@ import type { AnyFramework, Parameters, StoryFn, + Addon_IndexEntry, } from '@storybook/types'; import { StoryStore, userOrAutoTitle, sortStoriesV6 } from '@storybook/store'; import type { @@ -19,7 +21,6 @@ import type { StoryIndex, ModuleExports, Story, - IndexEntry, } from '@storybook/store'; import { logger } from '@storybook/client-logger'; import type { DocsOptions } from '@storybook/core-common'; @@ -38,7 +39,7 @@ export interface GetStorybookKind { export class StoryStoreFacade { projectAnnotations: NormalizedProjectAnnotations; - entries: Record; + entries: Record; csfExports: Record; @@ -100,7 +101,7 @@ export class StoryStoreFacade { ); // NOTE: the sortStoriesV6 version returns the v7 data format. confusing but more convenient! - let sortedV7: IndexEntry[]; + let sortedV7: Addon_IndexEntry[]; try { sortedV7 = sortStoriesV6(sortableV6, storySortParameter, fileNameOrder); diff --git a/code/lib/client-api/src/types.ts b/code/lib/client-api/src/types.ts index 7d71a8cf45fa..60ace3cafe9c 100644 --- a/code/lib/client-api/src/types.ts +++ b/code/lib/client-api/src/types.ts @@ -1,5 +1,7 @@ +/* eslint-disable camelcase */ +import type { Addon } from '@storybook/addons'; + import type { - Addon, StoryId, StoryName, StoryKind, @@ -8,11 +10,12 @@ import type { Parameters, Args, ArgTypes, - StoryApi, + Addon_StoryApi, DecoratorFunction, LoaderFunction, StoryContext, -} from '@storybook/addons'; +} from '@storybook/types'; + import { AnyFramework, StoryIdentifier, ProjectAnnotations } from '@storybook/types'; import type { RenderContext } from '@storybook/store'; import { StoryStore, HooksContext } from '@storybook/store'; @@ -95,12 +98,12 @@ export interface ClientApiParams { noStoryModuleAddMethodHotDispose?: boolean; } -export type ClientApiReturnFn = (...args: any[]) => StoryApi; - -export type { StoryApi, DecoratorFunction }; +export type ClientApiReturnFn = ( + ...args: any[] +) => Addon_StoryApi; export interface ClientApiAddon extends Addon { - apply: (a: StoryApi, b: any[]) => any; + apply: (a: Addon_StoryApi, b: any[]) => any; } export interface ClientApiAddons { diff --git a/code/lib/core-client/package.json b/code/lib/core-client/package.json index ec165f6e7b64..e485c9bb50b7 100644 --- a/code/lib/core-client/package.json +++ b/code/lib/core-client/package.json @@ -38,6 +38,7 @@ "@storybook/addons": "7.0.0-alpha.40", "@storybook/channel-postmessage": "7.0.0-alpha.40", "@storybook/channel-websocket": "7.0.0-alpha.40", + "@storybook/channels": "7.0.0-alpha.40", "@storybook/client-api": "7.0.0-alpha.40", "@storybook/client-logger": "7.0.0-alpha.40", "@storybook/core-events": "7.0.0-alpha.40", diff --git a/code/lib/core-client/src/manager/provider.ts b/code/lib/core-client/src/manager/provider.ts index 22cfa410d51b..a34d94dd8772 100644 --- a/code/lib/core-client/src/manager/provider.ts +++ b/code/lib/core-client/src/manager/provider.ts @@ -1,7 +1,9 @@ +/* eslint-disable camelcase */ import global from 'global'; import { Provider } from '@storybook/ui'; -import { addons, AddonStore, Channel } from '@storybook/addons'; -import type { Config, Types } from '@storybook/addons'; +import { Channel } from '@storybook/channels'; +import { addons, AddonStore, type Types } from '@storybook/addons'; +import type { Addon_Config } from '@storybook/types'; import * as postMessage from '@storybook/channel-postmessage'; import * as webSocket from '@storybook/channel-websocket'; import Events from '@storybook/core-events'; @@ -37,7 +39,7 @@ export default class ReactProvider extends Provider { return this.addons.getElements(type); } - getConfig(): Config { + getConfig(): Addon_Config { return this.addons.getConfig(); } diff --git a/code/lib/core-server/src/utils/StoryIndexGenerator.ts b/code/lib/core-server/src/utils/StoryIndexGenerator.ts index aab41e2445f6..407f19bca308 100644 --- a/code/lib/core-server/src/utils/StoryIndexGenerator.ts +++ b/code/lib/core-server/src/utils/StoryIndexGenerator.ts @@ -1,31 +1,30 @@ +/* eslint-disable camelcase */ import path from 'path'; import fs from 'fs-extra'; import glob from 'globby'; import slash from 'slash'; +import type { Path, StoryIndex, V2CompatIndexEntry, StoryId } from '@storybook/store'; import type { - Path, - StoryIndex, - V2CompatIndexEntry, - StoryId, - IndexEntry, - StoryIndexEntry, - StandaloneDocsIndexEntry, - TemplateDocsIndexEntry, -} from '@storybook/store'; + Addon_IndexEntry, + Addon_StoryIndexEntry, + Addon_StandaloneDocsIndexEntry, + Addon_TemplateDocsIndexEntry, + ComponentTitle, + StoryName, +} from '@storybook/types'; import { userOrAutoTitleFromSpecifier, sortStoriesV7 } from '@storybook/store'; import type { StoryIndexer, NormalizedStoriesSpecifier, DocsOptions } from '@storybook/core-common'; import { normalizeStoryPath } from '@storybook/core-common'; import { logger } from '@storybook/node-logger'; import { getStorySortParameter, NoMetaError } from '@storybook/csf-tools'; -import type { ComponentTitle, StoryName } from '@storybook/types'; import { toId } from '@storybook/csf'; /** A .mdx file will produce a "standalone" docs entry */ -type DocsCacheEntry = StandaloneDocsIndexEntry; +type DocsCacheEntry = Addon_StandaloneDocsIndexEntry; /** A *.stories.* file will produce a list of stories and possibly a docs entry */ type StoriesCacheEntry = { - entries: (StoryIndexEntry | TemplateDocsIndexEntry)[]; + entries: (Addon_StoryIndexEntry | Addon_TemplateDocsIndexEntry)[]; dependents: Path[]; type: 'stories'; }; @@ -141,7 +140,7 @@ export class StoryIndexGenerator { return /(? { + async ensureExtracted(): Promise { // First process all the story files. Then, in a second pass, // process the docs files. The reason for this is that the docs // files may use the `` syntax, which requires @@ -158,7 +157,7 @@ export class StoryIndexGenerator { return this.specifiers.flatMap((specifier) => { const cache = this.specifierToCache.get(specifier); - return Object.values(cache).flatMap((entry): IndexEntry[] => { + return Object.values(cache).flatMap((entry): Addon_IndexEntry[] => { if (!entry) return []; if (entry.type === 'docs') return [entry]; return entry.entries; @@ -196,7 +195,7 @@ export class StoryIndexGenerator { async extractStories(specifier: NormalizedStoriesSpecifier, absolutePath: Path) { const relativePath = path.relative(this.options.workingDir, absolutePath); - const entries = [] as IndexEntry[]; + const entries = [] as Addon_IndexEntry[]; try { const importPath = slash(normalizeStoryPath(relativePath)); const makeTitle = (userTitle?: string) => { @@ -327,7 +326,7 @@ export class StoryIndexGenerator { } } - chooseDuplicate(firstEntry: IndexEntry, secondEntry: IndexEntry): IndexEntry { + chooseDuplicate(firstEntry: Addon_IndexEntry, secondEntry: Addon_IndexEntry): Addon_IndexEntry { let firstIsBetter = true; if (secondEntry.type === 'story') { firstIsBetter = false; @@ -383,7 +382,7 @@ export class StoryIndexGenerator { return betterEntry; } - async sortStories(storiesList: IndexEntry[]) { + async sortStories(storiesList: Addon_IndexEntry[]) { const entries: StoryIndex['entries'] = {}; storiesList.forEach((entry) => { diff --git a/code/lib/instrumenter/package.json b/code/lib/instrumenter/package.json index 87ddeba02173..d9ba701e82ec 100644 --- a/code/lib/instrumenter/package.json +++ b/code/lib/instrumenter/package.json @@ -43,6 +43,7 @@ }, "dependencies": { "@storybook/addons": "7.0.0-alpha.40", + "@storybook/channels": "7.0.0-alpha.40", "@storybook/client-logger": "7.0.0-alpha.40", "@storybook/core-events": "7.0.0-alpha.40", "core-js": "^3.8.2", diff --git a/code/lib/instrumenter/src/instrumenter.ts b/code/lib/instrumenter/src/instrumenter.ts index 683e73cce502..30e171255c23 100644 --- a/code/lib/instrumenter/src/instrumenter.ts +++ b/code/lib/instrumenter/src/instrumenter.ts @@ -1,6 +1,7 @@ /* eslint-disable no-underscore-dangle */ -import { addons, Channel } from '@storybook/addons'; -import type { StoryId } from '@storybook/addons'; +import { Channel } from '@storybook/channels'; +import { addons } from '@storybook/addons'; +import type { StoryId } from '@storybook/types'; import { once, logger } from '@storybook/client-logger'; import { FORCE_REMOUNT, diff --git a/code/lib/instrumenter/src/types.ts b/code/lib/instrumenter/src/types.ts index f358ecb926e0..a61e875a521c 100644 --- a/code/lib/instrumenter/src/types.ts +++ b/code/lib/instrumenter/src/types.ts @@ -1,4 +1,4 @@ -import type { StoryId } from '@storybook/addons'; +import type { StoryId } from '@storybook/types'; export interface Call { id: string; diff --git a/code/lib/preview-web/src/Preview.tsx b/code/lib/preview-web/src/Preview.tsx index 8787772170f7..b4c9f40d8a25 100644 --- a/code/lib/preview-web/src/Preview.tsx +++ b/code/lib/preview-web/src/Preview.tsx @@ -14,17 +14,18 @@ import { UPDATE_STORY_ARGS, } from '@storybook/core-events'; import { logger } from '@storybook/client-logger'; -import { addons, Channel } from '@storybook/addons'; +import { Channel } from '@storybook/channels'; +import { addons } from '@storybook/addons'; import { AnyFramework, StoryId, ProjectAnnotations, Args, Globals } from '@storybook/types'; -import { +import type { ModuleImportFn, Story, - StoryStore, StoryIndex, PromiseLike, WebProjectAnnotations, RenderToDOM, } from '@storybook/store'; +import { StoryStore } from '@storybook/store'; import { StoryRender } from './render/StoryRender'; import { TemplateDocsRender } from './render/TemplateDocsRender'; diff --git a/code/lib/preview-web/src/UrlStore.ts b/code/lib/preview-web/src/UrlStore.ts index 3b56f76b0695..c2f6dee2b002 100644 --- a/code/lib/preview-web/src/UrlStore.ts +++ b/code/lib/preview-web/src/UrlStore.ts @@ -2,7 +2,7 @@ import type { SelectionSpecifier, Selection } from '@storybook/store'; import global from 'global'; import qs from 'qs'; -import type { ViewMode } from '@storybook/addons'; +import type { ViewMode } from '@storybook/types'; import { parseArgsParam } from './parseArgsParam'; diff --git a/code/lib/preview-web/src/parseArgsParam.ts b/code/lib/preview-web/src/parseArgsParam.ts index a45371d1bea7..2e9bff64b2d8 100644 --- a/code/lib/preview-web/src/parseArgsParam.ts +++ b/code/lib/preview-web/src/parseArgsParam.ts @@ -1,6 +1,6 @@ import qs from 'qs'; import { dedent } from 'ts-dedent'; -import type { Args } from '@storybook/addons'; +import type { Args } from '@storybook/types'; import { once } from '@storybook/client-logger'; import isPlainObject from 'lodash/isPlainObject'; diff --git a/code/lib/preview-web/src/render/StandaloneDocsRender.ts b/code/lib/preview-web/src/render/StandaloneDocsRender.ts index 08d624cba2e5..6f241fc6899c 100644 --- a/code/lib/preview-web/src/render/StandaloneDocsRender.ts +++ b/code/lib/preview-web/src/render/StandaloneDocsRender.ts @@ -1,6 +1,7 @@ -import { AnyFramework, StoryId } from '@storybook/types'; +/* eslint-disable camelcase */ +import { AnyFramework, StoryId, Addon_IndexEntry } from '@storybook/types'; import { CSFFile, ModuleExports, StoryStore } from '@storybook/store'; -import { Channel, IndexEntry } from '@storybook/addons'; +import type { Channel } from '@storybook/channels'; import { DOCS_RENDERED } from '@storybook/core-events'; import { Render, RenderType, PREPARE_ABORTED } from './Render'; @@ -39,7 +40,7 @@ export class StandaloneDocsRender implements Re constructor( protected channel: Channel, protected store: StoryStore, - public entry: IndexEntry + public entry: Addon_IndexEntry ) { this.id = entry.id; } diff --git a/code/lib/preview-web/src/render/StoryRender.ts b/code/lib/preview-web/src/render/StoryRender.ts index 5f5360ee67be..12aacb03aca8 100644 --- a/code/lib/preview-web/src/render/StoryRender.ts +++ b/code/lib/preview-web/src/render/StoryRender.ts @@ -7,13 +7,13 @@ import { StoryContext, } from '@storybook/types'; import { - Story, - RenderContext, + type Story, + type RenderContext, StoryStore, - RenderToDOM, - TeardownRenderToDOM, + type RenderToDOM, + type TeardownRenderToDOM, } from '@storybook/store'; -import { Channel } from '@storybook/addons'; +import { Channel } from '@storybook/channels'; import { logger } from '@storybook/client-logger'; import { STORY_RENDER_PHASE_CHANGED, diff --git a/code/lib/preview-web/src/render/TemplateDocsRender.ts b/code/lib/preview-web/src/render/TemplateDocsRender.ts index 02a05e351ce5..34d2d6f9afe7 100644 --- a/code/lib/preview-web/src/render/TemplateDocsRender.ts +++ b/code/lib/preview-web/src/render/TemplateDocsRender.ts @@ -1,6 +1,8 @@ +/* eslint-disable camelcase */ import { AnyFramework, StoryId } from '@storybook/types'; -import { CSFFile, Story, StoryStore } from '@storybook/store'; -import { Channel, IndexEntry } from '@storybook/addons'; +import { type CSFFile, type Story, StoryStore } from '@storybook/store'; +import type { Channel } from '@storybook/channels'; +import type { Addon_IndexEntry } from '@storybook/types'; import { DOCS_RENDERED } from '@storybook/core-events'; import { Render, RenderType, PREPARE_ABORTED } from './Render'; @@ -42,7 +44,7 @@ export class TemplateDocsRender implements Rend constructor( protected channel: Channel, protected store: StoryStore, - public entry: IndexEntry + public entry: Addon_IndexEntry ) { this.id = entry.id; } diff --git a/code/lib/store/src/StoryIndexStore.ts b/code/lib/store/src/StoryIndexStore.ts index 7e4b6e059b67..8c3bb5cd083c 100644 --- a/code/lib/store/src/StoryIndexStore.ts +++ b/code/lib/store/src/StoryIndexStore.ts @@ -1,14 +1,15 @@ +/* eslint-disable camelcase */ import { dedent } from 'ts-dedent'; -import type { StoryId } from '@storybook/types'; +import type { StoryId, Addon_IndexEntry } from '@storybook/types'; import memoize from 'memoizerific'; -import type { StorySpecifier, StoryIndex, IndexEntry, Path } from './types'; +import type { StorySpecifier, StoryIndex, Path } from './types'; const getImportPathMap = memoize(1)((entries: StoryIndex['entries']) => Object.values(entries).reduce((acc, entry) => { acc[entry.importPath] = acc[entry.importPath] || entry; return acc; - }, {} as Record) + }, {} as Record) ); export class StoryIndexStore { @@ -39,7 +40,7 @@ export class StoryIndexStore { return entries.find((entry) => entry.name === name && entry.title === title); } - storyIdToEntry(storyId: StoryId): IndexEntry { + storyIdToEntry(storyId: StoryId): Addon_IndexEntry { const storyEntry = this.entries[storyId]; if (!storyEntry) { throw new Error(dedent`Couldn't find story matching '${storyId}' after HMR. @@ -52,7 +53,7 @@ export class StoryIndexStore { return storyEntry; } - importPathToEntry(importPath: Path): IndexEntry { + importPathToEntry(importPath: Path): Addon_IndexEntry { return getImportPathMap(this.entries)[importPath]; } } diff --git a/code/lib/store/src/StoryStore.ts b/code/lib/store/src/StoryStore.ts index 9da263c52543..bfca7ec9a733 100644 --- a/code/lib/store/src/StoryStore.ts +++ b/code/lib/store/src/StoryStore.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import memoize from 'memoizerific'; import type { Parameters, @@ -8,6 +9,7 @@ import type { ComponentTitle, StoryContextForEnhancers, StoryContext, + Addon_IndexEntry, } from '@storybook/types'; import mapValues from 'lodash/mapValues'; import pick from 'lodash/pick'; @@ -28,7 +30,6 @@ import type { PromiseLike, StoryIndex, V2CompatIndexEntry, - IndexEntry, StoryIndexV3, ModuleExports, } from './types'; @@ -128,7 +129,7 @@ export class StoryStore { } // Get an entry from the index, waiting on initialization if necessary - async storyIdToEntry(storyId: StoryId): Promise { + async storyIdToEntry(storyId: StoryId): Promise { await this.initializationPromise; // The index will always be set before the initialization promise returns return this.storyIndex!.storyIdToEntry(storyId); diff --git a/code/lib/store/src/parameters.ts b/code/lib/store/src/parameters.ts index a961ba0326eb..b4ac9cb70186 100644 --- a/code/lib/store/src/parameters.ts +++ b/code/lib/store/src/parameters.ts @@ -1,5 +1,5 @@ // Utilities for handling parameters -import type { Parameters } from '@storybook/addons'; +import type { Parameters } from '@storybook/types'; import isPlainObject from 'lodash/isPlainObject'; /** diff --git a/code/lib/store/src/sortStories.ts b/code/lib/store/src/sortStories.ts index f817fca96bcf..1f4c2c3d18dd 100644 --- a/code/lib/store/src/sortStories.ts +++ b/code/lib/store/src/sortStories.ts @@ -1,26 +1,30 @@ +/* eslint-disable camelcase */ import { dedent } from 'ts-dedent'; import type { - Comparator, - IndexEntryLegacy, - StorySortParameter, - StorySortParameterV7, -} from '@storybook/addons'; + Parameters, + Addon_Comparator, + Addon_IndexEntryLegacy, + Addon_StorySortParameter, + Addon_StorySortParameterV7, + Addon_StoryIndexEntry, + Addon_IndexEntry, +} from '@storybook/types'; import { storySort } from './storySort'; -import type { Story, StoryIndexEntry, IndexEntry, Path, Parameters } from './types'; +import type { Story, Path } from './types'; const sortStoriesCommon = ( - stories: IndexEntry[], - storySortParameter: StorySortParameterV7, + stories: Addon_IndexEntry[], + storySortParameter: Addon_StorySortParameterV7, fileNameOrder: Path[] ) => { if (storySortParameter) { - let sortFn: Comparator; + let sortFn: Addon_Comparator; if (typeof storySortParameter === 'function') { sortFn = storySortParameter; } else { sortFn = storySort(storySortParameter); } - stories.sort(sortFn as (a: IndexEntry, b: IndexEntry) => number); + stories.sort(sortFn as (a: Addon_IndexEntry, b: Addon_IndexEntry) => number); } else { stories.sort( (s1, s2) => fileNameOrder.indexOf(s1.importPath) - fileNameOrder.indexOf(s2.importPath) @@ -30,8 +34,8 @@ const sortStoriesCommon = ( }; export const sortStoriesV7 = ( - stories: IndexEntry[], - storySortParameter: StorySortParameterV7, + stories: Addon_IndexEntry[], + storySortParameter: Addon_StorySortParameterV7, fileNameOrder: Path[] ) => { try { @@ -49,21 +53,27 @@ export const sortStoriesV7 = ( } }; -const toIndexEntry = (story: any): StoryIndexEntry => { +const toIndexEntry = (story: any): Addon_StoryIndexEntry => { const { id, title, name, parameters, type } = story; return { id, title, name, importPath: parameters.fileName, type }; }; export const sortStoriesV6 = ( stories: [string, Story, Parameters, Parameters][], - storySortParameter: StorySortParameter, + storySortParameter: Addon_StorySortParameter, fileNameOrder: Path[] ) => { if (storySortParameter && typeof storySortParameter === 'function') { - stories.sort(storySortParameter as (a: IndexEntryLegacy, b: IndexEntryLegacy) => number); + stories.sort( + storySortParameter as (a: Addon_IndexEntryLegacy, b: Addon_IndexEntryLegacy) => number + ); return stories.map((s) => toIndexEntry(s[1])); } const storiesV7 = stories.map((s) => toIndexEntry(s[1])); - return sortStoriesCommon(storiesV7, storySortParameter as StorySortParameterV7, fileNameOrder); + return sortStoriesCommon( + storiesV7, + storySortParameter as Addon_StorySortParameterV7, + fileNameOrder + ); }; diff --git a/code/lib/store/src/storySort.ts b/code/lib/store/src/storySort.ts index 11ac5c0248f9..1a8933391ed4 100644 --- a/code/lib/store/src/storySort.ts +++ b/code/lib/store/src/storySort.ts @@ -1,11 +1,15 @@ -import { StorySortComparatorV7, StorySortObjectParameter } from '@storybook/addons'; -import { IndexEntry } from './types'; +/* eslint-disable camelcase */ +import type { + Addon_StorySortComparatorV7, + Addon_StorySortObjectParameter, + Addon_IndexEntry, +} from '@storybook/types'; const STORY_KIND_PATH_SEPARATOR = /\s*\/\s*/; export const storySort = - (options: StorySortObjectParameter = {}): StorySortComparatorV7 => - (a: IndexEntry, b: IndexEntry): number => { + (options: Addon_StorySortObjectParameter = {}): Addon_StorySortComparatorV7 => + (a: Addon_IndexEntry, b: Addon_IndexEntry): number => { // If the two stories have the same story kind, then use the default // ordering, which is the order they are defined in the story file. // only when includeNames is falsy diff --git a/code/lib/store/src/types.ts b/code/lib/store/src/types.ts index e4cb5e107ba1..bc2160df636e 100644 --- a/code/lib/store/src/types.ts +++ b/code/lib/store/src/types.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import { SynchronousPromise } from 'synchronous-promise'; import type { DecoratorFunction, @@ -21,22 +22,10 @@ import type { ComponentId, PartialStoryFn, Parameters, + Addon_StoryIndexEntry, + Addon_IndexEntry, } from '@storybook/types'; -import type { - StoryIndexEntry, - DocsIndexEntry, - TemplateDocsIndexEntry, - StandaloneDocsIndexEntry, - IndexEntry, -} from '@storybook/addons'; - -export type { - StoryIndexEntry, - DocsIndexEntry, - IndexEntry, - TemplateDocsIndexEntry, - StandaloneDocsIndexEntry, -}; + export type { StoryId, Parameters }; export type Path = string; export type ModuleExport = any; @@ -117,9 +106,9 @@ export declare type RenderContext; }; -export interface V2CompatIndexEntry extends Omit { - kind: StoryIndexEntry['title']; - story: StoryIndexEntry['name']; +export interface V2CompatIndexEntry extends Omit { + kind: Addon_StoryIndexEntry['title']; + story: Addon_StoryIndexEntry['name']; parameters: Parameters; } @@ -130,7 +119,7 @@ export interface StoryIndexV3 { export interface StoryIndex { v: number; - entries: Record; + entries: Record; } export type StorySpecifier = StoryId | { name: StoryName; title: ComponentTitle } | '*'; diff --git a/code/lib/types/src/index.ts b/code/lib/types/src/index.ts index fa290b3b32a7..afbed3b0bd91 100644 --- a/code/lib/types/src/index.ts +++ b/code/lib/types/src/index.ts @@ -1,113 +1,2 @@ -import type { - ViewMode, - AnnotatedStoryFn, - AnyFramework, - ArgTypes, - ArgTypesEnhancer, - Args, - ArgsEnhancer, - ArgsStoryFn, - BaseAnnotations, - ComponentAnnotations, - ComponentId, - ComponentTitle, - Conditional, - DecoratorApplicator, - DecoratorFunction, - GlobalTypes, - Globals, - IncludeExcludeOptions, - InputType, - LegacyAnnotatedStoryFn, - LegacyStoryAnnotationsOrFn, - LegacyStoryFn, - LoaderFunction, - Parameters, - PartialStoryFn, - PlayFunction, - PlayFunctionContext, - ProjectAnnotations, - SBArrayType, - SBEnumType, - SBIntersectionType, - SBObjectType, - SBOtherType, - SBScalarType, - SBType, - SBUnionType, - SeparatorOptions, - StepFunction, - StepLabel, - StepRunner, - StoryAnnotations, - StoryAnnotationsOrFn, - StoryContext, - StoryContextForEnhancers, - StoryContextForLoaders, - StoryContextUpdate, - StoryFn, - StoryId, - StoryIdentifier, - StoryKind, - StoryName, - StrictArgTypes, - StrictGlobalTypes, - StrictInputType, -} from '@storybook/csf'; - -export { - ViewMode, - AnnotatedStoryFn, - AnyFramework, - ArgTypes, - ArgTypesEnhancer, - Args, - ArgsEnhancer, - ArgsStoryFn, - BaseAnnotations, - ComponentAnnotations, - ComponentId, - ComponentTitle, - Conditional, - DecoratorApplicator, - DecoratorFunction, - GlobalTypes, - Globals, - IncludeExcludeOptions, - InputType, - LegacyAnnotatedStoryFn, - LegacyStoryAnnotationsOrFn, - LegacyStoryFn, - LoaderFunction, - Parameters, - PartialStoryFn, - PlayFunction, - PlayFunctionContext, - ProjectAnnotations, - SBArrayType, - SBEnumType, - SBIntersectionType, - SBObjectType, - SBOtherType, - SBScalarType, - SBType, - SBUnionType, - SeparatorOptions, - StepFunction, - StepLabel, - StepRunner, - StoryAnnotations, - StoryAnnotationsOrFn, - StoryContext, - StoryContextForEnhancers, - StoryContextForLoaders, - StoryContextUpdate, - StoryFn, - StoryId, - StoryIdentifier, - StoryKind, - StoryName, - StrictArgTypes, - StrictGlobalTypes, - StrictInputType, -}; +export * from './modules/csf'; +export * from './modules/addons'; diff --git a/code/lib/types/src/modules/addons.ts b/code/lib/types/src/modules/addons.ts new file mode 100644 index 000000000000..8c90a3829f07 --- /dev/null +++ b/code/lib/types/src/modules/addons.ts @@ -0,0 +1,351 @@ +import type { RenderData as RouterData } from '@storybook/router'; +import type { ThemeVars } from '@storybook/theming'; +import type { API } from '@storybook/api'; +import type { types } from '@storybook/addons'; + +/* eslint-disable camelcase */ +import type { + AnyFramework, + InputType, + StoryContext as StoryContextForFramework, + LegacyStoryFn as LegacyStoryFnForFramework, + PartialStoryFn as PartialStoryFnForFramework, + ArgsStoryFn as ArgsStoryFnForFramework, + StoryFn as StoryFnForFramework, + DecoratorFunction as DecoratorFunctionForFramework, + LoaderFunction as LoaderFunctionForFramework, + StoryId, + StoryKind, + StoryName, + Args, + ComponentTitle, +} from '@storybook/types'; + +export type Addon_Types = types | string; + +export interface Addon_ArgType extends InputType { + defaultValue?: TArg; +} + +export type Addons_ArgTypes = { + [key in keyof Partial]: Addon_ArgType; +} & { + // for custom defined args + [key in string]: Addon_ArgType; +}; + +export type Addon_Comparator = ((a: T, b: T) => boolean) | ((a: T, b: T) => number); +export type Addon_StorySortMethod = 'configure' | 'alphabetical'; +export interface Addon_StorySortObjectParameter { + method?: Addon_StorySortMethod; + order?: any[]; + locales?: string; + includeNames?: boolean; +} + +export type Addon_Path = string; +export interface Addon_BaseIndexEntry { + id: StoryId; + name: StoryName; + title: ComponentTitle; + importPath: Addon_Path; +} +export type Addon_StoryIndexEntry = Addon_BaseIndexEntry & { + type: 'story'; +}; + +export type Addon_DocsIndexEntry = Addon_BaseIndexEntry & { + storiesImports: Addon_Path[]; + type: 'docs'; + standalone: boolean; +}; + +/** A StandaloneDocsIndexExtry represents a file who's default export is directly renderable */ +export type Addon_StandaloneDocsIndexEntry = Addon_DocsIndexEntry & { standalone: true }; +/** A TemplateDocsIndexEntry represents a stories file that gets rendered in "docs" mode */ +export type Addon_TemplateDocsIndexEntry = Addon_DocsIndexEntry & { standalone: false }; + +export type Addon_IndexEntry = Addon_StoryIndexEntry | Addon_DocsIndexEntry; + +// The `any` here is the story store's `StoreItem` record. Ideally we should probably only +// pass a defined subset of that full data, but we pass it all so far :shrug: +export type Addon_IndexEntryLegacy = [StoryId, any, Addon_Parameters, Addon_Parameters]; +export type Addon_StorySortComparator = Addon_Comparator; +export type Addon_StorySortParameter = Addon_StorySortComparator | Addon_StorySortObjectParameter; +export type Addon_StorySortComparatorV7 = Addon_Comparator; +export type Addon_StorySortParameterV7 = + | Addon_StorySortComparatorV7 + | Addon_StorySortObjectParameter; + +// TODO: remove all these types, they belong in the renderer and csf-package + +export interface Addon_OptionsParameter extends Object { + storySort?: Addon_StorySortParameter; + theme?: { + base: string; + brandTitle?: string; + }; + [key: string]: any; +} + +export interface Addon_Parameters { + fileName?: string; + options?: Addon_OptionsParameter; + /** The layout property defines basic styles added to the preview body where the story is rendered. If you pass 'none', no styles are applied. */ + layout?: 'centered' | 'fullscreen' | 'padded' | 'none'; + docsOnly?: boolean; + [key: string]: any; +} + +export type Addon_StoryContext = + StoryContextForFramework; +export type Addon_StoryContextUpdate = Partial; + +type Addon_ReturnTypeFramework = { component: any; storyResult: ReturnType }; +export type Addon_PartialStoryFn = PartialStoryFnForFramework< + Addon_ReturnTypeFramework +>; +export type Addon_LegacyStoryFn = LegacyStoryFnForFramework< + Addon_ReturnTypeFramework +>; +export type Addon_ArgsStoryFn = ArgsStoryFnForFramework< + Addon_ReturnTypeFramework +>; +export type Addon_StoryFn = StoryFnForFramework< + Addon_ReturnTypeFramework +>; + +export type Addon_DecoratorFunction = DecoratorFunctionForFramework< + Addon_ReturnTypeFramework +>; +export type Addon_LoaderFunction = LoaderFunctionForFramework>; + +export interface Addon_WrapperSettings { + options: object; + parameters: { + [key: string]: any; + }; +} + +export type Addon_StoryWrapper = ( + storyFn: Addon_LegacyStoryFn, + context: Addon_StoryContext, + settings: Addon_WrapperSettings +) => any; + +export type Addon_MakeDecoratorResult = (...args: any) => any; + +export interface Addon_AddStoryArgs { + id: StoryId; + kind: StoryKind; + name: StoryName; + storyFn: Addon_StoryFn; + parameters: Addon_Parameters; +} + +export interface Addon_ClientApiAddon extends Addon_Type { + apply: (a: Addon_StoryApi, b: any[]) => any; +} +export interface Addon_ClientApiAddons { + [key: string]: Addon_ClientApiAddon; +} + +export type Addon_ClientApiReturnFn = ( + ...args: any[] +) => Addon_StoryApi; + +export interface Addon_StoryApi { + kind: StoryKind; + add: ( + storyName: StoryName, + storyFn: Addon_StoryFn, + parameters?: Addon_Parameters + ) => Addon_StoryApi; + addDecorator: ( + decorator: Addon_DecoratorFunction + ) => Addon_StoryApi; + addLoader: (decorator: Addon_LoaderFunction) => Addon_StoryApi; + addParameters: (parameters: Addon_Parameters) => Addon_StoryApi; + [k: string]: string | Addon_ClientApiReturnFn; +} + +export interface Addon_ClientStoryApi { + storiesOf(kind: StoryKind, module: any): Addon_StoryApi; +} + +export type Addon_LoadFn = () => any; +export type Addon_RequireContext = any; // FIXME +export type Addon_Loadable = Addon_RequireContext | [Addon_RequireContext] | Addon_LoadFn; + +// CSF types, to be re-org'ed in 6.1 + +export type Addon_BaseDecorators = Array< + (story: () => StoryFnReturnType, context: Addon_StoryContext) => StoryFnReturnType +>; + +export interface Addon_BaseAnnotations { + /** + * Dynamic data that are provided (and possibly updated by) Storybook and its addons. + * @see [Arg story inputs](https://storybook.js.org/docs/react/api/csf#args-story-inputs) + */ + args?: Partial; + + /** + * ArgTypes encode basic metadata for args, such as `name`, `description`, `defaultValue` for an arg. These get automatically filled in by Storybook Docs. + * @see [Control annotations](https://github.com/storybookjs/storybook/blob/91e9dee33faa8eff0b342a366845de7100415367/addons/controls/README.md#control-annotations) + */ + argTypes?: Addons_ArgTypes; + + /** + * Custom metadata for a story. + * @see [Parameters](https://storybook.js.org/docs/basics/writing-stories/#parameters) + */ + parameters?: Addon_Parameters; + + /** + * Wrapper components or Storybook decorators that wrap a story. + * + * Decorators defined in Meta will be applied to every story variation. + * @see [Decorators](https://storybook.js.org/docs/addons/introduction/#1-decorators) + */ + decorators?: Addon_BaseDecorators; + + /** + * Define a custom render function for the story(ies). If not passed, a default render function by the framework will be used. + */ + render?: (args: Args, context: Addon_StoryContext) => StoryFnReturnType; + + /** + * Function that is executed after the story is rendered. + */ + play?: (context: Addon_StoryContext) => Promise | void; +} + +export interface Addon_Annotations + extends Addon_BaseAnnotations { + /** + * Used to only include certain named exports as stories. Useful when you want to have non-story exports such as mock data or ignore a few stories. + * @example + * includeStories: ['SimpleStory', 'ComplexStory'] + * includeStories: /.*Story$/ + * + * @see [Non-story exports](https://storybook.js.org/docs/formats/component-story-format/#non-story-exports) + */ + includeStories?: string[] | RegExp; + + /** + * Used to exclude certain named exports. Useful when you want to have non-story exports such as mock data or ignore a few stories. + * @example + * excludeStories: ['simpleData', 'complexData'] + * excludeStories: /.*Data$/ + * + * @see [Non-story exports](https://storybook.js.org/docs/formats/component-story-format/#non-story-exports) + */ + excludeStories?: string[] | RegExp; +} + +export interface Addon_BaseMeta { + /** + * Title of the story which will be presented in the navigation. **Should be unique.** + * + * Stories can be organized in a nested structure using "/" as a separator. + * + * Since CSF 3.0 this property is optional. + * + * @example + * export default { + * ... + * title: 'Design System/Atoms/Button' + * } + * + * @see [Story Hierarchy](https://storybook.js.org/docs/basics/writing-stories/#story-hierarchy) + */ + title?: string; + + /** + * Manually set the id of a story, which in particular is useful if you want to rename stories without breaking permalinks. + * + * Storybook will prioritize the id over the title for ID generation, if provided, and will prioritize the story.storyName over the export key for display. + * + * @see [Sidebar and URLs](https://storybook.js.org/docs/react/configure/sidebar-and-urls#permalinking-to-stories) + */ + id?: string; + + /** + * The primary component for your story. + * + * Used by addons for automatic prop table generation and display of other component metadata. + */ + component?: ComponentType; + + /** + * Auxiliary subcomponents that are part of the stories. + * + * Used by addons for automatic prop table generation and display of other component metadata. + * + * @example + * import { Button, ButtonGroup } from './components'; + * + * export default { + * ... + * subcomponents: { Button, ButtonGroup } + * } + * + * By defining them each component will have its tab in the args table. + */ + subcomponents?: Record; +} + +export type Addon_BaseStoryObject = { + /** + * Override the display name in the UI + */ + storyName?: string; +}; + +export type Addon_BaseStoryFn = { + (args: Args, context: Addon_StoryContext): StoryFnReturnType; +} & Addon_BaseStoryObject; + +export type BaseStory = + | Addon_BaseStoryFn + | Addon_BaseStoryObject; + +export interface Addon_RenderOptions { + active?: boolean; + key?: string; +} + +export interface Addon_Type { + title: (() => string) | string; + type?: Addon_Types; + id?: string; + route?: (routeOptions: RouterData) => string; + match?: (matchOptions: RouterData) => boolean; + render: (renderOptions: Addon_RenderOptions) => any | null; + paramKey?: string; + disabled?: boolean; + hidden?: boolean; +} + +export type Addon_Loader = (api: API) => void; + +export interface Addon_Loaders { + [key: string]: Addon_Loader; +} +export interface Addon_Collection { + [key: string]: Addon_Type; +} +export interface Addon_Elements { + [key: string]: Addon_Collection; +} +export interface Addon_ToolbarConfig { + hidden?: boolean; +} +export interface Addon_Config { + theme?: ThemeVars; + toolbar?: { + [id: string]: Addon_ToolbarConfig; + }; + [key: string]: any; +} diff --git a/code/lib/types/src/modules/csf.ts b/code/lib/types/src/modules/csf.ts new file mode 100644 index 000000000000..fa290b3b32a7 --- /dev/null +++ b/code/lib/types/src/modules/csf.ts @@ -0,0 +1,113 @@ +import type { + ViewMode, + AnnotatedStoryFn, + AnyFramework, + ArgTypes, + ArgTypesEnhancer, + Args, + ArgsEnhancer, + ArgsStoryFn, + BaseAnnotations, + ComponentAnnotations, + ComponentId, + ComponentTitle, + Conditional, + DecoratorApplicator, + DecoratorFunction, + GlobalTypes, + Globals, + IncludeExcludeOptions, + InputType, + LegacyAnnotatedStoryFn, + LegacyStoryAnnotationsOrFn, + LegacyStoryFn, + LoaderFunction, + Parameters, + PartialStoryFn, + PlayFunction, + PlayFunctionContext, + ProjectAnnotations, + SBArrayType, + SBEnumType, + SBIntersectionType, + SBObjectType, + SBOtherType, + SBScalarType, + SBType, + SBUnionType, + SeparatorOptions, + StepFunction, + StepLabel, + StepRunner, + StoryAnnotations, + StoryAnnotationsOrFn, + StoryContext, + StoryContextForEnhancers, + StoryContextForLoaders, + StoryContextUpdate, + StoryFn, + StoryId, + StoryIdentifier, + StoryKind, + StoryName, + StrictArgTypes, + StrictGlobalTypes, + StrictInputType, +} from '@storybook/csf'; + +export { + ViewMode, + AnnotatedStoryFn, + AnyFramework, + ArgTypes, + ArgTypesEnhancer, + Args, + ArgsEnhancer, + ArgsStoryFn, + BaseAnnotations, + ComponentAnnotations, + ComponentId, + ComponentTitle, + Conditional, + DecoratorApplicator, + DecoratorFunction, + GlobalTypes, + Globals, + IncludeExcludeOptions, + InputType, + LegacyAnnotatedStoryFn, + LegacyStoryAnnotationsOrFn, + LegacyStoryFn, + LoaderFunction, + Parameters, + PartialStoryFn, + PlayFunction, + PlayFunctionContext, + ProjectAnnotations, + SBArrayType, + SBEnumType, + SBIntersectionType, + SBObjectType, + SBOtherType, + SBScalarType, + SBType, + SBUnionType, + SeparatorOptions, + StepFunction, + StepLabel, + StepRunner, + StoryAnnotations, + StoryAnnotationsOrFn, + StoryContext, + StoryContextForEnhancers, + StoryContextForLoaders, + StoryContextUpdate, + StoryFn, + StoryId, + StoryIdentifier, + StoryKind, + StoryName, + StrictArgTypes, + StrictGlobalTypes, + StrictInputType, +}; diff --git a/code/renderers/html/src/public-api.ts b/code/renderers/html/src/public-api.ts index 28d78a70bff1..d3ebcfdbb632 100644 --- a/code/renderers/html/src/public-api.ts +++ b/code/renderers/html/src/public-api.ts @@ -1,14 +1,14 @@ -/* eslint-disable prefer-destructuring */ +/* eslint-disable camelcase, prefer-destructuring */ +import type { Addon_ClientStoryApi, Addon_Loadable } from '@storybook/types'; import { start } from '@storybook/core-client'; -import type { ClientStoryApi, Loadable } from '@storybook/addons'; import type { HtmlFramework } from './types'; import { renderToDOM, render } from './render'; const FRAMEWORK = 'html'; -interface ClientApi extends ClientStoryApi { - configure(loader: Loadable, module: NodeModule): void; +interface ClientApi extends Addon_ClientStoryApi { + configure(loader: Addon_Loadable, module: NodeModule): void; forceReRender(): void; raw: () => any; // todo add type } diff --git a/code/renderers/preact/src/public-api.ts b/code/renderers/preact/src/public-api.ts index ffa679e1d233..c8713f115dc4 100644 --- a/code/renderers/preact/src/public-api.ts +++ b/code/renderers/preact/src/public-api.ts @@ -1,12 +1,12 @@ -/* eslint-disable prefer-destructuring */ +/* eslint-disable camelcase, prefer-destructuring */ +import type { Addon_ClientStoryApi, Addon_Loadable } from '@storybook/types'; import { start } from '@storybook/core-client'; -import type { ClientStoryApi, Loadable } from '@storybook/addons'; import { renderToDOM } from './render'; import type { PreactFramework } from './types'; -export interface ClientApi extends ClientStoryApi { - configure(loader: Loadable, module: NodeModule): void; +export interface ClientApi extends Addon_ClientStoryApi { + configure(loader: Addon_Loadable, module: NodeModule): void; forceReRender(): void; raw: () => any; // todo add type load: (...args: any[]) => void; diff --git a/code/renderers/react/src/public-api.tsx b/code/renderers/react/src/public-api.tsx index 754c3466221b..8d9fd1cbbe8e 100644 --- a/code/renderers/react/src/public-api.tsx +++ b/code/renderers/react/src/public-api.tsx @@ -1,13 +1,13 @@ -/* eslint-disable prefer-destructuring */ +/* eslint-disable camelcase, prefer-destructuring */ +import type { Addon_ClientStoryApi, Addon_Loadable } from '@storybook/types'; import { start } from '@storybook/core-client'; -import type { ClientStoryApi, Loadable } from '@storybook/addons'; import { Args, DecoratorFunction } from '@storybook/types'; import { renderToDOM, render } from './render'; import type { ReactFramework } from './types'; -interface ClientApi extends ClientStoryApi { - configure(loader: Loadable, module: NodeModule): void; +interface ClientApi extends Addon_ClientStoryApi { + configure(loader: Addon_Loadable, module: NodeModule): void; forceReRender(): void; raw: () => any; // todo add type } diff --git a/code/renderers/server/src/public-api.ts b/code/renderers/server/src/public-api.ts index 71d4f110e071..5c348684c5c5 100644 --- a/code/renderers/server/src/public-api.ts +++ b/code/renderers/server/src/public-api.ts @@ -1,13 +1,14 @@ +/* eslint-disable camelcase */ +import type { Addon_ClientStoryApi, Addon_Loadable } from '@storybook/types'; import { start } from '@storybook/core-client'; -import type { ClientStoryApi, Loadable } from '@storybook/addons'; import { renderToDOM, render } from './render'; import type { ServerFramework } from './types'; const FRAMEWORK = 'server'; -interface ClientApi extends ClientStoryApi { - configure(loader: Loadable, module: NodeModule): void; +interface ClientApi extends Addon_ClientStoryApi { + configure(loader: Addon_Loadable, module: NodeModule): void; forceReRender(): void; raw: () => any; // todo add type } diff --git a/code/renderers/vue/src/public-api.ts b/code/renderers/vue/src/public-api.ts index f5c287a56032..feb698c00395 100644 --- a/code/renderers/vue/src/public-api.ts +++ b/code/renderers/vue/src/public-api.ts @@ -1,6 +1,6 @@ -/* eslint-disable prefer-destructuring */ +/* eslint-disable camelcase, prefer-destructuring */ +import type { Addon_ClientStoryApi, Addon_Loadable } from '@storybook/types'; import { start } from '@storybook/core-client'; -import type { ClientStoryApi, Loadable } from '@storybook/addons'; import type { VueFramework } from './types'; import { renderToDOM, render } from './render'; @@ -8,8 +8,8 @@ import { decorateStory } from './decorateStory'; const FRAMEWORK = 'vue'; -interface ClientApi extends ClientStoryApi { - configure(loader: Loadable, module: NodeModule): void; +interface ClientApi extends Addon_ClientStoryApi { + configure(loader: Addon_Loadable, module: NodeModule): void; forceReRender(): void; raw: () => any; // todo add type load: (...args: any[]) => void; diff --git a/code/renderers/vue3/src/public-api.ts b/code/renderers/vue3/src/public-api.ts index d1502a785276..89fd4401ab9e 100644 --- a/code/renderers/vue3/src/public-api.ts +++ b/code/renderers/vue3/src/public-api.ts @@ -1,6 +1,7 @@ +/* eslint-disable camelcase */ +import type { Addon_ClientStoryApi, Addon_Loadable } from '@storybook/types'; import type { App } from 'vue'; import { start } from '@storybook/core-client'; -import type { ClientStoryApi, Loadable } from '@storybook/addons'; import type { VueFramework } from './types'; import { decorateStory } from './decorateStory'; @@ -9,8 +10,8 @@ import { render, renderToDOM } from './render'; const FRAMEWORK = 'vue3'; -interface ClientApi extends ClientStoryApi { - configure(loader: Loadable, module: NodeModule): void; +interface ClientApi extends Addon_ClientStoryApi { + configure(loader: Addon_Loadable, module: NodeModule): void; forceReRender(): void; raw: () => any; // todo add type load: (...args: any[]) => void; diff --git a/code/renderers/web-components/src/public-api.ts b/code/renderers/web-components/src/public-api.ts index 775a90ea52f7..9582e8dcf008 100644 --- a/code/renderers/web-components/src/public-api.ts +++ b/code/renderers/web-components/src/public-api.ts @@ -1,14 +1,14 @@ -/* eslint-disable prefer-destructuring */ +/* eslint-disable camelcase, prefer-destructuring */ +import type { Addon_ClientStoryApi, Addon_Loadable } from '@storybook/types'; import { start } from '@storybook/core-client'; -import type { ClientStoryApi, Loadable } from '@storybook/addons'; import { renderToDOM } from './render'; import type { WebComponentsFramework } from './types'; const FRAMEWORK = 'web-components'; -interface ClientApi extends ClientStoryApi { - configure(loader: Loadable, module: NodeModule): void; +interface ClientApi extends Addon_ClientStoryApi { + configure(loader: Addon_Loadable, module: NodeModule): void; forceReRender(): void; raw: () => any; // todo add type } diff --git a/code/ui/manager/src/components/layout/app.mockdata.tsx b/code/ui/manager/src/components/layout/app.mockdata.tsx index 2686d44d3058..67ad2d284aee 100644 --- a/code/ui/manager/src/components/layout/app.mockdata.tsx +++ b/code/ui/manager/src/components/layout/app.mockdata.tsx @@ -1,7 +1,8 @@ +/* eslint-disable camelcase */ import global from 'global'; import React, { Component, FC } from 'react'; import { styled } from '@storybook/theming'; -import type { Collection } from '@storybook/addons'; +import type { Addon_Collection } from '@storybook/types'; import type { State } from '@storybook/api'; import { Sidebar, SidebarProps } from '../sidebar/Sidebar'; import Panel from '../panel/panel'; @@ -34,7 +35,7 @@ export const shortcuts: State['shortcuts'] = { expandAll: ['ctrl', 'shift', 'ArrowDown'], }; -export const panels: Collection = { +export const panels: Addon_Collection = { test1: { title: 'Test 1', render: ({ active, key }) => diff --git a/code/ui/manager/src/globals/exports.ts b/code/ui/manager/src/globals/exports.ts index f9652e7a9c78..1a7df907a8cc 100644 --- a/code/ui/manager/src/globals/exports.ts +++ b/code/ui/manager/src/globals/exports.ts @@ -214,7 +214,6 @@ export default { ], '@storybook/addons': [ 'AddonStore', - 'Channel', 'HooksContext', 'addons', 'applyHooks', diff --git a/code/ui/manager/src/runtime.ts b/code/ui/manager/src/runtime.ts index dd6c8737f2fa..a2394f081e34 100644 --- a/code/ui/manager/src/runtime.ts +++ b/code/ui/manager/src/runtime.ts @@ -1,7 +1,9 @@ +/* eslint-disable camelcase */ import global from 'global'; -import { addons, AddonStore, Channel } from '@storybook/addons'; -import type { Config, Types } from '@storybook/addons'; +import type { Channel } from '@storybook/channels'; +import { addons, AddonStore, Types } from '@storybook/addons'; +import type { Addon_Config } from '@storybook/types'; import * as postMessage from '@storybook/channel-postmessage'; import * as webSocket from '@storybook/channel-websocket'; import Events from '@storybook/core-events'; @@ -42,7 +44,7 @@ class ReactProvider extends Provider { return this.addons.getElements(type); } - getConfig(): Config { + getConfig(): Addon_Config { return this.addons.getConfig(); } diff --git a/docs/snippets/common/my-addon-initial-panel-state.js.mdx b/docs/snippets/common/my-addon-initial-panel-state.js.mdx index 8009d61ac4fd..591ba75867f1 100644 --- a/docs/snippets/common/my-addon-initial-panel-state.js.mdx +++ b/docs/snippets/common/my-addon-initial-panel-state.js.mdx @@ -3,7 +3,7 @@ import React from 'react'; -import { addons, types } from '@storybook/addons'; +import { addons, type types } from '@storybook/addons'; import { AddonPanel } from '@storybook/components'; diff --git a/docs/snippets/common/storybook-addon-panel-example.js.mdx b/docs/snippets/common/storybook-addon-panel-example.js.mdx index 29d8a1ab9d46..e98c6c37f386 100644 --- a/docs/snippets/common/storybook-addon-panel-example.js.mdx +++ b/docs/snippets/common/storybook-addon-panel-example.js.mdx @@ -5,7 +5,7 @@ import React from 'react'; import { AddonPanel } from '@storybook/components'; -import { addons, types } from '@storybook/addons'; +import { addons, type types } from '@storybook/addons'; import { useGlobals } from '@storybook/api'; diff --git a/docs/snippets/common/storybook-addon-panel-initial.js.mdx b/docs/snippets/common/storybook-addon-panel-initial.js.mdx index 9f9e6b6c05f0..57dc8646af17 100644 --- a/docs/snippets/common/storybook-addon-panel-initial.js.mdx +++ b/docs/snippets/common/storybook-addon-panel-initial.js.mdx @@ -3,7 +3,7 @@ import React from 'react'; -import { addons, types } from '@storybook/addons'; +import { addons, type types } from '@storybook/addons'; import { AddonPanel } from '@storybook/components'; diff --git a/docs/snippets/common/storybook-addon-tab-example.js.mdx b/docs/snippets/common/storybook-addon-tab-example.js.mdx index dcfa1b41f92b..6f471c7c6758 100644 --- a/docs/snippets/common/storybook-addon-tab-example.js.mdx +++ b/docs/snippets/common/storybook-addon-tab-example.js.mdx @@ -3,7 +3,7 @@ import React from 'react'; -import { addons, types } from '@storybook/addons'; +import { addons, type types } from '@storybook/addons'; addons.register('my/tab', () => { addons.add('my-panel-addon/tab', { diff --git a/docs/snippets/common/storybook-addon-toolbar-example.js.mdx b/docs/snippets/common/storybook-addon-toolbar-example.js.mdx index 869c9df49ad4..8c88e70e8e41 100644 --- a/docs/snippets/common/storybook-addon-toolbar-example.js.mdx +++ b/docs/snippets/common/storybook-addon-toolbar-example.js.mdx @@ -3,7 +3,7 @@ import React from "react"; -import { addons, types } from '@storybook/addons'; +import { addons, type types } from '@storybook/addons'; import { Icons, IconButton } from '@storybook/components'; From f968dbed3a3ba53ca859ad7f1e5d0c3496fe5bf7 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 21 Oct 2022 23:30:22 +0200 Subject: [PATCH 05/38] step 2 --- code/frameworks/angular/src/client/render.ts | 6 +- code/lib/client-api/src/ClientApi.ts | 10 +- code/lib/client-api/src/StoryStoreFacade.ts | 37 ++--- code/lib/client-api/src/types.ts | 9 +- .../src/preview/executeLoadable.ts | 11 +- code/lib/core-client/src/preview/start.ts | 15 +- code/lib/core-client/src/preview/types.ts | 8 +- .../src/utils/StoryIndexGenerator.ts | 45 ++--- .../lib/core-server/src/utils/stories-json.ts | 9 +- .../src/utils/watch-story-specifiers.ts | 17 +- code/lib/preview-web/src/Preview.tsx | 47 +++--- code/lib/preview-web/src/PreviewWeb.tsx | 26 +-- code/lib/preview-web/src/UrlStore.ts | 17 +- code/lib/preview-web/src/WebView.ts | 5 +- .../src/docs-context/DocsContext.ts | 32 ++-- .../src/docs-context/DocsContextProps.ts | 32 +++- code/lib/preview-web/src/index.ts | 3 +- .../src/render/StandaloneDocsRender.ts | 7 +- .../lib/preview-web/src/render/StoryRender.ts | 27 ++- .../src/render/TemplateDocsRender.ts | 15 +- code/lib/store/src/ArgsStore.ts | 10 +- code/lib/store/src/StoryIndexStore.ts | 22 ++- code/lib/store/src/StoryStore.ts | 84 +++++----- code/lib/store/src/csf/composeConfigs.ts | 20 ++- .../src/csf/normalizeComponentAnnotations.ts | 12 +- .../src/csf/normalizeProjectAnnotations.ts | 11 +- code/lib/store/src/csf/normalizeStory.ts | 8 +- code/lib/store/src/csf/prepareStory.ts | 19 +-- code/lib/store/src/csf/processCSFFile.ts | 22 ++- code/lib/store/src/index.ts | 2 - code/lib/store/src/sortStories.ts | 11 +- code/lib/store/src/types.ts | 155 ------------------ code/lib/types/package.json | 1 + code/lib/types/src/index.ts | 1 + code/lib/types/src/modules/store.ts | 154 +++++++++++++++++ 35 files changed, 494 insertions(+), 416 deletions(-) delete mode 100644 code/lib/store/src/types.ts create mode 100644 code/lib/types/src/modules/store.ts diff --git a/code/frameworks/angular/src/client/render.ts b/code/frameworks/angular/src/client/render.ts index a0b711035610..55a9132b6f74 100644 --- a/code/frameworks/angular/src/client/render.ts +++ b/code/frameworks/angular/src/client/render.ts @@ -1,5 +1,5 @@ -import type { RenderContext } from '@storybook/store'; -import type { ArgsStoryFn } from '@storybook/types'; +/* eslint-disable camelcase */ +import type { Store_RenderContext, ArgsStoryFn } from '@storybook/types'; import { renderNgApp } from './angular/helpers'; import type { AngularFramework } from './types'; @@ -17,7 +17,7 @@ export async function renderToDOM( forceRemount, storyContext: { parameters, component }, id, - }: RenderContext, + }: Store_RenderContext, element: HTMLElement ) { showMain(); diff --git a/code/lib/client-api/src/ClientApi.ts b/code/lib/client-api/src/ClientApi.ts index 162befde882a..9ef7ff088d59 100644 --- a/code/lib/client-api/src/ClientApi.ts +++ b/code/lib/client-api/src/ClientApi.ts @@ -21,6 +21,9 @@ import type { LegacyStoryFn, Addon_ClientApiAddons, Addon_StoryApi, + Store_NormalizedComponentAnnotations, + Store_Path, + Store_ModuleImportFn, } from '@storybook/types'; import { combineParameters, @@ -28,7 +31,6 @@ import { StoryStore, normalizeInputTypes, } from '@storybook/store'; -import type { NormalizedComponentAnnotations, Path, ModuleImportFn } from '@storybook/store'; import { StoryStoreFacade } from './StoryStoreFacade'; @@ -132,7 +134,7 @@ export class ClientApi { private addons: Addon_ClientApiAddons; - onImportFnChanged?: ({ importFn }: { importFn: ModuleImportFn }) => void; + onImportFnChanged?: ({ importFn }: { importFn: Store_ModuleImportFn }) => void; // If we don't get passed modules so don't know filenames, we can // just use numeric indexes @@ -149,7 +151,7 @@ export class ClientApi { singleton = this; } - importFn(path: Path) { + importFn(path: Store_Path) { return this.facade.importFn(path); } @@ -292,7 +294,7 @@ export class ClientApi { }; }); - const meta: NormalizedComponentAnnotations = { + const meta: Store_NormalizedComponentAnnotations = { id: sanitize(kind), title: kind, decorators: [], diff --git a/code/lib/client-api/src/StoryStoreFacade.ts b/code/lib/client-api/src/StoryStoreFacade.ts index e7d518478534..ae606483c953 100644 --- a/code/lib/client-api/src/StoryStoreFacade.ts +++ b/code/lib/client-api/src/StoryStoreFacade.ts @@ -12,16 +12,14 @@ import type { Parameters, StoryFn, Addon_IndexEntry, + Store_NormalizedProjectAnnotations, + Store_NormalizedStoriesSpecifier, + Store_Path, + Store_StoryIndex, + Store_ModuleExports, + Store_Story, } from '@storybook/types'; import { StoryStore, userOrAutoTitle, sortStoriesV6 } from '@storybook/store'; -import type { - NormalizedProjectAnnotations, - NormalizedStoriesSpecifier, - Path, - StoryIndex, - ModuleExports, - Story, -} from '@storybook/store'; import { logger } from '@storybook/client-logger'; import type { DocsOptions } from '@storybook/core-common'; @@ -37,11 +35,11 @@ export interface GetStorybookKind { } export class StoryStoreFacade { - projectAnnotations: NormalizedProjectAnnotations; + projectAnnotations: Store_NormalizedProjectAnnotations; entries: Record; - csfExports: Record; + csfExports: Record; constructor() { this.projectAnnotations = { @@ -61,7 +59,7 @@ export class StoryStoreFacade { // This doesn't actually import anything because the client-api loads fully // on startup, but this is a shim after all. - importFn(path: Path) { + importFn(path: Store_Path) { return SynchronousPromise.resolve().then(() => { const moduleExports = this.csfExports[path]; if (!moduleExports) throw new Error(`Unknown path: ${path}`); @@ -75,8 +73,8 @@ export class StoryStoreFacade { const storyEntries = Object.entries(this.entries); // Add the kind parameters and global parameters to each entry - const sortableV6: [StoryId, Story, Parameters, Parameters][] = storyEntries.map( - ([storyId, { type, importPath, ...entry }]) => { + const sortableV6: [StoryId, Store_Story, Parameters, Parameters][] = + storyEntries.map(([storyId, { type, importPath, ...entry }]) => { const exports = this.csfExports[importPath]; const csfFile = store.processCSFFileWithCache( exports, @@ -84,7 +82,7 @@ export class StoryStoreFacade { exports.default.title ); - let storyLike: Story; + let storyLike: Store_Story; if (type === 'story') { storyLike = store.storyFromCSFFile({ storyId, csfFile }); } else { @@ -97,8 +95,7 @@ export class StoryStoreFacade { } as any; } return [storyId, storyLike, csfFile.meta.parameters, this.projectAnnotations.parameters]; - } - ); + }); // NOTE: the sortStoriesV6 version returns the v7 data format. confusing but more convenient! let sortedV7: Addon_IndexEntry[]; @@ -126,12 +123,12 @@ export class StoryStoreFacade { // NOTE: this doesn't actually change the story object, just the index. acc[s.id] = this.entries[s.id]; return acc; - }, {} as StoryIndex['entries']); + }, {} as Store_StoryIndex['entries']); return { v: 4, entries }; } - clearFilenameExports(fileName: Path) { + clearFilenameExports(fileName: Store_Path) { if (!this.csfExports[fileName]) { return; } @@ -148,7 +145,7 @@ export class StoryStoreFacade { } // NOTE: we could potentially share some of this code with the stories.json generation - addStoriesFromExports(fileName: Path, fileExports: ModuleExports) { + addStoriesFromExports(fileName: Store_Path, fileExports: Store_ModuleExports) { if (fileName.match(/\.mdx$/) && !fileName.match(/\.stories\.mdx$/)) { return; } @@ -165,7 +162,7 @@ export class StoryStoreFacade { let { id: componentId, title } = defaultExport || {}; const specifiers = (global.STORIES || []).map( - (specifier: NormalizedStoriesSpecifier & { importPathMatcher: string }) => ({ + (specifier: Store_NormalizedStoriesSpecifier & { importPathMatcher: string }) => ({ ...specifier, importPathMatcher: new RegExp(specifier.importPathMatcher), }) diff --git a/code/lib/client-api/src/types.ts b/code/lib/client-api/src/types.ts index 60ace3cafe9c..0b9519d07cd8 100644 --- a/code/lib/client-api/src/types.ts +++ b/code/lib/client-api/src/types.ts @@ -14,10 +14,11 @@ import type { DecoratorFunction, LoaderFunction, StoryContext, + Store_RenderContext, + AnyFramework, + StoryIdentifier, + ProjectAnnotations, } from '@storybook/types'; - -import { AnyFramework, StoryIdentifier, ProjectAnnotations } from '@storybook/types'; -import type { RenderContext } from '@storybook/store'; import { StoryStore, HooksContext } from '@storybook/store'; export type { @@ -121,4 +122,4 @@ export interface GetStorybookKind { stories: GetStorybookStory[]; } -export type RenderContextWithoutStoryContext = Omit; +export type RenderContextWithoutStoryContext = Omit; diff --git a/code/lib/core-client/src/preview/executeLoadable.ts b/code/lib/core-client/src/preview/executeLoadable.ts index 05ab5cfdb464..ebb0c594a3d8 100644 --- a/code/lib/core-client/src/preview/executeLoadable.ts +++ b/code/lib/core-client/src/preview/executeLoadable.ts @@ -1,8 +1,9 @@ +/* eslint-disable camelcase */ /// /// import { logger } from '@storybook/client-logger'; -import { Path, ModuleExports } from '@storybook/store'; +import type { Store_Path, Store_ModuleExports } from '@storybook/types'; import { Loadable, RequireContext, LoaderFunction } from './types'; /** @@ -21,12 +22,12 @@ export function executeLoadable(loadable: Loadable) { reqs = [loadable as RequireContext]; } - let exportsMap = new Map(); + let exportsMap = new Map(); if (reqs) { reqs.forEach((req) => { req.keys().forEach((filename: string) => { try { - const fileExports = req(filename) as ModuleExports; + const fileExports = req(filename) as Store_ModuleExports; exportsMap.set( typeof req.resolve === 'function' ? req.resolve(filename) : filename, fileExports @@ -76,7 +77,7 @@ export function executeLoadableForChanges(loadable: Loadable, m?: NodeModule) { } const exportsMap = executeLoadable(loadable); - const added = new Map(); + const added = new Map(); Array.from(exportsMap.entries()) // Ignore files that do not have a default export .filter(([, fileExports]) => !!fileExports.default) @@ -84,7 +85,7 @@ export function executeLoadableForChanges(loadable: Loadable, m?: NodeModule) { .filter(([fileName, fileExports]) => lastExportsMap.get(fileName) !== fileExports) .forEach(([fileName, fileExports]) => added.set(fileName, fileExports)); - const removed = new Map(); + const removed = new Map(); Array.from(lastExportsMap.keys()) .filter((fileName) => !exportsMap.has(fileName)) .forEach((fileName) => removed.set(fileName, lastExportsMap.get(fileName))); diff --git a/code/lib/core-client/src/preview/start.ts b/code/lib/core-client/src/preview/start.ts index 52facd56e8e9..0033ad42a224 100644 --- a/code/lib/core-client/src/preview/start.ts +++ b/code/lib/core-client/src/preview/start.ts @@ -1,11 +1,16 @@ +/* eslint-disable camelcase */ import global from 'global'; import { ClientApi } from '@storybook/client-api'; import { PreviewWeb } from '@storybook/preview-web'; -import type { AnyFramework, ArgsStoryFn } from '@storybook/types'; +import type { + AnyFramework, + ArgsStoryFn, + Store_Path, + Store_WebProjectAnnotations, +} from '@storybook/types'; import { createChannel } from '@storybook/channel-postmessage'; import { addons } from '@storybook/addons'; import { FORCE_RE_RENDER } from '@storybook/core-events'; -import type { Path, WebProjectAnnotations } from '@storybook/store'; import { Loadable } from './types'; import { executeLoadableForChanges } from './executeLoadable'; @@ -17,7 +22,7 @@ const removedApi = (name: string) => () => { }; interface RendererImplementation { - decorateStory?: WebProjectAnnotations['applyDecorators']; + decorateStory?: Store_WebProjectAnnotations['applyDecorators']; render?: ArgsStoryFn; } @@ -38,7 +43,7 @@ interface StartReturnValue { } export function start( - renderToDOM: WebProjectAnnotations['renderToDOM'], + renderToDOM: Store_WebProjectAnnotations['renderToDOM'], { decorateStory, render }: RendererImplementation = {} ): StartReturnValue { if (globalWindow) { @@ -64,7 +69,7 @@ export function start( const preview = new PreviewWeb(); let initialized = false; - const importFn = (path: Path) => clientApi.importFn(path); + const importFn = (path: Store_Path) => clientApi.importFn(path); function onStoriesChanged() { const storyIndex = clientApi.getStoryIndex(); preview.onStoriesChanged({ storyIndex, importFn }); diff --git a/code/lib/core-client/src/preview/types.ts b/code/lib/core-client/src/preview/types.ts index d964e5012609..92edf829b348 100644 --- a/code/lib/core-client/src/preview/types.ts +++ b/code/lib/core-client/src/preview/types.ts @@ -1,4 +1,6 @@ -import { RenderContext, RenderContextWithoutStoryContext } from '@storybook/client-api'; +/* eslint-disable camelcase */ +import { Store_RenderContext } from '@storybook/types'; +import type { RenderContextWithoutStoryContext } from '@storybook/client-api'; export interface PreviewError { message?: string; @@ -23,7 +25,7 @@ export interface RequireContext { export type LoaderFunction = () => void | any[]; export type Loadable = RequireContext | RequireContext[] | LoaderFunction; -export type { RenderContext, RenderContextWithoutStoryContext }; +export type { Store_RenderContext as RenderContext, RenderContextWithoutStoryContext }; // The function used by a framework to render story to the DOM -export type RenderStoryFunction = (context: RenderContext) => void; +export type RenderStoryFunction = (context: Store_RenderContext) => void; diff --git a/code/lib/core-server/src/utils/StoryIndexGenerator.ts b/code/lib/core-server/src/utils/StoryIndexGenerator.ts index 407f19bca308..d100db31dd3e 100644 --- a/code/lib/core-server/src/utils/StoryIndexGenerator.ts +++ b/code/lib/core-server/src/utils/StoryIndexGenerator.ts @@ -4,8 +4,11 @@ import fs from 'fs-extra'; import glob from 'globby'; import slash from 'slash'; -import type { Path, StoryIndex, V2CompatIndexEntry, StoryId } from '@storybook/store'; import type { + Store_Path, + Store_StoryIndex, + Store_V2CompatIndexEntry, + StoryId, Addon_IndexEntry, Addon_StoryIndexEntry, Addon_StandaloneDocsIndexEntry, @@ -25,13 +28,17 @@ type DocsCacheEntry = Addon_StandaloneDocsIndexEntry; /** A *.stories.* file will produce a list of stories and possibly a docs entry */ type StoriesCacheEntry = { entries: (Addon_StoryIndexEntry | Addon_TemplateDocsIndexEntry)[]; - dependents: Path[]; + dependents: Store_Path[]; type: 'stories'; }; type CacheEntry = false | StoriesCacheEntry | DocsCacheEntry; -type SpecifierStoriesCache = Record; +type SpecifierStoriesCache = Record; -const makeAbsolute = (otherImport: Path, normalizedPath: Path, workingDir: Path) => +const makeAbsolute = ( + otherImport: Store_Path, + normalizedPath: Store_Path, + workingDir: Store_Path +) => otherImport.startsWith('.') ? slash( path.resolve( @@ -67,13 +74,13 @@ export class StoryIndexGenerator { // Cache the last value of `getStoryIndex`. We invalidate (by unsetting) when: // - any file changes, including deletions // - the preview changes [not yet implemented] - private lastIndex?: StoryIndex; + private lastIndex?: Store_StoryIndex; constructor( public readonly specifiers: NormalizedStoriesSpecifier[], public readonly options: { - workingDir: Path; - configDir: Path; + workingDir: Store_Path; + configDir: Store_Path; storiesV2Compatibility: boolean; storyStoreV7: boolean; storyIndexers: StoryIndexer[]; @@ -93,7 +100,7 @@ export class StoryIndexGenerator { path.join(this.options.workingDir, specifier.directory, specifier.files) ); const files = await glob(fullGlob); - files.sort().forEach((absolutePath: Path) => { + files.sort().forEach((absolutePath: Store_Path) => { const ext = path.extname(absolutePath); if (ext === '.storyshot') { const relativePath = path.relative(this.options.workingDir, absolutePath); @@ -118,7 +125,7 @@ export class StoryIndexGenerator { async updateExtracted( updater: ( specifier: NormalizedStoriesSpecifier, - absolutePath: Path, + absolutePath: Store_Path, existingEntry: CacheEntry ) => Promise, overwrite = false @@ -136,7 +143,7 @@ export class StoryIndexGenerator { ); } - isDocsMdx(absolutePath: Path) { + isDocsMdx(absolutePath: Store_Path) { return /(? { @@ -193,7 +200,7 @@ export class StoryIndexGenerator { return dependencies; } - async extractStories(specifier: NormalizedStoriesSpecifier, absolutePath: Path) { + async extractStories(specifier: NormalizedStoriesSpecifier, absolutePath: Store_Path) { const relativePath = path.relative(this.options.workingDir, absolutePath); const entries = [] as Addon_IndexEntry[]; try { @@ -244,7 +251,7 @@ export class StoryIndexGenerator { return { entries, type: 'stories', dependents: [] } as StoriesCacheEntry; } - async extractDocs(specifier: NormalizedStoriesSpecifier, absolutePath: Path) { + async extractDocs(specifier: NormalizedStoriesSpecifier, absolutePath: Store_Path) { const relativePath = path.relative(this.options.workingDir, absolutePath); try { if (!this.options.storyStoreV7) { @@ -265,10 +272,10 @@ export class StoryIndexGenerator { const content = await fs.readFile(absolutePath, 'utf8'); const result: { title?: ComponentTitle; - of?: Path; + of?: Store_Path; name?: StoryName; isTemplate?: boolean; - imports?: Path[]; + imports?: Store_Path[]; } = analyze(content); // Templates are not indexed @@ -383,7 +390,7 @@ export class StoryIndexGenerator { } async sortStories(storiesList: Addon_IndexEntry[]) { - const entries: StoryIndex['entries'] = {}; + const entries: Store_StoryIndex['entries'] = {}; storiesList.forEach((entry) => { const existing = entries[entry.id]; @@ -407,7 +414,7 @@ export class StoryIndexGenerator { return sortableStories.reduce((acc, item) => { acc[item.id] = item; return acc; - }, {} as StoryIndex['entries']); + }, {} as Store_StoryIndex['entries']); } async getIndex() { @@ -441,7 +448,7 @@ export class StoryIndexGenerator { }, }; return acc; - }, {} as Record); + }, {} as Record); } this.lastIndex = { @@ -452,7 +459,7 @@ export class StoryIndexGenerator { return this.lastIndex; } - invalidate(specifier: NormalizedStoriesSpecifier, importPath: Path, removed: boolean) { + invalidate(specifier: NormalizedStoriesSpecifier, importPath: Store_Path, removed: boolean) { const absolutePath = slash(path.resolve(this.options.workingDir, importPath)); const cache = this.specifierToCache.get(specifier); diff --git a/code/lib/core-server/src/utils/stories-json.ts b/code/lib/core-server/src/utils/stories-json.ts index 3e369612ad84..f110e8c15150 100644 --- a/code/lib/core-server/src/utils/stories-json.ts +++ b/code/lib/core-server/src/utils/stories-json.ts @@ -1,8 +1,9 @@ +/* eslint-disable camelcase */ import { Router, Request, Response } from 'express'; import { writeJSON } from 'fs-extra'; import type { NormalizedStoriesSpecifier } from '@storybook/core-common'; -import type { StoryIndex, StoryIndexV3 } from '@storybook/store'; +import type { Store_StoryIndex, Store_StoryIndexV3 } from '@storybook/types'; import debounce from 'lodash/debounce'; import { STORY_INDEX_INVALIDATED } from '@storybook/core-events'; @@ -15,7 +16,7 @@ export const DEBOUNCE = 100; export async function extractStoriesJson( outputFile: string, initializedStoryIndexGenerator: Promise, - transform?: (index: StoryIndex) => any + transform?: (index: Store_StoryIndex) => any ) { const generator = await initializedStoryIndexGenerator; const storyIndex = await generator.getIndex(); @@ -69,7 +70,7 @@ export function useStoriesJson({ }); } -export const convertToIndexV3 = (index: StoryIndex): StoryIndexV3 => { +export const convertToIndexV3 = (index: Store_StoryIndex): Store_StoryIndexV3 => { const { entries } = index; const stories = Object.entries(entries).reduce((acc, [id, entry]) => { const { type, ...rest } = entry; @@ -84,7 +85,7 @@ export const convertToIndexV3 = (index: StoryIndex): StoryIndexV3 => { }, }; return acc; - }, {} as StoryIndexV3['stories']); + }, {} as Store_StoryIndexV3['stories']); return { v: 3, stories, diff --git a/code/lib/core-server/src/utils/watch-story-specifiers.ts b/code/lib/core-server/src/utils/watch-story-specifiers.ts index 86f34924a84c..a8a5183de3d0 100644 --- a/code/lib/core-server/src/utils/watch-story-specifiers.ts +++ b/code/lib/core-server/src/utils/watch-story-specifiers.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import Watchpack from 'watchpack'; import slash from 'slash'; import fs from 'fs'; @@ -6,9 +7,9 @@ import glob from 'globby'; import uniq from 'lodash/uniq'; import type { NormalizedStoriesSpecifier } from '@storybook/core-common'; -import type { Path } from '@storybook/store'; +import type { Store_Path } from '@storybook/types'; -const isDirectory = (directory: Path) => { +const isDirectory = (directory: Store_Path) => { try { return fs.lstatSync(directory).isDirectory(); } catch (err) { @@ -19,14 +20,14 @@ const isDirectory = (directory: Path) => { // Watchpack (and path.relative) passes paths either with no leading './' - e.g. `src/Foo.stories.js`, // or with a leading `../` (etc), e.g. `../src/Foo.stories.js`. // We want to deal in importPaths relative to the working dir, so we normalize -function toImportPath(relativePath: Path) { +function toImportPath(relativePath: Store_Path) { return relativePath.startsWith('.') ? relativePath : `./${relativePath}`; } export function watchStorySpecifiers( specifiers: NormalizedStoriesSpecifier[], - options: { workingDir: Path }, - onInvalidate: (specifier: NormalizedStoriesSpecifier, path: Path, removed: boolean) => void + options: { workingDir: Store_Path }, + onInvalidate: (specifier: NormalizedStoriesSpecifier, path: Store_Path, removed: boolean) => void ) { // See https://www.npmjs.com/package/watchpack for full options. // If you want less traffic, consider using aggregation with some interval @@ -39,7 +40,7 @@ export function watchStorySpecifiers( directories: uniq(specifiers.map((ns) => ns.directory)), }); - async function onChangeOrRemove(watchpackPath: Path, removed: boolean) { + async function onChangeOrRemove(watchpackPath: Store_Path, removed: boolean) { // Watchpack passes paths either with no leading './' - e.g. `src/Foo.stories.js`, // or with a leading `../` (etc), e.g. `../src/Foo.stories.js`. // We want to deal in importPaths relative to the working dir, or absolute paths. @@ -92,7 +93,7 @@ export function watchStorySpecifiers( } } - wp.on('change', async (filePath: Path, mtime: Date, explanation: string) => { + wp.on('change', async (filePath: Store_Path, mtime: Date, explanation: string) => { // When a file is renamed (including being moved out of the watched dir) // we see first an event with explanation=rename and no mtime for the old name. // then an event with explanation=rename with an mtime for the new name. @@ -102,7 +103,7 @@ export function watchStorySpecifiers( const removed = !mtime; await onChangeOrRemove(filePath, removed); }); - wp.on('remove', async (filePath: Path, explanation: string) => { + wp.on('remove', async (filePath: Store_Path, explanation: string) => { await onChangeOrRemove(filePath, true); }); diff --git a/code/lib/preview-web/src/Preview.tsx b/code/lib/preview-web/src/Preview.tsx index b4c9f40d8a25..ec2453c90602 100644 --- a/code/lib/preview-web/src/Preview.tsx +++ b/code/lib/preview-web/src/Preview.tsx @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import { dedent } from 'ts-dedent'; import global from 'global'; import { SynchronousPromise } from 'synchronous-promise'; @@ -18,13 +19,13 @@ import { Channel } from '@storybook/channels'; import { addons } from '@storybook/addons'; import { AnyFramework, StoryId, ProjectAnnotations, Args, Globals } from '@storybook/types'; import type { - ModuleImportFn, - Story, - StoryIndex, - PromiseLike, - WebProjectAnnotations, - RenderToDOM, -} from '@storybook/store'; + Store_ModuleImportFn, + Store_Story, + Store_StoryIndex, + Store_PromiseLike, + Store_WebProjectAnnotations, + Store_RenderToDOM, +} from '@storybook/types'; import { StoryStore } from '@storybook/store'; import { StoryRender } from './render/StoryRender'; @@ -42,11 +43,11 @@ export class Preview { storyStore: StoryStore; - getStoryIndex?: () => StoryIndex; + getStoryIndex?: () => Store_StoryIndex; - importFn?: ModuleImportFn; + importFn?: Store_ModuleImportFn; - renderToDOM?: RenderToDOM; + renderToDOM?: Store_RenderToDOM; storyRenders: StoryRender[] = []; @@ -74,9 +75,9 @@ export class Preview { }: { // In the case of the v6 store, we can only get the index from the facade *after* // getProjectAnnotations has been run, thus this slightly awkward approach - getStoryIndex?: () => StoryIndex; - importFn: ModuleImportFn; - getProjectAnnotations: () => MaybePromise>; + getStoryIndex?: () => Store_StoryIndex; + importFn: Store_ModuleImportFn; + getProjectAnnotations: () => MaybePromise>; }) { // We save these two on initialization in case `getProjectAnnotations` errors, // in which case we may need them later when we recover. @@ -101,8 +102,8 @@ export class Preview { } getProjectAnnotationsOrRenderError( - getProjectAnnotations: () => MaybePromise> - ): PromiseLike> { + getProjectAnnotations: () => MaybePromise> + ): Store_PromiseLike> { return SynchronousPromise.resolve() .then(getProjectAnnotations) .then((projectAnnotations) => { @@ -127,12 +128,12 @@ export class Preview { } // If initialization gets as far as project annotations, this function runs. - initializeWithProjectAnnotations(projectAnnotations: WebProjectAnnotations) { + initializeWithProjectAnnotations(projectAnnotations: Store_WebProjectAnnotations) { this.storyStore.setProjectAnnotations(projectAnnotations); this.setInitialGlobals(); - let storyIndexPromise: PromiseLike; + let storyIndexPromise: Store_PromiseLike; if (global.FEATURES?.storyStoreV7) { storyIndexPromise = this.getStoryIndexFromServer(); } else { @@ -143,7 +144,7 @@ export class Preview { } return storyIndexPromise - .then((storyIndex: StoryIndex) => this.initializeWithStoryIndex(storyIndex)) + .then((storyIndex: Store_StoryIndex) => this.initializeWithStoryIndex(storyIndex)) .catch((err) => { this.renderPreviewEntryError('Error loading story index:', err); throw err; @@ -165,13 +166,13 @@ export class Preview { async getStoryIndexFromServer() { const result = await fetch(STORY_INDEX_PATH); - if (result.status === 200) return result.json() as StoryIndex; + if (result.status === 200) return result.json() as Store_StoryIndex; throw new Error(await result.text()); } // If initialization gets as far as the story index, this function runs. - initializeWithStoryIndex(storyIndex: StoryIndex): PromiseLike { + initializeWithStoryIndex(storyIndex: Store_StoryIndex): PromiseLike { if (!this.importFn) throw new Error(`Cannot call initializeWithStoryIndex before initialization`); @@ -232,8 +233,8 @@ export class Preview { importFn, storyIndex, }: { - importFn?: ModuleImportFn; - storyIndex?: StoryIndex; + importFn?: Store_ModuleImportFn; + storyIndex?: Store_StoryIndex; }) { await this.storyStore.onStoriesChanged({ importFn, storyIndex }); } @@ -300,7 +301,7 @@ export class Preview { // main to be consistent with the previous behaviour. In the future, // we will change it to go ahead and load the story, which will end up being // "instant", although async. - renderStoryToElement(story: Story, element: HTMLElement) { + renderStoryToElement(story: Store_Story, element: HTMLElement) { if (!this.renderToDOM) throw new Error(`Cannot call renderStoryToElement before initialization`); diff --git a/code/lib/preview-web/src/PreviewWeb.tsx b/code/lib/preview-web/src/PreviewWeb.tsx index 6ecc261e3acf..2703218724b9 100644 --- a/code/lib/preview-web/src/PreviewWeb.tsx +++ b/code/lib/preview-web/src/PreviewWeb.tsx @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import { dedent } from 'ts-dedent'; import global from 'global'; import { @@ -27,13 +28,12 @@ import { ViewMode, } from '@storybook/types'; import type { - ModuleImportFn, - Selection, - StorySpecifier, - StoryIndex, - PromiseLike, - WebProjectAnnotations, -} from '@storybook/store'; + Store_ModuleImportFn, + Store_Selection, + Store_StorySpecifier, + Store_StoryIndex, + Store_WebProjectAnnotations, +} from '@storybook/types'; import { MaybePromise, Preview } from './Preview'; @@ -69,7 +69,7 @@ export class PreviewWeb extends Preview; @@ -90,7 +90,7 @@ export class PreviewWeb extends Preview) { + initializeWithProjectAnnotations(projectAnnotations: Store_WebProjectAnnotations) { return super .initializeWithProjectAnnotations(projectAnnotations) .then(() => this.setInitialGlobals()); @@ -108,7 +108,7 @@ export class PreviewWeb extends Preview { + initializeWithStoryIndex(storyIndex: Store_StoryIndex): PromiseLike { return super.initializeWithStoryIndex(storyIndex).then(() => { if (!global.FEATURES?.storyStoreV7) { this.channel.emit(SET_STORIES, this.storyStore.getSetStoriesPayload()); @@ -185,8 +185,8 @@ export class PreviewWeb extends Preview extends Preview { const { search = '' } = document.location; @@ -37,7 +36,7 @@ const getQueryString = ({ ); }; -export const setPath = (selection?: Selection) => { +export const setPath = (selection?: Store_Selection) => { if (!selection) return; const query = getQueryString({ selection }); const { hash = '' } = document.location; @@ -65,7 +64,7 @@ const getFirstString = (v: ValueOf): string | void => { return undefined; }; -export const getSelectionSpecifierFromPath: () => SelectionSpecifier | null = () => { +export const getSelectionSpecifierFromPath: () => Store_SelectionSpecifier | null = () => { const query = qs.parse(document.location.search, { ignoreQueryPrefix: true }); const args = typeof query.args === 'string' ? parseArgsParam(query.args) : undefined; const globals = typeof query.globals === 'string' ? parseArgsParam(query.globals) : undefined; @@ -86,15 +85,15 @@ export const getSelectionSpecifierFromPath: () => SelectionSpecifier | null = () }; export class UrlStore { - selectionSpecifier: SelectionSpecifier | null; + selectionSpecifier: Store_SelectionSpecifier | null; - selection?: Selection; + selection?: Store_Selection; constructor() { this.selectionSpecifier = getSelectionSpecifierFromPath(); } - setSelection(selection: Selection) { + setSelection(selection: Store_Selection) { this.selection = selection; setPath(this.selection); } diff --git a/code/lib/preview-web/src/WebView.ts b/code/lib/preview-web/src/WebView.ts index 19608a653117..66d28b046d22 100644 --- a/code/lib/preview-web/src/WebView.ts +++ b/code/lib/preview-web/src/WebView.ts @@ -1,10 +1,11 @@ +/* eslint-disable camelcase */ import global from 'global'; import { logger } from '@storybook/client-logger'; import AnsiToHtml from 'ansi-to-html'; import { dedent } from 'ts-dedent'; import qs from 'qs'; -import type { Story } from '@storybook/store'; +import type { Store_Story } from '@storybook/types'; const { document } = global; @@ -64,7 +65,7 @@ export class WebView { } // Get ready to render a story, returning the element to render to - prepareForStory(story: Story) { + prepareForStory(story: Store_Story) { this.showStory(); this.applyLayout(story.parameters.layout); diff --git a/code/lib/preview-web/src/docs-context/DocsContext.ts b/code/lib/preview-web/src/docs-context/DocsContext.ts index 2f1aa015567d..4c3b6f76a856 100644 --- a/code/lib/preview-web/src/docs-context/DocsContext.ts +++ b/code/lib/preview-web/src/docs-context/DocsContext.ts @@ -1,26 +1,36 @@ -import type { AnyFramework, StoryContextForLoaders, StoryId, StoryName } from '@storybook/types'; -import type { CSFFile, ModuleExport, ModuleExports, Story, StoryStore } from '@storybook/store'; +/* eslint-disable camelcase */ +import type { + Store_CSFFile, + Store_ModuleExport, + Store_ModuleExports, + Store_Story, + AnyFramework, + StoryContextForLoaders, + StoryId, + StoryName, +} from '@storybook/types'; +import type { StoryStore } from '@storybook/store'; import type { Channel } from '@storybook/channels'; import { DocsContextProps } from './DocsContextProps'; export class DocsContext implements DocsContextProps { - private componentStoriesValue: Story[]; + private componentStoriesValue: Store_Story[]; - private storyIdToCSFFile: Map>; + private storyIdToCSFFile: Map>; - private exportToStoryId: Map; + private exportToStoryId: Map; private nameToStoryId: Map; - private primaryStory?: Story; + private primaryStory?: Store_Story; constructor( public channel: Channel, protected store: StoryStore, public renderStoryToElement: DocsContextProps['renderStoryToElement'], /** The CSF files known (via the index) to be refererenced by this docs file */ - csfFiles: CSFFile[], + csfFiles: Store_CSFFile[], componentStoriesFromAllCsfFiles = true ) { this.storyIdToCSFFile = new Map(); @@ -36,7 +46,7 @@ export class DocsContext implements DocsContext // This docs entry references this CSF file and can syncronously load the stories, as well // as reference them by module export. If the CSF is part of the "component" stories, they // can also be referenced by name and are in the componentStories list. - referenceCSFFile(csfFile: CSFFile, addToComponentStories: boolean) { + referenceCSFFile(csfFile: Store_CSFFile, addToComponentStories: boolean) { Object.values(csfFile.stories).forEach((annotation) => { this.storyIdToCSFFile.set(annotation.id, csfFile); this.exportToStoryId.set(annotation.moduleExport, annotation.id); @@ -50,11 +60,11 @@ export class DocsContext implements DocsContext }); } - setMeta(metaExports: ModuleExports) { + setMeta(metaExports: Store_ModuleExports) { // Do nothing (this is really only used by external docs) } - storyIdByModuleExport(storyExport: ModuleExport, metaExports?: ModuleExports) { + storyIdByModuleExport(storyExport: Store_ModuleExport, metaExports?: Store_ModuleExports) { const storyId = this.exportToStoryId.get(storyExport); if (storyId) return storyId; @@ -87,7 +97,7 @@ export class DocsContext implements DocsContext return this.store.storyFromCSFFile({ storyId, csfFile }); }; - getStoryContext = (story: Story) => { + getStoryContext = (story: Store_Story) => { return { ...this.store.getStoryContext(story), viewMode: 'docs', diff --git a/code/lib/preview-web/src/docs-context/DocsContextProps.ts b/code/lib/preview-web/src/docs-context/DocsContextProps.ts index 979810bc6aca..2509d55dc1c7 100644 --- a/code/lib/preview-web/src/docs-context/DocsContextProps.ts +++ b/code/lib/preview-web/src/docs-context/DocsContextProps.ts @@ -1,5 +1,13 @@ -import type { StoryId, StoryName, AnyFramework, StoryContextForLoaders } from '@storybook/types'; -import type { ModuleExport, ModuleExports, Story } from '@storybook/store'; +/* eslint-disable camelcase */ +import type { + StoryId, + StoryName, + AnyFramework, + StoryContextForLoaders, + Store_ModuleExport, + Store_ModuleExports, + Store_Story, +} from '@storybook/types'; import type { Channel } from '@storybook/channels'; export interface DocsContextProps { @@ -7,13 +15,16 @@ export interface DocsContextProps` block. */ - setMeta: (metaExports: ModuleExports) => void; + setMeta: (metaExports: Store_ModuleExports) => void; /** * Find a story's id from the direct export from the CSF file. * This is primarily used by the ` block. */ - storyIdByModuleExport: (storyExport: ModuleExport, metaExports?: ModuleExports) => StoryId; + storyIdByModuleExport: ( + storyExport: Store_ModuleExport, + metaExports?: Store_ModuleExports + ) => StoryId; /** * Find a story's id from the name of the story. * This is primarily used by the ` block. @@ -24,25 +35,28 @@ export interface DocsContextProps Story; + storyById: (id?: StoryId) => Store_Story; /** * Syncronously find all stories of the component referenced by the CSF file. */ - componentStories: () => Story[]; + componentStories: () => Store_Story[]; /** * Get the story context of the referenced story. */ - getStoryContext: (story: Story) => StoryContextForLoaders; + getStoryContext: (story: Store_Story) => StoryContextForLoaders; /** * Asyncronously load an arbitrary story by id. */ - loadStory: (id: StoryId) => Promise>; + loadStory: (id: StoryId) => Promise>; /** * Render a story to a given HTML element and keep it up to date across context changes */ - renderStoryToElement: (story: Story, element: HTMLElement) => () => Promise; + renderStoryToElement: ( + story: Store_Story, + element: HTMLElement + ) => () => Promise; /** * Storybook channel -- use for low level event watching/emitting diff --git a/code/lib/preview-web/src/index.ts b/code/lib/preview-web/src/index.ts index a30759b8b555..b8d48f50d329 100644 --- a/code/lib/preview-web/src/index.ts +++ b/code/lib/preview-web/src/index.ts @@ -1,6 +1,7 @@ +/* eslint-disable camelcase */ // FIXME: breaks builder-vite, remove this in 7.0 export { composeConfigs } from '@storybook/store'; -export type { WebProjectAnnotations } from '@storybook/store'; +export type { Store_WebProjectAnnotations as WebProjectAnnotations } from '@storybook/types'; export { Preview } from './Preview'; export { PreviewWeb } from './PreviewWeb'; diff --git a/code/lib/preview-web/src/render/StandaloneDocsRender.ts b/code/lib/preview-web/src/render/StandaloneDocsRender.ts index 6f241fc6899c..b150a44a3159 100644 --- a/code/lib/preview-web/src/render/StandaloneDocsRender.ts +++ b/code/lib/preview-web/src/render/StandaloneDocsRender.ts @@ -1,6 +1,7 @@ /* eslint-disable camelcase */ import { AnyFramework, StoryId, Addon_IndexEntry } from '@storybook/types'; -import { CSFFile, ModuleExports, StoryStore } from '@storybook/store'; +import { StoryStore } from '@storybook/store'; +import type { Store_CSFFile, Store_ModuleExports } from '@storybook/types'; import type { Channel } from '@storybook/channels'; import { DOCS_RENDERED } from '@storybook/core-events'; @@ -23,7 +24,7 @@ export class StandaloneDocsRender implements Re public readonly id: StoryId; - private exports?: ModuleExports; + private exports?: Store_ModuleExports; public rerender?: () => Promise; @@ -35,7 +36,7 @@ export class StandaloneDocsRender implements Re public preparing = false; - private csfFiles?: CSFFile[]; + private csfFiles?: Store_CSFFile[]; constructor( protected channel: Channel, diff --git a/code/lib/preview-web/src/render/StoryRender.ts b/code/lib/preview-web/src/render/StoryRender.ts index 12aacb03aca8..acf932d1c510 100644 --- a/code/lib/preview-web/src/render/StoryRender.ts +++ b/code/lib/preview-web/src/render/StoryRender.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import global from 'global'; import { AnyFramework, @@ -5,14 +6,12 @@ import { ViewMode, StoryContextForLoaders, StoryContext, + Store_Story, + Store_RenderContext, + Store_RenderToDOM, + Store_TeardownRenderToDOM, } from '@storybook/types'; -import { - type Story, - type RenderContext, - StoryStore, - type RenderToDOM, - type TeardownRenderToDOM, -} from '@storybook/store'; +import { StoryStore } from '@storybook/store'; import { Channel } from '@storybook/channels'; import { logger } from '@storybook/client-logger'; import { @@ -44,14 +43,14 @@ function serializeError(error: any) { } export type RenderContextCallbacks = Pick< - RenderContext, + Store_RenderContext, 'showMain' | 'showError' | 'showException' >; export class StoryRender implements Render { public type: RenderType = 'story'; - public story?: Story; + public story?: Store_Story; public phase?: RenderPhase; @@ -63,18 +62,18 @@ export class StoryRender implements Render {}; + private teardownRender: Store_TeardownRenderToDOM = () => {}; public torndown = false; constructor( public channel: Channel, public store: StoryStore, - private renderToScreen: RenderToDOM, + private renderToScreen: Store_RenderToDOM, private callbacks: RenderContextCallbacks, public id: StoryId, public viewMode: ViewMode, - story?: Story + story?: Store_Story ) { this.abortController = new AbortController(); @@ -105,7 +104,7 @@ export class StoryRender implements Render); + this.store.cleanupStory(this.story as Store_Story); throw PREPARE_ABORTED; } } @@ -188,7 +187,7 @@ export class StoryRender implements Render = { + const renderContext: Store_RenderContext = { componentId, title, kind: title, diff --git a/code/lib/preview-web/src/render/TemplateDocsRender.ts b/code/lib/preview-web/src/render/TemplateDocsRender.ts index 34d2d6f9afe7..e095dd4e8670 100644 --- a/code/lib/preview-web/src/render/TemplateDocsRender.ts +++ b/code/lib/preview-web/src/render/TemplateDocsRender.ts @@ -1,8 +1,13 @@ /* eslint-disable camelcase */ -import { AnyFramework, StoryId } from '@storybook/types'; -import { type CSFFile, type Story, StoryStore } from '@storybook/store'; +import type { + AnyFramework, + StoryId, + Store_CSFFile, + Store_Story, + Addon_IndexEntry, +} from '@storybook/types'; +import { StoryStore } from '@storybook/store'; import type { Channel } from '@storybook/channels'; -import type { Addon_IndexEntry } from '@storybook/types'; import { DOCS_RENDERED } from '@storybook/core-events'; import { Render, RenderType, PREPARE_ABORTED } from './Render'; @@ -27,7 +32,7 @@ export class TemplateDocsRender implements Rend public readonly id: StoryId; - public story?: Story; + public story?: Store_Story; public rerender?: () => Promise; @@ -39,7 +44,7 @@ export class TemplateDocsRender implements Rend public preparing = false; - private csfFiles?: CSFFile[]; + private csfFiles?: Store_CSFFile[]; constructor( protected channel: Channel, diff --git a/code/lib/store/src/ArgsStore.ts b/code/lib/store/src/ArgsStore.ts index 7efed70a4494..821198fbee9c 100644 --- a/code/lib/store/src/ArgsStore.ts +++ b/code/lib/store/src/ArgsStore.ts @@ -1,6 +1,6 @@ -import type { StoryId, Args } from '@storybook/types'; +/* eslint-disable camelcase */ +import type { StoryId, Args, Store_Story } from '@storybook/types'; -import type { Story } from './types'; import { combineArgs, mapArgsToTypes, validateOptions, deepDiff, DEEPLY_EQUAL } from './args'; function deleteUndefined(obj: Record) { @@ -22,7 +22,7 @@ export class ArgsStore { return this.argsByStoryId[storyId]; } - setInitial(story: Story) { + setInitial(story: Store_Story) { if (!this.initialArgsByStoryId[story.id]) { this.initialArgsByStoryId[story.id] = story.initialArgs; this.argsByStoryId[story.id] = story.initialArgs; @@ -38,7 +38,7 @@ export class ArgsStore { } } - updateFromDelta(story: Story, delta: Args) { + updateFromDelta(story: Store_Story, delta: Args) { // Use the argType to ensure we setting a type with defined options to something outside of that const validatedDelta = validateOptions(delta, story.argTypes); @@ -48,7 +48,7 @@ export class ArgsStore { this.argsByStoryId[story.id] = combineArgs(this.argsByStoryId[story.id], validatedDelta); } - updateFromPersisted(story: Story, persisted: Args) { + updateFromPersisted(story: Store_Story, persisted: Args) { // Use the argType to ensure we aren't persisting the wrong type of value to the type. // For instance you could try and set a string-valued arg to a number by changing the URL const mappedPersisted = mapArgsToTypes(persisted, story.argTypes); diff --git a/code/lib/store/src/StoryIndexStore.ts b/code/lib/store/src/StoryIndexStore.ts index 8c3bb5cd083c..8977674b4f48 100644 --- a/code/lib/store/src/StoryIndexStore.ts +++ b/code/lib/store/src/StoryIndexStore.ts @@ -1,25 +1,29 @@ /* eslint-disable camelcase */ import { dedent } from 'ts-dedent'; -import type { StoryId, Addon_IndexEntry } from '@storybook/types'; +import type { + StoryId, + Addon_IndexEntry, + Store_StorySpecifier, + Store_StoryIndex, + Store_Path, +} from '@storybook/types'; import memoize from 'memoizerific'; -import type { StorySpecifier, StoryIndex, Path } from './types'; - -const getImportPathMap = memoize(1)((entries: StoryIndex['entries']) => +const getImportPathMap = memoize(1)((entries: Store_StoryIndex['entries']) => Object.values(entries).reduce((acc, entry) => { acc[entry.importPath] = acc[entry.importPath] || entry; return acc; - }, {} as Record) + }, {} as Record) ); export class StoryIndexStore { - entries: StoryIndex['entries']; + entries: Store_StoryIndex['entries']; - constructor({ entries }: StoryIndex = { v: 4, entries: {} }) { + constructor({ entries }: Store_StoryIndex = { v: 4, entries: {} }) { this.entries = entries; } - entryFromSpecifier(specifier: StorySpecifier) { + entryFromSpecifier(specifier: Store_StorySpecifier) { const entries = Object.values(this.entries); if (specifier === '*') { // '*' means select the first entry. If there is none, we have no selection. @@ -53,7 +57,7 @@ export class StoryIndexStore { return storyEntry; } - importPathToEntry(importPath: Path): Addon_IndexEntry { + importPathToEntry(importPath: Store_Path): Addon_IndexEntry { return getImportPathMap(this.entries)[importPath]; } } diff --git a/code/lib/store/src/StoryStore.ts b/code/lib/store/src/StoryStore.ts index bfca7ec9a733..4f20c3c80eca 100644 --- a/code/lib/store/src/StoryStore.ts +++ b/code/lib/store/src/StoryStore.ts @@ -10,6 +10,18 @@ import type { StoryContextForEnhancers, StoryContext, Addon_IndexEntry, + Store_CSFFile, + Store_ModuleImportFn, + Store_Story, + Store_NormalizedProjectAnnotations, + Store_Path, + Store_ExtractOptions, + Store_BoundStory, + Store_PromiseLike, + Store_StoryIndex, + Store_V2CompatIndexEntry, + Store_StoryIndexV3, + Store_ModuleExports, } from '@storybook/types'; import mapValues from 'lodash/mapValues'; import pick from 'lodash/pick'; @@ -19,20 +31,6 @@ import { StoryIndexStore } from './StoryIndexStore'; import { ArgsStore } from './ArgsStore'; import { GlobalsStore } from './GlobalsStore'; import { processCSFFile, prepareStory, normalizeProjectAnnotations } from './csf'; -import type { - CSFFile, - ModuleImportFn, - Story, - NormalizedProjectAnnotations, - Path, - ExtractOptions, - BoundStory, - PromiseLike, - StoryIndex, - V2CompatIndexEntry, - StoryIndexV3, - ModuleExports, -} from './types'; import { HooksContext } from './hooks'; // TODO -- what are reasonable values for these? @@ -42,9 +40,9 @@ const STORY_CACHE_SIZE = 10000; export class StoryStore { storyIndex?: StoryIndexStore; - importFn?: ModuleImportFn; + importFn?: Store_ModuleImportFn; - projectAnnotations?: NormalizedProjectAnnotations; + projectAnnotations?: Store_NormalizedProjectAnnotations; globals?: GlobalsStore; @@ -52,7 +50,7 @@ export class StoryStore { hooks: Record>; - cachedCSFFiles?: Record>; + cachedCSFFiles?: Record>; processCSFFileWithCache: typeof processCSFFile; @@ -96,10 +94,10 @@ export class StoryStore { importFn, cache = false, }: { - storyIndex?: StoryIndex; - importFn: ModuleImportFn; + storyIndex?: Store_StoryIndex; + importFn: Store_ModuleImportFn; cache?: boolean; - }): PromiseLike { + }): Store_PromiseLike { this.storyIndex = new StoryIndexStore(storyIndex); this.importFn = importFn; @@ -117,8 +115,8 @@ export class StoryStore { importFn, storyIndex, }: { - importFn?: ModuleImportFn; - storyIndex?: StoryIndex; + importFn?: Store_ModuleImportFn; + storyIndex?: Store_StoryIndex; }) { await this.initializationPromise; @@ -136,7 +134,7 @@ export class StoryStore { } // To load a single CSF file to service a story we need to look up the importPath in the index - loadCSFFileByStoryId(storyId: StoryId): PromiseLike> { + loadCSFFileByStoryId(storyId: StoryId): Store_PromiseLike> { if (!this.storyIndex || !this.importFn) throw new Error(`loadCSFFileByStoryId called before initialization`); @@ -147,10 +145,10 @@ export class StoryStore { ); } - loadAllCSFFiles(): PromiseLike['cachedCSFFiles']> { + loadAllCSFFiles(): Store_PromiseLike['cachedCSFFiles']> { if (!this.storyIndex) throw new Error(`loadAllCSFFiles called before initialization`); - const importPaths: Record = {}; + const importPaths: Record = {}; Object.entries(this.storyIndex.entries).forEach(([storyId, { importPath }]) => { importPaths[importPath] = storyId; }); @@ -166,11 +164,11 @@ export class StoryStore { list.reduce((acc, { importPath, csfFile }) => { acc[importPath] = csfFile; return acc; - }, {} as Record>) + }, {} as Record>) ); } - cacheAllCSFFiles(): PromiseLike { + cacheAllCSFFiles(): Store_PromiseLike { return this.initializationPromise.then(() => this.loadAllCSFFiles().then((csfFiles) => { this.cachedCSFFiles = csfFiles; @@ -179,7 +177,7 @@ export class StoryStore { } // Load the CSF file for a story and prepare the story from it and the project annotations. - async loadStory({ storyId }: { storyId: StoryId }): Promise> { + async loadStory({ storyId }: { storyId: StoryId }): Promise> { await this.initializationPromise; const csfFile = await this.loadCSFFileByStoryId(storyId); return this.storyFromCSFFile({ storyId, csfFile }); @@ -192,8 +190,8 @@ export class StoryStore { csfFile, }: { storyId: StoryId; - csfFile: CSFFile; - }): Story { + csfFile: Store_CSFFile; + }): Store_Story { if (!this.projectAnnotations) throw new Error(`storyFromCSFFile called before initialization`); const storyAnnotations = csfFile.stories[storyId]; @@ -213,7 +211,11 @@ export class StoryStore { } // If we have a CSF file we can get all the stories from it synchronously - componentStoriesFromCSFFile({ csfFile }: { csfFile: CSFFile }): Story[] { + componentStoriesFromCSFFile({ + csfFile, + }: { + csfFile: Store_CSFFile; + }): Store_Story[] { if (!this.storyIndex) throw new Error(`componentStoriesFromCSFFile called before initialization`); @@ -236,14 +238,16 @@ export class StoryStore { const firstStoryEntry = storyIndex.importPathToEntry(storyImportPath); return this.loadCSFFileByStoryId(firstStoryEntry.id); }), - ])) as [ModuleExports, ...CSFFile[]]; + ])) as [Store_ModuleExports, ...Store_CSFFile[]]; return { entryExports, csfFiles }; } // A prepared story does not include args, globals or hooks. These are stored in the story store // and updated separtely to the (immutable) story. - getStoryContext(story: Story): Omit, 'viewMode'> { + getStoryContext( + story: Store_Story + ): Omit, 'viewMode'> { if (!this.globals) throw new Error(`getStoryContext called before initialization`); return { @@ -254,12 +258,12 @@ export class StoryStore { }; } - cleanupStory(story: Story): void { + cleanupStory(story: Store_Story): void { this.hooks[story.id].clean(); } extract( - options: ExtractOptions = { includeDocsOnly: false } + options: Store_ExtractOptions = { includeDocsOnly: false } ): Record> { if (!this.storyIndex) throw new Error(`extract called before initialization`); @@ -322,14 +326,14 @@ export class StoryStore { // NOTE: this is legacy `stories.json` data for the `extract` script. // It is used to allow v7 Storybooks to be composed in v6 Storybooks, which expect a // `stories.json` file with legacy fields (`kind` etc). - getStoriesJsonData = (): StoryIndexV3 => { + getStoriesJsonData = (): Store_StoryIndexV3 => { const { storyIndex } = this; if (!storyIndex) throw new Error(`getStoriesJsonData called before initialization`); const value = this.getSetStoriesPayload(); const allowedParameters = ['fileName', 'docsOnly', 'framework', '__id', '__isArgsStory']; - const stories: Record = mapValues(value.stories, (story) => { + const stories: Record = mapValues(value.stories, (story) => { const { importPath } = storyIndex.entries[story.id]; return { ...pick(story, ['id', 'name', 'title']), @@ -352,13 +356,13 @@ export class StoryStore { }; }; - raw(): BoundStory[] { + raw(): Store_BoundStory[] { return Object.values(this.extract()) .map(({ id }: { id: StoryId }) => this.fromId(id)) - .filter(Boolean) as BoundStory[]; + .filter(Boolean) as Store_BoundStory[]; } - fromId(storyId: StoryId): BoundStory | null { + fromId(storyId: StoryId): Store_BoundStory | null { if (!this.storyIndex) throw new Error(`fromId called before initialization`); if (!this.cachedCSFFiles) diff --git a/code/lib/store/src/csf/composeConfigs.ts b/code/lib/store/src/csf/composeConfigs.ts index 9b231d660f7d..ef622603919e 100644 --- a/code/lib/store/src/csf/composeConfigs.ts +++ b/code/lib/store/src/csf/composeConfigs.ts @@ -1,40 +1,44 @@ -import type { AnyFramework } from '@storybook/types'; +/* eslint-disable camelcase */ +import type { + AnyFramework, + Store_ModuleExports, + Store_WebProjectAnnotations, +} from '@storybook/types'; -import type { ModuleExports, WebProjectAnnotations } from '../types'; import { combineParameters } from '../parameters'; import { composeStepRunners } from './stepRunners'; export function getField( - moduleExportList: ModuleExports[], + moduleExportList: Store_ModuleExports[], field: string ): TFieldType | TFieldType[] { return moduleExportList.map((xs) => xs[field]).filter(Boolean); } export function getArrayField( - moduleExportList: ModuleExports[], + moduleExportList: Store_ModuleExports[], field: string ): TFieldType[] { return getField(moduleExportList, field).reduce((a: any, b: any) => [...a, ...b], []); } export function getObjectField>( - moduleExportList: ModuleExports[], + moduleExportList: Store_ModuleExports[], field: string ): TFieldType { return Object.assign({}, ...getField(moduleExportList, field)); } export function getSingletonField( - moduleExportList: ModuleExports[], + moduleExportList: Store_ModuleExports[], field: string ): TFieldType { return getField(moduleExportList, field).pop(); } export function composeConfigs( - moduleExportList: ModuleExports[] -): WebProjectAnnotations { + moduleExportList: Store_ModuleExports[] +): Store_WebProjectAnnotations { const allArgTypeEnhancers = getArrayField(moduleExportList, 'argTypesEnhancers'); const stepRunners = getField(moduleExportList, 'runStep'); diff --git a/code/lib/store/src/csf/normalizeComponentAnnotations.ts b/code/lib/store/src/csf/normalizeComponentAnnotations.ts index f20212d5cef8..f889664d9b0a 100644 --- a/code/lib/store/src/csf/normalizeComponentAnnotations.ts +++ b/code/lib/store/src/csf/normalizeComponentAnnotations.ts @@ -1,14 +1,18 @@ +/* eslint-disable camelcase */ import { sanitize } from '@storybook/csf'; -import type { AnyFramework } from '@storybook/types'; +import type { + AnyFramework, + Store_ModuleExports, + Store_NormalizedComponentAnnotations, +} from '@storybook/types'; -import type { ModuleExports, NormalizedComponentAnnotations } from '../types'; import { normalizeInputTypes } from './normalizeInputTypes'; export function normalizeComponentAnnotations( - defaultExport: ModuleExports['default'], + defaultExport: Store_ModuleExports['default'], title: string = defaultExport.title, importPath?: string -): NormalizedComponentAnnotations { +): Store_NormalizedComponentAnnotations { const { id, argTypes } = defaultExport; return { id: sanitize(id || title), diff --git a/code/lib/store/src/csf/normalizeProjectAnnotations.ts b/code/lib/store/src/csf/normalizeProjectAnnotations.ts index 91f486521cc5..40cf97b9e2b3 100644 --- a/code/lib/store/src/csf/normalizeProjectAnnotations.ts +++ b/code/lib/store/src/csf/normalizeProjectAnnotations.ts @@ -1,8 +1,13 @@ -import type { AnyFramework, ArgTypes, ProjectAnnotations } from '@storybook/types'; +/* eslint-disable camelcase */ +import type { + AnyFramework, + ArgTypes, + ProjectAnnotations, + Store_NormalizedProjectAnnotations, +} from '@storybook/types'; import { inferArgTypes } from '../inferArgTypes'; import { inferControls } from '../inferControls'; -import type { NormalizedProjectAnnotations } from '../types'; import { normalizeInputTypes } from './normalizeInputTypes'; export function normalizeProjectAnnotations({ @@ -10,7 +15,7 @@ export function normalizeProjectAnnotations({ globalTypes, argTypesEnhancers, ...annotations -}: ProjectAnnotations): NormalizedProjectAnnotations { +}: ProjectAnnotations): Store_NormalizedProjectAnnotations { return { ...(argTypes && { argTypes: normalizeInputTypes(argTypes as ArgTypes) }), ...(globalTypes && { globalTypes: normalizeInputTypes(globalTypes) }), diff --git a/code/lib/store/src/csf/normalizeStory.ts b/code/lib/store/src/csf/normalizeStory.ts index 1938d38618dc..16db7b77617b 100644 --- a/code/lib/store/src/csf/normalizeStory.ts +++ b/code/lib/store/src/csf/normalizeStory.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import type { AnyFramework, LegacyStoryAnnotationsOrFn, @@ -5,12 +6,13 @@ import type { StoryAnnotations, StoryFn, ArgTypes, + Store_NormalizedComponentAnnotations, + Store_NormalizedStoryAnnotations, } from '@storybook/types'; import { storyNameFromExport, toId } from '@storybook/csf'; import { dedent } from 'ts-dedent'; import { logger } from '@storybook/client-logger'; import deprecate from 'util-deprecate'; -import type { NormalizedComponentAnnotations, NormalizedStoryAnnotations } from '../types'; import { normalizeInputTypes } from './normalizeInputTypes'; const deprecatedStoryAnnotation = dedent` @@ -25,8 +27,8 @@ const deprecatedStoryAnnotationWarning = deprecate(() => {}, deprecatedStoryAnno export function normalizeStory( key: StoryId, storyAnnotations: LegacyStoryAnnotationsOrFn, - meta: NormalizedComponentAnnotations -): NormalizedStoryAnnotations { + meta: Store_NormalizedComponentAnnotations +): Store_NormalizedStoryAnnotations { const storyObject: StoryAnnotations = storyAnnotations; const userStoryFn: StoryFn | null = typeof storyAnnotations === 'function' ? storyAnnotations : null; diff --git a/code/lib/store/src/csf/prepareStory.ts b/code/lib/store/src/csf/prepareStory.ts index 3d6b0db2f045..03f98a3946c9 100644 --- a/code/lib/store/src/csf/prepareStory.ts +++ b/code/lib/store/src/csf/prepareStory.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import { dedent } from 'ts-dedent'; import deprecate from 'util-deprecate'; import global from 'global'; @@ -15,15 +16,13 @@ import type { PlayFunctionContext, StepLabel, PlayFunction, + Store_NormalizedComponentAnnotations, + Store_Story, + Store_NormalizedStoryAnnotations, + Store_NormalizedProjectAnnotations, } from '@storybook/types'; import { includeConditionalArg } from '@storybook/csf'; -import type { - NormalizedComponentAnnotations, - Story, - NormalizedStoryAnnotations, - NormalizedProjectAnnotations, -} from '../types'; import { combineParameters } from '../parameters'; import { applyHooks } from '../hooks'; import { defaultDecorateStory } from '../decorators'; @@ -44,10 +43,10 @@ const argTypeDefaultValueWarning = deprecate( // Note that this story function is *stateless* in the sense that it does not track args or globals // Instead, it is expected these are tracked separately (if necessary) and are passed into each invocation. export function prepareStory( - storyAnnotations: NormalizedStoryAnnotations, - componentAnnotations: NormalizedComponentAnnotations, - projectAnnotations: NormalizedProjectAnnotations -): Story { + storyAnnotations: Store_NormalizedStoryAnnotations, + componentAnnotations: Store_NormalizedComponentAnnotations, + projectAnnotations: Store_NormalizedProjectAnnotations +): Store_Story { // NOTE: in the current implementation we are doing everything once, up front, rather than doing // anything at render time. The assumption is that as we don't load all the stories at once, this // will have a limited cost. If this proves misguided, we can refactor it. diff --git a/code/lib/store/src/csf/processCSFFile.ts b/code/lib/store/src/csf/processCSFFile.ts index 3ce8f794947f..269daf73f1fe 100644 --- a/code/lib/store/src/csf/processCSFFile.ts +++ b/code/lib/store/src/csf/processCSFFile.ts @@ -1,10 +1,18 @@ -import type { Parameters, AnyFramework, ComponentTitle } from '@storybook/types'; +/* eslint-disable camelcase */ +import type { + Parameters, + AnyFramework, + ComponentTitle, + Store_ModuleExports, + Store_CSFFile, + Store_NormalizedComponentAnnotations, + Store_Path, +} from '@storybook/types'; import { isExportStory } from '@storybook/csf'; import { logger } from '@storybook/client-logger'; import { normalizeStory } from './normalizeStory'; import { normalizeComponentAnnotations } from './normalizeComponentAnnotations'; -import type { ModuleExports, CSFFile, NormalizedComponentAnnotations, Path } from '../types'; const checkGlobals = (parameters: Parameters) => { const { globals, globalTypes } = parameters; @@ -33,17 +41,17 @@ const checkDisallowedParameters = (parameters?: Parameters) => { // Given the raw exports of a CSF file, check and normalize it. export function processCSFFile( - moduleExports: ModuleExports, - importPath: Path, + moduleExports: Store_ModuleExports, + importPath: Store_Path, title: ComponentTitle -): CSFFile { +): Store_CSFFile { const { default: defaultExport, __namedExportsOrder, ...namedExports } = moduleExports; - const meta: NormalizedComponentAnnotations = + const meta: Store_NormalizedComponentAnnotations = normalizeComponentAnnotations(defaultExport, title, importPath); checkDisallowedParameters(meta.parameters); - const csfFile: CSFFile = { meta, stories: {} }; + const csfFile: Store_CSFFile = { meta, stories: {} }; Object.keys(namedExports).forEach((key) => { if (isExportStory(key, meta)) { diff --git a/code/lib/store/src/index.ts b/code/lib/store/src/index.ts index f3bca023e57b..f6694ad9017b 100644 --- a/code/lib/store/src/index.ts +++ b/code/lib/store/src/index.ts @@ -4,8 +4,6 @@ export { filterArgTypes } from './filterArgTypes'; export type { PropDescriptor } from './filterArgTypes'; export { inferControls } from './inferControls'; -export * from './types'; - export * from './csf'; export * from './hooks'; export * from './decorators'; diff --git a/code/lib/store/src/sortStories.ts b/code/lib/store/src/sortStories.ts index 1f4c2c3d18dd..bf7752be0936 100644 --- a/code/lib/store/src/sortStories.ts +++ b/code/lib/store/src/sortStories.ts @@ -8,14 +8,15 @@ import type { Addon_StorySortParameterV7, Addon_StoryIndexEntry, Addon_IndexEntry, + Store_Story, + Store_Path, } from '@storybook/types'; import { storySort } from './storySort'; -import type { Story, Path } from './types'; const sortStoriesCommon = ( stories: Addon_IndexEntry[], storySortParameter: Addon_StorySortParameterV7, - fileNameOrder: Path[] + fileNameOrder: Store_Path[] ) => { if (storySortParameter) { let sortFn: Addon_Comparator; @@ -36,7 +37,7 @@ const sortStoriesCommon = ( export const sortStoriesV7 = ( stories: Addon_IndexEntry[], storySortParameter: Addon_StorySortParameterV7, - fileNameOrder: Path[] + fileNameOrder: Store_Path[] ) => { try { return sortStoriesCommon(stories, storySortParameter, fileNameOrder); @@ -59,9 +60,9 @@ const toIndexEntry = (story: any): Addon_StoryIndexEntry => { }; export const sortStoriesV6 = ( - stories: [string, Story, Parameters, Parameters][], + stories: [string, Store_Story, Parameters, Parameters][], storySortParameter: Addon_StorySortParameter, - fileNameOrder: Path[] + fileNameOrder: Store_Path[] ) => { if (storySortParameter && typeof storySortParameter === 'function') { stories.sort( diff --git a/code/lib/store/src/types.ts b/code/lib/store/src/types.ts deleted file mode 100644 index bc2160df636e..000000000000 --- a/code/lib/store/src/types.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* eslint-disable camelcase */ -import { SynchronousPromise } from 'synchronous-promise'; -import type { - DecoratorFunction, - Args, - StoryContextForEnhancers, - StoryId, - StoryName, - StoryIdentifier, - ViewMode, - LegacyStoryFn, - StoryContextForLoaders, - StoryContext, - ComponentTitle, - AnyFramework, - ProjectAnnotations, - ComponentAnnotations, - StoryAnnotations, - StoryFn, - StrictArgTypes, - StrictGlobalTypes, - ComponentId, - PartialStoryFn, - Parameters, - Addon_StoryIndexEntry, - Addon_IndexEntry, -} from '@storybook/types'; - -export type { StoryId, Parameters }; -export type Path = string; -export type ModuleExport = any; -export type ModuleExports = Record; -export type PromiseLike = Promise | SynchronousPromise; -export type ModuleImportFn = (path: Path) => PromiseLike; - -type MaybePromise = Promise | T; - -export type TeardownRenderToDOM = () => MaybePromise; -export type RenderToDOM = ( - context: RenderContext, - element: Element -) => MaybePromise; - -export type WebProjectAnnotations = - ProjectAnnotations & { - renderToDOM?: RenderToDOM; - }; - -export type NormalizedProjectAnnotations = - ProjectAnnotations & { - argTypes?: StrictArgTypes; - globalTypes?: StrictGlobalTypes; - }; - -export type NormalizedComponentAnnotations = - ComponentAnnotations & { - // Useful to guarantee that id & title exists - id: ComponentId; - title: ComponentTitle; - argTypes?: StrictArgTypes; - }; - -export type NormalizedStoryAnnotations = Omit< - StoryAnnotations, - 'storyName' | 'story' -> & { - moduleExport: ModuleExport; - // You cannot actually set id on story annotations, but we normalize it to be there for convience - id: StoryId; - argTypes?: StrictArgTypes; - name: StoryName; - userStoryFn?: StoryFn; -}; - -export type CSFFile = { - meta: NormalizedComponentAnnotations; - stories: Record>; -}; - -export type Story = - StoryContextForEnhancers & { - moduleExport: ModuleExport; - originalStoryFn: StoryFn; - undecoratedStoryFn: LegacyStoryFn; - unboundStoryFn: LegacyStoryFn; - applyLoaders: ( - context: StoryContextForLoaders - ) => Promise< - StoryContextForLoaders & { loaded: StoryContext['loaded'] } - >; - playFunction?: (context: StoryContext) => Promise | void; - }; - -export type BoundStory = Story & { - storyFn: PartialStoryFn; -}; - -export declare type RenderContext = - StoryIdentifier & { - showMain: () => void; - showError: (error: { title: string; description: string }) => void; - showException: (err: Error) => void; - forceRemount: boolean; - storyContext: StoryContext; - storyFn: PartialStoryFn; - unboundStoryFn: LegacyStoryFn; - }; - -export interface V2CompatIndexEntry extends Omit { - kind: Addon_StoryIndexEntry['title']; - story: Addon_StoryIndexEntry['name']; - parameters: Parameters; -} - -export interface StoryIndexV3 { - v: number; - stories: Record; -} - -export interface StoryIndex { - v: number; - entries: Record; -} - -export type StorySpecifier = StoryId | { name: StoryName; title: ComponentTitle } | '*'; - -export interface SelectionSpecifier { - storySpecifier: StorySpecifier; - viewMode: ViewMode; - args?: Args; - globals?: Args; -} - -export interface Selection { - storyId: StoryId; - viewMode: ViewMode; -} - -export type DecoratorApplicator = ( - storyFn: LegacyStoryFn, - decorators: DecoratorFunction[] -) => LegacyStoryFn; - -export interface StoriesSpecifier { - directory: string; - titlePrefix?: string; -} -export interface NormalizedStoriesSpecifier { - glob?: string; - specifier?: StoriesSpecifier; -} - -export type ExtractOptions = { - includeDocsOnly?: boolean; -}; diff --git a/code/lib/types/package.json b/code/lib/types/package.json index 42fe4ac708fb..c3dbfab69952 100644 --- a/code/lib/types/package.json +++ b/code/lib/types/package.json @@ -41,6 +41,7 @@ }, "devDependencies": { "@storybook/csf": "0.0.2--canary.49.258942b.0", + "synchronous-promise": "^2.0.15", "typescript": "~4.6.3" }, "publishConfig": { diff --git a/code/lib/types/src/index.ts b/code/lib/types/src/index.ts index afbed3b0bd91..9552d51620e3 100644 --- a/code/lib/types/src/index.ts +++ b/code/lib/types/src/index.ts @@ -1,2 +1,3 @@ export * from './modules/csf'; export * from './modules/addons'; +export * from './modules/store'; diff --git a/code/lib/types/src/modules/store.ts b/code/lib/types/src/modules/store.ts new file mode 100644 index 000000000000..ca347aa48af8 --- /dev/null +++ b/code/lib/types/src/modules/store.ts @@ -0,0 +1,154 @@ +/* eslint-disable camelcase */ +import type { SynchronousPromise } from 'synchronous-promise'; +import type { Addon_IndexEntry, Addon_StoryIndexEntry } from './addons'; +import type { + AnyFramework, + Args, + ComponentAnnotations, + ComponentId, + ComponentTitle, + DecoratorFunction, + LegacyStoryFn, + Parameters, + PartialStoryFn, + ProjectAnnotations, + StoryAnnotations, + StoryContext, + StoryContextForEnhancers, + StoryContextForLoaders, + StoryFn, + StoryId, + StoryIdentifier, + StoryName, + StrictArgTypes, + StrictGlobalTypes, + ViewMode, +} from './csf'; + +export type Store_Path = string; +export type Store_ModuleExport = any; +export type Store_ModuleExports = Record; +export type Store_PromiseLike = Promise | SynchronousPromise; +export type Store_ModuleImportFn = (path: Store_Path) => Store_PromiseLike; + +type Store_MaybePromise = Promise | T; + +export type Store_TeardownRenderToDOM = () => Store_MaybePromise; +export type Store_RenderToDOM = ( + context: Store_RenderContext, + element: Element +) => Store_MaybePromise; + +export type Store_WebProjectAnnotations = + ProjectAnnotations & { + renderToDOM?: Store_RenderToDOM; + }; + +export type Store_NormalizedProjectAnnotations = + ProjectAnnotations & { + argTypes?: StrictArgTypes; + globalTypes?: StrictGlobalTypes; + }; + +export type Store_NormalizedComponentAnnotations = + ComponentAnnotations & { + // Useful to guarantee that id & title exists + id: ComponentId; + title: ComponentTitle; + argTypes?: StrictArgTypes; + }; + +export type Store_NormalizedStoryAnnotations = Omit< + StoryAnnotations, + 'storyName' | 'story' +> & { + moduleExport: Store_ModuleExport; + // You cannot actually set id on story annotations, but we normalize it to be there for convience + id: StoryId; + argTypes?: StrictArgTypes; + name: StoryName; + userStoryFn?: StoryFn; +}; + +export type Store_CSFFile = { + meta: Store_NormalizedComponentAnnotations; + stories: Record>; +}; + +export type Store_Story = + StoryContextForEnhancers & { + moduleExport: Store_ModuleExport; + originalStoryFn: StoryFn; + undecoratedStoryFn: LegacyStoryFn; + unboundStoryFn: LegacyStoryFn; + applyLoaders: ( + context: StoryContextForLoaders + ) => Promise< + StoryContextForLoaders & { loaded: StoryContext['loaded'] } + >; + playFunction?: (context: StoryContext) => Promise | void; + }; + +export type Store_BoundStory = + Store_Story & { + storyFn: PartialStoryFn; + }; + +export declare type Store_RenderContext = + StoryIdentifier & { + showMain: () => void; + showError: (error: { title: string; description: string }) => void; + showException: (err: Error) => void; + forceRemount: boolean; + storyContext: StoryContext; + storyFn: PartialStoryFn; + unboundStoryFn: LegacyStoryFn; + }; + +export interface Store_V2CompatIndexEntry extends Omit { + kind: Addon_StoryIndexEntry['title']; + story: Addon_StoryIndexEntry['name']; + parameters: Parameters; +} + +export interface Store_StoryIndexV3 { + v: number; + stories: Record; +} + +export interface Store_StoryIndex { + v: number; + entries: Record; +} + +export type Store_StorySpecifier = StoryId | { name: StoryName; title: ComponentTitle } | '*'; + +export interface Store_SelectionSpecifier { + storySpecifier: Store_StorySpecifier; + viewMode: ViewMode; + args?: Args; + globals?: Args; +} + +export interface Store_Selection { + storyId: StoryId; + viewMode: ViewMode; +} + +export type Store_DecoratorApplicator = ( + storyFn: LegacyStoryFn, + decorators: DecoratorFunction[] +) => LegacyStoryFn; + +export interface Store_StoriesSpecifier { + directory: string; + titlePrefix?: string; +} +export interface Store_NormalizedStoriesSpecifier { + glob?: string; + specifier?: Store_StoriesSpecifier; +} + +export type Store_ExtractOptions = { + includeDocsOnly?: boolean; +}; From c871510869392234f9396a671b455fb8f4c2bcf9 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 21 Oct 2022 23:42:47 +0200 Subject: [PATCH 06/38] step 3 --- code/lib/client-api/src/index.ts | 2 - code/lib/core-client/src/preview/types.ts | 4 +- code/lib/types/src/index.ts | 1 + .../src/modules/client-api.ts} | 80 ++++++++----------- 4 files changed, 36 insertions(+), 51 deletions(-) rename code/lib/{client-api/src/types.ts => types/src/modules/client-api.ts} (55%) diff --git a/code/lib/client-api/src/index.ts b/code/lib/client-api/src/index.ts index d2e72f77f949..d0a4035540c2 100644 --- a/code/lib/client-api/src/index.ts +++ b/code/lib/client-api/src/index.ts @@ -13,8 +13,6 @@ import { export type { GetStorybookKind, GetStorybookStory } from './ClientApi'; -export * from './types'; - export * from './queryparams'; export * from '@storybook/store'; diff --git a/code/lib/core-client/src/preview/types.ts b/code/lib/core-client/src/preview/types.ts index 92edf829b348..b6b825b2d905 100644 --- a/code/lib/core-client/src/preview/types.ts +++ b/code/lib/core-client/src/preview/types.ts @@ -1,6 +1,6 @@ /* eslint-disable camelcase */ import { Store_RenderContext } from '@storybook/types'; -import type { RenderContextWithoutStoryContext } from '@storybook/client-api'; +import type { ClientAPI_RenderContextWithoutStoryContext } from '@storybook/types'; export interface PreviewError { message?: string; @@ -25,7 +25,7 @@ export interface RequireContext { export type LoaderFunction = () => void | any[]; export type Loadable = RequireContext | RequireContext[] | LoaderFunction; -export type { Store_RenderContext as RenderContext, RenderContextWithoutStoryContext }; +export type { Store_RenderContext as RenderContext, ClientAPI_RenderContextWithoutStoryContext }; // The function used by a framework to render story to the DOM export type RenderStoryFunction = (context: Store_RenderContext) => void; diff --git a/code/lib/types/src/index.ts b/code/lib/types/src/index.ts index 9552d51620e3..0254f20e5a0e 100644 --- a/code/lib/types/src/index.ts +++ b/code/lib/types/src/index.ts @@ -1,3 +1,4 @@ export * from './modules/csf'; export * from './modules/addons'; export * from './modules/store'; +export * from './modules/client-api'; diff --git a/code/lib/client-api/src/types.ts b/code/lib/types/src/modules/client-api.ts similarity index 55% rename from code/lib/client-api/src/types.ts rename to code/lib/types/src/modules/client-api.ts index 0b9519d07cd8..544d6c0645f9 100644 --- a/code/lib/client-api/src/types.ts +++ b/code/lib/types/src/modules/client-api.ts @@ -1,57 +1,43 @@ /* eslint-disable camelcase */ import type { Addon } from '@storybook/addons'; +import type { StoryStore, HooksContext } from '@storybook/store'; +import type { Addon_StoryApi } from './addons'; +import type { Store_RenderContext } from './store'; import type { - StoryId, - StoryName, - StoryKind, - ViewMode, - StoryFn, - Parameters, + AnyFramework, Args, ArgTypes, - Addon_StoryApi, DecoratorFunction, LoaderFunction, + Parameters, + ProjectAnnotations, StoryContext, - Store_RenderContext, - AnyFramework, + StoryFn, + StoryId, StoryIdentifier, - ProjectAnnotations, -} from '@storybook/types'; -import { StoryStore, HooksContext } from '@storybook/store'; - -export type { - SBType, - SBScalarType, - SBArrayType, - SBObjectType, - SBEnumType, - SBIntersectionType, - SBUnionType, - SBOtherType, -} from '@storybook/types'; - -// NOTE: these types are really just here for back-compat. Many of them don't have much meaning -// Remove in 7.0 - -export interface ErrorLike { + StoryKind, + StoryName, + ViewMode, +} from './csf'; + +export interface ClientAPI_ErrorLike { message: string; stack: string; } // Metadata about a story that can be set at various levels: global, for a kind, or for a single story. -export interface StoryMetadata { +export interface ClientAPI_StoryMetadata { parameters?: Parameters; decorators?: DecoratorFunction[]; loaders?: LoaderFunction[]; } -export type ArgTypesEnhancer = (context: StoryContext) => ArgTypes; -export type ArgsEnhancer = (context: StoryContext) => Args; +export type ClientAPI_ArgTypesEnhancer = (context: StoryContext) => ArgTypes; +export type ClientAPI_ArgsEnhancer = (context: StoryContext) => Args; type StorySpecifier = StoryId | { name: StoryName; kind: StoryKind } | '*'; -export interface StoreSelectionSpecifier { +export interface ClientAPI_StoreSelectionSpecifier { storySpecifier: StorySpecifier; viewMode: ViewMode; singleStory?: boolean; @@ -59,19 +45,19 @@ export interface StoreSelectionSpecifier { globals?: Args; } -export interface StoreSelection { +export interface ClientAPI_StoreSelection { storyId: StoryId; viewMode: ViewMode; } -export type AddStoryArgs = StoryIdentifier & { +export type ClientAPI_AddStoryArgs = StoryIdentifier & { storyFn: StoryFn; parameters?: Parameters; decorators?: DecoratorFunction[]; loaders?: LoaderFunction[]; }; -export type StoreItem = StoryIdentifier & { +export type ClientAPI_StoreItem = StoryIdentifier & { parameters: Parameters; getDecorated: () => StoryFn; getOriginal: () => StoryFn; @@ -85,41 +71,41 @@ export type StoreItem = StoryIdentifier & { argTypes: ArgTypes; }; -export type PublishedStoreItem = StoreItem & { +export type ClientAPI_PublishedStoreItem = ClientAPI_StoreItem & { globals: Args; }; -export interface StoreData { - [key: string]: StoreItem; +export interface ClientAPI_StoreData { + [key: string]: ClientAPI_StoreItem; } -export interface ClientApiParams { +export interface ClientAPI_ClientApiParams { storyStore: StoryStore; decorateStory?: ProjectAnnotations['applyDecorators']; noStoryModuleAddMethodHotDispose?: boolean; } -export type ClientApiReturnFn = ( +export type ClientAPI_ClientApiReturnFn = ( ...args: any[] ) => Addon_StoryApi; -export interface ClientApiAddon extends Addon { +export interface ClientAPI_ClientApiAddon extends Addon { apply: (a: Addon_StoryApi, b: any[]) => any; } -export interface ClientApiAddons { - [key: string]: ClientApiAddon; +export interface ClientAPI_ClientApiAddons { + [key: string]: ClientAPI_ClientApiAddon; } -export interface GetStorybookStory { +export interface ClientAPI_GetStorybookStory { name: string; render: StoryFn; } -export interface GetStorybookKind { +export interface ClientAPI_GetStorybookKind { kind: string; fileName: string; - stories: GetStorybookStory[]; + stories: ClientAPI_GetStorybookStory[]; } -export type RenderContextWithoutStoryContext = Omit; +export type ClientAPI_RenderContextWithoutStoryContext = Omit; From 2ff0db7759d9cba7c826102bd2c6ad330fce5029 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 21 Oct 2022 23:48:47 +0200 Subject: [PATCH 07/38] step 4 --- code/lib/core-client/src/index.ts | 1 - .../core-client/src/preview/executeLoadable.ts | 8 ++++---- code/lib/core-client/src/preview/start.ts | 2 +- code/lib/types/src/index.ts | 1 + .../src/modules/core-client.ts} | 17 ++++++++++------- 5 files changed, 16 insertions(+), 13 deletions(-) rename code/lib/{core-client/src/preview/types.ts => types/src/modules/core-client.ts} (61%) diff --git a/code/lib/core-client/src/index.ts b/code/lib/core-client/src/index.ts index 2e0141f9cf39..45799160cd5b 100644 --- a/code/lib/core-client/src/index.ts +++ b/code/lib/core-client/src/index.ts @@ -1,2 +1 @@ export * from './preview'; -export * from './preview/types'; diff --git a/code/lib/core-client/src/preview/executeLoadable.ts b/code/lib/core-client/src/preview/executeLoadable.ts index ebb0c594a3d8..0a767b6ecdce 100644 --- a/code/lib/core-client/src/preview/executeLoadable.ts +++ b/code/lib/core-client/src/preview/executeLoadable.ts @@ -4,7 +4,7 @@ import { logger } from '@storybook/client-logger'; import type { Store_Path, Store_ModuleExports } from '@storybook/types'; -import { Loadable, RequireContext, LoaderFunction } from './types'; +import { Loadable, CoreClient_RequireContext, CoreClient_LoaderFunction } from '@storybook/types'; /** * Executes a Loadable (function that returns exports or require context(s)) @@ -18,8 +18,8 @@ export function executeLoadable(loadable: Loadable) { // todo discuss / improve type check if (Array.isArray(loadable)) { reqs = loadable; - } else if ((loadable as RequireContext).keys) { - reqs = [loadable as RequireContext]; + } else if ((loadable as CoreClient_RequireContext).keys) { + reqs = [loadable as CoreClient_RequireContext]; } let exportsMap = new Map(); @@ -40,7 +40,7 @@ export function executeLoadable(loadable: Loadable) { }); }); } else { - const exported = (loadable as LoaderFunction)(); + const exported = (loadable as CoreClient_LoaderFunction)(); if (Array.isArray(exported) && exported.every((obj) => obj.default != null)) { exportsMap = new Map( exported.map((fileExports, index) => [`exports-map-${index}`, fileExports]) diff --git a/code/lib/core-client/src/preview/start.ts b/code/lib/core-client/src/preview/start.ts index 0033ad42a224..55d381adf386 100644 --- a/code/lib/core-client/src/preview/start.ts +++ b/code/lib/core-client/src/preview/start.ts @@ -12,7 +12,7 @@ import { createChannel } from '@storybook/channel-postmessage'; import { addons } from '@storybook/addons'; import { FORCE_RE_RENDER } from '@storybook/core-events'; -import { Loadable } from './types'; +import { Loadable } from '@storybook/types'; import { executeLoadableForChanges } from './executeLoadable'; const { window: globalWindow, FEATURES } = global; diff --git a/code/lib/types/src/index.ts b/code/lib/types/src/index.ts index 0254f20e5a0e..bd67cbe406c9 100644 --- a/code/lib/types/src/index.ts +++ b/code/lib/types/src/index.ts @@ -2,3 +2,4 @@ export * from './modules/csf'; export * from './modules/addons'; export * from './modules/store'; export * from './modules/client-api'; +export * from './modules/core-client'; diff --git a/code/lib/core-client/src/preview/types.ts b/code/lib/types/src/modules/core-client.ts similarity index 61% rename from code/lib/core-client/src/preview/types.ts rename to code/lib/types/src/modules/core-client.ts index b6b825b2d905..1f0b27416992 100644 --- a/code/lib/core-client/src/preview/types.ts +++ b/code/lib/types/src/modules/core-client.ts @@ -1,8 +1,8 @@ /* eslint-disable camelcase */ -import { Store_RenderContext } from '@storybook/types'; -import type { ClientAPI_RenderContextWithoutStoryContext } from '@storybook/types'; +import { Store_RenderContext } from './store'; +import type { ClientAPI_RenderContextWithoutStoryContext } from './client-api'; -export interface PreviewError { +export interface CoreClient_PreviewError { message?: string; stack?: string; } @@ -17,15 +17,18 @@ export interface PreviewError { // id: string; // } -export interface RequireContext { +export interface CoreClient_RequireContext { keys: () => string[]; (id: string): any; resolve(id: string): string; } -export type LoaderFunction = () => void | any[]; -export type Loadable = RequireContext | RequireContext[] | LoaderFunction; +export type CoreClient_LoaderFunction = () => void | any[]; +export type Loadable = + | CoreClient_RequireContext + | CoreClient_RequireContext[] + | CoreClient_LoaderFunction; export type { Store_RenderContext as RenderContext, ClientAPI_RenderContextWithoutStoryContext }; // The function used by a framework to render story to the DOM -export type RenderStoryFunction = (context: Store_RenderContext) => void; +export type CoreClient_RenderStoryFunction = (context: Store_RenderContext) => void; From 67581a33d96aff3683a93674f9f6f1f87ce3b51f Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sat, 22 Oct 2022 00:37:46 +0200 Subject: [PATCH 08/38] step 5 --- code/addons/docs/src/preset.ts | 12 ++++-- .../src/frameworks/configure.ts | 16 +++---- .../src/builders/build-storybook/index.ts | 2 +- .../src/builders/start-storybook/index.ts | 2 +- .../src/builders/utils/standalone-options.ts | 2 +- code/frameworks/angular/src/preset.ts | 2 +- .../server/framework-preset-angular-docs.ts | 2 +- .../server/framework-preset-angular-ivy.ts | 2 +- .../angular/src/server/preset-options.ts | 2 +- code/frameworks/ember/src/preset.ts | 2 +- .../src/server/framework-preset-ember-docs.ts | 2 +- code/frameworks/html-webpack5/src/preset.ts | 2 +- code/frameworks/preact-webpack5/src/preset.ts | 2 +- code/frameworks/react-webpack5/src/preset.ts | 2 +- code/frameworks/server-webpack5/src/preset.ts | 2 +- code/frameworks/svelte-webpack5/src/preset.ts | 2 +- code/frameworks/vue-vite/src/preset.ts | 2 +- code/frameworks/vue-webpack5/src/preset.ts | 2 +- code/frameworks/vue3-webpack5/src/preset.ts | 2 +- .../web-components-webpack5/src/preset.ts | 2 +- code/lib/api/src/index.tsx | 2 +- code/lib/api/src/lib/stories.ts | 2 +- code/lib/builder-manager/src/types.ts | 2 +- code/lib/builder-manager/src/utils/data.ts | 2 +- .../lib/builder-manager/src/utils/template.ts | 2 +- code/lib/builder-vite/package.json | 1 + code/lib/builder-vite/src/codegen-entries.ts | 2 +- .../src/codegen-importfn-script.ts | 2 +- code/lib/builder-vite/src/index.ts | 10 ++--- .../builder-vite/src/plugins/mdx-plugin.ts | 2 +- .../builder-vite/src/transform-iframe-html.ts | 2 +- .../src/types/extended-options.type.ts | 2 +- code/lib/builder-webpack5/src/index.ts | 2 +- .../src/presets/custom-webpack-preset.ts | 2 +- .../src/preview/base-webpack.config.ts | 2 +- .../src/preview/iframe-webpack.config.ts | 2 +- code/lib/cli/package.json | 1 + .../cli/src/js-package-manager/PackageJson.ts | 4 +- code/lib/cli/src/repro-generators/configs.ts | 2 +- code/lib/client-api/src/StoryStoreFacade.ts | 2 +- code/lib/core-common/src/index.ts | 2 - code/lib/core-common/src/presets.ts | 2 +- .../src/utils/get-framework-name.ts | 2 +- .../src/utils/get-storybook-info.ts | 2 +- .../src/utils/get-storybook-refs.ts | 2 +- .../src/utils/load-custom-presets.ts | 2 +- .../core-common/src/utils/load-main-config.ts | 2 +- .../src/utils/normalize-stories.ts | 14 ++++--- code/lib/core-server/src/build-dev.ts | 2 +- code/lib/core-server/src/build-static.ts | 2 +- code/lib/core-server/src/dev-server.ts | 11 ++--- .../core-server/src/presets/common-preset.ts | 13 +++--- .../src/utils/StoryIndexGenerator.ts | 22 ++++++---- .../lib/core-server/src/utils/get-builders.ts | 2 +- .../src/utils/output-startup-information.ts | 2 +- .../lib/core-server/src/utils/output-stats.ts | 2 +- .../core-server/src/utils/release-notes.ts | 2 +- .../core-server/src/utils/server-statics.ts | 2 +- .../lib/core-server/src/utils/stories-json.ts | 9 ++-- .../lib/core-server/src/utils/update-check.ts | 2 +- .../src/utils/watch-story-specifiers.ts | 11 +++-- code/lib/core-webpack/package.json | 1 + code/lib/core-webpack/src/to-importFn.ts | 9 ++-- .../core-webpack/src/to-require-context.ts | 7 ++-- code/lib/core-webpack/src/types.ts | 4 +- code/lib/docs-tools/src/hasDocsOrControls.ts | 2 +- code/lib/telemetry/src/get-monorepo-type.ts | 2 +- code/lib/telemetry/src/storybook-metadata.ts | 2 +- code/lib/telemetry/src/types.ts | 2 +- code/lib/types/package.json | 4 ++ code/lib/types/src/index.ts | 1 + .../src/modules/core-common.ts} | 42 +++++++++++-------- .../common/storybook-a11y-register.ts.mdx | 2 +- .../storybook-main-default-setup.ts.mdx | 2 +- ...book-main-disable-telemetry.main-ts.ts.mdx | 2 +- ...y-main-enable-crash-reports.main-ts.ts.mdx | 2 +- 76 files changed, 170 insertions(+), 136 deletions(-) rename code/lib/{core-common/src/types.ts => types/src/modules/core-common.ts} (90%) diff --git a/code/addons/docs/src/preset.ts b/code/addons/docs/src/preset.ts index 4783bebd44b1..6a14fa09a238 100644 --- a/code/addons/docs/src/preset.ts +++ b/code/addons/docs/src/preset.ts @@ -1,8 +1,14 @@ +/* eslint-disable camelcase */ import fs from 'fs-extra'; import remarkSlug from 'remark-slug'; import remarkExternalLinks from 'remark-external-links'; -import type { DocsOptions, IndexerOptions, Options, StoryIndexer } from '@storybook/core-common'; +import type { + DocsOptions, + CoreCommon_IndexerOptions, + Options, + CoreCommon_StoryIndexer, +} from '@storybook/types'; import { logger } from '@storybook/node-logger'; import { loadCsf } from '@storybook/csf-tools'; @@ -147,8 +153,8 @@ export async function webpack( return result; } -export const storyIndexers = async (indexers: StoryIndexer[] | null) => { - const mdxIndexer = async (fileName: string, opts: IndexerOptions) => { +export const storyIndexers = async (indexers: CoreCommon_StoryIndexer[] | null) => { + const mdxIndexer = async (fileName: string, opts: CoreCommon_IndexerOptions) => { let code = (await fs.readFile(fileName, 'utf-8')).toString(); // @ts-expect-error (Converted from ts-ignore) const { compile } = await import('@storybook/mdx2-csf'); diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/configure.ts b/code/addons/storyshots/storyshots-core/src/frameworks/configure.ts index 20eba79c775a..902186a6db10 100644 --- a/code/addons/storyshots/storyshots-core/src/frameworks/configure.ts +++ b/code/addons/storyshots/storyshots-core/src/frameworks/configure.ts @@ -1,16 +1,18 @@ +/* eslint-disable camelcase */ import fs from 'fs'; import path from 'path'; -import type { NormalizedStoriesSpecifier, StoriesEntry } from '@storybook/core-common'; -import { toRequireContext } from '@storybook/core-webpack'; -import { normalizeStoriesEntry } from '@storybook/core-common'; -import registerRequireContextHook from '@storybook/babel-plugin-require-context-hook/register'; -import global from 'global'; import type { + CoreCommon_NormalizedStoriesSpecifier, + CoreCommon_StoriesEntry, AnyFramework, ArgsEnhancer, ArgTypesEnhancer, DecoratorFunction, } from '@storybook/types'; +import { toRequireContext } from '@storybook/core-webpack'; +import { normalizeStoriesEntry } from '@storybook/core-common'; +import registerRequireContextHook from '@storybook/babel-plugin-require-context-hook/register'; +import global from 'global'; import { ClientApi } from './Loader'; import type { StoryshotsOptions } from '../api/StoryshotsOptions'; @@ -28,7 +30,7 @@ const isFile = (file: string): boolean => { interface Output { features?: Record; preview?: string; - stories?: NormalizedStoriesSpecifier[]; + stories?: CoreCommon_NormalizedStoriesSpecifier[]; requireContexts?: string[]; } @@ -64,7 +66,7 @@ function getConfigPathParts(input: string): Output { output.features = features; const workingDir = process.cwd(); - output.stories = stories.map((entry: StoriesEntry) => { + output.stories = stories.map((entry: CoreCommon_StoriesEntry) => { const specifier = normalizeStoriesEntry(entry, { configDir, workingDir, diff --git a/code/frameworks/angular/src/builders/build-storybook/index.ts b/code/frameworks/angular/src/builders/build-storybook/index.ts index e049c05b0407..609768f572aa 100644 --- a/code/frameworks/angular/src/builders/build-storybook/index.ts +++ b/code/frameworks/angular/src/builders/build-storybook/index.ts @@ -7,7 +7,7 @@ import { } from '@angular-devkit/architect'; import { JsonObject } from '@angular-devkit/core'; import { from, Observable, of, throwError } from 'rxjs'; -import type { CLIOptions } from '@storybook/core-common'; +import type { CLIOptions } from '@storybook/types'; import { catchError, map, mapTo, switchMap } from 'rxjs/operators'; import { sync as findUpSync } from 'find-up'; import { sync as readUpSync } from 'read-pkg-up'; diff --git a/code/frameworks/angular/src/builders/start-storybook/index.ts b/code/frameworks/angular/src/builders/start-storybook/index.ts index ba3e5ca66ee4..a0a81a66cd17 100644 --- a/code/frameworks/angular/src/builders/start-storybook/index.ts +++ b/code/frameworks/angular/src/builders/start-storybook/index.ts @@ -12,7 +12,7 @@ import { StylePreprocessorOptions, } from '@angular-devkit/build-angular'; import { from, Observable, of } from 'rxjs'; -import type { CLIOptions } from '@storybook/core-common'; +import type { CLIOptions } from '@storybook/types'; import { map, switchMap, mapTo } from 'rxjs/operators'; import { sync as findUpSync } from 'find-up'; import { sync as readUpSync } from 'read-pkg-up'; diff --git a/code/frameworks/angular/src/builders/utils/standalone-options.ts b/code/frameworks/angular/src/builders/utils/standalone-options.ts index 56cb457a2e68..82bffe20bbb2 100644 --- a/code/frameworks/angular/src/builders/utils/standalone-options.ts +++ b/code/frameworks/angular/src/builders/utils/standalone-options.ts @@ -1,5 +1,5 @@ import type { BuilderContext } from '@angular-devkit/architect'; -import type { LoadOptions, CLIOptions, BuilderOptions } from '@storybook/core-common'; +import type { LoadOptions, CLIOptions, BuilderOptions } from '@storybook/types'; export type StandaloneOptions = Partial< CLIOptions & diff --git a/code/frameworks/angular/src/preset.ts b/code/frameworks/angular/src/preset.ts index bd8cfb7c8fe0..72af38500d13 100644 --- a/code/frameworks/angular/src/preset.ts +++ b/code/frameworks/angular/src/preset.ts @@ -1,5 +1,5 @@ import path from 'path'; -import type { PresetProperty } from '@storybook/core-common'; +import type { PresetProperty } from '@storybook/types'; import { StorybookConfig } from './types'; export const addons: PresetProperty<'addons', StorybookConfig> = [ diff --git a/code/frameworks/angular/src/server/framework-preset-angular-docs.ts b/code/frameworks/angular/src/server/framework-preset-angular-docs.ts index 8b0c9a8975ea..f1574ba7263f 100644 --- a/code/frameworks/angular/src/server/framework-preset-angular-docs.ts +++ b/code/frameworks/angular/src/server/framework-preset-angular-docs.ts @@ -1,5 +1,5 @@ import path from 'path'; -import { StorybookConfig } from '@storybook/core-common'; +import { StorybookConfig } from '@storybook/types'; import { hasDocsOrControls } from '@storybook/docs-tools'; export const previewAnnotations: StorybookConfig['previewAnnotations'] = (entry = [], options) => { diff --git a/code/frameworks/angular/src/server/framework-preset-angular-ivy.ts b/code/frameworks/angular/src/server/framework-preset-angular-ivy.ts index 16c5d3391558..0d081556db34 100644 --- a/code/frameworks/angular/src/server/framework-preset-angular-ivy.ts +++ b/code/frameworks/angular/src/server/framework-preset-angular-ivy.ts @@ -1,6 +1,6 @@ import { Configuration } from 'webpack'; import * as path from 'path'; -import type { Preset } from '@storybook/core-common'; +import type { Preset } from '@storybook/types'; import type { PresetOptions } from './preset-options'; import type { AngularOptions } from '../types'; diff --git a/code/frameworks/angular/src/server/preset-options.ts b/code/frameworks/angular/src/server/preset-options.ts index 4beedb64edd8..25b123203b97 100644 --- a/code/frameworks/angular/src/server/preset-options.ts +++ b/code/frameworks/angular/src/server/preset-options.ts @@ -1,4 +1,4 @@ -import type { Options as CoreOptions } from '@storybook/core-common'; +import type { Options as CoreOptions } from '@storybook/types'; import { BuilderContext } from '@angular-devkit/architect'; import { ExtraEntryPoint, StylePreprocessorOptions } from '@angular-devkit/build-angular'; diff --git a/code/frameworks/ember/src/preset.ts b/code/frameworks/ember/src/preset.ts index 422f2a750758..770fd2e7ab83 100644 --- a/code/frameworks/ember/src/preset.ts +++ b/code/frameworks/ember/src/preset.ts @@ -1,5 +1,5 @@ import path from 'path'; -import type { PresetProperty } from '@storybook/core-common'; +import type { PresetProperty } from '@storybook/types'; import type { StorybookConfig } from './types'; export const addons: PresetProperty<'addons', StorybookConfig> = [ diff --git a/code/frameworks/ember/src/server/framework-preset-ember-docs.ts b/code/frameworks/ember/src/server/framework-preset-ember-docs.ts index 2cdcc56e7cb8..f6dd860c2f9f 100644 --- a/code/frameworks/ember/src/server/framework-preset-ember-docs.ts +++ b/code/frameworks/ember/src/server/framework-preset-ember-docs.ts @@ -1,4 +1,4 @@ -import type { StorybookConfig } from '@storybook/core-common'; +import type { StorybookConfig } from '@storybook/types'; import { findDistEsm } from '@storybook/core-common'; import { hasDocsOrControls } from '@storybook/docs-tools'; diff --git a/code/frameworks/html-webpack5/src/preset.ts b/code/frameworks/html-webpack5/src/preset.ts index 8bec5e5d2428..dc5a83045290 100644 --- a/code/frameworks/html-webpack5/src/preset.ts +++ b/code/frameworks/html-webpack5/src/preset.ts @@ -1,5 +1,5 @@ import path from 'path'; -import type { PresetProperty } from '@storybook/core-common'; +import type { PresetProperty } from '@storybook/types'; import type { StorybookConfig } from './types'; export const addons: PresetProperty<'addons', StorybookConfig> = [ diff --git a/code/frameworks/preact-webpack5/src/preset.ts b/code/frameworks/preact-webpack5/src/preset.ts index 82aee136ba32..ce9204aeb106 100644 --- a/code/frameworks/preact-webpack5/src/preset.ts +++ b/code/frameworks/preact-webpack5/src/preset.ts @@ -1,5 +1,5 @@ import path from 'path'; -import type { PresetProperty } from '@storybook/core-common'; +import type { PresetProperty } from '@storybook/types'; import type { StorybookConfig } from './types'; export const addons: PresetProperty<'addons', StorybookConfig> = [ diff --git a/code/frameworks/react-webpack5/src/preset.ts b/code/frameworks/react-webpack5/src/preset.ts index b6eaf6a7f93f..cb777de87df1 100644 --- a/code/frameworks/react-webpack5/src/preset.ts +++ b/code/frameworks/react-webpack5/src/preset.ts @@ -1,7 +1,7 @@ /* eslint-disable no-param-reassign */ import path from 'path'; -import type { PresetProperty, Options } from '@storybook/core-common'; +import type { PresetProperty, Options } from '@storybook/types'; import type { FrameworkOptions, StorybookConfig } from './types'; export const addons: PresetProperty<'addons', StorybookConfig> = [ diff --git a/code/frameworks/server-webpack5/src/preset.ts b/code/frameworks/server-webpack5/src/preset.ts index d65800229c43..d8e973536f8a 100644 --- a/code/frameworks/server-webpack5/src/preset.ts +++ b/code/frameworks/server-webpack5/src/preset.ts @@ -1,5 +1,5 @@ import path from 'path'; -import type { PresetProperty } from '@storybook/core-common'; +import type { PresetProperty } from '@storybook/types'; import type { StorybookConfig } from './types'; export const addons: PresetProperty<'addons', StorybookConfig> = [ diff --git a/code/frameworks/svelte-webpack5/src/preset.ts b/code/frameworks/svelte-webpack5/src/preset.ts index 28a722442e99..4a4144d919b2 100644 --- a/code/frameworks/svelte-webpack5/src/preset.ts +++ b/code/frameworks/svelte-webpack5/src/preset.ts @@ -1,5 +1,5 @@ import path from 'path'; -import type { PresetProperty } from '@storybook/core-common'; +import type { PresetProperty } from '@storybook/types'; import type { StorybookConfig } from './types'; export const addons: PresetProperty<'addons', StorybookConfig> = [ diff --git a/code/frameworks/vue-vite/src/preset.ts b/code/frameworks/vue-vite/src/preset.ts index 1542d42930bd..c63136cd2085 100644 --- a/code/frameworks/vue-vite/src/preset.ts +++ b/code/frameworks/vue-vite/src/preset.ts @@ -1,5 +1,5 @@ import path from 'path'; -import type { PresetProperty } from '@storybook/core-common'; +import type { PresetProperty } from '@storybook/types'; import type { StorybookConfig } from '@storybook/builder-vite'; import { vueDocgen } from './plugins/vue-docgen'; diff --git a/code/frameworks/vue-webpack5/src/preset.ts b/code/frameworks/vue-webpack5/src/preset.ts index c813c89cff4b..dc5420f06f6d 100644 --- a/code/frameworks/vue-webpack5/src/preset.ts +++ b/code/frameworks/vue-webpack5/src/preset.ts @@ -1,5 +1,5 @@ import path from 'path'; -import type { PresetProperty } from '@storybook/core-common'; +import type { PresetProperty } from '@storybook/types'; import type { StorybookConfig } from './types'; export const addons: PresetProperty<'addons', StorybookConfig> = [ diff --git a/code/frameworks/vue3-webpack5/src/preset.ts b/code/frameworks/vue3-webpack5/src/preset.ts index 01edab6bf545..84e9626f89a8 100644 --- a/code/frameworks/vue3-webpack5/src/preset.ts +++ b/code/frameworks/vue3-webpack5/src/preset.ts @@ -1,5 +1,5 @@ import path from 'path'; -import type { PresetProperty } from '@storybook/core-common'; +import type { PresetProperty } from '@storybook/types'; import type { StorybookConfig } from './types'; export const addons: PresetProperty<'addons', StorybookConfig> = [ diff --git a/code/frameworks/web-components-webpack5/src/preset.ts b/code/frameworks/web-components-webpack5/src/preset.ts index 310c48ec7aec..cd7ad55e55fb 100644 --- a/code/frameworks/web-components-webpack5/src/preset.ts +++ b/code/frameworks/web-components-webpack5/src/preset.ts @@ -1,5 +1,5 @@ import path from 'path'; -import type { PresetProperty } from '@storybook/core-common'; +import type { PresetProperty } from '@storybook/types'; import type { StorybookConfig } from './types'; export const addons: PresetProperty<'addons', StorybookConfig> = [ diff --git a/code/lib/api/src/index.tsx b/code/lib/api/src/index.tsx index c8443c3cb5a3..8956c0ec79a0 100644 --- a/code/lib/api/src/index.tsx +++ b/code/lib/api/src/index.tsx @@ -21,7 +21,7 @@ import { } from '@storybook/core-events'; import type { RouterData } from '@storybook/router'; import type { Listener } from '@storybook/channels'; -import type { DocsOptions } from '@storybook/core-common'; +import type { DocsOptions } from '@storybook/types'; import { createContext } from './context'; import Store, { Options } from './store'; diff --git a/code/lib/api/src/lib/stories.ts b/code/lib/api/src/lib/stories.ts index a9284e6c54ff..b7a1823f4b6e 100644 --- a/code/lib/api/src/lib/stories.ts +++ b/code/lib/api/src/lib/stories.ts @@ -13,8 +13,8 @@ import type { ArgTypes, Parameters, ComponentId, + DocsOptions, } from '@storybook/types'; -import type { DocsOptions } from '@storybook/core-common'; import { combineParameters } from '../index'; import merge from './merge'; diff --git a/code/lib/builder-manager/src/types.ts b/code/lib/builder-manager/src/types.ts index 6f9b9cae1ad8..12723b889ffa 100644 --- a/code/lib/builder-manager/src/types.ts +++ b/code/lib/builder-manager/src/types.ts @@ -1,4 +1,4 @@ -import type { Builder } from '@storybook/core-common'; +import type { Builder } from '@storybook/types'; import type { BuildOptions, BuildResult } from 'esbuild'; diff --git a/code/lib/builder-manager/src/utils/data.ts b/code/lib/builder-manager/src/utils/data.ts index 9775112bd468..ecda2c28ccf5 100644 --- a/code/lib/builder-manager/src/utils/data.ts +++ b/code/lib/builder-manager/src/utils/data.ts @@ -1,5 +1,5 @@ import { join } from 'path'; -import type { DocsOptions, Options } from '@storybook/core-common'; +import type { DocsOptions, Options } from '@storybook/types'; import { getRefs } from '@storybook/core-common'; import { readTemplate } from './template'; diff --git a/code/lib/builder-manager/src/utils/template.ts b/code/lib/builder-manager/src/utils/template.ts index 6917c1fdafc4..8d86e5fdd7a6 100644 --- a/code/lib/builder-manager/src/utils/template.ts +++ b/code/lib/builder-manager/src/utils/template.ts @@ -3,7 +3,7 @@ import fs from 'fs-extra'; import { render } from 'ejs'; -import type { DocsOptions, Options, Ref } from '@storybook/core-common'; +import type { DocsOptions, Options, Ref } from '@storybook/types'; const interpolate = (string: string, data: Record = {}) => Object.entries(data).reduce((acc, [k, v]) => acc.replace(new RegExp(`%${k}%`, 'g'), v), string); diff --git a/code/lib/builder-vite/package.json b/code/lib/builder-vite/package.json index 8940e294c0db..b13a758069b4 100644 --- a/code/lib/builder-vite/package.json +++ b/code/lib/builder-vite/package.json @@ -26,6 +26,7 @@ "@storybook/node-logger": "7.0.0-alpha.40", "@storybook/preview-web": "7.0.0-alpha.40", "@storybook/source-loader": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "@vitejs/plugin-react": "^2.0.0", "browser-assert": "^1.2.1", "es-module-lexer": "^0.9.3", diff --git a/code/lib/builder-vite/src/codegen-entries.ts b/code/lib/builder-vite/src/codegen-entries.ts index 58ee541ad472..2e2f9b256175 100644 --- a/code/lib/builder-vite/src/codegen-entries.ts +++ b/code/lib/builder-vite/src/codegen-entries.ts @@ -1,5 +1,5 @@ import { loadPreviewOrConfigFile } from '@storybook/core-common'; -import type { Options } from '@storybook/core-common'; +import type { Options } from '@storybook/types'; import slash from 'slash'; import { normalizePath } from 'vite'; import type { ExtendedOptions } from './types'; diff --git a/code/lib/builder-vite/src/codegen-importfn-script.ts b/code/lib/builder-vite/src/codegen-importfn-script.ts index 958ca5c59efd..276c4f7b01f4 100644 --- a/code/lib/builder-vite/src/codegen-importfn-script.ts +++ b/code/lib/builder-vite/src/codegen-importfn-script.ts @@ -1,6 +1,6 @@ import * as path from 'path'; import { normalizePath } from 'vite'; -import type { Options } from '@storybook/core-common'; +import type { Options } from '@storybook/types'; import { logger } from '@storybook/node-logger'; import { listStories } from './list-stories'; diff --git a/code/lib/builder-vite/src/index.ts b/code/lib/builder-vite/src/index.ts index 5e10e18c0b76..fccf5694b8f8 100644 --- a/code/lib/builder-vite/src/index.ts +++ b/code/lib/builder-vite/src/index.ts @@ -2,11 +2,7 @@ import * as fs from 'fs'; import * as path from 'path'; -import type { - Builder, - StorybookConfig as StorybookBaseConfig, - Options, -} from '@storybook/core-common'; +import type { Builder, StorybookConfig as StorybookBaseConfig, Options } from '@storybook/types'; import type { RequestHandler, Request, Response } from 'express'; import type { InlineConfig, UserConfig, ViteDevServer } from 'vite'; import { transformIframeHtml } from './transform-iframe-html'; @@ -15,7 +11,9 @@ import { build as viteBuild } from './build'; import type { ExtendedOptions } from './types'; export { withoutVitePlugins } from './utils/without-vite-plugins'; -export type { TypescriptOptions } from '@storybook/core-common'; + +// TODO remove +export type { TypescriptOptions } from '@storybook/types'; // Storybook's Stats are optional Webpack related property export type ViteStats = { diff --git a/code/lib/builder-vite/src/plugins/mdx-plugin.ts b/code/lib/builder-vite/src/plugins/mdx-plugin.ts index e40c55bdbec1..3e215f2a13ed 100644 --- a/code/lib/builder-vite/src/plugins/mdx-plugin.ts +++ b/code/lib/builder-vite/src/plugins/mdx-plugin.ts @@ -1,4 +1,4 @@ -import type { Options } from '@storybook/core-common'; +import type { Options } from '@storybook/types'; import type { Plugin } from 'vite'; import { createFilter } from 'vite'; diff --git a/code/lib/builder-vite/src/transform-iframe-html.ts b/code/lib/builder-vite/src/transform-iframe-html.ts index a7bc35cf840a..d0b3294bd0f5 100644 --- a/code/lib/builder-vite/src/transform-iframe-html.ts +++ b/code/lib/builder-vite/src/transform-iframe-html.ts @@ -1,5 +1,5 @@ import { normalizeStories } from '@storybook/core-common'; -import type { CoreConfig, DocsOptions } from '@storybook/core-common'; +import type { CoreConfig, DocsOptions } from '@storybook/types'; import type { ExtendedOptions } from './types'; export type PreviewHtml = string | undefined; diff --git a/code/lib/builder-vite/src/types/extended-options.type.ts b/code/lib/builder-vite/src/types/extended-options.type.ts index cc3d6503b3f5..eaad5a8cc86c 100644 --- a/code/lib/builder-vite/src/types/extended-options.type.ts +++ b/code/lib/builder-vite/src/types/extended-options.type.ts @@ -1,4 +1,4 @@ -import type { Options } from '@storybook/core-common'; +import type { Options } from '@storybook/types'; // Using instead of `Record` to provide better aware of used options type IframeOptions = { diff --git a/code/lib/builder-webpack5/src/index.ts b/code/lib/builder-webpack5/src/index.ts index b32e9870ace0..61a0e9847abf 100644 --- a/code/lib/builder-webpack5/src/index.ts +++ b/code/lib/builder-webpack5/src/index.ts @@ -3,7 +3,7 @@ import webpackDevMiddleware from 'webpack-dev-middleware'; import webpackHotMiddleware from 'webpack-hot-middleware'; import { logger } from '@storybook/node-logger'; import { useProgressReporting } from '@storybook/core-common'; -import type { Builder, Options } from '@storybook/core-common'; +import type { Builder, Options } from '@storybook/types'; import { checkWebpackVersion } from '@storybook/core-webpack'; import { join } from 'path'; diff --git a/code/lib/builder-webpack5/src/presets/custom-webpack-preset.ts b/code/lib/builder-webpack5/src/presets/custom-webpack-preset.ts index c9b6957578e2..d71a67322d3e 100644 --- a/code/lib/builder-webpack5/src/presets/custom-webpack-preset.ts +++ b/code/lib/builder-webpack5/src/presets/custom-webpack-preset.ts @@ -1,6 +1,6 @@ import * as webpackReal from 'webpack'; import { logger } from '@storybook/node-logger'; -import type { Options, CoreConfig } from '@storybook/core-common'; +import type { Options, CoreConfig } from '@storybook/types'; import type { Configuration } from 'webpack'; import deprecate from 'util-deprecate'; import { dedent } from 'ts-dedent'; diff --git a/code/lib/builder-webpack5/src/preview/base-webpack.config.ts b/code/lib/builder-webpack5/src/preview/base-webpack.config.ts index c643e3b91325..62ba0d8ed50b 100644 --- a/code/lib/builder-webpack5/src/preview/base-webpack.config.ts +++ b/code/lib/builder-webpack5/src/preview/base-webpack.config.ts @@ -1,5 +1,5 @@ import { logger } from '@storybook/node-logger'; -import type { Options } from '@storybook/core-common'; +import type { Options } from '@storybook/types'; import type { Configuration } from 'webpack'; export async function createDefaultWebpackConfig( diff --git a/code/lib/builder-webpack5/src/preview/iframe-webpack.config.ts b/code/lib/builder-webpack5/src/preview/iframe-webpack.config.ts index e2f154e61800..6584a21be785 100644 --- a/code/lib/builder-webpack5/src/preview/iframe-webpack.config.ts +++ b/code/lib/builder-webpack5/src/preview/iframe-webpack.config.ts @@ -7,7 +7,7 @@ import TerserWebpackPlugin from 'terser-webpack-plugin'; import VirtualModulePlugin from 'webpack-virtual-modules'; import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'; -import type { Options, CoreConfig, DocsOptions } from '@storybook/core-common'; +import type { Options, CoreConfig, DocsOptions } from '@storybook/types'; import { stringifyProcessEnvs, handlebars, diff --git a/code/lib/cli/package.json b/code/lib/cli/package.json index 58772b7e0cbc..55c78978e79c 100644 --- a/code/lib/cli/package.json +++ b/code/lib/cli/package.json @@ -49,6 +49,7 @@ "@storybook/csf-tools": "7.0.0-alpha.40", "@storybook/node-logger": "7.0.0-alpha.40", "@storybook/telemetry": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "@types/semver": "^7.3.4", "boxen": "^5.1.2", "chalk": "^4.1.0", diff --git a/code/lib/cli/src/js-package-manager/PackageJson.ts b/code/lib/cli/src/js-package-manager/PackageJson.ts index 58340a478d79..a6313cfab244 100644 --- a/code/lib/cli/src/js-package-manager/PackageJson.ts +++ b/code/lib/cli/src/js-package-manager/PackageJson.ts @@ -1,6 +1,6 @@ -import type { PackageJson } from '@storybook/core-common'; +import type { PackageJson } from '@storybook/types'; -export type { PackageJson } from '@storybook/core-common'; +export type { PackageJson } from '@storybook/types'; export type PackageJsonWithDepsAndDevDeps = PackageJson & Required>; diff --git a/code/lib/cli/src/repro-generators/configs.ts b/code/lib/cli/src/repro-generators/configs.ts index 05685c29cb6a..b9045b60d1b4 100644 --- a/code/lib/cli/src/repro-generators/configs.ts +++ b/code/lib/cli/src/repro-generators/configs.ts @@ -1,5 +1,5 @@ /* eslint-disable camelcase */ -import type { StorybookConfig } from '@storybook/core-common'; +import type { StorybookConfig } from '@storybook/types'; import type { SupportedRenderers } from '../project_types'; export interface Parameters { diff --git a/code/lib/client-api/src/StoryStoreFacade.ts b/code/lib/client-api/src/StoryStoreFacade.ts index ae606483c953..6e012ce8a0eb 100644 --- a/code/lib/client-api/src/StoryStoreFacade.ts +++ b/code/lib/client-api/src/StoryStoreFacade.ts @@ -18,10 +18,10 @@ import type { Store_StoryIndex, Store_ModuleExports, Store_Story, + DocsOptions, } from '@storybook/types'; import { StoryStore, userOrAutoTitle, sortStoriesV6 } from '@storybook/store'; import { logger } from '@storybook/client-logger'; -import type { DocsOptions } from '@storybook/core-common'; export interface GetStorybookStory { name: string; diff --git a/code/lib/core-common/src/index.ts b/code/lib/core-common/src/index.ts index d0178dd2f3ba..e477fc76340c 100644 --- a/code/lib/core-common/src/index.ts +++ b/code/lib/core-common/src/index.ts @@ -30,6 +30,4 @@ export * from './utils/template'; export * from './utils/validate-config'; export * from './utils/validate-configuration-files'; -export * from './types'; - export { createFileSystemCache } from './utils/file-cache'; diff --git a/code/lib/core-common/src/presets.ts b/code/lib/core-common/src/presets.ts index 46c77bee7eb4..d960f4dcfd66 100644 --- a/code/lib/core-common/src/presets.ts +++ b/code/lib/core-common/src/presets.ts @@ -8,7 +8,7 @@ import { PresetConfig, Presets, BuilderOptions, -} from './types'; +} from '@storybook/types'; import { loadCustomPresets } from './utils/load-custom-presets'; import { safeResolve, safeResolveFrom } from './utils/safeResolve'; import { interopRequireDefault } from './utils/interpret-require'; diff --git a/code/lib/core-common/src/utils/get-framework-name.ts b/code/lib/core-common/src/utils/get-framework-name.ts index 1e93ea811823..e7191545b5a4 100644 --- a/code/lib/core-common/src/utils/get-framework-name.ts +++ b/code/lib/core-common/src/utils/get-framework-name.ts @@ -1,5 +1,5 @@ import { dedent } from 'ts-dedent'; -import type { Options } from '../types'; +import type { Options } from '@storybook/types'; /** * Framework can be a string or an object. This utility always returns the string name. diff --git a/code/lib/core-common/src/utils/get-storybook-info.ts b/code/lib/core-common/src/utils/get-storybook-info.ts index ea44ad5760df..1f8ddf1d8ae4 100644 --- a/code/lib/core-common/src/utils/get-storybook-info.ts +++ b/code/lib/core-common/src/utils/get-storybook-info.ts @@ -1,7 +1,7 @@ import path from 'path'; import fse from 'fs-extra'; +import { PackageJson } from '@storybook/types'; import { getStorybookConfiguration } from './get-storybook-configuration'; -import { PackageJson } from '../types'; interface StorybookInfo { version: string; diff --git a/code/lib/core-common/src/utils/get-storybook-refs.ts b/code/lib/core-common/src/utils/get-storybook-refs.ts index 20ceb1951c58..84e26008fbae 100644 --- a/code/lib/core-common/src/utils/get-storybook-refs.ts +++ b/code/lib/core-common/src/utils/get-storybook-refs.ts @@ -4,7 +4,7 @@ import findUp from 'find-up'; import resolveFrom from 'resolve-from'; import { logger } from '@storybook/node-logger'; -import { Options, Ref } from '../types'; +import { Options, Ref } from '@storybook/types'; export const getAutoRefs = async (options: Options): Promise> => { const location = await findUp('package.json', { cwd: options.configDir }); diff --git a/code/lib/core-common/src/utils/load-custom-presets.ts b/code/lib/core-common/src/utils/load-custom-presets.ts index bfa59ac819ba..252d1330e1b9 100644 --- a/code/lib/core-common/src/utils/load-custom-presets.ts +++ b/code/lib/core-common/src/utils/load-custom-presets.ts @@ -1,7 +1,7 @@ import path from 'path'; +import { PresetConfig } from '@storybook/types'; import { serverRequire, serverResolve } from './interpret-require'; import { validateConfigurationFiles } from './validate-configuration-files'; -import { PresetConfig } from '../types'; export function loadCustomPresets({ configDir }: { configDir: string }): PresetConfig[] { validateConfigurationFiles(configDir); diff --git a/code/lib/core-common/src/utils/load-main-config.ts b/code/lib/core-common/src/utils/load-main-config.ts index 67b294e33275..9be5344ca153 100644 --- a/code/lib/core-common/src/utils/load-main-config.ts +++ b/code/lib/core-common/src/utils/load-main-config.ts @@ -1,7 +1,7 @@ import path from 'path'; +import { StorybookConfig } from '@storybook/types'; import { serverRequire } from './interpret-require'; import { validateConfigurationFiles } from './validate-configuration-files'; -import { StorybookConfig } from '../types'; export function loadMainConfig({ configDir }: { configDir: string }): StorybookConfig { validateConfigurationFiles(configDir); diff --git a/code/lib/core-common/src/utils/normalize-stories.ts b/code/lib/core-common/src/utils/normalize-stories.ts index a74378929679..d19a871b8e8e 100644 --- a/code/lib/core-common/src/utils/normalize-stories.ts +++ b/code/lib/core-common/src/utils/normalize-stories.ts @@ -1,9 +1,13 @@ +/* eslint-disable camelcase */ import fs from 'fs'; import path from 'path'; import { scan } from 'picomatch'; import slash from 'slash'; -import type { StoriesEntry, NormalizedStoriesSpecifier } from '../types'; +import type { + CoreCommon_StoriesEntry, + CoreCommon_NormalizedStoriesSpecifier, +} from '@storybook/types'; import { normalizeStoryPath } from './paths'; import { globToRegexp } from './glob-to-regexp'; @@ -32,10 +36,10 @@ export const getDirectoryFromWorkingDir = ({ }; export const normalizeStoriesEntry = ( - entry: StoriesEntry, + entry: CoreCommon_StoriesEntry, { configDir, workingDir }: NormalizeOptions -): NormalizedStoriesSpecifier => { - let specifierWithoutMatcher: Omit; +): CoreCommon_NormalizedStoriesSpecifier => { + let specifierWithoutMatcher: Omit; if (typeof entry === 'string') { const globResult = scan(entry); @@ -100,5 +104,5 @@ interface NormalizeOptions { workingDir: string; } -export const normalizeStories = (entries: StoriesEntry[], options: NormalizeOptions) => +export const normalizeStories = (entries: CoreCommon_StoriesEntry[], options: NormalizeOptions) => entries.map((entry) => normalizeStoriesEntry(entry, options)); diff --git a/code/lib/core-server/src/build-dev.ts b/code/lib/core-server/src/build-dev.ts index 72bdd1405bdf..d84a41c28b44 100644 --- a/code/lib/core-server/src/build-dev.ts +++ b/code/lib/core-server/src/build-dev.ts @@ -4,7 +4,7 @@ import type { BuilderOptions, Options, StorybookConfig, -} from '@storybook/core-common'; +} from '@storybook/types'; import { resolvePathInStorybookCache, loadAllPresets, diff --git a/code/lib/core-server/src/build-static.ts b/code/lib/core-server/src/build-static.ts index 52bcb5eed7cd..4f50d3c25e1c 100644 --- a/code/lib/core-server/src/build-static.ts +++ b/code/lib/core-server/src/build-static.ts @@ -14,7 +14,7 @@ import type { StorybookConfig, CoreConfig, DocsOptions, -} from '@storybook/core-common'; +} from '@storybook/types'; import { loadAllPresets, normalizeStories, diff --git a/code/lib/core-server/src/dev-server.ts b/code/lib/core-server/src/dev-server.ts index 89f95bff4b59..f1b56887b092 100644 --- a/code/lib/core-server/src/dev-server.ts +++ b/code/lib/core-server/src/dev-server.ts @@ -1,14 +1,9 @@ import express, { Router } from 'express'; import compression from 'compression'; -import { - CoreConfig, - DocsOptions, - Options, - StorybookConfig, - normalizeStories, - logConfig, -} from '@storybook/core-common'; +import type { CoreConfig, DocsOptions, Options, StorybookConfig } from '@storybook/types'; + +import { normalizeStories, logConfig } from '@storybook/core-common'; import { telemetry } from '@storybook/telemetry'; import { getMiddleware } from './utils/middleware'; diff --git a/code/lib/core-server/src/presets/common-preset.ts b/code/lib/core-server/src/presets/common-preset.ts index eec47c64d9c4..b986a6390dc1 100644 --- a/code/lib/core-server/src/presets/common-preset.ts +++ b/code/lib/core-server/src/presets/common-preset.ts @@ -1,7 +1,7 @@ +/* eslint-disable camelcase */ import fs from 'fs-extra'; import { deprecate } from '@storybook/node-logger'; import { - type CLIOptions, getPreviewBodyTemplate, getPreviewHeadTemplate, getPreviewMainTemplate, @@ -9,11 +9,12 @@ import { } from '@storybook/core-common'; import type { Options, + CLIOptions, CoreConfig, StorybookConfig, - StoryIndexer, - IndexerOptions, -} from '@storybook/core-common'; + CoreCommon_StoryIndexer, + CoreCommon_IndexerOptions, +} from '@storybook/types'; import { loadCsf } from '@storybook/csf-tools'; export const babel = async (_: unknown, options: Options) => { @@ -111,8 +112,8 @@ export const features = async ( argTypeTargetsV7: true, }); -export const storyIndexers = async (indexers?: StoryIndexer[]) => { - const csfIndexer = async (fileName: string, opts: IndexerOptions) => { +export const storyIndexers = async (indexers?: CoreCommon_StoryIndexer[]) => { + const csfIndexer = async (fileName: string, opts: CoreCommon_IndexerOptions) => { const code = (await fs.readFile(fileName, 'utf-8')).toString(); return loadCsf(code, { ...opts, fileName }).parse(); }; diff --git a/code/lib/core-server/src/utils/StoryIndexGenerator.ts b/code/lib/core-server/src/utils/StoryIndexGenerator.ts index d100db31dd3e..b58e0a94b974 100644 --- a/code/lib/core-server/src/utils/StoryIndexGenerator.ts +++ b/code/lib/core-server/src/utils/StoryIndexGenerator.ts @@ -15,9 +15,11 @@ import type { Addon_TemplateDocsIndexEntry, ComponentTitle, StoryName, + CoreCommon_StoryIndexer, + CoreCommon_NormalizedStoriesSpecifier, + DocsOptions, } from '@storybook/types'; import { userOrAutoTitleFromSpecifier, sortStoriesV7 } from '@storybook/store'; -import type { StoryIndexer, NormalizedStoriesSpecifier, DocsOptions } from '@storybook/core-common'; import { normalizeStoryPath } from '@storybook/core-common'; import { logger } from '@storybook/node-logger'; import { getStorySortParameter, NoMetaError } from '@storybook/csf-tools'; @@ -69,7 +71,7 @@ const makeAbsolute = ( export class StoryIndexGenerator { // An internal cache mapping specifiers to a set of path=> // Later, we'll combine each of these subsets together to form the full index - private specifierToCache: Map; + private specifierToCache: Map; // Cache the last value of `getStoryIndex`. We invalidate (by unsetting) when: // - any file changes, including deletions @@ -77,13 +79,13 @@ export class StoryIndexGenerator { private lastIndex?: Store_StoryIndex; constructor( - public readonly specifiers: NormalizedStoriesSpecifier[], + public readonly specifiers: CoreCommon_NormalizedStoriesSpecifier[], public readonly options: { workingDir: Store_Path; configDir: Store_Path; storiesV2Compatibility: boolean; storyStoreV7: boolean; - storyIndexers: StoryIndexer[]; + storyIndexers: CoreCommon_StoryIndexer[]; docs: DocsOptions; } ) { @@ -124,7 +126,7 @@ export class StoryIndexGenerator { */ async updateExtracted( updater: ( - specifier: NormalizedStoriesSpecifier, + specifier: CoreCommon_NormalizedStoriesSpecifier, absolutePath: Store_Path, existingEntry: CacheEntry ) => Promise, @@ -200,7 +202,7 @@ export class StoryIndexGenerator { return dependencies; } - async extractStories(specifier: NormalizedStoriesSpecifier, absolutePath: Store_Path) { + async extractStories(specifier: CoreCommon_NormalizedStoriesSpecifier, absolutePath: Store_Path) { const relativePath = path.relative(this.options.workingDir, absolutePath); const entries = [] as Addon_IndexEntry[]; try { @@ -251,7 +253,7 @@ export class StoryIndexGenerator { return { entries, type: 'stories', dependents: [] } as StoriesCacheEntry; } - async extractDocs(specifier: NormalizedStoriesSpecifier, absolutePath: Store_Path) { + async extractDocs(specifier: CoreCommon_NormalizedStoriesSpecifier, absolutePath: Store_Path) { const relativePath = path.relative(this.options.workingDir, absolutePath); try { if (!this.options.storyStoreV7) { @@ -459,7 +461,11 @@ export class StoryIndexGenerator { return this.lastIndex; } - invalidate(specifier: NormalizedStoriesSpecifier, importPath: Store_Path, removed: boolean) { + invalidate( + specifier: CoreCommon_NormalizedStoriesSpecifier, + importPath: Store_Path, + removed: boolean + ) { const absolutePath = slash(path.resolve(this.options.workingDir, importPath)); const cache = this.specifierToCache.get(specifier); diff --git a/code/lib/core-server/src/utils/get-builders.ts b/code/lib/core-server/src/utils/get-builders.ts index 76a538ca83c5..c21a157cfb93 100644 --- a/code/lib/core-server/src/utils/get-builders.ts +++ b/code/lib/core-server/src/utils/get-builders.ts @@ -1,4 +1,4 @@ -import type { Options, CoreConfig, Builder } from '@storybook/core-common'; +import type { Options, CoreConfig, Builder } from '@storybook/types'; async function getManagerBuilder() { return import('@storybook/builder-manager'); diff --git a/code/lib/core-server/src/utils/output-startup-information.ts b/code/lib/core-server/src/utils/output-startup-information.ts index 44025b744fe6..25bf15dc01bf 100644 --- a/code/lib/core-server/src/utils/output-startup-information.ts +++ b/code/lib/core-server/src/utils/output-startup-information.ts @@ -4,7 +4,7 @@ import boxen from 'boxen'; import { dedent } from 'ts-dedent'; import Table from 'cli-table3'; import prettyTime from 'pretty-hrtime'; -import type { VersionCheck } from '@storybook/core-common'; +import type { VersionCheck } from '@storybook/types'; import { createUpdateMessage } from './update-check'; export function outputStartupInformation(options: { diff --git a/code/lib/core-server/src/utils/output-stats.ts b/code/lib/core-server/src/utils/output-stats.ts index 9df80f6c65d3..dd560c661bb5 100644 --- a/code/lib/core-server/src/utils/output-stats.ts +++ b/code/lib/core-server/src/utils/output-stats.ts @@ -1,6 +1,6 @@ import { stringifyStream } from '@discoveryjs/json-ext'; import { logger } from '@storybook/node-logger'; -import type { Stats } from '@storybook/core-common'; +import type { Stats } from '@storybook/types'; import chalk from 'chalk'; import fs from 'fs-extra'; import path from 'path'; diff --git a/code/lib/core-server/src/utils/release-notes.ts b/code/lib/core-server/src/utils/release-notes.ts index 068f4642a44f..0aa249113c58 100644 --- a/code/lib/core-server/src/utils/release-notes.ts +++ b/code/lib/core-server/src/utils/release-notes.ts @@ -1,5 +1,5 @@ import semver from 'semver'; -import type { ReleaseNotesData } from '@storybook/core-common'; +import type { ReleaseNotesData } from '@storybook/types'; // We only expect to have release notes available for major and minor releases. // For this reason, we convert the actual version of the build here so that diff --git a/code/lib/core-server/src/utils/server-statics.ts b/code/lib/core-server/src/utils/server-statics.ts index 585529cd142e..99b135ad9e62 100644 --- a/code/lib/core-server/src/utils/server-statics.ts +++ b/code/lib/core-server/src/utils/server-statics.ts @@ -1,5 +1,5 @@ import { logger } from '@storybook/node-logger'; -import type { Options, StorybookConfig } from '@storybook/core-common'; +import type { Options, StorybookConfig } from '@storybook/types'; import { getDirectoryFromWorkingDir } from '@storybook/core-common'; import chalk from 'chalk'; import express from 'express'; diff --git a/code/lib/core-server/src/utils/stories-json.ts b/code/lib/core-server/src/utils/stories-json.ts index f110e8c15150..698ec46a14a0 100644 --- a/code/lib/core-server/src/utils/stories-json.ts +++ b/code/lib/core-server/src/utils/stories-json.ts @@ -2,8 +2,11 @@ import { Router, Request, Response } from 'express'; import { writeJSON } from 'fs-extra'; -import type { NormalizedStoriesSpecifier } from '@storybook/core-common'; -import type { Store_StoryIndex, Store_StoryIndexV3 } from '@storybook/types'; +import type { + CoreCommon_NormalizedStoriesSpecifier, + Store_StoryIndex, + Store_StoryIndexV3, +} from '@storybook/types'; import debounce from 'lodash/debounce'; import { STORY_INDEX_INVALIDATED } from '@storybook/core-events'; @@ -34,7 +37,7 @@ export function useStoriesJson({ initializedStoryIndexGenerator: Promise; serverChannel: ServerChannel; workingDir?: string; - normalizedStories: NormalizedStoriesSpecifier[]; + normalizedStories: CoreCommon_NormalizedStoriesSpecifier[]; }) { const maybeInvalidate = debounce(() => serverChannel.emit(STORY_INDEX_INVALIDATED), DEBOUNCE, { leading: true, diff --git a/code/lib/core-server/src/utils/update-check.ts b/code/lib/core-server/src/utils/update-check.ts index 0452d89e9fa2..b20881d12352 100644 --- a/code/lib/core-server/src/utils/update-check.ts +++ b/code/lib/core-server/src/utils/update-check.ts @@ -4,7 +4,7 @@ import { colors } from '@storybook/node-logger'; import semver from 'semver'; import { dedent } from 'ts-dedent'; import { cache } from '@storybook/core-common'; -import type { VersionCheck } from '@storybook/core-common'; +import type { VersionCheck } from '@storybook/types'; const { STORYBOOK_VERSION_BASE = 'https://storybook.js.org', CI } = process.env; diff --git a/code/lib/core-server/src/utils/watch-story-specifiers.ts b/code/lib/core-server/src/utils/watch-story-specifiers.ts index a8a5183de3d0..1da7b37e8206 100644 --- a/code/lib/core-server/src/utils/watch-story-specifiers.ts +++ b/code/lib/core-server/src/utils/watch-story-specifiers.ts @@ -6,8 +6,7 @@ import path from 'path'; import glob from 'globby'; import uniq from 'lodash/uniq'; -import type { NormalizedStoriesSpecifier } from '@storybook/core-common'; -import type { Store_Path } from '@storybook/types'; +import type { CoreCommon_NormalizedStoriesSpecifier, Store_Path } from '@storybook/types'; const isDirectory = (directory: Store_Path) => { try { @@ -25,9 +24,13 @@ function toImportPath(relativePath: Store_Path) { } export function watchStorySpecifiers( - specifiers: NormalizedStoriesSpecifier[], + specifiers: CoreCommon_NormalizedStoriesSpecifier[], options: { workingDir: Store_Path }, - onInvalidate: (specifier: NormalizedStoriesSpecifier, path: Store_Path, removed: boolean) => void + onInvalidate: ( + specifier: CoreCommon_NormalizedStoriesSpecifier, + path: Store_Path, + removed: boolean + ) => void ) { // See https://www.npmjs.com/package/watchpack for full options. // If you want less traffic, consider using aggregation with some interval diff --git a/code/lib/core-webpack/package.json b/code/lib/core-webpack/package.json index 51daa038524d..655680401dd2 100644 --- a/code/lib/core-webpack/package.json +++ b/code/lib/core-webpack/package.json @@ -44,6 +44,7 @@ "dependencies": { "@storybook/core-common": "7.0.0-alpha.40", "@storybook/node-logger": "7.0.0-alpha.40", + "@storybook/types": "7.0.0-alpha.40", "@types/node": "^16.0.0", "ts-dedent": "^2.0.0" }, diff --git a/code/lib/core-webpack/src/to-importFn.ts b/code/lib/core-webpack/src/to-importFn.ts index f425e36a4b32..78c90bd91b62 100644 --- a/code/lib/core-webpack/src/to-importFn.ts +++ b/code/lib/core-webpack/src/to-importFn.ts @@ -1,10 +1,11 @@ +/* eslint-disable camelcase */ import { dedent } from 'ts-dedent'; -import type { NormalizedStoriesSpecifier } from '@storybook/core-common'; +import type { CoreCommon_NormalizedStoriesSpecifier } from '@storybook/types'; import { globToRegexp } from '@storybook/core-common'; import { importPipeline } from './importPipeline'; -export function webpackIncludeRegexp(specifier: NormalizedStoriesSpecifier) { +export function webpackIncludeRegexp(specifier: CoreCommon_NormalizedStoriesSpecifier) { const { directory, files } = specifier; // It appears webpack passes *something* similar to the absolute path to the file @@ -22,7 +23,7 @@ export function webpackIncludeRegexp(specifier: NormalizedStoriesSpecifier) { return new RegExp(webpackIncludeRegexpWithCaret.source.replace(/^\^/, '')); } -export function toImportFnPart(specifier: NormalizedStoriesSpecifier) { +export function toImportFnPart(specifier: CoreCommon_NormalizedStoriesSpecifier) { const { directory, importPathMatcher } = specifier; return dedent` @@ -43,7 +44,7 @@ export function toImportFnPart(specifier: NormalizedStoriesSpecifier) { } export function toImportFn( - stories: NormalizedStoriesSpecifier[], + stories: CoreCommon_NormalizedStoriesSpecifier[], { needPipelinedImport }: { needPipelinedImport?: boolean } = {} ) { let pipelinedImport = `const pipeline = (x) => x();`; diff --git a/code/lib/core-webpack/src/to-require-context.ts b/code/lib/core-webpack/src/to-require-context.ts index 97a812d724dc..c82d635d6160 100644 --- a/code/lib/core-webpack/src/to-require-context.ts +++ b/code/lib/core-webpack/src/to-require-context.ts @@ -1,7 +1,8 @@ -import type { NormalizedStoriesSpecifier } from '@storybook/core-common'; +/* eslint-disable camelcase */ +import type { CoreCommon_NormalizedStoriesSpecifier } from '@storybook/types'; import { globToRegexp } from '@storybook/core-common'; -export const toRequireContext = (specifier: NormalizedStoriesSpecifier) => { +export const toRequireContext = (specifier: CoreCommon_NormalizedStoriesSpecifier) => { const { directory, files } = specifier; // The importPathMatcher is a `./`-prefixed matcher that includes the directory @@ -15,7 +16,7 @@ export const toRequireContext = (specifier: NormalizedStoriesSpecifier) => { }; }; -export const toRequireContextString = (specifier: NormalizedStoriesSpecifier) => { +export const toRequireContextString = (specifier: CoreCommon_NormalizedStoriesSpecifier) => { const { path: p, recursive: r, match: m } = toRequireContext(specifier); const result = `require.context('${p}', ${r}, ${m})`; diff --git a/code/lib/core-webpack/src/types.ts b/code/lib/core-webpack/src/types.ts index d7819b0f995f..012b95f41cf6 100644 --- a/code/lib/core-webpack/src/types.ts +++ b/code/lib/core-webpack/src/types.ts @@ -1,6 +1,6 @@ -import type { Options, StorybookConfig as StorybookConfigBase } from '@storybook/core-common'; +import type { Options, StorybookConfig as StorybookConfigBase } from '@storybook/types'; -export type { Options, Preset, BuilderResult, TypescriptOptions } from '@storybook/core-common'; +export type { Options, Preset, BuilderResult, TypescriptOptions } from '@storybook/types'; export type RulesConfig = any; diff --git a/code/lib/docs-tools/src/hasDocsOrControls.ts b/code/lib/docs-tools/src/hasDocsOrControls.ts index 76dbfc25afa1..d460666d7bc3 100644 --- a/code/lib/docs-tools/src/hasDocsOrControls.ts +++ b/code/lib/docs-tools/src/hasDocsOrControls.ts @@ -1,4 +1,4 @@ -import type { Options } from '@storybook/core-common'; +import type { Options } from '@storybook/types'; // `addons/x` is for the monorepo, `addon-x` is for normal usage const packageRe = /(addons\/|addon-)(docs|controls)/; diff --git a/code/lib/telemetry/src/get-monorepo-type.ts b/code/lib/telemetry/src/get-monorepo-type.ts index e9a5c08a78d2..52de41e40dfb 100644 --- a/code/lib/telemetry/src/get-monorepo-type.ts +++ b/code/lib/telemetry/src/get-monorepo-type.ts @@ -1,6 +1,6 @@ import fs from 'fs-extra'; import path from 'path'; -import type { PackageJson } from '@storybook/core-common'; +import type { PackageJson } from '@storybook/types'; import { getProjectRoot } from '@storybook/core-common'; export const monorepoConfigs = { diff --git a/code/lib/telemetry/src/storybook-metadata.ts b/code/lib/telemetry/src/storybook-metadata.ts index da3727d261f3..d185fd41fa8d 100644 --- a/code/lib/telemetry/src/storybook-metadata.ts +++ b/code/lib/telemetry/src/storybook-metadata.ts @@ -6,7 +6,7 @@ import { getStorybookConfiguration, getProjectRoot, } from '@storybook/core-common'; -import type { StorybookConfig, PackageJson } from '@storybook/core-common'; +import type { StorybookConfig, PackageJson } from '@storybook/types'; import type { StorybookMetadata, Dependency, StorybookAddon } from './types'; import { getActualPackageVersion, getActualPackageVersions } from './package-versions'; diff --git a/code/lib/telemetry/src/types.ts b/code/lib/telemetry/src/types.ts index 3014d3fa1f15..e32e9761f9d1 100644 --- a/code/lib/telemetry/src/types.ts +++ b/code/lib/telemetry/src/types.ts @@ -1,4 +1,4 @@ -import type { StorybookConfig, TypescriptOptions } from '@storybook/core-common'; +import type { StorybookConfig, TypescriptOptions } from '@storybook/types'; import type { PM } from 'detect-package-manager'; import type { MonorepoType } from './get-monorepo-type'; diff --git a/code/lib/types/package.json b/code/lib/types/package.json index c3dbfab69952..76d750a98686 100644 --- a/code/lib/types/package.json +++ b/code/lib/types/package.json @@ -41,6 +41,10 @@ }, "devDependencies": { "@storybook/csf": "0.0.2--canary.49.258942b.0", + "@types/babel__core": "^7.0.0", + "@types/express": "^4.7.0", + "@types/node": "^16.0.0", + "file-system-cache": "^2.0.0", "synchronous-promise": "^2.0.15", "typescript": "~4.6.3" }, diff --git a/code/lib/types/src/index.ts b/code/lib/types/src/index.ts index bd67cbe406c9..63b43450b6ae 100644 --- a/code/lib/types/src/index.ts +++ b/code/lib/types/src/index.ts @@ -3,3 +3,4 @@ export * from './modules/addons'; export * from './modules/store'; export * from './modules/client-api'; export * from './modules/core-client'; +export * from './modules/core-common'; diff --git a/code/lib/core-common/src/types.ts b/code/lib/types/src/modules/core-common.ts similarity index 90% rename from code/lib/core-common/src/types.ts rename to code/lib/types/src/modules/core-common.ts index 0659f0e835f0..42c8c34fdd35 100644 --- a/code/lib/core-common/src/types.ts +++ b/code/lib/types/src/modules/core-common.ts @@ -1,10 +1,12 @@ +/* eslint-disable camelcase */ +import type { FileSystemCache } from 'file-system-cache'; + import type { Options as TelejsonOptions } from 'telejson'; import type { TransformOptions } from '@babel/core'; -import { Router } from 'express'; -import { Server } from 'http'; +import type { Router } from 'express'; +import type { Server } from 'http'; import type { Parameters } from '@storybook/types'; import type { PackageJson as PackageJsonFromTypeFest } from 'type-fest'; -import type { FileSystemCache } from './utils/file-cache'; /** * ⚠️ This file contains internal WIP types they MUST NOT be exported outside this package for now! @@ -59,7 +61,7 @@ export interface Presets { apply(extension: 'framework', config?: {}, args?: any): Promise; apply(extension: 'babel', config?: {}, args?: any): Promise; apply(extension: 'entries', config?: [], args?: any): Promise; - apply(extension: 'stories', config?: [], args?: any): Promise; + apply(extension: 'stories', config?: [], args?: any): Promise; apply(extension: 'managerEntries', config: [], args?: any): Promise; apply(extension: 'refs', config?: [], args?: any): Promise; apply(extension: 'core', config?: {}, args?: any): Promise; @@ -197,23 +199,23 @@ export interface Builder { overridePresets?: string[]; } -export interface IndexerOptions { +export interface CoreCommon_IndexerOptions { makeTitle: (userTitle?: string) => string; } -export interface IndexedStory { +export interface CoreCommon_IndexedStory { id: string; name: string; parameters?: Parameters; } -export interface StoryIndex { +export interface CoreCommon_StoryIndex { meta: { title?: string }; - stories: IndexedStory[]; + stories: CoreCommon_IndexedStory[]; } -export interface StoryIndexer { +export interface CoreCommon_StoryIndexer { test: RegExp; - indexer: (fileName: string, options: IndexerOptions) => Promise; + indexer: (fileName: string, options: CoreCommon_IndexerOptions) => Promise; addDocsTemplate?: boolean; } @@ -235,7 +237,7 @@ export interface TypescriptOptions { skipBabel: boolean; } -interface StoriesSpecifier { +interface CoreCommon_StoriesSpecifier { /** * When auto-titling, what to prefix all generated titles with (default: '') */ @@ -252,9 +254,9 @@ interface StoriesSpecifier { files?: string; } -export type StoriesEntry = string | StoriesSpecifier; +export type CoreCommon_StoriesEntry = string | CoreCommon_StoriesSpecifier; -export type NormalizedStoriesSpecifier = Required & { +export type CoreCommon_NormalizedStoriesSpecifier = Required & { /* * Match the "importPath" of a file (e.g. `./src/button/Button.stories.js') * relative to the current working directory. @@ -275,7 +277,10 @@ export type Preset = */ export type Entry = string; -type StorybookRefs = Record; +type CoreCommon_StorybookRefs = Record< + string, + { title: string; url: string } | { disable: boolean } +>; export type DocsOptions = { /** @@ -369,7 +374,7 @@ export interface StorybookConfig { * * @example `['./src/*.stories.@(j|t)sx?']` */ - stories: StoriesEntry[]; + stories: CoreCommon_StoriesEntry[]; /** * Framework, e.g. '@storybook/react', required in v7 @@ -384,7 +389,7 @@ export interface StorybookConfig { /** * References external Storybooks */ - refs?: StorybookRefs | ((config: any, options: Options) => StorybookRefs); + refs?: CoreCommon_StorybookRefs | ((config: any, options: Options) => CoreCommon_StorybookRefs); /** * Modify or return babel config. @@ -417,7 +422,10 @@ export interface StorybookConfig { /** * Process CSF files for the story index. */ - storyIndexers?: (indexers: StoryIndexer[], options: Options) => StoryIndexer[]; + storyIndexers?: ( + indexers: CoreCommon_StoryIndexer[], + options: Options + ) => CoreCommon_StoryIndexer[]; /** * Docs related features in index generation diff --git a/docs/snippets/common/storybook-a11y-register.ts.mdx b/docs/snippets/common/storybook-a11y-register.ts.mdx index 73137a1bf616..0b977c14953b 100644 --- a/docs/snippets/common/storybook-a11y-register.ts.mdx +++ b/docs/snippets/common/storybook-a11y-register.ts.mdx @@ -2,7 +2,7 @@ // .storybook/main.ts // Imports Storybook's configuration API -import type { StorybookConfig } from '@storybook/core-common'; +import type { StorybookConfig } from '@storybook/types'; const config: StorybookConfig = { stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'], diff --git a/docs/snippets/common/storybook-main-default-setup.ts.mdx b/docs/snippets/common/storybook-main-default-setup.ts.mdx index 0289e0191698..68cca7fd2797 100644 --- a/docs/snippets/common/storybook-main-default-setup.ts.mdx +++ b/docs/snippets/common/storybook-main-default-setup.ts.mdx @@ -2,7 +2,7 @@ // .storybook/main.ts // Imports the Storybook's configuration API -import type { StorybookConfig } from '@storybook/core-common'; +import type { StorybookConfig } from '@storybook/types'; const config: StorybookConfig = { stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'], diff --git a/docs/snippets/common/storybook-main-disable-telemetry.main-ts.ts.mdx b/docs/snippets/common/storybook-main-disable-telemetry.main-ts.ts.mdx index a3d37125b457..6d25e3e28337 100644 --- a/docs/snippets/common/storybook-main-disable-telemetry.main-ts.ts.mdx +++ b/docs/snippets/common/storybook-main-disable-telemetry.main-ts.ts.mdx @@ -2,7 +2,7 @@ // .storybook/main.ts // Imports Storybook's configuration API -import type { StorybookConfig } from '@storybook/core-common'; +import type { StorybookConfig } from '@storybook/types'; const config: StorybookConfig = { stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'], diff --git a/docs/snippets/common/storybook-telemetry-main-enable-crash-reports.main-ts.ts.mdx b/docs/snippets/common/storybook-telemetry-main-enable-crash-reports.main-ts.ts.mdx index 4b23ced1cc2c..a7d731e74d7f 100644 --- a/docs/snippets/common/storybook-telemetry-main-enable-crash-reports.main-ts.ts.mdx +++ b/docs/snippets/common/storybook-telemetry-main-enable-crash-reports.main-ts.ts.mdx @@ -2,7 +2,7 @@ // .storybook/main.ts // Imports Storybook's configuration API -import type { StorybookConfig } from '@storybook/core-common'; +import type { StorybookConfig } from '@storybook/types'; const config: StorybookConfig = { stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'], From c52e17c81a377e509725ea610ec9d55cb147efa4 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sat, 22 Oct 2022 01:08:39 +0200 Subject: [PATCH 09/38] step 6 --- code/lib/client-api/src/ClientApi.ts | 12 --------- code/lib/client-api/src/StoryStoreFacade.ts | 12 --------- code/lib/client-api/src/index.ts | 29 +++++---------------- code/lib/client-api/src/queryparams.ts | 3 +-- code/lib/types/src/modules/client-api.ts | 13 ++++----- 5 files changed, 14 insertions(+), 55 deletions(-) diff --git a/code/lib/client-api/src/ClientApi.ts b/code/lib/client-api/src/ClientApi.ts index 9ef7ff088d59..44fc74c68a0d 100644 --- a/code/lib/client-api/src/ClientApi.ts +++ b/code/lib/client-api/src/ClientApi.ts @@ -18,7 +18,6 @@ import type { StoryFn, Globals, GlobalTypes, - LegacyStoryFn, Addon_ClientApiAddons, Addon_StoryApi, Store_NormalizedComponentAnnotations, @@ -34,17 +33,6 @@ import { import { StoryStoreFacade } from './StoryStoreFacade'; -export interface GetStorybookStory { - name: string; - render: LegacyStoryFn; -} - -export interface GetStorybookKind { - kind: string; - fileName: string; - stories: GetStorybookStory[]; -} - // ClientApi (and StoreStore) are really singletons. However they are not created until the // relevant framework instanciates them via `start.js`. The good news is this happens right away. let singleton: ClientApi; diff --git a/code/lib/client-api/src/StoryStoreFacade.ts b/code/lib/client-api/src/StoryStoreFacade.ts index 6e012ce8a0eb..6765fe932e23 100644 --- a/code/lib/client-api/src/StoryStoreFacade.ts +++ b/code/lib/client-api/src/StoryStoreFacade.ts @@ -10,7 +10,6 @@ import type { StoryId, AnyFramework, Parameters, - StoryFn, Addon_IndexEntry, Store_NormalizedProjectAnnotations, Store_NormalizedStoriesSpecifier, @@ -23,17 +22,6 @@ import type { import { StoryStore, userOrAutoTitle, sortStoriesV6 } from '@storybook/store'; import { logger } from '@storybook/client-logger'; -export interface GetStorybookStory { - name: string; - render: StoryFn; -} - -export interface GetStorybookKind { - kind: string; - fileName: string; - stories: GetStorybookStory[]; -} - export class StoryStoreFacade { projectAnnotations: Store_NormalizedProjectAnnotations; diff --git a/code/lib/client-api/src/index.ts b/code/lib/client-api/src/index.ts index d0a4035540c2..976a34dec776 100644 --- a/code/lib/client-api/src/index.ts +++ b/code/lib/client-api/src/index.ts @@ -1,31 +1,14 @@ -import { - ClientApi, - addDecorator, - addLoader, - addParameters, +export { addArgs, - addArgTypes, addArgsEnhancer, + addArgTypes, addArgTypesEnhancer, - addStepRunner, - setGlobalRender, -} from './ClientApi'; - -export type { GetStorybookKind, GetStorybookStory } from './ClientApi'; - -export * from './queryparams'; - -export * from '@storybook/store'; - -export { addDecorator, addLoader, addParameters, - addArgsEnhancer, - addArgTypesEnhancer, - addArgs, - addArgTypes, addStepRunner, - setGlobalRender, ClientApi, -}; + setGlobalRender, +} from './ClientApi'; + +export * from './queryparams'; diff --git a/code/lib/client-api/src/queryparams.ts b/code/lib/client-api/src/queryparams.ts index e9d120f6263f..be0c29f201f6 100644 --- a/code/lib/client-api/src/queryparams.ts +++ b/code/lib/client-api/src/queryparams.ts @@ -1,9 +1,8 @@ import global from 'global'; import { parse } from 'qs'; -const { document } = global; - export const getQueryParams = () => { + const { document } = global; // document.location is not defined in react-native if (document && document.location && document.location.search) { return parse(document.location.search, { ignoreQueryPrefix: true }); diff --git a/code/lib/types/src/modules/client-api.ts b/code/lib/types/src/modules/client-api.ts index 544d6c0645f9..908abab0265d 100644 --- a/code/lib/types/src/modules/client-api.ts +++ b/code/lib/types/src/modules/client-api.ts @@ -12,6 +12,7 @@ import type { LoaderFunction, Parameters, ProjectAnnotations, + LegacyStoryFn, StoryContext, StoryFn, StoryId, @@ -97,15 +98,15 @@ export interface ClientAPI_ClientApiAddons { [key: string]: ClientAPI_ClientApiAddon; } -export interface ClientAPI_GetStorybookStory { +export type ClientAPI_RenderContextWithoutStoryContext = Omit; + +export interface ClientAPI_GetStorybookStory { name: string; - render: StoryFn; + render: LegacyStoryFn; } -export interface ClientAPI_GetStorybookKind { +export interface ClientAPI_GetStorybookKind { kind: string; fileName: string; - stories: ClientAPI_GetStorybookStory[]; + stories: ClientAPI_GetStorybookStory[]; } - -export type ClientAPI_RenderContextWithoutStoryContext = Omit; From fb5bbd792512bc98c5f39b83d0db652e59da6de8 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sat, 22 Oct 2022 01:32:57 +0200 Subject: [PATCH 10/38] part 7 --- code/lib/builder-manager/src/types.ts | 30 ++++++++--------- code/lib/builder-vite/src/envs.ts | 9 ++--- code/lib/builder-vite/src/list-stories.ts | 2 +- .../builder-vite/src/types/envs-raw.type.ts | 1 - code/lib/builder-vite/src/types/index.ts | 1 - code/lib/builder-vite/src/vite-config.ts | 6 ++-- code/lib/store/src/StoryStore.ts | 2 +- code/lib/store/src/autoTitle.ts | 12 +++---- code/lib/store/src/csf/prepareStory.ts | 2 +- code/lib/store/src/csf/testing-utils/index.ts | 2 +- code/lib/store/src/decorators.ts | 7 ++-- code/lib/store/src/filterArgTypes.ts | 11 +++---- code/lib/store/src/hooks.ts | 33 +------------------ code/lib/store/src/index.ts | 5 ++- code/lib/types/src/index.ts | 1 + code/lib/types/src/modules/builder.ts | 13 ++++++++ code/lib/types/src/modules/client-api.ts | 5 ++- code/lib/types/src/modules/store.ts | 13 ++++++++ 18 files changed, 72 insertions(+), 83 deletions(-) delete mode 100644 code/lib/builder-vite/src/types/envs-raw.type.ts create mode 100644 code/lib/types/src/modules/builder.ts diff --git a/code/lib/builder-manager/src/types.ts b/code/lib/builder-manager/src/types.ts index 12723b889ffa..9e9af7ed4004 100644 --- a/code/lib/builder-manager/src/types.ts +++ b/code/lib/builder-manager/src/types.ts @@ -1,32 +1,28 @@ -import type { Builder } from '@storybook/types'; +/* eslint-disable camelcase */ +import type { + Builder, + Builder_WithRequiredProperty, + BuilderStats, + Builder_Unpromise, +} from '@storybook/types'; import type { BuildOptions, BuildResult } from 'esbuild'; -export interface Stats { - // - toJson: () => any; -} - -export type WithRequiredProperty = Type & { - [Property in Key]-?: Type[Property]; -}; - export type ManagerBuilder = Builder< - WithRequiredProperty & { entryPoints: string[] }, - Stats + Builder_WithRequiredProperty & { entryPoints: string[] }, + BuilderStats >; -export type Unpromise> = T extends Promise ? U : never; +export type Compilation = BuildResult; export type BuilderStartOptions = Parameters['0']; -export type BuilderStartResult = Unpromise>; +export type BuilderStartResult = Builder_Unpromise>; + export type StarterFunction = ( options: BuilderStartOptions ) => AsyncGenerator; export type BuilderBuildOptions = Parameters['0']; -export type BuilderBuildResult = Unpromise>; +export type BuilderBuildResult = Builder_Unpromise>; export type BuilderFunction = ( options: BuilderBuildOptions ) => AsyncGenerator; - -export type Compilation = BuildResult; diff --git a/code/lib/builder-vite/src/envs.ts b/code/lib/builder-vite/src/envs.ts index 7ebead6aab45..fbc4f643e37a 100644 --- a/code/lib/builder-vite/src/envs.ts +++ b/code/lib/builder-vite/src/envs.ts @@ -1,7 +1,8 @@ +/* eslint-disable camelcase */ import { stringifyEnvs } from '@storybook/core-common'; import type { UserConfig } from 'vite'; -import type { EnvsRaw } from './types'; +import type { Builder_EnvsRaw } from '@storybook/types'; // Allowed env variables on the client const allowedEnvVariables = [ @@ -19,10 +20,10 @@ const allowedEnvVariables = [ * Customized version of stringifyProcessEnvs from @storybook/core-common which * uses import.meta.env instead of process.env and checks for allowed variables. */ -export function stringifyProcessEnvs(raw: EnvsRaw, envPrefix: UserConfig['envPrefix']) { - const updatedRaw: EnvsRaw = {}; +export function stringifyProcessEnvs(raw: Builder_EnvsRaw, envPrefix: UserConfig['envPrefix']) { + const updatedRaw: Builder_EnvsRaw = {}; const envs = Object.entries(raw).reduce( - (acc: EnvsRaw, [key, value]) => { + (acc: Builder_EnvsRaw, [key, value]) => { // Only add allowed values OR values from array OR string started with allowed prefixes if ( allowedEnvVariables.includes(key) || diff --git a/code/lib/builder-vite/src/list-stories.ts b/code/lib/builder-vite/src/list-stories.ts index de8c86d6ff62..56a962d5d5fb 100644 --- a/code/lib/builder-vite/src/list-stories.ts +++ b/code/lib/builder-vite/src/list-stories.ts @@ -2,7 +2,7 @@ import * as path from 'path'; import { promise as glob } from 'glob-promise'; import { normalizeStories } from '@storybook/core-common'; -import type { Options } from '@storybook/core-common'; +import type { Options } from '@storybook/types'; export async function listStories(options: Options) { return ( diff --git a/code/lib/builder-vite/src/types/envs-raw.type.ts b/code/lib/builder-vite/src/types/envs-raw.type.ts deleted file mode 100644 index cb62e513aacd..000000000000 --- a/code/lib/builder-vite/src/types/envs-raw.type.ts +++ /dev/null @@ -1 +0,0 @@ -export type EnvsRaw = Record; diff --git a/code/lib/builder-vite/src/types/index.ts b/code/lib/builder-vite/src/types/index.ts index e50c278bbd1e..937f58679fe6 100644 --- a/code/lib/builder-vite/src/types/index.ts +++ b/code/lib/builder-vite/src/types/index.ts @@ -1,2 +1 @@ -export * from './envs-raw.type'; export * from './extended-options.type'; diff --git a/code/lib/builder-vite/src/vite-config.ts b/code/lib/builder-vite/src/vite-config.ts index a3c516de5e54..2f72b72ba74a 100644 --- a/code/lib/builder-vite/src/vite-config.ts +++ b/code/lib/builder-vite/src/vite-config.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import * as path from 'path'; import { loadConfigFromFile, mergeConfig } from 'vite'; import type { @@ -8,6 +9,7 @@ import type { } from 'vite'; import viteReact from '@vitejs/plugin-react'; import { isPreservingSymlinks, getFrameworkName } from '@storybook/core-common'; +import type { Builder_EnvsRaw } from '@storybook/types'; import { stringifyProcessEnvs } from './envs'; import { codeGeneratorPlugin, @@ -15,7 +17,7 @@ import { mdxPlugin, stripStoryHMRBoundary, } from './plugins'; -import type { ExtendedOptions, EnvsRaw } from './types'; +import type { ExtendedOptions } from './types'; export type PluginConfigType = 'build' | 'development'; @@ -60,7 +62,7 @@ export async function commonConfig( const config: ViteConfig = mergeConfig(userConfig, sbConfig); // Sanitize environment variables if needed - const envsRaw = await presets.apply>('env'); + const envsRaw = await presets.apply>('env'); if (Object.keys(envsRaw).length) { // Stringify env variables after getting `envPrefix` from the config const envs = stringifyProcessEnvs(envsRaw, config.envPrefix); diff --git a/code/lib/store/src/StoryStore.ts b/code/lib/store/src/StoryStore.ts index 4f20c3c80eca..fd1dbc36ba50 100644 --- a/code/lib/store/src/StoryStore.ts +++ b/code/lib/store/src/StoryStore.ts @@ -27,11 +27,11 @@ import mapValues from 'lodash/mapValues'; import pick from 'lodash/pick'; import { SynchronousPromise } from 'synchronous-promise'; +import { HooksContext } from '@storybook/addons'; import { StoryIndexStore } from './StoryIndexStore'; import { ArgsStore } from './ArgsStore'; import { GlobalsStore } from './GlobalsStore'; import { processCSFFile, prepareStory, normalizeProjectAnnotations } from './csf'; -import { HooksContext } from './hooks'; // TODO -- what are reasonable values for these? const CSF_CACHE_SIZE = 1000; diff --git a/code/lib/store/src/autoTitle.ts b/code/lib/store/src/autoTitle.ts index a7885371b92e..e1bc561299b2 100644 --- a/code/lib/store/src/autoTitle.ts +++ b/code/lib/store/src/autoTitle.ts @@ -1,15 +1,11 @@ +/* eslint-disable camelcase */ import slash from 'slash'; import { dedent } from 'ts-dedent'; import { once } from '@storybook/client-logger'; +import type { Store_NormalizedStoriesSpecifierEntry } from '@storybook/types'; // FIXME: types duplicated type from `core-common', to be // removed when we remove v6 back-compat. -interface NormalizedStoriesSpecifier { - titlePrefix?: string; - directory: string; - files?: string; - importPathMatcher: RegExp; -} const stripExtension = (path: string[]) => { let parts = [...path]; @@ -52,7 +48,7 @@ function pathJoin(paths: string[]): string { export const userOrAutoTitleFromSpecifier = ( fileName: string | number, - entry: NormalizedStoriesSpecifier, + entry: Store_NormalizedStoriesSpecifierEntry, userTitle?: string ) => { const { directory, importPathMatcher, titlePrefix = '' } = entry || {}; @@ -91,7 +87,7 @@ export const userOrAutoTitleFromSpecifier = ( export const userOrAutoTitle = ( fileName: string, - storiesEntries: NormalizedStoriesSpecifier[], + storiesEntries: Store_NormalizedStoriesSpecifierEntry[], userTitle?: string ) => { for (let i = 0; i < storiesEntries.length; i += 1) { diff --git a/code/lib/store/src/csf/prepareStory.ts b/code/lib/store/src/csf/prepareStory.ts index 03f98a3946c9..cf11d4387a9b 100644 --- a/code/lib/store/src/csf/prepareStory.ts +++ b/code/lib/store/src/csf/prepareStory.ts @@ -23,8 +23,8 @@ import type { } from '@storybook/types'; import { includeConditionalArg } from '@storybook/csf'; +import { applyHooks } from '@storybook/addons'; import { combineParameters } from '../parameters'; -import { applyHooks } from '../hooks'; import { defaultDecorateStory } from '../decorators'; import { groupArgsByTarget, NO_TARGET_NAME } from '../args'; import { getValuesFromArgTypes } from './getValuesFromArgTypes'; diff --git a/code/lib/store/src/csf/testing-utils/index.ts b/code/lib/store/src/csf/testing-utils/index.ts index 8656bafe3f59..4943274345c5 100644 --- a/code/lib/store/src/csf/testing-utils/index.ts +++ b/code/lib/store/src/csf/testing-utils/index.ts @@ -11,10 +11,10 @@ import { LegacyStoryAnnotationsOrFn, } from '@storybook/types'; +import { HooksContext } from '@storybook/addons'; import { composeConfigs } from '../composeConfigs'; import { prepareStory } from '../prepareStory'; import { normalizeStory } from '../normalizeStory'; -import { HooksContext } from '../../hooks'; import { normalizeComponentAnnotations } from '../normalizeComponentAnnotations'; import { getValuesFromArgTypes } from '../getValuesFromArgTypes'; import { normalizeProjectAnnotations } from '../normalizeProjectAnnotations'; diff --git a/code/lib/store/src/decorators.ts b/code/lib/store/src/decorators.ts index 7605cb6904c0..0fad11f07baa 100644 --- a/code/lib/store/src/decorators.ts +++ b/code/lib/store/src/decorators.ts @@ -1,10 +1,11 @@ +/* eslint-disable camelcase */ import type { DecoratorFunction, - StoryContext, StoryContextUpdate, PartialStoryFn, LegacyStoryFn, AnyFramework, + Store_ContextStore, } from '@storybook/types'; export function decorateStory( @@ -20,8 +21,6 @@ export function decorateStory( return (context) => decorator(boundStoryFunction, context); } -type ContextStore = { value?: StoryContext }; - /** * Currently StoryContextUpdates are allowed to have any key in the type. * However, you cannot overwrite any of the build-it "static" keys. @@ -54,7 +53,7 @@ export function defaultDecorateStory( // (ie to this story), so there is no possibility of overlap. // This will break if you call the same story twice interleaved // (React might do it if you rendered the same story twice in the one ReactDom.render call, for instance) - const contextStore: ContextStore = {}; + const contextStore: Store_ContextStore = {}; /** * When you call the story function inside a decorator, e.g.: diff --git a/code/lib/store/src/filterArgTypes.ts b/code/lib/store/src/filterArgTypes.ts index c28c2f99491f..1ef8c54b5532 100644 --- a/code/lib/store/src/filterArgTypes.ts +++ b/code/lib/store/src/filterArgTypes.ts @@ -1,15 +1,14 @@ -import type { StrictArgTypes } from '@storybook/types'; +/* eslint-disable camelcase */ +import type { Store_PropDescriptor, StrictArgTypes } from '@storybook/types'; import pickBy from 'lodash/pickBy'; -export type PropDescriptor = string[] | RegExp; - -const matches = (name: string, descriptor: PropDescriptor) => +const matches = (name: string, descriptor: Store_PropDescriptor) => Array.isArray(descriptor) ? descriptor.includes(name) : name.match(descriptor); export const filterArgTypes = ( argTypes: StrictArgTypes, - include?: PropDescriptor, - exclude?: PropDescriptor + include?: Store_PropDescriptor, + exclude?: Store_PropDescriptor ) => { if (!include && !exclude) { return argTypes; diff --git a/code/lib/store/src/hooks.ts b/code/lib/store/src/hooks.ts index 69ad8b95e691..cfff7934ec3b 100644 --- a/code/lib/store/src/hooks.ts +++ b/code/lib/store/src/hooks.ts @@ -1,37 +1,6 @@ import { SHARED_STATE_CHANGED, SHARED_STATE_SET } from '@storybook/core-events'; -import { - addons, - HooksContext, - applyHooks, - useMemo, - useCallback, - useRef, - useState, - useReducer, - useEffect, - useChannel, - useStoryContext, - useParameter, - useArgs, - useGlobals, -} from '@storybook/addons'; - -export { - HooksContext, - applyHooks, - useMemo, - useCallback, - useRef, - useState, - useReducer, - useEffect, - useChannel, - useStoryContext, - useParameter, - useArgs, - useGlobals, -}; +import { addons, useMemo, useState, useEffect, useChannel } from '@storybook/addons'; export function useSharedState(sharedId: string, defaultState?: S): [S, (s: S) => void] { const channel = addons.getChannel(); diff --git a/code/lib/store/src/index.ts b/code/lib/store/src/index.ts index f6694ad9017b..e532a803a1be 100644 --- a/code/lib/store/src/index.ts +++ b/code/lib/store/src/index.ts @@ -1,9 +1,12 @@ +/* eslint-disable camelcase */ export { StoryStore } from './StoryStore'; export { combineParameters } from './parameters'; export { filterArgTypes } from './filterArgTypes'; -export type { PropDescriptor } from './filterArgTypes'; export { inferControls } from './inferControls'; +// TODO remove +export type { Store_PropDescriptor as PropDescriptor } from '@storybook/types'; + export * from './csf'; export * from './hooks'; export * from './decorators'; diff --git a/code/lib/types/src/index.ts b/code/lib/types/src/index.ts index 63b43450b6ae..84fa78dee25b 100644 --- a/code/lib/types/src/index.ts +++ b/code/lib/types/src/index.ts @@ -4,3 +4,4 @@ export * from './modules/store'; export * from './modules/client-api'; export * from './modules/core-client'; export * from './modules/core-common'; +export * from './modules/builder'; diff --git a/code/lib/types/src/modules/builder.ts b/code/lib/types/src/modules/builder.ts new file mode 100644 index 000000000000..221715d4b2d1 --- /dev/null +++ b/code/lib/types/src/modules/builder.ts @@ -0,0 +1,13 @@ +/* eslint-disable camelcase */ +export interface BuilderStats { + // + toJson: () => any; +} + +export type Builder_WithRequiredProperty = Type & { + [Property in Key]-?: Type[Property]; +}; + +export type Builder_Unpromise> = T extends Promise ? U : never; + +export type Builder_EnvsRaw = Record; diff --git a/code/lib/types/src/modules/client-api.ts b/code/lib/types/src/modules/client-api.ts index 908abab0265d..a4e9a5341b15 100644 --- a/code/lib/types/src/modules/client-api.ts +++ b/code/lib/types/src/modules/client-api.ts @@ -1,7 +1,6 @@ /* eslint-disable camelcase */ -import type { Addon } from '@storybook/addons'; - -import type { StoryStore, HooksContext } from '@storybook/store'; +import type { Addon, HooksContext } from '@storybook/addons'; +import type { StoryStore } from '@storybook/store'; import type { Addon_StoryApi } from './addons'; import type { Store_RenderContext } from './store'; import type { diff --git a/code/lib/types/src/modules/store.ts b/code/lib/types/src/modules/store.ts index ca347aa48af8..b2111b3df3c2 100644 --- a/code/lib/types/src/modules/store.ts +++ b/code/lib/types/src/modules/store.ts @@ -152,3 +152,16 @@ export interface Store_NormalizedStoriesSpecifier { export type Store_ExtractOptions = { includeDocsOnly?: boolean; }; + +export interface Store_NormalizedStoriesSpecifierEntry { + titlePrefix?: string; + directory: string; + files?: string; + importPathMatcher: RegExp; +} + +export type Store_ContextStore = { + value?: StoryContext; +}; + +export type Store_PropDescriptor = string[] | RegExp; From 0b474de2f77dd3d2300c3fac422e472a32927c0f Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sat, 22 Oct 2022 01:52:23 +0200 Subject: [PATCH 11/38] step 8 --- code/lib/store/src/csf/testing-utils/index.ts | 30 ++-------- code/lib/store/src/csf/testing-utils/types.ts | 41 ------------- code/lib/store/src/index.ts | 4 -- code/lib/store/src/inferControls.ts | 20 ++++--- code/lib/types/src/modules/store.ts | 60 +++++++++++++++++++ 5 files changed, 79 insertions(+), 76 deletions(-) delete mode 100644 code/lib/store/src/csf/testing-utils/types.ts diff --git a/code/lib/store/src/csf/testing-utils/index.ts b/code/lib/store/src/csf/testing-utils/index.ts index 4943274345c5..d1f81ed6cda1 100644 --- a/code/lib/store/src/csf/testing-utils/index.ts +++ b/code/lib/store/src/csf/testing-utils/index.ts @@ -1,26 +1,23 @@ +/* eslint-disable camelcase */ import { isExportStory } from '@storybook/csf'; import { AnyFramework, - AnnotatedStoryFn, - StoryAnnotations, ComponentAnnotations, ProjectAnnotations, Args, StoryContext, - Parameters, LegacyStoryAnnotationsOrFn, + Store_ComposeStory, } from '@storybook/types'; import { HooksContext } from '@storybook/addons'; +import type { Store_CSFExports, Store_ComposedStoryPlayFn } from '@storybook/types'; import { composeConfigs } from '../composeConfigs'; import { prepareStory } from '../prepareStory'; import { normalizeStory } from '../normalizeStory'; import { normalizeComponentAnnotations } from '../normalizeComponentAnnotations'; import { getValuesFromArgTypes } from '../getValuesFromArgTypes'; import { normalizeProjectAnnotations } from '../normalizeProjectAnnotations'; -import type { CSFExports, ComposedStoryPlayFn } from './types'; - -export * from './types'; let GLOBAL_STORYBOOK_PROJECT_ANNOTATIONS = {}; @@ -31,21 +28,6 @@ export function setProjectAnnotations { - ( - storyAnnotations: AnnotatedStoryFn | StoryAnnotations, - componentAnnotations: ComponentAnnotations, - projectAnnotations: ProjectAnnotations, - exportsName?: string - ): { - (extraArgs: Partial): TFramework['storyResult']; - storyName: string; - args: Args; - play: ComposedStoryPlayFn; - parameters: Parameters; - }; -} - export function composeStory< TFramework extends AnyFramework = AnyFramework, TArgs extends Args = Args @@ -105,16 +87,16 @@ export function composeStory< composedStory.storyName = storyName; composedStory.args = story.initialArgs; - composedStory.play = story.playFunction as ComposedStoryPlayFn; + composedStory.play = story.playFunction as Store_ComposedStoryPlayFn; composedStory.parameters = story.parameters; return composedStory; } -export function composeStories( +export function composeStories( storiesImport: TModule, globalConfig: ProjectAnnotations, - composeStoryFn: ComposeStory + composeStoryFn: Store_ComposeStory ) { const { default: meta, __esModule, __namedExportsOrder, ...stories } = storiesImport; const composedStories = Object.entries(stories).reduce((storiesMap, [exportsName, story]) => { diff --git a/code/lib/store/src/csf/testing-utils/types.ts b/code/lib/store/src/csf/testing-utils/types.ts deleted file mode 100644 index 459cd9e1fb92..000000000000 --- a/code/lib/store/src/csf/testing-utils/types.ts +++ /dev/null @@ -1,41 +0,0 @@ -import type { - AnyFramework, - AnnotatedStoryFn, - StoryAnnotations, - ComponentAnnotations, - Args, - StoryContext, -} from '@storybook/types'; - -export type CSFExports = { - default: ComponentAnnotations; - __esModule?: boolean; - __namedExportsOrder?: string[]; -}; - -export type ComposedStoryPlayContext = Partial & Pick; - -export type ComposedStoryPlayFn = (context: ComposedStoryPlayContext) => Promise | void; - -export type StoryFn< - TFramework extends AnyFramework = AnyFramework, - TArgs = Args -> = AnnotatedStoryFn & { play: ComposedStoryPlayFn }; - -export type ComposedStory = - | StoryFn - | StoryAnnotations; - -/** - * T represents the whole ES module of a stories file. K of T means named exports (basically the Story type) - * 1. pick the keys K of T that have properties that are Story - * 2. infer the actual prop type for each Story - * 3. reconstruct Story with Partial. Story -> Story> - */ -export type StoriesWithPartialProps = { - // @TODO once we can use Typescript 4.0 do this to exclude nonStory exports: - // replace [K in keyof TModule] with [K in keyof TModule as TModule[K] extends ComposedStory ? K : never] - [K in keyof TModule]: TModule[K] extends ComposedStory - ? AnnotatedStoryFn> - : unknown; -}; diff --git a/code/lib/store/src/index.ts b/code/lib/store/src/index.ts index e532a803a1be..ae7bcb809040 100644 --- a/code/lib/store/src/index.ts +++ b/code/lib/store/src/index.ts @@ -1,12 +1,8 @@ -/* eslint-disable camelcase */ export { StoryStore } from './StoryStore'; export { combineParameters } from './parameters'; export { filterArgTypes } from './filterArgTypes'; export { inferControls } from './inferControls'; -// TODO remove -export type { Store_PropDescriptor as PropDescriptor } from '@storybook/types'; - export * from './csf'; export * from './hooks'; export * from './decorators'; diff --git a/code/lib/store/src/inferControls.ts b/code/lib/store/src/inferControls.ts index 93b31e1882be..af769d9333d7 100644 --- a/code/lib/store/src/inferControls.ts +++ b/code/lib/store/src/inferControls.ts @@ -1,15 +1,21 @@ +/* eslint-disable camelcase */ import mapValues from 'lodash/mapValues'; import { logger } from '@storybook/client-logger'; -import type { AnyFramework, SBEnumType, StrictInputType, ArgTypesEnhancer } from '@storybook/types'; +import type { + AnyFramework, + SBEnumType, + StrictInputType, + ArgTypesEnhancer, + Store_ControlsMatchers, +} from '@storybook/types'; import { filterArgTypes } from './filterArgTypes'; import { combineParameters } from './parameters'; -type ControlsMatchers = { - date: RegExp; - color: RegExp; -}; - -const inferControl = (argType: StrictInputType, name: string, matchers: ControlsMatchers): any => { +const inferControl = ( + argType: StrictInputType, + name: string, + matchers: Store_ControlsMatchers +): any => { const { type, options } = argType; if (!type) { return undefined; diff --git a/code/lib/types/src/modules/store.ts b/code/lib/types/src/modules/store.ts index b2111b3df3c2..3bfd62a7eb65 100644 --- a/code/lib/types/src/modules/store.ts +++ b/code/lib/types/src/modules/store.ts @@ -2,6 +2,7 @@ import type { SynchronousPromise } from 'synchronous-promise'; import type { Addon_IndexEntry, Addon_StoryIndexEntry } from './addons'; import type { + AnnotatedStoryFn, AnyFramework, Args, ComponentAnnotations, @@ -165,3 +166,62 @@ export type Store_ContextStore = { }; export type Store_PropDescriptor = string[] | RegExp; + +export type Store_CSFExports = { + default: ComponentAnnotations; + __esModule?: boolean; + __namedExportsOrder?: string[]; +}; + +export type Store_ComposedStoryPlayContext = Partial & + Pick; + +export type Store_ComposedStoryPlayFn = ( + context: Store_ComposedStoryPlayContext +) => Promise | void; + +export type Store_StoryFn< + TFramework extends AnyFramework = AnyFramework, + TArgs = Args +> = AnnotatedStoryFn & { play: Store_ComposedStoryPlayFn }; + +export type Store_ComposedStory = + | StoryFn + | StoryAnnotations; + +/** + * T represents the whole ES module of a stories file. K of T means named exports (basically the Story type) + * 1. pick the keys K of T that have properties that are Story + * 2. infer the actual prop type for each Story + * 3. reconstruct Story with Partial. Story -> Story> + */ +export type Store_StoriesWithPartialProps = { + // @TODO once we can use Typescript 4.0 do this to exclude nonStory exports: + // replace [K in keyof TModule] with [K in keyof TModule as TModule[K] extends ComposedStory ? K : never] + [K in keyof TModule]: TModule[K] extends Store_ComposedStory + ? AnnotatedStoryFn> + : unknown; +}; + +export type Store_ControlsMatchers = { + date: RegExp; + color: RegExp; +}; + +export interface Store_ComposeStory< + TFramework extends AnyFramework = AnyFramework, + TArgs extends Args = Args +> { + ( + storyAnnotations: AnnotatedStoryFn | StoryAnnotations, + componentAnnotations: ComponentAnnotations, + projectAnnotations: ProjectAnnotations, + exportsName?: string + ): { + (extraArgs: Partial): TFramework['storyResult']; + storyName: string; + args: Args; + play: Store_ComposedStoryPlayFn; + parameters: Parameters; + }; +} From e3e1e62e306f17a182980cb934cca8ddfd1818d8 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sat, 22 Oct 2022 02:19:58 +0200 Subject: [PATCH 12/38] step 9 --- code/lib/core-client/src/preview/index.ts | 3 +- code/lib/core-client/src/preview/start.ts | 12 +++---- code/lib/core-common/src/presets.ts | 16 +++------- .../utils/__tests__/check-addon-order.test.ts | 14 +++++--- .../src/utils/check-addon-order.ts | 25 +++++++++------ .../src/utils/get-storybook-info.ts | 20 ++---------- code/lib/csf-tools/src/CsfFile.ts | 23 ++++--------- code/lib/types/src/modules/core-client.ts | 3 +- code/lib/types/src/modules/core-common.ts | 32 +++++++++++++++++++ code/lib/types/src/modules/csf.ts | 15 +++++++++ 10 files changed, 95 insertions(+), 68 deletions(-) diff --git a/code/lib/core-client/src/preview/index.ts b/code/lib/core-client/src/preview/index.ts index 64bcb0a0c89b..23c8d04e27e1 100644 --- a/code/lib/core-client/src/preview/index.ts +++ b/code/lib/core-client/src/preview/index.ts @@ -1,6 +1,5 @@ import { ClientApi } from '@storybook/client-api'; import { StoryStore } from '@storybook/store'; -import { toId } from '@storybook/csf'; import { start } from './start'; -export { start, toId, ClientApi, StoryStore }; +export { start, ClientApi, StoryStore }; diff --git a/code/lib/core-client/src/preview/start.ts b/code/lib/core-client/src/preview/start.ts index 55d381adf386..7c0430aa06e0 100644 --- a/code/lib/core-client/src/preview/start.ts +++ b/code/lib/core-client/src/preview/start.ts @@ -21,31 +21,31 @@ const removedApi = (name: string) => () => { throw new Error(`@storybook/client-api:${name} was removed in storyStoreV7.`); }; -interface RendererImplementation { +interface CoreClient_RendererImplementation { decorateStory?: Store_WebProjectAnnotations['applyDecorators']; render?: ArgsStoryFn; } -interface ClientAPIFacade { +interface CoreClient_ClientAPIFacade { /* deprecated */ storiesOf: (...args: any[]) => never; /* deprecated */ raw: (...args: any[]) => never; } -interface StartReturnValue { +interface CoreClient_StartReturnValue { /* deprecated */ forceReRender: () => void; /* deprecated */ configure: any; /* deprecated */ - clientApi: ClientApi | ClientAPIFacade; + clientApi: ClientApi | CoreClient_ClientAPIFacade; } export function start( renderToDOM: Store_WebProjectAnnotations['renderToDOM'], - { decorateStory, render }: RendererImplementation = {} -): StartReturnValue { + { decorateStory, render }: CoreClient_RendererImplementation = {} +): CoreClient_StartReturnValue { if (globalWindow) { // To enable user code to detect if it is running in Storybook globalWindow.IS_STORYBOOK = true; diff --git a/code/lib/core-common/src/presets.ts b/code/lib/core-common/src/presets.ts index d960f4dcfd66..4e2cb4f8cd82 100644 --- a/code/lib/core-common/src/presets.ts +++ b/code/lib/core-common/src/presets.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import { dedent } from 'ts-dedent'; import { logger } from '@storybook/node-logger'; import { dirname } from 'path'; @@ -8,6 +9,8 @@ import { PresetConfig, Presets, BuilderOptions, + CoreCommon_ResolvedAddonPreset, + CoreCommon_ResolvedAddonVirtual, } from '@storybook/types'; import { loadCustomPresets } from './utils/load-custom-presets'; import { safeResolve, safeResolveFrom } from './utils/safeResolve'; @@ -55,23 +58,12 @@ function resolvePresetFunction( * - { name: '@storybook/addon-docs(/preset)?', options: { ... } } * => { type: 'presets', item: { name: '@storybook/addon-docs/preset', options } } */ -interface ResolvedAddonPreset { - type: 'presets'; - name: string; -} -interface ResolvedAddonVirtual { - type: 'virtual'; - name: string; - managerEntries?: string[]; - previewAnnotations?: string[]; - presets?: (string | { name: string; options?: any })[]; -} export const resolveAddonName = ( configDir: string, name: string, options: any -): ResolvedAddonPreset | ResolvedAddonVirtual | undefined => { +): CoreCommon_ResolvedAddonPreset | CoreCommon_ResolvedAddonVirtual | undefined => { const resolve = name.startsWith('/') ? safeResolve : safeResolveFrom.bind(null, configDir); const resolved = resolve(name); diff --git a/code/lib/core-common/src/utils/__tests__/check-addon-order.test.ts b/code/lib/core-common/src/utils/__tests__/check-addon-order.test.ts index 8cd60be101cc..66fa015ea1aa 100644 --- a/code/lib/core-common/src/utils/__tests__/check-addon-order.test.ts +++ b/code/lib/core-common/src/utils/__tests__/check-addon-order.test.ts @@ -1,5 +1,11 @@ +/* eslint-disable camelcase */ import { logger } from '@storybook/node-logger'; -import { checkAddonOrder, AddonEntry, AddonInfo, OptionsEntry } from '../check-addon-order'; +import { + CoreCommon_AddonEntry, + CoreCommon_AddonInfo, + CoreCommon_OptionsEntry, +} from '@storybook/types'; +import { checkAddonOrder } from '../check-addon-order'; const configFile = './main.js'; const essentialAddons = [ @@ -13,15 +19,15 @@ const essentialAddons = [ 'outline', ]; -const pkgName = (entry: AddonEntry): string => { +const pkgName = (entry: CoreCommon_AddonEntry): string => { if (typeof entry === 'string') { if (entry.includes('node_modules')) return entry; return `@storybook/addon-${entry}`; } - return (entry as OptionsEntry).name; + return (entry as CoreCommon_OptionsEntry).name; }; -const fromName = (name: string): AddonInfo => ({ +const fromName = (name: string): CoreCommon_AddonInfo => ({ name: pkgName(name), inEssentials: essentialAddons.includes(name), }); diff --git a/code/lib/core-common/src/utils/check-addon-order.ts b/code/lib/core-common/src/utils/check-addon-order.ts index 55ee394a484f..35b747b48611 100644 --- a/code/lib/core-common/src/utils/check-addon-order.ts +++ b/code/lib/core-common/src/utils/check-addon-order.ts @@ -1,22 +1,29 @@ -const { logger } = require('@storybook/node-logger'); +/* eslint-disable camelcase */ +import type { + CoreCommon_AddonEntry, + CoreCommon_AddonInfo, + CoreCommon_OptionsEntry, +} from '@storybook/types'; -export type OptionsEntry = { name: string }; -export type AddonEntry = string | OptionsEntry; -export type AddonInfo = { name: string; inEssentials: boolean }; +import { logger } from '@storybook/node-logger'; interface Options { - before: AddonInfo; - after: AddonInfo; + before: CoreCommon_AddonInfo; + after: CoreCommon_AddonInfo; configFile: string; getConfig: (path: string) => any; } -const predicateFor = (addon: string) => (entry: AddonEntry) => { - const name = (entry as OptionsEntry).name || (entry as string); +const predicateFor = (addon: string) => (entry: CoreCommon_AddonEntry) => { + const name = (entry as CoreCommon_OptionsEntry).name || (entry as string); return name && name.includes(addon); }; -const isCorrectOrder = (addons: AddonEntry[], before: AddonInfo, after: AddonInfo) => { +const isCorrectOrder = ( + addons: CoreCommon_AddonEntry[], + before: CoreCommon_AddonInfo, + after: CoreCommon_AddonInfo +) => { const essentialsIndex = addons.findIndex(predicateFor('@storybook/addon-essentials')); let beforeIndex = addons.findIndex(predicateFor(before.name)); let afterIndex = addons.findIndex(predicateFor(after.name)); diff --git a/code/lib/core-common/src/utils/get-storybook-info.ts b/code/lib/core-common/src/utils/get-storybook-info.ts index 1f8ddf1d8ae4..c1efc457847c 100644 --- a/code/lib/core-common/src/utils/get-storybook-info.ts +++ b/code/lib/core-common/src/utils/get-storybook-info.ts @@ -1,23 +1,9 @@ +/* eslint-disable camelcase */ import path from 'path'; import fse from 'fs-extra'; -import { PackageJson } from '@storybook/types'; +import { CoreCommon_StorybookInfo, PackageJson } from '@storybook/types'; import { getStorybookConfiguration } from './get-storybook-configuration'; -interface StorybookInfo { - version: string; - // FIXME: these are renderers for now, - // need to update with framework OR fix - // the calling code - framework: string; - frameworkPackage: string; - renderer: string; - rendererPackage: string; - configDir?: string; - mainConfig?: string; - previewConfig?: string; - managerConfig?: string; -} - const rendererPackages: Record = { '@storybook/react': 'react', '@storybook/vue': 'vue', @@ -106,5 +92,5 @@ export const getStorybookInfo = (packageJson: PackageJson) => { return { ...rendererInfo, ...configInfo, - } as StorybookInfo; + } as CoreCommon_StorybookInfo; }; diff --git a/code/lib/csf-tools/src/CsfFile.ts b/code/lib/csf-tools/src/CsfFile.ts index 167005a1aae2..2cd82aef7be6 100644 --- a/code/lib/csf-tools/src/CsfFile.ts +++ b/code/lib/csf-tools/src/CsfFile.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ /* eslint-disable no-underscore-dangle */ import fs from 'fs-extra'; import { dedent } from 'ts-dedent'; @@ -5,22 +6,10 @@ import * as t from '@babel/types'; import generate from '@babel/generator'; import traverse from '@babel/traverse'; import { toId, isExportStory, storyNameFromExport } from '@storybook/csf'; +import type { CSF_Meta, CSF_Story } from '@storybook/types'; import { babelParse } from './babelParse'; const logger = console; -interface Meta { - id?: string; - title?: string; - component?: string; - includeStories?: string[] | RegExp; - excludeStories?: string[] | RegExp; -} - -interface Story { - id: string; - name: string; - parameters: Record; -} function parseIncludeExclude(prop: t.Node) { if (t.isArrayExpression(prop)) { @@ -146,9 +135,9 @@ export class CsfFile { _makeTitle: (title: string) => string; - _meta?: Meta; + _meta?: CSF_Meta; - _stories: Record = {}; + _stories: Record = {}; _metaAnnotations: Record = {}; @@ -182,7 +171,7 @@ export class CsfFile { } _parseMeta(declaration: t.ObjectExpression, program: t.Program) { - const meta: Meta = {}; + const meta: CSF_Meta = {}; declaration.properties.forEach((p: t.ObjectProperty) => { if (t.isIdentifier(p.key)) { this._metaAnnotations[p.key.name] = p.value; @@ -417,7 +406,7 @@ export class CsfFile { acc[key] = { ...story, id, parameters }; } return acc; - }, {} as Record); + }, {} as Record); Object.keys(self._storyExports).forEach((key) => { if (!isExportStory(key, self._meta)) { diff --git a/code/lib/types/src/modules/core-client.ts b/code/lib/types/src/modules/core-client.ts index 1f0b27416992..c74e548caadd 100644 --- a/code/lib/types/src/modules/core-client.ts +++ b/code/lib/types/src/modules/core-client.ts @@ -1,6 +1,7 @@ /* eslint-disable camelcase */ -import { Store_RenderContext } from './store'; +import { Store_RenderContext, Store_WebProjectAnnotations } from './store'; import type { ClientAPI_RenderContextWithoutStoryContext } from './client-api'; +import { ArgsStoryFn } from './csf'; export interface CoreClient_PreviewError { message?: string; diff --git a/code/lib/types/src/modules/core-common.ts b/code/lib/types/src/modules/core-common.ts index 42c8c34fdd35..2f05cd163c57 100644 --- a/code/lib/types/src/modules/core-common.ts +++ b/code/lib/types/src/modules/core-common.ts @@ -452,3 +452,35 @@ export type PresetPropertyFn | TStorybookConfig[K extends keyof TStorybookConfig ? K : never] | Promise; + +export interface CoreCommon_ResolvedAddonPreset { + type: 'presets'; + name: string; +} + +export interface CoreCommon_ResolvedAddonVirtual { + type: 'virtual'; + name: string; + managerEntries?: string[]; + previewAnnotations?: string[]; + presets?: (string | { name: string; options?: any })[]; +} + +export type CoreCommon_OptionsEntry = { name: string }; +export type CoreCommon_AddonEntry = string | CoreCommon_OptionsEntry; +export type CoreCommon_AddonInfo = { name: string; inEssentials: boolean }; + +export interface CoreCommon_StorybookInfo { + version: string; + // FIXME: these are renderers for now, + // need to update with framework OR fix + // the calling code + framework: string; + frameworkPackage: string; + renderer: string; + rendererPackage: string; + configDir?: string; + mainConfig?: string; + previewConfig?: string; + managerConfig?: string; +} diff --git a/code/lib/types/src/modules/csf.ts b/code/lib/types/src/modules/csf.ts index fa290b3b32a7..f62b833cf9ba 100644 --- a/code/lib/types/src/modules/csf.ts +++ b/code/lib/types/src/modules/csf.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import type { ViewMode, AnnotatedStoryFn, @@ -111,3 +112,17 @@ export { StrictGlobalTypes, StrictInputType, }; + +export interface CSF_Meta { + id?: string; + title?: string; + component?: string; + includeStories?: string[] | RegExp; + excludeStories?: string[] | RegExp; +} + +export interface CSF_Story { + id: string; + name: string; + parameters: Record; +} From fbb0895b797b75eba9ab266ab1d8788d79fa21ef Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sat, 22 Oct 2022 03:25:59 +0200 Subject: [PATCH 13/38] step 9 --- .../ComputesTemplateFromComponent.ts | 7 +- .../angular/src/client/docs/compodoc.ts | 7 +- code/lib/api/src/index.tsx | 121 +++----- code/lib/api/src/lib/events.ts | 6 +- code/lib/api/src/lib/shortcut.ts | 18 +- code/lib/api/src/lib/stories.ts | 282 +++-------------- code/lib/api/src/modules/addons.ts | 62 +--- code/lib/api/src/modules/globals.ts | 41 ++- code/lib/api/src/modules/layout.ts | 41 +-- code/lib/api/src/modules/notifications.ts | 22 +- code/lib/api/src/modules/provider.ts | 41 +-- code/lib/api/src/modules/refs.ts | 105 +++---- code/lib/api/src/modules/release-notes.ts | 10 +- code/lib/api/src/modules/settings.ts | 8 +- code/lib/api/src/modules/shortcuts.ts | 106 +++---- code/lib/api/src/modules/stories.ts | 70 ++--- code/lib/api/src/modules/url.ts | 7 +- code/lib/api/src/modules/versions.ts | 28 +- code/lib/types/src/index.ts | 2 + code/lib/types/src/modules/api-stories.ts | 288 ++++++++++++++++++ code/lib/types/src/modules/api.ts | 190 ++++++++++++ 21 files changed, 771 insertions(+), 691 deletions(-) create mode 100644 code/lib/types/src/modules/api-stories.ts create mode 100644 code/lib/types/src/modules/api.ts diff --git a/code/frameworks/angular/src/client/angular-beta/ComputesTemplateFromComponent.ts b/code/frameworks/angular/src/client/angular-beta/ComputesTemplateFromComponent.ts index ade69fb64695..77a1e41c9a85 100644 --- a/code/frameworks/angular/src/client/angular-beta/ComputesTemplateFromComponent.ts +++ b/code/frameworks/angular/src/client/angular-beta/ComputesTemplateFromComponent.ts @@ -1,5 +1,6 @@ +/* eslint-disable camelcase */ import type { Type } from '@angular/core'; -import type { ArgType, ArgTypes } from '@storybook/api'; +import type { API_ArgType, API_ArgTypes } from '@storybook/types'; import type { ICollection } from '../types'; import { ComponentInputsOutputs, @@ -71,7 +72,7 @@ const createAngularInputProperty = ({ }: { propertyName: string; value: any; - argType?: ArgType; + argType?: API_ArgType; }) => { const { name: type = null, summary = null } = argType?.type || {}; let templateValue = type === 'enum' && !!summary ? `${summary}.${value}` : value; @@ -97,7 +98,7 @@ const createAngularInputProperty = ({ export const computesTemplateSourceFromComponent = ( component: Type, initialProps?: ICollection, - argTypes?: ArgTypes + argTypes?: API_ArgTypes ) => { const ngComponentMetadata = getComponentDecoratorMetadata(component); if (!ngComponentMetadata) { diff --git a/code/frameworks/angular/src/client/docs/compodoc.ts b/code/frameworks/angular/src/client/docs/compodoc.ts index d8d16c2eb2aa..955130827ffe 100644 --- a/code/frameworks/angular/src/client/docs/compodoc.ts +++ b/code/frameworks/angular/src/client/docs/compodoc.ts @@ -1,7 +1,8 @@ +/* eslint-disable camelcase */ /* eslint-disable no-underscore-dangle */ /* global window */ -import type { ArgType, ArgTypes } from '@storybook/api'; +import type { API_ArgType, API_ArgTypes } from '@storybook/types'; import { logger } from '@storybook/client-logger'; import type { Argument, @@ -221,7 +222,7 @@ const resolveTypealias = (compodocType: string): string => { }; export const extractArgTypesFromData = (componentData: Class | Directive | Injectable | Pipe) => { - const sectionToItems: Record = {}; + const sectionToItems: Record = {}; const compodocClasses = ['component', 'directive'].includes(componentData.type) ? ['propertiesClass', 'methodsClass', 'inputsClass', 'outputsClass'] : ['properties', 'methods']; @@ -278,7 +279,7 @@ export const extractArgTypesFromData = (componentData: Class | Directive | Injec 'content child', 'content children', ]; - const argTypes: ArgTypes = {}; + const argTypes: API_ArgTypes = {}; SECTIONS.forEach((section) => { const items = sectionToItems[section]; if (items) { diff --git a/code/lib/api/src/index.tsx b/code/lib/api/src/index.tsx index 8956c0ec79a0..115d5d61337a 100644 --- a/code/lib/api/src/index.tsx +++ b/code/lib/api/src/index.tsx @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import React, { Component, Fragment, @@ -11,7 +12,14 @@ import React, { useRef, } from 'react'; import mergeWith from 'lodash/mergeWith'; -import { Conditional } from '@storybook/types'; +import { + API_Args, + API_ArgTypes, + API_OptionsData, + API_ProviderData, + API_StateMerger, + StoryId, +} from '@storybook/types'; import { STORY_CHANGED, @@ -21,22 +29,23 @@ import { } from '@storybook/core-events'; import type { RouterData } from '@storybook/router'; import type { Listener } from '@storybook/channels'; -import type { DocsOptions } from '@storybook/types'; +import type { + API_StoriesHash, + API_RootEntry, + API_GroupEntry, + API_ComponentEntry, + API_DocsEntry, + API_StoryEntry, + API_HashEntry, + API_LeafEntry, + API_ComposedRef, + API_Refs, + Parameters, +} from '@storybook/types'; import { createContext } from './context'; import Store, { Options } from './store'; import getInitialState from './initial-state'; -import type { - StoriesHash, - RootEntry, - GroupEntry, - ComponentEntry, - DocsEntry, - StoryEntry, - HashEntry, - LeafEntry, -} from './lib/stories'; -import type { ComposedRef, Refs } from './modules/refs'; import * as provider from './modules/provider'; import * as addons from './modules/addons'; @@ -61,17 +70,13 @@ export { ActiveTabs }; export const ManagerContext = createContext({ api: undefined, state: getInitialState({}) }); export type ModuleArgs = RouterData & - ProviderData & { + API_ProviderData & { mode?: 'production' | 'development'; state: State; fullAPI: API; store: Store; }; -type OptionsData = { - docsOptions: DocsOptions; -}; - export type State = layout.SubState & stories.SubState & refs.SubState & @@ -83,7 +88,7 @@ export type State = layout.SubState & settings.SubState & globals.SubState & RouterData & - OptionsData & + API_OptionsData & Other; export type API = addons.SubAPI & @@ -110,40 +115,11 @@ export interface Combo { state: State; } -interface ProviderData { - provider: provider.Provider; - docsOptions: DocsOptions; -} - export type ManagerProviderProps = RouterData & - ProviderData & { + API_ProviderData & { children: ReactNode | ((props: Combo) => ReactNode); }; -// These types are duplicated in addons. -export type StoryId = string; -export type StoryKind = string; - -export interface Args { - [key: string]: any; -} - -export interface ArgType { - name?: string; - description?: string; - defaultValue?: any; - if?: Conditional; - [key: string]: any; -} - -export interface ArgTypes { - [key: string]: ArgType; -} - -export interface Parameters { - [key: string]: any; -} - // This is duplicated from @storybook/client-api for the reasons mentioned in lib-addons/types.js export const combineParameters = (...parameterSets: Parameters[]) => mergeWith({}, ...parameterSets, (objValue: any, srcValue: any) => { @@ -196,7 +172,7 @@ class ManagerProvider extends Component { }); const routeData = { location, path, viewMode, singleStory, storyId, refId }; - const optionsData: OptionsData = { docsOptions }; + const optionsData: API_OptionsData = { docsOptions }; this.state = store.getInitialState(getInitialState({ ...routeData, ...optionsData })); @@ -344,20 +320,20 @@ export function useStorybookApi(): API { } export type { - StoriesHash, - RootEntry, - GroupEntry, - ComponentEntry, - DocsEntry, - StoryEntry, - HashEntry, - LeafEntry, - ComposedRef, - Refs, + API_StoriesHash as StoriesHash, + API_RootEntry as RootEntry, + API_GroupEntry as GroupEntry, + API_ComponentEntry as ComponentEntry, + API_DocsEntry as DocsEntry, + API_StoryEntry as StoryEntry, + API_HashEntry as HashEntry, + API_LeafEntry as LeafEntry, + API_ComposedRef as ComposedRef, + API_Refs as Refs, }; export { ManagerConsumer as Consumer, ManagerProvider as Provider }; -export interface EventMap { +export interface API_EventMap { [eventId: string]: Listener; } @@ -368,7 +344,7 @@ function orDefault(fromStore: S, defaultState: S): S { return fromStore; } -export const useChannel = (eventMap: EventMap, deps: any[] = []) => { +export const useChannel = (eventMap: API_EventMap, deps: any[] = []) => { const api = useStorybookApi(); useEffect(() => { Object.entries(eventMap).forEach(([type, listener]) => api.on(type, listener)); @@ -392,7 +368,6 @@ export function useParameter(parameterKey: string, defaultValue?: S) { return orDefault(result, defaultValue); } -type StateMerger = (input: S) => S; // cache for taking care of HMR const addonStateCache: { [key: string]: any; @@ -406,7 +381,7 @@ export function useSharedState(stateId: string, defaultState?: S) { existingState, addonStateCache[stateId] ? addonStateCache[stateId] : defaultState ); - const setState = (s: S | StateMerger, options?: Options) => { + const setState = (s: S | API_StateMerger, options?: Options) => { // set only after the stories are loaded if (addonStateCache[stateId]) { addonStateCache[stateId] = s; @@ -454,50 +429,50 @@ export function useSharedState(stateId: string, defaultState?: S) { const emit = useChannel(allListeners); return [ state, - (newStateOrMerger: S | StateMerger, options?: Options) => { + (newStateOrMerger: S | API_StateMerger, options?: Options) => { setState(newStateOrMerger, options); emit(`${SHARED_STATE_CHANGED}-manager-${stateId}`, newStateOrMerger); }, - ] as [S, (newStateOrMerger: S | StateMerger, options?: Options) => void]; + ] as [S, (newStateOrMerger: S | API_StateMerger, options?: Options) => void]; } export function useAddonState(addonId: string, defaultState?: S) { return useSharedState(addonId, defaultState); } -export function useArgs(): [Args, (newArgs: Args) => void, (argNames?: string[]) => void] { +export function useArgs(): [API_Args, (newArgs: API_Args) => void, (argNames?: string[]) => void] { const { getCurrentStoryData, updateStoryArgs, resetStoryArgs } = useStorybookApi(); const data = getCurrentStoryData(); const args = data.type === 'story' ? data.args : {}; const updateArgs = useCallback( - (newArgs: Args) => updateStoryArgs(data as StoryEntry, newArgs), + (newArgs: API_Args) => updateStoryArgs(data as API_StoryEntry, newArgs), [data, updateStoryArgs] ); const resetArgs = useCallback( - (argNames?: string[]) => resetStoryArgs(data as StoryEntry, argNames), + (argNames?: string[]) => resetStoryArgs(data as API_StoryEntry, argNames), [data, resetStoryArgs] ); return [args, updateArgs, resetArgs]; } -export function useGlobals(): [Args, (newGlobals: Args) => void] { +export function useGlobals(): [API_Args, (newGlobals: API_Args) => void] { const api = useStorybookApi(); return [api.getGlobals(), api.updateGlobals]; } -export function useGlobalTypes(): ArgTypes { +export function useGlobalTypes(): API_ArgTypes { return useStorybookApi().getGlobalTypes(); } -function useCurrentStory(): StoryEntry | DocsEntry { +function useCurrentStory(): API_StoryEntry | API_DocsEntry { const { getCurrentStoryData } = useStorybookApi(); return getCurrentStoryData(); } -export function useArgTypes(): ArgTypes { +export function useArgTypes(): API_ArgTypes { const current = useCurrentStory(); return (current?.type === 'story' && current.argTypes) || {}; } diff --git a/code/lib/api/src/lib/events.ts b/code/lib/api/src/lib/events.ts index 8da5157dfe80..37fe0963342d 100644 --- a/code/lib/api/src/lib/events.ts +++ b/code/lib/api/src/lib/events.ts @@ -1,10 +1,12 @@ +/* eslint-disable camelcase */ import { logger } from '@storybook/client-logger'; -import { getSourceType, ComposedRef } from '../modules/refs'; +import { API_ComposedRef } from '@storybook/types'; +import { getSourceType } from '../modules/refs'; import type { API } from '../index'; interface Meta { - ref?: ComposedRef; + ref?: API_ComposedRef; source?: string; sourceType?: 'local' | 'external'; sourceLocation?: string; diff --git a/code/lib/api/src/lib/shortcut.ts b/code/lib/api/src/lib/shortcut.ts index 8a3416caca45..ef0258873c54 100644 --- a/code/lib/api/src/lib/shortcut.ts +++ b/code/lib/api/src/lib/shortcut.ts @@ -1,7 +1,6 @@ +/* eslint-disable camelcase */ import global from 'global'; - -// The shortcut is our JSON-ifiable representation of a shortcut combination -import type { KeyCollection } from '../modules/shortcuts'; +import { API_KeyCollection } from '../modules/shortcuts'; const { navigator } = global; @@ -22,7 +21,7 @@ export type KeyboardEventLike = Pick< // Map a keyboard event to a keyboard shortcut // NOTE: if we change the fields on the event that we need, we'll need to update the serialization in core/preview/start.js -export const eventToShortcut = (e: KeyboardEventLike): KeyCollection | null => { +export const eventToShortcut = (e: KeyboardEventLike): API_KeyCollection | null => { // Meta key only doesn't map to a shortcut if (['Meta', 'Alt', 'Control', 'Shift'].includes(e.key)) { return null; @@ -68,8 +67,8 @@ export const eventToShortcut = (e: KeyboardEventLike): KeyCollection | null => { }; export const shortcutMatchesShortcut = ( - inputShortcut: KeyCollection, - shortcut: KeyCollection + inputShortcut: API_KeyCollection, + shortcut: API_KeyCollection ): boolean => { if (!inputShortcut || !shortcut) return false; if (inputShortcut.join('') === 'shift/') inputShortcut.shift(); // shift is optional for `/` @@ -78,7 +77,10 @@ export const shortcutMatchesShortcut = ( }; // Should this keyboard event trigger this keyboard shortcut? -export const eventMatchesShortcut = (e: KeyboardEventLike, shortcut: KeyCollection): boolean => { +export const eventMatchesShortcut = ( + e: KeyboardEventLike, + shortcut: API_KeyCollection +): boolean => { return shortcutMatchesShortcut(eventToShortcut(e), shortcut); }; @@ -120,6 +122,6 @@ export const keyToSymbol = (key: string): string => { }; // Display the shortcut as a human readable string -export const shortcutToHumanString = (shortcut: KeyCollection): string => { +export const shortcutToHumanString = (shortcut: API_KeyCollection): string => { return shortcut.map(keyToSymbol).join(' '); }; diff --git a/code/lib/api/src/lib/stories.ts b/code/lib/api/src/lib/stories.ts index b7a1823f4b6e..5cf09e6eeb46 100644 --- a/code/lib/api/src/lib/stories.ts +++ b/code/lib/api/src/lib/stories.ts @@ -1,228 +1,39 @@ +/* eslint-disable camelcase */ import memoize from 'memoizerific'; -import React from 'react'; import { dedent } from 'ts-dedent'; -import mapValues from 'lodash/mapValues'; import countBy from 'lodash/countBy'; import { toId, sanitize } from '@storybook/csf'; import type { StoryId, ComponentTitle, - StoryKind, - StoryName, - Args, - ArgTypes, Parameters, - ComponentId, DocsOptions, + API_Provider, + API_SetStoriesStoryData, + API_PreparedStoryIndex, + API_StoryIndexV3, + API_IndexEntry, + API_RootEntry, + API_GroupEntry, + API_ComponentEntry, + API_StoriesHash, + API_DocsEntry, + API_StoryEntry, + API_HashEntry, + API_SetStoriesPayload, } from '@storybook/types'; -import { combineParameters } from '../index'; +import mapValues from 'lodash/mapValues'; +import { API, combineParameters } from '../index'; import merge from './merge'; -import type { Provider } from '../modules/provider'; -import type { ViewMode } from '../modules/addons'; - -export type { StoryId }; - -export interface BaseEntry { - id: StoryId; - depth: number; - name: string; - refId?: string; - renderLabel?: (item: BaseEntry) => React.ReactNode; - - /** @deprecated */ - isRoot: boolean; - /** @deprecated */ - isComponent: boolean; - /** @deprecated */ - isLeaf: boolean; -} - -export interface RootEntry extends BaseEntry { - type: 'root'; - startCollapsed?: boolean; - children: StoryId[]; - - /** @deprecated */ - isRoot: true; - /** @deprecated */ - isComponent: false; - /** @deprecated */ - isLeaf: false; -} - -export interface GroupEntry extends BaseEntry { - type: 'group'; - parent?: StoryId; - children: StoryId[]; - - /** @deprecated */ - isRoot: false; - /** @deprecated */ - isComponent: false; - /** @deprecated */ - isLeaf: false; -} - -export interface ComponentEntry extends BaseEntry { - type: 'component'; - parent?: StoryId; - children: StoryId[]; - - /** @deprecated */ - isRoot: false; - /** @deprecated */ - isComponent: true; - /** @deprecated */ - isLeaf: false; -} - -export interface DocsEntry extends BaseEntry { - type: 'docs'; - parent: StoryId; - title: ComponentTitle; - /** @deprecated */ - kind: ComponentTitle; - importPath: Path; - - /** @deprecated */ - isRoot: false; - /** @deprecated */ - isComponent: false; - /** @deprecated */ - isLeaf: true; -} - -export interface StoryEntry extends BaseEntry { - type: 'story'; - parent: StoryId; - title: ComponentTitle; - /** @deprecated */ - kind: ComponentTitle; - importPath: Path; - prepared: boolean; - parameters?: { - [parameterName: string]: any; - }; - args?: Args; - argTypes?: ArgTypes; - initialArgs?: Args; - - /** @deprecated */ - isRoot: false; - /** @deprecated */ - isComponent: false; - /** @deprecated */ - isLeaf: true; -} - -export type LeafEntry = DocsEntry | StoryEntry; -export type HashEntry = RootEntry | GroupEntry | ComponentEntry | DocsEntry | StoryEntry; - -/** @deprecated */ -export type Root = RootEntry; - -/** @deprecated */ -export type Group = GroupEntry | ComponentEntry; - -/** @deprecated */ -export type Story = LeafEntry; - -/** - * The `StoriesHash` is our manager-side representation of the `StoryIndex`. - * We create entries in the hash not only for each story or docs entry, but - * also for each "group" of the component (split on '/'), as that's how things - * are manipulated in the manager (i.e. in the sidebar) - */ -export interface StoriesHash { - [id: string]: HashEntry; -} - -// The data received on the (legacy) `setStories` event -export interface SetStoriesStory { - id: StoryId; - name: string; - refId?: string; - componentId?: ComponentId; - kind: StoryKind; - parameters: { - fileName: string; - options: { - [optionName: string]: any; - }; - docsOnly?: boolean; - viewMode?: ViewMode; - [parameterName: string]: any; - }; - argTypes?: ArgTypes; - args?: Args; - initialArgs?: Args; -} - -export interface SetStoriesStoryData { - [id: string]: SetStoriesStory; -} - -export interface StoryKey { - id: StoryId; - refId?: string; -} - -export type SetStoriesPayload = - | { - v: 2; - error?: Error; - globals: Args; - globalParameters: Parameters; - stories: SetStoriesStoryData; - kindParameters: { - [kind: string]: Parameters; - }; - } - | ({ - v?: number; - stories: SetStoriesStoryData; - } & Record); - -// The data recevied via the story index -type Path = string; - -interface BaseIndexEntry { - id: StoryId; - name: StoryName; - title: ComponentTitle; - importPath: Path; -} - -export type StoryIndexEntry = BaseIndexEntry & { - type?: 'story'; -}; - -interface V3IndexEntry extends BaseIndexEntry { - parameters?: Parameters; -} -export interface StoryIndexV3 { - v: 3; - stories: Record; -} - -export type DocsIndexEntry = BaseIndexEntry & { - storiesImports: Path[]; - type: 'docs'; -}; - -export type IndexEntry = StoryIndexEntry | DocsIndexEntry; -export interface StoryIndex { - v: number; - entries: Record; -} +const TITLE_PATH_SEPARATOR = /\s*\/\s*/; export const denormalizeStoryParameters = ({ globalParameters, kindParameters, stories, -}: SetStoriesPayload): SetStoriesStoryData => { +}: API_SetStoriesPayload): API_SetStoriesStoryData => { return mapValues(stories, (storyData) => ({ ...storyData, parameters: combineParameters( @@ -233,24 +44,9 @@ export const denormalizeStoryParameters = ({ })); }; -const TITLE_PATH_SEPARATOR = /\s*\/\s*/; - -// We used to received a bit more data over the channel on the SET_STORIES event, including -// the full parameters for each story. -type PreparedIndexEntry = IndexEntry & { - parameters?: Parameters; - argTypes?: ArgTypes; - args?: Args; - initialArgs?: Args; -}; -export interface PreparedStoryIndex { - v: number; - entries: Record; -} - export const transformSetStoriesStoryDataToStoriesHash = ( - data: SetStoriesStoryData, - { provider, docsOptions }: { provider: Provider; docsOptions: DocsOptions } + data: API_SetStoriesStoryData, + { provider, docsOptions }: { provider: API_Provider; docsOptions: DocsOptions } ) => transformStoryIndexToStoriesHash( transformSetStoriesStoryDataToPreparedStoryIndex(data, { docsOptions }), @@ -261,11 +57,11 @@ export const transformSetStoriesStoryDataToStoriesHash = ( ); const transformSetStoriesStoryDataToPreparedStoryIndex = ( - stories: SetStoriesStoryData, + stories: API_SetStoriesStoryData, { docsOptions }: { docsOptions: DocsOptions } -): PreparedStoryIndex => { +): API_PreparedStoryIndex => { const seenTitles = new Set(); - const entries: PreparedStoryIndex['entries'] = Object.entries(stories).reduce( + const entries: API_PreparedStoryIndex['entries'] = Object.entries(stories).reduce( (acc, [id, story]) => { if (!story) return acc; @@ -308,18 +104,18 @@ const transformSetStoriesStoryDataToPreparedStoryIndex = ( } return acc; }, - {} as PreparedStoryIndex['entries'] + {} as API_PreparedStoryIndex['entries'] ); return { v: 4, entries }; }; -const transformStoryIndexV3toV4 = (index: StoryIndexV3): PreparedStoryIndex => { +const transformStoryIndexV3toV4 = (index: API_StoryIndexV3): API_PreparedStoryIndex => { const countByTitle = countBy(Object.values(index.stories), 'title'); return { v: 4, entries: Object.values(index.stories).reduce((acc, entry) => { - let type: IndexEntry['type'] = 'story'; + let type: API_IndexEntry['type'] = 'story'; if ( entry.parameters?.docsOnly || (entry.name === 'Page' && countByTitle[entry.title] === 1) @@ -332,20 +128,20 @@ const transformStoryIndexV3toV4 = (index: StoryIndexV3): PreparedStoryIndex => { ...entry, }; return acc; - }, {} as PreparedStoryIndex['entries']), + }, {} as API_PreparedStoryIndex['entries']), }; }; export const transformStoryIndexToStoriesHash = ( - index: PreparedStoryIndex, + index: API_PreparedStoryIndex, { provider, docsOptions, }: { - provider: Provider; + provider: API_Provider; docsOptions: DocsOptions; } -): StoriesHash => { +): API_StoriesHash => { if (!index.v) throw new Error('Composition: Missing stories.json version'); const v4Index = index.v === 4 ? index : transformStoryIndexV3toV4(index as any); @@ -389,7 +185,7 @@ export const transformStoryIndexToStoriesHash = ( const childId = paths[idx + 1] || item.id; if (root.length && idx === 0) { - acc[id] = merge((acc[id] || {}) as RootEntry, { + acc[id] = merge((acc[id] || {}) as API_RootEntry, { type: 'root', id, name: names[idx], @@ -413,7 +209,7 @@ export const transformStoryIndexToStoriesHash = ( // // In this example the entry for 'atoms-button' would *not* be a component. } else if ((!acc[id] || acc[id].type === 'component') && idx === paths.length - 1) { - acc[id] = merge((acc[id] || {}) as ComponentEntry, { + acc[id] = merge((acc[id] || {}) as API_ComponentEntry, { type: 'component', id, name: names[idx], @@ -429,7 +225,7 @@ export const transformStoryIndexToStoriesHash = ( isLeaf: false, }); } else { - acc[id] = merge((acc[id] || {}) as GroupEntry, { + acc[id] = merge((acc[id] || {}) as API_GroupEntry, { type: 'group', id, name: names[idx], @@ -461,13 +257,13 @@ export const transformStoryIndexToStoriesHash = ( isRoot: false, isComponent: false, isLeaf: true, - } as DocsEntry | StoryEntry; + } as API_DocsEntry | API_StoryEntry; return acc; - }, {} as StoriesHash); + }, {} as API_StoriesHash); // This function adds a "root" or "orphan" and all of its descendents to the hash. - function addItem(acc: StoriesHash, item: HashEntry) { + function addItem(acc: API_StoriesHash, item: API_HashEntry) { // If we were already inserted as part of a group, that's great. if (acc[item.id]) { return acc; @@ -491,7 +287,7 @@ export const transformStoryIndexToStoriesHash = ( .reduce(addItem, orphanHash); }; -export const addPreparedStories = (newHash: StoriesHash, oldHash?: StoriesHash) => { +export const addPreparedStories = (newHash: API_StoriesHash, oldHash?: API_StoriesHash) => { if (!oldHash) return newHash; return Object.fromEntries( @@ -506,7 +302,7 @@ export const addPreparedStories = (newHash: StoriesHash, oldHash?: StoriesHash) ); }; -export const getComponentLookupList = memoize(1)((hash: StoriesHash) => { +export const getComponentLookupList = memoize(1)((hash: API_StoriesHash) => { return Object.entries(hash).reduce((acc, i) => { const value = i[1]; if (value.type === 'component') { @@ -516,6 +312,6 @@ export const getComponentLookupList = memoize(1)((hash: StoriesHash) => { }, [] as StoryId[][]); }); -export const getStoriesLookupList = memoize(1)((hash: StoriesHash) => { +export const getStoriesLookupList = memoize(1)((hash: API_StoriesHash) => { return Object.keys(hash).filter((k) => ['story', 'docs'].includes(hash[k].type)); }); diff --git a/code/lib/api/src/modules/addons.ts b/code/lib/api/src/modules/addons.ts index 46cae050ca39..e5b0235cf23e 100644 --- a/code/lib/api/src/modules/addons.ts +++ b/code/lib/api/src/modules/addons.ts @@ -1,12 +1,10 @@ -import type { ReactElement } from 'react'; -import type { RenderData } from '@storybook/router'; +/* eslint-disable camelcase */ +import type { API_Collection, API_Panels, API_StateMerger, API_Types } from '@storybook/types'; import { ModuleFn } from '../index'; import { Options } from '../store'; -export type ViewMode = 'story' | 'info' | 'settings' | 'page' | undefined | string; - -export enum types { +enum types { TAB = 'tab', PANEL = 'panel', TOOL = 'tool', @@ -14,64 +12,26 @@ export enum types { NOTES_ELEMENT = 'notes-element', } -export type Types = types | string; -export interface RenderOptions { - active: boolean; - key: string; -} - -export interface RouteOptions { - storyId: string; - viewMode: ViewMode; - location: RenderData['location']; - path: string; -} -export interface MatchOptions { - storyId: string; - viewMode: ViewMode; - location: RenderData['location']; - path: string; -} - -export interface Addon { - title: string; - type?: Types; - id?: string; - route?: (routeOptions: RouteOptions) => string; - match?: (matchOptions: MatchOptions) => boolean; - render: (renderOptions: RenderOptions) => ReactElement; - paramKey?: string; - disabled?: boolean; - hidden?: boolean; -} -export interface Collection { - [key: string]: T; -} - -type Panels = Collection; - -type StateMerger = (input: S) => S; - export interface SubState { selectedPanel: string; addons: Record; } export interface SubAPI { - getElements: (type: Types) => Collection; - getPanels: () => Panels; - getStoryPanels: () => Panels; + getElements: (type: API_Types) => API_Collection; + getPanels: () => API_Panels; + getStoryPanels: () => API_Panels; getSelectedPanel: () => string; setSelectedPanel: (panelName: string) => void; setAddonState( addonId: string, - newStateOrMerger: S | StateMerger, + newStateOrMerger: S | API_StateMerger, options?: Options ): Promise; getAddonState(addonId: string): S; } -export function ensurePanel(panels: Panels, selectedPanel?: string, currentPanel?: string) { +export function ensurePanel(panels: API_Panels, selectedPanel?: string, currentPanel?: string) { const keys = Object.keys(panels); if (keys.indexOf(selectedPanel) >= 0) { @@ -99,7 +59,7 @@ export const init: ModuleFn = ({ provider, store, fullAPI }) = const { parameters } = story; - const filteredPanels: Collection = {}; + const filteredPanels: API_Collection = {}; Object.entries(allPanels).forEach(([id, panel]) => { const { paramKey } = panel; if (paramKey && parameters && parameters[paramKey] && parameters[paramKey].disable) { @@ -119,13 +79,13 @@ export const init: ModuleFn = ({ provider, store, fullAPI }) = }, setAddonState( addonId: string, - newStateOrMerger: S | StateMerger, + newStateOrMerger: S | API_StateMerger, options?: Options ): Promise { let nextState; const { addons: existing } = store.getState(); if (typeof newStateOrMerger === 'function') { - const merger = newStateOrMerger as StateMerger; + const merger = newStateOrMerger as API_StateMerger; nextState = merger(api.getAddonState(addonId)); } else { nextState = newStateOrMerger; diff --git a/code/lib/api/src/modules/globals.ts b/code/lib/api/src/modules/globals.ts index 1ff0689850ed..7f571126287d 100644 --- a/code/lib/api/src/modules/globals.ts +++ b/code/lib/api/src/modules/globals.ts @@ -1,17 +1,13 @@ +/* eslint-disable camelcase */ import { SET_GLOBALS, UPDATE_GLOBALS, GLOBALS_UPDATED } from '@storybook/core-events'; import { logger } from '@storybook/client-logger'; import { dequal as deepEqual } from 'dequal'; -import type { Globals, GlobalTypes } from '@storybook/types'; +import type { API_SetGlobalsPayload, Globals, GlobalTypes } from '@storybook/types'; import type { ModuleFn } from '../index'; import { getEventMetadata } from '../lib/events'; -interface SetGlobalsPayload { - globals: Globals; - globalTypes: GlobalTypes; -} - export interface SubState { globals?: Globals; globalTypes?: GlobalTypes; @@ -67,24 +63,27 @@ export const init: ModuleFn = ({ store, fullAPI }) => { }); // Emitted by the preview on initialization - fullAPI.on(SET_GLOBALS, function handleSetStories({ globals, globalTypes }: SetGlobalsPayload) { - const { ref } = getEventMetadata(this, fullAPI); - const currentGlobals = store.getState()?.globals; + fullAPI.on( + SET_GLOBALS, + function handleSetStories({ globals, globalTypes }: API_SetGlobalsPayload) { + const { ref } = getEventMetadata(this, fullAPI); + const currentGlobals = store.getState()?.globals; - if (!ref) { - store.setState({ globals, globalTypes }); - } else if (Object.keys(globals).length > 0) { - logger.warn('received globals from a non-local ref. This is not currently supported.'); - } + if (!ref) { + store.setState({ globals, globalTypes }); + } else if (Object.keys(globals).length > 0) { + logger.warn('received globals from a non-local ref. This is not currently supported.'); + } - if ( - currentGlobals && - Object.keys(currentGlobals).length !== 0 && - !deepEqual(globals, currentGlobals) - ) { - api.updateGlobals(currentGlobals); + if ( + currentGlobals && + Object.keys(currentGlobals).length !== 0 && + !deepEqual(globals, currentGlobals) + ) { + api.updateGlobals(currentGlobals); + } } - }); + ); }; return { diff --git a/code/lib/api/src/modules/layout.ts b/code/lib/api/src/modules/layout.ts index 623570a773ec..349a8c5811bc 100644 --- a/code/lib/api/src/modules/layout.ts +++ b/code/lib/api/src/modules/layout.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import global from 'global'; import pick from 'lodash/pick'; import { dequal as deepEqual } from 'dequal'; @@ -5,42 +6,21 @@ import { create } from '@storybook/theming/create'; import { SET_CONFIG } from '@storybook/core-events'; import type { ThemeVars } from '@storybook/theming'; +import type { API_Layout, API_PanelPositions, API_UI } from '@storybook/types'; import merge from '../lib/merge'; import type { State, ModuleFn } from '../index'; const { document } = global; -export type PanelPositions = 'bottom' | 'right'; -export type ActiveTabsType = 'sidebar' | 'canvas' | 'addons'; export const ActiveTabs = { SIDEBAR: 'sidebar' as const, CANVAS: 'canvas' as const, ADDONS: 'addons' as const, }; -export interface Layout { - initialActive: ActiveTabsType; - isFullscreen: boolean; - showPanel: boolean; - panelPosition: PanelPositions; - showNav: boolean; - showTabs: boolean; - showToolbar: boolean; - /** - * @deprecated - */ - isToolshown?: boolean; -} - -export interface UI { - name?: string; - url?: string; - enableShortcuts: boolean; -} - export interface SubState { - layout: Layout; - ui: UI; + layout: API_Layout; + ui: API_UI; selectedPanel: string | undefined; theme: ThemeVars; } @@ -48,7 +28,7 @@ export interface SubState { export interface SubAPI { toggleFullscreen: (toggled?: boolean) => void; togglePanel: (toggled?: boolean) => void; - togglePanelPosition: (position?: PanelPositions) => void; + togglePanelPosition: (position?: API_PanelPositions) => void; toggleNav: (toggled?: boolean) => void; toggleToolbar: (toggled?: boolean) => void; setOptions: (options: any) => void; @@ -56,17 +36,6 @@ export interface SubAPI { type PartialSubState = Partial; -export interface UIOptions { - name?: string; - url?: string; - goFullScreen: boolean; - showStoriesPanel: boolean; - showAddonPanel: boolean; - addonPanelInRight: boolean; - theme?: ThemeVars; - selectedPanel?: string; -} - const defaultState: SubState = { ui: { enableShortcuts: true, diff --git a/code/lib/api/src/modules/notifications.ts b/code/lib/api/src/modules/notifications.ts index f6fc4e408a5f..393160678f4a 100644 --- a/code/lib/api/src/modules/notifications.ts +++ b/code/lib/api/src/modules/notifications.ts @@ -1,27 +1,13 @@ -import type { ReactNode } from 'react'; +/* eslint-disable camelcase */ +import type { API_Notification } from '@storybook/types'; import { ModuleFn } from '../index'; -export interface Notification { - id: string; - link: string; - content: { - headline: string; - subHeadline?: string | ReactNode; - }; - - icon?: { - name: string; - color?: string; - }; - onClear?: () => void; -} - export interface SubState { - notifications: Notification[]; + notifications: API_Notification[]; } export interface SubAPI { - addNotification: (notification: Notification) => void; + addNotification: (notification: API_Notification) => void; clearNotification: (id: string) => void; } diff --git a/code/lib/api/src/modules/provider.ts b/code/lib/api/src/modules/provider.ts index 078204e30c43..878eccda79fc 100644 --- a/code/lib/api/src/modules/provider.ts +++ b/code/lib/api/src/modules/provider.ts @@ -1,42 +1,9 @@ -import type { ReactNode } from 'react'; -import { Channel } from '@storybook/channels'; -import type { ThemeVars } from '@storybook/theming'; - -import type { API, State, ModuleFn, HashEntry } from '../index'; -import type { StoryMapper } from './refs'; -import type { UIOptions } from './layout'; - -interface SidebarOptions { - showRoots?: boolean; - collapsedRoots?: string[]; - renderLabel?: (item: HashEntry) => ReactNode; -} - -type IframeRenderer = ( - storyId: string, - viewMode: State['viewMode'], - id: string, - baseUrl: string, - scale: number, - queryParams: Record -) => ReactNode; - -export interface Provider { - channel?: Channel; - serverChannel?: Channel; - renderPreview?: IframeRenderer; - handleAPI(api: API): void; - getConfig(): { - sidebar?: SidebarOptions; - theme?: ThemeVars; - StoryMapper?: StoryMapper; - [k: string]: any; - } & Partial; - [key: string]: any; -} +/* eslint-disable camelcase */ +import type { API_Provider } from '@storybook/types'; +import type { API, ModuleFn } from '../index'; export interface SubAPI { - renderPreview?: Provider['renderPreview']; + renderPreview?: API_Provider['renderPreview']; } export const init: ModuleFn = ({ provider, fullAPI }) => { diff --git a/code/lib/api/src/modules/refs.ts b/code/lib/api/src/modules/refs.ts index 98c1e5fce683..6cd3cffe49c5 100644 --- a/code/lib/api/src/modules/refs.ts +++ b/code/lib/api/src/modules/refs.ts @@ -1,78 +1,41 @@ +/* eslint-disable camelcase */ import global from 'global'; import { dedent } from 'ts-dedent'; +import type { + API_ComposedRef, + API_ComposedRefUpdate, + API_Refs, + API_SetRefData, + API_SetStoriesStoryData, + API_StoriesHash, + API_StoryMapper, +} from '@storybook/types'; import { transformSetStoriesStoryDataToStoriesHash, - SetStoriesStory, - StoriesHash, transformStoryIndexToStoriesHash, - SetStoriesStoryData, - StoryIndex, } from '../lib/stories'; import type { ModuleFn } from '../index'; const { location, fetch } = global; +// eslint-disable-next-line no-useless-escape +const findFilename = /(\/((?:[^\/]+?)\.[^\/]+?)|\/)$/; + export interface SubState { - refs: Refs; + refs: API_Refs; } -type Versions = Record; - -export type SetRefData = Partial< - ComposedRef & { - setStoriesData: SetStoriesStoryData; - storyIndex: StoryIndex; - } ->; - export interface SubAPI { - findRef: (source: string) => ComposedRef; - setRef: (id: string, data: SetRefData, ready?: boolean) => void; - updateRef: (id: string, ref: ComposedRefUpdate) => void; - getRefs: () => Refs; - checkRef: (ref: SetRefData) => Promise; + findRef: (source: string) => API_ComposedRef; + setRef: (id: string, data: API_SetRefData, ready?: boolean) => void; + updateRef: (id: string, ref: API_ComposedRefUpdate) => void; + getRefs: () => API_Refs; + checkRef: (ref: API_SetRefData) => Promise; changeRefVersion: (id: string, url: string) => void; changeRefState: (id: string, ready: boolean) => void; } -export type StoryMapper = (ref: ComposedRef, story: SetStoriesStory) => SetStoriesStory; -export interface ComposedRef { - id: string; - title?: string; - url: string; - type?: 'auto-inject' | 'unknown' | 'lazy' | 'server-checked'; - expanded?: boolean; - stories: StoriesHash; - versions?: Versions; - loginUrl?: string; - version?: string; - ready?: boolean; - error?: any; -} - -export type ComposedRefUpdate = Partial< - Pick< - ComposedRef, - | 'title' - | 'type' - | 'expanded' - | 'stories' - | 'versions' - | 'loginUrl' - | 'version' - | 'ready' - | 'error' - > ->; - -export type Refs = Record; -export type RefId = string; -export type RefUrl = string; - -// eslint-disable-next-line no-useless-escape -const findFilename = /(\/((?:[^\/]+?)\.[^\/]+?)|\/)$/; - export const getSourceType = (source: string, refId: string) => { const { origin: localOrigin, pathname: localPathname } = location; const { origin: sourceOrigin, pathname: sourcePathname } = new URL(source); @@ -89,17 +52,17 @@ export const getSourceType = (source: string, refId: string) => { return [null, null]; }; -export const defaultStoryMapper: StoryMapper = (b, a) => { +export const defaultStoryMapper: API_StoryMapper = (b, a) => { return { ...a, kind: a.kind.replace('|', '/') }; }; -const addRefIds = (input: StoriesHash, ref: ComposedRef): StoriesHash => { +const addRefIds = (input: API_StoriesHash, ref: API_ComposedRef): API_StoriesHash => { return Object.entries(input).reduce((acc, [id, item]) => { return { ...acc, [id]: { ...item, refId: ref.id } }; - }, {} as StoriesHash); + }, {} as API_StoriesHash); }; -async function handleRequest(request: Response | false): Promise { +async function handleRequest(request: Response | false): Promise { if (!request) return {}; try { @@ -112,22 +75,22 @@ async function handleRequest(request: Response | false): Promise { return { storyIndex: json }; } - return json as SetRefData; + return json as API_SetRefData; } catch (error) { return { error }; } } const map = ( - input: SetStoriesStoryData, - ref: ComposedRef, - options: { storyMapper?: StoryMapper } -): SetStoriesStoryData => { + input: API_SetStoriesStoryData, + ref: API_ComposedRef, + options: { storyMapper?: API_StoryMapper } +): API_SetStoriesStoryData => { const { storyMapper } = options; if (storyMapper) { return Object.entries(input).reduce((acc, [id, item]) => { return { ...acc, [id]: storyMapper(ref, item) }; - }, {} as SetStoriesStoryData); + }, {} as API_SetStoriesStoryData); } return input; }; @@ -144,7 +107,7 @@ export const init: ModuleFn = ( }, changeRefVersion: (id, url) => { const { versions, title } = api.getRefs()[id]; - const ref = { id, url, versions, title, stories: {} } as SetRefData; + const ref = { id, url, versions, title, stories: {} } as API_SetRefData; api.checkRef(ref); }, @@ -173,7 +136,7 @@ export const init: ModuleFn = ( // // then we fetch metadata if the above fetch succeeded - const loadedData: SetRefData = {}; + const loadedData: API_SetRefData = {}; const query = version ? `?version=${version}` : ''; const credentials = isPublic ? 'omit' : 'include'; @@ -245,7 +208,7 @@ export const init: ModuleFn = ( const { storyMapper = defaultStoryMapper } = provider.getConfig(); const ref = api.getRefs()[id]; - let storiesHash: StoriesHash; + let storiesHash: API_StoriesHash; if (setStoriesData) { storiesHash = transformSetStoriesStoryDataToStoriesHash( map(setStoriesData, ref, { storyMapper }), @@ -277,13 +240,13 @@ export const init: ModuleFn = ( }, }; - const refs: Refs = (!singleStory && global.REFS) || {}; + const refs: API_Refs = (!singleStory && global.REFS) || {}; const initialState: SubState['refs'] = refs; if (runCheck) { Object.entries(refs).forEach(([id, ref]) => { - api.checkRef({ ...ref, stories: {} } as SetRefData); + api.checkRef({ ...ref, stories: {} } as API_SetRefData); }); } diff --git a/code/lib/api/src/modules/release-notes.ts b/code/lib/api/src/modules/release-notes.ts index a7788070b5d8..5794f99853cf 100644 --- a/code/lib/api/src/modules/release-notes.ts +++ b/code/lib/api/src/modules/release-notes.ts @@ -1,17 +1,13 @@ +/* eslint-disable camelcase */ import global from 'global'; +import { API_ReleaseNotes } from '@storybook/types'; import memoize from 'memoizerific'; import type { ModuleFn } from '../index'; const { RELEASE_NOTES_DATA } = global; -export interface ReleaseNotes { - success?: boolean; - currentVersion?: string; - showOnFirstLaunch?: boolean; -} - -const getReleaseNotesData = memoize(1)((): ReleaseNotes => { +const getReleaseNotesData = memoize(1)((): API_ReleaseNotes => { try { return { ...(JSON.parse(RELEASE_NOTES_DATA) || {}) }; } catch (e) { diff --git a/code/lib/api/src/modules/settings.ts b/code/lib/api/src/modules/settings.ts index a0cbf8ec5693..f594923ec1e7 100644 --- a/code/lib/api/src/modules/settings.ts +++ b/code/lib/api/src/modules/settings.ts @@ -1,3 +1,5 @@ +/* eslint-disable camelcase */ +import { API_Settings } from '@storybook/types'; import type { ModuleFn } from '../index'; export interface SubAPI { @@ -7,12 +9,8 @@ export interface SubAPI { navigateToSettingsPage: (path: string) => Promise; } -export interface Settings { - lastTrackedStoryId: string; -} - export interface SubState { - settings: Settings; + settings: API_Settings; } export const init: ModuleFn = ({ store, navigate, fullAPI }) => { diff --git a/code/lib/api/src/modules/shortcuts.ts b/code/lib/api/src/modules/shortcuts.ts index 6e891e428f77..60704dcad67c 100644 --- a/code/lib/api/src/modules/shortcuts.ts +++ b/code/lib/api/src/modules/shortcuts.ts @@ -1,7 +1,7 @@ +/* eslint-disable camelcase */ import global from 'global'; import { PREVIEW_KEYDOWN } from '@storybook/core-events'; -import { DOMElement } from 'react'; import type { ModuleFn } from '../index'; import { shortcutMatchesShortcut, eventToShortcut, KeyboardEventLike } from '../lib/shortcut'; @@ -18,60 +18,60 @@ export function keys(o: O) { } export interface SubState { - shortcuts: Shortcuts; + shortcuts: API_Shortcuts; } export interface SubAPI { - getShortcutKeys(): Shortcuts; - getDefaultShortcuts(): Shortcuts | AddonShortcutDefaults; - getAddonsShortcuts(): AddonShortcuts; - getAddonsShortcutLabels(): AddonShortcutLabels; - getAddonsShortcutDefaults(): AddonShortcutDefaults; - setShortcuts(shortcuts: Shortcuts): Promise; - setShortcut(action: Action, value: KeyCollection): Promise; - setAddonShortcut(addon: string, shortcut: AddonShortcut): Promise; - restoreAllDefaultShortcuts(): Promise; - restoreDefaultShortcut(action: Action): Promise; + getShortcutKeys(): API_Shortcuts; + getDefaultShortcuts(): API_Shortcuts | API_AddonShortcutDefaults; + getAddonsShortcuts(): API_AddonShortcuts; + getAddonsShortcutLabels(): API_AddonShortcutLabels; + getAddonsShortcutDefaults(): API_AddonShortcutDefaults; + setShortcuts(shortcuts: API_Shortcuts): Promise; + setShortcut(action: API_Action, value: API_KeyCollection): Promise; + setAddonShortcut(addon: string, shortcut: API_AddonShortcut): Promise; + restoreAllDefaultShortcuts(): Promise; + restoreDefaultShortcut(action: API_Action): Promise; handleKeydownEvent(event: KeyboardEventLike): void; - handleShortcutFeature(feature: Action): void; + handleShortcutFeature(feature: API_Action): void; } -export type KeyCollection = string[]; - -export interface Shortcuts { - fullScreen: KeyCollection; - togglePanel: KeyCollection; - panelPosition: KeyCollection; - toggleNav: KeyCollection; - toolbar: KeyCollection; - search: KeyCollection; - focusNav: KeyCollection; - focusIframe: KeyCollection; - focusPanel: KeyCollection; - prevComponent: KeyCollection; - nextComponent: KeyCollection; - prevStory: KeyCollection; - nextStory: KeyCollection; - shortcutsPage: KeyCollection; - aboutPage: KeyCollection; - escape: KeyCollection; - collapseAll: KeyCollection; - expandAll: KeyCollection; +export type API_KeyCollection = string[]; + +export interface API_Shortcuts { + fullScreen: API_KeyCollection; + togglePanel: API_KeyCollection; + panelPosition: API_KeyCollection; + toggleNav: API_KeyCollection; + toolbar: API_KeyCollection; + search: API_KeyCollection; + focusNav: API_KeyCollection; + focusIframe: API_KeyCollection; + focusPanel: API_KeyCollection; + prevComponent: API_KeyCollection; + nextComponent: API_KeyCollection; + prevStory: API_KeyCollection; + nextStory: API_KeyCollection; + shortcutsPage: API_KeyCollection; + aboutPage: API_KeyCollection; + escape: API_KeyCollection; + collapseAll: API_KeyCollection; + expandAll: API_KeyCollection; } -export type Action = keyof Shortcuts; +export type API_Action = keyof API_Shortcuts; -interface AddonShortcut { +interface API_AddonShortcut { label: string; - defaultShortcut: KeyCollection; + defaultShortcut: API_KeyCollection; actionName: string; showInMenu?: boolean; action: (...args: any[]) => any; } -type AddonShortcuts = Record; -type AddonShortcutLabels = Record; -type AddonShortcutDefaults = Record; +type API_AddonShortcuts = Record; +type API_AddonShortcutLabels = Record; +type API_AddonShortcutDefaults = Record; -export const defaultShortcuts: Shortcuts = Object.freeze({ +export const defaultShortcuts: API_Shortcuts = Object.freeze({ fullScreen: ['F'], togglePanel: ['A'], panelPosition: ['D'], @@ -92,7 +92,7 @@ export const defaultShortcuts: Shortcuts = Object.freeze({ expandAll: [controlOrMetaKey(), 'shift', 'ArrowDown'], }); -const addonsShortcuts: AddonShortcuts = {}; +const addonsShortcuts: API_AddonShortcuts = {}; function focusInInput(event: KeyboardEvent) { const target = event.target as Element; @@ -102,47 +102,47 @@ function focusInInput(event: KeyboardEvent) { export const init: ModuleFn = ({ store, fullAPI }) => { const api: SubAPI = { // Getting and setting shortcuts - getShortcutKeys(): Shortcuts { + getShortcutKeys(): API_Shortcuts { return store.getState().shortcuts; }, - getDefaultShortcuts(): Shortcuts | AddonShortcutDefaults { + getDefaultShortcuts(): API_Shortcuts | API_AddonShortcutDefaults { return { ...defaultShortcuts, ...api.getAddonsShortcutDefaults(), }; }, - getAddonsShortcuts(): AddonShortcuts { + getAddonsShortcuts(): API_AddonShortcuts { return addonsShortcuts; }, - getAddonsShortcutLabels(): AddonShortcutLabels { - const labels: AddonShortcutLabels = {}; + getAddonsShortcutLabels(): API_AddonShortcutLabels { + const labels: API_AddonShortcutLabels = {}; Object.entries(api.getAddonsShortcuts()).forEach(([actionName, { label }]) => { labels[actionName] = label; }); return labels; }, - getAddonsShortcutDefaults(): AddonShortcutDefaults { - const defaults: AddonShortcutDefaults = {}; + getAddonsShortcutDefaults(): API_AddonShortcutDefaults { + const defaults: API_AddonShortcutDefaults = {}; Object.entries(api.getAddonsShortcuts()).forEach(([actionName, { defaultShortcut }]) => { defaults[actionName] = defaultShortcut; }); return defaults; }, - async setShortcuts(shortcuts: Shortcuts) { + async setShortcuts(shortcuts: API_Shortcuts) { await store.setState({ shortcuts }, { persistence: 'permanent' }); return shortcuts; }, async restoreAllDefaultShortcuts() { - return api.setShortcuts(api.getDefaultShortcuts() as Shortcuts); + return api.setShortcuts(api.getDefaultShortcuts() as API_Shortcuts); }, async setShortcut(action, value) { const shortcuts = api.getShortcutKeys(); await api.setShortcuts({ ...shortcuts, [action]: value }); return value; }, - async setAddonShortcut(addon: string, shortcut: AddonShortcut) { + async setAddonShortcut(addon: string, shortcut: API_AddonShortcut) { const shortcuts = api.getShortcutKeys(); await api.setShortcuts({ ...shortcuts, @@ -161,7 +161,7 @@ export const init: ModuleFn = ({ store, fullAPI }) => { const shortcut = eventToShortcut(event); const shortcuts = api.getShortcutKeys(); const actions = keys(shortcuts); - const matchedFeature = actions.find((feature: Action) => + const matchedFeature = actions.find((feature: API_Action) => shortcutMatchesShortcut(shortcut, shortcuts[feature]) ); if (matchedFeature) { diff --git a/code/lib/api/src/modules/stories.ts b/code/lib/api/src/modules/stories.ts index 1080eb9f8e1a..8e9b07c14965 100644 --- a/code/lib/api/src/modules/stories.ts +++ b/code/lib/api/src/modules/stories.ts @@ -1,5 +1,6 @@ +/* eslint-disable camelcase */ import global from 'global'; -import { toId, sanitize } from '@storybook/csf'; +import { toId, sanitize, StoryId } from '@storybook/csf'; import { PRELOAD_ENTRIES, STORY_PREPARED, @@ -15,6 +16,17 @@ import { } from '@storybook/core-events'; import { logger } from '@storybook/client-logger'; +import { + API_Args, + API_ComposedRef, + API_HashEntry, + API_LeafEntry, + API_SetStoriesPayload, + API_SetStoriesStoryData, + API_StoriesHash, + API_StoryEntry, + API_StoryIndex, +} from '@storybook/types'; import { getEventMetadata } from '../lib/events'; import { denormalizeStoryParameters, @@ -22,22 +34,10 @@ import { transformStoryIndexToStoriesHash, getComponentLookupList, getStoriesLookupList, - HashEntry, - LeafEntry, addPreparedStories, } from '../lib/stories'; -import type { - StoriesHash, - StoryEntry, - StoryId, - SetStoriesStoryData, - SetStoriesPayload, - StoryIndex, -} from '../lib/stories'; - -import type { Args, ModuleFn } from '../index'; -import type { ComposedRef } from './refs'; +import type { ModuleFn } from '../index'; const { FEATURES, fetch } = global; const STORY_INDEX_PATH = './index.json'; @@ -46,10 +46,10 @@ type Direction = -1 | 1; type ParameterName = string; type ViewMode = 'story' | 'info' | 'settings' | string | undefined; -type StoryUpdate = Pick; +type StoryUpdate = Pick; export interface SubState { - storiesHash: StoriesHash; + storiesHash: API_StoriesHash; storyId: StoryId; viewMode: ViewMode; storiesConfigured: boolean; @@ -58,37 +58,37 @@ export interface SubState { export interface SubAPI { storyId: typeof toId; - resolveStory: (storyId: StoryId, refsId?: string) => HashEntry; + resolveStory: (storyId: StoryId, refsId?: string) => API_HashEntry; selectFirstStory: () => void; selectStory: ( kindOrId?: string, story?: string, obj?: { ref?: string; viewMode?: ViewMode } ) => void; - getCurrentStoryData: () => LeafEntry; - setStories: (stories: SetStoriesStoryData, failed?: Error) => Promise; + getCurrentStoryData: () => API_LeafEntry; + setStories: (stories: API_SetStoriesStoryData, failed?: Error) => Promise; jumpToComponent: (direction: Direction) => void; jumpToStory: (direction: Direction) => void; - getData: (storyId: StoryId, refId?: string) => LeafEntry; + getData: (storyId: StoryId, refId?: string) => API_LeafEntry; isPrepared: (storyId: StoryId, refId?: string) => boolean; getParameters: ( storyId: StoryId | { storyId: StoryId; refId: string }, parameterName?: ParameterName - ) => StoryEntry['parameters'] | any; + ) => API_StoryEntry['parameters'] | any; getCurrentParameter(parameterName?: ParameterName): S; - updateStoryArgs(story: StoryEntry, newArgs: Args): void; - resetStoryArgs: (story: StoryEntry, argNames?: string[]) => void; - findLeafEntry(StoriesHash: StoriesHash, storyId: StoryId): LeafEntry; - findLeafStoryId(StoriesHash: StoriesHash, storyId: StoryId): StoryId; + updateStoryArgs(story: API_StoryEntry, newArgs: API_Args): void; + resetStoryArgs: (story: API_StoryEntry, argNames?: string[]) => void; + findLeafEntry(StoriesHash: API_StoriesHash, storyId: StoryId): API_LeafEntry; + findLeafStoryId(StoriesHash: API_StoriesHash, storyId: StoryId): StoryId; findSiblingStoryId( storyId: StoryId, - hash: StoriesHash, + hash: API_StoriesHash, direction: Direction, toSiblingGroup: boolean // when true, skip over leafs within the same group ): StoryId; fetchStoryList: () => Promise; - setStoryList: (storyList: StoryIndex) => Promise; - updateStory: (storyId: StoryId, update: StoryUpdate, ref?: ComposedRef) => Promise; + setStoryList: (storyList: API_StoryIndex) => Promise; + updateStory: (storyId: StoryId, update: StoryUpdate, ref?: API_ComposedRef) => Promise; } const removedOptions = ['enableShortcuts', 'theme', 'showRoots']; @@ -327,7 +327,7 @@ export const init: ModuleFn = ({ const result = await fetch(STORY_INDEX_PATH); if (result.status !== 200) throw new Error(await result.text()); - const storyIndex = (await result.json()) as StoryIndex; + const storyIndex = (await result.json()) as API_StoryIndex; // We can only do this if the stories.json is a proper storyIndex if (storyIndex.v < 3) { @@ -343,7 +343,7 @@ export const init: ModuleFn = ({ }); } }, - setStoryList: async (storyIndex: StoryIndex) => { + setStoryList: async (storyIndex: API_StoryIndex) => { const newHash = transformStoryIndexToStoriesHash(storyIndex, { provider, docsOptions, @@ -361,21 +361,21 @@ export const init: ModuleFn = ({ updateStory: async ( storyId: StoryId, update: StoryUpdate, - ref?: ComposedRef + ref?: API_ComposedRef ): Promise => { if (!ref) { const { storiesHash } = store.getState(); storiesHash[storyId] = { ...storiesHash[storyId], ...update, - } as StoryEntry; + } as API_StoryEntry; await store.setState({ storiesHash }); } else { const { id: refId, stories } = ref; stories[storyId] = { ...stories[storyId], ...update, - } as StoryEntry; + } as API_StoryEntry; await fullAPI.updateRef(refId, { stories }); } }, @@ -453,7 +453,7 @@ export const init: ModuleFn = ({ } }); - fullAPI.on(SET_STORIES, function handler(data: SetStoriesPayload) { + fullAPI.on(SET_STORIES, function handler(data: API_SetStoriesPayload) { const { ref } = getEventMetadata(this, fullAPI); const setStoriesData = data.v ? denormalizeStoryParameters(data) : data.stories; @@ -495,7 +495,7 @@ export const init: ModuleFn = ({ fullAPI.on( STORY_ARGS_UPDATED, - function handleStoryArgsUpdated({ storyId, args }: { storyId: StoryId; args: Args }) { + function handleStoryArgsUpdated({ storyId, args }: { storyId: StoryId; args: API_Args }) { const { ref } = getEventMetadata(this, fullAPI); fullAPI.updateStory(storyId, { args }, ref); } diff --git a/code/lib/api/src/modules/url.ts b/code/lib/api/src/modules/url.ts index 64f9b201f240..d6ce979acb0b 100644 --- a/code/lib/api/src/modules/url.ts +++ b/code/lib/api/src/modules/url.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import { NAVIGATE_URL, STORY_ARGS_UPDATED, @@ -10,8 +11,8 @@ import { queryFromLocation, buildArgsParam } from '@storybook/router'; import { dequal as deepEqual } from 'dequal'; import global from 'global'; +import type { API_Layout, API_UI } from '@storybook/types'; import { ModuleArgs, ModuleFn } from '../index'; -import { Layout, UI } from './layout'; const { window: globalWindow } = global; @@ -50,14 +51,14 @@ const initialUrlSupport = ({ ...otherParams // the rest gets passed to the iframe } = queryFromLocation(location); - const layout: Partial = { + const layout: Partial = { isFullscreen: parseBoolean(full), showNav: !singleStory && parseBoolean(nav), showPanel: parseBoolean(panel), panelPosition: ['right', 'bottom'].includes(panel) ? panel : undefined, showTabs: parseBoolean(tabs), }; - const ui: Partial = { + const ui: Partial = { enableShortcuts: parseBoolean(shortcuts), }; const selectedPanel = addonPanel || undefined; diff --git a/code/lib/api/src/modules/versions.ts b/code/lib/api/src/modules/versions.ts index 52adc92c3b23..1f7077866108 100644 --- a/code/lib/api/src/modules/versions.ts +++ b/code/lib/api/src/modules/versions.ts @@ -1,38 +1,22 @@ +/* eslint-disable camelcase */ import global from 'global'; import semver from 'semver'; import memoize from 'memoizerific'; +import type { API_UnknownEntries, API_Version, API_Versions } from '@storybook/types'; import { version as currentVersion } from '../version'; import type { ModuleFn } from '../index'; const { VERSIONCHECK } = global; -export interface Version { - version: string; - info?: { plain: string }; - [key: string]: any; -} - -export interface UnknownEntries { - [key: string]: { - [key: string]: any; - }; -} - -export interface Versions { - latest?: Version; - next?: Version; - current?: Version; -} - export interface SubState { - versions: Versions & UnknownEntries; + versions: API_Versions & API_UnknownEntries; lastVersionCheck: number; dismissedVersionNotification: undefined | string; } -const getVersionCheckData = memoize(1)((): Versions => { +const getVersionCheckData = memoize(1)((): API_Versions => { try { return { ...(JSON.parse(VERSIONCHECK).data || {}) }; } catch (e) { @@ -41,8 +25,8 @@ const getVersionCheckData = memoize(1)((): Versions => { }); export interface SubAPI { - getCurrentVersion: () => Version; - getLatestVersion: () => Version; + getCurrentVersion: () => API_Version; + getLatestVersion: () => API_Version; versionUpdateAvailable: () => boolean; } diff --git a/code/lib/types/src/index.ts b/code/lib/types/src/index.ts index 84fa78dee25b..043541675979 100644 --- a/code/lib/types/src/index.ts +++ b/code/lib/types/src/index.ts @@ -5,3 +5,5 @@ export * from './modules/client-api'; export * from './modules/core-client'; export * from './modules/core-common'; export * from './modules/builder'; +export * from './modules/api'; +export * from './modules/api-stories'; diff --git a/code/lib/types/src/modules/api-stories.ts b/code/lib/types/src/modules/api-stories.ts new file mode 100644 index 000000000000..4b70d1f51b35 --- /dev/null +++ b/code/lib/types/src/modules/api-stories.ts @@ -0,0 +1,288 @@ +/* eslint-disable camelcase */ + +import { API_ViewMode } from './api'; +import { DocsOptions } from './core-common'; +import { + Args, + ArgTypes, + ComponentId, + Parameters, + ComponentTitle, + StoryId, + StoryKind, + StoryName, + Conditional, + Globals, + GlobalTypes, +} from './csf'; + +export interface API_BaseEntry { + id: StoryId; + depth: number; + name: string; + refId?: string; + renderLabel?: (item: API_BaseEntry) => React.ReactNode; + + /** @deprecated */ + isRoot: boolean; + /** @deprecated */ + isComponent: boolean; + /** @deprecated */ + isLeaf: boolean; +} + +export interface API_RootEntry extends API_BaseEntry { + type: 'root'; + startCollapsed?: boolean; + children: StoryId[]; + + /** @deprecated */ + isRoot: true; + /** @deprecated */ + isComponent: false; + /** @deprecated */ + isLeaf: false; +} + +export interface API_GroupEntry extends API_BaseEntry { + type: 'group'; + parent?: StoryId; + children: StoryId[]; + + /** @deprecated */ + isRoot: false; + /** @deprecated */ + isComponent: false; + /** @deprecated */ + isLeaf: false; +} + +export interface API_ComponentEntry extends API_BaseEntry { + type: 'component'; + parent?: StoryId; + children: StoryId[]; + + /** @deprecated */ + isRoot: false; + /** @deprecated */ + isComponent: true; + /** @deprecated */ + isLeaf: false; +} + +export interface API_DocsEntry extends API_BaseEntry { + type: 'docs'; + parent: StoryId; + title: ComponentTitle; + /** @deprecated */ + kind: ComponentTitle; + importPath: API_Path; + + /** @deprecated */ + isRoot: false; + /** @deprecated */ + isComponent: false; + /** @deprecated */ + isLeaf: true; +} + +export interface API_StoryEntry extends API_BaseEntry { + type: 'story'; + parent: StoryId; + title: ComponentTitle; + /** @deprecated */ + kind: ComponentTitle; + importPath: API_Path; + prepared: boolean; + parameters?: { + [parameterName: string]: any; + }; + args?: Args; + argTypes?: ArgTypes; + initialArgs?: Args; + + /** @deprecated */ + isRoot: false; + /** @deprecated */ + isComponent: false; + /** @deprecated */ + isLeaf: true; +} + +export type API_LeafEntry = API_DocsEntry | API_StoryEntry; +export type API_HashEntry = + | API_RootEntry + | API_GroupEntry + | API_ComponentEntry + | API_DocsEntry + | API_StoryEntry; + +/** @deprecated */ +export type API_Root = API_RootEntry; + +/** @deprecated */ +export type API_Group = API_GroupEntry | API_ComponentEntry; + +/** @deprecated */ +export type API_Story = API_LeafEntry; + +/** + * The `StoriesHash` is our manager-side representation of the `StoryIndex`. + * We create entries in the hash not only for each story or docs entry, but + * also for each "group" of the component (split on '/'), as that's how things + * are manipulated in the manager (i.e. in the sidebar) + */ +export interface API_StoriesHash { + [id: string]: API_HashEntry; +} + +// The data received on the (legacy) `setStories` event +export interface API_SetStoriesStory { + id: StoryId; + name: string; + refId?: string; + componentId?: ComponentId; + kind: StoryKind; + parameters: { + fileName: string; + options: { + [optionName: string]: any; + }; + docsOnly?: boolean; + viewMode?: API_ViewMode; + [parameterName: string]: any; + }; + argTypes?: ArgTypes; + args?: Args; + initialArgs?: Args; +} + +export interface API_SetStoriesStoryData { + [id: string]: API_SetStoriesStory; +} + +export interface API_StoryKey { + id: StoryId; + refId?: string; +} + +export type API_SetStoriesPayload = + | { + v: 2; + error?: Error; + globals: Args; + globalParameters: Parameters; + stories: API_SetStoriesStoryData; + kindParameters: { + [kind: string]: Parameters; + }; + } + | ({ + v?: number; + stories: API_SetStoriesStoryData; + } & Record); + +// The data recevied via the story index +type API_Path = string; + +interface API_BaseIndexEntry { + id: StoryId; + name: StoryName; + title: ComponentTitle; + importPath: API_Path; +} + +export type API_StoryIndexEntry = API_BaseIndexEntry & { + type?: 'story'; +}; + +interface API_V3IndexEntry extends API_BaseIndexEntry { + parameters?: Parameters; +} + +export interface API_StoryIndexV3 { + v: 3; + stories: Record; +} + +export type API_DocsIndexEntry = API_BaseIndexEntry & { + storiesImports: API_Path[]; + type: 'docs'; +}; + +export type API_IndexEntry = API_StoryIndexEntry | API_DocsIndexEntry; +export interface StoryIndex { + v: number; + entries: Record; +} + +// We used to received a bit more data over the channel on the SET_STORIES event, including +// the full parameters for each story. +type API_PreparedIndexEntry = API_IndexEntry & { + parameters?: Parameters; + argTypes?: ArgTypes; + args?: Args; + initialArgs?: Args; +}; +export interface API_PreparedStoryIndex { + v: number; + entries: Record; +} + +export interface API_StoryIndex { + v: number; + entries: Record; +} + +export type API_OptionsData = { + docsOptions: DocsOptions; +}; + +export interface API_Args { + [key: string]: any; +} + +export interface API_ArgType { + name?: string; + description?: string; + defaultValue?: any; + if?: Conditional; + [key: string]: any; +} + +export interface API_ArgTypes { + [key: string]: API_ArgType; +} + +export interface API_ReleaseNotes { + success?: boolean; + currentVersion?: string; + showOnFirstLaunch?: boolean; +} + +export interface API_Settings { + lastTrackedStoryId: string; +} + +export interface API_SetGlobalsPayload { + globals: Globals; + globalTypes: GlobalTypes; +} + +export interface API_Version { + version: string; + info?: { plain: string }; + [key: string]: any; +} + +export interface API_UnknownEntries { + [key: string]: { + [key: string]: any; + }; +} + +export interface API_Versions { + latest?: API_Version; + next?: API_Version; + current?: API_Version; +} diff --git a/code/lib/types/src/modules/api.ts b/code/lib/types/src/modules/api.ts new file mode 100644 index 000000000000..63826148ffa2 --- /dev/null +++ b/code/lib/types/src/modules/api.ts @@ -0,0 +1,190 @@ +/* eslint-disable camelcase */ +import type { RenderData } from '@storybook/router'; +import type { Channel } from '@storybook/channels'; +import type { ThemeVars } from '@storybook/theming'; +import type { ViewMode } from './csf'; +import type { DocsOptions } from './core-common'; +import { + API_HashEntry, + API_SetStoriesStory, + API_SetStoriesStoryData, + API_StoriesHash, + API_StoryIndex, +} from './api-stories'; + +export type API_ViewMode = 'story' | 'info' | 'settings' | 'page' | undefined | string; + +enum types { + TAB = 'tab', + PANEL = 'panel', + TOOL = 'tool', + PREVIEW = 'preview', + NOTES_ELEMENT = 'notes-element', +} + +export type API_Types = types | string; +export interface API_RenderOptions { + active: boolean; + key: string; +} + +export interface API_RouteOptions { + storyId: string; + viewMode: API_ViewMode; + location: RenderData['location']; + path: string; +} +export interface API_MatchOptions { + storyId: string; + viewMode: API_ViewMode; + location: RenderData['location']; + path: string; +} + +export interface API_Addon { + title: string; + type?: API_Types; + id?: string; + route?: (routeOptions: API_RouteOptions) => string; + match?: (matchOptions: API_MatchOptions) => boolean; + render: (renderOptions: API_RenderOptions) => any; + paramKey?: string; + disabled?: boolean; + hidden?: boolean; +} +export interface API_Collection { + [key: string]: T; +} + +export type API_Panels = API_Collection; + +export type API_StateMerger = (input: S) => S; + +export interface API_ProviderData { + provider: API_Provider; + docsOptions: DocsOptions; +} + +export interface API_Provider { + channel?: Channel; + serverChannel?: Channel; + renderPreview?: API_IframeRenderer; + handleAPI(api: API): void; + getConfig(): { + sidebar?: API_SidebarOptions; + theme?: ThemeVars; + StoryMapper?: API_StoryMapper; + [k: string]: any; + } & Partial; + [key: string]: any; +} + +export type API_IframeRenderer = ( + storyId: string, + viewMode: ViewMode, + id: string, + baseUrl: string, + scale: number, + queryParams: Record +) => any; + +export interface API_UIOptions { + name?: string; + url?: string; + goFullScreen: boolean; + showStoriesPanel: boolean; + showAddonPanel: boolean; + addonPanelInRight: boolean; + theme?: ThemeVars; + selectedPanel?: string; +} + +export interface API_Layout { + initialActive: API_ActiveTabsType; + isFullscreen: boolean; + showPanel: boolean; + panelPosition: API_PanelPositions; + showNav: boolean; + showTabs: boolean; + showToolbar: boolean; + /** + * @deprecated + */ + isToolshown?: boolean; +} + +export interface API_UI { + name?: string; + url?: string; + enableShortcuts: boolean; +} + +export type API_PanelPositions = 'bottom' | 'right'; +export type API_ActiveTabsType = 'sidebar' | 'canvas' | 'addons'; + +export interface API_SidebarOptions { + showRoots?: boolean; + collapsedRoots?: string[]; + renderLabel?: (item: API_HashEntry) => any; +} + +export interface API_Notification { + id: string; + link: string; + content: { + headline: string; + subHeadline?: string | any; + }; + + icon?: { + name: string; + color?: string; + }; + onClear?: () => void; +} + +type API_Versions = Record; + +export type API_SetRefData = Partial< + API_ComposedRef & { + setStoriesData: API_SetStoriesStoryData; + storyIndex: API_StoryIndex; + } +>; + +export type API_StoryMapper = ( + ref: API_ComposedRef, + story: API_SetStoriesStory +) => API_SetStoriesStory; +export interface API_ComposedRef { + id: string; + title?: string; + url: string; + type?: 'auto-inject' | 'unknown' | 'lazy' | 'server-checked'; + expanded?: boolean; + stories: API_StoriesHash; + versions?: API_Versions; + loginUrl?: string; + version?: string; + ready?: boolean; + error?: any; +} + +export type API_ComposedRefUpdate = Partial< + Pick< + API_ComposedRef, + | 'title' + | 'type' + | 'expanded' + | 'stories' + | 'versions' + | 'loginUrl' + | 'version' + | 'ready' + | 'error' + > +>; + +export type API_Refs = Record; +export type API_RefId = string; +export type API_RefUrl = string; From 790c72b660f41a08ba97619aec2ddcf16a5effe6 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sat, 22 Oct 2022 04:29:20 +0200 Subject: [PATCH 14/38] step 10 --- code/lib/addons/src/main.ts | 20 +++----- code/lib/api/src/modules/channel.ts | 7 +-- code/lib/types/src/index.ts | 3 ++ code/lib/types/src/modules/addons.ts | 38 ++++++++------ code/lib/types/src/modules/api.ts | 6 +-- code/lib/types/src/modules/client-api.ts | 61 +++++++++++------------ code/lib/types/src/modules/core-common.ts | 2 +- code/lib/types/src/typings.d.ts | 1 + code/yarn.lock | 10 ++++ 9 files changed, 79 insertions(+), 69 deletions(-) create mode 100644 code/lib/types/src/typings.d.ts diff --git a/code/lib/addons/src/main.ts b/code/lib/addons/src/main.ts index 85742cbe027d..b10ef110d5f1 100644 --- a/code/lib/addons/src/main.ts +++ b/code/lib/addons/src/main.ts @@ -12,25 +12,17 @@ import type { Addon_Type, Addon_Types, } from '@storybook/types'; +import { Addon_TypesEnum } from '@storybook/types'; import { logger } from '@storybook/client-logger'; import { mockChannel } from './storybook-channel-mock'; -export enum types { - TAB = 'tab', - PANEL = 'panel', - TOOL = 'tool', - TOOLEXTRA = 'toolextra', - PREVIEW = 'preview', - NOTES_ELEMENT = 'notes-element', -} - -export { Addon_Type as Addon }; +export { Addon_Type as Addon, Addon_TypesEnum as types }; export function isSupportedType(type: Addon_Types): boolean { - return !!Object.values(types).find((typeVal) => typeVal === type); + return !!Object.values(Addon_TypesEnum).find((typeVal) => typeVal === type); } -export type Types = types | string; +export type Types = Addon_TypesEnum | string; export class AddonStore { constructor() { @@ -39,7 +31,7 @@ export class AddonStore { }) as Promise; } - private loaders: Addon_Loaders = {}; + private loaders: Addon_Loaders = {}; private elements: Addon_Elements = {}; @@ -94,7 +86,7 @@ export class AddonStore { addPanel = (name: string, options: Addon_Type): void => { this.add(name, { - type: types.PANEL, + type: Addon_TypesEnum.PANEL, ...options, }); }; diff --git a/code/lib/api/src/modules/channel.ts b/code/lib/api/src/modules/channel.ts index d2213348b73b..4beb752ae262 100644 --- a/code/lib/api/src/modules/channel.ts +++ b/code/lib/api/src/modules/channel.ts @@ -1,12 +1,13 @@ +/* eslint-disable camelcase */ /* eslint-disable no-param-reassign */ import { STORIES_COLLAPSE_ALL, STORIES_EXPAND_ALL } from '@storybook/core-events'; -import { Channel } from '@storybook/channels'; import type { Listener } from '@storybook/channels'; -import { ModuleFn } from '../index'; +import type { API_Provider } from '@storybook/types'; +import type { API, ModuleFn } from '../index'; export interface SubAPI { - getChannel: () => Channel; + getChannel: () => API_Provider['channel']; on: (type: string, cb: Listener) => () => void; off: (type: string, cb: Listener) => void; emit: (type: string, ...args: any[]) => void; diff --git a/code/lib/types/src/index.ts b/code/lib/types/src/index.ts index 043541675979..c2a5bacb891c 100644 --- a/code/lib/types/src/index.ts +++ b/code/lib/types/src/index.ts @@ -1,3 +1,6 @@ +// eslint-disable-next-line @typescript-eslint/triple-slash-reference +/// + export * from './modules/csf'; export * from './modules/addons'; export * from './modules/store'; diff --git a/code/lib/types/src/modules/addons.ts b/code/lib/types/src/modules/addons.ts index 8c90a3829f07..24eaf23a94b9 100644 --- a/code/lib/types/src/modules/addons.ts +++ b/code/lib/types/src/modules/addons.ts @@ -1,12 +1,14 @@ -import type { RenderData as RouterData } from '@storybook/router'; -import type { ThemeVars } from '@storybook/theming'; -import type { API } from '@storybook/api'; -import type { types } from '@storybook/addons'; - /* eslint-disable camelcase */ -import type { +import type { RenderData as RouterData } from '../../../router/src/router'; +import type { ThemeVars } from '../../../theming/src/types'; +import { AnyFramework, + Args, + ComponentTitle, InputType, + StoryId, + StoryKind, + StoryName, StoryContext as StoryContextForFramework, LegacyStoryFn as LegacyStoryFnForFramework, PartialStoryFn as PartialStoryFnForFramework, @@ -14,14 +16,9 @@ import type { StoryFn as StoryFnForFramework, DecoratorFunction as DecoratorFunctionForFramework, LoaderFunction as LoaderFunctionForFramework, - StoryId, - StoryKind, - StoryName, - Args, - ComponentTitle, -} from '@storybook/types'; +} from './csf'; -export type Addon_Types = types | string; +export type Addon_Types = Addon_TypesEnum | string; export interface Addon_ArgType extends InputType { defaultValue?: TArg; @@ -328,10 +325,10 @@ export interface Addon_Type { hidden?: boolean; } -export type Addon_Loader = (api: API) => void; +export type Addon_Loader = (api: API) => void; -export interface Addon_Loaders { - [key: string]: Addon_Loader; +export interface Addon_Loaders { + [key: string]: Addon_Loader; } export interface Addon_Collection { [key: string]: Addon_Type; @@ -349,3 +346,12 @@ export interface Addon_Config { }; [key: string]: any; } + +export enum Addon_TypesEnum { + TAB = 'tab', + PANEL = 'panel', + TOOL = 'tool', + TOOLEXTRA = 'toolextra', + PREVIEW = 'preview', + NOTES_ELEMENT = 'notes-element', +} diff --git a/code/lib/types/src/modules/api.ts b/code/lib/types/src/modules/api.ts index 63826148ffa2..a5701d838167 100644 --- a/code/lib/types/src/modules/api.ts +++ b/code/lib/types/src/modules/api.ts @@ -1,7 +1,7 @@ /* eslint-disable camelcase */ -import type { RenderData } from '@storybook/router'; -import type { Channel } from '@storybook/channels'; -import type { ThemeVars } from '@storybook/theming'; +import type { RenderData } from '../../../router/src/router'; +import type { Channel } from '../../../channels/src'; +import type { ThemeVars } from '../../../theming/src/types'; import type { ViewMode } from './csf'; import type { DocsOptions } from './core-common'; import { diff --git a/code/lib/types/src/modules/client-api.ts b/code/lib/types/src/modules/client-api.ts index a4e9a5341b15..8e505be14b69 100644 --- a/code/lib/types/src/modules/client-api.ts +++ b/code/lib/types/src/modules/client-api.ts @@ -1,7 +1,5 @@ /* eslint-disable camelcase */ -import type { Addon, HooksContext } from '@storybook/addons'; -import type { StoryStore } from '@storybook/store'; -import type { Addon_StoryApi } from './addons'; +import type { Addon_StoryApi, Addon_Type } from './addons'; import type { Store_RenderContext } from './store'; import type { AnyFramework, @@ -10,7 +8,6 @@ import type { DecoratorFunction, LoaderFunction, Parameters, - ProjectAnnotations, LegacyStoryFn, StoryContext, StoryFn, @@ -57,39 +54,39 @@ export type ClientAPI_AddStoryArgs = StoryIdentifier & { loaders?: LoaderFunction[]; }; -export type ClientAPI_StoreItem = StoryIdentifier & { - parameters: Parameters; - getDecorated: () => StoryFn; - getOriginal: () => StoryFn; - applyLoaders: () => Promise; - playFunction: (context: StoryContext) => Promise | void; - storyFn: StoryFn; - unboundStoryFn: StoryFn; - hooks: HooksContext; - args: Args; - initialArgs: Args; - argTypes: ArgTypes; -}; - -export type ClientAPI_PublishedStoreItem = ClientAPI_StoreItem & { - globals: Args; -}; - -export interface ClientAPI_StoreData { - [key: string]: ClientAPI_StoreItem; -} - -export interface ClientAPI_ClientApiParams { - storyStore: StoryStore; - decorateStory?: ProjectAnnotations['applyDecorators']; - noStoryModuleAddMethodHotDispose?: boolean; -} +// export type ClientAPI_StoreItem = StoryIdentifier & { +// parameters: Parameters; +// getDecorated: () => StoryFn; +// getOriginal: () => StoryFn; +// applyLoaders: () => Promise; +// playFunction: (context: StoryContext) => Promise | void; +// storyFn: StoryFn; +// unboundStoryFn: StoryFn; +// hooks: HooksContext; +// args: Args; +// initialArgs: Args; +// argTypes: ArgTypes; +// }; + +// export type ClientAPI_PublishedStoreItem = ClientAPI_StoreItem & { +// globals: Args; +// }; + +// export interface ClientAPI_StoreData { +// [key: string]: ClientAPI_StoreItem; +// } + +// export interface ClientAPI_ClientApiParams { +// storyStore: StoryStore; +// decorateStory?: ProjectAnnotations['applyDecorators']; +// noStoryModuleAddMethodHotDispose?: boolean; +// } export type ClientAPI_ClientApiReturnFn = ( ...args: any[] ) => Addon_StoryApi; -export interface ClientAPI_ClientApiAddon extends Addon { +export interface ClientAPI_ClientApiAddon extends Addon_Type { apply: (a: Addon_StoryApi, b: any[]) => any; } diff --git a/code/lib/types/src/modules/core-common.ts b/code/lib/types/src/modules/core-common.ts index 2f05cd163c57..182177f722d4 100644 --- a/code/lib/types/src/modules/core-common.ts +++ b/code/lib/types/src/modules/core-common.ts @@ -5,8 +5,8 @@ import type { Options as TelejsonOptions } from 'telejson'; import type { TransformOptions } from '@babel/core'; import type { Router } from 'express'; import type { Server } from 'http'; -import type { Parameters } from '@storybook/types'; import type { PackageJson as PackageJsonFromTypeFest } from 'type-fest'; +import type { Parameters } from './csf'; /** * ⚠️ This file contains internal WIP types they MUST NOT be exported outside this package for now! diff --git a/code/lib/types/src/typings.d.ts b/code/lib/types/src/typings.d.ts new file mode 100644 index 000000000000..2f4eb9cf4fd9 --- /dev/null +++ b/code/lib/types/src/typings.d.ts @@ -0,0 +1 @@ +declare module 'global'; diff --git a/code/yarn.lock b/code/yarn.lock index 3b45351f923c..f9663d57f55a 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -7060,6 +7060,7 @@ __metadata: "@storybook/node-logger": 7.0.0-alpha.40 "@storybook/preview-web": 7.0.0-alpha.40 "@storybook/source-loader": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 "@types/express": ^4.17.13 "@types/node": ^16.0.0 "@vitejs/plugin-react": ^2.0.0 @@ -7190,6 +7191,7 @@ __metadata: "@storybook/csf-tools": 7.0.0-alpha.40 "@storybook/node-logger": 7.0.0-alpha.40 "@storybook/telemetry": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 "@types/cross-spawn": ^6.0.2 "@types/degit": ^2.8.3 "@types/prompts": ^2.0.9 @@ -7331,6 +7333,7 @@ __metadata: "@storybook/addons": 7.0.0-alpha.40 "@storybook/channel-postmessage": 7.0.0-alpha.40 "@storybook/channel-websocket": 7.0.0-alpha.40 + "@storybook/channels": 7.0.0-alpha.40 "@storybook/client-api": 7.0.0-alpha.40 "@storybook/client-logger": 7.0.0-alpha.40 "@storybook/core-events": 7.0.0-alpha.40 @@ -7482,6 +7485,7 @@ __metadata: dependencies: "@storybook/core-common": 7.0.0-alpha.40 "@storybook/node-logger": 7.0.0-alpha.40 + "@storybook/types": 7.0.0-alpha.40 "@types/node": ^16.0.0 ts-dedent: ^2.0.0 typescript: ~4.6.3 @@ -7722,6 +7726,7 @@ __metadata: resolution: "@storybook/instrumenter@workspace:lib/instrumenter" dependencies: "@storybook/addons": 7.0.0-alpha.40 + "@storybook/channels": 7.0.0-alpha.40 "@storybook/client-logger": 7.0.0-alpha.40 "@storybook/core-events": 7.0.0-alpha.40 core-js: ^3.8.2 @@ -8699,6 +8704,11 @@ __metadata: resolution: "@storybook/types@workspace:lib/types" dependencies: "@storybook/csf": 0.0.2--canary.49.258942b.0 + "@types/babel__core": ^7.0.0 + "@types/express": ^4.7.0 + "@types/node": ^16.0.0 + file-system-cache: ^2.0.0 + synchronous-promise: ^2.0.15 typescript: ~4.6.3 languageName: unknown linkType: soft From 9ca18321bc81389bac58d4a95ca94dce602e3692 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sat, 22 Oct 2022 04:51:15 +0200 Subject: [PATCH 15/38] step 11 --- code/lib/router/src/router.tsx | 2 +- code/lib/types/package.json | 10 +++++++--- code/lib/types/src/modules/api-stories.ts | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/code/lib/router/src/router.tsx b/code/lib/router/src/router.tsx index ebd67e386385..031234dafe7f 100644 --- a/code/lib/router/src/router.tsx +++ b/code/lib/router/src/router.tsx @@ -24,7 +24,7 @@ interface MatchingData { } interface LocationProps { - children: (renderData: RenderData) => ReactNode; + children: (renderData: RenderData) => any; } interface MatchProps { path: string; diff --git a/code/lib/types/package.json b/code/lib/types/package.json index 76d750a98686..b9aab461d46e 100644 --- a/code/lib/types/package.json +++ b/code/lib/types/package.json @@ -39,12 +39,16 @@ "check": "../../../scripts/node_modules/.bin/tsc --noEmit", "prep": "../../../scripts/prepare/bundle.ts" }, - "devDependencies": { - "@storybook/csf": "0.0.2--canary.49.258942b.0", + "dependencies": { + "@babel/core": "^7.12.10", "@types/babel__core": "^7.0.0", "@types/express": "^4.7.0", + "express": "^4.17.1", + "file-system-cache": "^2.0.0" + }, + "devDependencies": { + "@storybook/csf": "0.0.2--canary.49.258942b.0", "@types/node": "^16.0.0", - "file-system-cache": "^2.0.0", "synchronous-promise": "^2.0.15", "typescript": "~4.6.3" }, diff --git a/code/lib/types/src/modules/api-stories.ts b/code/lib/types/src/modules/api-stories.ts index 4b70d1f51b35..b9036f88d191 100644 --- a/code/lib/types/src/modules/api-stories.ts +++ b/code/lib/types/src/modules/api-stories.ts @@ -21,7 +21,7 @@ export interface API_BaseEntry { depth: number; name: string; refId?: string; - renderLabel?: (item: API_BaseEntry) => React.ReactNode; + renderLabel?: (item: API_BaseEntry) => any; /** @deprecated */ isRoot: boolean; From 6f9940b4dd9ff0dea801bd0aeb55df512bf5ceed Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sat, 22 Oct 2022 04:51:49 +0200 Subject: [PATCH 16/38] fix lockfile --- code/yarn.lock | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/yarn.lock b/code/yarn.lock index f9663d57f55a..6b1e91f8d533 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -8703,10 +8703,12 @@ __metadata: version: 0.0.0-use.local resolution: "@storybook/types@workspace:lib/types" dependencies: + "@babel/core": ^7.12.10 "@storybook/csf": 0.0.2--canary.49.258942b.0 "@types/babel__core": ^7.0.0 "@types/express": ^4.7.0 "@types/node": ^16.0.0 + express: ^4.17.1 file-system-cache: ^2.0.0 synchronous-promise: ^2.0.15 typescript: ~4.6.3 From 9b3eeeae1515f1a7d31cd9c7d367b2b50e643048 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sat, 22 Oct 2022 12:48:46 +0200 Subject: [PATCH 17/38] fixes --- code/addons/a11y/src/manager.tsx | 2 +- code/addons/actions/src/manager.tsx | 2 +- code/addons/backgrounds/src/manager.tsx | 2 +- code/addons/controls/src/manager.tsx | 4 ++-- code/addons/interactions/src/manager.tsx | 2 +- code/addons/measure/src/manager.tsx | 2 +- code/addons/outline/src/manager.tsx | 2 +- code/addons/toolbars/src/manager.tsx | 2 +- code/addons/viewport/src/manager.tsx | 2 +- .../ember/src/client/preview/render.ts | 5 +++-- .../server/framework-preset-babel-ember.ts | 2 +- code/frameworks/nextjs/src/preset.ts | 2 +- .../telemetry/src/storybook-metadata.test.ts | 2 +- .../src/framework-preset-svelte.ts | 2 +- code/renderers/html/src/render.ts | 6 +++--- code/renderers/preact/src/render.tsx | 8 ++++---- code/renderers/react/src/render.tsx | 6 +++--- code/renderers/react/src/testing-api.ts | 20 ++++++++++++------- code/renderers/server/src/render.ts | 5 +++-- code/renderers/svelte/src/render.ts | 8 ++++---- code/renderers/vue/src/render.ts | 6 +++--- code/renderers/vue3/src/render.ts | 6 +++--- code/renderers/web-components/src/render.ts | 13 +++++++++--- .../my-addon-initial-panel-state.js.mdx | 2 +- .../storybook-addon-panel-example.js.mdx | 2 +- .../storybook-addon-panel-initial.js.mdx | 2 +- .../storybook-addon-toolbar-example.js.mdx | 2 +- 27 files changed, 67 insertions(+), 52 deletions(-) diff --git a/code/addons/a11y/src/manager.tsx b/code/addons/a11y/src/manager.tsx index 455ee88ccdfb..ce24d1c9cafd 100644 --- a/code/addons/a11y/src/manager.tsx +++ b/code/addons/a11y/src/manager.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { addons, type types } from '@storybook/addons'; +import { addons, types } from '@storybook/addons'; import { ADDON_ID, PANEL_ID, PARAM_KEY } from './constants'; import { VisionSimulator } from './components/VisionSimulator'; import { A11YPanel } from './components/A11YPanel'; diff --git a/code/addons/actions/src/manager.tsx b/code/addons/actions/src/manager.tsx index 8aa8d33c3353..bd024620ac5e 100644 --- a/code/addons/actions/src/manager.tsx +++ b/code/addons/actions/src/manager.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect } from 'react'; -import { addons, type types } from '@storybook/addons'; +import { addons, types } from '@storybook/addons'; import { STORY_CHANGED } from '@storybook/core-events'; import ActionLogger from './containers/ActionLogger'; import { ADDON_ID, EVENT_ID, PANEL_ID, PARAM_KEY } from './constants'; diff --git a/code/addons/backgrounds/src/manager.tsx b/code/addons/backgrounds/src/manager.tsx index fd494dc6a282..d3b8d095ec97 100644 --- a/code/addons/backgrounds/src/manager.tsx +++ b/code/addons/backgrounds/src/manager.tsx @@ -1,5 +1,5 @@ import React, { Fragment } from 'react'; -import { addons, type types } from '@storybook/addons'; +import { addons, types } from '@storybook/addons'; import { ADDON_ID } from './constants'; import { BackgroundSelector } from './containers/BackgroundSelector'; diff --git a/code/addons/controls/src/manager.tsx b/code/addons/controls/src/manager.tsx index f7aaa6125978..f76dfaf83e9a 100644 --- a/code/addons/controls/src/manager.tsx +++ b/code/addons/controls/src/manager.tsx @@ -1,7 +1,7 @@ import React from 'react'; -import { addons, type types } from '@storybook/addons'; +import { addons, types } from '@storybook/addons'; import { AddonPanel } from '@storybook/components'; -import { API, useArgTypes } from '@storybook/api'; +import { type API, useArgTypes } from '@storybook/api'; import { ControlsPanel } from './ControlsPanel'; import { ADDON_ID, PARAM_KEY } from './constants'; diff --git a/code/addons/interactions/src/manager.tsx b/code/addons/interactions/src/manager.tsx index 8a63871ab569..454945d6c44a 100644 --- a/code/addons/interactions/src/manager.tsx +++ b/code/addons/interactions/src/manager.tsx @@ -1,4 +1,4 @@ -import { addons, type types } from '@storybook/addons'; +import { addons, types } from '@storybook/addons'; import { ADDON_ID, PANEL_ID } from './constants'; import { Panel } from './Panel'; diff --git a/code/addons/measure/src/manager.tsx b/code/addons/measure/src/manager.tsx index 054279073967..162e7ce43ecd 100644 --- a/code/addons/measure/src/manager.tsx +++ b/code/addons/measure/src/manager.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { addons, type types } from '@storybook/addons'; +import { addons, types } from '@storybook/addons'; import { ADDON_ID, TOOL_ID } from './constants'; import { Tool } from './Tool'; diff --git a/code/addons/outline/src/manager.tsx b/code/addons/outline/src/manager.tsx index 5837ed744d06..3f3f96ae3b06 100644 --- a/code/addons/outline/src/manager.tsx +++ b/code/addons/outline/src/manager.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { addons, type types } from '@storybook/addons'; +import { addons, types } from '@storybook/addons'; import { ADDON_ID } from './constants'; import { OutlineSelector } from './OutlineSelector'; diff --git a/code/addons/toolbars/src/manager.tsx b/code/addons/toolbars/src/manager.tsx index bc1fbe98c038..c6681e989354 100644 --- a/code/addons/toolbars/src/manager.tsx +++ b/code/addons/toolbars/src/manager.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { addons, type types } from '@storybook/addons'; +import { addons, types } from '@storybook/addons'; import { ToolbarManager } from './components/ToolbarManager'; import { ADDON_ID } from './constants'; diff --git a/code/addons/viewport/src/manager.tsx b/code/addons/viewport/src/manager.tsx index abf47da815d2..81b1b17e588c 100644 --- a/code/addons/viewport/src/manager.tsx +++ b/code/addons/viewport/src/manager.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { addons, type types } from '@storybook/addons'; +import { addons, types } from '@storybook/addons'; import { ADDON_ID } from './constants'; diff --git a/code/frameworks/ember/src/client/preview/render.ts b/code/frameworks/ember/src/client/preview/render.ts index 19d71d881cc9..f238e55f3691 100644 --- a/code/frameworks/ember/src/client/preview/render.ts +++ b/code/frameworks/ember/src/client/preview/render.ts @@ -1,6 +1,7 @@ +/* eslint-disable camelcase */ import global from 'global'; import { dedent } from 'ts-dedent'; -import type { RenderContext } from '@storybook/store'; +import type { Store_RenderContext } from '@storybook/types'; // @ts-expect-error (Converted from ts-ignore) import Component from '@ember/component'; // eslint-disable-line import/no-unresolved import { OptionsArgs, EmberFramework } from './types'; @@ -61,7 +62,7 @@ function render(options: OptionsArgs, el: Element) { } export function renderToDOM( - { storyFn, kind, name, showMain, showError }: RenderContext, + { storyFn, kind, name, showMain, showError }: Store_RenderContext, domElement: Element ) { const element = storyFn(); diff --git a/code/frameworks/ember/src/server/framework-preset-babel-ember.ts b/code/frameworks/ember/src/server/framework-preset-babel-ember.ts index cab822afcfde..f85328fb84ee 100644 --- a/code/frameworks/ember/src/server/framework-preset-babel-ember.ts +++ b/code/frameworks/ember/src/server/framework-preset-babel-ember.ts @@ -1,7 +1,7 @@ import type { TransformOptions } from '@babel/core'; import { precompile } from 'ember-source/dist/ember-template-compiler'; import { findDistEsm } from '@storybook/core-common'; -import type { StorybookConfig, Options } from '@storybook/core-common'; +import type { StorybookConfig, Options } from '@storybook/types'; let emberOptions: any; diff --git a/code/frameworks/nextjs/src/preset.ts b/code/frameworks/nextjs/src/preset.ts index 03bcfb62d003..ba94c76ef99d 100644 --- a/code/frameworks/nextjs/src/preset.ts +++ b/code/frameworks/nextjs/src/preset.ts @@ -1,6 +1,6 @@ // https://storybook.js.org/docs/react/addons/writing-presets import { dirname, join } from 'path'; -import { Options, PresetProperty } from '@storybook/core-common'; +import type { Options, PresetProperty } from '@storybook/types'; import { TransformOptions } from '@babel/core'; import { configureConfig } from './config/webpack'; import { configureCss } from './css/webpack'; diff --git a/code/lib/telemetry/src/storybook-metadata.test.ts b/code/lib/telemetry/src/storybook-metadata.test.ts index f4875adc99c6..f23a78a418bb 100644 --- a/code/lib/telemetry/src/storybook-metadata.test.ts +++ b/code/lib/telemetry/src/storybook-metadata.test.ts @@ -1,4 +1,4 @@ -import type { PackageJson, StorybookConfig } from '@storybook/core-common'; +import type { PackageJson, StorybookConfig } from '@storybook/types'; import path from 'path'; import { computeStorybookMetadata, metaFrameworks, sanitizeAddonName } from './storybook-metadata'; diff --git a/code/presets/svelte-webpack/src/framework-preset-svelte.ts b/code/presets/svelte-webpack/src/framework-preset-svelte.ts index 48d20ce60d79..b82680721fff 100644 --- a/code/presets/svelte-webpack/src/framework-preset-svelte.ts +++ b/code/presets/svelte-webpack/src/framework-preset-svelte.ts @@ -1,4 +1,4 @@ -import type { Preset } from '@storybook/core-common'; +import type { Preset } from '@storybook/types'; import type { StorybookConfig, SvelteOptions } from './types'; export const webpack: StorybookConfig['webpack'] = async (config, { presets }) => { diff --git a/code/renderers/html/src/render.ts b/code/renderers/html/src/render.ts index fa92b430df50..710804bdfd6c 100644 --- a/code/renderers/html/src/render.ts +++ b/code/renderers/html/src/render.ts @@ -1,11 +1,11 @@ +/* eslint-disable camelcase */ /* eslint-disable no-param-reassign */ // @ts-expect-error (Converted from ts-ignore) import global from 'global'; import { dedent } from 'ts-dedent'; import { simulatePageLoad, simulateDOMContentLoaded } from '@storybook/preview-web'; -import type { RenderContext } from '@storybook/store'; -import { ArgsStoryFn } from '@storybook/types'; +import type { Store_RenderContext, ArgsStoryFn } from '@storybook/types'; import type { HtmlFramework } from './types'; const { Node } = global; @@ -43,7 +43,7 @@ export const render: ArgsStoryFn = (args, context) => { }; export function renderToDOM( - { storyFn, kind, name, showMain, showError, forceRemount }: RenderContext, + { storyFn, kind, name, showMain, showError, forceRemount }: Store_RenderContext, domElement: Element ) { const element = storyFn(); diff --git a/code/renderers/preact/src/render.tsx b/code/renderers/preact/src/render.tsx index 3d83b4b9dd94..25d2d8e3bd40 100644 --- a/code/renderers/preact/src/render.tsx +++ b/code/renderers/preact/src/render.tsx @@ -1,8 +1,8 @@ +/* eslint-disable camelcase */ /** @jsx h */ import * as preact from 'preact'; import { dedent } from 'ts-dedent'; -import type { RenderContext } from '@storybook/store'; -import { ArgsStoryFn } from '@storybook/types'; +import type { Store_RenderContext, ArgsStoryFn } from '@storybook/types'; import type { StoryFnPreactReturnType, PreactFramework } from './types'; @@ -36,7 +36,7 @@ function preactRender(story: StoryFnPreactReturnType | null, domElement: Element const StoryHarness: preact.FunctionalComponent<{ name: string; title: string; - showError: RenderContext['showError']; + showError: Store_RenderContext['showError']; storyFn: () => any; domElement: Element; }> = ({ showError, name, title, storyFn, domElement }) => { @@ -55,7 +55,7 @@ const StoryHarness: preact.FunctionalComponent<{ }; export function renderToDOM( - { storyFn, title, name, showMain, showError, forceRemount }: RenderContext, + { storyFn, title, name, showMain, showError, forceRemount }: Store_RenderContext, domElement: Element ) { if (forceRemount) { diff --git a/code/renderers/react/src/render.tsx b/code/renderers/react/src/render.tsx index 75f517c1662d..086a93d2b6cb 100644 --- a/code/renderers/react/src/render.tsx +++ b/code/renderers/react/src/render.tsx @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ // @ts-expect-error (Converted from ts-ignore) import global from 'global'; @@ -13,8 +14,7 @@ import React, { import ReactDOM, { version as reactDomVersion } from 'react-dom'; import type { Root as ReactRoot } from 'react-dom/client'; -import type { RenderContext } from '@storybook/store'; -import { ArgsStoryFn } from '@storybook/types'; +import type { Store_RenderContext, ArgsStoryFn } from '@storybook/types'; import type { ReactFramework, StoryContext } from './types'; @@ -137,7 +137,7 @@ export async function renderToDOM( showMain, showException, forceRemount, - }: RenderContext, + }: Store_RenderContext, domElement: Element ) { const Story = unboundStoryFn as FC>; diff --git a/code/renderers/react/src/testing-api.ts b/code/renderers/react/src/testing-api.ts index 4c0399c2fcd5..6b3a08ad560f 100644 --- a/code/renderers/react/src/testing-api.ts +++ b/code/renderers/react/src/testing-api.ts @@ -1,10 +1,16 @@ +/* eslint-disable camelcase */ import { composeStory as originalComposeStory, composeStories as originalComposeStories, setProjectAnnotations as originalSetProjectAnnotations, } from '@storybook/store'; -import type { CSFExports, ComposedStory, StoriesWithPartialProps } from '@storybook/store'; -import { ProjectAnnotations, Args } from '@storybook/types'; +import type { + Store_CSFExports, + Store_ComposedStory, + Store_StoriesWithPartialProps, + ProjectAnnotations, + Args, +} from '@storybook/types'; import { deprecate } from '@storybook/client-logger'; import { render } from './render'; @@ -76,13 +82,13 @@ const defaultProjectAnnotations: ProjectAnnotations = { * @param [exportsName] - in case your story does not contain a name and you want it to have a name. */ export function composeStory( - story: ComposedStory, + story: Store_ComposedStory, componentAnnotations: Meta, projectAnnotations?: ProjectAnnotations, exportsName?: string ) { return originalComposeStory( - story as ComposedStory, + story as Store_ComposedStory, componentAnnotations, projectAnnotations, defaultProjectAnnotations, @@ -115,7 +121,7 @@ export function composeStory( * @param csfExports - e.g. (import * as stories from './Button.stories') * @param [projectAnnotations] - e.g. (import * as projectAnnotations from '../.storybook/preview') this can be applied automatically if you use `setProjectAnnotations` in your setup files. */ -export function composeStories>( +export function composeStories>( csfExports: TModule, projectAnnotations?: ProjectAnnotations ) { @@ -123,7 +129,7 @@ export function composeStories>( const composedStories = originalComposeStories(csfExports, projectAnnotations, composeStory); return composedStories as unknown as Omit< - StoriesWithPartialProps, - keyof CSFExports + Store_StoriesWithPartialProps, + keyof Store_CSFExports >; } diff --git a/code/renderers/server/src/render.ts b/code/renderers/server/src/render.ts index ae35a8a6d138..3400d4cf1ecd 100644 --- a/code/renderers/server/src/render.ts +++ b/code/renderers/server/src/render.ts @@ -1,9 +1,10 @@ +/* eslint-disable camelcase */ /* eslint-disable no-param-reassign */ // @ts-expect-error (Converted from ts-ignore) import global from 'global'; import { dedent } from 'ts-dedent'; -import type { RenderContext } from '@storybook/store'; +import type { Store_RenderContext } from '@storybook/types'; import { simulatePageLoad, simulateDOMContentLoaded } from '@storybook/preview-web'; import type { StoryFn, Args, ArgTypes } from './public-types'; import type { FetchStoryHtmlType, ServerFramework } from './types'; @@ -55,7 +56,7 @@ export async function renderToDOM( storyFn, storyContext, storyContext: { parameters, args, argTypes }, - }: RenderContext, + }: Store_RenderContext, domElement: Element ) { // Some addons wrap the storyFn so we need to call it even though Server doesn't need the answer diff --git a/code/renderers/svelte/src/render.ts b/code/renderers/svelte/src/render.ts index 16dcbdb22fc6..37fa2b3859a8 100644 --- a/code/renderers/svelte/src/render.ts +++ b/code/renderers/svelte/src/render.ts @@ -1,9 +1,9 @@ +/* eslint-disable import/no-extraneous-dependencies */ +/* eslint-disable camelcase */ // @ts-expect-error (Converted from ts-ignore) import global from 'global'; -import type { ArgsStoryFn } from '@storybook/types'; -import type { RenderContext } from '@storybook/store'; -// eslint-disable-next-line import/no-extraneous-dependencies +import type { Store_RenderContext, ArgsStoryFn } from '@storybook/types'; import PreviewRender from '@storybook/svelte/templates/PreviewRender.svelte'; import { SvelteFramework } from './types'; @@ -20,7 +20,7 @@ function cleanUpPreviousStory() { } export function renderToDOM( - { storyFn, kind, name, showMain, showError, storyContext }: RenderContext, + { storyFn, kind, name, showMain, showError, storyContext }: Store_RenderContext, domElement: Element ) { cleanUpPreviousStory(); diff --git a/code/renderers/vue/src/render.ts b/code/renderers/vue/src/render.ts index 7a72723fca31..a2feacdbcb05 100644 --- a/code/renderers/vue/src/render.ts +++ b/code/renderers/vue/src/render.ts @@ -1,8 +1,8 @@ +/* eslint-disable camelcase */ /* eslint-disable no-underscore-dangle */ import { dedent } from 'ts-dedent'; import Vue from 'vue'; -import type { RenderContext } from '@storybook/store'; -import type { ArgsStoryFn } from '@storybook/types'; +import type { Store_RenderContext, ArgsStoryFn } from '@storybook/types'; import { CombinedVueInstance } from 'vue/types/vue'; import type { VueFramework } from './types'; @@ -93,7 +93,7 @@ export function renderToDOM( showError, showException, forceRemount, - }: RenderContext, + }: Store_RenderContext, domElement: Element ) { const root = getRoot(domElement); diff --git a/code/renderers/vue3/src/render.ts b/code/renderers/vue3/src/render.ts index 291746304a6a..f65ac5c80004 100644 --- a/code/renderers/vue3/src/render.ts +++ b/code/renderers/vue3/src/render.ts @@ -1,7 +1,7 @@ +/* eslint-disable camelcase */ import { dedent } from 'ts-dedent'; import { createApp, h } from 'vue'; -import type { RenderContext } from '@storybook/store'; -import type { ArgsStoryFn } from '@storybook/types'; +import type { Store_RenderContext, ArgsStoryFn } from '@storybook/types'; import { StoryFnVueReturnType, VueFramework } from './types'; @@ -25,7 +25,7 @@ export const setup = (fn: (app: any) => void) => { const map = new Map>(); export function renderToDOM( - { title, name, storyFn, showMain, showError, showException }: RenderContext, + { title, name, storyFn, showMain, showError, showException }: Store_RenderContext, domElement: Element ) { // TODO: explain cyclical nature of these app => story => mount diff --git a/code/renderers/web-components/src/render.ts b/code/renderers/web-components/src/render.ts index fdada72c3847..311ead09df35 100644 --- a/code/renderers/web-components/src/render.ts +++ b/code/renderers/web-components/src/render.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ /* eslint-disable @typescript-eslint/ban-ts-comment */ /* eslint-disable no-param-reassign */ import global from 'global'; @@ -8,8 +9,7 @@ import { render as litRender } from 'lit-html'; // eslint-disable-next-line import/extensions import { isTemplateResult } from 'lit-html/directive-helpers.js'; import { simulatePageLoad, simulateDOMContentLoaded } from '@storybook/preview-web'; -import type { RenderContext } from '@storybook/store'; -import { ArgsStoryFn } from '@storybook/types'; +import type { Store_RenderContext, ArgsStoryFn } from '@storybook/types'; import { WebComponentsFramework } from './types'; const { Node } = global; @@ -31,7 +31,14 @@ export const render: ArgsStoryFn = (args, context) => { }; export function renderToDOM( - { storyFn, kind, name, showMain, showError, forceRemount }: RenderContext, + { + storyFn, + kind, + name, + showMain, + showError, + forceRemount, + }: Store_RenderContext, domElement: Element ) { const element = storyFn(); diff --git a/docs/snippets/common/my-addon-initial-panel-state.js.mdx b/docs/snippets/common/my-addon-initial-panel-state.js.mdx index 591ba75867f1..8009d61ac4fd 100644 --- a/docs/snippets/common/my-addon-initial-panel-state.js.mdx +++ b/docs/snippets/common/my-addon-initial-panel-state.js.mdx @@ -3,7 +3,7 @@ import React from 'react'; -import { addons, type types } from '@storybook/addons'; +import { addons, types } from '@storybook/addons'; import { AddonPanel } from '@storybook/components'; diff --git a/docs/snippets/common/storybook-addon-panel-example.js.mdx b/docs/snippets/common/storybook-addon-panel-example.js.mdx index e98c6c37f386..29d8a1ab9d46 100644 --- a/docs/snippets/common/storybook-addon-panel-example.js.mdx +++ b/docs/snippets/common/storybook-addon-panel-example.js.mdx @@ -5,7 +5,7 @@ import React from 'react'; import { AddonPanel } from '@storybook/components'; -import { addons, type types } from '@storybook/addons'; +import { addons, types } from '@storybook/addons'; import { useGlobals } from '@storybook/api'; diff --git a/docs/snippets/common/storybook-addon-panel-initial.js.mdx b/docs/snippets/common/storybook-addon-panel-initial.js.mdx index 57dc8646af17..9f9e6b6c05f0 100644 --- a/docs/snippets/common/storybook-addon-panel-initial.js.mdx +++ b/docs/snippets/common/storybook-addon-panel-initial.js.mdx @@ -3,7 +3,7 @@ import React from 'react'; -import { addons, type types } from '@storybook/addons'; +import { addons, types } from '@storybook/addons'; import { AddonPanel } from '@storybook/components'; diff --git a/docs/snippets/common/storybook-addon-toolbar-example.js.mdx b/docs/snippets/common/storybook-addon-toolbar-example.js.mdx index 8c88e70e8e41..869c9df49ad4 100644 --- a/docs/snippets/common/storybook-addon-toolbar-example.js.mdx +++ b/docs/snippets/common/storybook-addon-toolbar-example.js.mdx @@ -3,7 +3,7 @@ import React from "react"; -import { addons, type types } from '@storybook/addons'; +import { addons, types } from '@storybook/addons'; import { Icons, IconButton } from '@storybook/components'; From 33d47b77c22206dca33bd0dc091017430a6ce665 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sat, 22 Oct 2022 13:38:56 +0200 Subject: [PATCH 18/38] fix dumb mistake --- code/workspace.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/workspace.json b/code/workspace.json index 5349650c3073..705eafd6a656 100644 --- a/code/workspace.json +++ b/code/workspace.json @@ -368,7 +368,7 @@ }, "@storybook/types": { "implicitDependencies": [], - "root": "lib/channels", + "root": "lib/types", "type": "library" }, "@storybook/ui": { From 4ceb1c6b805354a1d1a29ef1dc810b91122858d2 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sat, 22 Oct 2022 14:50:45 +0200 Subject: [PATCH 19/38] force it to work in the correct build-order --- code/addons/links/package.json | 1 + code/addons/links/src/utils.ts | 2 +- code/lib/types/README.md | 3 +- code/workspace.json | 168 ++++++++++++++++----------------- code/yarn.lock | 1 + 5 files changed, 89 insertions(+), 86 deletions(-) diff --git a/code/addons/links/package.json b/code/addons/links/package.json index 8d1185ad55ad..dee2afa2192a 100644 --- a/code/addons/links/package.json +++ b/code/addons/links/package.json @@ -66,6 +66,7 @@ "@storybook/addons": "7.0.0-alpha.41", "@storybook/client-logger": "7.0.0-alpha.41", "@storybook/core-events": "7.0.0-alpha.41", + "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/router": "7.0.0-alpha.41", "@storybook/types": "7.0.0-alpha.41", "global": "^4.4.0", diff --git a/code/addons/links/src/utils.ts b/code/addons/links/src/utils.ts index cc932afabf94..73ba6e0d3322 100644 --- a/code/addons/links/src/utils.ts +++ b/code/addons/links/src/utils.ts @@ -2,7 +2,7 @@ import global from 'global'; import { addons, makeDecorator } from '@storybook/addons'; import { STORY_CHANGED, SELECT_STORY } from '@storybook/core-events'; import type { StoryId, StoryName, ComponentTitle } from '@storybook/types'; -import { toId } from '@storybook/types'; +import { toId } from '@storybook/csf'; import { PARAM_KEY } from './constants'; const { document, HTMLElement } = global; diff --git a/code/lib/types/README.md b/code/lib/types/README.md index 9bbfbbfdf026..3fc5cbe80885 100644 --- a/code/lib/types/README.md +++ b/code/lib/types/README.md @@ -2,6 +2,7 @@ Storybook types exports only typescript types for storybook usage. -It has no runtime implementations. +It exports typescript enums, which do have a runtime implementation. +But it should not export any implementation such as classes, method, function or constants. It also has no dependencies, all the types it exports are bundled in. diff --git a/code/workspace.json b/code/workspace.json index 705eafd6a656..e05796807d25 100644 --- a/code/workspace.json +++ b/code/workspace.json @@ -2,132 +2,132 @@ "version": 2, "projects": { "@storybook/addon-a11y": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "addons/a11y", "type": "library" }, "@storybook/addon-actions": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "addons/actions", "type": "library" }, "@storybook/addon-backgrounds": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "addons/backgrounds", "type": "library" }, "@storybook/addon-controls": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "addons/controls", "type": "library" }, "@storybook/addon-docs": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "addons/docs", "type": "library" }, "@storybook/addon-essentials": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "addons/essentials", "type": "library" }, "@storybook/addon-highlight": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "addons/highlight", "type": "library" }, "@storybook/addon-interactions": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "addons/interactions", "type": "library" }, "@storybook/addon-jest": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "addons/jest", "type": "library" }, "@storybook/addon-links": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "addons/links", "type": "library" }, "@storybook/addon-measure": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "addons/measure", "type": "library" }, "@storybook/addon-outline": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "addons/outline", "type": "library" }, "@storybook/addon-storyshots": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "addons/storyshots/storyshots-core", "type": "library" }, "@storybook/addon-storyshots-puppeteer": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "addons/storyshots/storyshots-puppeteer", "type": "library" }, "@storybook/addon-storysource": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "addons/storysource", "type": "library" }, "@storybook/addon-toolbars": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "addons/toolbars", "type": "library" }, "@storybook/addon-viewport": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "addons/viewport", "type": "library" }, "@storybook/addons": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/addons", "type": "library" }, "@storybook/angular": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "frameworks/angular", "type": "library" }, "@storybook/api": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/api", "type": "library" }, "@storybook/blocks": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/blocks", "type": "library" }, "@storybook/builder-manager": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/builder-manager", "type": "library" }, "@storybook/builder-vite": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/builder-vite", "type": "library" }, "@storybook/builder-webpack5": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/builder-webpack5", "type": "library" }, "@storybook/channel-postmessage": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/channel-postmessage", "type": "library" }, "@storybook/channel-websocket": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/channel-websocket", "type": "library" }, @@ -137,12 +137,12 @@ "type": "library" }, "@storybook/cli": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/cli", "type": "library" }, "@storybook/client-api": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/client-api", "type": "library" }, @@ -152,82 +152,82 @@ "type": "library" }, "@storybook/codemod": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/codemod", "type": "library" }, "@storybook/components": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/components", "type": "library" }, "@storybook/core-client": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/core-client", "type": "library" }, "@storybook/core-common": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/core-common", "type": "library" }, "@storybook/core-events": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/core-events", "type": "library" }, "@storybook/core-server": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/core-server", "type": "library" }, "@storybook/core-vite": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/core-vite", "type": "library" }, "@storybook/core-webpack": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/core-webpack", "type": "library" }, "@storybook/csf-tools": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/csf-tools", "type": "library" }, "@storybook/docs-tools": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/docs-tools", "type": "library" }, "@storybook/ember": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "frameworks/ember", "type": "library" }, "@storybook/example-doc-blocks": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "examples/doc-blocks", "type": "library" }, "@storybook/external-docs": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "examples/external-docs", "type": "library" }, "@storybook/html": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "renderers/html", "type": "library" }, "@storybook/html-webpack5": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "frameworks/html-webpack5", "type": "library" }, "@storybook/instrumenter": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/instrumenter", "type": "library" }, @@ -237,82 +237,82 @@ "implicitDependencies": [] }, "@storybook/node-logger": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/node-logger", "type": "library" }, "@storybook/postinstall": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/postinstall", "type": "library" }, "@storybook/preact": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "renderers/preact", "type": "library" }, "@storybook/preact-webpack5": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "frameworks/preact-webpack5", "type": "library" }, "@storybook/preset-html-webpack": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "presets/html-webpack", "type": "library" }, "@storybook/preset-preact-webpack": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "presets/preact-webpack", "type": "library" }, "@storybook/preset-react-webpack": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "presets/react-webpack", "type": "library" }, "@storybook/preset-server-webpack": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "presets/server-webpack", "type": "library" }, "@storybook/preset-svelte-webpack": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "presets/svelte-webpack", "type": "library" }, "@storybook/preset-vue-webpack": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "presets/vue-webpack", "type": "library" }, "@storybook/preset-vue3-webpack": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "presets/vue3-webpack", "type": "library" }, "@storybook/preset-web-components-webpack": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "presets/web-components-webpack", "type": "library" }, "@storybook/preview-web": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/preview-web", "type": "library" }, "@storybook/react": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "renderers/react", "type": "library" }, "@storybook/react-vite": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "frameworks/react-vite", "type": "library" }, "@storybook/react-webpack5": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "frameworks/react-webpack5", "type": "library" }, @@ -322,42 +322,42 @@ "type": "library" }, "@storybook/server": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "renderers/server", "type": "library" }, "@storybook/server-webpack5": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "frameworks/server-webpack5", "type": "library" }, "@storybook/source-loader": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/source-loader", "type": "library" }, "@storybook/store": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/store", "type": "library" }, "@storybook/svelte": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "renderers/svelte", "type": "library" }, "@storybook/svelte-vite": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "frameworks/svelte-vite", "type": "library" }, "@storybook/svelte-webpack5": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "frameworks/svelte-webpack5", "type": "library" }, "@storybook/telemetry": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/telemetry", "type": "library" }, @@ -372,82 +372,82 @@ "type": "library" }, "@storybook/ui": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "ui/manager", "type": "library" }, "@storybook/vue": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "renderers/vue", "type": "library" }, "@storybook/vue-vite": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "frameworks/vue-vite", "type": "library" }, "@storybook/vue-webpack5": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "frameworks/vue-webpack5", "type": "library" }, "@storybook/vue3": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "renderers/vue3", "type": "library" }, "@storybook/vue3-vite": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "frameworks/vue3-vite", "type": "library" }, "@storybook/vue3-webpack5": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "frameworks/vue3-webpack5", "type": "library" }, "@storybook/web-components": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "renderers/web-components", "type": "library" }, "@storybook/web-components-vite": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "frameworks/web-components-vite", "type": "library" }, "@storybook/web-components-webpack5": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "frameworks/web-components-webpack5", "type": "library" }, "ember-example": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "examples/ember-cli", "type": "library" }, "sb": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/cli-sb", "type": "library" }, "server-kitchen-sink": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "examples/server-kitchen-sink", "type": "library" }, "standalone-preview": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "examples/standalone-preview", "type": "library" }, "storybook": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "lib/cli-storybook", "type": "library" }, "vue-3-cli-example": { - "implicitDependencies": [], + "implicitDependencies": ["@storybook/types"], "root": "examples/vue-3-cli", "type": "library" } diff --git a/code/yarn.lock b/code/yarn.lock index 98630e00be01..f83447d124aa 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -6562,6 +6562,7 @@ __metadata: "@storybook/addons": 7.0.0-alpha.41 "@storybook/client-logger": 7.0.0-alpha.41 "@storybook/core-events": 7.0.0-alpha.41 + "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/router": 7.0.0-alpha.41 "@storybook/types": 7.0.0-alpha.41 global: ^4.4.0 From 4a1bb57773a4aafbbee401e678e5067457536157 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sat, 22 Oct 2022 15:04:04 +0200 Subject: [PATCH 20/38] fixes --- code/frameworks/ember/package.json | 1 + .../ember/src/client/preview/types.ts | 2 +- code/lib/blocks/package.json | 1 + code/lib/blocks/src/blocks/ArgsTable.tsx | 19 ++++++++++--------- code/lib/blocks/src/blocks/Meta.tsx | 11 ++++++----- code/lib/blocks/src/blocks/Source.tsx | 12 ++++++------ .../lib/blocks/src/blocks/SourceContainer.tsx | 2 +- code/lib/blocks/src/blocks/Story.tsx | 15 +++++++++++---- code/lib/blocks/src/blocks/Title.tsx | 2 +- code/lib/blocks/src/blocks/types.ts | 2 ++ code/lib/blocks/src/blocks/useStory.ts | 10 +++++----- .../src/components/ArgsTable/ArgsTable.tsx | 2 +- .../blocks/src/components/ArgsTable/types.ts | 1 + .../src/components/BlockBackgroundStyles.tsx | 2 +- .../src/PreviewWeb.integration.test.ts | 11 ++++++----- code/renderers/html/src/types.ts | 2 +- code/renderers/preact/src/types.ts | 2 +- code/renderers/react/src/types.ts | 3 ++- code/renderers/server/src/types.ts | 2 +- code/renderers/svelte/src/types.ts | 2 +- code/renderers/vue/src/types.ts | 2 +- code/renderers/vue3/src/types.ts | 2 +- code/yarn.lock | 2 ++ 23 files changed, 64 insertions(+), 46 deletions(-) diff --git a/code/frameworks/ember/package.json b/code/frameworks/ember/package.json index 04973b7d1126..43b066cdd44d 100644 --- a/code/frameworks/ember/package.json +++ b/code/frameworks/ember/package.json @@ -35,6 +35,7 @@ "@storybook/core-common": "7.0.0-alpha.41", "@storybook/docs-tools": "7.0.0-alpha.41", "@storybook/store": "7.0.0-alpha.41", + "@storybook/types": "7.0.0-alpha.41", "global": "^4.4.0", "react": "16.14.0", "react-dom": "16.14.0", diff --git a/code/frameworks/ember/src/client/preview/types.ts b/code/frameworks/ember/src/client/preview/types.ts index eeee017fbb5e..29cfbcd153a9 100644 --- a/code/frameworks/ember/src/client/preview/types.ts +++ b/code/frameworks/ember/src/client/preview/types.ts @@ -1,4 +1,4 @@ -export type { RenderContext } from '@storybook/core-client'; +export type { RenderContext } from '@storybook/types'; export interface ShowErrorArgs { title: string; diff --git a/code/lib/blocks/package.json b/code/lib/blocks/package.json index c6ac11f3be13..dc92691b078e 100644 --- a/code/lib/blocks/package.json +++ b/code/lib/blocks/package.json @@ -46,6 +46,7 @@ "@storybook/client-logger": "7.0.0-alpha.41", "@storybook/components": "7.0.0-alpha.41", "@storybook/core-events": "7.0.0-alpha.41", + "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/docs-tools": "7.0.0-alpha.41", "@storybook/preview-web": "7.0.0-alpha.41", "@storybook/store": "7.0.0-alpha.41", diff --git a/code/lib/blocks/src/blocks/ArgsTable.tsx b/code/lib/blocks/src/blocks/ArgsTable.tsx index 369b7fa803fc..2176104285e0 100644 --- a/code/lib/blocks/src/blocks/ArgsTable.tsx +++ b/code/lib/blocks/src/blocks/ArgsTable.tsx @@ -1,14 +1,15 @@ +/* eslint-disable camelcase */ import React, { FC, useContext, useEffect, useState, useCallback } from 'react'; import mapValues from 'lodash/mapValues'; -import { ArgTypesExtractor } from '@storybook/docs-tools'; -import { filterArgTypes, PropDescriptor } from '@storybook/store'; +import type { ArgTypesExtractor } from '@storybook/docs-tools'; +import { filterArgTypes } from '@storybook/store'; +import type { Store_PropDescriptor, StrictArgTypes, Args, Globals } from '@storybook/types'; import { STORY_ARGS_UPDATED, UPDATE_STORY_ARGS, RESET_STORY_ARGS, GLOBALS_UPDATED, } from '@storybook/core-events'; -import { StrictArgTypes, Args, Globals } from '@storybook/types'; import { ArgsTable as PureArgsTable, ArgsTableProps as PureArgsTableProps, @@ -23,8 +24,8 @@ import { getComponentName } from './utils'; import { useStory } from './useStory'; interface BaseProps { - include?: PropDescriptor; - exclude?: PropDescriptor; + include?: Store_PropDescriptor; + exclude?: Store_PropDescriptor; sort?: SortType; } @@ -90,8 +91,8 @@ const useGlobals = (context: DocsContextProps): [Globals] => { export const extractComponentArgTypes = ( component: Component, context: DocsContextProps, - include?: PropDescriptor, - exclude?: PropDescriptor + include?: Store_PropDescriptor, + exclude?: Store_PropDescriptor ): StrictArgTypes => { const { parameters } = context.storyById(); const { extractArgTypes }: { extractArgTypes: ArgTypesExtractor } = parameters.docs || {}; @@ -125,8 +126,8 @@ const addComponentTabs = ( tabs: Record, components: Record, context: DocsContextProps, - include?: PropDescriptor, - exclude?: PropDescriptor, + include?: Store_PropDescriptor, + exclude?: Store_PropDescriptor, sort?: SortType ) => ({ ...tabs, diff --git a/code/lib/blocks/src/blocks/Meta.tsx b/code/lib/blocks/src/blocks/Meta.tsx index 7ae67746bfe1..8b343a8ff0e9 100644 --- a/code/lib/blocks/src/blocks/Meta.tsx +++ b/code/lib/blocks/src/blocks/Meta.tsx @@ -1,11 +1,11 @@ +/* eslint-disable camelcase */ import React, { FC, useContext } from 'react'; -import { BaseAnnotations } from '@storybook/types'; -import type { ModuleExports } from '@storybook/store'; +import type { BaseAnnotations, Store_ModuleExports } from '@storybook/types'; import { Anchor } from './Anchor'; import { DocsContext } from './DocsContext'; -type MetaProps = BaseAnnotations & { of?: ModuleExports }; +type MetaProps = BaseAnnotations & { of?: Store_ModuleExports }; /** * This component is used to declare component metadata in docs @@ -13,8 +13,9 @@ type MetaProps = BaseAnnotations & { of?: ModuleExports }; */ export const Meta: FC = ({ of }) => { const context = useContext(DocsContext); - console.log(DocsContext, context); - if (of) context.setMeta(of); + if (of) { + context.setMeta(of); + } try { const primary = context.storyById(); diff --git a/code/lib/blocks/src/blocks/Source.tsx b/code/lib/blocks/src/blocks/Source.tsx index 06de79308954..24b4e5e28c17 100644 --- a/code/lib/blocks/src/blocks/Source.tsx +++ b/code/lib/blocks/src/blocks/Source.tsx @@ -1,6 +1,6 @@ +/* eslint-disable camelcase */ import React, { ComponentProps, FC, useContext } from 'react'; -import type { StoryId } from '@storybook/api'; -import type { Story } from '@storybook/store'; +import type { StoryId, Store_Story } from '@storybook/types'; import { SourceType } from '@storybook/docs-tools'; import { Source as PureSource, SourceError } from '../components'; @@ -39,7 +39,7 @@ type NoneProps = CommonProps; type SourceProps = SingleSourceProps | MultiSourceProps | CodeProps | NoneProps; -const getSourceState = (stories: Story[]) => { +const getSourceState = (stories: Store_Story[]) => { const states = stories.map((story) => story.parameters.docs?.source?.state).filter(Boolean); if (states.length === 0) return SourceState.CLOSED; // FIXME: handling multiple stories is a pain @@ -53,7 +53,7 @@ const getStorySource = (storyId: StoryId, sourceContext: SourceContextProps): So return sources?.[storyId] || { code: '', format: false }; }; -const getSnippet = (snippet: string, story?: Story): string => { +const getSnippet = (snippet: string, story?: Store_Story): string => { if (!story) { return snippet; } @@ -118,13 +118,13 @@ export const getSourceProps = ( source = storyIds .map((storyId, idx) => { const { code: storySource } = getStorySource(storyId, sourceContext); - const storyObj = stories[idx] as Story; + const storyObj = stories[idx] as Store_Story; return getSnippet(storySource, storyObj); }) .join('\n\n'); } - const state = getSourceState(stories as Story[]); + const state = getSourceState(stories as Store_Story[]); const { docs: docsParameters = {} } = parameters; const { source: sourceParameters = {} } = docsParameters; diff --git a/code/lib/blocks/src/blocks/SourceContainer.tsx b/code/lib/blocks/src/blocks/SourceContainer.tsx index 6c3ebc77b5d1..9a58d4326447 100644 --- a/code/lib/blocks/src/blocks/SourceContainer.tsx +++ b/code/lib/blocks/src/blocks/SourceContainer.tsx @@ -5,7 +5,7 @@ import type { Channel } from '@storybook/channels'; import { SNIPPET_RENDERED } from '@storybook/docs-tools'; import type { SyntaxHighlighterFormatTypes } from '@storybook/components'; -import type { StoryId } from '@storybook/api'; +import type { StoryId } from '@storybook/types'; export interface SourceItem { code: string; diff --git a/code/lib/blocks/src/blocks/Story.tsx b/code/lib/blocks/src/blocks/Story.tsx index c3ad03adb776..613bc70c20dd 100644 --- a/code/lib/blocks/src/blocks/Story.tsx +++ b/code/lib/blocks/src/blocks/Story.tsx @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import React, { FC, ReactNode, @@ -8,8 +9,14 @@ import React, { useEffect, useState, } from 'react'; -import { StoryId, StoryAnnotations, AnyFramework } from '@storybook/types'; -import type { ModuleExport, ModuleExports, Story as StoryType } from '@storybook/store'; +import type { + StoryId, + StoryAnnotations, + AnyFramework, + Store_ModuleExport, + Store_ModuleExports, + Store_Story as StoryType, +} from '@storybook/types'; import { Story as PureStory, StorySkeleton } from '../components'; import { DocsContext, DocsContextProps } from './DocsContext'; @@ -31,8 +38,8 @@ type StoryDefProps = { type StoryRefProps = { id?: string; - of?: ModuleExport; - meta?: ModuleExports; + of?: Store_ModuleExport; + meta?: Store_ModuleExports; }; type StoryImportProps = { diff --git a/code/lib/blocks/src/blocks/Title.tsx b/code/lib/blocks/src/blocks/Title.tsx index d2edfa9bbe98..39e5b9f1486d 100644 --- a/code/lib/blocks/src/blocks/Title.tsx +++ b/code/lib/blocks/src/blocks/Title.tsx @@ -1,4 +1,4 @@ -import { ComponentTitle } from '@storybook/types'; +import type { ComponentTitle } from '@storybook/types'; import React, { useContext, FunctionComponent } from 'react'; import { Title as PureTitle } from '../components'; import { DocsContext } from './DocsContext'; diff --git a/code/lib/blocks/src/blocks/types.ts b/code/lib/blocks/src/blocks/types.ts index ea97155453ff..b48e9ac5f2bf 100644 --- a/code/lib/blocks/src/blocks/types.ts +++ b/code/lib/blocks/src/blocks/types.ts @@ -1,5 +1,7 @@ export const PRIMARY_STORY = '^'; +// TODO + export type Component = any; export interface StoryData { diff --git a/code/lib/blocks/src/blocks/useStory.ts b/code/lib/blocks/src/blocks/useStory.ts index 7c0e7d998a22..f2c01dec564a 100644 --- a/code/lib/blocks/src/blocks/useStory.ts +++ b/code/lib/blocks/src/blocks/useStory.ts @@ -1,13 +1,13 @@ +/* eslint-disable camelcase */ import { useState, useEffect } from 'react'; -import type { StoryId, AnyFramework } from '@storybook/types'; -import type { Story } from '@storybook/store'; +import type { StoryId, AnyFramework, Store_Story } from '@storybook/types'; import { DocsContextProps } from './DocsContext'; export function useStory( storyId: StoryId, context: DocsContextProps -): Story | void { +): Store_Story | void { const stories = useStories([storyId], context); return stories && stories[0]; } @@ -15,10 +15,10 @@ export function useStory( export function useStories( storyIds: StoryId[], context: DocsContextProps -): (Story | void)[] { +): (Store_Story | void)[] { // Legacy docs pages can reference any story by id. Those stories will need to be // asyncronously loaded; we use the state for this - const [storiesById, setStories] = useState>>({}); + const [storiesById, setStories] = useState>>({}); useEffect(() => { // deepscan-disable-next-line NO_EFFECT_CALL diff --git a/code/lib/blocks/src/components/ArgsTable/ArgsTable.tsx b/code/lib/blocks/src/components/ArgsTable/ArgsTable.tsx index 82f58ac95dd6..2b34084eebf1 100644 --- a/code/lib/blocks/src/components/ArgsTable/ArgsTable.tsx +++ b/code/lib/blocks/src/components/ArgsTable/ArgsTable.tsx @@ -2,7 +2,7 @@ import React, { FC } from 'react'; import pickBy from 'lodash/pickBy'; import { styled } from '@storybook/theming'; import { opacify, transparentize, darken, lighten } from 'polished'; -import { includeConditionalArg } from '@storybook/types'; +import { includeConditionalArg } from '@storybook/csf'; import { once } from '@storybook/client-logger'; import { IconButton, Icons, Link, ResetWrapper } from '@storybook/components'; import { ArgRow } from './ArgRow'; diff --git a/code/lib/blocks/src/components/ArgsTable/types.ts b/code/lib/blocks/src/components/ArgsTable/types.ts index 648268f26b54..3cb7b1db684e 100644 --- a/code/lib/blocks/src/components/ArgsTable/types.ts +++ b/code/lib/blocks/src/components/ArgsTable/types.ts @@ -1,5 +1,6 @@ import type { Conditional } from '@storybook/types'; +// TODO ? export interface JsDocParam { name: string; description?: string; diff --git a/code/lib/blocks/src/components/BlockBackgroundStyles.tsx b/code/lib/blocks/src/components/BlockBackgroundStyles.tsx index a037b5df830e..755df6e244cd 100644 --- a/code/lib/blocks/src/components/BlockBackgroundStyles.tsx +++ b/code/lib/blocks/src/components/BlockBackgroundStyles.tsx @@ -1,4 +1,4 @@ -import { Theme } from '@storybook/theming'; +import type { Theme } from '@storybook/theming'; export const getBlockBackgroundStyle: (theme: Theme) => object = (theme: Theme) => ({ borderRadius: theme.appBorderRadius, diff --git a/code/lib/preview-web/src/PreviewWeb.integration.test.ts b/code/lib/preview-web/src/PreviewWeb.integration.test.ts index 852d994f2602..924ab724a3d3 100644 --- a/code/lib/preview-web/src/PreviewWeb.integration.test.ts +++ b/code/lib/preview-web/src/PreviewWeb.integration.test.ts @@ -1,6 +1,7 @@ +/* eslint-disable camelcase */ import React from 'react'; import global from 'global'; -import { RenderContext } from '@storybook/store'; +import type { Store_RenderContext } from '@storybook/types'; import addons, { mockChannel as createMockChannel } from '@storybook/addons'; import { mocked } from 'ts-jest/utils'; @@ -73,8 +74,8 @@ describe('PreviewWeb', () => { const { DocsRenderer } = await import('@storybook/addon-docs'); projectAnnotations.parameters.docs.renderer = () => new DocsRenderer() as any; - projectAnnotations.renderToDOM.mockImplementationOnce(({ storyFn }: RenderContext) => - storyFn() + projectAnnotations.renderToDOM.mockImplementationOnce( + ({ storyFn }: Store_RenderContext) => storyFn() ); document.location.search = '?id=component-one--a'; await new PreviewWeb().initialize({ importFn, getProjectAnnotations }); @@ -133,8 +134,8 @@ describe('PreviewWeb', () => { await preview.initialize({ importFn, getProjectAnnotations }); await waitForRender(); - projectAnnotations.renderToDOM.mockImplementationOnce(({ storyFn }: RenderContext) => - storyFn() + projectAnnotations.renderToDOM.mockImplementationOnce( + ({ storyFn }: Store_RenderContext) => storyFn() ); projectAnnotations.decorators[0].mockClear(); mockChannel.emit.mockClear(); diff --git a/code/renderers/html/src/types.ts b/code/renderers/html/src/types.ts index 58e24cd5fe23..d7199b09acbc 100644 --- a/code/renderers/html/src/types.ts +++ b/code/renderers/html/src/types.ts @@ -1,7 +1,7 @@ import type { ArgsStoryFn, StoryContext as DefaultStoryContext } from '@storybook/types'; import { parameters } from './config'; -export type { RenderContext } from '@storybook/core-client'; +export type { RenderContext } from '@storybook/types'; export type StoryFnHtmlReturnType = string | Node; diff --git a/code/renderers/preact/src/types.ts b/code/renderers/preact/src/types.ts index 9ce6e34ea3e2..281f995d70a9 100644 --- a/code/renderers/preact/src/types.ts +++ b/code/renderers/preact/src/types.ts @@ -1,6 +1,6 @@ import type { AnyComponent } from 'preact'; -export type { RenderContext } from '@storybook/core-client'; +export type { RenderContext } from '@storybook/types'; export type StoryFnPreactReturnType = string | Node | preact.JSX.Element; diff --git a/code/renderers/react/src/types.ts b/code/renderers/react/src/types.ts index 0fdbdb992551..73bc47131cd8 100644 --- a/code/renderers/react/src/types.ts +++ b/code/renderers/react/src/types.ts @@ -1,7 +1,8 @@ +/* eslint-disable camelcase */ import type { ComponentType, ReactElement } from 'react'; import type { AnyFramework } from '@storybook/types'; -export type { RenderContext } from '@storybook/store'; +export type { Store_RenderContext as RenderContext } from '@storybook/types'; export type { StoryContext } from '@storybook/types'; export interface ReactFramework extends AnyFramework { diff --git a/code/renderers/server/src/types.ts b/code/renderers/server/src/types.ts index 32f6644027a1..decf1ddd21ca 100644 --- a/code/renderers/server/src/types.ts +++ b/code/renderers/server/src/types.ts @@ -1,6 +1,6 @@ import type { StoryContext as StoryContextBase } from '@storybook/types'; -export type { RenderContext } from '@storybook/core-client'; +export type { RenderContext } from '@storybook/types'; export type StoryFnServerReturnType = any; export type StoryContext = StoryContextBase; diff --git a/code/renderers/svelte/src/types.ts b/code/renderers/svelte/src/types.ts index 058c6ff7398e..c53f490464e9 100644 --- a/code/renderers/svelte/src/types.ts +++ b/code/renderers/svelte/src/types.ts @@ -1,6 +1,6 @@ import type { StoryContext as StoryContextBase } from '@storybook/types'; -export type { RenderContext } from '@storybook/core-client'; +export type { RenderContext } from '@storybook/types'; export type StoryContext = StoryContextBase; diff --git a/code/renderers/vue/src/types.ts b/code/renderers/vue/src/types.ts index 0522fcfc0e6a..cf49ae69735c 100644 --- a/code/renderers/vue/src/types.ts +++ b/code/renderers/vue/src/types.ts @@ -1,7 +1,7 @@ import type { StoryContext as StoryContextBase } from '@storybook/types'; import type { Component, AsyncComponent } from 'vue'; -export type { RenderContext } from '@storybook/core-client'; +export type { RenderContext } from '@storybook/types'; export interface ShowErrorArgs { title: string; diff --git a/code/renderers/vue3/src/types.ts b/code/renderers/vue3/src/types.ts index 1082586f06f6..121f918ef1df 100644 --- a/code/renderers/vue3/src/types.ts +++ b/code/renderers/vue3/src/types.ts @@ -1,7 +1,7 @@ import type { StoryContext as StoryContextBase } from '@storybook/types'; import type { ConcreteComponent } from 'vue'; -export type { RenderContext } from '@storybook/core-client'; +export type { RenderContext } from '@storybook/types'; export interface ShowErrorArgs { title: string; diff --git a/code/yarn.lock b/code/yarn.lock index f83447d124aa..df257e00fd38 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -7024,6 +7024,7 @@ __metadata: "@storybook/client-logger": 7.0.0-alpha.41 "@storybook/components": 7.0.0-alpha.41 "@storybook/core-events": 7.0.0-alpha.41 + "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/docs-tools": 7.0.0-alpha.41 "@storybook/preview-web": 7.0.0-alpha.41 "@storybook/store": 7.0.0-alpha.41 @@ -7607,6 +7608,7 @@ __metadata: "@storybook/core-common": 7.0.0-alpha.41 "@storybook/docs-tools": 7.0.0-alpha.41 "@storybook/store": 7.0.0-alpha.41 + "@storybook/types": 7.0.0-alpha.41 global: ^4.4.0 react: 16.14.0 react-dom: 16.14.0 From 7e8144b8a8cda6b4917083484b4fbf223d0524b2 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sat, 22 Oct 2022 15:50:18 +0200 Subject: [PATCH 21/38] cleanup --- code/lib/api/package.json | 1 + code/lib/api/src/tests/addons.test.js | 3 +- .../src/utils/StoryIndexGenerator.test.ts | 75 ++++++++++--------- code/lib/types/src/modules/core-client.ts | 5 +- 4 files changed, 44 insertions(+), 40 deletions(-) diff --git a/code/lib/api/package.json b/code/lib/api/package.json index 961804ea3550..6b3996931206 100644 --- a/code/lib/api/package.json +++ b/code/lib/api/package.json @@ -64,6 +64,7 @@ }, "devDependencies": { "@jest/globals": "^26.6.2", + "@storybook/addons": "7.0.0-alpha.41", "@storybook/core-common": "7.0.0-alpha.41", "@types/lodash": "^4.14.167", "@types/qs": "^6", diff --git a/code/lib/api/src/tests/addons.test.js b/code/lib/api/src/tests/addons.test.js index 3392b34aa632..803b9973aee4 100644 --- a/code/lib/api/src/tests/addons.test.js +++ b/code/lib/api/src/tests/addons.test.js @@ -1,4 +1,5 @@ -import { init as initAddons, types } from '../modules/addons'; +import { types } from '@storybook/addons'; +import { init as initAddons } from '../modules/addons'; const PANELS = { a11y: { diff --git a/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts b/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts index f4804e332ff1..b894116b52b5 100644 --- a/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts +++ b/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts @@ -1,11 +1,12 @@ +/* eslint-disable camelcase */ /// ; import path from 'path'; import fs from 'fs-extra'; import { normalizeStoriesEntry } from '@storybook/core-common'; -import type { NormalizedStoriesSpecifier } from '@storybook/core-common'; +import type { CoreCommon_NormalizedStoriesSpecifier } from '@storybook/types'; import { loadCsf, getStorySortParameter } from '@storybook/csf-tools'; -import { toId } from '@storybook/types'; +import { toId } from '@storybook/csf'; import { logger } from '@storybook/node-logger'; import { mocked } from 'ts-jest/utils'; @@ -62,18 +63,18 @@ describe('StoryIndexGenerator', () => { mocked(logger.warn).mockClear(); }); describe('extraction', () => { - const storiesSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const storiesSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/A.stories.(ts|js|jsx)', options ); - const docsSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const docsSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/docs2/*.mdx', options ); describe('single file specifier', () => { it('extracts stories from the right files', async () => { - const specifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const specifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/A.stories.js', options ); @@ -99,7 +100,7 @@ describe('StoryIndexGenerator', () => { }); describe('non-recursive specifier', () => { it('extracts stories from the right files', async () => { - const specifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const specifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/*/*.stories.(ts|js|jsx)', options ); @@ -133,7 +134,7 @@ describe('StoryIndexGenerator', () => { describe('recursive specifier', () => { it('extracts stories from the right files', async () => { - const specifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const specifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/**/*.stories.(ts|js|jsx)', options ); @@ -197,7 +198,7 @@ describe('StoryIndexGenerator', () => { const templateIndexer = { ...options.storyIndexers[0], addDocsTemplate: true }; it('adds docs entry with docs enabled', async () => { - const specifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const specifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/A.stories.js', options ); @@ -233,7 +234,7 @@ describe('StoryIndexGenerator', () => { `); }); it('does not add docs entry with docs disabled', async () => { - const specifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const specifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/A.stories.js', options ); @@ -268,7 +269,7 @@ describe('StoryIndexGenerator', () => { docs: { ...options.docs, docsPage: true }, }; it('generates an entry per CSF file', async () => { - const specifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const specifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/**/*.stories.(ts|js|jsx)', options ); @@ -382,12 +383,12 @@ describe('StoryIndexGenerator', () => { }); it('does not generate a docs page entry if there is a standalone entry with the same name', async () => { - const csfSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const csfSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/A.stories.js', options ); - const docsSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const docsSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/docs2/MetaOf.mdx', options ); @@ -423,7 +424,7 @@ describe('StoryIndexGenerator', () => { }); it('generates a combined entry if there are two stories files for the same title', async () => { - const specifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const specifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './duplicate/*.stories.(ts|js|jsx)', options ); @@ -467,7 +468,7 @@ describe('StoryIndexGenerator', () => { // https://github.com/storybookjs/storybook/issues/19142 it('does not generate a docs page entry if there are no stories in the CSF file', async () => { - const csfSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const csfSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './errors/NoStories.stories.ts', options ); @@ -679,7 +680,7 @@ describe('StoryIndexGenerator', () => { describe('duplicates', () => { it('warns when two standalone entries reference the same CSF file without a name', async () => { - const docsErrorSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const docsErrorSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './errors/DuplicateMetaOf.mdx', options ); @@ -707,7 +708,7 @@ describe('StoryIndexGenerator', () => { }); it('warns when a standalone entry has the same name as a story', async () => { - const docsErrorSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const docsErrorSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './errors/MetaOfClashingName.mdx', options ); @@ -760,11 +761,11 @@ describe('StoryIndexGenerator', () => { describe('sorting', () => { it('runs a user-defined sort function', async () => { - const storiesSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const storiesSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/**/*.stories.(ts|js|jsx)', options ); - const docsSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const docsSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/docs2/*.mdx', options ); @@ -796,7 +797,7 @@ describe('StoryIndexGenerator', () => { describe('caching', () => { describe('no invalidation', () => { it('does not extract csf files a second time', async () => { - const specifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const specifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/**/*.stories.(ts|js|jsx)', options ); @@ -813,11 +814,11 @@ describe('StoryIndexGenerator', () => { }); it('does not extract docs files a second time', async () => { - const storiesSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const storiesSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/A.stories.(ts|js|jsx)', options ); - const docsSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const docsSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/docs2/*.mdx', options ); @@ -833,7 +834,7 @@ describe('StoryIndexGenerator', () => { }); it('does not call the sort function a second time', async () => { - const specifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const specifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/**/*.stories.(ts|js|jsx)', options ); @@ -853,7 +854,7 @@ describe('StoryIndexGenerator', () => { describe('file changed', () => { it('calls extract csf file for just the one file', async () => { - const specifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const specifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/**/*.stories.(ts|js|jsx)', options ); @@ -872,11 +873,11 @@ describe('StoryIndexGenerator', () => { }); it('calls extract docs file for just the one file', async () => { - const storiesSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const storiesSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/A.stories.(ts|js|jsx)', options ); - const docsSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const docsSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/docs2/*.mdx', options ); @@ -894,11 +895,11 @@ describe('StoryIndexGenerator', () => { }); it('calls extract for a csf file and any of its docs dependents', async () => { - const storiesSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const storiesSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/A.stories.(ts|js|jsx)', options ); - const docsSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const docsSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/docs2/*.mdx', options ); @@ -916,7 +917,7 @@ describe('StoryIndexGenerator', () => { }); it('does call the sort function a second time', async () => { - const specifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const specifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/**/*.stories.(ts|js|jsx)', options ); @@ -938,7 +939,7 @@ describe('StoryIndexGenerator', () => { describe('file removed', () => { it('does not extract csf files a second time', async () => { - const specifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const specifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/**/*.stories.(ts|js|jsx)', options ); @@ -957,7 +958,7 @@ describe('StoryIndexGenerator', () => { }); it('does call the sort function a second time', async () => { - const specifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const specifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/**/*.stories.(ts|js|jsx)', options ); @@ -977,7 +978,7 @@ describe('StoryIndexGenerator', () => { }); it('does not include the deleted stories in results', async () => { - const specifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const specifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/**/*.stories.(ts|js|jsx)', options ); @@ -994,11 +995,11 @@ describe('StoryIndexGenerator', () => { }); it('does not include the deleted docs in results', async () => { - const storiesSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const storiesSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/A.stories.(ts|js|jsx)', options ); - const docsSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const docsSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/docs2/*.mdx', options ); @@ -1016,11 +1017,11 @@ describe('StoryIndexGenerator', () => { }); it('errors on dependency deletion', async () => { - const storiesSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const storiesSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/A.stories.(ts|js|jsx)', options ); - const docsSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const docsSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/docs2/*.mdx', options ); @@ -1040,11 +1041,11 @@ describe('StoryIndexGenerator', () => { }); it('cleans up properly on dependent docs deletion', async () => { - const storiesSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const storiesSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/A.stories.(ts|js|jsx)', options ); - const docsSpecifier: NormalizedStoriesSpecifier = normalizeStoriesEntry( + const docsSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry( './src/docs2/*.mdx', options ); diff --git a/code/lib/types/src/modules/core-client.ts b/code/lib/types/src/modules/core-client.ts index c74e548caadd..144c0447ae06 100644 --- a/code/lib/types/src/modules/core-client.ts +++ b/code/lib/types/src/modules/core-client.ts @@ -1,7 +1,8 @@ /* eslint-disable camelcase */ -import { Store_RenderContext, Store_WebProjectAnnotations } from './store'; +import { Store_RenderContext } from './store'; +// import { Store_RenderContext, Store_WebProjectAnnotations } from './store'; import type { ClientAPI_RenderContextWithoutStoryContext } from './client-api'; -import { ArgsStoryFn } from './csf'; +// import { ArgsStoryFn } from './csf'; export interface CoreClient_PreviewError { message?: string; From 0aefffea8912c92b8d204da7352bf9cba5e6a66e Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sat, 22 Oct 2022 16:33:04 +0200 Subject: [PATCH 22/38] fixes --- code/addons/controls/src/ControlsPanel.tsx | 17 ++--- code/addons/interactions/src/Panel.tsx | 11 ++- .../nextjs/src/routing/decorator.tsx | 5 +- code/lib/api/package.json | 1 - code/lib/api/src/tests/addons.test.js | 2 +- code/lib/api/src/tests/stories.test.ts | 68 ++++++++++++------- .../lib/core-client/src/preview/start.test.ts | 2 +- .../src/docs/custom-elements.ts | 9 +-- 8 files changed, 67 insertions(+), 48 deletions(-) diff --git a/code/addons/controls/src/ControlsPanel.tsx b/code/addons/controls/src/ControlsPanel.tsx index afcdd3042147..e59e68ce15c0 100644 --- a/code/addons/controls/src/ControlsPanel.tsx +++ b/code/addons/controls/src/ControlsPanel.tsx @@ -1,19 +1,14 @@ +/* eslint-disable camelcase */ import React, { FC } from 'react'; -import { - ArgTypes, - useArgs, - useGlobals, - useArgTypes, - useParameter, - useStorybookState, -} from '@storybook/api'; +import { useArgs, useGlobals, useArgTypes, useParameter, useStorybookState } from '@storybook/api'; import { PureArgsTable as ArgsTable, NoControlsWarning, - PresetColor, - SortType, + type PresetColor, + type SortType, } from '@storybook/blocks'; +import type { API_ArgTypes } from '@storybook/types'; import { PARAM_KEY } from './constants'; interface ControlsParameters { @@ -43,7 +38,7 @@ export const ControlsPanel: FC = () => { if (arg?.control?.type !== 'color' || arg?.control?.presetColors) acc[key] = arg; else acc[key] = { ...arg, control: { ...arg.control, presetColors } }; return acc; - }, {} as ArgTypes); + }, {} as API_ArgTypes); return ( <> diff --git a/code/addons/interactions/src/Panel.tsx b/code/addons/interactions/src/Panel.tsx index 2585c506f4d7..1130de8f59f4 100644 --- a/code/addons/interactions/src/Panel.tsx +++ b/code/addons/interactions/src/Panel.tsx @@ -1,6 +1,6 @@ import global from 'global'; import * as React from 'react'; -import { useChannel, useParameter, StoryId } from '@storybook/api'; +import { useChannel, useParameter } from '@storybook/api'; import { FORCE_REMOUNT, IGNORED_EXCEPTION, @@ -8,8 +8,15 @@ import { STORY_THREW_EXCEPTION, PLAY_FUNCTION_THREW_EXCEPTION, } from '@storybook/core-events'; -import { EVENTS, Call, CallStates, ControlStates, LogItem } from '@storybook/instrumenter'; +import { + EVENTS, + type Call, + CallStates, + type ControlStates, + type LogItem, +} from '@storybook/instrumenter'; +import type { StoryId } from '@storybook/types'; import { InteractionsPanel } from './components/InteractionsPanel'; import { TabIcon, TabStatus } from './components/TabStatus'; diff --git a/code/frameworks/nextjs/src/routing/decorator.tsx b/code/frameworks/nextjs/src/routing/decorator.tsx index c5d125c02890..79fe00a401f8 100644 --- a/code/frameworks/nextjs/src/routing/decorator.tsx +++ b/code/frameworks/nextjs/src/routing/decorator.tsx @@ -1,7 +1,8 @@ +/* eslint-disable camelcase */ import * as React from 'react'; // this will be aliased by webpack at runtime (this is just for typing) import { action as originalAction } from '@storybook/addon-actions'; -import { StoryContext } from '@storybook/addons'; +import type { Addon_StoryContext } from '@storybook/types'; import { RouterContext } from 'next/dist/shared/lib/router-context'; import Router from 'next/router'; @@ -55,7 +56,7 @@ const defaultRouter = { export const RouterDecorator = ( Story: React.FC, - { globals, parameters }: StoryContext + { globals, parameters }: Addon_StoryContext ): React.ReactNode => { const nextRouterParams = parameters.nextRouter ?? {}; diff --git a/code/lib/api/package.json b/code/lib/api/package.json index 6b3996931206..961804ea3550 100644 --- a/code/lib/api/package.json +++ b/code/lib/api/package.json @@ -64,7 +64,6 @@ }, "devDependencies": { "@jest/globals": "^26.6.2", - "@storybook/addons": "7.0.0-alpha.41", "@storybook/core-common": "7.0.0-alpha.41", "@types/lodash": "^4.14.167", "@types/qs": "^6", diff --git a/code/lib/api/src/tests/addons.test.js b/code/lib/api/src/tests/addons.test.js index 803b9973aee4..fd94abde0292 100644 --- a/code/lib/api/src/tests/addons.test.js +++ b/code/lib/api/src/tests/addons.test.js @@ -1,4 +1,4 @@ -import { types } from '@storybook/addons'; +import { Addon_TypesEnum as types } from '@storybook/types'; import { init as initAddons } from '../modules/addons'; const PANELS = { diff --git a/code/lib/api/src/tests/stories.test.ts b/code/lib/api/src/tests/stories.test.ts index a686680e2b3d..a8d109ee434a 100644 --- a/code/lib/api/src/tests/stories.test.ts +++ b/code/lib/api/src/tests/stories.test.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ /// ; // Need to import jest as mockJest for annoying jest reasons. Is there a better way? import { jest, jest as mockJest, it, describe, expect, beforeEach } from '@jest/globals'; @@ -14,16 +15,31 @@ import { } from '@storybook/core-events'; import { EventEmitter } from 'events'; import global from 'global'; -import { mockChannel } from '@storybook/addons'; +import { Channel } from '@storybook/channels'; + +import type { + API_StoryEntry, + API_SetStoriesStoryData, + API_SetStoriesStory, + API_StoryIndex, +} from '@storybook/types'; import { getEventMetadata } from '../lib/events'; import { init as initStories } from '../modules/stories'; -import { StoryEntry, SetStoriesStoryData, SetStoriesStory, StoryIndex } from '../lib/stories'; import type Store from '../store'; import { ModuleArgs } from '..'; -const mockStories = jest.fn(); +function mockChannel() { + const transport = { + setHandler: () => {}, + send: () => {}, + }; + + return new Channel({ transport }); +} + +const mockStories = jest.fn(); jest.mock('../lib/events'); jest.mock('global', () => ({ @@ -69,50 +85,50 @@ function createMockStore(initialState = {}) { const provider = { getConfig: jest.fn().mockReturnValue({}), serverChannel: mockChannel() }; -const parameters = {} as SetStoriesStory['parameters']; -const setStoriesData: SetStoriesStoryData = { +const parameters = {} as API_SetStoriesStory['parameters']; +const setStoriesData: API_SetStoriesStoryData = { 'a--1': { kind: 'a', name: '1', parameters, id: 'a--1', args: {}, - } as SetStoriesStory, + } as API_SetStoriesStory, 'a--2': { kind: 'a', name: '2', parameters, id: 'a--2', args: {}, - } as SetStoriesStory, + } as API_SetStoriesStory, 'b-c--1': { kind: 'b/c', name: '1', parameters, id: 'b-c--1', args: {}, - } as SetStoriesStory, + } as API_SetStoriesStory, 'b-d--1': { kind: 'b/d', name: '1', parameters, id: 'b-d--1', args: {}, - } as SetStoriesStory, + } as API_SetStoriesStory, 'b-d--2': { kind: 'b/d', name: '2', parameters, id: 'b-d--2', args: { a: 'b' }, - } as SetStoriesStory, + } as API_SetStoriesStory, 'custom-id--1': { kind: 'b/e', name: '1', parameters, id: 'custom-id--1', args: {}, - } as SetStoriesStory, + } as API_SetStoriesStory, }; beforeEach(() => { @@ -572,15 +588,15 @@ describe('stories API', () => { }); const { storiesHash: initialStoriesHash } = store.getState(); - expect((initialStoriesHash['a--1'] as StoryEntry).args).toEqual({ a: 'b' }); - expect((initialStoriesHash['b--1'] as StoryEntry).args).toEqual({ x: 'y' }); + expect((initialStoriesHash['a--1'] as API_StoryEntry).args).toEqual({ a: 'b' }); + expect((initialStoriesHash['b--1'] as API_StoryEntry).args).toEqual({ x: 'y' }); init(); fullAPI.emit(STORY_ARGS_UPDATED, { storyId: 'a--1', args: { foo: 'bar' } }); const { storiesHash: changedStoriesHash } = store.getState(); - expect((changedStoriesHash['a--1'] as StoryEntry).args).toEqual({ foo: 'bar' }); - expect((changedStoriesHash['b--1'] as StoryEntry).args).toEqual({ x: 'y' }); + expect((changedStoriesHash['a--1'] as API_StoryEntry).args).toEqual({ foo: 'bar' }); + expect((changedStoriesHash['b--1'] as API_StoryEntry).args).toEqual({ x: 'y' }); }); it('changes reffed args properly, per story when receiving STORY_ARGS_UPDATED', () => { @@ -620,7 +636,7 @@ describe('stories API', () => { Object.assign(fullAPI, api); init(); - api.updateStoryArgs({ id: 'a--1' } as StoryEntry, { foo: 'bar' }); + api.updateStoryArgs({ id: 'a--1' } as API_StoryEntry, { foo: 'bar' }); expect(emit).toHaveBeenCalledWith(UPDATE_STORY_ARGS, { storyId: 'a--1', updatedArgs: { foo: 'bar' }, @@ -630,8 +646,8 @@ describe('stories API', () => { }); const { storiesHash: changedStoriesHash } = store.getState(); - expect((changedStoriesHash['a--1'] as StoryEntry).args).toEqual({ a: 'b' }); - expect((changedStoriesHash['b--1'] as StoryEntry).args).toEqual({ x: 'y' }); + expect((changedStoriesHash['a--1'] as API_StoryEntry).args).toEqual({ a: 'b' }); + expect((changedStoriesHash['b--1'] as API_StoryEntry).args).toEqual({ x: 'y' }); }); it('updateStoryArgs emits UPDATE_STORY_ARGS to the right frame', () => { @@ -651,7 +667,7 @@ describe('stories API', () => { Object.assign(fullAPI, api); init(); - api.updateStoryArgs({ id: 'a--1', refId: 'refId' } as StoryEntry, { foo: 'bar' }); + api.updateStoryArgs({ id: 'a--1', refId: 'refId' } as API_StoryEntry, { foo: 'bar' }); expect(emit).toHaveBeenCalledWith(UPDATE_STORY_ARGS, { storyId: 'a--1', updatedArgs: { foo: 'bar' }, @@ -678,7 +694,7 @@ describe('stories API', () => { Object.assign(fullAPI, api); init(); - api.resetStoryArgs({ id: 'a--1' } as StoryEntry, ['foo']); + api.resetStoryArgs({ id: 'a--1' } as API_StoryEntry, ['foo']); expect(emit).toHaveBeenCalledWith(RESET_STORY_ARGS, { storyId: 'a--1', argNames: ['foo'], @@ -688,8 +704,8 @@ describe('stories API', () => { }); const { storiesHash: changedStoriesHash } = store.getState(); - expect((changedStoriesHash['a--1'] as StoryEntry).args).toEqual({ a: 'b' }); - expect((changedStoriesHash['b--1'] as StoryEntry).args).toEqual({ x: 'y' }); + expect((changedStoriesHash['a--1'] as API_StoryEntry).args).toEqual({ a: 'b' }); + expect((changedStoriesHash['b--1'] as API_StoryEntry).args).toEqual({ x: 'y' }); }); it('resetStoryArgs emits RESET_STORY_ARGS to the right frame', () => { @@ -709,7 +725,7 @@ describe('stories API', () => { Object.assign(fullAPI, api); init(); - api.resetStoryArgs({ id: 'a--1', refId: 'refId' } as StoryEntry, ['foo']); + api.resetStoryArgs({ id: 'a--1', refId: 'refId' } as API_StoryEntry, ['foo']); expect(emit).toHaveBeenCalledWith(RESET_STORY_ARGS, { storyId: 'a--1', argNames: ['foo'], @@ -1117,7 +1133,7 @@ describe('stories API', () => { prepared: false, }); expect( - (storedStoriesHash['component-a--story-1'] as StoryEntry as StoryEntry).args + (storedStoriesHash['component-a--story-1'] as API_StoryEntry as API_StoryEntry).args ).toBeUndefined(); }); @@ -1219,7 +1235,7 @@ describe('stories API', () => { }); // Let the promise/await chain resolve await new Promise((r) => setTimeout(r, 0)); - expect(store.getState().storiesHash['component-a--story-1'] as StoryEntry).toMatchObject({ + expect(store.getState().storiesHash['component-a--story-1'] as API_StoryEntry).toMatchObject({ prepared: true, parameters: { a: 'b' }, args: { c: 'd' }, @@ -1231,7 +1247,7 @@ describe('stories API', () => { // Let the promise/await chain resolve await new Promise((r) => setTimeout(r, 0)); - expect(store.getState().storiesHash['component-a--story-1'] as StoryEntry).toMatchObject({ + expect(store.getState().storiesHash['component-a--story-1'] as API_StoryEntry).toMatchObject({ prepared: true, parameters: { a: 'b' }, args: { c: 'd' }, diff --git a/code/lib/core-client/src/preview/start.test.ts b/code/lib/core-client/src/preview/start.test.ts index 6c6fe45884b0..3558f5753aff 100644 --- a/code/lib/core-client/src/preview/start.test.ts +++ b/code/lib/core-client/src/preview/start.test.ts @@ -12,8 +12,8 @@ import { import { WebView } from '@storybook/preview-web/dist/cjs/WebView'; import { setGlobalRender } from '@storybook/client-api'; +import type { Loadable } from '@storybook/types'; import { start as realStart } from './start'; -import { Loadable } from './types'; jest.mock('@storybook/preview-web/dist/cjs/WebView'); jest.spyOn(WebView.prototype, 'prepareForDocs').mockReturnValue('docs-root'); diff --git a/code/renderers/web-components/src/docs/custom-elements.ts b/code/renderers/web-components/src/docs/custom-elements.ts index f81f19665006..8643c0606828 100644 --- a/code/renderers/web-components/src/docs/custom-elements.ts +++ b/code/renderers/web-components/src/docs/custom-elements.ts @@ -1,4 +1,5 @@ -import type { ArgType, ArgTypes } from '@storybook/api'; +/* eslint-disable camelcase */ +import type { API_ArgType, API_ArgTypes } from '@storybook/types'; import { logger } from '@storybook/client-logger'; import { getCustomElements, isValidComponent, isValidMetaData } from '..'; @@ -46,7 +47,7 @@ interface Sections { cssShadowParts?: any; } -function mapItem(item: TagItem, category: string): ArgType { +function mapItem(item: TagItem, category: string): API_ArgType { const type = category === 'properties' ? { name: item.type?.text || item.type } : { name: 'void' }; @@ -65,7 +66,7 @@ function mapItem(item: TagItem, category: string): ArgType { }; } -function mapEvent(item: TagItem): ArgType[] { +function mapEvent(item: TagItem): API_ArgType[] { let name = item.name .replace(/(-|_|:|\.|\s)+(.)?/g, (_match, _separator, chr: string) => { return chr ? chr.toUpperCase() : ''; @@ -97,7 +98,7 @@ function mapData(data: TagItem[], category: string) { } return acc; - }, {} as ArgTypes) + }, {} as API_ArgTypes) ); } From 4c1925fbe3387037788cee2f86b5146cac65ba37 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sat, 22 Oct 2022 16:49:53 +0200 Subject: [PATCH 23/38] fix --- .../storyshots/storyshots-puppeteer/package.json | 1 + .../storyshots-puppeteer/src/__tests__/url.test.ts | 2 +- .../src/utils/StoryIndexGenerator.test.ts | 4 ++-- code/lib/store/src/hooks.test.ts | 12 +++++++----- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/code/addons/storyshots/storyshots-puppeteer/package.json b/code/addons/storyshots/storyshots-puppeteer/package.json index d9cdf7843e80..e784c5bf7699 100644 --- a/code/addons/storyshots/storyshots-puppeteer/package.json +++ b/code/addons/storyshots/storyshots-puppeteer/package.json @@ -34,6 +34,7 @@ }, "dependencies": { "@axe-core/puppeteer": "^4.2.0", + "@storybook/csf": "0.0.2--canary.49.258942b.0", "@storybook/node-logger": "7.0.0-alpha.41", "@storybook/types": "7.0.0-alpha.41", "@types/jest-image-snapshot": "^4.1.3", diff --git a/code/addons/storyshots/storyshots-puppeteer/src/__tests__/url.test.ts b/code/addons/storyshots/storyshots-puppeteer/src/__tests__/url.test.ts index c5d9b2ce187e..cf36929dee62 100644 --- a/code/addons/storyshots/storyshots-puppeteer/src/__tests__/url.test.ts +++ b/code/addons/storyshots/storyshots-puppeteer/src/__tests__/url.test.ts @@ -1,4 +1,4 @@ -import { toId } from '@storybook/types'; +import { toId } from '@storybook/csf'; import { constructUrl } from '../url'; diff --git a/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts b/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts index b894116b52b5..f629bc991e9d 100644 --- a/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts +++ b/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts @@ -13,8 +13,8 @@ import { mocked } from 'ts-jest/utils'; import { StoryIndexGenerator } from './StoryIndexGenerator'; jest.mock('@storybook/csf-tools'); -jest.mock('@storybook/types', () => { - const csf = jest.requireActual('@storybook/types'); +jest.mock('@storybook/csf', () => { + const csf = jest.requireActual('@storybook/csf'); return { ...csf, toId: jest.fn(csf.toId), diff --git a/code/lib/store/src/hooks.test.ts b/code/lib/store/src/hooks.test.ts index 3b0526eec09c..e5d48749093b 100644 --- a/code/lib/store/src/hooks.test.ts +++ b/code/lib/store/src/hooks.test.ts @@ -6,11 +6,8 @@ import { RESET_STORY_ARGS, UPDATE_GLOBALS, } from '@storybook/core-events'; -import { addons } from '@storybook/addons'; -import { DecoratorFunction, StoryContext } from '@storybook/types'; - -import { defaultDecorateStory } from './decorators'; import { + addons, applyHooks, useEffect, useMemo, @@ -24,7 +21,12 @@ import { HooksContext, useArgs, useGlobals, -} from './hooks'; +} from '@storybook/addons'; +import type { DecoratorFunction, StoryContext } from '@storybook/types'; + +import { defaultDecorateStory } from './decorators'; +// import { +// } from './hooks'; jest.mock('@storybook/client-logger', () => ({ logger: { warn: jest.fn(), log: jest.fn() }, From d1b725d385e9d1c905f34f9fdea2755892ca92fa Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sat, 22 Oct 2022 17:32:14 +0200 Subject: [PATCH 24/38] fixes & linting --- code/addons/docs/src/DocsRenderer.tsx | 4 +- code/addons/interactions/src/Panel.test.ts | 2 +- .../src/components/Interaction.stories.tsx | 2 +- .../src/components/Interaction.tsx | 2 +- .../src/components/InteractionsPanel.tsx | 2 +- .../interactions/src/components/List.tsx | 2 +- .../src/components/MethodCall.stories.tsx | 2 +- .../src/components/MethodCall.tsx | 2 +- .../src/components/StatusBadge.tsx | 2 +- .../src/components/StatusIcon.tsx | 4 +- code/addons/interactions/src/mocks/index.ts | 2 +- .../addons/jest/src/hoc/provideJestResult.tsx | 2 +- code/addons/storysource/src/StoryPanel.tsx | 6 +- .../src/components/ToolbarMenuButton.tsx | 2 +- .../src/components/ToolbarMenuList.tsx | 5 +- code/addons/viewport/src/Tool.tsx | 2 +- .../components/AccountForm.stories.tsx | 2 +- .../src/client/angular-beta/DocsRenderer.ts | 6 +- .../server/framework-preset-angular-docs.ts | 2 +- code/frameworks/svelte-vite/src/preset.ts | 2 +- code/lib/addons/src/make-decorator.test.ts | 7 +- code/lib/api/src/index.tsx | 22 ++- code/lib/api/src/lib/events.ts | 2 +- code/lib/api/src/modules/release-notes.ts | 2 +- code/lib/api/src/modules/settings.ts | 2 +- code/lib/api/src/modules/stories.ts | 2 +- code/lib/blocks/src/blocks/Canvas.tsx | 2 +- code/lib/blocks/src/blocks/DocsContainer.tsx | 2 +- .../src/blocks/external/ExternalDocs.tsx | 2 +- .../blocks/external/ExternalDocsContainer.tsx | 2 +- .../blocks/external/ExternalDocsContext.ts | 15 ++- .../src/blocks/external/ExternalPreview.ts | 22 ++- code/lib/blocks/src/controls/Object.tsx | 4 +- code/lib/components/src/tooltip/Tooltip.tsx | 2 +- code/lib/core-client/src/manager/provider.ts | 4 +- .../src/preview/executeLoadable.ts | 9 +- .../lib/core-client/src/preview/start.test.ts | 126 +++++++----------- code/lib/core-common/src/presets.ts | 2 +- .../utils/__tests__/check-addon-order.test.ts | 2 +- code/lib/preview-web/src/Preview.tsx | 6 +- .../src/PreviewWeb.integration.test.ts | 2 +- code/lib/preview-web/src/PreviewWeb.tsx | 4 +- code/lib/preview-web/src/render/Render.ts | 2 +- .../src/render/StandaloneDocsRender.test.ts | 6 +- .../src/render/StandaloneDocsRender.ts | 9 +- .../src/render/StoryRender.test.ts | 6 +- .../lib/preview-web/src/render/StoryRender.ts | 4 +- .../src/render/TemplateDocsRender.test.ts | 6 +- code/lib/store/src/StoryIndexStore.test.ts | 5 +- code/lib/store/src/args.test.ts | 2 +- code/lib/store/src/csf/normalizeStory.test.ts | 4 +- code/lib/store/src/csf/testing-utils/index.ts | 5 +- code/lib/store/src/hooks.test.ts | 4 +- code/lib/store/src/storySort.test.ts | 8 +- .../store/template/stories/hooks.stories.ts | 2 +- code/lib/store/template/stories/preview.ts | 2 +- .../react/src/__test__/CSF3.test.tsx | 8 +- code/renderers/react/src/docs/extractProps.ts | 2 +- .../renderers/react/src/docs/jsxDecorator.tsx | 2 +- .../lib/defaultValues/createDefaultValue.ts | 2 +- .../defaultValues/createFromRawDefaultProp.ts | 4 +- .../docs/lib/defaultValues/generateArray.ts | 2 +- .../docs/lib/defaultValues/generateObject.ts | 2 +- .../docs/propTypes/generateFuncSignature.ts | 2 +- .../src/docs/propTypes/handleProp.test.tsx | 6 +- .../react/src/docs/propTypes/handleProp.ts | 2 +- .../react/src/docs/propTypes/sortProps.ts | 2 +- .../src/docs/typeScript/handleProp.test.tsx | 6 +- .../react/src/docs/typeScript/handleProp.ts | 2 +- code/renderers/react/src/public-api.tsx | 8 +- .../src/components/preview/utils/types.tsx | 4 +- code/ui/manager/src/runtime.ts | 6 +- 72 files changed, 210 insertions(+), 213 deletions(-) diff --git a/code/addons/docs/src/DocsRenderer.tsx b/code/addons/docs/src/DocsRenderer.tsx index 1591d12d6e55..83f9a2e49af1 100644 --- a/code/addons/docs/src/DocsRenderer.tsx +++ b/code/addons/docs/src/DocsRenderer.tsx @@ -1,7 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; -import { AnyFramework, Parameters } from '@storybook/types'; -import { DocsContextProps, DocsRenderFunction } from '@storybook/preview-web'; +import type { AnyFramework, Parameters } from '@storybook/types'; +import type { DocsContextProps, DocsRenderFunction } from '@storybook/preview-web'; import { components as htmlComponents } from '@storybook/components'; import { Docs, CodeOrSourceMdx, AnchorMdx, HeadersMdx } from '@storybook/blocks'; import { MDXProvider } from '@mdx-js/react'; diff --git a/code/addons/interactions/src/Panel.test.ts b/code/addons/interactions/src/Panel.test.ts index 06a1e7278120..869b64b8bb0d 100644 --- a/code/addons/interactions/src/Panel.test.ts +++ b/code/addons/interactions/src/Panel.test.ts @@ -1,4 +1,4 @@ -import { Call, CallStates, LogItem } from '@storybook/instrumenter'; +import { type Call, CallStates, type LogItem } from '@storybook/instrumenter'; import { getInteractions } from './Panel'; describe('Panel', () => { diff --git a/code/addons/interactions/src/components/Interaction.stories.tsx b/code/addons/interactions/src/components/Interaction.stories.tsx index c1b38cafd63e..ea03a78431d5 100644 --- a/code/addons/interactions/src/components/Interaction.stories.tsx +++ b/code/addons/interactions/src/components/Interaction.stories.tsx @@ -1,4 +1,4 @@ -import { ComponentStoryObj, ComponentMeta } from '@storybook/react'; +import type { ComponentStoryObj, ComponentMeta } from '@storybook/react'; import { expect } from '@storybook/jest'; import { CallStates } from '@storybook/instrumenter'; import { userEvent, within } from '@storybook/testing-library'; diff --git a/code/addons/interactions/src/components/Interaction.tsx b/code/addons/interactions/src/components/Interaction.tsx index b83dfeebbc80..ade45185ed02 100644 --- a/code/addons/interactions/src/components/Interaction.tsx +++ b/code/addons/interactions/src/components/Interaction.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import { IconButton, Icons, TooltipNote, WithTooltip } from '@storybook/components'; -import { Call, CallStates, ControlStates } from '@storybook/instrumenter'; +import { type Call, CallStates, type ControlStates } from '@storybook/instrumenter'; import { styled, typography } from '@storybook/theming'; import { transparentize } from 'polished'; diff --git a/code/addons/interactions/src/components/InteractionsPanel.tsx b/code/addons/interactions/src/components/InteractionsPanel.tsx index ab53206790be..ddeb9bcac5f4 100644 --- a/code/addons/interactions/src/components/InteractionsPanel.tsx +++ b/code/addons/interactions/src/components/InteractionsPanel.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import { AddonPanel, Link, Placeholder } from '@storybook/components'; -import { Call, CallStates, ControlStates } from '@storybook/instrumenter'; +import { type Call, CallStates, type ControlStates } from '@storybook/instrumenter'; import { styled } from '@storybook/theming'; import { transparentize } from 'polished'; diff --git a/code/addons/interactions/src/components/List.tsx b/code/addons/interactions/src/components/List.tsx index b2acb5a6cbff..8c420d37102a 100644 --- a/code/addons/interactions/src/components/List.tsx +++ b/code/addons/interactions/src/components/List.tsx @@ -1,6 +1,6 @@ import React, { Fragment, useState } from 'react'; import { styled, themes, convert } from '@storybook/theming'; -import { Icons, IconsProps } from '@storybook/components'; +import { Icons, type IconsProps } from '@storybook/components'; const ListWrapper = styled.ul({ listStyle: 'none', diff --git a/code/addons/interactions/src/components/MethodCall.stories.tsx b/code/addons/interactions/src/components/MethodCall.stories.tsx index 953a9e6adbb6..05b920a05cd2 100644 --- a/code/addons/interactions/src/components/MethodCall.stories.tsx +++ b/code/addons/interactions/src/components/MethodCall.stories.tsx @@ -1,4 +1,4 @@ -import { Call } from '@storybook/instrumenter'; +import type { Call } from '@storybook/instrumenter'; import React from 'react'; import { styled, typography } from '@storybook/theming'; import { Node, MethodCall } from './MethodCall'; diff --git a/code/addons/interactions/src/components/MethodCall.tsx b/code/addons/interactions/src/components/MethodCall.tsx index c5e62c0caf69..64e24c74f2e5 100644 --- a/code/addons/interactions/src/components/MethodCall.tsx +++ b/code/addons/interactions/src/components/MethodCall.tsx @@ -1,5 +1,5 @@ import { ObjectInspector } from '@devtools-ds/object-inspector'; -import { Call, CallRef, ElementRef } from '@storybook/instrumenter'; +import type { Call, CallRef, ElementRef } from '@storybook/instrumenter'; import { useTheme } from '@storybook/theming'; import React, { Fragment, ReactElement } from 'react'; diff --git a/code/addons/interactions/src/components/StatusBadge.tsx b/code/addons/interactions/src/components/StatusBadge.tsx index 4c28636166f3..e4fc657cde75 100644 --- a/code/addons/interactions/src/components/StatusBadge.tsx +++ b/code/addons/interactions/src/components/StatusBadge.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Call, CallStates } from '@storybook/instrumenter'; +import { type Call, CallStates } from '@storybook/instrumenter'; import { styled, typography } from '@storybook/theming'; export interface StatusBadgeProps { diff --git a/code/addons/interactions/src/components/StatusIcon.tsx b/code/addons/interactions/src/components/StatusIcon.tsx index b223a3960521..a563f6df1521 100644 --- a/code/addons/interactions/src/components/StatusIcon.tsx +++ b/code/addons/interactions/src/components/StatusIcon.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import { Icons, IconsProps } from '@storybook/components'; -import { Call, CallStates } from '@storybook/instrumenter'; +import { Icons, type IconsProps } from '@storybook/components'; +import { type Call, CallStates } from '@storybook/instrumenter'; import { styled } from '@storybook/theming'; import { transparentize } from 'polished'; diff --git a/code/addons/interactions/src/mocks/index.ts b/code/addons/interactions/src/mocks/index.ts index c0d0b9599647..cffabc3352bc 100644 --- a/code/addons/interactions/src/mocks/index.ts +++ b/code/addons/interactions/src/mocks/index.ts @@ -1,4 +1,4 @@ -import { CallStates, Call } from '@storybook/instrumenter'; +import { CallStates, type Call } from '@storybook/instrumenter'; export const getCalls = (finalStatus: CallStates) => { const calls: Call[] = [ diff --git a/code/addons/jest/src/hoc/provideJestResult.tsx b/code/addons/jest/src/hoc/provideJestResult.tsx index 1b20ba19243c..812a645ffeec 100644 --- a/code/addons/jest/src/hoc/provideJestResult.tsx +++ b/code/addons/jest/src/hoc/provideJestResult.tsx @@ -1,6 +1,6 @@ import React, { Component as ReactComponent, ComponentType } from 'react'; import { STORY_CHANGED } from '@storybook/core-events'; -import { API } from '@storybook/api'; +import type { API } from '@storybook/api'; import { ADD_TESTS } from '../shared'; // TODO: import type from @types/jest diff --git a/code/addons/storysource/src/StoryPanel.tsx b/code/addons/storysource/src/StoryPanel.tsx index 405c88a24e41..cf1bea1b891c 100644 --- a/code/addons/storysource/src/StoryPanel.tsx +++ b/code/addons/storysource/src/StoryPanel.tsx @@ -1,11 +1,11 @@ import React from 'react'; -import { API, useParameter } from '@storybook/api'; +import { type API, useParameter } from '@storybook/api'; import { styled } from '@storybook/theming'; import { Link } from '@storybook/router'; import { SyntaxHighlighter, - SyntaxHighlighterProps, - SyntaxHighlighterRendererProps, + type SyntaxHighlighterProps, + type SyntaxHighlighterRendererProps, } from '@storybook/components'; // @ts-expect-error Typedefs don't currently expose `createElement` even though it exists diff --git a/code/addons/toolbars/src/components/ToolbarMenuButton.tsx b/code/addons/toolbars/src/components/ToolbarMenuButton.tsx index abeefe06cdf6..e167d191939b 100644 --- a/code/addons/toolbars/src/components/ToolbarMenuButton.tsx +++ b/code/addons/toolbars/src/components/ToolbarMenuButton.tsx @@ -1,5 +1,5 @@ import React, { FC } from 'react'; -import { Icons, IconButton, IconsProps } from '@storybook/components'; +import { Icons, IconButton, type IconsProps } from '@storybook/components'; interface ToolbarMenuButtonProps { active: boolean; diff --git a/code/addons/toolbars/src/components/ToolbarMenuList.tsx b/code/addons/toolbars/src/components/ToolbarMenuList.tsx index 31a0c36eceb6..8e62123cab77 100644 --- a/code/addons/toolbars/src/components/ToolbarMenuList.tsx +++ b/code/addons/toolbars/src/components/ToolbarMenuList.tsx @@ -1,5 +1,6 @@ import React, { useCallback, FC, ReactNode } from 'react'; import { useGlobals } from '@storybook/api'; +import { deprecate } from '@storybook/client-logger'; import { WithTooltip, TooltipLinkList } from '@storybook/components'; import { ToolbarMenuButton } from './ToolbarMenuButton'; import { withKeyboardCycle, WithKeyboardCycleProps } from '../hoc/withKeyboardCycle'; @@ -38,12 +39,12 @@ export const ToolbarMenuList: FC = withKeyboardCycle( // Deprecation support for old "name of global arg used as title" if (showName && !title) { title = name; - console.warn( + deprecate( '`showName` is deprecated as `name` will stop having dual purposes in the future. Please specify a `title` in `globalTypes` instead.' ); } else if (!showName && !icon && !title) { title = name; - console.warn( + deprecate( `Using the \`name\` "${name}" as toolbar title for backward compatibility. \`name\` will stop having dual purposes in the future. Please specify either a \`title\` or an \`icon\` in \`globalTypes\` instead.` ); } diff --git a/code/addons/viewport/src/Tool.tsx b/code/addons/viewport/src/Tool.tsx index cffa249cfbd5..bd1f5542b358 100644 --- a/code/addons/viewport/src/Tool.tsx +++ b/code/addons/viewport/src/Tool.tsx @@ -2,7 +2,7 @@ import React, { Fragment, ReactNode, useEffect, useRef, FC, memo } from 'react'; import memoize from 'memoizerific'; -import { styled, Global, Theme, withTheme } from '@storybook/theming'; +import { styled, Global, type Theme, withTheme } from '@storybook/theming'; import { Icons, IconButton, WithTooltip, TooltipLinkList } from '@storybook/components'; diff --git a/code/examples/external-docs/components/AccountForm.stories.tsx b/code/examples/external-docs/components/AccountForm.stories.tsx index ea8e89c33e0e..c4579abaf5e3 100644 --- a/code/examples/external-docs/components/AccountForm.stories.tsx +++ b/code/examples/external-docs/components/AccountForm.stories.tsx @@ -1,6 +1,6 @@ /* eslint-disable storybook/use-storybook-testing-library */ // @TODO: use addon-interactions and remove the rule disable above -import { ComponentStoryObj, ComponentMeta } from '@storybook/react'; +import type { ComponentStoryObj, ComponentMeta } from '@storybook/react'; import { screen } from '@testing-library/dom'; import userEvent from '@testing-library/user-event'; import { AccountForm } from './AccountForm'; diff --git a/code/frameworks/angular/src/client/angular-beta/DocsRenderer.ts b/code/frameworks/angular/src/client/angular-beta/DocsRenderer.ts index 465d470593fa..3f9d94ac8b3a 100644 --- a/code/frameworks/angular/src/client/angular-beta/DocsRenderer.ts +++ b/code/frameworks/angular/src/client/angular-beta/DocsRenderer.ts @@ -1,5 +1,5 @@ import { addons } from '@storybook/addons'; -import Events from '@storybook/core-events'; +import { DOCS_RENDERED, STORY_CHANGED } from '@storybook/core-events'; import { AbstractRenderer } from './AbstractRenderer'; import { StoryFnAngularReturnType, Parameters } from '../types'; @@ -22,7 +22,7 @@ export class DocsRenderer extends AbstractRenderer { * rendered in the doc. But one event could be enough for the whole docs * */ - channel.once(Events.STORY_CHANGED, async () => { + channel.once(STORY_CHANGED, async () => { await DocsRenderer.resetPlatformBrowserDynamic(); }); @@ -31,7 +31,7 @@ export class DocsRenderer extends AbstractRenderer { * when doc re render. Allows to call ngOnDestroy of angular * for previous component */ - channel.once(Events.DOCS_RENDERED, async () => { + channel.once(DOCS_RENDERED, async () => { await DocsRenderer.resetPlatformBrowserDynamic(); }); diff --git a/code/frameworks/angular/src/server/framework-preset-angular-docs.ts b/code/frameworks/angular/src/server/framework-preset-angular-docs.ts index f1574ba7263f..e5dca7dc6759 100644 --- a/code/frameworks/angular/src/server/framework-preset-angular-docs.ts +++ b/code/frameworks/angular/src/server/framework-preset-angular-docs.ts @@ -1,5 +1,5 @@ import path from 'path'; -import { StorybookConfig } from '@storybook/types'; +import type { StorybookConfig } from '@storybook/types'; import { hasDocsOrControls } from '@storybook/docs-tools'; export const previewAnnotations: StorybookConfig['previewAnnotations'] = (entry = [], options) => { diff --git a/code/frameworks/svelte-vite/src/preset.ts b/code/frameworks/svelte-vite/src/preset.ts index b7e0edc4f770..ea8391e96eb8 100644 --- a/code/frameworks/svelte-vite/src/preset.ts +++ b/code/frameworks/svelte-vite/src/preset.ts @@ -1,4 +1,4 @@ -import { StorybookConfig, withoutVitePlugins } from '@storybook/builder-vite'; +import { type StorybookConfig, withoutVitePlugins } from '@storybook/builder-vite'; import { hasPlugin } from './utils'; import { svelteDocgen } from './plugins/svelte-docgen'; diff --git a/code/lib/addons/src/make-decorator.test.ts b/code/lib/addons/src/make-decorator.test.ts index 4cd66aada8bd..f5bd36333404 100644 --- a/code/lib/addons/src/make-decorator.test.ts +++ b/code/lib/addons/src/make-decorator.test.ts @@ -1,12 +1,13 @@ -import { StoryContext } from './types'; +/* eslint-disable camelcase */ +import type { Addon_StoryContext } from '@storybook/types'; import { makeDecorator } from './make-decorator'; // Copy & paste from internal api: client-api/src/client_api -type DecoratorFn = (fn: any, context: StoryContext) => any; +type DecoratorFn = (fn: any, context: Addon_StoryContext) => any; const defaultDecorateStory = (getStory: any, decorators: DecoratorFn[]) => decorators.reduce( - (decorated, decorator) => (context: StoryContext) => + (decorated, decorator) => (context: Addon_StoryContext) => decorator(() => decorated(context), context), getStory ); diff --git a/code/lib/api/src/index.tsx b/code/lib/api/src/index.tsx index 115d5d61337a..46e540ae8814 100644 --- a/code/lib/api/src/index.tsx +++ b/code/lib/api/src/index.tsx @@ -12,24 +12,13 @@ import React, { useRef, } from 'react'; import mergeWith from 'lodash/mergeWith'; -import { +import type { API_Args, API_ArgTypes, API_OptionsData, API_ProviderData, API_StateMerger, StoryId, -} from '@storybook/types'; - -import { - STORY_CHANGED, - SHARED_STATE_CHANGED, - SHARED_STATE_SET, - SET_STORIES, -} from '@storybook/core-events'; -import type { RouterData } from '@storybook/router'; -import type { Listener } from '@storybook/channels'; -import type { API_StoriesHash, API_RootEntry, API_GroupEntry, @@ -43,6 +32,15 @@ import type { Parameters, } from '@storybook/types'; +import { + STORY_CHANGED, + SHARED_STATE_CHANGED, + SHARED_STATE_SET, + SET_STORIES, +} from '@storybook/core-events'; +import type { RouterData } from '@storybook/router'; +import type { Listener } from '@storybook/channels'; + import { createContext } from './context'; import Store, { Options } from './store'; import getInitialState from './initial-state'; diff --git a/code/lib/api/src/lib/events.ts b/code/lib/api/src/lib/events.ts index 37fe0963342d..71cf84e3137c 100644 --- a/code/lib/api/src/lib/events.ts +++ b/code/lib/api/src/lib/events.ts @@ -1,7 +1,7 @@ /* eslint-disable camelcase */ import { logger } from '@storybook/client-logger'; -import { API_ComposedRef } from '@storybook/types'; +import type { API_ComposedRef } from '@storybook/types'; import { getSourceType } from '../modules/refs'; import type { API } from '../index'; diff --git a/code/lib/api/src/modules/release-notes.ts b/code/lib/api/src/modules/release-notes.ts index 5794f99853cf..74deb4185a40 100644 --- a/code/lib/api/src/modules/release-notes.ts +++ b/code/lib/api/src/modules/release-notes.ts @@ -1,6 +1,6 @@ /* eslint-disable camelcase */ import global from 'global'; -import { API_ReleaseNotes } from '@storybook/types'; +import type { API_ReleaseNotes } from '@storybook/types'; import memoize from 'memoizerific'; import type { ModuleFn } from '../index'; diff --git a/code/lib/api/src/modules/settings.ts b/code/lib/api/src/modules/settings.ts index f594923ec1e7..1a3c8717dc92 100644 --- a/code/lib/api/src/modules/settings.ts +++ b/code/lib/api/src/modules/settings.ts @@ -1,5 +1,5 @@ /* eslint-disable camelcase */ -import { API_Settings } from '@storybook/types'; +import type { API_Settings } from '@storybook/types'; import type { ModuleFn } from '../index'; export interface SubAPI { diff --git a/code/lib/api/src/modules/stories.ts b/code/lib/api/src/modules/stories.ts index 8e9b07c14965..09fd4e8cfb0e 100644 --- a/code/lib/api/src/modules/stories.ts +++ b/code/lib/api/src/modules/stories.ts @@ -16,7 +16,7 @@ import { } from '@storybook/core-events'; import { logger } from '@storybook/client-logger'; -import { +import type { API_Args, API_ComposedRef, API_HashEntry, diff --git a/code/lib/blocks/src/blocks/Canvas.tsx b/code/lib/blocks/src/blocks/Canvas.tsx index cdb542e847d4..2672eb9effed 100644 --- a/code/lib/blocks/src/blocks/Canvas.tsx +++ b/code/lib/blocks/src/blocks/Canvas.tsx @@ -1,5 +1,5 @@ import React, { FC, ReactElement, ReactNode, ReactNodeArray, useContext } from 'react'; -import { AnyFramework } from '@storybook/types'; +import type { AnyFramework } from '@storybook/types'; import { Preview as PurePreview, PreviewProps as PurePreviewProps, diff --git a/code/lib/blocks/src/blocks/DocsContainer.tsx b/code/lib/blocks/src/blocks/DocsContainer.tsx index d7556e1eb969..5cb33c3a2a5c 100644 --- a/code/lib/blocks/src/blocks/DocsContainer.tsx +++ b/code/lib/blocks/src/blocks/DocsContainer.tsx @@ -2,7 +2,7 @@ import React, { FunctionComponent, useEffect, ReactNode } from 'react'; import global from 'global'; import type { ThemeVars } from '@storybook/theming'; import { ThemeProvider, ensure as ensureTheme } from '@storybook/theming'; -import { AnyFramework } from '@storybook/types'; +import type { AnyFramework } from '@storybook/types'; import { DocsWrapper, DocsContent } from '../components'; import { DocsContextProps, DocsContext } from './DocsContext'; import { SourceContainer } from './SourceContainer'; diff --git a/code/lib/blocks/src/blocks/external/ExternalDocs.tsx b/code/lib/blocks/src/blocks/external/ExternalDocs.tsx index a9227fa9c491..8cea5382fbe2 100644 --- a/code/lib/blocks/src/blocks/external/ExternalDocs.tsx +++ b/code/lib/blocks/src/blocks/external/ExternalDocs.tsx @@ -1,5 +1,5 @@ import React, { FunctionComponent, useRef } from 'react'; -import { AnyFramework, ProjectAnnotations } from '@storybook/types'; +import type { AnyFramework, ProjectAnnotations } from '@storybook/types'; import { composeConfigs } from '@storybook/store'; import { Docs } from '../Docs'; diff --git a/code/lib/blocks/src/blocks/external/ExternalDocsContainer.tsx b/code/lib/blocks/src/blocks/external/ExternalDocsContainer.tsx index 156c512e31fc..06d593e086e4 100644 --- a/code/lib/blocks/src/blocks/external/ExternalDocsContainer.tsx +++ b/code/lib/blocks/src/blocks/external/ExternalDocsContainer.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { ThemeProvider, themes, ensure } from '@storybook/theming'; -import { AnyFramework } from '@storybook/types'; +import type { AnyFramework } from '@storybook/types'; import { DocsContext } from '../DocsContext'; import { ExternalPreview } from './ExternalPreview'; diff --git a/code/lib/blocks/src/blocks/external/ExternalDocsContext.ts b/code/lib/blocks/src/blocks/external/ExternalDocsContext.ts index 96c748a58756..cd90388885ae 100644 --- a/code/lib/blocks/src/blocks/external/ExternalDocsContext.ts +++ b/code/lib/blocks/src/blocks/external/ExternalDocsContext.ts @@ -1,8 +1,13 @@ -import { AnyFramework } from '@storybook/types'; +/* eslint-disable camelcase */ +import type { + AnyFramework, + Store_CSFFile, + Store_ModuleExport, + Store_ModuleExports, +} from '@storybook/types'; import { DocsContext } from '@storybook/preview-web'; import { StoryStore } from '@storybook/store'; import type { DocsContextProps } from '@storybook/preview-web'; -import type { CSFFile, ModuleExport, ModuleExports } from '@storybook/store'; import type { Channel } from '@storybook/channels'; export class ExternalDocsContext extends DocsContext { @@ -10,17 +15,17 @@ export class ExternalDocsContext extends DocsCo public channel: Channel, protected store: StoryStore, public renderStoryToElement: DocsContextProps['renderStoryToElement'], - private processMetaExports: (metaExports: ModuleExports) => CSFFile + private processMetaExports: (metaExports: Store_ModuleExports) => Store_CSFFile ) { super(channel, store, renderStoryToElement, [], true); } - setMeta = (metaExports: ModuleExports) => { + setMeta = (metaExports: Store_ModuleExports) => { const csfFile = this.processMetaExports(metaExports); this.referenceCSFFile(csfFile, true); }; - storyIdByModuleExport(storyExport: ModuleExport, metaExports?: ModuleExports) { + storyIdByModuleExport(storyExport: Store_ModuleExport, metaExports?: Store_ModuleExports) { if (metaExports) { const csfFile = this.processMetaExports(metaExports); this.referenceCSFFile(csfFile, false); diff --git a/code/lib/blocks/src/blocks/external/ExternalPreview.ts b/code/lib/blocks/src/blocks/external/ExternalPreview.ts index de095f8195b8..fe6bb7d12049 100644 --- a/code/lib/blocks/src/blocks/external/ExternalPreview.ts +++ b/code/lib/blocks/src/blocks/external/ExternalPreview.ts @@ -1,11 +1,19 @@ +/* eslint-disable camelcase */ import { Preview } from '@storybook/preview-web'; -import { Path, ModuleExports, StoryIndex, composeConfigs } from '@storybook/store'; -import { AnyFramework, ComponentTitle, ProjectAnnotations } from '@storybook/types'; +import type { + Store_Path, + Store_ModuleExports, + Store_StoryIndex, + AnyFramework, + ComponentTitle, + ProjectAnnotations, +} from '@storybook/types'; +import { composeConfigs } from '@storybook/store'; import { Channel } from '@storybook/channels'; import { ExternalDocsContext } from './ExternalDocsContext'; -type MetaExports = ModuleExports; +type MetaExports = Store_ModuleExports; class ConstantMap { entries = new Map(); @@ -24,20 +32,20 @@ class ConstantMap { export class ExternalPreview< TFramework extends AnyFramework = AnyFramework > extends Preview { - private importPaths = new ConstantMap('./importPath/'); + private importPaths = new ConstantMap('./importPath/'); private titles = new ConstantMap('title-'); - private storyIndex: StoryIndex = { v: 4, entries: {} }; + private storyIndex: Store_StoryIndex = { v: 4, entries: {} }; - private moduleExportsByImportPath: Record = {}; + private moduleExportsByImportPath: Record = {}; constructor(public projectAnnotations: ProjectAnnotations) { super(new Channel()); this.initialize({ getStoryIndex: () => this.storyIndex, - importFn: (path: Path) => { + importFn: (path: Store_Path) => { return Promise.resolve(this.moduleExportsByImportPath[path]); }, getProjectAnnotations: () => diff --git a/code/lib/blocks/src/controls/Object.tsx b/code/lib/blocks/src/controls/Object.tsx index 6333f5b49b7b..28ed21692649 100644 --- a/code/lib/blocks/src/controls/Object.tsx +++ b/code/lib/blocks/src/controls/Object.tsx @@ -11,8 +11,8 @@ import React, { FC, FocusEvent, } from 'react'; -import { styled, useTheme, Theme } from '@storybook/theming'; -import { Form, Icons, IconsProps, IconButton } from '@storybook/components'; +import { styled, useTheme, type Theme } from '@storybook/theming'; +import { Form, Icons, type IconsProps, IconButton } from '@storybook/components'; import { JsonTree, getObjectType } from './react-editable-json-tree'; import { getControlId, getControlSetterButtonId } from './helpers'; import type { ControlProps, ObjectValue, ObjectConfig } from './types'; diff --git a/code/lib/components/src/tooltip/Tooltip.tsx b/code/lib/components/src/tooltip/Tooltip.tsx index 5e6e30f6e0c1..c52243b84757 100644 --- a/code/lib/components/src/tooltip/Tooltip.tsx +++ b/code/lib/components/src/tooltip/Tooltip.tsx @@ -1,7 +1,7 @@ import React, { FC } from 'react'; import memoize from 'memoizerific'; -import { styled, Color, lighten } from '@storybook/theming'; +import { styled, type Color, lighten } from '@storybook/theming'; const match = memoize(1000)((requests, actual, value, fallback = 0) => actual.split('-')[0] === requests ? value : fallback diff --git a/code/lib/core-client/src/manager/provider.ts b/code/lib/core-client/src/manager/provider.ts index a34d94dd8772..0d4dcd8f0291 100644 --- a/code/lib/core-client/src/manager/provider.ts +++ b/code/lib/core-client/src/manager/provider.ts @@ -6,7 +6,7 @@ import { addons, AddonStore, type Types } from '@storybook/addons'; import type { Addon_Config } from '@storybook/types'; import * as postMessage from '@storybook/channel-postmessage'; import * as webSocket from '@storybook/channel-websocket'; -import Events from '@storybook/core-events'; +import { CHANNEL_CREATED } from '@storybook/core-events'; const { FEATURES, SERVER_CHANNEL_URL } = global; @@ -23,7 +23,7 @@ export default class ReactProvider extends Provider { const channel = postMessage.createChannel({ page: 'manager' }); addons.setChannel(channel); - channel.emit(Events.CHANNEL_CREATED); + channel.emit(CHANNEL_CREATED); this.addons = addons; this.channel = channel; diff --git a/code/lib/core-client/src/preview/executeLoadable.ts b/code/lib/core-client/src/preview/executeLoadable.ts index 0a767b6ecdce..9e0f625dd868 100644 --- a/code/lib/core-client/src/preview/executeLoadable.ts +++ b/code/lib/core-client/src/preview/executeLoadable.ts @@ -3,8 +3,13 @@ /// import { logger } from '@storybook/client-logger'; -import type { Store_Path, Store_ModuleExports } from '@storybook/types'; -import { Loadable, CoreClient_RequireContext, CoreClient_LoaderFunction } from '@storybook/types'; +import type { + Store_Path, + Store_ModuleExports, + Loadable, + CoreClient_RequireContext, + CoreClient_LoaderFunction, +} from '@storybook/types'; /** * Executes a Loadable (function that returns exports or require context(s)) diff --git a/code/lib/core-client/src/preview/start.test.ts b/code/lib/core-client/src/preview/start.test.ts index 3558f5753aff..0d7c090f25e3 100644 --- a/code/lib/core-client/src/preview/start.test.ts +++ b/code/lib/core-client/src/preview/start.test.ts @@ -1,5 +1,5 @@ /* global window */ -import Events from '@storybook/core-events'; +import Events, { SET_STORIES, STORY_RENDERED } from '@storybook/core-events'; import { waitForRender, @@ -88,9 +88,8 @@ describe('start', () => { }); await waitForRender(); - expect( - mockChannel.emit.mock.calls.find((call: [string, any]) => call[0] === Events.SET_STORIES)[1] - ).toMatchInlineSnapshot(` + expect(mockChannel.emit.mock.calls.find((call: [string, any]) => call[0] === SET_STORIES)[1]) + .toMatchInlineSnapshot(` Object { "globalParameters": Object {}, "globals": Object {}, @@ -165,10 +164,7 @@ describe('start', () => { `); await waitForRender(); - expect(mockChannel.emit).toHaveBeenCalledWith( - Events.STORY_RENDERED, - 'component-a--story-one' - ); + expect(mockChannel.emit).toHaveBeenCalledWith(STORY_RENDERED, 'component-a--story-one'); expect(renderToDOM).toHaveBeenCalledWith( expect.objectContaining({ @@ -189,10 +185,9 @@ describe('start', () => { .add('Story One', jest.fn(), { docsOnly: true, docs: {} }); }); - await waitForEvents([Events.SET_STORIES]); - expect( - mockChannel.emit.mock.calls.find((call: [string, any]) => call[0] === Events.SET_STORIES)[1] - ).toMatchInlineSnapshot(` + await waitForEvents([SET_STORIES]); + expect(mockChannel.emit.mock.calls.find((call: [string, any]) => call[0] === SET_STORIES)[1]) + .toMatchInlineSnapshot(` Object { "globalParameters": Object {}, "globals": Object {}, @@ -242,7 +237,7 @@ describe('start', () => { await waitForRender(); - expect(mockChannel.emit).toHaveBeenCalledWith(Events.STORY_RENDERED, 'component-a--default'); + expect(mockChannel.emit).toHaveBeenCalledWith(STORY_RENDERED, 'component-a--default'); }); it('deals with stories with camel-cased names', async () => { @@ -258,7 +253,7 @@ describe('start', () => { await waitForRender(); - expect(mockChannel.emit).toHaveBeenCalledWith(Events.STORY_RENDERED, 'component-a--storyone'); + expect(mockChannel.emit).toHaveBeenCalledWith(STORY_RENDERED, 'component-a--storyone'); }); it('deals with stories with spaces in the name', async () => { @@ -274,10 +269,7 @@ describe('start', () => { await waitForRender(); - expect(mockChannel.emit).toHaveBeenCalledWith( - Events.STORY_RENDERED, - 'component-a--story-one' - ); + expect(mockChannel.emit).toHaveBeenCalledWith(STORY_RENDERED, 'component-a--story-one'); }); // https://github.com/storybookjs/storybook/issues/16303 @@ -292,7 +284,7 @@ describe('start', () => { await waitForRender(); - expect(mockChannel.emit).toHaveBeenCalledWith(Events.STORY_RENDERED, 'component-a--story0'); + expect(mockChannel.emit).toHaveBeenCalledWith(STORY_RENDERED, 'component-a--story0'); }); it('deals with storiesOf from the same file twice', async () => { @@ -307,10 +299,10 @@ describe('start', () => { }); await waitForRender(); - expect(mockChannel.emit).toHaveBeenCalledWith(Events.STORY_RENDERED, 'component-a--default'); + expect(mockChannel.emit).toHaveBeenCalledWith(STORY_RENDERED, 'component-a--default'); const storiesOfData = mockChannel.emit.mock.calls.find( - (call: [string, any]) => call[0] === Events.SET_STORIES + (call: [string, any]) => call[0] === SET_STORIES )[1]; expect(Object.values(storiesOfData.stories).map((s: any) => s.parameters.fileName)).toEqual([ 'file1', @@ -368,13 +360,13 @@ describe('start', () => { }); await waitForRender(); - expect(mockChannel.emit).toHaveBeenCalledWith(Events.STORY_RENDERED, 'component-a--default'); + expect(mockChannel.emit).toHaveBeenCalledWith(STORY_RENDERED, 'component-a--default'); mockChannel.emit.mockClear(); forceReRender(); await waitForRender(); - expect(mockChannel.emit).toHaveBeenCalledWith(Events.STORY_RENDERED, 'component-a--default'); + expect(mockChannel.emit).toHaveBeenCalledWith(STORY_RENDERED, 'component-a--default'); }); it('supports HMR when a story file changes', async () => { @@ -398,7 +390,7 @@ describe('start', () => { }); await waitForRender(); - expect(mockChannel.emit).toHaveBeenCalledWith(Events.STORY_RENDERED, 'component-a--default'); + expect(mockChannel.emit).toHaveBeenCalledWith(STORY_RENDERED, 'component-a--default'); expect(firstImplementation).toHaveBeenCalled(); expect(module.hot.accept).toHaveBeenCalled(); expect(disposeCallback).toBeDefined(); @@ -409,7 +401,7 @@ describe('start', () => { clientApi.storiesOf('Component A', module as any).add('default', secondImplementation); await waitForRender(); - expect(mockChannel.emit).toHaveBeenCalledWith(Events.STORY_RENDERED, 'component-a--default'); + expect(mockChannel.emit).toHaveBeenCalledWith(STORY_RENDERED, 'component-a--default'); expect(secondImplementation).toHaveBeenCalled(); }); @@ -441,10 +433,9 @@ describe('start', () => { .add('default', jest.fn()) .add('new', jest.fn()); - await waitForEvents([Events.SET_STORIES]); - expect( - mockChannel.emit.mock.calls.find((call: [string, any]) => call[0] === Events.SET_STORIES)[1] - ).toMatchInlineSnapshot(` + await waitForEvents([SET_STORIES]); + expect(mockChannel.emit.mock.calls.find((call: [string, any]) => call[0] === SET_STORIES)[1]) + .toMatchInlineSnapshot(` Object { "globalParameters": Object {}, "globals": Object {}, @@ -518,10 +509,9 @@ describe('start', () => { clientApi.storiesOf('Component B', moduleB as any).add('default', jest.fn()); }); - await waitForEvents([Events.SET_STORIES]); - expect( - mockChannel.emit.mock.calls.find((call: [string, any]) => call[0] === Events.SET_STORIES)[1] - ).toMatchInlineSnapshot(` + await waitForEvents([SET_STORIES]); + expect(mockChannel.emit.mock.calls.find((call: [string, any]) => call[0] === SET_STORIES)[1]) + .toMatchInlineSnapshot(` Object { "globalParameters": Object {}, "globals": Object {}, @@ -577,10 +567,9 @@ describe('start', () => { mockChannel.emit.mockClear(); disposeCallback(); - await waitForEvents([Events.SET_STORIES]); - expect( - mockChannel.emit.mock.calls.find((call: [string, any]) => call[0] === Events.SET_STORIES)[1] - ).toMatchInlineSnapshot(` + await waitForEvents([SET_STORIES]); + expect(mockChannel.emit.mock.calls.find((call: [string, any]) => call[0] === SET_STORIES)[1]) + .toMatchInlineSnapshot(` Object { "globalParameters": Object {}, "globals": Object {}, @@ -631,9 +620,8 @@ describe('start', () => { configure('test', () => [componentCExports]); await waitForRender(); - expect( - mockChannel.emit.mock.calls.find((call: [string, any]) => call[0] === Events.SET_STORIES)[1] - ).toMatchInlineSnapshot(` + expect(mockChannel.emit.mock.calls.find((call: [string, any]) => call[0] === SET_STORIES)[1]) + .toMatchInlineSnapshot(` Object { "globalParameters": Object {}, "globals": Object {}, @@ -685,10 +673,7 @@ describe('start', () => { `); await waitForRender(); - expect(mockChannel.emit).toHaveBeenCalledWith( - Events.STORY_RENDERED, - 'component-c--story-one' - ); + expect(mockChannel.emit).toHaveBeenCalledWith(STORY_RENDERED, 'component-c--story-one'); expect(renderToDOM).toHaveBeenCalledWith( expect.objectContaining({ @@ -717,10 +702,7 @@ describe('start', () => { configure('test', () => [componentCExports], module as any); await waitForRender(); - expect(mockChannel.emit).toHaveBeenCalledWith( - Events.STORY_RENDERED, - 'component-c--story-one' - ); + expect(mockChannel.emit).toHaveBeenCalledWith(STORY_RENDERED, 'component-c--story-one'); expect(componentCExports.StoryOne).toHaveBeenCalled(); expect(module.hot.accept).toHaveBeenCalled(); expect(disposeCallback).toBeDefined(); @@ -735,10 +717,7 @@ describe('start', () => { ); await waitForRender(); - expect(mockChannel.emit).toHaveBeenCalledWith( - Events.STORY_RENDERED, - 'component-c--story-one' - ); + expect(mockChannel.emit).toHaveBeenCalledWith(STORY_RENDERED, 'component-c--story-one'); expect(secondImplementation).toHaveBeenCalled(); }); @@ -765,10 +744,9 @@ describe('start', () => { disposeCallback(module.hot.data); configure('test', () => [{ ...componentCExports, StoryThree: jest.fn() }], module as any); - await waitForEvents([Events.SET_STORIES]); - expect( - mockChannel.emit.mock.calls.find((call: [string, any]) => call[0] === Events.SET_STORIES)[1] - ).toMatchInlineSnapshot(` + await waitForEvents([SET_STORIES]); + expect(mockChannel.emit.mock.calls.find((call: [string, any]) => call[0] === SET_STORIES)[1]) + .toMatchInlineSnapshot(` Object { "globalParameters": Object {}, "globals": Object {}, @@ -860,10 +838,9 @@ describe('start', () => { module as any ); - await waitForEvents([Events.SET_STORIES]); - expect( - mockChannel.emit.mock.calls.find((call: [string, any]) => call[0] === Events.SET_STORIES)[1] - ).toMatchInlineSnapshot(` + await waitForEvents([SET_STORIES]); + expect(mockChannel.emit.mock.calls.find((call: [string, any]) => call[0] === SET_STORIES)[1]) + .toMatchInlineSnapshot(` Object { "globalParameters": Object {}, "globals": Object {}, @@ -939,10 +916,9 @@ describe('start', () => { disposeCallback(module.hot.data); configure('test', () => [componentCExports], module as any); - await waitForEvents([Events.SET_STORIES]); - expect( - mockChannel.emit.mock.calls.find((call: [string, any]) => call[0] === Events.SET_STORIES)[1] - ).toMatchInlineSnapshot(` + await waitForEvents([SET_STORIES]); + expect(mockChannel.emit.mock.calls.find((call: [string, any]) => call[0] === SET_STORIES)[1]) + .toMatchInlineSnapshot(` Object { "globalParameters": Object {}, "globals": Object {}, @@ -1017,10 +993,7 @@ describe('start', () => { }); await waitForRender(); - expect(mockChannel.emit).toHaveBeenCalledWith( - Events.STORY_RENDERED, - 'component-a--story-one' - ); + expect(mockChannel.emit).toHaveBeenCalledWith(STORY_RENDERED, 'component-a--story-one'); expect(frameworkRender).not.toHaveBeenCalled(); expect(projectRender).toHaveBeenCalled(); @@ -1046,9 +1019,8 @@ describe('start', () => { }); await waitForRender(); - expect( - mockChannel.emit.mock.calls.find((call: [string, any]) => call[0] === Events.SET_STORIES)[1] - ).toMatchInlineSnapshot(` + expect(mockChannel.emit.mock.calls.find((call: [string, any]) => call[0] === SET_STORIES)[1]) + .toMatchInlineSnapshot(` Object { "globalParameters": Object {}, "globals": Object {}, @@ -1162,10 +1134,7 @@ describe('start', () => { `); await waitForRender(); - expect(mockChannel.emit).toHaveBeenCalledWith( - Events.STORY_RENDERED, - 'component-a--story-one' - ); + expect(mockChannel.emit).toHaveBeenCalledWith(STORY_RENDERED, 'component-a--story-one'); expect(renderToDOM).toHaveBeenCalledWith( expect.objectContaining({ @@ -1189,10 +1158,9 @@ describe('start', () => { const { configure } = start(renderToDOM); configure('test', () => [componentDExports]); - await waitForEvents([Events.SET_STORIES]); - expect( - mockChannel.emit.mock.calls.find((call: [string, any]) => call[0] === Events.SET_STORIES)[1] - ).toMatchInlineSnapshot(` + await waitForEvents([SET_STORIES]); + expect(mockChannel.emit.mock.calls.find((call: [string, any]) => call[0] === SET_STORIES)[1]) + .toMatchInlineSnapshot(` Object { "globalParameters": Object {}, "globals": Object {}, diff --git a/code/lib/core-common/src/presets.ts b/code/lib/core-common/src/presets.ts index 4e2cb4f8cd82..84a3a8a4f531 100644 --- a/code/lib/core-common/src/presets.ts +++ b/code/lib/core-common/src/presets.ts @@ -2,7 +2,7 @@ import { dedent } from 'ts-dedent'; import { logger } from '@storybook/node-logger'; import { dirname } from 'path'; -import { +import type { CLIOptions, LoadedPreset, LoadOptions, diff --git a/code/lib/core-common/src/utils/__tests__/check-addon-order.test.ts b/code/lib/core-common/src/utils/__tests__/check-addon-order.test.ts index 66fa015ea1aa..93174040e542 100644 --- a/code/lib/core-common/src/utils/__tests__/check-addon-order.test.ts +++ b/code/lib/core-common/src/utils/__tests__/check-addon-order.test.ts @@ -1,6 +1,6 @@ /* eslint-disable camelcase */ import { logger } from '@storybook/node-logger'; -import { +import type { CoreCommon_AddonEntry, CoreCommon_AddonInfo, CoreCommon_OptionsEntry, diff --git a/code/lib/preview-web/src/Preview.tsx b/code/lib/preview-web/src/Preview.tsx index ec2453c90602..76693eb5a4b8 100644 --- a/code/lib/preview-web/src/Preview.tsx +++ b/code/lib/preview-web/src/Preview.tsx @@ -17,8 +17,12 @@ import { import { logger } from '@storybook/client-logger'; import { Channel } from '@storybook/channels'; import { addons } from '@storybook/addons'; -import { AnyFramework, StoryId, ProjectAnnotations, Args, Globals } from '@storybook/types'; import type { + AnyFramework, + StoryId, + ProjectAnnotations, + Args, + Globals, Store_ModuleImportFn, Store_Story, Store_StoryIndex, diff --git a/code/lib/preview-web/src/PreviewWeb.integration.test.ts b/code/lib/preview-web/src/PreviewWeb.integration.test.ts index 924ab724a3d3..d3d886332a32 100644 --- a/code/lib/preview-web/src/PreviewWeb.integration.test.ts +++ b/code/lib/preview-web/src/PreviewWeb.integration.test.ts @@ -2,7 +2,7 @@ import React from 'react'; import global from 'global'; import type { Store_RenderContext } from '@storybook/types'; -import addons, { mockChannel as createMockChannel } from '@storybook/addons'; +import { addons, mockChannel as createMockChannel } from '@storybook/addons'; import { mocked } from 'ts-jest/utils'; import { expect } from '@jest/globals'; diff --git a/code/lib/preview-web/src/PreviewWeb.tsx b/code/lib/preview-web/src/PreviewWeb.tsx index 2703218724b9..58a30a3a5f10 100644 --- a/code/lib/preview-web/src/PreviewWeb.tsx +++ b/code/lib/preview-web/src/PreviewWeb.tsx @@ -19,15 +19,13 @@ import { UPDATE_QUERY_PARAMS, } from '@storybook/core-events'; import { logger } from '@storybook/client-logger'; -import { +import type { AnyFramework, StoryId, ProjectAnnotations, Args, Globals, ViewMode, -} from '@storybook/types'; -import type { Store_ModuleImportFn, Store_Selection, Store_StorySpecifier, diff --git a/code/lib/preview-web/src/render/Render.ts b/code/lib/preview-web/src/render/Render.ts index 7dd3b796bde0..8e1b187c37b2 100644 --- a/code/lib/preview-web/src/render/Render.ts +++ b/code/lib/preview-web/src/render/Render.ts @@ -1,4 +1,4 @@ -import { StoryId, AnyFramework } from '@storybook/types'; +import type { StoryId, AnyFramework } from '@storybook/types'; export type RenderType = 'story' | 'docs'; diff --git a/code/lib/preview-web/src/render/StandaloneDocsRender.test.ts b/code/lib/preview-web/src/render/StandaloneDocsRender.test.ts index 531ce49986c0..fe02df2ea9dd 100644 --- a/code/lib/preview-web/src/render/StandaloneDocsRender.test.ts +++ b/code/lib/preview-web/src/render/StandaloneDocsRender.test.ts @@ -1,8 +1,8 @@ +/* eslint-disable camelcase */ import { jest, describe, it, expect } from '@jest/globals'; import { Channel } from '@storybook/channels'; -import { AnyFramework } from '@storybook/types'; +import type { AnyFramework, Addon_StandaloneDocsIndexEntry } from '@storybook/types'; import { StoryStore } from '@storybook/store'; -import type { StandaloneDocsIndexEntry } from '@storybook/store'; import { PREPARE_ABORTED } from './Render'; import { StandaloneDocsRender } from './StandaloneDocsRender'; @@ -15,7 +15,7 @@ const entry = { importPath: './Introduction.mdx', storiesImports: [], standalone: true, -} as StandaloneDocsIndexEntry; +} as Addon_StandaloneDocsIndexEntry; const createGate = (): [Promise, (_?: any) => void] => { let openGate = (_?: any) => {}; diff --git a/code/lib/preview-web/src/render/StandaloneDocsRender.ts b/code/lib/preview-web/src/render/StandaloneDocsRender.ts index b150a44a3159..56a32925a06b 100644 --- a/code/lib/preview-web/src/render/StandaloneDocsRender.ts +++ b/code/lib/preview-web/src/render/StandaloneDocsRender.ts @@ -1,7 +1,12 @@ /* eslint-disable camelcase */ -import { AnyFramework, StoryId, Addon_IndexEntry } from '@storybook/types'; +import type { + AnyFramework, + StoryId, + Addon_IndexEntry, + Store_CSFFile, + Store_ModuleExports, +} from '@storybook/types'; import { StoryStore } from '@storybook/store'; -import type { Store_CSFFile, Store_ModuleExports } from '@storybook/types'; import type { Channel } from '@storybook/channels'; import { DOCS_RENDERED } from '@storybook/core-events'; diff --git a/code/lib/preview-web/src/render/StoryRender.test.ts b/code/lib/preview-web/src/render/StoryRender.test.ts index 91514526f391..aa56b1177f93 100644 --- a/code/lib/preview-web/src/render/StoryRender.test.ts +++ b/code/lib/preview-web/src/render/StoryRender.test.ts @@ -1,8 +1,8 @@ +/* eslint-disable camelcase */ import { jest, describe, it, expect } from '@jest/globals'; import { Channel } from '@storybook/channels'; -import { AnyFramework } from '@storybook/types'; +import type { AnyFramework, Addon_StoryIndexEntry } from '@storybook/types'; import { StoryStore } from '@storybook/store'; -import type { StoryIndexEntry } from '@storybook/store'; import { PREPARE_ABORTED } from './Render'; import { StoryRender } from './StoryRender'; @@ -13,7 +13,7 @@ const entry = { name: 'A', title: 'component', importPath: './component.stories.ts', -} as StoryIndexEntry; +} as Addon_StoryIndexEntry; const createGate = (): [Promise, (_?: any) => void] => { let openGate = (_?: any) => {}; diff --git a/code/lib/preview-web/src/render/StoryRender.ts b/code/lib/preview-web/src/render/StoryRender.ts index acf932d1c510..646917ea5ccf 100644 --- a/code/lib/preview-web/src/render/StoryRender.ts +++ b/code/lib/preview-web/src/render/StoryRender.ts @@ -1,6 +1,6 @@ /* eslint-disable camelcase */ import global from 'global'; -import { +import type { AnyFramework, StoryId, ViewMode, @@ -11,7 +11,7 @@ import { Store_RenderToDOM, Store_TeardownRenderToDOM, } from '@storybook/types'; -import { StoryStore } from '@storybook/store'; +import type { StoryStore } from '@storybook/store'; import { Channel } from '@storybook/channels'; import { logger } from '@storybook/client-logger'; import { diff --git a/code/lib/preview-web/src/render/TemplateDocsRender.test.ts b/code/lib/preview-web/src/render/TemplateDocsRender.test.ts index 806b00df7883..4f316efb16ac 100644 --- a/code/lib/preview-web/src/render/TemplateDocsRender.test.ts +++ b/code/lib/preview-web/src/render/TemplateDocsRender.test.ts @@ -1,8 +1,8 @@ +/* eslint-disable camelcase */ import { jest, describe, it, expect } from '@jest/globals'; import { Channel } from '@storybook/channels'; -import { AnyFramework } from '@storybook/types'; +import type { AnyFramework, Addon_TemplateDocsIndexEntry } from '@storybook/types'; import { StoryStore } from '@storybook/store'; -import type { TemplateDocsIndexEntry } from '@storybook/store'; import { PREPARE_ABORTED } from './Render'; import { TemplateDocsRender } from './TemplateDocsRender'; @@ -15,7 +15,7 @@ const entry = { importPath: './Component.stories.ts', storiesImports: [], standalone: false, -} as TemplateDocsIndexEntry; +} as Addon_TemplateDocsIndexEntry; const createGate = (): [Promise, (_?: any) => void] => { let openGate = (_?: any) => {}; diff --git a/code/lib/store/src/StoryIndexStore.test.ts b/code/lib/store/src/StoryIndexStore.test.ts index 72e6302bb49a..41b2909ce51d 100644 --- a/code/lib/store/src/StoryIndexStore.test.ts +++ b/code/lib/store/src/StoryIndexStore.test.ts @@ -1,11 +1,12 @@ +/* eslint-disable camelcase */ import { expect } from '@jest/globals'; +import type { Store_StoryIndex } from '@storybook/types'; import { StoryIndexStore } from './StoryIndexStore'; -import { StoryIndex } from './types'; jest.mock('@storybook/channel-websocket', () => () => ({ on: jest.fn() })); -const storyIndex: StoryIndex = { +const storyIndex: Store_StoryIndex = { v: 4, entries: { 'component-one--a': { diff --git a/code/lib/store/src/args.test.ts b/code/lib/store/src/args.test.ts index ec5ab1388c9c..8d00cafaf945 100644 --- a/code/lib/store/src/args.test.ts +++ b/code/lib/store/src/args.test.ts @@ -1,6 +1,6 @@ import { once } from '@storybook/client-logger'; import { expect } from '@jest/globals'; -import { SBType } from '@storybook/types'; +import type { SBType } from '@storybook/types'; import { combineArgs, diff --git a/code/lib/store/src/csf/normalizeStory.test.ts b/code/lib/store/src/csf/normalizeStory.test.ts index ce78bc1a3b97..d83060a20f36 100644 --- a/code/lib/store/src/csf/normalizeStory.test.ts +++ b/code/lib/store/src/csf/normalizeStory.test.ts @@ -1,5 +1,5 @@ -import { expect } from '@jest/globals'; -import { AnyFramework, StoryAnnotationsOrFn } from '@storybook/types'; +import { expect, describe, it } from '@jest/globals'; +import type { AnyFramework, StoryAnnotationsOrFn } from '@storybook/types'; import { normalizeStory } from './normalizeStory'; diff --git a/code/lib/store/src/csf/testing-utils/index.ts b/code/lib/store/src/csf/testing-utils/index.ts index d1f81ed6cda1..97e6e128421e 100644 --- a/code/lib/store/src/csf/testing-utils/index.ts +++ b/code/lib/store/src/csf/testing-utils/index.ts @@ -1,6 +1,6 @@ /* eslint-disable camelcase */ import { isExportStory } from '@storybook/csf'; -import { +import type { AnyFramework, ComponentAnnotations, ProjectAnnotations, @@ -8,10 +8,11 @@ import { StoryContext, LegacyStoryAnnotationsOrFn, Store_ComposeStory, + Store_CSFExports, + Store_ComposedStoryPlayFn, } from '@storybook/types'; import { HooksContext } from '@storybook/addons'; -import type { Store_CSFExports, Store_ComposedStoryPlayFn } from '@storybook/types'; import { composeConfigs } from '../composeConfigs'; import { prepareStory } from '../prepareStory'; import { normalizeStory } from '../normalizeStory'; diff --git a/code/lib/store/src/hooks.test.ts b/code/lib/store/src/hooks.test.ts index e5d48749093b..c124c9f63fc5 100644 --- a/code/lib/store/src/hooks.test.ts +++ b/code/lib/store/src/hooks.test.ts @@ -25,8 +25,6 @@ import { import type { DecoratorFunction, StoryContext } from '@storybook/types'; import { defaultDecorateStory } from './decorators'; -// import { -// } from './hooks'; jest.mock('@storybook/client-logger', () => ({ logger: { warn: jest.fn(), log: jest.fn() }, @@ -66,7 +64,7 @@ beforeEach(() => { const decorateStory = applyHooks(defaultDecorateStory); const run = (storyFn, decorators: DecoratorFunction[] = [], context = {}) => - decorateStory(storyFn, decorators)({ ...context, hooks } as Partial); + decorateStory(storyFn, decorators)({ ...context, hooks } as StoryContext); describe('Preview hooks', () => { describe('useEffect', () => { diff --git a/code/lib/store/src/storySort.test.ts b/code/lib/store/src/storySort.test.ts index c26033476686..2b65037af8d3 100644 --- a/code/lib/store/src/storySort.test.ts +++ b/code/lib/store/src/storySort.test.ts @@ -1,11 +1,11 @@ -import { expect } from '@jest/globals'; -import { StoryId } from '@storybook/types'; -import { StoryIndexEntry } from '@storybook/store'; +/* eslint-disable camelcase */ +import { expect, describe, it } from '@jest/globals'; +import type { StoryId, Addon_StoryIndexEntry } from '@storybook/types'; import { storySort } from './storySort'; describe('preview.storySort', () => { - const fixture: Record = Object.fromEntries( + const fixture: Record = Object.fromEntries( Object.entries({ a: { title: 'a' }, á: { title: 'á' }, diff --git a/code/lib/store/template/stories/hooks.stories.ts b/code/lib/store/template/stories/hooks.stories.ts index 4ddfb1add79c..0d57994f01d6 100644 --- a/code/lib/store/template/stories/hooks.stories.ts +++ b/code/lib/store/template/stories/hooks.stories.ts @@ -1,6 +1,6 @@ import globalThis from 'global'; import { PartialStoryFn, PlayFunctionContext } from '@storybook/csf'; -import { useEffect, useState } from '@storybook/client-api'; +import { useEffect, useState } from '@storybook/addons'; import { within, userEvent } from '@storybook/testing-library'; export default { diff --git a/code/lib/store/template/stories/preview.ts b/code/lib/store/template/stories/preview.ts index 43fd9b08cda2..3f479374e900 100644 --- a/code/lib/store/template/stories/preview.ts +++ b/code/lib/store/template/stories/preview.ts @@ -1,4 +1,4 @@ -import { PartialStoryFn, StoryContext } from '@storybook/types'; +import type { PartialStoryFn, StoryContext } from '@storybook/types'; export const parameters = { projectParameter: 'projectParameter', diff --git a/code/renderers/react/src/__test__/CSF3.test.tsx b/code/renderers/react/src/__test__/CSF3.test.tsx index b53d0ac680a9..487ff3766330 100644 --- a/code/renderers/react/src/__test__/CSF3.test.tsx +++ b/code/renderers/react/src/__test__/CSF3.test.tsx @@ -1,13 +1,13 @@ import React, { KeyboardEventHandler, ReactNode } from 'react'; import { expectTypeOf } from 'expect-type'; import { describe, test } from '@jest/globals'; -import { StoryAnnotations } from '@storybook/types'; +import type { StoryAnnotations } from '@storybook/types'; import { SetOptional } from 'type-fest'; -import { Meta, StoryObj } from '../public-types'; -import { DecoratorFn } from '../public-api'; +import type { Meta, StoryObj } from '../public-types'; +import type { DecoratorFn } from '../public-api'; import { satisfies } from './utils'; -import { ReactFramework } from '../types'; +import type { ReactFramework } from '../types'; type ReactStory = StoryAnnotations; diff --git a/code/renderers/react/src/docs/extractProps.ts b/code/renderers/react/src/docs/extractProps.ts index 8efd89ea7869..e5b09f6422b6 100644 --- a/code/renderers/react/src/docs/extractProps.ts +++ b/code/renderers/react/src/docs/extractProps.ts @@ -1,5 +1,5 @@ import PropTypes from 'prop-types'; -import { PropDef, hasDocgen, extractComponentProps, TypeSystem } from '@storybook/docs-tools'; +import { type PropDef, hasDocgen, extractComponentProps, TypeSystem } from '@storybook/docs-tools'; import { enhancePropTypesProps } from './propTypes/handleProp'; import { enhanceTypeScriptProps } from './typeScript/handleProp'; import { isMemo } from './lib'; diff --git a/code/renderers/react/src/docs/jsxDecorator.tsx b/code/renderers/react/src/docs/jsxDecorator.tsx index b0fda7e927d1..dcf15bbb805f 100644 --- a/code/renderers/react/src/docs/jsxDecorator.tsx +++ b/code/renderers/react/src/docs/jsxDecorator.tsx @@ -3,7 +3,7 @@ import React, { createElement, ReactElement } from 'react'; import reactElementToJSXString, { Options } from 'react-element-to-jsx-string'; import { addons, useEffect } from '@storybook/addons'; -import { StoryContext, ArgsStoryFn, PartialStoryFn } from '@storybook/types'; +import type { StoryContext, ArgsStoryFn, PartialStoryFn } from '@storybook/types'; import { SourceType, SNIPPET_RENDERED, getDocgenSection } from '@storybook/docs-tools'; import { logger } from '@storybook/client-logger'; diff --git a/code/renderers/react/src/docs/lib/defaultValues/createDefaultValue.ts b/code/renderers/react/src/docs/lib/defaultValues/createDefaultValue.ts index f74ef59c597c..810808a327dd 100644 --- a/code/renderers/react/src/docs/lib/defaultValues/createDefaultValue.ts +++ b/code/renderers/react/src/docs/lib/defaultValues/createDefaultValue.ts @@ -1,7 +1,7 @@ import { createSummaryValue, isTooLongForDefaultValueSummary, - PropDefaultValue, + type PropDefaultValue, } from '@storybook/docs-tools'; import { FUNCTION_CAPTION, ELEMENT_CAPTION } from '../captions'; diff --git a/code/renderers/react/src/docs/lib/defaultValues/createFromRawDefaultProp.ts b/code/renderers/react/src/docs/lib/defaultValues/createFromRawDefaultProp.ts index d76800870209..eeb6fa095b21 100644 --- a/code/renderers/react/src/docs/lib/defaultValues/createFromRawDefaultProp.ts +++ b/code/renderers/react/src/docs/lib/defaultValues/createFromRawDefaultProp.ts @@ -4,10 +4,10 @@ import isFunction from 'lodash/isFunction'; import isString from 'lodash/isString'; import reactElementToJSXString from 'react-element-to-jsx-string'; import { - PropDef, + type PropDef, createSummaryValue, isTooLongForDefaultValueSummary, - PropDefaultValue, + type PropDefaultValue, } from '@storybook/docs-tools'; import { inspectValue, InspectionFunction } from '../inspection'; diff --git a/code/renderers/react/src/docs/lib/defaultValues/generateArray.ts b/code/renderers/react/src/docs/lib/defaultValues/generateArray.ts index 8d80f9a371fb..0ac2cd426ce7 100644 --- a/code/renderers/react/src/docs/lib/defaultValues/generateArray.ts +++ b/code/renderers/react/src/docs/lib/defaultValues/generateArray.ts @@ -1,7 +1,7 @@ import { createSummaryValue, isTooLongForDefaultValueSummary, - PropDefaultValue, + type PropDefaultValue, } from '@storybook/docs-tools'; import { ARRAY_CAPTION } from '../captions'; import { InspectionResult, InspectionArray } from '../inspection'; diff --git a/code/renderers/react/src/docs/lib/defaultValues/generateObject.ts b/code/renderers/react/src/docs/lib/defaultValues/generateObject.ts index 2aa6e45e7a3f..0e27259b0974 100644 --- a/code/renderers/react/src/docs/lib/defaultValues/generateObject.ts +++ b/code/renderers/react/src/docs/lib/defaultValues/generateObject.ts @@ -1,7 +1,7 @@ import { createSummaryValue, isTooLongForDefaultValueSummary, - PropDefaultValue, + type PropDefaultValue, } from '@storybook/docs-tools'; import { OBJECT_CAPTION } from '../captions'; diff --git a/code/renderers/react/src/docs/propTypes/generateFuncSignature.ts b/code/renderers/react/src/docs/propTypes/generateFuncSignature.ts index 2e1b500a9e5f..cd54b4ebe37d 100644 --- a/code/renderers/react/src/docs/propTypes/generateFuncSignature.ts +++ b/code/renderers/react/src/docs/propTypes/generateFuncSignature.ts @@ -1,4 +1,4 @@ -import { ExtractedJsDocParam, ExtractedJsDocReturns } from '@storybook/docs-tools'; +import type { ExtractedJsDocParam, ExtractedJsDocReturns } from '@storybook/docs-tools'; export function generateFuncSignature( params: ExtractedJsDocParam[], diff --git a/code/renderers/react/src/docs/propTypes/handleProp.test.tsx b/code/renderers/react/src/docs/propTypes/handleProp.test.tsx index 1e950ea2a21d..031e7384aa27 100644 --- a/code/renderers/react/src/docs/propTypes/handleProp.test.tsx +++ b/code/renderers/react/src/docs/propTypes/handleProp.test.tsx @@ -3,10 +3,10 @@ import PropTypes from 'prop-types'; import React from 'react'; import { - PropDef, + type PropDef, extractComponentProps, - DocgenInfo, - DocgenPropDefaultValue, + type DocgenInfo, + type DocgenPropDefaultValue, } from '@storybook/docs-tools'; import { enhancePropTypesProp, enhancePropTypesProps } from './handleProp'; diff --git a/code/renderers/react/src/docs/propTypes/handleProp.ts b/code/renderers/react/src/docs/propTypes/handleProp.ts index a59022ffd7e3..71ae824c9236 100644 --- a/code/renderers/react/src/docs/propTypes/handleProp.ts +++ b/code/renderers/react/src/docs/propTypes/handleProp.ts @@ -1,4 +1,4 @@ -import { PropDef, ExtractedProp } from '@storybook/docs-tools'; +import type { PropDef, ExtractedProp } from '@storybook/docs-tools'; import { createType } from './createType'; import { createDefaultValue, createDefaultValueFromRawDefaultProp } from '../lib/defaultValues'; import { keepOriginalDefinitionOrder } from './sortProps'; diff --git a/code/renderers/react/src/docs/propTypes/sortProps.ts b/code/renderers/react/src/docs/propTypes/sortProps.ts index 311f478e35d5..3bfb7a5a3211 100644 --- a/code/renderers/react/src/docs/propTypes/sortProps.ts +++ b/code/renderers/react/src/docs/propTypes/sortProps.ts @@ -1,4 +1,4 @@ -import { PropDef } from '@storybook/docs-tools'; +import type { PropDef } from '@storybook/docs-tools'; type Component = any; diff --git a/code/renderers/react/src/docs/typeScript/handleProp.test.tsx b/code/renderers/react/src/docs/typeScript/handleProp.test.tsx index 396cbcc49879..3ff0c2627c2e 100644 --- a/code/renderers/react/src/docs/typeScript/handleProp.test.tsx +++ b/code/renderers/react/src/docs/typeScript/handleProp.test.tsx @@ -2,10 +2,10 @@ import React from 'react'; import { - PropDef, + type PropDef, extractComponentProps, - DocgenInfo, - DocgenPropDefaultValue, + type DocgenInfo, + type DocgenPropDefaultValue, } from '@storybook/docs-tools'; import { enhanceTypeScriptProp } from './handleProp'; diff --git a/code/renderers/react/src/docs/typeScript/handleProp.ts b/code/renderers/react/src/docs/typeScript/handleProp.ts index 2d7d13522ef7..1cdceba179fa 100644 --- a/code/renderers/react/src/docs/typeScript/handleProp.ts +++ b/code/renderers/react/src/docs/typeScript/handleProp.ts @@ -1,4 +1,4 @@ -import { PropDef, ExtractedProp } from '@storybook/docs-tools'; +import type { PropDef, ExtractedProp } from '@storybook/docs-tools'; import { createDefaultValue, createDefaultValueFromRawDefaultProp } from '../lib/defaultValues'; export function enhanceTypeScriptProp(extractedProp: ExtractedProp, rawDefaultProp?: any): PropDef { diff --git a/code/renderers/react/src/public-api.tsx b/code/renderers/react/src/public-api.tsx index 8d9fd1cbbe8e..2514c85604a5 100644 --- a/code/renderers/react/src/public-api.tsx +++ b/code/renderers/react/src/public-api.tsx @@ -1,7 +1,11 @@ /* eslint-disable camelcase, prefer-destructuring */ -import type { Addon_ClientStoryApi, Addon_Loadable } from '@storybook/types'; +import type { + Addon_ClientStoryApi, + Addon_Loadable, + Args, + DecoratorFunction, +} from '@storybook/types'; import { start } from '@storybook/core-client'; -import { Args, DecoratorFunction } from '@storybook/types'; import { renderToDOM, render } from './render'; import type { ReactFramework } from './types'; diff --git a/code/ui/manager/src/components/preview/utils/types.tsx b/code/ui/manager/src/components/preview/utils/types.tsx index 25af5f96cff9..3801c921fb8c 100644 --- a/code/ui/manager/src/components/preview/utils/types.tsx +++ b/code/ui/manager/src/components/preview/utils/types.tsx @@ -1,6 +1,6 @@ -import { FunctionComponent, ReactNode } from 'react'; +import type { FunctionComponent, ReactNode } from 'react'; import type { State, API, LeafEntry } from '@storybook/api'; -import { StoryId } from '@storybook/types'; +import type { StoryId } from '@storybook/types'; export type ViewMode = State['viewMode']; diff --git a/code/ui/manager/src/runtime.ts b/code/ui/manager/src/runtime.ts index a2394f081e34..c2f573e60aeb 100644 --- a/code/ui/manager/src/runtime.ts +++ b/code/ui/manager/src/runtime.ts @@ -2,11 +2,11 @@ import global from 'global'; import type { Channel } from '@storybook/channels'; -import { addons, AddonStore, Types } from '@storybook/addons'; +import { addons, AddonStore, type Types } from '@storybook/addons'; import type { Addon_Config } from '@storybook/types'; import * as postMessage from '@storybook/channel-postmessage'; import * as webSocket from '@storybook/channel-websocket'; -import Events from '@storybook/core-events'; +import { CHANNEL_CREATED } from '@storybook/core-events'; import Provider from './provider'; import { renderStorybookUI } from './index'; @@ -28,7 +28,7 @@ class ReactProvider extends Provider { const channel = postMessage.createChannel({ page: 'manager' }); addons.setChannel(channel); - channel.emit(Events.CHANNEL_CREATED); + channel.emit(CHANNEL_CREATED); this.addons = addons; this.channel = channel; From 0f69691faea48536204a939f597f1d2fa7db23ef Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sat, 22 Oct 2022 17:35:51 +0200 Subject: [PATCH 25/38] fix lockfile --- code/yarn.lock | 1 + 1 file changed, 1 insertion(+) diff --git a/code/yarn.lock b/code/yarn.lock index df257e00fd38..e67ca09dd1b7 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -6632,6 +6632,7 @@ __metadata: resolution: "@storybook/addon-storyshots-puppeteer@workspace:addons/storyshots/storyshots-puppeteer" dependencies: "@axe-core/puppeteer": ^4.2.0 + "@storybook/csf": 0.0.2--canary.49.258942b.0 "@storybook/node-logger": 7.0.0-alpha.41 "@storybook/types": 7.0.0-alpha.41 "@types/jest-image-snapshot": ^4.1.3 From 636912879227d6ee07637e34d9a3205beb50b7f4 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sat, 22 Oct 2022 17:41:23 +0200 Subject: [PATCH 26/38] a bit of linting left --- code/lib/core-client/src/preview/start.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/lib/core-client/src/preview/start.test.ts b/code/lib/core-client/src/preview/start.test.ts index 0d7c090f25e3..a9f5fc72e62d 100644 --- a/code/lib/core-client/src/preview/start.test.ts +++ b/code/lib/core-client/src/preview/start.test.ts @@ -1,5 +1,5 @@ /* global window */ -import Events, { SET_STORIES, STORY_RENDERED } from '@storybook/core-events'; +import { SET_STORIES, STORY_RENDERED } from '@storybook/core-events'; import { waitForRender, From d0276140f510c42b301a77634426900c955e6f39 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sat, 22 Oct 2022 19:07:50 +0200 Subject: [PATCH 27/38] fix things --- code/addons/toolbars/src/types.ts | 7 ++++--- code/lib/router/src/router.tsx | 2 +- code/lib/types/src/modules/csf.ts | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/code/addons/toolbars/src/types.ts b/code/addons/toolbars/src/types.ts index 4b6d18aa54d3..f6af2f259d04 100644 --- a/code/addons/toolbars/src/types.ts +++ b/code/addons/toolbars/src/types.ts @@ -1,5 +1,6 @@ +/* eslint-disable camelcase */ import type { IconsProps } from '@storybook/components'; -import type { ArgType } from '@storybook/api'; +import type { API_ArgType } from '@storybook/types'; export type ToolbarShortcutType = 'next' | 'previous' | 'reset'; @@ -37,7 +38,7 @@ export interface NormalizedToolbarConfig { dynamicTitle?: boolean; } -export type NormalizedToolbarArgType = ArgType & { +export type NormalizedToolbarArgType = API_ArgType & { toolbar: NormalizedToolbarConfig; }; @@ -45,7 +46,7 @@ export type ToolbarConfig = NormalizedToolbarConfig & { items: string[] | ToolbarItem[]; }; -export type ToolbarArgType = ArgType & { +export type ToolbarArgType = API_ArgType & { toolbar: ToolbarConfig; }; diff --git a/code/lib/router/src/router.tsx b/code/lib/router/src/router.tsx index 031234dafe7f..0d45ad95d75c 100644 --- a/code/lib/router/src/router.tsx +++ b/code/lib/router/src/router.tsx @@ -13,7 +13,7 @@ interface Other extends StoryData { } export type RouterData = { - location: Partial; + location: Partial; navigate: ReturnType; } & Other; diff --git a/code/lib/types/src/modules/csf.ts b/code/lib/types/src/modules/csf.ts index f62b833cf9ba..fd69b3125efa 100644 --- a/code/lib/types/src/modules/csf.ts +++ b/code/lib/types/src/modules/csf.ts @@ -1,6 +1,6 @@ /* eslint-disable camelcase */ import type { - ViewMode, + ViewMode as ViewModeFromCSF, AnnotatedStoryFn, AnyFramework, ArgTypes, @@ -57,7 +57,6 @@ import type { } from '@storybook/csf'; export { - ViewMode, AnnotatedStoryFn, AnyFramework, ArgTypes, @@ -126,3 +125,5 @@ export interface CSF_Story { name: string; parameters: Record; } + +export type ViewMode = ViewModeFromCSF | 'story' | 'info' | 'settings' | string | undefined; From 6ba53de7d882355efda272ebb96eedb71bb8c6bf Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sat, 22 Oct 2022 19:42:50 +0200 Subject: [PATCH 28/38] fix lockfile --- code/yarn.lock | 780 ++++++++++++++++++++++++------------------------- 1 file changed, 387 insertions(+), 393 deletions(-) diff --git a/code/yarn.lock b/code/yarn.lock index d41ee4bbf199..76a1da275d57 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -441,25 +441,25 @@ __metadata: linkType: hard "@babel/core@npm:^7.1.0, @babel/core@npm:^7.11.5, @babel/core@npm:^7.11.6, @babel/core@npm:^7.12.0, @babel/core@npm:^7.12.10, @babel/core@npm:^7.12.3, @babel/core@npm:^7.12.9, @babel/core@npm:^7.13.16, @babel/core@npm:^7.17.2, @babel/core@npm:^7.17.5, @babel/core@npm:^7.18.13, @babel/core@npm:^7.3.4, @babel/core@npm:^7.7.2, @babel/core@npm:^7.7.5, @babel/core@npm:^7.8.0": - version: 7.19.3 - resolution: "@babel/core@npm:7.19.3" + version: 7.19.6 + resolution: "@babel/core@npm:7.19.6" dependencies: "@ampproject/remapping": ^2.1.0 "@babel/code-frame": ^7.18.6 - "@babel/generator": ^7.19.3 + "@babel/generator": ^7.19.6 "@babel/helper-compilation-targets": ^7.19.3 - "@babel/helper-module-transforms": ^7.19.0 - "@babel/helpers": ^7.19.0 - "@babel/parser": ^7.19.3 + "@babel/helper-module-transforms": ^7.19.6 + "@babel/helpers": ^7.19.4 + "@babel/parser": ^7.19.6 "@babel/template": ^7.18.10 - "@babel/traverse": ^7.19.3 - "@babel/types": ^7.19.3 + "@babel/traverse": ^7.19.6 + "@babel/types": ^7.19.4 convert-source-map: ^1.7.0 debug: ^4.1.0 gensync: ^1.0.0-beta.2 json5: ^2.2.1 semver: ^6.3.0 - checksum: 2ef6bc3c407f5aa868a3fdc5ec58bcaf98d073de5fff65c1b16b1133cd232f43b5a413a1356c4cdd37f477fb006ac9fc0d5fce8a0f2f4f5d881de0dd1f6b0b06 + checksum: 58a095dac601444128ca17ffa08bd08cb3ea31305f49389ff882a2df450937f6929108810e94742306f5ccb13cd113244a9012a2f50bdbd7539873d6fd767521 languageName: node linkType: hard @@ -474,14 +474,14 @@ __metadata: languageName: node linkType: hard -"@babel/generator@npm:^7.12.11, @babel/generator@npm:^7.16.8, @babel/generator@npm:^7.19.3, @babel/generator@npm:^7.19.4, @babel/generator@npm:^7.4.0, @babel/generator@npm:^7.7.2, @babel/generator@npm:^7.8.7": - version: 7.19.5 - resolution: "@babel/generator@npm:7.19.5" +"@babel/generator@npm:^7.12.11, @babel/generator@npm:^7.16.8, @babel/generator@npm:^7.19.6, @babel/generator@npm:^7.4.0, @babel/generator@npm:^7.7.2, @babel/generator@npm:^7.8.7": + version: 7.19.6 + resolution: "@babel/generator@npm:7.19.6" dependencies: "@babel/types": ^7.19.4 "@jridgewell/gen-mapping": ^0.3.2 jsesc: ^2.5.1 - checksum: e0308398b212bbe09648ede3838b9004362586195c5a476bd73adf16f5786253676345c80920aaf8491f1733214189e8b33e0de4969e3ee5b53a8cb2232107d6 + checksum: 7c28a778310b718af5889a225bb004b51c86c0ddba5397cc3b90782fb6acf386bee29d4c23faa5d0e7fa8132a652213c1e08dbf01751f5aaada6e6f01a43258e languageName: node linkType: hard @@ -625,19 +625,19 @@ __metadata: languageName: node linkType: hard -"@babel/helper-module-transforms@npm:^7.16.7, @babel/helper-module-transforms@npm:^7.18.6, @babel/helper-module-transforms@npm:^7.19.0": - version: 7.19.0 - resolution: "@babel/helper-module-transforms@npm:7.19.0" +"@babel/helper-module-transforms@npm:^7.16.7, @babel/helper-module-transforms@npm:^7.18.6, @babel/helper-module-transforms@npm:^7.19.6": + version: 7.19.6 + resolution: "@babel/helper-module-transforms@npm:7.19.6" dependencies: "@babel/helper-environment-visitor": ^7.18.9 "@babel/helper-module-imports": ^7.18.6 - "@babel/helper-simple-access": ^7.18.6 + "@babel/helper-simple-access": ^7.19.4 "@babel/helper-split-export-declaration": ^7.18.6 - "@babel/helper-validator-identifier": ^7.18.6 + "@babel/helper-validator-identifier": ^7.19.1 "@babel/template": ^7.18.10 - "@babel/traverse": ^7.19.0 - "@babel/types": ^7.19.0 - checksum: 8a36ad46a144cf779e300e4a620c46ddad27d68353769d522c220731c8f33d8823ae9a6c9e207b330ecb1d044180ad8f7c129f1191ccf09fae978cddcb31061b + "@babel/traverse": ^7.19.6 + "@babel/types": ^7.19.4 + checksum: c6d5fd5cb299591b005144ee2e142d6bba06f8c2a87c9b19e2e9a5189f39a59e313266a6ca0213cdd185e4757c47accc2f3e346b5004da0a69da87e214bd7f09 languageName: node linkType: hard @@ -684,7 +684,7 @@ __metadata: languageName: node linkType: hard -"@babel/helper-simple-access@npm:^7.18.6": +"@babel/helper-simple-access@npm:^7.19.4": version: 7.19.4 resolution: "@babel/helper-simple-access@npm:7.19.4" dependencies: @@ -744,7 +744,7 @@ __metadata: languageName: node linkType: hard -"@babel/helpers@npm:^7.16.7, @babel/helpers@npm:^7.19.0, @babel/helpers@npm:^7.8.4": +"@babel/helpers@npm:^7.16.7, @babel/helpers@npm:^7.19.4, @babel/helpers@npm:^7.8.4": version: 7.19.4 resolution: "@babel/helpers@npm:7.19.4" dependencies: @@ -766,12 +766,12 @@ __metadata: languageName: node linkType: hard -"@babel/parser@npm:^7.1.0, @babel/parser@npm:^7.11.5, @babel/parser@npm:^7.12.11, @babel/parser@npm:^7.13.12, @babel/parser@npm:^7.13.16, @babel/parser@npm:^7.14.7, @babel/parser@npm:^7.16.12, @babel/parser@npm:^7.16.4, @babel/parser@npm:^7.16.7, @babel/parser@npm:^7.18.10, @babel/parser@npm:^7.18.4, @babel/parser@npm:^7.19.3, @babel/parser@npm:^7.19.4, @babel/parser@npm:^7.4.3, @babel/parser@npm:^7.4.5, @babel/parser@npm:^7.6.0, @babel/parser@npm:^7.7.0, @babel/parser@npm:^7.8.6, @babel/parser@npm:^7.8.7, @babel/parser@npm:^7.9.6": - version: 7.19.4 - resolution: "@babel/parser@npm:7.19.4" +"@babel/parser@npm:^7.1.0, @babel/parser@npm:^7.11.5, @babel/parser@npm:^7.12.11, @babel/parser@npm:^7.13.12, @babel/parser@npm:^7.13.16, @babel/parser@npm:^7.14.7, @babel/parser@npm:^7.16.12, @babel/parser@npm:^7.16.4, @babel/parser@npm:^7.16.7, @babel/parser@npm:^7.18.10, @babel/parser@npm:^7.18.4, @babel/parser@npm:^7.19.6, @babel/parser@npm:^7.4.3, @babel/parser@npm:^7.4.5, @babel/parser@npm:^7.6.0, @babel/parser@npm:^7.7.0, @babel/parser@npm:^7.8.6, @babel/parser@npm:^7.8.7, @babel/parser@npm:^7.9.6": + version: 7.19.6 + resolution: "@babel/parser@npm:7.19.6" bin: parser: ./bin/babel-parser.js - checksum: 51a69ca46dcd4d303df3466bc0ac3da421fdbf3cc62c1cd59d4776561334fe048e2b2445356074fdba54905cad6389feea650c6cc69131c77e93faeae141bb78 + checksum: 1cebcfd242bf424adea11c364f54c4339796291b3b124f20f08dca800ece217588db09f23202f520c671e3ff9a9f97ca645c4f98df0127149d0c60331c7d3e39 languageName: node linkType: hard @@ -852,8 +852,8 @@ __metadata: linkType: hard "@babel/plugin-proposal-decorators@npm:^7.13.5, @babel/plugin-proposal-decorators@npm:^7.17.2": - version: 7.19.3 - resolution: "@babel/plugin-proposal-decorators@npm:7.19.3" + version: 7.19.6 + resolution: "@babel/plugin-proposal-decorators@npm:7.19.6" dependencies: "@babel/helper-create-class-features-plugin": ^7.19.0 "@babel/helper-plugin-utils": ^7.19.0 @@ -862,7 +862,7 @@ __metadata: "@babel/plugin-syntax-decorators": ^7.19.0 peerDependencies: "@babel/core": ^7.0.0-0 - checksum: b51493858cf9be2a39fc9e680c058e1cc1c02962f454cbeb9ac371265bed899d09edfa967ffdefb19c57b83b69c5650d5367ff4dc284cb2f9cbf0a0fb9a257fc + checksum: 41390c8d0fe87072915eac1687bab638be8430b88494b2f40d1cf2ee2a64c08777b1f18949bb8e8dc76d341e79f0d26eca3ad8bd5c751ce02f9a9955bafb1a82 languageName: node linkType: hard @@ -1464,44 +1464,41 @@ __metadata: linkType: hard "@babel/plugin-transform-modules-amd@npm:^7.12.1, @babel/plugin-transform-modules-amd@npm:^7.13.0, @babel/plugin-transform-modules-amd@npm:^7.16.7, @babel/plugin-transform-modules-amd@npm:^7.18.6": - version: 7.18.6 - resolution: "@babel/plugin-transform-modules-amd@npm:7.18.6" + version: 7.19.6 + resolution: "@babel/plugin-transform-modules-amd@npm:7.19.6" dependencies: - "@babel/helper-module-transforms": ^7.18.6 - "@babel/helper-plugin-utils": ^7.18.6 - babel-plugin-dynamic-import-node: ^2.3.3 + "@babel/helper-module-transforms": ^7.19.6 + "@babel/helper-plugin-utils": ^7.19.0 peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 1391af0dd70959c1a1acb61cd830e18603c06dcc47af811ce06fc321da504993ff72c582e26facef8b55524215ae5ee766ea330498361adc5ad5236835a47bfc + checksum: 937c3aff2b5fdad44294480ed97208d9799df7f6ef5c0e5d3b01eea387fae9dbdcca5241db359c9c0050917a1a4ebd00cfd0220dffe7823f17ae1c41e960cb88 languageName: node linkType: hard "@babel/plugin-transform-modules-commonjs@npm:^7.13.8, @babel/plugin-transform-modules-commonjs@npm:^7.16.8, @babel/plugin-transform-modules-commonjs@npm:^7.18.6, @babel/plugin-transform-modules-commonjs@npm:^7.2.0": - version: 7.18.6 - resolution: "@babel/plugin-transform-modules-commonjs@npm:7.18.6" + version: 7.19.6 + resolution: "@babel/plugin-transform-modules-commonjs@npm:7.19.6" dependencies: - "@babel/helper-module-transforms": ^7.18.6 - "@babel/helper-plugin-utils": ^7.18.6 - "@babel/helper-simple-access": ^7.18.6 - babel-plugin-dynamic-import-node: ^2.3.3 + "@babel/helper-module-transforms": ^7.19.6 + "@babel/helper-plugin-utils": ^7.19.0 + "@babel/helper-simple-access": ^7.19.4 peerDependencies: "@babel/core": ^7.0.0-0 - checksum: de3850b3e6a6b6ab206414897f451de332ca29713e8083d1d58ae0072516428fb138f418cae806546aef7c5e130a5cecd4bd1d938c93f20fe8c6312ef6546327 + checksum: a5c504eb3f65ee805d27ab64fb399e3628f1e1e09e61a7764708bf2525a97503f3cd527b71f2b46cf26a18a9ff95fa0507f664600ed68881a58c8e8e6ed9a7d6 languageName: node linkType: hard "@babel/plugin-transform-modules-systemjs@npm:^7.16.7, @babel/plugin-transform-modules-systemjs@npm:^7.19.0": - version: 7.19.0 - resolution: "@babel/plugin-transform-modules-systemjs@npm:7.19.0" + version: 7.19.6 + resolution: "@babel/plugin-transform-modules-systemjs@npm:7.19.6" dependencies: "@babel/helper-hoist-variables": ^7.18.6 - "@babel/helper-module-transforms": ^7.19.0 + "@babel/helper-module-transforms": ^7.19.6 "@babel/helper-plugin-utils": ^7.19.0 - "@babel/helper-validator-identifier": ^7.18.6 - babel-plugin-dynamic-import-node: ^2.3.3 + "@babel/helper-validator-identifier": ^7.19.1 peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 45e3529ddb53c222f806d225dac725366f2c80863b2f19ee2d794b71cd8b799e62743dffa241593848b7333f36ede712872a4997bf9d803d9e27e8a5f259573e + checksum: 0f05058170f1d2027bda95ae8d57b021698f4d7f33df859c95db072ae80941079c5049ac12bde3bc87311436e9451e5edca8205754e9a4e5b54bd6e4f3ecf2ed languageName: node linkType: hard @@ -1619,13 +1616,13 @@ __metadata: linkType: hard "@babel/plugin-transform-react-jsx-source@npm:^7.18.6": - version: 7.18.6 - resolution: "@babel/plugin-transform-react-jsx-source@npm:7.18.6" + version: 7.19.6 + resolution: "@babel/plugin-transform-react-jsx-source@npm:7.19.6" dependencies: - "@babel/helper-plugin-utils": ^7.18.6 + "@babel/helper-plugin-utils": ^7.19.0 peerDependencies: "@babel/core": ^7.0.0-0 - checksum: af95477936a29f6c8c33277d6f1c8484309f7c8ddd2cb19a8e90d0ea944eb6a988d2ba21f4b9948918aa801cd0aaddbae6cea57a076f8cae2126fd5a43dbf57a + checksum: f2e7304b9d789fdac73f21319fcae76c8cdd8e76efce34e21f67828c1bcbd3fe7ce386ca71a43b9e928365155a3f7fe6551005f19ef3fe8cba7f75f17307d2c8 languageName: node linkType: hard @@ -1696,8 +1693,8 @@ __metadata: linkType: hard "@babel/plugin-transform-runtime@npm:^7.13.9": - version: 7.19.1 - resolution: "@babel/plugin-transform-runtime@npm:7.19.1" + version: 7.19.6 + resolution: "@babel/plugin-transform-runtime@npm:7.19.6" dependencies: "@babel/helper-module-imports": ^7.18.6 "@babel/helper-plugin-utils": ^7.19.0 @@ -1707,7 +1704,7 @@ __metadata: semver: ^6.3.0 peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 6b68438aff9558d42366954882d9e0f45df0e324a69c7e36a69155335998f4edbe4752a09d3d1ab2cc4e8f97ed63ad9f9f135b90d3b679d0ef7fecfa3295af39 + checksum: 39c1a7a6421dbd00d599082b4c38ed1b3ba5844af1249d3860d7de7ce7e6451641ee0fc5b237af4a02f5cd77c7896a2b50799d0f90b1b30b6d2cd92061b2fdff languageName: node linkType: hard @@ -2067,12 +2064,12 @@ __metadata: linkType: hard "@babel/runtime-corejs3@npm:^7.10.2": - version: 7.19.4 - resolution: "@babel/runtime-corejs3@npm:7.19.4" + version: 7.19.6 + resolution: "@babel/runtime-corejs3@npm:7.19.6" dependencies: core-js-pure: ^3.25.1 regenerator-runtime: ^0.13.4 - checksum: 01b55c54c4b649d4897f873982ee0097b1f9d597b62a97491c5ca4b0e659bf9576914d00b2cd6d140f19497a8f5ace6efdb958eff123ffa499c422f338946deb + checksum: df8d369446b24bc2f6d7428963f9976b83cba0449e8906b057c1a0e5c49177cd68f6e1cbcfa9efd2f1dc70c1dd9e71bfa2458e27e3d4569ea6478c8d77643803 languageName: node linkType: hard @@ -2154,25 +2151,25 @@ __metadata: languageName: node linkType: hard -"@babel/traverse@npm:^7.1.0, @babel/traverse@npm:^7.1.6, @babel/traverse@npm:^7.12.11, @babel/traverse@npm:^7.16.10, @babel/traverse@npm:^7.19.0, @babel/traverse@npm:^7.19.1, @babel/traverse@npm:^7.19.3, @babel/traverse@npm:^7.19.4, @babel/traverse@npm:^7.4.3, @babel/traverse@npm:^7.4.5, @babel/traverse@npm:^7.7.0, @babel/traverse@npm:^7.7.2, @babel/traverse@npm:^7.8.6": - version: 7.19.4 - resolution: "@babel/traverse@npm:7.19.4" +"@babel/traverse@npm:^7.1.0, @babel/traverse@npm:^7.1.6, @babel/traverse@npm:^7.12.11, @babel/traverse@npm:^7.16.10, @babel/traverse@npm:^7.19.0, @babel/traverse@npm:^7.19.1, @babel/traverse@npm:^7.19.4, @babel/traverse@npm:^7.19.6, @babel/traverse@npm:^7.4.3, @babel/traverse@npm:^7.4.5, @babel/traverse@npm:^7.7.0, @babel/traverse@npm:^7.7.2, @babel/traverse@npm:^7.8.6": + version: 7.19.6 + resolution: "@babel/traverse@npm:7.19.6" dependencies: "@babel/code-frame": ^7.18.6 - "@babel/generator": ^7.19.4 + "@babel/generator": ^7.19.6 "@babel/helper-environment-visitor": ^7.18.9 "@babel/helper-function-name": ^7.19.0 "@babel/helper-hoist-variables": ^7.18.6 "@babel/helper-split-export-declaration": ^7.18.6 - "@babel/parser": ^7.19.4 + "@babel/parser": ^7.19.6 "@babel/types": ^7.19.4 debug: ^4.1.0 globals: ^11.1.0 - checksum: 592312804a5d4fe87a5c9c914e94c292055e67ba9fdba6b5b0b9ea1f93008a7bc3aed7e56cdd1550ca758dba8212cf96eb82990ee4c5697a3bd407203211c020 + checksum: 19fa31560fec222b7683003f75e724f77410319e6548c72fee268e17be7e481963f43b8fceb6cdd0557338e547646448f681369da07fc79d7e966485ed910fb8 languageName: node linkType: hard -"@babel/types@npm:^7.0.0, @babel/types@npm:^7.11.5, @babel/types@npm:^7.12.11, @babel/types@npm:^7.16.7, @babel/types@npm:^7.16.8, @babel/types@npm:^7.18.10, @babel/types@npm:^7.18.6, @babel/types@npm:^7.18.8, @babel/types@npm:^7.18.9, @babel/types@npm:^7.19.0, @babel/types@npm:^7.19.3, @babel/types@npm:^7.19.4, @babel/types@npm:^7.2.0, @babel/types@npm:^7.3.0, @babel/types@npm:^7.3.3, @babel/types@npm:^7.4.0, @babel/types@npm:^7.4.4, @babel/types@npm:^7.6.1, @babel/types@npm:^7.7.0, @babel/types@npm:^7.7.2, @babel/types@npm:^7.8.3, @babel/types@npm:^7.8.6, @babel/types@npm:^7.8.7, @babel/types@npm:^7.9.6": +"@babel/types@npm:^7.0.0, @babel/types@npm:^7.11.5, @babel/types@npm:^7.12.11, @babel/types@npm:^7.16.7, @babel/types@npm:^7.16.8, @babel/types@npm:^7.18.10, @babel/types@npm:^7.18.6, @babel/types@npm:^7.18.8, @babel/types@npm:^7.18.9, @babel/types@npm:^7.19.0, @babel/types@npm:^7.19.4, @babel/types@npm:^7.2.0, @babel/types@npm:^7.3.0, @babel/types@npm:^7.3.3, @babel/types@npm:^7.4.0, @babel/types@npm:^7.4.4, @babel/types@npm:^7.6.1, @babel/types@npm:^7.7.0, @babel/types@npm:^7.7.2, @babel/types@npm:^7.8.3, @babel/types@npm:^7.8.6, @babel/types@npm:^7.8.7, @babel/types@npm:^7.9.6": version: 7.19.4 resolution: "@babel/types@npm:7.19.4" dependencies: @@ -2405,19 +2402,20 @@ __metadata: linkType: hard "@digitak/esrun@npm:^3.2.2": - version: 3.2.11 - resolution: "@digitak/esrun@npm:3.2.11" + version: 3.2.13 + resolution: "@digitak/esrun@npm:3.2.13" dependencies: - "@digitak/grubber": ^3.1.1 + "@digitak/grubber": ^3.1.3 chokidar: ^3.5.1 + cuid: ^2.1.8 esbuild: ^0.14.47 bin: esrun: bin.js - checksum: ec3fa94e6d77b757b25d5f9c614c7a3e2f1145d54a73f7e4af2a8e45bda0d7bfcfa4d9d8c0b2f59ae6e1de63e42a202ecc76ae85c544ae6166235afaac922805 + checksum: 1182b449dae86449cc260998aeac12798574ccc842c6b3adb1b6a97a31e14e03cc517a9c4a089da9badb2f7a0f66468f0de625bdee5a821c6f5748084805a389 languageName: node linkType: hard -"@digitak/grubber@npm:^3.1.1": +"@digitak/grubber@npm:^3.1.3": version: 3.1.3 resolution: "@digitak/grubber@npm:3.1.3" checksum: c6d4570af921e006f7db0bab5c0f156a6238a0eda817df2029f2aade622ccc9c9923ba457a70eaa55b315c4940392a81b1af5133b3fa75c6c600f4eb25fbe70b @@ -3070,12 +3068,12 @@ __metadata: languageName: node linkType: hard -"@jest/expect-utils@npm:^29.1.2": - version: 29.1.2 - resolution: "@jest/expect-utils@npm:29.1.2" +"@jest/expect-utils@npm:^29.2.1": + version: 29.2.1 + resolution: "@jest/expect-utils@npm:29.2.1" dependencies: - jest-get-type: ^29.0.0 - checksum: b37a164336bf60fc02ed08c8ae34a62b3a171132dfe5e259ccc6a967360abeb783f830973560e11fde240e2a68f3f692b8f6114bb0e35a33ca4674ea6ec32420 + jest-get-type: ^29.2.0 + checksum: 42e47f53b9836ca9da0f4c8a09a2ac26ebe6c6e6f8126f00f04ffc77d4fc97f883b720121404058633c48169de0f7270719d8e0086292d6a7b8249c3066947ff languageName: node linkType: hard @@ -3589,9 +3587,9 @@ __metadata: languageName: node linkType: hard -"@jest/types@npm:^29.1.2": - version: 29.1.2 - resolution: "@jest/types@npm:29.1.2" +"@jest/types@npm:^29.2.1": + version: 29.2.1 + resolution: "@jest/types@npm:29.2.1" dependencies: "@jest/schemas": ^29.0.0 "@types/istanbul-lib-coverage": ^2.0.0 @@ -3599,7 +3597,7 @@ __metadata: "@types/node": "*" "@types/yargs": ^17.0.8 chalk: ^4.0.0 - checksum: 931b864bca5e7f99f86de02d6efc0ee1a86eef7fc2b6db7103f84cf8dd73278122855b0e5b964087f391169c73887a6c069aa8dbc8a722c00c5cb0f33cc42b63 + checksum: 4f3ed71cec9bc9511d2bdb3637c587269a3e0f846610bfd085db1b34ae96c37eee805100f4ec094382549802a20327e79d4fcaf91a47a9d4a7d7fb7106b7baa9 languageName: node linkType: hard @@ -3682,12 +3680,12 @@ __metadata: linkType: hard "@jridgewell/trace-mapping@npm:^0.3.12, @jridgewell/trace-mapping@npm:^0.3.13, @jridgewell/trace-mapping@npm:^0.3.14, @jridgewell/trace-mapping@npm:^0.3.7, @jridgewell/trace-mapping@npm:^0.3.8, @jridgewell/trace-mapping@npm:^0.3.9": - version: 0.3.16 - resolution: "@jridgewell/trace-mapping@npm:0.3.16" + version: 0.3.17 + resolution: "@jridgewell/trace-mapping@npm:0.3.17" dependencies: "@jridgewell/resolve-uri": 3.1.0 "@jridgewell/sourcemap-codec": 1.4.14 - checksum: e253b9b52dcf3cef7ec085e2ea9ab580aa8f9e1ad0d62ae3f60c37fbc23bdb3b5dad132c2dbe021910c002e7990385a342e5b6182a54ab5b6f90f3fcd679f909 + checksum: 40b65fcbdd7cc5a60dbe0a2780b6670ebbc1a31c96e43833e0bf2fee0773b1ba5137ab7d137b28fc3f215567bd5f9d06b7b30634ba15636c13bd8a863c20ae9a languageName: node linkType: hard @@ -4571,20 +4569,20 @@ __metadata: linkType: hard "@mdx-js/loader@npm:^2.0.0-next.9": - version: 2.1.4 - resolution: "@mdx-js/loader@npm:2.1.4" + version: 2.1.5 + resolution: "@mdx-js/loader@npm:2.1.5" dependencies: "@mdx-js/mdx": ^2.0.0 source-map: ^0.7.0 peerDependencies: webpack: ">=4" - checksum: 6fc7240799494bdc8bd9b249d3d0a43be9f7f306a5e65b1ad5fd7ae2da7228835d998b28430a20c980046a5dec216625f582f056a3159929cceb024642fe1b3a + checksum: 1198674f5efd96528cf24c2dcc9b046bfb3fb315f18bd216d520bcf3ad2673055a68bd07bde63cd613c23b11d18b14d693b408dae60bbf32142989736a7851b1 languageName: node linkType: hard "@mdx-js/mdx@npm:^2.0.0": - version: 2.1.4 - resolution: "@mdx-js/mdx@npm:2.1.4" + version: 2.1.5 + resolution: "@mdx-js/mdx@npm:2.1.5" dependencies: "@types/estree-jsx": ^1.0.0 "@types/mdx": ^2.0.0 @@ -4603,7 +4601,7 @@ __metadata: unist-util-stringify-position: ^3.0.0 unist-util-visit: ^4.0.0 vfile: ^5.0.0 - checksum: 7e6929dfd5c080e6b5ef21171117c4ade7db82a5e37a57b2eec79ce9399d8af9005f2d31a489c348f9a563874ff83e640d0523b695eb496c5e0c58505c963d32 + checksum: 364f70656038ea9f9281b867ca4ce9efa7c678621f489711cc293bdd253687704b68303101c2446b1bb6296adda99ef07f601e8278410399438ac8f1dc9311aa languageName: node linkType: hard @@ -6194,9 +6192,9 @@ __metadata: linkType: hard "@sinclair/typebox@npm:^0.24.1": - version: 0.24.44 - resolution: "@sinclair/typebox@npm:0.24.44" - checksum: 51f54cec2f94fbb26019d96d2316490bd2a0244b494ce34a7958cc68d650a47230813b9fc04549d68dd6a84ac0d0529c11cbbfaa4b3875d4b6348a7958605b7f + version: 0.24.48 + resolution: "@sinclair/typebox@npm:0.24.48" + checksum: 60cff4c2b10faf6b48c2bf43de179a07d3927c0d57e39d50cdd05e44be3c5d0156dd9f91a0c451dcb2036f117f593916f25869882b75eeb07ce679abb405a0b1 languageName: node linkType: hard @@ -9483,12 +9481,12 @@ __metadata: linkType: hard "@types/eslint@npm:*": - version: 8.4.6 - resolution: "@types/eslint@npm:8.4.6" + version: 8.4.7 + resolution: "@types/eslint@npm:8.4.7" dependencies: "@types/estree": "*" "@types/json-schema": "*" - checksum: 0f11bc8623ec4238ad999d7a1d05d57e28c962c0b127b3e632b9f9ba72dc882f45aa84191c6b4e19db65d4f31ee46841eea6b44cad91e08ff8dfb69da4ee4b88 + checksum: 8fa7cea6ec0e3a288ba5548e9d3cb8f79d2f6f9a7a176f1dd4ca92ea04de0d2a779976b2011da00dea5871183a3068849f0631f2951e80422b5feb8922935c58 languageName: node linkType: hard @@ -9698,12 +9696,12 @@ __metadata: linkType: hard "@types/jest@npm:*, @types/jest@npm:>=26.0.0": - version: 29.1.2 - resolution: "@types/jest@npm:29.1.2" + version: 29.2.0 + resolution: "@types/jest@npm:29.2.0" dependencies: expect: ^29.0.0 pretty-format: ^29.0.0 - checksum: b67a87ccdfeffe935f97958ca2f2768a7f1a60fb85e87b08d8a702c61a4e6e49cbeaf2529382c0366296d4b6cbdeadcf86bd3a02081f2ad6c35725a85b263608 + checksum: b992f309b18b919aa25a74e7d5f9ec3d4712d5a5251ec7cb4b393ac586ca675e046cbbdff6612defc1177052150dab371777a18f208b236676d2994375315049 languageName: node linkType: hard @@ -9785,9 +9783,9 @@ __metadata: linkType: hard "@types/mdx@npm:^2.0.0": - version: 2.0.2 - resolution: "@types/mdx@npm:2.0.2" - checksum: f018734c4de1386f20c95d1daeda07da072e570a6ffebd9cbd1e3f006f281acb09a11c67e8c81132ad81c9d7ff0464add08c23d22b0bf089cd89da5bde3c41ab + version: 2.0.3 + resolution: "@types/mdx@npm:2.0.3" + checksum: 8637338ca56191fa6dbf3aaa06b6468d0ad9bcd824294e41bafd53fb9ca48657ae8487a8c8146c8285c46708e1a281632efff9bec667177cacf23bf60981f5a8 languageName: node linkType: hard @@ -9860,23 +9858,16 @@ __metadata: linkType: hard "@types/node@npm:*, @types/node@npm:>= 8, @types/node@npm:>=10.0.0, @types/node@npm:^18.7.20": - version: 18.8.4 - resolution: "@types/node@npm:18.8.4" - checksum: 2dab5a821edd12c2e435c14645dc396d568090c1703d65aef2f8a2b66abf24cce8cd925ce7c645a105c505a1457722159d6248e9f69f35c0d196fa85e0a52f3c - languageName: node - linkType: hard - -"@types/node@npm:^14.14.20 || ^16.0.0": - version: 16.11.66 - resolution: "@types/node@npm:16.11.66" - checksum: 7de1769c50ccb772a2edb22a02d67359deb5b655013b60152245b5a6e4ba71c38c815775b9de3906a6e0e7c879bad50fb2415a5fc9ad096adce583665a7cea91 + version: 18.11.3 + resolution: "@types/node@npm:18.11.3" + checksum: 97da0b4e6505bf179cb0560e02d88e63681ba8d5a1105a91e2870d7ca9f15bc38728670586e96a25760f3830fa366dcb7c8a90f94eba2588ae1c62b55dad5fd6 languageName: node linkType: hard -"@types/node@npm:^16.0.0": - version: 16.11.65 - resolution: "@types/node@npm:16.11.65" - checksum: 5d66c2e0119ff194b2e196b0016d5d083fd332a114cea04822fbc22a7733b2feba0db9de380a289f457312a24b2f313396084b682d670038f5b2ced2d14fc659 +"@types/node@npm:^14.14.20 || ^16.0.0, @types/node@npm:^16.0.0": + version: 16.11.68 + resolution: "@types/node@npm:16.11.68" + checksum: 59a13a94b08759717809571e25f7d9cf1e143401f0258cc5d16998dec10158c23463d41015249cc17e6b5bc94cb20cfec20a374b4183ac2e8e118f8da4fb3e31 languageName: node linkType: hard @@ -9996,11 +9987,11 @@ __metadata: linkType: hard "@types/puppeteer@npm:^5.4.0": - version: 5.4.6 - resolution: "@types/puppeteer@npm:5.4.6" + version: 5.4.7 + resolution: "@types/puppeteer@npm:5.4.7" dependencies: "@types/node": "*" - checksum: 573f2acf8f77cd74cf7e246092e7f7823265a353dfb5d434ffaab78d82e36419d42f408e2dbdb4d95f7f462ff7a4810b2e9ffe456a5e8b51933873b8362cbf3d + checksum: f15bccf30526151c6e42c797b844f24eb7489f0180b391857c8d6902dfa96c7f48730540229a681505ca70e9197cdac0dfbeaca0c2537526358ad5656bef703d languageName: node linkType: hard @@ -10036,7 +10027,7 @@ __metadata: languageName: node linkType: hard -"@types/react@npm:*, @types/react@npm:^16, @types/react@npm:^16.14.23": +"@types/react@npm:*, @types/react@npm:>=16, @types/react@npm:^16, @types/react@npm:^16.14.23": version: 16.14.32 resolution: "@types/react@npm:16.14.32" dependencies: @@ -10047,17 +10038,6 @@ __metadata: languageName: node linkType: hard -"@types/react@npm:>=16": - version: 18.0.21 - resolution: "@types/react@npm:18.0.21" - dependencies: - "@types/prop-types": "*" - "@types/scheduler": "*" - csstype: ^3.0.2 - checksum: cfe65f3291a62c86b342935df70943c222a4a70b3c74bfb45c1acb7bec47a583c9832b4628313baf0c312447c08baa6353a6f39313b0624b6eb7c1251cf5a0a0 - languageName: node - linkType: hard - "@types/react@npm:^17.0.39": version: 17.0.50 resolution: "@types/react@npm:17.0.50" @@ -10102,7 +10082,7 @@ __metadata: languageName: node linkType: hard -"@types/semver@npm:^7.3.4": +"@types/semver@npm:^7.3.12, @types/semver@npm:^7.3.4": version: 7.3.12 resolution: "@types/semver@npm:7.3.12" checksum: bd76432b8f58f6d853d0aa938377d7da623b21ae477797940cc84445203669b7acea042c66336976db3c26a7c27e8afc71707fec01ec1d83d5e4d191ea008182 @@ -10245,11 +10225,11 @@ __metadata: linkType: hard "@types/uglify-js@npm:*": - version: 3.17.0 - resolution: "@types/uglify-js@npm:3.17.0" + version: 3.17.1 + resolution: "@types/uglify-js@npm:3.17.1" dependencies: source-map: ^0.6.1 - checksum: ee6d4a8ff6b1dcc080638c0380f54fccd00fd577100a37375b7f365bc78c2f328564132abba494963bcce11d6a6a2b54c2cdb3eb31b18556d26cafa9eb223fd8 + checksum: c19a44017a901ab15f862e6645023bf96ffb7502b7305a15ee811667693ec66a997a42d5d0ba67814de537b562dafd26230142e26c9bb9f840ee8bb7f798cbcc languageName: node linkType: hard @@ -10332,8 +10312,8 @@ __metadata: linkType: hard "@types/webpack@npm:^4": - version: 4.41.32 - resolution: "@types/webpack@npm:4.41.32" + version: 4.41.33 + resolution: "@types/webpack@npm:4.41.33" dependencies: "@types/node": "*" "@types/tapable": ^1 @@ -10341,7 +10321,7 @@ __metadata: "@types/webpack-sources": "*" anymatch: ^3.0.0 source-map: ^0.6.0 - checksum: 7ebb64fe22eb436b42a89761b1bd67998769dfe26a6f371ac3733859414cea2f4cc743121f2dce638a280053fbd478747c9c15e8fa22644788cdc002e5a567f8 + checksum: dc6db66fa84664d8fab7ea79bd2482ea1c4500b09ed6939258e205548501b8d29c06b0fe5e869c4b59f74acf884c61a391875dadb9f7a91c8cd10c3841143729 languageName: node linkType: hard @@ -10414,12 +10394,12 @@ __metadata: linkType: hard "@typescript-eslint/eslint-plugin@npm:^5.15.0": - version: 5.40.0 - resolution: "@typescript-eslint/eslint-plugin@npm:5.40.0" + version: 5.40.1 + resolution: "@typescript-eslint/eslint-plugin@npm:5.40.1" dependencies: - "@typescript-eslint/scope-manager": 5.40.0 - "@typescript-eslint/type-utils": 5.40.0 - "@typescript-eslint/utils": 5.40.0 + "@typescript-eslint/scope-manager": 5.40.1 + "@typescript-eslint/type-utils": 5.40.1 + "@typescript-eslint/utils": 5.40.1 debug: ^4.3.4 ignore: ^5.2.0 regexpp: ^3.2.0 @@ -10431,7 +10411,7 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: 51e92fe54b6dcdc5a06fb355c0f33ba9d701fe9afed153e5fc07d0161273fa7aec5005d7c38da9cd59ba54019c8738e020716cd03c55527504ad596c4ffbbdb0 + checksum: d89f18a56ff7e9598c6ac68b7c91eb75331e1957971438a04c4cc0c600af273a5da06f4aa0f543925a209a6dd119ddc3e2e6523c1465734d67b12dfe097e9b56 languageName: node linkType: hard @@ -10452,19 +10432,19 @@ __metadata: linkType: hard "@typescript-eslint/parser@npm:^5.15.0": - version: 5.40.0 - resolution: "@typescript-eslint/parser@npm:5.40.0" + version: 5.40.1 + resolution: "@typescript-eslint/parser@npm:5.40.1" dependencies: - "@typescript-eslint/scope-manager": 5.40.0 - "@typescript-eslint/types": 5.40.0 - "@typescript-eslint/typescript-estree": 5.40.0 + "@typescript-eslint/scope-manager": 5.40.1 + "@typescript-eslint/types": 5.40.1 + "@typescript-eslint/typescript-estree": 5.40.1 debug: ^4.3.4 peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 peerDependenciesMeta: typescript: optional: true - checksum: aecb9ff21e17c3d940c9ede426d177ae0ef41ff133b5bb2b5b2c39a3773a35fcf7aa7729ef7081d31fce2c8cffa75c3615ebf49bc45042b69a1754c263315e03 + checksum: abe851a89ed1619b3bfb37d7e666adf3f8fe3027a6aa8a20b1f88282e759dd5cb2c478971ca4132409084c568ab1b9ce9c3fea8aed6a46393445d0e981611417 languageName: node linkType: hard @@ -10478,22 +10458,22 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/scope-manager@npm:5.40.0": - version: 5.40.0 - resolution: "@typescript-eslint/scope-manager@npm:5.40.0" +"@typescript-eslint/scope-manager@npm:5.40.1": + version: 5.40.1 + resolution: "@typescript-eslint/scope-manager@npm:5.40.1" dependencies: - "@typescript-eslint/types": 5.40.0 - "@typescript-eslint/visitor-keys": 5.40.0 - checksum: 0a27270c7f8174b0173c3200b7019d07d1bb7d37dec7f94e417c25a994a0bd646160c204c2ce647f74df0ecdf33bacb73f9e0e41560777d3d51ddb422cdf3938 + "@typescript-eslint/types": 5.40.1 + "@typescript-eslint/visitor-keys": 5.40.1 + checksum: 6dececfc112ab908f12e8fae728da043b148d8ed6d64e108f37f07ed314663c240808647469054bfaf4d8b2fae91830a97462c439f61c3b6bfff8d6e018ae763 languageName: node linkType: hard -"@typescript-eslint/type-utils@npm:5.40.0": - version: 5.40.0 - resolution: "@typescript-eslint/type-utils@npm:5.40.0" +"@typescript-eslint/type-utils@npm:5.40.1": + version: 5.40.1 + resolution: "@typescript-eslint/type-utils@npm:5.40.1" dependencies: - "@typescript-eslint/typescript-estree": 5.40.0 - "@typescript-eslint/utils": 5.40.0 + "@typescript-eslint/typescript-estree": 5.40.1 + "@typescript-eslint/utils": 5.40.1 debug: ^4.3.4 tsutils: ^3.21.0 peerDependencies: @@ -10501,7 +10481,7 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: ec9350d7f2c55d7307e7f90de967ffe478c47e891f1d022173d2681b792f5a45f1f2f8cbb283a867c859a19f9c592b0ae764b46545b5d7865c78ce13d8782d38 + checksum: 0e060303e0eda941e1b0436a3302803588e8cda6d57eb46463dd82cfd5f969873cebdb45874ac3a1e3140c11bca7ab2812b5e2766a2d75114f148f9dc5d30838 languageName: node linkType: hard @@ -10512,10 +10492,10 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/types@npm:5.40.0": - version: 5.40.0 - resolution: "@typescript-eslint/types@npm:5.40.0" - checksum: d9f328c559fe2b66c949ee0614a51b9be0d9afd688487cd712dc9f23b92aeb00dae5163336f3568b5e1e2644d539bd1586558bf8a08932dfd21cc169c6658d57 +"@typescript-eslint/types@npm:5.40.1": + version: 5.40.1 + resolution: "@typescript-eslint/types@npm:5.40.1" + checksum: ad3d54291b43689d3ef573d1574106a8097407e6d89d74f076337c86ae3ee319c27e2466d5d99859abd6c4f1c96b0ae34e308464a1f76df22e0fdbeab6fd4d79 languageName: node linkType: hard @@ -10537,12 +10517,12 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/typescript-estree@npm:5.40.0": - version: 5.40.0 - resolution: "@typescript-eslint/typescript-estree@npm:5.40.0" +"@typescript-eslint/typescript-estree@npm:5.40.1": + version: 5.40.1 + resolution: "@typescript-eslint/typescript-estree@npm:5.40.1" dependencies: - "@typescript-eslint/types": 5.40.0 - "@typescript-eslint/visitor-keys": 5.40.0 + "@typescript-eslint/types": 5.40.1 + "@typescript-eslint/visitor-keys": 5.40.1 debug: ^4.3.4 globby: ^11.1.0 is-glob: ^4.0.3 @@ -10551,24 +10531,25 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: a89d168729146ea5d07f451ad95368299744fbc6c2e640ad23a7b8a55ab8acc8fda0c70b5cce808fecd566e93dc7ed0c14c103cfc2a471171cde6f9f9b9a38b2 + checksum: 6c6cf712eebc80d2f6c48916009d7fad28f10d8bbe455e2190ab9b866e7aa74c48fab211151e8d11757a8aac62bafd7ee39ce8e69ddec8ad754e62bd1e0e79b1 languageName: node linkType: hard -"@typescript-eslint/utils@npm:5.40.0": - version: 5.40.0 - resolution: "@typescript-eslint/utils@npm:5.40.0" +"@typescript-eslint/utils@npm:5.40.1": + version: 5.40.1 + resolution: "@typescript-eslint/utils@npm:5.40.1" dependencies: "@types/json-schema": ^7.0.9 - "@typescript-eslint/scope-manager": 5.40.0 - "@typescript-eslint/types": 5.40.0 - "@typescript-eslint/typescript-estree": 5.40.0 + "@types/semver": ^7.3.12 + "@typescript-eslint/scope-manager": 5.40.1 + "@typescript-eslint/types": 5.40.1 + "@typescript-eslint/typescript-estree": 5.40.1 eslint-scope: ^5.1.1 eslint-utils: ^3.0.0 semver: ^7.3.7 peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 - checksum: ff374e26b4404ee962e85464c21040f6ebb52b650daf15f901b0ed3d9581b1611bb54b327d341faee11f07611ba6285425190fe2ad45d2764e44cbaffb96ac42 + checksum: 1c74083cf8696c2bc703c5465de7df42feeb2f376c6fc5062962bebac04f80075655ab2cddef3580a535253156e3df495e193e9acd77bf799ac295346d1c092c languageName: node linkType: hard @@ -10582,13 +10563,13 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/visitor-keys@npm:5.40.0": - version: 5.40.0 - resolution: "@typescript-eslint/visitor-keys@npm:5.40.0" +"@typescript-eslint/visitor-keys@npm:5.40.1": + version: 5.40.1 + resolution: "@typescript-eslint/visitor-keys@npm:5.40.1" dependencies: - "@typescript-eslint/types": 5.40.0 + "@typescript-eslint/types": 5.40.1 eslint-visitor-keys: ^3.3.0 - checksum: c973fc9429fe2aeb375821645d2bb5439f80ed2e77ff89def205aba272343ed3c7b18ee0a4e718f5e753f972d0718c6c8facb3b177fdfb5b5f3be3998f9299d4 + checksum: a1be113da3d85b02c2635ecb9189a057b4039820eff2e2fc4c0aed3f1fb86afdfe61cc0892b6e231cbfd522ae76f1d0a1380b27ffcf05e7d670f517b3ded589c languageName: node linkType: hard @@ -10691,15 +10672,15 @@ __metadata: languageName: node linkType: hard -"@vue/compiler-core@npm:3.2.40": - version: 3.2.40 - resolution: "@vue/compiler-core@npm:3.2.40" +"@vue/compiler-core@npm:3.2.41": + version: 3.2.41 + resolution: "@vue/compiler-core@npm:3.2.41" dependencies: "@babel/parser": ^7.16.4 - "@vue/shared": 3.2.40 + "@vue/shared": 3.2.41 estree-walker: ^2.0.2 source-map: ^0.6.1 - checksum: bf4747135aa27952aa526ae0ed1e93a028d07701e9920d76586f649bf34b49e770cf46aad6b2818be5fd7190e8ea3dfc871db93c64ebd25eadbe796019ebdc75 + checksum: 9f1023c2f0e8834a8056f5d0a4ac5d751b351d901e8cd03163aca10e317b08c599d326ef5de70a3d2ba1c7ee333e7a2289fc72ce4f6ac0496e750b044689f803 languageName: node linkType: hard @@ -10713,24 +10694,24 @@ __metadata: languageName: node linkType: hard -"@vue/compiler-dom@npm:3.2.40, @vue/compiler-dom@npm:^3.2.0": - version: 3.2.40 - resolution: "@vue/compiler-dom@npm:3.2.40" +"@vue/compiler-dom@npm:3.2.41, @vue/compiler-dom@npm:^3.2.0": + version: 3.2.41 + resolution: "@vue/compiler-dom@npm:3.2.41" dependencies: - "@vue/compiler-core": 3.2.40 - "@vue/shared": 3.2.40 - checksum: e6c867509f5504ad2568c381dc79f79b81c90de8a8905c4fb9149ef7b69e307a67b085be8b73178b850475c6ee3967fd0e066edd2775253f05e2d2d6028d3d05 + "@vue/compiler-core": 3.2.41 + "@vue/shared": 3.2.41 + checksum: 5dbbd925d4603668f5edcb134c8e8718e22738b7890e1cd6f2e8621aabf42a96df2f851f722f1176ca1744345fc74000c941b7cf4dc323dbbcd70da87ccdf378 languageName: node linkType: hard -"@vue/compiler-sfc@npm:2.7.10": - version: 2.7.10 - resolution: "@vue/compiler-sfc@npm:2.7.10" +"@vue/compiler-sfc@npm:2.7.13": + version: 2.7.13 + resolution: "@vue/compiler-sfc@npm:2.7.13" dependencies: "@babel/parser": ^7.18.4 postcss: ^8.4.14 source-map: ^0.6.1 - checksum: 54118cc771e18ae2804aa39c2bcca889f7758bfb85392d96a9b94a494a3b6c12fc00984eb0ae8ef861dcedf6481e0933dd9774211ef9c2579fe7a7e7ffe97876 + checksum: 3a55e888b7b0b998cdfac6f000f16214efc5a159f41642a76c4de1778f3f8fbafbc3447d2ad78b09c3b90615b23108675119d4359372856c5a51e9169a797da9 languageName: node linkType: hard @@ -10760,21 +10741,21 @@ __metadata: languageName: node linkType: hard -"@vue/compiler-sfc@npm:3.2.40, @vue/compiler-sfc@npm:^3.2.0, @vue/compiler-sfc@npm:^3.2.33": - version: 3.2.40 - resolution: "@vue/compiler-sfc@npm:3.2.40" +"@vue/compiler-sfc@npm:3.2.41, @vue/compiler-sfc@npm:^3.2.0, @vue/compiler-sfc@npm:^3.2.33": + version: 3.2.41 + resolution: "@vue/compiler-sfc@npm:3.2.41" dependencies: "@babel/parser": ^7.16.4 - "@vue/compiler-core": 3.2.40 - "@vue/compiler-dom": 3.2.40 - "@vue/compiler-ssr": 3.2.40 - "@vue/reactivity-transform": 3.2.40 - "@vue/shared": 3.2.40 + "@vue/compiler-core": 3.2.41 + "@vue/compiler-dom": 3.2.41 + "@vue/compiler-ssr": 3.2.41 + "@vue/reactivity-transform": 3.2.41 + "@vue/shared": 3.2.41 estree-walker: ^2.0.2 magic-string: ^0.25.7 postcss: ^8.1.10 source-map: ^0.6.1 - checksum: 7670799d830d4e23f02e6098fc4e69ee69cfb12a5ee7deec1280c1d8501c3c1994c85abb866f2ad09d29d12c9340d960ee3a034d6209e5d4d7ef0aea4dc8110c + checksum: 327fb7acff404ac007c8eabefe485efb4d070e347bffca2c170232f502021fac01fabeda5f4f91a7b0b175b48cef184e053da9a2ef46b7ab188b8383bef188cb languageName: node linkType: hard @@ -10788,13 +10769,13 @@ __metadata: languageName: node linkType: hard -"@vue/compiler-ssr@npm:3.2.40": - version: 3.2.40 - resolution: "@vue/compiler-ssr@npm:3.2.40" +"@vue/compiler-ssr@npm:3.2.41": + version: 3.2.41 + resolution: "@vue/compiler-ssr@npm:3.2.41" dependencies: - "@vue/compiler-dom": 3.2.40 - "@vue/shared": 3.2.40 - checksum: 3aaa309590114b3a22d369c74efce1e29e2b80a9fb7ec045982ac876ef98597ba3bf36c9be556ae91d473c590ee36e0c8fda9c8874f05b06739e3540665d5633 + "@vue/compiler-dom": 3.2.41 + "@vue/shared": 3.2.41 + checksum: 508361b2799097d86abd740548eabf7a20f9a6e1af29cda23dad07ed0b7d72569371492619f80ba2283c3e87c66016985a531cf2110742dabafe5566ca22e6eb languageName: node linkType: hard @@ -10818,16 +10799,16 @@ __metadata: languageName: node linkType: hard -"@vue/reactivity-transform@npm:3.2.40": - version: 3.2.40 - resolution: "@vue/reactivity-transform@npm:3.2.40" +"@vue/reactivity-transform@npm:3.2.41": + version: 3.2.41 + resolution: "@vue/reactivity-transform@npm:3.2.41" dependencies: "@babel/parser": ^7.16.4 - "@vue/compiler-core": 3.2.40 - "@vue/shared": 3.2.40 + "@vue/compiler-core": 3.2.41 + "@vue/shared": 3.2.41 estree-walker: ^2.0.2 magic-string: ^0.25.7 - checksum: 7005932064e56030d7e5d4f5648cf0212c76f7b33dc2720b58cb30b89c80ee5aae6485c5b9326ddb72f2c3c94e7bb87bce646ec3c9a53544ab6cc1c8e9b2242d + checksum: 8f4350efa220ed3ba8f0c4721a54ae4a2c043a8cff2d8d7227525df59f09145bb76a842f30fd3b0684c083b3e776653b464d737c7c53e43ce0739ac3d958a24a languageName: node linkType: hard @@ -10840,12 +10821,12 @@ __metadata: languageName: node linkType: hard -"@vue/reactivity@npm:3.2.40": - version: 3.2.40 - resolution: "@vue/reactivity@npm:3.2.40" +"@vue/reactivity@npm:3.2.41": + version: 3.2.41 + resolution: "@vue/reactivity@npm:3.2.41" dependencies: - "@vue/shared": 3.2.40 - checksum: f30cb2dd5533ca7007292ef7d0cb42bc47ee83316cdec15e014957e663302688611654828968f42b9f11349b5e133c17b5f5f77db54fe90dae28eff855180f1a + "@vue/shared": 3.2.41 + checksum: f76b7e3f12c441ff018ea1cb8c080365d135d87ddc075a10c87ea440a2c95e5d5ac04bb83dda0ce1f498fb390afff5d3d0c06d0a0fb46ca535df70c66dc3be90 languageName: node linkType: hard @@ -10859,13 +10840,13 @@ __metadata: languageName: node linkType: hard -"@vue/runtime-core@npm:3.2.40": - version: 3.2.40 - resolution: "@vue/runtime-core@npm:3.2.40" +"@vue/runtime-core@npm:3.2.41": + version: 3.2.41 + resolution: "@vue/runtime-core@npm:3.2.41" dependencies: - "@vue/reactivity": 3.2.40 - "@vue/shared": 3.2.40 - checksum: f167fe91d081c8fbf45f4e9e08d2fe225e91f8d07c88609e4426b4a3721e44a2a29051eb76199fde082327bca0264286a5c67e2826c7b8ebd2243656c41a2a6b + "@vue/reactivity": 3.2.41 + "@vue/shared": 3.2.41 + checksum: 9c21632c5a3330283649a9175ae03cebe27776a7615d10b9e8f2a98e4002951a9913be7b2810623c06d6481cb56b62e2f5e6f9a5d29d79f75d66ec10b528cdc2 languageName: node linkType: hard @@ -10880,26 +10861,26 @@ __metadata: languageName: node linkType: hard -"@vue/runtime-dom@npm:3.2.40": - version: 3.2.40 - resolution: "@vue/runtime-dom@npm:3.2.40" +"@vue/runtime-dom@npm:3.2.41": + version: 3.2.41 + resolution: "@vue/runtime-dom@npm:3.2.41" dependencies: - "@vue/runtime-core": 3.2.40 - "@vue/shared": 3.2.40 + "@vue/runtime-core": 3.2.41 + "@vue/shared": 3.2.41 csstype: ^2.6.8 - checksum: 797dbf1d095db0a036f38493af633946ad195870ac6e72abff84389b8a87523758ada1859dc7d562df3fd267f6c62774f837476d6c679d3086eaf09c501749c0 + checksum: 744d50eb98b5a00b31ef6c318a04b9d9786f35d9f255689aba7c15e7be927c14f4d4379b704cde97f0ba467b3f36c46efcc7d0b119c9bde3419a966a21081f78 languageName: node linkType: hard -"@vue/server-renderer@npm:3.2.40": - version: 3.2.40 - resolution: "@vue/server-renderer@npm:3.2.40" +"@vue/server-renderer@npm:3.2.41": + version: 3.2.41 + resolution: "@vue/server-renderer@npm:3.2.41" dependencies: - "@vue/compiler-ssr": 3.2.40 - "@vue/shared": 3.2.40 + "@vue/compiler-ssr": 3.2.41 + "@vue/shared": 3.2.41 peerDependencies: - vue: 3.2.40 - checksum: a2b54c5e6ccba84776634f9c1cf36120584ed05f4c731e82680918ef11105be83cad206bb1d80d1c8af3b7f203337f58feed3b35018bc270f9045b7e82f6ba62 + vue: 3.2.41 + checksum: 3aa31b70e46e0171e2c07562aa09bc1e75ccc6c876c146c3d25b4674d9394de46ba9ff338105ae81d7ff679763c9ecfe48e6d7382d52de163319481132cfc55a languageName: node linkType: hard @@ -10910,10 +10891,10 @@ __metadata: languageName: node linkType: hard -"@vue/shared@npm:3.2.40": - version: 3.2.40 - resolution: "@vue/shared@npm:3.2.40" - checksum: e0a86e693fac0f3995011f4059d364581a2fdf91b4abfee1c1c40d8377fb7f054085c779b2e67dd6d7f309c3ee2596714e5f0023271dda44aca49cf72bffb8e3 +"@vue/shared@npm:3.2.41": + version: 3.2.41 + resolution: "@vue/shared@npm:3.2.41" + checksum: bc46bf36e856a10646639561b346a76594e8a1afa992e3394056a6e0b534c6c71b1330e13960ba9788bb36265a5e761ac4c562daad0d168265d496fc3e7d6575 languageName: node linkType: hard @@ -14296,9 +14277,9 @@ __metadata: linkType: hard "caniuse-lite@npm:^1.0.30001299, caniuse-lite@npm:^1.0.30001400, caniuse-lite@npm:^1.0.30001406, caniuse-lite@npm:^1.0.30001407": - version: 1.0.30001418 - resolution: "caniuse-lite@npm:1.0.30001418" - checksum: 0b7165f1ea0d232676d339af875038b75af2d025ee67f1651b46ab78db1bb12021875c3fa4e533e1fa1febf373d1858672f1038426ca4a1b240138bad3297ec5 + version: 1.0.30001423 + resolution: "caniuse-lite@npm:1.0.30001423" + checksum: ffed328e54af20d96ff46fac1889cf70f1e0be8588f7b79156e0bbc356eb8d1570f804e7ec09c9fb221c2f8c95796357cf1c93c0902466f1a82e864dc8916b87 languageName: node linkType: hard @@ -14417,9 +14398,9 @@ __metadata: linkType: hard "chalk@npm:^5.0.1": - version: 5.1.0 - resolution: "chalk@npm:5.1.0" - checksum: 070ba0563592039f199c880e50a1f95e86c54ef8a05541603e6ae2d7b98a2691ade2697992da626cc658bb81ad0a82f079e9f55353fe79f6c8fa40bd35e1e486 + version: 5.1.2 + resolution: "chalk@npm:5.1.2" + checksum: 7ce3d213b339ae54322e0b15f82967f01ed36bcd261fdf021a7dd3ebaf48f27f1d3dcc7af898acee73e19fd0caa52006325b12e229af76087ae7a87978f06751 languageName: node linkType: hard @@ -14581,8 +14562,8 @@ __metadata: linkType: hard "chromatic@npm:^6.10.2": - version: 6.10.2 - resolution: "chromatic@npm:6.10.2" + version: 6.10.5 + resolution: "chromatic@npm:6.10.5" dependencies: "@discoveryjs/json-ext": ^0.5.7 "@types/webpack-env": ^1.17.0 @@ -14590,7 +14571,7 @@ __metadata: chroma: bin/main.cjs chromatic: bin/main.cjs chromatic-cli: bin/main.cjs - checksum: 79d70518a07711736f0658baa256b9f275f8db126e639fedf4aaf3ee4582fe5b69b0292ac9b4f87731cf05acf2f2d8d341a5169e494ba5bced2acbf7b1fb778b + checksum: cc8c066708415dbb0a58af84bc51fc1a9599ff06ed9e6b9613925d5ca217d45989dbce87cd543ae0a4adc5c8f04127d4ae90c6ec4336a2c83ec4c33c4c2c9630 languageName: node linkType: hard @@ -16044,6 +16025,13 @@ __metadata: languageName: node linkType: hard +"cuid@npm:^2.1.8": + version: 2.1.8 + resolution: "cuid@npm:2.1.8" + checksum: 6514d247c6de3e5cd32f485821365f4816ee14b777841fa717d37b7a8f791f3cb268be9e37ca54b110f6f5f625e4f0af581c3226aa14f259790539ba20fdaf61 + languageName: node + linkType: hard + "currently-unhandled@npm:^0.4.1": version: 0.4.1 resolution: "currently-unhandled@npm:0.4.1" @@ -16316,9 +16304,9 @@ __metadata: linkType: hard "decimal.js@npm:^10.2.1, decimal.js@npm:^10.3.1": - version: 10.4.1 - resolution: "decimal.js@npm:10.4.1" - checksum: 7dfe188af43c50c10cea18349d0f85cf89ac2952e53b5f359f4a37606b789da54116cea0060497794df9deca8f98fd6b662562507031ade66be974d2c49898bd + version: 10.4.2 + resolution: "decimal.js@npm:10.4.2" + checksum: 2f50de33c9c9fcd4c7ffd74cd02edecadeaa4d954e14ef721ee1d381d293c9237b1a90f54198b91f06fd5d3bb8b97079bba54fbc9ccd205d9e6bc8ffa82f6202 languageName: node linkType: hard @@ -16773,10 +16761,10 @@ __metadata: languageName: node linkType: hard -"diff-sequences@npm:^29.0.0": - version: 29.0.0 - resolution: "diff-sequences@npm:29.0.0" - checksum: 345f899af91ef981c4b02adb1d41ed001eb74743120ffdb751c942b39e8cbf37ece60d7c120977ef7ce48538d60f5a63b17e7d13e6797e4c5dcd91d2fe5cd215 +"diff-sequences@npm:^29.2.0": + version: 29.2.0 + resolution: "diff-sequences@npm:29.2.0" + checksum: 4b83cda386c251f772c6983e3dfbe36d6d563c6b223e8845c98469417d2f2e35839dc4cf23dbabc3ccecaf30bf8e188481fee6f1660cb3e8fbfa9a27506790ef languageName: node linkType: hard @@ -17305,9 +17293,9 @@ __metadata: linkType: hard "electron-to-chromium@npm:^1.4.251": - version: 1.4.276 - resolution: "electron-to-chromium@npm:1.4.276" - checksum: 9e1cbae134517be9a79c127df7d7b9b87f35725c5fc55b24c41fc640d050cab81be91b63aa1d45c53f1b6258a8302e4bb393be97838924f26cf4f572e5e333c9 + version: 1.4.284 + resolution: "electron-to-chromium@npm:1.4.284" + checksum: 33a7509755efbc0e13e81cdf0486ed37ea354857213b92a987a81e229083c1b2ee5f663c1103db9e5ec142a611e0daeeee02f757f7184833866f8aecb7046c2b languageName: node linkType: hard @@ -17321,12 +17309,12 @@ __metadata: linkType: hard "ember-ajax@npm:^5.0.0": - version: 5.1.1 - resolution: "ember-ajax@npm:5.1.1" + version: 5.1.2 + resolution: "ember-ajax@npm:5.1.2" dependencies: ember-cli-babel: ^7.5.0 najax: ^1.0.7 - checksum: dbe92e684c32b98b20c1ff08d5f6df7d9639d50cb531b7004d1674d4fd357b15592ec39a6abac0aa0e2b4549b5a3b8ebaf371857931c8679e928f4156a66dcea + checksum: 2e8741f568a331ff41a262c599e11b6237b3e8af5ef8ab537f974bb83a5d4fb902fa7917cda15fe56e7bdd18e6afb566d970395c458104abd6932bd9ee147bba languageName: node linkType: hard @@ -18502,11 +18490,11 @@ __metadata: linkType: hard "esbuild-wasm@npm:>=0.13.8": - version: 0.15.10 - resolution: "esbuild-wasm@npm:0.15.10" + version: 0.15.12 + resolution: "esbuild-wasm@npm:0.15.12" bin: esbuild: bin/esbuild - checksum: e71e77dd9fe268390014ce74fb559e789948b89ac0ffd22af70f3fbbfe054f69182d62cc5c0937317c144305a7a37bef173bad4926080190d48407a24752b6fe + checksum: 112e1a35e05bcaa932b26182ffa574162ce745cc9dd6f8e6a471ea48e2841d49e18026bc32577eb1cbdf2f6ac639042a49a16c6aefc3e67cb88375c3b6e57a51 languageName: node linkType: hard @@ -18947,8 +18935,8 @@ __metadata: linkType: hard "eslint-plugin-storybook@npm:^0.6.4": - version: 0.6.4 - resolution: "eslint-plugin-storybook@npm:0.6.4" + version: 0.6.6 + resolution: "eslint-plugin-storybook@npm:0.6.6" dependencies: "@storybook/csf": ^0.0.1 "@typescript-eslint/experimental-utils": ^5.3.0 @@ -18956,7 +18944,7 @@ __metadata: ts-dedent: ^2.2.0 peerDependencies: eslint: ">=6" - checksum: c7fcdb663ae3e064b78d743b880545a7dc44d36368e72b1535706401cba65430cd41b5b7d4aa089bb6aab10357a9dcb894d4469fd1b546a043b9078587270f85 + checksum: aad2d3bda6b1a676b685029cb8ee1140bd5aeb40d29394b320175e6ebd47ce025d96990ae6bef905cf631dde181216bb9283a1ef9a483028fd8aa72d4d2b98ec languageName: node linkType: hard @@ -19518,15 +19506,15 @@ __metadata: linkType: hard "expect@npm:^29.0.0": - version: 29.1.2 - resolution: "expect@npm:29.1.2" + version: 29.2.1 + resolution: "expect@npm:29.2.1" dependencies: - "@jest/expect-utils": ^29.1.2 - jest-get-type: ^29.0.0 - jest-matcher-utils: ^29.1.2 - jest-message-util: ^29.1.2 - jest-util: ^29.1.2 - checksum: fc5110b470e1a87e8ebcd869f8b68e1feca9b5f7b20949fe1c75c5d7f833b435808dcd4db597b2af32ce232b3b9328be498b3ed30756cebcefb2f095b1d62c32 + "@jest/expect-utils": ^29.2.1 + jest-get-type: ^29.2.0 + jest-matcher-utils: ^29.2.1 + jest-message-util: ^29.2.1 + jest-util: ^29.2.1 + checksum: 4f9c0b6294ee64b9a721a3abe89328003b1cd56b41431b243ef3e191d9ea0301fcbec2763c8db3c856ffe88fceddec629016128afff476da8ad175fc61a0daef languageName: node linkType: hard @@ -20019,12 +20007,12 @@ __metadata: linkType: hard "file-system-cache@npm:^2.0.0": - version: 2.0.0 - resolution: "file-system-cache@npm:2.0.0" + version: 2.0.1 + resolution: "file-system-cache@npm:2.0.1" dependencies: fs-extra: ^10.1.0 ramda: ^0.28.0 - checksum: 8ff29a9afa9edd6d0608bd345ea0e22376ff14b6bf11406ebff47877a8081263b7c20eadeb54c7f9b03404ace5743cc61eef9d262734c3b2fdb72ff9b7a468c1 + checksum: 1efe6fdd02835d9810565ed4e5c5f2c383014d0439771779335ab4fefa4cf03f673415fe8140c40f50ca31ee135f373aefa82def079c6caaab8963a09e7fd0fd languageName: node linkType: hard @@ -20381,9 +20369,9 @@ __metadata: linkType: hard "flow-parser@npm:0.*": - version: 0.188.2 - resolution: "flow-parser@npm:0.188.2" - checksum: 1aebf747657987f976531d349e5e058cb5751dbd7d7f3465de30e09f6ca851ed29fedd430caa61f01301660c78302b8432d721de43c5ee843f2d06346cd01bc3 + version: 0.190.1 + resolution: "flow-parser@npm:0.190.1" + checksum: d6a142b2c58b82715dd00b5258717c4754cdd7aa849dbefe522947757c198a0c1ade5a0ef82aa2c06ccf4d1fe4bb9cf67330a4d61d1f50ffe2932b4be6d51ecd languageName: node linkType: hard @@ -23345,11 +23333,11 @@ __metadata: linkType: hard "is-core-module@npm:^2.5.0, is-core-module@npm:^2.8.1, is-core-module@npm:^2.9.0": - version: 2.10.0 - resolution: "is-core-module@npm:2.10.0" + version: 2.11.0 + resolution: "is-core-module@npm:2.11.0" dependencies: has: ^1.0.3 - checksum: af7c3b24cb3375688a84306dcfa71c9305fd03af6548aaeb51ed345f85abafe22e071835b3a5f4bb1e87b434404410ec31ee45749f617a7acf2a4dcb9f677ae7 + checksum: fd8f78ef4e243c295deafa809f89381d89aff5aaf38bb63266b17ee6e34b6a051baa5bdc2365456863336d56af6a59a4c1df1256b4eff7d6b4afac618586b004 languageName: node linkType: hard @@ -24409,15 +24397,15 @@ __metadata: languageName: node linkType: hard -"jest-diff@npm:^29.1.2": - version: 29.1.2 - resolution: "jest-diff@npm:29.1.2" +"jest-diff@npm:^29.2.1": + version: 29.2.1 + resolution: "jest-diff@npm:29.2.1" dependencies: chalk: ^4.0.0 - diff-sequences: ^29.0.0 - jest-get-type: ^29.0.0 - pretty-format: ^29.1.2 - checksum: 3cdde0e29bc902b977a0a176a9488d2cdb6f561c1b6011495376527cbc436510816f94986cdaeecbee4b4b20e2977f88b440897a95b418e8b027942423387956 + diff-sequences: ^29.2.0 + jest-get-type: ^29.2.0 + pretty-format: ^29.2.1 + checksum: ce76f24f1ed026cf501c920675a783356e92c5ec69795d3b505c7b2ff09aa3271111524dd24bc185178ce8d7e992f2947a2f3e932efd2bef60215f7cbf9e552e languageName: node linkType: hard @@ -24648,10 +24636,10 @@ __metadata: languageName: node linkType: hard -"jest-get-type@npm:^29.0.0": - version: 29.0.0 - resolution: "jest-get-type@npm:29.0.0" - checksum: 953a32cef3034764c0e2ac53e8192fe1fa3e5e56465086f0b57cd1a45aebbfceecca1f8cf890004be41b99fa7c4585b3c183a2dee5017c088a8a5b760dca31d0 +"jest-get-type@npm:^29.2.0": + version: 29.2.0 + resolution: "jest-get-type@npm:29.2.0" + checksum: 6466631b344ff8e9d3fa6a47bafa4fc2baf42ec8b4f5de5c99fa1edda128af869da319af4cf770662776e4ed7a3e44656eba690cf5b662c664605b0331762bc7 languageName: node linkType: hard @@ -24898,15 +24886,15 @@ __metadata: languageName: node linkType: hard -"jest-matcher-utils@npm:^29.1.2": - version: 29.1.2 - resolution: "jest-matcher-utils@npm:29.1.2" +"jest-matcher-utils@npm:^29.2.1": + version: 29.2.1 + resolution: "jest-matcher-utils@npm:29.2.1" dependencies: chalk: ^4.0.0 - jest-diff: ^29.1.2 - jest-get-type: ^29.0.0 - pretty-format: ^29.1.2 - checksum: 10ed0b787b1664a3d2f760a65beedf9f23993bfddac64b3b86e41515059f329c97396e7f4273e6c341f850d840671d89dfc976ef05cd5e91ba77f3521ab48c48 + jest-diff: ^29.2.1 + jest-get-type: ^29.2.0 + pretty-format: ^29.2.1 + checksum: 58e852454dbdb8ebb5dd26626b5962cc254091355ea11b67b8b512de3455254fd00b2d955e41b71e8e314aa3f5f5c1e4277930389dc412ad3ecbefc5be90f950 languageName: node linkType: hard @@ -24977,20 +24965,20 @@ __metadata: languageName: node linkType: hard -"jest-message-util@npm:^29.1.2": - version: 29.1.2 - resolution: "jest-message-util@npm:29.1.2" +"jest-message-util@npm:^29.2.1": + version: 29.2.1 + resolution: "jest-message-util@npm:29.2.1" dependencies: "@babel/code-frame": ^7.12.13 - "@jest/types": ^29.1.2 + "@jest/types": ^29.2.1 "@types/stack-utils": ^2.0.0 chalk: ^4.0.0 graceful-fs: ^4.2.9 micromatch: ^4.0.4 - pretty-format: ^29.1.2 + pretty-format: ^29.2.1 slash: ^3.0.0 stack-utils: ^2.0.3 - checksum: 38219d23ddef7b22fabef79aa07dd97eebaba7ca1985323c03ba2ad2d97705aea8b6046304efa85605a6e2dd42a6d8cc0faaebc304c49f491918c59cfe52d153 + checksum: 1931a6666b7e650b69f1ee702c8680e7e57becba8be0cb7ac06b35c5a12778338a6702295a39022d975c87a10cc3c7c53f4f3d76b14065ead4a0d4f01ce1f22c languageName: node linkType: hard @@ -25617,17 +25605,17 @@ __metadata: languageName: node linkType: hard -"jest-util@npm:^29.1.2": - version: 29.1.2 - resolution: "jest-util@npm:29.1.2" +"jest-util@npm:^29.2.1": + version: 29.2.1 + resolution: "jest-util@npm:29.2.1" dependencies: - "@jest/types": ^29.1.2 + "@jest/types": ^29.2.1 "@types/node": "*" chalk: ^4.0.0 ci-info: ^3.2.0 graceful-fs: ^4.2.9 picomatch: ^2.2.3 - checksum: 59e1c7bd99684e9be39a789f05f34e7c00309d7d18ea7fa52f3405b2df1a74dae7ae32293d8548ed15b4c9231a1dbd48a03cbbca56b1b71bbabcc3390fe522ff + checksum: 678ae6089b460156882c0c2f94f46dfcbf9e00d147edee0eb7101a1b38ef36c7a5e7b7c7d8d3aa089a8fa08b2930bf3392c5bb527d229b70a5fd0d48fd091be0 languageName: node linkType: hard @@ -25844,15 +25832,15 @@ __metadata: linkType: hard "joi@npm:^17.3.0": - version: 17.6.2 - resolution: "joi@npm:17.6.2" + version: 17.6.4 + resolution: "joi@npm:17.6.4" dependencies: "@hapi/hoek": ^9.0.0 "@hapi/topo": ^5.0.0 "@sideway/address": ^4.1.3 "@sideway/formula": ^3.0.0 "@sideway/pinpoint": ^2.0.0 - checksum: 6300fc478c18ef1714a44bd093d5468d7007306f345f67f2f2e352a3f429bac49a3f73f694ae8a824bd927cb342ef559492cb7d05250eb2c0038c1118f5e10bf + checksum: 187f7e807653c5802db52fc64dd25183ba55db86f97b02507abbc5dc5a4c466ee96c74c0b79b3592fe99fdf9a29b02cf55a95d8292e88a422d5ef059ff6d2673 languageName: node linkType: hard @@ -26340,9 +26328,9 @@ __metadata: linkType: hard "jsonify@npm:~0.0.0": - version: 0.0.0 - resolution: "jsonify@npm:0.0.0" - checksum: acb05782ee86a842d098e086fe07fde89c3f3b4f6c18b563b7e24ddc1e323d5c3cce10a3ed947b3b080109ad787cd370b912ba58ecca22fdb7a97d9094f95614 + version: 0.0.1 + resolution: "jsonify@npm:0.0.1" + checksum: 7f5499cdd59a0967ed35bda48b7cec43d850bbc8fb955cdd3a1717bb0efadbe300724d5646de765bb7a99fc1c3ab06eb80d93503c6faaf99b4ff50a3326692f6 languageName: node linkType: hard @@ -27178,13 +27166,13 @@ __metadata: linkType: hard "loader-utils@npm:^2.0.0": - version: 2.0.2 - resolution: "loader-utils@npm:2.0.2" + version: 2.0.3 + resolution: "loader-utils@npm:2.0.3" dependencies: big.js: ^5.2.2 emojis-list: ^3.0.0 json5: ^2.1.2 - checksum: 332ae8db3d4d3fac7e5bbed82da9230857d3f85b3ccf6d3f2e286fa2431887aa9e46965928b2c77a93f5f721cec037539c0cfc718164f0287c5c90f5dce07ad9 + checksum: 6a674996d134ebc267b0bf4b846e99b4b0d53cebc15ecc971ef2ac5977570aae3e6b7d61f4809e135dca76f5e0b29084856e8723b1599762bffd4301e4a28b95 languageName: node linkType: hard @@ -29265,9 +29253,9 @@ __metadata: linkType: hard "minimist@npm:^0.2.1": - version: 0.2.1 - resolution: "minimist@npm:0.2.1" - checksum: 4f74b3657718631fde19c305aef796bc56864374dd8f0b5f5ee3ec89f96871f7b5958cd426a6ac98e6f7541f6494b86d8bd8964cce4632f59a38020b597051a3 + version: 0.2.2 + resolution: "minimist@npm:0.2.2" + checksum: 4dbb3af457f8d4c5ca9d20a2f49a6ea8f062f8be509c2fd7989a57b3ad8274efdccbe329ab3e54ada4521582863c7d60747f17cf873376692583f114467ac671 languageName: node linkType: hard @@ -32096,13 +32084,13 @@ __metadata: linkType: hard "postcss-custom-properties@npm:^12.1.2": - version: 12.1.9 - resolution: "postcss-custom-properties@npm:12.1.9" + version: 12.1.10 + resolution: "postcss-custom-properties@npm:12.1.10" dependencies: postcss-value-parser: ^4.2.0 peerDependencies: postcss: ^8.2 - checksum: 5df43e5b3ce3e1d1eaa67e3e9d1514dfac36be557d3017f000803370cd5cc627dffb867af356da8c22c5b9774078d169ae325a0f7292f650819d1aea829b6fe4 + checksum: 567245deb152d4b390aa13b45c0801abf14a549d8c44140229dd3411ed8a7b68c9da233260dd27aef863040079ff18509bba0447fd128eaa905279d523be72d5 languageName: node linkType: hard @@ -32555,13 +32543,13 @@ __metadata: linkType: hard "postcss@npm:^8.1.10, postcss@npm:^8.2.14, postcss@npm:^8.2.15, postcss@npm:^8.3.7, postcss@npm:^8.4.14, postcss@npm:^8.4.16, postcss@npm:^8.4.7": - version: 8.4.17 - resolution: "postcss@npm:8.4.17" + version: 8.4.18 + resolution: "postcss@npm:8.4.18" dependencies: nanoid: ^3.3.4 picocolors: ^1.0.0 source-map-js: ^1.0.2 - checksum: d6999ff9d97d69138a4ca890644543825792d925549366bde10b587e0fccfc0e8e2d85f627588d67238f0c24e3cf7940171017f62c74710ef36f253e4256b940 + checksum: df38b43e0cd79b115305fb787f4586d376b38c515692ef7429785af84d00ebe86f2276b98071d3f62848daf8639ee4ef6057618b34c292196dc6af072eeede5e languageName: node linkType: hard @@ -32614,9 +32602,9 @@ __metadata: linkType: hard "preact@npm:^10.5.13": - version: 10.11.1 - resolution: "preact@npm:10.11.1" - checksum: c34596775e27072ad642a6b18bc6325676e576c6e3ed29b1cef441396ccf2040dd468cf1415072b3cf325c4b441560f98c505ffcfb6d7701f004f3337d649ace + version: 10.11.2 + resolution: "preact@npm:10.11.2" + checksum: ae370a7ef997bc3c4d4e3057ee9b78ced8b078bd96139388e815a5221bdd1e16bf2b62a957b59fb8afdd8eb40e07445bd1c10dbe21b28ec0f6e163829efa475a languageName: node linkType: hard @@ -32720,14 +32708,14 @@ __metadata: languageName: node linkType: hard -"pretty-format@npm:^29.0.0, pretty-format@npm:^29.1.2": - version: 29.1.2 - resolution: "pretty-format@npm:29.1.2" +"pretty-format@npm:^29.0.0, pretty-format@npm:^29.2.1": + version: 29.2.1 + resolution: "pretty-format@npm:29.2.1" dependencies: "@jest/schemas": ^29.0.0 ansi-styles: ^5.0.0 react-is: ^18.0.0 - checksum: 7b9b37ca8412aa05a5db359f88b0497174c8520c687e6ee06b2f16b7369161cb11469f9ae9ff5bf6bf0ced95f86752b8a0fa796476fe3b2da7596ea02e8f77a0 + checksum: 35d275a65379fdd52cbf2d984432bca91ca4ebecc6c3459e5d96f653a2855b9aab8147fe303b68435c3d18ec8b80bdbe425ed3b9fc8e4ff112f552f4b949108d languageName: node linkType: hard @@ -34086,15 +34074,15 @@ __metadata: languageName: node linkType: hard -"recast@npm:0.21.1": - version: 0.21.1 - resolution: "recast@npm:0.21.1" +"recast@npm:0.21.5": + version: 0.21.5 + resolution: "recast@npm:0.21.5" dependencies: ast-types: 0.15.2 esprima: ~4.0.0 source-map: ~0.6.1 tslib: ^2.0.1 - checksum: f3e103a21594dc3ef1d481f81be327d349798e7d1b9a57cecfac5d4cadc59e3865b12a28f364f7191e158b16c9deaf6cb3341953d591fe63d22e4ad5b6a995dd + checksum: a45168c82195f24fa2c70293a624fece0069a2e8e8adb637f9963777735f81cb3bb62e55172db677ec3573b08b2daaf1eddd85b74da6fe0bd37c9b15eeaf94b4 languageName: node linkType: hard @@ -34232,7 +34220,7 @@ __metadata: languageName: node linkType: hard -"regenerator-runtime@npm:0.13.9, regenerator-runtime@npm:^0.13.2, regenerator-runtime@npm:^0.13.4, regenerator-runtime@npm:^0.13.7": +"regenerator-runtime@npm:0.13.9": version: 0.13.9 resolution: "regenerator-runtime@npm:0.13.9" checksum: b0f26612204f061a84064d2f3361629eae09993939112b9ffc3680bb369ecd125764d6654eace9ef11b36b44282ee52b988dda946ea52d372e7599a30eea73ee @@ -34246,6 +34234,13 @@ __metadata: languageName: node linkType: hard +"regenerator-runtime@npm:^0.13.2, regenerator-runtime@npm:^0.13.4, regenerator-runtime@npm:^0.13.7": + version: 0.13.10 + resolution: "regenerator-runtime@npm:0.13.10" + checksum: 2990a7a998ff6bf5caf5597c5671751f447560c5060ae5628469620a7ce640131bf0744c506d63c2166783121535da4ed782c3383371f945fb9a37481598a761 + languageName: node + linkType: hard + "regenerator-transform@npm:^0.15.0": version: 0.15.0 resolution: "regenerator-transform@npm:0.15.0" @@ -34662,12 +34657,12 @@ __metadata: linkType: hard "remark-mdx@npm:^2.0.0": - version: 2.1.4 - resolution: "remark-mdx@npm:2.1.4" + version: 2.1.5 + resolution: "remark-mdx@npm:2.1.5" dependencies: mdast-util-mdx: ^2.0.0 micromark-extension-mdxjs: ^1.0.0 - checksum: 8f15191ab12480505ce13071a03578ace6bc405b64f15055f81602faa002b0f540411317d323b857440a40a3c9e7d074a7e3d37572dd8a5cc84c212d7144a151 + checksum: f16e21e45fbd5004f361a20e3f4f8ca4cf2cc9c99f7db9aaba9f010cda02c08cf052c5f94d5af798a01c68b1186613fb537a3ef04faf25c292aaba0b7e3d6d7f languageName: node linkType: hard @@ -36352,8 +36347,8 @@ __metadata: linkType: hard "socket.io@npm:^4.1.2": - version: 4.5.2 - resolution: "socket.io@npm:4.5.2" + version: 4.5.3 + resolution: "socket.io@npm:4.5.3" dependencies: accepts: ~1.3.4 base64id: ~2.0.0 @@ -36361,7 +36356,7 @@ __metadata: engine.io: ~6.2.0 socket.io-adapter: ~2.4.0 socket.io-parser: ~4.2.0 - checksum: 6b17ed97ec6d99499b7eed2ba8e57846b3528096b2f57a6289ca28931d8929c4a0605f7d0c1941db86f89eb93e52b127be850fad057c826b50a7d05e11c24369 + checksum: da5f66ae4126f84c38de2635d1512ffc02db038061eddbb0735bbe2027ba340f8daf96dcdc25e252bfc6a9d779ba6d6d95076508dbe3a60f02079e1305f6b47e languageName: node linkType: hard @@ -37674,9 +37669,9 @@ __metadata: linkType: hard "svelte@npm:^3.0.0, svelte@npm:^3.31.2, svelte@npm:^3.48.0": - version: 3.51.0 - resolution: "svelte@npm:3.51.0" - checksum: 303b14941e684f7cbc82593d7cdc0f988c6909166cfa600d7a2b57e94c49412f4629d17ce91fd6a33edabae81379517cc357d713562c8b68a19c690df0bb8a0c + version: 3.52.0 + resolution: "svelte@npm:3.52.0" + checksum: 98446c71e598ad5ae2cfdb68e1c8a6c69af36eb89f970bbcfe478f127dbbffb2acf882986c368a81ae5cdf4044c3f4bf0876abe0dd7e66c75707618d8fe70ff9 languageName: node linkType: hard @@ -38503,9 +38498,9 @@ __metadata: linkType: hard "traverse@npm:^0.6.6": - version: 0.6.6 - resolution: "traverse@npm:0.6.6" - checksum: 72b2c95463e991063cfa3603dc80e8ca35cae4bf1a736e5b6df3a50226dca341777699f702b55f61b9a329e7be0a76fb77d994f4981f49de98bb02065ca1e7d9 + version: 0.6.7 + resolution: "traverse@npm:0.6.7" + checksum: 97312cbcce0fdc640cf871a33c3f8efa85fbc2e21020bcbbf48b50883db4c41cfef580f3deaab67217291b761be4558fff34aab1baff7eb2b65323412458a489 languageName: node linkType: hard @@ -38848,8 +38843,8 @@ __metadata: linkType: hard "tsup@npm:^6.2.2": - version: 6.2.3 - resolution: "tsup@npm:6.2.3" + version: 6.3.0 + resolution: "tsup@npm:6.3.0" dependencies: bundle-require: ^3.1.0 cac: ^6.7.12 @@ -38879,7 +38874,7 @@ __metadata: bin: tsup: dist/cli-default.js tsup-node: dist/cli-node.js - checksum: b346d50ba32b79946936629252a202fda7d4eef0bac76380819a69c882939f51cb2e2875ea314e27ee4370e06ca10edded6f4f50a309945b255d21cbaee1b720 + checksum: fc60bc67ab93d0e59ebb028d980d853cc22328ba05ec0a09b3e6a0ea21bb2078a68e8c6978a2a1f9bd03090a8cbe77400c8c750bfdb639b47bab1bfea7232a2a languageName: node linkType: hard @@ -39832,16 +39827,15 @@ __metadata: linkType: hard "util@npm:^0.12.4": - version: 0.12.4 - resolution: "util@npm:0.12.4" + version: 0.12.5 + resolution: "util@npm:0.12.5" dependencies: inherits: ^2.0.3 is-arguments: ^1.0.4 is-generator-function: ^1.0.7 is-typed-array: ^1.1.3 - safe-buffer: ^5.1.2 which-typed-array: ^1.1.2 - checksum: 3e04e6feb68bccdc9fdfa013050719b3b41ce698ff5e244ee683d675b7fb9b91c8a1594b164696ee2201cca9579c286b968d0aabd9c9069ae1667413940a4e49 + checksum: c27054de2cea2229a66c09522d0fa1415fb12d861d08523a8846bf2e4cbf0079d4c3f725f09dcb87493549bcbf05f5798dce1688b53c6c17201a45759e7253f3 languageName: node linkType: hard @@ -40154,8 +40148,8 @@ __metadata: linkType: hard "vite@npm:^3.1.0, vite@npm:^3.1.3, vite@npm:^3.1.7": - version: 3.1.7 - resolution: "vite@npm:3.1.7" + version: 3.1.8 + resolution: "vite@npm:3.1.8" dependencies: esbuild: ^0.15.9 fsevents: ~2.3.2 @@ -40181,7 +40175,7 @@ __metadata: optional: true bin: vite: bin/vite.js - checksum: c2156ade7e4aa1ec17fe9df1011ea6a45dad39a3ee159ecde4036f3ea643bb5226fd5d227213acfe63c7dd1ebcbae119bccf295934559a09ffcf380a537ae140 + checksum: 75f3959c386b8126e0ed27fdb4723bf63689e9c12f5ea84f537be7c6df460978d53f3237293eecf7b9e8b07ee72eb82c44dca3c0c94063736b6d4bc8c0eeb96c languageName: node linkType: hard @@ -40250,8 +40244,8 @@ __metadata: linkType: hard "vue-docgen-api@npm:^4.40.0, vue-docgen-api@npm:^4.44.23, vue-docgen-api@npm:^4.46.0": - version: 4.52.0 - resolution: "vue-docgen-api@npm:4.52.0" + version: 4.54.2 + resolution: "vue-docgen-api@npm:4.54.2" dependencies: "@babel/parser": ^7.13.12 "@babel/types": ^7.18.8 @@ -40261,10 +40255,10 @@ __metadata: hash-sum: ^1.0.2 lru-cache: ^4.1.5 pug: ^3.0.2 - recast: 0.21.1 + recast: 0.21.5 ts-map: ^1.0.3 vue-inbrowser-compiler-independent-utils: ^4.52.0 - checksum: 38e7d44205a6fc14fc28c98e77f89fee5167ef0ad59e9083fcf17f8b9fb9e7aa20941a107b6b67fa7f9bfbf5bf0159925ac750b4d99ee06154e01a2695bf58ad + checksum: e42440d80b3cc08bde6fbb6a4c61e14768fb1e98781fe8305df50d9d74143a6a323184e4c2ffe839283ea2f932b8a3b92c77c119e512f9c49bef50af55b85374 languageName: node linkType: hard @@ -40379,12 +40373,12 @@ __metadata: linkType: hard "vue-template-compiler@npm:^2.6.14": - version: 2.7.10 - resolution: "vue-template-compiler@npm:2.7.10" + version: 2.7.13 + resolution: "vue-template-compiler@npm:2.7.13" dependencies: de-indent: ^1.0.2 he: ^1.2.0 - checksum: aaffcb60f7999d97dea0e020b9aa881f8e9560c8e6a6752da53c3a26ae3df5fd5ea5b7170f08a10a198d0d0c298506a9515a15961f5060a1dcab638d5e0b0628 + checksum: 6f1b54e74cc5b2a97ccda5335123fc2e9d1b63b934efe67552fbe7a4041ac55fc24b802e5715e7509696c6bcf5d1c6e0c69e4cd0ba85b3e32384df66b452ae82 languageName: node linkType: hard @@ -40407,25 +40401,25 @@ __metadata: linkType: hard "vue@npm:^2.6.12, vue@npm:^2.7.10": - version: 2.7.10 - resolution: "vue@npm:2.7.10" + version: 2.7.13 + resolution: "vue@npm:2.7.13" dependencies: - "@vue/compiler-sfc": 2.7.10 + "@vue/compiler-sfc": 2.7.13 csstype: ^3.1.0 - checksum: b01d8370dc7b4018aa0ddf9838ea1f0536f7c3ae3a88b6585ac8e72fc9951f25f4bc793d27bc2f6fdaf63836f7d16167f3a4aad3402b2b839a882772e90c7f2c + checksum: 71ed60ac28721e5e170202ac143bb23332c0cc4223c55b53d7cdb21215c6b98cab6b8e19cf812fac0d4f3a2c0bbdce23c3abaf19d5185d142ebf2c3528be8845 languageName: node linkType: hard "vue@npm:^3.0.0, vue@npm:^3.2.33": - version: 3.2.40 - resolution: "vue@npm:3.2.40" - dependencies: - "@vue/compiler-dom": 3.2.40 - "@vue/compiler-sfc": 3.2.40 - "@vue/runtime-dom": 3.2.40 - "@vue/server-renderer": 3.2.40 - "@vue/shared": 3.2.40 - checksum: 90221e963126182c6e9f89a30a131628541cba880e0ac3c186ec2d24a8ac3dcb52f04a79fc151995c486a6dc1088d84194a5a81a9d2320acc15fbf7f6bf670f8 + version: 3.2.41 + resolution: "vue@npm:3.2.41" + dependencies: + "@vue/compiler-dom": 3.2.41 + "@vue/compiler-sfc": 3.2.41 + "@vue/runtime-dom": 3.2.41 + "@vue/server-renderer": 3.2.41 + "@vue/shared": 3.2.41 + checksum: fac4f47b5ecec8b7b7366eccb6b35866712e11887a12df0f04f989134578de27b69364c1ea1377384b38d048a0c4f604fd096500647f30c0b45cc68cff421d8d languageName: node linkType: hard From 06d00041ecdf9f31f9cd3696fe2dc345fdca13a1 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sat, 22 Oct 2022 20:22:29 +0200 Subject: [PATCH 29/38] fix linting --- code/examples/external-docs/components/button.stories.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/code/examples/external-docs/components/button.stories.tsx b/code/examples/external-docs/components/button.stories.tsx index 1e9b62081e2e..9779b0339c53 100644 --- a/code/examples/external-docs/components/button.stories.tsx +++ b/code/examples/external-docs/components/button.stories.tsx @@ -1,4 +1,3 @@ -/* eslint-disable storybook/await-interactions */ /* eslint-disable storybook/use-storybook-testing-library */ // @TODO: use addon-interactions and remove the rule disable above import React from 'react'; From 9cdedc4527f05e528ba3b734477ae9d4ba6cf1a5 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sat, 22 Oct 2022 20:23:51 +0200 Subject: [PATCH 30/38] oops --- scripts/verdaccio.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/verdaccio.yaml b/scripts/verdaccio.yaml index 2177322c9024..92011f313490 100644 --- a/scripts/verdaccio.yaml +++ b/scripts/verdaccio.yaml @@ -27,7 +27,7 @@ packages: proxy: npmjs # storybook's packages not hosted in this monorepo - '@storybook/types': + '@storybook/csf': access: $all publish: $all proxy: npmjs From d28b0245c789d5fc363ddfbb45c9b09e5c8f47f6 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sat, 22 Oct 2022 20:52:21 +0200 Subject: [PATCH 31/38] fix backgrounds not getting applied --- code/addons/backgrounds/src/preview.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/addons/backgrounds/src/preview.tsx b/code/addons/backgrounds/src/preview.tsx index cc67d00f6318..9405b34897c5 100644 --- a/code/addons/backgrounds/src/preview.tsx +++ b/code/addons/backgrounds/src/preview.tsx @@ -15,3 +15,7 @@ export const parameters = { ], }, }; + +export const globals = { + backgrounds: { name: 'light', value: '#F8F8F8' }, +}; From aaecde646941beebfe759957f5436eed276dbd9f Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sat, 22 Oct 2022 23:14:13 +0200 Subject: [PATCH 32/38] I'm going to revert this for a bit, see if it makes the e2e pass --- code/addons/backgrounds/src/preview.tsx | 5 +++-- code/lib/store/src/GlobalsStore.ts | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/code/addons/backgrounds/src/preview.tsx b/code/addons/backgrounds/src/preview.tsx index 9405b34897c5..289a0b3f9b1c 100644 --- a/code/addons/backgrounds/src/preview.tsx +++ b/code/addons/backgrounds/src/preview.tsx @@ -1,9 +1,10 @@ import { withBackground } from './decorators/withBackground'; import { withGrid } from './decorators/withGrid'; +import { PARAM_KEY as BACKGROUNDS_PARAM_KEY } from './constants'; export const decorators = [withGrid, withBackground]; export const parameters = { - backgrounds: { + [BACKGROUNDS_PARAM_KEY]: { grid: { cellSize: 20, opacity: 0.5, @@ -17,5 +18,5 @@ export const parameters = { }; export const globals = { - backgrounds: { name: 'light', value: '#F8F8F8' }, + [BACKGROUNDS_PARAM_KEY]: null as any, }; diff --git a/code/lib/store/src/GlobalsStore.ts b/code/lib/store/src/GlobalsStore.ts index 97085edc3461..019db3cba65e 100644 --- a/code/lib/store/src/GlobalsStore.ts +++ b/code/lib/store/src/GlobalsStore.ts @@ -56,6 +56,7 @@ export class GlobalsStore { } update(newGlobals: Globals) { - this.globals = { ...this.globals, ...this.filterAllowedGlobals(newGlobals) }; + // this.globals = { ...this.globals, ...this.filterAllowedGlobals(newGlobals) }; + this.globals = { ...this.globals, ...newGlobals }; } } From f7b78e3a679d78d0ade1e3856dce3833867e4d9a Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sun, 23 Oct 2022 19:03:12 +0200 Subject: [PATCH 33/38] cleanup --- code/renderers/svelte/src/public-types.test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/renderers/svelte/src/public-types.test.ts b/code/renderers/svelte/src/public-types.test.ts index 5c6636bea050..79663ebd8e1e 100644 --- a/code/renderers/svelte/src/public-types.test.ts +++ b/code/renderers/svelte/src/public-types.test.ts @@ -1,14 +1,14 @@ import { describe, test } from '@jest/globals'; import { satisfies } from '@storybook/core-common'; -import { ComponentAnnotations, StoryAnnotations } from '@storybook/csf'; +import type { ComponentAnnotations, StoryAnnotations } from '@storybook/types'; import { expectTypeOf } from 'expect-type'; -import { ComponentProps, SvelteComponentTyped } from 'svelte'; +import type { ComponentProps, SvelteComponentTyped } from 'svelte'; import Button from './__test__/Button.svelte'; import Decorator from './__test__/Decorator.svelte'; import Decorator2 from './__test__/Decorator2.svelte'; -import { DecoratorFn, Meta, StoryObj } from './public-types'; -import { SvelteFramework } from './types'; +import type { DecoratorFn, Meta, StoryObj } from './public-types'; +import type { SvelteFramework } from './types'; type SvelteStory = StoryAnnotations< SvelteFramework, From 464c671c61af7f6adcfb38a9590014e7008a5dba Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sun, 23 Oct 2022 19:17:53 +0200 Subject: [PATCH 34/38] add missing export --- code/lib/types/src/modules/csf.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/code/lib/types/src/modules/csf.ts b/code/lib/types/src/modules/csf.ts index fd69b3125efa..c1f6e7c50c09 100644 --- a/code/lib/types/src/modules/csf.ts +++ b/code/lib/types/src/modules/csf.ts @@ -1,13 +1,13 @@ /* eslint-disable camelcase */ import type { - ViewMode as ViewModeFromCSF, AnnotatedStoryFn, AnyFramework, - ArgTypes, - ArgTypesEnhancer, Args, ArgsEnhancer, + ArgsFromMeta, ArgsStoryFn, + ArgTypes, + ArgTypesEnhancer, BaseAnnotations, ComponentAnnotations, ComponentId, @@ -15,8 +15,8 @@ import type { Conditional, DecoratorApplicator, DecoratorFunction, - GlobalTypes, Globals, + GlobalTypes, IncludeExcludeOptions, InputType, LegacyAnnotatedStoryFn, @@ -54,16 +54,18 @@ import type { StrictArgTypes, StrictGlobalTypes, StrictInputType, + ViewMode as ViewModeFromCSF, } from '@storybook/csf'; export { AnnotatedStoryFn, AnyFramework, - ArgTypes, - ArgTypesEnhancer, Args, ArgsEnhancer, + ArgsFromMeta, ArgsStoryFn, + ArgTypes, + ArgTypesEnhancer, BaseAnnotations, ComponentAnnotations, ComponentId, @@ -71,8 +73,8 @@ export { Conditional, DecoratorApplicator, DecoratorFunction, - GlobalTypes, Globals, + GlobalTypes, IncludeExcludeOptions, InputType, LegacyAnnotatedStoryFn, From 2342173213895cb3f5bea073fd7ee6f416eb19a3 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sun, 23 Oct 2022 19:35:09 +0200 Subject: [PATCH 35/38] fixes --- code/renderers/svelte/src/decorators.ts | 3 +-- code/renderers/svelte/src/docs/sourceDecorator.test.ts | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/code/renderers/svelte/src/decorators.ts b/code/renderers/svelte/src/decorators.ts index b79aa9cc55ff..03eb6c3b2e27 100644 --- a/code/renderers/svelte/src/decorators.ts +++ b/code/renderers/svelte/src/decorators.ts @@ -1,7 +1,6 @@ import type { DecoratorFunction, StoryContext, LegacyStoryFn } from '@storybook/types'; import { sanitizeStoryContextUpdate } from '@storybook/store'; -// eslint-disable-next-line import/no-extraneous-dependencies -import SlotDecorator from '@storybook/svelte/templates/SlotDecorator.svelte'; +import SlotDecorator from '../templates/SlotDecorator.svelte'; import { SvelteFramework } from './types'; /** diff --git a/code/renderers/svelte/src/docs/sourceDecorator.test.ts b/code/renderers/svelte/src/docs/sourceDecorator.test.ts index eaa26616f792..25553344d8b9 100644 --- a/code/renderers/svelte/src/docs/sourceDecorator.test.ts +++ b/code/renderers/svelte/src/docs/sourceDecorator.test.ts @@ -1,5 +1,6 @@ +/* eslint-disable camelcase */ import { describe, expect, test } from '@jest/globals'; -import type { Args } from '@storybook/api'; +import type { API_Args } from '@storybook/types'; import { generateSvelteSource } from './sourceDecorator'; expect.addSnapshotSerializer({ @@ -7,7 +8,7 @@ expect.addSnapshotSerializer({ test: (val: unknown) => typeof val === 'string', }); -function generateForArgs(args: Args, slotProperty: string | null = null) { +function generateForArgs(args: API_Args, slotProperty: string | null = null) { return generateSvelteSource({ name: 'Component' }, args, {}, slotProperty); } From 2f6d16dd7ce95c5fff0db89b266b789773edb46e Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Mon, 24 Oct 2022 15:35:06 +0200 Subject: [PATCH 36/38] fixes --- code/lib/core-server/src/withTelemetry.ts | 6 +- code/yarn.lock | 261 +++++++++++++++------- 2 files changed, 180 insertions(+), 87 deletions(-) diff --git a/code/lib/core-server/src/withTelemetry.ts b/code/lib/core-server/src/withTelemetry.ts index f147c509defc..fbd77d0129fb 100644 --- a/code/lib/core-server/src/withTelemetry.ts +++ b/code/lib/core-server/src/withTelemetry.ts @@ -1,5 +1,5 @@ import prompts from 'prompts'; -import type { CLIOptions, CoreConfig } from '@storybook/core-common'; +import type { CLIOptions, CoreConfig } from '@storybook/types'; import { loadAllPresets, cache } from '@storybook/core-common'; import { telemetry } from '@storybook/telemetry'; import type { EventType } from '@storybook/telemetry'; @@ -10,7 +10,9 @@ type TelemetryOptions = { }; const promptCrashReports = async () => { - if (process.env.CI && process.env.NODE_ENV !== 'test') return undefined; + if (process.env.CI && process.env.NODE_ENV !== 'test') { + return undefined; + } const { enableCrashReports } = await prompts({ type: 'confirm', diff --git a/code/yarn.lock b/code/yarn.lock index b02d1c5999c7..0212636c7da2 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -6192,9 +6192,9 @@ __metadata: linkType: hard "@sinclair/typebox@npm:^0.24.1": - version: 0.24.48 - resolution: "@sinclair/typebox@npm:0.24.48" - checksum: 60cff4c2b10faf6b48c2bf43de179a07d3927c0d57e39d50cdd05e44be3c5d0156dd9f91a0c451dcb2036f117f593916f25869882b75eeb07ce679abb405a0b1 + version: 0.24.50 + resolution: "@sinclair/typebox@npm:0.24.50" + checksum: 85607a3e8ad5592afd1378ddaf8dba8e91cad27cd4f4347e0a2b893c986f0ba9a87fa51c7f9be9e2bfb96cae2f0163c98538095b8f394d2c365cd33d5d1e8bea languageName: node linkType: hard @@ -6844,17 +6844,17 @@ __metadata: languageName: unknown linkType: soft -"@storybook/addons@npm:6.5.12": - version: 6.5.12 - resolution: "@storybook/addons@npm:6.5.12" +"@storybook/addons@npm:6.5.13": + version: 6.5.13 + resolution: "@storybook/addons@npm:6.5.13" dependencies: - "@storybook/api": 6.5.12 - "@storybook/channels": 6.5.12 - "@storybook/client-logger": 6.5.12 - "@storybook/core-events": 6.5.12 + "@storybook/api": 6.5.13 + "@storybook/channels": 6.5.13 + "@storybook/client-logger": 6.5.13 + "@storybook/core-events": 6.5.13 "@storybook/csf": 0.0.2--canary.4566f4d.1 - "@storybook/router": 6.5.12 - "@storybook/theming": 6.5.12 + "@storybook/router": 6.5.13 + "@storybook/theming": 6.5.13 "@types/webpack-env": ^1.16.0 core-js: ^3.8.2 global: ^4.4.0 @@ -6862,7 +6862,7 @@ __metadata: peerDependencies: react: ^16.8.0 || ^17.0.0 || ^18.0.0 react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 - checksum: 253df9fef74f0fe6de084b40e68e24f9c5d71e0ecd8e3b14a8aaae9bf695ee84b659be4a3b26180ac5fe64ef3aa95d84b50fbde2e2ad52a79fcb2bb3d612066b + checksum: 7700696b40cc692b9827af560351c007a007bc3a309afebaba2c6b6267c9a3305e76c9a5827a70520817e7027f1d58bd92b6377682fb48155282bd237e15c5b3 languageName: node linkType: hard @@ -6977,17 +6977,17 @@ __metadata: languageName: unknown linkType: soft -"@storybook/api@npm:6.5.12": - version: 6.5.12 - resolution: "@storybook/api@npm:6.5.12" +"@storybook/api@npm:6.5.13": + version: 6.5.13 + resolution: "@storybook/api@npm:6.5.13" dependencies: - "@storybook/channels": 6.5.12 - "@storybook/client-logger": 6.5.12 - "@storybook/core-events": 6.5.12 + "@storybook/channels": 6.5.13 + "@storybook/client-logger": 6.5.13 + "@storybook/core-events": 6.5.13 "@storybook/csf": 0.0.2--canary.4566f4d.1 - "@storybook/router": 6.5.12 + "@storybook/router": 6.5.13 "@storybook/semver": ^7.3.2 - "@storybook/theming": 6.5.12 + "@storybook/theming": 6.5.13 core-js: ^3.8.2 fast-deep-equal: ^3.1.3 global: ^4.4.0 @@ -7001,7 +7001,7 @@ __metadata: peerDependencies: react: ^16.8.0 || ^17.0.0 || ^18.0.0 react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 - checksum: 40cbba08fa132f9ae54e5475667e44a9dd0e64f4e8b1fe46427a452bec9377bd2d60a877d21deccc95f8416aff0322b2b5128ceef5b90380a07f0a1687aab430 + checksum: c30816e95845876694ccca3cc6e37fe2493027447fc607e56709bd55d610ae6b925233566150f09c891ecd1ba04bb6b0d7c0ad928f676b0aa4ca5cf2b11f3f4c languageName: node linkType: hard @@ -7187,14 +7187,14 @@ __metadata: languageName: unknown linkType: soft -"@storybook/channels@npm:6.5.12": - version: 6.5.12 - resolution: "@storybook/channels@npm:6.5.12" +"@storybook/channels@npm:6.5.13": + version: 6.5.13 + resolution: "@storybook/channels@npm:6.5.13" dependencies: core-js: ^3.8.2 ts-dedent: ^2.0.0 util-deprecate: ^1.0.2 - checksum: 8a7d2d79faab8445ae2e8fbc2207ec5cdafe152d4ecd66e4ed91ee5021688094be2b394d267d05d69c7778a186bc62fb6eb6a8541731c8039d8df66d68dac97b + checksum: 0d1c58a3e528272d066996a232f3693ed8fbdbcd7c8e5e8b2ae211a22ac7b0359f43f234f0df453cd6aab6aa0cdfc227e7e953cbe2a584e2395f36604ede7fd1 languageName: node linkType: hard @@ -7284,13 +7284,13 @@ __metadata: languageName: unknown linkType: soft -"@storybook/client-logger@npm:6.5.12, @storybook/client-logger@npm:^6.4.0": - version: 6.5.12 - resolution: "@storybook/client-logger@npm:6.5.12" +"@storybook/client-logger@npm:6.5.13, @storybook/client-logger@npm:^6.4.0": + version: 6.5.13 + resolution: "@storybook/client-logger@npm:6.5.13" dependencies: core-js: ^3.8.2 global: ^4.4.0 - checksum: 959b3cce73c2434eee1b39c4f5ed82d0df4fb725475004a24760f02a8c22acee6b55214d5b0756c4df27a466f2b095dbfc52f7cc0a3b1f8c64e8ed50dabe7a7c + checksum: 54f2e2738b4e07b0a9ad4e37f45461311ad9db1dd4a5e89bddbbd93363ae91f4f801fd49064e548185cb4683c44e564c5f77e3ea28319d8cc5bd4e75794c26fc languageName: node linkType: hard @@ -7423,12 +7423,12 @@ __metadata: languageName: unknown linkType: soft -"@storybook/core-events@npm:6.5.12": - version: 6.5.12 - resolution: "@storybook/core-events@npm:6.5.12" +"@storybook/core-events@npm:6.5.13": + version: 6.5.13 + resolution: "@storybook/core-events@npm:6.5.13" dependencies: core-js: ^3.8.2 - checksum: 846aa0381b103dbd79be2a10f6d64449f19749e10b5cb49a92958af388f04b77d3b8a90bbf605a48752f93dda1308eeead117879f2641be8c70312fc8cfc7274 + checksum: 35333de8a10765609b0a4eb6fe1e5c3d93913b7284233852d6aa9564967118e54eb6fe237fdbb7040da3e255d7a8f3e8243e4bf38381afd0ac0107166bf57870 languageName: node linkType: hard @@ -7759,15 +7759,15 @@ __metadata: linkType: soft "@storybook/instrumenter@npm:^6.4.0": - version: 6.5.12 - resolution: "@storybook/instrumenter@npm:6.5.12" + version: 6.5.13 + resolution: "@storybook/instrumenter@npm:6.5.13" dependencies: - "@storybook/addons": 6.5.12 - "@storybook/client-logger": 6.5.12 - "@storybook/core-events": 6.5.12 + "@storybook/addons": 6.5.13 + "@storybook/client-logger": 6.5.13 + "@storybook/core-events": 6.5.13 core-js: ^3.8.2 global: ^4.4.0 - checksum: 165f5b1a7fd865fea7ca272f5cc2dc4a7596204b73da9a5aaae38aabf25e88855627d4e1abfaf4f597f6998b8da2fffb4aa0cd5966206a621f26241846f95c70 + checksum: 506a8a90906df864bee3d0fef9a84ea5a635fc3758829c220822fff8ebd21b6504e2f49b15c5afb22e164dd558f1cca63d258d35830ec269d9f03077c8db3ec6 languageName: node linkType: hard @@ -8528,11 +8528,11 @@ __metadata: languageName: unknown linkType: soft -"@storybook/router@npm:6.5.12": - version: 6.5.12 - resolution: "@storybook/router@npm:6.5.12" +"@storybook/router@npm:6.5.13": + version: 6.5.13 + resolution: "@storybook/router@npm:6.5.13" dependencies: - "@storybook/client-logger": 6.5.12 + "@storybook/client-logger": 6.5.13 core-js: ^3.8.2 memoizerific: ^1.11.3 qs: ^6.10.0 @@ -8540,7 +8540,7 @@ __metadata: peerDependencies: react: ^16.8.0 || ^17.0.0 || ^18.0.0 react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 - checksum: e51ea851d97e04ae296bc7393752beecaff2c4d794527c934b0c2688d8417ac57001928b8d357c47d4ca0021d488a0b43b6cc596a140c81efb3c86601ba22a26 + checksum: a1c904b59603b776c76e5786c0c744ca99a61302b388d5585153dddfa9e64d278e560d09847453c0eb1a47eb6c621035314cc4519ff484c8f926e96ec9bd50a2 languageName: node linkType: hard @@ -8757,18 +8757,18 @@ __metadata: languageName: unknown linkType: soft -"@storybook/theming@npm:6.5.12": - version: 6.5.12 - resolution: "@storybook/theming@npm:6.5.12" +"@storybook/theming@npm:6.5.13": + version: 6.5.13 + resolution: "@storybook/theming@npm:6.5.13" dependencies: - "@storybook/client-logger": 6.5.12 + "@storybook/client-logger": 6.5.13 core-js: ^3.8.2 memoizerific: ^1.11.3 regenerator-runtime: ^0.13.7 peerDependencies: react: ^16.8.0 || ^17.0.0 || ^18.0.0 react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 - checksum: ef649ca76f57cfa2524ecfd864ca175a370e1abfd89c5b8a7205b280bfeb95f23e071e8662e61b670dac1630dffb01616acdec66cfa5109d30e1b64ccb84d0ae + checksum: 8bf458d40a66979aba1f2ed03d77dade107f69cf8ed6caebaf7b98fe4a9870e74afee86f8da9724d528e5c4e129ce51ad8bff65ea4304d50a299f5e89bc6ce99 languageName: node linkType: hard @@ -9861,16 +9861,16 @@ __metadata: linkType: hard "@types/node@npm:*, @types/node@npm:>= 8, @types/node@npm:>=10.0.0, @types/node@npm:^18.7.20": - version: 18.11.3 - resolution: "@types/node@npm:18.11.3" - checksum: 97da0b4e6505bf179cb0560e02d88e63681ba8d5a1105a91e2870d7ca9f15bc38728670586e96a25760f3830fa366dcb7c8a90f94eba2588ae1c62b55dad5fd6 + version: 18.11.4 + resolution: "@types/node@npm:18.11.4" + checksum: e5199e778490ff3cd98419f89827a2f695fdd0818da37594ac639ddb1c80dd0eb1d86e657d0bbb37bf82ca7d4d467b0cf9c459d3eba42be60b037c41456f122a languageName: node linkType: hard "@types/node@npm:^14.14.20 || ^16.0.0, @types/node@npm:^16.0.0": - version: 16.11.68 - resolution: "@types/node@npm:16.11.68" - checksum: 59a13a94b08759717809571e25f7d9cf1e143401f0258cc5d16998dec10158c23463d41015249cc17e6b5bc94cb20cfec20a374b4183ac2e8e118f8da4fb3e31 + version: 16.18.0 + resolution: "@types/node@npm:16.18.0" + checksum: cab5add5b756c572461302b685910c1bd8ba98af516f82ea7061b5f4afa0fb3b90ee2c4d82ac722afb0058522835d5d0fa364e8f2f4aa69a363212ec0f401676 languageName: node linkType: hard @@ -11855,9 +11855,11 @@ __metadata: linkType: hard "aria-query@npm:^5.0.0": - version: 5.0.2 - resolution: "aria-query@npm:5.0.2" - checksum: fe1ce894c408b58a6bc9c905c7400ccf278944b1cc67be9766124324f1a2a78afdb07b90569faa2420a4f360dca7f641d3511ef42871b857b8079ac856a3b1bd + version: 5.1.1 + resolution: "aria-query@npm:5.1.1" + dependencies: + deep-equal: ^2.0.5 + checksum: 8be9b1e6e4e4c296082d13620555914749195a55ad1f10f0013f8cdaa2e1ce3adfb8ecca9e5b06b865e79ce505d8ab264e3edec158ade5ca154fe7d21a66fc6b languageName: node linkType: hard @@ -15612,18 +15614,18 @@ __metadata: linkType: hard "core-js-compat@npm:^3.20.2, core-js-compat@npm:^3.21.0, core-js-compat@npm:^3.25.1": - version: 3.25.5 - resolution: "core-js-compat@npm:3.25.5" + version: 3.26.0 + resolution: "core-js-compat@npm:3.26.0" dependencies: browserslist: ^4.21.4 - checksum: 67d928148e2e09f725c535f8380e13c552a5b4436e942950e0107376dc5807e1ca83acf42d65ec564b00581945bd968b9509692c398cc6720918c2b5ccbcedf9 + checksum: c93684da7bda013e5f356f59472f76a6d5976b7ce1ae7a781ab922949db2995040bb81bd41b6a15e2b7da09870485a05854abee2ace29aaf9c1b92c57e3461b7 languageName: node linkType: hard "core-js-pure@npm:^3.23.3, core-js-pure@npm:^3.25.1": - version: 3.25.5 - resolution: "core-js-pure@npm:3.25.5" - checksum: 47c84be3d06c4e1d49e7e9f191368dda4d2d4cb4cb94929e6e8caf2230b87b1a944a0d64d767ea9e7c540853082ad7e68f9310800d79809a4cd9feb3a0c00269 + version: 3.26.0 + resolution: "core-js-pure@npm:3.26.0" + checksum: d2fd6f787903c77d9ea4f3c961bd79e4632e12ae2ddf55ecba0bbb186d31e46b0649e98f9d9a8def2a5127ad2272f31650f54e84f80b833dd822291730c6dd77 languageName: node linkType: hard @@ -15642,9 +15644,9 @@ __metadata: linkType: hard "core-js@npm:^3.0.4, core-js@npm:^3.6.5, core-js@npm:^3.8.2": - version: 3.25.5 - resolution: "core-js@npm:3.25.5" - checksum: 4b94b271f924cecf98fa5b1031c0109c9da2ff97a3d4df83465be9e90c3bf0b32a0bed98bb6a3c3aaa8951109c6fb9b3111fbe77a7036e075619c5a40a79dfbf + version: 3.26.0 + resolution: "core-js@npm:3.26.0" + checksum: 5b61da1cccea18b42e64dafe7270b3a12e31f6fca97f7bbebd565b89acd71c2bbb45605ceb164f5b0aa7e41843f6ae8ecc16d4833a081ac269969220c50fd8d6 languageName: node linkType: hard @@ -16456,6 +16458,29 @@ __metadata: languageName: node linkType: hard +"deep-equal@npm:^2.0.5": + version: 2.0.5 + resolution: "deep-equal@npm:2.0.5" + dependencies: + call-bind: ^1.0.0 + es-get-iterator: ^1.1.1 + get-intrinsic: ^1.0.1 + is-arguments: ^1.0.4 + is-date-object: ^1.0.2 + is-regex: ^1.1.1 + isarray: ^2.0.5 + object-is: ^1.1.4 + object-keys: ^1.1.1 + object.assign: ^4.1.2 + regexp.prototype.flags: ^1.3.0 + side-channel: ^1.0.3 + which-boxed-primitive: ^1.0.1 + which-collection: ^1.0.1 + which-typed-array: ^1.1.2 + checksum: e36a16ef53a4d3010f6bb9a3f7945cb0c15910590fa04444cfa965d6e1cd77b75418e2e7e45083f22bd769c18b606fc6e24b6a05232405bb51d9b897ee7c55f5 + languageName: node + linkType: hard + "deep-extend@npm:^0.6.0": version: 0.6.0 resolution: "deep-extend@npm:0.6.0" @@ -18245,6 +18270,22 @@ __metadata: languageName: node linkType: hard +"es-get-iterator@npm:^1.1.1": + version: 1.1.2 + resolution: "es-get-iterator@npm:1.1.2" + dependencies: + call-bind: ^1.0.2 + get-intrinsic: ^1.1.0 + has-symbols: ^1.0.1 + is-arguments: ^1.1.0 + is-map: ^2.0.2 + is-set: ^2.0.2 + is-string: ^1.0.5 + isarray: ^2.0.5 + checksum: 76a832b3bfd85941c556287cd50a3ad612f5193264b761e2011503f311dfa20aa52b9ebd701d3f16022d4cb56a7130a4cfb50186427d3aecd0d4e547a471f68e + languageName: node + linkType: hard + "es-module-lexer@npm:^0.9.0, es-module-lexer@npm:^0.9.3": version: 0.9.3 resolution: "es-module-lexer@npm:0.9.3" @@ -21014,7 +21055,7 @@ __metadata: languageName: node linkType: hard -"get-intrinsic@npm:^1.0.2, get-intrinsic@npm:^1.1.0, get-intrinsic@npm:^1.1.1, get-intrinsic@npm:^1.1.3": +"get-intrinsic@npm:^1.0.1, get-intrinsic@npm:^1.0.2, get-intrinsic@npm:^1.1.0, get-intrinsic@npm:^1.1.1, get-intrinsic@npm:^1.1.3": version: 1.1.3 resolution: "get-intrinsic@npm:1.1.3" dependencies: @@ -23270,7 +23311,7 @@ __metadata: languageName: node linkType: hard -"is-arguments@npm:^1.0.4": +"is-arguments@npm:^1.0.4, is-arguments@npm:^1.1.0": version: 1.1.1 resolution: "is-arguments@npm:1.1.1" dependencies: @@ -23385,7 +23426,7 @@ __metadata: languageName: node linkType: hard -"is-date-object@npm:^1.0.1": +"is-date-object@npm:^1.0.1, is-date-object@npm:^1.0.2": version: 1.0.5 resolution: "is-date-object@npm:1.0.5" dependencies: @@ -23616,6 +23657,13 @@ __metadata: languageName: node linkType: hard +"is-map@npm:^2.0.1, is-map@npm:^2.0.2": + version: 2.0.2 + resolution: "is-map@npm:2.0.2" + checksum: 119ff9137a37fd131a72fab3f4ab8c9d6a24b0a1ee26b4eff14dc625900d8675a97785eea5f4174265e2006ed076cc24e89f6e57ebd080a48338d914ec9168a5 + languageName: node + linkType: hard + "is-natural-number@npm:^4.0.1": version: 4.0.1 resolution: "is-natural-number@npm:4.0.1" @@ -23764,7 +23812,7 @@ __metadata: languageName: node linkType: hard -"is-regex@npm:^1.0.3, is-regex@npm:^1.0.4, is-regex@npm:^1.0.5, is-regex@npm:^1.1.0, is-regex@npm:^1.1.2, is-regex@npm:^1.1.4": +"is-regex@npm:^1.0.3, is-regex@npm:^1.0.4, is-regex@npm:^1.0.5, is-regex@npm:^1.1.0, is-regex@npm:^1.1.1, is-regex@npm:^1.1.2, is-regex@npm:^1.1.4": version: 1.1.4 resolution: "is-regex@npm:1.1.4" dependencies: @@ -23788,6 +23836,13 @@ __metadata: languageName: node linkType: hard +"is-set@npm:^2.0.1, is-set@npm:^2.0.2": + version: 2.0.2 + resolution: "is-set@npm:2.0.2" + checksum: 5f8bd1880df8c0004ce694e315e6e1e47a3452014be792880bb274a3b2cdb952fdb60789636ca6e084c7947ca8b7ae03ccaf54c93a7fcfed228af810559e5432 + languageName: node + linkType: hard + "is-shared-array-buffer@npm:^1.0.2": version: 1.0.2 resolution: "is-shared-array-buffer@npm:1.0.2" @@ -23897,6 +23952,13 @@ __metadata: languageName: node linkType: hard +"is-weakmap@npm:^2.0.1": + version: 2.0.1 + resolution: "is-weakmap@npm:2.0.1" + checksum: 9c9fec9efa7bf5030a4a927f33fff2a6976b93646259f92b517d3646c073cc5b98283a162ce75c412b060a46de07032444b530f0a4c9b6e012ef8f1741c3a987 + languageName: node + linkType: hard + "is-weakref@npm:^1.0.2": version: 1.0.2 resolution: "is-weakref@npm:1.0.2" @@ -23906,6 +23968,16 @@ __metadata: languageName: node linkType: hard +"is-weakset@npm:^2.0.1": + version: 2.0.2 + resolution: "is-weakset@npm:2.0.2" + dependencies: + call-bind: ^1.0.2 + get-intrinsic: ^1.1.1 + checksum: ef5136bd446ae4603229b897f73efd0720c6ab3ec6cc05c8d5c4b51aa9f95164713c4cad0a22ff1fedf04865ff86cae4648bc1d5eead4b6388e1150525af1cc1 + languageName: node + linkType: hard + "is-what@npm:^3.14.1": version: 3.14.1 resolution: "is-what@npm:3.14.1" @@ -23964,6 +24036,13 @@ __metadata: languageName: node linkType: hard +"isarray@npm:^2.0.5": + version: 2.0.5 + resolution: "isarray@npm:2.0.5" + checksum: 4199f14a7a13da2177c66c31080008b7124331956f47bca57dd0b6ea9f11687aa25e565a2c7a2b519bc86988d10398e3049a1f5df13c9f6b7664154690ae79fd + languageName: node + linkType: hard + "isbinaryfile@npm:^4.0.6": version: 4.0.10 resolution: "isbinaryfile@npm:4.0.10" @@ -30716,7 +30795,7 @@ __metadata: languageName: node linkType: hard -"object-is@npm:^1.0.1, object-is@npm:^1.0.2, object-is@npm:^1.1.2": +"object-is@npm:^1.0.1, object-is@npm:^1.0.2, object-is@npm:^1.1.2, object-is@npm:^1.1.4": version: 1.1.5 resolution: "object-is@npm:1.1.5" dependencies: @@ -32617,13 +32696,13 @@ __metadata: linkType: hard "preact-render-to-string@npm:^5.1.19": - version: 5.2.5 - resolution: "preact-render-to-string@npm:5.2.5" + version: 5.2.6 + resolution: "preact-render-to-string@npm:5.2.6" dependencies: pretty-format: ^3.8.0 peerDependencies: preact: ">=10" - checksum: df5b35af48e148e8e98851f6323681d2b709622b57d9947e3bf57789a8a86b4385d61f41bc3458b1beac3e98e350bde2c04212133178e7603439d8591ce947d7 + checksum: fb40f952f377900d87d3274e8ede1b59271347f7a3f41ae390aedeb088d162fe15f0a8040272404bd4477551cc2ec83b8a661e2fd3084702498b1543bb08dd11 languageName: node linkType: hard @@ -34293,7 +34372,7 @@ __metadata: languageName: node linkType: hard -"regexp.prototype.flags@npm:^1.2.0, regexp.prototype.flags@npm:^1.4.1, regexp.prototype.flags@npm:^1.4.3": +"regexp.prototype.flags@npm:^1.2.0, regexp.prototype.flags@npm:^1.3.0, regexp.prototype.flags@npm:^1.4.1, regexp.prototype.flags@npm:^1.4.3": version: 1.4.3 resolution: "regexp.prototype.flags@npm:1.4.3" dependencies: @@ -36208,7 +36287,7 @@ __metadata: languageName: node linkType: hard -"side-channel@npm:^1.0.4": +"side-channel@npm:^1.0.3, side-channel@npm:^1.0.4": version: 1.0.4 resolution: "side-channel@npm:1.0.4" dependencies: @@ -39196,11 +39275,11 @@ __metadata: linkType: hard "uglify-js@npm:^3.1.4": - version: 3.17.3 - resolution: "uglify-js@npm:3.17.3" + version: 3.17.4 + resolution: "uglify-js@npm:3.17.4" bin: uglifyjs: bin/uglifyjs - checksum: aaf157c0bbcabf7528460b9fbcd162ace2544ea3f2934446fcc114d649dc9b8a3969dd3a90621d340838a038974f9556b3b95bb62d2acc3938129d5d36bc28cf + checksum: 8b7fcdca69deb284fed7d2025b73eb747ce37f9aca6af53422844f46427152d5440601b6e2a033e77856a2f0591e4167153d5a21b68674ad11f662034ec13ced languageName: node linkType: hard @@ -41078,7 +41157,7 @@ __metadata: languageName: node linkType: hard -"which-boxed-primitive@npm:^1.0.2": +"which-boxed-primitive@npm:^1.0.1, which-boxed-primitive@npm:^1.0.2": version: 1.0.2 resolution: "which-boxed-primitive@npm:1.0.2" dependencies: @@ -41091,6 +41170,18 @@ __metadata: languageName: node linkType: hard +"which-collection@npm:^1.0.1": + version: 1.0.1 + resolution: "which-collection@npm:1.0.1" + dependencies: + is-map: ^2.0.1 + is-set: ^2.0.1 + is-weakmap: ^2.0.1 + is-weakset: ^2.0.1 + checksum: 249f913e1758ed2f06f00706007d87dc22090a80591a56917376e70ecf8fc9ab6c41d98e1c87208bb9648676f65d4b09c0e4d23c56c7afb0f0a73a27d701df5d + languageName: node + linkType: hard + "which-module@npm:^2.0.0": version: 2.0.0 resolution: "which-module@npm:2.0.0" @@ -41248,9 +41339,9 @@ __metadata: linkType: hard "workerpool@npm:^6.0.3": - version: 6.2.1 - resolution: "workerpool@npm:6.2.1" - checksum: f0efd2d74eafd58eaeb36d7d85837d080f75c52b64893cff317b66257dd308e5c9f85ef0b12904f6c7f24ed2365bc3cfeba1f1d16aa736d84d6ef8156ae37c80 + version: 6.3.0 + resolution: "workerpool@npm:6.3.0" + checksum: 88fbf47a978a7be021ba5129439c7f3ffd1f2ff14c2a792b2aeec6e50ae6325786121435ec1b6779be551b5ba0e8dd03f77ac8c73944c3f51b4ebc337ab37e98 languageName: node linkType: hard From 554be961f1f31d0bc02efd99af21cd6701686925 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Tue, 25 Oct 2022 13:54:59 +0200 Subject: [PATCH 37/38] fixes --- code/lib/client-api/src/ClientApi.ts | 4 ++-- code/lib/core-common/src/utils/get-renderer-name.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/code/lib/client-api/src/ClientApi.ts b/code/lib/client-api/src/ClientApi.ts index 714c057e7e7e..68eb2e897239 100644 --- a/code/lib/client-api/src/ClientApi.ts +++ b/code/lib/client-api/src/ClientApi.ts @@ -23,13 +23,13 @@ import type { Store_NormalizedComponentAnnotations, Store_Path, Store_ModuleImportFn, + Store_ModuleExports, } from '@storybook/types'; import { combineParameters, composeStepRunners, StoryStore, normalizeInputTypes, - ModuleExports, } from '@storybook/store'; import { StoryStoreFacade } from './StoryStoreFacade'; @@ -214,7 +214,7 @@ export class ClientApi { // storiesOf file to finish adding stories, and us to load it into the facade as a // single psuedo-CSF file. So instead we just keep collecting the CSF files and load // them all into the facade at the end. - _addedExports = {} as Record; + _addedExports = {} as Record; _loadAddedExports() { // eslint-disable-next-line no-underscore-dangle diff --git a/code/lib/core-common/src/utils/get-renderer-name.ts b/code/lib/core-common/src/utils/get-renderer-name.ts index b4a90e8cbcbd..375190affb60 100644 --- a/code/lib/core-common/src/utils/get-renderer-name.ts +++ b/code/lib/core-common/src/utils/get-renderer-name.ts @@ -1,5 +1,5 @@ import { dedent } from 'ts-dedent'; -import type { Options } from '../types'; +import type { Options } from '@storybook/types'; /** * Render is set as a string on core. It must be set by the framework From b9ae97c8ede368c5241a26093e659812c46ad1be Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Tue, 25 Oct 2022 14:08:03 +0200 Subject: [PATCH 38/38] fixes --- code/workspace.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/workspace.json b/code/workspace.json index ea5c6ceaf1b1..ee1c8b28c79e 100644 --- a/code/workspace.json +++ b/code/workspace.json @@ -103,7 +103,7 @@ }, "@storybook/blocks": { "implicitDependencies": ["@storybook/types"], - "root": "lib/blocks", + "root": "ui/blocks", "type": "library" }, "@storybook/builder-manager": {