mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-31 05:03:21 +08:00
Move internal Preview types into pacagek
This commit is contained in:
parent
a9ca2bcb98
commit
6189d76fda
@ -24,7 +24,6 @@ import type {
|
||||
Globals,
|
||||
ModuleImportFn,
|
||||
StoryIndex,
|
||||
PreparedStorySpecifier,
|
||||
ProjectAnnotations,
|
||||
StoryId,
|
||||
ViewMode,
|
||||
@ -39,6 +38,7 @@ import { TemplateDocsRender } from './render/TemplateDocsRender';
|
||||
import { StandaloneDocsRender } from './render/StandaloneDocsRender';
|
||||
import type { Selection, SelectionStore } from './SelectionStore';
|
||||
import type { View } from './View';
|
||||
import type { StorySpecifier } from '../store/StoryIndexStore';
|
||||
|
||||
const globalWindow = globalThis;
|
||||
|
||||
@ -447,7 +447,7 @@ export class PreviewWithSelection<TFramework extends Renderer> extends Preview<T
|
||||
this.channel.emit(STORY_MISSING);
|
||||
}
|
||||
|
||||
renderStoryLoadingException(storySpecifier: PreparedStorySpecifier, err: Error) {
|
||||
renderStoryLoadingException(storySpecifier: StorySpecifier, err: Error) {
|
||||
// logger.error(`Unable to load story '${storySpecifier}':`);
|
||||
logger.error(err);
|
||||
this.view.showErrorDisplay(err);
|
||||
|
@ -1,7 +1,8 @@
|
||||
import type { PreparedStorySpecifier, ViewMode, Args, StoryId } from '@storybook/types';
|
||||
import type { ViewMode, Args, StoryId } from '@storybook/types';
|
||||
import type { StorySpecifier } from '../store/StoryIndexStore';
|
||||
|
||||
export interface SelectionSpecifier {
|
||||
storySpecifier: PreparedStorySpecifier;
|
||||
storySpecifier: StorySpecifier;
|
||||
viewMode: ViewMode;
|
||||
args?: Args;
|
||||
globals?: Args;
|
||||
|
@ -3,11 +3,14 @@ import type {
|
||||
IndexEntry,
|
||||
Path,
|
||||
StoryIndex,
|
||||
PreparedStorySpecifier,
|
||||
StoryId,
|
||||
StoryName,
|
||||
ComponentTitle,
|
||||
} from '@storybook/types';
|
||||
import memoize from 'memoizerific';
|
||||
|
||||
export type StorySpecifier = StoryId | { name: StoryName; title: ComponentTitle } | '*';
|
||||
|
||||
const getImportPathMap = memoize(1)((entries: StoryIndex['entries']) =>
|
||||
Object.values(entries).reduce((acc, entry) => {
|
||||
acc[entry.importPath] = acc[entry.importPath] || entry;
|
||||
@ -22,7 +25,7 @@ export class StoryIndexStore {
|
||||
this.entries = entries;
|
||||
}
|
||||
|
||||
entryFromSpecifier(specifier: PreparedStorySpecifier) {
|
||||
entryFromSpecifier(specifier: StorySpecifier) {
|
||||
const entries = Object.values(this.entries);
|
||||
if (specifier === '*') {
|
||||
// '*' means select the first entry. If there is none, we have no selection.
|
||||
|
@ -1,4 +1,3 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import type { SynchronousPromise } from 'synchronous-promise';
|
||||
import type { Renderer, ProjectAnnotations as CsfProjectAnnotations } from '@storybook/csf';
|
||||
|
||||
@ -21,10 +20,6 @@ import type {
|
||||
StrictGlobalTypes,
|
||||
} from './csf';
|
||||
|
||||
// Internal to preview, exported until preview package consolidation
|
||||
export type Store_PromiseLike<T> = Promise<T> | SynchronousPromise<T>;
|
||||
export type PreparedStorySpecifier = StoryId | { name: StoryName; title: ComponentTitle } | '*';
|
||||
|
||||
// Store Types
|
||||
export interface WebRenderer extends Renderer {
|
||||
canvasElement: HTMLElement;
|
||||
@ -32,7 +27,7 @@ export interface WebRenderer extends Renderer {
|
||||
|
||||
export type ModuleExport = any;
|
||||
export type ModuleExports = Record<string, ModuleExport>;
|
||||
export type ModuleImportFn = (path: Path) => Store_PromiseLike<ModuleExports>;
|
||||
export type ModuleImportFn = (path: Path) => Promise<ModuleExports>;
|
||||
|
||||
type MaybePromise<T> = Promise<T> | T;
|
||||
export type TeardownRenderToCanvas = () => MaybePromise<void>;
|
||||
|
Loading…
x
Reference in New Issue
Block a user