Merge branch 'fix/storystorev6-vite' into norbert/sb-1063-vite-in-dev-mode-with-storystorev6

This commit is contained in:
Norbert de Langen 2022-12-12 14:13:49 +01:00
commit 3eb16e7ded
No known key found for this signature in database
GPG Key ID: FD0E78AF9A837762
4 changed files with 9 additions and 3 deletions

View File

@ -337,7 +337,7 @@ export class Instrumenter {
track(method: string, fn: Function, args: any[], options: Options) {
const storyId: StoryId =
args?.[0]?.__storyId__ ||
global.window.__STORYBOOK_PREVIEW__.selectionStore.selection.storyId;
global.window.__STORYBOOK_PREVIEW__.selectionStore?.selection?.storyId;
const { cursor, ancestors } = this.getState(storyId);
this.setState(storyId, { cursor: cursor + 1 });
const id = `${ancestors.slice(-1)[0] || storyId} [${cursor}] ${method}`;

View File

@ -125,6 +125,10 @@ export class ClientApi<TRenderer extends Renderer> {
private lastFileName = 0;
constructor({ storyStore }: { storyStore?: StoryStore<TRenderer> } = {}) {
console.log(
'CLIENT_API_MODULE, you should only see this log, exactly ONCE, in the browser console'
);
this.facade = new StoryStoreFacade();
this.addons = {};

View File

@ -3,7 +3,7 @@ import { global } from '@storybook/global';
import type { Renderer, ArgsStoryFn, Path, ProjectAnnotations } from '@storybook/types';
import { createChannel } from '@storybook/channel-postmessage';
import { FORCE_RE_RENDER } from '@storybook/core-events';
import { addons } from '../addons';
import { addons } from '../../addons';
import { PreviewWeb } from '../../preview-web';
import { ClientApi } from '../../client-api';

View File

@ -24,6 +24,8 @@ import { FramesRenderer } from './FramesRenderer';
import type { PreviewProps } from './utils/types';
const { FEATURES } = global;
const getWrappers = (getFn: API['getElements']) => Object.values(getFn<Addon>(types.PREVIEW));
const getTabs = (getFn: API['getElements']) => Object.values(getFn<Addon>(types.TAB));
@ -70,7 +72,7 @@ const createCanvas = (id: string, baseUrl = 'iframe.html', withLoader = true): A
const [progress, setProgress] = useState(undefined);
useEffect(() => {
if (global.CONFIG_TYPE === 'DEVELOPMENT') {
if (FEATURES?.storyStoreV7 && global.CONFIG_TYPE === 'DEVELOPMENT') {
const channel = addons.getServerChannel();
channel.on(PREVIEW_BUILDER_PROGRESS, (options) => {