npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

editor-build-helper

v0.1.5

Published

<a name="devmd"></a>

Readme

editor-build-helper - Cocos Creator 构建工具库

接口文档

请参考文档

如何使用内置的Vue来开发界面

我们各个插件一般使用Vue来开发界面,直接使用npm安装Vue有一个问题, Vue的npm包太大了,包含多个版本的Vue以及一些额外的东西,这会导致 插件包体太大,于是我们选择在本库中内置一个删除多余文件的Vue包。

使用方法:

import Vue from 'editor-build-helper/vue';

注,请在发布时,关闭Vue生产环境提示及devtools:

Vue.config.productionTip = false;
Vue.config.devtools = false;

如何导入Cocos Creator及Cocos Service类型声明

本库内置了Cocos Creator及Cocos Service的类型文件,位于 editor-build-helper/@types目录下,方便各插件进行引用。

举个例子,你想导入Editor全局变量的类型声明,两种方法:

如果你想在某个文件内局部引用,那么在该文件中直接import对应的类型声明文 件即可,例如:

import {} from 'editor-build-helper/@types/index';
/*
 * 请不要直接使用import 'editor-build-helper/@types/index';
 * 这会导致生成的JavaScript文件去require index.d.ts,导致运行时出错。
 */

如果你想在整个项目内全局引用,在项目的tsconfig.json中加入skipLibCheck、 types两个编译选项,例如:

{
  "compilerOptions": {
    ...
    "skipLibCheck": true,
    "types": ["./node_modules/editor-build-helper/@types/index"]
  }
  ...
}

同理,如果你想导入ccService全局变量的类型声明,可以任选下面两种:

文件内局部引用:

import {} from 'editor-build-helper/@types/service/utils/index';
/*
 * 请不要直接使用import 'editor-build-helper/@types/service/utils/index';
 * 这会导致生成的JavaScript文件去require index.d.ts,导致运行时出错。
 */

项目内全局引用:

{
  "compilerOptions": {
    ...
    "skipLibCheck": true,
    "types": ["./node_modules/editor-build-helper/@types/service/utils/index"]
  }
  ...
}

维护者指南(以下文档供维护者参考)

发布

执行:

npm run pub

该脚本会顺带执行构建+生成最新文档,然后才进行发布。

该脚本取名pub而非publish是为了避免把npm run publish写成npm publish, 导致跳过构建+生成文档的步骤。

构建

执行:

npm run build

编写及生成最新文档

文档请在DEV.md中编写,不要直接编辑README.md,DEV.md会和生成的接口文档 合并成一份README.md。

生成最新文档请执行:

npm run gen-docs

该脚本会先执行构建,然后再生成最新文档,故不用额外执行构建脚本。

editor-build-helper

Table of contents

References

Namespaces

Variables

References

android

Re-exports: android


assetDB

Re-exports: assetDB


file

Re-exports: file


service

Re-exports: service


utils

Re-exports: utils

Variables

nativePlatform

Const nativePlatform: string[]

Defined in: exports.ts:7

Namespace: android

default.android

Table of contents

Functions

Functions

addUsesPermission

addUsesPermission(manifestPath: string, permission: string): void

Parameters:

Name | Type | :------ | :------ | manifestPath | string | permission | string |

Returns: void

Defined in: android.ts:4


getDependencyTag

getDependencyTag(dependency: string): string

Parameters:

Name | Type | :------ | :------ | dependency | string |

Returns: string

Defined in: android.ts:11


insertDependency

insertDependency(buildGralde: string, dependency: string): void

Parameters:

Name | Type | :------ | :------ | buildGralde | string | dependency | string |

Returns: void

Defined in: android.ts:20

Namespace: assetDB

default.assetDB

Table of contents

Functions

Functions

copy

copy(source: string, target: string, option: AssetOperationOption): Promise<null | AssetInfo>

复制某个资源

Parameters:

Name | Type | Description | :------ | :------ | :------ | source | string | 源资源的 url,例如 db://assets/abc.json | target | string | 复制到的目标位置 url | option | AssetOperationOption | 资源的操作类型 |

Returns: Promise<null | AssetInfo>

Defined in: assetdb.ts:43


create

create(url: string, content: string | Buffer | null, option: AssetOperationOption): Promise<null | AssetInfo>

新建一个资源

Parameters:

Name | Type | Description | :------ | :------ | :------ | url | string | 资源的 url,例如 db://assets/abc.json | content | string | Buffer | null | 写入文件的内容,为 null 则新建文件夹 | option | AssetOperationOption | 资源的操作类型 |

Returns: Promise<null | AssetInfo>

Defined in: assetdb.ts:22


delete

delete(url: string): Promise<null | AssetInfo>

删除一个资源

Parameters:

Name | Type | Description | :------ | :------ | :------ | url | string | 资源的 url |

Returns: Promise<null | AssetInfo>

Defined in: assetdb.ts:61


exist

exist(urlOrUUID: string): Promise<boolean>

