Files
esengine/demo/scripts/api.d.ts

453 lines
10 KiB
TypeScript
Raw Permalink Normal View History

2020-06-08 11:49:45 +08:00
/**
* ResourceManager
*/
type ResourceManagerConfig = {
/**
*
*/
buildConfig: (param: BuildConfigParam) => UserConfig,
/**
*
*/
typeSelector: (path: string) => (string | null | undefined)
/**
*
*/
mergeSelector?: (path: string) => (string | null | undefined),
/**
*
* beta 使
*/
nameSelector?: (path: string) => (string | null | undefined)
}
/**
*
*/
type UserConfig = {
/**
*
*/
outputDir: string,
/**
*
*/
commands: (string | plugins.Command)[]
}
type BuildConfigParam = {
/**
* build command
*/
readonly command: string;
/**
*
*/
readonly target: string;
/**
*
*/
readonly version: string;
/**
*
*/
readonly projectName: string;
/**
*
*/
readonly projectRoot: string;
/**
*
*/
readonly projectConfig: ProjectConfig;
}
type ProjectConfig = {
entryClassName: string;
orientation: string;
frameRate: number;
scaleMode: string;
contentWidth: number;
contentHeight: number;
showFPS: boolean;
fpsStyles: string;
showLog: boolean;
maxTouches: number;
}
/**
* from to
* from glob , to [path][name][hash][ext]
* { from:"resource/**.*" , to:"[path][name]_[hash].[ext]" }
*/
type Matcher = {
from: string,
to: string
}
declare namespace plugins {
interface CommandContext {
/**
*
*/
createFile(relativeFilePath: string, contents: Buffer);
/**
*
*/
buildConfig: BuildConfigParam;
/**
*
*/
projectRoot: string;
/**
*
*/
outputDir: string;
}
/**
* 线
*/
interface Command {
/**
* file null 线
*/
onFile?(file: File): Promise<File | null>
/**
*
*
*/
onFinish?(pluginContext?: CommandContext): Promise<void>
[options: string]: any;
}
interface File {
/**
*
*/
contents: Buffer;
/**
*
*/
path: string;
/**
*
*/
readonly base: string;
/**
* base
*/
readonly relative: string;
/**
* history[0] origin
*/
readonly history: ReadonlyArray<string>;
/**
*
*/
readonly dirname: string;
/**
*
*/
readonly basename: string;
/**
*
*/
readonly extname: string;
/**
*
*/
readonly origin: string;
/**
*
*/
[customProperty: string]: any;
}
}
declare module 'built-in' {
/**
*
*/
type UglifyPluginOption = { sources: string[], target: string };
type UglifyPluginOptions = UglifyPluginOption[];
/**
*
*/
export class UglifyPlugin implements plugins.Command {
constructor(mergeSelector: UglifyPluginOptions);
}
type LibraryType = "debug" | "release";
type CompilePluginOptions = { libraryType: LibraryType, defines?: any };
/**
*
*/
export class CompilePlugin implements plugins.Command {
constructor(options: CompilePluginOptions);
}
/**
* EXML EXML
*/
export class ExmlPlugin implements plugins.Command {
constructor(publishPolicy: EXML_Publish_Policy);
}
/**
*
* * debug : 默认策略
* * contents : EXML
* * gjs : 将生成的JS文件写入到主题文件中
* * commonjs : 将EXML合并为一个 CommonJS
* * commonjs2 : 将EXML合并为一个含有解析方法和皮肤定义的文件
* * json : 将每个EXML文件生成一份配置
*/
type EXML_Publish_Policy = "debug" | "contents" | "gjs" | "commonjs" | "commonjs2" | "json"
/**
* manifest JavaScript
*/
export class ManifestPlugin implements plugins.Command {
constructor(options?: ManifestPluginOptions)
}
/**
*
* json js
*/
type ManifestPluginOptions = {
output: string,
hash?: "crc32",
/**
*
*/
verbose?: boolean,
/**
*
*/
info?:any
/**
* use wechat engine plugin
*/
useWxPlugin?: boolean
/**
* use QQgame engine plugin
*/
qqPlugin?: { use: boolean, pluginList: string[] }
}
/**
* EmitResConfigFilePlugin
* * output: 生成路径 *.res.js *.res.json
* * typeSelector: 根据文件路径决定文件类型
* * nameSelector: 根据文件路径决定文件的资源名
* * groupSelector: 根据文件路径决定资源所述的资源组
*/
type EmitResConfigFilePluginOptions = {
output: string,
typeSelector: (path: string) => string | null | undefined,
nameSelector: (path: string) => string | null | undefined,
groupSelector: (path: string) => string | null | undefined,
}
/**
* res.json res.js
*/
export class EmitResConfigFilePlugin implements plugins.Command {
constructor(options: EmitResConfigFilePluginOptions)
}
export type ConvertResourceConfigPluginOption = {
resourceConfigFiles: { filename: string, root: string }[];
nameSelector: (url: string) => string;
TM_Verbose: boolean;
}
export class ConvertResConfigFilePlugin implements plugins.Command {
constructor(options: ConvertResourceConfigPluginOption);
}
/**
*
* JavaScript 线 js
* watch
*/
export class IncrementCompilePlugin implements plugins.Command {
}
type TextureMergerOptions = {
textureMergerRoot: string[];
}
/**
* 使 TextureMerger TextureMerger 1.7
*/
export class TextureMergerPlugin implements plugins.Command {
constructor(options: TextureMergerOptions);
}
type CleanPluginOptions = {
matchers: string[]
}
export class CleanPlugin implements plugins.Command {
constructor(options: CleanPluginOptions);
}
type RenamePluginOptions = {
/**
*
* Whether to output the log
*/
verbose?: boolean
/**
* hash crc32
* What hash algorithm is used, currently only crc32 is supported
*/
hash?: "crc32"
/**
*
*
* Set up matching rules to copy specified files to other folders
* This parameter is an array that allows multiple matching rules to be set
*/
matchers: Matcher[]
/**
*
* The callback function, return value includes some information about the file
*/
callback?: Function
}
/**
*
*/
export class RenamePlugin implements plugins.Command {
constructor(options: RenamePluginOptions);
}
type ResSplitPluginOptions = {
/**
*
* Whether to output the log
*/
verbose?: boolean
/**
*
*
* Set up matching rules to copy specified files to other folders
* This parameter is an array that allows multiple matching rules to be set
*/
matchers: Matcher[]
}
export class ResSplitPlugin implements plugins.Command {
constructor(options: ResSplitPluginOptions);
}
type ZipPluginOptions = {
mergeSelector: (p: string) => string
}
export class ZipPlugin implements plugins.Command {
constructor(option: ZipPluginOptions);
}
type MergeEuiJsonPluginOptions = {
mergeSelector?: (p: string) => string | null,
createConfig?: boolean
}
export class MergeEuiJsonPlugin implements plugins.Command {
constructor(option?: MergeEuiJsonPluginOptions);
}
}