CodeVetter · Repo Unpack · Data flow
storybookjs/storybook
Configuration enters through CLI options and project presets, then supplies story discovery, builders, and runtime feature gates. The server produces an index whose import paths connect static discovery to executable preview modules. Channel events carry selections, args, and results between realms. Persistence is explicit: browser preferences, rewritten story files, static snapshots, and instance discovery records have different owners.
- dev() combines CLI input with a default ./.storybook config directory, development mode, cache, and package metadata before withTelemetry invokes buildDevStandalone().
- Story specifiers are normalized once and shared by reference; watched story changes invalidate individual index entries, while preview configuration changes invalidate the complete index.
- extractStories converts an absolute source path to an importPath, derives titles from the matching specifier, and delegates extraction to the first matching indexer's createIndex().
- StoryStore resolves storyId through the index, calls importFn(importPath), processes the CSF exports, combines story/component/project annotations, and initializes args and hook state.
- Manager updateStoryArgs emits UPDATE_STORY_ARGS with a ref target; Preview.onUpdateArgs updates the args store, rerenders or remounts matching renders, and emits STORY_ARGS_UPDATED.
- Controls serializes changed args with csfId/importPath; initializeSaveStory parses them, mutates the selected CSF export or duplicate, formats printed source, and writes the file.
- Manager Store.setState first awaits React's state update, then persists the delta through a URL handler, session storage, or local storage; initial state gives session values precedence over local values.
- Static service queries require load/staticPath/staticInputs, validate each input, execute against fresh runtimes, merge snapshots by logical path, and serialize JSON into outputDir/services.