-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Core: Add UniversalStore
API to sync state/events between multiple environments
#30445
base: next
Are you sure you want to change the base?
Conversation
- Move channel to internal field of UniversalStore - Add static currentEnvironment getter
View your CI Pipeline Execution ↗ for commit df59bc4.
☁️ Nx Cloud last updated this comment at |
…ybook into feature/universal-store
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
17 file(s) reviewed, 19 comment(s)
Edit PR Review Bot Settings | Greptile
code/core/src/shared/universal-store/use-universal-store-manager.ts
Outdated
Show resolved
Hide resolved
Package BenchmarksCommit: The following packages have significant changes to their size or dependencies:
|
Before | After | Difference | |
---|---|---|---|
Dependency count | 54 | 54 | 0 |
Self size | 19.05 MB | 19.22 MB | 🚨 +164 KB 🚨 |
Dependency size | 14.44 MB | 14.44 MB | 0 B |
Bundle Size Analyzer | Link | Link |
storybook
Before | After | Difference | |
---|---|---|---|
Dependency count | 55 | 55 | 0 |
Self size | 22 KB | 22 KB | 0 B |
Dependency size | 33.50 MB | 33.66 MB | 🚨 +164 KB 🚨 |
Bundle Size Analyzer | Link | Link |
sb
Before | After | Difference | |
---|---|---|---|
Dependency count | 56 | 56 | 0 |
Self size | 1 KB | 1 KB | 0 B |
Dependency size | 33.52 MB | 33.68 MB | 🚨 +164 KB 🚨 |
Bundle Size Analyzer | Link | Link |
@storybook/cli
Before | After | Difference | |
---|---|---|---|
Dependency count | 388 | 388 | 0 |
Self size | 503 KB | 503 KB | 0 B |
Dependency size | 75.37 MB | 75.54 MB | 🚨 +164 KB 🚨 |
Bundle Size Analyzer | Link | Link |
@storybook/codemod
Before | After | Difference | |
---|---|---|---|
Dependency count | 277 | 277 | 0 |
Self size | 617 KB | 617 KB | 0 B |
Dependency size | 65.45 MB | 65.62 MB | 🚨 +164 KB 🚨 |
Bundle Size Analyzer | Link | Link |
create-storybook
Before | After | Difference | |
---|---|---|---|
Dependency count | 113 | 113 | 0 |
Self size | 1.11 MB | 1.11 MB | 0 B |
Dependency size | 42.63 MB | 42.79 MB | 🚨 +164 KB 🚨 |
Bundle Size Analyzer | Link | Link |
Co-authored-by: Valentin Palkovic <[email protected]>
…ybook into feature/universal-store
…iple leaders detected
@valentinpalkovic made some changes:
|
id: string; | ||
leader?: false; | ||
debug?: boolean; | ||
initialState?: undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure, but isn't this more correct:
initialState?: never
Works on #30201
What I did
Added initial implementation of the UniversalStore.
See this overview of tests and note the skipped ones are todo (potentially in a follow-up):
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
To test this out manually you can make the following changes to the UI Storybook:
'./my-preset.ts
to the list of addons incode/.storybook/main.ts
code/.storybook/my-preset.ts
with:code/.storybook/manager.tsx
to be:code/.storybook/preview.tsx
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal
,ci:merged
orci:daily
GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.ts
Make sure this PR contains one of the labels below:
Available labels
bug
: Internal changes that fixes incorrect behavior.maintenance
: User-facing maintenance tasks.dependencies
: Upgrading (sometimes downgrading) dependencies.build
: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup
: Minor cleanup style change. Will not show up in release changelog.documentation
: Documentation only changes. Will not show up in release changelog.feature request
: Introducing a new feature.BREAKING CHANGE
: Changes that break compatibility in some way with current major version.other
: Changes that don't fit in the above categories.🦋 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/core
team here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>
Greptile Summary
Introduces a new UniversalStore API for synchronizing state and events across different Storybook environments (server, manager UI, preview) with a leader-follower pattern.
code/core/src/shared/universal-store/index.ts
implementing core UniversalStore functionality with state sync and event handlingcode/core/src/shared/universal-store/use-universal-store-manager.ts
anduse-universal-store-preview.ts
with environment-specific React hookscode/core/src/shared/universal-store/index.test.ts
for store creation, state management and event handlingcode/core/src/shared/universal-store/types.ts
for type-safe state and event handling