判断一个资源是否存在

Parameters:

Name | Type | Description | :------ | :------ | :------ | urlOrUUID | string | 资源 url 或者 uuid |

Returns: Promise<boolean>

Defined in: assetdb.ts:111


generateAvailableUrl

generateAvailableUrl(url: string): Promise<string>

根据传入的 url 生成一个可用的新 url

Parameters:

Name | Type | Description | :------ | :------ | :------ | url | string | 资源的 url |

Returns: Promise<string>

Defined in: assetdb.ts:167


import

import(source: string, target: string, option: AssetOperationOption): Promise<null | AssetInfo>

将一个文件或这文件夹导入到资源数据库中

Parameters:

Name | Type | Description | :------ | :------ | :------ | source | string | 本地的文件绝对路径地址 | target | string | 导入到数据库的 url 地址 | option | AssetOperationOption | 资源的操作类型 |

Returns: Promise<null | AssetInfo>

Defined in: assetdb.ts:32


isReady

isReady(): Promise<boolean>

检查资源数据库是否启动完毕

Returns: Promise<boolean>

Defined in: assetdb.ts:12


move

move(source: string, target: string, option: AssetOperationOption): Promise<null | AssetInfo>

讲一个资源移动到某个地方

Parameters:

Name | Type | Description | :------ | :------ | :------ | source | string | 需要移动的源资源的 url,例如 db://assets/abc.json | target | string | 移动到到的目标位置 url | option | AssetOperationOption | 资源的操作类型 |

Returns: Promise<null | AssetInfo>

Defined in: assetdb.ts:53


open

open(urlOrUUID: string): Promise<void>

尝试使用记录的打开程序打开一个资源

Parameters:

Name | Type | Description | :------ | :------ | :------ | urlOrUUID | string | 资源 url 或者 uuid |

Returns: Promise<void>

Defined in: assetdb.ts:69


queryAssetInfo

queryAssetInfo(urlOrUUID: string): Promise<null | AssetInfo>

查询一个资源的基本信息

Parameters:

Name | Type | Description | :------ | :------ | :------ | urlOrUUID | string | 资源 url 或者 uuid |

Returns: Promise<null | AssetInfo>

Defined in: assetdb.ts:151


queryAssetMeta

queryAssetMeta(urlOrUUID: string): Promise<any>

查询一个资源的 meta 信息

Parameters:

Name | Type | Description | :------ | :------ | :------ | urlOrUUID | string | 资源 url 或者 uuid |

Returns: Promise<any>

Defined in: assetdb.ts:159


queryAssets

queryAssets(option: QueryAssetsOption): Promise<AssetInfo[]>

根据条件查询资源数组

Parameters:

Name | Type | Description | :------ | :------ | :------ | option | QueryAssetsOption | 查询选项 |

Returns: Promise<AssetInfo[]>

Defined in: assetdb.ts:143


queryPath

queryPath(urlOrUUID: string): Promise<null | string>

查询一个资源的磁盘绝对路径

Parameters:

Name | Type | Description | :------ | :------ | :------ | urlOrUUID | string | 资源 url 或者 uuid |

Returns: Promise<null | string>

Defined in: assetdb.ts:119


queryUUID

queryUUID(url: string): Promise<null | string>

查询一个资源的 uuid

Parameters:

Name | Type | Description | :------ | :------ | :------ | url | string | 资源的 url |

Returns: Promise<null | string>

Defined in: assetdb.ts:135


queryUrl

queryUrl(uuid: string): Promise<null | string>

查询一个资源的 url

Parameters:

Name | Type | Description | :------ | :------ | :------ | uuid | string | 资源的 uuid |

Returns: Promise<null | string>

Defined in: assetdb.ts:127


refresh

refresh(urlOrUUID: string): Promise<boolean>

刷新一个资源所在 url 位置,删除资源则会被销毁,新增资源会导入

Parameters:

Name | Type | Description | :------ | :------ | :------ | urlOrUUID | string | 资源 url 或者 uuid |

Returns: Promise<boolean>

Defined in: assetdb.ts:103


reimport

reimport(urlOrUUID: string): Promise<boolean>

重新导入资源

Parameters:

Name | Type | Description | :------ | :------ | :------ | urlOrUUID | string | 资源 url 或者 uuid |

Returns: Promise<boolean>

Defined in: assetdb.ts:95


save

save(urlOrUUID: string, content: string | Buffer): Promise<null | AssetInfo>

保存资源

Parameters:

Name | Type | Description | :------ | :------ | :------ | urlOrUUID | string | 资源 url 或者 uuid | content | string | Buffer | 资源的内容字符串,如果是 typeArray,请使用 Buffer.from 转换 |

Returns: Promise<null | AssetInfo>

Defined in: assetdb.ts:78


saveMeta

saveMeta(urlOrUUID: string, content: string): Promise<null | AssetInfo>

保存资源的 meta 信息

Parameters:

