import type { AnyFS } from '@teambit/any-fs'; import type { SemVer } from 'semver'; import type { ComponentID } from '@teambit/component-id'; import type { BuildStatus } from '@teambit/legacy.constants'; import type { ComponentLog } from '@teambit/objects'; import type { DependencyList } from '@teambit/dependency-resolver'; import type { ComponentFactory } from './component-factory'; import type ComponentFS from './component-fs'; import type { Config as ComponentConfig } from './config'; import type { Snap } from './snap'; import type { State } from './state'; import { TagMap } from './tag-map'; import type { Tag } from './tag'; import type { IComponent, RawComponentMetadata } from './component-interface'; type SnapsIterableOpts = { firstParentOnly?: boolean; stopFn?: (snap: Snap) => Promise; }; export type InvalidComponent = { id: ComponentID; err: Error; }; /** * in-memory representation of a component. */ export declare class Component implements IComponent { /** * component ID represented by the `ComponentId` type. */ readonly id: ComponentID; /** * head version of the component. can be `null` for new components. * if on main, returns the head on main. * if on a lane, returns the head on the lane. */ readonly head: Snap | null; /** * state of the component. */ private _state; /** * tags of the component. */ readonly tags: TagMap; /** * the component factory */ private factory; constructor( /** * component ID represented by the `ComponentId` type. */ id: ComponentID, /** * head version of the component. can be `null` for new components. * if on main, returns the head on main. * if on a lane, returns the head on the lane. */ head: (Snap | null) | undefined, /** * state of the component. */ _state: State, /** * tags of the component. */ tags: TagMap | undefined, /** * the component factory */ factory: ComponentFactory); get mainFile(): import("@teambit/component.sources").AbstractVinyl; get state(): State; set state(state: State); /** * component configuration which is later generated to a component `package.json` and `bit.json`. */ get config(): ComponentConfig; /** * in-memory representation of the component current filesystem. */ get filesystem(): ComponentFS; /** * build status of the component */ get buildStatus(): BuildStatus; get homepage(): string | undefined; get headTag(): Tag | undefined; get latest(): string | undefined; /** * get aspect data from current state. */ get(id: string): RawComponentMetadata | undefined; getLogs(filter?: { type?: string; offset?: number; limit?: number; head?: string; sort?: string; }): Promise; getDependencies(): DependencyList; getPackageName(): string; stringify(): string; /** * record component changes in the `Scope`. */ /** * display name of the component. */ get displayName(): string; /** * tag a component `Snap` with a semantic version. we follow SemVer specs as defined [here](https://semver.org/)). */ tag(version: SemVer): void; /** * determines whether this component is modified in the workspace. */ isModified(): Promise; /** * whether a component is marked as deleted. * warning! if this component is not the head, it might be deleted by a range later on. * to get accurate results, please use teambit.component/remove aspect, "isDeleted" method. */ isDeleted(): boolean; /** * is component isOutdated */ isOutdated(): boolean; /** * determines whether this component is new. */ isNew(): Promise; /** * whether the component exists on the remote. */ isExported(): boolean; loadState(snapId: string): Promise; loadSnap(snapId?: string): Promise; /** * Get iterable which iterate over snap parents lazily * @param snapId * @param options */ snapsIterable(snapId?: string, options?: SnapsIterableOpts): AsyncIterable; /** * traverse recursively from the provided snap (or head) upwards until it finds a tag * @param snapToStartFrom */ getClosestTag(snapToStartFrom?: string): Promise; /** * id.version can be either a tag or a hash. * if it's a hash, it may have a tag point to it. if it does, return the tag. */ getTag(): Tag | undefined; /** * id.version can be either a tag or a hash. * if it's a tag, find the hash it points to. */ getSnapHash(): string | undefined; /** * in case a component is new, it returns undefined. * otherwise, it returns the Snap object (hash/parents/log) of the current component (according to the version in the id) */ getCurrentSnap(): Promise; /** * checkout the component to a different version in its working tree. */ checkout(version: SemVer): void; /** * examine difference between two components. */ /** * merge two different components */ /** * write a component to a given file system. * @param path root path to write the component * @param fs instance of any fs to use. */ write(path: string, fs?: AnyFS): void; /** * * Check if 2 components are equal * @param {Component} component * @returns {boolean} * @memberof Component */ equals(component: Component): boolean; } export {};