diff --git a/.circleci/config.yml b/.circleci/config.yml
index ef32f6fb4984..f6674fc9c46c 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -19,7 +19,7 @@ executors:
docker:
- image: cimg/node:16.17.1
environment:
- NODE_OPTIONS: --max_old_space_size=3076
+ NODE_OPTIONS: --max_old_space_size=6144
resource_class: <>
sb_node_16_browsers:
parameters:
@@ -32,7 +32,7 @@ executors:
docker:
- image: cimg/node:16.17.1-browsers
environment:
- NODE_OPTIONS: --max_old_space_size=3076
+ NODE_OPTIONS: --max_old_space_size=6144
resource_class: <>
sb_playwright:
parameters:
@@ -43,14 +43,15 @@ executors:
default: 'small'
working_directory: /tmp/storybook
docker:
- - image: mcr.microsoft.com/playwright:v1.27.0-focal
+ - image: mcr.microsoft.com/playwright:v1.28.0-focal
environment:
- NODE_OPTIONS: --max_old_space_size=3076
+ NODE_OPTIONS: --max_old_space_size=6144
resource_class: <>
orbs:
git-shallow-clone: guitarrapc/git-shallow-clone@2.4.0
browser-tools: circleci/browser-tools@1.4.0
+ discord: antonioned/discord@0.1.0
commands:
# Forked off from https://github.com/guitarrapc/git-shallow-clone-orb
@@ -101,7 +102,7 @@ commands:
then
export HOME=$(getent passwd $(id -un) | cut -d: -f6)
fi
-
+
# known_hosts
mkdir -p ~/.ssh
if [ -x "$(command -v ssh-keyscan)" ] && ([ "<< parameters.keyscan_github >>" == "true" ] || [ "<< parameters.keyscan_bitbucket >>" == "true" ])
@@ -125,19 +126,19 @@ commands:
echo 'bitbucket.org ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/VqLat/MaB33pZy0y3rJZtnqwR2qOOvbwKZYKiEO1O6VqNEBxKvJJelCq0dTXWT5pbO2gDXC6h6QDXCaHo6pOHGPUy+YBaGQRGuSusMEASYiWunYN0vCAI8QaXnWMXNMdFP3jHAJH0eDsoiGnLPBlBp4TNm6rYI74nMzgz3B9IikW4WVK+dc8KZJZWYjAuORU3jc1c/NPskD2ASinf8v3xnfXeukU0sJ5N6m5E8VLjObPEO+mN2t/FZTMZLiFqPWc/ALSqnMnnhwrNi2rbfg/rd/IpL8Le3pSBne8+seeFVBoGqzHM9yXw==
' >> ~/.ssh/known_hosts
fi
-
+
(umask 077; touch ~/.ssh/id_rsa)
chmod 0600 ~/.ssh/id_rsa
(echo $CHECKOUT_KEY > ~/.ssh/id_rsa)
-
+
# use git+ssh instead of https
git config --global url."ssh://git@github.com".insteadOf "https://github.com" || true
git config --global gc.auto 0 || true
-
+
# checkout
git clone << parameters.clone_options >> $CIRCLE_REPOSITORY_URL "<< parameters.path >>"
cd "<< parameters.path >>"
-
+
# Fetch remote and check the commit ID of the checked out code
if [ -n "$CIRCLE_TAG" ]
then
@@ -151,7 +152,7 @@ commands:
# others
git fetch << parameters.fetch_options >> --force origin "$CIRCLE_BRANCH:remotes/origin/$CIRCLE_BRANCH"
fi
-
+
# Check the commit ID of the checked out code
if [ -n "$CIRCLE_TAG" ]
then
@@ -162,7 +163,7 @@ commands:
git reset --hard "$CIRCLE_SHA1"
git checkout -q -B "$CIRCLE_BRANCH"
fi
-
+
git reset --hard "$CIRCLE_SHA1"
name: Checkout code shallow
cancel-workflow-on-failure:
@@ -175,7 +176,36 @@ commands:
echo "Canceling workflow as previous step resulted in failure."
echo "To execute all checks locally, please run yarn ci-tests"
curl -X POST --header "Content-Type: application/json" "https://circleci.com/api/v2/workflow/${CIRCLE_WORKFLOW_ID}/cancel?circle-token=${WORKFLOW_CANCELER}"
+ report-workflow-on-failure:
+ description: 'Reports failures to discord'
+ parameters:
+ template:
+ description: |
+ Which template to report in discord. Applicable for parallel sandbox jobs
+ type: string
+ default: 'none'
+ steps:
+ - run:
+ when: on_fail
+ command: git fetch --unshallow
+ - discord/status:
+ only_for_branches: main,next,next-release,latest-release
+ fail_only: true
+ failure_message: $(yarn get-report-message << pipeline.parameters.workflow >> << parameters.template >>)
jobs:
+ pretty-docs:
+ executor:
+ class: small
+ name: sb_node_16_classic
+ steps:
+ - checkout_advanced:
+ clone_options: '--depth 1 --verbose'
+ - run:
+ name: Prettier
+ command: |
+ cd scripts
+ yarn
+ yarn docs:prettier:check
build:
executor:
class: large
@@ -197,6 +227,7 @@ jobs:
command: |
cd code
yarn local-registry --publish
+ - report-workflow-on-failure
- save_cache:
name: Save Yarn cache
key: build-yarn-2-cache-v4--{{ checksum "code/yarn.lock" }}--{{ checksum "scripts/yarn.lock" }}
@@ -241,21 +272,22 @@ jobs:
name: set up cra repro, skip tests
command: |
cd code
- node ./lib/cli/bin/index.js repro-next cra/default-js --output ../../cra-bench
+ SANDBOX_ROOT=../bench yarn task --task sandbox --template cra/default-ts --skip-template-stories --start-from=never --no-link
- run:
name: Run @storybook/bench on repro
command: |
- cd ../cra-bench
+ cd bench/cra-default-ts
rm -rf node_modules
mkdir node_modules
- npx -p @storybook/bench@0.7.6--canary.14.6702e4f.0 sb-bench 'yarn install' --label cra
+ npx -p @storybook/bench@next sb-bench 'yarn install' --label cra
+ - report-workflow-on-failure
- run:
name: prep artifacts
when: always
- command: tar cvzf /tmp/sb-bench.tar.gz ../cra-bench
+ command: tar cvzf /tmp/cra-default-ts-bench.tar.gz bench/cra-default-ts
- store_artifacts:
- path: /tmp/sb-bench.tar.gz
- destination: sb-bench.tar.gz
+ path: /tmp/cra-default-ts-bench.tar.gz
+ destination: cra-default-ts-bench.tar.gz
react-vite-bench:
executor:
class: large
@@ -281,24 +313,25 @@ jobs:
name: set up react-vite repro, skip tests
command: |
cd code
- node ./lib/cli/bin/index.js repro-next react-vite/default-ts --output ../../react-vite-bench
+ SANDBOX_ROOT=../bench yarn task --task sandbox --template react-vite/default-ts --skip-template-stories --start-from=never --no-link
- run:
name: Run @storybook/bench on repro
command: |
- cd ../react-vite-bench
+ cd bench/react-vite-default-ts
rm -rf node_modules
mkdir node_modules
- npx -p @storybook/bench@0.7.6--canary.14.6702e4f.0 sb-bench 'yarn install' --label react-vite
+ npx -p @storybook/bench@next sb-bench 'yarn install' --label react-vite
+ - report-workflow-on-failure
- run:
name: prep artifacts
when: always
- command: tar cvzf /tmp/sb-bench.tar.gz ../react-vite-bench
+ command: tar cvzf /tmp/react-vite-default-ts-bench.tar.gz bench/react-vite-default-ts
- store_artifacts:
- path: /tmp/sb-bench.tar.gz
- destination: sb-bench.tar.gz
+ path: /tmp/react-vite-default-ts-bench.tar.gz
+ destination: react-vite-default-ts-bench.tar.gz
lint:
executor:
- class: medium
+ class: large
name: sb_node_16_classic
steps:
- checkout_advanced:
@@ -310,6 +343,7 @@ jobs:
command: |
cd code
yarn lint
+ - report-workflow-on-failure
- cancel-workflow-on-failure
check:
executor:
@@ -325,6 +359,7 @@ jobs:
command: |
yarn task --task check --start-from=auto --no-link --debug
git diff --exit-code
+ - report-workflow-on-failure
- cancel-workflow-on-failure
script-unit-tests:
executor: sb_node_16_browsers
@@ -340,6 +375,7 @@ jobs:
yarn test --coverage --ci
- store_test_results:
path: scripts/junit.xml
+ - report-workflow-on-failure
- cancel-workflow-on-failure
unit-tests:
executor:
@@ -354,13 +390,14 @@ jobs:
name: Test
command: |
cd code
- yarn test --coverage --ci
+ yarn test --coverage --ci --maxWorkers=6
- store_test_results:
path: code/junit.xml
- persist_to_workspace:
root: .
paths:
- code/coverage
+ - report-workflow-on-failure
- cancel-workflow-on-failure
coverage:
executor:
@@ -376,10 +413,13 @@ jobs:
command: |
cd code
yarn coverage
+ - report-workflow-on-failure
chromatic-internal-storybooks:
executor:
- class: medium
+ class: medium+
name: sb_node_16_browsers
+ environment:
+ NODE_OPTIONS: --max_old_space_size=6144
steps:
# switched this to the CircleCI helper to get the full git history for TurboSnap
- checkout
@@ -391,6 +431,7 @@ jobs:
cd code
yarn storybook:ui:chromatic
yarn storybook:blocks:chromatic
+ - report-workflow-on-failure
- store_test_results:
path: test-results
## new workflow
@@ -410,7 +451,9 @@ jobs:
at: .
- run:
name: Creating Sandboxes
- command: yarn task --task sandbox --template $(yarn get-template << pipeline.parameters.workflow >> create) --no-link --start-from=never --junit
+ command: yarn task --task sandbox --template $(yarn get-template << pipeline.parameters.workflow >> sandbox) --no-link --start-from=never --junit
+ - report-workflow-on-failure:
+ template: $(yarn get-template << pipeline.parameters.workflow >> sandbox)
- persist_to_workspace:
root: .
paths:
@@ -434,6 +477,8 @@ jobs:
- run:
name: Smoke Testing Sandboxes
command: yarn task --task smoke-test --template $(yarn get-template << pipeline.parameters.workflow >> smoke-test) --no-link --start-from=never --junit
+ - report-workflow-on-failure:
+ template: $(yarn get-template << pipeline.parameters.workflow >> smoke-test)
- store_test_results:
path: test-results
build-sandboxes:
@@ -453,6 +498,8 @@ jobs:
- run:
name: Building Sandboxes
command: yarn task --task build --template $(yarn get-template << pipeline.parameters.workflow >> build) --no-link --start-from=never --junit
+ - report-workflow-on-failure:
+ template: $(yarn get-template << pipeline.parameters.workflow >> build)
- store_test_results:
path: test-results
- persist_to_workspace:
@@ -476,6 +523,8 @@ jobs:
- run:
name: Running Test Runner
command: yarn task --task test-runner --template $(yarn get-template << pipeline.parameters.workflow >> test-runner) --no-link --start-from=never --junit
+ - report-workflow-on-failure:
+ template: $(yarn get-template << pipeline.parameters.workflow >> test-runner)
- store_test_results:
path: test-results
chromatic-sandboxes:
@@ -494,6 +543,8 @@ jobs:
- run:
name: Running Chromatic
command: yarn task --task chromatic --template $(yarn get-template << pipeline.parameters.workflow >> chromatic) --no-link --start-from=never --junit
+ - report-workflow-on-failure:
+ template: $(yarn get-template << pipeline.parameters.workflow >> chromatic)
- store_test_results:
path: test-results
e2e-sandboxes:
@@ -513,6 +564,8 @@ jobs:
- run:
name: Running E2E Tests
command: yarn task --task e2e-tests --template $(yarn get-template << pipeline.parameters.workflow >> e2e-tests) --no-link --start-from=never --junit
+ - report-workflow-on-failure:
+ template: $(yarn get-template << pipeline.parameters.workflow >> e2e-tests)
- store_test_results:
path: test-results
- store_artifacts: # this is where playwright puts more complex stuff
@@ -523,9 +576,10 @@ workflows:
ci:
when:
and:
- - equal: [ api, << pipeline.trigger_source >> ]
- - equal: [ ci, << pipeline.parameters.workflow >> ]
+ - equal: [api, << pipeline.trigger_source >>]
+ - equal: [ci, << pipeline.parameters.workflow >>]
jobs:
+ - pretty-docs
- build
- lint:
requires:
@@ -556,8 +610,9 @@ workflows:
- build-sandboxes
pr:
when:
- equal: [ pr, << pipeline.parameters.workflow >> ]
+ equal: [pr, << pipeline.parameters.workflow >>]
jobs:
+ - pretty-docs
- build
- lint:
requires:
@@ -605,8 +660,9 @@ workflows:
- build-sandboxes
merged:
when:
- equal: [ merged, << pipeline.parameters.workflow >> ]
+ equal: [merged, << pipeline.parameters.workflow >>]
jobs:
+ - pretty-docs
- build
- lint:
requires:
@@ -633,11 +689,11 @@ workflows:
requires:
- build
- create-sandboxes:
- parallelism: 14
+ parallelism: 15
requires:
- build
- build-sandboxes:
- parallelism: 14
+ parallelism: 15
requires:
- create-sandboxes
- test-runner-sandboxes:
@@ -645,27 +701,27 @@ workflows:
requires:
- build-sandboxes
- chromatic-sandboxes:
- parallelism: 14
+ parallelism: 15
requires:
- build-sandboxes
- e2e-sandboxes:
- parallelism: 14
+ parallelism: 15
requires:
- build-sandboxes
daily:
when:
- equal: [ daily, << pipeline.parameters.workflow >> ]
+ equal: [daily, << pipeline.parameters.workflow >>]
jobs:
- build
- create-sandboxes:
- parallelism: 24
+ parallelism: 25
requires:
- build
# - smoke-test-sandboxes: # disabled for now
# requires:
# - create-sandboxes
- build-sandboxes:
- parallelism: 24
+ parallelism: 25
requires:
- create-sandboxes
- test-runner-sandboxes:
@@ -673,10 +729,10 @@ workflows:
requires:
- build-sandboxes
- chromatic-sandboxes:
- parallelism: 24
+ parallelism: 25
requires:
- build-sandboxes
- e2e-sandboxes:
- parallelism: 24
+ parallelism: 25
requires:
- - build-sandboxes
\ No newline at end of file
+ - build-sandboxes
diff --git a/.github/workflows/generate-repros-next.yml b/.github/workflows/generate-repros-next.yml
index 42b36076d37b..fcd1ee8072c5 100644
--- a/.github/workflows/generate-repros-next.yml
+++ b/.github/workflows/generate-repros-next.yml
@@ -28,6 +28,12 @@ jobs:
run: node ./scripts/check-dependencies.js
- name: Compile Storybook libraries
run: yarn task --task publish --start-from=auto --no-link
+ - name: Running local registry
+ run: yarn local-registry --port 6001 --open &
+ working-directory: ./code
+ - name: Wait for registry
+ run: yarn wait-on http://localhost:6001
+ working-directory: ./code
- name: Generate repros
run: yarn generate-repros-next --local-registry
working-directory: ./code
diff --git a/.gitignore b/.gitignore
index 41baa60da98e..25b6e5a7b525 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,6 +10,7 @@ junit.xml
test-results
/repros
/sandbox
+/bench
.verdaccio-cache
# Yarn stuff
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5faead8d09d2..39bce5bab28e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,86 @@
+## 7.0.0-alpha.51 (November 19, 2022)
+
+#### Bug Fixes
+
+- NextJS: Fix out-of-the-box babel handling [#19842](https://github.com/storybooks/storybook/pull/19842)
+- NextJS: Fix import url on windows [#19798](https://github.com/storybooks/storybook/pull/19798)
+- UI: Fix panel invisible for any addon listed after the interactions panel [#19771](https://github.com/storybooks/storybook/pull/19771)
+- Core: Bail preview builder on failure [#19849](https://github.com/storybooks/storybook/pull/19849)
+- Core: Fix double esbuild-register register [#19852](https://github.com/storybooks/storybook/pull/19852)
+- Composition: Fix regression in the `#root` to `#storybook-root` change [#19848](https://github.com/storybooks/storybook/pull/19848)
+- UI: Fix `showPanel=false` doesn't work on mobile view [#19807](https://github.com/storybooks/storybook/pull/19807)
+
+#### Maintenance
+
+- CLI: Replace degit with giget [#19870](https://github.com/storybooks/storybook/pull/19870)
+- Build: Bundle lib/channel-websocket with tsup [#19694](https://github.com/storybooks/storybook/pull/19694)
+- Maintenance: Upgrade monorepo to TS 4.9 [#19869](https://github.com/storybooks/storybook/pull/19869)
+
+#### Build
+
+- Build: Downgrade @types/node [#19890](https://github.com/storybooks/storybook/pull/19890)
+- Maintenance: Add angular 14 template and skip test runner on angular 15 for now [#19871](https://github.com/storybooks/storybook/pull/19871)
+- Build: Upgrade Jest to 29 [#19863](https://github.com/storybooks/storybook/pull/19863)
+- Build: Fix chromatic version to 6.11.2 in local scripts [#19889](https://github.com/storybooks/storybook/pull/19889)
+- Build: Pin chromatic version to 6.11.2 to temporary fix flakiness [#19874](https://github.com/storybooks/storybook/pull/19874)
+
+#### Dependency Upgrades
+
+- Bump mdx2-csf dependency [#19885](https://github.com/storybooks/storybook/pull/19885)
+
+## 7.0.0-alpha.50 (November 17, 2022)
+
+#### Features
+
+- Expose more CSF types in all renderers [#19833](https://github.com/storybooks/storybook/pull/19833)
+- CSF: Renamed Framework to Renderer [#19802](https://github.com/storybooks/storybook/pull/19802)
+
+#### Bug Fixes
+
+- Next.js: use file path instead of image contents for next-image-loader-stub [#19858](https://github.com/storybooks/storybook/pull/19858)
+- TypeScript: Fix type inference bug with decorators [#19839](https://github.com/storybooks/storybook/pull/19839)
+- Vite: Keep using absolute path node_modules splitting [#19836](https://github.com/storybooks/storybook/pull/19836)
+- Vite: Fix preview annotation paths on Windows [#19822](https://github.com/storybooks/storybook/pull/19822)
+- Fix csf-plugin ignoring options [#19823](https://github.com/storybooks/storybook/pull/19823)
+- Controls: Checkbox does not update when using useArgs hook [#19508](https://github.com/storybooks/storybook/pull/19508)
+
+#### Maintenance
+
+- Jest: switch from Parameters to StorybookInternalParameters [#19853](https://github.com/storybooks/storybook/pull/19853)
+- Blocks: Story stories [#19805](https://github.com/storybooks/storybook/pull/19805)
+- Blocks: Canvas stories [#19804](https://github.com/storybooks/storybook/pull/19804)
+- Tech: TypeScript should check stories and tests as well [#19831](https://github.com/storybooks/storybook/pull/19831)
+
+#### Build
+
+- UI Storybook: Disable sourcemaps when building in CI [#19862](https://github.com/storybooks/storybook/pull/19862)
+- Build: Increase max node memory for jobs [#19856](https://github.com/storybooks/storybook/pull/19856)
+- CI: improve error reporting mechanism [#19841](https://github.com/storybooks/storybook/pull/19841)
+- Fix tests on Windows [#19777](https://github.com/storybooks/storybook/pull/19777)
+- Build: Fix benchmark to run on local packages [#19832](https://github.com/storybooks/storybook/pull/19832)
+- CI: Report failures on discord [#19801](https://github.com/storybooks/storybook/pull/19801)
+
+## 7.0.0-alpha.49 (November 13, 2022)
+
+#### Bug Fixes
+
+- Essentials: Fix preview annotations for Vite pnpm support [#19689](https://github.com/storybooks/storybook/pull/19689)
+
+#### Maintenance
+
+- Build: convert addon-docs to use ts-up [#19790](https://github.com/storybooks/storybook/pull/19790)
+- Core: Allow overriding WebView and UrlStore [#19623](https://github.com/storybooks/storybook/pull/19623)
+- Storyshots: Support .cjs and .mjs file extensions [#19726](https://github.com/storybooks/storybook/pull/19726)
+
+#### Build
+
+- Build: less noise when compiling [#19808](https://github.com/storybooks/storybook/pull/19808)
+- Build: Upgrade bench to `next` [#19791](https://github.com/storybooks/storybook/pull/19791)
+- Maintenance: improve error feedback when tasks fail in CI [#19786](https://github.com/storybooks/storybook/pull/19786)
+- UI: Enable TurboSnap for UI Storybook [#19767](https://github.com/storybooks/storybook/pull/19767)
+- CI: Use a new cadence (ci, pr, merged, daily) and trigger CircleCI from github actions [#19768](https://github.com/storybooks/storybook/pull/19768)
+- Maintenance: provide expected failure metadata in junit reports [#19775](https://github.com/storybooks/storybook/pull/19775)
+
## 7.0.0-alpha.48 (November 7, 2022)
#### Breaking Changes
@@ -542,9 +625,10 @@ Bad publish
#### Bug Fixes
-- CLI: Fix race condition in sb init [#19083](https://github.com/storybooks/storybook/pull/19083)
-- Vite: Fix framework option checks, and SSv6 [#19062](https://github.com/storybooks/storybook/pull/19062)
-- Core: Fix WebProjectAnnotations export in preview-web for back-compat [#19048](https://github.com/storybooks/storybook/pull/19048)
+- CLI: Fix race condition in sb init [#19083](https://github.com/storybooks/storybook/pull/19083)
+- Vite: Fix framework option checks, and SSv6 [#19062](https://github.com/storybooks/storybook/pull/19062)
+- Core: Fix WebProjectAnnotations export in preview-web for back-compat [#19048](https://github.com/storybooks/storybook/pull/19048)
+- Blocks: Fix Checkbox control update when using useArgs hook
#### Maintenance
diff --git a/MIGRATION.md b/MIGRATION.md
index 06dac6694ebb..2f9f0c15c407 100644
--- a/MIGRATION.md
+++ b/MIGRATION.md
@@ -43,7 +43,9 @@
- [7.0 Deprecations](#70-deprecations)
- [`Story` type deprecated](#story-type-deprecated)
- [`ComponentStory`, `ComponentStoryObj`, `ComponentStoryFn` and `ComponentMeta` types are deprecated](#componentstory-componentstoryobj-componentstoryfn-and-componentmeta-types-are-deprecated)
- - [Renamed `renderToDOM` to `renderToCanvas`](#renamed-rendertodom-to-rendertoroot)
+ - [Renamed `renderToDOM` to `renderToCanvas`](#renamed-rendertodom-to-rendertocanvas)
+ - [Renamed `XFramework` to `XRenderer`](#renamed-xframework-to-xrenderer)
+ - [Renamed `DecoratorFn` to `Decorator`](#renamed-decoratorfn-to-decorator)
- [From version 6.4.x to 6.5.0](#from-version-64x-to-650)
- [Vue 3 upgrade](#vue-3-upgrade)
- [React18 new root API](#react18-new-root-api)
@@ -841,6 +843,69 @@ CSF2Story.args = { label: 'Label' };
The "rendering" function that renderers (ex-frameworks) must export (`renderToDOM`) has been renamed to `renderToCanvas` to acknowledge that some consumers of frameworks/the preview do not work with DOM elements.
+#### Renamed `XFramework` to `XRenderer`
+
+In 6.x you could import XFramework types:
+
+```ts
+import type { ReactFramework } from '@storybook/react';
+import type { VueFramework } from '@storybook/vue';
+import type { SvelteFramework } from '@storybook/svelte';
+
+// etc.
+```
+
+Those are deprecated in 7.0 as they are renamed to:
+
+```ts
+import type { ReactRenderer } from '@storybook/react';
+import type { VueRenderer } from '@storybook/vue';
+import type { SvelteRenderer } from '@storybook/svelte';
+
+// etc.
+```
+
+#### Renamed `DecoratorFn` to `Decorator`
+
+In 6.x you could import the type `DecoratorFn`:
+
+```ts
+import type { DecoratorFn } from '@storybook/react';
+```
+
+This type is deprecated in 7.0, instead you can use the type `Decorator`, which is now available for all renderers:
+
+```ts
+import type { Decorator } from '@storybook/react';
+// or
+import type { Decorator } from '@storybook/vue';
+// or
+import type { Decorator } from '@storybook/svelte';
+// etc.
+```
+
+The type `Decorator` accepts a generic parameter `TArgs`. This can be used like this:
+
+```tsx
+import type { Decorator } from '@storybook/react';
+import { LocaleProvider } from './locale';
+
+const withLocale: Decorator<{ locale: 'en' | 'es' }> = (Story, { args }) => (
+
+
+
+);
+```
+
+If you want to use `Decorator` in a backwards compatible way to `DecoratorFn`, you can use:
+
+```tsx
+import type { Args, Decorator } from '@storybook/react';
+
+// Decorator behaves the same as DecoratorFn (without generic)
+const withLocale: Decorator = (Story, { args }) => // args has type { [name: string]: any }
+```
+
## From version 6.4.x to 6.5.0
### Vue 3 upgrade
diff --git a/README.md b/README.md
index fd4b1a777064..7462b6c9fcb7 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,12 @@
-
+
+
+
+
+
+
Build bulletproof UI components faster
diff --git a/code/.eslintignore b/code/.eslintignore
index 6f8539b9b7b6..3a410b6472bc 100644
--- a/code/.eslintignore
+++ b/code/.eslintignore
@@ -1,5 +1,4 @@
dist
-lib/**/dll
build
coverage
node_modules
diff --git a/code/addons/a11y/jest.config.js b/code/addons/a11y/jest.config.js
new file mode 100644
index 000000000000..4396fbc7010d
--- /dev/null
+++ b/code/addons/a11y/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.browser');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/addons/a11y/package.json b/code/addons/a11y/package.json
index 94be93335614..212f173d2ce2 100644
--- a/code/addons/a11y/package.json
+++ b/code/addons/a11y/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-a11y",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Test component compliance with web accessibility standards",
"keywords": [
"a11y",
@@ -62,15 +62,15 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/addon-highlight": "7.0.0-alpha.48",
- "@storybook/addons": "7.0.0-alpha.48",
- "@storybook/api": "7.0.0-alpha.48",
- "@storybook/channels": "7.0.0-alpha.48",
- "@storybook/client-logger": "7.0.0-alpha.48",
- "@storybook/components": "7.0.0-alpha.48",
- "@storybook/core-events": "7.0.0-alpha.48",
- "@storybook/theming": "7.0.0-alpha.48",
- "@storybook/types": "7.0.0-alpha.48",
+ "@storybook/addon-highlight": "7.0.0-alpha.51",
+ "@storybook/addons": "7.0.0-alpha.51",
+ "@storybook/api": "7.0.0-alpha.51",
+ "@storybook/channels": "7.0.0-alpha.51",
+ "@storybook/client-logger": "7.0.0-alpha.51",
+ "@storybook/components": "7.0.0-alpha.51",
+ "@storybook/core-events": "7.0.0-alpha.51",
+ "@storybook/theming": "7.0.0-alpha.51",
+ "@storybook/types": "7.0.0-alpha.51",
"axe-core": "^4.2.0",
"global": "^4.4.0",
"lodash": "^4.17.21",
@@ -78,7 +78,7 @@
},
"devDependencies": {
"@testing-library/react": "^11.2.2",
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
@@ -102,7 +102,7 @@
"./src/preview.tsx"
]
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd",
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded",
"storybook": {
"displayName": "Accessibility",
"icon": "https://user-images.githubusercontent.com/263385/101991665-47042f80-3c7c-11eb-8f00-64b5a18f498a.png",
diff --git a/code/addons/actions/jest.config.js b/code/addons/actions/jest.config.js
new file mode 100644
index 000000000000..4396fbc7010d
--- /dev/null
+++ b/code/addons/actions/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.browser');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/addons/actions/package.json b/code/addons/actions/package.json
index cd45f1d91c8e..bd85b1c9ba07 100644
--- a/code/addons/actions/package.json
+++ b/code/addons/actions/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-actions",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Get UI feedback when an action is performed on an interactive element",
"keywords": [
"storybook",
@@ -52,6 +52,19 @@
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
+ "typesVersions": {
+ "*": {
+ "*": [
+ "dist/index.d.ts"
+ ],
+ "manager": [
+ "dist/manager.d.ts"
+ ],
+ "preview": [
+ "dist/preview.d.ts"
+ ]
+ }
+ },
"files": [
"dist/**/*",
"README.md",
@@ -63,13 +76,13 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/addons": "7.0.0-alpha.48",
- "@storybook/api": "7.0.0-alpha.48",
- "@storybook/client-logger": "7.0.0-alpha.48",
- "@storybook/components": "7.0.0-alpha.48",
- "@storybook/core-events": "7.0.0-alpha.48",
- "@storybook/theming": "7.0.0-alpha.48",
- "@storybook/types": "7.0.0-alpha.48",
+ "@storybook/addons": "7.0.0-alpha.51",
+ "@storybook/api": "7.0.0-alpha.51",
+ "@storybook/client-logger": "7.0.0-alpha.51",
+ "@storybook/components": "7.0.0-alpha.51",
+ "@storybook/core-events": "7.0.0-alpha.51",
+ "@storybook/theming": "7.0.0-alpha.51",
+ "@storybook/types": "7.0.0-alpha.51",
"dequal": "^2.0.2",
"global": "^4.4.0",
"lodash": "^4.17.21",
@@ -82,7 +95,7 @@
},
"devDependencies": {
"@types/lodash": "^4.14.167",
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
@@ -107,7 +120,7 @@
"./src/preview.ts"
]
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd",
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded",
"storybook": {
"displayName": "Actions",
"unsupportedFrameworks": [
diff --git a/code/addons/actions/src/addArgsHelpers.ts b/code/addons/actions/src/addArgsHelpers.ts
index 6a91c6e1ddef..530cb76c0621 100644
--- a/code/addons/actions/src/addArgsHelpers.ts
+++ b/code/addons/actions/src/addArgsHelpers.ts
@@ -1,4 +1,4 @@
-import type { Args, Framework, ArgsEnhancer } from '@storybook/types';
+import type { Args, Renderer, ArgsEnhancer } from '@storybook/types';
import { action } from './runtime/action';
// interface ActionsParameter {
@@ -14,7 +14,7 @@ const isInInitialArgs = (name: string, initialArgs: Args) =>
* matches a regex, such as `^on.*` for react-style `onClick` etc.
*/
-export const inferActionsFromArgTypesRegex: ArgsEnhancer = (context) => {
+export const inferActionsFromArgTypesRegex: ArgsEnhancer = (context) => {
const {
initialArgs,
argTypes,
@@ -40,7 +40,7 @@ export const inferActionsFromArgTypesRegex: ArgsEnhancer = (context)
/**
* Add action args for list of strings.
*/
-export const addActionsFromArgTypes: ArgsEnhancer = (context) => {
+export const addActionsFromArgTypes: ArgsEnhancer = (context) => {
const {
initialArgs,
argTypes,
diff --git a/code/addons/actions/tsconfig.json b/code/addons/actions/tsconfig.json
index 25de4fbd3e60..a4429176e35f 100644
--- a/code/addons/actions/tsconfig.json
+++ b/code/addons/actions/tsconfig.json
@@ -3,13 +3,5 @@
"compilerOptions": {
"strict": true
},
- "include": ["src/**/*"],
- "exclude": [
- "src/**/*.test.*",
- "src/**/tests/**/*",
- "src/**/__tests__/**/*",
- "src/**/*.stories.*",
- "src/**/*.mockdata.*",
- "src/**/__testfixtures__/**"
- ]
+ "include": ["src/**/*"]
}
diff --git a/code/addons/backgrounds/jest.config.js b/code/addons/backgrounds/jest.config.js
new file mode 100644
index 000000000000..4396fbc7010d
--- /dev/null
+++ b/code/addons/backgrounds/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.browser');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/addons/backgrounds/package.json b/code/addons/backgrounds/package.json
index 2584ee916f76..b001b099307f 100644
--- a/code/addons/backgrounds/package.json
+++ b/code/addons/backgrounds/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-backgrounds",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Switch backgrounds to view components in different settings",
"keywords": [
"addon",
@@ -51,6 +51,19 @@
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
+ "typesVersions": {
+ "*": {
+ "*": [
+ "dist/index.d.ts"
+ ],
+ "manager": [
+ "dist/manager.d.ts"
+ ],
+ "preview": [
+ "dist/preview.d.ts"
+ ]
+ }
+ },
"files": [
"dist/**/*",
"README.md",
@@ -62,19 +75,19 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/addons": "7.0.0-alpha.48",
- "@storybook/api": "7.0.0-alpha.48",
- "@storybook/client-logger": "7.0.0-alpha.48",
- "@storybook/components": "7.0.0-alpha.48",
- "@storybook/core-events": "7.0.0-alpha.48",
- "@storybook/theming": "7.0.0-alpha.48",
- "@storybook/types": "7.0.0-alpha.48",
+ "@storybook/addons": "7.0.0-alpha.51",
+ "@storybook/api": "7.0.0-alpha.51",
+ "@storybook/client-logger": "7.0.0-alpha.51",
+ "@storybook/components": "7.0.0-alpha.51",
+ "@storybook/core-events": "7.0.0-alpha.51",
+ "@storybook/theming": "7.0.0-alpha.51",
+ "@storybook/types": "7.0.0-alpha.51",
"global": "^4.4.0",
"memoizerific": "^1.11.3",
"ts-dedent": "^2.0.0"
},
"devDependencies": {
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
@@ -98,7 +111,7 @@
"./src/preview.tsx"
]
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd",
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded",
"storybook": {
"displayName": "Backgrounds",
"icon": "https://user-images.githubusercontent.com/263385/101991667-479cc600-3c7c-11eb-96d3-410e936252e7.png",
diff --git a/code/addons/backgrounds/src/decorators/withBackground.ts b/code/addons/backgrounds/src/decorators/withBackground.ts
index 49500b8a7c12..309c6a8f7599 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 { Framework, PartialStoryFn as StoryFunction, StoryContext } from '@storybook/types';
+import type { Renderer, PartialStoryFn as StoryFunction, StoryContext } from '@storybook/types';
import { PARAM_KEY as BACKGROUNDS_PARAM_KEY } from '../constants';
import {
@@ -10,8 +10,8 @@ import {
} from '../helpers';
export const withBackground = (
- StoryFn: StoryFunction,
- context: StoryContext
+ StoryFn: StoryFunction,
+ context: StoryContext
) => {
const { globals, parameters } = context;
const globalsBackgroundColor = globals[BACKGROUNDS_PARAM_KEY]?.value;
diff --git a/code/addons/backgrounds/src/decorators/withGrid.ts b/code/addons/backgrounds/src/decorators/withGrid.ts
index 8e129dcf5af9..3647dd2f4cad 100644
--- a/code/addons/backgrounds/src/decorators/withGrid.ts
+++ b/code/addons/backgrounds/src/decorators/withGrid.ts
@@ -1,10 +1,10 @@
import { useMemo, useEffect } from '@storybook/addons';
-import type { Framework, PartialStoryFn as StoryFunction, StoryContext } from '@storybook/types';
+import type { Renderer, PartialStoryFn as StoryFunction, StoryContext } from '@storybook/types';
import { clearStyles, addGridStyle } from '../helpers';
import { PARAM_KEY as BACKGROUNDS_PARAM_KEY } from '../constants';
-export const withGrid = (StoryFn: StoryFunction, context: StoryContext) => {
+export const withGrid = (StoryFn: StoryFunction, context: StoryContext) => {
const { globals, parameters } = context;
const gridParameters = parameters[BACKGROUNDS_PARAM_KEY].grid;
const isActive = globals[BACKGROUNDS_PARAM_KEY]?.grid === true && gridParameters.disable !== true;
diff --git a/code/addons/backgrounds/tsconfig.json b/code/addons/backgrounds/tsconfig.json
index d23f9a406fc2..52d43eaaa9b9 100644
--- a/code/addons/backgrounds/tsconfig.json
+++ b/code/addons/backgrounds/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/addons/controls/jest.config.js b/code/addons/controls/jest.config.js
new file mode 100644
index 000000000000..4396fbc7010d
--- /dev/null
+++ b/code/addons/controls/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.browser');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/addons/controls/package.json b/code/addons/controls/package.json
index c51bf2682882..051c62d9dc00 100644
--- a/code/addons/controls/package.json
+++ b/code/addons/controls/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-controls",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Interact with component inputs dynamically in the Storybook UI",
"keywords": [
"addon",
@@ -46,6 +46,16 @@
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
+ "typesVersions": {
+ "*": {
+ "*": [
+ "dist/index.d.ts"
+ ],
+ "manager": [
+ "dist/manager.d.ts"
+ ]
+ }
+ },
"files": [
"dist/**/*",
"README.md",
@@ -57,16 +67,16 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/addons": "7.0.0-alpha.48",
- "@storybook/api": "7.0.0-alpha.48",
- "@storybook/blocks": "7.0.0-alpha.48",
- "@storybook/client-logger": "7.0.0-alpha.48",
- "@storybook/components": "7.0.0-alpha.48",
- "@storybook/core-common": "7.0.0-alpha.48",
- "@storybook/node-logger": "7.0.0-alpha.48",
- "@storybook/store": "7.0.0-alpha.48",
- "@storybook/theming": "7.0.0-alpha.48",
- "@storybook/types": "7.0.0-alpha.48",
+ "@storybook/addons": "7.0.0-alpha.51",
+ "@storybook/api": "7.0.0-alpha.51",
+ "@storybook/blocks": "7.0.0-alpha.51",
+ "@storybook/client-logger": "7.0.0-alpha.51",
+ "@storybook/components": "7.0.0-alpha.51",
+ "@storybook/core-common": "7.0.0-alpha.51",
+ "@storybook/node-logger": "7.0.0-alpha.51",
+ "@storybook/store": "7.0.0-alpha.51",
+ "@storybook/theming": "7.0.0-alpha.51",
+ "@storybook/types": "7.0.0-alpha.51",
"lodash": "^4.17.21",
"ts-dedent": "^2.0.0"
},
@@ -92,7 +102,7 @@
],
"platform": "browser"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd",
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded",
"storybook": {
"displayName": "Controls",
"icon": "https://user-images.githubusercontent.com/263385/101991669-479cc600-3c7c-11eb-93d9-38b67e8371f2.png",
diff --git a/code/addons/controls/tsconfig.json b/code/addons/controls/tsconfig.json
index 25de4fbd3e60..a4429176e35f 100644
--- a/code/addons/controls/tsconfig.json
+++ b/code/addons/controls/tsconfig.json
@@ -3,13 +3,5 @@
"compilerOptions": {
"strict": true
},
- "include": ["src/**/*"],
- "exclude": [
- "src/**/*.test.*",
- "src/**/tests/**/*",
- "src/**/__tests__/**/*",
- "src/**/*.stories.*",
- "src/**/*.mockdata.*",
- "src/**/__testfixtures__/**"
- ]
+ "include": ["src/**/*"]
}
diff --git a/code/addons/docs/jest.config.js b/code/addons/docs/jest.config.js
new file mode 100644
index 000000000000..4396fbc7010d
--- /dev/null
+++ b/code/addons/docs/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.browser');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/addons/docs/package.json b/code/addons/docs/package.json
index 912874857cd0..e6cfee21fb79 100644
--- a/code/addons/docs/package.json
+++ b/code/addons/docs/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-docs",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Document component usage and properties in Markdown",
"keywords": [
"addon",
@@ -24,9 +24,44 @@
"url": "https://opencollective.com/storybook"
},
"license": "MIT",
- "main": "dist/cjs/index.js",
- "module": "dist/esm/index.js",
- "types": "dist/types/index.d.ts",
+ "exports": {
+ ".": {
+ "require": "./dist/index.js",
+ "import": "./dist/index.mjs",
+ "types": "./dist/index.d.ts"
+ },
+ "./preview": {
+ "require": "./dist/preview.js",
+ "import": "./dist/preview.mjs",
+ "types": "./dist/preview.d.ts"
+ },
+ "./preset": {
+ "require": "./dist/preset.js",
+ "import": "./dist/preset.mjs",
+ "types": "./dist/preset.d.ts"
+ },
+ "./dist/preview": {
+ "require": "./dist/preview.js",
+ "import": "./dist/preview.mjs",
+ "types": "./dist/preview.d.ts"
+ },
+ "./dist/preset": {
+ "require": "./dist/preset.js",
+ "import": "./dist/preset.mjs",
+ "types": "./dist/preset.d.ts"
+ },
+ "./svelte/HOC.svelte": "./svelte/HOC.svelte",
+ "./ember": "./ember/index.js",
+ "./ember/index.js": "./ember/index.js",
+ "./angular": "./angular/index.js",
+ "./angular/index.js": "./angular/index.js",
+ "./web-components/index.js": "./web-components/index.js",
+ "./jest-transform-mdx": "./jest-transform-mdx.js",
+ "./package.json": "./package.json"
+ },
+ "main": "dist/index.js",
+ "module": "dist/index.mjs",
+ "types": "dist/index.d.ts",
"files": [
"dist/**/*",
"angular/**/*",
@@ -46,29 +81,21 @@
],
"scripts": {
"check": "../../../scripts/node_modules/.bin/tsc --noEmit",
- "prep": "node ../../../scripts/prepare.js"
+ "prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@babel/plugin-transform-react-jsx": "^7.12.12",
- "@jest/transform": "^26.6.2",
+ "@babel/plugin-transform-react-jsx": "^7.19.0",
+ "@jest/transform": "^29.3.1",
"@mdx-js/react": "^2.1.5",
- "@storybook/addons": "7.0.0-alpha.48",
- "@storybook/api": "7.0.0-alpha.48",
- "@storybook/blocks": "7.0.0-alpha.48",
- "@storybook/components": "7.0.0-alpha.48",
- "@storybook/core-common": "7.0.0-alpha.48",
- "@storybook/core-events": "7.0.0-alpha.48",
- "@storybook/csf-plugin": "7.0.0-alpha.48",
- "@storybook/csf-tools": "7.0.0-alpha.48",
- "@storybook/docs-tools": "7.0.0-alpha.48",
+ "@storybook/blocks": "7.0.0-alpha.51",
+ "@storybook/components": "7.0.0-alpha.51",
+ "@storybook/csf-plugin": "7.0.0-alpha.51",
+ "@storybook/csf-tools": "7.0.0-alpha.51",
"@storybook/mdx2-csf": "next",
- "@storybook/node-logger": "7.0.0-alpha.48",
- "@storybook/postinstall": "7.0.0-alpha.48",
- "@storybook/preview-web": "7.0.0-alpha.48",
- "@storybook/store": "7.0.0-alpha.48",
- "@storybook/theming": "7.0.0-alpha.48",
- "@storybook/types": "7.0.0-alpha.48",
- "dequal": "^2.0.2",
+ "@storybook/node-logger": "7.0.0-alpha.51",
+ "@storybook/postinstall": "7.0.0-alpha.51",
+ "@storybook/preview-web": "7.0.0-alpha.51",
+ "@storybook/types": "7.0.0-alpha.51",
"fs-extra": "^9.0.1",
"global": "^4.4.0",
"remark-external-links": "^8.0.0",
@@ -76,8 +103,8 @@
"ts-dedent": "^2.0.0"
},
"devDependencies": {
- "@babel/core": "^7.12.10",
- "typescript": "~4.6.3"
+ "@babel/core": "^7.20.2",
+ "typescript": "^4.9.3"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
@@ -94,7 +121,14 @@
"publishConfig": {
"access": "public"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd",
+ "bundler": {
+ "entries": [
+ "./src/index.ts",
+ "./src/preset.ts",
+ "./src/preview.ts"
+ ]
+ },
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded",
"storybook": {
"displayName": "Docs",
"icon": "https://user-images.githubusercontent.com/263385/101991672-48355c80-3c7c-11eb-82d9-95fa12438f64.png",
diff --git a/code/addons/docs/preset.js b/code/addons/docs/preset.js
index e45ac5b4cec0..a83f95279e7f 100644
--- a/code/addons/docs/preset.js
+++ b/code/addons/docs/preset.js
@@ -1 +1 @@
-module.exports = require('./dist/cjs/preset');
+module.exports = require('./dist/preset');
diff --git a/code/addons/docs/preview.js b/code/addons/docs/preview.js
index e726cab5a1b6..49ad602f79f4 100644
--- a/code/addons/docs/preview.js
+++ b/code/addons/docs/preview.js
@@ -1 +1 @@
-export * from './dist/esm/preview';
+export * from './dist/preview';
diff --git a/code/addons/docs/src/DocsRenderer.tsx b/code/addons/docs/src/DocsRenderer.tsx
index fb55fcb33f06..b1c6a6391a16 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 type { Framework, Parameters } from '@storybook/types';
+import type { Renderer, 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';
@@ -14,14 +14,14 @@ export const defaultComponents: Record = {
...HeadersMdx,
};
-export class DocsRenderer {
- public render: DocsRenderFunction;
+export class DocsRenderer {
+ public render: DocsRenderFunction;
public unmount: (element: HTMLElement) => void;
constructor() {
this.render = (
- context: DocsContextProps,
+ context: DocsContextProps,
docsParameter: Parameters,
element: HTMLElement,
callback: () => void
@@ -33,6 +33,7 @@ export class DocsRenderer {
...defaultComponents,
...docsParameter?.components,
};
+
ReactDOM.render(
diff --git a/code/addons/docs/src/blocks.ts b/code/addons/docs/src/blocks.ts
deleted file mode 100644
index 119f7ce62757..000000000000
--- a/code/addons/docs/src/blocks.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from '@storybook/blocks';
diff --git a/code/addons/docs/src/index.ts b/code/addons/docs/src/index.ts
index 807e2656e5b8..b74399955f12 100644
--- a/code/addons/docs/src/index.ts
+++ b/code/addons/docs/src/index.ts
@@ -1,2 +1,2 @@
-export * from './blocks';
+export * from '@storybook/blocks';
export { DocsRenderer } from './DocsRenderer';
diff --git a/code/addons/docs/src/preset.ts b/code/addons/docs/src/preset.ts
index 0538a94fabd6..df92976b9696 100644
--- a/code/addons/docs/src/preset.ts
+++ b/code/addons/docs/src/preset.ts
@@ -16,12 +16,11 @@ import { loadCsf } from '@storybook/csf-tools';
// the jsx to transpile mdx, for now there will be a flag for that
// for more complex solutions we can find alone that we need to add '@babel/plugin-transform-react-jsx'
type BabelParams = {
- babelOptions?: any;
mdxBabelOptions?: any;
configureJSX?: boolean;
};
-function createBabelOptions({ babelOptions, mdxBabelOptions, configureJSX }: BabelParams) {
- const babelPlugins = mdxBabelOptions?.plugins || babelOptions?.plugins || [];
+function createBabelOptions({ mdxBabelOptions, configureJSX }: BabelParams) {
+ const babelPlugins = mdxBabelOptions?.plugins || [];
const filteredBabelPlugins = babelPlugins.filter((p: any) => {
const name = Array.isArray(p) ? p[0] : p;
@@ -40,13 +39,12 @@ function createBabelOptions({ babelOptions, mdxBabelOptions, configureJSX }: Bab
// don't use the root babelrc by default (users can override this in mdxBabelOptions)
babelrc: false,
configFile: false,
- ...babelOptions,
...mdxBabelOptions,
plugins,
};
}
-export async function webpack(
+async function webpack(
webpackConfig: any = {},
options: Options &
BabelParams & {
@@ -65,7 +63,6 @@ export async function webpack(
// it will reuse babel options that are already in use in storybook
// also, these babel options are chained with other presets.
const {
- babelOptions,
mdxBabelOptions,
configureJSX = true,
csfPluginOptions = {},
@@ -100,7 +97,7 @@ export async function webpack(
use: [
{
loader: resolvedBabelLoader,
- options: createBabelOptions({ babelOptions, mdxBabelOptions, configureJSX }),
+ options: createBabelOptions({ mdxBabelOptions, configureJSX }),
},
{
loader: mdxLoader,
@@ -128,7 +125,7 @@ export async function webpack(
use: [
{
loader: resolvedBabelLoader,
- options: createBabelOptions({ babelOptions, mdxBabelOptions, configureJSX }),
+ options: createBabelOptions({ mdxBabelOptions, configureJSX }),
},
{
loader: mdxLoader,
@@ -145,7 +142,7 @@ export async function webpack(
use: [
{
loader: resolvedBabelLoader,
- options: createBabelOptions({ babelOptions, mdxBabelOptions, configureJSX }),
+ options: createBabelOptions({ mdxBabelOptions, configureJSX }),
},
{
loader: mdxLoader,
@@ -160,7 +157,7 @@ export async function webpack(
return result;
}
-export const storyIndexers = (indexers: CoreCommon_StoryIndexer[] | null) => {
+const storyIndexers = (indexers: CoreCommon_StoryIndexer[] | null) => {
const mdxIndexer = async (fileName: string, opts: CoreCommon_IndexerOptions) => {
let code = (await fs.readFile(fileName, 'utf-8')).toString();
const { compile } = await import('@storybook/mdx2-csf');
@@ -176,7 +173,7 @@ export const storyIndexers = (indexers: CoreCommon_StoryIndexer[] | null) => {
];
};
-export const docs = (docsOptions: DocsOptions) => {
+const docs = (docsOptions: DocsOptions) => {
return {
...docsOptions,
enabled: true,
@@ -184,3 +181,13 @@ export const docs = (docsOptions: DocsOptions) => {
docsPage: true,
};
};
+
+/*
+ * This is a workaround for https://github.com/Swatinem/rollup-plugin-dts/issues/162
+ * something down the dependency chain is using typescript namespaces, which are not supported by rollup-plugin-dts
+ */
+const webpackX = webpack as any;
+const storyIndexersX = storyIndexers as any;
+const docsX = docs as any;
+
+export { webpackX as webpack, storyIndexersX as storyIndexers, docsX as docs };
diff --git a/code/addons/docs/src/shared.ts b/code/addons/docs/src/shared.ts
deleted file mode 100644
index 178bf46ca387..000000000000
--- a/code/addons/docs/src/shared.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-export const ADDON_ID = 'storybook/docs';
-export const PANEL_ID = `${ADDON_ID}/panel`;
-export const PARAM_KEY = `docs`;
-
-export const SNIPPET_RENDERED = `${ADDON_ID}/snippet-rendered`;
-
-export enum SourceType {
- /**
- * AUTO is the default
- *
- * Use the CODE logic if:
- * - the user has set a custom source snippet in `docs.source.code` story parameter
- * - the story is not an args-based story
- *
- * Use the DYNAMIC rendered snippet if the story is an args story
- */
- AUTO = 'auto',
-
- /**
- * Render the code extracted by source-loader
- */
- CODE = 'code',
-
- /**
- * Render dynamically-rendered source snippet from the story's virtual DOM (currently React only)
- */
- DYNAMIC = 'dynamic',
-}
diff --git a/code/addons/docs/tsconfig.json b/code/addons/docs/tsconfig.json
index b1bd17fc8aed..cf1e09965901 100644
--- a/code/addons/docs/tsconfig.json
+++ b/code/addons/docs/tsconfig.json
@@ -3,12 +3,5 @@
"compilerOptions": {
"skipLibCheck": true
},
- "include": ["src/**/*"],
- "exclude": [
- "src/**/*.test.*",
- "src/**/__tests__/**/*",
- "src/**/*.stories.*",
- "src/**/*.mockdata.*",
- "src/**/__testfixtures__/**"
- ]
+ "include": ["src/**/*"]
}
diff --git a/code/addons/essentials/jest.config.js b/code/addons/essentials/jest.config.js
new file mode 100644
index 000000000000..4396fbc7010d
--- /dev/null
+++ b/code/addons/essentials/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.browser');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/addons/essentials/package.json b/code/addons/essentials/package.json
index 7445ad9c83d3..65ed32752123 100644
--- a/code/addons/essentials/package.json
+++ b/code/addons/essentials/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-essentials",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Curated addons to bring out the best of Storybook",
"keywords": [
"addon",
@@ -27,6 +27,76 @@
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
+ "./actions/preview": {
+ "require": "./dist/actions/preview.js",
+ "import": "./dist/actions/preview.mjs",
+ "types": "./dist/actions/preview.d.ts"
+ },
+ "./actions/manager": {
+ "require": "./dist/actions/manager.js",
+ "import": "./dist/actions/manager.mjs",
+ "types": "./dist/actions/manager.d.ts"
+ },
+ "./backgrounds/preview": {
+ "require": "./dist/backgrounds/preview.js",
+ "import": "./dist/backgrounds/preview.mjs",
+ "types": "./dist/backgrounds/preview.d.ts"
+ },
+ "./backgrounds/manager": {
+ "require": "./dist/backgrounds/manager.js",
+ "import": "./dist/backgrounds/manager.mjs",
+ "types": "./dist/backgrounds/manager.d.ts"
+ },
+ "./controls/manager": {
+ "require": "./dist/controls/manager.js",
+ "import": "./dist/controls/manager.mjs",
+ "types": "./dist/controls/manager.d.ts"
+ },
+ "./docs/preview": {
+ "require": "./dist/docs/preview.js",
+ "import": "./dist/docs/preview.mjs",
+ "types": "./dist/docs/preview.d.ts"
+ },
+ "./docs/preset": {
+ "require": "./dist/docs/preset.js",
+ "import": "./dist/docs/preset.mjs",
+ "types": "./dist/docs/preset.d.ts"
+ },
+ "./highlight/preview": {
+ "require": "./dist/highlight/preview.js",
+ "import": "./dist/highlight/preview.mjs",
+ "types": "./dist/highlight/preview.d.ts"
+ },
+ "./measure/preview": {
+ "require": "./dist/measure/preview.js",
+ "import": "./dist/measure/preview.mjs",
+ "types": "./dist/measure/preview.d.ts"
+ },
+ "./measure/manager": {
+ "require": "./dist/measure/manager.js",
+ "import": "./dist/measure/manager.mjs",
+ "types": "./dist/measure/manager.d.ts"
+ },
+ "./outline/preview": {
+ "require": "./dist/outline/preview.js",
+ "import": "./dist/outline/preview.mjs",
+ "types": "./dist/outline/preview.d.ts"
+ },
+ "./outline/manager": {
+ "require": "./dist/outline/manager.js",
+ "import": "./dist/outline/manager.mjs",
+ "types": "./dist/outline/manager.d.ts"
+ },
+ "./toolbars/manager": {
+ "require": "./dist/toolbars/manager.js",
+ "import": "./dist/toolbars/manager.mjs",
+ "types": "./dist/toolbars/manager.d.ts"
+ },
+ "./viewport/manager": {
+ "require": "./dist/viewport/manager.js",
+ "import": "./dist/viewport/manager.mjs",
+ "types": "./dist/viewport/manager.d.ts"
+ },
"./package.json": "./package.json"
},
"main": "dist/index.js",
@@ -41,76 +111,51 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/addon-actions": "7.0.0-alpha.48",
- "@storybook/addon-backgrounds": "7.0.0-alpha.48",
- "@storybook/addon-controls": "7.0.0-alpha.48",
- "@storybook/addon-docs": "7.0.0-alpha.48",
- "@storybook/addon-highlight": "7.0.0-alpha.48",
- "@storybook/addon-measure": "7.0.0-alpha.48",
- "@storybook/addon-outline": "7.0.0-alpha.48",
- "@storybook/addon-toolbars": "7.0.0-alpha.48",
- "@storybook/addon-viewport": "7.0.0-alpha.48",
- "@storybook/addons": "7.0.0-alpha.48",
- "@storybook/api": "7.0.0-alpha.48",
- "@storybook/core-common": "7.0.0-alpha.48",
- "@storybook/node-logger": "7.0.0-alpha.48",
+ "@storybook/addon-actions": "7.0.0-alpha.51",
+ "@storybook/addon-backgrounds": "7.0.0-alpha.51",
+ "@storybook/addon-controls": "7.0.0-alpha.51",
+ "@storybook/addon-docs": "7.0.0-alpha.51",
+ "@storybook/addon-highlight": "7.0.0-alpha.51",
+ "@storybook/addon-measure": "7.0.0-alpha.51",
+ "@storybook/addon-outline": "7.0.0-alpha.51",
+ "@storybook/addon-toolbars": "7.0.0-alpha.51",
+ "@storybook/addon-viewport": "7.0.0-alpha.51",
+ "@storybook/addons": "7.0.0-alpha.51",
+ "@storybook/api": "7.0.0-alpha.51",
+ "@storybook/core-common": "7.0.0-alpha.51",
+ "@storybook/node-logger": "7.0.0-alpha.51",
"ts-dedent": "^2.0.0"
},
"devDependencies": {
- "@babel/core": "^7.12.10",
- "@storybook/vue": "7.0.0-alpha.48",
- "@types/jest": "^26.0.16",
- "typescript": "~4.6.3"
+ "@babel/core": "^7.20.2",
+ "@storybook/vue": "7.0.0-alpha.51",
+ "typescript": "^4.9.3"
},
"peerDependencies": {
"@babel/core": "^7.9.6"
},
- "peerDependenciesMeta": {
- "@storybook/angular": {
- "optional": true
- },
- "@storybook/html": {
- "optional": true
- },
- "@storybook/vue": {
- "optional": true
- },
- "@storybook/vue3": {
- "optional": true
- },
- "@storybook/web-components": {
- "optional": true
- },
- "lit": {
- "optional": true
- },
- "lit-html": {
- "optional": true
- },
- "react": {
- "optional": true
- },
- "react-dom": {
- "optional": true
- },
- "svelte": {
- "optional": true
- },
- "sveltedoc-parser": {
- "optional": true
- },
- "vue": {
- "optional": true
- }
- },
"publishConfig": {
"access": "public"
},
"bundler": {
"entries": [
- "./src/index.ts"
+ "./src/index.ts",
+ "./src/actions/preview.ts",
+ "./src/actions/manager.ts",
+ "./src/backgrounds/preview.ts",
+ "./src/backgrounds/manager.ts",
+ "./src/controls/manager.ts",
+ "./src/docs/preview.ts",
+ "./src/docs/preset.ts",
+ "./src/highlight/preview.ts",
+ "./src/measure/preview.ts",
+ "./src/measure/manager.ts",
+ "./src/outline/preview.ts",
+ "./src/outline/manager.ts",
+ "./src/toolbars/manager.ts",
+ "./src/viewport/manager.ts"
],
"platform": "node"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/addons/essentials/src/actions/manager.ts b/code/addons/essentials/src/actions/manager.ts
new file mode 100644
index 000000000000..7e125b743169
--- /dev/null
+++ b/code/addons/essentials/src/actions/manager.ts
@@ -0,0 +1,2 @@
+// @ts-expect-error The generated definition file is empty. https://github.com/egoist/tsup/issues/762
+export * from '@storybook/addon-actions/manager';
diff --git a/code/addons/essentials/src/actions/preview.ts b/code/addons/essentials/src/actions/preview.ts
new file mode 100644
index 000000000000..86c6d5f2e656
--- /dev/null
+++ b/code/addons/essentials/src/actions/preview.ts
@@ -0,0 +1,4 @@
+/* eslint-disable import/export */
+// TODO: We need to configure an eslint-import typescript resolver for export maps to be considered
+
+export * from '@storybook/addon-actions/preview';
diff --git a/code/addons/essentials/src/backgrounds/manager.ts b/code/addons/essentials/src/backgrounds/manager.ts
new file mode 100644
index 000000000000..bc51f1b22b4e
--- /dev/null
+++ b/code/addons/essentials/src/backgrounds/manager.ts
@@ -0,0 +1,2 @@
+// @ts-expect-error The generated definition file is empty. https://github.com/egoist/tsup/issues/762
+export * from '@storybook/addon-backgrounds/manager';
diff --git a/code/addons/essentials/src/backgrounds/preview.ts b/code/addons/essentials/src/backgrounds/preview.ts
new file mode 100644
index 000000000000..5e56121e4a03
--- /dev/null
+++ b/code/addons/essentials/src/backgrounds/preview.ts
@@ -0,0 +1,4 @@
+/* eslint-disable import/export */
+// TODO: We need to configure an eslint-import typescript resolver for export maps to be considered
+
+export * from '@storybook/addon-backgrounds/preview';
diff --git a/code/addons/essentials/src/controls/manager.ts b/code/addons/essentials/src/controls/manager.ts
new file mode 100644
index 000000000000..49e403523565
--- /dev/null
+++ b/code/addons/essentials/src/controls/manager.ts
@@ -0,0 +1,2 @@
+// @ts-expect-error The generated definition file is empty. https://github.com/egoist/tsup/issues/762
+export * from '@storybook/addon-controls/manager';
diff --git a/code/addons/essentials/src/docs/preset.ts b/code/addons/essentials/src/docs/preset.ts
new file mode 100644
index 000000000000..dca808a37dd7
--- /dev/null
+++ b/code/addons/essentials/src/docs/preset.ts
@@ -0,0 +1,2 @@
+/* eslint-disable import/export */
+export * from '@storybook/addon-docs/dist/preset';
diff --git a/code/addons/essentials/src/docs/preview.ts b/code/addons/essentials/src/docs/preview.ts
new file mode 100644
index 000000000000..176a03c1f83f
--- /dev/null
+++ b/code/addons/essentials/src/docs/preview.ts
@@ -0,0 +1 @@
+export * from '@storybook/addon-docs/dist/preview';
diff --git a/code/addons/essentials/src/highlight/preview.ts b/code/addons/essentials/src/highlight/preview.ts
new file mode 100644
index 000000000000..ffcf62555af2
--- /dev/null
+++ b/code/addons/essentials/src/highlight/preview.ts
@@ -0,0 +1,4 @@
+/* eslint-disable import/export */
+// TODO: We need to configure an eslint-import typescript resolver for export maps to be considered
+
+export * from '@storybook/addon-highlight/preview';
diff --git a/code/addons/essentials/src/index.ts b/code/addons/essentials/src/index.ts
index 861fd91162da..96fd171146bb 100644
--- a/code/addons/essentials/src/index.ts
+++ b/code/addons/essentials/src/index.ts
@@ -1,4 +1,4 @@
-import path, { dirname, join } from 'path';
+import path from 'path';
import { logger } from '@storybook/node-logger';
import { serverRequire } from '@storybook/core-common';
@@ -24,7 +24,8 @@ const requireMain = (configDir: string) => {
};
export function addons(options: PresetOptions) {
- const checkInstalled = (addon: string, main: any) => {
+ const checkInstalled = (addonName: string, main: any) => {
+ const addon = `@storybook/addon-${addonName}`;
const existingAddon = main.addons?.find((entry: string | { name: string }) => {
const name = typeof entry === 'string' ? entry : entry.name;
return name?.startsWith(addon);
@@ -36,35 +37,21 @@ export function addons(options: PresetOptions) {
};
const main = requireMain(options.configDir);
- return (
- [
- 'docs',
- 'controls',
- 'actions',
- 'backgrounds',
- 'viewport',
- 'toolbars',
- 'measure',
- 'outline',
- 'highlight',
- ]
- .filter((key) => (options as any)[key] !== false)
- .map((key) => `@storybook/addon-${key}`)
- .filter((addon) => !checkInstalled(addon, main))
- // Use `require.resolve` to ensure Yarn PnP compatibility
- // Files of various addons should be resolved in the context of `addon-essentials` as they are listed as deps here
- // and not in `@storybook/core` nor in SB user projects. If `@storybook/core` make the require itself Yarn 2 will
- // throw an error saying that the package to require must be added as a dependency. Doing `require.resolve` will
- // allow `@storybook/core` to work with absolute path directly, no more require of dep no more issue.
- // File to load can be `preset.js`, `register.js`, or the package entry point, so we need to check all these cases
- // as it's done in `lib/core/src/server/presets.js`.
- .map((addon) => {
- try {
- return dirname(require.resolve(join(addon, 'package.json')));
- // eslint-disable-next-line no-empty
- } catch (err) {}
-
- return require.resolve(addon);
- })
- );
+ return [
+ 'docs',
+ 'controls',
+ 'actions',
+ 'backgrounds',
+ 'viewport',
+ 'toolbars',
+ 'measure',
+ 'outline',
+ 'highlight',
+ ]
+ .filter((key) => (options as any)[key] !== false)
+ .filter((addon) => !checkInstalled(addon, main))
+ .map((addon) => {
+ // We point to the re-export from addon-essentials to support yarn pnp and pnpm.
+ return `@storybook/addon-essentials/${addon}`;
+ });
}
diff --git a/code/addons/essentials/src/measure/manager.ts b/code/addons/essentials/src/measure/manager.ts
new file mode 100644
index 000000000000..cf95d95a76da
--- /dev/null
+++ b/code/addons/essentials/src/measure/manager.ts
@@ -0,0 +1,2 @@
+// @ts-expect-error The generated definition file is empty. https://github.com/egoist/tsup/issues/762
+export * from '@storybook/addon-measure/manager';
diff --git a/code/addons/essentials/src/measure/preview.ts b/code/addons/essentials/src/measure/preview.ts
new file mode 100644
index 000000000000..f18769ff001a
--- /dev/null
+++ b/code/addons/essentials/src/measure/preview.ts
@@ -0,0 +1,4 @@
+/* eslint-disable import/export */
+// TODO: We need to configure an eslint-import typescript resolver for export maps to be considered
+
+export * from '@storybook/addon-measure/preview';
diff --git a/code/addons/essentials/src/outline/manager.ts b/code/addons/essentials/src/outline/manager.ts
new file mode 100644
index 000000000000..07a0a1e4879a
--- /dev/null
+++ b/code/addons/essentials/src/outline/manager.ts
@@ -0,0 +1,2 @@
+// @ts-expect-error The generated definition file is empty. https://github.com/egoist/tsup/issues/762
+export * from '@storybook/addon-outline/manager';
diff --git a/code/addons/essentials/src/outline/preview.ts b/code/addons/essentials/src/outline/preview.ts
new file mode 100644
index 000000000000..1cc44b9689a8
--- /dev/null
+++ b/code/addons/essentials/src/outline/preview.ts
@@ -0,0 +1,4 @@
+/* eslint-disable import/export */
+// TODO: We need to configure an eslint-import typescript resolver for export maps to be considered
+
+export * from '@storybook/addon-outline/preview';
diff --git a/code/addons/essentials/src/toolbars/manager.ts b/code/addons/essentials/src/toolbars/manager.ts
new file mode 100644
index 000000000000..8c4868b1e254
--- /dev/null
+++ b/code/addons/essentials/src/toolbars/manager.ts
@@ -0,0 +1,2 @@
+// @ts-expect-error The generated definition file is empty. https://github.com/egoist/tsup/issues/762
+export * from '@storybook/addon-toolbars/manager';
diff --git a/code/addons/essentials/src/viewport/manager.ts b/code/addons/essentials/src/viewport/manager.ts
new file mode 100644
index 000000000000..7c052f303800
--- /dev/null
+++ b/code/addons/essentials/src/viewport/manager.ts
@@ -0,0 +1,2 @@
+// @ts-expect-error The generated definition file is empty. https://github.com/egoist/tsup/issues/762
+export * from '@storybook/addon-viewport/manager';
diff --git a/code/addons/essentials/tsconfig.json b/code/addons/essentials/tsconfig.json
index 25de4fbd3e60..a4429176e35f 100644
--- a/code/addons/essentials/tsconfig.json
+++ b/code/addons/essentials/tsconfig.json
@@ -3,13 +3,5 @@
"compilerOptions": {
"strict": true
},
- "include": ["src/**/*"],
- "exclude": [
- "src/**/*.test.*",
- "src/**/tests/**/*",
- "src/**/__tests__/**/*",
- "src/**/*.stories.*",
- "src/**/*.mockdata.*",
- "src/**/__testfixtures__/**"
- ]
+ "include": ["src/**/*"]
}
diff --git a/code/addons/highlight/jest.config.js b/code/addons/highlight/jest.config.js
new file mode 100644
index 000000000000..4396fbc7010d
--- /dev/null
+++ b/code/addons/highlight/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.browser');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/addons/highlight/package.json b/code/addons/highlight/package.json
index c8a7d9ef48e6..aa74943371d2 100644
--- a/code/addons/highlight/package.json
+++ b/code/addons/highlight/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-highlight",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Highlight DOM nodes within your stories",
"keywords": [
"storybook-addons",
@@ -30,15 +30,25 @@
"types": "./dist/index.d.ts"
},
"./preview": {
- "require": "./dist/highlight.js",
- "import": "./dist/highlight.mjs",
- "types": "./dist/highlight.d.ts"
+ "require": "./dist/preview.js",
+ "import": "./dist/preview.mjs",
+ "types": "./dist/preview.d.ts"
},
"./package.json": "./package.json"
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
+ "typesVersions": {
+ "*": {
+ "*": [
+ "dist/index.d.ts"
+ ],
+ "preview": [
+ "dist/preview.d.ts"
+ ]
+ }
+ },
"files": [
"dist/**/*",
"README.md",
@@ -50,13 +60,13 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/addons": "7.0.0-alpha.48",
- "@storybook/core-events": "7.0.0-alpha.48",
+ "@storybook/addons": "7.0.0-alpha.51",
+ "@storybook/core-events": "7.0.0-alpha.51",
"global": "^4.4.0"
},
"devDependencies": {
"@types/webpack-env": "^1.16.0",
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"publishConfig": {
"access": "public"
@@ -64,10 +74,10 @@
"bundler": {
"entries": [
"./src/index.ts",
- "./src/highlight.ts"
+ "./src/preview.ts"
]
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd",
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded",
"sbmodern": "dist/modern/index.js",
"storybook": {
"displayName": "Highlight",
diff --git a/code/addons/highlight/preview.js b/code/addons/highlight/preview.js
index f7dfc599138c..49ad602f79f4 100644
--- a/code/addons/highlight/preview.js
+++ b/code/addons/highlight/preview.js
@@ -1 +1 @@
-export * from './dist/highlight';
+export * from './dist/preview';
diff --git a/code/addons/highlight/src/highlight.ts b/code/addons/highlight/src/preview.ts
similarity index 100%
rename from code/addons/highlight/src/highlight.ts
rename to code/addons/highlight/src/preview.ts
diff --git a/code/addons/highlight/tsconfig.json b/code/addons/highlight/tsconfig.json
index 6b79f028c19c..c94fb6fc9dd5 100644
--- a/code/addons/highlight/tsconfig.json
+++ b/code/addons/highlight/tsconfig.json
@@ -4,13 +4,5 @@
"rootDir": "./src",
"types": ["webpack-env"]
},
- "include": ["src/**/*"],
- "exclude": [
- "src/**/*.test.*",
- "src/**/tests/**/*",
- "src/**/__tests__/**/*",
- "src/**/*.stories.*",
- "src/**/*.mockdata.*",
- "src/**/__testfixtures__/**"
- ]
+ "include": ["src/**/*"]
}
diff --git a/code/addons/interactions/jest.config.js b/code/addons/interactions/jest.config.js
new file mode 100644
index 000000000000..4396fbc7010d
--- /dev/null
+++ b/code/addons/interactions/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.browser');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/addons/interactions/package.json b/code/addons/interactions/package.json
index 0eb7130861b4..6f120a25e357 100644
--- a/code/addons/interactions/package.json
+++ b/code/addons/interactions/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-interactions",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Automate, test and debug user interactions",
"keywords": [
"storybook-addons",
@@ -33,9 +33,9 @@
"types": "./dist/manager.d.ts"
},
"./preview": {
- "require": "./dist/preset/preview.js",
- "import": "./dist/preset/preview.mjs",
- "types": "./dist/preset/preview.d.ts"
+ "require": "./dist/preview.js",
+ "import": "./dist/preview.mjs",
+ "types": "./dist/preview.d.ts"
},
"./register.js": {
"require": "./dist/manager.js",
@@ -47,6 +47,19 @@
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
+ "typesVersions": {
+ "*": {
+ "*": [
+ "dist/index.d.ts"
+ ],
+ "manager": [
+ "dist/manager.d.ts"
+ ],
+ "preview": [
+ "dist/preview.d.ts"
+ ]
+ }
+ },
"files": [
"dist/**/*",
"README.md",
@@ -59,15 +72,15 @@
},
"dependencies": {
"@devtools-ds/object-inspector": "^1.1.2",
- "@storybook/addons": "7.0.0-alpha.48",
- "@storybook/api": "7.0.0-alpha.48",
- "@storybook/client-logger": "7.0.0-alpha.48",
- "@storybook/components": "7.0.0-alpha.48",
- "@storybook/core-common": "7.0.0-alpha.48",
- "@storybook/core-events": "7.0.0-alpha.48",
- "@storybook/instrumenter": "7.0.0-alpha.48",
- "@storybook/theming": "7.0.0-alpha.48",
- "@storybook/types": "7.0.0-alpha.48",
+ "@storybook/addons": "7.0.0-alpha.51",
+ "@storybook/api": "7.0.0-alpha.51",
+ "@storybook/client-logger": "7.0.0-alpha.51",
+ "@storybook/components": "7.0.0-alpha.51",
+ "@storybook/core-common": "7.0.0-alpha.51",
+ "@storybook/core-events": "7.0.0-alpha.51",
+ "@storybook/instrumenter": "7.0.0-alpha.51",
+ "@storybook/theming": "7.0.0-alpha.51",
+ "@storybook/types": "7.0.0-alpha.51",
"global": "^4.4.0",
"jest-mock": "^27.0.6",
"polished": "^4.2.2",
@@ -76,9 +89,9 @@
"devDependencies": {
"@storybook/jest": "^0.0.10",
"@storybook/testing-library": "0.0.14-next.0",
- "@types/node": "^16.0.0",
+ "@types/node": "^16.0.0 || ^18.0.0",
"formik": "^2.2.9",
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
@@ -99,12 +112,12 @@
"entries": [
"./src/index.ts",
"./src/manager.tsx",
- "./src/preset/preview.ts",
+ "./src/preview.ts",
"./src/preset/checkActionsLoaded.ts"
],
"platform": "node"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd",
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded",
"storybook": {
"displayName": "Interactions",
"unsupportedFrameworks": [
diff --git a/code/addons/interactions/preview.js b/code/addons/interactions/preview.js
index 48714cc6fba3..49ad602f79f4 100644
--- a/code/addons/interactions/preview.js
+++ b/code/addons/interactions/preview.js
@@ -1 +1 @@
-export * from './dist/preset/preview';
+export * from './dist/preview';
diff --git a/code/addons/interactions/src/components/InteractionsPanel.stories.tsx b/code/addons/interactions/src/components/InteractionsPanel.stories.tsx
index f55d28944c5a..179023b84906 100644
--- a/code/addons/interactions/src/components/InteractionsPanel.stories.tsx
+++ b/code/addons/interactions/src/components/InteractionsPanel.stories.tsx
@@ -1,4 +1,3 @@
-/* eslint-disable jest/no-standalone-expect */
import React from 'react';
import type { StoryObj, Meta } from '@storybook/react';
import { CallStates } from '@storybook/instrumenter';
diff --git a/code/addons/interactions/src/preset/preview.ts b/code/addons/interactions/src/preview.ts
similarity index 95%
rename from code/addons/interactions/src/preset/preview.ts
rename to code/addons/interactions/src/preview.ts
index d36c4bbf4f55..b4f094b7b986 100644
--- a/code/addons/interactions/src/preset/preview.ts
+++ b/code/addons/interactions/src/preview.ts
@@ -3,7 +3,7 @@
import { addons } from '@storybook/addons';
import { FORCE_REMOUNT, STORY_RENDER_PHASE_CHANGED } from '@storybook/core-events';
import type {
- Framework,
+ Renderer,
ArgsEnhancer,
PlayFunction,
PlayFunctionContext,
@@ -52,7 +52,7 @@ const addSpies = (id: string, val: any, key?: string): any => {
return val;
};
-const addActionsFromArgTypes: ArgsEnhancer = ({ id, initialArgs }) =>
+const addActionsFromArgTypes: ArgsEnhancer = ({ id, initialArgs }) =>
addSpies(id, initialArgs);
export const argsEnhancers = [addActionsFromArgTypes];
diff --git a/code/addons/interactions/template/stories/basics.stories.ts b/code/addons/interactions/template/stories/basics.stories.ts
index 57af27cc34fa..9a1919e748c9 100644
--- a/code/addons/interactions/template/stories/basics.stories.ts
+++ b/code/addons/interactions/template/stories/basics.stories.ts
@@ -1,4 +1,3 @@
-/* eslint-disable jest/no-standalone-expect */
import globalThis from 'global';
import {
within,
diff --git a/code/addons/interactions/tsconfig.json b/code/addons/interactions/tsconfig.json
index d23f9a406fc2..52d43eaaa9b9 100644
--- a/code/addons/interactions/tsconfig.json
+++ b/code/addons/interactions/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/addons/jest/jest.config.js b/code/addons/jest/jest.config.js
new file mode 100644
index 000000000000..4396fbc7010d
--- /dev/null
+++ b/code/addons/jest/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.browser');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/addons/jest/package.json b/code/addons/jest/package.json
index 96f77afe0c62..dd08248b8e0c 100644
--- a/code/addons/jest/package.json
+++ b/code/addons/jest/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-jest",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "React storybook addon that show component jest report",
"keywords": [
"addon",
@@ -48,6 +48,16 @@
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
+ "typesVersions": {
+ "*": {
+ "*": [
+ "dist/index.d.ts"
+ ],
+ "manager": [
+ "dist/manager.d.ts"
+ ]
+ }
+ },
"files": [
"dist/**/*",
"README.md",
@@ -59,18 +69,18 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/addons": "7.0.0-alpha.48",
- "@storybook/api": "7.0.0-alpha.48",
- "@storybook/client-logger": "7.0.0-alpha.48",
- "@storybook/components": "7.0.0-alpha.48",
- "@storybook/core-events": "7.0.0-alpha.48",
- "@storybook/theming": "7.0.0-alpha.48",
+ "@storybook/addons": "7.0.0-alpha.51",
+ "@storybook/api": "7.0.0-alpha.51",
+ "@storybook/client-logger": "7.0.0-alpha.51",
+ "@storybook/components": "7.0.0-alpha.51",
+ "@storybook/core-events": "7.0.0-alpha.51",
+ "@storybook/theming": "7.0.0-alpha.51",
"global": "^4.4.0",
"react-sizeme": "^3.0.1",
"upath": "^1.2.0"
},
"devDependencies": {
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
@@ -94,7 +104,7 @@
],
"platform": "browser"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd",
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded",
"storybook": {
"displayName": "Jest",
"icon": "https://pbs.twimg.com/profile_images/821713465245102080/mMtKIMax_400x400.jpg",
diff --git a/code/addons/jest/src/shared.test.ts b/code/addons/jest/src/shared.test.ts
index e051f4563f61..ddc3a0c71b17 100644
--- a/code/addons/jest/src/shared.test.ts
+++ b/code/addons/jest/src/shared.test.ts
@@ -27,7 +27,7 @@ describe('defineJestParameter', () => {
});
test('returns null if filename is a module ID that cannot be inferred from', () => {
- // @ts-expect-error (Converted from ts-ignore)
+ // @ts-expect-error Storybook's fileName type is string, but according to this test it could be number in case it is a module id.
expect(defineJestParameter({ fileName: 1234 })).toBeNull();
});
});
diff --git a/code/addons/jest/src/shared.ts b/code/addons/jest/src/shared.ts
index 9b761e1d9dec..ef078b7af8a8 100644
--- a/code/addons/jest/src/shared.ts
+++ b/code/addons/jest/src/shared.ts
@@ -1,4 +1,4 @@
-import type { Parameters } from '@storybook/types';
+import type { StorybookInternalParameters } from '@storybook/types';
// addons, panels and events get unique names using a prefix
export const PARAM_KEY = 'test';
@@ -7,7 +7,7 @@ export const PANEL_ID = `${ADDON_ID}/panel`;
export const ADD_TESTS = `${ADDON_ID}/add_tests`;
-interface AddonParameters extends Parameters {
+interface AddonParameters extends StorybookInternalParameters {
jest?: string | string[] | { disabled: true };
}
diff --git a/code/addons/jest/tsconfig.json b/code/addons/jest/tsconfig.json
index f8b60c90fdef..73a65ef2ef6e 100644
--- a/code/addons/jest/tsconfig.json
+++ b/code/addons/jest/tsconfig.json
@@ -1,13 +1,5 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {},
- "include": ["src/**/*"],
- "exclude": [
- "src/**/*.test.*",
- "src/**/tests/**/*",
- "src/**/__tests__/**/*",
- "src/**/*.stories.*",
- "src/**/*.mockdata.*",
- "src/**/__testfixtures__/**"
- ]
+ "include": ["src/**/*"]
}
diff --git a/code/addons/links/jest.config.js b/code/addons/links/jest.config.js
new file mode 100644
index 000000000000..4396fbc7010d
--- /dev/null
+++ b/code/addons/links/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.browser');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/addons/links/package.json b/code/addons/links/package.json
index 92cc62a00d09..c26f963e48ed 100644
--- a/code/addons/links/package.json
+++ b/code/addons/links/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-links",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Link stories together to build demos and prototypes with your UI components",
"keywords": [
"addon",
@@ -52,6 +52,19 @@
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
+ "typesVersions": {
+ "*": {
+ "*": [
+ "dist/index.d.ts"
+ ],
+ "manager": [
+ "dist/manager.d.ts"
+ ],
+ "preview": [
+ "dist/preview.d.ts"
+ ]
+ }
+ },
"files": [
"dist/**/*",
"README.md",
@@ -63,18 +76,18 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/addons": "7.0.0-alpha.48",
- "@storybook/client-logger": "7.0.0-alpha.48",
- "@storybook/core-events": "7.0.0-alpha.48",
+ "@storybook/addons": "7.0.0-alpha.51",
+ "@storybook/client-logger": "7.0.0-alpha.51",
+ "@storybook/core-events": "7.0.0-alpha.51",
"@storybook/csf": "next",
- "@storybook/router": "7.0.0-alpha.48",
- "@storybook/types": "7.0.0-alpha.48",
+ "@storybook/router": "7.0.0-alpha.51",
+ "@storybook/types": "7.0.0-alpha.51",
"global": "^4.4.0",
"prop-types": "^15.7.2",
"ts-dedent": "^2.0.0"
},
"devDependencies": {
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
@@ -99,7 +112,7 @@
"./src/react/index.ts"
]
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd",
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded",
"storybook": {
"displayName": "Links",
"icon": "https://user-images.githubusercontent.com/263385/101991673-48355c80-3c7c-11eb-9b6e-b627c96a75f6.png",
diff --git a/code/addons/links/src/react/components/link.test.tsx b/code/addons/links/src/react/components/link.test.tsx
index 664670baa264..9b1d5e09552a 100644
--- a/code/addons/links/src/react/components/link.test.tsx
+++ b/code/addons/links/src/react/components/link.test.tsx
@@ -14,7 +14,6 @@ jest.mock('global', () => ({
search: 'search',
},
},
- // @ts-expect-error (Converted from ts-ignore)
window: global,
__STORYBOOK_STORY_STORE__: {
fromId: jest.fn(() => ({})),
diff --git a/code/addons/links/src/utils.test.ts b/code/addons/links/src/utils.test.ts
index 443886653810..291b613c7edb 100644
--- a/code/addons/links/src/utils.test.ts
+++ b/code/addons/links/src/utils.test.ts
@@ -5,9 +5,7 @@ import { linkTo, hrefTo } from './utils';
jest.mock('@storybook/addons');
jest.mock('global', () => ({
- // @ts-expect-error (Converted from ts-ignore)
document: global.document,
- // @ts-expect-error (Converted from ts-ignore)
window: global,
}));
@@ -41,6 +39,7 @@ describe('preview', () => {
it('should select the story (only) provided', () => {
// simulate a currently selected, but not found as ID
+ // @ts-expect-error (not strict)
const handler = linkTo(undefined, 'name');
handler();
diff --git a/code/addons/links/src/utils.ts b/code/addons/links/src/utils.ts
index b4ece3c80fea..73ba6e0d3322 100644
--- a/code/addons/links/src/utils.ts
+++ b/code/addons/links/src/utils.ts
@@ -49,7 +49,6 @@ export const hrefTo = (title: ComponentTitle, name: StoryName): Promise
});
};
-// eslint-disable-next-line @typescript-eslint/no-shadow
const valueOrCall = (args: string[]) => (value: string | ((...args: string[]) => string)) =>
typeof value === 'function' ? value(...args) : value;
diff --git a/code/addons/links/tsconfig.json b/code/addons/links/tsconfig.json
index 25de4fbd3e60..a4429176e35f 100644
--- a/code/addons/links/tsconfig.json
+++ b/code/addons/links/tsconfig.json
@@ -3,13 +3,5 @@
"compilerOptions": {
"strict": true
},
- "include": ["src/**/*"],
- "exclude": [
- "src/**/*.test.*",
- "src/**/tests/**/*",
- "src/**/__tests__/**/*",
- "src/**/*.stories.*",
- "src/**/*.mockdata.*",
- "src/**/__testfixtures__/**"
- ]
+ "include": ["src/**/*"]
}
diff --git a/code/addons/measure/jest.config.js b/code/addons/measure/jest.config.js
new file mode 100644
index 000000000000..4396fbc7010d
--- /dev/null
+++ b/code/addons/measure/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.browser');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/addons/measure/package.json b/code/addons/measure/package.json
index 6ab70183b27a..6305042530ad 100644
--- a/code/addons/measure/package.json
+++ b/code/addons/measure/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-measure",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Inspect layouts by visualizing the box model",
"keywords": [
"storybook-addons",
@@ -50,6 +50,19 @@
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
+ "typesVersions": {
+ "*": {
+ "*": [
+ "dist/index.d.ts"
+ ],
+ "manager": [
+ "dist/manager.d.ts"
+ ],
+ "preview": [
+ "dist/preview.d.ts"
+ ]
+ }
+ },
"files": [
"dist/**/*",
"README.md",
@@ -61,16 +74,16 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/addons": "7.0.0-alpha.48",
- "@storybook/api": "7.0.0-alpha.48",
- "@storybook/client-logger": "7.0.0-alpha.48",
- "@storybook/components": "7.0.0-alpha.48",
- "@storybook/core-events": "7.0.0-alpha.48",
- "@storybook/types": "7.0.0-alpha.48",
+ "@storybook/addons": "7.0.0-alpha.51",
+ "@storybook/api": "7.0.0-alpha.51",
+ "@storybook/client-logger": "7.0.0-alpha.51",
+ "@storybook/components": "7.0.0-alpha.51",
+ "@storybook/core-events": "7.0.0-alpha.51",
+ "@storybook/types": "7.0.0-alpha.51",
"global": "^4.4.0"
},
"devDependencies": {
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
@@ -94,7 +107,7 @@
"./src/preview.tsx"
]
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd",
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded",
"storybook": {
"displayName": "Measure",
"unsupportedFrameworks": [
diff --git a/code/addons/measure/src/withMeasure.ts b/code/addons/measure/src/withMeasure.ts
index e0a0fa1a101b..4dea5601dc7a 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 { Framework, PartialStoryFn as StoryFunction, StoryContext } from '@storybook/types';
+import type { Renderer, 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';
@@ -13,10 +13,7 @@ function findAndDrawElement(x: number, y: number) {
drawSelectedElement(nodeAtPointerRef);
}
-export const withMeasure = (
- StoryFn: StoryFunction,
- context: StoryContext
-) => {
+export const withMeasure = (StoryFn: StoryFunction, context: StoryContext) => {
const { measureEnabled } = context.globals;
useEffect(() => {
diff --git a/code/addons/measure/tsconfig.json b/code/addons/measure/tsconfig.json
index d23f9a406fc2..52d43eaaa9b9 100644
--- a/code/addons/measure/tsconfig.json
+++ b/code/addons/measure/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/addons/outline/jest.config.js b/code/addons/outline/jest.config.js
new file mode 100644
index 000000000000..4396fbc7010d
--- /dev/null
+++ b/code/addons/outline/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.browser');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/addons/outline/package.json b/code/addons/outline/package.json
index 478b1d9b23a6..90d030b061be 100644
--- a/code/addons/outline/package.json
+++ b/code/addons/outline/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-outline",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Outline all elements with CSS to help with layout placement and alignment",
"keywords": [
"storybook-addons",
@@ -39,9 +39,9 @@
"types": "./dist/manager.d.ts"
},
"./preview": {
- "require": "./dist/preset/preview.js",
- "import": "./dist/preset/preview.mjs",
- "types": "./dist/preset/preview.d.ts"
+ "require": "./dist/preview.js",
+ "import": "./dist/preview.mjs",
+ "types": "./dist/preview.d.ts"
},
"./register": {
"require": "./dist/manager.js",
@@ -53,6 +53,19 @@
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
+ "typesVersions": {
+ "*": {
+ "*": [
+ "dist/index.d.ts"
+ ],
+ "manager": [
+ "dist/manager.d.ts"
+ ],
+ "preview": [
+ "dist/preview.d.ts"
+ ]
+ }
+ },
"files": [
"dist/**/*",
"README.md",
@@ -64,17 +77,17 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/addons": "7.0.0-alpha.48",
- "@storybook/api": "7.0.0-alpha.48",
- "@storybook/client-logger": "7.0.0-alpha.48",
- "@storybook/components": "7.0.0-alpha.48",
- "@storybook/core-events": "7.0.0-alpha.48",
- "@storybook/types": "7.0.0-alpha.48",
+ "@storybook/addons": "7.0.0-alpha.51",
+ "@storybook/api": "7.0.0-alpha.51",
+ "@storybook/client-logger": "7.0.0-alpha.51",
+ "@storybook/components": "7.0.0-alpha.51",
+ "@storybook/core-events": "7.0.0-alpha.51",
+ "@storybook/types": "7.0.0-alpha.51",
"global": "^4.4.0",
"ts-dedent": "^2.0.0"
},
"devDependencies": {
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
@@ -95,10 +108,10 @@
"entries": [
"./src/index.ts",
"./src/manager.tsx",
- "./src/preset/preview.tsx"
+ "./src/preview.tsx"
]
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd",
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded",
"storybook": {
"displayName": "Outline",
"unsupportedFrameworks": [
diff --git a/code/addons/outline/preview.js b/code/addons/outline/preview.js
index 48714cc6fba3..49ad602f79f4 100644
--- a/code/addons/outline/preview.js
+++ b/code/addons/outline/preview.js
@@ -1 +1 @@
-export * from './dist/preset/preview';
+export * from './dist/preview';
diff --git a/code/addons/outline/src/preset/preview.tsx b/code/addons/outline/src/preview.tsx
similarity index 51%
rename from code/addons/outline/src/preset/preview.tsx
rename to code/addons/outline/src/preview.tsx
index 1abee6e575c6..65161c6c4f29 100644
--- a/code/addons/outline/src/preset/preview.tsx
+++ b/code/addons/outline/src/preview.tsx
@@ -1,5 +1,5 @@
-import { withOutline } from '../withOutline';
-import { PARAM_KEY } from '../constants';
+import { withOutline } from './withOutline';
+import { PARAM_KEY } from './constants';
export const decorators = [withOutline];
diff --git a/code/addons/outline/src/withOutline.ts b/code/addons/outline/src/withOutline.ts
index 1fc20affb60d..455d84ae945a 100644
--- a/code/addons/outline/src/withOutline.ts
+++ b/code/addons/outline/src/withOutline.ts
@@ -1,14 +1,11 @@
import { useMemo, useEffect } from '@storybook/addons';
-import type { Framework, PartialStoryFn as StoryFunction, StoryContext } from '@storybook/types';
+import type { Renderer, PartialStoryFn as StoryFunction, StoryContext } from '@storybook/types';
import { clearStyles, addOutlineStyles } from './helpers';
import { PARAM_KEY } from './constants';
import outlineCSS from './outlineCSS';
-export const withOutline = (
- StoryFn: StoryFunction,
- context: StoryContext
-) => {
+export const withOutline = (StoryFn: StoryFunction, context: StoryContext) => {
const { globals } = context;
const isActive = globals[PARAM_KEY] === true;
const isInDocs = context.viewMode === 'docs';
diff --git a/code/addons/outline/tsconfig.json b/code/addons/outline/tsconfig.json
index d23f9a406fc2..52d43eaaa9b9 100644
--- a/code/addons/outline/tsconfig.json
+++ b/code/addons/outline/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/addons/storyshots/jest.config.js b/code/addons/storyshots/jest.config.js
new file mode 100644
index 000000000000..0115c67e5629
--- /dev/null
+++ b/code/addons/storyshots/jest.config.js
@@ -0,0 +1,12 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.browser');
+
+module.exports = {
+ ...baseConfig,
+ snapshotSerializers: [...baseConfig.snapshotSerializers, 'enzyme-to-json/serializer'],
+ transform: {
+ ...baseConfig.transform,
+ '^.+\\.stories\\.[jt]sx?$': '@storybook/addon-storyshots/injectFileName',
+ },
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/addons/storyshots/storyshots-core/package.json b/code/addons/storyshots/storyshots-core/package.json
index 539ef73cb34a..d4da0a55e08f 100644
--- a/code/addons/storyshots/storyshots-core/package.json
+++ b/code/addons/storyshots/storyshots-core/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-storyshots",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Take a code snapshot of every story automatically with Jest",
"keywords": [
"addon",
@@ -37,23 +37,22 @@
"storybook": "yarn sb dev -p 6006"
},
"dependencies": {
- "@jest/transform": "^26.6.2",
- "@storybook/addons": "7.0.0-alpha.48",
+ "@jest/transform": "^29.3.1",
+ "@storybook/addons": "7.0.0-alpha.51",
"@storybook/babel-plugin-require-context-hook": "1.0.1",
- "@storybook/client-api": "7.0.0-alpha.48",
- "@storybook/core-client": "7.0.0-alpha.48",
- "@storybook/core-common": "7.0.0-alpha.48",
- "@storybook/core-webpack": "7.0.0-alpha.48",
- "@storybook/types": "7.0.0-alpha.48",
+ "@storybook/client-api": "7.0.0-alpha.51",
+ "@storybook/core-client": "7.0.0-alpha.51",
+ "@storybook/core-common": "7.0.0-alpha.51",
+ "@storybook/core-webpack": "7.0.0-alpha.51",
+ "@storybook/types": "7.0.0-alpha.51",
"@types/glob": "^7.1.3",
- "@types/jest": "^26.0.16",
- "@types/jest-specific-snapshot": "^0.5.3",
+ "@types/jest-specific-snapshot": "^0.5.6",
"core-js": "^3.8.2",
"glob": "^7.1.6",
"global": "^4.4.0",
- "jest-specific-snapshot": "^4.0.0",
+ "jest-specific-snapshot": "^6.0.0",
"preact-render-to-string": "^5.1.19",
- "pretty-format": "^26.6.2",
+ "pretty-format": "^28.0.0",
"react-test-renderer": "^16.8.0 || ^17.0.0 || ^18.0.0",
"read-pkg-up": "^7.0.1",
"ts-dedent": "^2.0.0"
@@ -62,12 +61,12 @@
"@angular/core": "^13.3.6",
"@angular/platform-browser-dynamic": "^13.3.6",
"@emotion/jest": "^11.8.0",
- "@storybook/addon-docs": "7.0.0-alpha.48",
- "@storybook/angular": "7.0.0-alpha.48",
- "@storybook/react": "7.0.0-alpha.48",
- "@storybook/vue": "7.0.0-alpha.48",
- "@storybook/vue3": "7.0.0-alpha.48",
- "babel-loader": "^8.2.5",
+ "@storybook/addon-docs": "7.0.0-alpha.51",
+ "@storybook/angular": "7.0.0-alpha.51",
+ "@storybook/react": "7.0.0-alpha.51",
+ "@storybook/vue": "7.0.0-alpha.51",
+ "@storybook/vue3": "7.0.0-alpha.51",
+ "babel-loader": "^8.3.0",
"enzyme": "^3.11.0",
"enzyme-to-json": "^3.6.1",
"jest-preset-angular": "^8.3.2",
@@ -144,7 +143,7 @@
"publishConfig": {
"access": "public"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd",
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded",
"storybook": {
"displayName": "Storyshots",
"icon": "https://user-images.githubusercontent.com/263385/101991676-48cdf300-3c7c-11eb-8aa1-944dab6ab29b.png",
diff --git a/code/addons/storyshots/storyshots-core/src/Stories2SnapsConverter.test.ts b/code/addons/storyshots/storyshots-core/src/Stories2SnapsConverter.test.ts
index 168849f26be5..d066d1226e58 100644
--- a/code/addons/storyshots/storyshots-core/src/Stories2SnapsConverter.test.ts
+++ b/code/addons/storyshots/storyshots-core/src/Stories2SnapsConverter.test.ts
@@ -4,33 +4,33 @@ const target = new Stories2SnapsConverter();
describe('getSnapshotFileName', () => {
it('fileName is provided - snapshot is stored in __snapshots__ dir', () => {
- const context = { fileName: 'foo.js' };
+ const context = { fileName: 'foo.js', kind: 'kind' };
- // @ts-expect-error (TODO)
const result = target.getSnapshotFileName(context);
const platformAgnosticResult = result.replace(/\\|\//g, '/');
- expect(platformAgnosticResult).toBe('__snapshots__/foo.storyshot');
+ // This is an absolute path, so we need to use `toContain()`
+ expect(platformAgnosticResult).toContain('__snapshots__/foo.storyshot');
});
it('fileName with multiple extensions is provided - only the last extension is replaced', () => {
- const context = { fileName: 'foo.web.stories.js' };
+ const context = { fileName: 'foo.web.stories.js', kind: 'kind' };
- // @ts-expect-error (TODO)
const result = target.getSnapshotFileName(context);
const platformAgnosticResult = result.replace(/\\|\//g, '/');
- expect(platformAgnosticResult).toBe('__snapshots__/foo.web.stories.storyshot');
+ // This is an absolute path, so we need to use `toContain()`
+ expect(platformAgnosticResult).toContain('__snapshots__/foo.web.stories.storyshot');
});
it('fileName with dir is provided - __snapshots__ dir is created inside another dir', () => {
- const context = { fileName: 'test/foo.js' };
+ const context = { fileName: 'test/foo.js', kind: 'kind' };
- // @ts-expect-error (TODO)
const result = target.getSnapshotFileName(context);
const platformAgnosticResult = result.replace(/\\|\//g, '/');
- expect(platformAgnosticResult).toBe('test/__snapshots__/foo.storyshot');
+ // This is an absolute path, so we need to use `toContain()`
+ expect(platformAgnosticResult).toContain('test/__snapshots__/foo.storyshot');
});
});
diff --git a/code/addons/storyshots/storyshots-core/src/Stories2SnapsConverter.ts b/code/addons/storyshots/storyshots-core/src/Stories2SnapsConverter.ts
index 527a946847c8..439a514f7bd4 100644
--- a/code/addons/storyshots/storyshots-core/src/Stories2SnapsConverter.ts
+++ b/code/addons/storyshots/storyshots-core/src/Stories2SnapsConverter.ts
@@ -29,7 +29,15 @@ export class Stories2SnapsConverter {
const { dir, name } = path.parse(fileName);
const { snapshotsDirName, snapshotExtension } = this.options;
- return path.format({ dir: path.join(dir, snapshotsDirName), name, ext: snapshotExtension });
+ // Convert to absolute path, in case jest is not running in CWD,
+ // else it will create snapshots with the wrong path
+ const absDir = path.isAbsolute(dir) ? dir : path.resolve(dir);
+
+ return path.format({
+ dir: path.join(absDir, snapshotsDirName),
+ name,
+ ext: snapshotExtension,
+ });
}
getSnapshotFileName(context: { fileName?: string; kind: any }) {
diff --git a/code/addons/storyshots/storyshots-core/src/api/integrityTestTemplate.ts b/code/addons/storyshots/storyshots-core/src/api/integrityTestTemplate.ts
index b4fb63b582ff..d52260268104 100644
--- a/code/addons/storyshots/storyshots-core/src/api/integrityTestTemplate.ts
+++ b/code/addons/storyshots/storyshots-core/src/api/integrityTestTemplate.ts
@@ -52,7 +52,6 @@ function integrityTest(integrityOptions: any, stories2snapsConverter: any) {
const snapshotExtension = stories2snapsConverter.getSnapshotExtension();
const storyshots = glob.sync(`**/*${snapshotExtension}`, integrityOptions);
- // @ts-expect-error (Converted from ts-ignore)
expect(storyshots).notToBeAbandoned(stories2snapsConverter);
});
});
diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/Loader.ts b/code/addons/storyshots/storyshots-core/src/frameworks/Loader.ts
index c844fe11973d..80b863c51102 100644
--- a/code/addons/storyshots/storyshots-core/src/frameworks/Loader.ts
+++ b/code/addons/storyshots/storyshots-core/src/frameworks/Loader.ts
@@ -1,11 +1,11 @@
-import type { Framework, Addon_Loadable } from '@storybook/types';
+import type { Renderer, Addon_Loadable } from '@storybook/types';
import type { ClientApi as ClientApiClass } from '@storybook/client-api';
import type { StoryshotsOptions } from '../api/StoryshotsOptions';
import type { SupportedFramework } from './SupportedFramework';
export type RenderTree = (story: any, context?: any, options?: any) => any;
-export interface ClientApi extends ClientApiClass {
+export interface ClientApi extends ClientApiClass {
configure(
loader: Addon_Loadable,
module: NodeModule | false,
@@ -19,7 +19,7 @@ export interface Loader {
framework: SupportedFramework;
renderTree: RenderTree;
renderShallowTree: any;
- storybook: ClientApi;
+ storybook: ClientApi;
};
test: (options: StoryshotsOptions) => boolean;
}
diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/angular/loader.ts b/code/addons/storyshots/storyshots-core/src/frameworks/angular/loader.ts
index 401b25764122..40a7def7ffa7 100644
--- a/code/addons/storyshots/storyshots-core/src/frameworks/angular/loader.ts
+++ b/code/addons/storyshots/storyshots-core/src/frameworks/angular/loader.ts
@@ -33,17 +33,35 @@ function test(options: StoryshotsOptions): boolean {
function load(options: StoryshotsOptions) {
setupAngularJestPreset();
- const storybook = jest.requireActual('@storybook/angular');
- const clientAPI = jest.requireActual('@storybook/client-api');
+ let mockStartedAPI: any;
- const api = {
- ...clientAPI,
- ...storybook,
- };
+ jest.mock('@storybook/core-client', () => {
+ const coreClientAPI = jest.requireActual('@storybook/core-client');
+
+ return {
+ ...coreClientAPI,
+ start: (...args: any[]) => {
+ mockStartedAPI = coreClientAPI.start(...args);
+ return mockStartedAPI;
+ },
+ };
+ });
+
+ jest.mock('@storybook/angular', () => {
+ const renderAPI = jest.requireActual('@storybook/angular');
+
+ renderAPI.addDecorator = mockStartedAPI.clientApi.addDecorator;
+ renderAPI.addParameters = mockStartedAPI.clientApi.addParameters;
+
+ return renderAPI;
+ });
+
+ // eslint-disable-next-line global-require
+ const storybook = require('@storybook/angular');
configure({
...options,
- storybook: api,
+ storybook,
});
return {
@@ -52,7 +70,7 @@ function load(options: StoryshotsOptions) {
renderShallowTree: () => {
throw new Error('Shallow renderer is not supported for angular');
},
- storybook: api,
+ storybook,
};
}
diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/configure.ts b/code/addons/storyshots/storyshots-core/src/frameworks/configure.ts
index 25c03f8622e8..aafc21c96f6c 100644
--- a/code/addons/storyshots/storyshots-core/src/frameworks/configure.ts
+++ b/code/addons/storyshots/storyshots-core/src/frameworks/configure.ts
@@ -1,7 +1,7 @@
import fs from 'fs';
import path from 'path';
import type {
- Framework,
+ Renderer,
ArgsEnhancer,
ArgTypesEnhancer,
CoreCommon_NormalizedStoriesSpecifier,
@@ -87,9 +87,9 @@ function getConfigPathParts(input: string): Output {
return { preview: configDir };
}
-function configure(
+function configure(
options: {
- storybook: ClientApi;
+ storybook: ClientApi;
} & StoryshotsOptions
): void {
const { configPath = '.storybook', config, storybook } = options;
@@ -125,7 +125,7 @@ function configure(
} = jest.requireActual(preview);
if (decorators) {
- decorators.forEach((decorator: DecoratorFunction) =>
+ decorators.forEach((decorator: DecoratorFunction) =>
storybook.addDecorator(decorator)
);
}
@@ -136,12 +136,12 @@ function configure(
storybook.addStepRunner(runStep);
}
if (argsEnhancers) {
- argsEnhancers.forEach((enhancer: ArgsEnhancer) =>
+ argsEnhancers.forEach((enhancer: ArgsEnhancer) =>
storybook.addArgsEnhancer(enhancer as any)
);
}
if (argTypesEnhancers) {
- argTypesEnhancers.forEach((enhancer: ArgTypesEnhancer) =>
+ argTypesEnhancers.forEach((enhancer: ArgTypesEnhancer) =>
storybook.addArgTypesEnhancer(enhancer as any)
);
}
diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/html/loader.ts b/code/addons/storyshots/storyshots-core/src/frameworks/html/loader.ts
index 6cc2b9d3e943..55a8dfdd6b12 100644
--- a/code/addons/storyshots/storyshots-core/src/frameworks/html/loader.ts
+++ b/code/addons/storyshots/storyshots-core/src/frameworks/html/loader.ts
@@ -10,17 +10,35 @@ function test(options: StoryshotsOptions): boolean {
function load(options: StoryshotsOptions) {
global.STORYBOOK_ENV = 'html';
- const storybook = jest.requireActual('@storybook/html');
- const clientAPI = jest.requireActual('@storybook/client-api');
+ let mockStartedAPI: any;
+
+ jest.mock('@storybook/core-client', () => {
+ const coreClientAPI = jest.requireActual('@storybook/core-client');
+
+ return {
+ ...coreClientAPI,
+ start: (...args: any[]) => {
+ mockStartedAPI = coreClientAPI.start(...args);
+ return mockStartedAPI;
+ },
+ };
+ });
- const api = {
- ...clientAPI,
- ...storybook,
- };
+ jest.mock('@storybook/html', () => {
+ const renderAPI = jest.requireActual('@storybook/html');
+
+ renderAPI.addDecorator = mockStartedAPI.clientApi.addDecorator;
+ renderAPI.addParameters = mockStartedAPI.clientApi.addParameters;
+
+ return renderAPI;
+ });
+
+ // eslint-disable-next-line global-require
+ const storybook = require('@storybook/html');
configure({
...options,
- storybook: api,
+ storybook,
});
return {
@@ -29,7 +47,7 @@ function load(options: StoryshotsOptions) {
renderShallowTree: () => {
throw new Error('Shallow renderer is not supported for HTML');
},
- storybook: api,
+ storybook,
};
}
diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/preact/loader.ts b/code/addons/storyshots/storyshots-core/src/frameworks/preact/loader.ts
index c45f7c9b8efc..986dcf5f911f 100644
--- a/code/addons/storyshots/storyshots-core/src/frameworks/preact/loader.ts
+++ b/code/addons/storyshots/storyshots-core/src/frameworks/preact/loader.ts
@@ -16,17 +16,35 @@ function test(options: StoryshotsOptions): boolean {
function load(options: StoryshotsOptions) {
global.STORYBOOK_ENV = 'preact';
- const storybook = jest.requireActual('@storybook/preact');
- const clientAPI = jest.requireActual('@storybook/client-api');
+ let mockStartedAPI: any;
- const api = {
- ...clientAPI,
- ...storybook,
- };
+ jest.mock('@storybook/core-client', () => {
+ const coreClientAPI = jest.requireActual('@storybook/core-client');
+
+ return {
+ ...coreClientAPI,
+ start: (...args: any[]) => {
+ mockStartedAPI = coreClientAPI.start(...args);
+ return mockStartedAPI;
+ },
+ };
+ });
+
+ jest.mock('@storybook/preact', () => {
+ const renderAPI = jest.requireActual('@storybook/preact');
+
+ renderAPI.addDecorator = mockStartedAPI.clientApi.addDecorator;
+ renderAPI.addParameters = mockStartedAPI.clientApi.addParameters;
+
+ return renderAPI;
+ });
+
+ // eslint-disable-next-line global-require
+ const storybook = require('@storybook/preact');
configure({
...options,
- storybook: api,
+ storybook,
});
return {
@@ -35,7 +53,7 @@ function load(options: StoryshotsOptions) {
renderShallowTree: () => {
throw new Error('Shallow renderer is not supported for preact');
},
- storybook: api,
+ storybook,
};
}
diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/rax/loader.ts b/code/addons/storyshots/storyshots-core/src/frameworks/rax/loader.ts
index 86284861d29b..2d14593fd096 100644
--- a/code/addons/storyshots/storyshots-core/src/frameworks/rax/loader.ts
+++ b/code/addons/storyshots/storyshots-core/src/frameworks/rax/loader.ts
@@ -11,17 +11,35 @@ function test(options: StoryshotsOptions): boolean {
function load(options: StoryshotsOptions) {
global.STORYBOOK_ENV = 'rax';
- const storybook = jest.requireActual('@storybook/rax');
- const clientAPI = jest.requireActual('@storybook/client-api');
+ let mockStartedAPI: any;
+
+ jest.mock('@storybook/core-client', () => {
+ const coreClientAPI = jest.requireActual('@storybook/core-client');
+
+ return {
+ ...coreClientAPI,
+ start: (...args: any[]) => {
+ mockStartedAPI = coreClientAPI.start(...args);
+ return mockStartedAPI;
+ },
+ };
+ });
- const api = {
- ...clientAPI,
- ...storybook,
- };
+ jest.mock('@storybook/rax', () => {
+ const renderAPI = jest.requireActual('@storybook/rax');
+
+ renderAPI.addDecorator = mockStartedAPI.clientApi.addDecorator;
+ renderAPI.addParameters = mockStartedAPI.clientApi.addParameters;
+
+ return renderAPI;
+ });
+
+ // eslint-disable-next-line global-require
+ const storybook = require('@storybook/rax');
configure({
...options,
- storybook: api,
+ storybook,
});
return {
@@ -30,7 +48,7 @@ function load(options: StoryshotsOptions) {
renderShallowTree: () => {
throw new Error('Shallow renderer is not supported for rax');
},
- storybook: api,
+ storybook,
};
}
diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/react-native/loader.ts b/code/addons/storyshots/storyshots-core/src/frameworks/react-native/loader.ts
index a31758cdc2b9..7c0e51d23f0f 100644
--- a/code/addons/storyshots/storyshots-core/src/frameworks/react-native/loader.ts
+++ b/code/addons/storyshots/storyshots-core/src/frameworks/react-native/loader.ts
@@ -25,20 +25,14 @@ function configure(options: StoryshotsOptions, storybook: any) {
function load(options: StoryshotsOptions) {
const storybook = jest.requireActual('@storybook/react-native');
- const clientAPI = jest.requireActual('@storybook/client-api');
- const api = {
- ...clientAPI,
- ...storybook,
- };
-
- configure(options, api);
+ configure(options, storybook);
return {
renderTree: require('../react/renderTree').default,
renderShallowTree: require('../react/renderShallowTree').default,
framework: 'react-native' as const,
- storybook: api,
+ storybook,
};
}
diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/react/loader.ts b/code/addons/storyshots/storyshots-core/src/frameworks/react/loader.ts
index 1ba371b1d622..bc6f9153f10f 100644
--- a/code/addons/storyshots/storyshots-core/src/frameworks/react/loader.ts
+++ b/code/addons/storyshots/storyshots-core/src/frameworks/react/loader.ts
@@ -8,24 +8,42 @@ function test(options: StoryshotsOptions): boolean {
}
function load(options: StoryshotsOptions) {
- const storybook = jest.requireActual('@storybook/react');
- const clientAPI = jest.requireActual('@storybook/client-api');
+ let mockStartedAPI: any;
- const api = {
- ...clientAPI,
- ...storybook,
- };
+ jest.mock('@storybook/core-client', () => {
+ const coreClientAPI = jest.requireActual('@storybook/core-client');
+
+ return {
+ ...coreClientAPI,
+ start: (...args: any[]) => {
+ mockStartedAPI = coreClientAPI.start(...args);
+ return mockStartedAPI;
+ },
+ };
+ });
+
+ jest.mock('@storybook/react', () => {
+ const renderAPI = jest.requireActual('@storybook/react');
+
+ renderAPI.addDecorator = mockStartedAPI.clientApi.addDecorator;
+ renderAPI.addParameters = mockStartedAPI.clientApi.addParameters;
+
+ return renderAPI;
+ });
+
+ // eslint-disable-next-line global-require
+ const storybook = require('@storybook/react');
configure({
...options,
- storybook: api,
+ storybook,
});
return {
framework: 'react' as const,
renderTree: jest.requireActual('./renderTree').default,
renderShallowTree: jest.requireActual('./renderShallowTree').default,
- storybook: api,
+ storybook,
};
}
diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/riot/loader.ts b/code/addons/storyshots/storyshots-core/src/frameworks/riot/loader.ts
index 1e352031dfba..bd131ba1f80f 100644
--- a/code/addons/storyshots/storyshots-core/src/frameworks/riot/loader.ts
+++ b/code/addons/storyshots/storyshots-core/src/frameworks/riot/loader.ts
@@ -16,17 +16,35 @@ function load(options: StoryshotsOptions) {
global.STORYBOOK_ENV = 'riot';
mockRiotToIncludeCompiler();
- const storybook = jest.requireActual('@storybook/riot');
- const clientAPI = jest.requireActual('@storybook/client-api');
+ let mockStartedAPI: any;
- const api = {
- ...clientAPI,
- ...storybook,
- };
+ jest.mock('@storybook/core-client', () => {
+ const coreClientAPI = jest.requireActual('@storybook/core-client');
+
+ return {
+ ...coreClientAPI,
+ start: (...args: any[]) => {
+ mockStartedAPI = coreClientAPI.start(...args);
+ return mockStartedAPI;
+ },
+ };
+ });
+
+ jest.mock('@storybook/riot', () => {
+ const renderAPI = jest.requireActual('@storybook/riot');
+
+ renderAPI.addDecorator = mockStartedAPI.clientApi.addDecorator;
+ renderAPI.addParameters = mockStartedAPI.clientApi.addParameters;
+
+ return renderAPI;
+ });
+
+ // eslint-disable-next-line global-require
+ const storybook = require('@storybook/riot');
configure({
...options,
- storybook: api,
+ storybook,
});
return {
@@ -35,7 +53,7 @@ function load(options: StoryshotsOptions) {
renderShallowTree: () => {
throw new Error('Shallow renderer is not supported for riot');
},
- storybook: api,
+ storybook,
};
}
diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/svelte/loader.ts b/code/addons/storyshots/storyshots-core/src/frameworks/svelte/loader.ts
index 8f874c7468bd..d7a45bc58466 100644
--- a/code/addons/storyshots/storyshots-core/src/frameworks/svelte/loader.ts
+++ b/code/addons/storyshots/storyshots-core/src/frameworks/svelte/loader.ts
@@ -13,26 +13,43 @@ function test(options: StoryshotsOptions): boolean {
function load(options: StoryshotsOptions) {
global.STORYBOOK_ENV = 'svelte';
- const storybook = jest.requireActual('@storybook/svelte');
- const clientAPI = jest.requireActual('@storybook/client-api');
+ let mockStartedAPI: any;
+
+ jest.mock('@storybook/core-client', () => {
+ const coreClientAPI = jest.requireActual('@storybook/core-client');
+
+ return {
+ ...coreClientAPI,
+ start: (...args: any[]) => {
+ mockStartedAPI = coreClientAPI.start(...args);
+ return mockStartedAPI;
+ },
+ };
+ });
- const api = {
- ...clientAPI,
- ...storybook,
- };
+ jest.mock('@storybook/svelte', () => {
+ const renderAPI = jest.requireActual('@storybook/svelte');
+
+ renderAPI.addDecorator = mockStartedAPI.clientApi.addDecorator;
+ renderAPI.addParameters = mockStartedAPI.clientApi.addParameters;
+
+ return renderAPI;
+ });
+
+ // eslint-disable-next-line global-require
+ const storybook = require('@storybook/svelte');
configure({
...options,
- storybook: api,
+ storybook,
});
-
return {
framework: 'svelte' as const,
renderTree: jest.requireActual('./renderTree').default,
renderShallowTree: () => {
throw new Error('Shallow renderer is not supported for svelte');
},
- storybook: api,
+ storybook,
};
}
diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/vue/loader.ts b/code/addons/storyshots/storyshots-core/src/frameworks/vue/loader.ts
index 3748e7713633..bb97cd1560b5 100644
--- a/code/addons/storyshots/storyshots-core/src/frameworks/vue/loader.ts
+++ b/code/addons/storyshots/storyshots-core/src/frameworks/vue/loader.ts
@@ -16,26 +16,43 @@ function load(options: StoryshotsOptions) {
global.STORYBOOK_ENV = 'vue';
mockVueToIncludeCompiler();
- const storybook = jest.requireActual('@storybook/vue');
- const clientAPI = jest.requireActual('@storybook/client-api');
+ let mockStartedAPI: any;
- const api = {
- ...clientAPI,
- ...storybook,
- };
+ jest.mock('@storybook/core-client', () => {
+ const coreClientAPI = jest.requireActual('@storybook/core-client');
+
+ return {
+ ...coreClientAPI,
+ start: (...args: any[]) => {
+ mockStartedAPI = coreClientAPI.start(...args);
+ return mockStartedAPI;
+ },
+ };
+ });
+
+ jest.mock('@storybook/vue', () => {
+ const renderAPI = jest.requireActual('@storybook/vue');
+
+ renderAPI.addDecorator = mockStartedAPI.clientApi.addDecorator;
+ renderAPI.addParameters = mockStartedAPI.clientApi.addParameters;
+
+ return renderAPI;
+ });
+
+ // eslint-disable-next-line global-require
+ const storybook = require('@storybook/vue');
configure({
...options,
- storybook: api,
+ storybook,
});
-
return {
framework: 'vue' as const,
renderTree: jest.requireActual('./renderTree').default,
renderShallowTree: () => {
throw new Error('Shallow renderer is not supported for vue');
},
- storybook: api,
+ storybook,
};
}
diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/vue3/loader.ts b/code/addons/storyshots/storyshots-core/src/frameworks/vue3/loader.ts
index 980b26e14c98..01de29fa01cc 100644
--- a/code/addons/storyshots/storyshots-core/src/frameworks/vue3/loader.ts
+++ b/code/addons/storyshots/storyshots-core/src/frameworks/vue3/loader.ts
@@ -11,17 +11,35 @@ function test(options: StoryshotsOptions): boolean {
function load(options: StoryshotsOptions) {
global.STORYBOOK_ENV = 'vue3';
- const storybook = jest.requireActual('@storybook/vue');
- const clientAPI = jest.requireActual('@storybook/client-api');
+ let mockStartedAPI: any;
+
+ jest.mock('@storybook/core-client', () => {
+ const coreClientAPI = jest.requireActual('@storybook/core-client');
+
+ return {
+ ...coreClientAPI,
+ start: (...args: any[]) => {
+ mockStartedAPI = coreClientAPI.start(...args);
+ return mockStartedAPI;
+ },
+ };
+ });
- const api = {
- ...clientAPI,
- ...storybook,
- };
+ jest.mock('@storybook/vue3', () => {
+ const renderAPI = jest.requireActual('@storybook/vue3');
+
+ renderAPI.addDecorator = mockStartedAPI.clientApi.addDecorator;
+ renderAPI.addParameters = mockStartedAPI.clientApi.addParameters;
+
+ return renderAPI;
+ });
+
+ // eslint-disable-next-line global-require
+ const storybook = require('@storybook/vue3');
configure({
...options,
- storybook: api,
+ storybook,
});
return {
@@ -30,7 +48,7 @@ function load(options: StoryshotsOptions) {
renderShallowTree: () => {
throw new Error('Shallow renderer is not supported for Vue 3');
},
- storybook: api,
+ storybook,
};
}
diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/web-components/loader.ts b/code/addons/storyshots/storyshots-core/src/frameworks/web-components/loader.ts
index 35f8020718f3..b17cd8f4474f 100644
--- a/code/addons/storyshots/storyshots-core/src/frameworks/web-components/loader.ts
+++ b/code/addons/storyshots/storyshots-core/src/frameworks/web-components/loader.ts
@@ -10,17 +10,35 @@ function test(options: StoryshotsOptions): boolean {
function load(options: StoryshotsOptions) {
global.STORYBOOK_ENV = 'web-components';
- const storybook = jest.requireActual('@storybook/html');
- const clientAPI = jest.requireActual('@storybook/client-api');
+ let mockStartedAPI: any;
+
+ jest.mock('@storybook/core-client', () => {
+ const coreClientAPI = jest.requireActual('@storybook/core-client');
+
+ return {
+ ...coreClientAPI,
+ start: (...args: any[]) => {
+ mockStartedAPI = coreClientAPI.start(...args);
+ return mockStartedAPI;
+ },
+ };
+ });
- const api = {
- ...clientAPI,
- ...storybook,
- };
+ jest.mock('@storybook/html', () => {
+ const renderAPI = jest.requireActual('@storybook/html');
+
+ renderAPI.addDecorator = mockStartedAPI.clientApi.addDecorator;
+ renderAPI.addParameters = mockStartedAPI.clientApi.addParameters;
+
+ return renderAPI;
+ });
+
+ // eslint-disable-next-line global-require
+ const storybook = require('@storybook/html');
configure({
...options,
- storybook: api,
+ storybook,
});
return {
@@ -29,7 +47,7 @@ function load(options: StoryshotsOptions) {
renderShallowTree: () => {
throw new Error('Shallow renderer is not supported for web-components');
},
- storybook: api,
+ storybook,
};
}
diff --git a/code/addons/storyshots/storyshots-puppeteer/package.json b/code/addons/storyshots/storyshots-puppeteer/package.json
index 50097f24f000..125d5283599a 100644
--- a/code/addons/storyshots/storyshots-puppeteer/package.json
+++ b/code/addons/storyshots/storyshots-puppeteer/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-storyshots-puppeteer",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Image snapshots addition to StoryShots based on puppeteer",
"keywords": [
"addon",
@@ -35,17 +35,17 @@
"dependencies": {
"@axe-core/puppeteer": "^4.2.0",
"@storybook/csf": "next",
- "@storybook/node-logger": "7.0.0-alpha.48",
- "@storybook/types": "7.0.0-alpha.48",
- "@types/jest-image-snapshot": "^4.1.3",
- "jest-image-snapshot": "^4.3.0"
+ "@storybook/node-logger": "7.0.0-alpha.51",
+ "@storybook/types": "7.0.0-alpha.51",
+ "@types/jest-image-snapshot": "^5.1.0",
+ "jest-image-snapshot": "^6.0.0"
},
"devDependencies": {
"@types/puppeteer": "^5.4.0",
"puppeteer": "^2.0.0 || ^3.0.0"
},
"peerDependencies": {
- "@storybook/addon-storyshots": "7.0.0-alpha.48",
+ "@storybook/addon-storyshots": "7.0.0-alpha.51",
"puppeteer": ">=2.0.0"
},
"peerDependenciesMeta": {
@@ -56,5 +56,5 @@
"publishConfig": {
"access": "public"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/addons/storyshots/storyshots-puppeteer/tsconfig.json b/code/addons/storyshots/storyshots-puppeteer/tsconfig.json
index 8198a4b0a167..d16da0e1d60f 100644
--- a/code/addons/storyshots/storyshots-puppeteer/tsconfig.json
+++ b/code/addons/storyshots/storyshots-puppeteer/tsconfig.json
@@ -5,6 +5,5 @@
"types": ["node"],
"declaration": true
},
- "include": ["src/**/*"],
- "exclude": []
+ "include": ["src/**/*"]
}
diff --git a/code/addons/storysource/jest.config.js b/code/addons/storysource/jest.config.js
new file mode 100644
index 000000000000..4396fbc7010d
--- /dev/null
+++ b/code/addons/storysource/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.browser');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/addons/storysource/package.json b/code/addons/storysource/package.json
index 587615a846c7..a18a4f13d23b 100644
--- a/code/addons/storysource/package.json
+++ b/code/addons/storysource/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-storysource",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "View a story’s source code to see how it works and paste into your app",
"keywords": [
"addon",
@@ -53,21 +53,21 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/addons": "7.0.0-alpha.48",
- "@storybook/api": "7.0.0-alpha.48",
- "@storybook/client-logger": "7.0.0-alpha.48",
- "@storybook/components": "7.0.0-alpha.48",
- "@storybook/router": "7.0.0-alpha.48",
- "@storybook/source-loader": "7.0.0-alpha.48",
- "@storybook/theming": "7.0.0-alpha.48",
+ "@storybook/addons": "7.0.0-alpha.51",
+ "@storybook/api": "7.0.0-alpha.51",
+ "@storybook/client-logger": "7.0.0-alpha.51",
+ "@storybook/components": "7.0.0-alpha.51",
+ "@storybook/router": "7.0.0-alpha.51",
+ "@storybook/source-loader": "7.0.0-alpha.51",
+ "@storybook/theming": "7.0.0-alpha.51",
"estraverse": "^5.2.0",
"prop-types": "^15.7.2",
"react-syntax-highlighter": "^15.5.0"
},
"devDependencies": {
- "@types/react": "^16.14.23",
+ "@types/react": "^16.14.34",
"@types/react-syntax-highlighter": "11.0.5",
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
@@ -91,7 +91,7 @@
"./src/preset.ts"
]
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd",
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded",
"storybook": {
"displayName": "Storysource",
"icon": "https://user-images.githubusercontent.com/263385/101991675-48cdf300-3c7c-11eb-9400-58de5ac6daa7.png",
diff --git a/code/addons/storysource/tsconfig.json b/code/addons/storysource/tsconfig.json
index 13c4f6e9ee64..cf1e09965901 100644
--- a/code/addons/storysource/tsconfig.json
+++ b/code/addons/storysource/tsconfig.json
@@ -3,13 +3,5 @@
"compilerOptions": {
"skipLibCheck": true
},
- "include": ["src/**/*"],
- "exclude": [
- "src/**/*.test.*",
- "src/**/tests/**/*",
- "src/**/__tests__/**/*",
- "src/**/*.stories.*",
- "src/**/*.mockdata.*",
- "src/**/__testfixtures__/**"
- ]
+ "include": ["src/**/*"]
}
diff --git a/code/addons/toolbars/jest.config.js b/code/addons/toolbars/jest.config.js
new file mode 100644
index 000000000000..4396fbc7010d
--- /dev/null
+++ b/code/addons/toolbars/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.browser');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/addons/toolbars/package.json b/code/addons/toolbars/package.json
index 0b4cbde72ca5..8dce94d497bf 100644
--- a/code/addons/toolbars/package.json
+++ b/code/addons/toolbars/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-toolbars",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Create your own toolbar items that control story rendering",
"keywords": [
"addon",
@@ -46,6 +46,16 @@
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
+ "typesVersions": {
+ "*": {
+ "*": [
+ "dist/index.d.ts"
+ ],
+ "manager": [
+ "dist/manager.d.ts"
+ ]
+ }
+ },
"files": [
"dist/**/*",
"README.md",
@@ -57,14 +67,14 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/addons": "7.0.0-alpha.48",
- "@storybook/api": "7.0.0-alpha.48",
- "@storybook/client-logger": "7.0.0-alpha.48",
- "@storybook/components": "7.0.0-alpha.48",
- "@storybook/theming": "7.0.0-alpha.48"
+ "@storybook/addons": "7.0.0-alpha.51",
+ "@storybook/api": "7.0.0-alpha.51",
+ "@storybook/client-logger": "7.0.0-alpha.51",
+ "@storybook/components": "7.0.0-alpha.51",
+ "@storybook/theming": "7.0.0-alpha.51"
},
"devDependencies": {
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
@@ -88,7 +98,7 @@
],
"platform": "browser"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd",
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded",
"storybook": {
"displayName": "Toolbars",
"icon": "https://user-images.githubusercontent.com/263385/101991677-48cdf300-3c7c-11eb-93b4-19b0e3366959.png",
diff --git a/code/addons/toolbars/tsconfig.json b/code/addons/toolbars/tsconfig.json
index 25de4fbd3e60..a4429176e35f 100644
--- a/code/addons/toolbars/tsconfig.json
+++ b/code/addons/toolbars/tsconfig.json
@@ -3,13 +3,5 @@
"compilerOptions": {
"strict": true
},
- "include": ["src/**/*"],
- "exclude": [
- "src/**/*.test.*",
- "src/**/tests/**/*",
- "src/**/__tests__/**/*",
- "src/**/*.stories.*",
- "src/**/*.mockdata.*",
- "src/**/__testfixtures__/**"
- ]
+ "include": ["src/**/*"]
}
diff --git a/code/addons/viewport/jest.config.js b/code/addons/viewport/jest.config.js
new file mode 100644
index 000000000000..4396fbc7010d
--- /dev/null
+++ b/code/addons/viewport/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.browser');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/addons/viewport/package.json b/code/addons/viewport/package.json
index 35d69a6bc5b9..1174a56e8339 100644
--- a/code/addons/viewport/package.json
+++ b/code/addons/viewport/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-viewport",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Build responsive components by adjusting Storybook’s viewport size and orientation",
"keywords": [
"addon",
@@ -48,6 +48,19 @@
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
+ "typesVersions": {
+ "*": {
+ "*": [
+ "dist/index.d.ts"
+ ],
+ "manager": [
+ "dist/manager.d.ts"
+ ],
+ "preview": [
+ "dist/preview.d.ts"
+ ]
+ }
+ },
"files": [
"dist/**/*",
"README.md",
@@ -59,18 +72,18 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/addons": "7.0.0-alpha.48",
- "@storybook/api": "7.0.0-alpha.48",
- "@storybook/client-logger": "7.0.0-alpha.48",
- "@storybook/components": "7.0.0-alpha.48",
- "@storybook/core-events": "7.0.0-alpha.48",
- "@storybook/theming": "7.0.0-alpha.48",
+ "@storybook/addons": "7.0.0-alpha.51",
+ "@storybook/api": "7.0.0-alpha.51",
+ "@storybook/client-logger": "7.0.0-alpha.51",
+ "@storybook/components": "7.0.0-alpha.51",
+ "@storybook/core-events": "7.0.0-alpha.51",
+ "@storybook/theming": "7.0.0-alpha.51",
"global": "^4.4.0",
"memoizerific": "^1.11.3",
"prop-types": "^15.7.2"
},
"devDependencies": {
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
@@ -95,7 +108,7 @@
"./src/preview.ts"
]
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd",
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded",
"storybook": {
"displayName": "Viewport",
"icon": "https://user-images.githubusercontent.com/263385/101991678-48cdf300-3c7c-11eb-9764-f8af293c1b28.png",
diff --git a/code/addons/viewport/src/shortcuts.ts b/code/addons/viewport/src/shortcuts.ts
index 779726eb9e23..6e9b7302b1c1 100644
--- a/code/addons/viewport/src/shortcuts.ts
+++ b/code/addons/viewport/src/shortcuts.ts
@@ -1,6 +1,11 @@
import type { API } from '@storybook/api';
import { ADDON_ID } from './constants';
+type State = {
+ selected: string;
+ isRotated: boolean;
+};
+
const getCurrentViewportIndex = (viewportsKeys: string[], current: string): number =>
viewportsKeys.indexOf(current);
@@ -24,7 +29,7 @@ export const registerShortcuts = async (api: API, setState: any, viewportsKeys:
defaultShortcut: ['shift', 'V'],
actionName: 'previous',
action: () => {
- const { selected, isRotated } = api.getAddonState(ADDON_ID);
+ const { selected, isRotated } = api.getAddonState(ADDON_ID);
setState({
selected: getPreviousViewport(viewportsKeys, selected),
isRotated,
@@ -37,7 +42,7 @@ export const registerShortcuts = async (api: API, setState: any, viewportsKeys:
defaultShortcut: ['V'],
actionName: 'next',
action: () => {
- const { selected, isRotated } = api.getAddonState(ADDON_ID);
+ const { selected, isRotated } = api.getAddonState(ADDON_ID);
setState({
selected: getNextViewport(viewportsKeys, selected),
isRotated,
@@ -50,7 +55,7 @@ export const registerShortcuts = async (api: API, setState: any, viewportsKeys:
defaultShortcut: ['alt', 'V'],
actionName: 'reset',
action: () => {
- const { isRotated } = api.getAddonState(ADDON_ID);
+ const { isRotated } = api.getAddonState(ADDON_ID);
setState({
selected: 'reset',
isRotated,
diff --git a/code/addons/viewport/tsconfig.json b/code/addons/viewport/tsconfig.json
index d23f9a406fc2..52d43eaaa9b9 100644
--- a/code/addons/viewport/tsconfig.json
+++ b/code/addons/viewport/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/frameworks/angular/jest.config.js b/code/frameworks/angular/jest.config.js
index 687a16f155b2..dc0ffa5cecd4 100644
--- a/code/frameworks/angular/jest.config.js
+++ b/code/frameworks/angular/jest.config.js
@@ -1,5 +1,12 @@
+const path = require('path');
+
module.exports = {
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
preset: 'jest-preset-angular',
setupFilesAfterEnv: ['/setup-jest.ts'],
- transformIgnorePatterns: ['^.+\\.js$'],
+ transformIgnorePatterns: ['/node_modules/(?!@angular|rxjs|nanoid|uuid)'],
+ snapshotFormat: {
+ escapeString: true,
+ printBasicPrototype: true,
+ },
};
diff --git a/code/frameworks/angular/package.json b/code/frameworks/angular/package.json
index 52275544488c..6dcb8e151f57 100644
--- a/code/frameworks/angular/package.json
+++ b/code/frameworks/angular/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/angular",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook for Angular: Develop Angular components in isolation with hot reloading.",
"keywords": [
"storybook",
@@ -34,23 +34,24 @@
"prep": "rimraf dist && ../../../scripts/node_modules/.bin/tsc --project tsconfig.build.json && echo \"Preventing passing flags to tsc\""
},
"dependencies": {
- "@storybook/addons": "7.0.0-alpha.48",
- "@storybook/api": "7.0.0-alpha.48",
- "@storybook/builder-webpack5": "7.0.0-alpha.48",
- "@storybook/client-logger": "7.0.0-alpha.48",
- "@storybook/core-client": "7.0.0-alpha.48",
- "@storybook/core-common": "7.0.0-alpha.48",
- "@storybook/core-events": "7.0.0-alpha.48",
- "@storybook/core-server": "7.0.0-alpha.48",
- "@storybook/core-webpack": "7.0.0-alpha.48",
- "@storybook/docs-tools": "7.0.0-alpha.48",
- "@storybook/node-logger": "7.0.0-alpha.48",
- "@storybook/store": "7.0.0-alpha.48",
- "@storybook/types": "7.0.0-alpha.48",
- "@types/node": "^16.0.0",
- "@types/react": "^16.14.23",
+ "@storybook/addons": "7.0.0-alpha.51",
+ "@storybook/api": "7.0.0-alpha.51",
+ "@storybook/builder-webpack5": "7.0.0-alpha.51",
+ "@storybook/client-logger": "7.0.0-alpha.51",
+ "@storybook/core-client": "7.0.0-alpha.51",
+ "@storybook/core-common": "7.0.0-alpha.51",
+ "@storybook/core-events": "7.0.0-alpha.51",
+ "@storybook/core-server": "7.0.0-alpha.51",
+ "@storybook/core-webpack": "7.0.0-alpha.51",
+ "@storybook/docs-tools": "7.0.0-alpha.51",
+ "@storybook/node-logger": "7.0.0-alpha.51",
+ "@storybook/store": "7.0.0-alpha.51",
+ "@storybook/types": "7.0.0-alpha.51",
+ "@types/node": "^16.0.0 || ^18.0.0",
+ "@types/react": "^16.14.34",
"@types/react-dom": "^16.9.14",
"@types/semver": "^7.3.4",
+ "@types/webpack-env": "^1.18.0",
"core-js": "^3.8.2",
"find-up": "^5.0.0",
"global": "^4.4.0",
@@ -80,12 +81,12 @@
"@types/rimraf": "^3.0.2",
"@types/tmp": "^0.2.3",
"cross-spawn": "^7.0.3",
- "jest": "^27.5.1",
+ "jest": "^29.3.1",
"jest-preset-angular": "^12.0.0",
- "jest-specific-snapshot": "^5.0.0",
+ "jest-specific-snapshot": "^6.0.0",
"rimraf": "^3.0.2",
"tmp": "^0.2.1",
- "typescript": "~4.6.3",
+ "typescript": "^4.9.3",
"webpack": "5",
"zone.js": "^0.11.0"
},
@@ -122,5 +123,5 @@
"access": "public"
},
"builders": "dist/builders/builders.json",
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/frameworks/angular/setup-jest.ts b/code/frameworks/angular/setup-jest.ts
index 3caa91649606..06e753a2e78e 100644
--- a/code/frameworks/angular/setup-jest.ts
+++ b/code/frameworks/angular/setup-jest.ts
@@ -1,4 +1,12 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import 'jest-preset-angular/setup-jest';
+import { webcrypto } from 'node:crypto';
+
+Object.defineProperty(window, 'crypto', {
+ get() {
+ return webcrypto;
+ },
+});
+
global.EventSource = class {} as any;
diff --git a/code/frameworks/angular/src/builders/build-storybook/index.spec.ts b/code/frameworks/angular/src/builders/build-storybook/index.spec.ts
index f539e00793a0..c5164efcf99e 100644
--- a/code/frameworks/angular/src/builders/build-storybook/index.spec.ts
+++ b/code/frameworks/angular/src/builders/build-storybook/index.spec.ts
@@ -3,8 +3,13 @@ import { TestingArchitectHost } from '@angular-devkit/architect/testing';
import { schema } from '@angular-devkit/core';
import * as path from 'path';
-const buildStandaloneMock = jest.fn();
-jest.doMock('@storybook/angular/standalone', () => buildStandaloneMock);
+const buildDevStandaloneMock = jest.fn();
+const buildStaticStandaloneMock = jest.fn();
+const buildMock = {
+ buildDevStandalone: buildDevStandaloneMock,
+ buildStaticStandalone: buildStaticStandaloneMock,
+};
+jest.doMock('@storybook/core-server', () => buildMock);
jest.doMock('find-up', () => ({ sync: () => './storybook/tsconfig.ts' }));
const cpSpawnMock = {
@@ -50,7 +55,7 @@ describe('Build Storybook Builder', () => {
});
beforeEach(() => {
- buildStandaloneMock.mockImplementation((_options: unknown) => Promise.resolve());
+ buildStaticStandaloneMock.mockImplementation((_options: unknown) => Promise.resolve());
cpSpawnMock.spawn.mockImplementation(() => ({
stdout: { on: () => {} },
stderr: { on: () => {} },
@@ -74,14 +79,16 @@ describe('Build Storybook Builder', () => {
expect(output.success).toBeTruthy();
expect(cpSpawnMock.spawn).not.toHaveBeenCalledWith();
- expect(buildStandaloneMock).toHaveBeenCalledWith({
+ expect(buildStaticStandaloneMock).toHaveBeenCalledWith({
angularBrowserTarget: 'angular-cli:build-2',
angularBuilderContext: expect.any(Object),
angularBuilderOptions: {},
configDir: '.storybook',
+ docs: undefined,
loglevel: undefined,
quiet: false,
outputDir: 'storybook-static',
+ packageJson: expect.any(Object),
mode: 'static',
tsConfig: './storybook/tsconfig.ts',
webpackStatsJson: false,
@@ -100,14 +107,16 @@ describe('Build Storybook Builder', () => {
expect(output.success).toBeTruthy();
expect(cpSpawnMock.spawn).not.toHaveBeenCalledWith();
- expect(buildStandaloneMock).toHaveBeenCalledWith({
+ expect(buildStaticStandaloneMock).toHaveBeenCalledWith({
angularBrowserTarget: null,
angularBuilderContext: expect.any(Object),
angularBuilderOptions: {},
configDir: '.storybook',
+ docs: undefined,
loglevel: undefined,
quiet: false,
outputDir: 'storybook-static',
+ packageJson: expect.any(Object),
mode: 'static',
tsConfig: 'path/to/tsConfig.json',
webpackStatsJson: false,
@@ -127,14 +136,16 @@ describe('Build Storybook Builder', () => {
expect(output.success).toBeTruthy();
expect(cpSpawnMock.spawn).not.toHaveBeenCalledWith();
- expect(buildStandaloneMock).toHaveBeenCalledWith({
+ expect(buildStaticStandaloneMock).toHaveBeenCalledWith({
angularBrowserTarget: null,
angularBuilderContext: expect.any(Object),
angularBuilderOptions: {},
configDir: '.storybook',
+ docs: undefined,
loglevel: undefined,
quiet: false,
outputDir: 'storybook-static',
+ packageJson: expect.any(Object),
mode: 'static',
tsConfig: 'path/to/tsConfig.json',
webpackStatsJson: true,
@@ -142,7 +153,7 @@ describe('Build Storybook Builder', () => {
});
it('should throw error', async () => {
- buildStandaloneMock.mockRejectedValue(true);
+ buildStaticStandaloneMock.mockRejectedValue(true);
const run = await architect.scheduleBuilder('@storybook/angular:start-storybook', {
browserTarget: 'angular-cli:build-2',
@@ -177,16 +188,19 @@ describe('Build Storybook Builder', () => {
['compodoc', '-p', './storybook/tsconfig.ts', '-d', '', '-e', 'json'],
{
cwd: '',
+ shell: true,
}
);
- expect(buildStandaloneMock).toHaveBeenCalledWith({
+ expect(buildStaticStandaloneMock).toHaveBeenCalledWith({
angularBrowserTarget: 'angular-cli:build-2',
angularBuilderContext: expect.any(Object),
angularBuilderOptions: {},
configDir: '.storybook',
+ docs: undefined,
loglevel: undefined,
quiet: false,
outputDir: 'storybook-static',
+ packageJson: expect.any(Object),
mode: 'static',
tsConfig: './storybook/tsconfig.ts',
webpackStatsJson: false,
@@ -206,14 +220,16 @@ describe('Build Storybook Builder', () => {
expect(output.success).toBeTruthy();
expect(cpSpawnMock.spawn).not.toHaveBeenCalledWith();
- expect(buildStandaloneMock).toHaveBeenCalledWith({
+ expect(buildStaticStandaloneMock).toHaveBeenCalledWith({
angularBrowserTarget: null,
angularBuilderContext: expect.any(Object),
angularBuilderOptions: { styles: ['style.scss'] },
configDir: '.storybook',
+ docs: undefined,
loglevel: undefined,
quiet: false,
outputDir: 'storybook-static',
+ packageJson: expect.any(Object),
mode: 'static',
tsConfig: 'path/to/tsConfig.json',
webpackStatsJson: false,
diff --git a/code/frameworks/angular/src/builders/start-storybook/index.spec.ts b/code/frameworks/angular/src/builders/start-storybook/index.spec.ts
index aacd352b6a8c..c70d7cbf5b37 100644
--- a/code/frameworks/angular/src/builders/start-storybook/index.spec.ts
+++ b/code/frameworks/angular/src/builders/start-storybook/index.spec.ts
@@ -3,8 +3,13 @@ import { TestingArchitectHost } from '@angular-devkit/architect/testing';
import { schema } from '@angular-devkit/core';
import * as path from 'path';
-const buildStandaloneMock = jest.fn();
-jest.doMock('@storybook/angular/standalone', () => buildStandaloneMock);
+const buildDevStandaloneMock = jest.fn();
+const buildStaticStandaloneMock = jest.fn();
+const buildMock = {
+ buildDevStandalone: buildDevStandaloneMock,
+ buildStaticStandalone: buildStaticStandaloneMock,
+};
+jest.doMock('@storybook/core-server', () => buildMock);
jest.doMock('find-up', () => ({ sync: () => './storybook/tsconfig.ts' }));
const cpSpawnMock = {
@@ -49,7 +54,7 @@ describe('Start Storybook Builder', () => {
});
beforeEach(() => {
- buildStandaloneMock.mockImplementation((_options: unknown) => Promise.resolve());
+ buildDevStandaloneMock.mockImplementation((_options: unknown) => Promise.resolve());
cpSpawnMock.spawn.mockImplementation(() => ({
stdout: { on: () => {} },
stderr: { on: () => {} },
@@ -74,14 +79,16 @@ describe('Start Storybook Builder', () => {
expect(output.success).toBeTruthy();
expect(cpSpawnMock.spawn).not.toHaveBeenCalledWith();
- expect(buildStandaloneMock).toHaveBeenCalledWith({
+ expect(buildDevStandaloneMock).toHaveBeenCalledWith({
angularBrowserTarget: 'angular-cli:build-2',
angularBuilderContext: expect.any(Object),
angularBuilderOptions: {},
ci: false,
configDir: '.storybook',
+ docs: undefined,
host: 'localhost',
https: false,
+ packageJson: expect.any(Object),
port: 4400,
quiet: false,
smokeTest: false,
@@ -105,14 +112,16 @@ describe('Start Storybook Builder', () => {
expect(output.success).toBeTruthy();
expect(cpSpawnMock.spawn).not.toHaveBeenCalledWith();
- expect(buildStandaloneMock).toHaveBeenCalledWith({
+ expect(buildDevStandaloneMock).toHaveBeenCalledWith({
angularBrowserTarget: null,
angularBuilderContext: expect.any(Object),
angularBuilderOptions: {},
ci: false,
configDir: '.storybook',
+ docs: undefined,
host: 'localhost',
https: false,
+ packageJson: expect.any(Object),
port: 4400,
quiet: false,
smokeTest: false,
@@ -124,7 +133,7 @@ describe('Start Storybook Builder', () => {
});
it('should throw error', async () => {
- buildStandaloneMock.mockRejectedValue(true);
+ buildDevStandaloneMock.mockRejectedValue(true);
const run = await architect.scheduleBuilder('@storybook/angular:start-storybook', {
browserTarget: 'angular-cli:build-2',
@@ -159,16 +168,19 @@ describe('Start Storybook Builder', () => {
['compodoc', '-p', './storybook/tsconfig.ts', '-d', '', '-e', 'json'],
{
cwd: '',
+ shell: true,
}
);
- expect(buildStandaloneMock).toHaveBeenCalledWith({
+ expect(buildDevStandaloneMock).toHaveBeenCalledWith({
angularBrowserTarget: 'angular-cli:build-2',
angularBuilderContext: expect.any(Object),
angularBuilderOptions: {},
ci: false,
configDir: '.storybook',
+ docs: undefined,
host: 'localhost',
https: false,
+ packageJson: expect.any(Object),
port: 9009,
quiet: false,
smokeTest: false,
@@ -193,7 +205,7 @@ describe('Start Storybook Builder', () => {
expect(output.success).toBeTruthy();
expect(cpSpawnMock.spawn).not.toHaveBeenCalledWith();
- expect(buildStandaloneMock).toHaveBeenCalledWith({
+ expect(buildDevStandaloneMock).toHaveBeenCalledWith({
angularBrowserTarget: null,
angularBuilderContext: expect.any(Object),
angularBuilderOptions: {
@@ -201,9 +213,11 @@ describe('Start Storybook Builder', () => {
},
ci: false,
configDir: '.storybook',
+ docs: undefined,
host: 'localhost',
https: false,
port: 4400,
+ packageJson: expect.any(Object),
quiet: false,
smokeTest: false,
sslCa: undefined,
diff --git a/code/frameworks/angular/src/builders/utils/run-compodoc.spec.ts b/code/frameworks/angular/src/builders/utils/run-compodoc.spec.ts
index 900bc6a7669f..06d0f37a5223 100644
--- a/code/frameworks/angular/src/builders/utils/run-compodoc.spec.ts
+++ b/code/frameworks/angular/src/builders/utils/run-compodoc.spec.ts
@@ -51,6 +51,7 @@ describe('runCompodoc', () => {
['compodoc', '-p', 'path/to/tsconfig.json', '-d', 'path/to/project'],
{
cwd: 'path/to/project',
+ shell: true,
}
);
});
@@ -74,6 +75,7 @@ describe('runCompodoc', () => {
['compodoc', '-d', 'path/to/project', '-p', 'path/to/tsconfig.stories.json'],
{
cwd: 'path/to/project',
+ shell: true,
}
);
});
diff --git a/code/frameworks/angular/src/client/angular-beta/RendererFactory.test.ts b/code/frameworks/angular/src/client/angular-beta/RendererFactory.test.ts
index 0129a09f68a2..a50a8c5ff80c 100644
--- a/code/frameworks/angular/src/client/angular-beta/RendererFactory.test.ts
+++ b/code/frameworks/angular/src/client/angular-beta/RendererFactory.test.ts
@@ -18,8 +18,8 @@ describe('RendererFactory', () => {
beforeEach(async () => {
rendererFactory = new RendererFactory();
document.body.innerHTML =
- '
';
- rootTargetDOMNode = global.document.getElementById('root');
+ '
';
+ rootTargetDOMNode = global.document.getElementById('storybook-root');
rootDocstargetDOMNode = global.document.getElementById('root-docs');
(platformBrowserDynamic as any).mockImplementation(platformBrowserDynamicTesting);
jest.spyOn(console, 'log').mockImplementation(() => {});
@@ -301,14 +301,16 @@ describe('RendererFactory', () => {
});
it('should reset root HTML', async () => {
- global.document.getElementById('root').appendChild(global.document.createElement('👾'));
+ global.document
+ .getElementById('storybook-root')
+ .appendChild(global.document.createElement('👾'));
- expect(global.document.getElementById('root').innerHTML).toContain('Canvas 🖼');
+ expect(global.document.getElementById('storybook-root').innerHTML).toContain('Canvas 🖼');
const render = await rendererFactory.getRendererInstance(
'my-story-in-docs',
rootDocstargetDOMNode
);
- expect(global.document.getElementById('root').innerHTML).toBe('');
+ expect(global.document.getElementById('storybook-root').innerHTML).toBe('');
});
});
diff --git a/code/frameworks/angular/src/client/angular/helpers.ts b/code/frameworks/angular/src/client/angular/helpers.ts
index ce0c1fcd9f1c..10ce71718090 100644
--- a/code/frameworks/angular/src/client/angular/helpers.ts
+++ b/code/frameworks/angular/src/client/angular/helpers.ts
@@ -7,7 +7,7 @@ import { Subscriber, Observable, ReplaySubject } from 'rxjs';
import { PartialStoryFn } from '@storybook/types';
import { AppComponent } from './app.component';
import { STORY } from './app.token';
-import { NgModuleMetadata, StoryFnAngularReturnType, AngularFramework } from '../types';
+import { NgModuleMetadata, StoryFnAngularReturnType, AngularRenderer } from '../types';
const { document } = global;
@@ -131,7 +131,7 @@ const getExistenceOfComponentInModules = (
});
};
-const initModule = (storyFn: PartialStoryFn) => {
+const initModule = (storyFn: PartialStoryFn) => {
const storyObj = storyFn();
const { component, template, props, styles, moduleMetadata = {} } = storyObj;
@@ -198,7 +198,7 @@ const draw = (newModule: DynamicComponentType): void => {
}
};
-export const renderNgApp = (storyFn: PartialStoryFn, forced: boolean) => {
+export const renderNgApp = (storyFn: PartialStoryFn, forced: boolean) => {
if (!forced) {
draw(initModule(storyFn));
} else {
diff --git a/code/frameworks/angular/src/client/decorateStory.test.ts b/code/frameworks/angular/src/client/decorateStory.test.ts
index 646f56398c80..bf5d7b6dd5bb 100644
--- a/code/frameworks/angular/src/client/decorateStory.test.ts
+++ b/code/frameworks/angular/src/client/decorateStory.test.ts
@@ -3,12 +3,12 @@ import { DecoratorFunction, StoryContext } from '@storybook/types';
import { componentWrapperDecorator } from './decorators';
import decorateStory from './decorateStory';
-import { AngularFramework } from './types';
+import { AngularRenderer } from './types';
describe('decorateStory', () => {
describe('angular behavior', () => {
it('should use componentWrapperDecorator with args', () => {
- const decorators: DecoratorFunction[] = [
+ const decorators: DecoratorFunction[] = [
componentWrapperDecorator(ParentComponent, ({ args }) => args),
componentWrapperDecorator(
(story) => `${story} `,
@@ -42,7 +42,7 @@ describe('decorateStory', () => {
});
it('should use componentWrapperDecorator with input / output', () => {
- const decorators: DecoratorFunction[] = [
+ const decorators: DecoratorFunction[] = [
componentWrapperDecorator(ParentComponent, {
parentInput: 'Parent input',
parentOutput: () => {},
@@ -81,7 +81,7 @@ describe('decorateStory', () => {
});
it('should use componentWrapperDecorator', () => {
- const decorators: DecoratorFunction[] = [
+ const decorators: DecoratorFunction[] = [
componentWrapperDecorator(ParentComponent),
componentWrapperDecorator((story) => `${story} `),
componentWrapperDecorator((story) => `${story} `),
@@ -96,7 +96,7 @@ describe('decorateStory', () => {
});
it('should use template in preference to component parameters', () => {
- const decorators: DecoratorFunction[] = [
+ const decorators: DecoratorFunction[] = [
(s) => {
const story = s();
return {
@@ -129,7 +129,7 @@ describe('decorateStory', () => {
});
it('should include story templates in decorators', () => {
- const decorators: DecoratorFunction[] = [
+ const decorators: DecoratorFunction[] = [
(s) => {
const story = s();
return {
@@ -162,7 +162,7 @@ describe('decorateStory', () => {
});
it('should include story components in decorators', () => {
- const decorators: DecoratorFunction[] = [
+ const decorators: DecoratorFunction[] = [
(s) => {
const story = s();
return {
@@ -195,7 +195,7 @@ describe('decorateStory', () => {
});
it('should include legacy story components in decorators', () => {
- const decorators: DecoratorFunction[] = [
+ const decorators: DecoratorFunction[] = [
(s) => {
const story = s();
return {
@@ -229,7 +229,7 @@ describe('decorateStory', () => {
});
it('should keep template with an empty value', () => {
- const decorators: DecoratorFunction[] = [
+ const decorators: DecoratorFunction[] = [
componentWrapperDecorator(ParentComponent),
];
const decorated = decorateStory(() => ({ template: '' }), decorators);
@@ -272,7 +272,7 @@ describe('decorateStory', () => {
describe('default behavior', () => {
it('calls decorators in out to in order', () => {
- const decorators: DecoratorFunction[] = [
+ const decorators: DecoratorFunction[] = [
(s) => {
const story = s();
return { ...story, props: { a: [...story.props.a, 1] } };
@@ -292,7 +292,7 @@ describe('decorateStory', () => {
});
it('passes context through to sub decorators', () => {
- const decorators: DecoratorFunction[] = [
+ const decorators: DecoratorFunction[] = [
(s, c) => {
const story = s({ ...c, k: 1 });
return { ...story, props: { a: [...story.props.a, c.k] } };
@@ -312,7 +312,7 @@ describe('decorateStory', () => {
});
it('DOES NOT merge parameter or pass through parameters key in context', () => {
- const decorators: DecoratorFunction[] = [
+ const decorators: DecoratorFunction[] = [
(s, c) => {
const story = s({ ...c, k: 1, parameters: { p: 1 } });
return {
@@ -347,7 +347,7 @@ describe('decorateStory', () => {
});
});
-function makeContext(input: Record): StoryContext {
+function makeContext(input: Record): StoryContext {
return {
id: 'id',
kind: 'kind',
@@ -355,7 +355,7 @@ function makeContext(input: Record): StoryContext;
+ } as StoryContext;
}
@Component({
diff --git a/code/frameworks/angular/src/client/decorateStory.ts b/code/frameworks/angular/src/client/decorateStory.ts
index a7816084f232..2b3daf651371 100644
--- a/code/frameworks/angular/src/client/decorateStory.ts
+++ b/code/frameworks/angular/src/client/decorateStory.ts
@@ -2,15 +2,15 @@ import { DecoratorFunction, LegacyStoryFn, StoryContext } from '@storybook/types
import { sanitizeStoryContextUpdate } from '@storybook/store';
import { computesTemplateFromComponent } from './angular-beta/ComputesTemplateFromComponent';
-import { AngularFramework } from './types';
+import { AngularRenderer } from './types';
export default function decorateStory(
- mainStoryFn: LegacyStoryFn,
- decorators: DecoratorFunction[]
-): LegacyStoryFn {
+ mainStoryFn: LegacyStoryFn,
+ decorators: DecoratorFunction[]
+): LegacyStoryFn {
const returnDecorators = [cleanArgsDecorator, ...decorators].reduce(
- (previousStoryFn: LegacyStoryFn, decorator) =>
- (context: StoryContext) => {
+ (previousStoryFn: LegacyStoryFn, decorator) =>
+ (context: StoryContext) => {
const decoratedStory = decorator((update) => {
return previousStoryFn({
...context,
@@ -29,9 +29,9 @@ export default function decorateStory(
export { decorateStory };
const prepareMain = (
- story: AngularFramework['storyResult'],
- context: StoryContext
-): AngularFramework['storyResult'] => {
+ story: AngularRenderer['storyResult'],
+ context: StoryContext
+): AngularRenderer['storyResult'] => {
let { template } = story;
const component = story.component ?? context.component;
@@ -50,7 +50,7 @@ function hasNoTemplate(template: string | null | undefined): template is undefin
return template === null || template === undefined;
}
-const cleanArgsDecorator: DecoratorFunction = (storyFn, context) => {
+const cleanArgsDecorator: DecoratorFunction = (storyFn, context) => {
if (!context.argTypes || !context.args) {
return storyFn();
}
diff --git a/code/frameworks/angular/src/client/decorators.test.ts b/code/frameworks/angular/src/client/decorators.test.ts
index 3f7651051f2a..8ed4e347c55a 100644
--- a/code/frameworks/angular/src/client/decorators.test.ts
+++ b/code/frameworks/angular/src/client/decorators.test.ts
@@ -2,9 +2,9 @@ import { Addon_StoryContext } from '@storybook/types';
import { Component } from '@angular/core';
import { moduleMetadata } from './decorators';
-import { AngularFramework } from './types';
+import { AngularRenderer } from './types';
-const defaultContext: Addon_StoryContext = {
+const defaultContext: Addon_StoryContext = {
componentId: 'unspecified',
kind: 'unspecified',
title: 'unspecified',
diff --git a/code/frameworks/angular/src/client/decorators.ts b/code/frameworks/angular/src/client/decorators.ts
index 9e5a59ca04e6..b34b416e71a2 100644
--- a/code/frameworks/angular/src/client/decorators.ts
+++ b/code/frameworks/angular/src/client/decorators.ts
@@ -3,12 +3,12 @@ import { Type } from '@angular/core';
import { DecoratorFunction, StoryContext } from '@storybook/types';
import { computesTemplateFromComponent } from './angular-beta/ComputesTemplateFromComponent';
import { isComponent } from './angular-beta/utils/NgComponentAnalyzer';
-import { ICollection, NgModuleMetadata, AngularFramework } from './types';
+import { ICollection, NgModuleMetadata, AngularRenderer } from './types';
// We use `any` here as the default type rather than `Args` because we need something that is
// castable to any component-specific args type when the user is being careful.
export const moduleMetadata =
- (metadata: Partial): DecoratorFunction =>
+ (metadata: Partial): DecoratorFunction =>
(storyFn) => {
const story = storyFn();
const storyMetadata = story.moduleMetadata || {};
@@ -32,8 +32,8 @@ export const moduleMetadata =
export const componentWrapperDecorator =
(
element: Type | ((story: string) => string),
- props?: ICollection | ((storyContext: StoryContext) => ICollection)
- ): DecoratorFunction =>
+ props?: ICollection | ((storyContext: StoryContext) => ICollection)
+ ): DecoratorFunction =>
(storyFn, storyContext) => {
const story = storyFn();
const currentProps = typeof props === 'function' ? (props(storyContext) as ICollection) : props;
diff --git a/code/frameworks/angular/src/client/docs/__testfixtures__/doc-button/compodoc-posix.snapshot b/code/frameworks/angular/src/client/docs/__testfixtures__/doc-button/compodoc-posix.snapshot
index dbb2d4c08edf..de95727d81f5 100644
--- a/code/frameworks/angular/src/client/docs/__testfixtures__/doc-button/compodoc-posix.snapshot
+++ b/code/frameworks/angular/src/client/docs/__testfixtures__/doc-button/compodoc-posix.snapshot
@@ -10,7 +10,7 @@ Object {
"getSignature": Object {
"description": "Getter for inputValue
.
",
- "line": 115,
+ "line": 116,
"name": "inputValue",
"rawdescription": "
Getter for \`inputValue\`.",
@@ -42,7 +42,7 @@ Getter for \`inputValue\`.",
"type": "string",
},
],
- "line": 110,
+ "line": 111,
"name": "inputValue",
"rawdescription": "
Setter for \`inputValue\` that is also an \`@Input\`.",
@@ -74,7 +74,7 @@ Setter for \`inputValue\` that is also an \`@Input\`.",
"type": "T[]",
},
],
- "line": 195,
+ "line": 196,
"name": "item",
"returnType": "void",
"type": "void",
@@ -84,7 +84,7 @@ Setter for \`inputValue\` that is also an \`@Input\`.",
"getSignature": Object {
"description": "Get the private value.
",
- "line": 154,
+ "line": 155,
"name": "value",
"rawdescription": "
Get the private value.",
@@ -116,7 +116,7 @@ Get the private value.",
"type": "string | number",
},
],
- "line": 149,
+ "line": 150,
"name": "value",
"rawdescription": "
Set the private value.",
@@ -137,14 +137,14 @@ like bold , italic , and inline code
.
",
"encapsulation": Array [],
"entryComponents": Array [],
- "file": "addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts",
+ "file": "frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts",
"hostBindings": Array [
Object {
"decorators": Array [],
"defaultValue": "false",
"deprecated": false,
"deprecationMessage": "",
- "line": 124,
+ "line": 125,
"name": "class.focused",
"type": "boolean",
},
@@ -164,7 +164,7 @@ like bold , italic , and inline code
.
],
"deprecated": false,
"deprecationMessage": "",
- "line": 120,
+ "line": 121,
"name": "click",
},
],
@@ -177,7 +177,7 @@ like bold , italic , and inline code
.
"deprecationMessage": "",
"description": "Specify the accent-type of the button
",
- "line": 56,
+ "line": 57,
"name": "accent",
"rawdescription": "
Specify the accent-type of the button",
@@ -190,7 +190,7 @@ Specify the accent-type of the button",
"deprecationMessage": "",
"description": "Appearance style of the button.
",
- "line": 52,
+ "line": 53,
"name": "appearance",
"rawdescription": "
Appearance style of the button.",
@@ -202,7 +202,7 @@ Appearance style of the button.",
"deprecationMessage": "",
"description": "Setter for inputValue
that is also an @Input
.
",
- "line": 110,
+ "line": 111,
"name": "inputValue",
"rawdescription": "
Setter for \`inputValue\` that is also an \`@Input\`.",
@@ -215,7 +215,7 @@ Setter for \`inputValue\` that is also an \`@Input\`.",
"deprecationMessage": "",
"description": "Sets the button to a disabled state.
",
- "line": 60,
+ "line": 61,
"name": "isDisabled",
"rawdescription": "
Sets the button to a disabled state.",
@@ -225,7 +225,7 @@ Sets the button to a disabled state.",
"decorators": Array [],
"deprecated": false,
"deprecationMessage": "",
- "line": 195,
+ "line": 196,
"name": "item",
"type": "T[]",
},
@@ -238,24 +238,24 @@ Sets the button to a disabled state.",
"jsdoctags": Array [
Object {
"comment": "",
- "end": 1525,
+ "end": 1587,
"flags": 4227072,
"kind": 325,
"modifierFlagsCache": 0,
- "pos": 1512,
+ "pos": 1574,
"tagName": Object {
- "end": 1521,
+ "end": 1583,
"escapedText": "required",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
- "pos": 1513,
+ "pos": 1575,
"transformFlags": 0,
},
"transformFlags": 0,
},
],
- "line": 68,
+ "line": 69,
"name": "label",
"rawdescription": "
@@ -268,7 +268,7 @@ The inner text of the button.
"decorators": Array [],
"deprecated": false,
"deprecationMessage": "",
- "line": 192,
+ "line": 193,
"name": "showKeyAlias",
"type": "",
},
@@ -279,7 +279,7 @@ The inner text of the button.
"deprecationMessage": "",
"description": "Size of the button.
",
- "line": 72,
+ "line": 73,
"name": "size",
"rawdescription": "
Size of the button.",
@@ -291,7 +291,7 @@ Size of the button.",
"deprecationMessage": "",
"description": "Specifies some arbitrary object
",
- "line": 75,
+ "line": 76,
"name": "someDataObject",
"rawdescription": "
Specifies some arbitrary object",
@@ -307,24 +307,24 @@ Specifies some arbitrary object",
"jsdoctags": Array [
Object {
"comment": "",
- "end": 1802,
+ "end": 1864,
"flags": 4227072,
"kind": 329,
"modifierFlagsCache": 0,
- "pos": 1787,
+ "pos": 1849,
"tagName": Object {
- "end": 1798,
+ "end": 1860,
"escapedText": "deprecated",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
- "pos": 1788,
+ "pos": 1850,
"transformFlags": 0,
},
"transformFlags": 0,
},
],
- "line": 83,
+ "line": 84,
"name": "somethingYouShouldNotUse",
"rawdescription": "
@@ -361,21 +361,21 @@ Some input you shouldn't use.
"deprecated": false,
"deprecationMessage": "",
"name": Object {
- "end": 3518,
+ "end": 3580,
"escapedText": "x",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
- "pos": 3517,
+ "pos": 3579,
"transformFlags": 0,
},
"tagName": Object {
- "end": 3516,
+ "end": 3578,
"escapedText": "param",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
- "pos": 3511,
+ "pos": 3573,
"transformFlags": 0,
},
"type": "number",
@@ -386,27 +386,27 @@ Some input you shouldn't use.
"deprecated": false,
"deprecationMessage": "",
"name": Object {
- "end": 3563,
+ "end": 3625,
"escapedText": "y",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
- "pos": 3562,
+ "pos": 3624,
"transformFlags": 0,
},
"tagName": Object {
- "end": 3561,
+ "end": 3623,
"escapedText": "param",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
- "pos": 3556,
+ "pos": 3618,
"transformFlags": 0,
},
"type": "string | number",
},
],
- "line": 164,
+ "line": 165,
"modifierKind": Array [
123,
],
@@ -448,7 +448,7 @@ An internal calculation method which adds \`x\` and \`y\` together.
"type": "",
},
],
- "line": 120,
+ "line": 121,
"name": "onClickListener",
"optional": false,
"returnType": "void",
@@ -474,27 +474,27 @@ An internal calculation method which adds \`x\` and \`y\` together.
"deprecated": false,
"deprecationMessage": "",
"name": Object {
- "end": 4079,
+ "end": 4141,
"escapedText": "password",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
- "pos": 4071,
+ "pos": 4133,
"transformFlags": 0,
},
"tagName": Object {
- "end": 4070,
+ "end": 4132,
"escapedText": "param",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
- "pos": 4065,
+ "pos": 4127,
"transformFlags": 0,
},
"type": "string",
},
],
- "line": 187,
+ "line": 188,
"modifierKind": Array [
121,
],
@@ -529,28 +529,28 @@ A private method.
"deprecated": false,
"deprecationMessage": "",
"name": Object {
- "end": 3938,
+ "end": 4000,
"escapedText": "id",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
- "pos": 3936,
+ "pos": 3998,
"transformFlags": 0,
},
"optional": true,
"tagName": Object {
- "end": 3935,
+ "end": 3997,
"escapedText": "param",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
- "pos": 3930,
+ "pos": 3992,
"transformFlags": 0,
},
"type": "number",
},
],
- "line": 178,
+ "line": 179,
"modifierKind": Array [
122,
],
@@ -588,7 +588,7 @@ A protected method.
"type": "ISomeInterface",
},
],
- "line": 169,
+ "line": 170,
"modifierKind": Array [
123,
],
@@ -610,7 +610,7 @@ A public method using an interface.",
"description": "Handler to be called when the button is clicked by a user.
Will also block the emission of the event if isDisabled
is true.
",
- "line": 91,
+ "line": 92,
"name": "onClick",
"rawdescription": "
@@ -627,7 +627,7 @@ Will also block the emission of the event if \`isDisabled\` is true.
"deprecated": false,
"deprecationMessage": "",
"description": "",
- "line": 106,
+ "line": 107,
"modifierKind": Array [
121,
],
@@ -641,7 +641,7 @@ Will also block the emission of the event if \`isDisabled\` is true.
"deprecationMessage": "",
"description": "Private value.
",
- "line": 146,
+ "line": 147,
"modifierKind": Array [
121,
],
@@ -661,7 +661,7 @@ Private value.",
"deprecated": false,
"deprecationMessage": "",
"description": "",
- "line": 48,
+ "line": 49,
"name": "buttonRef",
"optional": false,
"type": "ElementRef",
@@ -677,7 +677,7 @@ Private value.",
"deprecated": false,
"deprecationMessage": "",
"description": "",
- "line": 124,
+ "line": 125,
"name": "focus",
"optional": false,
"type": "",
@@ -688,7 +688,7 @@ Private value.",
"deprecationMessage": "",
"description": "Public value.
",
- "line": 143,
+ "line": 144,
"modifierKind": Array [
123,
],
@@ -702,7 +702,7 @@ Public value.",
"deprecated": false,
"deprecationMessage": "",
"description": "",
- "line": 199,
+ "line": 200,
"modifierKind": Array [
123,
],
@@ -937,7 +937,7 @@ export class InputComponent {
Object {
"coverageCount": "16/25",
"coveragePercent": 64,
- "filePath": "addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts",
+ "filePath": "frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts",
"linktype": "component",
"name": "InputComponent",
"status": "good",
@@ -946,7 +946,7 @@ export class InputComponent {
Object {
"coverageCount": "0/4",
"coveragePercent": 0,
- "filePath": "addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts",
+ "filePath": "frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts",
"linktype": "interface",
"name": "ISomeInterface",
"status": "low",
@@ -955,7 +955,7 @@ export class InputComponent {
Object {
"coverageCount": "0/1",
"coveragePercent": 0,
- "filePath": "addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts",
+ "filePath": "frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts",
"linksubtype": "variable",
"linktype": "miscellaneous",
"name": "exportedConstant",
@@ -973,7 +973,7 @@ export class InputComponent {
Object {
"deprecated": false,
"deprecationMessage": "",
- "file": "addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts",
+ "file": "frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts",
"id": "interface-ISomeInterface-d145da25329b094ee29610c45a9e46387cb39eddb2a67b4c9fadb84bcec76eacd60d131e48d98b2ee5725dedd25f2eb299b704e8e0a34307d6e84f6e57d57044",
"indexSignatures": Array [],
"kind": 165,
@@ -984,7 +984,7 @@ export class InputComponent {
"deprecated": false,
"deprecationMessage": "",
"description": "",
- "line": 25,
+ "line": 26,
"name": "one",
"optional": false,
"type": "string",
@@ -993,7 +993,7 @@ export class InputComponent {
"deprecated": false,
"deprecationMessage": "",
"description": "",
- "line": 27,
+ "line": 28,
"name": "three",
"optional": false,
"type": "any[]",
@@ -1002,7 +1002,7 @@ export class InputComponent {
"deprecated": false,
"deprecationMessage": "",
"description": "",
- "line": 26,
+ "line": 27,
"name": "two",
"optional": false,
"type": "boolean",
@@ -1230,14 +1230,14 @@ export class InputComponent {
"deprecated": false,
"deprecationMessage": "",
"description": "",
- "file": "addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts",
+ "file": "frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts",
"name": "ButtonAccent",
"subtype": "enum",
},
],
"functions": Array [],
"groupedEnumerations": Object {
- "addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts": Array [
+ "frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts": Array [
Object {
"childs": Array [
Object {
@@ -1257,7 +1257,7 @@ export class InputComponent {
"deprecated": false,
"deprecationMessage": "",
"description": "",
- "file": "addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts",
+ "file": "frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts",
"name": "ButtonAccent",
"subtype": "enum",
},
@@ -1265,13 +1265,13 @@ export class InputComponent {
},
"groupedFunctions": Object {},
"groupedTypeAliases": Object {
- "addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts": Array [
+ "frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts": Array [
Object {
"ctype": "miscellaneous",
"deprecated": false,
"deprecationMessage": "",
"description": "",
- "file": "addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts",
+ "file": "frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts",
"kind": 186,
"name": "ButtonSize",
"rawtype": "\\"small\\" | \\"medium\\" | \\"large\\" | \\"xlarge\\"",
@@ -1280,13 +1280,13 @@ export class InputComponent {
],
},
"groupedVariables": Object {
- "addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts": Array [
+ "frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts": Array [
Object {
"ctype": "miscellaneous",
"defaultValue": "'An exported constant'",
"deprecated": false,
"deprecationMessage": "",
- "file": "addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts",
+ "file": "frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts",
"name": "exportedConstant",
"subtype": "variable",
"type": "string",
@@ -1299,7 +1299,7 @@ export class InputComponent {
"deprecated": false,
"deprecationMessage": "",
"description": "",
- "file": "addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts",
+ "file": "frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts",
"kind": 186,
"name": "ButtonSize",
"rawtype": "\\"small\\" | \\"medium\\" | \\"large\\" | \\"xlarge\\"",
@@ -1312,7 +1312,7 @@ export class InputComponent {
"defaultValue": "'An exported constant'",
"deprecated": false,
"deprecationMessage": "",
- "file": "addons/docs/src/frameworks/angular/__testfixtures__/doc-button/input.ts",
+ "file": "frameworks/angular/src/client/docs/__testfixtures__/doc-button/input.ts",
"name": "exportedConstant",
"subtype": "variable",
"type": "string",
diff --git a/code/frameworks/angular/src/client/docs/__testfixtures__/doc-button/compodoc-undefined.snapshot b/code/frameworks/angular/src/client/docs/__testfixtures__/doc-button/compodoc-undefined.snapshot
index 012aeb4a1651..de95727d81f5 100644
--- a/code/frameworks/angular/src/client/docs/__testfixtures__/doc-button/compodoc-undefined.snapshot
+++ b/code/frameworks/angular/src/client/docs/__testfixtures__/doc-button/compodoc-undefined.snapshot
@@ -10,7 +10,7 @@ Object {
"getSignature": Object {
"description": "Getter for inputValue
.
",
- "line": 115,
+ "line": 116,
"name": "inputValue",
"rawdescription": "
Getter for \`inputValue\`.",
@@ -42,7 +42,7 @@ Getter for \`inputValue\`.",
"type": "string",
},
],
- "line": 110,
+ "line": 111,
"name": "inputValue",
"rawdescription": "
Setter for \`inputValue\` that is also an \`@Input\`.",
@@ -74,7 +74,7 @@ Setter for \`inputValue\` that is also an \`@Input\`.",
"type": "T[]",
},
],
- "line": 195,
+ "line": 196,
"name": "item",
"returnType": "void",
"type": "void",
@@ -84,7 +84,7 @@ Setter for \`inputValue\` that is also an \`@Input\`.",
"getSignature": Object {
"description": "Get the private value.
",
- "line": 154,
+ "line": 155,
"name": "value",
"rawdescription": "
Get the private value.",
@@ -116,7 +116,7 @@ Get the private value.",
"type": "string | number",
},
],
- "line": 149,
+ "line": 150,
"name": "value",
"rawdescription": "
Set the private value.",
@@ -144,7 +144,7 @@ like bold , italic , and inline code
.
"defaultValue": "false",
"deprecated": false,
"deprecationMessage": "",
- "line": 124,
+ "line": 125,
"name": "class.focused",
"type": "boolean",
},
@@ -164,7 +164,7 @@ like bold , italic , and inline code
.
],
"deprecated": false,
"deprecationMessage": "",
- "line": 120,
+ "line": 121,
"name": "click",
},
],
@@ -177,7 +177,7 @@ like bold , italic , and inline code
.
"deprecationMessage": "",
"description": "Specify the accent-type of the button
",
- "line": 56,
+ "line": 57,
"name": "accent",
"rawdescription": "
Specify the accent-type of the button",
@@ -190,7 +190,7 @@ Specify the accent-type of the button",
"deprecationMessage": "",
"description": "Appearance style of the button.
",
- "line": 52,
+ "line": 53,
"name": "appearance",
"rawdescription": "
Appearance style of the button.",
@@ -202,7 +202,7 @@ Appearance style of the button.",
"deprecationMessage": "",
"description": "Setter for inputValue
that is also an @Input
.
",
- "line": 110,
+ "line": 111,
"name": "inputValue",
"rawdescription": "
Setter for \`inputValue\` that is also an \`@Input\`.",
@@ -215,7 +215,7 @@ Setter for \`inputValue\` that is also an \`@Input\`.",
"deprecationMessage": "",
"description": "Sets the button to a disabled state.
",
- "line": 60,
+ "line": 61,
"name": "isDisabled",
"rawdescription": "
Sets the button to a disabled state.",
@@ -225,7 +225,7 @@ Sets the button to a disabled state.",
"decorators": Array [],
"deprecated": false,
"deprecationMessage": "",
- "line": 195,
+ "line": 196,
"name": "item",
"type": "T[]",
},
@@ -238,24 +238,24 @@ Sets the button to a disabled state.",
"jsdoctags": Array [
Object {
"comment": "",
- "end": 1525,
+ "end": 1587,
"flags": 4227072,
"kind": 325,
"modifierFlagsCache": 0,
- "pos": 1512,
+ "pos": 1574,
"tagName": Object {
- "end": 1521,
+ "end": 1583,
"escapedText": "required",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
- "pos": 1513,
+ "pos": 1575,
"transformFlags": 0,
},
"transformFlags": 0,
},
],
- "line": 68,
+ "line": 69,
"name": "label",
"rawdescription": "
@@ -268,7 +268,7 @@ The inner text of the button.
"decorators": Array [],
"deprecated": false,
"deprecationMessage": "",
- "line": 192,
+ "line": 193,
"name": "showKeyAlias",
"type": "",
},
@@ -279,7 +279,7 @@ The inner text of the button.
"deprecationMessage": "",
"description": "Size of the button.
",
- "line": 72,
+ "line": 73,
"name": "size",
"rawdescription": "
Size of the button.",
@@ -291,7 +291,7 @@ Size of the button.",
"deprecationMessage": "",
"description": "Specifies some arbitrary object
",
- "line": 75,
+ "line": 76,
"name": "someDataObject",
"rawdescription": "
Specifies some arbitrary object",
@@ -307,24 +307,24 @@ Specifies some arbitrary object",
"jsdoctags": Array [
Object {
"comment": "",
- "end": 1802,
+ "end": 1864,
"flags": 4227072,
"kind": 329,
"modifierFlagsCache": 0,
- "pos": 1787,
+ "pos": 1849,
"tagName": Object {
- "end": 1798,
+ "end": 1860,
"escapedText": "deprecated",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
- "pos": 1788,
+ "pos": 1850,
"transformFlags": 0,
},
"transformFlags": 0,
},
],
- "line": 83,
+ "line": 84,
"name": "somethingYouShouldNotUse",
"rawdescription": "
@@ -361,21 +361,21 @@ Some input you shouldn't use.
"deprecated": false,
"deprecationMessage": "",
"name": Object {
- "end": 3518,
+ "end": 3580,
"escapedText": "x",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
- "pos": 3517,
+ "pos": 3579,
"transformFlags": 0,
},
"tagName": Object {
- "end": 3516,
+ "end": 3578,
"escapedText": "param",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
- "pos": 3511,
+ "pos": 3573,
"transformFlags": 0,
},
"type": "number",
@@ -386,27 +386,27 @@ Some input you shouldn't use.
"deprecated": false,
"deprecationMessage": "",
"name": Object {
- "end": 3563,
+ "end": 3625,
"escapedText": "y",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
- "pos": 3562,
+ "pos": 3624,
"transformFlags": 0,
},
"tagName": Object {
- "end": 3561,
+ "end": 3623,
"escapedText": "param",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
- "pos": 3556,
+ "pos": 3618,
"transformFlags": 0,
},
"type": "string | number",
},
],
- "line": 164,
+ "line": 165,
"modifierKind": Array [
123,
],
@@ -448,7 +448,7 @@ An internal calculation method which adds \`x\` and \`y\` together.
"type": "",
},
],
- "line": 120,
+ "line": 121,
"name": "onClickListener",
"optional": false,
"returnType": "void",
@@ -474,27 +474,27 @@ An internal calculation method which adds \`x\` and \`y\` together.
"deprecated": false,
"deprecationMessage": "",
"name": Object {
- "end": 4079,
+ "end": 4141,
"escapedText": "password",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
- "pos": 4071,
+ "pos": 4133,
"transformFlags": 0,
},
"tagName": Object {
- "end": 4070,
+ "end": 4132,
"escapedText": "param",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
- "pos": 4065,
+ "pos": 4127,
"transformFlags": 0,
},
"type": "string",
},
],
- "line": 187,
+ "line": 188,
"modifierKind": Array [
121,
],
@@ -529,28 +529,28 @@ A private method.
"deprecated": false,
"deprecationMessage": "",
"name": Object {
- "end": 3938,
+ "end": 4000,
"escapedText": "id",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
- "pos": 3936,
+ "pos": 3998,
"transformFlags": 0,
},
"optional": true,
"tagName": Object {
- "end": 3935,
+ "end": 3997,
"escapedText": "param",
"flags": 4227072,
"kind": 79,
"modifierFlagsCache": 0,
- "pos": 3930,
+ "pos": 3992,
"transformFlags": 0,
},
"type": "number",
},
],
- "line": 178,
+ "line": 179,
"modifierKind": Array [
122,
],
@@ -588,7 +588,7 @@ A protected method.
"type": "ISomeInterface",
},
],
- "line": 169,
+ "line": 170,
"modifierKind": Array [
123,
],
@@ -610,7 +610,7 @@ A public method using an interface.",
"description": "Handler to be called when the button is clicked by a user.
Will also block the emission of the event if isDisabled
is true.
",
- "line": 91,
+ "line": 92,
"name": "onClick",
"rawdescription": "
@@ -627,7 +627,7 @@ Will also block the emission of the event if \`isDisabled\` is true.
"deprecated": false,
"deprecationMessage": "",
"description": "",
- "line": 106,
+ "line": 107,
"modifierKind": Array [
121,
],
@@ -641,7 +641,7 @@ Will also block the emission of the event if \`isDisabled\` is true.
"deprecationMessage": "",
"description": "Private value.
",
- "line": 146,
+ "line": 147,
"modifierKind": Array [
121,
],
@@ -661,7 +661,7 @@ Private value.",
"deprecated": false,
"deprecationMessage": "",
"description": "",
- "line": 48,
+ "line": 49,
"name": "buttonRef",
"optional": false,
"type": "ElementRef",
@@ -677,7 +677,7 @@ Private value.",
"deprecated": false,
"deprecationMessage": "",
"description": "",
- "line": 124,
+ "line": 125,
"name": "focus",
"optional": false,
"type": "",
@@ -688,7 +688,7 @@ Private value.",
"deprecationMessage": "",
"description": "Public value.
",
- "line": 143,
+ "line": 144,
"modifierKind": Array [
123,
],
@@ -702,7 +702,7 @@ Public value.",
"deprecated": false,
"deprecationMessage": "",
"description": "",
- "line": 199,
+ "line": 200,
"modifierKind": Array [
123,
],
@@ -984,7 +984,7 @@ export class InputComponent {
"deprecated": false,
"deprecationMessage": "",
"description": "",
- "line": 25,
+ "line": 26,
"name": "one",
"optional": false,
"type": "string",
@@ -993,7 +993,7 @@ export class InputComponent {
"deprecated": false,
"deprecationMessage": "",
"description": "",
- "line": 27,
+ "line": 28,
"name": "three",
"optional": false,
"type": "any[]",
@@ -1002,7 +1002,7 @@ export class InputComponent {
"deprecated": false,
"deprecationMessage": "",
"description": "",
- "line": 26,
+ "line": 27,
"name": "two",
"optional": false,
"type": "boolean",
diff --git a/code/frameworks/angular/src/client/docs/sourceDecorator.ts b/code/frameworks/angular/src/client/docs/sourceDecorator.ts
index 605112b11b24..7769aa6968aa 100644
--- a/code/frameworks/angular/src/client/docs/sourceDecorator.ts
+++ b/code/frameworks/angular/src/client/docs/sourceDecorator.ts
@@ -1,7 +1,7 @@
import { addons, useEffect } from '@storybook/addons';
import { PartialStoryFn } from '@storybook/types';
import { SNIPPET_RENDERED, SourceType } from '@storybook/docs-tools';
-import { StoryContext, AngularFramework } from '../types';
+import { StoryContext, AngularRenderer } from '../types';
import { computesTemplateSourceFromComponent } from '../../renderer';
export const skipSourceRender = (context: StoryContext) => {
@@ -22,7 +22,7 @@ export const skipSourceRender = (context: StoryContext) => {
* @param context StoryContext
*/
export const sourceDecorator = (
- storyFn: PartialStoryFn,
+ storyFn: PartialStoryFn,
context: StoryContext
) => {
const story = storyFn();
diff --git a/code/frameworks/angular/src/client/public-api.ts b/code/frameworks/angular/src/client/public-api.ts
index 31c4c273420f..596a5fd1b4a3 100644
--- a/code/frameworks/angular/src/client/public-api.ts
+++ b/code/frameworks/angular/src/client/public-api.ts
@@ -3,20 +3,20 @@ import { Addon_ClientStoryApi, Addon_Loadable } from '@storybook/types';
import { start } from '@storybook/core-client';
import { renderToCanvas, render } from './render';
import decorateStory from './decorateStory';
-import { AngularFramework } from './types';
+import { AngularRenderer } from './types';
export * from './public-types';
const FRAMEWORK = 'angular';
-interface ClientApi extends Addon_ClientStoryApi {
+interface ClientApi extends Addon_ClientStoryApi {
configure(loader: Addon_Loadable, module: NodeModule): void;
forceReRender(): void;
raw: () => any; // todo add type
load: (...args: any[]) => void;
}
-const api = start(renderToCanvas, { decorateStory, render });
+const api = start(renderToCanvas, { decorateStory, render });
export const storiesOf: ClientApi['storiesOf'] = (kind, m) => {
return (api.clientApi.storiesOf(kind, m) as ReturnType).addParameters({
diff --git a/code/frameworks/angular/src/client/public-types.ts b/code/frameworks/angular/src/client/public-types.ts
index da446898d293..c4a54cf25898 100644
--- a/code/frameworks/angular/src/client/public-types.ts
+++ b/code/frameworks/angular/src/client/public-types.ts
@@ -1,28 +1,39 @@
-import { AnnotatedStoryFn, Args, ComponentAnnotations, StoryAnnotations } from '@storybook/types';
-import { AngularFramework } from './types';
+import {
+ AnnotatedStoryFn,
+ Args,
+ ComponentAnnotations,
+ DecoratorFunction,
+ LoaderFunction,
+ StoryAnnotations,
+ StoryContext as GenericStoryContext,
+ StrictArgs,
+} from '@storybook/types';
+import { AngularRenderer } from './types';
-export type { Args, ArgTypes } from '@storybook/types';
+export type { Args, ArgTypes, Parameters, StrictArgs } from '@storybook/types';
+export type { Parameters as AngularParameters } from './types';
+export type { AngularRenderer };
/**
* Metadata to configure the stories for a component.
*
* @see [Default export](https://storybook.js.org/docs/formats/component-story-format/#default-export)
*/
-export type Meta = ComponentAnnotations;
+export type Meta = ComponentAnnotations;
/**
* Story function that represents a CSFv2 component example.
*
* @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
*/
-export type StoryFn = AnnotatedStoryFn;
+export type StoryFn = AnnotatedStoryFn;
/**
* Story function that represents a CSFv3 component example.
*
* @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
*/
-export type StoryObj = StoryAnnotations;
+export type StoryObj = StoryAnnotations;
/**
* @deprecated Use `StoryFn` instead.
@@ -34,3 +45,7 @@ export type StoryObj = StoryAnnotations;
* @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
*/
export type Story = StoryFn;
+
+export type Decorator = DecoratorFunction;
+export type Loader = LoaderFunction;
+export type StoryContext = GenericStoryContext;
diff --git a/code/frameworks/angular/src/client/render.ts b/code/frameworks/angular/src/client/render.ts
index 622fe0ed6e8f..f8d220d93c6f 100644
--- a/code/frameworks/angular/src/client/render.ts
+++ b/code/frameworks/angular/src/client/render.ts
@@ -1,13 +1,13 @@
import { Store_RenderContext, ArgsStoryFn } from '@storybook/types';
import { renderNgApp } from './angular/helpers';
-import { AngularFramework } from './types';
+import { AngularRenderer } from './types';
import { RendererFactory } from './angular-beta/RendererFactory';
export const rendererFactory = new RendererFactory();
-export const render: ArgsStoryFn = (props) => ({ props });
+export const render: ArgsStoryFn = (props) => ({ props });
export async function renderToCanvas(
{
@@ -16,7 +16,7 @@ export async function renderToCanvas(
forceRemount,
storyContext: { parameters, component },
id,
- }: Store_RenderContext,
+ }: Store_RenderContext,
element: HTMLElement
) {
showMain();
diff --git a/code/frameworks/angular/src/client/types.ts b/code/frameworks/angular/src/client/types.ts
index 36ebabc89edd..14f41557d5d5 100644
--- a/code/frameworks/angular/src/client/types.ts
+++ b/code/frameworks/angular/src/client/types.ts
@@ -1,7 +1,7 @@
import {
Parameters as DefaultParameters,
StoryContext as DefaultStoryContext,
- WebFramework,
+ WebRenderer,
} from '@storybook/types';
export interface NgModuleMetadata {
@@ -27,7 +27,11 @@ export interface StoryFnAngularReturnType {
userDefinedTemplate?: boolean;
}
-export interface AngularFramework extends WebFramework {
+/**
+ * @deprecated Use `AngularRenderer` instead.
+ */
+export type AngularFramework = AngularRenderer;
+export interface AngularRenderer extends WebRenderer {
component: any;
storyResult: StoryFnAngularReturnType;
}
@@ -38,4 +42,4 @@ export type Parameters = DefaultParameters & {
bootstrapModuleOptions?: unknown;
};
-export type StoryContext = DefaultStoryContext & { parameters: Parameters };
+export type StoryContext = DefaultStoryContext & { parameters: Parameters };
diff --git a/code/frameworks/angular/src/server/framework-preset-angular-cli.ts b/code/frameworks/angular/src/server/framework-preset-angular-cli.ts
index 6342bb1118a6..fcc4a17aea81 100644
--- a/code/frameworks/angular/src/server/framework-preset-angular-cli.ts
+++ b/code/frameworks/angular/src/server/framework-preset-angular-cli.ts
@@ -1,3 +1,4 @@
+/* eslint-disable @typescript-eslint/no-shadow */
import webpack from 'webpack';
import { logger } from '@storybook/node-logger';
import { BuilderContext, Target, targetFromTargetString } from '@angular-devkit/architect';
diff --git a/code/frameworks/angular/template/cli/Button.stories.ts b/code/frameworks/angular/template/cli/Button.stories.ts
index b7154d6c8714..6bcd3ee47389 100644
--- a/code/frameworks/angular/template/cli/Button.stories.ts
+++ b/code/frameworks/angular/template/cli/Button.stories.ts
@@ -1,20 +1,17 @@
import type { Meta, StoryObj } from '@storybook/angular';
import Button from './button.component';
-// More on how to set up stories at: https://storybook.js.org/docs/angular/writing-stories/introduction#default-export
+// More on how to set up stories at: https://storybook.js.org/docs/7.0/angular/writing-stories/introduction
const meta: Meta = {
title: 'Example/Button',
component: Button,
- // This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/angular/writing-docs/docs-page
tags: ['docsPage'],
- // More on component templates: https://storybook.js.org/docs/angular/writing-stories/introduction#using-args
render: (args: Button) => ({
props: {
backgroundColor: null,
...args,
},
}),
- // More on argTypes: https://storybook.js.org/docs/angular/api/argtypes
argTypes: {
backgroundColor: {
control: 'color',
@@ -25,7 +22,7 @@ const meta: Meta = {
export default meta;
type Story = StoryObj;
-// More on component templates: https://storybook.js.org/docs/angular/writing-stories/introduction#using-args
+// More on writing stories with args: https://storybook.js.org/docs/7.0/angular/writing-stories/args
export const Primary: Story = {
args: {
primary: true,
diff --git a/code/frameworks/angular/template/cli/Header.stories.ts b/code/frameworks/angular/template/cli/Header.stories.ts
index 8b6b954a64de..70852b3205f9 100644
--- a/code/frameworks/angular/template/cli/Header.stories.ts
+++ b/code/frameworks/angular/template/cli/Header.stories.ts
@@ -8,7 +8,7 @@ import Header from './header.component';
const meta: Meta = {
title: 'Example/Header',
component: Header,
- // This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/angular/writing-docs/docs-page
+ // This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/7.0/angular/writing-docs/docs-page
tags: ['docsPage'],
render: (args) => ({ props: args }),
decorators: [
@@ -18,7 +18,7 @@ const meta: Meta = {
}),
],
parameters: {
- // More on Story layout: https://storybook.js.org/docs/angular/configure/story-layout
+ // More on how to position stories at: https://storybook.js.org/docs/7.0/angular/configure/story-layout
layout: 'fullscreen',
},
};
diff --git a/code/frameworks/angular/template/cli/Page.stories.ts b/code/frameworks/angular/template/cli/Page.stories.ts
index dd16b59371ab..4ae8d3bbb0fd 100644
--- a/code/frameworks/angular/template/cli/Page.stories.ts
+++ b/code/frameworks/angular/template/cli/Page.stories.ts
@@ -11,7 +11,7 @@ const meta: Meta = {
title: 'Example/Page',
component: Page,
parameters: {
- // More on StoryFn layout: https://storybook.js.org/docs/angular/configure/story-layout
+ // More on how to position stories at: https://storybook.js.org/docs/7.0/angular/configure/story-layout
layout: 'fullscreen',
},
decorators: [
@@ -31,7 +31,7 @@ export const LoggedOut: Story = {
}),
};
-// More on interaction testing: https://storybook.js.org/docs/angular/writing-tests/interaction-testing
+// More on interaction testing: https://storybook.js.org/docs/7.0/angular/writing-tests/interaction-testing
export const LoggedIn: Story = {
render: (args: Page) => ({
props: args,
diff --git a/code/frameworks/ember/jest.config.js b/code/frameworks/ember/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/frameworks/ember/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/frameworks/ember/package.json b/code/frameworks/ember/package.json
index bb2ae7b4ce45..d22e956e2718 100644
--- a/code/frameworks/ember/package.json
+++ b/code/frameworks/ember/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/ember",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook for Ember: Develop Ember Component in isolation with Hot Reloading.",
"homepage": "https://github.com/storybookjs/storybook/tree/main/frameworks/ember",
"bugs": {
@@ -31,12 +31,12 @@
"prep": "node ../../../scripts/prepare.js"
},
"dependencies": {
- "@storybook/builder-webpack5": "7.0.0-alpha.48",
- "@storybook/core-client": "7.0.0-alpha.48",
- "@storybook/core-common": "7.0.0-alpha.48",
- "@storybook/docs-tools": "7.0.0-alpha.48",
- "@storybook/store": "7.0.0-alpha.48",
- "@storybook/types": "7.0.0-alpha.48",
+ "@storybook/builder-webpack5": "7.0.0-alpha.51",
+ "@storybook/core-client": "7.0.0-alpha.51",
+ "@storybook/core-common": "7.0.0-alpha.51",
+ "@storybook/docs-tools": "7.0.0-alpha.51",
+ "@storybook/store": "7.0.0-alpha.51",
+ "@storybook/types": "7.0.0-alpha.51",
"global": "^4.4.0",
"react": "16.14.0",
"react-dom": "16.14.0",
@@ -45,7 +45,7 @@
},
"devDependencies": {
"ember-source": "~3.28.1",
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"peerDependencies": {
"@babel/core": "*",
@@ -60,5 +60,5 @@
"publishConfig": {
"access": "public"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/frameworks/ember/src/client/preview/index.ts b/code/frameworks/ember/src/client/preview/index.ts
index 13a01a7a0351..96a58ede904b 100644
--- a/code/frameworks/ember/src/client/preview/index.ts
+++ b/code/frameworks/ember/src/client/preview/index.ts
@@ -1,9 +1,10 @@
import { start } from '@storybook/core-client';
import './globals';
+import type { EmberRenderer } from './types';
import { renderToCanvas } from './render';
-const { configure: coreConfigure, clientApi, forceReRender } = start(renderToCanvas);
+const { configure: coreConfigure, clientApi, forceReRender } = start(renderToCanvas);
export const { raw } = clientApi;
diff --git a/code/frameworks/ember/src/client/preview/render.ts b/code/frameworks/ember/src/client/preview/render.ts
index 426eabcc2074..0f951bc1962a 100644
--- a/code/frameworks/ember/src/client/preview/render.ts
+++ b/code/frameworks/ember/src/client/preview/render.ts
@@ -3,7 +3,7 @@ import { dedent } from 'ts-dedent';
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 type { OptionsArgs, EmberFramework } from './types';
+import type { OptionsArgs, EmberRenderer } from './types';
const { window: globalWindow, document } = global;
@@ -20,7 +20,7 @@ let lastPromise = app.boot();
let hasRendered = false;
let isRendering = false;
-function render(options: OptionsArgs, el: EmberFramework['canvasElement']) {
+function render(options: OptionsArgs, el: EmberRenderer['canvasElement']) {
if (isRendering) return;
isRendering = true;
@@ -61,8 +61,8 @@ function render(options: OptionsArgs, el: EmberFramework['canvasElement']) {
}
export function renderToCanvas(
- { storyFn, kind, name, showMain, showError }: Store_RenderContext,
- canvasElement: EmberFramework['canvasElement']
+ { storyFn, kind, name, showMain, showError }: Store_RenderContext,
+ canvasElement: EmberRenderer['canvasElement']
) {
const element = storyFn();
diff --git a/code/frameworks/ember/src/client/preview/types.ts b/code/frameworks/ember/src/client/preview/types.ts
index e360063627ea..5df0b2632aa5 100644
--- a/code/frameworks/ember/src/client/preview/types.ts
+++ b/code/frameworks/ember/src/client/preview/types.ts
@@ -1,4 +1,4 @@
-import type { WebFramework } from '@storybook/types';
+import type { WebRenderer } from '@storybook/types';
export type { RenderContext } from '@storybook/types';
@@ -13,7 +13,11 @@ export interface OptionsArgs {
element: any;
}
-export interface EmberFramework extends WebFramework {
+/**
+ * @deprecated Use `EmberRenderer` instead.
+ */
+export type EmberFramework = EmberRenderer;
+export interface EmberRenderer extends WebRenderer {
component: any;
storyResult: OptionsArgs;
}
diff --git a/code/frameworks/ember/template/cli/1-Button.stories.js b/code/frameworks/ember/template/cli/Button.stories.js
similarity index 78%
rename from code/frameworks/ember/template/cli/1-Button.stories.js
rename to code/frameworks/ember/template/cli/Button.stories.js
index 9aff5c61cb45..92d4eb67f58f 100644
--- a/code/frameworks/ember/template/cli/1-Button.stories.js
+++ b/code/frameworks/ember/template/cli/Button.stories.js
@@ -2,20 +2,19 @@ import { hbs } from 'ember-cli-htmlbars';
import { action } from '@storybook/addon-actions';
import { linkTo } from '@storybook/addon-links';
-// More on default export: https://storybook.js.org/docs/ember/writing-stories/introduction#default-export
+// More on how to set up stories at: https://storybook.js.org/docs/7.0/ember/writing-stories/introduction
export default {
- title: 'Button',
+ title: 'Example/Button',
render: (args) => ({
template: hbs`{{label}} `,
context: args,
}),
- // More on argTypes: https://storybook.js.org/docs/ember/api/argtypes
argTypes: {
label: { control: 'text' },
},
};
-// More on component templates: https://storybook.js.org/docs/ember/writing-stories/introduction#using-args
+// More on writing stories with args: https://storybook.js.org/docs/7.0/ember/writing-stories/args
export const Text = {
args: {
label: 'Button',
diff --git a/code/frameworks/ember/tsconfig.json b/code/frameworks/ember/tsconfig.json
index 5627221de68f..2cf6db4b14d3 100644
--- a/code/frameworks/ember/tsconfig.json
+++ b/code/frameworks/ember/tsconfig.json
@@ -4,6 +4,5 @@
"strict": true,
"resolveJsonModule": true
},
- "include": ["src/**/*", "package.json"],
- "exclude": ["src/**/*.test.*"]
+ "include": ["src/**/*", "package.json"]
}
diff --git a/code/frameworks/html-webpack5/jest.config.js b/code/frameworks/html-webpack5/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/frameworks/html-webpack5/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/frameworks/html-webpack5/package.json b/code/frameworks/html-webpack5/package.json
index 5d2e4bd25c5a..dbb83c5852f1 100644
--- a/code/frameworks/html-webpack5/package.json
+++ b/code/frameworks/html-webpack5/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/html-webpack5",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook for HTML: View HTML snippets in isolation with Hot Reloading.",
"keywords": [
"storybook"
@@ -50,17 +50,17 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/builder-webpack5": "7.0.0-alpha.48",
- "@storybook/core-common": "7.0.0-alpha.48",
- "@storybook/html": "7.0.0-alpha.48",
- "@storybook/preset-html-webpack": "7.0.0-alpha.48",
- "@types/node": "^16.0.0",
+ "@storybook/builder-webpack5": "7.0.0-alpha.51",
+ "@storybook/core-common": "7.0.0-alpha.51",
+ "@storybook/html": "7.0.0-alpha.51",
+ "@storybook/preset-html-webpack": "7.0.0-alpha.51",
+ "@types/node": "^16.0.0 || ^18.0.0",
"global": "^4.4.0",
"react": "16.14.0",
"react-dom": "16.14.0"
},
"devDependencies": {
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"peerDependencies": {
"@babel/core": "*"
@@ -78,5 +78,5 @@
],
"platform": "node"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/frameworks/html-webpack5/tsconfig.json b/code/frameworks/html-webpack5/tsconfig.json
index d9463d503988..a4429176e35f 100644
--- a/code/frameworks/html-webpack5/tsconfig.json
+++ b/code/frameworks/html-webpack5/tsconfig.json
@@ -3,6 +3,5 @@
"compilerOptions": {
"strict": true
},
- "include": ["src/**/*"],
- "exclude": ["src/**/*.test.*", "src/__tests__/**/*"]
+ "include": ["src/**/*"]
}
diff --git a/code/frameworks/nextjs/jest.config.js b/code/frameworks/nextjs/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/frameworks/nextjs/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/frameworks/nextjs/package.json b/code/frameworks/nextjs/package.json
index 80e845870e81..ca855ed8e16f 100644
--- a/code/frameworks/nextjs/package.json
+++ b/code/frameworks/nextjs/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/nextjs",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook for Next.js",
"keywords": [
"storybook",
@@ -59,14 +59,13 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@babel/preset-typescript": "^7.18.6",
- "@storybook/addons": "7.0.0-alpha.48",
- "@storybook/builder-webpack5": "7.0.0-alpha.48",
- "@storybook/core-common": "7.0.0-alpha.48",
- "@storybook/node-logger": "7.0.0-alpha.48",
- "@storybook/preset-react-webpack": "7.0.0-alpha.48",
- "@storybook/react": "7.0.0-alpha.48",
- "@types/node": "^14.14.20 || ^16.0.0",
+ "@storybook/addons": "7.0.0-alpha.51",
+ "@storybook/builder-webpack5": "7.0.0-alpha.51",
+ "@storybook/core-common": "7.0.0-alpha.51",
+ "@storybook/node-logger": "7.0.0-alpha.51",
+ "@storybook/preset-react-webpack": "7.0.0-alpha.51",
+ "@storybook/react": "7.0.0-alpha.51",
+ "@types/node": "^16.0.0 || ^18.0.0",
"find-up": "^5.0.0",
"fs-extra": "^9.0.1",
"image-size": "^1.0.0",
@@ -81,10 +80,9 @@
"tsconfig-paths-webpack-plugin": "^3.5.2"
},
"devDependencies": {
- "@storybook/addon-actions": "7.0.0-alpha.48",
- "@types/loader-utils": "^2.0.3",
+ "@storybook/addon-actions": "7.0.0-alpha.51",
"next": "^12.2.4",
- "typescript": "~4.6.3",
+ "typescript": "^4.9.3",
"webpack": "^5.65.0"
},
"peerDependencies": {
@@ -121,5 +119,5 @@
],
"platform": "node"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/frameworks/nextjs/src/config/babel.ts b/code/frameworks/nextjs/src/config/babel.ts
deleted file mode 100644
index cceba0dc534d..000000000000
--- a/code/frameworks/nextjs/src/config/babel.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import type { TransformOptions } from '@babel/core';
-import { loadConfig } from 'tsconfig-paths';
-
-export const configureTypescript = async (baseConfig: TransformOptions) => {
- const configLoadResult = loadConfig();
-
- // if tsconfig is successfully loaded, this is a typescript project
- if (configLoadResult.resultType === 'success') {
- baseConfig.presets ||= [];
-
- if (!baseConfig.presets.includes('@babel/preset-typescript')) {
- baseConfig.presets.push('@babel/preset-typescript');
- }
- }
-};
diff --git a/code/frameworks/nextjs/src/config/webpack.ts b/code/frameworks/nextjs/src/config/webpack.ts
index 2bd4ba751691..924b9311795c 100644
--- a/code/frameworks/nextjs/src/config/webpack.ts
+++ b/code/frameworks/nextjs/src/config/webpack.ts
@@ -5,6 +5,7 @@ import { pathExists } from 'fs-extra';
import type { NextConfig } from 'next';
import dedent from 'ts-dedent';
import { DefinePlugin } from 'webpack';
+import { pathToFileURL } from 'node:url';
import { addScopedAlias } from '../utils';
export const configureConfig = async ({
@@ -60,7 +61,7 @@ const resolveNextConfig = async ({
);
}
- const nextConfigExport = await import(nextConfigFile);
+ const nextConfigExport = await import(pathToFileURL(nextConfigFile).href);
const nextConfig =
typeof nextConfigExport === 'function'
diff --git a/code/frameworks/nextjs/src/next-image-loader-stub.ts b/code/frameworks/nextjs/src/next-image-loader-stub.ts
index bf913e5e85cc..b506cba14e27 100644
--- a/code/frameworks/nextjs/src/next-image-loader-stub.ts
+++ b/code/frameworks/nextjs/src/next-image-loader-stub.ts
@@ -1,3 +1,4 @@
+// @ts-expect-error (loader-utils has no webpack5 compatible types)
import { interpolateName } from 'loader-utils';
import imageSizeOf from 'image-size';
import type { RawLoaderDefinition } from 'webpack';
@@ -15,7 +16,7 @@ const nextImageLoaderStub: RawLoaderDefinition = function (conten
this.emitFile(outputPath, content);
- const { width, height } = imageSizeOf(content);
+ const { width, height } = imageSizeOf(this.resourcePath);
return `export default ${JSON.stringify({
src: outputPath,
@@ -27,4 +28,4 @@ const nextImageLoaderStub: RawLoaderDefinition = function (conten
nextImageLoaderStub.raw = true;
-export = nextImageLoaderStub;
+export default nextImageLoaderStub;
diff --git a/code/frameworks/nextjs/src/preset.ts b/code/frameworks/nextjs/src/preset.ts
index 2833d9c5752f..5a688210c58f 100644
--- a/code/frameworks/nextjs/src/preset.ts
+++ b/code/frameworks/nextjs/src/preset.ts
@@ -1,17 +1,17 @@
// https://storybook.js.org/docs/react/addons/writing-presets
import { dirname, join } from 'path';
import type { Options, PresetProperty } from '@storybook/types';
-import type { TransformOptions } from '@babel/core';
+import type { ConfigItem, TransformOptions } from '@babel/core';
+import { loadPartialConfig } from '@babel/core';
+import { getProjectRoot } from '@storybook/core-common';
import { configureConfig } from './config/webpack';
import { configureCss } from './css/webpack';
import { configureImports } from './imports/webpack';
import { configureRouting } from './routing/webpack';
import { configureStyledJsx } from './styledJsx/webpack';
-import { configureStyledJsxTransforms } from './styledJsx/babel';
import { configureImages } from './images/webpack';
import { configureRuntimeNextjsVersionResolution } from './utils';
import type { FrameworkOptions, StorybookConfig } from './types';
-import { configureTypescript } from './config/babel';
export const addons: PresetProperty<'addons', StorybookConfig> = [
dirname(require.resolve(join('@storybook/preset-react-webpack', 'package.json'))),
@@ -72,10 +72,42 @@ export const config: StorybookConfig['previewAnnotations'] = (entry = []) => [
// You're using a version of Nextjs prior to v10, which is unsupported by this framework.
export const babel = async (baseConfig: TransformOptions): Promise => {
- configureTypescript(baseConfig);
- configureStyledJsxTransforms(baseConfig);
+ const configPartial = loadPartialConfig({
+ ...baseConfig,
+ filename: `${getProjectRoot()}/__fake__.js`,
+ });
- return baseConfig;
+ const options = configPartial?.options;
+
+ const isPresetConfigItem = (preset: any): preset is ConfigItem => {
+ return typeof preset === 'object' && preset !== null && 'file' in preset;
+ };
+
+ const hasNextBabelConfig = options?.presets?.find(
+ (preset) =>
+ (Array.isArray(preset) && preset[0] === 'next/babel') ||
+ preset === 'next/babel' ||
+ (isPresetConfigItem(preset) && preset.file?.request === 'next/babel')
+ );
+
+ if (!hasNextBabelConfig) {
+ options?.presets?.push('next/babel');
+ }
+
+ const presets = options?.presets?.filter(
+ (preset) =>
+ !(
+ isPresetConfigItem(preset) &&
+ (preset as ConfigItem).file?.request === require.resolve('@babel/preset-react')
+ )
+ );
+
+ return {
+ ...options,
+ presets,
+ babelrc: false,
+ configFile: false,
+ };
};
export const webpackFinal: StorybookConfig['webpackFinal'] = async (baseConfig, options) => {
diff --git a/code/frameworks/nextjs/src/styledJsx/babel.ts b/code/frameworks/nextjs/src/styledJsx/babel.ts
deleted file mode 100644
index fe90611129d5..000000000000
--- a/code/frameworks/nextjs/src/styledJsx/babel.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import type { TransformOptions } from '@babel/core';
-
-export const configureStyledJsxTransforms = async (baseConfig: TransformOptions) => {
- baseConfig.plugins ||= [];
-
- if (!baseConfig.plugins.includes('styled-jsx/babel')) {
- baseConfig.plugins.push('styled-jsx/babel');
- }
-};
diff --git a/code/frameworks/nextjs/template/cli/js/Button.stories.js b/code/frameworks/nextjs/template/cli/js/Button.stories.js
new file mode 100644
index 000000000000..d9d3e1b70574
--- /dev/null
+++ b/code/frameworks/nextjs/template/cli/js/Button.stories.js
@@ -0,0 +1,41 @@
+import { Button } from './Button';
+
+// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction
+export default {
+ title: 'Example/Button',
+ component: Button,
+ tags: ['docsPage'],
+ argTypes: {
+ backgroundColor: {
+ control: 'color',
+ },
+ },
+};
+
+// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args
+export const Primary = {
+ args: {
+ primary: true,
+ label: 'Button',
+ },
+};
+
+export const Secondary = {
+ args: {
+ label: 'Button',
+ },
+};
+
+export const Large = {
+ args: {
+ size: 'large',
+ label: 'Button',
+ },
+};
+
+export const Small = {
+ args: {
+ size: 'small',
+ label: 'Button',
+ },
+};
diff --git a/code/frameworks/nextjs/template/cli/js/Button.stories.jsx b/code/frameworks/nextjs/template/cli/js/Button.stories.jsx
deleted file mode 100644
index bfabf81396b9..000000000000
--- a/code/frameworks/nextjs/template/cli/js/Button.stories.jsx
+++ /dev/null
@@ -1,42 +0,0 @@
-import React from 'react';
-
-import { Button } from './Button';
-
-// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
-export default {
- title: 'Example/Button',
- component: Button,
- // This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/react/writing-docs/docs-page
- tags: ['docsPage'],
- // More on argTypes: https://storybook.js.org/docs/react/api/argtypes
- argTypes: {
- backgroundColor: { control: 'color' },
- },
-};
-
-// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
-const Template = (args) => ;
-
-export const Primary = Template.bind({});
-// More on args: https://storybook.js.org/docs/react/writing-stories/args
-Primary.args = {
- primary: true,
- label: 'Button',
-};
-
-export const Secondary = Template.bind({});
-Secondary.args = {
- label: 'Button',
-};
-
-export const Large = Template.bind({});
-Large.args = {
- size: 'large',
- label: 'Button',
-};
-
-export const Small = Template.bind({});
-Small.args = {
- size: 'small',
- label: 'Button',
-};
diff --git a/code/frameworks/nextjs/template/cli/js/Header.stories.js b/code/frameworks/nextjs/template/cli/js/Header.stories.js
new file mode 100644
index 000000000000..a931a5e8b9f7
--- /dev/null
+++ b/code/frameworks/nextjs/template/cli/js/Header.stories.js
@@ -0,0 +1,23 @@
+import { Header } from './Header';
+
+export default {
+ title: 'Example/Header',
+ component: Header,
+ // This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/7.0/react/writing-docs/docs-page
+ tags: ['docsPage'],
+ parameters: {
+ // More on how to position stories at: https://storybook.js.org/docs/7.0/react/configure/story-layout
+ layout: 'fullscreen',
+ },
+};
+export const LoggedIn = {
+ args: {
+ user: {
+ name: 'Jane Doe',
+ },
+ },
+};
+
+export const LoggedOut = {
+ args: {},
+};
diff --git a/code/frameworks/nextjs/template/cli/js/Header.stories.jsx b/code/frameworks/nextjs/template/cli/js/Header.stories.jsx
deleted file mode 100644
index 824597f35ee8..000000000000
--- a/code/frameworks/nextjs/template/cli/js/Header.stories.jsx
+++ /dev/null
@@ -1,26 +0,0 @@
-import React from 'react';
-
-import { Header } from './Header';
-
-export default {
- title: 'Example/Header',
- component: Header,
- // This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/react/writing-docs/docs-page
- tags: ['docsPage'],
- parameters: {
- // More on Story layout: https://storybook.js.org/docs/react/configure/story-layout
- layout: 'fullscreen',
- },
-};
-
-const Template = (args) => ;
-
-export const LoggedIn = Template.bind({});
-LoggedIn.args = {
- user: {
- name: 'Jane Doe',
- },
-};
-
-export const LoggedOut = Template.bind({});
-LoggedOut.args = {};
diff --git a/code/frameworks/nextjs/template/cli/js/Page.stories.js b/code/frameworks/nextjs/template/cli/js/Page.stories.js
new file mode 100644
index 000000000000..40b25af0a1e6
--- /dev/null
+++ b/code/frameworks/nextjs/template/cli/js/Page.stories.js
@@ -0,0 +1,24 @@
+import { within, userEvent } from '@storybook/testing-library';
+import { Page } from './Page';
+
+export default {
+ title: 'Example/Page',
+ component: Page,
+ parameters: {
+ // More on how to position stories at: https://storybook.js.org/docs/7.0/react/configure/story-layout
+ layout: 'fullscreen',
+ },
+};
+
+export const LoggedOut = {};
+
+// More on interaction testing: https://storybook.js.org/docs/7.0/react/writing-tests/interaction-testing
+export const LoggedIn = {
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const loginButton = await canvas.getByRole('button', {
+ name: /Log in/i,
+ });
+ await userEvent.click(loginButton);
+ },
+};
diff --git a/code/frameworks/nextjs/template/cli/js/Page.stories.jsx b/code/frameworks/nextjs/template/cli/js/Page.stories.jsx
deleted file mode 100644
index 0174fdb881f9..000000000000
--- a/code/frameworks/nextjs/template/cli/js/Page.stories.jsx
+++ /dev/null
@@ -1,25 +0,0 @@
-import React from 'react';
-import { within, userEvent } from '@storybook/testing-library';
-
-import { Page } from './Page';
-
-export default {
- title: 'Example/Page',
- component: Page,
- parameters: {
- // More on Story layout: https://storybook.js.org/docs/react/configure/story-layout
- layout: 'fullscreen',
- },
-};
-
-const Template = (args) => ;
-
-// More on interaction testing: https://storybook.js.org/docs/react/writing-tests/interaction-testing
-export const LoggedOut = Template.bind({});
-
-export const LoggedIn = Template.bind({});
-LoggedIn.play = async ({ canvasElement }) => {
- const canvas = within(canvasElement);
- const loginButton = await canvas.getByRole('button', { name: /Log in/i });
- await userEvent.click(loginButton);
-};
diff --git a/code/frameworks/nextjs/template/cli/ts/Button.stories.ts b/code/frameworks/nextjs/template/cli/ts/Button.stories.ts
index c220928db6d6..000d644a4299 100644
--- a/code/frameworks/nextjs/template/cli/ts/Button.stories.ts
+++ b/code/frameworks/nextjs/template/cli/ts/Button.stories.ts
@@ -2,13 +2,11 @@ import type { Meta, StoryObj } from '@storybook/react';
import { Button } from './Button';
-// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
+// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction
const meta: Meta = {
title: 'Example/Button',
component: Button,
- // This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/react/writing-docs/docs-page
tags: ['docsPage'],
- // More on argTypes: https://storybook.js.org/docs/react/api/argtypes
argTypes: {
backgroundColor: {
control: 'color',
@@ -19,7 +17,7 @@ const meta: Meta = {
export default meta;
type Story = StoryObj;
-// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
+// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args
export const Primary: Story = {
args: {
primary: true,
diff --git a/code/frameworks/nextjs/template/cli/ts/Header.stories.ts b/code/frameworks/nextjs/template/cli/ts/Header.stories.ts
index 728b2043ce14..18a379082fbe 100644
--- a/code/frameworks/nextjs/template/cli/ts/Header.stories.ts
+++ b/code/frameworks/nextjs/template/cli/ts/Header.stories.ts
@@ -4,10 +4,10 @@ import { Header } from './Header';
const meta: Meta = {
title: 'Example/Header',
component: Header,
- // This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/react/writing-docs/docs-page
+ // This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/7.0/react/writing-docs/docs-page
tags: ['docsPage'],
parameters: {
- // More on Story layout: https://storybook.js.org/docs/react/configure/story-layout
+ // More on how to position stories at: https://storybook.js.org/docs/7.0/react/configure/story-layout
layout: 'fullscreen',
},
};
diff --git a/code/frameworks/nextjs/template/cli/ts/Page.stories.ts b/code/frameworks/nextjs/template/cli/ts/Page.stories.ts
index 52c4cb406233..357a46f74d91 100644
--- a/code/frameworks/nextjs/template/cli/ts/Page.stories.ts
+++ b/code/frameworks/nextjs/template/cli/ts/Page.stories.ts
@@ -7,7 +7,7 @@ const meta: Meta = {
title: 'Example/Page',
component: Page,
parameters: {
- // More on Story layout: https://storybook.js.org/docs/react/configure/story-layout
+ // More on how to position stories at: https://storybook.js.org/docs/7.0/react/configure/story-layout
layout: 'fullscreen',
},
};
@@ -17,7 +17,7 @@ type Story = StoryObj;
export const LoggedOut: Story = {};
-// More on interaction testing: https://storybook.js.org/docs/react/writing-tests/interaction-testing
+// More on interaction testing: https://storybook.js.org/docs/7.0/react/writing-tests/interaction-testing
export const LoggedIn: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
diff --git a/code/frameworks/nextjs/tsconfig.json b/code/frameworks/nextjs/tsconfig.json
index 4461940be450..26be65113f88 100644
--- a/code/frameworks/nextjs/tsconfig.json
+++ b/code/frameworks/nextjs/tsconfig.json
@@ -5,6 +5,5 @@
"resolveJsonModule": true,
"skipLibCheck": true
},
- "include": ["src/**/*", "template/**/*"],
- "exclude": ["src/**/*.test.*", "src/**/__testfixtures__/**"]
+ "include": ["src/**/*", "template/**/*"]
}
diff --git a/code/frameworks/preact-webpack5/jest.config.js b/code/frameworks/preact-webpack5/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/frameworks/preact-webpack5/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/frameworks/preact-webpack5/package.json b/code/frameworks/preact-webpack5/package.json
index 899d9d86feff..043508c0cde6 100644
--- a/code/frameworks/preact-webpack5/package.json
+++ b/code/frameworks/preact-webpack5/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/preact-webpack5",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook for Preact: Develop Preact Component in isolation.",
"keywords": [
"storybook"
@@ -50,17 +50,17 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/builder-webpack5": "7.0.0-alpha.48",
- "@storybook/core-common": "7.0.0-alpha.48",
- "@storybook/preact": "7.0.0-alpha.48",
- "@storybook/preset-preact-webpack": "7.0.0-alpha.48",
- "@types/node": "^16.0.0",
+ "@storybook/builder-webpack5": "7.0.0-alpha.51",
+ "@storybook/core-common": "7.0.0-alpha.51",
+ "@storybook/preact": "7.0.0-alpha.51",
+ "@storybook/preset-preact-webpack": "7.0.0-alpha.51",
+ "@types/node": "^16.0.0 || ^18.0.0",
"react": "16.14.0",
"react-dom": "16.14.0"
},
"devDependencies": {
"preact": "^10.5.13",
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"peerDependencies": {
"@babel/core": "*",
@@ -79,5 +79,5 @@
],
"platform": "node"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/frameworks/preact-webpack5/tsconfig.json b/code/frameworks/preact-webpack5/tsconfig.json
index 88fbabf6e314..77832da6336d 100644
--- a/code/frameworks/preact-webpack5/tsconfig.json
+++ b/code/frameworks/preact-webpack5/tsconfig.json
@@ -4,6 +4,5 @@
"strict": true,
"resolveJsonModule": true
},
- "include": ["src/**/*"],
- "exclude": ["src/**/*.test.*"]
+ "include": ["src/**/*"]
}
diff --git a/code/frameworks/react-vite/jest.config.js b/code/frameworks/react-vite/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/frameworks/react-vite/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/frameworks/react-vite/package.json b/code/frameworks/react-vite/package.json
index 2955ecc3bdb2..d4d2651b9b1a 100644
--- a/code/frameworks/react-vite/package.json
+++ b/code/frameworks/react-vite/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/react-vite",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook for React and Vite: Develop React components in isolation with Hot Reloading.",
"keywords": [
"storybook"
@@ -53,13 +53,13 @@
"dependencies": {
"@joshwooding/vite-plugin-react-docgen-typescript": "^0.0.5",
"@rollup/pluginutils": "^4.2.0",
- "@storybook/addons": "7.0.0-alpha.48",
- "@storybook/builder-vite": "7.0.0-alpha.48",
- "@storybook/channel-postmessage": "7.0.0-alpha.48",
- "@storybook/channel-websocket": "7.0.0-alpha.48",
- "@storybook/client-api": "7.0.0-alpha.48",
- "@storybook/preview-web": "7.0.0-alpha.48",
- "@storybook/react": "7.0.0-alpha.48",
+ "@storybook/addons": "7.0.0-alpha.51",
+ "@storybook/builder-vite": "7.0.0-alpha.51",
+ "@storybook/channel-postmessage": "7.0.0-alpha.51",
+ "@storybook/channel-websocket": "7.0.0-alpha.51",
+ "@storybook/client-api": "7.0.0-alpha.51",
+ "@storybook/preview-web": "7.0.0-alpha.51",
+ "@storybook/react": "7.0.0-alpha.51",
"@vitejs/plugin-react": "^2.0.0",
"ast-types": "^0.14.2",
"magic-string": "^0.26.1",
@@ -67,8 +67,8 @@
"vite": "^3.1.3"
},
"devDependencies": {
- "@types/node": "^16.0.0",
- "typescript": "~4.6.3",
+ "@types/node": "^16.0.0 || ^18.0.0",
+ "typescript": "^4.9.3",
"vite": "^3.1.3"
},
"peerDependencies": {
@@ -88,5 +88,5 @@
],
"platform": "node"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/frameworks/react-vite/src/index.ts b/code/frameworks/react-vite/src/index.ts
index 8fbdfff5e6e2..067a9d564f75 100644
--- a/code/frameworks/react-vite/src/index.ts
+++ b/code/frameworks/react-vite/src/index.ts
@@ -1,8 +1,13 @@
// exports for builder-vite
+import * as clientApi from '@storybook/client-api';
+
+// client-api exposes both a class, and individual named exports.
+// The class is used in StoryStoreV7 and the individual exports in SSv6
+const { ClientApi } = clientApi;
export { createChannel as createPostMessageChannel } from '@storybook/channel-postmessage';
export { createChannel as createWebSocketChannel } from '@storybook/channel-websocket';
export { addons } from '@storybook/addons';
export { composeConfigs, PreviewWeb } from '@storybook/preview-web';
-export { ClientApi } from '@storybook/client-api';
+export { clientApi, ClientApi };
export type { StorybookConfig } from '@storybook/builder-vite';
diff --git a/code/frameworks/react-vite/tsconfig.json b/code/frameworks/react-vite/tsconfig.json
index 534e4ddd108a..13e04352a3c7 100644
--- a/code/frameworks/react-vite/tsconfig.json
+++ b/code/frameworks/react-vite/tsconfig.json
@@ -5,6 +5,5 @@
"types": ["node"],
"resolveJsonModule": true
},
- "include": ["src/**/*"],
- "exclude": ["src/**/*.test.*", "src/**/__testfixtures__/**"]
+ "include": ["src/**/*"]
}
diff --git a/code/frameworks/react-webpack5/jest.config.js b/code/frameworks/react-webpack5/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/frameworks/react-webpack5/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/frameworks/react-webpack5/package.json b/code/frameworks/react-webpack5/package.json
index fbb4e80d02f7..6e389bf4093c 100644
--- a/code/frameworks/react-webpack5/package.json
+++ b/code/frameworks/react-webpack5/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/react-webpack5",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook for React: Develop React Component in isolation with Hot Reloading.",
"keywords": [
"storybook"
@@ -51,14 +51,14 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/builder-webpack5": "7.0.0-alpha.48",
- "@storybook/preset-react-webpack": "7.0.0-alpha.48",
- "@storybook/react": "7.0.0-alpha.48",
- "@types/node": "^16.0.0"
+ "@storybook/builder-webpack5": "7.0.0-alpha.51",
+ "@storybook/preset-react-webpack": "7.0.0-alpha.51",
+ "@storybook/react": "7.0.0-alpha.51",
+ "@types/node": "^16.0.0 || ^18.0.0"
},
"devDependencies": {
- "jest-specific-snapshot": "^4.0.0",
- "typescript": "~4.6.3"
+ "jest-specific-snapshot": "^6.0.0",
+ "typescript": "^4.9.3"
},
"peerDependencies": {
"@babel/core": "^7.11.5",
@@ -86,5 +86,5 @@
],
"platform": "node"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/frameworks/react-webpack5/tsconfig.json b/code/frameworks/react-webpack5/tsconfig.json
index 5505b0889f9e..77832da6336d 100644
--- a/code/frameworks/react-webpack5/tsconfig.json
+++ b/code/frameworks/react-webpack5/tsconfig.json
@@ -4,6 +4,5 @@
"strict": true,
"resolveJsonModule": true
},
- "include": ["src/**/*"],
- "exclude": ["src/**/*.test.*", "src/**/__testfixtures__/**"]
+ "include": ["src/**/*"]
}
diff --git a/code/frameworks/server-webpack5/jest.config.js b/code/frameworks/server-webpack5/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/frameworks/server-webpack5/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/frameworks/server-webpack5/package.json b/code/frameworks/server-webpack5/package.json
index 213ed072a345..f22559f93df0 100644
--- a/code/frameworks/server-webpack5/package.json
+++ b/code/frameworks/server-webpack5/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/server-webpack5",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook for Server: View HTML snippets from a server in isolation with Hot Reloading.",
"keywords": [
"storybook"
@@ -50,16 +50,16 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/builder-webpack5": "7.0.0-alpha.48",
- "@storybook/core-common": "7.0.0-alpha.48",
- "@storybook/preset-server-webpack": "7.0.0-alpha.48",
- "@storybook/server": "7.0.0-alpha.48",
- "@types/node": "^16.0.0",
+ "@storybook/builder-webpack5": "7.0.0-alpha.51",
+ "@storybook/core-common": "7.0.0-alpha.51",
+ "@storybook/preset-server-webpack": "7.0.0-alpha.51",
+ "@storybook/server": "7.0.0-alpha.51",
+ "@types/node": "^16.0.0 || ^18.0.0",
"react": "16.14.0",
"react-dom": "16.14.0"
},
"devDependencies": {
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"engines": {
"node": ">=10.13.0"
@@ -74,5 +74,5 @@
],
"platform": "node"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/frameworks/server-webpack5/tsconfig.json b/code/frameworks/server-webpack5/tsconfig.json
index 640955dd9694..a4429176e35f 100644
--- a/code/frameworks/server-webpack5/tsconfig.json
+++ b/code/frameworks/server-webpack5/tsconfig.json
@@ -3,6 +3,5 @@
"compilerOptions": {
"strict": true
},
- "include": ["src/**/*"],
- "exclude": ["src/__tests__/**/*"]
+ "include": ["src/**/*"]
}
diff --git a/code/frameworks/svelte-vite/jest.config.js b/code/frameworks/svelte-vite/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/frameworks/svelte-vite/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/frameworks/svelte-vite/package.json b/code/frameworks/svelte-vite/package.json
index 1f49c052ce30..8619b5787c21 100644
--- a/code/frameworks/svelte-vite/package.json
+++ b/code/frameworks/svelte-vite/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/svelte-vite",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook for Svelte and Vite: Develop Svelte components in isolation with Hot Reloading.",
"keywords": [
"storybook"
@@ -52,14 +52,14 @@
},
"dependencies": {
"@storybook/addon-svelte-csf": "^2.0.0",
- "@storybook/addons": "7.0.0-alpha.48",
- "@storybook/builder-vite": "7.0.0-alpha.48",
- "@storybook/channel-postmessage": "7.0.0-alpha.48",
- "@storybook/channel-websocket": "7.0.0-alpha.48",
- "@storybook/client-api": "7.0.0-alpha.48",
- "@storybook/node-logger": "7.0.0-alpha.48",
- "@storybook/preview-web": "7.0.0-alpha.48",
- "@storybook/svelte": "7.0.0-alpha.48",
+ "@storybook/addons": "7.0.0-alpha.51",
+ "@storybook/builder-vite": "7.0.0-alpha.51",
+ "@storybook/channel-postmessage": "7.0.0-alpha.51",
+ "@storybook/channel-websocket": "7.0.0-alpha.51",
+ "@storybook/client-api": "7.0.0-alpha.51",
+ "@storybook/node-logger": "7.0.0-alpha.51",
+ "@storybook/preview-web": "7.0.0-alpha.51",
+ "@storybook/svelte": "7.0.0-alpha.51",
"@sveltejs/vite-plugin-svelte": "^1.0.0",
"magic-string": "^0.26.1",
"svelte": "^3.0.0",
@@ -67,8 +67,8 @@
"vite": "^3.1.3"
},
"devDependencies": {
- "@types/node": "^16.0.0",
- "typescript": "~4.6.3",
+ "@types/node": "^16.0.0 || ^18.0.0",
+ "typescript": "^4.9.3",
"vite": "^3.1.3"
},
"peerDependencies": {
@@ -92,5 +92,5 @@
],
"platform": "node"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/frameworks/svelte-vite/src/index.ts b/code/frameworks/svelte-vite/src/index.ts
index 8fbdfff5e6e2..067a9d564f75 100644
--- a/code/frameworks/svelte-vite/src/index.ts
+++ b/code/frameworks/svelte-vite/src/index.ts
@@ -1,8 +1,13 @@
// exports for builder-vite
+import * as clientApi from '@storybook/client-api';
+
+// client-api exposes both a class, and individual named exports.
+// The class is used in StoryStoreV7 and the individual exports in SSv6
+const { ClientApi } = clientApi;
export { createChannel as createPostMessageChannel } from '@storybook/channel-postmessage';
export { createChannel as createWebSocketChannel } from '@storybook/channel-websocket';
export { addons } from '@storybook/addons';
export { composeConfigs, PreviewWeb } from '@storybook/preview-web';
-export { ClientApi } from '@storybook/client-api';
+export { clientApi, ClientApi };
export type { StorybookConfig } from '@storybook/builder-vite';
diff --git a/code/frameworks/svelte-vite/tsconfig.json b/code/frameworks/svelte-vite/tsconfig.json
index 534e4ddd108a..13e04352a3c7 100644
--- a/code/frameworks/svelte-vite/tsconfig.json
+++ b/code/frameworks/svelte-vite/tsconfig.json
@@ -5,6 +5,5 @@
"types": ["node"],
"resolveJsonModule": true
},
- "include": ["src/**/*"],
- "exclude": ["src/**/*.test.*", "src/**/__testfixtures__/**"]
+ "include": ["src/**/*"]
}
diff --git a/code/frameworks/svelte-webpack5/jest.config.js b/code/frameworks/svelte-webpack5/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/frameworks/svelte-webpack5/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/frameworks/svelte-webpack5/package.json b/code/frameworks/svelte-webpack5/package.json
index 88ef0e088f94..f162ed24e6d6 100644
--- a/code/frameworks/svelte-webpack5/package.json
+++ b/code/frameworks/svelte-webpack5/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/svelte-webpack5",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook for Svelte: Develop Svelte Component in isolation with Hot Reloading.",
"keywords": [
"storybook"
@@ -51,17 +51,17 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/builder-webpack5": "7.0.0-alpha.48",
- "@storybook/core-common": "7.0.0-alpha.48",
- "@storybook/preset-svelte-webpack": "7.0.0-alpha.48",
- "@storybook/svelte": "7.0.0-alpha.48",
+ "@storybook/builder-webpack5": "7.0.0-alpha.51",
+ "@storybook/core-common": "7.0.0-alpha.51",
+ "@storybook/preset-svelte-webpack": "7.0.0-alpha.51",
+ "@storybook/svelte": "7.0.0-alpha.51",
"react": "16.14.0",
"react-dom": "16.14.0"
},
"devDependencies": {
"svelte": "^3.48.0",
"svelte-loader": "^3.1.2",
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"peerDependencies": {
"@babel/core": "*",
@@ -81,5 +81,5 @@
],
"platform": "node"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/frameworks/svelte-webpack5/tsconfig.json b/code/frameworks/svelte-webpack5/tsconfig.json
index 88fbabf6e314..77832da6336d 100644
--- a/code/frameworks/svelte-webpack5/tsconfig.json
+++ b/code/frameworks/svelte-webpack5/tsconfig.json
@@ -4,6 +4,5 @@
"strict": true,
"resolveJsonModule": true
},
- "include": ["src/**/*"],
- "exclude": ["src/**/*.test.*"]
+ "include": ["src/**/*"]
}
diff --git a/code/frameworks/vue-vite/jest.config.js b/code/frameworks/vue-vite/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/frameworks/vue-vite/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/frameworks/vue-vite/package.json b/code/frameworks/vue-vite/package.json
index e879f908697b..652eb4a47b0a 100644
--- a/code/frameworks/vue-vite/package.json
+++ b/code/frameworks/vue-vite/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/vue-vite",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook for Vue2 and Vite: Develop Vue2 Components in isolation with Hot Reloading.",
"keywords": [
"storybook"
@@ -50,21 +50,21 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/addons": "7.0.0-alpha.48",
- "@storybook/builder-vite": "7.0.0-alpha.48",
- "@storybook/channel-postmessage": "7.0.0-alpha.48",
- "@storybook/channel-websocket": "7.0.0-alpha.48",
- "@storybook/client-api": "7.0.0-alpha.48",
- "@storybook/core-common": "7.0.0-alpha.48",
- "@storybook/core-server": "7.0.0-alpha.48",
- "@storybook/preview-web": "7.0.0-alpha.48",
- "@storybook/vue": "7.0.0-alpha.48",
+ "@storybook/addons": "7.0.0-alpha.51",
+ "@storybook/builder-vite": "7.0.0-alpha.51",
+ "@storybook/channel-postmessage": "7.0.0-alpha.51",
+ "@storybook/channel-websocket": "7.0.0-alpha.51",
+ "@storybook/client-api": "7.0.0-alpha.51",
+ "@storybook/core-common": "7.0.0-alpha.51",
+ "@storybook/core-server": "7.0.0-alpha.51",
+ "@storybook/preview-web": "7.0.0-alpha.51",
+ "@storybook/vue": "7.0.0-alpha.51",
"magic-string": "^0.26.1",
"vite": "^3.1.3",
"vue-docgen-api": "^4.40.0"
},
"devDependencies": {
- "typescript": "~4.6.3",
+ "typescript": "^4.9.3",
"vue": "^2.7.10"
},
"peerDependencies": {
@@ -83,5 +83,5 @@
],
"platform": "node"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/frameworks/vue-vite/src/index.ts b/code/frameworks/vue-vite/src/index.ts
index 8fbdfff5e6e2..067a9d564f75 100644
--- a/code/frameworks/vue-vite/src/index.ts
+++ b/code/frameworks/vue-vite/src/index.ts
@@ -1,8 +1,13 @@
// exports for builder-vite
+import * as clientApi from '@storybook/client-api';
+
+// client-api exposes both a class, and individual named exports.
+// The class is used in StoryStoreV7 and the individual exports in SSv6
+const { ClientApi } = clientApi;
export { createChannel as createPostMessageChannel } from '@storybook/channel-postmessage';
export { createChannel as createWebSocketChannel } from '@storybook/channel-websocket';
export { addons } from '@storybook/addons';
export { composeConfigs, PreviewWeb } from '@storybook/preview-web';
-export { ClientApi } from '@storybook/client-api';
+export { clientApi, ClientApi };
export type { StorybookConfig } from '@storybook/builder-vite';
diff --git a/code/frameworks/vue-vite/tsconfig.json b/code/frameworks/vue-vite/tsconfig.json
index 1f9bdf2596c3..1405a8fbb5a6 100644
--- a/code/frameworks/vue-vite/tsconfig.json
+++ b/code/frameworks/vue-vite/tsconfig.json
@@ -5,6 +5,5 @@
"skipLibCheck": true,
"resolveJsonModule": true
},
- "include": ["src/**/*"],
- "exclude": ["src/**/*.test.*"]
+ "include": ["src/**/*"]
}
diff --git a/code/frameworks/vue-webpack5/jest.config.js b/code/frameworks/vue-webpack5/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/frameworks/vue-webpack5/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/frameworks/vue-webpack5/package.json b/code/frameworks/vue-webpack5/package.json
index 88e5f2f825a7..ff40e2f9f5a8 100644
--- a/code/frameworks/vue-webpack5/package.json
+++ b/code/frameworks/vue-webpack5/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/vue-webpack5",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook for Vue: Develop Vue Component in isolation with Hot Reloading.",
"keywords": [
"storybook"
@@ -50,16 +50,16 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/builder-webpack5": "7.0.0-alpha.48",
- "@storybook/core-common": "7.0.0-alpha.48",
- "@storybook/preset-vue-webpack": "7.0.0-alpha.48",
- "@storybook/vue": "7.0.0-alpha.48",
- "@types/node": "^16.0.0",
+ "@storybook/builder-webpack5": "7.0.0-alpha.51",
+ "@storybook/core-common": "7.0.0-alpha.51",
+ "@storybook/preset-vue-webpack": "7.0.0-alpha.51",
+ "@storybook/vue": "7.0.0-alpha.51",
+ "@types/node": "^16.0.0 || ^18.0.0",
"react": "16.14.0",
"react-dom": "16.14.0"
},
"devDependencies": {
- "typescript": "~4.6.3",
+ "typescript": "^4.9.3",
"vue": "^2.6.12",
"vue-loader": "^15.7.0",
"vue-template-compiler": "^2.6.14"
@@ -85,5 +85,5 @@
],
"platform": "node"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/frameworks/vue-webpack5/tsconfig.json b/code/frameworks/vue-webpack5/tsconfig.json
index 1f9bdf2596c3..1405a8fbb5a6 100644
--- a/code/frameworks/vue-webpack5/tsconfig.json
+++ b/code/frameworks/vue-webpack5/tsconfig.json
@@ -5,6 +5,5 @@
"skipLibCheck": true,
"resolveJsonModule": true
},
- "include": ["src/**/*"],
- "exclude": ["src/**/*.test.*"]
+ "include": ["src/**/*"]
}
diff --git a/code/frameworks/vue3-vite/jest.config.js b/code/frameworks/vue3-vite/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/frameworks/vue3-vite/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/frameworks/vue3-vite/package.json b/code/frameworks/vue3-vite/package.json
index 1b1f0a8201d8..0d5cf3855a63 100644
--- a/code/frameworks/vue3-vite/package.json
+++ b/code/frameworks/vue3-vite/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/vue3-vite",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook for Vue3 and Vite: Develop Vue3 components in isolation with Hot Reloading.",
"keywords": [
"storybook"
@@ -51,22 +51,22 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/addons": "7.0.0-alpha.48",
- "@storybook/builder-vite": "7.0.0-alpha.48",
- "@storybook/channel-postmessage": "7.0.0-alpha.48",
- "@storybook/channel-websocket": "7.0.0-alpha.48",
- "@storybook/client-api": "7.0.0-alpha.48",
- "@storybook/core-server": "7.0.0-alpha.48",
- "@storybook/preview-web": "7.0.0-alpha.48",
- "@storybook/vue3": "7.0.0-alpha.48",
+ "@storybook/addons": "7.0.0-alpha.51",
+ "@storybook/builder-vite": "7.0.0-alpha.51",
+ "@storybook/channel-postmessage": "7.0.0-alpha.51",
+ "@storybook/channel-websocket": "7.0.0-alpha.51",
+ "@storybook/client-api": "7.0.0-alpha.51",
+ "@storybook/core-server": "7.0.0-alpha.51",
+ "@storybook/preview-web": "7.0.0-alpha.51",
+ "@storybook/vue3": "7.0.0-alpha.51",
"@vitejs/plugin-vue": "^3.0.0",
"magic-string": "^0.26.1",
"vite": "^3.1.3",
"vue-docgen-api": "^4.40.0"
},
"devDependencies": {
- "@types/node": "^16.0.0",
- "typescript": "~4.6.3",
+ "@types/node": "^16.0.0 || ^18.0.0",
+ "typescript": "^4.9.3",
"vite": "^3.1.3"
},
"engines": {
@@ -82,5 +82,5 @@
],
"platform": "node"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/frameworks/vue3-vite/src/index.ts b/code/frameworks/vue3-vite/src/index.ts
index 8fbdfff5e6e2..067a9d564f75 100644
--- a/code/frameworks/vue3-vite/src/index.ts
+++ b/code/frameworks/vue3-vite/src/index.ts
@@ -1,8 +1,13 @@
// exports for builder-vite
+import * as clientApi from '@storybook/client-api';
+
+// client-api exposes both a class, and individual named exports.
+// The class is used in StoryStoreV7 and the individual exports in SSv6
+const { ClientApi } = clientApi;
export { createChannel as createPostMessageChannel } from '@storybook/channel-postmessage';
export { createChannel as createWebSocketChannel } from '@storybook/channel-websocket';
export { addons } from '@storybook/addons';
export { composeConfigs, PreviewWeb } from '@storybook/preview-web';
-export { ClientApi } from '@storybook/client-api';
+export { clientApi, ClientApi };
export type { StorybookConfig } from '@storybook/builder-vite';
diff --git a/code/frameworks/vue3-vite/tsconfig.json b/code/frameworks/vue3-vite/tsconfig.json
index d710036f4bec..3ce879217eb5 100644
--- a/code/frameworks/vue3-vite/tsconfig.json
+++ b/code/frameworks/vue3-vite/tsconfig.json
@@ -6,6 +6,5 @@
"skipLibCheck": true,
"resolveJsonModule": true
},
- "include": ["src/**/*"],
- "exclude": ["src/**/*.test.*", "src/**/__testfixtures__/**"]
+ "include": ["src/**/*"]
}
diff --git a/code/frameworks/vue3-webpack5/jest.config.js b/code/frameworks/vue3-webpack5/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/frameworks/vue3-webpack5/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/frameworks/vue3-webpack5/package.json b/code/frameworks/vue3-webpack5/package.json
index 1c2078817477..e02c4981d5a6 100644
--- a/code/frameworks/vue3-webpack5/package.json
+++ b/code/frameworks/vue3-webpack5/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/vue3-webpack5",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook for Vue 3: Develop Vue 3 Components in isolation with Hot Reloading.",
"keywords": [
"storybook"
@@ -50,17 +50,17 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/builder-webpack5": "7.0.0-alpha.48",
- "@storybook/core-common": "7.0.0-alpha.48",
- "@storybook/preset-vue3-webpack": "7.0.0-alpha.48",
- "@storybook/vue3": "7.0.0-alpha.48",
- "@types/node": "^16.0.0",
+ "@storybook/builder-webpack5": "7.0.0-alpha.51",
+ "@storybook/core-common": "7.0.0-alpha.51",
+ "@storybook/preset-vue3-webpack": "7.0.0-alpha.51",
+ "@storybook/vue3": "7.0.0-alpha.51",
+ "@types/node": "^16.0.0 || ^18.0.0",
"react": "16.14.0",
"react-dom": "16.14.0"
},
"devDependencies": {
"@vue/compiler-sfc": "3.0.0",
- "typescript": "~4.6.3",
+ "typescript": "^4.9.3",
"vue": "3.0.0"
},
"peerDependencies": {
@@ -82,5 +82,5 @@
],
"platform": "node"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/frameworks/vue3-webpack5/tsconfig.json b/code/frameworks/vue3-webpack5/tsconfig.json
index a9b035c99817..863d7c2de0d2 100644
--- a/code/frameworks/vue3-webpack5/tsconfig.json
+++ b/code/frameworks/vue3-webpack5/tsconfig.json
@@ -4,6 +4,5 @@
"resolveJsonModule": true,
"skipLibCheck": true
},
- "include": ["src/**/*"],
- "exclude": ["src/**/*.test.*"]
+ "include": ["src/**/*"]
}
diff --git a/code/frameworks/web-components-vite/jest.config.js b/code/frameworks/web-components-vite/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/frameworks/web-components-vite/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/frameworks/web-components-vite/package.json b/code/frameworks/web-components-vite/package.json
index 5cb60b1b3df1..bab78c14ebc9 100644
--- a/code/frameworks/web-components-vite/package.json
+++ b/code/frameworks/web-components-vite/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/web-components-vite",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook for web-components and Vite: Develop Web Components in isolation with Hot Reloading.",
"keywords": [
"storybook"
@@ -51,21 +51,21 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/addons": "7.0.0-alpha.48",
- "@storybook/builder-vite": "7.0.0-alpha.48",
- "@storybook/channel-postmessage": "7.0.0-alpha.48",
- "@storybook/channel-websocket": "7.0.0-alpha.48",
- "@storybook/client-api": "7.0.0-alpha.48",
- "@storybook/core-server": "7.0.0-alpha.48",
- "@storybook/node-logger": "7.0.0-alpha.48",
- "@storybook/preview-web": "7.0.0-alpha.48",
- "@storybook/web-components": "7.0.0-alpha.48",
+ "@storybook/addons": "7.0.0-alpha.51",
+ "@storybook/builder-vite": "7.0.0-alpha.51",
+ "@storybook/channel-postmessage": "7.0.0-alpha.51",
+ "@storybook/channel-websocket": "7.0.0-alpha.51",
+ "@storybook/client-api": "7.0.0-alpha.51",
+ "@storybook/core-server": "7.0.0-alpha.51",
+ "@storybook/node-logger": "7.0.0-alpha.51",
+ "@storybook/preview-web": "7.0.0-alpha.51",
+ "@storybook/web-components": "7.0.0-alpha.51",
"magic-string": "^0.26.1",
"vite": "3"
},
"devDependencies": {
- "@types/node": "^16.0.0",
- "typescript": "~4.6.3",
+ "@types/node": "^16.0.0 || ^18.0.0",
+ "typescript": "^4.9.3",
"vite": "^3.1.0"
},
"engines": {
@@ -81,5 +81,5 @@
],
"platform": "node"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/frameworks/web-components-vite/src/index.ts b/code/frameworks/web-components-vite/src/index.ts
index 8fbdfff5e6e2..067a9d564f75 100644
--- a/code/frameworks/web-components-vite/src/index.ts
+++ b/code/frameworks/web-components-vite/src/index.ts
@@ -1,8 +1,13 @@
// exports for builder-vite
+import * as clientApi from '@storybook/client-api';
+
+// client-api exposes both a class, and individual named exports.
+// The class is used in StoryStoreV7 and the individual exports in SSv6
+const { ClientApi } = clientApi;
export { createChannel as createPostMessageChannel } from '@storybook/channel-postmessage';
export { createChannel as createWebSocketChannel } from '@storybook/channel-websocket';
export { addons } from '@storybook/addons';
export { composeConfigs, PreviewWeb } from '@storybook/preview-web';
-export { ClientApi } from '@storybook/client-api';
+export { clientApi, ClientApi };
export type { StorybookConfig } from '@storybook/builder-vite';
diff --git a/code/frameworks/web-components-vite/tsconfig.json b/code/frameworks/web-components-vite/tsconfig.json
index 534e4ddd108a..13e04352a3c7 100644
--- a/code/frameworks/web-components-vite/tsconfig.json
+++ b/code/frameworks/web-components-vite/tsconfig.json
@@ -5,6 +5,5 @@
"types": ["node"],
"resolveJsonModule": true
},
- "include": ["src/**/*"],
- "exclude": ["src/**/*.test.*", "src/**/__testfixtures__/**"]
+ "include": ["src/**/*"]
}
diff --git a/code/frameworks/web-components-webpack5/jest.config.js b/code/frameworks/web-components-webpack5/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/frameworks/web-components-webpack5/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/frameworks/web-components-webpack5/package.json b/code/frameworks/web-components-webpack5/package.json
index 895cc52e21b1..5243dd33b7ab 100644
--- a/code/frameworks/web-components-webpack5/package.json
+++ b/code/frameworks/web-components-webpack5/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/web-components-webpack5",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook for web-components: View web components snippets in isolation with Hot Reloading.",
"keywords": [
"lit-html",
@@ -52,18 +52,18 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@babel/preset-env": "^7.12.11",
- "@storybook/builder-webpack5": "7.0.0-alpha.48",
- "@storybook/core-common": "7.0.0-alpha.48",
- "@storybook/preset-web-components-webpack": "7.0.0-alpha.48",
- "@storybook/web-components": "7.0.0-alpha.48",
- "@types/node": "^16.0.0",
+ "@babel/preset-env": "^7.20.2",
+ "@storybook/builder-webpack5": "7.0.0-alpha.51",
+ "@storybook/core-common": "7.0.0-alpha.51",
+ "@storybook/preset-web-components-webpack": "7.0.0-alpha.51",
+ "@storybook/web-components": "7.0.0-alpha.51",
+ "@types/node": "^16.0.0 || ^18.0.0",
"react": "16.14.0",
"react-dom": "16.14.0"
},
"devDependencies": {
"lit-html": "2.0.2",
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"peerDependencies": {
"lit-html": "^1.4.1 || ^2.0.0"
@@ -81,5 +81,5 @@
],
"platform": "node"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/frameworks/web-components-webpack5/tsconfig.json b/code/frameworks/web-components-webpack5/tsconfig.json
index d9463d503988..a4429176e35f 100644
--- a/code/frameworks/web-components-webpack5/tsconfig.json
+++ b/code/frameworks/web-components-webpack5/tsconfig.json
@@ -3,6 +3,5 @@
"compilerOptions": {
"strict": true
},
- "include": ["src/**/*"],
- "exclude": ["src/**/*.test.*", "src/__tests__/**/*"]
+ "include": ["src/**/*"]
}
diff --git a/code/jest.config.base.js b/code/jest.config.base.js
new file mode 100644
index 000000000000..dd8850d0115c
--- /dev/null
+++ b/code/jest.config.base.js
@@ -0,0 +1,94 @@
+const os = require('os');
+const path = require('path');
+
+/**
+ * TODO: Some windows related tasks are still commented out, because they are behaving differently on
+ * a local Windows machine compared to the Windows Server 2022 machine running in GitHub Actions.
+ * The main issue is that path.sep is behaving differently on the two machines. Some more investagations
+ * are necessary!
+ * */
+const skipOnWindows = [
+ 'lib/core-server/src/utils/__tests__/server-statics.test.ts',
+ 'lib/core-common/src/utils/__tests__/template.test.ts',
+ 'addons/storyshots/storyshots-core/src/frameworks/configure.test.ts',
+ 'lib/core-common/src/utils/__tests__/interpret-files.test.ts',
+ 'lib/cli/src/helpers.test.ts',
+];
+
+module.exports = {
+ cacheDirectory: path.resolve('.cache/jest'),
+ clearMocks: true,
+ moduleNameMapper: {
+ // non-js files
+ '\\.(jpg|jpeg|png|apng|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
+ path.resolve('./__mocks__/fileMock.js'),
+ '\\.(css|scss|stylesheet)$': path.resolve('./__mocks__/styleMock.js'),
+ '\\.(md)$': path.resolve('./__mocks__/htmlMock.js'),
+
+ // core-js v2 to v3 mapping
+ 'core-js/modules/es6.(.*)': 'core-js/modules/es.$1',
+ 'core-js/modules/es7.(.*)': 'core-js/modules/esnext.$1',
+ 'core-js/library/fn/(.*)': `core-js/features/$1`,
+ 'core-js/es5/(.*)': `core-js/es/$1`,
+ 'core-js/es6/(.*)': `core-js/es/$1`,
+ 'core-js/es7/reflect': `core-js/proposals/reflect-metadata`,
+ 'core-js/es7/(.*)': `core-js/proposals/$1`,
+ 'core-js/object$/': `core-js/es/object`,
+ 'core-js/object/(.*)': `core-js/es/object/$1`,
+ 'babel-runtime/core-js/(.*)': `core-js/es/$1`,
+ // 'babel-runtime/core-js/object/assign'
+ 'core-js/library/fn/object/assign': 'core-js/es/object/assign',
+ },
+ transform: {
+ '^.+\\.[jt]sx?$': path.resolve('../scripts/utils/jest-transform-js.js'),
+ '^.+\\.mdx$': '@storybook/addon-docs/jest-transform-mdx',
+ },
+ transformIgnorePatterns: ['/node_modules/(?!@angular|rxjs|nanoid|uuid|lit-html|@mdx-js)'],
+ testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
+ testPathIgnorePatterns: [
+ '/storybook-static/',
+ '/node_modules/',
+ '/dist/',
+ '/prebuilt/',
+ '/template/',
+ 'addon-jest.test.js',
+ // TODO: Can not get svelte-jester to work, but also not necessary for this test, as it is run by tsc/svelte-check.
+ '/renderers/svelte/src/public-types.test.ts',
+ '/renderers/vue/src/public-types.test.ts',
+ '/renderers/vue3/src/public-types.test.ts',
+ ...(process.platform === 'win32' ? skipOnWindows : []),
+ ],
+ coveragePathIgnorePatterns: [
+ '/node_modules/',
+ '/cli/test/',
+ '/dist/',
+ '/prebuilt/',
+ '/generators/',
+ '/template/',
+ '/__mocks__ /',
+ '/__mockdata__/',
+ '/__mocks-ng-workspace__/',
+ '/__testfixtures__/',
+ '^.*\\.stories\\.[jt]sx?$',
+ 'typings.d.ts$',
+ ],
+ globals: {
+ PREVIEW_URL: undefined,
+ SNAPSHOT_OS: os.platform() === 'win32' ? 'windows' : 'posix',
+ },
+ snapshotSerializers: ['@emotion/jest/serializer', 'jest-serializer-html'],
+ testEnvironmentOptions: {
+ url: 'http://localhost',
+ },
+ modulePathIgnorePatterns: [
+ //
+ '/dist/.*/__mocks__/',
+ '/storybook-static/',
+ '/template/',
+ ],
+ moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'node'],
+ snapshotFormat: {
+ escapeString: true,
+ printBasicPrototype: true,
+ },
+};
diff --git a/code/jest.config.browser.js b/code/jest.config.browser.js
new file mode 100644
index 000000000000..2e94523b8eff
--- /dev/null
+++ b/code/jest.config.browser.js
@@ -0,0 +1,9 @@
+const path = require('path');
+const baseConfig = require('./jest.config.base');
+
+module.exports = {
+ ...baseConfig,
+ setupFilesAfterEnv: [path.resolve('./jest.init.browser.ts')],
+ testEnvironment: 'jest-environment-jsdom',
+ setupFiles: ['raf/polyfill'],
+};
diff --git a/code/jest.config.js b/code/jest.config.js
index ef5b43abe791..ee2ebd55a9ac 100644
--- a/code/jest.config.js
+++ b/code/jest.config.js
@@ -1,75 +1,10 @@
-const os = require('os');
-
-// TODO Revisit this test later, when we have a windows machine @valentinpalkovic
-const skipOnWindows = [
- 'lib/core-server/src/utils/stories-json.test.ts',
- 'lib/core-server/src/utils/StoryIndexGenerator.test.ts',
- 'lib/cli/src/helpers.test.ts',
- 'lib/core-server/src/utils/__tests__/server-statics.test.ts',
- 'lib/core-common/src/utils/__tests__/template.test.ts',
- 'addons/storyshots/storyshots-core/src/frameworks/configure.test.ts',
- 'lib/core-common/src/utils/__tests__/interpret-files.test.ts',
- 'lib/builder-manager/src/utils/files.test.ts',
- 'lib/cli/src/helpers.test.ts',
- 'lib/core-server/src/utils/__tests__/server-statics.test.ts',
- 'lib/core-common/src/utils/__tests__/template.test.ts',
- 'addons/storyshots/storyshots-core/src/frameworks/configure.test.ts',
- 'lib/core-common/src/utils/__tests__/interpret-files.test.ts',
- 'lib/builder-manager/src/utils/files.test.ts',
-];
-
module.exports = {
- cacheDirectory: '.cache/jest',
- clearMocks: true,
- moduleNameMapper: {
- // non-js files
- '\\.(jpg|jpeg|png|apng|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
- '/__mocks__/fileMock.js',
- '\\.(css|scss|stylesheet)$': '/__mocks__/styleMock.js',
- '\\.(md)$': '/__mocks__/htmlMock.js',
-
- // core-js v2 to v3 mapping
- 'core-js/modules/es6.(.*)': 'core-js/modules/es.$1',
- 'core-js/modules/es7.(.*)': 'core-js/modules/esnext.$1',
- 'core-js/library/fn/(.*)': `core-js/features/$1`,
- 'core-js/es5/(.*)': `core-js/es/$1`,
- 'core-js/es6/(.*)': `core-js/es/$1`,
- 'core-js/es7/reflect': `core-js/proposals/reflect-metadata`,
- 'core-js/es7/(.*)': `core-js/proposals/$1`,
- 'core-js/object$/': `core-js/es/object`,
- 'core-js/object/(.*)': `core-js/es/object/$1`,
- 'babel-runtime/core-js/(.*)': `core-js/es/$1`,
- // 'babel-runtime/core-js/object/assign'
- 'core-js/library/fn/object/assign': 'core-js/es/object/assign',
- },
- projects: [''],
- roots: ['/addons', '/frameworks', '/lib', '/renderers'],
- transform: {
- '^.+\\.stories\\.[jt]sx?$': '@storybook/addon-storyshots/injectFileName',
- '^.+\\.[jt]sx?$': '/../scripts/utils/jest-transform-js.js',
- '^.+\\.mdx$': '@storybook/addon-docs/jest-transform-mdx',
- },
- transformIgnorePatterns: [
- '/node_modules/(?!(lit-html|@mdx-js)).+\\.js',
- '/node_modules/(?!).+\\.js',
- ],
- testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
- testPathIgnorePatterns: [
- '/storybook-static/',
- '/node_modules/',
- '/dist/',
- '/prebuilt/',
- '/template/',
- 'addon-jest.test.js',
- '/frameworks/angular/*',
- '/examples/*/src/*.*',
- '/examples/*/src/*/*.*',
- '/examples/*/src/*/*/*.*',
- // TODO: Can not get svelte-jester to work, but also not necessary for this test, as it is run by tsc/svelte-check.
- '/renderers/svelte/src/public-types.test.ts',
- '/renderers/vue/src/public-types.test.ts',
- '/renderers/vue3/src/public-types.test.ts',
- ...(process.platform === 'win32' ? skipOnWindows : []),
+ projects: [
+ '/addons/*',
+ '/frameworks/!(angular)*',
+ '/lib/*',
+ '/renderers/*',
+ '/ui/*',
],
collectCoverage: false,
collectCoverageFrom: [
@@ -77,44 +12,10 @@ module.exports = {
'lib/*/src/**/*.{js,jsx,ts,tsx}',
'renderers/*/src/**/*.{js,jsx,ts,tsx}',
'addons/*/src/**/*.{js,jsx,ts,tsx}',
- ],
- coveragePathIgnorePatterns: [
- '/node_modules/',
- '/cli/test/',
- '/dist/',
- '/prebuilt/',
- '/generators/',
- '/template/',
- '/dll/',
- '/__mocks__ /',
- '/__mockdata__/',
- '/__mocks-ng-workspace__/',
- '/__testfixtures__/',
- '^.*\\.stories\\.[jt]sx?$',
- 'typings.d.ts$',
- ],
- globals: {
- PREVIEW_URL: undefined,
- SNAPSHOT_OS: os.platform() === 'win32' ? 'windows' : 'posix',
- },
- snapshotSerializers: [
- '@emotion/jest/serializer',
- 'enzyme-to-json/serializer',
- 'jest-serializer-html',
+ 'ui/*/src/**/*.{js,jsx,ts,tsx}',
],
coverageDirectory: 'coverage',
- setupFilesAfterEnv: ['./jest.init.ts'],
coverageReporters: ['lcov'],
- testEnvironment: 'jest-environment-jsdom-thirteen',
- setupFiles: ['raf/polyfill'],
- testURL: 'http://localhost',
- modulePathIgnorePatterns: [
- //
- '/dist/.*/__mocks__/',
- '/storybook-static/',
- '/template/',
- ],
- moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'node'],
- watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
reporters: ['default', 'jest-junit'],
+ watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
};
diff --git a/code/jest.config.node.js b/code/jest.config.node.js
new file mode 100644
index 000000000000..54acf2670929
--- /dev/null
+++ b/code/jest.config.node.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('./jest.config.base');
+
+module.exports = {
+ ...baseConfig,
+ setupFilesAfterEnv: [path.resolve('./jest.init.base.ts')],
+};
diff --git a/code/jest.init.ts b/code/jest.init.base.ts
similarity index 68%
rename from code/jest.init.ts
rename to code/jest.init.base.ts
index bf6a5ee3a9af..535f1bc74a0d 100644
--- a/code/jest.init.ts
+++ b/code/jest.init.base.ts
@@ -1,4 +1,3 @@
-import 'jest-enzyme/lib/index';
import '@testing-library/jest-dom';
// setup file
@@ -8,7 +7,6 @@ import Adapter from 'enzyme-adapter-react-16';
// @ts-expect-error (Converted from ts-ignore)
import regeneratorRuntime from 'regenerator-runtime';
import registerRequireContextHook from '@storybook/babel-plugin-require-context-hook/register';
-import EventEmitter from 'events';
registerRequireContextHook();
@@ -58,41 +56,3 @@ const throwError = (message: any) => throwMessage('error: ', message);
global.console.error = throwError;
global.console.warn = throwWarning;
-
-// Mock for matchMedia since it's not yet implemented in JSDOM (https://jestjs.io/docs/en/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom)
-global.window.matchMedia = jest.fn().mockImplementation((query) => {
- return {
- matches: false,
- media: query,
- onchange: null,
- addListener: jest.fn(), // deprecated
- removeListener: jest.fn(), // deprecated
- addEventListener: jest.fn(),
- removeEventListener: jest.fn(),
- dispatchEvent: jest.fn(),
- };
-});
-class EventSourceMock {
- static sources: EventSourceMock[] = [];
-
- static reset() {
- this.sources = [];
- }
-
- emitter: EventEmitter;
-
- constructor() {
- this.emitter = new EventEmitter();
- EventSourceMock.sources.push(this);
- }
-
- addEventListener(event: string, cb: (data: any) => void) {
- this.emitter.on(event, cb);
- }
-
- emit(event: string, data: any) {
- this.emitter.emit(event, data);
- }
-}
-
-global.window.EventSource = EventSourceMock as any;
diff --git a/code/jest.init.browser.ts b/code/jest.init.browser.ts
new file mode 100644
index 000000000000..0ad9f9d2e7ac
--- /dev/null
+++ b/code/jest.init.browser.ts
@@ -0,0 +1,48 @@
+import './jest.init.base';
+import EventEmitter from 'events';
+import { webcrypto } from 'node:crypto';
+
+// Mock for matchMedia since it's not yet implemented in JSDOM (https://jestjs.io/docs/en/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom)
+global.window.matchMedia = jest.fn().mockImplementation((query) => {
+ return {
+ matches: false,
+ media: query,
+ onchange: null,
+ addListener: jest.fn(), // deprecated
+ removeListener: jest.fn(), // deprecated
+ addEventListener: jest.fn(),
+ removeEventListener: jest.fn(),
+ dispatchEvent: jest.fn(),
+ };
+});
+
+class EventSourceMock {
+ static sources: EventSourceMock[] = [];
+
+ static reset() {
+ this.sources = [];
+ }
+
+ emitter: EventEmitter;
+
+ constructor() {
+ this.emitter = new EventEmitter();
+ EventSourceMock.sources.push(this);
+ }
+
+ addEventListener(event: string, cb: (data: any) => void) {
+ this.emitter.on(event, cb);
+ }
+
+ emit(event: string, data: any) {
+ this.emitter.emit(event, data);
+ }
+}
+
+global.window.EventSource = EventSourceMock as any;
+
+Object.defineProperty(window, 'crypto', {
+ get() {
+ return webcrypto;
+ },
+});
diff --git a/code/lerna.json b/code/lerna.json
index 8442865df4d6..ee66d5a2ad77 100644
--- a/code/lerna.json
+++ b/code/lerna.json
@@ -2,5 +2,5 @@
"npmClient": "yarn",
"useWorkspaces": true,
"registry": "https://registry.npmjs.org",
- "version": "7.0.0-alpha.48"
+ "version": "7.0.0-alpha.51"
}
diff --git a/code/lib/addons/jest.config.js b/code/lib/addons/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/lib/addons/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/lib/addons/package.json b/code/lib/addons/package.json
index 57cf53a7bebb..5b86a7e526c2 100644
--- a/code/lib/addons/package.json
+++ b/code/lib/addons/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/addons",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook addons store",
"keywords": [
"storybook"
@@ -42,13 +42,13 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/api": "7.0.0-alpha.48",
- "@storybook/channels": "7.0.0-alpha.48",
- "@storybook/client-logger": "7.0.0-alpha.48",
- "@storybook/core-events": "7.0.0-alpha.48",
- "@storybook/router": "7.0.0-alpha.48",
- "@storybook/theming": "7.0.0-alpha.48",
- "@storybook/types": "7.0.0-alpha.48",
+ "@storybook/api": "7.0.0-alpha.51",
+ "@storybook/channels": "7.0.0-alpha.51",
+ "@storybook/client-logger": "7.0.0-alpha.51",
+ "@storybook/core-events": "7.0.0-alpha.51",
+ "@storybook/router": "7.0.0-alpha.51",
+ "@storybook/theming": "7.0.0-alpha.51",
+ "@storybook/types": "7.0.0-alpha.51",
"global": "^4.4.0"
},
"peerDependencies": {
@@ -63,5 +63,5 @@
"./src/index.ts"
]
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/lib/addons/src/hooks.ts b/code/lib/addons/src/hooks.ts
index c456c219451b..55ec838f995f 100644
--- a/code/lib/addons/src/hooks.ts
+++ b/code/lib/addons/src/hooks.ts
@@ -1,7 +1,7 @@
import global from 'global';
import { logger } from '@storybook/client-logger';
import type {
- Framework,
+ Renderer,
Args,
DecoratorApplicator,
DecoratorFunction,
@@ -32,7 +32,7 @@ interface Effect {
type AbstractFunction = (...args: any[]) => any;
-export class HooksContext {
+export class HooksContext {
hookListsMap: WeakMap;
mountedDecorators: Set;
@@ -53,7 +53,7 @@ export class HooksContext {
hasUpdates: boolean;
- currentContext: StoryContext | null;
+ currentContext: StoryContext | null;
renderListener = (storyId: StoryId) => {
if (storyId !== this.currentContext.id) return;
@@ -126,15 +126,15 @@ export class HooksContext {
}
}
-function hookify(
- storyFn: LegacyStoryFn
-): LegacyStoryFn;
-function hookify(
- decorator: DecoratorFunction
-): DecoratorFunction;
-function hookify(fn: AbstractFunction) {
+function hookify(
+ storyFn: LegacyStoryFn
+): LegacyStoryFn;
+function hookify(
+ decorator: DecoratorFunction
+): DecoratorFunction;
+function hookify(fn: AbstractFunction) {
return (...args: any[]) => {
- const { hooks }: { hooks: HooksContext } =
+ const { hooks }: { hooks: HooksContext } =
typeof args[0] === 'function' ? args[1] : args[0];
const prevPhase = hooks.currentPhase;
@@ -177,16 +177,16 @@ function hookify(fn: AbstractFunction) {
let numberOfRenders = 0;
const RENDER_LIMIT = 25;
export const applyHooks =
- (
- applyDecorators: DecoratorApplicator
- ): DecoratorApplicator =>
- (storyFn: LegacyStoryFn, decorators: DecoratorFunction[]) => {
+ (
+ applyDecorators: DecoratorApplicator
+ ): DecoratorApplicator =>
+ (storyFn: LegacyStoryFn, decorators: DecoratorFunction[]) => {
const decorated = applyDecorators(
hookify(storyFn),
decorators.map((decorator) => hookify(decorator))
);
return (context) => {
- const { hooks } = context as { hooks: HooksContext };
+ const { hooks } = context as { hooks: HooksContext };
hooks.prevMountedDecorators = hooks.mountedDecorators;
hooks.mountedDecorators = new Set([storyFn, ...decorators]);
hooks.currentContext = context;
@@ -215,12 +215,12 @@ const areDepsEqual = (deps: any[], nextDeps: any[]) =>
const invalidHooksError = () =>
new Error('Storybook preview hooks can only be called inside decorators and story functions.');
-function getHooksContextOrNull(): HooksContext | null {
+function getHooksContextOrNull(): HooksContext | null {
return global.STORYBOOK_HOOKS_CONTEXT || null;
}
-function getHooksContextOrThrow(): HooksContext {
- const hooks = getHooksContextOrNull();
+function getHooksContextOrThrow(): HooksContext {
+ const hooks = getHooksContextOrNull();
if (hooks == null) {
throw invalidHooksError();
}
@@ -404,7 +404,7 @@ export function useChannel(eventMap: EventMap, deps: any[] = []) {
}
/* Returns current story context */
-export function useStoryContext(): StoryContext {
+export function useStoryContext(): StoryContext {
const { currentContext } = getHooksContextOrThrow();
if (currentContext == null) {
throw invalidHooksError();
diff --git a/code/lib/addons/tsconfig.json b/code/lib/addons/tsconfig.json
index d23f9a406fc2..52d43eaaa9b9 100644
--- a/code/lib/addons/tsconfig.json
+++ b/code/lib/addons/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/lib/api/jest.config.js b/code/lib/api/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/lib/api/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/lib/api/package.json b/code/lib/api/package.json
index 467c173b5131..ebdd7937d3c0 100644
--- a/code/lib/api/package.json
+++ b/code/lib/api/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/api",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Core Storybook API & Context",
"keywords": [
"storybook"
@@ -45,13 +45,13 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/channels": "7.0.0-alpha.48",
- "@storybook/client-logger": "7.0.0-alpha.48",
- "@storybook/core-events": "7.0.0-alpha.48",
+ "@storybook/channels": "7.0.0-alpha.51",
+ "@storybook/client-logger": "7.0.0-alpha.51",
+ "@storybook/core-events": "7.0.0-alpha.51",
"@storybook/csf": "next",
- "@storybook/router": "7.0.0-alpha.48",
- "@storybook/theming": "7.0.0-alpha.48",
- "@storybook/types": "7.0.0-alpha.48",
+ "@storybook/router": "7.0.0-alpha.51",
+ "@storybook/theming": "7.0.0-alpha.51",
+ "@storybook/types": "7.0.0-alpha.51",
"dequal": "^2.0.2",
"global": "^4.4.0",
"lodash": "^4.17.21",
@@ -63,13 +63,12 @@
"util-deprecate": "^1.0.2"
},
"devDependencies": {
- "@jest/globals": "^26.6.2",
- "@storybook/core-common": "7.0.0-alpha.48",
+ "@storybook/core-common": "7.0.0-alpha.51",
"@types/lodash": "^4.14.167",
"@types/qs": "^6",
"flush-promises": "^1.0.2",
"qs": "^6.10.1",
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
@@ -84,5 +83,5 @@
"./src/shortcut.ts"
]
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/lib/api/src/modules/globals.ts b/code/lib/api/src/modules/globals.ts
index ab7207b6a676..c7b99ce186ca 100644
--- a/code/lib/api/src/modules/globals.ts
+++ b/code/lib/api/src/modules/globals.ts
@@ -19,7 +19,7 @@ export interface SubAPI {
updateGlobals: (newGlobals: Globals) => void;
}
-export const init: ModuleFn = ({ store, fullAPI }) => {
+export const init: ModuleFn = ({ store, fullAPI }) => {
const api: SubAPI = {
getGlobals() {
return store.getState().globals;
diff --git a/code/lib/api/src/tests/shortcut.test.js b/code/lib/api/src/tests/shortcut.test.js
index 9a4532532682..23aeb049236e 100644
--- a/code/lib/api/src/tests/shortcut.test.js
+++ b/code/lib/api/src/tests/shortcut.test.js
@@ -1,3 +1,7 @@
+/**
+ * @jest-environment jsdom
+ */
+
import global from 'global';
import { eventToShortcut, keyToSymbol } from '../lib/shortcut';
diff --git a/code/lib/api/src/tests/stories.test.ts b/code/lib/api/src/tests/stories.test.ts
index 229862fa0871..59ce70e8cf7d 100644
--- a/code/lib/api/src/tests/stories.test.ts
+++ b/code/lib/api/src/tests/stories.test.ts
@@ -34,7 +34,7 @@ function mockChannel() {
return new Channel({ transport });
}
-const mockGetEntries = jest.fn();
+const mockGetEntries = jest.fn<() => API_StoryIndex['entries']>();
jest.mock('../lib/events');
jest.mock('global', () => ({
diff --git a/code/lib/api/src/version.ts b/code/lib/api/src/version.ts
index 22f21c33eed5..2a1066536ca1 100644
--- a/code/lib/api/src/version.ts
+++ b/code/lib/api/src/version.ts
@@ -1 +1 @@
-export const version = '7.0.0-alpha.48';
+export const version = '7.0.0-alpha.51';
diff --git a/code/lib/api/tsconfig.json b/code/lib/api/tsconfig.json
index f8b60c90fdef..cf1e09965901 100644
--- a/code/lib/api/tsconfig.json
+++ b/code/lib/api/tsconfig.json
@@ -1,13 +1,7 @@
{
"extends": "../../tsconfig.json",
- "compilerOptions": {},
- "include": ["src/**/*"],
- "exclude": [
- "src/**/*.test.*",
- "src/**/tests/**/*",
- "src/**/__tests__/**/*",
- "src/**/*.stories.*",
- "src/**/*.mockdata.*",
- "src/**/__testfixtures__/**"
- ]
+ "compilerOptions": {
+ "skipLibCheck": true
+ },
+ "include": ["src/**/*"]
}
diff --git a/code/lib/builder-manager/jest.config.js b/code/lib/builder-manager/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/lib/builder-manager/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/lib/builder-manager/package.json b/code/lib/builder-manager/package.json
index 84a286b93dd1..594d9cf6eb1f 100644
--- a/code/lib/builder-manager/package.json
+++ b/code/lib/builder-manager/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/builder-manager",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook manager builder",
"keywords": [
"storybook"
@@ -42,9 +42,9 @@
},
"dependencies": {
"@fal-works/esbuild-plugin-global-externals": "^2.1.2",
- "@storybook/core-common": "7.0.0-alpha.48",
- "@storybook/manager": "7.0.0-alpha.48",
- "@storybook/node-logger": "7.0.0-alpha.48",
+ "@storybook/core-common": "7.0.0-alpha.51",
+ "@storybook/manager": "7.0.0-alpha.51",
+ "@storybook/node-logger": "7.0.0-alpha.51",
"@types/ejs": "^3.1.1",
"@yarnpkg/esbuild-plugin-pnp": "^3.0.0-rc.10",
"browser-assert": "^1.2.1",
@@ -58,7 +58,7 @@
"util": "^0.12.4"
},
"devDependencies": {
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"publishConfig": {
"access": "public"
@@ -69,5 +69,5 @@
],
"platform": "node"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/lib/builder-manager/src/utils/files.test.ts b/code/lib/builder-manager/src/utils/files.test.ts
index 41d62ec82693..2cdb1f0d4c59 100644
--- a/code/lib/builder-manager/src/utils/files.test.ts
+++ b/code/lib/builder-manager/src/utils/files.test.ts
@@ -1,17 +1,27 @@
+import { platform } from 'os';
import { sanitizePath } from './files';
+const os = platform();
+const isWindows = os === 'win32';
+
test('sanitizePath', () => {
- const addonsDir = '/Users/username/Projects/projectname/storybook';
+ const addonsDir = isWindows
+ ? 'C:\\Users\\username\\Projects\\projectname\\storybook'
+ : '/Users/username/Projects/projectname/storybook';
const text = 'demo text';
const file = {
- path: '/Users/username/Projects/projectname/storybook/node_modules/@storybook/addon-x+y/dist/manager.mjs',
+ path: isWindows
+ ? 'C:\\Users\\username\\Projects\\projectname\\storybook\\node_modules\\@storybook\\addon-x+y\\dist\\manager.mjs'
+ : '/Users/username/Projects/projectname/storybook/node_modules/@storybook/addon-x+y/dist/manager.mjs',
contents: Uint8Array.from(Array.from(text).map((letter) => letter.charCodeAt(0))),
text,
};
const { location, url } = sanitizePath(file, addonsDir);
- expect(location).toMatchInlineSnapshot(
- `"/Users/username/Projects/projectname/storybook/node_modules/@storybook/addon-x+y/dist/manager.mjs"`
+ expect(location).toEqual(
+ isWindows
+ ? 'C:\\Users\\username\\Projects\\projectname\\storybook\\node_modules\\@storybook\\addon-x+y\\dist\\manager.mjs'
+ : '/Users/username/Projects/projectname/storybook/node_modules/@storybook/addon-x+y/dist/manager.mjs'
);
expect(url).toMatchInlineSnapshot(
`"./sb-addons/node_modules/%40storybook/addon-x%2By/dist/manager.mjs"`
diff --git a/code/lib/builder-manager/src/utils/files.ts b/code/lib/builder-manager/src/utils/files.ts
index bded035f9a2c..bca197dcda9e 100644
--- a/code/lib/builder-manager/src/utils/files.ts
+++ b/code/lib/builder-manager/src/utils/files.ts
@@ -1,6 +1,6 @@
import type { OutputFile } from 'esbuild';
import fs from 'fs-extra';
-import { join } from 'path';
+import { join, normalize } from 'path';
import slash from 'slash';
import type { Compilation } from '../types';
@@ -26,7 +26,8 @@ export async function readOrderedFiles(
export function sanitizePath(file: OutputFile, addonsDir: string) {
const filePath = file.path.replace(addonsDir, '');
- const location = join(addonsDir, filePath);
+ const location = normalize(join(addonsDir, filePath));
const url = `./sb-addons${slash(filePath).split('/').map(encodeURIComponent).join('/')}`;
+
return { location, url };
}
diff --git a/code/lib/builder-manager/tsconfig.json b/code/lib/builder-manager/tsconfig.json
index 314889c338e2..b89e79d6ea26 100644
--- a/code/lib/builder-manager/tsconfig.json
+++ b/code/lib/builder-manager/tsconfig.json
@@ -4,6 +4,5 @@
"strict": true,
"skipLibCheck": true
},
- "include": ["src/**/*", "typings.d.ts"],
- "exclude": ["src/**.test.ts"]
+ "include": ["src/**/*", "typings.d.ts"]
}
diff --git a/code/lib/builder-vite/jest.config.js b/code/lib/builder-vite/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/lib/builder-vite/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/lib/builder-vite/package.json b/code/lib/builder-vite/package.json
index dbc277446d42..bec560c5f36a 100644
--- a/code/lib/builder-vite/package.json
+++ b/code/lib/builder-vite/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/builder-vite",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "A plugin to run and build Storybooks with Vite",
"homepage": "https://github.com/storybookjs/storybook/tree/main/code/lib/builder-vite/#readme",
"repository": {
@@ -19,14 +19,14 @@
},
"dependencies": {
"@joshwooding/vite-plugin-react-docgen-typescript": "0.0.5",
- "@storybook/client-api": "7.0.0-alpha.48",
- "@storybook/client-logger": "7.0.0-alpha.48",
- "@storybook/core-common": "7.0.0-alpha.48",
+ "@storybook/client-api": "7.0.0-alpha.51",
+ "@storybook/client-logger": "7.0.0-alpha.51",
+ "@storybook/core-common": "7.0.0-alpha.51",
"@storybook/mdx2-csf": "next",
- "@storybook/node-logger": "7.0.0-alpha.48",
- "@storybook/preview-web": "7.0.0-alpha.48",
- "@storybook/source-loader": "7.0.0-alpha.48",
- "@storybook/types": "7.0.0-alpha.48",
+ "@storybook/node-logger": "7.0.0-alpha.51",
+ "@storybook/preview-web": "7.0.0-alpha.51",
+ "@storybook/source-loader": "7.0.0-alpha.51",
+ "@storybook/types": "7.0.0-alpha.51",
"@vitejs/plugin-react": "^2.0.0",
"browser-assert": "^1.2.1",
"es-module-lexer": "^0.9.3",
@@ -38,12 +38,12 @@
},
"devDependencies": {
"@types/express": "^4.17.13",
- "@types/node": "^16.0.0",
- "typescript": "~4.6.3",
+ "@types/node": "^16.0.0 || ^18.0.0",
+ "typescript": "^4.9.3",
"vite": "^3.1.3"
},
"publishConfig": {
"access": "public"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/lib/builder-vite/src/codegen-iframe-script.ts b/code/lib/builder-vite/src/codegen-iframe-script.ts
index 141965a0034e..fdfe0249bce5 100644
--- a/code/lib/builder-vite/src/codegen-iframe-script.ts
+++ b/code/lib/builder-vite/src/codegen-iframe-script.ts
@@ -1,22 +1,23 @@
-import { isAbsolute, resolve } from 'path';
-import { getRendererName } from '@storybook/core-common';
+import { getRendererName, getFrameworkName } from '@storybook/core-common';
+import type { PreviewAnnotation } from '@storybook/types';
import { virtualPreviewFile, virtualStoriesFile } from './virtual-file-names';
-import { transformAbsPath } from './utils/transform-abs-path';
import type { ExtendedOptions } from './types';
+import { processPreviewAnnotation } from './utils/process-preview-annotation';
export async function generateIframeScriptCode(options: ExtendedOptions) {
const { presets } = options;
const rendererName = await getRendererName(options);
- const previewAnnotations = await presets.apply('previewAnnotations', [], options);
- const resolvedPreviewAnnotations = previewAnnotations.map((entry) =>
- isAbsolute(entry) ? entry : resolve(entry)
+ const frameworkName = await getFrameworkName(options);
+
+ const previewAnnotations = await presets.apply(
+ 'previewAnnotations',
+ [],
+ options
);
- const configEntries = [...resolvedPreviewAnnotations].filter(Boolean);
+ const configEntries = [...previewAnnotations].filter(Boolean).map(processPreviewAnnotation);
- const absoluteFilesToImport = (files: string[], name: string) =>
- files
- .map((el, i) => `import ${name ? `* as ${name}_${i} from ` : ''}'${transformAbsPath(el)}'`)
- .join('\n');
+ const filesToImport = (files: string[], name: string) =>
+ files.map((el, i) => `import ${name ? `* as ${name}_${i} from ` : ''}'${el}'`).join('\n');
const importArray = (name: string, length: number) =>
new Array(length).fill(0).map((_, i) => `${name}_${i}`);
@@ -28,10 +29,8 @@ export async function generateIframeScriptCode(options: ExtendedOptions) {
// Ensure that the client API is initialized by the framework before any other iframe code
// is loaded. That way our client-apis can assume the existence of the API+store
import { configure } from '${rendererName}';
-
- import * as clientApi from "@storybook/client-api";
- import { logger } from '@storybook/client-logger';
- ${absoluteFilesToImport(configEntries, 'config')}
+ import { clientApi } from '${frameworkName}';
+ ${filesToImport(configEntries, 'config')}
import * as preview from '${virtualPreviewFile}';
import { configStories } from '${virtualStoriesFile}';
diff --git a/code/lib/builder-vite/src/codegen-modern-iframe-script.ts b/code/lib/builder-vite/src/codegen-modern-iframe-script.ts
index ee5339228f23..c1c7aa6a4444 100644
--- a/code/lib/builder-vite/src/codegen-modern-iframe-script.ts
+++ b/code/lib/builder-vite/src/codegen-modern-iframe-script.ts
@@ -1,21 +1,22 @@
-import { isAbsolute, resolve } from 'path';
import { loadPreviewOrConfigFile, getFrameworkName } from '@storybook/core-common';
+import type { PreviewAnnotation } from '@storybook/types';
import { virtualStoriesFile, virtualAddonSetupFile } from './virtual-file-names';
-import { transformAbsPath } from './utils/transform-abs-path';
import type { ExtendedOptions } from './types';
+import { processPreviewAnnotation } from './utils/process-preview-annotation';
export async function generateModernIframeScriptCode(options: ExtendedOptions) {
const { presets, configDir } = options;
const frameworkName = await getFrameworkName(options);
const previewOrConfigFile = loadPreviewOrConfigFile({ configDir });
- const previewAnnotations = await presets.apply('previewAnnotations', [], options);
- const resolvedPreviewAnnotations = [...previewAnnotations].map((entry) =>
- isAbsolute(entry) ? entry : resolve(entry)
+ const previewAnnotations = await presets.apply(
+ 'previewAnnotations',
+ [],
+ options
);
- const relativePreviewAnnotations = [...resolvedPreviewAnnotations, previewOrConfigFile]
+ const relativePreviewAnnotations = [...previewAnnotations, previewOrConfigFile]
.filter(Boolean)
- .map((configEntry) => transformAbsPath(configEntry as string));
+ .map(processPreviewAnnotation);
// eslint-disable-next-line @typescript-eslint/no-shadow
const generateHMRHandler = (frameworkName: string): string => {
diff --git a/code/lib/builder-vite/src/utils/process-preview-annotation.ts b/code/lib/builder-vite/src/utils/process-preview-annotation.ts
new file mode 100644
index 000000000000..b37ac876d817
--- /dev/null
+++ b/code/lib/builder-vite/src/utils/process-preview-annotation.ts
@@ -0,0 +1,41 @@
+import type { PreviewAnnotation } from '@storybook/types';
+import { resolve } from 'path';
+import slash from 'slash';
+import { transformAbsPath } from './transform-abs-path';
+
+/**
+ * Preview annotations can take several forms, and vite needs them to be
+ * a bit more restrained.
+ *
+ * For node_modules, we want bare imports (so vite can process them),
+ * and for files in the user's source,
+ * we want absolute paths.
+ */
+export function processPreviewAnnotation(path: PreviewAnnotation | undefined) {
+ // If entry is an object, take the first, which is the
+ // bare (non-absolute) specifier.
+ // This is so that webpack can use an absolute path, and
+ // continue supporting super-addons in pnp/pnpm without
+ // requiring them to re-export their sub-addons as we do
+ // in addon-essentials.
+ if (typeof path === 'object') {
+ return path.bare;
+ }
+ // resolve relative paths into absolute paths, but don't resolve "bare" imports
+ if (path?.startsWith('./') || path?.startsWith('../')) {
+ return slash(resolve(path));
+ }
+ // This should not occur, since we use `.filter(Boolean)` prior to
+ // calling this function, but this makes typescript happy
+ if (!path) {
+ throw new Error('Could not determine path for previewAnnotation');
+ }
+
+ // For addon dependencies that use require.resolve(), we need to convert to a bare path
+ // so that vite will process it as a dependency (cjs -> esm, etc).
+ if (path.includes('node_modules')) {
+ return transformAbsPath(path);
+ }
+
+ return slash(path);
+}
diff --git a/code/lib/builder-vite/tsconfig.json b/code/lib/builder-vite/tsconfig.json
index 76d943e5d483..d3576aa8f726 100644
--- a/code/lib/builder-vite/tsconfig.json
+++ b/code/lib/builder-vite/tsconfig.json
@@ -5,6 +5,5 @@
"resolveJsonModule": true,
"skipLibCheck": true
},
- "include": ["src/**/*"],
- "exclude": ["src/**/*.test.*", "src/**/__testfixtures__/**"]
+ "include": ["src/**/*"]
}
diff --git a/code/lib/builder-webpack5/jest.config.js b/code/lib/builder-webpack5/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/lib/builder-webpack5/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/lib/builder-webpack5/package.json b/code/lib/builder-webpack5/package.json
index 4e547eb766ab..8777a7d915ec 100644
--- a/code/lib/builder-webpack5/package.json
+++ b/code/lib/builder-webpack5/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/builder-webpack5",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook framework-agnostic API",
"keywords": [
"storybook"
@@ -25,15 +25,15 @@
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
- "./presets/custom-webpack-preset.js": {
- "require": "./presets/custom-webpack-preset.js",
- "import": "./presets/custom-webpack-preset.mjs",
- "types": "./presets/custom-webpack-preset.d.ts"
+ "./presets/custom-webpack-preset": {
+ "require": "./dist/presets/custom-webpack-preset.js",
+ "import": "./dist/presets/custom-webpack-preset.mjs",
+ "types": "./dist/presets/custom-webpack-preset.d.ts"
},
- "./presets/preview-preset.js": {
- "require": "./presets/preview-preset.js",
- "import": "./presets/preview-preset.mjs",
- "types": "./presets/preview-preset.d.ts"
+ "./presets/preview-preset": {
+ "require": "./dist/presets/preview-preset.js",
+ "import": "./dist/presets/preview-preset.mjs",
+ "types": "./dist/presets/preview-preset.d.ts"
},
"./templates/virtualModuleModernEntry.js.handlebars": "./templates/virtualModuleModernEntry.js.handlebars",
"./package.json": "./package.json"
@@ -52,26 +52,26 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@babel/core": "^7.12.10",
- "@storybook/addons": "7.0.0-alpha.48",
- "@storybook/api": "7.0.0-alpha.48",
- "@storybook/channel-postmessage": "7.0.0-alpha.48",
- "@storybook/channel-websocket": "7.0.0-alpha.48",
- "@storybook/channels": "7.0.0-alpha.48",
- "@storybook/client-api": "7.0.0-alpha.48",
- "@storybook/client-logger": "7.0.0-alpha.48",
- "@storybook/components": "7.0.0-alpha.48",
- "@storybook/core-common": "7.0.0-alpha.48",
- "@storybook/core-events": "7.0.0-alpha.48",
- "@storybook/core-webpack": "7.0.0-alpha.48",
- "@storybook/node-logger": "7.0.0-alpha.48",
- "@storybook/preview-web": "7.0.0-alpha.48",
- "@storybook/router": "7.0.0-alpha.48",
- "@storybook/store": "7.0.0-alpha.48",
- "@storybook/theming": "7.0.0-alpha.48",
- "@types/node": "^16.0.0",
+ "@babel/core": "^7.20.2",
+ "@storybook/addons": "7.0.0-alpha.51",
+ "@storybook/api": "7.0.0-alpha.51",
+ "@storybook/channel-postmessage": "7.0.0-alpha.51",
+ "@storybook/channel-websocket": "7.0.0-alpha.51",
+ "@storybook/channels": "7.0.0-alpha.51",
+ "@storybook/client-api": "7.0.0-alpha.51",
+ "@storybook/client-logger": "7.0.0-alpha.51",
+ "@storybook/components": "7.0.0-alpha.51",
+ "@storybook/core-common": "7.0.0-alpha.51",
+ "@storybook/core-events": "7.0.0-alpha.51",
+ "@storybook/core-webpack": "7.0.0-alpha.51",
+ "@storybook/node-logger": "7.0.0-alpha.51",
+ "@storybook/preview-web": "7.0.0-alpha.51",
+ "@storybook/router": "7.0.0-alpha.51",
+ "@storybook/store": "7.0.0-alpha.51",
+ "@storybook/theming": "7.0.0-alpha.51",
+ "@types/node": "^16.0.0 || ^18.0.0",
"@types/semver": "^7.3.4",
- "babel-loader": "^8.2.5",
+ "babel-loader": "^8.3.0",
"babel-plugin-named-exports-order": "^0.0.2",
"browser-assert": "^1.2.1",
"case-sensitive-paths-webpack-plugin": "^2.4.0",
@@ -93,12 +93,11 @@
"webpack-virtual-modules": "^0.4.3"
},
"devDependencies": {
- "@types/case-sensitive-paths-webpack-plugin": "^2.1.6",
"@types/terser-webpack-plugin": "^5.2.0",
"@types/webpack-dev-middleware": "^5.3.0",
"@types/webpack-hot-middleware": "^2.25.6",
"@types/webpack-virtual-modules": "^0.1.1",
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
@@ -120,5 +119,5 @@
],
"platform": "node"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
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 ac29c5ad5d95..78dedb2d0df9 100644
--- a/code/lib/builder-webpack5/src/preview/iframe-webpack.config.ts
+++ b/code/lib/builder-webpack5/src/preview/iframe-webpack.config.ts
@@ -2,12 +2,13 @@ import path from 'path';
import { DefinePlugin, HotModuleReplacementPlugin, ProgressPlugin, ProvidePlugin } from 'webpack';
import type { Configuration } from 'webpack';
import HtmlWebpackPlugin from 'html-webpack-plugin';
+// @ts-expect-error (I removed this on purpose, because it's incorrect)
import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin';
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/types';
+import type { Options, CoreConfig, DocsOptions, PreviewAnnotation } from '@storybook/types';
import {
getRendererName,
stringifyProcessEnvs,
@@ -82,7 +83,18 @@ export default async (
const docsOptions = await presets.apply('docs');
const previewAnnotations = [
- ...(await presets.apply('previewAnnotations', [], options)),
+ ...(await presets.apply('previewAnnotations', [], options)).map(
+ (entry) => {
+ // If entry is an object, use the absolute import specifier.
+ // This is to maintain back-compat with community addons that bundle other addons
+ // and package managers that "hide" sub dependencies (e.g. pnpm / yarn pnp)
+ // The vite builder uses the bare import specifier.
+ if (typeof entry === 'object') {
+ return entry.absolute;
+ }
+ return entry;
+ }
+ ),
loadPreviewOrConfigFile(options),
].filter(Boolean);
const entries = (await presets.apply('entries', [], options)) as string[];
diff --git a/code/lib/builder-webpack5/tsconfig.json b/code/lib/builder-webpack5/tsconfig.json
index de98a048bdd5..5b3f3a56a68d 100644
--- a/code/lib/builder-webpack5/tsconfig.json
+++ b/code/lib/builder-webpack5/tsconfig.json
@@ -4,6 +4,5 @@
"strict": true,
"skipLibCheck": true
},
- "include": ["src/**/*", "typings.d.ts", "templates/virtualModuleEntry.template.js"],
- "exclude": ["src/**.test.ts"]
+ "include": ["src/**/*"]
}
diff --git a/code/lib/channel-postmessage/jest.config.js b/code/lib/channel-postmessage/jest.config.js
new file mode 100644
index 000000000000..4396fbc7010d
--- /dev/null
+++ b/code/lib/channel-postmessage/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.browser');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/lib/channel-postmessage/package.json b/code/lib/channel-postmessage/package.json
index 1b676a31d54f..42cd02e500be 100644
--- a/code/lib/channel-postmessage/package.json
+++ b/code/lib/channel-postmessage/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/channel-postmessage",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "",
"keywords": [
"storybook"
@@ -42,15 +42,15 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/channels": "7.0.0-alpha.48",
- "@storybook/client-logger": "7.0.0-alpha.48",
- "@storybook/core-events": "7.0.0-alpha.48",
+ "@storybook/channels": "7.0.0-alpha.51",
+ "@storybook/client-logger": "7.0.0-alpha.51",
+ "@storybook/core-events": "7.0.0-alpha.51",
"global": "^4.4.0",
"qs": "^6.10.0",
"telejson": "^6.0.8"
},
"devDependencies": {
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"publishConfig": {
"access": "public"
@@ -60,5 +60,5 @@
"./src/index.ts"
]
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/lib/channel-postmessage/tsconfig.json b/code/lib/channel-postmessage/tsconfig.json
index d23f9a406fc2..52d43eaaa9b9 100644
--- a/code/lib/channel-postmessage/tsconfig.json
+++ b/code/lib/channel-postmessage/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/lib/channel-websocket/jest.config.js b/code/lib/channel-websocket/jest.config.js
new file mode 100644
index 000000000000..4396fbc7010d
--- /dev/null
+++ b/code/lib/channel-websocket/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.browser');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/lib/channel-websocket/package.json b/code/lib/channel-websocket/package.json
index 7372527e2a85..b764c37825f2 100644
--- a/code/lib/channel-websocket/package.json
+++ b/code/lib/channel-websocket/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/channel-websocket",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "",
"keywords": [
"storybook"
@@ -20,9 +20,17 @@
},
"license": "MIT",
"sideEffects": false,
- "main": "dist/cjs/index.js",
- "module": "dist/esm/index.js",
- "types": "dist/types/index.d.ts",
+ "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",
@@ -31,19 +39,24 @@
],
"scripts": {
"check": "../../../scripts/node_modules/.bin/tsc --noEmit",
- "prep": "node ../../../scripts/prepare.js"
+ "prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/channels": "7.0.0-alpha.48",
- "@storybook/client-logger": "7.0.0-alpha.48",
+ "@storybook/channels": "7.0.0-alpha.51",
+ "@storybook/client-logger": "7.0.0-alpha.51",
"global": "^4.4.0",
"telejson": "^6.0.8"
},
"devDependencies": {
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"publishConfig": {
"access": "public"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "bundler": {
+ "entries": [
+ "./src/index.ts"
+ ]
+ },
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/lib/channel-websocket/tsconfig.json b/code/lib/channel-websocket/tsconfig.json
index d23f9a406fc2..52d43eaaa9b9 100644
--- a/code/lib/channel-websocket/tsconfig.json
+++ b/code/lib/channel-websocket/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/lib/channels/jest.config.js b/code/lib/channels/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/lib/channels/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/lib/channels/package.json b/code/lib/channels/package.json
index 9518d25fee5d..d9c87671b88a 100644
--- a/code/lib/channels/package.json
+++ b/code/lib/channels/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/channels",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "",
"keywords": [
"storybook"
@@ -42,7 +42,7 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"devDependencies": {
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"publishConfig": {
"access": "public"
@@ -52,5 +52,5 @@
"./src/index.ts"
]
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/lib/channels/tsconfig.json b/code/lib/channels/tsconfig.json
index d23f9a406fc2..52d43eaaa9b9 100644
--- a/code/lib/channels/tsconfig.json
+++ b/code/lib/channels/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/lib/cli-sb/jest.config.js b/code/lib/cli-sb/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/lib/cli-sb/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/lib/cli-sb/package.json b/code/lib/cli-sb/package.json
index 6bf000d0e72c..d190a11a5730 100644
--- a/code/lib/cli-sb/package.json
+++ b/code/lib/cli-sb/package.json
@@ -1,6 +1,6 @@
{
"name": "sb",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook CLI",
"keywords": [
"storybook"
@@ -24,13 +24,13 @@
"prep": "node ../../../scripts/prepare.js"
},
"dependencies": {
- "@storybook/cli": "7.0.0-alpha.48"
+ "@storybook/cli": "7.0.0-alpha.51"
},
"devDependencies": {
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"publishConfig": {
"access": "public"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/lib/cli-storybook/jest.config.js b/code/lib/cli-storybook/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/lib/cli-storybook/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/lib/cli-storybook/package.json b/code/lib/cli-storybook/package.json
index 484cef2424ec..0e2e705cc01c 100644
--- a/code/lib/cli-storybook/package.json
+++ b/code/lib/cli-storybook/package.json
@@ -1,6 +1,6 @@
{
"name": "storybook",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook CLI",
"keywords": [
"storybook"
@@ -27,13 +27,13 @@
"prep": "node ../../../scripts/prepare.js"
},
"dependencies": {
- "@storybook/cli": "7.0.0-alpha.48"
+ "@storybook/cli": "7.0.0-alpha.51"
},
"devDependencies": {
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"publishConfig": {
"access": "public"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/lib/cli/jest.config.js b/code/lib/cli/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/lib/cli/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/lib/cli/package.json b/code/lib/cli/package.json
index 651e93c0d66d..a88039fca170 100644
--- a/code/lib/cli/package.json
+++ b/code/lib/cli/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/cli",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook's CLI - easiest method of adding storybook to your projects",
"keywords": [
"cli",
@@ -41,21 +41,20 @@
"test": "jest test/**/*.test.js"
},
"dependencies": {
- "@babel/core": "^7.12.10",
- "@babel/preset-env": "^7.12.11",
- "@storybook/codemod": "7.0.0-alpha.48",
- "@storybook/core-common": "7.0.0-alpha.48",
- "@storybook/core-server": "7.0.0-alpha.48",
- "@storybook/csf-tools": "7.0.0-alpha.48",
- "@storybook/node-logger": "7.0.0-alpha.48",
- "@storybook/telemetry": "7.0.0-alpha.48",
- "@storybook/types": "7.0.0-alpha.48",
+ "@babel/core": "^7.20.2",
+ "@babel/preset-env": "^7.20.2",
+ "@storybook/codemod": "7.0.0-alpha.51",
+ "@storybook/core-common": "7.0.0-alpha.51",
+ "@storybook/core-server": "7.0.0-alpha.51",
+ "@storybook/csf-tools": "7.0.0-alpha.51",
+ "@storybook/node-logger": "7.0.0-alpha.51",
+ "@storybook/telemetry": "7.0.0-alpha.51",
+ "@storybook/types": "7.0.0-alpha.51",
"@types/semver": "^7.3.4",
"boxen": "^5.1.2",
"chalk": "^4.1.0",
"commander": "^6.2.1",
"cross-spawn": "^7.0.3",
- "degit": "^2.8.4",
"detect-indent": "^6.1.0",
"envinfo": "^7.7.3",
"execa": "^5.0.0",
@@ -63,6 +62,7 @@
"find-up": "^5.0.0",
"fs-extra": "^9.0.1",
"get-port": "^5.1.1",
+ "giget": "^1.0.0",
"globby": "^11.0.2",
"jscodeshift": "^0.13.1",
"leven": "^3.1.0",
@@ -77,9 +77,8 @@
"util-deprecate": "^1.0.2"
},
"devDependencies": {
- "@storybook/client-api": "7.0.0-alpha.48",
+ "@storybook/client-api": "7.0.0-alpha.51",
"@types/cross-spawn": "^6.0.2",
- "@types/degit": "^2.8.3",
"@types/prompts": "^2.0.9",
"@types/puppeteer-core": "^2.1.0",
"@types/semver": "^7.3.4",
@@ -87,7 +86,7 @@
"@types/update-notifier": "^6.0.1",
"@types/util-deprecate": "^1.0.0",
"strip-json-comments": "^3.1.1",
- "typescript": "~4.6.3",
+ "typescript": "^4.9.3",
"update-notifier": "^6.0.2"
},
"publishConfig": {
@@ -99,5 +98,5 @@
],
"platform": "node"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/lib/cli/src/automigrate/fixes/remove-global-client-apis.test.ts b/code/lib/cli/src/automigrate/fixes/remove-global-client-apis.test.ts
index 0dd4419f3639..0ae9971db053 100644
--- a/code/lib/cli/src/automigrate/fixes/remove-global-client-apis.test.ts
+++ b/code/lib/cli/src/automigrate/fixes/remove-global-client-apis.test.ts
@@ -8,7 +8,7 @@ import { RemovedAPIs, removedGlobalClientAPIs as migration } from './remove-glob
// eslint-disable-next-line global-require, jest/no-mocks-import
jest.mock('fs-extra', () => require('../../../../../__mocks__/fs-extra'));
-const check = async ({ packageJson = {}, contents }) => {
+const check = async ({ packageJson = {}, contents }: any) => {
if (contents) {
// eslint-disable-next-line global-require
require('fs-extra').__setMockFiles({
diff --git a/code/lib/cli/src/generate.ts b/code/lib/cli/src/generate.ts
index cd07092f24f9..31ae5ab1e876 100644
--- a/code/lib/cli/src/generate.ts
+++ b/code/lib/cli/src/generate.ts
@@ -161,7 +161,7 @@ program
.command('repro-next [filterValue]')
.description('Create a reproduction from a set of possible templates')
.option('-o --output ', 'Define an output directory')
- .option('-b --branch ', 'Define the branch to degit from', 'next')
+ .option('-b --branch ', 'Define the branch to download from', 'next')
.option('--no-init', 'Whether to download a template without an initialized Storybook', false)
.action((filterValue, options) =>
reproNext({ filterValue, ...options }).catch((e) => {
diff --git a/code/lib/cli/src/helpers.test.ts b/code/lib/cli/src/helpers.test.ts
index dbc6760c0809..c53cbf3a9d97 100644
--- a/code/lib/cli/src/helpers.test.ts
+++ b/code/lib/cli/src/helpers.test.ts
@@ -9,7 +9,7 @@ jest.mock('fs', () => ({
existsSync: jest.fn(),
}));
jest.mock('./dirs', () => ({
- getRendererDir: (renderer) => `@storybook/${renderer}`,
+ getRendererDir: (renderer: string) => `@storybook/${renderer}`,
getCliDir: () => '@storybook/cli',
}));
diff --git a/code/lib/cli/src/helpers.ts b/code/lib/cli/src/helpers.ts
index 00ebb767831f..53bfc848077d 100644
--- a/code/lib/cli/src/helpers.ts
+++ b/code/lib/cli/src/helpers.ts
@@ -198,6 +198,7 @@ export async function copyComponents(
const componentsPath = async () => {
const baseDir = getRendererDir(renderer);
const assetsDir = join(baseDir, 'template/cli');
+
const assetsLanguage = join(assetsDir, languageFolderMapping[language]);
const assetsJS = join(assetsDir, languageFolderMapping[SupportedLanguage.JAVASCRIPT]);
const assetsTSLegacy = join(
@@ -232,7 +233,9 @@ export async function copyComponents(
};
const destinationPath = await targetPath();
- await fse.copy(join(getCliDir(), 'rendererAssets/common'), destinationPath, { overwrite: true });
+ await fse.copy(join(getCliDir(), 'rendererAssets/common'), destinationPath, {
+ overwrite: true,
+ });
await fse.copy(await componentsPath(), destinationPath, { overwrite: true });
}
diff --git a/code/lib/cli/src/js-package-manager/PNPMProxy.test.ts b/code/lib/cli/src/js-package-manager/PNPMProxy.test.ts
index 17ebaffad8b2..66e50ab6d9fd 100644
--- a/code/lib/cli/src/js-package-manager/PNPMProxy.test.ts
+++ b/code/lib/cli/src/js-package-manager/PNPMProxy.test.ts
@@ -181,6 +181,7 @@ describe('NPM Proxy', () => {
const writePackageSpy = jest.spyOn(pnpmProxy, 'writePackageJson').mockImplementation(jest.fn);
jest.spyOn(pnpmProxy, 'retrievePackageJson').mockImplementation(
+ // @ts-expect-error (not strict)
jest.fn(() => ({
overrides: {
bar: 'x.x.x',
diff --git a/code/lib/cli/src/repro-generators/configs.ts b/code/lib/cli/src/repro-generators/configs.ts
index cf9f3b917706..3a2194c152be 100644
--- a/code/lib/cli/src/repro-generators/configs.ts
+++ b/code/lib/cli/src/repro-generators/configs.ts
@@ -264,5 +264,5 @@ export const svelte: Parameters = {
renderer: 'svelte',
name: 'svelte',
version: 'latest',
- generator: 'npx degit sveltejs/template {{appName}}',
+ generator: 'npx giget github:sveltejs/template#master {{appName}}',
};
diff --git a/code/lib/cli/src/repro-next.ts b/code/lib/cli/src/repro-next.ts
index 2c118507d068..d1a75a13ba6b 100644
--- a/code/lib/cli/src/repro-next.ts
+++ b/code/lib/cli/src/repro-next.ts
@@ -3,7 +3,7 @@ import path from 'path';
import chalk from 'chalk';
import boxen from 'boxen';
import { dedent } from 'ts-dedent';
-import degit from 'degit';
+import { downloadTemplate } from 'giget';
import { existsSync } from 'fs-extra';
import { allTemplates as TEMPLATES } from './repro-templates';
@@ -137,12 +137,13 @@ export const reproNext = async ({
try {
const templateType = init ? 'after-storybook' : 'before-storybook';
// Download the repro based on subfolder "after-storybook" and selected branch
- await degit(
- `storybookjs/repro-templates-temp/${selectedTemplate}/${templateType}#${branch}`,
+ await downloadTemplate(
+ `github:storybookjs/repro-templates-temp/${selectedTemplate}/${templateType}#${branch}`,
{
force: true,
+ dir: templateDestination,
}
- ).clone(templateDestination);
+ );
} catch (err) {
logger.error(`🚨 Failed to download repro template: ${err.message}`);
throw err;
diff --git a/code/lib/cli/src/repro-templates.ts b/code/lib/cli/src/repro-templates.ts
index 1cfad2991091..9027de5f4203 100644
--- a/code/lib/cli/src/repro-templates.ts
+++ b/code/lib/cli/src/repro-templates.ts
@@ -2,6 +2,7 @@ export const allTemplates = {
'cra/default-js': {
name: 'Create React App (Javascript)',
script: 'npx create-react-app .',
+ inDevelopment: true,
expected: {
// TODO: change this to @storybook/cra once that package is created
framework: '@storybook/react-webpack5',
@@ -141,6 +142,17 @@ export const allTemplates = {
name: 'Angular CLI (latest)',
script:
'npx -p @angular/cli ng new angular-latest --directory . --routing=true --minimal=true --style=scss --strict --skip-git --skip-install --package-manager=yarn',
+ skipTasks: ['test-runner'],
+ expected: {
+ framework: '@storybook/angular',
+ renderer: '@storybook/angular',
+ builder: '@storybook/builder-webpack5',
+ },
+ },
+ 'angular-cli/14-ts': {
+ name: 'Angular CLI (Version 14)',
+ script:
+ 'npx -p @angular/cli@14 ng new angular-v14 --directory . --routing=true --minimal=true --style=scss --strict --skip-git --skip-install --package-manager=yarn',
expected: {
framework: '@storybook/angular',
renderer: '@storybook/angular',
@@ -251,7 +263,8 @@ type TemplateKey = keyof typeof allTemplates;
export const ci: TemplateKey[] = ['cra/default-ts', 'react-vite/default-ts'];
export const pr: TemplateKey[] = [
...ci,
- 'angular-cli/default-ts',
+ // TODO: swap with 'angular-cli/default-ts' once angular 15 fully works with Storybook
+ 'angular-cli/14-ts',
'vue3-vite/default-ts',
'vue-cli/vue2-default-js',
'lit-vite/default-ts',
@@ -263,6 +276,7 @@ export const merged: TemplateKey[] = [
...pr,
'react-webpack/18-ts',
'react-webpack/17-ts',
+ 'angular-cli/default-ts',
'angular-cli/13-ts',
'preact-webpack5/default-ts',
'html-webpack/default',
diff --git a/code/lib/cli/src/versions.ts b/code/lib/cli/src/versions.ts
index c00a272d65e2..3874f63135d8 100644
--- a/code/lib/cli/src/versions.ts
+++ b/code/lib/cli/src/versions.ts
@@ -1,85 +1,85 @@
// auto generated file, do not edit
export default {
- '@storybook/addon-a11y': '7.0.0-alpha.48',
- '@storybook/addon-actions': '7.0.0-alpha.48',
- '@storybook/addon-backgrounds': '7.0.0-alpha.48',
- '@storybook/addon-controls': '7.0.0-alpha.48',
- '@storybook/addon-docs': '7.0.0-alpha.48',
- '@storybook/addon-essentials': '7.0.0-alpha.48',
- '@storybook/addon-highlight': '7.0.0-alpha.48',
- '@storybook/addon-interactions': '7.0.0-alpha.48',
- '@storybook/addon-jest': '7.0.0-alpha.48',
- '@storybook/addon-links': '7.0.0-alpha.48',
- '@storybook/addon-measure': '7.0.0-alpha.48',
- '@storybook/addon-outline': '7.0.0-alpha.48',
- '@storybook/addon-storyshots': '7.0.0-alpha.48',
- '@storybook/addon-storyshots-puppeteer': '7.0.0-alpha.48',
- '@storybook/addon-storysource': '7.0.0-alpha.48',
- '@storybook/addon-toolbars': '7.0.0-alpha.48',
- '@storybook/addon-viewport': '7.0.0-alpha.48',
- '@storybook/addons': '7.0.0-alpha.48',
- '@storybook/angular': '7.0.0-alpha.48',
- '@storybook/api': '7.0.0-alpha.48',
- '@storybook/blocks': '7.0.0-alpha.48',
- '@storybook/builder-manager': '7.0.0-alpha.48',
- '@storybook/builder-vite': '7.0.0-alpha.48',
- '@storybook/builder-webpack5': '7.0.0-alpha.48',
- '@storybook/channel-postmessage': '7.0.0-alpha.48',
- '@storybook/channel-websocket': '7.0.0-alpha.48',
- '@storybook/channels': '7.0.0-alpha.48',
- '@storybook/cli': '7.0.0-alpha.48',
- '@storybook/client-api': '7.0.0-alpha.48',
- '@storybook/client-logger': '7.0.0-alpha.48',
- '@storybook/codemod': '7.0.0-alpha.48',
- '@storybook/components': '7.0.0-alpha.48',
- '@storybook/core-client': '7.0.0-alpha.48',
- '@storybook/core-common': '7.0.0-alpha.48',
- '@storybook/core-events': '7.0.0-alpha.48',
- '@storybook/core-server': '7.0.0-alpha.48',
- '@storybook/core-webpack': '7.0.0-alpha.48',
- '@storybook/csf-tools': '7.0.0-alpha.48',
- '@storybook/docs-tools': '7.0.0-alpha.48',
- '@storybook/ember': '7.0.0-alpha.48',
- '@storybook/html': '7.0.0-alpha.48',
- '@storybook/html-webpack5': '7.0.0-alpha.48',
- '@storybook/instrumenter': '7.0.0-alpha.48',
- '@storybook/nextjs': '7.0.0-alpha.48',
- '@storybook/node-logger': '7.0.0-alpha.48',
- '@storybook/postinstall': '7.0.0-alpha.48',
- '@storybook/preact': '7.0.0-alpha.48',
- '@storybook/preact-webpack5': '7.0.0-alpha.48',
- '@storybook/preset-html-webpack': '7.0.0-alpha.48',
- '@storybook/preset-preact-webpack': '7.0.0-alpha.48',
- '@storybook/preset-react-webpack': '7.0.0-alpha.48',
- '@storybook/preset-server-webpack': '7.0.0-alpha.48',
- '@storybook/preset-svelte-webpack': '7.0.0-alpha.48',
- '@storybook/preset-vue-webpack': '7.0.0-alpha.48',
- '@storybook/preset-vue3-webpack': '7.0.0-alpha.48',
- '@storybook/preset-web-components-webpack': '7.0.0-alpha.48',
- '@storybook/preview-web': '7.0.0-alpha.48',
- '@storybook/react': '7.0.0-alpha.48',
- '@storybook/react-vite': '7.0.0-alpha.48',
- '@storybook/react-webpack5': '7.0.0-alpha.48',
- '@storybook/router': '7.0.0-alpha.48',
- '@storybook/server': '7.0.0-alpha.48',
- '@storybook/server-webpack5': '7.0.0-alpha.48',
- '@storybook/source-loader': '7.0.0-alpha.48',
- '@storybook/store': '7.0.0-alpha.48',
- '@storybook/svelte': '7.0.0-alpha.48',
- '@storybook/svelte-vite': '7.0.0-alpha.48',
- '@storybook/svelte-webpack5': '7.0.0-alpha.48',
- '@storybook/telemetry': '7.0.0-alpha.48',
- '@storybook/theming': '7.0.0-alpha.48',
- '@storybook/manager': '7.0.0-alpha.48',
- '@storybook/vue': '7.0.0-alpha.48',
- '@storybook/vue-vite': '7.0.0-alpha.48',
- '@storybook/vue-webpack5': '7.0.0-alpha.48',
- '@storybook/vue3': '7.0.0-alpha.48',
- '@storybook/vue3-vite': '7.0.0-alpha.48',
- '@storybook/vue3-webpack5': '7.0.0-alpha.48',
- '@storybook/web-components': '7.0.0-alpha.48',
- '@storybook/web-components-webpack5': '7.0.0-alpha.48',
- '@storybook/web-components-vite': '7.0.0-alpha.48',
- sb: '7.0.0-alpha.48',
- storybook: '7.0.0-alpha.48',
+ '@storybook/addon-a11y': '7.0.0-alpha.51',
+ '@storybook/addon-actions': '7.0.0-alpha.51',
+ '@storybook/addon-backgrounds': '7.0.0-alpha.51',
+ '@storybook/addon-controls': '7.0.0-alpha.51',
+ '@storybook/addon-docs': '7.0.0-alpha.51',
+ '@storybook/addon-essentials': '7.0.0-alpha.51',
+ '@storybook/addon-highlight': '7.0.0-alpha.51',
+ '@storybook/addon-interactions': '7.0.0-alpha.51',
+ '@storybook/addon-jest': '7.0.0-alpha.51',
+ '@storybook/addon-links': '7.0.0-alpha.51',
+ '@storybook/addon-measure': '7.0.0-alpha.51',
+ '@storybook/addon-outline': '7.0.0-alpha.51',
+ '@storybook/addon-storyshots': '7.0.0-alpha.51',
+ '@storybook/addon-storyshots-puppeteer': '7.0.0-alpha.51',
+ '@storybook/addon-storysource': '7.0.0-alpha.51',
+ '@storybook/addon-toolbars': '7.0.0-alpha.51',
+ '@storybook/addon-viewport': '7.0.0-alpha.51',
+ '@storybook/addons': '7.0.0-alpha.51',
+ '@storybook/angular': '7.0.0-alpha.51',
+ '@storybook/api': '7.0.0-alpha.51',
+ '@storybook/blocks': '7.0.0-alpha.51',
+ '@storybook/builder-manager': '7.0.0-alpha.51',
+ '@storybook/builder-vite': '7.0.0-alpha.51',
+ '@storybook/builder-webpack5': '7.0.0-alpha.51',
+ '@storybook/channel-postmessage': '7.0.0-alpha.51',
+ '@storybook/channel-websocket': '7.0.0-alpha.51',
+ '@storybook/channels': '7.0.0-alpha.51',
+ '@storybook/cli': '7.0.0-alpha.51',
+ '@storybook/client-api': '7.0.0-alpha.51',
+ '@storybook/client-logger': '7.0.0-alpha.51',
+ '@storybook/codemod': '7.0.0-alpha.51',
+ '@storybook/components': '7.0.0-alpha.51',
+ '@storybook/core-client': '7.0.0-alpha.51',
+ '@storybook/core-common': '7.0.0-alpha.51',
+ '@storybook/core-events': '7.0.0-alpha.51',
+ '@storybook/core-server': '7.0.0-alpha.51',
+ '@storybook/core-webpack': '7.0.0-alpha.51',
+ '@storybook/csf-tools': '7.0.0-alpha.51',
+ '@storybook/docs-tools': '7.0.0-alpha.51',
+ '@storybook/ember': '7.0.0-alpha.51',
+ '@storybook/html': '7.0.0-alpha.51',
+ '@storybook/html-webpack5': '7.0.0-alpha.51',
+ '@storybook/instrumenter': '7.0.0-alpha.51',
+ '@storybook/nextjs': '7.0.0-alpha.51',
+ '@storybook/node-logger': '7.0.0-alpha.51',
+ '@storybook/postinstall': '7.0.0-alpha.51',
+ '@storybook/preact': '7.0.0-alpha.51',
+ '@storybook/preact-webpack5': '7.0.0-alpha.51',
+ '@storybook/preset-html-webpack': '7.0.0-alpha.51',
+ '@storybook/preset-preact-webpack': '7.0.0-alpha.51',
+ '@storybook/preset-react-webpack': '7.0.0-alpha.51',
+ '@storybook/preset-server-webpack': '7.0.0-alpha.51',
+ '@storybook/preset-svelte-webpack': '7.0.0-alpha.51',
+ '@storybook/preset-vue-webpack': '7.0.0-alpha.51',
+ '@storybook/preset-vue3-webpack': '7.0.0-alpha.51',
+ '@storybook/preset-web-components-webpack': '7.0.0-alpha.51',
+ '@storybook/preview-web': '7.0.0-alpha.51',
+ '@storybook/react': '7.0.0-alpha.51',
+ '@storybook/react-vite': '7.0.0-alpha.51',
+ '@storybook/react-webpack5': '7.0.0-alpha.51',
+ '@storybook/router': '7.0.0-alpha.51',
+ '@storybook/server': '7.0.0-alpha.51',
+ '@storybook/server-webpack5': '7.0.0-alpha.51',
+ '@storybook/source-loader': '7.0.0-alpha.51',
+ '@storybook/store': '7.0.0-alpha.51',
+ '@storybook/svelte': '7.0.0-alpha.51',
+ '@storybook/svelte-vite': '7.0.0-alpha.51',
+ '@storybook/svelte-webpack5': '7.0.0-alpha.51',
+ '@storybook/telemetry': '7.0.0-alpha.51',
+ '@storybook/theming': '7.0.0-alpha.51',
+ '@storybook/manager': '7.0.0-alpha.51',
+ '@storybook/vue': '7.0.0-alpha.51',
+ '@storybook/vue-vite': '7.0.0-alpha.51',
+ '@storybook/vue-webpack5': '7.0.0-alpha.51',
+ '@storybook/vue3': '7.0.0-alpha.51',
+ '@storybook/vue3-vite': '7.0.0-alpha.51',
+ '@storybook/vue3-webpack5': '7.0.0-alpha.51',
+ '@storybook/web-components': '7.0.0-alpha.51',
+ '@storybook/web-components-webpack5': '7.0.0-alpha.51',
+ '@storybook/web-components-vite': '7.0.0-alpha.51',
+ sb: '7.0.0-alpha.51',
+ storybook: '7.0.0-alpha.51',
};
diff --git a/code/lib/cli/src/window.d.ts b/code/lib/cli/src/window.d.ts
index 0adbb33da3b6..7a5da303ea67 100644
--- a/code/lib/cli/src/window.d.ts
+++ b/code/lib/cli/src/window.d.ts
@@ -1,8 +1,8 @@
-import type { Framework } from '@storybook/types';
+import type { Renderer } from '@storybook/types';
import type { StoryStore } from '@storybook/client-api';
declare global {
interface Window {
- __STORYBOOK_STORY_STORE__: StoryStore;
+ __STORYBOOK_STORY_STORE__: StoryStore;
}
}
diff --git a/code/lib/cli/tsconfig.json b/code/lib/cli/tsconfig.json
index 0521e258ae2f..b0f65014db55 100644
--- a/code/lib/cli/tsconfig.json
+++ b/code/lib/cli/tsconfig.json
@@ -7,6 +7,5 @@
"strictNullChecks": false,
"resolveJsonModule": true
},
- "include": ["src/**/*"],
- "exclude": ["templates/**/**", "**/*.test.*", "src/frameworks/**/*"]
+ "include": ["src/**/*"]
}
diff --git a/code/lib/client-api/jest.config.js b/code/lib/client-api/jest.config.js
new file mode 100644
index 000000000000..4396fbc7010d
--- /dev/null
+++ b/code/lib/client-api/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.browser');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/lib/client-api/package.json b/code/lib/client-api/package.json
index 26f9f27e31dd..cefa94b7a261 100644
--- a/code/lib/client-api/package.json
+++ b/code/lib/client-api/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/client-api",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook Client API",
"keywords": [
"storybook"
@@ -42,11 +42,11 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/addons": "7.0.0-alpha.48",
- "@storybook/client-logger": "7.0.0-alpha.48",
+ "@storybook/addons": "7.0.0-alpha.51",
+ "@storybook/client-logger": "7.0.0-alpha.51",
"@storybook/csf": "next",
- "@storybook/store": "7.0.0-alpha.48",
- "@storybook/types": "7.0.0-alpha.48",
+ "@storybook/store": "7.0.0-alpha.51",
+ "@storybook/types": "7.0.0-alpha.51",
"@types/qs": "^6.9.5",
"@types/webpack-env": "^1.16.4",
"global": "^4.4.0",
@@ -56,8 +56,8 @@
"util-deprecate": "^1.0.2"
},
"devDependencies": {
- "@storybook/core-common": "7.0.0-alpha.48",
- "typescript": "~4.6.3"
+ "@storybook/core-common": "7.0.0-alpha.51",
+ "typescript": "^4.9.3"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
@@ -71,5 +71,5 @@
"./src/index.ts"
]
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/lib/client-api/src/ClientApi.ts b/code/lib/client-api/src/ClientApi.ts
index b09c69a5ec6f..d0d61f76e177 100644
--- a/code/lib/client-api/src/ClientApi.ts
+++ b/code/lib/client-api/src/ClientApi.ts
@@ -8,7 +8,7 @@ import type {
Args,
StepRunner,
ArgTypes,
- Framework,
+ Renderer,
DecoratorFunction,
Parameters,
ArgTypesEnhancer,
@@ -31,7 +31,7 @@ import { StoryStoreFacade } from './StoryStoreFacade';
// 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;
+let singleton: ClientApi;
const warningAlternatives = {
addDecorator: `Instead, use \`export const decorators = [];\` in your \`preview.js\`.`,
@@ -60,7 +60,7 @@ const checkMethod = (method: keyof typeof warningAlternatives) => {
}
};
-export const addDecorator = (decorator: DecoratorFunction) => {
+export const addDecorator = (decorator: DecoratorFunction) => {
checkMethod('addDecorator');
singleton.addDecorator(decorator);
};
@@ -70,7 +70,7 @@ export const addParameters = (parameters: Parameters) => {
singleton.addParameters(parameters);
};
-export const addLoader = (loader: LoaderFunction) => {
+export const addLoader = (loader: LoaderFunction) => {
checkMethod('addLoader');
singleton.addLoader(loader);
};
@@ -85,12 +85,12 @@ export const addArgTypes = (argTypes: ArgTypes) => {
singleton.addArgTypes(argTypes);
};
-export const addArgsEnhancer = (enhancer: ArgsEnhancer) => {
+export const addArgsEnhancer = (enhancer: ArgsEnhancer) => {
checkMethod('addArgsEnhancer');
singleton.addArgsEnhancer(enhancer);
};
-export const addArgTypesEnhancer = (enhancer: ArgTypesEnhancer) => {
+export const addArgTypesEnhancer = (enhancer: ArgTypesEnhancer) => {
checkMethod('addArgTypesEnhancer');
singleton.addArgTypesEnhancer(enhancer);
};
@@ -105,18 +105,18 @@ export const getGlobalRender = () => {
return singleton.facade.projectAnnotations.render;
};
-export const setGlobalRender = (render: StoryFn) => {
+export const setGlobalRender = (render: StoryFn) => {
checkMethod('setGlobalRender');
singleton.facade.projectAnnotations.render = render;
};
const invalidStoryTypes = new Set(['string', 'number', 'boolean', 'symbol']);
-export class ClientApi {
- facade: StoryStoreFacade;
+export class ClientApi {
+ facade: StoryStoreFacade;
- storyStore?: StoryStore;
+ storyStore?: StoryStore;
- private addons: Addon_ClientApiAddons;
+ private addons: Addon_ClientApiAddons;
onImportFnChanged?: ({ importFn }: { importFn: Store_ModuleImportFn }) => void;
@@ -124,7 +124,7 @@ export class ClientApi {
// just use numeric indexes
private lastFileName = 0;
- constructor({ storyStore }: { storyStore?: StoryStore } = {}) {
+ constructor({ storyStore }: { storyStore?: StoryStore } = {}) {
this.facade = new StoryStoreFacade();
this.addons = {};
@@ -146,7 +146,7 @@ export class ClientApi {
return this.facade.getStoryIndex(this.storyStore);
}
- addDecorator = (decorator: DecoratorFunction) => {
+ addDecorator = (decorator: DecoratorFunction) => {
this.facade.projectAnnotations.decorators.push(decorator);
};
@@ -179,7 +179,7 @@ export class ClientApi {
);
};
- addLoader = (loader: LoaderFunction) => {
+ addLoader = (loader: LoaderFunction) => {
this.facade.projectAnnotations.loaders.push(loader);
};
@@ -197,11 +197,11 @@ export class ClientApi {
};
};
- addArgsEnhancer = (enhancer: ArgsEnhancer) => {
+ addArgsEnhancer = (enhancer: ArgsEnhancer) => {
this.facade.projectAnnotations.argsEnhancers.push(enhancer);
};
- addArgTypesEnhancer = (enhancer: ArgTypesEnhancer) => {
+ addArgTypesEnhancer = (enhancer: ArgTypesEnhancer) => {
this.facade.projectAnnotations.argTypesEnhancers.push(enhancer);
};
@@ -219,7 +219,7 @@ export class ClientApi {
}
// what are the occasions that "m" is a boolean vs an obj
- storiesOf = (kind: string, m?: NodeModule): Addon_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');
}
@@ -275,7 +275,7 @@ export class ClientApi {
}
let hasAdded = false;
- const api: Addon_StoryApi = {
+ const api: Addon_StoryApi = {
kind: kind.toString(),
add: () => api,
addDecorator: () => api,
@@ -292,7 +292,7 @@ export class ClientApi {
};
});
- const meta: Store_NormalizedComponentAnnotations = {
+ const meta: Store_NormalizedComponentAnnotations = {
id: sanitize(kind),
title: kind,
decorators: [],
@@ -304,7 +304,7 @@ export class ClientApi {
this._addedExports[fileName] = { default: meta };
let counter = 0;
- api.add = (storyName: string, storyFn: StoryFn, parameters: Parameters = {}) => {
+ api.add = (storyName: string, storyFn: StoryFn, parameters: Parameters = {}) => {
hasAdded = true;
if (typeof storyName !== 'string') {
@@ -340,7 +340,7 @@ export class ClientApi {
return api;
};
- api.addDecorator = (decorator: DecoratorFunction) => {
+ api.addDecorator = (decorator: DecoratorFunction) => {
if (hasAdded)
throw new Error(`You cannot add a decorator after the first story for a kind.
Read more here: https://github.com/storybookjs/storybook/blob/master/MIGRATION.md#can-no-longer-add-decoratorsparameters-after-stories`);
@@ -349,7 +349,7 @@ Read more here: https://github.com/storybookjs/storybook/blob/master/MIGRATION.m
return api;
};
- api.addLoader = (loader: LoaderFunction) => {
+ api.addLoader = (loader: LoaderFunction) => {
if (hasAdded) throw new Error(`You cannot add a loader after the first story for a kind.`);
meta.loaders.push(loader);
diff --git a/code/lib/client-api/src/StoryStoreFacade.ts b/code/lib/client-api/src/StoryStoreFacade.ts
index a7a1d6c8f1c2..c62c8e2e6c6c 100644
--- a/code/lib/client-api/src/StoryStoreFacade.ts
+++ b/code/lib/client-api/src/StoryStoreFacade.ts
@@ -5,7 +5,7 @@ import { SynchronousPromise } from 'synchronous-promise';
import { toId, isExportStory, storyNameFromExport } from '@storybook/csf';
import type {
Addon_IndexEntry,
- Framework,
+ Renderer,
ComponentId,
DocsOptions,
Parameters,
@@ -21,8 +21,8 @@ import type { StoryStore } from '@storybook/store';
import { userOrAutoTitle, sortStoriesV6 } from '@storybook/store';
import { logger } from '@storybook/client-logger';
-export class StoryStoreFacade {
- projectAnnotations: Store_NormalizedProjectAnnotations;
+export class StoryStoreFacade {
+ projectAnnotations: Store_NormalizedProjectAnnotations;
entries: Record;
@@ -54,22 +54,22 @@ export class StoryStoreFacade {
});
}
- getStoryIndex(store: StoryStore) {
+ getStoryIndex(store: StoryStore) {
const fileNameOrder = Object.keys(this.csfExports);
const storySortParameter = this.projectAnnotations.parameters?.options?.storySort;
const storyEntries = Object.entries(this.entries);
// Add the kind parameters and global parameters to each entry
- const sortableV6: [StoryId, Store_Story, Parameters, Parameters][] =
+ const sortableV6: [StoryId, Store_Story, Parameters, Parameters][] =
storyEntries.map(([storyId, { type, importPath, ...entry }]) => {
const exports = this.csfExports[importPath];
- const csfFile = store.processCSFFileWithCache(
+ const csfFile = store.processCSFFileWithCache(
exports,
importPath,
exports.default.title
);
- let storyLike: Store_Story;
+ let storyLike: Store_Story;
if (type === 'story') {
storyLike = store.storyFromCSFFile({ storyId, csfFile });
} else {
diff --git a/code/lib/client-api/tsconfig.json b/code/lib/client-api/tsconfig.json
index d23f9a406fc2..52d43eaaa9b9 100644
--- a/code/lib/client-api/tsconfig.json
+++ b/code/lib/client-api/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/lib/client-logger/jest.config.js b/code/lib/client-logger/jest.config.js
new file mode 100644
index 000000000000..4396fbc7010d
--- /dev/null
+++ b/code/lib/client-logger/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.browser');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/lib/client-logger/package.json b/code/lib/client-logger/package.json
index ec0ed24068e0..069191d031a0 100644
--- a/code/lib/client-logger/package.json
+++ b/code/lib/client-logger/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/client-logger",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "",
"keywords": [
"storybook"
@@ -45,7 +45,7 @@
"global": "^4.4.0"
},
"devDependencies": {
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"publishConfig": {
"access": "public"
@@ -55,5 +55,5 @@
"./src/index.ts"
]
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/lib/client-logger/tsconfig.json b/code/lib/client-logger/tsconfig.json
index 25de4fbd3e60..a4429176e35f 100644
--- a/code/lib/client-logger/tsconfig.json
+++ b/code/lib/client-logger/tsconfig.json
@@ -3,13 +3,5 @@
"compilerOptions": {
"strict": true
},
- "include": ["src/**/*"],
- "exclude": [
- "src/**/*.test.*",
- "src/**/tests/**/*",
- "src/**/__tests__/**/*",
- "src/**/*.stories.*",
- "src/**/*.mockdata.*",
- "src/**/__testfixtures__/**"
- ]
+ "include": ["src/**/*"]
}
diff --git a/code/lib/codemod/jest.config.js b/code/lib/codemod/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/lib/codemod/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/lib/codemod/package.json b/code/lib/codemod/package.json
index 61a87d4def31..b83654578441 100644
--- a/code/lib/codemod/package.json
+++ b/code/lib/codemod/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/codemod",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "A collection of codemod scripts written with JSCodeshift",
"keywords": [
"storybook"
@@ -37,23 +37,23 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@babel/types": "^7.12.11",
+ "@babel/types": "^7.20.2",
"@storybook/csf": "next",
- "@storybook/csf-tools": "7.0.0-alpha.48",
- "@storybook/node-logger": "7.0.0-alpha.48",
- "@storybook/types": "7.0.0-alpha.48",
+ "@storybook/csf-tools": "7.0.0-alpha.51",
+ "@storybook/node-logger": "7.0.0-alpha.51",
+ "@storybook/types": "7.0.0-alpha.51",
"cross-spawn": "^7.0.3",
"globby": "^11.0.2",
"jscodeshift": "^0.13.1",
"lodash": "^4.17.21",
- "prettier": ">=2.2.1 <=3.0.0",
+ "prettier": "^2.7.1",
"recast": "^0.19.0",
"util": "^0.12.4"
},
"devDependencies": {
- "jest": "^26.6.3",
- "jest-specific-snapshot": "^4.0.0",
- "typescript": "~4.6.3"
+ "jest": "^29.3.1",
+ "jest-specific-snapshot": "^6.0.0",
+ "typescript": "^4.9.3"
},
"publishConfig": {
"access": "public"
@@ -64,5 +64,5 @@
"./src/index.js"
]
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/lib/codemod/src/transforms/__tests__/csf-2-to-3.test.ts b/code/lib/codemod/src/transforms/__tests__/csf-2-to-3.test.ts
index 277ca3d9ac6e..0905da1ea0a2 100644
--- a/code/lib/codemod/src/transforms/__tests__/csf-2-to-3.test.ts
+++ b/code/lib/codemod/src/transforms/__tests__/csf-2-to-3.test.ts
@@ -1,11 +1,10 @@
-import { describe } from '@jest/globals';
+import { describe, it, expect } from '@jest/globals';
import { dedent } from 'ts-dedent';
import _transform from '../csf-2-to-3';
-// @ts-expect-error (Converted from ts-ignore)
expect.addSnapshotSerializer({
print: (val: any) => val,
- test: (val) => true,
+ test: () => true,
});
const jsTransform = (source: string) => _transform({ source }, null, {}).trim();
diff --git a/code/lib/codemod/tsconfig.json b/code/lib/codemod/tsconfig.json
index f8b60c90fdef..cf1e09965901 100644
--- a/code/lib/codemod/tsconfig.json
+++ b/code/lib/codemod/tsconfig.json
@@ -1,13 +1,7 @@
{
"extends": "../../tsconfig.json",
- "compilerOptions": {},
- "include": ["src/**/*"],
- "exclude": [
- "src/**/*.test.*",
- "src/**/tests/**/*",
- "src/**/__tests__/**/*",
- "src/**/*.stories.*",
- "src/**/*.mockdata.*",
- "src/**/__testfixtures__/**"
- ]
+ "compilerOptions": {
+ "skipLibCheck": true
+ },
+ "include": ["src/**/*"]
}
diff --git a/code/lib/core-client/jest.config.js b/code/lib/core-client/jest.config.js
new file mode 100644
index 000000000000..4396fbc7010d
--- /dev/null
+++ b/code/lib/core-client/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.browser');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/lib/core-client/package.json b/code/lib/core-client/package.json
index 33788fffd9fa..0cb253f09187 100644
--- a/code/lib/core-client/package.json
+++ b/code/lib/core-client/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/core-client",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook framework-agnostic API",
"keywords": [
"storybook"
@@ -35,22 +35,22 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/addons": "7.0.0-alpha.48",
- "@storybook/channel-postmessage": "7.0.0-alpha.48",
- "@storybook/channel-websocket": "7.0.0-alpha.48",
- "@storybook/channels": "7.0.0-alpha.48",
- "@storybook/client-api": "7.0.0-alpha.48",
- "@storybook/client-logger": "7.0.0-alpha.48",
- "@storybook/core-events": "7.0.0-alpha.48",
+ "@storybook/addons": "7.0.0-alpha.51",
+ "@storybook/channel-postmessage": "7.0.0-alpha.51",
+ "@storybook/channel-websocket": "7.0.0-alpha.51",
+ "@storybook/channels": "7.0.0-alpha.51",
+ "@storybook/client-api": "7.0.0-alpha.51",
+ "@storybook/client-logger": "7.0.0-alpha.51",
+ "@storybook/core-events": "7.0.0-alpha.51",
"@storybook/csf": "next",
- "@storybook/preview-web": "7.0.0-alpha.48",
- "@storybook/store": "7.0.0-alpha.48",
- "@storybook/types": "7.0.0-alpha.48",
+ "@storybook/preview-web": "7.0.0-alpha.51",
+ "@storybook/store": "7.0.0-alpha.51",
+ "@storybook/types": "7.0.0-alpha.51",
"global": "^4.4.0",
"util-deprecate": "^1.0.2"
},
"devDependencies": {
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"peerDependenciesMeta": {
"typescript": {
@@ -65,5 +65,5 @@
"./src/index.ts"
]
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/lib/core-client/src/PreviewWeb.mockdata.ts b/code/lib/core-client/src/PreviewWeb.mockdata.ts
index e176aecc069c..4bcd742107ea 100644
--- a/code/lib/core-client/src/PreviewWeb.mockdata.ts
+++ b/code/lib/core-client/src/PreviewWeb.mockdata.ts
@@ -173,9 +173,9 @@ export const waitForEvents = (
events.forEach((event) => mockChannel.on(event, listener));
// Don't wait too long
- waitForQuiescence().then(() =>
- reject(new Error(`Event was not emitted in time: ${debugLabel || events}`))
- );
+ waitForQuiescence().then(() => {
+ reject(new Error(`Event was not emitted in time: ${debugLabel || events}`));
+ });
});
};
diff --git a/code/lib/core-client/src/start.test.ts b/code/lib/core-client/src/start.test.ts
index 8d3040025c86..c09ce001b591 100644
--- a/code/lib/core-client/src/start.test.ts
+++ b/code/lib/core-client/src/start.test.ts
@@ -15,7 +15,6 @@ import {
import { start as realStart } from './start';
jest.mock('global', () => ({
- // @ts-expect-error (jest is not happy with this)
...jest.requireActual('global'),
history: { replaceState: jest.fn() },
document: {
diff --git a/code/lib/core-client/src/start.ts b/code/lib/core-client/src/start.ts
index 99e63c7203a3..9c7d69bb5cb1 100644
--- a/code/lib/core-client/src/start.ts
+++ b/code/lib/core-client/src/start.ts
@@ -2,7 +2,7 @@
import global from 'global';
import { ClientApi } from '@storybook/client-api';
import { PreviewWeb } from '@storybook/preview-web';
-import type { Framework, ArgsStoryFn, Loadable, Path, ProjectAnnotations } from '@storybook/types';
+import type { Renderer, ArgsStoryFn, Loadable, Path, ProjectAnnotations } from '@storybook/types';
import { createChannel } from '@storybook/channel-postmessage';
import { addons } from '@storybook/addons';
import { FORCE_RE_RENDER } from '@storybook/core-events';
@@ -15,9 +15,9 @@ const removedApi = (name: string) => () => {
throw new Error(`@storybook/client-api:${name} was removed in storyStoreV7.`);
};
-interface CoreClient_RendererImplementation {
- decorateStory?: ProjectAnnotations['applyDecorators'];
- render?: ArgsStoryFn;
+interface CoreClient_RendererImplementation {
+ decorateStory?: ProjectAnnotations['applyDecorators'];
+ render?: ArgsStoryFn;
}
interface CoreClient_ClientAPIFacade {
@@ -27,19 +27,19 @@ interface CoreClient_ClientAPIFacade {
raw: (...args: any[]) => never;
}
-interface CoreClient_StartReturnValue {
+interface CoreClient_StartReturnValue {
/* deprecated */
forceReRender: () => void;
/* deprecated */
configure: any;
/* deprecated */
- clientApi: ClientApi | CoreClient_ClientAPIFacade;
+ clientApi: ClientApi | CoreClient_ClientAPIFacade;
}
-export function start(
- renderToCanvas: ProjectAnnotations['renderToCanvas'],
- { decorateStory, render }: CoreClient_RendererImplementation = {}
-): CoreClient_StartReturnValue {
+export function start(
+ renderToCanvas: ProjectAnnotations['renderToCanvas'],
+ { decorateStory, render }: CoreClient_RendererImplementation = {}
+): CoreClient_StartReturnValue {
if (globalWindow) {
// To enable user code to detect if it is running in Storybook
globalWindow.IS_STORYBOOK = true;
@@ -59,8 +59,8 @@ export function start(
const channel = createChannel({ page: 'preview' });
addons.setChannel(channel);
- const clientApi = new ClientApi();
- const preview = new PreviewWeb();
+ const clientApi = new ClientApi();
+ const preview = new PreviewWeb();
let initialized = false;
const importFn = (path: Path) => clientApi.importFn(path);
diff --git a/code/lib/core-client/tsconfig.json b/code/lib/core-client/tsconfig.json
index 053f1bdbcc37..49e844294dce 100644
--- a/code/lib/core-client/tsconfig.json
+++ b/code/lib/core-client/tsconfig.json
@@ -1,5 +1,4 @@
{
"extends": "../../tsconfig.json",
- "include": ["src/**/*", "typings.d.ts"],
- "exclude": []
+ "include": ["src/**/*", "typings.d.ts"]
}
diff --git a/code/lib/core-common/jest.config.js b/code/lib/core-common/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/lib/core-common/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/lib/core-common/package.json b/code/lib/core-common/package.json
index 78bf96fe271c..22a11e36a78c 100644
--- a/code/lib/core-common/package.json
+++ b/code/lib/core-common/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/core-common",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook framework-agnostic API",
"keywords": [
"storybook"
@@ -46,12 +46,12 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@babel/core": "^7.12.10",
- "@storybook/node-logger": "7.0.0-alpha.48",
- "@storybook/types": "7.0.0-alpha.48",
- "@types/babel__core": "^7.0.0",
+ "@babel/core": "^7.20.2",
+ "@storybook/node-logger": "7.0.0-alpha.51",
+ "@storybook/types": "7.0.0-alpha.51",
+ "@types/babel__core": "^7.1.20",
"@types/express": "^4.7.0",
- "@types/node": "^16.0.0",
+ "@types/node": "^16.0.0 || ^18.0.0",
"@types/pretty-hrtime": "^1.0.0",
"chalk": "^4.1.0",
"esbuild": "^0.14.48",
@@ -73,11 +73,11 @@
"util-deprecate": "^1.0.2"
},
"devDependencies": {
- "@types/mock-fs": "^4.13.0",
+ "@types/mock-fs": "^4.13.1",
"@types/picomatch": "^2.3.0",
- "mock-fs": "^4.13.0",
- "type-fest": "^2.17.0",
- "typescript": "~4.6.3"
+ "mock-fs": "^5.2.0",
+ "type-fest": "^2.19.0",
+ "typescript": "^4.9.3"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
@@ -97,5 +97,5 @@
],
"platform": "node"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/lib/core-common/src/presets.test.ts b/code/lib/core-common/src/presets.test.ts
index 76749c0ee2d6..f9829c286db6 100644
--- a/code/lib/core-common/src/presets.test.ts
+++ b/code/lib/core-common/src/presets.test.ts
@@ -1,3 +1,5 @@
+import './presets';
+
function wrapPreset(basePresets: any): { babel: Function; webpack: Function } {
return {
babel: async (config: any, args: any) => basePresets.apply('babel', config, args),
diff --git a/code/lib/core-common/src/presets.ts b/code/lib/core-common/src/presets.ts
index 2ab9fd3bdc1e..7a3f2ba529ff 100644
--- a/code/lib/core-common/src/presets.ts
+++ b/code/lib/core-common/src/presets.ts
@@ -1,6 +1,5 @@
import { dedent } from 'ts-dedent';
import { logger } from '@storybook/node-logger';
-import { dirname } from 'path';
import type {
BuilderOptions,
CLIOptions,
@@ -82,35 +81,26 @@ export const resolveAddonName = (
}
}
- const absolutePackageJson = resolved && resolve(`${name}/package.json`);
-
- // We want to absolutize the package name part to a path on disk
- // (i.e. '/Users/foo/.../node_modules/@addons/foo') as otherwise
- // we may not be able to import the package in certain module systems (eg. pnpm, yarn pnp)
- const absoluteDir = absolutePackageJson && dirname(absolutePackageJson);
-
- // If the package has an export (e.g. `/preview`), absolutize it, eg. to
- // /Users/foo/.../node_modules/@addons/foo/preview
- // NOTE: this looks like the path of an absolute file, but it DOES NOT exist.
- // - However it is importable by webpack.
- // - Vite needs to strip off the absolute part to import it though
- // (vite cannot import absolute files: https://github.com/vitejs/vite/issues/5494
- // this also means vite suffers issues with pnpm etc)
- const absolutizeExport = (exportName: string) => {
- if (resolve(`${name}${exportName}`)) return `${absoluteDir}${exportName}`;
+ const checkExists = (exportName: string) => {
+ if (resolve(`${name}${exportName}`)) return `${name}${exportName}`;
return undefined;
};
- const path = name;
+ // This is used to maintain back-compat with community addons that do not
+ // re-export their sub-addons but reference the sub-addon name directly.
+ // We need to turn it into an absolute path so that webpack can
+ // serve it up correctly when yarn pnp or pnpm is being used.
+ // Vite will be broken in such cases, because it does not process absolute paths,
+ // and it will try to import from the bare import, breaking in pnp/pnpm.
+ const absolutizeExport = (exportName: string) => {
+ return resolve(`${name}${exportName}`);
+ };
- // We don't want to resolve an import path (e.g. '@addons/foo/preview') to the file on disk,
- // because you are not allowed to import arbitrary files in packages in Vite.
- // Instead we check if the export exists and "absolutize" it.
const managerFile = absolutizeExport(`/manager`);
const registerFile = absolutizeExport(`/register`) || absolutizeExport(`/register-panel`);
- const previewFile = absolutizeExport(`/preview`);
- // Presets are imported by node, so therefore fine to be a path on disk (at this stage anyway)
- const presetFile = resolve(`${path}/preset`);
+ const previewFile = checkExists(`/preview`);
+ const previewFileAbsolute = absolutizeExport('/preview');
+ const presetFile = absolutizeExport(`/preset`);
if (!(managerFile || previewFile) && presetFile) {
return {
@@ -132,9 +122,17 @@ export const resolveAddonName = (
return {
type: 'virtual',
- name: path,
+ name,
...(managerEntries.length ? { managerEntries } : {}),
- ...(previewFile ? { previewAnnotations: [previewFile] } : {}),
+ ...(previewFile
+ ? {
+ previewAnnotations: [
+ previewFileAbsolute
+ ? { bare: previewFile, absolute: previewFileAbsolute }
+ : previewFile,
+ ],
+ }
+ : {}),
...(presetFile ? { presets: [{ name: presetFile, options }] } : {}),
};
}
@@ -233,7 +231,6 @@ export async function loadPreset(
logger.warn(warning);
logger.error(e);
-
return [];
}
}
diff --git a/code/lib/core-common/src/utils/interpret-require.ts b/code/lib/core-common/src/utils/interpret-require.ts
index f8da08edf20f..8ed1c200197f 100644
--- a/code/lib/core-common/src/utils/interpret-require.ts
+++ b/code/lib/core-common/src/utils/interpret-require.ts
@@ -3,7 +3,10 @@ import { getInterpretedFileWithExt } from './interpret-files';
let registered = false;
export function interopRequireDefault(filePath: string) {
- if (registered === false) {
+ // eslint-disable-next-line no-underscore-dangle, global-require
+ const hasEsbuildBeenRegistered = !!require('module')._extensions['.ts'];
+
+ if (registered === false && !hasEsbuildBeenRegistered) {
// eslint-disable-next-line global-require
const { register } = require('esbuild-register/dist/node');
registered = true;
diff --git a/code/lib/core-common/tsconfig.json b/code/lib/core-common/tsconfig.json
index 41ca5ea687e5..a4429176e35f 100644
--- a/code/lib/core-common/tsconfig.json
+++ b/code/lib/core-common/tsconfig.json
@@ -3,6 +3,5 @@
"compilerOptions": {
"strict": true
},
- "include": ["src/**/*"],
- "exclude": ["src/**.test.ts"]
+ "include": ["src/**/*"]
}
diff --git a/code/lib/core-events/jest.config.js b/code/lib/core-events/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/lib/core-events/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/lib/core-events/package.json b/code/lib/core-events/package.json
index 2b1a9721a0be..a807d33b8311 100644
--- a/code/lib/core-events/package.json
+++ b/code/lib/core-events/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/core-events",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Event names used in storybook core",
"keywords": [
"storybook"
@@ -42,7 +42,7 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"devDependencies": {
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"publishConfig": {
"access": "public"
@@ -52,5 +52,5 @@
"./src/index.ts"
]
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/lib/core-events/tsconfig.json b/code/lib/core-events/tsconfig.json
index d23f9a406fc2..52d43eaaa9b9 100644
--- a/code/lib/core-events/tsconfig.json
+++ b/code/lib/core-events/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/lib/core-server/jest.config.js b/code/lib/core-server/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/lib/core-server/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/lib/core-server/package.json b/code/lib/core-server/package.json
index 1739945e976a..f91e46d8e5f1 100644
--- a/code/lib/core-server/package.json
+++ b/code/lib/core-server/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/core-server",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook framework-agnostic API",
"keywords": [
"storybook"
@@ -35,18 +35,18 @@
"dependencies": {
"@aw-web-design/x-default-browser": "1.4.88",
"@discoveryjs/json-ext": "^0.5.3",
- "@storybook/builder-manager": "7.0.0-alpha.48",
- "@storybook/core-client": "7.0.0-alpha.48",
- "@storybook/core-common": "7.0.0-alpha.48",
- "@storybook/core-events": "7.0.0-alpha.48",
+ "@storybook/builder-manager": "7.0.0-alpha.51",
+ "@storybook/core-client": "7.0.0-alpha.51",
+ "@storybook/core-common": "7.0.0-alpha.51",
+ "@storybook/core-events": "7.0.0-alpha.51",
"@storybook/csf": "next",
- "@storybook/csf-tools": "7.0.0-alpha.48",
+ "@storybook/csf-tools": "7.0.0-alpha.51",
"@storybook/docs-mdx": "0.0.1-canary.12433cf.0",
- "@storybook/node-logger": "7.0.0-alpha.48",
- "@storybook/store": "7.0.0-alpha.48",
- "@storybook/telemetry": "7.0.0-alpha.48",
- "@storybook/types": "7.0.0-alpha.48",
- "@types/node": "^16.0.0",
+ "@storybook/node-logger": "7.0.0-alpha.51",
+ "@storybook/store": "7.0.0-alpha.51",
+ "@storybook/telemetry": "7.0.0-alpha.51",
+ "@storybook/types": "7.0.0-alpha.51",
+ "@types/node": "^16.0.0 || ^18.0.0",
"@types/node-fetch": "^2.5.7",
"@types/pretty-hrtime": "^1.0.0",
"@types/semver": "^7.3.4",
@@ -77,15 +77,14 @@
"ws": "^8.2.3"
},
"devDependencies": {
- "@storybook/builder-webpack5": "7.0.0-alpha.48",
+ "@storybook/builder-webpack5": "7.0.0-alpha.51",
"@types/compression": "^1.7.0",
"@types/ip": "^1.1.0",
"@types/serve-favicon": "^2.5.2",
"@types/ws": "^8",
"jest-os-detection": "^1.3.1",
- "jest-specific-snapshot": "^4.0.0",
- "ts-jest": "^26.4.4",
- "typescript": "~4.6.3",
+ "jest-specific-snapshot": "^6.0.0",
+ "typescript": "^4.9.3",
"webpack": "5"
},
"peerDependencies": {
@@ -103,5 +102,5 @@
"publishConfig": {
"access": "public"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/lib/core-server/src/core-presets.disabled-test.ts b/code/lib/core-server/src/core-presets.disabled-test.ts
index 4c8f22320f2a..495ae1e3b73a 100644
--- a/code/lib/core-server/src/core-presets.disabled-test.ts
+++ b/code/lib/core-server/src/core-presets.disabled-test.ts
@@ -19,6 +19,7 @@ import { buildStaticStandalone } from './build-static';
import { outputStats } from './utils/output-stats';
+// @ts-expect-error (not strict)
const { SNAPSHOT_OS } = global;
const mkdtemp = promisify(mkdtempCb);
const { packageJson } = readUpSync({ cwd: __dirname });
@@ -33,6 +34,7 @@ jest.mock('webpack', () => {
const actual = jest.requireActual('webpack');
Object.keys(actual).forEach((key) => {
+ // @ts-expect-error (not strict)
value[key] = actual[key];
});
return value;
@@ -88,6 +90,7 @@ jest.mock('@storybook/store', () => {
jest.mock('http', () => ({
...jest.requireActual('http'),
+ // @ts-expect-error (not strict)
createServer: () => ({ listen: (_options, cb) => cb(), on: jest.fn() }),
}));
jest.mock('ws');
@@ -129,7 +132,7 @@ const baseOptions = {
const ROOT = getProjectRoot();
const CWD = process.cwd();
const NODE_MODULES = /.*node_modules/g;
-const cleanRoots = (obj): any => {
+const cleanRoots = (obj: any): any => {
if (!obj) return obj;
if (typeof obj === 'string')
return obj.replace(CWD, 'CWD').replace(ROOT, 'ROOT').replace(NODE_MODULES, 'NODE_MODULES');
@@ -148,15 +151,18 @@ const cleanRoots = (obj): any => {
return obj;
};
-const getConfig = (fn: any, name): Configuration | null => {
- const call = fn.mock.calls.find((c) => c[0].name === name);
+const getConfig = (fn: any, name: string): Configuration | null => {
+ const call = fn.mock.calls.find((c: any) => c[0].name === name);
if (!call) {
return null;
}
return call[0];
};
-const prepareSnap = (get: any, name): Pick => {
+const prepareSnap = (
+ get: any,
+ name: string
+): Pick => {
const config = getConfig(get(), name);
if (!config) {
return null;
@@ -173,7 +179,8 @@ const snap = (name: string) => `__snapshots__/${name}`;
// FIXME: we no longer have test cases
// eslint-disable-next-line jest/no-disabled-tests
describe.skip('FIXME', () => {
- describe.each([[]])('%s', (example) => {
+ // @ts-expect-error (not strict)
+ describe.each([[]])('%s', (example: string) => {
describe.each([
['manager', managerExecutor],
['preview', previewExecutor],
@@ -209,8 +216,8 @@ describe.skip('FIXME', () => {
});
});
-const progressPlugin = (config) =>
- config.plugins.find((p) => p.constructor.name === 'ProgressPlugin');
+const progressPlugin = (config: any) =>
+ config.plugins.find((p: any) => p.constructor.name === 'ProgressPlugin');
describe('dev cli flags', () => {
beforeEach(async () => {
@@ -271,6 +278,7 @@ describe('dev cli flags', () => {
it('production mode', async () => {
expect.assertions(1);
+ // @ts-expect-error (not strict)
await expect(buildStaticStandalone(optionsWithInvalidStaticDir)).rejects.toThrow(
"Won't copy root directory. Check your staticDirs!"
);
diff --git a/code/lib/core-server/src/dev-server.ts b/code/lib/core-server/src/dev-server.ts
index f25c87e46d28..300e52dcdd78 100644
--- a/code/lib/core-server/src/dev-server.ts
+++ b/code/lib/core-server/src/dev-server.ts
@@ -159,6 +159,11 @@ export async function storybookDevServer(options: Options) {
});
} catch (error) {
await managerBuilder?.bail();
+ // For some reason, even when Webpack fails e.g. wrong main.js config,
+ // the preview may continue to print to stdout, which can affect output
+ // when we catch this error and process those errors (e.g. telemetry)
+ // gets overwritten by preview progress output. Therefore, we should bail the preview too.
+ await previewBuilder?.bail().catch();
throw error;
}
}
diff --git a/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts b/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts
index 676abe654994..67a56c64bd58 100644
--- a/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts
+++ b/code/lib/core-server/src/utils/StoryIndexGenerator.test.ts
@@ -1,6 +1,10 @@
/* eslint-disable @typescript-eslint/no-shadow */
/// ;
+/**
+ * @jest-environment node
+ */
+
import path from 'path';
import fs from 'fs-extra';
import { normalizeStoriesEntry } from '@storybook/core-common';
@@ -11,7 +15,6 @@ import type {
import { loadCsf, getStorySortParameter } from '@storybook/csf-tools';
import { toId } from '@storybook/csf';
import { logger } from '@storybook/node-logger';
-import { mocked } from 'ts-jest/utils';
import { StoryIndexGenerator } from './StoryIndexGenerator';
@@ -74,7 +77,7 @@ describe('StoryIndexGenerator', () => {
beforeEach(() => {
const actual = jest.requireActual('@storybook/csf-tools');
loadCsfMock.mockImplementation(actual.loadCsf);
- mocked(logger.warn).mockClear();
+ jest.mocked(logger.warn).mockClear();
});
describe('extraction', () => {
const storiesSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry(
@@ -862,7 +865,7 @@ describe('StoryIndexGenerator', () => {
`);
expect(logger.warn).toHaveBeenCalledTimes(1);
- expect(mocked(logger.warn).mock.calls[0][0]).toMatchInlineSnapshot(
+ expect(jest.mocked(logger.warn).mock.calls[0][0]).toMatchInlineSnapshot(
`"🚨 You have two component docs pages with the same name A:docs. Use \` \` to distinguish them."`
);
});
@@ -890,7 +893,7 @@ describe('StoryIndexGenerator', () => {
`);
expect(logger.warn).toHaveBeenCalledTimes(1);
- expect(mocked(logger.warn).mock.calls[0][0]).toMatchInlineSnapshot(
+ expect(jest.mocked(logger.warn).mock.calls[0][0]).toMatchInlineSnapshot(
`"🚨 You have a story for A with the same name as your component docs page (Story One), so the docs page is being dropped. Use \` \` to distinguish them."`
);
});
@@ -912,7 +915,7 @@ describe('StoryIndexGenerator', () => {
`);
expect(logger.warn).toHaveBeenCalledTimes(1);
- expect(mocked(logger.warn).mock.calls[0][0]).toMatchInlineSnapshot(
+ expect(jest.mocked(logger.warn).mock.calls[0][0]).toMatchInlineSnapshot(
`"🚨 You have a story for A with the same name as your default docs entry name (Story One), so the docs page is being dropped. Consider changing the story name."`
);
});
@@ -1176,30 +1179,6 @@ describe('StoryIndexGenerator', () => {
expect(Object.keys((await generator.getIndex()).entries)).not.toContain('notitle--docs');
});
- it('errors on dependency deletion', async () => {
- const storiesSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry(
- './src/A.stories.(ts|js|jsx)',
- options
- );
- const docsSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry(
- './src/docs2/*.mdx',
- options
- );
-
- const generator = new StoryIndexGenerator([docsSpecifier, storiesSpecifier], options);
- await generator.initialize();
- await generator.getIndex();
- expect(toId).toHaveBeenCalledTimes(5);
-
- expect(Object.keys((await generator.getIndex()).entries)).toContain('a--story-one');
-
- generator.invalidate(storiesSpecifier, './src/A.stories.js', true);
-
- await expect(() => generator.getIndex()).rejects.toThrowError(
- /Could not find "..\/A.stories" for docs file/
- );
- });
-
it('cleans up properly on dependent docs deletion', async () => {
const storiesSpecifier: CoreCommon_NormalizedStoriesSpecifier = normalizeStoriesEntry(
'./src/A.stories.(ts|js|jsx)',
diff --git a/code/lib/core-server/src/utils/StoryIndexGenerator.ts b/code/lib/core-server/src/utils/StoryIndexGenerator.ts
index 2d8f3d4c5180..d6a4be5afea9 100644
--- a/code/lib/core-server/src/utils/StoryIndexGenerator.ts
+++ b/code/lib/core-server/src/utils/StoryIndexGenerator.ts
@@ -304,7 +304,12 @@ export class StoryIndexGenerator {
dependencies.forEach((dep) => {
if (dep.entries.length > 0) {
const first = dep.entries[0];
- if (path.resolve(this.options.workingDir, first.importPath).startsWith(absoluteOf)) {
+
+ if (
+ path
+ .normalize(path.resolve(this.options.workingDir, first.importPath))
+ .startsWith(path.normalize(absoluteOf))
+ ) {
ofTitle = first.title;
}
}
@@ -485,11 +490,6 @@ export class StoryIndexGenerator {
}
});
});
-
- const notFound = dependents.filter((dep) => !invalidated.has(dep));
- if (notFound.length > 0) {
- throw new Error(`Could not invalidate ${notFound.length} deps: ${notFound.join(', ')}`);
- }
}
if (removed) {
diff --git a/code/lib/core-server/src/withTelemetry.test.ts b/code/lib/core-server/src/withTelemetry.test.ts
index b60fd8d382f2..d887909ecc72 100644
--- a/code/lib/core-server/src/withTelemetry.test.ts
+++ b/code/lib/core-server/src/withTelemetry.test.ts
@@ -3,7 +3,6 @@
import prompts from 'prompts';
import { loadAllPresets, cache } from '@storybook/core-common';
import { telemetry } from '@storybook/telemetry';
-import { mocked } from 'ts-jest/utils';
import { withTelemetry } from './withTelemetry';
@@ -57,7 +56,7 @@ describe('when command fails', () => {
});
it('does not send error message when crash reports are disabled', async () => {
- mocked(loadAllPresets).mockResolvedValueOnce({
+ jest.mocked(loadAllPresets).mockResolvedValueOnce({
apply: async () => ({ enableCrashReports: false } as any),
});
await expect(async () =>
@@ -73,7 +72,7 @@ describe('when command fails', () => {
});
it('does send error message when crash reports are enabled', async () => {
- mocked(loadAllPresets).mockResolvedValueOnce({
+ jest.mocked(loadAllPresets).mockResolvedValueOnce({
apply: async () => ({ enableCrashReports: true } as any),
});
@@ -90,7 +89,7 @@ describe('when command fails', () => {
});
it('does not send error message when telemetry is disabled', async () => {
- mocked(loadAllPresets).mockResolvedValueOnce({
+ jest.mocked(loadAllPresets).mockResolvedValueOnce({
apply: async () => ({ disableTelemetry: true } as any),
});
@@ -107,7 +106,7 @@ describe('when command fails', () => {
});
it('does send error messages when telemetry is disabled, but crash reports are enabled', async () => {
- mocked(loadAllPresets).mockResolvedValueOnce({
+ jest.mocked(loadAllPresets).mockResolvedValueOnce({
apply: async () => ({ disableTelemetry: true, enableCrashReports: true } as any),
});
@@ -124,10 +123,10 @@ describe('when command fails', () => {
});
it('does not send error messages when disabled crash reports are cached', async () => {
- mocked(loadAllPresets).mockResolvedValueOnce({
+ jest.mocked(loadAllPresets).mockResolvedValueOnce({
apply: async () => ({} as any),
});
- mocked(cache.get).mockResolvedValueOnce(false);
+ jest.mocked(cache.get).mockResolvedValueOnce(false);
await expect(async () =>
withTelemetry('dev', { presetOptions: {} as any }, run)
@@ -142,10 +141,10 @@ describe('when command fails', () => {
});
it('does send error messages when enabled crash reports are cached', async () => {
- mocked(loadAllPresets).mockResolvedValueOnce({
+ jest.mocked(loadAllPresets).mockResolvedValueOnce({
apply: async () => ({} as any),
});
- mocked(cache.get).mockResolvedValueOnce(true);
+ jest.mocked(cache.get).mockResolvedValueOnce(true);
await expect(async () =>
withTelemetry('dev', { presetOptions: {} as any }, run)
@@ -160,11 +159,11 @@ describe('when command fails', () => {
});
it('does not send error messages when disabled crash reports are prompted', async () => {
- mocked(loadAllPresets).mockResolvedValueOnce({
+ jest.mocked(loadAllPresets).mockResolvedValueOnce({
apply: async () => ({} as any),
});
- mocked(cache.get).mockResolvedValueOnce(undefined);
- mocked(prompts).mockResolvedValueOnce({ enableCrashReports: false });
+ jest.mocked(cache.get).mockResolvedValueOnce(undefined);
+ jest.mocked(prompts).mockResolvedValueOnce({ enableCrashReports: false });
await expect(async () =>
withTelemetry('dev', { presetOptions: {} as any }, run)
@@ -179,11 +178,11 @@ describe('when command fails', () => {
});
it('does send error messages when enabled crash reports are prompted', async () => {
- mocked(loadAllPresets).mockResolvedValueOnce({
+ jest.mocked(loadAllPresets).mockResolvedValueOnce({
apply: async () => ({} as any),
});
- mocked(cache.get).mockResolvedValueOnce(undefined);
- mocked(prompts).mockResolvedValueOnce({ enableCrashReports: true });
+ jest.mocked(cache.get).mockResolvedValueOnce(undefined);
+ jest.mocked(prompts).mockResolvedValueOnce({ enableCrashReports: true });
await expect(async () =>
withTelemetry('dev', { presetOptions: {} as any }, run)
@@ -199,7 +198,7 @@ describe('when command fails', () => {
// if main.js has errors, we have no way to tell if they've disabled telemetry
it('does not send error messages when presets fail to evaluate', async () => {
- mocked(loadAllPresets).mockRejectedValueOnce(error);
+ jest.mocked(loadAllPresets).mockRejectedValueOnce(error);
await expect(async () =>
withTelemetry('dev', { presetOptions: {} as any }, run)
diff --git a/code/lib/core-server/tsconfig.json b/code/lib/core-server/tsconfig.json
index 63768daf6d49..cf1e09965901 100644
--- a/code/lib/core-server/tsconfig.json
+++ b/code/lib/core-server/tsconfig.json
@@ -1,6 +1,7 @@
{
"extends": "../../tsconfig.json",
- "compilerOptions": {},
- "include": ["src/**/*"],
- "exclude": ["src/**/**.test.ts", "src/**/**.disabled-test.ts"]
+ "compilerOptions": {
+ "skipLibCheck": true
+ },
+ "include": ["src/**/*"]
}
diff --git a/code/lib/core-webpack/jest.config.js b/code/lib/core-webpack/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/lib/core-webpack/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/lib/core-webpack/package.json b/code/lib/core-webpack/package.json
index 757e358853e0..5201166b69f5 100644
--- a/code/lib/core-webpack/package.json
+++ b/code/lib/core-webpack/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/core-webpack",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook framework-agnostic API",
"keywords": [
"storybook"
@@ -42,14 +42,14 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/core-common": "7.0.0-alpha.48",
- "@storybook/node-logger": "7.0.0-alpha.48",
- "@storybook/types": "7.0.0-alpha.48",
- "@types/node": "^16.0.0",
+ "@storybook/core-common": "7.0.0-alpha.51",
+ "@storybook/node-logger": "7.0.0-alpha.51",
+ "@storybook/types": "7.0.0-alpha.51",
+ "@types/node": "^16.0.0 || ^18.0.0",
"ts-dedent": "^2.0.0"
},
"devDependencies": {
- "typescript": "~4.6.3",
+ "typescript": "^4.9.3",
"webpack": "5"
},
"publishConfig": {
@@ -61,5 +61,5 @@
],
"platform": "node"
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/lib/core-webpack/tsconfig.json b/code/lib/core-webpack/tsconfig.json
index 41ca5ea687e5..a4429176e35f 100644
--- a/code/lib/core-webpack/tsconfig.json
+++ b/code/lib/core-webpack/tsconfig.json
@@ -3,6 +3,5 @@
"compilerOptions": {
"strict": true
},
- "include": ["src/**/*"],
- "exclude": ["src/**.test.ts"]
+ "include": ["src/**/*"]
}
diff --git a/code/lib/csf-plugin/jest.config.js b/code/lib/csf-plugin/jest.config.js
new file mode 100644
index 000000000000..4396fbc7010d
--- /dev/null
+++ b/code/lib/csf-plugin/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.browser');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/lib/csf-plugin/package.json b/code/lib/csf-plugin/package.json
index bf9f23a7e561..f50a8cafc867 100644
--- a/code/lib/csf-plugin/package.json
+++ b/code/lib/csf-plugin/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/csf-plugin",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Enrich CSF files via static analysis",
"keywords": [
"storybook"
@@ -42,11 +42,11 @@
"prep": "node ../../../scripts/prepare.js"
},
"dependencies": {
- "@storybook/csf-tools": "7.0.0-alpha.48",
+ "@storybook/csf-tools": "7.0.0-alpha.51",
"unplugin": "^0.10.2"
},
"devDependencies": {
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"publishConfig": {
"access": "public"
@@ -56,5 +56,5 @@
"./src/index.ts"
]
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/lib/csf-plugin/src/index.ts b/code/lib/csf-plugin/src/index.ts
index 037f156abf4b..8204a1f723ac 100644
--- a/code/lib/csf-plugin/src/index.ts
+++ b/code/lib/csf-plugin/src/index.ts
@@ -20,7 +20,7 @@ export const unplugin = createUnplugin((options) => {
const code = await fs.readFile(fname, 'utf-8');
try {
const csf = loadCsf(code, { makeTitle: (userTitle) => userTitle || 'default' }).parse();
- enrichCsf(csf);
+ enrichCsf(csf, options);
return formatCsf(csf);
} catch (err: any) {
logger.warn(err.message);
diff --git a/code/lib/csf-plugin/tsconfig.json b/code/lib/csf-plugin/tsconfig.json
index 25de4fbd3e60..a4429176e35f 100644
--- a/code/lib/csf-plugin/tsconfig.json
+++ b/code/lib/csf-plugin/tsconfig.json
@@ -3,13 +3,5 @@
"compilerOptions": {
"strict": true
},
- "include": ["src/**/*"],
- "exclude": [
- "src/**/*.test.*",
- "src/**/tests/**/*",
- "src/**/__tests__/**/*",
- "src/**/*.stories.*",
- "src/**/*.mockdata.*",
- "src/**/__testfixtures__/**"
- ]
+ "include": ["src/**/*"]
}
diff --git a/code/lib/csf-tools/jest.config.js b/code/lib/csf-tools/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/lib/csf-tools/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/lib/csf-tools/package.json b/code/lib/csf-tools/package.json
index 0baf282324c3..b8d0f9c29bd3 100644
--- a/code/lib/csf-tools/package.json
+++ b/code/lib/csf-tools/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/csf-tools",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "",
"keywords": [
"storybook"
@@ -42,19 +42,19 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@babel/types": "^7.12.11",
+ "@babel/types": "^7.20.2",
"@storybook/csf": "next",
- "@storybook/types": "7.0.0-alpha.48",
+ "@storybook/types": "7.0.0-alpha.51",
"fs-extra": "^9.0.1",
"ts-dedent": "^2.0.0"
},
"devDependencies": {
- "@babel/generator": "^7.12.11",
- "@babel/parser": "^7.12.11",
- "@babel/traverse": "^7.12.11",
+ "@babel/generator": "^7.20.4",
+ "@babel/parser": "^7.20.3",
+ "@babel/traverse": "^7.20.1",
"@types/fs-extra": "^9.0.6",
"js-yaml": "^3.14.1",
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"publishConfig": {
"access": "public"
@@ -64,5 +64,5 @@
"./src/index.ts"
]
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/lib/csf-tools/tsconfig.json b/code/lib/csf-tools/tsconfig.json
index f8b60c90fdef..73a65ef2ef6e 100644
--- a/code/lib/csf-tools/tsconfig.json
+++ b/code/lib/csf-tools/tsconfig.json
@@ -1,13 +1,5 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {},
- "include": ["src/**/*"],
- "exclude": [
- "src/**/*.test.*",
- "src/**/tests/**/*",
- "src/**/__tests__/**/*",
- "src/**/*.stories.*",
- "src/**/*.mockdata.*",
- "src/**/__testfixtures__/**"
- ]
+ "include": ["src/**/*"]
}
diff --git a/code/lib/docs-tools/jest.config.js b/code/lib/docs-tools/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/lib/docs-tools/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/lib/docs-tools/package.json b/code/lib/docs-tools/package.json
index b0c9065aa270..4326d0376908 100644
--- a/code/lib/docs-tools/package.json
+++ b/code/lib/docs-tools/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/docs-tools",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Shared utility functions for frameworks to implement docs",
"keywords": [
"storybook"
@@ -42,17 +42,17 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@babel/core": "^7.12.10",
- "@storybook/core-common": "7.0.0-alpha.48",
- "@storybook/store": "7.0.0-alpha.48",
- "@storybook/types": "7.0.0-alpha.48",
+ "@babel/core": "^7.20.2",
+ "@storybook/core-common": "7.0.0-alpha.51",
+ "@storybook/store": "7.0.0-alpha.51",
+ "@storybook/types": "7.0.0-alpha.51",
"doctrine": "^3.0.0",
"lodash": "^4.17.21"
},
"devDependencies": {
- "jest-specific-snapshot": "^4.0.0",
+ "jest-specific-snapshot": "^6.0.0",
"require-from-string": "^2.0.2",
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"publishConfig": {
"access": "public"
@@ -62,5 +62,5 @@
"./src/index.ts"
]
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/lib/docs-tools/src/argTypes/docgen/extractDocgenProps.test.ts b/code/lib/docs-tools/src/argTypes/docgen/extractDocgenProps.test.ts
index f6f35ec345b2..8e60d01b5ff6 100644
--- a/code/lib/docs-tools/src/argTypes/docgen/extractDocgenProps.test.ts
+++ b/code/lib/docs-tools/src/argTypes/docgen/extractDocgenProps.test.ts
@@ -40,7 +40,6 @@ function createFuncType(typeSystemDef: TypeSystemDef, others: Record): Component {
const component = () => {};
- // @ts-expect-error (Converted from ts-ignore)
component.__docgenInfo = {
[DOCGEN_SECTION]: {
[PROP_NAME]: {
diff --git a/code/lib/docs-tools/src/argTypes/enhanceArgTypes.test.ts b/code/lib/docs-tools/src/argTypes/enhanceArgTypes.test.ts
index 5c0e0cb5ca66..7fdedf3db758 100644
--- a/code/lib/docs-tools/src/argTypes/enhanceArgTypes.test.ts
+++ b/code/lib/docs-tools/src/argTypes/enhanceArgTypes.test.ts
@@ -1,5 +1,4 @@
-import type { ArgTypes } from '@storybook/api';
-import type { StrictInputType } from '@storybook/types';
+import type { ArgTypes, StrictInputType } from '@storybook/types';
import { enhanceArgTypes } from './enhanceArgTypes';
expect.addSnapshotSerializer({
@@ -37,6 +36,7 @@ const enhance = ({
args: { input: arg },
globals: {},
};
+ // @ts-expect-error (not strict)
return enhanceArgTypes(context);
};
diff --git a/code/lib/docs-tools/src/argTypes/enhanceArgTypes.ts b/code/lib/docs-tools/src/argTypes/enhanceArgTypes.ts
index f339c4d68b67..aa2d8c13e5c5 100644
--- a/code/lib/docs-tools/src/argTypes/enhanceArgTypes.ts
+++ b/code/lib/docs-tools/src/argTypes/enhanceArgTypes.ts
@@ -1,8 +1,8 @@
-import type { Framework, StoryContextForEnhancers } from '@storybook/types';
+import type { Renderer, StoryContextForEnhancers } from '@storybook/types';
import { combineParameters } from '@storybook/store';
-export const enhanceArgTypes = (
- context: StoryContextForEnhancers
+export const enhanceArgTypes = (
+ context: StoryContextForEnhancers
) => {
const {
component,
diff --git a/code/lib/docs-tools/src/hasDocsOrControls.ts b/code/lib/docs-tools/src/hasDocsOrControls.ts
index d460666d7bc3..b1585ee534d7 100644
--- a/code/lib/docs-tools/src/hasDocsOrControls.ts
+++ b/code/lib/docs-tools/src/hasDocsOrControls.ts
@@ -1,7 +1,7 @@
import type { Options } from '@storybook/types';
// `addons/x` is for the monorepo, `addon-x` is for normal usage
-const packageRe = /(addons\/|addon-)(docs|controls)/;
+const packageRe = /(addons\/|addon-|addon-essentials\/)(docs|controls)/;
export const hasDocsOrControls = (options: Options) =>
options.presetsList?.some((preset) => packageRe.test(preset.name));
diff --git a/code/lib/docs-tools/tsconfig.json b/code/lib/docs-tools/tsconfig.json
index f8b60c90fdef..73a65ef2ef6e 100644
--- a/code/lib/docs-tools/tsconfig.json
+++ b/code/lib/docs-tools/tsconfig.json
@@ -1,13 +1,5 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {},
- "include": ["src/**/*"],
- "exclude": [
- "src/**/*.test.*",
- "src/**/tests/**/*",
- "src/**/__tests__/**/*",
- "src/**/*.stories.*",
- "src/**/*.mockdata.*",
- "src/**/__testfixtures__/**"
- ]
+ "include": ["src/**/*"]
}
diff --git a/code/lib/instrumenter/jest.config.js b/code/lib/instrumenter/jest.config.js
new file mode 100644
index 000000000000..4396fbc7010d
--- /dev/null
+++ b/code/lib/instrumenter/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.browser');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/lib/instrumenter/package.json b/code/lib/instrumenter/package.json
index 438b26938564..241cd28c1c1c 100644
--- a/code/lib/instrumenter/package.json
+++ b/code/lib/instrumenter/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/instrumenter",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "",
"keywords": [
"storybook"
@@ -42,15 +42,15 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/addons": "7.0.0-alpha.48",
- "@storybook/channels": "7.0.0-alpha.48",
- "@storybook/client-logger": "7.0.0-alpha.48",
- "@storybook/core-events": "7.0.0-alpha.48",
+ "@storybook/addons": "7.0.0-alpha.51",
+ "@storybook/channels": "7.0.0-alpha.51",
+ "@storybook/client-logger": "7.0.0-alpha.51",
+ "@storybook/core-events": "7.0.0-alpha.51",
"core-js": "^3.8.2",
"global": "^4.4.0"
},
"devDependencies": {
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"publishConfig": {
"access": "public"
@@ -60,5 +60,5 @@
"./src/index.ts"
]
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/lib/instrumenter/src/instrumenter.test.ts b/code/lib/instrumenter/src/instrumenter.test.ts
index 647dbedb1486..367915be5499 100644
--- a/code/lib/instrumenter/src/instrumenter.test.ts
+++ b/code/lib/instrumenter/src/instrumenter.test.ts
@@ -554,7 +554,7 @@ describe('Instrumenter', () => {
});
it.skip('starts debugging at the first non-nested interceptable call', () => {
- const fn = (...args) => args;
+ const fn = (...args: any[]) => args;
const { fn1, fn2, fn3 } = instrument({ fn1: fn, fn2: fn, fn3: fn }, { intercept: true });
fn3(fn1(), fn2()); // setup the dependencies
addons.getChannel().emit(EVENTS.START, { storyId });
diff --git a/code/lib/instrumenter/tsconfig.json b/code/lib/instrumenter/tsconfig.json
index d23f9a406fc2..52d43eaaa9b9 100644
--- a/code/lib/instrumenter/tsconfig.json
+++ b/code/lib/instrumenter/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/lib/node-logger/jest.config.js b/code/lib/node-logger/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/lib/node-logger/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/lib/node-logger/package.json b/code/lib/node-logger/package.json
index 8b3c1ca3beeb..988b605ad948 100644
--- a/code/lib/node-logger/package.json
+++ b/code/lib/node-logger/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/node-logger",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "",
"keywords": [
"storybook"
@@ -49,7 +49,7 @@
},
"devDependencies": {
"@types/pretty-hrtime": "^1.0.0",
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"publishConfig": {
"access": "public"
@@ -59,5 +59,5 @@
"./src/index.ts"
]
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/lib/node-logger/tsconfig.json b/code/lib/node-logger/tsconfig.json
index 25de4fbd3e60..a4429176e35f 100644
--- a/code/lib/node-logger/tsconfig.json
+++ b/code/lib/node-logger/tsconfig.json
@@ -3,13 +3,5 @@
"compilerOptions": {
"strict": true
},
- "include": ["src/**/*"],
- "exclude": [
- "src/**/*.test.*",
- "src/**/tests/**/*",
- "src/**/__tests__/**/*",
- "src/**/*.stories.*",
- "src/**/*.mockdata.*",
- "src/**/__testfixtures__/**"
- ]
+ "include": ["src/**/*"]
}
diff --git a/code/lib/postinstall/jest.config.js b/code/lib/postinstall/jest.config.js
new file mode 100644
index 000000000000..343e4c7a7f32
--- /dev/null
+++ b/code/lib/postinstall/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.node');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/lib/postinstall/package.json b/code/lib/postinstall/package.json
index 914ed77992a7..d3deed811f2d 100644
--- a/code/lib/postinstall/package.json
+++ b/code/lib/postinstall/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/postinstall",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "Storybook addons postinstall utilities",
"keywords": [
"api",
@@ -43,10 +43,10 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"devDependencies": {
- "jest": "^26.6.3",
- "jest-specific-snapshot": "^4.0.0",
+ "jest": "^29.3.1",
+ "jest-specific-snapshot": "^6.0.0",
"jscodeshift": "^0.13.1",
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"publishConfig": {
"access": "public"
@@ -56,5 +56,5 @@
"./src/index.ts"
]
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/lib/postinstall/src/codemods.test.ts b/code/lib/postinstall/src/codemods.test.ts
index 77684e253143..cc7489df0b0e 100644
--- a/code/lib/postinstall/src/codemods.test.ts
+++ b/code/lib/postinstall/src/codemods.test.ts
@@ -1,6 +1,7 @@
import path from 'path';
import fs from 'fs';
import 'jest-specific-snapshot';
+// @ts-expect-error (broken types)
import { applyTransform } from 'jscodeshift/dist/testUtils';
jest.mock('@storybook/node-logger');
diff --git a/code/lib/postinstall/tsconfig.json b/code/lib/postinstall/tsconfig.json
index bda0ed7ef097..52d43eaaa9b9 100644
--- a/code/lib/postinstall/tsconfig.json
+++ b/code/lib/postinstall/tsconfig.json
@@ -1,5 +1,4 @@
{
"extends": "../../tsconfig.json",
- "include": ["src/**/*"],
- "exclude": ["src/**.test.ts"]
+ "include": ["src/**/*"]
}
diff --git a/code/lib/preview-web/jest.config.js b/code/lib/preview-web/jest.config.js
new file mode 100644
index 000000000000..4396fbc7010d
--- /dev/null
+++ b/code/lib/preview-web/jest.config.js
@@ -0,0 +1,7 @@
+const path = require('path');
+const baseConfig = require('../../jest.config.browser');
+
+module.exports = {
+ ...baseConfig,
+ displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
+};
diff --git a/code/lib/preview-web/package.json b/code/lib/preview-web/package.json
index 0a636823871e..e6202852b2e4 100644
--- a/code/lib/preview-web/package.json
+++ b/code/lib/preview-web/package.json
@@ -1,6 +1,6 @@
{
"name": "@storybook/preview-web",
- "version": "7.0.0-alpha.48",
+ "version": "7.0.0-alpha.51",
"description": "",
"keywords": [
"storybook"
@@ -42,12 +42,12 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "@storybook/addons": "7.0.0-alpha.48",
- "@storybook/channels": "7.0.0-alpha.48",
- "@storybook/client-logger": "7.0.0-alpha.48",
- "@storybook/core-events": "7.0.0-alpha.48",
- "@storybook/store": "7.0.0-alpha.48",
- "@storybook/types": "7.0.0-alpha.48",
+ "@storybook/addons": "7.0.0-alpha.51",
+ "@storybook/channels": "7.0.0-alpha.51",
+ "@storybook/client-logger": "7.0.0-alpha.51",
+ "@storybook/core-events": "7.0.0-alpha.51",
+ "@storybook/store": "7.0.0-alpha.51",
+ "@storybook/types": "7.0.0-alpha.51",
"ansi-to-html": "^0.6.11",
"global": "^4.4.0",
"lodash": "^4.17.21",
@@ -57,10 +57,9 @@
"util-deprecate": "^1.0.2"
},
"devDependencies": {
- "@storybook/channel-postmessage": "7.0.0-alpha.48",
+ "@storybook/channel-postmessage": "7.0.0-alpha.51",
"react": "16.14.0",
- "ts-jest": "^28.0.8",
- "typescript": "~4.6.3"
+ "typescript": "^4.9.3"
},
"publishConfig": {
"access": "public"
@@ -70,5 +69,5 @@
"./src/index.ts"
]
},
- "gitHead": "b58a29b785462f8a8b711b6bb2d7223fd6dc17fd"
+ "gitHead": "4fec76c3f5135854d9834ebc1cf2f1f325696ded"
}
diff --git a/code/lib/preview-web/src/Preview.tsx b/code/lib/preview-web/src/Preview.tsx
index d01e8169e4a5..75e0b564a647 100644
--- a/code/lib/preview-web/src/Preview.tsx
+++ b/code/lib/preview-web/src/Preview.tsx
@@ -17,7 +17,7 @@ import { logger, deprecate } from '@storybook/client-logger';
import type { Channel } from '@storybook/channels';
import { addons } from '@storybook/addons';
import type {
- Framework,
+ Renderer,
Args,
Globals,
Store_ModuleImportFn,
@@ -41,7 +41,7 @@ const STORY_INDEX_PATH = './index.json';
export type MaybePromise = Promise | T;
-export class Preview {
+export class Preview {
serverChannel?: Channel;
storyStore: StoryStore;
diff --git a/code/lib/preview-web/src/PreviewWeb.integration.test.ts b/code/lib/preview-web/src/PreviewWeb.integration.test.ts
index e387d1fec987..43eb31038ff2 100644
--- a/code/lib/preview-web/src/PreviewWeb.integration.test.ts
+++ b/code/lib/preview-web/src/PreviewWeb.integration.test.ts
@@ -3,7 +3,6 @@ import global from 'global';
import type { Store_RenderContext } from '@storybook/types';
import { addons, mockChannel as createMockChannel } from '@storybook/addons';
-import { mocked } from 'ts-jest/utils';
import { expect } from '@jest/globals';
import { PreviewWeb } from './PreviewWeb';
@@ -29,7 +28,6 @@ jest.mock('./WebView');
const { window, document } = global;
jest.mock('global', () => ({
- // @ts-expect-error (Converted from ts-ignore)
...jest.requireActual('global'),
history: { replaceState: jest.fn() },
document: {
@@ -63,8 +61,8 @@ beforeEach(() => {
addons.setChannel(mockChannel as any);
addons.setServerChannel(createMockChannel());
- mocked(WebView.prototype).prepareForDocs.mockReturnValue('docs-element' as any);
- mocked(WebView.prototype).prepareForStory.mockReturnValue('story-element' as any);
+ jest.mocked(WebView.prototype).prepareForDocs.mockReturnValue('docs-element' as any);
+ jest.mocked(WebView.prototype).prepareForStory.mockReturnValue('story-element' as any);
});
describe('PreviewWeb', () => {
@@ -77,6 +75,7 @@ describe('PreviewWeb', () => {
({ storyFn }: Store_RenderContext) => storyFn()
);
document.location.search = '?id=component-one--a';
+ // @ts-expect-error (not strict)
await new PreviewWeb().initialize({ importFn, getProjectAnnotations });
await waitForRender();
@@ -100,6 +99,7 @@ describe('PreviewWeb', () => {
React.createElement('div', {}, 'INSIDE')
);
+ // @ts-expect-error (not strict)
await preview.initialize({ importFn, getProjectAnnotations });
await waitForRender();
@@ -130,6 +130,7 @@ describe('PreviewWeb', () => {
document.location.search = '?id=component-one--a';
const preview = new PreviewWeb();
+ // @ts-expect-error (not strict)
await preview.initialize({ importFn, getProjectAnnotations });
await waitForRender();
diff --git a/code/lib/preview-web/src/PreviewWeb.test.ts b/code/lib/preview-web/src/PreviewWeb.test.ts
index b32229c319de..cf65a9db5e15 100644
--- a/code/lib/preview-web/src/PreviewWeb.test.ts
+++ b/code/lib/preview-web/src/PreviewWeb.test.ts
@@ -29,9 +29,12 @@ import {
} from '@storybook/core-events';
import { logger } from '@storybook/client-logger';
import { addons, mockChannel as createMockChannel } from '@storybook/addons';
-import type { Framework } from '@storybook/types';
-import type { ModuleImportFn, WebProjectAnnotations } from '@storybook/store';
-import { mocked } from 'ts-jest/utils';
+import type {
+ DecoratorFunction,
+ Renderer,
+ Store_ModuleImportFn,
+ ProjectAnnotations,
+} from '@storybook/types';
import { PreviewWeb } from './PreviewWeb';
import {
@@ -57,7 +60,7 @@ const { history, document } = global;
const mockStoryIndex = jest.fn(() => storyIndex);
-let mockFetchResult;
+let mockFetchResult: any;
jest.mock('global', () => ({
...(mockJest.requireActual('global') as any),
history: { replaceState: mockJest.fn() },
@@ -67,11 +70,6 @@ jest.mock('global', () => ({
search: '?id=*',
},
},
- window: {
- location: {
- reload: mockJest.fn(),
- },
- },
FEATURES: {
storyStoreV7: true,
breakingChangesV7: true,
@@ -101,16 +99,18 @@ const createGate = (): [Promise, (_?: any) => void] => {
// a timer, so we need to first setImmediate (to get past the resolution), then run the timers
// Probably jest modern timers do this but they aren't working for some bizzarre reason.
async function waitForSetCurrentStory() {
- await new Promise((r) => setImmediate(r));
+ jest.useFakeTimers({ doNotFake: ['setTimeout'] });
+ await new Promise((r) => setTimeout(r, 0));
jest.runAllTimers();
}
async function createAndRenderPreview({
+ // @ts-expect-error (not strict)
importFn: inputImportFn = importFn,
getProjectAnnotations: inputGetProjectAnnotations = getProjectAnnotations,
}: {
- importFn?: ModuleImportFn;
- getProjectAnnotations?: () => WebProjectAnnotations;
+ importFn?: Store_ModuleImportFn;
+ getProjectAnnotations?: () => ProjectAnnotations;
} = {}) {
const preview = new PreviewWeb();
await preview.initialize({
@@ -140,8 +140,8 @@ beforeEach(() => {
addons.setServerChannel(createMockChannel());
mockFetchResult = { status: 200, json: mockStoryIndex, text: () => 'error text' };
- mocked(WebView.prototype).prepareForDocs.mockReturnValue('docs-element' as any);
- mocked(WebView.prototype).prepareForStory.mockReturnValue('story-element' as any);
+ jest.mocked(WebView.prototype).prepareForDocs.mockReturnValue('docs-element' as any);
+ jest.mocked(WebView.prototype).prepareForStory.mockReturnValue('story-element' as any);
});
describe('PreviewWeb', () => {
@@ -151,6 +151,7 @@ describe('PreviewWeb', () => {
const preview = new PreviewWeb();
await expect(
preview.initialize({
+ // @ts-expect-error (not strict)
importFn,
getProjectAnnotations: () => {
throw err;
@@ -167,6 +168,7 @@ describe('PreviewWeb', () => {
mockFetchResult = { status: 500, text: async () => err.toString() };
const preview = new PreviewWeb();
+ // @ts-expect-error (not strict)
await expect(preview.initialize({ importFn, getProjectAnnotations })).rejects.toThrow(
'sort error'
);
@@ -194,6 +196,7 @@ describe('PreviewWeb', () => {
it('SET_GLOBALS sets globals and types even when undefined', async () => {
await createAndRenderPreview({
+ // @ts-expect-error (not strict)
getProjectAnnotations: () => ({ renderToCanvas: jest.fn() }),
});
@@ -237,6 +240,7 @@ describe('PreviewWeb', () => {
it('allows async getProjectAnnotations', async () => {
const preview = new PreviewWeb();
await preview.initialize({
+ // @ts-expect-error (not strict)
importFn,
getProjectAnnotations: async () => {
return getProjectAnnotations();
@@ -519,6 +523,7 @@ describe('PreviewWeb', () => {
renderToCanvas: undefined,
});
const preview = new PreviewWeb();
+ // @ts-expect-error (not strict)
await expect(preview.initialize({ importFn, getProjectAnnotations })).rejects.toThrow();
expect(preview.view.showErrorDisplay).toHaveBeenCalled();
@@ -632,6 +637,7 @@ describe('PreviewWeb', () => {
});
const preview = new PreviewWeb();
+ // @ts-expect-error (not strict)
await preview.initialize({ importFn, getProjectAnnotations });
await waitForRender();
@@ -687,7 +693,7 @@ describe('PreviewWeb', () => {
const context = docsRenderer.render.mock.calls[0][0];
- expect(context.componentStories().map((s) => s.id)).toEqual([
+ expect(context.componentStories().map((s: any) => s.id)).toEqual([
'component-one--a',
'component-one--b',
'component-one--e',
@@ -897,6 +903,7 @@ describe('PreviewWeb', () => {
document.location.search = '?id=component-one--a';
componentOneExports.default.loaders[0].mockImplementationOnce(async () => gate);
+ // @ts-expect-error (not strict)
await new PreviewWeb().initialize({ importFn, getProjectAnnotations });
await waitForRenderPhase('loading');
@@ -958,6 +965,7 @@ describe('PreviewWeb', () => {
document.location.search = '?id=component-one--a';
projectAnnotations.renderToCanvas.mockImplementation(async () => gate);
+ // @ts-expect-error (not strict)
await new PreviewWeb().initialize({ importFn, getProjectAnnotations });
await waitForRenderPhase('rendering');
@@ -1037,6 +1045,7 @@ describe('PreviewWeb', () => {
});
document.location.search = '?id=component-one--a';
+ // @ts-expect-error (not strict)
await new PreviewWeb().initialize({ importFn, getProjectAnnotations });
await waitForRenderPhase('playing');
@@ -1104,6 +1113,7 @@ describe('PreviewWeb', () => {
mockChannel.emit.mockClear();
const story = await preview.storyStore.loadStory({ storyId: 'component-one--a' });
+ // @ts-expect-error (not strict)
preview.renderStoryToElement(story, 'story-element' as any);
await waitForRender();
@@ -1421,6 +1431,7 @@ describe('PreviewWeb', () => {
document.location.search = '?id=component-one--a';
projectAnnotations.renderToCanvas.mockImplementation(async () => gate);
+ // @ts-expect-error (not strict)
await new PreviewWeb().initialize({ importFn, getProjectAnnotations });
await waitForRenderPhase('rendering');
@@ -1517,6 +1528,7 @@ describe('PreviewWeb', () => {
it('still renders the selected story, once ready', async () => {
document.location.search = '';
// We intentionally are *not* awaiting here
+ // @ts-expect-error (not strict)
new PreviewWeb().initialize({ importFn, getProjectAnnotations });
emitter.emit(SET_CURRENT_STORY, {
@@ -1623,6 +1635,7 @@ describe('PreviewWeb', () => {
const preview = new PreviewWeb();
// We can't wait for the initialize function, as it waits for `renderSelection()`
// which prepares, but it does emit `CURRENT_STORY_WAS_SET` right before that
+ // @ts-expect-error (not strict)
preview.initialize({ importFn, getProjectAnnotations });
await waitForEvents([CURRENT_STORY_WAS_SET]);
@@ -1668,6 +1681,7 @@ describe('PreviewWeb', () => {
const preview = new PreviewWeb();
// We can't wait for the initialize function, as it waits for `renderSelection()`
// which prepares, but it does emit `CURRENT_STORY_WAS_SET` right before that
+ // @ts-expect-error (not strict)
preview.initialize({ importFn, getProjectAnnotations });
await waitForEvents([CURRENT_STORY_WAS_SET]);
@@ -1712,6 +1726,7 @@ describe('PreviewWeb', () => {
const preview = new PreviewWeb();
// We can't wait for the initialize function, as it waits for `renderSelection()`
// which prepares, but it does emit `CURRENT_STORY_WAS_SET` right before that
+ // @ts-expect-error (not strict)
preview.initialize({ importFn, getProjectAnnotations });
await waitForEvents([CURRENT_STORY_WAS_SET]);
@@ -2015,11 +2030,24 @@ describe('PreviewWeb', () => {
});
describe('while story is still rendering', () => {
+ let originalLocation = window.location;
+ beforeEach(() => {
+ originalLocation = window.location;
+ delete (window as Partial).location;
+ window.location = { ...originalLocation, reload: jest.fn() };
+ });
+
+ afterEach(() => {
+ delete (window as Partial).location;
+ window.location = { ...originalLocation, reload: originalLocation.reload };
+ });
+
it('stops initial story after loaders if running', async () => {
const [gate, openGate] = createGate();
componentOneExports.default.loaders[0].mockImplementationOnce(async () => gate);
document.location.search = '?id=component-one--a';
+ // @ts-expect-error (not strict)
await new PreviewWeb().initialize({ importFn, getProjectAnnotations });
await waitForRenderPhase('loading');
@@ -2053,6 +2081,7 @@ describe('PreviewWeb', () => {
document.location.search = '?id=component-one--a';
projectAnnotations.renderToCanvas.mockImplementation(async () => gate);
+ // @ts-expect-error (not strict)
await new PreviewWeb().initialize({ importFn, getProjectAnnotations });
await waitForRenderPhase('rendering');
@@ -2087,6 +2116,7 @@ describe('PreviewWeb', () => {
componentOneExports.a.play.mockImplementationOnce(async () => gate);
document.location.search = '?id=component-one--a';
+ // @ts-expect-error (not strict)
await new PreviewWeb().initialize({ importFn, getProjectAnnotations });
await waitForRenderPhase('playing');
@@ -2140,6 +2170,7 @@ describe('PreviewWeb', () => {
componentOneExports.a.play.mockImplementationOnce(async () => gate);
document.location.search = '?id=component-one--a';
+ // @ts-expect-error (not strict)
await new PreviewWeb().initialize({ importFn, getProjectAnnotations });
await waitForRenderPhase('playing');
@@ -2162,10 +2193,11 @@ describe('PreviewWeb', () => {
// Wait three ticks without resolving the play function
await waitForSetCurrentStory();
- await waitForSetCurrentStory();
- await waitForSetCurrentStory();
+ // We can't mock setTimeout for this test, due to waitForSetCurrentStory hack,
+ // So give some (real) time for the reload to be called
+ await new Promise((r) => setTimeout(r, 100));
- expect(global.window.location.reload).toHaveBeenCalled();
+ expect(window.location.reload).toHaveBeenCalled();
expect(mockChannel.emit).not.toHaveBeenCalledWith(STORY_CHANGED, 'component-one--b');
expect(projectAnnotations.renderToCanvas).not.toHaveBeenCalledWith(
expect.objectContaining({
@@ -2542,6 +2574,7 @@ describe('PreviewWeb', () => {
mockFetchResult = { status: 500, text: async () => err.toString() };
const preview = new PreviewWeb();
+ // @ts-expect-error (not strict)
await expect(preview.initialize({ importFn, getProjectAnnotations })).rejects.toThrow(
'sort error'
);
@@ -2562,6 +2595,7 @@ describe('PreviewWeb', () => {
mockFetchResult = { status: 500, text: async () => err.toString() };
const preview = new PreviewWeb();
+ // @ts-expect-error (not strict)
await expect(preview.initialize({ importFn, getProjectAnnotations })).rejects.toThrow(
'sort error'
);
@@ -3065,6 +3099,7 @@ describe('PreviewWeb', () => {
await waitForEvents([STORY_MISSING]);
mockChannel.emit.mockClear();
+ // @ts-expect-error (not strict)
preview.onStoriesChanged({ importFn, storyIndex });
await waitForRender();
expect(mockChannel.emit).toHaveBeenCalledWith(STORY_RENDERED, 'component-one--a');
@@ -3074,7 +3109,7 @@ describe('PreviewWeb', () => {
describe('when a standalone docs file changes', () => {
const newStandaloneDocsExports = { default: jest.fn() };
- const newImportFn = jest.fn(async (path) => {
+ const newImportFn = jest.fn(async (path: string) => {
return path === './src/Introduction.mdx' ? newStandaloneDocsExports : importFn(path);
});
@@ -3084,6 +3119,7 @@ describe('PreviewWeb', () => {
mockChannel.emit.mockClear();
docsRenderer.render.mockClear();
+ // @ts-expect-error (not strict)
preview.onStoriesChanged({ importFn: newImportFn });
await waitForRender();
@@ -3103,6 +3139,7 @@ describe('PreviewWeb', () => {
const preview = await createAndRenderPreview();
mockChannel.emit.mockClear();
+ // @ts-expect-error (not strict)
preview.onStoriesChanged({ importFn: newImportFn });
await waitForRender();
@@ -3120,6 +3157,7 @@ describe('PreviewWeb', () => {
const preview = new PreviewWeb();
await expect(
preview.initialize({
+ // @ts-expect-error (not strict)
importFn,
getProjectAnnotations: () => {
throw err;
@@ -3140,6 +3178,7 @@ describe('PreviewWeb', () => {
const preview = new PreviewWeb();
await expect(
preview.initialize({
+ // @ts-expect-error (not strict)
importFn,
getProjectAnnotations: () => {
throw err;
@@ -3182,7 +3221,7 @@ describe('PreviewWeb', () => {
expect(mockChannel.emit).toHaveBeenCalledWith(CONFIG_ERROR, err);
});
- const newGlobalDecorator = jest.fn((s) => s());
+ const newGlobalDecorator = jest.fn((s) => s());
const newGetProjectAnnotations = () => {
return {
...projectAnnotations,
@@ -3311,6 +3350,7 @@ describe('PreviewWeb', () => {
const [gate, openGate] = createGate();
componentOneExports.a.play.mockImplementationOnce(async () => gate);
const preview = new PreviewWeb();
+ // @ts-expect-error (not strict)
await preview.initialize({ importFn, getProjectAnnotations });
await waitForRenderPhase('playing');
@@ -3333,6 +3373,7 @@ describe('PreviewWeb', () => {
mockChannel.emit.mockClear();
const [gate, openGate] = createGate();
componentOneExports.b.play.mockImplementationOnce(async () => gate);
+ // @ts-expect-error (not strict)
preview.renderStoryToElement(
await preview.storyStore.loadStory({ storyId: 'component-one--b' }),
{} as any
@@ -3365,6 +3406,7 @@ describe('PreviewWeb', () => {
const preview = new PreviewWeb();
await expect(
preview.initialize({
+ // @ts-expect-error (not strict)
importFn,
getProjectAnnotations: () => {
throw err;
@@ -3380,6 +3422,7 @@ describe('PreviewWeb', () => {
mockFetchResult = { status: 500, text: async () => err.toString() };
const preview = new PreviewWeb();
+ // @ts-expect-error (not strict)
await expect(preview.initialize({ importFn, getProjectAnnotations })).rejects.toThrow(
'sort error'
);
@@ -3390,11 +3433,13 @@ describe('PreviewWeb', () => {
it('waits for stories to be cached', async () => {
const [gate, openGate] = createGate();
+ // @ts-expect-error (not strict)
const gatedImportFn = async (path) => {
await gate;
return importFn(path);
};
+ // @ts-expect-error (not strict)
const preview = await createAndRenderPreview({ importFn: gatedImportFn });
let extracted = false;
diff --git a/code/lib/preview-web/src/PreviewWeb.tsx b/code/lib/preview-web/src/PreviewWeb.tsx
index 4e21f0b5f354..a1ed45f445c9 100644
--- a/code/lib/preview-web/src/PreviewWeb.tsx
+++ b/code/lib/preview-web/src/PreviewWeb.tsx
@@ -1,10 +1,10 @@
-import type { Framework } from '@storybook/types';
+import type { Renderer } from '@storybook/types';
import { PreviewWithSelection } from './PreviewWithSelection';
import { UrlStore } from './UrlStore';
import { WebView } from './WebView';
-export class PreviewWeb extends PreviewWithSelection