UNPKG

@foxpage/foxpage-manager

Version:

foxpage resource manager

72 lines (71 loc) 2.07 kB
import { Application, Block, BlockManager, ContentRelationInfo, Relations, ResourceUpdateInfo } from '@foxpage/foxpage-types'; import { ManagerBaseImpl } from '../common'; import { BlockInstance } from './block'; /** * block manager * * @export * @class BlockManager */ export declare class BlockManagerImpl extends ManagerBaseImpl<Block> implements BlockManager { constructor(app: Application); /** * add block to manager * * @param {Block} block */ addBlock(block: Block): BlockInstance; /** * remove block from manager * * @param {string[]} blockIds */ removeBlocks(blockIds: string[]): void; /** * get block from local first * no exist will fetch from server * * @param {string} blockId * @return {*} {(Block | undefined)} */ getBlock(blockId: string): Promise<Block | undefined>; /** * get blocks * * @param {string[]} blockIds * @return {*} {Promise<Block[]>} */ getBlocks(blockIds: string[]): Promise<Block[]>; /** * fetch draft blocks * * @param {string[]} blockIds * @return {*} {Promise<ContentRelationInfo[]>} */ getDraftBlocks(blockIds: string[]): Promise<ContentRelationInfo[]>; /** * fetch draft blocks * * @param {string[]} blockId * @param {number} version * @return {*} {Promise<ContentRelationInfo>} */ getPreviewBlocks(blockId: string, version: number): Promise<ContentRelationInfo>; /** * fetch blocks from server * * @return {*} {Promise<Block[]>} */ freshBlocks(blockIds?: string[]): Promise<Block[]>; /** * first request block will return the all relations * * @protected * @param {string[]} blockIds */ protected onFetch(blockIds: string[]): Promise<BlockInstance[]>; protected onPull(data: ResourceUpdateInfo): Promise<void>; protected onStash(data: Relations): void; protected createInstance(data: Block): Promise<BlockInstance>; private newBlock; }