@player-ui/player
Version:
71 lines • 2.57 kB
TypeScript
import type { Flow } from "@player-ui/types";
import type { Logger } from "./logger";
import { TapableLogger } from "./logger";
import { ConstantsController } from "./controllers";
import type { PlayerFlowState, CompletedState, PlayerHooks } from "./types";
export interface PlayerPlugin {
/**
* Unique identifier of the plugin.
* Enables the plugin to be retrievable from Player.
*/
symbol?: symbol;
/** The name of the plugin */
name: string;
/**
* Use this to tap into Player hooks
*/
apply: (player: Player) => void;
}
export interface ExtendedPlayerPlugin<Assets = void, Views = void, Expressions = void, DataTypes = void> {
}
export interface PlayerConfigOptions {
/** A set of plugins to load */
plugins?: PlayerPlugin[];
/** A logger to use */
logger?: Logger;
}
export interface PlayerInfo {
/** Version of the running player */
version: string;
/** Hash of the HEAD commit used to build the current version */
commit: string;
}
/**
* This is it.
*/
export declare class Player {
static readonly info: PlayerInfo;
readonly logger: TapableLogger;
readonly constantsController: ConstantsController;
private config;
private state;
readonly hooks: PlayerHooks;
constructor(config?: PlayerConfigOptions);
/** Returns currently registered plugins */
getPlugins(): PlayerPlugin[];
/** Find instance of [Plugin] that has been registered to Player */
findPlugin<Plugin extends PlayerPlugin>(symbol: symbol): Plugin | undefined;
/** Retrieve an instance of [Plugin] and conditionally invoke [apply] if it exists */
applyTo<Plugin extends PlayerPlugin>(symbol: symbol, apply: (plugin: Plugin) => void): void;
/** Register and apply [Plugin] if one with the same symbol is not already registered. */
registerPlugin(plugin: PlayerPlugin): void;
/** Returns the current version of the running player */
getVersion(): string;
/** Returns the git commit used to build Player version */
getCommit(): string;
/**
* Fetch the current state of Player.
* It will return either `not-started`, `in-progress`, `completed`
* with some extra data in each
*/
getState(): PlayerFlowState;
/**
* A private means of setting the state of Player
* Calls the hooks for subscribers to listen for this event
*/
private setState;
/** Start Player with the given flow */
private setupFlow;
start(payload: Flow): Promise<CompletedState>;
}
//# sourceMappingURL=player.d.ts.map