Name | Type | Description | :------ | :------ | :------ | urlOrUUID | string | 资源 url 或者 uuid | content | string | 资源 meta 序列化后的内容字符串 |

Returns: Promise<null | AssetInfo>

Defined in: assetdb.ts:87

Namespace: file

default.file

Table of contents

Functions

Functions

appendFileContent

appendFileContent(path: string, content: string): void

在文件中追加内容

Parameters:

Name | Type | Description | :------ | :------ | :------ | path | string | 文件路径 | content | string | 要追加的内容 |

Returns: void

Defined in: file.ts:107


checkFileContent

checkFileContent(path: string, match: string | RegExp): boolean

检测文件中是否存在指定的内容 (文件不存在也返回 false)

Parameters:

Name | Type | Description | :------ | :------ | :------ | path | string | 文件路径 | match | string | RegExp | 检查的文件内容 |

Returns: boolean

Defined in: file.ts:84


copyFile

copyFile(src: string, dest: string, deleted?: boolean): void

复制文件

Parameters:

Name | Type | Default value | Description | :------ | :------ | :------ | :------ | src | string | - | 源路径 | dest | string | - | 目标路径 | deleted | boolean | false | 是否要删除之前的文件 |

Returns: void

Defined in: file.ts:33


copyFileByItem

copyFileByItem(item: FileItem, deleted: boolean): void

根据文件 Item 复制文件

Parameters:

Name | Type | Description | :------ | :------ | :------ | item | FileItem | 文件 Item | deleted | boolean | 是否要删除之前的文件 |

Returns: void

Defined in: file.ts:23


copyFilesByItem

copyFilesByItem(list: FileItem[], deleted?: boolean): void

根据文件 Item 列表批量复制文件

Parameters:

Name | Type | Default value | Description | :------ | :------ | :------ | :------ | list | FileItem[] | - | 文件 Item 列表 | deleted | boolean | false | 是否要删除之前的文件 |

Returns: void

Defined in: file.ts:67


removeFile

removeFile(path: string): void

移除文件

Parameters:

Name | Type | Description | :------ | :------ | :------ | path | string | 文件路径 |

Returns: void

Defined in: file.ts:57


removeFileByItem

removeFileByItem(item: FileItem): void

根据文件 Item 移除目标文件

Parameters:

Name | Type | Description | :------ | :------ | :------ | item | FileItem | 文件 Item |

Returns: void

Defined in: file.ts:49


removeFilesByItem

removeFilesByItem(list: FileItem[]): void

根据文件 Item 列表批量删除目标文件

Parameters:

Name | Type | Description | :------ | :------ | :------ | list | FileItem[] | 文件 Item 列表 |

Returns: void

Defined in: file.ts:75


replaceFileContent

replaceFileContent(path: string, match: string | RegExp, content: string): void

替换文件中的内容

Parameters:

Name | Type | Description | :------ | :------ | :------ | path | string | 文件路径 | match | string | RegExp | 被替换的内容 | content | string | 要替换的文件内容 |

Returns: void

Defined in: file.ts:96


writeFileContent

writeFileContent(path: string, content: string): void

Parameters:

Name | Type | :------ | :------ | path | string | content | string |

Returns: void

Defined in: file.ts:113

Namespace: default

Table of contents

Namespaces

Variables

Variables

nativePlatform

Const nativePlatform: string[]

Defined in: exports.ts:7

Namespace: service

default.service

Table of contents

Functions

Functions

copyJSToAssets

copyJSToAssets(settingsPath: string, jsPath: string): void

Parameters:

Name | Type | :------ | :------ | settingsPath | string | jsPath | string |

Returns: void

Defined in: service.ts:41


getEnableFromOptions

getEnableFromOptions(options: TaskOption, srv_name: string): boolean

Parameters:

Name | Type | :------ | :------ | options | TaskOption | srv_name | string |

Returns: boolean

Defined in: service.ts:18


getParamsFromOptions

getParamsFromOptions(options: TaskOption, srv_name: string): undefined | ParamType

Parameters:

Name | Type | :------ | :------ | options | TaskOption | srv_name | string |

Returns: undefined | ParamType

Defined in: service.ts:25


insertToJSList

insertToJSList(settingsPath: string, jsFile: string): void

Parameters:

Name | Type | :------ | :------ | settingsPath | string | jsFile | string |

Returns: void

Defined in: service.ts:32


writeClassName

writeClassName(assetsDir: string, className: string): void

Parameters:

Name | Type | :------ | :------ | assetsDir | string | className | string |

Returns: void

Defined in: service.ts:7


writeJSToAssets

writeJSToAssets(settingsPath: string, jsName: string, content: string): void

Parameters:

Name | Type | :------ | :------ | settingsPath | string | jsName | string | content | string |

Returns: void

Defined in: service.ts:51

Namespace: utils

default.utils

Table of contents

Functions

Functions

validateObject

validateObject(obj: any): boolean

Parameters:

Name | Type | :------ | :------ | obj | any |

Returns: boolean

Defined in: utils.ts:1