import type { ComponentType } from 'react'; import type { AspectMain } from '@teambit/aspect'; import type { AspectDefinition } from '@teambit/aspect-loader'; import type { CacheMain } from '@teambit/cache'; import type { CLIMain } from '@teambit/cli'; import type { ComponentMain } from '@teambit/component'; import type { ExpressMain } from '@teambit/express'; import type { GraphqlMain } from '@teambit/graphql'; import type { SlotRegistry, Harmony } from '@teambit/harmony'; import type { Logger, LoggerMain } from '@teambit/logger'; import type { PubsubMain } from '@teambit/pubsub'; import type { UIRoot } from './ui-root'; import { UIServer } from './ui-server'; import type { StartPlugin } from './start-plugin'; export type UIDeps = [PubsubMain, CLIMain, GraphqlMain, ExpressMain, ComponentMain, CacheMain, LoggerMain, AspectMain]; export type UIRootRegistry = SlotRegistry; export type PreStart = (preStartOpts: PreStartOpts) => Promise; export type PreStartOpts = { skipCompilation?: boolean; }; export type OnStart = () => Promise>; export type StartPluginSlot = SlotRegistry; export type PublicDirOverwrite = (uiRoot: UIRoot) => Promise; export type BuildMethodOverwrite = (name: string, uiRoot: UIRoot, rebuild?: boolean) => Promise; export type PreStartSlot = SlotRegistry; export type OnStartSlot = SlotRegistry; export type PublicDirOverwriteSlot = SlotRegistry; export type BuildMethodOverwriteSlot = SlotRegistry; export type UIConfig = { /** * port for the UI root to use. */ port?: number; /** * port range for the UI root to use. */ portRange: [number, number]; /** * host for the UI root */ host: string; /** * directory in workspace to use for public assets. * always relative to the workspace root directory. */ publicDir: string; /** the url to display when server is listening. Note that bit does not provide proxying to this url */ publicUrl?: string; }; export type RuntimeOptions = { /** * determine whether to initiate on verbose mode. */ verbose?: boolean; /** * name of the UI root to load. */ uiRootName?: string; uiRootAspectIdOrName?: string; /** * component selector pattern to load. */ pattern?: string; /** * determine whether to start a dev server (defaults to false). */ dev?: boolean; /** * port of the config. */ port?: number; /** * determine whether to rebuild the UI before start. */ rebuild?: boolean; /** * skip build the UI before start */ skipUiBuild?: boolean; /** * Show the internal urls of the dev servers */ showInternalUrls?: boolean; /** * resolve component previews from root node_modules instead of .bit_roots */ useRootModules?: boolean; /** * resolve local workspace component previews from source files instead of dist artifacts. */ useSource?: boolean; }; export declare class UiMain { /** * Pubsub extension. */ private pubsub; private config; /** * graphql extension. */ private graphql; /** * slot registry of ui roots. */ private uiRootSlot; /** * express extension. */ private express; /** * pre-start slot */ private preStartSlot; /** * on start slot */ private onStartSlot; /** * Overwrite the public dir Slot */ private publicDirOverwriteSlot; /** * Overwrite the build ui method */ private buildMethodOverwriteSlot; /** * component extension. */ private componentExtension; /** * ui logger instance. */ private cache; /** * ui logger instance. */ private logger; private harmony; private startPluginSlot; private _isBundleUiServed; private currentUIServer; constructor( /** * Pubsub extension. */ pubsub: PubsubMain, config: UIConfig, /** * graphql extension. */ graphql: GraphqlMain, /** * slot registry of ui roots. */ uiRootSlot: UIRootRegistry, /** * express extension. */ express: ExpressMain, /** * pre-start slot */ preStartSlot: PreStartSlot, /** * on start slot */ onStartSlot: OnStartSlot, /** * Overwrite the public dir Slot */ publicDirOverwriteSlot: PublicDirOverwriteSlot, /** * Overwrite the build ui method */ buildMethodOverwriteSlot: BuildMethodOverwriteSlot, /** * component extension. */ componentExtension: ComponentMain, /** * ui logger instance. */ cache: CacheMain, /** * ui logger instance. */ logger: Logger, harmony: Harmony, startPluginSlot: StartPluginSlot); publicDir(uiRoot: UIRoot): Promise; private getUiByName; /** * create a build of the given UI root. */ build(uiRootAspectIdOrName?: string, customOutputPath?: string): Promise; registerStartPlugin(startPlugin: StartPlugin): this; private runRspackPromise; private initiatePlugins; runtimeOptions: RuntimeOptions; getUIServer(): UIServer | undefined; /** * create a Bit UI runtime. */ createRuntime(runtimeOptions: RuntimeOptions): Promise; private addSignalListener; getPort(port?: number): Promise; /** * Events */ private createUiServerStartedEvent; /** * pre-start events are triggered and *completed* before the webserver started. * (the promise is awaited) */ registerPreStart(preStartFn: PreStart): void; /** * bind to ui server start event. */ registerOnStart(onStartFn: OnStart): this; /** * overwrite the build ui function */ registerBuildUIOverwrite(fn: BuildMethodOverwrite): this; /** * overwrite the build ui function */ registerPublicDirOverwrite(fn: PublicDirOverwrite): this; private getOverwriteBuildFn; private getOverwritePublic; invokePreStart(preStartOpts: PreStartOpts): Promise; invokeOnStart(): Promise; /** * register a UI slot. */ registerUiRoot(uiRoot: UIRoot): void; /** * get a UI runtime instance. */ getUi(uiRootAspectIdOrName?: string): [string, UIRoot] | undefined; isHostAvailable(): boolean; getUiName(uiRootAspectIdOrName?: string): string | undefined; private possibleUis; createLink(aspectDefs: AspectDefinition[], rootExtensionName: string): Promise; /** * generate the root file of the UI runtime. */ generateRoot(aspectDefs: AspectDefinition[], rootExtensionName: string, runtimeName?: string, rootAspect?: string, config?: object, path?: string, ignoreVersion?: boolean, addRuntimes?: boolean, harmonyPackage?: string, shouldRun?: boolean): Promise; private selectPort; private buildUI; private shouldServeBundleUi; buildIfChanged(uiRootAspectId: string, uiRoot: UIRoot, force: boolean | undefined): Promise; private createBuildUiHash; /** * Generate hash for a given root * This API is public and used by external users, do not rename this function */ buildUiHash(uiRoot: UIRoot, runtime?: string): Promise; createBundleUiHash(uiRoot: UIRoot, runtime?: string): Promise; private readBundleUiHash; private getBundleUiPath; private buildIfNoBundle; clearConsole(): void; get publicUrl(): string | undefined; static defaultConfig: UIConfig; static runtime: import("@teambit/harmony").RuntimeDefinition; static dependencies: import("@teambit/harmony").Aspect[]; static slots: (((registerFn: () => string) => SlotRegistry) | ((registerFn: () => string) => SlotRegistry) | ((registerFn: () => string) => SlotRegistry) | ((registerFn: () => string) => SlotRegistry) | ((registerFn: () => string) => SlotRegistry) | ((registerFn: () => string) => SlotRegistry))[]; static provider([pubsub, cli, graphql, express, componentExtension, cache, loggerMain]: UIDeps, config: any, [uiRootSlot, preStartSlot, onStartSlot, publicDirOverwriteSlot, buildMethodOverwriteSlot, proxyGetterSlot]: [ UIRootRegistry, PreStartSlot, OnStartSlot, PublicDirOverwriteSlot, BuildMethodOverwriteSlot, StartPluginSlot ], harmony: Harmony): Promise; }