-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Open Service: Add sync between server, manager and preview #35017
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
Merged
Merged
Changes from all commits
Commits
Show all changes
72 commits
Select commit
Hold shift + click to select a range
0309863
Implement open-service architecture runtime sync
ndelangen d4dd5a6
Implement open-service architecture runtime sync
ndelangen 0beda2b
Refactor open-service channel integration and enhance state synchroni…
ndelangen 1dc1df2
Enhance open-service integration and background handling
ndelangen 8ec8992
Refactor postMessage integration and clean up unused event exports
ndelangen abf5677
Enhance ManagerProvider initialization and refine open-service tests
ndelangen 10d2dd5
Refine open-service documentation and enhance type safety in tests
ndelangen b58178b
Merge branch 'jeppe-cursor/docgen-subscription-referential-equality-5…
ndelangen 5f3eb96
Merge branch 'norbert/service-clients' of github.com:storybookjs/stor…
ndelangen bd0719a
Refactor open-service registration and channel integration
ndelangen 17d8157
Refactor open-service channel events and enhance synchronization logic
ndelangen ee68aa1
Refactor open-service imports and enhance build configuration
ndelangen d6268e2
Refactor global channel assignment in common preset
ndelangen 68c5ca1
Refactor open-service documentation and enhance channel sync tests
ndelangen 88125e7
Merge branch 'next' into norbert/service-clients
ndelangen 034ba47
Remove deprecated `getServiceChannel` export from multiple modules
ndelangen b61ab95
Merge branch 'norbert/service-clients' of github.com:storybookjs/stor…
ndelangen 1bd402d
Add OpenServiceMissingChannelError for improved error handling
ndelangen 6dcbd33
Update Playwright configuration and add new E2E tests
ndelangen 40d9619
Refactor Open Service API exports for improved clarity and structure
ndelangen b3f7da7
Refactor Open Service API imports and exports for improved clarity
ndelangen 1e2b76a
Update Playwright configuration and enhance E2E testing setup
ndelangen 4ea789c
Refactor global channel assignment in common preset
ndelangen a160e59
wip
ndelangen 8619d7b
Fix the OOM problem
ndelangen a3ba897
Refactor channel management in Storybook
ndelangen 26d1e08
Enhance channel management and testing in Storybook
ndelangen c6883a3
Refactor channel management and enhance service registration in Story…
ndelangen 96bae6d
cleanup
ndelangen 952b7f0
Refactor Vitest plugin configuration and channel management
ndelangen 654d283
Enhance channel management in Storybook stories
ndelangen 6d8a916
Enhance test setup for service commands and queries
ndelangen d8181dd
Enhance Vitest configuration and channel management
ndelangen 25439eb
Refactor mock channel implementation and introduce test channel
ndelangen e6c885e
Merge branch 'next' into norbert/service-clients
ndelangen b3df163
Update channel type casting in AddonStore
ndelangen 7386dd2
Merge branch 'norbert/service-clients' of github.com:storybookjs/stor…
ndelangen 715e480
Merge branch 'next' into norbert/service-clients
ndelangen e3a77cc
Refactor: Update background service registration import path
ndelangen 88bd895
chore: Add TypeScript configuration for Storybook
ndelangen 323725b
Refactor: Remove redundant global channel assignment in initTransport…
ndelangen 9957d28
Refactor: Replace global object references with globalThis in channel…
ndelangen 62a1bc7
Refactor: Remove channel assignment from common preset service initia…
ndelangen 86afb92
Refactor: Consolidate mockChannel import paths and remove unused files
ndelangen b11f8d4
Refactor: Update import paths for getChannel in globals-runtime and r…
ndelangen 5136549
Refactor: Update channel management in Storybook stories
ndelangen 829b7e0
Refactor: Update import path for channel management in addons module
ndelangen e7323c5
Refactor: Simplify telemetry error handling in runtime
ndelangen bbb594d
Refactor: Remove open-service client module
ndelangen 80c2529
Refactor: Remove state schema validation from open-service module
ndelangen ef87843
Merge branch 'next' into norbert/service-clients
ndelangen d506661
Refactor: Enhance error handling in channel-slot tests
ndelangen 2b11a51
Refactor: Update channel type casting in addon store
ndelangen 5551ec9
Refactor: Restrict query and command overrides in service registry
ndelangen ad42215
Refactor: Enhance validation in parseStampedSnapshot function
ndelangen 8e8a1d3
Refactor: Remove unnecessary wait time in open-service background tests
ndelangen 60873aa
Refactor: Add undefined output query service fixture and update tests
ndelangen a6c1bb0
Refactor: Update global channel options handling in PostMessageTransp…
ndelangen 22412f5
wip
ndelangen 1336062
Refactor: Standardize channel options handling in PostMessageTranspor…
ndelangen 747b49c
Merge branch 'norbert/service-clients' into norbert/remote-command-ex…
ndelangen 434e664
Refactor: Improve documentation for remote command execution in README
ndelangen 333f57c
Merge branch 'norbert/remote-command-execution' of github.com:storybo…
ndelangen ef9f323
Merge pull request #35068 from storybookjs/norbert/remote-command-exe…
JReinhold 191b318
Merge branch 'next' into norbert/service-clients
JReinhold 743764e
refactor(open-service): tidy channel transport, deps, and query hook …
JReinhold 57ab839
refactor(open-service): schema-validate channel payloads and constrai…
JReinhold 5905767
Add open-service sync demos
JReinhold 182c107
Format open-service sync demos
JReinhold 17e1200
Fix open-service sync type errors
JReinhold 062e88b
Revert unrelated addon-vitest configureVitest change
JReinhold ccccfc0
ci: retry CircleCI after flaky portable-react E2E
JReinhold File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "extends": "../tsconfig.json", | ||
| "include": ["**/*"] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| import { afterEach, describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| import { Channel } from './main.ts'; | ||
| import { | ||
| clearChannel, | ||
| ensureChannel, | ||
| getChannel, | ||
| installNoopChannel, | ||
| setChannel, | ||
| } from './channel-slot.ts'; | ||
|
|
||
| describe('channel slot', () => { | ||
| afterEach(() => { | ||
| clearChannel(); | ||
| vi.unstubAllGlobals(); | ||
| }); | ||
|
|
||
| it('returns null after clearChannel', () => { | ||
| setChannel(new Channel({})); | ||
| clearChannel(); | ||
|
|
||
| expect(getChannel()).toBeNull(); | ||
| expect(globalThis.__STORYBOOK_ADDONS_CHANNEL__).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('mirrors setChannel to the global slot', () => { | ||
| const channel = new Channel({}); | ||
|
|
||
| setChannel(channel); | ||
|
|
||
| expect(getChannel()).toBe(channel); | ||
| expect(globalThis.__STORYBOOK_ADDONS_CHANNEL__).toBe(channel); | ||
| }); | ||
|
|
||
| it('hydrates the module slot from a pre-existing global assignment', () => { | ||
| const channel = new Channel({}); | ||
| clearChannel(); | ||
| vi.stubGlobal('__STORYBOOK_ADDONS_CHANNEL__', channel); | ||
|
|
||
| expect(getChannel()).toBe(channel); | ||
| }); | ||
|
|
||
| it('prefers the global slot over a stale module-level noop', () => { | ||
| clearChannel(); | ||
| installNoopChannel(); | ||
|
|
||
| const real = new Channel({ transport: { setHandler: vi.fn(), send: vi.fn() } }); | ||
| vi.stubGlobal('__STORYBOOK_ADDONS_CHANNEL__', real); | ||
|
|
||
| expect(getChannel()).toBe(real); | ||
| }); | ||
|
|
||
| it('installNoopChannel provides an in-process channel', () => { | ||
| clearChannel(); | ||
| installNoopChannel(); | ||
|
|
||
| expect(getChannel()).toBeInstanceOf(Channel); | ||
| expect(getChannel()?.hasTransport).toBe(false); | ||
| }); | ||
|
|
||
| it('ensureChannel is a no-op when a channel is already installed', () => { | ||
| const channel = new Channel({}); | ||
| setChannel(channel); | ||
|
|
||
| ensureChannel(); | ||
|
|
||
| expect(getChannel()).toBe(channel); | ||
| }); | ||
|
|
||
| it('ensureChannel installs a noop channel when missing', () => { | ||
| clearChannel(); | ||
|
|
||
| ensureChannel(); | ||
|
|
||
| expect(getChannel()).toBeInstanceOf(Channel); | ||
| }); | ||
|
|
||
| it('setChannel(null) clears both module and global slots', () => { | ||
| const channel = new Channel({}); | ||
| setChannel(channel); | ||
|
|
||
| setChannel(null); | ||
|
|
||
| expect(getChannel()).toBeNull(); | ||
| expect(globalThis.__STORYBOOK_ADDONS_CHANNEL__).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('replaces an existing channel on setChannel', () => { | ||
| const first = new Channel({}); | ||
| const second = new Channel({ transport: { setHandler: vi.fn(), send: vi.fn() } }); | ||
|
|
||
| setChannel(first); | ||
| setChannel(second); | ||
|
|
||
| expect(getChannel()).toBe(second); | ||
| expect(globalThis.__STORYBOOK_ADDONS_CHANNEL__).toBe(second); | ||
| }); | ||
| }); | ||
|
|
||
| describe('module import', () => { | ||
| it('does not auto-install a channel in a browser-like environment', async () => { | ||
| vi.stubGlobal('window', {}); | ||
| vi.stubGlobal('document', {}); | ||
| vi.stubEnv('VITEST', ''); | ||
|
|
||
| vi.resetModules(); | ||
| try { | ||
| const { getChannel } = await import('./channel-slot.ts'); | ||
| expect(getChannel()).toBeNull(); | ||
| } finally { | ||
| vi.unstubAllGlobals(); | ||
| vi.unstubAllEnvs(); | ||
| vi.resetModules(); | ||
| } | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.