@tarojs/service
Version:
Taro Service
39 lines (38 loc) • 1.31 kB
TypeScript
import { PLATFORM_TYPE } from '@tarojs/shared';
import type { Func } from '@tarojs/taro/types/compile';
import type { IPluginContext, TConfig } from '../utils/types';
interface IWrapper {
init?(): void;
close?(): void;
}
export declare class Transaction<T = TaroPlatform> {
wrappers: IWrapper[];
perform(fn: Func, scope: T, ...args: any[]): Promise<void>;
initAll(scope: T): void;
closeAll(scope: T): void;
addWrapper(wrapper: IWrapper): void;
}
export default abstract class TaroPlatform<T extends TConfig = TConfig> {
protected ctx: IPluginContext;
protected config: T;
protected helper: IPluginContext['helper'];
protected compiler: string;
abstract platformType: PLATFORM_TYPE;
abstract platform: string;
abstract runtimePath: string | string[];
behaviorsName?: string;
protected setupTransaction: Transaction<this>;
protected buildTransaction: Transaction<this>;
constructor(ctx: IPluginContext, config: T);
getConfig(): T;
protected emptyOutputDir(excludes?: Array<string | RegExp>): void;
/**
* 如果分端编译详情 webpack 配置了 output 则需更新 outputPath 位置
*/
private updateOutputPath;
/**
* 调用 runner 开启编译
*/
abstract start(): Promise<void>;
}
export {};