first commit
This commit is contained in:
4
extensions/app/engine/.gitignore
vendored
Normal file
4
extensions/app/engine/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# files
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
/node_modules
|
||||
1227
extensions/app/engine/@types/editor.d.ts
vendored
Normal file
1227
extensions/app/engine/@types/editor.d.ts
vendored
Normal file
@@ -0,0 +1,1227 @@
|
||||
/// <reference path='./electron.d.ts'/>
|
||||
|
||||
/// <reference types='node' />
|
||||
/// <reference path='./extension.d.ts'/>
|
||||
|
||||
import * as NodeJSPath from 'path';
|
||||
import { EventEmitter } from 'events';
|
||||
import { FileFilter, BrowserWindow, OpenDialogReturnValue, SaveDialogReturnValue, MessageBoxReturnValue } from 'electron';
|
||||
|
||||
declare global {
|
||||
export namespace Editor {
|
||||
export namespace App {
|
||||
export const userAgent: string;
|
||||
/**
|
||||
* 是否是开发模式
|
||||
* Development mode
|
||||
*/
|
||||
export const dev: boolean;
|
||||
/**
|
||||
* 编辑器版本号
|
||||
* Editor version
|
||||
*/
|
||||
export const version: string;
|
||||
/**
|
||||
* 主目录
|
||||
* Home directory
|
||||
*/
|
||||
export const home: string;
|
||||
/**
|
||||
* 编辑器程序文件夹
|
||||
* Program folder
|
||||
*/
|
||||
export const path: string;
|
||||
/**
|
||||
* 获取当前编辑器的临时缓存目录
|
||||
* Temporary cache directory
|
||||
*/
|
||||
export const temp: string;
|
||||
/**
|
||||
* 获取当前编辑器 icon 地址
|
||||
* Gets the icon address of the current editor
|
||||
*/
|
||||
export const icon: string;
|
||||
/**
|
||||
* 获取当前编辑器使用的 url 地址
|
||||
* Gets the URL used by the current editor
|
||||
*/
|
||||
export const urls: {
|
||||
manual: string;
|
||||
api: string;
|
||||
forum: string;
|
||||
};
|
||||
/**
|
||||
* 退出程序
|
||||
* Exit the program
|
||||
*/
|
||||
export function quit(): void;
|
||||
}
|
||||
export namespace Clipboard {
|
||||
export type ICopyType = 'image' | 'text' | 'files' | string;
|
||||
/**
|
||||
* 获取剪贴板内容
|
||||
* @param type
|
||||
*/
|
||||
export function read(type: ICopyType): any;
|
||||
/**
|
||||
* 写入剪贴板内容
|
||||
* @param type
|
||||
* @param value
|
||||
*/
|
||||
export function write(type: 'image', value: string): boolean;
|
||||
export function write(type: 'text', value: string): boolean;
|
||||
export function write(type: 'files', value: FileList): boolean;
|
||||
export function write(type: string, value: any): boolean;
|
||||
|
||||
/**
|
||||
* 判断当前剪贴板内是否是指定类型
|
||||
* @param type
|
||||
*/
|
||||
export function has(type: ICopyType): boolean;
|
||||
/**
|
||||
* 清空剪贴板
|
||||
*/
|
||||
export function clear(): void;
|
||||
}
|
||||
export namespace Dialog {
|
||||
|
||||
export interface SaveDialogOptions {
|
||||
title?: string;
|
||||
path?: string;
|
||||
button?: string;
|
||||
filters?: FileFilter[];
|
||||
}
|
||||
export interface SelectDialogOptions {
|
||||
title?: string;
|
||||
path?: string;
|
||||
type?: 'directory' | 'file';
|
||||
button?: string;
|
||||
multi?: boolean;
|
||||
filters?: FileFilter[];
|
||||
extensions?: string;
|
||||
}
|
||||
export interface MessageDialogOptions {
|
||||
title?: string;
|
||||
detail?: string;
|
||||
default?: number;
|
||||
cancel?: number;
|
||||
checkboxLabel?: string;
|
||||
checkboxChecked?: boolean;
|
||||
buttons?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择文件弹窗
|
||||
* Select the file popover
|
||||
*
|
||||
* @param options 选择弹窗参数 Select popover parameters
|
||||
* @param window 依附于哪个窗口(插件主进程才可使用) Which window it is attached to (only available to the plugin's main process)
|
||||
*/
|
||||
export function select(options?: SelectDialogOptions, window?: BrowserWindow): Promise<OpenDialogReturnValue>;
|
||||
/**
|
||||
* 保存文件弹窗
|
||||
* Save the file popup
|
||||
*
|
||||
* @param options 保存文件窗口参数 Save the file window parameters
|
||||
* @param window 依附于哪个窗口(插件主进程才可使用) Which window it is attached to (only available to the plugin's main process)
|
||||
*/
|
||||
export function save(options?: SaveDialogOptions, window?: BrowserWindow): Promise<SaveDialogReturnValue>;
|
||||
/**
|
||||
* 信息弹窗
|
||||
* Information popup window
|
||||
*
|
||||
* @param message 显示的消息 Displayed message
|
||||
* @param options 信息弹窗可选参数 Information popup optional parameter
|
||||
* @param window 依附于哪个窗口(插件主进程才可使用) Which window it is attached to (only available to the plugin's main process)
|
||||
*/
|
||||
export function info(message: string, options?: MessageDialogOptions, window?: BrowserWindow): Promise<MessageBoxReturnValue>;
|
||||
/**
|
||||
* 警告弹窗
|
||||
* Warning popup
|
||||
*
|
||||
* @param message 警告信息 Warning message
|
||||
* @param options 警告弹窗可选参数 Warning popover optional parameter
|
||||
* @param window 依附于哪个窗口(插件主进程才可使用) Which window it is attached to (only available to the plugin's main process)
|
||||
*/
|
||||
export function warn(message: string, options?: MessageDialogOptions, window?: BrowserWindow): Promise<MessageBoxReturnValue>;
|
||||
/**
|
||||
* 错误弹窗
|
||||
* Error popup window
|
||||
*
|
||||
* @param message 错误信息 The error message
|
||||
* @param options 错误弹窗可选参数 Error popover optional parameter
|
||||
* @param window 依附于哪个窗口(插件主进程才可使用) Which window it is attached to (only available to the plugin's main process)
|
||||
*/
|
||||
export function error(message: string, options?: MessageDialogOptions, window?: BrowserWindow): Promise<MessageBoxReturnValue>;
|
||||
}
|
||||
export namespace EditMode {
|
||||
/**
|
||||
* 标记编辑器进入了一种编辑模式
|
||||
* The tag editor goes into an edit mode
|
||||
*
|
||||
* @param mode 编辑模式的名字 The name of the edit mode
|
||||
*/
|
||||
export function enter(mode: string);
|
||||
/**
|
||||
* 当前所处的编辑模式
|
||||
* The current editing mode
|
||||
*
|
||||
*/
|
||||
export function getMode(): string;
|
||||
}
|
||||
export namespace I18n {
|
||||
export type I18nMap = {
|
||||
[key: string]: I18nMap | string;
|
||||
};
|
||||
/**
|
||||
* 获取当前的语言 zh | en
|
||||
* Get the current language
|
||||
*/
|
||||
export function getLanguage(): string;
|
||||
/**
|
||||
* 传入 key,翻译成当前语言
|
||||
* Passing in the key translates into the current language
|
||||
* 允许翻译变量 {a},传入的第二个参数 obj 内定义 a
|
||||
* The translation variable {a} is allowed, and a is defined in the second argument passed in obj
|
||||
*
|
||||
* @param key 用于翻译的 key 值 The key value for translation
|
||||
* @param obj 翻译字段内如果有 {key} 等可以在这里传入替换字段 If you have {key} in the translation field, you can pass in the replacement field here
|
||||
*/
|
||||
export function t(
|
||||
key: string,
|
||||
obj?: {
|
||||
[key: string]: string;
|
||||
},
|
||||
): string;
|
||||
|
||||
/**
|
||||
* 选择一种翻译语言
|
||||
* Choose a translation language
|
||||
*
|
||||
* @param language 选择当前使用的语言 Select the language currently in use
|
||||
*/
|
||||
export function select(language: string): void;
|
||||
}
|
||||
export namespace Layout {
|
||||
/**
|
||||
* 应用布局信息
|
||||
* Application layout information
|
||||
*
|
||||
* @param json 布局文件内容 Layout file content
|
||||
*/
|
||||
export function apply(json: any);
|
||||
/**
|
||||
* 初始化布局系统
|
||||
* Initialize the layout system
|
||||
*/
|
||||
export function init();
|
||||
}
|
||||
export namespace Logger {
|
||||
/**
|
||||
* 清空所有的日志
|
||||
* Clear all logs
|
||||
*/
|
||||
export function clear(regexp?: string | RegExp): any;
|
||||
/**
|
||||
* 查询所有日志
|
||||
* Query all logs
|
||||
*/
|
||||
export function query(): any;
|
||||
}
|
||||
export namespace Menu {
|
||||
export interface BaseMenuItem {
|
||||
template?: string;
|
||||
type?: string;
|
||||
label?: string;
|
||||
sublabel?: string;
|
||||
checked?: boolean;
|
||||
enabled?: boolean;
|
||||
icon?: string;
|
||||
accelerator?: string;
|
||||
order?: number;
|
||||
group?: string;
|
||||
message?: string;
|
||||
target?: string;
|
||||
params?: any[];
|
||||
click?: Function | null;
|
||||
role?: string;
|
||||
submenu?: MenuTemplateItem[];
|
||||
}
|
||||
export interface MainMenuItem extends BaseMenuItem {
|
||||
path: string;
|
||||
}
|
||||
export interface ContextMenuItem extends BaseMenuItem {
|
||||
accelerator?: string;
|
||||
}
|
||||
export type MenuTemplateItem = BaseMenuItem;
|
||||
export interface PopupOptions {
|
||||
x?: number;
|
||||
y?: number;
|
||||
menu: ContextMenuItem[];
|
||||
}
|
||||
/**
|
||||
* 右键弹窗
|
||||
* Right-click pop-up
|
||||
* 只有面板进程可以使用
|
||||
* Only panel processes can be used
|
||||
*
|
||||
* @param json
|
||||
*/
|
||||
export function popup(json: PopupOptions): any;
|
||||
}
|
||||
export namespace Message {
|
||||
export interface MessageInfo {
|
||||
methods: string[];
|
||||
public?: boolean;
|
||||
description?: string;
|
||||
doc?: string;
|
||||
sync?: boolean;
|
||||
}
|
||||
|
||||
export interface TableBase {
|
||||
[x: string]: any;
|
||||
params: any[];
|
||||
}
|
||||
/**
|
||||
* 发送一个消息,并等待返回
|
||||
* Send a message and wait for it to return
|
||||
*
|
||||
* @param name 目标插件的名字 The name of the target plug-in
|
||||
* @param message 触发消息的名字 The name of the trigger message
|
||||
* @param args 消息需要的参数 The parameters required for the message
|
||||
*/
|
||||
export function request<J extends string, K extends keyof EditorMessageMaps[J]>(
|
||||
name: J,
|
||||
message: K,
|
||||
...args: EditorMessageMaps[J][K]['params']
|
||||
): Promise<EditorMessageMaps[J][K]['result']>;
|
||||
/**
|
||||
* 发送一个消息,没有返回
|
||||
* Send a message, no return
|
||||
*
|
||||
* @param name 目标插件的名字 The name of the target plug-in
|
||||
* @param message 触发消息的名字 The name of the trigger message
|
||||
* @param args 消息需要的参数 The parameters required for the message
|
||||
*/
|
||||
export function send<M extends string, N extends keyof EditorMessageMaps[M]>(
|
||||
name: M,
|
||||
message: N,
|
||||
...args: EditorMessageMaps[M][N]['params']
|
||||
): void;
|
||||
/**
|
||||
* 广播一个消息
|
||||
* Broadcast a message
|
||||
*
|
||||
* @param message 消息的名字 Name of message
|
||||
* @param args 消息附加的参数 Parameter attached to the message
|
||||
*/
|
||||
export function broadcast(message: string, ...args: any[]): void;
|
||||
/**
|
||||
* 新增一个广播消息监听器
|
||||
* Add a new broadcast message listener
|
||||
* 不监听的时候,需要主动取消监听
|
||||
* When not listening, you need to take the initiative to cancel listening
|
||||
*
|
||||
* @param message 消息名 Message name
|
||||
* @param func 处理函数 The processing function
|
||||
*/
|
||||
export function addBroadcastListener(message: string, func: Function): any;
|
||||
/**
|
||||
* 新增一个广播消息监听器
|
||||
* Removes a broadcast message listener
|
||||
*
|
||||
* @param message 消息名 Message name
|
||||
* @param func 处理函数 The processing function
|
||||
*/
|
||||
export function removeBroadcastListener(message: string, func: Function): any;
|
||||
}
|
||||
export namespace Network {
|
||||
/**
|
||||
* 查询当前电脑的 ip 列表
|
||||
* Query the IP list of the current computer
|
||||
*/
|
||||
export function queryIPList(): string[];
|
||||
/**
|
||||
* 测试是否可以联通 passport.cocos.com 服务器
|
||||
* Test whether you can connect to the passport.cocos.com server
|
||||
*/
|
||||
export function testConnectServer(): Promise<boolean>;
|
||||
/**
|
||||
* 检查一个端口是否被占用
|
||||
* Checks if a port is used
|
||||
*
|
||||
* @param port
|
||||
*/
|
||||
export function portIsOccupied(port: number): Promise<boolean>;
|
||||
/**
|
||||
* 测试是否可以联通某一台主机
|
||||
* Test whether a host can be connected
|
||||
*
|
||||
* @param ip
|
||||
*/
|
||||
export function testHost(ip: string): Promise<boolean>;
|
||||
/**
|
||||
* Get 方式请求某个服务器数据
|
||||
* GET requests data from a server
|
||||
*
|
||||
* @param url
|
||||
* @param data
|
||||
*/
|
||||
export function get(
|
||||
url: string,
|
||||
data?: {
|
||||
[index: string]: string | string[];
|
||||
},
|
||||
): Promise<Buffer>;
|
||||
/**
|
||||
* Post 方式请求某个服务器数据
|
||||
* POST requests data from a server
|
||||
*
|
||||
* @param url
|
||||
* @param data
|
||||
*/
|
||||
export function post(
|
||||
url: string,
|
||||
data?: {
|
||||
[index: string]: string | number | string[];
|
||||
},
|
||||
): Promise<Buffer>;
|
||||
/**
|
||||
* 获取某个可用的端口号
|
||||
* get the port that is free
|
||||
*
|
||||
* @param port
|
||||
*/
|
||||
export function getFreePort(port: number): Promise<number>;
|
||||
}
|
||||
export namespace Package {
|
||||
// export module VERSION: string;
|
||||
export interface GetPackageOptions {
|
||||
name?: string;
|
||||
debug?: boolean;
|
||||
path?: string;
|
||||
enable?: boolean;
|
||||
invalid?: boolean;
|
||||
}
|
||||
export interface PackageJson {
|
||||
author?: string;
|
||||
debug?: boolean;
|
||||
description?: string;
|
||||
main?: string;
|
||||
menu?: any;
|
||||
name: string;
|
||||
version: string;
|
||||
windows: string;
|
||||
editor?: string;
|
||||
panel?: any;
|
||||
}
|
||||
export type PathType = 'home' | 'data' | 'temp';
|
||||
/**
|
||||
* 查询插件列表
|
||||
* Query Plug-in List
|
||||
*
|
||||
* @param options
|
||||
*/
|
||||
export function getPackages(options?: GetPackageOptions): Editor.Interface.PackageInfo[];
|
||||
/**
|
||||
* 注册一个插件
|
||||
* Register a plug-in
|
||||
* 谨慎使用,之后会被移除
|
||||
* Use with caution and it will be removed later
|
||||
*
|
||||
* @param path
|
||||
*/
|
||||
export function register(path: string): any;
|
||||
/**
|
||||
* 反注册一个插件
|
||||
* Unregister a plug-in
|
||||
* 谨慎使用,之后会被移除
|
||||
* Use with caution and it will be removed later
|
||||
*
|
||||
* @param path
|
||||
*/
|
||||
export function unregister(path: string): any;
|
||||
/**
|
||||
* 启动一个插件
|
||||
* Enable a plug-in
|
||||
*
|
||||
* @param path
|
||||
*/
|
||||
export function enable(path: string): any;
|
||||
/**
|
||||
* 关闭一个插件
|
||||
* Disable a plug-in
|
||||
*
|
||||
* @param path
|
||||
*/
|
||||
export function disable(path: string, options: any): any;
|
||||
/**
|
||||
* 获取一个插件的几个预制目录地址
|
||||
* Gets several prefab directory addresses for a plug-in
|
||||
*
|
||||
* @param extensionName 扩展的名字 Name of the extension
|
||||
* @param type 地址类型(temp 临时目录,data 需要同步的数据目录,不传则返回现在打开的插件路径) Address type (temp temporary directory, data need to synchronize data directory, do not pass to return the current open plug-in path)
|
||||
*/
|
||||
export function getPath(extensionName: string, type?: PathType): any;
|
||||
}
|
||||
export namespace Panel {
|
||||
/**
|
||||
* 打开一个面板
|
||||
* Open up a panel
|
||||
*
|
||||
* @param name
|
||||
* @param args
|
||||
*/
|
||||
export function open(name: string, ...args: any[]): any;
|
||||
/**
|
||||
* 关闭一个面板
|
||||
* Close a panel
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
export function close(name: string): any;
|
||||
/**
|
||||
* 将焦点传递给一个面板
|
||||
* Pass focus to a panel
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
export function focus(name: string): any;
|
||||
/**
|
||||
* 检查面板是否已经打开
|
||||
* Check that the panel is open
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
export function has(name: string): Promise<boolean>;
|
||||
/**
|
||||
* 查询当前窗口里某个面板里的元素列表
|
||||
* @param name
|
||||
* @param selector
|
||||
*/
|
||||
export function querySelector(name: string, selector: string): Promise<any>;
|
||||
|
||||
export type Selector<$> = { $: Record<keyof $, HTMLElement | null> };
|
||||
|
||||
export type Options<S, M, U extends (...args: any[]) => void> = {
|
||||
/**
|
||||
* @en Listening to panel events
|
||||
* @zh 监听面板事件
|
||||
*/
|
||||
listeners?: {
|
||||
/**
|
||||
* @en Hooks triggered when the panel is displayed
|
||||
* @zh 面板显示的时候触发的钩子
|
||||
*/
|
||||
show?: () => any;
|
||||
/**
|
||||
* @en Hooks triggered when the panel is hidden
|
||||
* @zh 面板隐藏的时候触发的钩子
|
||||
*/
|
||||
hide?: () => any;
|
||||
};
|
||||
|
||||
/**
|
||||
* @en Template of the panel
|
||||
* @zh 面板的内容
|
||||
*/
|
||||
template: string;
|
||||
/**
|
||||
* @en Style of the panel
|
||||
* @zh 面板上的样式
|
||||
* */
|
||||
style?: string;
|
||||
/**
|
||||
* @en Selector of the panel
|
||||
* @zh 快捷选择器
|
||||
*/
|
||||
$?: S;
|
||||
/**
|
||||
* @en Panel built-in function methods that can be called in Messages, Listeners, lifecycle functions
|
||||
* @zh panel 内置的函数方法,可以在 messages、listeners、生命周期函数内调用
|
||||
*/
|
||||
methods?: M;
|
||||
/**
|
||||
* @en Hooks triggered when the panel is update
|
||||
* @zh 面板数据更新后触发的钩子函数
|
||||
*/
|
||||
update?: (...args: Parameters<U>) => void;
|
||||
/**
|
||||
* @en Hooks triggered when the panel is ready
|
||||
* @zh 面板启动后触发的钩子函数
|
||||
*/
|
||||
ready?: () => void;
|
||||
/**
|
||||
* @en The function that will be triggered when the panel is ready to close, and will terminate the closing of the panel if it
|
||||
* returns false
|
||||
* @zh 面板准备关闭的时候会触发的函数,return false 的话,会终止关闭面板
|
||||
* 生命周期函数,在 panel 准备关闭的时候触发
|
||||
* 如果 return false,则会中断关闭流程,请谨慎使用,错误的判断会导致编辑器无法关闭。
|
||||
*/
|
||||
beforeClose?: () => Promise<boolean | void> | boolean | void;
|
||||
/**
|
||||
* @en Hook functions after panel closure
|
||||
* @zh 面板关闭后的钩子函数
|
||||
*/
|
||||
close?: () => void;
|
||||
} & ThisType<Selector<S> & M>; // merge them together
|
||||
|
||||
export function define<U extends (...args: any[]) => void, Selector = Record<string, string>, M = Record<string, Function>>(
|
||||
options: Options<Selector, M, U>,
|
||||
): any;
|
||||
}
|
||||
export namespace Profile {
|
||||
export type preferencesProtocol = 'default' | 'global' | 'local';
|
||||
export type projectProtocol = 'default' | 'project';
|
||||
export type tempProtocol = 'temp';
|
||||
export interface ProfileGetOptions {
|
||||
type: 'deep' | 'current' | 'inherit';
|
||||
}
|
||||
export interface ProfileObj {
|
||||
get: (key?: string, options?: ProfileGetOptions) => any;
|
||||
set: (key?: string, value?: any) => any;
|
||||
remove: (key: string) => void;
|
||||
save: () => void;
|
||||
clear: () => void;
|
||||
reset: () => void;
|
||||
}
|
||||
/**
|
||||
* 读取插件配置
|
||||
* Read the plug-in configuration
|
||||
*
|
||||
* @param name 插件名 The plugin name
|
||||
* @param key 配置路径 Configure path
|
||||
* @param type 配置的类型,选填 Type of configuration, optional(global,local,default)
|
||||
*/
|
||||
export function getConfig(name: string, key?: string, type?: preferencesProtocol): Promise<any>;
|
||||
/**
|
||||
* 设置插件配置
|
||||
* Set the plug-in configuration
|
||||
*
|
||||
* @param name 插件名 The plugin name
|
||||
* @param key 配置路径 Configure path
|
||||
* @param value 配置的值 The value of the configuration
|
||||
* @param type 配置的类型,选填 Type of configuration, optional(global,local,default)
|
||||
*/
|
||||
export function setConfig(name: string, key: string, value: any, type?: preferencesProtocol): Promise<void>;
|
||||
/**
|
||||
* 删除某个插件配置
|
||||
* Delete a plug-in configuration
|
||||
*
|
||||
* @param name 插件名 The plugin name
|
||||
* @param key 配置路径 Configure path
|
||||
* @param type 配置的类型,选填 Type of configuration, optional(global,local,default)
|
||||
*/
|
||||
export function removeConfig(name: string, key: string, type?: preferencesProtocol): Promise<void>;
|
||||
/**
|
||||
* 读取插件内的项目配置
|
||||
* Read the project configuration within the plug-in
|
||||
*
|
||||
* @param name 插件名 The plugin name
|
||||
* @param key 配置路径 Configure path
|
||||
* @param type 配置的类型,选填 Type of configuration, optional(project,default)
|
||||
*/
|
||||
export function getProject(name: string, key?: string, type?: projectProtocol): Promise<any>;
|
||||
/**
|
||||
* 设置插件内的项目配置
|
||||
* Set the project configuration within the plug-in
|
||||
*
|
||||
* @param name 插件名 The plugin name
|
||||
* @param key 配置路径 Configure path
|
||||
* @param value 配置的值 The value of the configuration
|
||||
* @param type 配置的类型,选填 Type of configuration, optional(project,default)
|
||||
*/
|
||||
export function setProject(name: string, key: string, value: any, type?: projectProtocol): Promise<void>;
|
||||
/**
|
||||
* 删除插件内的项目配置
|
||||
* Delete the project configuration within the plug-in
|
||||
*
|
||||
* @param name 插件名 The plugin name
|
||||
* @param key 配置路径 Configure path
|
||||
* @param type 配置的类型,选填 Type of configuration, optional(project,default)
|
||||
*/
|
||||
export function removeProject(name: string, key: string, type?: projectProtocol): Promise<void>;
|
||||
/**
|
||||
* 读取插件配置
|
||||
* Read the plug-in configuration
|
||||
*
|
||||
* @param name 插件名 The plugin name
|
||||
* @param key 配置路径 Configure path
|
||||
*/
|
||||
export function getTemp(name: string, key?: string): Promise<any>;
|
||||
/**
|
||||
* 设置插件配置
|
||||
* Set the plug-in configuration
|
||||
*
|
||||
* @param name 插件名 The plugin name
|
||||
* @param key 配置路径 Configure path
|
||||
* @param value 配置的值 The value of the configuration
|
||||
*/
|
||||
export function setTemp(name: string, key: string, value: any): Promise<void>;
|
||||
/**
|
||||
* 删除某个插件配置
|
||||
* Delete a plug-in configuration
|
||||
*
|
||||
* @param name 插件名 The plugin name
|
||||
* @param key 配置路径 Configure path
|
||||
*/
|
||||
export function removeTemp(name: string, key: string): Promise<void>;
|
||||
/**
|
||||
* 迁移插件某个版本的本地配置数据到编辑器最新版本
|
||||
* Migrate the local configuration data of a certain version of the plugin to the latest version of the editor
|
||||
*
|
||||
* @param pkgName
|
||||
* @param profileVersion
|
||||
* @param profileData
|
||||
*/
|
||||
export function migrateLocal(pkgName: string, profileVersion: string, profileData: any): any;
|
||||
/**
|
||||
* 迁移插件某个版本的全局配置数据到编辑器最新版本
|
||||
* Migrate the global configuration data of a certain version of the plugin to the latest version of the editor
|
||||
*
|
||||
* @param pkgName
|
||||
* @param profileVersion
|
||||
* @param profileData
|
||||
*/
|
||||
export function migrateGlobal(pkgName: string, profileVersion: string, profileData: any): any;
|
||||
/**
|
||||
* 迁移插件某个版本的项目配置数据到编辑器最新版本
|
||||
* Migrate the project configuration data of a certain version of the plugin to the latest version of the editor
|
||||
*
|
||||
* @param pkgName
|
||||
* @param profileVersion
|
||||
* @param profileData
|
||||
*/
|
||||
export function migrateProject(pkgName: string, profileVersion: string, profileData: any): any;
|
||||
}
|
||||
export namespace Project {
|
||||
/**
|
||||
* 创建一个项目
|
||||
* Creating a project
|
||||
* 谨慎使用,之后会被移除
|
||||
* Use with caution and it will be removed later
|
||||
*/
|
||||
export function create(): any;
|
||||
/**
|
||||
* 打开一个项目
|
||||
* Open a project
|
||||
* 谨慎使用,之后会被移除
|
||||
* Use with caution and it will be removed later
|
||||
*
|
||||
* @param path
|
||||
*/
|
||||
export function open(path?: string): Promise<any>;
|
||||
/**
|
||||
* 添加一个项目
|
||||
* Add a project
|
||||
* 谨慎使用,之后会被移除
|
||||
* Use with caution and it will be removed later
|
||||
*
|
||||
* @param path
|
||||
*/
|
||||
export function add(path: string): any;
|
||||
/**
|
||||
* 当前项目路径
|
||||
* Current project path
|
||||
*/
|
||||
export const path: string;
|
||||
/**
|
||||
* 当前项目 uuid
|
||||
* The current project UUID
|
||||
*/
|
||||
export const uuid: string;
|
||||
/**
|
||||
* 当前项目名称(取自 package.json)
|
||||
* The current project name
|
||||
*/
|
||||
export const name: string;
|
||||
/**
|
||||
* 当前项目临时文件夹
|
||||
* Temporary folder for current project
|
||||
*/
|
||||
export const tmpDir: string;
|
||||
/**
|
||||
* 当前项目类型
|
||||
* 谨慎使用,之后会被移除
|
||||
* Use with caution and it will be removed later
|
||||
*/
|
||||
export const type: '2d' | '3d';
|
||||
}
|
||||
export namespace Selection {
|
||||
/**
|
||||
* 选中一个或者一组元素
|
||||
* Select one or a group of elements
|
||||
*
|
||||
* @param type
|
||||
* @param uuid
|
||||
*/
|
||||
export function select(type: string, uuid: string | string[]): any;
|
||||
/**
|
||||
* 取消一个或者一组元素的选中状态
|
||||
* To deselect one or a group of elements
|
||||
*
|
||||
* @param type
|
||||
* @param uuid
|
||||
*/
|
||||
export function unselect(type: string, uuid: string | string[]): any;
|
||||
/**
|
||||
* 清空一个类型的所有选中元素
|
||||
* Clears all selected elements of a type
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
export function clear(type: string): any;
|
||||
/**
|
||||
* 更新当前选中的类型数据
|
||||
* Updates the currently selected type data
|
||||
*
|
||||
* @param type
|
||||
* @param uuids
|
||||
*/
|
||||
export function update(type: string, uuids: string[]): any;
|
||||
/**
|
||||
* 悬停触碰了某个元素
|
||||
* Hover touches an element
|
||||
* 会发出 selection:hover 的广播消息
|
||||
* A broadcast message for selection:hover is issued
|
||||
*
|
||||
* @param type
|
||||
* @param uuid
|
||||
*/
|
||||
export function hover(type: string, uuid?: string): any;
|
||||
/**
|
||||
* 获取最后选中的元素的类型
|
||||
* Gets the type of the last selected element
|
||||
*/
|
||||
export function getLastSelectedType(): string;
|
||||
/**
|
||||
* 获取某个类型内,最后选中的元素
|
||||
* Gets the last selected element of a type
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
export function getLastSelected(type: string): string;
|
||||
/**
|
||||
* 获取一个类型选中的所有元素数组
|
||||
* Gets an array of all elements selected for a type
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
export function getSelected(type: string): string[];
|
||||
}
|
||||
export namespace Task {
|
||||
export interface NoticeOptions {
|
||||
title: string;
|
||||
message?: string;
|
||||
type?: 'error' | 'warn' | 'log' | 'success';
|
||||
source?: string;
|
||||
timeout?: number;
|
||||
}
|
||||
/**
|
||||
* 添加一个同步任务
|
||||
* Add a synchronous task
|
||||
* 会在主窗口显示一个遮罩层
|
||||
* A mask layer is displayed in the main window
|
||||
*
|
||||
* @param title 任务名字 The task name
|
||||
* @param describe 任务描述 Task description
|
||||
* @param message 任务内容 Content of the task
|
||||
*/
|
||||
export function addSyncTask(title: string, describe?: string, message?: string): any;
|
||||
/**
|
||||
* 更新某一个同步任务显示的数据
|
||||
* Update the data displayed by a synchronous task
|
||||
*
|
||||
* @param title 任务名字 The task name
|
||||
* @param describe 任务描述 Task description
|
||||
* @param message 任务内容 Content of the task
|
||||
*/
|
||||
export function updateSyncTask(title: string, describe?: string, message?: string): any;
|
||||
/**
|
||||
* 删除一个同步任务
|
||||
* Delete a synchronous task
|
||||
*
|
||||
* @param title 任务的名字 The name of the task
|
||||
*/
|
||||
export function removeSyncTask(title: string): any;
|
||||
/**
|
||||
* 添加一个通知
|
||||
* Add a notification
|
||||
*
|
||||
* @param options 消息配置 Message configuration
|
||||
*/
|
||||
export function addNotice(options: NoticeOptions): any;
|
||||
/**
|
||||
* 删除一个通知
|
||||
* Delete a notification
|
||||
*
|
||||
* @param id 通知 id Notification ID
|
||||
*/
|
||||
export function removeNotice(id: number): any;
|
||||
/**
|
||||
* 修改 notice 自动移除的时间
|
||||
* Modify notice automatic removal time
|
||||
*
|
||||
* @param id 通知 id Notification ID
|
||||
* @param time 超时时间 timeout
|
||||
*/
|
||||
export function changeNoticeTimeout(id: number, time: number): any;
|
||||
/**
|
||||
* 查询所有通知
|
||||
* Query all notifications
|
||||
*/
|
||||
export function queryNotices(): any;
|
||||
/**
|
||||
* 页面进程立即同步一次主进程数据
|
||||
* The page process synchronizes the master process data immediately
|
||||
* 谨慎使用,之后会被移除
|
||||
* Use with caution and it will be removed later
|
||||
*/
|
||||
export function sync(): any;
|
||||
}
|
||||
export namespace Theme {
|
||||
/**
|
||||
* 获取所有主题的名字
|
||||
* Gets the names of all topics
|
||||
*/
|
||||
export function getList(): any;
|
||||
/**
|
||||
* 使用某个皮肤
|
||||
* Use a certain skin
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
export function use(name?: string): any;
|
||||
}
|
||||
export namespace UI {
|
||||
/**
|
||||
* 在当前页面上注册一个自定义节点
|
||||
* Registers a custom node on the current page
|
||||
* 谨慎使用,之后会被移除
|
||||
* Use with caution and it will be removed later
|
||||
*
|
||||
* @param tagName 元素名字
|
||||
* @param element 元素的定义函数
|
||||
*/
|
||||
export function register(tagName: string, element: any): void;
|
||||
export const Base: any;
|
||||
export const Button: any;
|
||||
export const Input: any;
|
||||
export const NumInput: any;
|
||||
export const Loading: any;
|
||||
export const Checkbox: any;
|
||||
export const Section: any;
|
||||
export const Select: any;
|
||||
export const Bit: any;
|
||||
export const Slider: any;
|
||||
export const ColorPicker: any;
|
||||
export const Color: any;
|
||||
export const DragItem: any;
|
||||
export const DragArea: any;
|
||||
export const DragObject: any;
|
||||
export const Prop: any;
|
||||
export const Tooltip: any;
|
||||
export const TextArea: any;
|
||||
export const Progress: any;
|
||||
export const Label: any;
|
||||
export const Code: any;
|
||||
export const Tab: any;
|
||||
export const Gradient: any;
|
||||
export const GradientPicker: any;
|
||||
export const Icon: any;
|
||||
export const File: any;
|
||||
export const Link: any;
|
||||
export const Image: any;
|
||||
export const QRCode: any;
|
||||
export const Markdown: any;
|
||||
export const Curve: any;
|
||||
export const CurveEditor: any;
|
||||
export const NodeGraph: any;
|
||||
}
|
||||
export namespace User {
|
||||
export interface UserData {
|
||||
session_id: string;
|
||||
session_key: string;
|
||||
cocos_uid: string;
|
||||
email: string;
|
||||
nickname: string;
|
||||
}
|
||||
/**
|
||||
* 跳过 User
|
||||
* Skip the User
|
||||
* 谨慎使用,之后会被移除
|
||||
* Use with caution and it will be removed later
|
||||
*/
|
||||
export function skip(): any;
|
||||
/**
|
||||
* 获取 user 数据
|
||||
* Get user data
|
||||
*/
|
||||
export function getData(): Promise<UserData>;
|
||||
/**
|
||||
* 检查用户是否登陆
|
||||
* Check if the user is logged in
|
||||
*/
|
||||
export function isLoggedIn(): Promise<boolean>;
|
||||
/**
|
||||
* 用户登陆
|
||||
* The user login
|
||||
* 失败会抛出异常
|
||||
* Failure throws an exception
|
||||
*
|
||||
* @param username
|
||||
* @param password
|
||||
*/
|
||||
export function login(username: string, password: string): Promise<UserData>;
|
||||
/**
|
||||
* 退出登陆
|
||||
* Logged out
|
||||
* 失败会抛出异常
|
||||
* Failure throws an exception
|
||||
*/
|
||||
export function logout(): void;
|
||||
/**
|
||||
* 获取用户 token
|
||||
* Get user token
|
||||
* 失败会抛出异常
|
||||
* Failure throws an exception
|
||||
*/
|
||||
export function getUserToken(): Promise<string>;
|
||||
/**
|
||||
* 根据插件 id 返回 session code
|
||||
* Returns the session code based on the plug-in ID
|
||||
*
|
||||
* @param extensionId
|
||||
*/
|
||||
export function getSessionCode(extensionId: number): Promise<string>;
|
||||
/**
|
||||
* 显示用户登陆遮罩层
|
||||
* Shows user login mask layer
|
||||
* 谨慎使用,之后会被移除
|
||||
* Use with caution and it will be removed later
|
||||
*/
|
||||
export function showMask(): void;
|
||||
/**
|
||||
* 隐藏用户登陆遮罩层
|
||||
* Hide user login mask layer
|
||||
* 谨慎使用,之后会被移除
|
||||
* Use with caution and it will be removed later
|
||||
*/
|
||||
export function hideMask(): void;
|
||||
/**
|
||||
* 监听事件
|
||||
* Listen for an event
|
||||
* 谨慎使用,之后会被移除
|
||||
* Use with caution and it will be removed later
|
||||
* @param action
|
||||
* @param handle
|
||||
*/
|
||||
export function on(action: string, handle: Function): any;
|
||||
/**
|
||||
* 监听一次事件
|
||||
* Listening for one event
|
||||
* 谨慎使用,之后会被移除
|
||||
* Use with caution and it will be removed later
|
||||
* @param action
|
||||
* @param handle
|
||||
*/
|
||||
export function once(action: string, handle: Function): any;
|
||||
/**
|
||||
* 取消已经监听的事件
|
||||
* Cancels the event you are listening for
|
||||
* 谨慎使用,之后会被移除
|
||||
* Use with caution and it will be removed later
|
||||
* @param action
|
||||
* @param handle
|
||||
*/
|
||||
export function removeListener(action: string, handle: Function): any;
|
||||
}
|
||||
export namespace Utils {
|
||||
export namespace File {
|
||||
/**
|
||||
* 初始化一个可用的文件名
|
||||
* Initializes a available filename
|
||||
* 返回可用名称的文件路径
|
||||
* Returns the file path with the available name
|
||||
*
|
||||
* @param file 初始文件路径 Initial file path
|
||||
*/
|
||||
export function getName(file: string): string;
|
||||
interface UnzipOptions {
|
||||
peel?: boolean;
|
||||
}
|
||||
/**
|
||||
* 解压文件夹
|
||||
* Unzip folder
|
||||
*
|
||||
* @param zip
|
||||
* @param target
|
||||
* @param options
|
||||
*/
|
||||
export function unzip(zip: string, target: string, options?: UnzipOptions): Promise<void>;
|
||||
/**
|
||||
* 复制一个文件到另一个位置
|
||||
* Copy a file to another location
|
||||
*
|
||||
* @param source
|
||||
* @param target
|
||||
*/
|
||||
export function copy(source: string, target: string): void;
|
||||
}
|
||||
export namespace Path {
|
||||
/**
|
||||
* 返回一个不含扩展名的文件名
|
||||
* @param path
|
||||
*/
|
||||
export function basenameNoExt(path: string): string;
|
||||
/**
|
||||
* 将 \ 统一换成 /
|
||||
* @param path
|
||||
*/
|
||||
export function slash(path: string): string;
|
||||
/**
|
||||
* 去除路径最后的斜杆,返回一个不带斜杆的路径
|
||||
* @param path
|
||||
*/
|
||||
export function stripSep(path: string): string;
|
||||
/**
|
||||
* 删除一个路径的扩展名
|
||||
* @param path
|
||||
*/
|
||||
export function stripExt(path: string): string;
|
||||
/**
|
||||
* 判断路径 pathA 是否包含 pathB
|
||||
* pathA = foo/bar, pathB = foo/bar/foobar, return true
|
||||
* pathA = foo/bar, pathB = foo/bar, return true
|
||||
* pathA = foo/bar/foobar, pathB = foo/bar, return false
|
||||
* pathA = foo/bar/foobar, pathB = foobar/bar/foo, return false
|
||||
* @param pathA
|
||||
* @param pathB
|
||||
*/
|
||||
export function contains(pathA: string, pathB: string): boolean;
|
||||
/**
|
||||
* 格式化路径
|
||||
* 如果是 Windows 平台,需要将盘符转成小写进行判断
|
||||
* @param path
|
||||
*/
|
||||
export function normalize(path: string): string;
|
||||
export const join: typeof NodeJSPath.join;
|
||||
export const resolve: typeof NodeJSPath.resolve;
|
||||
export const isAbsolute: typeof NodeJSPath.isAbsolute;
|
||||
export const relative: typeof NodeJSPath.relative;
|
||||
export const dirname: typeof NodeJSPath.dirname;
|
||||
export const basename: typeof NodeJSPath.basename;
|
||||
export const extname: typeof NodeJSPath.extname;
|
||||
export const sep: '\\' | '/';
|
||||
export const delimiter: ';' | ':';
|
||||
export const parse: typeof NodeJSPath.parse;
|
||||
export const format: typeof NodeJSPath.format;
|
||||
}
|
||||
export namespace Math {
|
||||
/**
|
||||
* 取给定边界范围的值
|
||||
* Take the value of the given boundary range
|
||||
* @param {number} val
|
||||
* @param {number} min
|
||||
* @param {number} max
|
||||
*/
|
||||
export function clamp(val: number, min: number, max: number): number;
|
||||
/**
|
||||
* @function clamp01
|
||||
* @param {number} val
|
||||
* @returns {number}
|
||||
*
|
||||
* Clamps a value between 0 and 1.
|
||||
*/
|
||||
export function clamp01(val: number): number;
|
||||
/**
|
||||
* 加法函数
|
||||
* 入参:函数内部转化时会先转字符串再转数值,因而传入字符串或 number 均可
|
||||
* 返回值:arg1 加上 arg2 的精确结果
|
||||
* @param {number|string} arg1
|
||||
* @param {number|string} arg2
|
||||
*/
|
||||
export function add(arg1: number | string, arg2: number | string): number;
|
||||
/**
|
||||
* 减法函数
|
||||
* 入参:函数内部转化时会先转字符串再转数值,因而传入字符串或number均可
|
||||
* 返回值:arg1 减 arg2的精确结果
|
||||
* @param {number|string} arg1
|
||||
* @param {number|string} arg2
|
||||
*/
|
||||
export function sub(arg1: number | string, arg2: number | string): number;
|
||||
/**
|
||||
* 保留小数点
|
||||
* @param val
|
||||
* @param num
|
||||
*/
|
||||
export function toFixed(val: number, num: number): number;
|
||||
}
|
||||
export namespace Parse {
|
||||
interface WhenParam {
|
||||
PanelName?: string;
|
||||
EditMode?: string;
|
||||
ProjectType?: string;
|
||||
}
|
||||
/**
|
||||
* 解析 when 参数
|
||||
* when 的格式:
|
||||
* PanelName === '' && EditMode === ''
|
||||
* 整理后的数据格式:
|
||||
* {
|
||||
* PanelName: '',
|
||||
* EditMode: '',
|
||||
* }
|
||||
*/
|
||||
export function when(when: string): WhenParam;
|
||||
/**
|
||||
* 判断一个 when 数据是否符合当前条件
|
||||
* @param when
|
||||
*/
|
||||
export function checkWhen(when: string): boolean;
|
||||
}
|
||||
export namespace Url {
|
||||
/**
|
||||
* 快捷获取文档路径
|
||||
* @param relativeUrl
|
||||
* @param type
|
||||
*/
|
||||
export function getDocUrl(relativeUrl: string, type?: 'manual' | 'api'): string;
|
||||
}
|
||||
|
||||
export namespace UUID {
|
||||
/**
|
||||
* 压缩 UUID
|
||||
* compress UUID
|
||||
* @param uuid
|
||||
* @param min
|
||||
*/
|
||||
export function compressUUID(uuid: string, min: boolean): string;
|
||||
/**
|
||||
* 解压 UUID
|
||||
* decompress the UUID
|
||||
* @param str
|
||||
*/
|
||||
export function decompressUUID(str: string): string;
|
||||
/**
|
||||
* 检查输入字符串是否是 UUID
|
||||
* Check whether the input string is a UUID
|
||||
* @param str
|
||||
*/
|
||||
export function isUUID(str: string): string;
|
||||
/**
|
||||
* 生成一个新的 uuid
|
||||
*/
|
||||
export function generate(): string;
|
||||
}
|
||||
}
|
||||
export namespace Module {
|
||||
/**
|
||||
* 导入一个项目模块。
|
||||
* @param url 项目模块的 Database URL。
|
||||
* @experimental 实验性质。
|
||||
*/
|
||||
export function importProjectModule(url: string): Promise<unknown>;
|
||||
}
|
||||
}
|
||||
}
|
||||
16090
extensions/app/engine/@types/electron.d.ts
vendored
Normal file
16090
extensions/app/engine/@types/electron.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
61
extensions/app/engine/@types/extension.d.ts
vendored
Normal file
61
extensions/app/engine/@types/extension.d.ts
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
declare namespace Editor {
|
||||
|
||||
namespace Interface {
|
||||
// ---- Package ---- start
|
||||
interface PackageInfo {
|
||||
debug: boolean;
|
||||
enable: boolean;
|
||||
// TODO 更名为 packageJSON 更合适
|
||||
info: PackageJson;
|
||||
invalid: boolean;
|
||||
name: string;
|
||||
path: string;
|
||||
version: string;
|
||||
}
|
||||
|
||||
interface PackageJson {
|
||||
name: string;
|
||||
version: string;
|
||||
|
||||
title?: string;
|
||||
author?: string;
|
||||
debug?: boolean;
|
||||
description?: string;
|
||||
main?: string;
|
||||
editor?: string;
|
||||
panel?: any;
|
||||
contributions?: {
|
||||
[key: string]: any;
|
||||
builder?: string; // 构建插件注册脚本
|
||||
};
|
||||
}
|
||||
// ---- Package ---- end
|
||||
|
||||
// ---- UI ---- start
|
||||
interface PanelInfo {
|
||||
template?: string;
|
||||
style?: string;
|
||||
listeners?: { [key: string]: () => {} };
|
||||
methods?: { [key: string]: Function };
|
||||
$?: { [key: string]: string };
|
||||
ready?(): void;
|
||||
update?(...args: any[]): void;
|
||||
beforeClose?(): void;
|
||||
close?(): void;
|
||||
}
|
||||
|
||||
namespace UIKit {
|
||||
interface UIPanelInfo extends PanelInfo {
|
||||
// 向上触发事件
|
||||
dispath(eventName: string, ...arg: any): void;
|
||||
}
|
||||
|
||||
interface EditorElementBase extends HTMLElement {
|
||||
value: any;
|
||||
dispath: (name: string, event: any) => void;
|
||||
}
|
||||
|
||||
}
|
||||
// ---- UI ---- end
|
||||
}
|
||||
}
|
||||
2
extensions/app/engine/@types/index.d.ts
vendored
Normal file
2
extensions/app/engine/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/// <reference path="./editor.d.ts"/>
|
||||
/// <reference path="./message.d.ts"/>
|
||||
27
extensions/app/engine/@types/message.d.ts
vendored
Normal file
27
extensions/app/engine/@types/message.d.ts
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import * as AssetDB from './packages/asset-db/@types/message';
|
||||
import * as Scene from './packages/scene/@types/message';
|
||||
import * as Engine from './packages/engine/@types/message';
|
||||
import * as Builder from './packages/builder/@types/public/message';
|
||||
import * as Programming from './packages/programming/@types/message';
|
||||
// import * as Extension from './packages/extension/@types/message';
|
||||
|
||||
declare global {
|
||||
interface EditorMessageContent {
|
||||
params: any[],
|
||||
result: any;
|
||||
}
|
||||
|
||||
interface EditorMessageMap {
|
||||
[x: string]: EditorMessageContent;
|
||||
}
|
||||
|
||||
interface EditorMessageMaps {
|
||||
[x: string]: EditorMessageMap;
|
||||
'asset-db': AssetDB.message;
|
||||
'scene': Scene.message;
|
||||
'engine': Engine.message;
|
||||
'builder': Builder.message;
|
||||
'programming': Programming.message,
|
||||
// 'extension': Extension.message;
|
||||
}
|
||||
}
|
||||
14
extensions/app/engine/@types/packages/alipay-mini-game/@types/index.d.ts
vendored
Normal file
14
extensions/app/engine/@types/packages/alipay-mini-game/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
/// <reference path='../../../@types/index'/>
|
||||
|
||||
export * from '@editor/library-type/packages/builder/@types/protect';
|
||||
import { IInternalBuildOptions, IPolyFills, ISettings } from '@editor/library-type/packages/builder/@types/protect';
|
||||
|
||||
export type IOrientation = 'landscape' | 'portrait';
|
||||
|
||||
export interface ITaskOption extends IInternalBuildOptions {
|
||||
packages: {
|
||||
'alipay-mini-game': {
|
||||
deviceOrientation: IOrientation;
|
||||
};
|
||||
};
|
||||
}
|
||||
72
extensions/app/engine/@types/packages/android/@types/index.d.ts
vendored
Normal file
72
extensions/app/engine/@types/packages/android/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
/// <reference path='../../../@types/index'/>
|
||||
export * from '@editor/library-type/packages/builder/@types/protect';
|
||||
|
||||
import { IInternalBuildOptions, InternalBuildResult } from '@editor/library-type/packages/builder/@types/protect';
|
||||
import { IOptions as INativeOption } from '@editor/library-type/packages/native';
|
||||
|
||||
export type IOrientation = 'landscape' | 'portrait';
|
||||
|
||||
export interface ITaskOption extends IInternalBuildOptions {
|
||||
packages: {
|
||||
'android': IOptions;
|
||||
native: INativeOption;
|
||||
}
|
||||
}
|
||||
|
||||
export type IAppABI = 'armeabi-v7a' | 'arm64-v8a' | 'x86' | 'x86_64';
|
||||
|
||||
export interface IOptions {
|
||||
packageName: string;
|
||||
orientation: {
|
||||
landscapeRight: boolean;
|
||||
landscapeLeft: boolean;
|
||||
portrait: boolean;
|
||||
upsideDown: boolean;
|
||||
},
|
||||
|
||||
apiLevel: number;
|
||||
appABIs: IAppABI[];
|
||||
|
||||
useDebugKeystore: boolean;
|
||||
keystorePath: string;
|
||||
keystorePassword: string;
|
||||
keystoreAlias: string;
|
||||
keystoreAliasPassword: string;
|
||||
|
||||
appBundle: boolean;
|
||||
androidInstant: boolean;
|
||||
remoteUrl: string;
|
||||
sdkPath: string;
|
||||
ndkPath: string;
|
||||
|
||||
swappy: boolean;
|
||||
|
||||
renderBackEnd: {
|
||||
vulkan: boolean;
|
||||
gles3: boolean;
|
||||
gles2: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
export interface IBuildResult extends InternalBuildResult {
|
||||
userFrameWorks: boolean; // 是否使用用户的配置数据
|
||||
}
|
||||
|
||||
export interface ICertificateSetting {
|
||||
country: string;
|
||||
state: string;
|
||||
locality: string;
|
||||
organizationalUnit: string;
|
||||
organization: string;
|
||||
email: string;
|
||||
certificatePath: string;
|
||||
|
||||
password: string; // 密钥密码
|
||||
confirmPassword: string; // 确认密钥密码
|
||||
|
||||
alias: string; // 密钥别名
|
||||
aliasPassword: string;
|
||||
confirmAliasPassword: string;
|
||||
|
||||
validity: number; // 有效期
|
||||
}
|
||||
179
extensions/app/engine/@types/packages/asset-db/@types/message.d.ts
vendored
Normal file
179
extensions/app/engine/@types/packages/asset-db/@types/message.d.ts
vendored
Normal file
@@ -0,0 +1,179 @@
|
||||
import { AssetInfo, QueryAssetsOption, AssetOperationOption, AssetDBOptions, IAssetMeta } from './public';
|
||||
|
||||
export interface message extends EditorMessageMap {
|
||||
'query-ready': {
|
||||
params: [],
|
||||
result: boolean,
|
||||
},
|
||||
'create-asset': {
|
||||
params: [
|
||||
string,
|
||||
string | Buffer | null,
|
||||
] | [
|
||||
string,
|
||||
string | Buffer | null,
|
||||
AssetOperationOption,
|
||||
],
|
||||
result: AssetInfo | null,
|
||||
},
|
||||
'import-asset': {
|
||||
params: [
|
||||
string,
|
||||
string,
|
||||
] | [
|
||||
string,
|
||||
string,
|
||||
AssetOperationOption,
|
||||
],
|
||||
result: AssetInfo | null,
|
||||
},
|
||||
'copy-asset': {
|
||||
params: [
|
||||
string,
|
||||
string,
|
||||
] | [
|
||||
string,
|
||||
string,
|
||||
AssetOperationOption,
|
||||
],
|
||||
result: AssetInfo | null,
|
||||
},
|
||||
'move-asset': {
|
||||
params: [
|
||||
string,
|
||||
string,
|
||||
] | [
|
||||
string,
|
||||
string,
|
||||
AssetOperationOption,
|
||||
],
|
||||
result: AssetInfo | null,
|
||||
},
|
||||
'delete-asset': {
|
||||
params: [
|
||||
string,
|
||||
],
|
||||
result: AssetInfo | null,
|
||||
},
|
||||
'open-asset': {
|
||||
params: [
|
||||
string,
|
||||
],
|
||||
result: void,
|
||||
},
|
||||
'save-asset': {
|
||||
params: [
|
||||
string,
|
||||
string | Buffer,
|
||||
],
|
||||
result: AssetInfo | null,
|
||||
},
|
||||
'save-asset-meta': {
|
||||
params: [
|
||||
string,
|
||||
string,
|
||||
],
|
||||
result: AssetInfo | null,
|
||||
},
|
||||
'reimport-asset': {
|
||||
params: [
|
||||
string,
|
||||
],
|
||||
result: boolean,
|
||||
},
|
||||
'refresh-asset': {
|
||||
params: [
|
||||
string
|
||||
],
|
||||
result: boolean,
|
||||
},
|
||||
'query-asset-info': {
|
||||
params: [
|
||||
string, // uuid | url | path
|
||||
],
|
||||
result: AssetInfo | null,
|
||||
},
|
||||
'query-asset-meta': {
|
||||
params: [
|
||||
string,
|
||||
],
|
||||
result: IAssetMeta | null,
|
||||
},
|
||||
'query-path': {
|
||||
params: [
|
||||
string,
|
||||
],
|
||||
result: string | null,
|
||||
},
|
||||
'query-url': {
|
||||
params: [
|
||||
string
|
||||
],
|
||||
result: string | null,
|
||||
},
|
||||
'query-uuid': {
|
||||
params: [
|
||||
string
|
||||
],
|
||||
result: string | null,
|
||||
},
|
||||
'query-assets': {
|
||||
params: [] | [
|
||||
QueryAssetsOption,
|
||||
],
|
||||
result: AssetInfo[],
|
||||
},
|
||||
'generate-available-url': {
|
||||
params: [
|
||||
string,
|
||||
],
|
||||
result: string,
|
||||
},
|
||||
|
||||
// private
|
||||
|
||||
'query-asset-mtime': {
|
||||
params: [
|
||||
string
|
||||
],
|
||||
result: string | null,
|
||||
},
|
||||
'refresh': {
|
||||
params: [],
|
||||
result: void,
|
||||
},
|
||||
'open-devtools': {
|
||||
params: [],
|
||||
result: void,
|
||||
},
|
||||
'query-db-info': {
|
||||
params: [
|
||||
string,
|
||||
],
|
||||
result: AssetDBOptions,
|
||||
},
|
||||
'create-asset-dialog': {
|
||||
params: [
|
||||
string,
|
||||
] | [
|
||||
string,
|
||||
string,
|
||||
],
|
||||
result: string | null,
|
||||
},
|
||||
'init-asset': {
|
||||
params: [
|
||||
string,
|
||||
string,
|
||||
],
|
||||
result: AssetInfo | null,
|
||||
},
|
||||
'query-all-importer': {
|
||||
params: [],
|
||||
result: string[],
|
||||
},
|
||||
'query-all-asset-types': {
|
||||
params: [],
|
||||
result: string[],
|
||||
},
|
||||
}
|
||||
117
extensions/app/engine/@types/packages/asset-db/@types/public.d.ts
vendored
Normal file
117
extensions/app/engine/@types/packages/asset-db/@types/public.d.ts
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
// Basic information about the resource
|
||||
// 资源的基础信息
|
||||
export interface AssetInfo {
|
||||
// Asset name
|
||||
// 资源名字
|
||||
name: string;
|
||||
// Asset display name
|
||||
// 资源用于显示的名字
|
||||
displayName: string;
|
||||
// URL
|
||||
source: string;
|
||||
// loader 加载的层级地址
|
||||
path: string;
|
||||
// loader 加载地址会去掉扩展名,这个参数不去掉
|
||||
url: string;
|
||||
// 绝对路径
|
||||
file: string;
|
||||
// 资源的唯一 ID
|
||||
uuid: string;
|
||||
// 使用的导入器名字
|
||||
importer: string;
|
||||
// 类型
|
||||
type: string;
|
||||
// 是否是文件夹
|
||||
isDirectory: boolean;
|
||||
// 导入资源的 map
|
||||
library: { [key: string]: string };
|
||||
// 子资源 map
|
||||
subAssets: { [key: string]: AssetInfo };
|
||||
// 是否显示
|
||||
visible: boolean;
|
||||
// 是否只读
|
||||
readonly: boolean;
|
||||
|
||||
// 虚拟资源可以实例化成实体的话,会带上这个扩展名
|
||||
instantiation?: string;
|
||||
// 跳转指向资源
|
||||
redirect?: IRedirectInfo;
|
||||
// 继承类型
|
||||
extends?: string[];
|
||||
// 是否导入完成
|
||||
imported: boolean;
|
||||
// 是否导入失败
|
||||
invalid: boolean;
|
||||
}
|
||||
|
||||
export interface IRedirectInfo {
|
||||
// 跳转资源的类型
|
||||
type: string;
|
||||
// 跳转资源的 uuid
|
||||
uuid: string;
|
||||
}
|
||||
|
||||
export interface QueryAssetsOption {
|
||||
type?: string;
|
||||
pattern?: string;
|
||||
ccType?: string;
|
||||
extname?: string;
|
||||
importer?: string;
|
||||
isBundle?: boolean;
|
||||
}
|
||||
|
||||
export interface AssetOperationOption {
|
||||
// 是否强制覆盖已经存在的文件,默认 false
|
||||
overwrite?: boolean;
|
||||
// 是否自动重命名冲突文件,默认 false
|
||||
rename?: boolean;
|
||||
}
|
||||
|
||||
export interface AssetDBOptions {
|
||||
name: string;
|
||||
target: string;
|
||||
library: string;
|
||||
temp: string;
|
||||
/**
|
||||
* 0: 忽略错误
|
||||
* 1: 仅仅打印错误
|
||||
* 2: 打印错误、警告
|
||||
* 3: 打印错误、警告、日志
|
||||
* 4: 打印错误、警告、日志、调试信息
|
||||
*/
|
||||
level: number;
|
||||
ignoreFiles: string[];
|
||||
readonly: boolean;
|
||||
}
|
||||
|
||||
export interface ContributionInfo {
|
||||
mount?: {
|
||||
path: string;
|
||||
readonly?: boolean;
|
||||
visible?: boolean;
|
||||
enable?: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ExecuteAssetDBScriptMethodOptions {
|
||||
name: string;
|
||||
method: string;
|
||||
args: any[];
|
||||
}
|
||||
|
||||
export interface IAssetMeta {
|
||||
ver: string;
|
||||
importer: string;
|
||||
imported: boolean;
|
||||
uuid: string;
|
||||
files: string[];
|
||||
subMetas: {
|
||||
[index: string]: IAssetMeta;
|
||||
};
|
||||
userData: {
|
||||
[index: string]: any;
|
||||
};
|
||||
displayName: string;
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
25
extensions/app/engine/@types/packages/assets/@types/public.d.ts
vendored
Normal file
25
extensions/app/engine/@types/packages/assets/@types/public.d.ts
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* 外部插件注册搜索方式指定返回的接口
|
||||
*
|
||||
* @export
|
||||
* @interface SearchMenuItem
|
||||
*/
|
||||
export interface SearchMenuItem {
|
||||
label: string;
|
||||
key: string;
|
||||
// handler 方法是外部扩展的搜索方法,返回 true 表示匹配搜索成功
|
||||
// searchValue 表示 assets 面板输入的搜索内容,asset 表示匹配搜索时的节点信息
|
||||
handler: (searchVale: string, asset: any) => boolean | Promise<boolean>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 外部插件注册扩展的入口
|
||||
* 可以是搜索方式或限定搜索类型
|
||||
*
|
||||
* @export
|
||||
* @interface SearchExtension
|
||||
*/
|
||||
export interface SearchExtension {
|
||||
typeMenu?: Function; // 限定的搜索类型
|
||||
searchMenu: Function; // 搜索方式
|
||||
}
|
||||
18
extensions/app/engine/@types/packages/baidu-mini-game/@types/index.d.ts
vendored
Normal file
18
extensions/app/engine/@types/packages/baidu-mini-game/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
/// <reference path='../../../@types/index'/>
|
||||
export * from '@editor/library-type/packages/builder/@types/protect';
|
||||
|
||||
import { IInternalBuildOptions } from '@editor/library-type/packages/builder/@types/protect';
|
||||
|
||||
export type IOrientation = 'auto' | 'landscape' | 'portrait';
|
||||
|
||||
export interface IOptions {
|
||||
appid: string;
|
||||
buildOpenDataContextTemplate: boolean;
|
||||
orientation: IOrientation;
|
||||
}
|
||||
|
||||
export interface ITaskOption extends IInternalBuildOptions {
|
||||
packages: {
|
||||
'baidu-mini-game': IOptions;
|
||||
};
|
||||
}
|
||||
2
extensions/app/engine/@types/packages/builder/@types/index.d.ts
vendored
Normal file
2
extensions/app/engine/@types/packages/builder/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
export * from './public';
|
||||
101
extensions/app/engine/@types/packages/builder/@types/public/build-plugin.d.ts
vendored
Normal file
101
extensions/app/engine/@types/packages/builder/@types/public/build-plugin.d.ts
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
import { ITextureCompressType, IPVRQuality, IASTCQuality, IETCQuality, ITextureFormatInfo } from './texture-compress';
|
||||
import { IBuildTaskOption, IConsoleType } from './options';
|
||||
import { IBuildResult } from './build-result';
|
||||
|
||||
export interface IBuildPluginConfig {
|
||||
doc?: string; // 文档地址,支持 HTTP 地址,支持相对于编辑器官方 URL 的地址
|
||||
hooks?: string; // relate url about IHook
|
||||
options?: IDisplayOptions; // config of options
|
||||
verifyRuleMap?: IVerificationRuleMap;
|
||||
}
|
||||
|
||||
export type IVerificationFunc = (val: any, ...arg: any[]) => boolean | Promise<boolean>;
|
||||
export type IInternalVerificationFunc = (val: any, ...arg: any[]) => boolean;
|
||||
|
||||
export type IVerificationRuleMap = Record<string, IVerificationRule>;
|
||||
|
||||
export interface IVerificationRule {
|
||||
func: IVerificationFunc;
|
||||
message: string;
|
||||
}
|
||||
export interface IInternalVerificationRule {
|
||||
func: IInternalVerificationFunc;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface ITextureFormatConfig {
|
||||
displayName: string;
|
||||
options: IDisplayOptions;
|
||||
formats: ITextureFormatInfo[]; // 未指定 formats 则当前格式 key 作为存储的格式 value
|
||||
suffix: string;
|
||||
}
|
||||
|
||||
export type IDisplayOptions = Record<string, IConfigItem>;
|
||||
|
||||
export type ArrayItem = {
|
||||
label: string;
|
||||
value: string;
|
||||
};
|
||||
|
||||
export interface IConfigItem {
|
||||
key?: string; // 唯一标识符
|
||||
// 配置显示的名字,如果需要翻译,则传入 i18n:${key}
|
||||
label?: string;
|
||||
// 设置的简单说明
|
||||
description?: string;
|
||||
|
||||
experiment?: boolean; // 是否为实验性属性
|
||||
// 默认值
|
||||
default?: any;
|
||||
// 配置的类型
|
||||
type?: 'array' | 'object';
|
||||
itemConfigs?: IConfigItem[] | Record<string, IConfigItem>;
|
||||
verifyRules?: string[];
|
||||
verifyLevel?: IConsoleType, // 不赋值是默认为 error,等级为 error 时校验不通过将会无法点击构建,其他则仅做界面提示
|
||||
hidden?: boolean; // 是否隐藏
|
||||
render?: {
|
||||
ui: string;
|
||||
attributes?: Record<string, string | boolean | number>;
|
||||
items?: ArrayItem[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface IBuildPlugin {
|
||||
configs?: BuildPlugin.Configs;
|
||||
assetHandlers?: BuildPlugin.AssetHandlers;
|
||||
load?: BuildPlugin.load;
|
||||
unload?: BuildPlugin.Unload;
|
||||
}
|
||||
export type IBaseHooks = (options: IBuildTaskOption, result: IBuildResult) => Promise<void> | void;
|
||||
export type IBuildStageHooks = (root: string, options: IBuildTaskOption) => Promise<void> | void;
|
||||
|
||||
export namespace BuildPlugin {
|
||||
export type Configs = Record<string, IBuildPluginConfig>;
|
||||
export type AssetHandlers = string;
|
||||
export type load = () => Promise<void> | void;
|
||||
export type Unload = () => Promise<void> | void;
|
||||
}
|
||||
|
||||
export namespace BuildHook {
|
||||
export type throwError = boolean; // 插件注入的钩子函数,在执行失败时是否直接退出构建流程
|
||||
export type title = string; // 插件任务整体 title,支持 i18n 写法
|
||||
|
||||
export type onError = IBaseHooks; // 构建发生中断错误时的回调,仅作为事件通知,并不能劫持错误
|
||||
|
||||
export type onBeforeBuild = IBaseHooks;
|
||||
export type onBeforeCompressSettings = IBaseHooks;
|
||||
export type onAfterCompressSettings = IBaseHooks;
|
||||
export type onAfterBuild = IBaseHooks;
|
||||
|
||||
export type onAfterMake = IBuildStageHooks;
|
||||
export type onBeforeMake = IBuildStageHooks;
|
||||
|
||||
export type load = () => Promise<void> | void;
|
||||
export type unload = () => Promise<void> | void;
|
||||
}
|
||||
|
||||
export namespace AssetHandlers {
|
||||
export type compressTextures = (
|
||||
tasks: { src: string; dest: string; quality: number | IPVRQuality | IASTCQuality | IETCQuality; format: ITextureCompressType }[],
|
||||
) => Promise<void>;
|
||||
}
|
||||
243
extensions/app/engine/@types/packages/builder/@types/public/build-result.d.ts
vendored
Normal file
243
extensions/app/engine/@types/packages/builder/@types/public/build-result.d.ts
vendored
Normal file
@@ -0,0 +1,243 @@
|
||||
/**
|
||||
* settings.js 里定义的数据
|
||||
*/
|
||||
|
||||
import { ISplashSetting, ICustomJointTextureLayout, UUID, IOrientation } from './options';
|
||||
|
||||
// ****************************** settings ************************************************
|
||||
|
||||
// debug: true
|
||||
// designResolution: {width: "960", height: "640", policy: 4}
|
||||
// jsList: ["assets/resources/b.js", "assets/resources/a.js"]
|
||||
// launchScene: "db://assets/New Scene-001.scene"
|
||||
// platform: "web-desktop"
|
||||
// rawAssets: {
|
||||
// assets: {
|
||||
// "0e95a9f8-d4e7-4849-875a-7a11dd692b34": ["mesh/env/gltf/textures/birch_yellow_mat_baseColor.png", "cc.ImageAsset"]
|
||||
// }
|
||||
// internal: {
|
||||
// "1baf0fc9-befa-459c-8bdd-af1a450a0319": ["effects/builtin-standard.effect", "cc.EffectAsset"]
|
||||
// }
|
||||
// }
|
||||
// scenes: [{url: "db://assets/New Scene-001.scene", uuid: "69dc4a42-cc6c-49fb-9a57-7de0c212f83d"},…]
|
||||
// startScene: "current_scene"
|
||||
export interface ISettings {
|
||||
CocosEngine: string;
|
||||
debug: boolean;
|
||||
designResolution: ISettingsDesignResolution;
|
||||
jsList: string[];
|
||||
launchScene: string;
|
||||
preloadAssets: string[],
|
||||
moduleIds: string[];
|
||||
platform: string;
|
||||
renderPipeline: string;
|
||||
physics?: IPhysicsConfig;
|
||||
exactFitScreen: boolean;
|
||||
|
||||
bundleVers: Record<string, string>;
|
||||
subpackages: string[];
|
||||
remoteBundles: string[];
|
||||
server: string;
|
||||
hasResourcesBundle: boolean;
|
||||
hasStartSceneBundle: boolean;
|
||||
|
||||
scriptPackages?: string[];
|
||||
splashScreen?: ISplashSetting;
|
||||
|
||||
customJointTextureLayouts?: ICustomJointTextureLayout[];
|
||||
|
||||
importMaps?: Array<{
|
||||
url: string;
|
||||
map: any;
|
||||
}>;
|
||||
|
||||
macros?: Record<string, any>;
|
||||
collisionMatrix?: any;
|
||||
groupList?: any;
|
||||
// preview
|
||||
engineModules: string[];
|
||||
customLayers: {name: string, bit: number}[];
|
||||
orientation?: IOrientation;
|
||||
}
|
||||
|
||||
export interface IOutputSettings {
|
||||
CocosEngine: string;
|
||||
engine: {
|
||||
debug: boolean;
|
||||
macros: Record<string, any>;
|
||||
customLayers: {name: string, bit: number}[];
|
||||
platform: string;
|
||||
engineModules?: string[];
|
||||
builtinAssets: string[];
|
||||
};
|
||||
physics?: IPhysicsConfig;
|
||||
rendering: {
|
||||
renderPipeline: string;
|
||||
renderMode?: number;
|
||||
};
|
||||
assets: {
|
||||
server: string;
|
||||
remoteBundles: string[];
|
||||
bundleVers: Record<string, string>;
|
||||
preloadBundles: { bundle: string, version?: string }[];
|
||||
importBase?: string;
|
||||
nativeBase?: string;
|
||||
subpackages: string[];
|
||||
preloadAssets: string[];
|
||||
jsbDownloaderMaxTasks?: number;
|
||||
jsbDownloaderTimeout?: number;
|
||||
projectBundles: string[];
|
||||
};
|
||||
plugins: {
|
||||
jsList: string[];
|
||||
};
|
||||
scripting: {
|
||||
scriptPackages?: string[];
|
||||
};
|
||||
launch: {
|
||||
launchScene: string;
|
||||
};
|
||||
screen: {
|
||||
frameRate?: number;
|
||||
exactFitScreen: boolean;
|
||||
orientation?: IOrientation;
|
||||
designResolution: ISettingsDesignResolution;
|
||||
};
|
||||
splashScreen?: ISplashSetting;
|
||||
animation: {
|
||||
customJointTextureLayouts?: ICustomJointTextureLayout[];
|
||||
};
|
||||
profiling?: {
|
||||
showFPS: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
// 物理配置
|
||||
export interface IVec3Like {
|
||||
x: number;
|
||||
y: number;
|
||||
z: number;
|
||||
}
|
||||
|
||||
export interface ICollisionMatrix {
|
||||
[x: string]: number;
|
||||
}
|
||||
|
||||
export interface IPhysicsMaterial {
|
||||
friction: number; // 0.5
|
||||
rollingFriction: number; // 0.1
|
||||
spinningFriction: number; // 0.1
|
||||
restitution: number; // 0.1
|
||||
}
|
||||
|
||||
export interface IPhysicsConfig {
|
||||
gravity: IVec3Like; // (0,-10, 0)
|
||||
allowSleep: boolean; // true
|
||||
sleepThreshold: number; // 0.1,最小 0
|
||||
autoSimulation: boolean; // true
|
||||
fixedTimeStep: number; // 1 / 60 ,最小 0
|
||||
maxSubSteps: number; // 1,最小 0
|
||||
defaultMaterial: IPhysicsMaterial;
|
||||
useNodeChains: boolean; // true
|
||||
collisionMatrix: ICollisionMatrix;
|
||||
physicsEngine: string;
|
||||
}
|
||||
|
||||
export interface IPackageInfo {
|
||||
name: string;
|
||||
path: string;
|
||||
uuids: UUID[];
|
||||
}
|
||||
|
||||
export interface ISettingsDesignResolution {
|
||||
width: number;
|
||||
height: number;
|
||||
policy: number;
|
||||
}
|
||||
|
||||
interface IAssetPathBase {
|
||||
bundleName?: string;
|
||||
redirect?: string; // 重定向的 bundle 包名
|
||||
}
|
||||
|
||||
export interface IRawAssetPathInfo extends IAssetPathBase {
|
||||
raw: string[];
|
||||
}
|
||||
export declare interface IAssetPathInfo extends IAssetPathBase {
|
||||
raw?: string[];
|
||||
json?: string;
|
||||
groupIndex?: number;
|
||||
}
|
||||
|
||||
export interface IJsonPathInfo extends IAssetPathBase {
|
||||
json?: string;
|
||||
groupIndex?: number;
|
||||
}
|
||||
|
||||
export interface IBuildPaths {
|
||||
dir: string; // 构建资源输出地址( assets 所在的目录,并不一定与构建目录对应)
|
||||
settings: string; // settings.json 输出地址
|
||||
systemJs?: string; // system.js 生成地址
|
||||
engineDir?: string; // 引擎生成地址
|
||||
polyfillsJs?: string; // polyfill.js 生成地址
|
||||
assets: string; // assets 目录
|
||||
subpackages: string; // subpackages 目录
|
||||
remote: string; // remote 目录
|
||||
bundleScripts: string // bundle 的脚本,某些平台无法下载脚本,则将远程包中的脚本移到本地
|
||||
applicationJS: string; // application.js 的生成地址
|
||||
compileConfig?: string; // cocos.compile.config.json
|
||||
importMap: string; // import-map 文件地址
|
||||
}
|
||||
|
||||
export declare class IBuildResult {
|
||||
dest: string; // options 指定的构建目录
|
||||
|
||||
paths: IBuildPaths; // 构建后资源相关地址集合
|
||||
|
||||
settings?: ISettings;
|
||||
|
||||
/**
|
||||
* 指定的 uuid 资源是否包含在构建资源中
|
||||
*/
|
||||
containsAsset: (uuid: string) => boolean;
|
||||
|
||||
/**
|
||||
* 获取指定 uuid 原始资源的存放路径(不包括序列化 json)
|
||||
* 自动图集的小图 uuid 和自动图集的 uuid 都将会查询到合图大图的生成路径
|
||||
* 实际返回多个路径的情况:查询 uuid 为自动图集资源,且对应图集生成多张大图,纹理压缩会有多个图片格式路径
|
||||
*/
|
||||
getRawAssetPaths: (uuid: string) => IRawAssetPathInfo[];
|
||||
|
||||
/**
|
||||
* 获取指定 uuid 资源的序列化 json 路径
|
||||
*/
|
||||
getJsonPathInfo: (uuid: string) => IJsonPathInfo[];
|
||||
|
||||
/**
|
||||
* 获取指定 uuid 资源的路径相关信息
|
||||
* @return {raw?: string[]; json?: string; groupIndex?: number;}
|
||||
* @return.raw: 该资源源文件的实际存储位置
|
||||
* @return.json: 该资源序列化 json 的实际存储位置,不存在为空
|
||||
* @return.groupIndex: 若该资源的序列化 json 在某个 json 分组内,这里标识在分组内的 index,不存在为空
|
||||
*/
|
||||
getAssetPathInfo: (uuid: string) => IAssetPathInfo[];
|
||||
}
|
||||
|
||||
export interface IBundleConfig {
|
||||
importBase: string; // bundle 中 import 目录的名称,通常是 'import'
|
||||
nativeBase: string; // native 中 native 目录的名称,通常是 'native'
|
||||
name: string; // bundle 的名称,可以通过 bundle 名称加载 bundle
|
||||
deps: string[]; // 该 bundle 依赖的其他 bundle 名称
|
||||
uuids: UUID[]; // 该 bundle 中的所有资源的 uuid
|
||||
paths: Record<string, any[]>; // 该 bundle 中可以通过路径加载的资源,参考以前 settings 中 rawAssets 的定义
|
||||
scenes: Record<string, UUID|number>; // 该 bundle 中所有场景,场景名为 key, uuid 为 value
|
||||
packs: Record<UUID, UUID[]>; // 该 bundle 中所有合并的 json, 参考以前 settings 中 packedAssets 的定义
|
||||
versions: { import: Array<string|number>, native: Array<string|number> }; // 该 bundle 中所有资源的版本号,参考以前 settings 中 md5AssetsMap 的定义
|
||||
redirect: Array<string|number>; // 该 bundle 中重定向到其他 bundle 的资源
|
||||
debug: boolean; // 是否是 debug 模式,debug 模式会对 config.json 的数据进行压缩,所以运行时得解压
|
||||
types?: string[]; // paths 中的类型数组,参考以前 settings 中 assetTypes 的定义
|
||||
encrypted?: boolean; // 原生上使用,标记该 bundle 中的脚本是否加密
|
||||
isZip?: boolean; // 是否是 zip 模式
|
||||
zipVersion?: string;
|
||||
extensionMap: Record<string, UUID[]>
|
||||
}
|
||||
7
extensions/app/engine/@types/packages/builder/@types/public/global.d.ts
vendored
Normal file
7
extensions/app/engine/@types/packages/builder/@types/public/global.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { IBuild } from '.';
|
||||
|
||||
// 定义 builder 进程内的全局变量
|
||||
declare global {
|
||||
// @ts-ignore
|
||||
const Build: IBuild;
|
||||
}
|
||||
101
extensions/app/engine/@types/packages/builder/@types/public/index.d.ts
vendored
Normal file
101
extensions/app/engine/@types/packages/builder/@types/public/index.d.ts
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
import { ITransformOptions } from './options';
|
||||
|
||||
export * from './build-result';
|
||||
export * from './build-plugin';
|
||||
export * from './texture-compress';
|
||||
export * from './options';
|
||||
|
||||
interface IAppendRes {
|
||||
hash: string;
|
||||
paths: string[];
|
||||
}
|
||||
|
||||
interface ICreateBundleOptions {
|
||||
excludes?: string[];
|
||||
debug?: boolean;
|
||||
sourceMap?: boolean;
|
||||
targets?: string;
|
||||
}
|
||||
export interface IBuildUtils {
|
||||
/**
|
||||
* 压缩 uuid
|
||||
* 'fc991dd7-0033-4b80-9d41-c8a86a702e59' -> 'fc9913XADNLgJ1ByKhqcC5Z'
|
||||
*/
|
||||
compressUuid: (uuid: string, min: boolean) => string;
|
||||
|
||||
/**
|
||||
* 解压缩 uuid
|
||||
* 'fc9913XADNLgJ1ByKhqcC5Z' -> 'fc991dd7-0033-4b80-9d41-c8a86a702e59'
|
||||
*/
|
||||
decompressUuid: (uuid: string) => string;
|
||||
|
||||
/**
|
||||
* 翻译带有 i18n 开头的名称(i18n:test)(待定)
|
||||
* 'i18n:test' -> '测试'
|
||||
*/
|
||||
transI18nName: (name: string) => string;
|
||||
|
||||
/**
|
||||
* 移除 db 前缀
|
||||
* 'db://assets/test.jpg' -> 'assets/test.jpg'
|
||||
*/
|
||||
removeDbHeader: (url: string) => string;
|
||||
|
||||
/**
|
||||
* 将 db 开头的 url 转为项目里的实际 url
|
||||
* 'db://assets/test.jpg' -> 'c:/project/assets/test.jpg'
|
||||
*/
|
||||
dbUrlToRawPath: (url: string) => string;
|
||||
|
||||
/**
|
||||
* 从路径里获取存在的 uuid
|
||||
* 'E:\test3d\library\oc\0c0c1f5742-89b0-4a1e-b5eb-914d84f48c1c.json' -> '0c0c1f5742-89b0-4a1e-b5eb-914d84f48c1c'
|
||||
*/
|
||||
getUuidFromPath: (path: string) => string;
|
||||
|
||||
/**
|
||||
* 检查是否全局安装了 nodejs
|
||||
*/
|
||||
isInstallNodeJs: () => Promise<boolean>;
|
||||
|
||||
/**
|
||||
* 逐文件拷贝
|
||||
*/
|
||||
copyDirSync: (src: string, dest: string) => void;
|
||||
|
||||
/**
|
||||
* 获取相对路径接口
|
||||
* 返回 / 拼接的相对路径
|
||||
*/
|
||||
relativeUrl: (from: string, to: string) => string;
|
||||
|
||||
transformCode: (code: string, options: ITransformOptions) => Promise<string>;
|
||||
|
||||
/**
|
||||
* 给指定路径添加 md5
|
||||
*/
|
||||
appendMd5ToPaths: (paths: string[]) => Promise<IAppendRes | null>;
|
||||
|
||||
calcMd5: (data: Buffer | string) => string;
|
||||
|
||||
copyPaths: (paths: { src: string; dest: string }[]) => Promise<void[]>;
|
||||
|
||||
createBundle: (src: string, dest: string, options?: ICreateBundleOptions) => Promise<unknown>;
|
||||
}
|
||||
export interface IBuild {
|
||||
Utils: IBuildUtils;
|
||||
|
||||
LIBRARY_NAME: string;
|
||||
IMPORT_HEADER: string;
|
||||
NATIVE_HEADER: string;
|
||||
ASSETS_HEADER: string;
|
||||
SUBPACKAGES_HEADER: string;
|
||||
REMOTE_HEADER: string;
|
||||
BUNDLE_SCRIPTS_HEADER: string;
|
||||
SCRIPT_NAME: string;
|
||||
CONFIG_NAME: string;
|
||||
BUNDLE_ZIP_NAME: string;
|
||||
projectTempDir: string;
|
||||
globalTempDir: string;
|
||||
buildTemplateDir: string; // 构建模板地址 build-templates
|
||||
}
|
||||
40
extensions/app/engine/@types/packages/builder/@types/public/message.d.ts
vendored
Normal file
40
extensions/app/engine/@types/packages/builder/@types/public/message.d.ts
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
import { IBundleConfig, ISettings, IOutputSettings } from './build-result';
|
||||
import { IBuildTaskItemJSON } from './options';
|
||||
export interface message extends EditorMessageMap {
|
||||
'open-devtools': {
|
||||
params: [],
|
||||
result: void,
|
||||
},
|
||||
open: {
|
||||
params: [],
|
||||
result: void,
|
||||
},
|
||||
'generate-preview-setting': {
|
||||
params: any[],
|
||||
result: Promise<{
|
||||
settings: IOutputSettings;
|
||||
script2library: Record<string, string>;
|
||||
bundleConfigs: IBundleConfig[];
|
||||
}>,
|
||||
},
|
||||
'query-tasks-info': {
|
||||
params: [],
|
||||
result: {
|
||||
queue: Record<string, IBuildTaskItemJSON>,
|
||||
free: Promise<boolean>,
|
||||
},
|
||||
},
|
||||
'query-task': {
|
||||
params: string[],
|
||||
result: Promise<IBuildTaskItemJSON>,
|
||||
},
|
||||
/**
|
||||
* 预览合图
|
||||
* @param {object} pacUuid
|
||||
*/
|
||||
'preview-pac': {
|
||||
params: string[],
|
||||
result: Promise<IBuildTaskItemJSON>,
|
||||
},
|
||||
|
||||
}
|
||||
187
extensions/app/engine/@types/packages/builder/@types/public/options.d.ts
vendored
Normal file
187
extensions/app/engine/@types/packages/builder/@types/public/options.d.ts
vendored
Normal file
@@ -0,0 +1,187 @@
|
||||
import * as babel from '@babel/core';
|
||||
|
||||
export type IConsoleType = 'log' | 'warn' | 'error' | 'debug';
|
||||
|
||||
/**
|
||||
* 构建所需的完整参数
|
||||
*/
|
||||
export interface IBuildTaskOption {
|
||||
// 构建后的游戏文件夹生成的路径
|
||||
buildPath: string;
|
||||
debug: boolean;
|
||||
inlineSpriteFrames: boolean;
|
||||
md5Cache: boolean;
|
||||
|
||||
// bundle 设置
|
||||
mainBundleCompressionType: BundleCompressionType;
|
||||
mainBundleIsRemote: boolean;
|
||||
useBuiltinServer: boolean; // 使用内置的服务器地址,实验性功能
|
||||
server?: string; // 服务器地址
|
||||
// 小游戏平台将会自动勾选
|
||||
moveRemoteBundleScript: boolean;
|
||||
|
||||
mergeJson: boolean;
|
||||
name: string;
|
||||
// packAutoAtlas: boolean;
|
||||
platform: Platform;
|
||||
scenes: IBuildSceneItem[];
|
||||
skipCompressTexture: boolean;
|
||||
sourceMaps: boolean;
|
||||
startScene: string;
|
||||
outputName: string;
|
||||
experimentalEraseModules: boolean;
|
||||
polyfills?: IPolyFills;
|
||||
nextStages?: string[];
|
||||
|
||||
// 构建阶段性任务绑定分组
|
||||
buildStageGroup?: Record<string, string[]>;
|
||||
|
||||
/**
|
||||
* 是否是预览进程发送的构建请求。
|
||||
* @default false
|
||||
*/
|
||||
preview?: boolean;
|
||||
|
||||
// 项目设置
|
||||
includeModules?: string[];
|
||||
renderPipeline?: string;
|
||||
designResolution?: IBuildDesignResolution;
|
||||
physicsConfig?: any;
|
||||
flags?: Record<string, boolean>;
|
||||
customLayers: {name: string, value: number}[];
|
||||
|
||||
// 是否使用自定义插屏选项
|
||||
replaceSplashScreen?: boolean;
|
||||
splashScreen: ISplashSetting;
|
||||
|
||||
packages?: Record<string, any>;
|
||||
id?: string; // 手动配置构建任务 id
|
||||
// recompileConfig?: IRecompileConfig;
|
||||
|
||||
// 一些偏好设置选项
|
||||
useBuildAssetCache?: boolean;
|
||||
useBuildEngineCache?: boolean;
|
||||
useBuildTextureCompressCache?: boolean;
|
||||
useBuildAutoAtlasCache?: boolean;
|
||||
__version__?: string;
|
||||
}
|
||||
|
||||
export type UUID = string;
|
||||
|
||||
export interface ISplashSetting {
|
||||
enabled: boolean;
|
||||
base64src: string;
|
||||
displayRatio: number;
|
||||
totalTime: number;
|
||||
effect: string;
|
||||
clearColor: { x: number; y: number; z: number; w: number };
|
||||
displayWatermark: boolean;
|
||||
}
|
||||
|
||||
export interface ICustomJointTextureLayout {
|
||||
textureLength: number;
|
||||
contents: IChunkContent[];
|
||||
}
|
||||
|
||||
export interface IChunkContent {
|
||||
skeleton: null | string;
|
||||
clips: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建使用的设计分辨率数据
|
||||
*/
|
||||
export interface IBuildDesignResolution {
|
||||
height: number;
|
||||
width: number;
|
||||
fitWidth?: boolean;
|
||||
fitHeight?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建使用的场景的数据
|
||||
*/
|
||||
export interface IBuildSceneItem {
|
||||
url: string;
|
||||
uuid: string;
|
||||
inBundle?: boolean;
|
||||
}
|
||||
|
||||
export interface IPolyFills {
|
||||
/**
|
||||
* True if async functions polyfills(i.e. regeneratorRuntime) needs to be included.
|
||||
* You need to turn on this field if you want to use async functions in language.
|
||||
*/
|
||||
asyncFunctions?: boolean;
|
||||
|
||||
/**
|
||||
* If true, [core-js](https://github.com/zloirock/core-js) polyfills are included.
|
||||
* The default options of [core-js-builder](https://github.com/zloirock/core-js/tree/master/packages/core-js-builder)
|
||||
* will be used to build the core-js.
|
||||
*/
|
||||
coreJs?: boolean;
|
||||
|
||||
targets?: string;
|
||||
}
|
||||
|
||||
// **************************** options *******************************************
|
||||
export type Platform =
|
||||
| 'web-desktop'
|
||||
| 'web-mobile'
|
||||
| 'wechatgame'
|
||||
| 'oppo-mini-game'
|
||||
| 'vivo-mini-game'
|
||||
| 'huawei-quick-game'
|
||||
| 'alipay-mini-game'
|
||||
| 'mac'
|
||||
| 'ios'
|
||||
| 'linux'
|
||||
// | 'ios-app-clip'
|
||||
| 'android'
|
||||
| 'ohos'
|
||||
| 'open-harmonyos'
|
||||
| 'windows'
|
||||
| 'xiaomi-quick-game'
|
||||
| 'baidu-mini-game'
|
||||
| 'bytedance-mini-game'
|
||||
| 'cocos-play'
|
||||
| 'huawei-agc'
|
||||
| 'link-sure'
|
||||
| 'qtt'
|
||||
| 'cocos-runtime'
|
||||
| 'xr-meta'
|
||||
| 'xr-huaweivr'
|
||||
| 'xr-pico'
|
||||
| 'xr-rokid'
|
||||
| 'xr-monado'
|
||||
| 'ar-android'
|
||||
| 'ar-ios'
|
||||
;
|
||||
|
||||
export type BundleCompressionType = 'none' | 'merge_dep' | 'merge_all_json' | 'subpackage' | 'zip';
|
||||
export type IModules = 'esm' | 'commonjs' | 'systemjs';
|
||||
|
||||
export interface ITransformOptions {
|
||||
importMapFormat: IModules;
|
||||
plugins?: babel.PluginItem[];
|
||||
}
|
||||
|
||||
export type ITaskState = 'waiting' | 'success' | 'failure' | 'cancel' | 'processing';
|
||||
|
||||
export interface ITaskItemJSON{
|
||||
id: string;
|
||||
progress: number;
|
||||
state: ITaskState;
|
||||
message: string;
|
||||
time: string;
|
||||
}
|
||||
|
||||
export interface IBuildTaskItemJSON extends ITaskItemJSON {
|
||||
stage: 'build' | string;
|
||||
options: IBuildTaskOption;
|
||||
dirty: boolean;
|
||||
rawOptions?: IBuildTaskOption;
|
||||
type: 'build',
|
||||
}
|
||||
|
||||
export type IOrientation = 'auto' | 'landscape' | 'portrait';
|
||||
70
extensions/app/engine/@types/packages/builder/@types/public/texture-compress.d.ts
vendored
Normal file
70
extensions/app/engine/@types/packages/builder/@types/public/texture-compress.d.ts
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
export type ITextureCompressType =
|
||||
| 'jpg'
|
||||
| 'png'
|
||||
| 'webp'
|
||||
| 'pvrtc_4bits_rgb'
|
||||
| 'pvrtc_4bits_rgba'
|
||||
| 'pvrtc_4bits_rgb_a'
|
||||
| 'pvrtc_2bits_rgb'
|
||||
| 'pvrtc_2bits_rgba'
|
||||
| 'pvrtc_2bits_rgb_a'
|
||||
| 'etc1_rgb'
|
||||
| 'etc1_rgb_a'
|
||||
| 'etc2_rgb'
|
||||
| 'etc2_rgba'
|
||||
| 'astc_4x4'
|
||||
| 'astc_5x5'
|
||||
| 'astc_6x6'
|
||||
| 'astc_8x8'
|
||||
| 'astc_10x5'
|
||||
| 'astc_10x10'
|
||||
| 'astc_12x12'
|
||||
| string;
|
||||
export type ITextureCompressPlatform = 'miniGame' | 'web' | 'ios' | 'android';
|
||||
|
||||
export interface IHandlerInfo {
|
||||
type: 'program' | 'npm' | 'function';
|
||||
info: ICommandInfo | Function;
|
||||
func?: Function;
|
||||
}
|
||||
|
||||
export interface ICustomConfig {
|
||||
id: string;
|
||||
name: string;
|
||||
path: string;
|
||||
command: string;
|
||||
format: string;
|
||||
overwrite?: boolean;
|
||||
}
|
||||
|
||||
export interface ICommandInfo {
|
||||
command: string;
|
||||
params?: string[];
|
||||
path: string;
|
||||
}
|
||||
|
||||
export interface ITextureFormatInfo {
|
||||
displayName: string;
|
||||
value: ITextureCompressType | string;
|
||||
formatSuffix?: string;
|
||||
alpha?: boolean;
|
||||
formatType?: string;
|
||||
handler?: IHandlerInfo;
|
||||
custom?: boolean;
|
||||
params?: string[];
|
||||
}
|
||||
export interface ISupportFormat {
|
||||
rgb: ITextureCompressType[];
|
||||
rgba: ITextureCompressType[];
|
||||
}
|
||||
export interface IConfigGroupsInfo {
|
||||
defaultSupport?: ISupportFormat,
|
||||
support: ISupportFormat,
|
||||
displayName: string;
|
||||
icon: string;
|
||||
}
|
||||
export type IConfigGroups = Record<ITextureCompressPlatform, IConfigGroupsInfo>;
|
||||
|
||||
export type IPVRQuality = 'fastest' | 'fast' | 'normal' | 'high' | 'best';
|
||||
export type IETCQuality = 'slow' | 'fast';
|
||||
export type IASTCQuality = 'veryfast' | 'fast' | 'medium' | 'thorough' | 'exhaustive';
|
||||
26
extensions/app/engine/@types/packages/bytedance-mini-game/@types/index.d.ts
vendored
Normal file
26
extensions/app/engine/@types/packages/bytedance-mini-game/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
/// <reference path='../../../@types/index'/>
|
||||
|
||||
export * from '@editor/library-type/packages/builder/@types/protect';
|
||||
|
||||
import { IInternalBuildOptions } from '@editor/library-type/packages/builder/@types/protect';
|
||||
|
||||
export type IOrientation = 'auto' | 'landscape' | 'portrait';
|
||||
|
||||
export interface IOptions {
|
||||
appid: string;
|
||||
buildOpenDataContextTemplate: boolean;
|
||||
orientation: IOrientation;
|
||||
physX: {
|
||||
use: 'physX' | 'project';
|
||||
notPackPhysXLibs: boolean;
|
||||
mutiThread: boolean;
|
||||
subThreadCount: number;
|
||||
epsilon: number;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ITaskOption extends IInternalBuildOptions {
|
||||
packages: {
|
||||
'bytedance-mini-game': IOptions;
|
||||
};
|
||||
}
|
||||
1
extensions/app/engine/@types/packages/certificate/@types/index.d.ts
vendored
Normal file
1
extensions/app/engine/@types/packages/certificate/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/// <reference path='../../../@types/index'/>
|
||||
1
extensions/app/engine/@types/packages/channel-upload-tools/@types/index.d.ts
vendored
Normal file
1
extensions/app/engine/@types/packages/channel-upload-tools/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/// <reference path='../../../@types/index'/>
|
||||
28
extensions/app/engine/@types/packages/cocos-play/@types/index.d.ts
vendored
Normal file
28
extensions/app/engine/@types/packages/cocos-play/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
/// <reference path='../../../@types/index'/>
|
||||
|
||||
export * from '@editor/library-type/packages/builder/@types/protect';
|
||||
import { IInternalBuildOptions } from '@editor/library-type/packages/builder/@types/protect';
|
||||
|
||||
export type IOrientation = 'landscape' | 'portrait';
|
||||
|
||||
export interface PlatformSettings {
|
||||
runtimeVersion: string,
|
||||
deviceOrientation: IOrientation,
|
||||
statusbarDisplay: boolean,
|
||||
startSceneAssetBundle: false,
|
||||
workerPath: string,
|
||||
XHRTimeout: number,
|
||||
WSTimeout: number,
|
||||
uploadFileTimeout: number,
|
||||
downloadFileTimeout: number,
|
||||
cameraPermissionHint: string,
|
||||
userInfoPermissionHint: string,
|
||||
locationPermissionHint: string,
|
||||
albumPermissionHint: string
|
||||
}
|
||||
|
||||
export interface ITaskOption extends IInternalBuildOptions {
|
||||
packages: {
|
||||
'cocos-play': PlatformSettings
|
||||
}
|
||||
}
|
||||
33
extensions/app/engine/@types/packages/console/@types/pritate.d.ts
vendored
Normal file
33
extensions/app/engine/@types/packages/console/@types/pritate.d.ts
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
export type logType = 'log' | 'warn' | 'error';
|
||||
export interface IMessageItem {
|
||||
rows: number; // 内部有几行 包括 details & stacks
|
||||
translateY: number;
|
||||
show: boolean;
|
||||
title: string;
|
||||
content: string[]; // details
|
||||
count: number; // 重复的个数
|
||||
fold: boolean; // 折叠
|
||||
type: logType;
|
||||
message: any;
|
||||
texture: string; // 纹理 light or dark
|
||||
date?: number; // 格式化的时间
|
||||
time?: number; // 时间戳
|
||||
process?: string;
|
||||
stack: string[];
|
||||
}
|
||||
|
||||
export interface INewItem {
|
||||
type: logType
|
||||
[propName: string]: any
|
||||
}
|
||||
|
||||
export type ILogCounter = Record<logType, number>;
|
||||
|
||||
export type IConsoleExtension = {
|
||||
name: string,
|
||||
key: string,
|
||||
label: string,
|
||||
value?: boolean,
|
||||
show: boolean
|
||||
}
|
||||
684
extensions/app/engine/@types/packages/engine-extends/@types/glTF.d.ts
vendored
Normal file
684
extensions/app/engine/@types/packages/engine-extends/@types/glTF.d.ts
vendored
Normal file
@@ -0,0 +1,684 @@
|
||||
export type GlTfId = number;
|
||||
/**
|
||||
* Indices of those attributes that deviate from their initialization value.
|
||||
*/
|
||||
export interface AccessorSparseIndices {
|
||||
/**
|
||||
* The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target.
|
||||
*/
|
||||
'bufferView': GlTfId;
|
||||
/**
|
||||
* The offset relative to the start of the bufferView in bytes. Must be aligned.
|
||||
*/
|
||||
'byteOffset'?: number;
|
||||
/**
|
||||
* The indices data type.
|
||||
*/
|
||||
'componentType': 5121 | 5123 | 5125 | number;
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
[k: string]: any;
|
||||
}
|
||||
/**
|
||||
* Array of size `accessor.sparse.count` times number of components storing the displaced accessor attributes pointed by `accessor.sparse.indices`.
|
||||
*/
|
||||
export interface AccessorSparseValues {
|
||||
/**
|
||||
* The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target.
|
||||
*/
|
||||
'bufferView': GlTfId;
|
||||
/**
|
||||
* The offset relative to the start of the bufferView in bytes. Must be aligned.
|
||||
*/
|
||||
'byteOffset'?: number;
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
[k: string]: any;
|
||||
}
|
||||
/**
|
||||
* Sparse storage of attributes that deviate from their initialization value.
|
||||
*/
|
||||
export interface AccessorSparse {
|
||||
/**
|
||||
* Number of entries stored in the sparse array.
|
||||
*/
|
||||
'count': number;
|
||||
/**
|
||||
* Index array of size `count` that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase.
|
||||
*/
|
||||
'indices': AccessorSparseIndices;
|
||||
/**
|
||||
* Array of size `count` times number of components, storing the displaced accessor attributes pointed by `indices`. Substituted values must have the same `componentType` and number of components as the base accessor.
|
||||
*/
|
||||
'values': AccessorSparseValues;
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
[k: string]: any;
|
||||
}
|
||||
/**
|
||||
* A typed view into a bufferView. A bufferView contains raw binary data. An accessor provides a typed view into a bufferView or a subset of a bufferView similar to how WebGL's `vertexAttribPointer()` defines an attribute in a buffer.
|
||||
*/
|
||||
export interface Accessor {
|
||||
/**
|
||||
* The index of the bufferView.
|
||||
*/
|
||||
'bufferView'?: GlTfId;
|
||||
/**
|
||||
* The offset relative to the start of the bufferView in bytes.
|
||||
*/
|
||||
'byteOffset'?: number;
|
||||
/**
|
||||
* The datatype of components in the attribute.
|
||||
*/
|
||||
'componentType': 5120 | 5121 | 5122 | 5123 | 5125 | 5126 | number;
|
||||
/**
|
||||
* Specifies whether integer data values should be normalized.
|
||||
*/
|
||||
'normalized'?: boolean;
|
||||
/**
|
||||
* The number of attributes referenced by this accessor.
|
||||
*/
|
||||
'count': number;
|
||||
/**
|
||||
* Specifies if the attribute is a scalar, vector, or matrix.
|
||||
*/
|
||||
'type': 'SCALAR' | 'VEC2' | 'VEC3' | 'VEC4' | 'MAT2' | 'MAT3' | 'MAT4' | string;
|
||||
/**
|
||||
* Maximum value of each component in this attribute.
|
||||
*/
|
||||
'max'?: number[];
|
||||
/**
|
||||
* Minimum value of each component in this attribute.
|
||||
*/
|
||||
'min'?: number[];
|
||||
/**
|
||||
* Sparse storage of attributes that deviate from their initialization value.
|
||||
*/
|
||||
'sparse'?: AccessorSparse;
|
||||
'name'?: any;
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
[k: string]: any;
|
||||
}
|
||||
/**
|
||||
* The index of the node and TRS property that an animation channel targets.
|
||||
*/
|
||||
export interface AnimationChannelTarget {
|
||||
/**
|
||||
* The index of the node to target.
|
||||
*/
|
||||
'node'?: GlTfId;
|
||||
/**
|
||||
* The name of the node's TRS property to modify, or the "weights" of the Morph Targets it instantiates. For the "translation" property, the values that are provided by the sampler are the translation along the x, y, and z axes. For the "rotation" property, the values are a quaternion in the order (x, y, z, w), where w is the scalar. For the "scale" property, the values are the scaling factors along the x, y, and z axes.
|
||||
*/
|
||||
'path': 'translation' | 'rotation' | 'scale' | 'weights' | string;
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
[k: string]: any;
|
||||
}
|
||||
/**
|
||||
* Targets an animation's sampler at a node's property.
|
||||
*/
|
||||
export interface AnimationChannel {
|
||||
/**
|
||||
* The index of a sampler in this animation used to compute the value for the target.
|
||||
*/
|
||||
'sampler': GlTfId;
|
||||
/**
|
||||
* The index of the node and TRS property to target.
|
||||
*/
|
||||
'target': AnimationChannelTarget;
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
[k: string]: any;
|
||||
}
|
||||
/**
|
||||
* Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target).
|
||||
*/
|
||||
export interface AnimationSampler {
|
||||
/**
|
||||
* The index of an accessor containing keyframe input values, e.g., time.
|
||||
*/
|
||||
'input': GlTfId;
|
||||
/**
|
||||
* Interpolation algorithm.
|
||||
*/
|
||||
'interpolation'?: 'LINEAR' | 'STEP' | 'CUBICSPLINE' | string;
|
||||
/**
|
||||
* The index of an accessor, containing keyframe output values.
|
||||
*/
|
||||
'output': GlTfId;
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
[k: string]: any;
|
||||
}
|
||||
/**
|
||||
* A keyframe animation.
|
||||
*/
|
||||
export interface Animation {
|
||||
/**
|
||||
* An array of channels, each of which targets an animation's sampler at a node's property. Different channels of the same animation can't have equal targets.
|
||||
*/
|
||||
'channels': AnimationChannel[];
|
||||
/**
|
||||
* An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target).
|
||||
*/
|
||||
'samplers': AnimationSampler[];
|
||||
'name'?: any;
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
[k: string]: any;
|
||||
}
|
||||
/**
|
||||
* Metadata about the glTF asset.
|
||||
*/
|
||||
export interface Asset {
|
||||
/**
|
||||
* A copyright message suitable for display to credit the content creator.
|
||||
*/
|
||||
'copyright'?: string;
|
||||
/**
|
||||
* Tool that generated this glTF model. Useful for debugging.
|
||||
*/
|
||||
'generator'?: string;
|
||||
/**
|
||||
* The glTF version that this asset targets.
|
||||
*/
|
||||
'version': string;
|
||||
/**
|
||||
* The minimum glTF version that this asset targets.
|
||||
*/
|
||||
'minVersion'?: string;
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
[k: string]: any;
|
||||
}
|
||||
/**
|
||||
* A buffer points to binary geometry, animation, or skins.
|
||||
*/
|
||||
export interface Buffer {
|
||||
/**
|
||||
* The uri of the buffer.
|
||||
*/
|
||||
'uri'?: string;
|
||||
/**
|
||||
* The length of the buffer in bytes.
|
||||
*/
|
||||
'byteLength': number;
|
||||
'name'?: any;
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
[k: string]: any;
|
||||
}
|
||||
/**
|
||||
* A view into a buffer generally representing a subset of the buffer.
|
||||
*/
|
||||
export interface BufferView {
|
||||
/**
|
||||
* The index of the buffer.
|
||||
*/
|
||||
'buffer': GlTfId;
|
||||
/**
|
||||
* The offset into the buffer in bytes.
|
||||
*/
|
||||
'byteOffset'?: number;
|
||||
/**
|
||||
* The length of the bufferView in bytes.
|
||||
*/
|
||||
'byteLength': number;
|
||||
/**
|
||||
* The stride, in bytes.
|
||||
*/
|
||||
'byteStride'?: number;
|
||||
/**
|
||||
* The target that the GPU buffer should be bound to.
|
||||
*/
|
||||
'target'?: 34962 | 34963 | number;
|
||||
'name'?: any;
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
[k: string]: any;
|
||||
}
|
||||
/**
|
||||
* An orthographic camera containing properties to create an orthographic projection matrix.
|
||||
*/
|
||||
export interface CameraOrthographic {
|
||||
/**
|
||||
* The floating-point horizontal magnification of the view. Must not be zero.
|
||||
*/
|
||||
'xmag': number;
|
||||
/**
|
||||
* The floating-point vertical magnification of the view. Must not be zero.
|
||||
*/
|
||||
'ymag': number;
|
||||
/**
|
||||
* The floating-point distance to the far clipping plane. `zfar` must be greater than `znear`.
|
||||
*/
|
||||
'zfar': number;
|
||||
/**
|
||||
* The floating-point distance to the near clipping plane.
|
||||
*/
|
||||
'znear': number;
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
[k: string]: any;
|
||||
}
|
||||
/**
|
||||
* A perspective camera containing properties to create a perspective projection matrix.
|
||||
*/
|
||||
export interface CameraPerspective {
|
||||
/**
|
||||
* The floating-point aspect ratio of the field of view.
|
||||
*/
|
||||
'aspectRatio'?: number;
|
||||
/**
|
||||
* The floating-point vertical field of view in radians.
|
||||
*/
|
||||
'yfov': number;
|
||||
/**
|
||||
* The floating-point distance to the far clipping plane.
|
||||
*/
|
||||
'zfar'?: number;
|
||||
/**
|
||||
* The floating-point distance to the near clipping plane.
|
||||
*/
|
||||
'znear': number;
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
[k: string]: any;
|
||||
}
|
||||
/**
|
||||
* A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene.
|
||||
*/
|
||||
export interface Camera {
|
||||
/**
|
||||
* An orthographic camera containing properties to create an orthographic projection matrix.
|
||||
*/
|
||||
'orthographic'?: CameraOrthographic;
|
||||
/**
|
||||
* A perspective camera containing properties to create a perspective projection matrix.
|
||||
*/
|
||||
'perspective'?: CameraPerspective;
|
||||
/**
|
||||
* Specifies if the camera uses a perspective or orthographic projection.
|
||||
*/
|
||||
'type': 'perspective' | 'orthographic' | string;
|
||||
'name'?: any;
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
[k: string]: any;
|
||||
}
|
||||
/**
|
||||
* Image data used to create a texture. Image can be referenced by URI or `bufferView` index. `mimeType` is required in the latter case.
|
||||
*/
|
||||
export interface Image {
|
||||
/**
|
||||
* The uri of the image.
|
||||
*/
|
||||
'uri'?: string;
|
||||
/**
|
||||
* The image's MIME type. Required if `bufferView` is defined.
|
||||
*/
|
||||
'mimeType'?: 'image/jpeg' | 'image/png' | string;
|
||||
/**
|
||||
* The index of the bufferView that contains the image. Use this instead of the image's uri property.
|
||||
*/
|
||||
'bufferView'?: GlTfId;
|
||||
'name'?: any;
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
[k: string]: any;
|
||||
}
|
||||
/**
|
||||
* Reference to a texture.
|
||||
*/
|
||||
export interface TextureInfo {
|
||||
/**
|
||||
* The index of the texture.
|
||||
*/
|
||||
'index': GlTfId;
|
||||
/**
|
||||
* The set index of texture's TEXCOORD attribute used for texture coordinate mapping.
|
||||
*/
|
||||
'texCoord'?: number;
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
[k: string]: any;
|
||||
}
|
||||
/**
|
||||
* A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology.
|
||||
*/
|
||||
export interface MaterialPbrMetallicRoughness {
|
||||
/**
|
||||
* The material's base color factor.
|
||||
*/
|
||||
'baseColorFactor'?: number[];
|
||||
/**
|
||||
* The base color texture.
|
||||
*/
|
||||
'baseColorTexture'?: TextureInfo;
|
||||
/**
|
||||
* The metalness of the material.
|
||||
*/
|
||||
'metallicFactor'?: number;
|
||||
/**
|
||||
* The roughness of the material.
|
||||
*/
|
||||
'roughnessFactor'?: number;
|
||||
/**
|
||||
* The metallic-roughness texture.
|
||||
*/
|
||||
'metallicRoughnessTexture'?: TextureInfo;
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
[k: string]: any;
|
||||
}
|
||||
export interface MaterialNormalTextureInfo {
|
||||
'index'?: any;
|
||||
'texCoord'?: any;
|
||||
/**
|
||||
* The scalar multiplier applied to each normal vector of the normal texture.
|
||||
*/
|
||||
'scale'?: number;
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
[k: string]: any;
|
||||
}
|
||||
export interface MaterialOcclusionTextureInfo {
|
||||
'index'?: any;
|
||||
'texCoord'?: any;
|
||||
/**
|
||||
* A scalar multiplier controlling the amount of occlusion applied.
|
||||
*/
|
||||
'strength'?: number;
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
[k: string]: any;
|
||||
}
|
||||
/**
|
||||
* The material appearance of a primitive.
|
||||
*/
|
||||
export interface Material {
|
||||
'name'?: any;
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
/**
|
||||
* A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology. When not specified, all the default values of `pbrMetallicRoughness` apply.
|
||||
*/
|
||||
'pbrMetallicRoughness'?: MaterialPbrMetallicRoughness;
|
||||
/**
|
||||
* The normal map texture.
|
||||
*/
|
||||
'normalTexture'?: MaterialNormalTextureInfo;
|
||||
/**
|
||||
* The occlusion map texture.
|
||||
*/
|
||||
'occlusionTexture'?: MaterialOcclusionTextureInfo;
|
||||
/**
|
||||
* The emissive map texture.
|
||||
*/
|
||||
'emissiveTexture'?: TextureInfo;
|
||||
/**
|
||||
* The emissive color of the material.
|
||||
*/
|
||||
'emissiveFactor'?: number[];
|
||||
/**
|
||||
* The alpha rendering mode of the material.
|
||||
*/
|
||||
'alphaMode'?: 'OPAQUE' | 'MASK' | 'BLEND' | string;
|
||||
/**
|
||||
* The alpha cutoff value of the material.
|
||||
*/
|
||||
'alphaCutoff'?: number;
|
||||
/**
|
||||
* Specifies whether the material is double sided.
|
||||
*/
|
||||
'doubleSided'?: boolean;
|
||||
[k: string]: any;
|
||||
}
|
||||
/**
|
||||
* Geometry to be rendered with the given material.
|
||||
*/
|
||||
export interface MeshPrimitive {
|
||||
/**
|
||||
* A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data.
|
||||
*/
|
||||
'attributes': {
|
||||
[k: string]: GlTfId;
|
||||
};
|
||||
/**
|
||||
* The index of the accessor that contains the indices.
|
||||
*/
|
||||
'indices'?: GlTfId;
|
||||
/**
|
||||
* The index of the material to apply to this primitive when rendering.
|
||||
*/
|
||||
'material'?: GlTfId;
|
||||
/**
|
||||
* The type of primitives to render.
|
||||
*/
|
||||
'mode'?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | number;
|
||||
/**
|
||||
* An array of Morph Targets, each Morph Target is a dictionary mapping attributes (only `POSITION`, `NORMAL`, and `TANGENT` supported) to their deviations in the Morph Target.
|
||||
*/
|
||||
'targets'?: {
|
||||
[k: string]: GlTfId;
|
||||
}[];
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
[k: string]: any;
|
||||
}
|
||||
/**
|
||||
* A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene.
|
||||
*/
|
||||
export interface Mesh {
|
||||
/**
|
||||
* An array of primitives, each defining geometry to be rendered with a material.
|
||||
*/
|
||||
'primitives': MeshPrimitive[];
|
||||
/**
|
||||
* Array of weights to be applied to the Morph Targets.
|
||||
*/
|
||||
'weights'?: number[];
|
||||
'name'?: any;
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
[k: string]: any;
|
||||
}
|
||||
/**
|
||||
* A node in the node hierarchy. When the node contains `skin`, all `mesh.primitives` must contain `JOINTS_0` and `WEIGHTS_0` attributes. A node can have either a `matrix` or any combination of `translation`/`rotation`/`scale` (TRS) properties. TRS properties are converted to matrices and postmultiplied in the `T * R * S` order to compose the transformation matrix; first the scale is applied to the vertices, then the rotation, and then the translation. If none are provided, the transform is the identity. When a node is targeted for animation (referenced by an animation.channel.target), only TRS properties may be present; `matrix` will not be present.
|
||||
*/
|
||||
export interface Node {
|
||||
/**
|
||||
* The index of the camera referenced by this node.
|
||||
*/
|
||||
'camera'?: GlTfId;
|
||||
/**
|
||||
* The indices of this node's children.
|
||||
*/
|
||||
'children'?: GlTfId[];
|
||||
/**
|
||||
* The index of the skin referenced by this node.
|
||||
*/
|
||||
'skin'?: GlTfId;
|
||||
/**
|
||||
* A floating-point 4x4 transformation matrix stored in column-major order.
|
||||
*/
|
||||
'matrix'?: number[];
|
||||
/**
|
||||
* The index of the mesh in this node.
|
||||
*/
|
||||
'mesh'?: GlTfId;
|
||||
/**
|
||||
* The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar.
|
||||
*/
|
||||
'rotation'?: number[];
|
||||
/**
|
||||
* The node's non-uniform scale, given as the scaling factors along the x, y, and z axes.
|
||||
*/
|
||||
'scale'?: number[];
|
||||
/**
|
||||
* The node's translation along the x, y, and z axes.
|
||||
*/
|
||||
'translation'?: number[];
|
||||
/**
|
||||
* The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh.
|
||||
*/
|
||||
'weights'?: number[];
|
||||
'name'?: any;
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
[k: string]: any;
|
||||
}
|
||||
/**
|
||||
* Texture sampler properties for filtering and wrapping modes.
|
||||
*/
|
||||
export interface Sampler {
|
||||
/**
|
||||
* Magnification filter.
|
||||
*/
|
||||
'magFilter'?: 9728 | 9729 | number;
|
||||
/**
|
||||
* Minification filter.
|
||||
*/
|
||||
'minFilter'?: 9728 | 9729 | 9984 | 9985 | 9986 | 9987 | number;
|
||||
/**
|
||||
* s wrapping mode.
|
||||
*/
|
||||
'wrapS'?: 33071 | 33648 | 10497 | number;
|
||||
/**
|
||||
* t wrapping mode.
|
||||
*/
|
||||
'wrapT'?: 33071 | 33648 | 10497 | number;
|
||||
'name'?: any;
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
[k: string]: any;
|
||||
}
|
||||
/**
|
||||
* The root nodes of a scene.
|
||||
*/
|
||||
export interface Scene {
|
||||
/**
|
||||
* The indices of each root node.
|
||||
*/
|
||||
'nodes'?: GlTfId[];
|
||||
'name'?: any;
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
[k: string]: any;
|
||||
}
|
||||
/**
|
||||
* Joints and matrices defining a skin.
|
||||
*/
|
||||
export interface Skin {
|
||||
/**
|
||||
* The index of the accessor containing the floating-point 4x4 inverse-bind matrices. The default is that each matrix is a 4x4 identity matrix, which implies that inverse-bind matrices were pre-applied.
|
||||
*/
|
||||
'inverseBindMatrices'?: GlTfId;
|
||||
/**
|
||||
* The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root.
|
||||
*/
|
||||
'skeleton'?: GlTfId;
|
||||
/**
|
||||
* Indices of skeleton nodes, used as joints in this skin.
|
||||
*/
|
||||
'joints': GlTfId[];
|
||||
'name'?: any;
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
[k: string]: any;
|
||||
}
|
||||
/**
|
||||
* A texture and its sampler.
|
||||
*/
|
||||
export interface Texture {
|
||||
/**
|
||||
* The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used.
|
||||
*/
|
||||
'sampler'?: GlTfId;
|
||||
/**
|
||||
* The index of the image used by this texture.
|
||||
*/
|
||||
'source'?: GlTfId;
|
||||
'name'?: any;
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
[k: string]: any;
|
||||
}
|
||||
/**
|
||||
* The root object for a glTF asset.
|
||||
*/
|
||||
export interface GlTf {
|
||||
/**
|
||||
* Names of glTF extensions used somewhere in this asset.
|
||||
*/
|
||||
'extensionsUsed'?: string[];
|
||||
/**
|
||||
* Names of glTF extensions required to properly load this asset.
|
||||
*/
|
||||
'extensionsRequired'?: string[];
|
||||
/**
|
||||
* An array of accessors.
|
||||
*/
|
||||
'accessors'?: Accessor[];
|
||||
/**
|
||||
* An array of keyframe animations.
|
||||
*/
|
||||
'animations'?: Animation[];
|
||||
/**
|
||||
* Metadata about the glTF asset.
|
||||
*/
|
||||
'asset': Asset;
|
||||
/**
|
||||
* An array of buffers.
|
||||
*/
|
||||
'buffers'?: Buffer[];
|
||||
/**
|
||||
* An array of bufferViews.
|
||||
*/
|
||||
'bufferViews'?: BufferView[];
|
||||
/**
|
||||
* An array of cameras.
|
||||
*/
|
||||
'cameras'?: Camera[];
|
||||
/**
|
||||
* An array of images.
|
||||
*/
|
||||
'images'?: Image[];
|
||||
/**
|
||||
* An array of materials.
|
||||
*/
|
||||
'materials'?: Material[];
|
||||
/**
|
||||
* An array of meshes.
|
||||
*/
|
||||
'meshes'?: Mesh[];
|
||||
/**
|
||||
* An array of nodes.
|
||||
*/
|
||||
'nodes'?: Node[];
|
||||
/**
|
||||
* An array of samplers.
|
||||
*/
|
||||
'samplers'?: Sampler[];
|
||||
/**
|
||||
* The index of the default scene.
|
||||
*/
|
||||
'scene'?: GlTfId;
|
||||
/**
|
||||
* An array of scenes.
|
||||
*/
|
||||
'scenes'?: Scene[];
|
||||
/**
|
||||
* An array of skins.
|
||||
*/
|
||||
'skins'?: Skin[];
|
||||
/**
|
||||
* An array of textures.
|
||||
*/
|
||||
'textures'?: Texture[];
|
||||
'extensions'?: any;
|
||||
'extras'?: any;
|
||||
[k: string]: any;
|
||||
}
|
||||
109
extensions/app/engine/@types/packages/engine-extends/@types/gltf-validator.d.ts
vendored
Normal file
109
extensions/app/engine/@types/packages/engine-extends/@types/gltf-validator.d.ts
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
|
||||
declare module 'gltf-validator' {
|
||||
/**
|
||||
* Returns a version string.
|
||||
*/
|
||||
export const version: string;
|
||||
|
||||
/**
|
||||
* Returns an array of supported extensions names.
|
||||
*/
|
||||
export const supportedExtensions: string[];
|
||||
|
||||
/**
|
||||
* @param uri Relative URI of the external resource.
|
||||
* @returns Promise with Uint8Array data.
|
||||
*/
|
||||
export type ExternalResourceFunction = (uri: string) => Promise<Uint8Array>;
|
||||
|
||||
export interface ValidationOptions {
|
||||
/**
|
||||
* Absolute or relative asset URI that will be copied to validation report.
|
||||
*/
|
||||
uri?: string;
|
||||
|
||||
/**
|
||||
* Max number of reported issues. Use 0 for unlimited output.
|
||||
*/
|
||||
maxIssues?: number;
|
||||
|
||||
/**
|
||||
* Array of ignored issue codes.
|
||||
*/
|
||||
ignoredIssues?: string[];
|
||||
|
||||
/**
|
||||
* Object with overridden severities for issue codes.
|
||||
*/
|
||||
severityOverrides?: {
|
||||
[x: string]: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Function for loading external resources. If omitted, external resources are not validated.
|
||||
*/
|
||||
externalResourceFunction?: ExternalResourceFunction;
|
||||
|
||||
/**
|
||||
* Set to false to skip reading of accessor data.
|
||||
*/
|
||||
validateAccessorData?: boolean;
|
||||
}
|
||||
|
||||
export interface Resource {
|
||||
pointer: string;
|
||||
mimeType: string;
|
||||
storage: string;
|
||||
uri: string;
|
||||
}
|
||||
|
||||
export interface Report {
|
||||
uri: string;
|
||||
mimeType: string;
|
||||
validatorVersion: string;
|
||||
validatedAt: string;
|
||||
issues: {
|
||||
numErrors: number;
|
||||
numWarnings: number;
|
||||
numInfos: number;
|
||||
numHints: number;
|
||||
messages: Array<{
|
||||
code: string;
|
||||
message: string;
|
||||
pointer: string;
|
||||
severity: number;
|
||||
}>;
|
||||
truncated: boolean;
|
||||
};
|
||||
info: {
|
||||
version: string;
|
||||
generator: string;
|
||||
resources: Array<{
|
||||
pointer: string;
|
||||
mimeType: string;
|
||||
storage: string;
|
||||
uri: string;
|
||||
}>;
|
||||
hasAnimations: boolean;
|
||||
hasMaterials: boolean;
|
||||
hasMorphTargets: boolean;
|
||||
hasSkins: boolean;
|
||||
hasTextures: boolean;
|
||||
hasDefaultScene: boolean;
|
||||
primitivesCount: number;
|
||||
maxAttributesUsed: number;
|
||||
};
|
||||
}
|
||||
|
||||
export function validateBytes(data: Uint8Array, options?: ValidationOptions): Promise<Report>;
|
||||
|
||||
export function validateString(json: string, options?: ValidationOptions): Promise<Report>;
|
||||
|
||||
export const enum Severity {
|
||||
Error = 0,
|
||||
|
||||
Warning = 1,
|
||||
|
||||
Information = 2,
|
||||
}
|
||||
}
|
||||
811
extensions/app/engine/@types/packages/engine-extends/@types/i18n-well-defined.d.ts
vendored
Normal file
811
extensions/app/engine/@types/packages/engine-extends/@types/i18n-well-defined.d.ts
vendored
Normal file
@@ -0,0 +1,811 @@
|
||||
declare module '@base/electron-i18n' {
|
||||
export function translation(key: string, language?: any): string;
|
||||
}
|
||||
|
||||
declare interface I18NWellDefinedDictionary {
|
||||
['about.title']: [];
|
||||
['about.editor']: [];
|
||||
['about.engine']: [];
|
||||
['about.version']: [];
|
||||
['animator.title']: [];
|
||||
['animator.loading.wait_scene_ready']: [];
|
||||
['animator.loading.init_animation_data']: [];
|
||||
['animator.mask.need_select_node']: [];
|
||||
['animator.mask.need_animation_component']: [];
|
||||
['animator.mask.need_animation_clip']: [];
|
||||
['animator.mask.enter_animation_mode']: [];
|
||||
['animator.mask.add_animation_component']: [];
|
||||
['animator.mask.add_animation_clip']: [];
|
||||
['animator.toolbar.exit']: [];
|
||||
['animator.toolbar.setting']: [];
|
||||
['animator.toolbar.order']: [];
|
||||
['animator.toolbar.jump_first_frame']: [];
|
||||
['animator.toolbar.jump_prev_frame']: [];
|
||||
['animator.toolbar.play_animation']: [];
|
||||
['animator.toolbar.stop_animation']: [];
|
||||
['animator.toolbar.pause_animation']: [];
|
||||
['animator.toolbar.jump_next_frame']: [];
|
||||
['animator.toolbar.jump_last_frame']: [];
|
||||
['animator.toolbar.insert_event']: [];
|
||||
['animator.toolbar.save_clip']: [];
|
||||
['animator.property.title']: [];
|
||||
['animator.property.create_prop']: [];
|
||||
['animator.property.remove_prop']: [];
|
||||
['animator.property.clear_keys']: [];
|
||||
['animator.property.create_key']: [];
|
||||
['animator.property.remove_key']: [];
|
||||
['animator.property.copy_key']: [];
|
||||
['animator.property.paste_key']: [];
|
||||
['animator.property.spacing_key']: [];
|
||||
['animator.property.spacing_frame']: [];
|
||||
['animator.event.title']: [];
|
||||
['animator.event.add_func']: [];
|
||||
['animator.event.del_func']: [];
|
||||
['animator.event.add_params']: [];
|
||||
['animator.event.del_params']: [];
|
||||
['animator.event.clear_params']: [];
|
||||
['animator.event.create']: [];
|
||||
['animator.event.paste']: [];
|
||||
['animator.bezier.title']: [];
|
||||
['animator.bezier.click_to_apply']: [];
|
||||
['animator.node.title']: [];
|
||||
['animator.node.move_data']: [];
|
||||
['animator.node.move_data_to']: [];
|
||||
['animator.node.clear_data']: [];
|
||||
['animator.preview_row.line_tips']: [];
|
||||
['animator.preview_row.open_curve_editor']: [];
|
||||
['animator.preview_row.asset_type_should_be']: [];
|
||||
['animator.preview_row.asset_position_tips']: [];
|
||||
['animator.is_save']: [];
|
||||
['animator.is_save_message']: [];
|
||||
['animator.is_paste_overwrite']: [];
|
||||
['animator.is_paste_overwrite_message']: [];
|
||||
['animator.overwrite']: [];
|
||||
['animator.is_clear']: [];
|
||||
['animator.is_clear_message']: [];
|
||||
['animator.is_move_data']: [];
|
||||
['animator.is_move_data_message']: [];
|
||||
['animator.is_remove_prop.title']: [];
|
||||
['animator.is_remove_prop.message']: [];
|
||||
['animator.is_remove_prop.remove']: [];
|
||||
['animator.is_clear_prop.title']: [];
|
||||
['animator.is_clear_prop.message']: [];
|
||||
['animator.is_clear_prop.remove']: [];
|
||||
['animator.move']: [];
|
||||
['animator.clear']: [];
|
||||
['animator.copy']: [];
|
||||
['animator.paste']: [];
|
||||
['animator.save']: [];
|
||||
['animator.abort']: [];
|
||||
['animator.cancel']: [];
|
||||
['animator.edit']: [];
|
||||
['animator.delete']: [];
|
||||
['animator.toolbar.spacing_frame']: [];
|
||||
['asset-db.mask.startup']: [];
|
||||
['asset-db.mask.loading']: [];
|
||||
['asset-db.debug-mode']: [];
|
||||
['asset-db.operate.dialogError']: [];
|
||||
['asset-db.operate.dialogWarning']: [];
|
||||
['asset-db.operate.dialogQuestion']: [];
|
||||
['asset-db.operate.dialogInfo']: [];
|
||||
['asset-db.fail.readonly']: [];
|
||||
['asset-db.createAsset.fail.unknown']: [];
|
||||
['asset-db.createAsset.fail.url']: [];
|
||||
['asset-db.createAsset.fail.exist']: [];
|
||||
['asset-db.createAsset.fail.drop']: [];
|
||||
['asset-db.createAsset.fail.toUrl']: [];
|
||||
['asset-db.createAsset.fail.uuid']: [];
|
||||
['asset-db.createAsset.fail.content']: [];
|
||||
['asset-db.createAsset.fail.readonly']: [];
|
||||
['asset-db.createAsset.warn.overwrite']: [];
|
||||
['asset-db.dropAsset.overwrite']: [];
|
||||
['asset-db.dropAsset.reserve']: [];
|
||||
['asset-db.dropAsset.fail.unknown']: [];
|
||||
['asset-db.dropAsset.fail.url']: [];
|
||||
['asset-db.dropAsset.fail.filepaths']: [];
|
||||
['asset-db.dropAsset.fail.readonly']: [];
|
||||
['asset-db.dropAsset.warn.overwrite']: [];
|
||||
['asset-db.dropAsset.warn.sameway']: [];
|
||||
['asset-db.saveAsset.fail.unknown']: [];
|
||||
['asset-db.saveAsset.fail.uuid']: [];
|
||||
['asset-db.saveAsset.fail.content']: [];
|
||||
['asset-db.saveAsset.fail.readonly']: [];
|
||||
['asset-db.saveAssetMeta.fail.unknown']: [];
|
||||
['asset-db.saveAssetMeta.fail.uuid']: [];
|
||||
['asset-db.saveAssetMeta.fail.content']: [];
|
||||
['asset-db.saveAssetMeta.fail.readonly']: [];
|
||||
['asset-db.copyAsset.fail.unknown']: [];
|
||||
['asset-db.copyAsset.fail.url']: [];
|
||||
['asset-db.copyAsset.fail.source']: [];
|
||||
['asset-db.copyAsset.fail.target']: [];
|
||||
['asset-db.copyAsset.fail.include']: [];
|
||||
['asset-db.copyAsset.fail.parent']: [];
|
||||
['asset-db.copyAsset.fail.readonly']: [];
|
||||
['asset-db.copyAsset.fail.metauuid']: [];
|
||||
['asset-db.moveAsset.fail.unknown']: [];
|
||||
['asset-db.moveAsset.fail.url']: [];
|
||||
['asset-db.moveAsset.fail.source']: [];
|
||||
['asset-db.moveAsset.fail.target']: [];
|
||||
['asset-db.moveAsset.fail.exist']: [];
|
||||
['asset-db.moveAsset.fail.include']: [];
|
||||
['asset-db.moveAsset.fail.parent']: [];
|
||||
['asset-db.moveAsset.fail.readonly_source']: [];
|
||||
['asset-db.moveAsset.fail.readonly']: [];
|
||||
['asset-db.moveAsset.warn.overwrite']: [];
|
||||
['asset-db.deleteAsset.fail.unknown']: [];
|
||||
['asset-db.deleteAsset.fail.url']: [];
|
||||
['asset-db.deleteAsset.fail.unexist']: [];
|
||||
['asset-db.deleteAsset.fail.readonly']: [];
|
||||
['asset-db.preferences.log_level']: [];
|
||||
['asset-db.preferences.log_level_debug']: [];
|
||||
['asset-db.preferences.log_level_log']: [];
|
||||
['asset-db.preferences.log_level_warn']: [];
|
||||
['asset-db.preferences.log_level_error']: [];
|
||||
['asset-db.importers.glTF.glTF_asset_group_mesh']: [];
|
||||
['asset-db.importers.glTF.glTF_asset_group_animation']: [];
|
||||
['asset-db.importers.glTF.glTF_asset_group_node']: [];
|
||||
['asset-db.importers.glTF.glTF_asset_group_skin']: [];
|
||||
['asset-db.importers.glTF.glTF_asset_group_sampler']: [];
|
||||
['asset-db.importers.glTF.glTF_asset']: [{
|
||||
group: any;
|
||||
index: any;
|
||||
name: any;
|
||||
}];
|
||||
['asset-db.importers.glTF.glTF_asset_no_name']: [{
|
||||
group: any;
|
||||
index: any;
|
||||
}];
|
||||
['asset-db.importers.glTF.unsupported_alpha_mode']: [{
|
||||
material: any;
|
||||
mode: any;
|
||||
}];
|
||||
['asset-db.importers.glTF.unsupported_texture_parameter']: [{
|
||||
texture: any;
|
||||
sampler: any;
|
||||
type: any;
|
||||
value: any;
|
||||
}];
|
||||
['asset-db.importers.glTF.texture_parameter_min_filter']: [];
|
||||
['asset-db.importers.glTF.texture_parameter_mag_filter']: [];
|
||||
['asset-db.importers.glTF.unsupported_channel_path']: [{
|
||||
animation: any;
|
||||
channel: any;
|
||||
path: any;
|
||||
}];
|
||||
['asset-db.importers.glTF.reference_skin_in_different_scene']: [{
|
||||
node: any;
|
||||
skin: any;
|
||||
}];
|
||||
['asset-db.importers.glTF.disallow_cubic_spline_channel_split']: [{
|
||||
animation: any;
|
||||
channel: any;
|
||||
}];
|
||||
['asset-db.importers.glTF.failed_to_calculate_tangents_due_to_lack_of_normals']: [{
|
||||
mesh: any;
|
||||
primitive: any;
|
||||
}];
|
||||
['asset-db.importers.glTF.failed_to_calculate_tangents_due_to_lack_of_uvs']: [{
|
||||
mesh: any;
|
||||
primitive: any;
|
||||
}];
|
||||
['asset-db.importers.glTF.failed_to_load_image']: [{
|
||||
url: any;
|
||||
reason: any;
|
||||
}];
|
||||
['asset-db.importers.glTF.image_uri_should_be_file_url']: [];
|
||||
['asset-db.importers.glTF.failed_to_convert_tga']: [];
|
||||
['asset-db.importers.fbx.failed_to_convert_fbx_file']: [{
|
||||
path: any;
|
||||
}];
|
||||
['asset-db.importers.fbx.no_available_fbx_temp_dir']: [];
|
||||
['asset-db.importers.fbx.fbx2glTF_exists_with_non_zero_code']: [{
|
||||
code: any;
|
||||
output: any;
|
||||
}];
|
||||
['asset-db.importers.javascript.transform_failure']: [{
|
||||
path: any;
|
||||
reason: any;
|
||||
}];
|
||||
['assets.title']: [];
|
||||
['assets.previewTitle']: [];
|
||||
['assets.menu.createMenu']: [];
|
||||
['assets.menu.searchPlaceholder_name']: [];
|
||||
['assets.menu.searchPlaceholder_uuid']: [];
|
||||
['assets.menu.searchPlaceholder_type']: [];
|
||||
['assets.menu.searchTip']: [];
|
||||
['assets.menu.search']: [];
|
||||
['assets.menu.searchName']: [];
|
||||
['assets.menu.searchUuid']: [];
|
||||
['assets.menu.searchType']: [];
|
||||
['assets.menu.sort']: [];
|
||||
['assets.menu.sortName']: [];
|
||||
['assets.menu.sortType']: [];
|
||||
['assets.menu.refresh']: [];
|
||||
['assets.menu.allExpand']: [];
|
||||
['assets.menu.allCollapse']: [];
|
||||
['assets.menu.new']: [];
|
||||
['assets.menu.newFolder']: [];
|
||||
['assets.menu.newJavaScript']: [];
|
||||
['assets.menu.newTypeScript']: [];
|
||||
['assets.menu.newCubeMap']: [];
|
||||
['assets.menu.newScene']: [];
|
||||
['assets.menu.newMaterial']: [];
|
||||
['assets.menu.newPhysicsMaterial']: [];
|
||||
['assets.menu.newEffect']: [];
|
||||
['assets.menu.newChunk']: [];
|
||||
['assets.menu.newAnimation']: [];
|
||||
['assets.menu.renderPipeline']: [];
|
||||
['assets.menu.forwardPipeline']: [];
|
||||
['assets.menu.renderPipelineTS']: [];
|
||||
['assets.menu.RenderFlowTS']: [];
|
||||
['assets.menu.RenderStageTS']: [];
|
||||
['assets.menu.newPac']: [];
|
||||
['assets.menu.newTerrain']: [];
|
||||
['assets.menu.copy']: [];
|
||||
['assets.menu.cut']: [];
|
||||
['assets.menu.paste']: [];
|
||||
['assets.menu.delete']: [];
|
||||
['assets.menu.rename']: [];
|
||||
['assets.menu.selectall']: [];
|
||||
['assets.menu.readonly']: [];
|
||||
['assets.menu.revealInlibrary']: [];
|
||||
['assets.menu.reimport']: [];
|
||||
['assets.menu.revealInExplorer']: [];
|
||||
['assets.menu.showUuid']: [];
|
||||
['assets.menu.recommendTS']: [];
|
||||
['assets.operate.cutReady']: [];
|
||||
['assets.operate.cutDone']: [];
|
||||
['assets.operate.copyReady']: [];
|
||||
['assets.operate.copyDone']: [];
|
||||
['assets.operate.dialogError']: [];
|
||||
['assets.operate.dialogWarning']: [];
|
||||
['assets.operate.dialogQuestion']: [];
|
||||
['assets.operate.dialogInfo']: [];
|
||||
['assets.operate.refreshing']: [];
|
||||
['assets.operate.assetDataError']: [];
|
||||
['assets.operate.sureDelete']: [{
|
||||
length: any;
|
||||
filelist: any;
|
||||
}];
|
||||
['assets.operate.renameFail']: [];
|
||||
['assets.operate.pasteFail_parent_into_child']: [];
|
||||
['assets.operate.refreshFail']: [];
|
||||
['assets.operate.readDefaultFileFail']: [];
|
||||
['assets.operate.errorNewnameDuplicate']: [];
|
||||
['assets.operate.errorNewnameUnlegal']: [];
|
||||
['assets.operate.errorNewnameEmpty']: [];
|
||||
['assets.operate.errorScriptName']: [];
|
||||
['assets.operate.errorScriptClassName']: [];
|
||||
['assets.deprecate.fire']: [];
|
||||
['builder.title']: [];
|
||||
['builder.create_user_template']: [];
|
||||
['builder.build_config']: [];
|
||||
['builder.build']: [];
|
||||
['builder.compile']: [];
|
||||
['builder.select_all']: [];
|
||||
['builder.open_compile_file']: [];
|
||||
['builder.source_map']: [];
|
||||
['builder.recompile_engine']: [];
|
||||
['builder.debug_mode']: [];
|
||||
['builder.web_debugger']: [];
|
||||
['builder.require']: [];
|
||||
['builder.new_build_task']: [];
|
||||
['builder.empty_task_holder']: [];
|
||||
['builder.empty_scene']: [];
|
||||
['builder.reveal_in_explorer']: [];
|
||||
['builder.view_build_config']: [];
|
||||
['builder.recompile']: [];
|
||||
['builder.compress_texture']: [];
|
||||
['builder.pack_autoAtlas']: [];
|
||||
['builder.replace_splash_screen']: [];
|
||||
['builder.run']: [];
|
||||
['builder.open']: [];
|
||||
['builder.export']: [];
|
||||
['builder.import']: [];
|
||||
['builder.export_build_config']: [];
|
||||
['builder.import_build_config']: [];
|
||||
['builder.include_project_setting']: [];
|
||||
['builder.only_build_panel']: [];
|
||||
['builder.options.taskName']: [];
|
||||
['builder.options.name']: [];
|
||||
['builder.options.platform']: [];
|
||||
['builder.options.build_path']: [];
|
||||
['builder.options.start_scene']: [];
|
||||
['builder.options.inline_SpriteFrames']: [];
|
||||
['builder.options.merge_json_by_scene']: [];
|
||||
['builder.options.merge_start_scene']: [];
|
||||
['builder.options.orientation']: [];
|
||||
['builder.options.scenes']: [];
|
||||
['builder.options.debug']: [];
|
||||
['builder.options.resolution']: [];
|
||||
['builder.options.preview_url']: [];
|
||||
['builder.options.source_map']: [];
|
||||
['builder.options.force_combile_engine']: [];
|
||||
['builder.options.web_debugger']: [];
|
||||
['builder.options.compress_texture']: [];
|
||||
['builder.options.pack_autoAtlas']: [];
|
||||
['builder.package']: [];
|
||||
['builder.package_hint']: [];
|
||||
['builder.desktop_icon']: [];
|
||||
['builder.desktop_icon_hint']: [];
|
||||
['builder.version_name']: [];
|
||||
['builder.version_name_hint']: [];
|
||||
['builder.version_number']: [];
|
||||
['builder.version_number_hint']: [];
|
||||
['builder.support_min_platform']: [];
|
||||
['builder.support_min_platform_hint']: [];
|
||||
['builder.full_screen']: [];
|
||||
['builder.screen_orientation']: [];
|
||||
['builder.landscape']: [];
|
||||
['builder.portrait']: [];
|
||||
['builder.tiny_packet_mode']: [];
|
||||
['builder.tiny_packet_path']: [];
|
||||
['builder.tiny_packet_path_hint']: [];
|
||||
['builder.keystore']: [];
|
||||
['builder.use_debug_keystore']: [];
|
||||
['builder.private_pem_path']: [];
|
||||
['builder.private_pem_path_hint']: [];
|
||||
['builder.certificate_pem_path']: [];
|
||||
['builder.certificate_pem_path_hint']: [];
|
||||
['builder.print_finger']: [];
|
||||
['builder.pack_res_to_first_pack']: [];
|
||||
['builder.custom_npm_path']: [];
|
||||
['builder.custom_npm_path_hint']: [];
|
||||
['builder.custom_manifest_data']: [];
|
||||
['builder.custom_manifest_data_error']: [];
|
||||
['builder.remote_url']: [];
|
||||
['builder.not_install_nodejs_windows_error']: [];
|
||||
['builder.not_install_nodejs_mac_error']: [];
|
||||
['builder.rpk_installing']: [];
|
||||
['builder.rpk_install_fail']: [];
|
||||
['builder.rpk_install_success']: [];
|
||||
['builder.not_mainfest_data']: [];
|
||||
['builder.npm_installed_success']: [];
|
||||
['builder.npm_install_fail']: [];
|
||||
['builder.oppo.new']: [];
|
||||
['builder.oppo.not_empty']: [];
|
||||
['builder.oppo.icon_not_exist']: [];
|
||||
['builder.oppo.signature_not_exist']: [];
|
||||
['builder.oppo.private_pem_path_error']: [];
|
||||
['builder.oppo.certificate_pem_path_error']: [];
|
||||
['builder.certificate.country']: [];
|
||||
['builder.certificate.state']: [];
|
||||
['builder.certificate.locality']: [];
|
||||
['builder.certificate.organization']: [];
|
||||
['builder.certificate.organizationalUnit']: [];
|
||||
['builder.certificate.commonName']: [];
|
||||
['builder.certificate.email']: [];
|
||||
['builder.certificate.certificatePath']: [];
|
||||
['builder.certificate.generate']: [];
|
||||
['builder.certificate.build_certificate_complete']: [];
|
||||
['builder.certificate.build_certificate_fail']: [];
|
||||
['builder.huawei.select_certificate_path']: [];
|
||||
['builder.huawei.install_nodejs_before_view_certificate']: [];
|
||||
['builder.huawei.select_certificate_path_after_view_certificate']: [];
|
||||
['builder.huawei.certificate_fingerprint']: [];
|
||||
['builder.huawei.certificate_fingerprint_error']: [];
|
||||
['builder.huawei.use_native_renderer']: [];
|
||||
['builder.wechat_game.separate_engine']: [];
|
||||
['builder.wechat_game.separate_engine_tips']: [];
|
||||
['builder.wechat_game.client_path_error']: [{
|
||||
path: any;
|
||||
}];
|
||||
['builder.wechat_game.client_info_path_err']: [{
|
||||
path: any;
|
||||
}];
|
||||
['builder.wechat_game.client_version_low']: [];
|
||||
['builder.wechat_game.remote_server_address']: [];
|
||||
['builder.wechat_game.remote_server_address_tips']: [];
|
||||
['builder.wechat_game.sub_context']: [];
|
||||
['builder.wechat_game.sub_context_tips']: [];
|
||||
['builder.wechat_game.build_sub']: [];
|
||||
['builder.wechat_game.build_sub_tips']: [];
|
||||
['builder.wechat_game.wechatgame_app_path_empty']: [];
|
||||
['builder.error.build_error']: [];
|
||||
['builder.error.dirty_info']: [];
|
||||
['builder.error.build_dir_not_exists']: [{
|
||||
buildDir: any;
|
||||
}];
|
||||
['builder.error.build_path_contains_space']: [];
|
||||
['builder.error.build_path_contains_chinese']: [];
|
||||
['builder.error.can_not_empty']: [];
|
||||
['builder.error.project_name_not_legal']: [];
|
||||
['builder.error.package_name_not_legal']: [];
|
||||
['builder.error.package_name_start_with_number']: [];
|
||||
['builder.error.select_scenes_to_build']: [];
|
||||
['builder.error.binary_api_level']: [];
|
||||
['builder.error.path_too_long_title']: [];
|
||||
['builder.error.path_too_long_desc']: [{
|
||||
max_length: any;
|
||||
}];
|
||||
['builder.error.keep_raw_texture_of_atlas']: [{
|
||||
texturePath: any;
|
||||
pacPath: any;
|
||||
assetPath: any;
|
||||
}];
|
||||
['builder.error.arm64_not_support']: [{
|
||||
current_api: any;
|
||||
min_version: any;
|
||||
}];
|
||||
['builder.warn.same_url']: [];
|
||||
['builder.tasks.build_asset']: [];
|
||||
['builder.tasks.build_engine']: [];
|
||||
['builder.tasks.build_img']: [];
|
||||
['builder.tasks.build_json']: [];
|
||||
['builder.tasks.build_atlas']: [];
|
||||
['builder.tasks.build_script']: [];
|
||||
['builder.tasks.build_suffix']: [];
|
||||
['builder.tasks.build_template']: [];
|
||||
['builder.tasks.load_script']: [];
|
||||
['builder.tasks.sort_asset']: [];
|
||||
['builder.tasks.sort_image']: [];
|
||||
['builder.tasks.sort_script']: [];
|
||||
['builder.tasks.sort_sprite_frame']: [];
|
||||
['builder.tasks.sort_texture']: [];
|
||||
['builder.tasks.sort_json']: [];
|
||||
['builder.tasks.settings.compress']: [];
|
||||
['builder.tasks.settings.design_resolution']: [];
|
||||
['builder.tasks.settings.group']: [];
|
||||
['builder.tasks.settings.md5']: [];
|
||||
['builder.tasks.settings.scene']: [];
|
||||
['builder.tasks.settings.script']: [];
|
||||
['builder.tips.enter_name']: [];
|
||||
['builder.tips.taskName']: [];
|
||||
['builder.tips.build_path']: [];
|
||||
['builder.tips.build_scenes']: [];
|
||||
['builder.tips.inline_SpriteFrames']: [];
|
||||
['builder.tips.md5Cache']: [];
|
||||
['builder.tips.merge_start_scene']: [];
|
||||
['builder.tips.debug']: [];
|
||||
['builder.tips.resolution']: [];
|
||||
['builder.tips.web_debugger']: [];
|
||||
['builder.tips.creat_template_success']: [];
|
||||
['builder.tips.set_start_scene']: [];
|
||||
['builder.splash_setting.title']: [];
|
||||
['builder.splash_setting.drag_img_here']: [];
|
||||
['builder.splash_setting.img_loading']: [];
|
||||
['builder.splash_setting.confirm']: [];
|
||||
['builder.splash_setting.settings.total_time']: [];
|
||||
['builder.splash_setting.settings.display_ratio']: [];
|
||||
['builder.splash_setting.settings.clear_color']: [];
|
||||
['builder.splash_setting.settings.effect']: [];
|
||||
['builder.splash_setting.settings.display_watermark']: [];
|
||||
['builder.splash_setting.is_save_dialog.title']: [];
|
||||
['builder.splash_setting.is_save_dialog.save']: [];
|
||||
['builder.splash_setting.is_save_dialog.cancel']: [];
|
||||
['builder.splash_setting.is_save_dialog.abort']: [];
|
||||
['builder.is_remove_task.title']: [];
|
||||
['builder.is_remove_task.has_building_task']: [];
|
||||
['builder.is_remove_task.message']: [];
|
||||
['builder.is_remove_task.remove']: [];
|
||||
['builder.is_remove_task.deep_remove']: [];
|
||||
['builder.is_remove_task.cancel']: [];
|
||||
['builder.is_stop_build.title']: [];
|
||||
['builder.is_stop_build.message']: [];
|
||||
['builder.is_stop_build.stop']: [];
|
||||
['builder.is_stop_build.cancel']: [];
|
||||
['builder.is_close_win.title']: [];
|
||||
['builder.is_close_win.message']: [];
|
||||
['builder.is_close_win.force_close']: [];
|
||||
['builder.is_close_win.cancel']: [];
|
||||
['builder.is_save_scene.title']: [];
|
||||
['builder.is_save_scene.message']: [];
|
||||
['builder.is_save_scene.save']: [];
|
||||
['builder.is_save_scene.ignore']: [];
|
||||
['builder.is_save_scene.cancel']: [];
|
||||
['builder.merge_json_by_scene']: [];
|
||||
['builder.not_require']: [];
|
||||
['builder.options.open_compile_file']: [];
|
||||
['builder.custom_manifest_file_path']: [];
|
||||
['builder.custom_manifest_file_path_hint']: [];
|
||||
['builder.install_nodejs_before_view_certificate']: [];
|
||||
['builder.window_default_npm_path_error']: [];
|
||||
['builder.mac_default_npm_path_error']: [];
|
||||
['builder.oppo.package_name_error']: [];
|
||||
['builder.huawei.certificate_fingerprint_window_error']: [];
|
||||
['builder.huawei.certificate_fingerprint_mac_error']: [];
|
||||
['console.title']: [];
|
||||
['console.editorLog']: [];
|
||||
['console.cocosLog']: [];
|
||||
['console.tabbar.regex']: [];
|
||||
['console.preferences.display_date']: [];
|
||||
['console.preferences.font_size']: [];
|
||||
['console.preferences.line_height']: [];
|
||||
['engine.title']: [];
|
||||
['engine.compile_engine']: [];
|
||||
['engine.wait_quick_compile']: [];
|
||||
['engine.confirm']: [];
|
||||
['engine.browse']: [];
|
||||
['engine.open']: [];
|
||||
['engine.engine_directory_illegal']: [];
|
||||
['engine.engine_compile_failed']: [];
|
||||
['engine.engine_compile_crash']: [];
|
||||
['engine.javascript_engine']: [];
|
||||
['engine.use_builtin_engine']: [];
|
||||
['engine.custom_engine_path']: [];
|
||||
['engine.QUICK_COMPILER.engine_modified_info']: [];
|
||||
['engine.resources_docs_1']: [];
|
||||
['engine.resources_docs_2']: [];
|
||||
['engine.resources_docs_3']: [];
|
||||
['engine.resources_docs_4']: [];
|
||||
['hierarchy.title']: [];
|
||||
['hierarchy.menu.createMenu']: [];
|
||||
['hierarchy.menu.searchPlaceholder']: [];
|
||||
['hierarchy.menu.searchPlaceholder_name']: [];
|
||||
['hierarchy.menu.searchPlaceholder_uuid']: [];
|
||||
['hierarchy.menu.searchPlaceholder_component']: [];
|
||||
['hierarchy.menu.searchTip']: [];
|
||||
['hierarchy.menu.search']: [];
|
||||
['hierarchy.menu.searchName']: [];
|
||||
['hierarchy.menu.searchUuid']: [];
|
||||
['hierarchy.menu.searchComponent']: [];
|
||||
['hierarchy.menu.refresh']: [];
|
||||
['hierarchy.menu.allExpand']: [];
|
||||
['hierarchy.menu.allCollapse']: [];
|
||||
['hierarchy.menu.newNode']: [];
|
||||
['hierarchy.menu.newNodeEmpty']: [];
|
||||
['hierarchy.menu.new3dObject']: [];
|
||||
['hierarchy.menu.new3dCube']: [];
|
||||
['hierarchy.menu.new3dCylinder']: [];
|
||||
['hierarchy.menu.new3dSphere']: [];
|
||||
['hierarchy.menu.new3dCapsule']: [];
|
||||
['hierarchy.menu.new3dCone']: [];
|
||||
['hierarchy.menu.new3dTorus']: [];
|
||||
['hierarchy.menu.new3dPlane']: [];
|
||||
['hierarchy.menu.new3dQuad']: [];
|
||||
['hierarchy.menu.newLightObject']: [];
|
||||
['hierarchy.menu.newLightDirectional']: [];
|
||||
['hierarchy.menu.newLightSphere']: [];
|
||||
['hierarchy.menu.newLightSpot']: [];
|
||||
['hierarchy.menu.newCameraObject']: [];
|
||||
['hierarchy.menu.newTerrain']: [];
|
||||
['hierarchy.menu.newEffects']: [];
|
||||
['hierarchy.menu.newEffectsParticle']: [];
|
||||
['hierarchy.menu.newUI']: [];
|
||||
['hierarchy.menu.newUICanvas']: [];
|
||||
['hierarchy.menu.newUISprite']: [];
|
||||
['hierarchy.menu.newUILabel']: [];
|
||||
['hierarchy.menu.newUIButton']: [];
|
||||
['hierarchy.menu.newUIToggle']: [];
|
||||
['hierarchy.menu.newUIToggleGroup']: [];
|
||||
['hierarchy.menu.newUISlider']: [];
|
||||
['hierarchy.menu.newUIProgressBar']: [];
|
||||
['hierarchy.menu.newUIWidget']: [];
|
||||
['hierarchy.menu.newUIEditBox']: [];
|
||||
['hierarchy.menu.newUILayout']: [];
|
||||
['hierarchy.menu.newUIScrollView']: [];
|
||||
['hierarchy.menu.newUIMask']: [];
|
||||
['hierarchy.menu.copy']: [];
|
||||
['hierarchy.menu.cut']: [];
|
||||
['hierarchy.menu.paste']: [];
|
||||
['hierarchy.menu.delete']: [];
|
||||
['hierarchy.menu.rename']: [];
|
||||
['hierarchy.menu.duplicate']: [];
|
||||
['hierarchy.menu.showUuid']: [];
|
||||
['hierarchy.menu.link_prefab']: [];
|
||||
['hierarchy.menu.link_prefab_error_node_empty']: [];
|
||||
['hierarchy.menu.link_prefab_error_node_isScene']: [];
|
||||
['hierarchy.menu.link_prefab_error_asset_empty']: [];
|
||||
['hierarchy.menu.link_prefab_error_asset_invalid']: [];
|
||||
['hierarchy.menu.link_prefab_make_sure']: [];
|
||||
['hierarchy.menu.unlink_prefab']: [];
|
||||
['hierarchy.menu.unlink_prefab_error_prefab_empty']: [];
|
||||
['hierarchy.menu.errorNewnameEmpty']: [];
|
||||
['hierarchy.operate.cutReady']: [];
|
||||
['hierarchy.operate.cutDone']: [];
|
||||
['hierarchy.operate.copyReady']: [];
|
||||
['hierarchy.operate.copyDone']: [];
|
||||
['hierarchy.operate.duplicateDone']: [];
|
||||
['hierarchy.operate.dialogError']: [];
|
||||
['hierarchy.operate.dialogWarning']: [];
|
||||
['hierarchy.operate.dialogQuestion']: [];
|
||||
['hierarchy.operate.dialogInfo']: [];
|
||||
['hierarchy.operate.renameFail']: [];
|
||||
['inspector.title']: [];
|
||||
['inspector.add_component']: [];
|
||||
['inspector.lock_unlock']: [];
|
||||
['inspector.backward_selection']: [];
|
||||
['inspector.forward_selection']: [];
|
||||
['inspector.menu.remove_component']: [];
|
||||
['inspector.menu.move_up_component']: [];
|
||||
['inspector.menu.move_down_component']: [];
|
||||
['inspector.menu.copy_node_value']: [];
|
||||
['inspector.menu.paste_node_value']: [];
|
||||
['inspector.menu.copy_component']: [];
|
||||
['inspector.menu.paste_component']: [];
|
||||
['inspector.menu.paste_component_values']: [];
|
||||
['inspector.asset.directory.is_subpackage']: [];
|
||||
['inspector.asset.directory.subpackage_name']: [];
|
||||
['inspector.asset.javascript.plugin']: [];
|
||||
['inspector.asset.javascript.loadPluginInWeb']: [];
|
||||
['inspector.asset.javascript.loadPluginInEditor']: [];
|
||||
['inspector.asset.javascript.loadPluginInNative']: [];
|
||||
['inspector.asset.fbx.browse']: [];
|
||||
['inspector.asset.spriteFrame.edit']: [];
|
||||
['inspector.asset.texture.modeWarn']: [];
|
||||
['inspector.node.layer.confirm_message']: [];
|
||||
['inspector.node.layer.change_children']: [];
|
||||
['inspector.node.layer.change_self']: [];
|
||||
['inspector.gradient.title']: [];
|
||||
['inspector.curve_editor.title']: [];
|
||||
['inspector.sprite_editor.title']: [];
|
||||
['inspector.sprite_editor.scale']: [];
|
||||
['inspector.sprite_editor.reset']: [];
|
||||
['inspector.sprite_editor.save']: [];
|
||||
['inspector.sprite_editor.saveError']: [];
|
||||
['inspector.sprite_editor.border']: [];
|
||||
['inspector.sprite_editor.left']: [];
|
||||
['inspector.sprite_editor.right']: [];
|
||||
['inspector.sprite_editor.top']: [];
|
||||
['inspector.sprite_editor.bottom']: [];
|
||||
['inspector.check_is_saved.message']: [];
|
||||
['inspector.check_is_saved.save']: [];
|
||||
['inspector.check_is_saved.abort']: [];
|
||||
['inspector.prefab.local']: [];
|
||||
['inspector.prefab.reset']: [];
|
||||
['inspector.prefab.save']: [];
|
||||
['inspector.prefab.link']: [];
|
||||
['inspector.prefab.unlink']: [];
|
||||
['inspector.prefab.lost']: [];
|
||||
['inspector.prefab.exist']: [];
|
||||
['packager.title']: [];
|
||||
['packager.menu.internal']: [];
|
||||
['packager.menu.project']: [];
|
||||
['packager.menu.global']: [];
|
||||
['packager.menu.add']: [];
|
||||
['packager.menu.addProject']: [];
|
||||
['packager.menu.addGlobal']: [];
|
||||
['packager.menu.addLabel']: [];
|
||||
['packager.menu.addSuccess']: [];
|
||||
['packager.menu.import']: [];
|
||||
['packager.menu.importProject']: [];
|
||||
['packager.menu.importGlobal']: [];
|
||||
['packager.menu.importSuccess']: [];
|
||||
['packager.menu.install']: [];
|
||||
['packager.menu.installProject']: [];
|
||||
['packager.menu.installGlobal']: [];
|
||||
['packager.menu.installSuccess']: [];
|
||||
['packager.menu.selectDirectory']: [];
|
||||
['packager.menu.search']: [];
|
||||
['packager.menu.openFolder']: [];
|
||||
['packager.menu.author']: [];
|
||||
['packager.menu.state']: [];
|
||||
['packager.menu.remove']: [];
|
||||
['packager.menu.removeSuccess']: [];
|
||||
['packager.menu.removeConfirm']: [];
|
||||
['packager.menu.enable']: [];
|
||||
['packager.menu.disable']: [];
|
||||
['packager.menu.enabled']: [];
|
||||
['packager.menu.disabled']: [];
|
||||
['packager.menu.invalid']: [];
|
||||
['packager.menu.confirm']: [];
|
||||
['packager.menu.addError']: [];
|
||||
['packager.menu.importError']: [];
|
||||
['preferences.title']: [];
|
||||
['preferences.nav.general']: [];
|
||||
['preferences.nav.edit']: [];
|
||||
['preferences.nav.extension']: [];
|
||||
['preferences.nav.native']: [];
|
||||
['preferences.nav.laboratory']: [];
|
||||
['preferences.general.language']: [];
|
||||
['preferences.general.step']: [];
|
||||
['preferences.general.preci']: [];
|
||||
['preferences.general.theme']: [];
|
||||
['preferences.general.themeColor']: [];
|
||||
['preferences.general.preview_ip']: [];
|
||||
['preferences.edit.script_editor']: [];
|
||||
['preferences.edit.picture_editor']: [];
|
||||
['preferences.edit.browse']: [];
|
||||
['preferences.edit.remove']: [];
|
||||
['preferences.edit.internal']: [];
|
||||
['preferences.native.wechatgame_app_path']: [];
|
||||
['preferences.extension.package']: [];
|
||||
['preferences.laboratory.about']: [];
|
||||
['preferences.laboratory.new_add_component']: [];
|
||||
['preferences.browse']: [];
|
||||
['preferences.open']: [];
|
||||
['preview.title']: [];
|
||||
['preview.automatic']: [];
|
||||
['preview.automatic_tooltip']: [];
|
||||
['preview.scene_is_empty']: [];
|
||||
['preview.play']: [];
|
||||
['preview.refresh_device']: [];
|
||||
['preview.scan']: [];
|
||||
['preview.create_template']: [];
|
||||
['preview.load_current_scene_error']: [];
|
||||
['preview.creat_template_success']: [];
|
||||
['project-setting.title']: [];
|
||||
['project-setting.nav.preview']: [];
|
||||
['project-setting.nav.groupList']: [];
|
||||
['project-setting.nav.modules']: [];
|
||||
['project-setting.nav.engine']: [];
|
||||
['project-setting.nav.layer']: [];
|
||||
['project-setting.nav.graphics']: [];
|
||||
['project-setting.nav.general']: [];
|
||||
['project-setting.nav.projectPath']: [];
|
||||
['project-setting.nav.wizardPath']: [];
|
||||
['project-setting.preview.start_scene']: [];
|
||||
['project-setting.preview.auto_refresh']: [];
|
||||
['project-setting.preview.current_scene']: [];
|
||||
['project-setting.preview.simulator_setting_type']: [];
|
||||
['project-setting.preview.global']: [];
|
||||
['project-setting.preview.project']: [];
|
||||
['project-setting.preview.simulator_device_orientation']: [];
|
||||
['project-setting.preview.simulator_resolution']: [];
|
||||
['project-setting.preview.customize_resolution']: [];
|
||||
['project-setting.preview.vertical']: [];
|
||||
['project-setting.preview.horizontal']: [];
|
||||
['project-setting.modules.title']: [];
|
||||
['project-setting.modules.info']: [];
|
||||
['project-setting.modules.warn']: [];
|
||||
['project-setting.modules.module']: [];
|
||||
['project-setting.modules.inquiry']: [];
|
||||
['project-setting.modules.submodule']: [];
|
||||
['project-setting.modules.inquiry_all']: [];
|
||||
['project-setting.engine.cocos_default']: [];
|
||||
['project-setting.engine.user_customize']: [];
|
||||
['project-setting.engine.renderPipeline']: [];
|
||||
['project-setting.engine.physics']: [];
|
||||
['project-setting.engine.builtin']: [];
|
||||
['project-setting.engine.cannon']: [];
|
||||
['project-setting.engine.ammo']: [];
|
||||
['project-setting.general.browse']: [];
|
||||
['project-setting.general.ts_compiler']: [];
|
||||
['project-setting.general.tslint.title']: [];
|
||||
['project-setting.general.tslint.default']: [];
|
||||
['project-setting.general.tslint.path']: [];
|
||||
['project-setting.general.section_canvas']: [];
|
||||
['project-setting.general.design_resolution']: [];
|
||||
['project-setting.general.width']: [];
|
||||
['project-setting.general.height']: [];
|
||||
['project-setting.general.fit_width']: [];
|
||||
['project-setting.general.fit_height']: [];
|
||||
['project-setting.general.type_check_level']: [];
|
||||
['project-setting.general.type_check_tips.disable']: [];
|
||||
['project-setting.general.type_check_tips.checkOnly']: [];
|
||||
['project-setting.general.type_check_tips.fatalOnError']: [];
|
||||
['scene.title']: [];
|
||||
['scene.new']: [];
|
||||
['scene.save']: [];
|
||||
['scene.save_as']: [];
|
||||
['scene.develop']: [];
|
||||
['scene.terrain.is_create_message']: [];
|
||||
['scene.terrain.is_create']: [];
|
||||
['scene.terrain.cancel']: [];
|
||||
['scene.terrain.edit']: [];
|
||||
['scene.terrain.save']: [];
|
||||
['scene.terrain.delete']: [];
|
||||
['scene.terrain.abort']: [];
|
||||
['scene.messages.warning']: [];
|
||||
['scene.messages.scenario_modified']: [];
|
||||
['scene.messages.want_to_save']: [];
|
||||
['scene.messages.save']: [];
|
||||
['scene.messages.dont_save']: [];
|
||||
['scene.messages.cancel']: [];
|
||||
['scene.messages.save_as_fail']: [];
|
||||
['scene.save_prefab']: [];
|
||||
['scene.close_prefab']: [];
|
||||
['scene.save_clip']: [];
|
||||
['scene.close_clip']: [];
|
||||
['scene.gizmos.icon3d']: [];
|
||||
['scene.gizmos.showGrid']: [];
|
||||
['scene.ui_tools.zoom_up']: [];
|
||||
['scene.ui_tools.zoom_down']: [];
|
||||
['scene.ui_tools.zoom_reset']: [];
|
||||
['scene.ui_tools.align_top']: [];
|
||||
['scene.ui_tools.align_v_center']: [];
|
||||
['scene.ui_tools.align_bottom']: [];
|
||||
['scene.ui_tools.align_left']: [];
|
||||
['scene.ui_tools.align_h_center']: [];
|
||||
['scene.ui_tools.align_right']: [];
|
||||
['scene.ui_tools.distribute_top']: [];
|
||||
['scene.ui_tools.distribute_v_center']: [];
|
||||
['scene.ui_tools.distribute_bottom']: [];
|
||||
['scene.ui_tools.distribute_left']: [];
|
||||
['scene.ui_tools.distribute_h_center']: [];
|
||||
['scene.ui_tools.distribute_right']: [];
|
||||
['tester.auto_tooltip']: [];
|
||||
['tester.play_tooltip']: [];
|
||||
['tester.pause_tooltip']: [];
|
||||
['ui-kit.title']: [];
|
||||
}
|
||||
160
extensions/app/engine/@types/packages/engine-extends/@types/third-parts.d.ts
vendored
Normal file
160
extensions/app/engine/@types/packages/engine-extends/@types/third-parts.d.ts
vendored
Normal file
@@ -0,0 +1,160 @@
|
||||
declare module 'tga-js' {
|
||||
export default class TGA {
|
||||
width: number;
|
||||
height: number;
|
||||
getImageData(imageData?: ImageData): ImageData | {width: number, height: number, data: Uint8ClampedArray};
|
||||
constructor();
|
||||
load(data: Buffer): null;
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'psd.js' {
|
||||
import PNG from 'pngjs';
|
||||
export default class PSD {
|
||||
constructor (data: Buffer);
|
||||
|
||||
parse();
|
||||
|
||||
image: {
|
||||
toPng(): PNG;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'draco3dgltf' {
|
||||
export function createDecoderModule(options: DecoderModuleOptions): typeof DecoderModule;
|
||||
|
||||
// eslint-disable-next-line
|
||||
export interface DecoderModuleOptions {
|
||||
|
||||
}
|
||||
|
||||
// eslint-disable-next-line
|
||||
interface DecoderModule {
|
||||
|
||||
}
|
||||
|
||||
namespace DecoderModule {
|
||||
function destroy(decoder: Decoder): void;
|
||||
|
||||
function destroy(buffer: DecoderBuffer): void;
|
||||
|
||||
function destroy(int32Array: DracoInt32Array): void;
|
||||
|
||||
function destroy(mesh: Geometry): void;
|
||||
|
||||
export class DecoderBuffer {
|
||||
public Init(buffer: Int8Array, size: number): void;
|
||||
}
|
||||
|
||||
export class Decoder {
|
||||
public GetEncodedGeometryType(buffer: DecoderBuffer): GeometryType;
|
||||
|
||||
public DecodeBufferToMesh(buffer: DecoderBuffer, mesh: Mesh): Status;
|
||||
|
||||
public DecodeBufferToPointCloud(buffer: DecoderBuffer, pointCloud: PointCloud): Status;
|
||||
|
||||
public GetFaceFromMesh(geometry: Geometry, index: number, out: DracoInt32Array): void;
|
||||
|
||||
public GetAttributeId(geometry: Geometry, attributeType: AttributeType): number;
|
||||
|
||||
public GetAttributeByUniqueId(geometry: Geometry, uniqueId: number): Attribute;
|
||||
|
||||
public GetAttribute(geometry: Geometry, attributeId: number): Attribute;
|
||||
|
||||
public GetAttributeInt8ForAllPoints(geometry: Geometry, attribute: Attribute, attributeData: DracoInt8Array): void;
|
||||
|
||||
public GetAttributeInt16ForAllPoints(geometry: Geometry, attribute: Attribute, attributeData: DracoInt16Array): void;
|
||||
|
||||
public GetAttributeInt32ForAllPoints(geometry: Geometry, attribute: Attribute, attributeData: DracoInt32Array): void;
|
||||
|
||||
public GetAttributeUInt8ForAllPoints(geometry: Geometry, attribute: Attribute, attributeData: DracoUInt8Array): void;
|
||||
|
||||
public GetAttributeUInt16ForAllPoints(geometry: Geometry, attribute: Attribute, attributeData: DracoUInt16Array): void;
|
||||
|
||||
public GetAttributeUInt32ForAllPoints(geometry: Geometry, attribute: Attribute, attributeData: DracoUInt32Array): void;
|
||||
|
||||
public GetAttributeFloatForAllPoints(geometry: Geometry, attribute: Attribute, attributeData: DracoFloat32Array): void;
|
||||
}
|
||||
|
||||
class Status {
|
||||
public ok(): boolean;
|
||||
public error_msg(): string;
|
||||
}
|
||||
|
||||
enum GeometryType {
|
||||
// See below
|
||||
}
|
||||
|
||||
export const TRIANGULAR_MESH: GeometryType;
|
||||
|
||||
export const POINT_CLOUD: GeometryType;
|
||||
|
||||
export class Mesh {
|
||||
public ptr: number;
|
||||
|
||||
public num_faces(): number;
|
||||
|
||||
public num_points(): number;
|
||||
}
|
||||
|
||||
export class PointCloud {
|
||||
public ptr: number;
|
||||
|
||||
public num_points(): number;
|
||||
}
|
||||
|
||||
export type Geometry = Mesh | PointCloud;
|
||||
|
||||
enum AttributeType {
|
||||
// See below
|
||||
}
|
||||
|
||||
export const POSITION: AttributeType;
|
||||
export const NORMAL: AttributeType;
|
||||
export const COLOR: AttributeType;
|
||||
export const TEX_COORD: AttributeType;
|
||||
|
||||
class Attribute {
|
||||
private constructor();
|
||||
public num_components(): number;
|
||||
}
|
||||
|
||||
export class DracoInt8Array {
|
||||
public size(): number;
|
||||
public GetValue(index: number): number;
|
||||
}
|
||||
|
||||
export class DracoInt16Array {
|
||||
public size(): number;
|
||||
public GetValue(index: number): number;
|
||||
}
|
||||
|
||||
export class DracoInt32Array {
|
||||
public size(): number;
|
||||
public GetValue(index: number): number;
|
||||
}
|
||||
|
||||
export class DracoUInt8Array {
|
||||
public size(): number;
|
||||
public GetValue(index: number): number;
|
||||
}
|
||||
|
||||
export class DracoUInt16Array {
|
||||
public size(): number;
|
||||
public GetValue(index: number): number;
|
||||
}
|
||||
|
||||
export class DracoUInt32Array {
|
||||
public size(): number;
|
||||
public GetValue(index: number): number;
|
||||
}
|
||||
|
||||
export class DracoFloat32Array {
|
||||
public size(): number;
|
||||
public GetValue(index: number): number;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare const EditorExtends: any;
|
||||
15
extensions/app/engine/@types/packages/engine/@types/index.d.ts
vendored
Normal file
15
extensions/app/engine/@types/packages/engine/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
export * from './module';
|
||||
export interface EngineInfo {
|
||||
typescript: {
|
||||
type: 'builtin' | 'custom'; // 当前使用的引擎类型(内置或自定义)
|
||||
custom: string; // 自定义引擎地址
|
||||
builtin: string, // 内置引擎地址
|
||||
path: string; // 当前使用的引擎路径,为空也表示编译失败
|
||||
},
|
||||
native: {
|
||||
type: 'builtin' | 'custom'; // 当前使用的引擎类型(内置或自定义)
|
||||
custom: string; // 自定义引擎地址
|
||||
builtin: string; // 内置引擎地址
|
||||
path: string; // 当前使用的引擎路径,为空也表示编译失败
|
||||
},
|
||||
}
|
||||
22
extensions/app/engine/@types/packages/engine/@types/message.d.ts
vendored
Normal file
22
extensions/app/engine/@types/packages/engine/@types/message.d.ts
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import { EngineInfo } from './index';
|
||||
export interface message extends EditorMessageMap {
|
||||
'query-info': {
|
||||
params: [] | [
|
||||
string,
|
||||
],
|
||||
result: {
|
||||
version: string;
|
||||
path: string;
|
||||
nativeVersion: string; // 原生引擎类型 'custom' 'builtin'
|
||||
nativePath: string;
|
||||
editor: string;
|
||||
},
|
||||
},
|
||||
'query-engine-info': {
|
||||
params: [] | [
|
||||
string,
|
||||
],
|
||||
result: EngineInfo,
|
||||
},
|
||||
}
|
||||
|
||||
78
extensions/app/engine/@types/packages/engine/@types/module.d.ts
vendored
Normal file
78
extensions/app/engine/@types/packages/engine/@types/module.d.ts
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
|
||||
export type IModules = Record<string, IModuleItem>;
|
||||
|
||||
export interface IFlagBaseItem {
|
||||
/**
|
||||
* Display text.
|
||||
*/
|
||||
label: string;
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*/
|
||||
description?: string;
|
||||
|
||||
native?: string;
|
||||
|
||||
wechatPlugin?: boolean;
|
||||
|
||||
default?: string[];
|
||||
}
|
||||
|
||||
export interface IBaseItem {
|
||||
/**
|
||||
* Display text.
|
||||
*/
|
||||
label: string;
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*/
|
||||
description?: string;
|
||||
|
||||
required?: boolean;
|
||||
|
||||
native?: string;
|
||||
|
||||
wechatPlugin?: boolean;
|
||||
}
|
||||
|
||||
export interface IModuleItem extends IBaseItem {
|
||||
/**
|
||||
* Display text.
|
||||
*/
|
||||
label: string;
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*/
|
||||
description?: string;
|
||||
|
||||
/**
|
||||
* Whether if the feature of options allow multiple selection.
|
||||
*/
|
||||
multi?: boolean;
|
||||
|
||||
/**
|
||||
* If have default it will checked
|
||||
*/
|
||||
default?: string[];
|
||||
|
||||
options?: Record<string, IBaseItem>;
|
||||
|
||||
category?: string;
|
||||
|
||||
flags?: Record<string, IFlagBaseItem>;
|
||||
}
|
||||
|
||||
export interface IDisplayModuleItem extends IModuleItem {
|
||||
_value: boolean;
|
||||
_option?: string;
|
||||
options?: Record<string, IDisplayModuleItem>;
|
||||
}
|
||||
|
||||
export interface IDisplayModuleCache {
|
||||
_value: boolean;
|
||||
_option?: string;
|
||||
flags?: Record<string, boolean>;
|
||||
}
|
||||
50
extensions/app/engine/@types/packages/huawei-agc/@types/index.d.ts
vendored
Normal file
50
extensions/app/engine/@types/packages/huawei-agc/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
|
||||
/// <reference path='../../../@types/index'/>
|
||||
export * from '@editor/library-type/packages/builder/@types/protect';
|
||||
|
||||
import { IInternalBuildOptions, InternalBuildResult } from '@editor/library-type/packages/builder/@types/protect';
|
||||
|
||||
export type IOrientation = 'landscape' | 'portrait';
|
||||
|
||||
export interface ITaskOption extends IInternalBuildOptions {
|
||||
packages: {
|
||||
'android': IOptions;
|
||||
}
|
||||
}
|
||||
|
||||
export type IAppABI = 'armeabi-v7a' | 'arm64-v8a' | 'x86' | 'x86_64';
|
||||
|
||||
export interface IOptions {
|
||||
packageName: string;
|
||||
orientation: {
|
||||
landscapeRight: boolean;
|
||||
landscapeLeft: boolean;
|
||||
portrait: boolean;
|
||||
upsideDown: boolean;
|
||||
},
|
||||
|
||||
apiLevel: number;
|
||||
appABIs: IAppABI[];
|
||||
|
||||
useDebugKeystore: boolean;
|
||||
keystorePath: string;
|
||||
keystorePassword: string;
|
||||
keystoreAlias: string;
|
||||
keystoreAliasPassword: string;
|
||||
|
||||
appBundle: boolean;
|
||||
androidInstant: boolean;
|
||||
remoteUrl: string;
|
||||
sdkPath: string;
|
||||
ndkPath: string;
|
||||
|
||||
renderBackEnd: {
|
||||
vulkan: boolean;
|
||||
gles3: boolean;
|
||||
gles2: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
export interface IBuildResult extends InternalBuildResult {
|
||||
userFrameWorks: boolean; // 是否使用用户的配置数据
|
||||
}
|
||||
32
extensions/app/engine/@types/packages/huawei-quick-game/@types/index.d.ts
vendored
Normal file
32
extensions/app/engine/@types/packages/huawei-quick-game/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/// <reference path='../../../@types/index'/>
|
||||
export * from '@editor/library-type/packages/builder/@types/protect';
|
||||
import { IInternalBuildOptions } from '@editor/library-type/packages/builder/@types/protect';
|
||||
|
||||
export type IOrientation = 'landscape' | 'portrait';
|
||||
|
||||
export interface ITaskOption extends IInternalBuildOptions {
|
||||
packages: {
|
||||
'huawei-quick-game': IOptions;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IOptions {
|
||||
package: string;
|
||||
icon: string;
|
||||
versionName: string;
|
||||
versionCode: string;
|
||||
minPlatformVersion: string;
|
||||
deviceOrientation: IOrientation;
|
||||
useDebugKey: boolean;
|
||||
privatePemPath: string;
|
||||
certificatePemPath: string;
|
||||
|
||||
fullScreen: boolean;
|
||||
logLevel: string;
|
||||
manifestPath?: string;
|
||||
separateEngine: boolean;
|
||||
}
|
||||
|
||||
export interface ICompileOptions {
|
||||
name: string;
|
||||
}
|
||||
41
extensions/app/engine/@types/packages/ios/@types/index.d.ts
vendored
Normal file
41
extensions/app/engine/@types/packages/ios/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
/// <reference path='../../../@types/index'/>
|
||||
export * from '@editor/library-type/packages/builder/@types/protect';
|
||||
|
||||
import { IInternalBuildOptions, InternalBuildResult } from '@editor/library-type/packages/builder/@types/protect';
|
||||
|
||||
export type IOrientation = 'landscape' | 'portrait';
|
||||
|
||||
export interface ITaskOption extends IInternalBuildOptions {
|
||||
packages: {
|
||||
'ios': IOptions;
|
||||
native: {
|
||||
JobSystem: 'none' | 'tbb' | 'taskFlow';
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export interface IBuildResult extends InternalBuildResult {
|
||||
userFrameWorks: boolean; // 是否使用用户的配置数据
|
||||
}
|
||||
|
||||
export interface IOptions {
|
||||
packageName: string;
|
||||
orientation: {
|
||||
landscapeRight: boolean;
|
||||
landscapeLeft: boolean;
|
||||
portrait: boolean;
|
||||
upsideDown: boolean;
|
||||
},
|
||||
skipUpdateXcodeProject: boolean;
|
||||
renderBackEnd: {
|
||||
metal: boolean;
|
||||
gles3: boolean;
|
||||
gles2: boolean;
|
||||
},
|
||||
osTarget: {
|
||||
iphoneos: boolean,
|
||||
simulator: boolean,
|
||||
},
|
||||
developerTeam?: string,
|
||||
targetVersion: string,
|
||||
}
|
||||
18
extensions/app/engine/@types/packages/linux/@types/index.d.ts
vendored
Normal file
18
extensions/app/engine/@types/packages/linux/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
/// <reference path='../../../@types/index'/>
|
||||
export * from '@editor/library-type/packages/builder/@types/protect';
|
||||
import { IInternalBuildOptions, InternalBuildResult } from '@editor/library-type/packages/builder/@types/protect';
|
||||
|
||||
export interface ITaskOption extends IInternalBuildOptions {
|
||||
packages: {
|
||||
'linux': IOptions;
|
||||
native: any;
|
||||
}
|
||||
}
|
||||
|
||||
interface IOptions {
|
||||
renderBackEnd: {
|
||||
metal: boolean;
|
||||
gles3: boolean;
|
||||
gles2: boolean;
|
||||
},
|
||||
}
|
||||
42
extensions/app/engine/@types/packages/localization-editor/@types/gettext-parser/index.d.ts
vendored
Normal file
42
extensions/app/engine/@types/packages/localization-editor/@types/gettext-parser/index.d.ts
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
// Type definitions for gettext-parser 4.0
|
||||
// Project: https://github.com/smhg/gettext-parser
|
||||
// Definitions by: Lorent Lempereur <https://github.com/looorent>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module 'gettext-parser' {
|
||||
export interface GetTextComment {
|
||||
translator?: string;
|
||||
reference?: string;
|
||||
extracted?: string;
|
||||
flag?: string;
|
||||
previous?: string;
|
||||
}
|
||||
|
||||
export interface GetTextTranslation {
|
||||
msgctxt?: string | undefined;
|
||||
msgid: string;
|
||||
msgid_plural?: string;
|
||||
msgstr: string[];
|
||||
comments: GetTextComment;
|
||||
}
|
||||
|
||||
export interface GetTextTranslations {
|
||||
charset: string;
|
||||
headers: { [headerName: string]: string };
|
||||
translations: { [msgctxt: string]: { [msgId: string]: GetTextTranslation } };
|
||||
}
|
||||
|
||||
export interface PoParser {
|
||||
parse: (buffer: Buffer | string, defaultCharset?: string) => GetTextTranslations;
|
||||
compile: (table: GetTextTranslations, options?: any) => Buffer;
|
||||
createParseStream: (buffer: any, defaultCharset?: string) => any;
|
||||
}
|
||||
|
||||
export interface MoParser {
|
||||
parse: (buffer: Buffer | string, defaultCharset?: string) => GetTextTranslations;
|
||||
compile: (table: GetTextTranslations, options?: any) => Buffer;
|
||||
}
|
||||
|
||||
export const po: PoParser;
|
||||
export const mo: MoParser;
|
||||
}
|
||||
104
extensions/app/engine/@types/packages/localization-editor/@types/globals.d.ts
vendored
Normal file
104
extensions/app/engine/@types/packages/localization-editor/@types/globals.d.ts
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
||||
Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
declare const gfx: any;
|
||||
declare const global: any;
|
||||
|
||||
interface Window {
|
||||
|
||||
[x: string]: any;
|
||||
|
||||
WebGL2RenderingContext: any;
|
||||
|
||||
sharedCanvas: any;
|
||||
__canvas: any;
|
||||
canvas: any;
|
||||
|
||||
XMLHttpRequest: any;
|
||||
mozRequestAnimationFrame(callback: any, element?: any): any;
|
||||
oRequestAnimationFrame(callback: any, element?: any): any;
|
||||
msRequestAnimationFrame(callback: any, element?: any): any;
|
||||
cancelRequestAnimationFrame(callback: any, element?: any): any;
|
||||
msCancelRequestAnimationFrame(callback: any, element?: any): any;
|
||||
mozCancelRequestAnimationFrame(callback: any, element?: any): any;
|
||||
oCancelRequestAnimationFrame(callback: any, element?: any): any;
|
||||
webkitCancelRequestAnimationFrame(callback: any, element?: any): any;
|
||||
msCancelAnimationFrame(callback: any, element?: any): any;
|
||||
mozCancelAnimationFrame(callback: any, element?: any): any;
|
||||
ocancelAnimationFrame(callback: any, element?: any): any;
|
||||
}
|
||||
|
||||
interface Document {
|
||||
mozHidden: any;
|
||||
msHidden: any;
|
||||
webkitHidden: any;
|
||||
}
|
||||
|
||||
interface HTMLElement {
|
||||
content: any;
|
||||
name: any;
|
||||
}
|
||||
|
||||
declare type CompareFunction<T> = (a: T, b: T) => number;
|
||||
|
||||
declare type RecursivePartial<T> = {
|
||||
[P in keyof T]?:
|
||||
T[P] extends Array<infer U> ? Array<RecursivePartial<U>> :
|
||||
T[P] extends ReadonlyArray<infer V> ? ReadonlyArray<RecursivePartial<V>> : RecursivePartial<T[P]>;
|
||||
};
|
||||
|
||||
declare type TypedArray = Uint8Array | Uint8ClampedArray | Int8Array | Uint16Array |
|
||||
Int16Array | Uint32Array | Int32Array | Float32Array | Float64Array;
|
||||
|
||||
declare type TypedArrayConstructor = Uint8ArrayConstructor | Uint8ClampedArrayConstructor |
|
||||
Int8ArrayConstructor | Uint16ArrayConstructor | Int16ArrayConstructor | Uint32ArrayConstructor |
|
||||
Int32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor;
|
||||
|
||||
declare interface IWritableArrayLike<T> {
|
||||
readonly length: number;
|
||||
[index: number]: T;
|
||||
}
|
||||
|
||||
declare type Constructor<T = unknown> = new (...args: any[]) => T;
|
||||
|
||||
declare type AbstractedConstructor<T = unknown> = abstract new (...args: any[]) => T;
|
||||
|
||||
/**
|
||||
* Alias of `Function` but suppress eslint warning.
|
||||
* Please avoid using it and explicitly specify function signatures as possible.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
declare type AnyFunction = Function;
|
||||
|
||||
declare type Mutable<T> = { -readonly [P in keyof T]: T[P] };
|
||||
|
||||
declare type Getter = () => any;
|
||||
|
||||
declare type Setter = (value: any) => void;
|
||||
|
||||
declare const Buffer: any;
|
||||
|
||||
declare type EnumAlias<EnumT> = EnumT[keyof EnumT];
|
||||
37
extensions/app/engine/@types/packages/localization-editor/@types/index.d.ts
vendored
Normal file
37
extensions/app/engine/@types/packages/localization-editor/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
interface CCENodeEventMap {
|
||||
added (node: import('cc').Node): void
|
||||
change (node: import('cc').Node): void
|
||||
removed (node: import('cc').Node): void
|
||||
}
|
||||
|
||||
interface CCEComponentEventMap {
|
||||
added (component: import('cc').Component): void,
|
||||
removed (component: import('cc').Component): void,
|
||||
}
|
||||
|
||||
declare class CCENodeManager extends EventEmitter {
|
||||
on<T extends keyof CCENodeEventMap> (message: T, callback: CCENodeEventMap[T]): this;
|
||||
off<T extends keyof CCENodeEventMap> (message: T, callback: CCENodeEventMap[T]): this;
|
||||
}
|
||||
declare class CCEComponentManager extends EventEmitter {
|
||||
on<T extends keyof CCEComponentEventMap> (message: T, callback: CCEComponentEventMap[T]): this;
|
||||
off<T extends keyof CCEComponentEventMap> (message: T, callback: CCEComponentEventMap[T]): this;
|
||||
}
|
||||
|
||||
type CCE = {
|
||||
Node: CCENodeManager,
|
||||
Component: CCEComponentManager,
|
||||
Prefab: {
|
||||
generatePrefabDataFromNode(nodeUUID: string| cc.Node): string | null
|
||||
}
|
||||
};
|
||||
|
||||
declare const cce: CCE;
|
||||
declare type UnPromise<T> = T extends Promise<infer R> ? R : T;
|
||||
declare type UUID = string;
|
||||
declare type Dump = { value: Record<string, { value: Dump | any, values?: any | Dump[], visible: boolean, readonly: boolean }> };
|
||||
declare module 'cc/env' {
|
||||
export const EDITOR: boolean;
|
||||
export const BUILD: boolean;
|
||||
}
|
||||
declare const EditorExtends: any;
|
||||
111
extensions/app/engine/@types/packages/localization-editor/@types/intl/index.d.ts
vendored
Normal file
111
extensions/app/engine/@types/packages/localization-editor/@types/intl/index.d.ts
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
declare namespace Intl {
|
||||
type BCP47LanguageTag = string;
|
||||
/**
|
||||
* The locale matching algorithm to use.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat#parameters).
|
||||
*/
|
||||
type ListFormatLocaleMatcher = 'lookup' | 'best fit';
|
||||
|
||||
/**
|
||||
* The format of output message.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat#parameters).
|
||||
*/
|
||||
type ListFormatType = 'conjunction' | 'disjunction' | 'unit';
|
||||
|
||||
/**
|
||||
* The length of the formatted message.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat#parameters).
|
||||
*/
|
||||
type ListFormatStyle = 'long' | 'short' | 'narrow';
|
||||
|
||||
/**
|
||||
* An object with some or all properties of the `Intl.ListFormat` constructor `options` parameter.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat#parameters).
|
||||
*/
|
||||
interface ListFormatOptions {
|
||||
/** The locale matching algorithm to use. For information about this option, see [Intl page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation). */
|
||||
localeMatcher?: ListFormatLocaleMatcher | undefined;
|
||||
/** The format of output message. */
|
||||
type?: ListFormatType | undefined;
|
||||
/** The length of the internationalized message. */
|
||||
style?: ListFormatStyle | undefined;
|
||||
}
|
||||
|
||||
interface ListFormat {
|
||||
/**
|
||||
* Returns a string with a language-specific representation of the list.
|
||||
*
|
||||
* @param list - An iterable object, such as an [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array).
|
||||
*
|
||||
* @throws `TypeError` if `list` includes something other than the possible values.
|
||||
*
|
||||
* @returns {string} A language-specific formatted string representing the elements of the list.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/format).
|
||||
*/
|
||||
format(list: Iterable<string>): string;
|
||||
|
||||
/**
|
||||
* Returns an Array of objects representing the different components that can be used to format a list of values in a locale-aware fashion.
|
||||
*
|
||||
* @param list - An iterable object, such as an [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array), to be formatted according to a locale.
|
||||
*
|
||||
* @throws `TypeError` if `list` includes something other than the possible values.
|
||||
*
|
||||
* @returns {{ type: "element" | "literal", value: string; }[]} An Array of components which contains the formatted parts from the list.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/formatToParts).
|
||||
*/
|
||||
formatToParts(list: Iterable<string>): { type: 'element' | 'literal', value: string; }[];
|
||||
}
|
||||
|
||||
const ListFormat: {
|
||||
prototype: ListFormat;
|
||||
|
||||
/**
|
||||
* Creates [Intl.ListFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat) objects that
|
||||
* enable language-sensitive list formatting.
|
||||
*
|
||||
* @param locales - A string with a [BCP 47 language tag](http://tools.ietf.org/html/rfc5646), or an array of such strings.
|
||||
* For the general form and interpretation of the `locales` argument,
|
||||
* see the [`Intl` page](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).
|
||||
*
|
||||
* @param options - An [object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat#parameters)
|
||||
* with some or all options of `ListFormatOptions`.
|
||||
*
|
||||
* @returns [Intl.ListFormatOptions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat) object.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat).
|
||||
*/
|
||||
new(locales?: BCP47LanguageTag | BCP47LanguageTag[], options?: ListFormatOptions): ListFormat;
|
||||
|
||||
/**
|
||||
* Returns an array containing those of the provided locales that are
|
||||
* supported in list formatting without having to fall back to the runtime's default locale.
|
||||
*
|
||||
* @param locales - A string with a [BCP 47 language tag](http://tools.ietf.org/html/rfc5646), or an array of such strings.
|
||||
* For the general form and interpretation of the `locales` argument,
|
||||
* see the [`Intl` page](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).
|
||||
*
|
||||
* @param options - An [object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/supportedLocalesOf#parameters).
|
||||
* with some or all possible options.
|
||||
*
|
||||
* @returns An array of strings representing a subset of the given locale tags that are supported in list
|
||||
* formatting without having to fall back to the runtime's default locale.
|
||||
*
|
||||
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/supportedLocalesOf).
|
||||
*/
|
||||
supportedLocalesOf(locales: BCP47LanguageTag | BCP47LanguageTag[], options?: Pick<ListFormatOptions, 'localeMatcher'>): BCP47LanguageTag[];
|
||||
};
|
||||
|
||||
type TextInfo = { direction: 'ltr' | 'rtl' }
|
||||
|
||||
interface Locale {
|
||||
prototype: Locale
|
||||
textInfo(): TextInfo
|
||||
}
|
||||
}
|
||||
25
extensions/app/engine/@types/packages/localization-editor/@types/po.d.ts
vendored
Normal file
25
extensions/app/engine/@types/packages/localization-editor/@types/po.d.ts
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
export type PoHeader = {
|
||||
/** This is the name and version of the package. */
|
||||
'Project-Id-Version'?: string
|
||||
/** (非必须) po 创建日期 */
|
||||
'POT-Creation-Date'?: string
|
||||
/** (非必须) po 修改日期*/
|
||||
'PO-Revision-Date'?: string
|
||||
/** 上一个翻译人员 */
|
||||
'Last-Translator'?: string
|
||||
/** 翻译团队的名称或者邮箱 */
|
||||
'Language-Team'?: string
|
||||
/** (非必须)要使 MIME 文档符合 RFC 2045,需要此字段在顶级头中值为 1.0 */
|
||||
'MIME-Version'?: '1.0'
|
||||
/** 译文的语言 */
|
||||
Language: string
|
||||
/** Content-Type 定义了正文的类型,我们实际上是通过这个标识来知道正文内是什么类型的文件。比如:text/plain 表示的是无格式的文本正文,text/html 表示的 Html 文档,image/gif 表示的是 gif 格式的图片等等 */
|
||||
'Content-Type'?: 'text/plain; charset=UTF-8'
|
||||
/** 它表示了这个部分文档的编码方式。只有识别了这个说明,才能用正确的解码方式实现对其解码。 */
|
||||
'Content-Transfer-Encoding'?: '8bit'
|
||||
/** (非必须)复数的规则,*/
|
||||
'Plural-Forms'?: string
|
||||
}
|
||||
|
||||
export type IPluralRulesJson = Record<Intl.BCP47LanguageTag, [Intl.LDMLPluralRule]>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export {};
|
||||
@@ -0,0 +1,11 @@
|
||||
/// <reference types="../../../@types/cc" />
|
||||
import { Component, Label } from 'cc';
|
||||
export default abstract class L10nComponent extends Component {
|
||||
protected constructor();
|
||||
get string(): string;
|
||||
label?: Label | null;
|
||||
protected onLoad(): void;
|
||||
protected start(): void;
|
||||
render(): void;
|
||||
preview(value: string): void;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import L10nComponent from './l10n-component';
|
||||
export default class L10nLabel extends L10nComponent {
|
||||
_key: string;
|
||||
set key(value: string);
|
||||
get key(): string;
|
||||
_count: number;
|
||||
set count(value: number);
|
||||
get count(): number;
|
||||
onLoad(): void;
|
||||
render(): void;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { AssetManager } from 'cc';
|
||||
import type { L10nManager } from './l10n-manager';
|
||||
export default class AMPipeLineManager {
|
||||
initialized: boolean;
|
||||
l10n?: L10nManager;
|
||||
_redirectTask: this['redirectTask'];
|
||||
initAssetManager(l10n: L10nManager): void;
|
||||
uninstall(): void;
|
||||
redirectTask: (task: {
|
||||
output: AssetManager.RequestItem[];
|
||||
input: AssetManager.RequestItem[];
|
||||
}) => void;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export {};
|
||||
51
extensions/app/engine/@types/packages/localization-editor/@types/runtime/core/icu-options.d.ts
vendored
Normal file
51
extensions/app/engine/@types/packages/localization-editor/@types/runtime/core/icu-options.d.ts
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
import { FallbackLanguage, L10nValue } from './l10n-options';
|
||||
export declare type FormattedValue = string;
|
||||
export declare type TextInfoDirection = 'ltr' | 'rtl';
|
||||
export interface StandardOption {
|
||||
count?: number;
|
||||
defaultValue?: L10nValue;
|
||||
language?: Intl.BCP47LanguageTag;
|
||||
fallbackLanguage?: FallbackLanguage;
|
||||
}
|
||||
export interface Template {
|
||||
[key: string]: string | {
|
||||
[key: string]: StandardOption;
|
||||
};
|
||||
}
|
||||
export interface NumberFormatOptions extends Intl.NumberFormatOptions {
|
||||
style?: 'decimal' | 'percent' | 'currency' | string;
|
||||
/**
|
||||
* 货币代码,采用ISO 4217标准
|
||||
* @see ISO4217Tag
|
||||
*/
|
||||
currency?: string;
|
||||
currencySign?: 'standard' | 'accounting' | string;
|
||||
currencyDisplay?: 'symbol' | 'code' | 'name' | string;
|
||||
useGrouping?: boolean;
|
||||
minimumIntegerDigits?: number;
|
||||
minimumFractionDigits?: number;
|
||||
maximumFractionDigits?: number;
|
||||
minimumSignificantDigits?: number;
|
||||
maximumSignificantDigits?: number;
|
||||
}
|
||||
export interface DateTimeFormatOptions {
|
||||
localeMatcher?: 'best fit' | 'lookup' | undefined | string;
|
||||
weekday?: 'long' | 'short' | 'narrow' | undefined | string;
|
||||
era?: 'long' | 'short' | 'narrow' | undefined | string;
|
||||
year?: 'numeric' | '2-digit' | undefined | string;
|
||||
month?: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow' | undefined | string;
|
||||
day?: 'numeric' | '2-digit' | undefined | string;
|
||||
hour?: 'numeric' | '2-digit' | undefined | string;
|
||||
minute?: 'numeric' | '2-digit' | undefined | string;
|
||||
second?: 'numeric' | '2-digit' | undefined | string;
|
||||
timeZoneName?: 'long' | 'short' | undefined | string;
|
||||
formatMatcher?: 'best fit' | 'basic' | undefined | string;
|
||||
hour12?: boolean | undefined;
|
||||
timeZone?: string | undefined;
|
||||
}
|
||||
export declare type RelativeTimeFormatUnit = 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year' | string;
|
||||
export interface RelativeTimeFormatOptions {
|
||||
localeMatcher?: 'lookup' | 'best fit' | string;
|
||||
style?: 'narrow' | 'short' | 'long' | string;
|
||||
numeric?: 'auto' | 'always' | string;
|
||||
}
|
||||
10
extensions/app/engine/@types/packages/localization-editor/@types/runtime/core/icu-type.d.ts
vendored
Normal file
10
extensions/app/engine/@types/packages/localization-editor/@types/runtime/core/icu-type.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Intl formatting
|
||||
*/
|
||||
declare enum ICUType {
|
||||
DateTime = 0,
|
||||
Number = 1,
|
||||
List = 2,
|
||||
RelativeTime = 3,
|
||||
}
|
||||
export default ICUType;
|
||||
@@ -0,0 +1,5 @@
|
||||
declare enum L10nListenEvent {
|
||||
languageChanged = 'languageChanged',
|
||||
onMissingKey = 'missingKey',
|
||||
}
|
||||
export default L10nListenEvent;
|
||||
60
extensions/app/engine/@types/packages/localization-editor/@types/runtime/core/l10n-manager.d.ts
vendored
Normal file
60
extensions/app/engine/@types/packages/localization-editor/@types/runtime/core/l10n-manager.d.ts
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
import type { L10nOptions, ResourceData, L10nKey, L10nValue } from './l10n-options';
|
||||
import { StandardOption, Template, TextInfoDirection } from './icu-options';
|
||||
import L10nListenEvent from './l10n-listen-event';
|
||||
import ResourceDataManager from './resource-data-manager';
|
||||
import AMPipeLineManager from './asset-manager-initer';
|
||||
export declare class L10nManager {
|
||||
static LOCAL_STORAGE_LANGUAGE_KEY: string;
|
||||
static DEFAULT_NAMESPACE: string;
|
||||
static l10n: L10nManager;
|
||||
/**
|
||||
* @zh
|
||||
* i18n 实例
|
||||
* @en
|
||||
* i18next instance
|
||||
*/
|
||||
private _intl?;
|
||||
private _options;
|
||||
private resourceList?;
|
||||
private resourceBundle;
|
||||
resourceDataManager: ResourceDataManager;
|
||||
amPipeLineManager: AMPipeLineManager;
|
||||
private constructor();
|
||||
isInitialized(): boolean;
|
||||
createIntl(options: L10nOptions): Promise<void>;
|
||||
cloneIntl(options: L10nOptions): void;
|
||||
reloadResourceData(): Promise<boolean>;
|
||||
/** 初始化 i18next */
|
||||
config(options: L10nOptions): void;
|
||||
changeLanguage(language: Intl.BCP47LanguageTag): Promise<void>;
|
||||
t(key: L10nKey, options?: StandardOption | Template): L10nValue;
|
||||
/**
|
||||
* 实验性功能暂不开放
|
||||
* 数字类ICU
|
||||
*/
|
||||
private tn;
|
||||
/**
|
||||
* 实验性功能暂不开放
|
||||
* 日期/时刻类ICU
|
||||
*/
|
||||
private td;
|
||||
/**
|
||||
* 实验性功能暂不开放
|
||||
* 时长类ICU
|
||||
*/
|
||||
private tt;
|
||||
/**
|
||||
* 实验性功能暂不开放
|
||||
* 数组类ICU
|
||||
*/
|
||||
private tl;
|
||||
exists(key: L10nKey): boolean;
|
||||
get currentLanguage(): Intl.BCP47LanguageTag;
|
||||
get languages(): readonly Intl.BCP47LanguageTag[];
|
||||
direction(language?: Intl.BCP47LanguageTag): TextInfoDirection;
|
||||
on(event: L10nListenEvent, callback: (...args: any[]) => void): void;
|
||||
off(event: L10nListenEvent, callback: (...args: any[]) => void): void;
|
||||
getResourceBundle(language: string): ResourceData | undefined;
|
||||
}
|
||||
declare const l10n: L10nManager;
|
||||
export default l10n;
|
||||
78
extensions/app/engine/@types/packages/localization-editor/@types/runtime/core/l10n-options.d.ts
vendored
Normal file
78
extensions/app/engine/@types/packages/localization-editor/@types/runtime/core/l10n-options.d.ts
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
export declare type L10nKey = string;
|
||||
export declare type L10nValue = string;
|
||||
export interface ResourceList {
|
||||
defaultLanguage?: Intl.BCP47LanguageTag;
|
||||
fallbackLanguage?: Intl.BCP47LanguageTag;
|
||||
languages: Intl.BCP47LanguageTag[];
|
||||
}
|
||||
export interface ResourceBundle {
|
||||
[language: Intl.BCP47LanguageTag]: ResourceData;
|
||||
}
|
||||
export interface ResourceData {
|
||||
[namespace: string]: ResourceItem;
|
||||
}
|
||||
export interface ResourceItem {
|
||||
[key: string]: any;
|
||||
}
|
||||
export interface FallbackLanguageObjectList {
|
||||
[language: string]: readonly string[];
|
||||
}
|
||||
export declare type FallbackLanguage = string | readonly string[] | FallbackLanguageObjectList | ((language: Intl.BCP47LanguageTag) => string | readonly string[] | FallbackLanguageObjectList);
|
||||
export interface L10nOptions {
|
||||
/**
|
||||
* Logs info level to console output. Helps finding issues with loading not working.
|
||||
* @default false
|
||||
*/
|
||||
/**
|
||||
* Resources to initialize with (if not using loading or not appending using addResourceBundle)
|
||||
* @default undefined
|
||||
*/
|
||||
resources?: ResourceBundle;
|
||||
/**
|
||||
* Language to use (overrides language detection)
|
||||
*/
|
||||
language?: Intl.BCP47LanguageTag;
|
||||
/**
|
||||
* Language to use if translations in user language are not available.
|
||||
* @default same as language
|
||||
*/
|
||||
fallbackLanguage?: false | FallbackLanguage;
|
||||
/**
|
||||
* @default IntlManager.LOCAL_STORAGE_LANGUAGE_KEY
|
||||
*/
|
||||
localStorageLanguageKey?: string;
|
||||
/**
|
||||
* @zh
|
||||
* 可以对key进行前置处理,返回值应该是处理后的key
|
||||
*
|
||||
* @en
|
||||
* Preprocess the key
|
||||
*
|
||||
* @param key
|
||||
* @return string
|
||||
* onBeforeProcessHandler
|
||||
*/
|
||||
beforeTranslate?: (key: L10nKey) => L10nValue;
|
||||
/**
|
||||
* @zh
|
||||
* 对value进行后置处理,返回值应该是处理后的value
|
||||
*
|
||||
* @en
|
||||
* Postprocess the value, return the processed value
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return string
|
||||
*/
|
||||
afterTranslate?: (key: string, value: string) => string;
|
||||
/**
|
||||
* Allows null values as valid translation
|
||||
* @default true
|
||||
*/
|
||||
returnNull?: boolean;
|
||||
/**
|
||||
* Allows empty string as valid translation
|
||||
* @default true
|
||||
*/
|
||||
returnEmptyString?: boolean;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export declare const pluginName = 'Localization Editor';
|
||||
export declare const mainName = 'localization-editor';
|
||||
export declare const runtimeBundleName = 'l10n';
|
||||
export declare const resourceListPath = 'resource-list';
|
||||
export declare const resourceBundlePath = 'resource-bundle';
|
||||
@@ -0,0 +1,25 @@
|
||||
/// <reference types="../../../@types/cc" />
|
||||
import { AssetManager, JsonAsset } from 'cc';
|
||||
import { ResourceBundle, ResourceList } from './l10n-options';
|
||||
export default class ResourceDataManager {
|
||||
readResourceList(): Promise<ResourceList>;
|
||||
readResourceBundle(tags: Intl.BCP47LanguageTag[]): Promise<ResourceBundle>;
|
||||
/**
|
||||
* 编辑器模式下使用
|
||||
* @param locales
|
||||
*/
|
||||
editorLoad(locales: Intl.BCP47LanguageTag[]): Promise<ResourceBundle | undefined>;
|
||||
/**
|
||||
* 构建后运行时使用
|
||||
* @param fileName
|
||||
*/
|
||||
runtimeLoad<T>(fileName: string): Promise<T | undefined>;
|
||||
/**
|
||||
* 浏览器预览使用
|
||||
* @param urlPath
|
||||
*/
|
||||
previewLoad<T>(urlPath: string): Promise<T | undefined>;
|
||||
checkBundle(bundleName: string): Promise<boolean>;
|
||||
getBundle(bundleName: string): Promise<AssetManager.Bundle | undefined>;
|
||||
getResource(bundle: AssetManager.Bundle, resourceName: string): Promise<JsonAsset | undefined>;
|
||||
}
|
||||
5
extensions/app/engine/@types/packages/localization-editor/@types/runtime/l10n.d.ts
vendored
Normal file
5
extensions/app/engine/@types/packages/localization-editor/@types/runtime/l10n.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import l10n, { L10nManager } from './core/l10n-manager';
|
||||
import L10nListenEvent from './core/l10n-listen-event';
|
||||
import L10nLabel from './components/l10n-label';
|
||||
export type { L10nKey, L10nValue, ResourceList, ResourceBundle, ResourceData, ResourceItem, FallbackLanguageObjectList, FallbackLanguage, L10nOptions } from './core/l10n-options';
|
||||
export { l10n, L10nManager, L10nLabel, L10nListenEvent };
|
||||
@@ -0,0 +1 @@
|
||||
import '@formatjs/intl-datetimeformat';
|
||||
@@ -0,0 +1 @@
|
||||
import '@formatjs/intl-displaynames';
|
||||
@@ -0,0 +1 @@
|
||||
import '@formatjs/intl-listformat';
|
||||
@@ -0,0 +1 @@
|
||||
import '@formatjs/intl-locale';
|
||||
@@ -0,0 +1 @@
|
||||
import '@formatjs/intl-numberformat';
|
||||
@@ -0,0 +1 @@
|
||||
import 'intl-pluralrules';
|
||||
@@ -0,0 +1 @@
|
||||
import '@formatjs/intl-relativetimeformat';
|
||||
@@ -0,0 +1 @@
|
||||
import '@formatjs/intl-getcanonicallocales';
|
||||
29
extensions/app/engine/@types/packages/mac/@types/index.d.ts
vendored
Normal file
29
extensions/app/engine/@types/packages/mac/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
/// <reference path='../../../@types/index'/>
|
||||
export * from '@editor/library-type/packages/builder/@types/protect';
|
||||
|
||||
import { IInternalBuildOptions, InternalBuildResult } from '@editor/library-type/packages/builder/@types/protect';
|
||||
|
||||
export type IOrientation = 'landscape' | 'portrait';
|
||||
|
||||
export interface ITaskOption extends IInternalBuildOptions {
|
||||
packages: {
|
||||
'mac': IOptions;
|
||||
native: any;
|
||||
}
|
||||
}
|
||||
|
||||
export interface IOptions {
|
||||
packageName: string;
|
||||
renderBackEnd: {
|
||||
metal: boolean;
|
||||
gles3: boolean;
|
||||
gles2: boolean;
|
||||
},
|
||||
supportM1: boolean;
|
||||
skipUpdateXcodeProject: boolean;
|
||||
targetVersion: string;
|
||||
}
|
||||
|
||||
export interface IBuildCache extends InternalBuildResult {
|
||||
userFrameWorks: boolean; // 是否使用用户的配置数据
|
||||
}
|
||||
39
extensions/app/engine/@types/packages/native/@types/index.d.ts
vendored
Normal file
39
extensions/app/engine/@types/packages/native/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
/// <reference path='../../../@types/index'/>
|
||||
export * from '@editor/library-type/packages/builder/@types/protect';
|
||||
import { IInternalBuildOptions, InternalBuildResult, IPolyFills, IBuildScriptParam } from '@editor/library-type/packages/builder/@types/protect';
|
||||
import { CocosParams } from 'native-pack-tool';
|
||||
|
||||
declare enum NetMode {
|
||||
client = 0,
|
||||
hostServer = 1,
|
||||
listenServer = 2,
|
||||
}
|
||||
export interface ITaskOptionPackages {
|
||||
native: IOptions;
|
||||
}
|
||||
|
||||
interface ICustomBuildScriptParam extends IBuildScriptParam {
|
||||
experimentalHotReload: boolean;
|
||||
}
|
||||
|
||||
export interface ITaskOption extends IInternalBuildOptions {
|
||||
packages: ITaskOptionPackages;
|
||||
buildScriptParam: ICustomBuildScriptParam;
|
||||
}
|
||||
|
||||
export interface IOptions {
|
||||
template: string;
|
||||
engine?: string;
|
||||
runAfterMake: boolean;
|
||||
encrypted: boolean;// 是否加密脚本
|
||||
compressZip: boolean;// 是否压缩脚本
|
||||
xxteaKey?: string;// xxtea 加密的 key 值
|
||||
params?: CocosParams; // console 需要的参数
|
||||
JobSystem: 'none' | 'tbb' | 'taskFlow';
|
||||
serverMode: boolean;
|
||||
netMode: NetMode;
|
||||
}
|
||||
|
||||
export interface IBuildCache extends InternalBuildResult {
|
||||
userFrameWorks: boolean; // 是否使用用户的配置数据
|
||||
}
|
||||
36
extensions/app/engine/@types/packages/ohos/@types/index.d.ts
vendored
Normal file
36
extensions/app/engine/@types/packages/ohos/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
/// <reference path='../../../@types/index'/>
|
||||
export * from '@editor/library-type/packages/builder/@types/protect';
|
||||
|
||||
import { IInternalBuildOptions, InternalBuildResult } from '@editor/library-type/packages/builder/@types/protect';
|
||||
|
||||
export type IOrientation = 'landscape' | 'portrait';
|
||||
|
||||
export interface ITaskOption extends IInternalBuildOptions {
|
||||
packages: {
|
||||
'ohos': IOptions;
|
||||
}
|
||||
}
|
||||
|
||||
export interface IOptions {
|
||||
packageName: string;
|
||||
orientation: {
|
||||
landscapeRight: boolean;
|
||||
landscapeLeft: boolean;
|
||||
portrait: boolean;
|
||||
upsideDown: boolean;
|
||||
},
|
||||
|
||||
apiLevel: number;
|
||||
sdkPath: string;
|
||||
ndkPath: string;
|
||||
|
||||
renderBackEnd: {
|
||||
// vulkan: boolean;
|
||||
gles3: boolean;
|
||||
// gles2: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
export interface IBuildResult extends InternalBuildResult {
|
||||
userFrameWorks: boolean; // 是否使用用户的配置数据
|
||||
}
|
||||
37
extensions/app/engine/@types/packages/open-harmonyos/@types/index.d.ts
vendored
Normal file
37
extensions/app/engine/@types/packages/open-harmonyos/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
/// <reference path="../../../@types/index.d.ts"/>
|
||||
/// <reference path="@editor/library-type/packages/builder/@types/protect/global.d.ts"/>
|
||||
|
||||
export * from '@editor/library-type/packages/builder/@types/protect';
|
||||
import { IInternalBuildOptions, InternalBuildResult } from '@editor/library-type/packages/builder/@types/protect';
|
||||
export type IOrientation = 'landscape' | 'portrait';
|
||||
|
||||
export interface ITaskOption extends IInternalBuildOptions {
|
||||
packages: {
|
||||
'open-harmonyos': IOptions;
|
||||
}
|
||||
}
|
||||
|
||||
export interface IOptions {
|
||||
packageName: string;
|
||||
orientation: {
|
||||
landscapeRight: boolean;
|
||||
landscapeLeft: boolean;
|
||||
portrait: boolean;
|
||||
upsideDown: boolean;
|
||||
},
|
||||
|
||||
apiLevel: string;
|
||||
sdkPath: string;
|
||||
ndkPath: string;
|
||||
|
||||
renderBackEnd: {
|
||||
// vulkan: boolean;
|
||||
gles3: boolean;
|
||||
// gles2: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
export interface IBuildResult extends InternalBuildResult {
|
||||
userFrameWorks: boolean; // 是否使用用户的配置数据
|
||||
}
|
||||
30
extensions/app/engine/@types/packages/oppo-mini-game/@types/index.d.ts
vendored
Normal file
30
extensions/app/engine/@types/packages/oppo-mini-game/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
/// <reference path='../../../@types/index'/>
|
||||
export * from '@editor/library-type/packages/builder/@types/protect';
|
||||
import { IInternalBuildOptions } from '@editor/library-type/packages/builder/@types/protect';
|
||||
|
||||
export type IOrientation = 'landscape' | 'portrait';
|
||||
export interface ITaskOption extends IInternalBuildOptions {
|
||||
packages: {
|
||||
'oppo-mini-game': IOptions;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IOptions {
|
||||
package: string;
|
||||
icon: string;
|
||||
versionName: string;
|
||||
versionCode: string;
|
||||
minPlatformVersion: string;
|
||||
deviceOrientation: IOrientation;
|
||||
useDebugKey: boolean;
|
||||
privatePemPath: string;
|
||||
certificatePemPath: string;
|
||||
hasSubPackage?: boolean;
|
||||
separateEngine: boolean;
|
||||
}
|
||||
|
||||
export interface ICompileOptions {
|
||||
name: string;
|
||||
useDebugKey: boolean;
|
||||
hasSubPackage: boolean;
|
||||
}
|
||||
60
extensions/app/engine/@types/packages/package-asset/@types/public.d.ts
vendored
Normal file
60
extensions/app/engine/@types/packages/package-asset/@types/public.d.ts
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
export interface MenuAssetInfo {
|
||||
// 资源名字
|
||||
name: string;
|
||||
// 资源用于显示的名字
|
||||
displayName: string;
|
||||
// loader 加载的层级地址
|
||||
url: string;
|
||||
// 绝对路径
|
||||
file: string;
|
||||
// 资源的唯一 ID
|
||||
uuid: string;
|
||||
// 使用的导入器名字
|
||||
importer: string;
|
||||
// 类型
|
||||
type: string;
|
||||
// 是否是文件夹
|
||||
isDirectory: boolean;
|
||||
// 是否只读
|
||||
readonly: boolean;
|
||||
// 虚拟资源可以实例化成实体的话,会带上这个扩展名
|
||||
instantiation?: string;
|
||||
// 跳转指向资源
|
||||
redirect?: IRedirectInfo;
|
||||
// 继承类型
|
||||
extends?: string[];
|
||||
// 是否导入完成
|
||||
imported: boolean;
|
||||
// 是否导入失败
|
||||
invalid: boolean;
|
||||
}
|
||||
|
||||
export interface IRedirectInfo {
|
||||
// 跳转资源的类型
|
||||
type: string;
|
||||
// 跳转资源的 uuid
|
||||
uuid: string;
|
||||
}
|
||||
export interface IAssetInfo {
|
||||
name: string; // 资源名字
|
||||
displayName: string; // 资源用于显示的名字
|
||||
source: string; // url 地址
|
||||
path: string; // loader 加载的层级地址
|
||||
url: string; // loader 加载地址会去掉扩展名,这个参数不去掉
|
||||
file: string; // 绝对路径
|
||||
uuid: string; // 资源的唯一 ID
|
||||
importer: string; // 使用的导入器名字
|
||||
imported: boolean; // 是否结束导入过程
|
||||
invalid: boolean; // 是否导入成功
|
||||
type: string; // 类型
|
||||
isDirectory: boolean; // 是否是文件夹
|
||||
library: { [key: string]: string }; // 导入资源的 map
|
||||
subAssets: { [key: string]: IAssetInfo }; // 子资源 map
|
||||
visible: boolean; // 是否显示
|
||||
readonly: boolean; // 是否只读
|
||||
|
||||
instantiation?: string; // 虚拟资源可以实例化成实体的话,会带上这个扩展名
|
||||
redirect?: IRedirectInfo; // 跳转指向资源
|
||||
meta?: any,
|
||||
fatherInfo?: any;
|
||||
}
|
||||
1
extensions/app/engine/@types/packages/preview/@types/index.d.ts
vendored
Normal file
1
extensions/app/engine/@types/packages/preview/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './protect';
|
||||
19
extensions/app/engine/@types/packages/programming/@types/message.d.ts
vendored
Normal file
19
extensions/app/engine/@types/packages/programming/@types/message.d.ts
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
export interface message extends EditorMessageMap {
|
||||
'query-shared-settings': {
|
||||
params: [],
|
||||
result: {
|
||||
useDefineForClassFields: boolean;
|
||||
allowDeclareFields: boolean;
|
||||
loose: boolean;
|
||||
guessCommonJsExports: boolean;
|
||||
exportsConditions: string[];
|
||||
importMap?: {
|
||||
json: {
|
||||
imports?: Record<string, string>;
|
||||
scopes?: Record<string, Record<string, string>>;
|
||||
};
|
||||
url: string;
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
2
extensions/app/engine/@types/packages/runtime-dev-tools/@types/index.d.ts
vendored
Normal file
2
extensions/app/engine/@types/packages/runtime-dev-tools/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/// <reference path='../../../@types/index'/>
|
||||
export * from '../../../@types/editor';
|
||||
72
extensions/app/engine/@types/packages/scene/@types/engine-view.d.ts
vendored
Normal file
72
extensions/app/engine/@types/packages/scene/@types/engine-view.d.ts
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
import type { WebviewTag } from 'electron';
|
||||
import ISceneFacade from './scene-facade-interface';
|
||||
/**
|
||||
* 这个是 engine-view 标签的接口
|
||||
*/
|
||||
export interface EngineView {
|
||||
dirty: boolean;
|
||||
managerReady: boolean;
|
||||
|
||||
$scene: WebviewTag;
|
||||
depend: any;
|
||||
$floatWindow: any;
|
||||
|
||||
// 封装的 webview 通讯模块
|
||||
ipc: any;
|
||||
|
||||
info: any;
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*/
|
||||
init(): Promise<any>;
|
||||
|
||||
/**
|
||||
* 调用场景进程里的方法
|
||||
* @param methodName
|
||||
* @param params
|
||||
* @param forced
|
||||
* @param timeout
|
||||
*/
|
||||
|
||||
callSceneMethod<T extends keyof ISceneFacade>(methodName: T, params: Parameters<ISceneFacade[T]>, forced?: boolean, timeout?: boolean): Promise<ReturnType<typeof ISceneFacade[T]>>
|
||||
|
||||
/**
|
||||
* 执行组件方法
|
||||
* @param options
|
||||
*/
|
||||
executeComponentMethod(options: { uuid: string, index: number, methodNames: string[] });
|
||||
|
||||
//////////////
|
||||
|
||||
attachFloatWindow(name: string, options: FloatWindowOptions)
|
||||
|
||||
detachFloatWindow(name: string)
|
||||
|
||||
attachToolbar(name: string, options: any)
|
||||
|
||||
detachToolbar(name: string)
|
||||
|
||||
attachInfobar(name: string, options: any)
|
||||
|
||||
detachInfobar(name: string)
|
||||
}
|
||||
export interface FloatWindowOptions {
|
||||
type: string;
|
||||
width: number;
|
||||
height: number;
|
||||
top?: number;
|
||||
bottom?: number;
|
||||
left?: number;
|
||||
right?: number;
|
||||
|
||||
dock?: boolean;
|
||||
|
||||
mode?: 'dock' | 'simple';
|
||||
|
||||
template: string;
|
||||
ready?: ($window: HTMLDivElement, info: ScenePluginInfo, componentMap: { [type: string]: ScenePluginComponentInfo[] }) => void;
|
||||
close?: Function;
|
||||
update?: Function;
|
||||
send?: Function;
|
||||
}
|
||||
68
extensions/app/engine/@types/packages/scene/@types/message.d.ts
vendored
Normal file
68
extensions/app/engine/@types/packages/scene/@types/message.d.ts
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
import {
|
||||
SetPropertyOptions,
|
||||
} from './public';
|
||||
|
||||
export interface message extends EditorMessageMap {
|
||||
'update-create-node-template': {
|
||||
params: [],
|
||||
result: any,
|
||||
},
|
||||
'open': {
|
||||
params: [],
|
||||
result: any,
|
||||
},
|
||||
'open-devtools': {
|
||||
params: [],
|
||||
result: any,
|
||||
},
|
||||
'graphical-tools': {
|
||||
params: [
|
||||
boolean,
|
||||
],
|
||||
result: void,
|
||||
},
|
||||
'open-scene': {
|
||||
params: [
|
||||
string,
|
||||
],
|
||||
result: boolean,
|
||||
},
|
||||
'save-scene': {
|
||||
params: [] | [
|
||||
boolean,
|
||||
],
|
||||
result: boolean,
|
||||
},
|
||||
'save-as-scene': {
|
||||
params: [
|
||||
boolean,
|
||||
],
|
||||
result: boolean,
|
||||
},
|
||||
'close-scene': {
|
||||
params: [],
|
||||
result: boolean,
|
||||
},
|
||||
'set-property': {
|
||||
params: [
|
||||
SetPropertyOptions,
|
||||
],
|
||||
result: boolean,
|
||||
},
|
||||
'query-node-tree': {
|
||||
params: [] | [
|
||||
string,
|
||||
],
|
||||
result: any,
|
||||
},
|
||||
'execute-scene-script': {
|
||||
params: [] | [
|
||||
{
|
||||
name: string;
|
||||
method: string;
|
||||
args: any[];
|
||||
}
|
||||
],
|
||||
result: any,
|
||||
},
|
||||
}
|
||||
469
extensions/app/engine/@types/packages/scene/@types/public.d.ts
vendored
Normal file
469
extensions/app/engine/@types/packages/scene/@types/public.d.ts
vendored
Normal file
@@ -0,0 +1,469 @@
|
||||
import { EmbeddedPlayerGroup } from 'cc';
|
||||
// ---- 一些 engine 基础数据 ---- start
|
||||
interface Vec2 {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
export interface Vec3 {
|
||||
x: number;
|
||||
y: number;
|
||||
z: number;
|
||||
}
|
||||
|
||||
interface Vec4 {
|
||||
x: number;
|
||||
y: number;
|
||||
z: number;
|
||||
w: number;
|
||||
}
|
||||
|
||||
interface Quat {
|
||||
x: number;
|
||||
y: number;
|
||||
z: number;
|
||||
w: number;
|
||||
}
|
||||
|
||||
interface Color3 {
|
||||
r: number;
|
||||
g: number;
|
||||
b: number;
|
||||
}
|
||||
|
||||
interface Color4 {
|
||||
r: number;
|
||||
g: number;
|
||||
b: number;
|
||||
a: number;
|
||||
}
|
||||
|
||||
interface Mat3 {
|
||||
m00: number;
|
||||
m01: number;
|
||||
m02: number;
|
||||
|
||||
m03: number;
|
||||
m04: number;
|
||||
m05: number;
|
||||
|
||||
m06: number;
|
||||
m07: number;
|
||||
m08: number;
|
||||
}
|
||||
|
||||
interface Mat4 {
|
||||
m00: number;
|
||||
m01: number;
|
||||
m02: number;
|
||||
m03: number;
|
||||
|
||||
m04: number;
|
||||
m05: number;
|
||||
m06: number;
|
||||
m07: number;
|
||||
|
||||
m08: number;
|
||||
m09: number;
|
||||
m10: number;
|
||||
m11: number;
|
||||
|
||||
m12: number;
|
||||
m13: number;
|
||||
m14: number;
|
||||
m15: number;
|
||||
}
|
||||
// ---- 一些 engine 基础数据 ---- end
|
||||
|
||||
// ---- 操作消息的参数定义 --- strart
|
||||
|
||||
// set-property 消息的 options 定义
|
||||
export interface SetPropertyOptions {
|
||||
uuid: string; // 修改属性的对象的 uuid
|
||||
path: string; // 属性挂载对象的搜索路径
|
||||
// key: string; // 属性的 key
|
||||
dump: IProperty; // 属性 dump 出来的数据
|
||||
record?: boolean;// 是否记录undo
|
||||
}
|
||||
|
||||
// move-array-element 消息的 options 定义
|
||||
export interface MoveArrayOptions {
|
||||
uuid: string;
|
||||
path: string;
|
||||
target: number;
|
||||
offset: number;
|
||||
}
|
||||
|
||||
// remove-array-element 消息的 options 定义
|
||||
export interface RemoveArrayOptions {
|
||||
uuid: string;
|
||||
path: string;
|
||||
index: number;
|
||||
}
|
||||
|
||||
export interface PasteNodeOptions {
|
||||
target: string; // 目标节点
|
||||
uuids: string | string[]; // 被复制的节点 uuids
|
||||
keepWorldTransform?: boolean; // 是否保持新节点的世界坐标不变
|
||||
pasteAsChild?: boolean; // 是否粘贴成为子节点
|
||||
}
|
||||
|
||||
export interface CutNodeOptions {
|
||||
parent: string; // 父节点
|
||||
uuids: string | string[]; // 被移入的节点 uuids
|
||||
keepWorldTransform?: boolean; // 是否保持新节点的世界坐标不变
|
||||
}
|
||||
|
||||
// create-node 消息的 options 定义
|
||||
export interface CreateNodeOptions {
|
||||
parent?: string;
|
||||
components?: string[];
|
||||
|
||||
name?: string;
|
||||
dump?: INode | IScene; // node 初始化应用的数据
|
||||
keepWorldTransform?: boolean; // 是否保持新节点的世界坐标不变
|
||||
type?: string; // 资源类型
|
||||
assetUuid?: string; // asset uuid , type value 格式保持兼容拖动的数据格式,有资源 id,则从资源内创建对应的节点
|
||||
canvasRequired?: boolean; // 是否需要有 Canvas
|
||||
unlinkPrefab?: boolean; // 创建后取消 prefab 状态
|
||||
position?: Vec3; // 指定生成的位置
|
||||
nameIncrease?: boolean; // 名称自增 xxx001 -> xxx002
|
||||
snapshot?: boolean;
|
||||
}
|
||||
|
||||
export interface ResetNodeOptions {
|
||||
uuid: string | string[];
|
||||
}
|
||||
|
||||
export interface RemoveNodeOptions {
|
||||
uuid: string | string[];
|
||||
keepWorldTransform?: boolean;
|
||||
}
|
||||
|
||||
export interface CreateComponentOptions {
|
||||
uuid: string;
|
||||
component: string;
|
||||
}
|
||||
|
||||
export interface ResetComponentOptions {
|
||||
uuid: string;
|
||||
}
|
||||
|
||||
export interface RemoveComponentOptions {
|
||||
uuid: string;
|
||||
component: string;
|
||||
}
|
||||
|
||||
export interface ExecuteComponentMethodOptions {
|
||||
uuid: string;
|
||||
name: string;
|
||||
args: any[];
|
||||
}
|
||||
|
||||
export interface IAnimOperation {
|
||||
funcName: string;
|
||||
args: any[];
|
||||
}
|
||||
|
||||
export interface ExecuteSceneScriptMethodOptions {
|
||||
name: string;
|
||||
method: string;
|
||||
args: any[];
|
||||
}
|
||||
|
||||
export type IPropertyValueType = IProperty | IProperty[] | null | undefined | number | boolean | string | Vec3 | Vec2;
|
||||
|
||||
export interface IPropertyGroupOptions {
|
||||
id: string // 默认 'default'
|
||||
name: string,
|
||||
displayOrder: number, // 默认 Infinity, 排在最后面
|
||||
style: string // 默认为 'tab'
|
||||
}
|
||||
|
||||
export interface IProperty {
|
||||
value: { [key: string]: IPropertyValueType } | IPropertyValueType;
|
||||
default?: any; // 默认值
|
||||
|
||||
// 多选节点之后,这里存储多个数据,用于自行判断多选后的显示效果,无需更新该数据
|
||||
values?: ({ [key: string]: IPropertyValueType } | IPropertyValueType)[];
|
||||
|
||||
cid?: string;
|
||||
type?: string;
|
||||
ui?: { name: string, data?: any }; // 是否用指定的 UI 组件,name 是组件的名称
|
||||
readonly?: boolean;
|
||||
visible?: boolean;
|
||||
name?: string;
|
||||
|
||||
elementTypeData?: IProperty; // 数组里的数据的默认值 dump
|
||||
|
||||
path?: string; // 数据的搜索路径,这个是由使用方填充的
|
||||
|
||||
isArray?: boolean;
|
||||
invalid?: boolean;
|
||||
extends?: string[]; // 继承链
|
||||
displayName?: string; // 显示到界面上的名字
|
||||
displayOrder?: number; // 显示排序
|
||||
help?: string; // 帮助文档的 url 地址
|
||||
group?: IPropertyGroupOptions; // tab
|
||||
tooltip?: string; // 提示文本
|
||||
editor?: any; // 组件上定义的编辑器数据
|
||||
animatable?: boolean; // 是否可以在动画中编辑
|
||||
|
||||
// Enum
|
||||
enumList?: any[]; // enum 类型的 list 选项数组
|
||||
|
||||
bitmaskList?: any[];
|
||||
|
||||
// Number
|
||||
min?: number; // 数值类型的最小值
|
||||
max?: number; // 数值类型的最大值
|
||||
step?: number; // 数值类型的步进值
|
||||
slide?: boolean; // 数组是否显示为滑块
|
||||
unit?: string; // 显示的单位
|
||||
radian?: boolean; // 标识是否为角度
|
||||
|
||||
// Label
|
||||
multiline?: boolean; // 字符串是否允许换行
|
||||
// nullable?: boolean; 属性是否允许为空
|
||||
|
||||
optionalTypes?: string[]; // 对属性是 object 且是可变类型的数据的支持,比如 render-pipeline
|
||||
}
|
||||
|
||||
export interface IRemovedComponentInfo {
|
||||
name: string;
|
||||
fileID: string;
|
||||
}
|
||||
|
||||
export interface INode {
|
||||
active: IProperty;
|
||||
locked: IProperty;
|
||||
name: IProperty;
|
||||
position: IProperty;
|
||||
|
||||
/**
|
||||
* 此为 dump 数据,非 node.rotation
|
||||
* 实际指向 node.eulerAngles
|
||||
* rotation 为了给用户更友好的文案
|
||||
*/
|
||||
rotation: IProperty;
|
||||
|
||||
scale: IProperty;
|
||||
layer: IProperty;
|
||||
uuid: IProperty;
|
||||
|
||||
children: any[];
|
||||
parent: any;
|
||||
|
||||
__comps__: IProperty[];
|
||||
__type__: string;
|
||||
__prefab__?: any;
|
||||
_prefabInstance?: any;
|
||||
removedComponents?: IRemovedComponentInfo[];
|
||||
mountedRoot?: string;
|
||||
}
|
||||
|
||||
export interface IComponent extends IProperty {
|
||||
value: {
|
||||
enabled: IPropertyValueType;
|
||||
uuid: IPropertyValueType;
|
||||
name: IPropertyValueType;
|
||||
} & Record<string, IPropertyValueType>;
|
||||
mountedRoot?: string;
|
||||
}
|
||||
|
||||
export interface IScene {
|
||||
name: IProperty;
|
||||
active: IProperty;
|
||||
locked: IProperty;
|
||||
_globals: any;
|
||||
isScene: boolean;
|
||||
autoReleaseAssets: IProperty;
|
||||
|
||||
uuid: IProperty;
|
||||
children: any[];
|
||||
parent: any;
|
||||
__type__: string;
|
||||
targetOverrides?: any;
|
||||
}
|
||||
|
||||
export interface ITargetOverrideInfo {
|
||||
source: string;
|
||||
sourceInfo?: string[];
|
||||
propertyPath: string[];
|
||||
target: string;
|
||||
targetInfo?: string[];
|
||||
}
|
||||
// ---- 操作消息的参数定义 --- end
|
||||
|
||||
// ---- 场景插件返回的 info 信息 ---- start
|
||||
interface ScenePluginNodeInfo {
|
||||
uuid: string;
|
||||
components: ScenePluginComponentInfo[];
|
||||
}
|
||||
|
||||
// 场景插件传回的场景信息
|
||||
export interface ScenePluginInfo {
|
||||
// 选中节点列表
|
||||
nodes: ScenePluginNodeInfo[];
|
||||
|
||||
// gizmo 的一些信息
|
||||
gizmo: {
|
||||
is2D: boolean;
|
||||
};
|
||||
// 当前编辑模式数组
|
||||
modes: string[];
|
||||
}
|
||||
|
||||
// 场景插件传回的组件信息
|
||||
export interface ScenePluginComponentInfo {
|
||||
uuid: string;
|
||||
enabled: boolean;
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface QueryClassesOptions {
|
||||
extends?: string | string[];
|
||||
excludeSelf?: boolean;
|
||||
}
|
||||
|
||||
// ---- 场景插件返回的 info 信息 ---- end
|
||||
|
||||
// ---- 动画数据 ---- start
|
||||
|
||||
export interface IKeyDumpData {
|
||||
frame: number;
|
||||
dump: any; // value的dump数据
|
||||
inTangent?: number;
|
||||
inTangentWeight?: number;
|
||||
outTangent?: number;
|
||||
outTangentWeight?: number;
|
||||
interpMode?: number;
|
||||
broken?: boolean;
|
||||
tangentWeightMode?: number;
|
||||
imgUrl?: string;
|
||||
easingMethod?: number;
|
||||
}
|
||||
|
||||
export interface IDumpType {
|
||||
value: string;
|
||||
extends?: string[];
|
||||
}
|
||||
|
||||
export interface IPropCurveDumpData {
|
||||
nodePath: string;
|
||||
// 原始的 keyframe 数据
|
||||
keyframes: IKeyDumpData[];
|
||||
displayName: string;
|
||||
key: string;
|
||||
type?: IDumpType;
|
||||
preExtrap: number;
|
||||
postExtrap: number;
|
||||
isCurveSupport: boolean; // 是否支持贝塞尔曲线编辑
|
||||
}
|
||||
|
||||
export interface IAnimCopyKeySrcInfo {
|
||||
curvesDump: IPropCurveDumpData[];
|
||||
}
|
||||
|
||||
export interface IAnimCopyNodeSrcInfo {
|
||||
curvesDump: IPropCurveDumpData[];
|
||||
}
|
||||
|
||||
export interface IAnimCopyNodeDstInfo {
|
||||
nodePath: string;
|
||||
}
|
||||
|
||||
interface IEventDump {
|
||||
frame: number;
|
||||
func: string;
|
||||
params: string[];
|
||||
}
|
||||
|
||||
interface IEventDump {
|
||||
frame: number;
|
||||
func: string;
|
||||
params: string[];
|
||||
}
|
||||
|
||||
export interface IPlayableInfo {
|
||||
type: 'animation-clip' | 'particle-system';
|
||||
clip?: string;
|
||||
path?: string;
|
||||
}
|
||||
|
||||
export interface IEmbeddedPlayers {
|
||||
begin: number;
|
||||
end: number;
|
||||
reconciledSpeed: boolean;
|
||||
playable?: IPlayableInfo;
|
||||
group: string;
|
||||
}
|
||||
|
||||
export interface AnimationClipPlayerInfo extends IPlayableInfo {
|
||||
clip: string;
|
||||
path: string;
|
||||
}
|
||||
|
||||
export interface ParticleSystemPlayerInfo extends IPlayableInfo {
|
||||
path: string;
|
||||
}
|
||||
|
||||
export interface EditorAnimationClipDump {
|
||||
name: string;
|
||||
duration: number;
|
||||
sample: number;
|
||||
speed: number;
|
||||
wrapMode: number;
|
||||
|
||||
curves: ICurveDumpData[];
|
||||
events: IEventDump[];
|
||||
embeddedPlayers: IEmbeddedPlayers[];
|
||||
time: number;
|
||||
isLock: boolean;
|
||||
embeddedPlayerGroups: EmbeddedPlayerGroup[];
|
||||
}
|
||||
|
||||
export interface EditorEmbeddedPlayer extends IEmbeddedPlayers {
|
||||
_embeddedPlayer: any;
|
||||
}
|
||||
|
||||
export interface IAnimCopyEmbeddedPlayersSrcInfo {
|
||||
embeddedPlayersDump: IEmbeddedPlayers[];
|
||||
}
|
||||
|
||||
export interface IAnimCopyEventSrcInfo {
|
||||
eventsDump: IEventDump[];
|
||||
}
|
||||
|
||||
export interface IAnimCopyPropSrcInfo {
|
||||
curvesDump: IPropCurveDumpData[];
|
||||
}
|
||||
|
||||
export interface IAnimCopyPropDstInfo {
|
||||
nodePath: string;
|
||||
propKeys?: string[];
|
||||
}
|
||||
|
||||
export interface IAnimCopyKeyDstInfo {
|
||||
nodePath: string;
|
||||
propKeys?: string[];
|
||||
startFrame: number;
|
||||
}
|
||||
|
||||
export interface IAnimCopyEventDstInfo {
|
||||
startFrame: number;
|
||||
}
|
||||
// ---- 动画数据 ---- end
|
||||
|
||||
// ---- Contributions ---- start
|
||||
|
||||
export interface ContributionDropItem {
|
||||
type: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
// ---- Contributions ---- end
|
||||
|
||||
export interface UnitTestInfo {
|
||||
name: string;
|
||||
}
|
||||
761
extensions/app/engine/@types/packages/scene/@types/scene-facade-interface.d.ts
vendored
Normal file
761
extensions/app/engine/@types/packages/scene/@types/scene-facade-interface.d.ts
vendored
Normal file
@@ -0,0 +1,761 @@
|
||||
import {
|
||||
SetPropertyOptions,
|
||||
MoveArrayOptions,
|
||||
RemoveArrayOptions,
|
||||
CutNodeOptions,
|
||||
PasteNodeOptions,
|
||||
CreateNodeOptions,
|
||||
RemoveNodeOptions,
|
||||
CreateComponentOptions,
|
||||
RemoveComponentOptions,
|
||||
ExecuteComponentMethodOptions,
|
||||
IAnimOperation,
|
||||
ExecuteSceneScriptMethodOptions,
|
||||
QueryClassesOptions,
|
||||
} from './public';
|
||||
|
||||
import { Node, Vec3, Quat } from 'cc';
|
||||
import type ParticleManager from '../source/script/3d/manager/particle';
|
||||
import { ISceneEvents } from '../source/script/3d/manager/scene-events-interface';
|
||||
|
||||
interface ISceneFacade extends ISceneEvents {
|
||||
init(): void;
|
||||
|
||||
//////////
|
||||
// node //
|
||||
//////////
|
||||
|
||||
/**
|
||||
* 打开某个场景
|
||||
* @param uuid 场景uuid
|
||||
*/
|
||||
openScene(uuid: string): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* 保存当前场景
|
||||
*/
|
||||
saveScene(asNew: boolean): Promise<boolean>;
|
||||
|
||||
closeScene(): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* 软刷新场景
|
||||
*/
|
||||
softReloadScene(json: any): Promise<boolean>;
|
||||
|
||||
reloadScene(): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* 查询当前场景的节点树信息
|
||||
* @param uuid 节点的唯一标识符
|
||||
*/
|
||||
queryNodeTree(uuid: string): Promise<any>;
|
||||
|
||||
/**
|
||||
* 查询使用了资源 UUID 的节点
|
||||
* @param uuid 资源 asset uuid
|
||||
*/
|
||||
queryNodesByAssetUuid(uuid: string): Promise<any>;
|
||||
|
||||
/**
|
||||
* 查询当前场景的序列化数据
|
||||
*/
|
||||
querySceneSerializedData(): Promise<any>;
|
||||
|
||||
/**
|
||||
* 查询当前场景是否被修改
|
||||
*/
|
||||
querySceneDirty(): Promise<any>;
|
||||
|
||||
/**
|
||||
* 查询引擎内所有的类
|
||||
*/
|
||||
queryClasses(options?: QueryClassesOptions): Promise<any>;
|
||||
|
||||
/**
|
||||
* 查询引擎内所有的组件列表
|
||||
*/
|
||||
queryComponents(): Promise<any>;
|
||||
|
||||
/**
|
||||
* 查询引擎组件列表是否含有指定类名的脚本
|
||||
* @param name 查询脚本的名字
|
||||
*/
|
||||
queryComponentHasScript(name: string): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* 查询引擎内 Layer 的内置项
|
||||
*/
|
||||
queryLayerBuiltin(): Promise<any>;
|
||||
|
||||
/**
|
||||
* 查询当前场景的编辑模式
|
||||
*/
|
||||
queryMode(): string;
|
||||
|
||||
/**
|
||||
* 查询当前场景资源的 uuid
|
||||
*/
|
||||
queryCurrentSceneUuid(): string;
|
||||
|
||||
//////////
|
||||
// node //
|
||||
//////////
|
||||
|
||||
/**
|
||||
* 查询一个节点的 dump 数据
|
||||
* @param uuid 节点的唯一标识符
|
||||
*/
|
||||
queryNodeDump(uuid: string): Promise<any>;
|
||||
|
||||
/**
|
||||
* 查询一个节点内挂载的所有组件以及对应的函数
|
||||
* @param uuid 节点的唯一标识符
|
||||
*/
|
||||
queryComponentFunctionOfNode(uuid: string): Promise<any>;
|
||||
|
||||
/**
|
||||
* 设置某个元素内的属性
|
||||
* @param options
|
||||
*/
|
||||
setNodeProperty(options: SetPropertyOptions): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* 设置某个元素内的某个属性的默认值
|
||||
* @param options
|
||||
*/
|
||||
resetNodeProperty(options: SetPropertyOptions): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* 预览设置某个元素内的属性(不会进undo)
|
||||
* @param options
|
||||
*/
|
||||
previewSetNodeProperty(options: SetPropertyOptions): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* 取消预览设置某个元素内的属性(不会进undo)
|
||||
* @param options
|
||||
*/
|
||||
cancelPreviewSetNodeProperty(options: SetPropertyOptions): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* 将一个属性从 null 值变为可编辑的值
|
||||
* @param options
|
||||
*/
|
||||
updateNodePropertyFromNull(options: SetPropertyOptions): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* 设置某个节点连同它的子集的 layer 属性值
|
||||
* @param options
|
||||
*/
|
||||
setNodeAndChildrenLayer(options: SetPropertyOptions): void;
|
||||
|
||||
/**
|
||||
* 移动数组类型 property 内的某个 item 的位置
|
||||
* @param options
|
||||
*/
|
||||
moveNodeArrayElement(options: MoveArrayOptions): void;
|
||||
|
||||
/**
|
||||
* 删除数组类型 property 内的某个 item 的位置
|
||||
* @param options
|
||||
*/
|
||||
removeNodeArrayElement(options: RemoveArrayOptions): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* 实时获取新节点在一个父节点下的有效名称
|
||||
* 规则是 Node 同名时为 Node-001
|
||||
* @param name 名称
|
||||
* @param parentUuid 父节点 uuid
|
||||
*/
|
||||
generateNodeAvailableName(name: string, parentUuid: string): Promise<string>;
|
||||
|
||||
/**
|
||||
* 暂存一个节点的实例化对象
|
||||
* 一般用在复制节点的动作,给下一步粘贴(创建)节点准备数据
|
||||
* @param uuids 节点uuid
|
||||
*/
|
||||
copyNode(uuids: string | string[]): string[];
|
||||
|
||||
/**
|
||||
* 复制节点自身
|
||||
* ctrl + d
|
||||
* @param uuids 节点uuid
|
||||
*/
|
||||
duplicateNode(uuids: string | string[]): string[];
|
||||
|
||||
/**
|
||||
* 粘贴节点
|
||||
* @param options 参数
|
||||
*/
|
||||
pasteNode(options: PasteNodeOptions): Promise<string[]>;
|
||||
|
||||
/**
|
||||
* 挂载节点
|
||||
* @param options 参数
|
||||
*/
|
||||
setNodeParent(options: CutNodeOptions): Promise<string[]>;
|
||||
|
||||
/**
|
||||
* 创建一个新的节点
|
||||
* @param options 参数
|
||||
*/
|
||||
createNode(options: CreateNodeOptions): Promise<any>;
|
||||
|
||||
/**
|
||||
* 重置节点属性 position rotation scale
|
||||
* @param options 参数
|
||||
*/
|
||||
resetNode(uuid: string): Promise<any>;
|
||||
|
||||
/**
|
||||
* 删除一个节点
|
||||
* @param options 参数
|
||||
*/
|
||||
removeNode(options: RemoveNodeOptions): void;
|
||||
|
||||
/**
|
||||
* 锁定一个节点不让其在场景中被选中
|
||||
* @param uuids 节点uuid
|
||||
* @param locked true | false
|
||||
* @param loop true | false 是否循环子孙级节点设置
|
||||
*/
|
||||
changeNodeLock(uuids: string | string[], locked: Boolean, loop: Boolean): void;
|
||||
|
||||
/**
|
||||
* 从资源数据还原一个 prefab 节点
|
||||
* @param uuid 节点uuid
|
||||
* @param assetUuid 资源uuid
|
||||
*/
|
||||
restorePrefab(uuid: string, assetUuid: string): Promise<boolean>;
|
||||
|
||||
///////////////
|
||||
// component //
|
||||
///////////////
|
||||
|
||||
/**
|
||||
* 查询一个组件的 dump 数据
|
||||
* @param uuid 节点的唯一标识符
|
||||
*/
|
||||
queryComponent(uuid: string): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* 在某个节点上创建一个组件
|
||||
* @param options 参数
|
||||
*/
|
||||
createComponent(options: CreateComponentOptions): void;
|
||||
|
||||
/**
|
||||
* 重置组件
|
||||
* @param uuid 组件
|
||||
*/
|
||||
resetComponent(uuid: string): void;
|
||||
|
||||
/**
|
||||
* 删除某个节点上的某个组件
|
||||
* @param options 参数
|
||||
*/
|
||||
removeComponent(options: RemoveComponentOptions): void;
|
||||
|
||||
/**
|
||||
* 执行 entity 上指定组件的方法
|
||||
* @param options 参数
|
||||
*/
|
||||
executeComponentMethod(options: ExecuteComponentMethodOptions): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* 执行插件注册的场景脚本方法
|
||||
* @param name 插件名字
|
||||
* @param method 方法名字
|
||||
* @param args 传入的参数
|
||||
*/
|
||||
executeSceneScriptMethod(options: ExecuteSceneScriptMethodOptions): Promise<any>;
|
||||
|
||||
///////////////
|
||||
// undo/redo //
|
||||
///////////////
|
||||
|
||||
/**
|
||||
* 保存一次操作记录
|
||||
*/
|
||||
snapshot(command?: any): void;
|
||||
|
||||
/**
|
||||
* 放弃当前步骤的所有变动记录
|
||||
*/
|
||||
abortSnapshot(): void;
|
||||
|
||||
/**
|
||||
* 撤销一次操作记录
|
||||
*/
|
||||
undo(): void;
|
||||
|
||||
/**
|
||||
* 重做一次操作记录
|
||||
*/
|
||||
redo(): void;
|
||||
|
||||
/**
|
||||
* 记录变动的节点
|
||||
* @param node
|
||||
* @param enable enable = false 是内部 undo redo 产生的变化, 不参与重新记录
|
||||
*/
|
||||
recordNode(node: Node, enable: boolean): void;
|
||||
|
||||
///////////
|
||||
// asset //
|
||||
///////////
|
||||
|
||||
/**
|
||||
* 查询所有内置 Effects
|
||||
*/
|
||||
queryAllEffects(): Promise<any>;
|
||||
|
||||
/**
|
||||
* 查询一个 material 的 dump 数据
|
||||
* @param uuid material 的唯一标识符
|
||||
*/
|
||||
queryMaterial(uuid: string): Promise<any>;
|
||||
|
||||
/**
|
||||
* 根据 effecName 构建指定 Effect 的 props 和 defines 属性
|
||||
* @param effectName effect 的名字
|
||||
*/
|
||||
queryEffect(effectName: string): Promise<any>;
|
||||
|
||||
/**
|
||||
* 查询当个 RenderPipeline
|
||||
* @param uuid 查询的资源的唯一标识符
|
||||
*/
|
||||
queryRenderPipeline(uuid: string): Promise<any>;
|
||||
|
||||
/**
|
||||
* 材质,实时预览 material 数据
|
||||
* @param uuid 材质uuid
|
||||
* @param material 材质数据
|
||||
*/
|
||||
previewMaterial(uuid: string, material: any, opts?: {emit?: boolean}): void;
|
||||
|
||||
/**
|
||||
* 应用材质
|
||||
* @param uuid 材质uuid
|
||||
* @param materialDump 材质dump数据
|
||||
*/
|
||||
applyMaterial(uuid: string, materialDump: any): void;
|
||||
|
||||
/**
|
||||
* 修改 physics-material
|
||||
* @param dump dump数据
|
||||
*/
|
||||
changePhysicsMaterial(dump: any): Promise<any>;
|
||||
|
||||
/**
|
||||
* 保存 physics-material
|
||||
* @param uuid uuid
|
||||
*/
|
||||
applyPhysicsMaterial(uuid: string): void;
|
||||
|
||||
/**
|
||||
* 修改 animation-mask
|
||||
* @param dump dump数据
|
||||
*/
|
||||
changeAnimationMask(dump: any): Promise<any>;
|
||||
|
||||
/**
|
||||
* 保存 animation-mask
|
||||
* @param uuid uuid
|
||||
*/
|
||||
applyAnimationMask(uuid: string): void;
|
||||
|
||||
/**
|
||||
* 保存 render-texture
|
||||
* @param uuid uuid
|
||||
* @param dump dump数据
|
||||
*/
|
||||
applyRenderTexture(uuid: string, dump: any): void;
|
||||
|
||||
/**
|
||||
* 修改了 RenderPipeline 数据
|
||||
* @param dump 数据
|
||||
*/
|
||||
changeRenderPipeline(dump: any): Promise<any>;
|
||||
|
||||
/**
|
||||
* 应用 RenderPipeline 数据
|
||||
* @param uuid pipeline uuid
|
||||
* @param renderPipelineDump RenderPipeline的dump数据
|
||||
*/
|
||||
applyRenderPipeline(uuid: string, renderPipelineDump: any): void;
|
||||
|
||||
/**
|
||||
* 查询一个 physics-material 的 dump 数据
|
||||
* @param uuid 资源的唯一标识符
|
||||
*/
|
||||
queryPhysicsMaterial(uuid: string): any;
|
||||
|
||||
/**
|
||||
* 查询一个 animation-mask 的 dump 数据
|
||||
* @param uuid 资源的唯一标识符
|
||||
*/
|
||||
queryAnimationMask(uuid: string): any;
|
||||
|
||||
/**
|
||||
* 查询可以被创建为节点的所有资源类型
|
||||
*/
|
||||
queryCreatableAssetTypes(): any;
|
||||
|
||||
assetChange(uuid: string, info?: any, meta?: any): Promise<void>;
|
||||
|
||||
assetDelete(uuid: string, info?: any): void;
|
||||
|
||||
/**
|
||||
* 一个资源更新到场景的引用中后发出此消息
|
||||
* @param uuid 资源uuid
|
||||
*/
|
||||
assetRefresh(uuid: string): void;
|
||||
|
||||
///////////
|
||||
// gizmo //
|
||||
///////////
|
||||
|
||||
/**
|
||||
* 查询当前 gizmo 工具的名字
|
||||
*/
|
||||
queryGizmoToolName(): Promise<string>;
|
||||
|
||||
/**
|
||||
* 查询 gizmo 中心点类型
|
||||
*/
|
||||
queryGizmoPivot(): Promise<string>;
|
||||
|
||||
/**
|
||||
* 查询 gizmo 坐标类型
|
||||
*/
|
||||
queryGizmoCoordinate(): Promise<string>;
|
||||
|
||||
/**
|
||||
* 查询 是否处于2D编辑模式
|
||||
*/
|
||||
queryIs2D(): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* 查询icon gizmo是否为3D
|
||||
*/
|
||||
queryIsIconGizmo3D(): boolean;
|
||||
|
||||
/**
|
||||
* 获取icon gizmo的大小
|
||||
*/
|
||||
queryIconGizmoSize(): number;
|
||||
|
||||
/**
|
||||
* 改变Gizmo的操作工具
|
||||
* @param name 变换工具名字
|
||||
*/
|
||||
setTransformToolName(name: string): void;
|
||||
|
||||
/**
|
||||
* 改变基准中心
|
||||
* @param name 中心位置名
|
||||
*/
|
||||
setPivot(name: string): void;
|
||||
|
||||
/**
|
||||
* 设置使用全局或局部坐标系
|
||||
* @param type 坐标系类型
|
||||
*/
|
||||
setCoordinate(type: string): void;
|
||||
|
||||
/**
|
||||
* 是否进入2D编辑模式
|
||||
* @param value 是否使用2D
|
||||
*/
|
||||
setIs2D(value: boolean): void;
|
||||
|
||||
/**
|
||||
* 设置icon gizmo是否为3D
|
||||
* @param is3D 是否为3D icon
|
||||
*/
|
||||
setIconGizmo3D(is3D: boolean): void;
|
||||
|
||||
/**
|
||||
* 设置icon gizmo的大小
|
||||
*
|
||||
* @param size icon大小
|
||||
*/
|
||||
setIconGizmoSize(size: number): void;
|
||||
|
||||
////////////
|
||||
// camera //
|
||||
////////////
|
||||
/**
|
||||
* 聚焦于某个节点
|
||||
* @param uuid 节点uuid
|
||||
*/
|
||||
focus(uuid: string[] | null, position?: Vec3, rotation?: Quat, viewCenter?: Vec3, immediate?: boolean): void;
|
||||
|
||||
/**
|
||||
* 将编辑相机数据拷贝到节点上
|
||||
* @param uuids 节点数组
|
||||
*/
|
||||
alignNodeToSceneView(uuids: string[]): void;
|
||||
|
||||
/**
|
||||
* 查询grid是否可见
|
||||
*/
|
||||
queryIsGridVisible(): boolean;
|
||||
/**
|
||||
* 设置grid是否可见
|
||||
* @param visible 是否可见
|
||||
*/
|
||||
setGridVisible(visible: boolean): void;
|
||||
|
||||
/**
|
||||
* 将选中的节点与场景相机对齐
|
||||
*/
|
||||
alignWithView(): void;
|
||||
|
||||
/**
|
||||
* 将场景相机与选中的节点对齐
|
||||
*/
|
||||
alignViewWithNode(): void;
|
||||
/**
|
||||
* 设置网格线的颜色
|
||||
* @param color 网格线的颜色[255,255,255,255]
|
||||
*/
|
||||
setGridLineColor(color: number[]): void;
|
||||
|
||||
getCameraProperty(): any;
|
||||
setCameraProperty(opts: any): void;
|
||||
getCameraWheelSpeed(): number;
|
||||
setCameraWheelSpeed(speed: number): void;
|
||||
getCameraWanderSpeed(): number;
|
||||
setCameraWanderSpeed(speed: number): void;
|
||||
zoomSceneViewUp(): void;
|
||||
zoomSceneViewDown(): void;
|
||||
resetSceneViewZoom(): void;
|
||||
|
||||
///////////////
|
||||
// animation //
|
||||
///////////////
|
||||
|
||||
/**
|
||||
* 查询当前动画的播放状态
|
||||
*/
|
||||
queryCurrentAnimationState(): any;
|
||||
|
||||
/**
|
||||
* 查询当前动画的播放状态
|
||||
*/
|
||||
queryCurrentAnimationInfo(): any;
|
||||
|
||||
/**
|
||||
* 传入一个节点,查询这个节点所在的动画节点的 uuid
|
||||
* @param uuid 查询的节点的 uuid
|
||||
*/
|
||||
queryAnimationRootNode(uuid: string): string;
|
||||
|
||||
/**
|
||||
* 查询动画根节点的动画数据信息
|
||||
* @param uuid 查询的节点的 uuid
|
||||
*/
|
||||
queryAnimationRootInfo(uuid: string): any;
|
||||
|
||||
/**
|
||||
* 查询一个 clip 的 dump 数据
|
||||
* @param nodeUuid 节点的唯一标识符
|
||||
* @param clipUuid 动画的唯一标识符
|
||||
*/
|
||||
queryAnimationClip(nodeUuid: string, clipUuid: string): any;
|
||||
|
||||
/**
|
||||
* 查询一个节点上,可以编辑的动画属性数组
|
||||
* @param uuid 动画的 uuid
|
||||
*/
|
||||
queryAnimationProperties(uuid: string): any;
|
||||
|
||||
/**
|
||||
* 查询一个节点上,可以编辑的嵌入播放器数组
|
||||
* @param uuid 节点的 uuid
|
||||
*/
|
||||
queryEmbeddedPlayerMenu(uuid: string): any;
|
||||
|
||||
/**
|
||||
* 查询一个节点上的所有动画 clips 信息
|
||||
* @param nodeUuid 节点的唯一标识符
|
||||
*/
|
||||
queryAnimationClipsInfo(nodeUuid: string): any;
|
||||
|
||||
/**
|
||||
* 查询动画当前的播放时间信息
|
||||
* @param clipUuid 动画资源的唯一标识符
|
||||
*/
|
||||
queryAnimationClipCurrentTime(clipUuid: string): number;
|
||||
|
||||
/**
|
||||
* 查询动画当前轨道的某一帧的数值
|
||||
* @param clipUuid 动画 uuid
|
||||
* @param nodePath 查询数据所在的节点搜索路径
|
||||
* @param propKey 属性名字
|
||||
* @param frame 关键帧数
|
||||
*/
|
||||
queryAnimationPropValueAtFrame(clipUuid: string, nodePath: string, propKey: string, frame: number): any;
|
||||
|
||||
/**
|
||||
* 更改当前动画编辑模式
|
||||
* @param uuid uuid
|
||||
* @param active 激活或关闭
|
||||
*/
|
||||
recordAnimation(uuid: string, active: boolean): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* 切换动画根节点
|
||||
* @param uuid uuid
|
||||
* @param clipUuid uuid of clip
|
||||
*/
|
||||
changeAnimationRootNode(uuid: string, clipUuid: string): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* 更改当前当前关键帧
|
||||
* @param time 时间
|
||||
*/
|
||||
setCurEditTime(time: number): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* 更改当前正在编辑的动画的播放状态
|
||||
* @param operate 操作
|
||||
* @param clipUuid uuid of clip
|
||||
*/
|
||||
changeClipState(operate: string, clipUuid: string): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* 更改当前正在编辑的动画 uuid
|
||||
* @param clipUuid uuid of clip
|
||||
*/
|
||||
setEditClip(clipUuid: string): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* 保存动画数据
|
||||
*/
|
||||
saveClip(): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* 动画操作
|
||||
*
|
||||
* @param operationList 操作方法数组
|
||||
*/
|
||||
applyAnimationOperation(operationList: IAnimOperation[]): Promise<boolean>;
|
||||
|
||||
/////////////
|
||||
// preview //
|
||||
/////////////
|
||||
queryPreviewWindowList(): any;
|
||||
|
||||
////////////
|
||||
// script //
|
||||
////////////
|
||||
queryScriptName(uuid: string): Promise<any>;
|
||||
queryScriptCid(uuid: string): Promise<any>;
|
||||
loadScript(uuid: string): Promise<void>;
|
||||
removeScript(info: any): Promise<void>;
|
||||
scriptChange(info: any): Promise<void>;
|
||||
|
||||
///////////////
|
||||
// selection //
|
||||
///////////////
|
||||
_selectNode(uuid: string): void;
|
||||
_unselectNode(uuid: string): void;
|
||||
querySelection(): string[];
|
||||
isSelectNode(uuid: string): boolean;
|
||||
selectNode(uuid: string): void;
|
||||
unselectNode(uuid: string): void;
|
||||
clearSelection(): void;
|
||||
|
||||
////////////
|
||||
// effect //
|
||||
////////////
|
||||
registerEffects(uuids: string[]): void;
|
||||
removeEffects(uuids: string[]): void;
|
||||
updateEffect(uuid: string): void;
|
||||
|
||||
/////////////
|
||||
// terrain //
|
||||
/////////////
|
||||
onRemoveTerrain(uuid: string, info: any): void;
|
||||
|
||||
/////////////
|
||||
// prefab //
|
||||
/////////////
|
||||
createPrefab(uuid: string, url: string): any;
|
||||
getPrefabData(uuid: string): any;
|
||||
linkPrefab(nodeUuid: string, assetUuid: string): any;
|
||||
unlinkPrefab(nodeUuid: string, removeNested: boolean): any;
|
||||
applyPrefab(nodeUuid: string): any;
|
||||
|
||||
//////////
|
||||
// UI //
|
||||
//////////
|
||||
distributeSelectionUI(type: string): void;
|
||||
alignSelectionUI(type: string): void;
|
||||
|
||||
////////////////
|
||||
// particle //
|
||||
////////////////
|
||||
/**
|
||||
* 查询粒子播放的信息
|
||||
* @param uuid 粒子组件的 uuid
|
||||
*/
|
||||
queryParticlePlayInfo(uuid: string): any;
|
||||
/**
|
||||
* 设置粒子播放速度
|
||||
* @param uuid 粒子组件的 uuid
|
||||
* @param speed
|
||||
*/
|
||||
setParticlePlaySpeed(uuid: string, speed: number): void;
|
||||
/**
|
||||
* 播放选中的粒子
|
||||
* @param uuid 粒子组件的 uuid
|
||||
*/
|
||||
playParticle();
|
||||
/**
|
||||
* 重新开始播放选中的粒子
|
||||
* @param uuid 粒子组件的 uuid
|
||||
*/
|
||||
restartParticle();
|
||||
/**
|
||||
* 暂停选中的粒子
|
||||
* @param uuid 粒子组件的 uuid
|
||||
*/
|
||||
pauseParticle();
|
||||
/**
|
||||
* 停止播放选中的粒子
|
||||
* @param uuid 粒子组件的 uuid
|
||||
*/
|
||||
stopParticle();
|
||||
/////////////////
|
||||
// wireframe //
|
||||
/////////////////
|
||||
// applyWireframeStorage(mode: any, color: any): void;
|
||||
// setWireframeMode(mode: any): void;
|
||||
// setWireframeColor(color: any): void;
|
||||
|
||||
///////////////////
|
||||
// physics //
|
||||
///////////////////
|
||||
updatePhysicsGroup(): void;
|
||||
|
||||
// others
|
||||
onEngineUpdate(): void;
|
||||
|
||||
///////////////////
|
||||
// physics 2D //
|
||||
///////////////////
|
||||
regeneratePolygon2DPoints(uuid: string): void;
|
||||
|
||||
///////////////////
|
||||
// particle 2D //
|
||||
///////////////////
|
||||
exportParticlePlist(uuid: string): Promise<any>;
|
||||
}
|
||||
|
||||
export default ISceneFacade;
|
||||
27
extensions/app/engine/@types/packages/server/@types/package.d.ts
vendored
Normal file
27
extensions/app/engine/@types/packages/server/@types/package.d.ts
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
// 消息定义
|
||||
interface MessageInterface {
|
||||
params: any[],
|
||||
result: any;
|
||||
}
|
||||
|
||||
// host
|
||||
export interface HostInfo {
|
||||
host: string;
|
||||
ip: string;
|
||||
port: number;
|
||||
}
|
||||
|
||||
// 消息定义
|
||||
export interface main {
|
||||
scene: {
|
||||
[x: string]: MessageInterface;
|
||||
'query-port': {
|
||||
params: [],
|
||||
result: number,
|
||||
};
|
||||
'scan-lan': {
|
||||
params: [],
|
||||
result: HostInfo[],
|
||||
};
|
||||
}
|
||||
}
|
||||
20
extensions/app/engine/@types/packages/shortcuts/@types/shortcut.d.ts
vendored
Normal file
20
extensions/app/engine/@types/packages/shortcuts/@types/shortcut.d.ts
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
export interface ShortcutItem {
|
||||
when: string;
|
||||
message: string;
|
||||
shortcut: string;
|
||||
pkgName: string;
|
||||
params?: Array<string | number | boolean>;
|
||||
rawShortcut?: string;
|
||||
key: string;
|
||||
missing?: boolean;
|
||||
}
|
||||
|
||||
export type IShortcutItemMap = Record<string, ShortcutItem>;
|
||||
|
||||
export interface IShortcutEditInfo {
|
||||
key: string;
|
||||
shortcut: string;
|
||||
searches: ShortcutItem[];
|
||||
conflict: boolean;
|
||||
when: string;
|
||||
}
|
||||
30
extensions/app/engine/@types/packages/vivo-mini-game/@types/index.d.ts
vendored
Normal file
30
extensions/app/engine/@types/packages/vivo-mini-game/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
/// <reference path='../../../@types/index'/>
|
||||
export * from '@editor/library-type/packages/builder/@types/protect';
|
||||
import { IInternalBuildOptions } from '@editor/library-type/packages/builder/@types/protect';
|
||||
|
||||
export type IOrientation = 'landscape' | 'portrait';
|
||||
|
||||
export interface ITaskOption extends IInternalBuildOptions {
|
||||
packages: {
|
||||
'vivo-mini-game': IOptions;
|
||||
}
|
||||
}
|
||||
|
||||
export interface IOptions {
|
||||
package: string;
|
||||
icon: string;
|
||||
versionName: string;
|
||||
versionCode: string;
|
||||
minPlatformVersion: string;
|
||||
deviceOrientation: IOrientation;
|
||||
useDebugKey: boolean;
|
||||
privatePemPath: string;
|
||||
certificatePemPath: string;
|
||||
logLevel: string;
|
||||
separateEngine: boolean;
|
||||
}
|
||||
|
||||
export interface ICompileOptions {
|
||||
name: string;
|
||||
useDebugKey: boolean;
|
||||
}
|
||||
17
extensions/app/engine/@types/packages/web-desktop/@types/index.d.ts
vendored
Normal file
17
extensions/app/engine/@types/packages/web-desktop/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/// <reference path='../../../@types/index'/>
|
||||
export * from '@editor/library-type/packages/builder/@types/protect';
|
||||
|
||||
import { appTemplateData, IInternalBuildOptions, IPolyFills } from '@editor/library-type/packages/builder/@types/protect';
|
||||
|
||||
export interface IOptions {
|
||||
resolution: {
|
||||
designHeight: number;
|
||||
designWidth: number;
|
||||
},
|
||||
}
|
||||
export interface ITaskOption extends IInternalBuildOptions {
|
||||
packages: {
|
||||
'web-desktop': IOptions;
|
||||
};
|
||||
appTemplateData: appTemplateData;
|
||||
}
|
||||
15
extensions/app/engine/@types/packages/web-mobile/@types/index.d.ts
vendored
Normal file
15
extensions/app/engine/@types/packages/web-mobile/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
/// <reference path='../../../@types/index'/>
|
||||
export * from '@editor/library-type/packages/builder/@types/protect';
|
||||
|
||||
import { IInternalBuildOptions, IPolyFills, ISettings } from '@editor/library-type/packages/builder/@types/protect';
|
||||
|
||||
export type IOrientation = 'auto' | 'landscape' | 'portrait';
|
||||
export interface IOptions {
|
||||
orientation: IOrientation;
|
||||
embedWebDebugger: boolean;
|
||||
}
|
||||
export interface ITaskOption extends IInternalBuildOptions {
|
||||
packages: {
|
||||
'web-mobile': IOptions;
|
||||
}
|
||||
}
|
||||
100
extensions/app/engine/@types/packages/wechatgame/@types/index.d.ts
vendored
Normal file
100
extensions/app/engine/@types/packages/wechatgame/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
/// <reference path='../../../@types/index'/>
|
||||
export * from '@editor/library-type/packages/builder/@types/protect';
|
||||
export * from '../../../@types/editor';
|
||||
|
||||
import { IInternalBuildOptions } from '@editor/library-type/packages/builder/@types/protect';
|
||||
|
||||
export type IOrientation = 'auto' | 'landscape' | 'portrait';
|
||||
|
||||
export interface IOptions {
|
||||
appid: string;
|
||||
buildOpenDataContextTemplate: boolean;
|
||||
orientation: IOrientation;
|
||||
separateEngine: boolean;
|
||||
wasm: 'js' | 'wasm' | boolean;
|
||||
enabelWebGL2: 'off' | 'sameAsProjectSetting';
|
||||
}
|
||||
|
||||
export interface ITaskOption extends IInternalBuildOptions {
|
||||
packages: {
|
||||
wechatgame: IOptions;
|
||||
};
|
||||
}
|
||||
|
||||
// TODO 需要更新 editor 接口定义
|
||||
export type IModules = Record<string, IModuleItem>;
|
||||
|
||||
export interface IFlagBaseItem {
|
||||
/**
|
||||
* Display text.
|
||||
*/
|
||||
label: string;
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*/
|
||||
description?: string;
|
||||
|
||||
native?: string;
|
||||
|
||||
wechatPlugin?: boolean;
|
||||
|
||||
default?: string[];
|
||||
}
|
||||
export interface IBaseItem {
|
||||
/**
|
||||
* Display text.
|
||||
*/
|
||||
label: string;
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*/
|
||||
description?: string;
|
||||
|
||||
required?: boolean;
|
||||
|
||||
native?: string;
|
||||
|
||||
wechatPlugin?: boolean;
|
||||
}
|
||||
|
||||
export interface IModuleItem extends IBaseItem {
|
||||
/**
|
||||
* Display text.
|
||||
*/
|
||||
label: string;
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*/
|
||||
description?: string;
|
||||
|
||||
/**
|
||||
* Whether if the feature of options allow multiple selection.
|
||||
*/
|
||||
multi?: boolean;
|
||||
|
||||
/**
|
||||
* If have default it will checked
|
||||
*/
|
||||
default?: string[];
|
||||
|
||||
options?: Record<string, IBaseItem>;
|
||||
|
||||
category?: string;
|
||||
|
||||
flags?: Record<string, IFlagBaseItem>;
|
||||
}
|
||||
|
||||
export interface IDisplayModuleItem extends IModuleItem {
|
||||
_value: boolean;
|
||||
_option?: string;
|
||||
options?: Record<string, IDisplayModuleItem>;
|
||||
}
|
||||
|
||||
export interface IDisplayModuleCache {
|
||||
_value: boolean;
|
||||
_option?: string;
|
||||
flags?: Record<string, boolean>;
|
||||
}
|
||||
29
extensions/app/engine/@types/packages/windows/@types/index.d.ts
vendored
Normal file
29
extensions/app/engine/@types/packages/windows/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
/// <reference path='../../../@types/index'/>
|
||||
export * from '@editor/library-type/packages/builder/@types/protect';
|
||||
|
||||
import { IInternalBuildOptions, InternalBuildResult } from '@editor/library-type/packages/builder/@types/protect';
|
||||
import { IOptions as INativeOption } from '@editor/library-type/packages/native';
|
||||
|
||||
export type IOrientation = 'landscape' | 'portrait';
|
||||
|
||||
export interface ITaskOption extends IInternalBuildOptions {
|
||||
packages: {
|
||||
'windows': IOptions;
|
||||
native: INativeOption;
|
||||
}
|
||||
}
|
||||
|
||||
export interface IOptions {
|
||||
renderBackEnd: {
|
||||
vulkan: boolean;
|
||||
gles3: boolean;
|
||||
gles2: boolean;
|
||||
};
|
||||
targetPlatform: 'win32' | 'x64';
|
||||
serverMode: boolean;
|
||||
targetPlatform: 'x64';
|
||||
}
|
||||
|
||||
export interface IBuildResult extends InternalBuildResult {
|
||||
userFrameWorks: boolean; // 是否使用用户的配置数据
|
||||
}
|
||||
33
extensions/app/engine/@types/packages/xiaomi-quick-game/@types/index.d.ts
vendored
Normal file
33
extensions/app/engine/@types/packages/xiaomi-quick-game/@types/index.d.ts
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
export * from '@editor/library-type/packages/builder/@types/protect';
|
||||
import { IInternalBuildOptions, ISettings } from '@editor/library-type/packages/builder/@types/protect';
|
||||
|
||||
export type IOrientation = 'landscape' | 'portrait';
|
||||
|
||||
export interface ITaskOption extends IInternalBuildOptions {
|
||||
packages: {
|
||||
'xiaomi-quick-game': IOptions;
|
||||
};
|
||||
}
|
||||
|
||||
export interface IOptions {
|
||||
package: string;
|
||||
icon: string;
|
||||
versionName: string;
|
||||
versionCode: string;
|
||||
minPlatformVersion: string;
|
||||
deviceOrientation: IOrientation;
|
||||
useDebugKey: boolean;
|
||||
privatePemPath: string;
|
||||
certificatePemPath: string;
|
||||
logLevel: string;
|
||||
|
||||
encapsulation: boolean;
|
||||
}
|
||||
|
||||
export interface ICompileOption {
|
||||
name: string;
|
||||
useDebugKey: boolean;
|
||||
tinyPackageServer: string;
|
||||
}
|
||||
|
||||
18
extensions/app/engine/dist/builder/hooks.js
vendored
Normal file
18
extensions/app/engine/dist/builder/hooks.js
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.onAfterBuild = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const file_1 = require("./utils/file");
|
||||
const onAfterBuild = async function (options, result) {
|
||||
if (options.platform !== 'web-mobile' && options.platform !== 'web-desktop') {
|
||||
return;
|
||||
}
|
||||
if (!options.md5Cache) {
|
||||
return;
|
||||
}
|
||||
file_1.adaptFileMD5(path_1.default.join(result.dest, 'index.html'));
|
||||
};
|
||||
exports.onAfterBuild = onAfterBuild;
|
||||
8
extensions/app/engine/dist/builder/index.js
vendored
Normal file
8
extensions/app/engine/dist/builder/index.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.configs = void 0;
|
||||
exports.configs = {
|
||||
'*': {
|
||||
hooks: './hooks',
|
||||
}
|
||||
};
|
||||
248
extensions/app/engine/dist/builder/utils/file.js
vendored
Normal file
248
extensions/app/engine/dist/builder/utils/file.js
vendored
Normal file
@@ -0,0 +1,248 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.queryFile = exports.getFilePathRemoveMD5 = exports.getFileNameRemoveMD5 = exports.getFilesBySameNameDiffMD5 = exports.renameFileByMD5 = exports.isFileNameHasMD5 = exports.adaptFilename = exports.adaptFileMD5 = void 0;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const md5_1 = __importDefault(require("./md5"));
|
||||
const includeExts = ['.html', '.css', '.js', '.json'];
|
||||
const regExp = new RegExp('(?<=(\'|"|url\\(|URL\\())(?!//)[a-zA-Z0-9_\./-]+\\.(js|css|json|png|apng|jpg|jpeg|gif|svg)(?=(\'|"|\\)))', 'g');
|
||||
/**
|
||||
* 获取文件夹内的文件
|
||||
*/
|
||||
function getFiles(dir) {
|
||||
const result = [];
|
||||
// 判断文件是否存在
|
||||
if (!fs_1.default.existsSync(dir))
|
||||
return result;
|
||||
// 如果不是文件夹则返回
|
||||
if (!fs_1.default.statSync(dir).isDirectory())
|
||||
return result;
|
||||
// 遍历文件夹
|
||||
fs_1.default.readdirSync(dir).forEach(item => {
|
||||
const item_path = path_1.default.join(dir, item);
|
||||
const isDir = fs_1.default.statSync(item_path).isDirectory();
|
||||
if (!isDir)
|
||||
result.push(item_path);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* 以某个文件为起点,对其引用的文件树进行md5
|
||||
* @param filepath 文件路径
|
||||
* @param exclude 排除的文件路径(不带md5,不支持相对路径),排除的文件不会遍历子文件树,默认其本身会进行md5
|
||||
*/
|
||||
function adaptFileMD5(filepath, exclude = []) {
|
||||
// 参数不合法
|
||||
if (!filepath)
|
||||
return false;
|
||||
// 修正文件路径
|
||||
filepath = fs_1.default.existsSync(filepath) ? filepath : queryFile(filepath);
|
||||
if (!filepath)
|
||||
return false;
|
||||
// 排除的文件
|
||||
const fileExt = path_1.default.extname(filepath);
|
||||
const filepathNoMD5 = getFilePathRemoveMD5(filepath);
|
||||
const excludeItem = exclude.find(item => {
|
||||
if (item.path instanceof RegExp)
|
||||
return item.path.test(filepath);
|
||||
else
|
||||
return item.path === filepathNoMD5;
|
||||
});
|
||||
const isExcluded = !!excludeItem || includeExts.indexOf(fileExt) === -1;
|
||||
// 文件扩展名
|
||||
if (!isExcluded) {
|
||||
// 文件目录
|
||||
const fileDir = path_1.default.dirname(filepath);
|
||||
// 文件内容
|
||||
let fileText = fs_1.default.readFileSync(filepath, 'utf-8');
|
||||
// 文件内所有引用的相对路径(排重)
|
||||
const subRelativePaths = Array.from(new Set(fileText.match(regExp)));
|
||||
for (let index = 0; index < subRelativePaths.length; index++) {
|
||||
// 子文件相对路径(读取到的)
|
||||
const subRelativePath = subRelativePaths[index];
|
||||
// 子文件路径(读取到的)
|
||||
const subFilePath = path_1.default.join(fileDir, subRelativePath);
|
||||
// 如果当前引用的文件的路径带有md5戳,并且文件存在,则跳过
|
||||
if (isFileNameHasMD5(subFilePath) && fs_1.default.existsSync(subFilePath))
|
||||
continue;
|
||||
{
|
||||
// 实际的子文件路径(不确定有没有md5)
|
||||
const subFilePathReal = queryFile(subFilePath);
|
||||
// 实际的子文件不存在
|
||||
if (!subFilePathReal) {
|
||||
// console.warn('[跳过] [文件不存在]', filepath, subRelativePath);
|
||||
continue;
|
||||
}
|
||||
// 如果引用的文件路径不带md5,但是实际文件有md5,则
|
||||
if (!isFileNameHasMD5(subFilePath) && isFileNameHasMD5(subFilePathReal)) {
|
||||
// 原始的子文件名
|
||||
const subFileBasename = path_1.default.basename(subRelativePath);
|
||||
// 实际的子文件名(带md5)
|
||||
const subFileBasenameReal = path_1.default.basename(subFilePathReal);
|
||||
// 替换
|
||||
fileText = fileText.replace(new RegExp(subRelativePath, 'g'), subRelativePath.replace(subFileBasename, subFileBasenameReal));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
{
|
||||
// 对它进行md5处理
|
||||
const result = adaptFileMD5(subFilePath, exclude);
|
||||
// 文件不存在
|
||||
if (!result) {
|
||||
// console.warn('[跳过] [文件不存在]', filepath, subRelativePath);
|
||||
continue;
|
||||
}
|
||||
// 实际的子文件路径(已经带上md5了)
|
||||
const subFilepathReal = queryFile(subFilePath);
|
||||
// 原始的子文件名
|
||||
const subFileBasename = path_1.default.basename(subRelativePath);
|
||||
// 实际的子文件名(带md5)
|
||||
const subFileBasenameReal = path_1.default.basename(subFilepathReal);
|
||||
// 替换
|
||||
fileText = fileText.replace(new RegExp(subRelativePath, 'g'), subRelativePath.replace(subFileBasename, subFileBasenameReal));
|
||||
}
|
||||
}
|
||||
// 重新写入文件内容
|
||||
fs_1.default.writeFileSync(filepath, fileText, 'utf-8');
|
||||
}
|
||||
// 将文件md5重命名
|
||||
if (fileExt !== '.html' && (excludeItem === null || excludeItem === void 0 ? void 0 : excludeItem.md5) !== false) {
|
||||
renameFileByMD5(filepath);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
exports.adaptFileMD5 = adaptFileMD5;
|
||||
/**
|
||||
* 替换某个文件里引用的的文件名
|
||||
* @param {string} filepath 被替换的文件路径
|
||||
* @param {string} adaptDir adaptFile所在的文件夹
|
||||
* @param {string} adaptFile 文件名.后缀,不能包含其他东西
|
||||
*/
|
||||
function adaptFilename(filepath, adaptDir, adaptFile) {
|
||||
if (!fs_1.default.existsSync(filepath))
|
||||
return false;
|
||||
const adaptName = adaptFile.split('.')[0];
|
||||
const adaptExtname = path_1.default.extname(adaptFile) || '';
|
||||
let text = fs_1.default.readFileSync(filepath, 'utf-8');
|
||||
const filePaths = getFiles(adaptDir);
|
||||
for (let index = 0; index < filePaths.length; index++) {
|
||||
const filePath = filePaths[index];
|
||||
const basename = path_1.default.basename(filePath);
|
||||
const name = basename.split('.')[0];
|
||||
const extname = path_1.default.extname(basename) || '';
|
||||
if (basename !== adaptFile && name === adaptName && extname === adaptExtname) {
|
||||
const regExp = new RegExp(`(?<=('|"|\/))${name}[\.a-zA-Z0-9]*\\${extname}(?=('|"))`, 'g');
|
||||
text = text.replace(regExp, basename);
|
||||
break;
|
||||
}
|
||||
}
|
||||
fs_1.default.writeFileSync(filepath, text, 'utf-8');
|
||||
return true;
|
||||
}
|
||||
exports.adaptFilename = adaptFilename;
|
||||
/**
|
||||
* 判断一个文件是否有md5戳
|
||||
* @param {string} filename
|
||||
*/
|
||||
function isFileNameHasMD5(filename) {
|
||||
filename = path_1.default.basename(filename);
|
||||
return filename !== getFileNameRemoveMD5(filename);
|
||||
}
|
||||
exports.isFileNameHasMD5 = isFileNameHasMD5;
|
||||
/**
|
||||
* md5重命名文件名字
|
||||
* @param {string} filePath
|
||||
* @returns
|
||||
*/
|
||||
function renameFileByMD5(filePath) {
|
||||
const basename = getFileNameRemoveMD5(filePath);
|
||||
const extname = path_1.default.extname(basename);
|
||||
if (!extname)
|
||||
return filePath;
|
||||
const filename = basename.slice(0, -extname.length);
|
||||
if (!filename)
|
||||
return filePath;
|
||||
const dirname = path_1.default.dirname(filePath);
|
||||
const txt = fs_1.default.readFileSync(filePath, 'utf-8');
|
||||
const renamePath = path_1.default.join(dirname, `${filename}.${md5_1.default(txt)}${extname}`);
|
||||
fs_1.default.renameSync(filePath, renamePath);
|
||||
return renamePath;
|
||||
}
|
||||
exports.renameFileByMD5 = renameFileByMD5;
|
||||
/**
|
||||
* 获取相同名字相同后缀, 但md5戳不一样的文件数组
|
||||
* @param {string} dir
|
||||
*/
|
||||
function getFilesBySameNameDiffMD5(dir) {
|
||||
// [ [ {name:'index',ext:'.js',files:['/test/index.js','/test/index.c67d.js']} ]
|
||||
const result = [];
|
||||
const files = getFiles(dir);
|
||||
files.forEach(filepath => {
|
||||
const basename = getFileNameRemoveMD5(filepath);
|
||||
if (!basename)
|
||||
return;
|
||||
const extname = path_1.default.extname(basename);
|
||||
if (!extname)
|
||||
return;
|
||||
const filename = basename.slice(0, -extname.length);
|
||||
if (!filename)
|
||||
return;
|
||||
const res = result.find(data => data.name === filename && data.ext === extname);
|
||||
if (res)
|
||||
return res.files.push(filepath);
|
||||
result.push({
|
||||
name: filename,
|
||||
ext: extname,
|
||||
files: [filepath]
|
||||
});
|
||||
});
|
||||
return result.filter((data) => data.files.length >= 2);
|
||||
}
|
||||
exports.getFilesBySameNameDiffMD5 = getFilesBySameNameDiffMD5;
|
||||
/**
|
||||
* 将文件名中的md5字段去除
|
||||
* @param {string} filename
|
||||
* @returns
|
||||
*/
|
||||
function getFileNameRemoveMD5(filename) {
|
||||
const basename = path_1.default.basename(filename)
|
||||
// a-jqw89a.js => a.js
|
||||
// a-jqw89a.min.js => a.min.js
|
||||
.replace(/-[a-z0-9]+\./, '.');
|
||||
return basename.split('.').filter((str, index, array) => {
|
||||
if (index === 0 || index === array.length - 1)
|
||||
return true;
|
||||
return index == 1 && str === 'min';
|
||||
}).join('.');
|
||||
}
|
||||
exports.getFileNameRemoveMD5 = getFileNameRemoveMD5;
|
||||
/**
|
||||
* 删除文件路径中的md5字段
|
||||
* @param {string} filepath
|
||||
* @returns
|
||||
*/
|
||||
function getFilePathRemoveMD5(filepath) {
|
||||
const dirname = path_1.default.dirname(filepath);
|
||||
return path_1.default.join(dirname, getFileNameRemoveMD5(filepath));
|
||||
}
|
||||
exports.getFilePathRemoveMD5 = getFilePathRemoveMD5;
|
||||
/**
|
||||
* 输入文件路径,可以索引到对应的带有md5的文件路径
|
||||
* @param {string} filepath 文件路径(带后缀)
|
||||
* @returns
|
||||
*/
|
||||
function queryFile(filepath) {
|
||||
// 将文件名中的md5字段去除
|
||||
const filename = getFileNameRemoveMD5(filepath);
|
||||
const fileDir = path_1.default.dirname(filepath);
|
||||
const filesList = getFiles(fileDir);
|
||||
return filesList.find(filepath => {
|
||||
return path_1.default.basename(filepath) === filename;
|
||||
}) || filesList.find(filepath => {
|
||||
return getFileNameRemoveMD5(filepath) === filename;
|
||||
});
|
||||
}
|
||||
exports.queryFile = queryFile;
|
||||
370
extensions/app/engine/dist/builder/utils/md5.js
vendored
Normal file
370
extensions/app/engine/dist/builder/utils/md5.js
vendored
Normal file
@@ -0,0 +1,370 @@
|
||||
"use strict";
|
||||
/*
|
||||
* JavaScript MD5
|
||||
* https://github.com/blueimp/JavaScript-MD5
|
||||
*
|
||||
* Copyright 2011, Sebastian Tschan
|
||||
* https://blueimp.net
|
||||
*
|
||||
* Licensed under the MIT license:
|
||||
* https://opensource.org/licenses/MIT
|
||||
*
|
||||
* Based on
|
||||
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
|
||||
* Digest Algorithm, as defined in RFC 1321.
|
||||
* Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
|
||||
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
|
||||
* Distributed under the BSD License
|
||||
* See http://pajhome.org.uk/crypt/md5 for more info.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
/* global define */
|
||||
/* eslint-disable strict */
|
||||
/**
|
||||
* Add integers, wrapping at 2^32.
|
||||
* This uses 16-bit operations internally to work around bugs in interpreters.
|
||||
*
|
||||
* @param {number} x First integer
|
||||
* @param {number} y Second integer
|
||||
* @returns {number} Sum
|
||||
*/
|
||||
function safeAdd(x, y) {
|
||||
let lsw = (x & 0xffff) + (y & 0xffff);
|
||||
let msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
||||
return (msw << 16) | (lsw & 0xffff);
|
||||
}
|
||||
/**
|
||||
* Bitwise rotate a 32-bit number to the left.
|
||||
*
|
||||
* @param {number} num 32-bit number
|
||||
* @param {number} cnt Rotation count
|
||||
* @returns {number} Rotated number
|
||||
*/
|
||||
function bitRotateLeft(num, cnt) {
|
||||
return (num << cnt) | (num >>> (32 - cnt));
|
||||
}
|
||||
/**
|
||||
* Basic operation the algorithm uses.
|
||||
*
|
||||
* @param {number} q q
|
||||
* @param {number} a a
|
||||
* @param {number} b b
|
||||
* @param {number} x x
|
||||
* @param {number} s s
|
||||
* @param {number} t t
|
||||
* @returns {number} Result
|
||||
*/
|
||||
function md5cmn(q, a, b, x, s, t) {
|
||||
return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
|
||||
}
|
||||
/**
|
||||
* Basic operation the algorithm uses.
|
||||
*
|
||||
* @param {number} a a
|
||||
* @param {number} b b
|
||||
* @param {number} c c
|
||||
* @param {number} d d
|
||||
* @param {number} x x
|
||||
* @param {number} s s
|
||||
* @param {number} t t
|
||||
* @returns {number} Result
|
||||
*/
|
||||
function md5ff(a, b, c, d, x, s, t) {
|
||||
return md5cmn((b & c) | (~b & d), a, b, x, s, t);
|
||||
}
|
||||
/**
|
||||
* Basic operation the algorithm uses.
|
||||
*
|
||||
* @param {number} a a
|
||||
* @param {number} b b
|
||||
* @param {number} c c
|
||||
* @param {number} d d
|
||||
* @param {number} x x
|
||||
* @param {number} s s
|
||||
* @param {number} t t
|
||||
* @returns {number} Result
|
||||
*/
|
||||
function md5gg(a, b, c, d, x, s, t) {
|
||||
return md5cmn((b & d) | (c & ~d), a, b, x, s, t);
|
||||
}
|
||||
/**
|
||||
* Basic operation the algorithm uses.
|
||||
*
|
||||
* @param {number} a a
|
||||
* @param {number} b b
|
||||
* @param {number} c c
|
||||
* @param {number} d d
|
||||
* @param {number} x x
|
||||
* @param {number} s s
|
||||
* @param {number} t t
|
||||
* @returns {number} Result
|
||||
*/
|
||||
function md5hh(a, b, c, d, x, s, t) {
|
||||
return md5cmn(b ^ c ^ d, a, b, x, s, t);
|
||||
}
|
||||
/**
|
||||
* Basic operation the algorithm uses.
|
||||
*
|
||||
* @param {number} a a
|
||||
* @param {number} b b
|
||||
* @param {number} c c
|
||||
* @param {number} d d
|
||||
* @param {number} x x
|
||||
* @param {number} s s
|
||||
* @param {number} t t
|
||||
* @returns {number} Result
|
||||
*/
|
||||
function md5ii(a, b, c, d, x, s, t) {
|
||||
return md5cmn(c ^ (b | ~d), a, b, x, s, t);
|
||||
}
|
||||
/**
|
||||
* Calculate the MD5 of an array of little-endian words, and a bit length.
|
||||
*
|
||||
* @param {Array} x Array of little-endian words
|
||||
* @param {number} len Bit length
|
||||
* @returns {Array<number>} MD5 Array
|
||||
*/
|
||||
function binlMD5(x, len) {
|
||||
/* append padding */
|
||||
x[len >> 5] |= 0x80 << len % 32;
|
||||
x[(((len + 64) >>> 9) << 4) + 14] = len;
|
||||
let i;
|
||||
let olda;
|
||||
let oldb;
|
||||
let oldc;
|
||||
let oldd;
|
||||
let a = 1732584193;
|
||||
let b = -271733879;
|
||||
let c = -1732584194;
|
||||
let d = 271733878;
|
||||
for (i = 0; i < x.length; i += 16) {
|
||||
olda = a;
|
||||
oldb = b;
|
||||
oldc = c;
|
||||
oldd = d;
|
||||
a = md5ff(a, b, c, d, x[i], 7, -680876936);
|
||||
d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
|
||||
c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
|
||||
b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
|
||||
a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
|
||||
d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
|
||||
c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
|
||||
b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
|
||||
a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
|
||||
d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
|
||||
c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
|
||||
b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
|
||||
a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
|
||||
d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
|
||||
c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
|
||||
b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
|
||||
a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
|
||||
d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
|
||||
c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
|
||||
b = md5gg(b, c, d, a, x[i], 20, -373897302);
|
||||
a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
|
||||
d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
|
||||
c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
|
||||
b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
|
||||
a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
|
||||
d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
|
||||
c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
|
||||
b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
|
||||
a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
|
||||
d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
|
||||
c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
|
||||
b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
|
||||
a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
|
||||
d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
|
||||
c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
|
||||
b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
|
||||
a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
|
||||
d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
|
||||
c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
|
||||
b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
|
||||
a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
|
||||
d = md5hh(d, a, b, c, x[i], 11, -358537222);
|
||||
c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
|
||||
b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
|
||||
a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
|
||||
d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
|
||||
c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
|
||||
b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
|
||||
a = md5ii(a, b, c, d, x[i], 6, -198630844);
|
||||
d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
|
||||
c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
|
||||
b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
|
||||
a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
|
||||
d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
|
||||
c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
|
||||
b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
|
||||
a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
|
||||
d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
|
||||
c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
|
||||
b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
|
||||
a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
|
||||
d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
|
||||
c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
|
||||
b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
|
||||
a = safeAdd(a, olda);
|
||||
b = safeAdd(b, oldb);
|
||||
c = safeAdd(c, oldc);
|
||||
d = safeAdd(d, oldd);
|
||||
}
|
||||
return [a, b, c, d];
|
||||
}
|
||||
/**
|
||||
* Convert an array of little-endian words to a string
|
||||
*
|
||||
* @param {Array<number>} input MD5 Array
|
||||
* @returns {string} MD5 string
|
||||
*/
|
||||
function binl2rstr(input) {
|
||||
let i;
|
||||
let output = '';
|
||||
let length32 = input.length * 32;
|
||||
for (i = 0; i < length32; i += 8) {
|
||||
output += String.fromCharCode((input[i >> 5] >>> i % 32) & 0xff);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
/**
|
||||
* Convert a raw string to an array of little-endian words
|
||||
* Characters >255 have their high-byte silently ignored.
|
||||
*
|
||||
* @param {string} input Raw input string
|
||||
* @returns {Array<number>} Array of little-endian words
|
||||
*/
|
||||
function rstr2binl(input) {
|
||||
let i;
|
||||
let output = [];
|
||||
output[(input.length >> 2) - 1] = undefined;
|
||||
for (i = 0; i < output.length; i += 1) {
|
||||
output[i] = 0;
|
||||
}
|
||||
let length8 = input.length * 8;
|
||||
for (i = 0; i < length8; i += 8) {
|
||||
output[i >> 5] |= (input.charCodeAt(i / 8) & 0xff) << i % 32;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
/**
|
||||
* Calculate the MD5 of a raw string
|
||||
*
|
||||
* @param {string} s Input string
|
||||
* @returns {string} Raw MD5 string
|
||||
*/
|
||||
function rstrMD5(s) {
|
||||
return binl2rstr(binlMD5(rstr2binl(s), s.length * 8));
|
||||
}
|
||||
/**
|
||||
* Calculates the HMAC-MD5 of a key and some data (raw strings)
|
||||
*
|
||||
* @param {string} key HMAC key
|
||||
* @param {string} data Raw input string
|
||||
* @returns {string} Raw MD5 string
|
||||
*/
|
||||
function rstrHMACMD5(key, data) {
|
||||
let i;
|
||||
let bkey = rstr2binl(key);
|
||||
let ipad = [];
|
||||
let opad = [];
|
||||
let hash;
|
||||
ipad[15] = opad[15] = undefined;
|
||||
if (bkey.length > 16) {
|
||||
bkey = binlMD5(bkey, key.length * 8);
|
||||
}
|
||||
for (i = 0; i < 16; i += 1) {
|
||||
ipad[i] = bkey[i] ^ 0x36363636;
|
||||
opad[i] = bkey[i] ^ 0x5c5c5c5c;
|
||||
}
|
||||
hash = binlMD5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
|
||||
return binl2rstr(binlMD5(opad.concat(hash), 512 + 128));
|
||||
}
|
||||
/**
|
||||
* Convert a raw string to a hex string
|
||||
*
|
||||
* @param {string} input Raw input string
|
||||
* @returns {string} Hex encoded string
|
||||
*/
|
||||
function rstr2hex(input) {
|
||||
let hexTab = '0123456789abcdef';
|
||||
let output = '';
|
||||
let x;
|
||||
let i;
|
||||
for (i = 0; i < input.length; i += 1) {
|
||||
x = input.charCodeAt(i);
|
||||
output += hexTab.charAt((x >>> 4) & 0x0f) + hexTab.charAt(x & 0x0f);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
/**
|
||||
* Encode a string as UTF-8
|
||||
*
|
||||
* @param {string} input Input string
|
||||
* @returns {string} UTF8 string
|
||||
*/
|
||||
function str2rstrUTF8(input) {
|
||||
return unescape(encodeURIComponent(input));
|
||||
}
|
||||
/**
|
||||
* Encodes input string as raw MD5 string
|
||||
*
|
||||
* @param {string} s Input string
|
||||
* @returns {string} Raw MD5 string
|
||||
*/
|
||||
function rawMD5(s) {
|
||||
return rstrMD5(str2rstrUTF8(s));
|
||||
}
|
||||
/**
|
||||
* Encodes input string as Hex encoded string
|
||||
*
|
||||
* @param {string} s Input string
|
||||
* @returns {string} Hex encoded string
|
||||
*/
|
||||
function hexMD5(s) {
|
||||
return rstr2hex(rawMD5(s));
|
||||
}
|
||||
/**
|
||||
* Calculates the raw HMAC-MD5 for the given key and data
|
||||
*
|
||||
* @param {string} k HMAC key
|
||||
* @param {string} d Input string
|
||||
* @returns {string} Raw MD5 string
|
||||
*/
|
||||
function rawHMACMD5(k, d) {
|
||||
return rstrHMACMD5(str2rstrUTF8(k), str2rstrUTF8(d));
|
||||
}
|
||||
/**
|
||||
* Calculates the Hex encoded HMAC-MD5 for the given key and data
|
||||
*
|
||||
* @param {string} k HMAC key
|
||||
* @param {string} d Input string
|
||||
* @returns {string} Raw MD5 string
|
||||
*/
|
||||
function hexHMACMD5(k, d) {
|
||||
return rstr2hex(rawHMACMD5(k, d));
|
||||
}
|
||||
/**
|
||||
* Calculates MD5 value for a given string.
|
||||
* If a key is provided, calculates the HMAC-MD5 value.
|
||||
* Returns a Hex encoded string unless the raw argument is given.
|
||||
*
|
||||
* @param {string} string Input string
|
||||
* @param {string} [key] HMAC key
|
||||
* @param {boolean} [raw] Raw output switch
|
||||
* @returns {string} MD5 output
|
||||
*/
|
||||
function md5(string, key, raw) {
|
||||
if (!key) {
|
||||
if (!raw) {
|
||||
return hexMD5(string);
|
||||
}
|
||||
return rawMD5(string);
|
||||
}
|
||||
if (!raw) {
|
||||
return hexHMACMD5(key, string);
|
||||
}
|
||||
return rawHMACMD5(key, string);
|
||||
}
|
||||
exports.default = md5;
|
||||
49
extensions/app/engine/dist/inspector/asset-directory.js
vendored
Normal file
49
extensions/app/engine/dist/inspector/asset-directory.js
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
'use strict';
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.close = exports.ready = exports.update = exports.template = exports.$ = void 0;
|
||||
const fs_1 = require("fs");
|
||||
const path_1 = require("path");
|
||||
exports.$ = {
|
||||
'code': '#code',
|
||||
'section': '#section',
|
||||
};
|
||||
exports.template = `
|
||||
<ui-section id="section" header="文件夹说明" expand>
|
||||
<ui-code id="code"></ui-code>
|
||||
</ui-section>
|
||||
`;
|
||||
function update(assetList, metaList) {
|
||||
this.assetList = assetList;
|
||||
this.metaList = metaList;
|
||||
if (assetList.length === 0) {
|
||||
this.$.code.innerHTML = '';
|
||||
}
|
||||
else {
|
||||
this.$.code.innerHTML = assetList
|
||||
.filter((asset) => {
|
||||
const mdFile = path_1.join(asset.file, `.${asset.name}.md`);
|
||||
return fs_1.existsSync(mdFile);
|
||||
})
|
||||
.map((asset) => {
|
||||
const mdFile = path_1.join(asset.file, `.${asset.name}.md`);
|
||||
const mdStr = fs_1.readFileSync(mdFile, 'utf-8');
|
||||
return assetList.length > 1 ? `${asset.url}:\n ${mdStr}` : mdStr;
|
||||
})
|
||||
.join('\n') || '';
|
||||
}
|
||||
if (this.$.code.innerHTML === '') {
|
||||
this.$.section.hidden = true;
|
||||
}
|
||||
else {
|
||||
this.$.section.hidden = false;
|
||||
}
|
||||
}
|
||||
exports.update = update;
|
||||
function ready() {
|
||||
// TODO something
|
||||
}
|
||||
exports.ready = ready;
|
||||
function close() {
|
||||
// TODO something
|
||||
}
|
||||
exports.close = close;
|
||||
549
extensions/app/engine/dist/main.js
vendored
Normal file
549
extensions/app/engine/dist/main.js
vendored
Normal file
@@ -0,0 +1,549 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @en Registration method for the main process of Extension
|
||||
* @zh 为扩展的主进程的注册方法
|
||||
*/
|
||||
/**
|
||||
* // 打开panel
|
||||
* Editor.Panel.open(`${插件名}.${panel名}`);
|
||||
* // 调用普通事件
|
||||
* Editor.Message.request(插件名, 消息名, ...args);
|
||||
* // 调用场景方法
|
||||
* Editor.Message.request('scene', 'execute-scene-script', {
|
||||
* //插件名
|
||||
* name: string,
|
||||
* //方法名
|
||||
* method: string,
|
||||
* //参数列表
|
||||
* args: any[]
|
||||
* });
|
||||
*
|
||||
*/
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.unload = exports.load = exports.methods = void 0;
|
||||
// path.join不能正确处理'db://'结构,会把'//'变成'/'
|
||||
const fs_1 = require("fs");
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const utils_1 = require("./utils");
|
||||
const electron = require('electron');
|
||||
const adminFolderName = 'app-admin';
|
||||
const controllerFolderName = 'app-controller';
|
||||
const managerFolderName = 'app-manager';
|
||||
const modelFolderName = 'app-model';
|
||||
const soundFolderName = 'app-sound';
|
||||
const viewFolderName = 'app-view';
|
||||
const builtinFolderName = 'app-builtin';
|
||||
const bundleFolderName = 'app-bundle';
|
||||
const pkgFolderUrl = 'db://pkg/';
|
||||
const pkgFolderPath = utils_1.convertUrlToPath(pkgFolderUrl);
|
||||
const builtinFolderUrl = 'db://assets/' + builtinFolderName;
|
||||
const builtinFolderPath = utils_1.convertUrlToPath(builtinFolderUrl);
|
||||
const bundleFolderUrl = 'db://assets/' + bundleFolderName;
|
||||
const bundleFolderPath = utils_1.convertUrlToPath(bundleFolderUrl);
|
||||
const adminFolderUrl = builtinFolderUrl + '/' + adminFolderName;
|
||||
const adminFolderPath = builtinFolderPath + '/' + adminFolderName;
|
||||
const controllerFolderUrl = builtinFolderUrl + '/' + controllerFolderName;
|
||||
const controllerFolderPath = builtinFolderPath + '/' + controllerFolderName;
|
||||
const managerFolderUrl = builtinFolderUrl + '/' + managerFolderName;
|
||||
const managerFolderPath = builtinFolderPath + '/' + managerFolderName;
|
||||
const modelFolderUrl = builtinFolderUrl + '/' + modelFolderName;
|
||||
const modelFolderPath = builtinFolderPath + '/' + modelFolderName;
|
||||
const soundFolderUrl = bundleFolderUrl + '/' + soundFolderName;
|
||||
const soundFolderPath = bundleFolderPath + '/' + soundFolderName;
|
||||
const viewFolderUrl = bundleFolderUrl + '/' + viewFolderName;
|
||||
const viewFolderPath = bundleFolderPath + '/' + viewFolderName;
|
||||
const executorFileUrl = adminFolderUrl + '/executor.ts';
|
||||
const executorFilePath = adminFolderPath + '/executor.ts';
|
||||
function isExecutor(info, strict = true) {
|
||||
if (!strict) {
|
||||
if (info.path.endsWith('Controller') && info.type === 'cc.Script')
|
||||
return true;
|
||||
if (info.path.endsWith('Manager') && (info.type === 'cc.Script' || info.type === 'cc.Prefab'))
|
||||
return true;
|
||||
if ((info.name.startsWith('data.') || info.name.startsWith('config.') || info.name.startsWith('store.')) && info.type === 'cc.Script')
|
||||
return true;
|
||||
if ((info.name.startsWith('Page') || info.name.startsWith('Paper') || info.name.startsWith('Pop') || info.name.startsWith('Top'))
|
||||
&& (info.type === 'cc.Script' || info.type === 'cc.Prefab' || info.type === 'cc.Scene' || info.type === 'cc.SceneAsset'))
|
||||
return true;
|
||||
if (info.type === 'cc.AudioClip')
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
if (info.path === builtinFolderUrl)
|
||||
return true;
|
||||
if (info.path === bundleFolderUrl)
|
||||
return true;
|
||||
if (info.path === managerFolderUrl)
|
||||
return true;
|
||||
if (info.path === controllerFolderUrl)
|
||||
return true;
|
||||
if (info.path === modelFolderUrl)
|
||||
return true;
|
||||
if (info.path === soundFolderUrl)
|
||||
return true;
|
||||
if (info.path === viewFolderUrl)
|
||||
return true;
|
||||
if (info.path.startsWith(controllerFolderUrl)) {
|
||||
return info.path.endsWith('Controller') && info.type === 'cc.Script';
|
||||
}
|
||||
if (info.path.startsWith(managerFolderUrl)) {
|
||||
return info.path.endsWith('Manager') && (info.type === 'cc.Script' || info.type === 'cc.Prefab');
|
||||
}
|
||||
if (info.path.startsWith(modelFolderUrl)) {
|
||||
return (info.name.startsWith('data.') || info.name.startsWith('config.') || info.name.startsWith('store.')) && info.type === 'cc.Script';
|
||||
}
|
||||
if (info.path.startsWith(viewFolderUrl)) {
|
||||
return (info.name.startsWith('Page') || info.name.startsWith('Paper') || info.name.startsWith('Pop') || info.name.startsWith('Top'))
|
||||
&& (info.type === 'cc.Script' || info.type === 'cc.Prefab' || info.type === 'cc.Scene' || info.type === 'cc.SceneAsset');
|
||||
}
|
||||
if (info.path.startsWith(soundFolderUrl)) {
|
||||
return info.type === 'cc.AudioClip';
|
||||
}
|
||||
}
|
||||
function compareStr(str1, str2) {
|
||||
if (str1 === str2) {
|
||||
return 0;
|
||||
}
|
||||
const len = Math.max(str1.length, str2.length);
|
||||
for (let i = 0, code1 = 0, code2 = 0; i < len; i++) {
|
||||
if (str1.length <= i) {
|
||||
return -1;
|
||||
}
|
||||
else if (str2.length <= i) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
code1 = str1.charCodeAt(i);
|
||||
code2 = str2.charCodeAt(i);
|
||||
if (code1 > code2) {
|
||||
return 1;
|
||||
}
|
||||
else if (code1 < code2) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
const viewSelect = ['Page', 'Paper', 'Pop', 'Top'];
|
||||
const viewRegExp = RegExp(`^(${viewSelect.join('|')})`);
|
||||
function readFileSyncByPath(url) {
|
||||
const filepath = utils_1.convertUrlToPath(url);
|
||||
return fs_1.existsSync(filepath) ? fs_1.readFileSync(filepath, 'utf8') : '';
|
||||
}
|
||||
function isTSDefault(value) {
|
||||
// const varname = value[0];
|
||||
const filename = value[1];
|
||||
const dirname = value[2];
|
||||
const extname = value[3];
|
||||
if (extname.endsWith('js')) {
|
||||
return false;
|
||||
}
|
||||
const filepath = path_1.default.join(utils_1.convertUrlToPath(dirname), filename + '.ts');
|
||||
const js = fs_1.readFileSync(filepath, 'utf8');
|
||||
return js.search(/export\s+default/) >= 0;
|
||||
}
|
||||
const keyWords = [
|
||||
'lib', 'manager', 'Manager', 'controller', 'Controller', 'data', 'config', 'store',
|
||||
'IViewName', 'IViewNames', 'IMiniViewName', 'IMiniViewNames', 'IMusicName', 'IMusicNames', 'IEffectName', 'IEffectNames',
|
||||
'ViewName', 'MiniViewName', 'MusicName', 'EffectName'
|
||||
];
|
||||
async function clearExecutor() {
|
||||
if (!fs_1.existsSync(executorFilePath))
|
||||
return;
|
||||
let result = '/* eslint-disable */\n' +
|
||||
'import { Component } from \'cc\';\n' +
|
||||
'import { app } from \'../../app/app\';\n' +
|
||||
'import { EDITOR,EDITOR_NOT_IN_PREVIEW } from \'cc/env\';\n\n';
|
||||
result += 'export type IReadOnly<T> = { readonly [P in keyof T]: T[P] extends Function ? T[P] : (T[P] extends Object ? IReadOnly<T[P]> : T[P]); };\n\n';
|
||||
result += 'export type IViewName = "never"\n';
|
||||
result += 'export type IViewNames = IViewName[]\n';
|
||||
result += 'export type IMiniViewName = "never"\n';
|
||||
result += 'export type IMiniViewNames = IMiniViewName[]\n';
|
||||
result += 'export type IMusicName = "never"\n';
|
||||
result += 'export type IMusicNames = IMusicName[]\n';
|
||||
result += 'export type IEffectName = "never"\n';
|
||||
result += 'export type IEffectNames = IEffectName[]\n\n';
|
||||
result += 'export type IApp = {\n';
|
||||
result += ' Controller: {},\n';
|
||||
result += ' controller: {},\n';
|
||||
result += ' Manager: {},\n';
|
||||
result += ' manager: {},\n';
|
||||
result += ' data: {},\n';
|
||||
result += ' config: {}\n';
|
||||
result += ' store: {}\n';
|
||||
result += '}\n';
|
||||
// config
|
||||
result += 'if(!EDITOR||!EDITOR_NOT_IN_PREVIEW) Object.assign(app.config, {})\n';
|
||||
// data
|
||||
result += 'if(!EDITOR||!EDITOR_NOT_IN_PREVIEW) Object.assign(app.data, {})\n';
|
||||
// store
|
||||
result += 'if(!EDITOR||!EDITOR_NOT_IN_PREVIEW) Object.assign(app.store, {})\n\n';
|
||||
// controller
|
||||
result += 'if(!EDITOR||!EDITOR_NOT_IN_PREVIEW) Object.assign(app.Controller, {})\n';
|
||||
result += 'if(!EDITOR||!EDITOR_NOT_IN_PREVIEW) Object.assign(app.controller, {})\n\n';
|
||||
// 修正windows系统中的\为/
|
||||
result = result.replace(/\\/g, '/');
|
||||
// save
|
||||
if (readFileSyncByPath(executorFileUrl) !== result) {
|
||||
await Editor.Message.request('asset-db', 'create-asset', executorFileUrl, result, {
|
||||
overwrite: true
|
||||
});
|
||||
}
|
||||
}
|
||||
async function updateExecutor() {
|
||||
// app-builtin文件夹不存在, 创建
|
||||
if (!fs_1.existsSync(builtinFolderPath))
|
||||
await utils_1.createFolderByUrl(builtinFolderUrl, { readme: utils_1.getResReadme(builtinFolderName) });
|
||||
// app-admin文件夹不存在, 创建
|
||||
if (!fs_1.existsSync(adminFolderPath))
|
||||
await utils_1.createFolderByUrl(adminFolderUrl, { meta: utils_1.getResMeta(adminFolderName), readme: utils_1.getResReadme(adminFolderName) });
|
||||
const mgrList = [];
|
||||
const ctrList = [];
|
||||
const dataList = [];
|
||||
const confList = [];
|
||||
const storeList = [];
|
||||
const viewScene = {};
|
||||
const miniViewKeys = {};
|
||||
const musicKeys = {};
|
||||
const effectKeys = {};
|
||||
// app-controller app-manager app-model
|
||||
const result1 = await Editor.Message.request('asset-db', 'query-assets', { pattern: builtinFolderUrl + '/{app-controller,app-manager/*,app-model}/*.ts' })
|
||||
.then(res => {
|
||||
return res.sort((a, b) => compareStr(a.name, b.name));
|
||||
})
|
||||
.catch(() => []);
|
||||
// app-sound
|
||||
const result2 = await Editor.Message.request('asset-db', 'query-assets', { pattern: soundFolderUrl + '/{music,effect}/**/*.*' })
|
||||
.then(res => {
|
||||
return res.sort((a, b) => compareStr(a.name, b.name));
|
||||
})
|
||||
.catch(() => []);
|
||||
// app-view
|
||||
const result3 = await Editor.Message.request('asset-db', 'query-assets', { pattern: viewFolderUrl + '/{page,pop,top,paper/*}/*/native/*.{prefab,scene}' })
|
||||
.then(res => {
|
||||
return res.sort((a, b) => compareStr(a.name, b.name));
|
||||
})
|
||||
.catch(() => []);
|
||||
// manager
|
||||
const result4 = await Editor.Message.request('asset-db', 'query-assets', { pattern: 'db://app/manager/**/*.ts' })
|
||||
.then(res => {
|
||||
return res.sort((a, b) => compareStr(a.name, b.name));
|
||||
})
|
||||
.catch(() => []);
|
||||
// 集合
|
||||
const results = result1.slice().concat(result2).concat(result3).concat(result4);
|
||||
for (let index = 0; index < results.length; index++) {
|
||||
const result = results[index];
|
||||
const fileUrl = result.url;
|
||||
// 文件名.扩展名
|
||||
const basename = path_1.default.basename(result.url || '') || '';
|
||||
// 扩展名
|
||||
const extname = path_1.default.extname(result.url || '') || '';
|
||||
// 文件名
|
||||
const filename = basename.slice(0, -extname.length);
|
||||
// 文件目录名
|
||||
const dirname = path_1.default.dirname(result.url || '') || '';
|
||||
if (!basename)
|
||||
continue;
|
||||
if (!extname)
|
||||
continue;
|
||||
if (!filename)
|
||||
continue;
|
||||
if (!dirname)
|
||||
continue;
|
||||
if (extname === '.ts') {
|
||||
// 变量名
|
||||
const varname = filename.replace(/[.-]/g, '_');
|
||||
if (keyWords.indexOf(varname) >= 0) {
|
||||
console.log(`[跳过此文件] [${filename}] 原因: ${varname}与关键字中(${JSON.stringify(keyWords)})的一个重复`);
|
||||
}
|
||||
else if (fileUrl.startsWith(controllerFolderUrl)) {
|
||||
// 用户controller
|
||||
if (filename.endsWith('Controller')) {
|
||||
ctrList.push([varname, filename, dirname, extname]);
|
||||
}
|
||||
}
|
||||
else if (fileUrl.startsWith(managerFolderUrl)) {
|
||||
// 用户manager
|
||||
if (filename.endsWith('Manager') && dirname.endsWith(utils_1.stringCaseNegate(filename.slice(0, -7)))) {
|
||||
mgrList.push([varname, filename, dirname, extname]);
|
||||
}
|
||||
}
|
||||
else if (fileUrl.startsWith('db://app/manager/')) {
|
||||
// 系统manager(系统Mgr的文件夹命名为了美观没有那么规范,所以和用户Mgr的逻辑有区别)
|
||||
if (filename.endsWith('Manager') && dirname.endsWith(filename.slice(0, -7).toLowerCase())) {
|
||||
mgrList.push([varname, filename, dirname, extname]);
|
||||
}
|
||||
}
|
||||
else if (fileUrl.startsWith(modelFolderUrl)) {
|
||||
// model
|
||||
if (filename.startsWith('data.')) {
|
||||
dataList.push([varname, filename, dirname, extname]);
|
||||
}
|
||||
else if (filename.startsWith('config.')) {
|
||||
confList.push([varname, filename, dirname, extname]);
|
||||
}
|
||||
else if (filename.startsWith('store.')) {
|
||||
storeList.push([varname, filename, dirname, extname]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (extname === '.prefab' || extname === '.scene') {
|
||||
if (fileUrl.startsWith(viewFolderUrl) && viewRegExp.test(filename)) {
|
||||
const dirArray = dirname.split('/');
|
||||
const index = dirArray.indexOf(viewFolderName);
|
||||
const viewDirArray = dirArray.slice(index + 1);
|
||||
if (['page', 'paper', 'pop', 'top'].indexOf(viewDirArray[0].toLowerCase()) >= 0) {
|
||||
// 主界面
|
||||
if (filename === `${utils_1.stringCase(viewDirArray[0], false)}${utils_1.stringCase(viewDirArray[1], false)}`) {
|
||||
viewScene[filename] = extname === '.scene';
|
||||
}
|
||||
// 子界面
|
||||
else if (filename === `${utils_1.stringCase(viewDirArray[0], false)}${utils_1.stringCase(viewDirArray[1], false)}${utils_1.stringCase(viewDirArray[2], false)}`) {
|
||||
miniViewKeys[filename] = `${utils_1.stringCase(viewDirArray[0], false)}${utils_1.stringCase(viewDirArray[1], false)}`;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// 主界面
|
||||
if (filename === `${utils_1.stringCase(viewDirArray[1], false)}${utils_1.stringCase(viewDirArray[2], false)}`) {
|
||||
viewScene[filename] = extname === '.scene';
|
||||
}
|
||||
// 子界面
|
||||
else if (filename === `${utils_1.stringCase(viewDirArray[1], false)}${utils_1.stringCase(viewDirArray[2], false)}${utils_1.stringCase(viewDirArray[3], false)}`) {
|
||||
miniViewKeys[filename] = `${utils_1.stringCase(viewDirArray[0], false)}${utils_1.stringCase(viewDirArray[1], false)}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (fileUrl.startsWith(soundFolderUrl)) {
|
||||
const dir = path_1.default.join(dirname.split(soundFolderName + '/').pop(), filename);
|
||||
if (dir.startsWith('music')) {
|
||||
// musicKeys
|
||||
musicKeys[dir] = dir;
|
||||
}
|
||||
else {
|
||||
// effectKeys
|
||||
effectKeys[dir] = dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
// const pkgNames: string[] = [];
|
||||
// if (existsSync(pkgFolderPath)) {
|
||||
// readdirSync(pkgFolderPath).forEach(function (item) {
|
||||
// const item_path = path.join(pkgFolderPath, item);
|
||||
// const item_stat = statSync(item_path);
|
||||
// if (!item_stat.isDirectory()) return;
|
||||
// const item_name = path.basename(item_path);
|
||||
// if (item_name.startsWith('@')) {
|
||||
// readdirSync(item_path).forEach(function (sub) {
|
||||
// const sub_path = path.join(item_path, sub);
|
||||
// const sub_stat = statSync(sub_path);
|
||||
// if (!sub_stat.isDirectory()) return;
|
||||
// const sub_name = path.basename(sub_path);
|
||||
// pkgNames.push(item_name + '/' + sub_name);
|
||||
// });
|
||||
// } else {
|
||||
// pkgNames.push(item_name);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
let result = '/* eslint-disable */\n' +
|
||||
'import { Component,director,Director } from \'cc\';\n' +
|
||||
'import { app } from \'../../app/app\';\n' +
|
||||
'import { EDITOR,EDITOR_NOT_IN_PREVIEW } from \'cc/env\';\n\n';
|
||||
result += 'export type IReadOnly<T> = { readonly [P in keyof T]: T[P] extends Function ? T[P] : (T[P] extends Object ? IReadOnly<T[P]> : T[P]); };\n\n';
|
||||
result += `export type IViewName = ${Object.keys(viewScene).map(str => `"${str}"`).join('|') || '"never"'}\n`;
|
||||
result += 'export type IViewNames = IViewName[]\n';
|
||||
result += `export type IMiniViewName = ${Object.keys(miniViewKeys).map(str => `"${str}"`).join('|') || '"never"'}\n`;
|
||||
result += 'export type IMiniViewNames = IMiniViewName[]\n';
|
||||
result += `export type IMusicName = ${Object.keys(musicKeys).map(str => `"${str}"`).join('|') || '"never"'}\n`;
|
||||
result += 'export type IMusicNames = IMusicName[]\n';
|
||||
result += `export type IEffectName = ${Object.keys(effectKeys).map(str => `"${str}"`).join('|') || '"never"'}\n`;
|
||||
result += 'export type IEffectNames = IEffectName[]\n\n';
|
||||
// pkgNames.forEach(name => result += `import 'db://pkg/${name}'\n`);
|
||||
const writeImport = function writeImport(arr, module) {
|
||||
return arr.forEach(function (value) {
|
||||
const varname = value[0];
|
||||
const filename = value[1];
|
||||
const dirname = value[2];
|
||||
if (isTSDefault(value)) {
|
||||
result += `import ${varname} from '${path_1.default.join(path_1.default.relative(adminFolderPath, utils_1.convertUrlToPath(dirname)), filename)}'\n`;
|
||||
}
|
||||
else if (module) {
|
||||
result += `import {${varname}} from '${path_1.default.join(path_1.default.relative(adminFolderPath, utils_1.convertUrlToPath(dirname)), filename)}'\n`;
|
||||
}
|
||||
else {
|
||||
result += `import * as ${varname} from '${path_1.default.join(path_1.default.relative(adminFolderPath, utils_1.convertUrlToPath(dirname)), filename)}'\n`;
|
||||
}
|
||||
});
|
||||
};
|
||||
writeImport(confList, false);
|
||||
writeImport(dataList, false);
|
||||
writeImport(storeList, false);
|
||||
writeImport(ctrList, true);
|
||||
writeImport(mgrList, true);
|
||||
// controller
|
||||
let ctrStr = '';
|
||||
let CtrStr = '';
|
||||
ctrList.forEach(function ([varname], index, array) {
|
||||
CtrStr += `${varname.slice(0, -10)}:typeof ${varname}`;
|
||||
ctrStr += `${varname.slice(0, -10).toLowerCase()}:IReadOnly<${varname}>`;
|
||||
if (index < array.length - 1) {
|
||||
CtrStr += ',';
|
||||
ctrStr += ',';
|
||||
}
|
||||
});
|
||||
// manager
|
||||
let mgrStr = '';
|
||||
let MgrStr = '';
|
||||
mgrList.forEach(function ([varname], index, array) {
|
||||
MgrStr += `${varname.slice(0, -7)}:Omit<typeof ${varname},keyof Component>`;
|
||||
if (varname === 'UIManager') {
|
||||
mgrStr += `${varname.slice(0, -7).toLowerCase()}:Omit<${varname}<IViewName,IMiniViewName>,keyof Component>`;
|
||||
}
|
||||
else if (varname === 'SoundManager') {
|
||||
mgrStr += `${varname.slice(0, -7).toLowerCase()}:Omit<${varname}<IEffectName,IMusicName>,keyof Component>`;
|
||||
}
|
||||
else {
|
||||
mgrStr += `${varname.slice(0, -7).toLowerCase()}:Omit<${varname},keyof Component>`;
|
||||
}
|
||||
if (index < array.length - 1) {
|
||||
MgrStr += ',';
|
||||
mgrStr += ',';
|
||||
}
|
||||
});
|
||||
result += 'export type IApp = {\n';
|
||||
result += ` Controller: {${CtrStr}},\n`;
|
||||
result += ` controller: {${ctrStr}},\n`;
|
||||
result += ` Manager: {${MgrStr}},\n`;
|
||||
result += ` manager: {${mgrStr}},\n`;
|
||||
result += ` data: {${dataList.map(([varname]) => `${varname.slice(5)}:${varname}`).join(',')}},\n`;
|
||||
result += ` config: {${confList.map(([varname]) => `${varname.slice(7)}:IReadOnly<${varname}>`).join(',')}}\n`;
|
||||
result += ` store: {${storeList.map(([varname]) => `${varname.slice(6)}:IReadOnly<${varname}>`).join(',')}}\n`;
|
||||
result += '}\n\n';
|
||||
result += 'function init(){\n';
|
||||
// config
|
||||
result += `if(!EDITOR||!EDITOR_NOT_IN_PREVIEW) Object.assign(app.config, {${confList.map(([varname]) => `${varname.slice(7)}:new ${varname}()`).join(',')}})\n`;
|
||||
// data
|
||||
result += `if(!EDITOR||!EDITOR_NOT_IN_PREVIEW) Object.assign(app.data, {${dataList.map(([varname]) => `${varname.slice(5)}:new ${varname}()`).join(',')}})\n`;
|
||||
// store
|
||||
result += `if(!EDITOR||!EDITOR_NOT_IN_PREVIEW) Object.assign(app.store, {${storeList.map(([varname]) => `${varname.slice(6)}:new ${varname}()`).join(',')}})\n\n`;
|
||||
// controller
|
||||
result += `if(!EDITOR||!EDITOR_NOT_IN_PREVIEW) Object.assign(app.Controller, {${ctrList.map(([varname]) => `${varname.slice(0, -10)}:${varname}`).join(',')}})\n`;
|
||||
result += `if(!EDITOR||!EDITOR_NOT_IN_PREVIEW) Object.assign(app.controller, {${ctrList.map(([varname]) => `${varname.slice(0, -10).toLowerCase()}:new ${varname}()`).join(',')}})\n`;
|
||||
result += '}\n';
|
||||
result += 'if(!EDITOR||!EDITOR_NOT_IN_PREVIEW) director.on(Director.EVENT_RESET,init)\n';
|
||||
result += 'if(!EDITOR||!EDITOR_NOT_IN_PREVIEW) init()\n';
|
||||
// 修正windows系统中的\为/
|
||||
result = result.replace(/\\/g, '/');
|
||||
// save
|
||||
if (readFileSyncByPath(executorFileUrl) !== result) {
|
||||
await Editor.Message.request('asset-db', 'create-asset', executorFileUrl, result, {
|
||||
overwrite: true
|
||||
});
|
||||
}
|
||||
}
|
||||
let timer = null;
|
||||
function callUpdateExecutor(clear = false) {
|
||||
if (timer)
|
||||
return;
|
||||
if (clear) {
|
||||
clearExecutor();
|
||||
callUpdateExecutor(false);
|
||||
}
|
||||
else {
|
||||
timer = setTimeout(() => {
|
||||
updateExecutor().finally(() => {
|
||||
timer = null;
|
||||
});
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
// 获得Creator主窗口
|
||||
function getMainWebContents() {
|
||||
const windows = electron.BrowserWindow.getAllWindows();
|
||||
for (let i = 0; i < windows.length; i++) {
|
||||
const win = windows[i];
|
||||
if (win.webContents.getURL().includes('windows/main.html') || (win.title && win.title.includes('Cocos Creator'))) {
|
||||
return win.webContents;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
function updateMark() {
|
||||
const webContents = getMainWebContents();
|
||||
if (webContents) {
|
||||
const hackCode = fs_1.readFileSync(path_1.default.join(__dirname, '../res/mark.js'), 'utf-8');
|
||||
webContents.executeJavaScript(hackCode);
|
||||
}
|
||||
}
|
||||
exports.methods = {
|
||||
['open-panel']() {
|
||||
Editor.Panel.open('app.open-panel');
|
||||
},
|
||||
['open-wiki']() {
|
||||
const url = 'https://gitee.com/cocos2d-zp/xforge/wikis/pages';
|
||||
Editor.Message.send('program', 'open-url', url);
|
||||
},
|
||||
['open-issues']() {
|
||||
const url = 'https://gitee.com/cocos2d-zp/xforge/issues';
|
||||
Editor.Message.send('program', 'open-url', url);
|
||||
},
|
||||
['open-github']() {
|
||||
const url = 'https://github.com/a1076559139/XForge';
|
||||
Editor.Message.send('program', 'open-url', url);
|
||||
},
|
||||
['open-store']() {
|
||||
const url = 'https://store.cocos.com/app/search?name=xforge';
|
||||
Editor.Message.send('program', 'open-url', url);
|
||||
},
|
||||
['refresh-executor']() {
|
||||
// 点击更新
|
||||
callUpdateExecutor();
|
||||
console.log('[executor.ts] 刷新成功');
|
||||
},
|
||||
['scene:ready']() {
|
||||
//
|
||||
},
|
||||
['asset-db:ready']() {
|
||||
updateExecutor();
|
||||
updateMark();
|
||||
},
|
||||
['asset-db:asset-add'](uuid, info) {
|
||||
if (!isExecutor(info))
|
||||
return;
|
||||
callUpdateExecutor();
|
||||
},
|
||||
['asset-db:asset-change'](uuid, info) {
|
||||
if (!isExecutor(info, false))
|
||||
return;
|
||||
callUpdateExecutor();
|
||||
},
|
||||
['asset-db:asset-delete'](uuid, info) {
|
||||
if (!isExecutor(info))
|
||||
return;
|
||||
callUpdateExecutor(true);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* @en Hooks triggered after extension loading is complete
|
||||
* @zh 扩展加载完成后触发的钩子
|
||||
*/
|
||||
function load() {
|
||||
Editor.Message.request('asset-db', 'query-ready').then(ready => {
|
||||
if (!ready)
|
||||
return;
|
||||
updateExecutor();
|
||||
});
|
||||
}
|
||||
exports.load = load;
|
||||
/**
|
||||
* @en Hooks triggered after extension uninstallation is complete
|
||||
* @zh 扩展卸载完成后触发的钩子
|
||||
*/
|
||||
function unload() { }
|
||||
exports.unload = unload;
|
||||
38
extensions/app/engine/dist/menu/index.js
vendored
Normal file
38
extensions/app/engine/dist/menu/index.js
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.onAssetMenu = exports.onPanelMenu = exports.onDBMenu = exports.onCreateMenu = void 0;
|
||||
const tinyPNG_1 = __importDefault(require("./tinyPNG"));
|
||||
function getMenu(assetInfo) {
|
||||
return [
|
||||
{
|
||||
label: 'i18n:app.app',
|
||||
submenu: [
|
||||
{
|
||||
label: 'i18n:app.tiny',
|
||||
click() {
|
||||
tinyPNG_1.default(assetInfo.file);
|
||||
},
|
||||
}
|
||||
],
|
||||
},
|
||||
];
|
||||
}
|
||||
function onCreateMenu(assetInfo) {
|
||||
// return getMenu();
|
||||
}
|
||||
exports.onCreateMenu = onCreateMenu;
|
||||
function onDBMenu(assetInfo) {
|
||||
// return getMenu();
|
||||
}
|
||||
exports.onDBMenu = onDBMenu;
|
||||
function onPanelMenu(assetInfo) {
|
||||
// return getMenu();
|
||||
}
|
||||
exports.onPanelMenu = onPanelMenu;
|
||||
function onAssetMenu(assetInfo) {
|
||||
return getMenu(assetInfo);
|
||||
}
|
||||
exports.onAssetMenu = onAssetMenu;
|
||||
164
extensions/app/engine/dist/menu/tinyPNG.js
vendored
Normal file
164
extensions/app/engine/dist/menu/tinyPNG.js
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
"use strict";
|
||||
/**
|
||||
*
|
||||
* 参考: https://segmentfault.com/a/1190000015467084
|
||||
* 优化:通过 X-Forwarded-For 添加了动态随机伪IP,绕过 tinypng 的上传数量限制
|
||||
*
|
||||
*/
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const https_1 = __importDefault(require("https"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const url_1 = require("url");
|
||||
const exts = ['.png', '.jpg', '.jpeg'];
|
||||
const max = 5200000; // 5MB == 5242848.754299136
|
||||
const options = {
|
||||
method: 'POST',
|
||||
hostname: 'tinypng.com',
|
||||
path: '/backend/opt/shrink',
|
||||
headers: {
|
||||
'rejectUnauthorized': 'false',
|
||||
'Postman-Token': Date.now(),
|
||||
'Cache-Control': 'no-cache',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36'
|
||||
}
|
||||
};
|
||||
// 生成随机IP, 赋值给 X-Forwarded-For
|
||||
function getRandomIP() {
|
||||
return Array.from(Array(4)).map(() => Math.floor(Math.random() * 255)).join('.');
|
||||
}
|
||||
// 遍历文件列表
|
||||
function fileEach(folder, callback) {
|
||||
fs_1.default.readdir(folder, (err, files) => {
|
||||
if (err)
|
||||
console.error(err);
|
||||
files.forEach(file => {
|
||||
const filePath = path_1.default.join(folder, file);
|
||||
fs_1.default.stat(filePath, (err, stats) => {
|
||||
if (err)
|
||||
return console.error(err);
|
||||
if (stats.isDirectory()) {
|
||||
fileEach(filePath, callback);
|
||||
}
|
||||
else if (
|
||||
// 必须是文件,小于5MB,后缀 jpg||png
|
||||
stats.size <= max &&
|
||||
stats.isFile() &&
|
||||
exts.includes(path_1.default.extname(file))) {
|
||||
callback(filePath);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
// 压缩图片
|
||||
async function fileUpload(img_path) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// 通过 X-Forwarded-For 头部伪造客户端IP
|
||||
options.headers['X-Forwarded-For'] = getRandomIP();
|
||||
const req = https_1.default.request(options, function (res) {
|
||||
res.on('data', buf => {
|
||||
const data = JSON.parse(buf.toString());
|
||||
if (data.error) {
|
||||
reject(data.message);
|
||||
}
|
||||
else {
|
||||
resolve(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
req.write(fs_1.default.readFileSync(img_path), 'binary');
|
||||
req.on('error', err => {
|
||||
reject(err);
|
||||
});
|
||||
req.end();
|
||||
});
|
||||
}
|
||||
// 该方法被循环调用,请求图片数据
|
||||
function fileUpdate(img_path, obj) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const options = new url_1.URL(obj.output.url);
|
||||
const req = https_1.default.request(options, res => {
|
||||
let body = '';
|
||||
res.setEncoding('binary');
|
||||
res.on('data', function (data) {
|
||||
body += data;
|
||||
});
|
||||
res.on('end', function () {
|
||||
fs_1.default.writeFile(img_path, body, 'binary', err => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
resolve(obj);
|
||||
});
|
||||
});
|
||||
});
|
||||
req.on('error', err => {
|
||||
reject(err);
|
||||
});
|
||||
req.end();
|
||||
});
|
||||
}
|
||||
// 根据字节大小转成B、KB、MB
|
||||
function toSize(b) {
|
||||
if (b < 1024) {
|
||||
return b + 'B';
|
||||
}
|
||||
else if (b < 1024 * 1024) {
|
||||
return (b / 1024).toFixed(2) + 'KB';
|
||||
}
|
||||
else {
|
||||
return (b / 1024 / 1024).toFixed(2) + 'MB';
|
||||
}
|
||||
}
|
||||
// 根据小数转成百分比字符串
|
||||
function toPercent(num) {
|
||||
return (num * 100).toFixed(2) + '%';
|
||||
}
|
||||
async function fileTiny(filePath) {
|
||||
return fileUpload(filePath)
|
||||
.then(obj => fileUpdate(filePath, obj));
|
||||
}
|
||||
function default_1(folder) {
|
||||
// 路径是否存在
|
||||
if (!fs_1.default.existsSync(folder)) {
|
||||
console.log(`路径不存在:${folder}`);
|
||||
return;
|
||||
}
|
||||
const basename = path_1.default.basename(folder);
|
||||
console.log(`[${basename}] 压缩中...`);
|
||||
// 是文件
|
||||
if (!fs_1.default.statSync(folder).isDirectory()) {
|
||||
if (!exts.includes(path_1.default.extname(folder))) {
|
||||
console.log(`[${basename}] 压缩失败!报错:只支持png、jpg与jpeg格式`);
|
||||
return;
|
||||
}
|
||||
fileTiny(folder)
|
||||
.then(obj => {
|
||||
console.log('[1/1]', `[${basename}]`, `压缩成功,原始: ${toSize(obj.input.size)},压缩: ${toSize(obj.output.size)},压缩比: ${toPercent(obj.output.ratio)}`);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log('[1/1]', `[${basename}]`, `压缩失败!报错:${err}`);
|
||||
});
|
||||
return;
|
||||
}
|
||||
let total = 0;
|
||||
let finished = 0;
|
||||
// 是文件夹
|
||||
fileEach(folder, (filePath => {
|
||||
total++;
|
||||
const relativePath = path_1.default.relative(folder, filePath);
|
||||
fileTiny(filePath)
|
||||
.then(obj => {
|
||||
console.log(`[${++finished}/${total}]`, `[${relativePath}]`, `压缩成功,原始: ${toSize(obj.input.size)},压缩: ${toSize(obj.output.size)},压缩比: ${toPercent(obj.output.ratio)}`);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(`[${++finished}/${total}]`, `[${relativePath}]`, `压缩失败!报错:${err}`);
|
||||
});
|
||||
}));
|
||||
}
|
||||
exports.default = default_1;
|
||||
31
extensions/app/engine/dist/panel/components/app-create.js
vendored
Normal file
31
extensions/app/engine/dist/panel/components/app-create.js
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs_1 = require("fs");
|
||||
const path_1 = require("path");
|
||||
const vue_1 = __importDefault(require("../../../../vue"));
|
||||
const create_controller_1 = __importDefault(require("./create-controller"));
|
||||
const create_manager_1 = __importDefault(require("./create-manager"));
|
||||
const create_model_1 = __importDefault(require("./create-model"));
|
||||
const create_res_1 = __importDefault(require("./create-res"));
|
||||
const create_sound_1 = __importDefault(require("./create-sound"));
|
||||
const create_view_1 = __importDefault(require("./create-view"));
|
||||
const Assets = path_1.join(__dirname, '../../../res/panel');
|
||||
const Menus = ['ViewComponent', 'ManagerComponent', 'ControllerComponent', 'ModelComponent', 'SoundComponent', 'ResComponent'];
|
||||
exports.default = vue_1.default.extend({
|
||||
components: { ViewComponent: create_view_1.default, ManagerComponent: create_manager_1.default, ControllerComponent: create_controller_1.default, ModelComponent: create_model_1.default, SoundComponent: create_sound_1.default, ResComponent: create_res_1.default },
|
||||
template: fs_1.readFileSync(path_1.join(Assets, 'components/app.html'), 'utf-8'),
|
||||
data() {
|
||||
return {
|
||||
menus: ['View', 'Manager', 'Controller', 'Model', 'Sound', '资源目录'],
|
||||
content: 'ViewComponent'
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
onClick(index) {
|
||||
this.content = Menus[index];
|
||||
}
|
||||
},
|
||||
});
|
||||
31
extensions/app/engine/dist/panel/components/app.js
vendored
Normal file
31
extensions/app/engine/dist/panel/components/app.js
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs_1 = require("fs");
|
||||
const path_1 = require("path");
|
||||
const vue_1 = __importDefault(require("../../../../vue"));
|
||||
const create_controller_1 = __importDefault(require("./create-controller"));
|
||||
const create_manager_1 = __importDefault(require("./create-manager"));
|
||||
const create_model_1 = __importDefault(require("./create-model"));
|
||||
const create_res_1 = __importDefault(require("./create-res"));
|
||||
const create_sound_1 = __importDefault(require("./create-sound"));
|
||||
const create_view_1 = __importDefault(require("./create-view"));
|
||||
const Assets = path_1.join(__dirname, '../../../res/panel');
|
||||
const Menus = ['ViewComponent', 'ManagerComponent', 'ControllerComponent', 'ModelComponent', 'SoundComponent', 'ResComponent'];
|
||||
exports.default = vue_1.default.extend({
|
||||
components: { ViewComponent: create_view_1.default, ManagerComponent: create_manager_1.default, ControllerComponent: create_controller_1.default, ModelComponent: create_model_1.default, SoundComponent: create_sound_1.default, ResComponent: create_res_1.default },
|
||||
template: fs_1.readFileSync(path_1.join(Assets, 'components/app.html'), 'utf-8'),
|
||||
data() {
|
||||
return {
|
||||
menus: ['View', 'Manager', 'Controller', 'Model', 'Sound', '资源目录'],
|
||||
content: 'ViewComponent'
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
onClick(index) {
|
||||
this.content = Menus[index];
|
||||
}
|
||||
},
|
||||
});
|
||||
83
extensions/app/engine/dist/panel/components/create-controller.js
vendored
Normal file
83
extensions/app/engine/dist/panel/components/create-controller.js
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs_1 = require("fs");
|
||||
const vue_1 = __importDefault(require("../../../../vue"));
|
||||
const utils_1 = require("../../utils");
|
||||
/**
|
||||
* 根据语言获取脚本内容
|
||||
*/
|
||||
function getScript(name) {
|
||||
const basePath = '../../../extensions/app/assets/base/BaseController';
|
||||
return 'import BaseController from \'' + basePath + '\';\r\n' +
|
||||
'export class ' + name + ' extends BaseController<' + name + ', {\r\n' +
|
||||
' // 定义了事件,并同时定义参数列表和返回值\r\n' +
|
||||
' Refresh: (a: number) => boolean\r\n' +
|
||||
'}>() {\r\n' +
|
||||
' // Controller中发射事件, UI中监听事件:\r\n' +
|
||||
' // 1、UI中需要将 「extends BaseView」 改为=> 「extends BaseView.bindController(' + name + ')」\r\n' +
|
||||
' // 2、UI中使用「this.controller.on/once」监听事件, 使用「this.controller.emit」发射事件, 使用「this.controller.off/targetOff」取消监听事件\r\n' +
|
||||
' // 3、在外部(无法使用this.controller的地方)可以通过「app.controller.xxx」来调用对外导出的方法, 比如下面的refresh方法\r\n' +
|
||||
' refresh() {\r\n' +
|
||||
' this.emit(' + name + '.Event.Refresh, 1000); // 参数类型正确\r\n' +
|
||||
' this.emit(' + name + '.Event.Refresh, true); // 参数类型错误\r\n' +
|
||||
' const result = this.call(' + name + '.Event.Refresh, 1000); // 自动推导返回值类型\r\n' +
|
||||
' }\r\n' +
|
||||
'}';
|
||||
}
|
||||
exports.default = vue_1.default.extend({
|
||||
template: utils_1.getResPanel('create-controller'),
|
||||
data() {
|
||||
return {
|
||||
inputName: '',
|
||||
display: '',
|
||||
showLoading: false
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
async onClickCreate() {
|
||||
const name = this.inputName;
|
||||
if (/^[a-z][a-z0-9-]*[a-z0-9]+$/.test(name) === false) {
|
||||
this.display = '[错误] 名字不合法\n1、不能以数字开头\n2、不能有大写字母\n3、分隔符只能使用-\n4、不能以分隔符开头或结尾';
|
||||
return;
|
||||
}
|
||||
const rootPath = 'db://assets/app-builtin/app-controller';
|
||||
const controlName = `${utils_1.stringCase(name)}Controller`;
|
||||
const scriptUrl = `${rootPath}/${controlName}.ts`;
|
||||
// 创建前确认
|
||||
const createResponse = await Editor.Dialog.info('请确认', { detail: controlName, buttons: ['创建并打开', '仅创建', '取消'], default: 0, cancel: 2 });
|
||||
if (createResponse.response == 2) {
|
||||
return;
|
||||
}
|
||||
this.display = '创建中';
|
||||
this.showLoading = true;
|
||||
if (fs_1.existsSync(utils_1.convertUrlToPath(scriptUrl))) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 文件已存在, 请删除\n${scriptUrl}`;
|
||||
return;
|
||||
}
|
||||
// 目录如果不存在则创建
|
||||
if (!await utils_1.createFolderByUrl(rootPath, { meta: utils_1.getResMeta('app-controller'), readme: utils_1.getResReadme('app-controller') })) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 创建目录失败\n${rootPath}`;
|
||||
return;
|
||||
}
|
||||
// 创建script
|
||||
const createScriptResult = await Editor.Message.request('asset-db', 'create-asset', scriptUrl, getScript(controlName)).catch(_ => null);
|
||||
if (!createScriptResult) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 创建脚本失败\n${scriptUrl}`;
|
||||
return;
|
||||
}
|
||||
this.showLoading = false;
|
||||
this.display = `[成功] 创建成功\n${rootPath}`;
|
||||
Editor.Message.send('assets', 'twinkle', scriptUrl);
|
||||
// 是否打开
|
||||
if (createResponse.response == 0) {
|
||||
Editor.Message.request('asset-db', 'open-asset', scriptUrl);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
107
extensions/app/engine/dist/panel/components/create-manager.js
vendored
Normal file
107
extensions/app/engine/dist/panel/components/create-manager.js
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs_1 = require("fs");
|
||||
const vue_1 = __importDefault(require("../../../../vue"));
|
||||
const utils_1 = require("../../utils");
|
||||
/**
|
||||
* 根据语言获取脚本内容
|
||||
*/
|
||||
function getScript(name) {
|
||||
const basePath = '../../../../extensions/app/assets/base/BaseManager';
|
||||
return 'import { _decorator } from \'cc\';\r\n' +
|
||||
'import BaseManager from \'' + basePath + '\';\r\n' +
|
||||
'const { ccclass, property } = _decorator;\r\n' +
|
||||
'@ccclass(\'' + name + '\')\r\n' +
|
||||
'export class ' + name + ' extends BaseManager {\r\n' +
|
||||
' // [无序] 加载完成时触发\r\n' +
|
||||
' protected onLoad() { }\r\n\r\n' +
|
||||
' // [无序] 自身初始化完成, init执行完毕后被调用\r\n' +
|
||||
' protected onInited() { }\r\n\r\n' +
|
||||
' // [无序] 所有manager初始化完成\r\n' +
|
||||
' protected onFinished() { }\r\n\r\n' +
|
||||
' // [无序] 初始化manager,在初始化完成后,调用finish方法\r\n' +
|
||||
' protected init(finish: Function) {\r\n' +
|
||||
' super.init(finish);\r\n' +
|
||||
' }\r\n' +
|
||||
'}';
|
||||
}
|
||||
exports.default = vue_1.default.extend({
|
||||
template: utils_1.getResPanel('create-manager'),
|
||||
data() {
|
||||
return {
|
||||
inputName: '',
|
||||
display: '',
|
||||
showLoading: false
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
async onClickCreate() {
|
||||
const name = this.inputName;
|
||||
if (/^[a-z][a-z0-9-]*[a-z0-9]+$/.test(name) === false) {
|
||||
this.display = '[错误] 名字不合法\n1、不能以数字开头\n2、不能有大写字母\n3、分隔符只能使用-\n4、不能以分隔符开头或结尾';
|
||||
return;
|
||||
}
|
||||
const rootPath = 'db://assets/app-builtin/app-manager';
|
||||
const managerName = `${utils_1.stringCase(name)}Manager`;
|
||||
const folderName = name;
|
||||
const folderPath = `${rootPath}/${folderName}`;
|
||||
const scriptUrl = `${folderPath}/${managerName}.ts`;
|
||||
const prefabUrl = `${folderPath}/${managerName}.prefab`;
|
||||
// 创建前确认
|
||||
const createResponse = await Editor.Dialog.info('请确认', { detail: managerName, buttons: ['创建并打开', '仅创建', '取消'], default: 0, cancel: 2 });
|
||||
if (createResponse.response == 2) {
|
||||
return;
|
||||
}
|
||||
this.display = '创建中';
|
||||
this.showLoading = true;
|
||||
if (fs_1.existsSync(utils_1.convertUrlToPath(folderPath))) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 目录已存在, 请删除\n${folderPath}`;
|
||||
return;
|
||||
}
|
||||
// 目录如果不存在则创建
|
||||
if (!await utils_1.createFolderByUrl(rootPath, {
|
||||
meta: utils_1.getResMeta('app-manager'),
|
||||
readme: utils_1.getResReadme('app-manager'),
|
||||
subFolders: [
|
||||
{
|
||||
folder: folderName,
|
||||
readme: `1、${managerName}所在文件夹, 通过app.manager.${utils_1.stringCase(name, true)}的方式调用\n2、如不再需要,可以直接删除此文件夹`
|
||||
}
|
||||
]
|
||||
})) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 创建目录失败\n${folderPath}`;
|
||||
return;
|
||||
}
|
||||
// 创建script
|
||||
const createScriptResult = await Editor.Message.request('asset-db', 'create-asset', scriptUrl, getScript(managerName)).catch(_ => null);
|
||||
if (!createScriptResult) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 创建脚本失败\n${scriptUrl}`;
|
||||
return;
|
||||
}
|
||||
// 创建prefab
|
||||
const createPrefabResult = await Editor.Message.request('scene', 'execute-scene-script', {
|
||||
name: 'app',
|
||||
method: 'createPrefab',
|
||||
args: [managerName, prefabUrl]
|
||||
});
|
||||
if (!createPrefabResult) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 创建预制体失败\n${prefabUrl}`;
|
||||
return;
|
||||
}
|
||||
this.showLoading = false;
|
||||
this.display = `[成功] 创建成功\n${rootPath}`;
|
||||
Editor.Message.send('assets', 'twinkle', scriptUrl);
|
||||
// 是否打开
|
||||
if (createResponse.response == 0) {
|
||||
Editor.Message.request('asset-db', 'open-asset', scriptUrl);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
105
extensions/app/engine/dist/panel/components/create-model.js
vendored
Normal file
105
extensions/app/engine/dist/panel/components/create-model.js
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs_1 = require("fs");
|
||||
const vue_1 = __importDefault(require("../../../../vue"));
|
||||
const utils_1 = require("../../utils");
|
||||
/**
|
||||
* 根据语言获取脚本内容
|
||||
*/
|
||||
function getScript(type, className) {
|
||||
if (type === 'data') {
|
||||
const BaseModel = '../../../extensions/app/assets/base/BaseModel';
|
||||
return 'import { IModel } from \'' + BaseModel + '\';\r\n' +
|
||||
'// data中不能定义任何方法(更建议使用store)\r\n' +
|
||||
'export default class ' + className + ' implements IModel<' + className + '> {\r\n' +
|
||||
'}';
|
||||
}
|
||||
else if (type === 'config') {
|
||||
const BaseModel = '../../../extensions/app/assets/base/BaseModel';
|
||||
return 'import { IModel } from \'' + BaseModel + '\';\r\n' +
|
||||
'// config中不能定义任何方法, 任何变量在外部访问都是readonly\r\n' +
|
||||
'// 如果config中的内容是服务器下发的,可以使用Object.assign覆盖config中的内容\r\n' +
|
||||
'export default class ' + className + ' implements IModel<' + className + '> {\r\n' +
|
||||
'}';
|
||||
}
|
||||
else if (type === 'store') {
|
||||
const BaseModel = '../../../extensions/app/assets/base/BaseModel';
|
||||
return 'import { IStore } from \'' + BaseModel + '\';\r\n' +
|
||||
'// store中只允许在根路径下定义方法,任何变量在外部访问都是readonly\r\n' +
|
||||
'// store类型的引入是借鉴了Web前端框架中全局状态管理的思路,意图是让数据更安全,更可控。同时框架中还提供了数据绑定的扩展包,可以通过pkg的方式安装,实现「数据->视图」的单向绑定。\r\n' +
|
||||
'export default class ' + className + ' implements IStore<' + className + '> {\r\n' +
|
||||
' count = 0;\r\n' +
|
||||
' setCount(v: number) {\r\n' +
|
||||
' this.count = v;\r\n' +
|
||||
' }\r\n' +
|
||||
'}';
|
||||
}
|
||||
else {
|
||||
return '// 🔥切记: 当前文件处于分包中, 由于加载顺序的原因,不可以在「主包」中使用此文件内导出的变量\r\n' +
|
||||
'// 存放直接导出的interface、type或enum等\r\n\r\n' +
|
||||
'// export type IString = string;\r\n' +
|
||||
'// export enum Type { None };';
|
||||
}
|
||||
}
|
||||
exports.default = vue_1.default.extend({
|
||||
template: utils_1.getResPanel('create-model'),
|
||||
data() {
|
||||
return {
|
||||
inputName: '',
|
||||
display: '',
|
||||
typeSelects: ['store', 'data', 'config', 'export'],
|
||||
typeSelectIndex: 0,
|
||||
showLoading: false
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
onChangeTypeSelect(index) {
|
||||
this.typeSelectIndex = Number(index);
|
||||
},
|
||||
async onClickCreate() {
|
||||
const type = this.typeSelects[this.typeSelectIndex];
|
||||
const name = this.inputName;
|
||||
if (/^[a-z][a-z0-9-]*[a-z0-9]+$/.test(name) === false) {
|
||||
this.display = '[错误] 名字不合法\n1、不能以数字开头\n2、不能有大写字母\n3、分隔符只能使用-\n4、不能以分隔符开头或结尾';
|
||||
return;
|
||||
}
|
||||
const rootPath = 'db://assets/app-builtin/app-model';
|
||||
const modelName = `${type}.${name}`;
|
||||
const scriptUrl = `${rootPath}/${modelName}.ts`;
|
||||
// 创建前确认
|
||||
const createResponse = await Editor.Dialog.info('请确认', { detail: modelName, buttons: ['创建并打开', '仅创建', '取消'], default: 0, cancel: 2 });
|
||||
if (createResponse.response == 2) {
|
||||
return;
|
||||
}
|
||||
this.display = '创建中';
|
||||
this.showLoading = true;
|
||||
// 目录如果不存在则创建
|
||||
if (!await utils_1.createFolderByUrl(rootPath, { meta: utils_1.getResMeta('app-model'), readme: utils_1.getResReadme('app-model') })) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 创建目录失败\n${rootPath}`;
|
||||
return;
|
||||
}
|
||||
if (fs_1.existsSync(utils_1.convertUrlToPath(scriptUrl))) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 文件已存在, 请删除\n${scriptUrl}`;
|
||||
return;
|
||||
}
|
||||
const createScriptResult = await Editor.Message.request('asset-db', 'create-asset', scriptUrl, getScript(type, utils_1.stringCase(name))).catch(_ => null);
|
||||
if (!createScriptResult) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 创建脚本失败\n${scriptUrl}`;
|
||||
return;
|
||||
}
|
||||
this.showLoading = false;
|
||||
this.display = `[成功] 创建成功\n${rootPath}`;
|
||||
Editor.Message.send('assets', 'twinkle', scriptUrl);
|
||||
// 是否打开
|
||||
if (createResponse.response == 0) {
|
||||
Editor.Message.request('asset-db', 'open-asset', scriptUrl);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
62
extensions/app/engine/dist/panel/components/create-res.js
vendored
Normal file
62
extensions/app/engine/dist/panel/components/create-res.js
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const vue_1 = __importDefault(require("../../../../vue"));
|
||||
const utils_1 = require("../../utils");
|
||||
const typeNames = ['res-native', 'res-bundle', 'resources'];
|
||||
exports.default = vue_1.default.extend({
|
||||
template: utils_1.getResPanel('create-res'),
|
||||
data() {
|
||||
return {
|
||||
inputName: '',
|
||||
display: '',
|
||||
typeSelects: ['公共静态目录', '公共动态目录', 'resources'],
|
||||
typeSelectIndex: 0,
|
||||
showLoading: false
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
onChangeTypeSelect(index) {
|
||||
this.typeSelectIndex = Number(index);
|
||||
},
|
||||
async onClickCreate() {
|
||||
const folderName = typeNames[this.typeSelectIndex];
|
||||
const folderPath = `db://assets/${folderName}`;
|
||||
const name = utils_1.stringCase(this.inputName, true);
|
||||
if (/^[a-z][a-z0-9-]*[a-z0-9]+$/.test(this.inputName) === false) {
|
||||
this.display = '[错误] 名字不合法\n1、不能以数字开头\n2、不能有大写字母\n3、分隔符只能使用-\n4、不能以分隔符开头或结尾';
|
||||
return;
|
||||
}
|
||||
if (name === 'resources') {
|
||||
this.display = '[错误] 名字不合法\n1、不能使用resources作为名字';
|
||||
return;
|
||||
}
|
||||
// 创建前确认
|
||||
const createResponse = await Editor.Dialog.info('请确认', { detail: name, buttons: ['创建', '取消'], default: 0, cancel: 1 });
|
||||
if (createResponse.response == 1) {
|
||||
return;
|
||||
}
|
||||
this.display = '创建中';
|
||||
this.showLoading = true;
|
||||
if (!await utils_1.createFolderByUrl(folderPath, {
|
||||
readme: utils_1.getResReadme(folderName),
|
||||
meta: folderName === 'resources' ? utils_1.getResMeta('resources') : undefined,
|
||||
subFolders: [
|
||||
{
|
||||
folder: name,
|
||||
meta: folderName === 'res-bundle' ? utils_1.getResMeta('custom-bundle') : undefined
|
||||
}
|
||||
]
|
||||
})) {
|
||||
this.showLoading = false;
|
||||
this.display = '[错误] 创建失败';
|
||||
return;
|
||||
}
|
||||
this.showLoading = false;
|
||||
this.display = `[成功] 创建成功\n${folderPath}`;
|
||||
Editor.Message.send('assets', 'twinkle', folderPath);
|
||||
}
|
||||
},
|
||||
});
|
||||
45
extensions/app/engine/dist/panel/components/create-sound.js
vendored
Normal file
45
extensions/app/engine/dist/panel/components/create-sound.js
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const vue_1 = __importDefault(require("../../../../vue"));
|
||||
const utils_1 = require("../../utils");
|
||||
exports.default = vue_1.default.extend({
|
||||
template: utils_1.getResPanel('create-sound'),
|
||||
data() {
|
||||
return {
|
||||
display: '',
|
||||
typeSelects: ['音乐', '音效'],
|
||||
typeSelectIndex: 0,
|
||||
showLoading: false
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
onChangeTypeSelect(index) {
|
||||
this.typeSelectIndex = Number(index);
|
||||
},
|
||||
async onClickCreate() {
|
||||
this.display = '创建中';
|
||||
this.showLoading = true;
|
||||
const rootPath = 'db://assets/app-bundle/app-sound';
|
||||
if (!await utils_1.createFolderByUrl(rootPath, {
|
||||
meta: utils_1.getResMeta('app-sound'),
|
||||
readme: utils_1.getResReadme('app-sound'),
|
||||
subFolders: [
|
||||
{
|
||||
folder: this.typeSelectIndex === 0 ? 'music' : 'effect',
|
||||
readme: utils_1.getResReadme(this.typeSelectIndex === 0 ? 'sound-music' : 'sound-effect')
|
||||
}
|
||||
]
|
||||
})) {
|
||||
this.showLoading = false;
|
||||
this.display = '[错误] 创建失败';
|
||||
return;
|
||||
}
|
||||
this.showLoading = false;
|
||||
this.display = `[成功] 创建成功\n${rootPath}`;
|
||||
Editor.Message.send('assets', 'twinkle', rootPath);
|
||||
}
|
||||
},
|
||||
});
|
||||
249
extensions/app/engine/dist/panel/components/create-view.js
vendored
Normal file
249
extensions/app/engine/dist/panel/components/create-view.js
vendored
Normal file
@@ -0,0 +1,249 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs_1 = require("fs");
|
||||
const path_1 = require("path");
|
||||
const vue_1 = __importDefault(require("../../../../vue"));
|
||||
const utils_1 = require("../../utils");
|
||||
/**
|
||||
* 获取脚本内容
|
||||
*/
|
||||
function getComScript(name = 'NewClass') {
|
||||
const isPage = name.toLowerCase().startsWith('page');
|
||||
const isPaper = name.toLowerCase().startsWith('paper');
|
||||
const basePath = isPaper ? '../../../../../../../extensions/app/assets/base/BaseView' : '../../../../../../extensions/app/assets/base/BaseView';
|
||||
return 'import { _decorator, Node } from \'cc\';\r\n' +
|
||||
'import BaseView from \'' + basePath + '\';\r\n' +
|
||||
`${isPage ? 'import { IMiniViewNames } from \'../../../../../app-builtin/app-admin/executor\';\r\n' : ''}` +
|
||||
'const { ccclass, property } = _decorator;\r\n' +
|
||||
'@ccclass(\'' + name + '\')\r\n' +
|
||||
'export class ' + name + ' extends BaseView {\r\n' +
|
||||
` ${isPage ? '// 子界面列表,数组顺序为子界面排列顺序\r\n' : ''}` +
|
||||
` ${isPage ? 'protected miniViews: IMiniViewNames = [];\r\n\r\n' : '\r\n'}` +
|
||||
' // 初始化的相关逻辑写在这\r\n' +
|
||||
' onLoad() {}\r\n\r\n' +
|
||||
' // 界面打开时的相关逻辑写在这(onShow可被多次调用-它与onHide不成对)\r\n' +
|
||||
' onShow(params: any) {\r\n' +
|
||||
` ${isPage ? 'this.showMiniViews({ views: this.miniViews });' : ''}\r\n` +
|
||||
' }\r\n\r\n' +
|
||||
' // 界面关闭时的相关逻辑写在这(已经关闭的界面不会触发onHide)\r\n' +
|
||||
' onHide(result: undefined) {\r\n' +
|
||||
` ${isPaper ? '' : '// app.manager.ui.show<' + name + '>({name: \'' + name + '\', onHide:(result) => { 接收到return的数据,并且有类型提示 }})\r\n'}` +
|
||||
` ${isPaper ? '' : 'return result;'}\r\n` +
|
||||
' }\r\n' +
|
||||
'}';
|
||||
}
|
||||
function getNaMetaUserData(name = 'new-class') {
|
||||
return Object.assign(Object.assign({}, utils_1.getResMeta('view-native')), { 'bundleName': `${name}` });
|
||||
}
|
||||
function getResMetaUserData(name = 'new-class') {
|
||||
return Object.assign(Object.assign({}, utils_1.getResMeta('view-resources')), { 'bundleName': `${name}-res` });
|
||||
}
|
||||
/**
|
||||
* UI类型(小写)
|
||||
*/
|
||||
const TypeSelects = ['page', 'paper', 'pop', 'top'];
|
||||
/**
|
||||
* 大驼峰UI名(带page前缀) => 串式UI目录名(不带page前缀)
|
||||
*/
|
||||
const PageNames = new Map();
|
||||
function updatePages() {
|
||||
PageNames.clear();
|
||||
// page目录
|
||||
const pageRootPath = path_1.join(Editor.Project.path, 'assets/app-bundle/app-view/page');
|
||||
// 读取page目录下所有文件
|
||||
const folderNames = fs_1.existsSync(pageRootPath) ? fs_1.readdirSync(pageRootPath) : [];
|
||||
// 大驼峰命名的UI名
|
||||
folderNames.forEach((folderName) => {
|
||||
// folderName为串式命名法
|
||||
const pagePath = path_1.join(pageRootPath, folderName);
|
||||
const isDirectory = fs_1.statSync(pagePath).isDirectory();
|
||||
if (isDirectory) {
|
||||
PageNames.set(`Page${utils_1.stringCase(folderName)}`, folderName);
|
||||
}
|
||||
});
|
||||
PageNames.set('通用', 'all');
|
||||
return Array.from(PageNames.keys());
|
||||
}
|
||||
exports.default = vue_1.default.extend({
|
||||
template: utils_1.getResPanel('create-view'),
|
||||
data() {
|
||||
return {
|
||||
showLoading: false,
|
||||
showSelectPage: false,
|
||||
showSelectGroup: true,
|
||||
inputName: '',
|
||||
display: '',
|
||||
typeSelects: TypeSelects,
|
||||
typeSelectIndex: 0,
|
||||
groupSelects: ['2D', '3D'],
|
||||
groupSelectIndex: 0,
|
||||
pageSelects: [],
|
||||
pageSelectIndex: 0,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
onChangeGroupSelect(index) {
|
||||
this.groupSelectIndex = Number(index);
|
||||
},
|
||||
onChangeTypeSelect(index) {
|
||||
this.typeSelectIndex = Number(index);
|
||||
if (index == '0') {
|
||||
this.showSelectGroup = true;
|
||||
}
|
||||
else {
|
||||
this.showSelectGroup = false;
|
||||
}
|
||||
if (index == '1') {
|
||||
this.pageSelectIndex = 0;
|
||||
this.pageSelects = updatePages();
|
||||
this.showSelectPage = true;
|
||||
}
|
||||
else {
|
||||
this.showSelectPage = false;
|
||||
}
|
||||
},
|
||||
onChangePageSelect(index) {
|
||||
this.pageSelectIndex = Number(index);
|
||||
},
|
||||
async onClickCreate() {
|
||||
const isPage = this.typeSelectIndex == 0;
|
||||
const isPaper = this.typeSelectIndex == 1;
|
||||
// ui归属(大驼峰)
|
||||
const owner = this.pageSelects[this.pageSelectIndex];
|
||||
// ui类型(小写)
|
||||
const type = this.typeSelects[this.typeSelectIndex];
|
||||
// ui名字(串式)
|
||||
const name = this.inputName;
|
||||
if (/^[a-z][a-z0-9-]*[a-z0-9]+$/.test(name) === false) {
|
||||
this.display = '[错误] 名字不合法\n1、不能以数字开头\n2、不能有大写字母\n3、分隔符只能使用-\n4、不能以分隔符开头或结尾';
|
||||
return;
|
||||
}
|
||||
if (name === 'all' || name === 'page' || name === 'paper' || name === 'pop' || name === 'top') {
|
||||
this.display = '[错误] 名字不合法\n1、不能使用all、page、paper、pop、top作为名字';
|
||||
return;
|
||||
}
|
||||
const is3D = isPage && this.groupSelectIndex == 1;
|
||||
const ownerName = PageNames.get(owner);
|
||||
const uiName = isPaper ?
|
||||
`${utils_1.stringCase(type)}${utils_1.stringCase(ownerName)}${utils_1.stringCase(name)}` :
|
||||
`${utils_1.stringCase(type)}${utils_1.stringCase(name)}`;
|
||||
const bundleName = isPaper ?
|
||||
`${type}-${ownerName}-${name}` :
|
||||
`${type}-${name}`;
|
||||
const bundleFolderUrl = 'db://assets/app-bundle';
|
||||
const viewFolderUrl = `${bundleFolderUrl}/app-view`;
|
||||
const typeFolderUrl = `${viewFolderUrl}/${type}`;
|
||||
const uiFolderUrl = isPaper ?
|
||||
`${typeFolderUrl}/${ownerName}/${name}` :
|
||||
`${typeFolderUrl}/${name}`;
|
||||
const nativeUrl = `${uiFolderUrl}/native`;
|
||||
const resourcesUrl = `${uiFolderUrl}/resources`;
|
||||
const expansionUrl = `${nativeUrl}/expansion`;
|
||||
const scriptUrl = `${nativeUrl}/${uiName}.ts`;
|
||||
const prefabUrl = `${nativeUrl}/${uiName}.prefab`;
|
||||
const sceneUrl = `${nativeUrl}/${uiName}.scene`;
|
||||
const singleColorUrl = `${resourcesUrl}/singleColor.png`;
|
||||
// 创建前确认
|
||||
const createResponse = await Editor.Dialog.info('请确认', { detail: uiName, buttons: ['创建并打开', '仅创建', '取消'], default: 0, cancel: 2 });
|
||||
if (createResponse.response == 2) {
|
||||
return;
|
||||
}
|
||||
this.display = '创建中';
|
||||
this.showLoading = true;
|
||||
// 创建目录
|
||||
if (!await utils_1.createFolderByUrl(uiFolderUrl, { subPaths: ['native', 'resources', 'native/expansion'] })) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 创建目录失败\n${uiFolderUrl}`;
|
||||
return;
|
||||
}
|
||||
// 设置native分包
|
||||
await utils_1.delayFileExistsByUrl(`${nativeUrl}.meta`);
|
||||
const queryNativeMeta = await Editor.Message.request('asset-db', 'query-asset-meta', nativeUrl).catch(_ => null);
|
||||
if (!queryNativeMeta) {
|
||||
this.showLoading = false;
|
||||
this.display = '[错误] 设置native分包配置失败';
|
||||
return;
|
||||
}
|
||||
queryNativeMeta.userData = getNaMetaUserData(bundleName);
|
||||
await Editor.Message.request('asset-db', 'save-asset-meta', nativeUrl, JSON.stringify(queryNativeMeta)).catch(_ => null);
|
||||
// 设置resources分包
|
||||
await utils_1.delayFileExistsByUrl(`${resourcesUrl}.meta`);
|
||||
const queryResMeta = await Editor.Message.request('asset-db', 'query-asset-meta', resourcesUrl).catch(_ => null);
|
||||
if (!queryResMeta) {
|
||||
this.showLoading = false;
|
||||
this.display = '[错误] 设置resources分包配置失败';
|
||||
return;
|
||||
}
|
||||
queryResMeta.userData = getResMetaUserData(bundleName);
|
||||
await Editor.Message.request('asset-db', 'save-asset-meta', resourcesUrl, JSON.stringify(queryResMeta)).catch(_ => null);
|
||||
fs_1.writeFileSync(path_1.join(utils_1.convertUrlToPath(bundleFolderUrl), '.app-bundle.md'), utils_1.getResReadme('app-bundle'));
|
||||
fs_1.writeFileSync(path_1.join(utils_1.convertUrlToPath(viewFolderUrl), '.app-view.md'), utils_1.getResReadme('app-view'));
|
||||
fs_1.writeFileSync(path_1.join(utils_1.convertUrlToPath(typeFolderUrl), `.${type}.md`), `1、所有${type}类型UI的根目录\n2、如不再需要,可以直接删除此文件夹`);
|
||||
fs_1.writeFileSync(path_1.join(utils_1.convertUrlToPath(nativeUrl), '.native.md'), utils_1.getResReadme('view-native'));
|
||||
fs_1.writeFileSync(path_1.join(utils_1.convertUrlToPath(resourcesUrl), '.resources.md'), utils_1.getResReadme('view-resources'));
|
||||
fs_1.writeFileSync(path_1.join(utils_1.convertUrlToPath(expansionUrl), '.expansion.md'), utils_1.getResReadme('view-expansion'));
|
||||
if (isPaper) {
|
||||
fs_1.writeFileSync(path_1.join(utils_1.convertUrlToPath(`${typeFolderUrl}/${ownerName}`), `.${ownerName}.md`), (ownerName === 'all' ? '1、归属于全体Page' : `1、归属于Page${utils_1.stringCase(ownerName)}`) + '\n2、如不再需要,可以直接删除此文件夹');
|
||||
fs_1.writeFileSync(path_1.join(utils_1.convertUrlToPath(uiFolderUrl), `.${name}.md`), `${uiName}所在文件夹\n1、通过${ownerName === 'all' ? '在任意Page中配置miniViews属性并调用showMiniViews方法' : `在${owner}中配置miniViews属性并调用showMiniViews方法`}的方式加载\n2、如不再需要,可以直接删除此文件夹`);
|
||||
}
|
||||
else {
|
||||
fs_1.writeFileSync(path_1.join(utils_1.convertUrlToPath(uiFolderUrl), `.${name}.md`), `${uiName}所在文件夹\n1、通过app.manager.ui.show({ name:'${uiName}' })的方式加载\n2、如不再需要,可以直接删除此文件夹`);
|
||||
}
|
||||
// 创建script
|
||||
if (!fs_1.existsSync(utils_1.convertUrlToPath(scriptUrl))) {
|
||||
const createScriptResult = await Editor.Message.request('asset-db', 'create-asset', scriptUrl, getComScript(uiName)).catch(_ => null);
|
||||
if (!createScriptResult) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 创建脚本失败\n${scriptUrl}`;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// 创建view
|
||||
if (!fs_1.existsSync(utils_1.convertUrlToPath(prefabUrl)) && !fs_1.existsSync(utils_1.convertUrlToPath(sceneUrl))) {
|
||||
if (is3D && isPage) {
|
||||
const createSceneResult = await Editor.Message.request('scene', 'execute-scene-script', {
|
||||
name: 'app',
|
||||
method: 'createScene',
|
||||
args: [uiName, sceneUrl]
|
||||
}).catch(_ => null);
|
||||
if (!createSceneResult) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 创建场景失败\n${sceneUrl}`;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
const createPrefabResult = await Editor.Message.request('scene', 'execute-scene-script', {
|
||||
name: 'app',
|
||||
method: 'createPrefab',
|
||||
args: [uiName, prefabUrl, is3D]
|
||||
}).catch(_ => null);
|
||||
if (!createPrefabResult) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 创建预制体失败\n${prefabUrl}`;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.showLoading = false;
|
||||
this.display = `[成功] 创建成功\n${uiFolderUrl}`;
|
||||
Editor.Message.send('assets', 'twinkle', scriptUrl);
|
||||
// 是否打开
|
||||
if (createResponse.response == 0) {
|
||||
if (is3D) {
|
||||
Editor.Message.request('asset-db', 'open-asset', sceneUrl);
|
||||
}
|
||||
else {
|
||||
Editor.Message.request('asset-db', 'open-asset', prefabUrl);
|
||||
}
|
||||
Editor.Message.request('asset-db', 'open-asset', scriptUrl);
|
||||
}
|
||||
const base64 = 'iVBORw0KGgoAAAANSUhEUgAAAAIAAAACAQMAAABIeJ9nAAAAA1BMVEX///+nxBvIAAAACklEQVQI12MAAgAABAABINItbwAAAABJRU5ErkJggg==';
|
||||
fs_1.writeFileSync(utils_1.convertUrlToPath(singleColorUrl), new Buffer(base64, 'base64'));
|
||||
Editor.Message.request('asset-db', 'refresh-asset', singleColorUrl).catch(_ => null);
|
||||
}
|
||||
}
|
||||
});
|
||||
29
extensions/app/engine/dist/panel/index.js
vendored
Normal file
29
extensions/app/engine/dist/panel/index.js
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs_1 = require("fs");
|
||||
const path_1 = require("path");
|
||||
const Assets = path_1.join(__dirname, '../../res/panel');
|
||||
const app_1 = __importDefault(require("./components/app"));
|
||||
module.exports = Editor.Panel.define({
|
||||
template: fs_1.readFileSync(path_1.join(Assets, 'index.html'), 'utf-8'),
|
||||
style: fs_1.readFileSync(path_1.join(Assets, 'styles/index.css'), 'utf-8'),
|
||||
$: {
|
||||
app: '#app'
|
||||
},
|
||||
listeners: {
|
||||
show() { console.log('show'); },
|
||||
hide() { console.log('hide'); },
|
||||
},
|
||||
methods: {},
|
||||
ready() {
|
||||
if (!this.$.app)
|
||||
return;
|
||||
const com = new app_1.default();
|
||||
com.$mount(this.$.app);
|
||||
},
|
||||
beforeClose() { },
|
||||
close() { },
|
||||
});
|
||||
73
extensions/app/engine/dist/scene.js
vendored
Normal file
73
extensions/app/engine/dist/scene.js
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.methods = exports.unload = exports.load = void 0;
|
||||
const path_1 = require("path");
|
||||
module.paths.push(path_1.join(Editor.App.path, 'node_modules'));
|
||||
function load() { }
|
||||
exports.load = load;
|
||||
function unload() { }
|
||||
exports.unload = unload;
|
||||
// 在其他扩展脚本中,我们可以使用如下代码调用 rotateCamera 函数
|
||||
// const options: ExecuteSceneScriptMethodOptions = {
|
||||
// name: scene.ts 所在的扩展包名, 如: App,
|
||||
// method: scene.ts 中定义的方法, 如: rotateCamera,
|
||||
// args: 参数,可选, 只传递json
|
||||
// };
|
||||
// const result = await Editor.Message.request('scene', 'execute-scene-script', options);
|
||||
exports.methods = {
|
||||
async createPrefab(fileName, fileUrl, is3D = false) {
|
||||
const { Node, js, Layers } = require('cc');
|
||||
const node = new Node(fileName);
|
||||
node.layer = is3D ? Layers.Enum.UI_3D : Layers.Enum.UI_2D;
|
||||
while (true) {
|
||||
const result = js.getClassByName(fileName);
|
||||
if (result)
|
||||
break;
|
||||
await new Promise((next) => {
|
||||
setTimeout(next, 100);
|
||||
});
|
||||
}
|
||||
const com = node.addComponent(fileName);
|
||||
com.resetInEditor && com.resetInEditor();
|
||||
const info = cce.Prefab.generatePrefabDataFromNode(node);
|
||||
node.destroy();
|
||||
return Editor.Message.request('asset-db', 'create-asset', fileUrl, info.prefabData || info);
|
||||
},
|
||||
async createScene(fileName, fileUrl) {
|
||||
const { SceneAsset, Scene, Node, js, Layers, Camera, DirectionalLight } = require('cc');
|
||||
while (true) {
|
||||
const result = js.getClassByName(fileName);
|
||||
if (result)
|
||||
break;
|
||||
await new Promise((next) => {
|
||||
setTimeout(next, 100);
|
||||
});
|
||||
}
|
||||
const scene = new Scene(fileName);
|
||||
// 根节点
|
||||
const node = new Node(fileName);
|
||||
node.layer = Layers.Enum.DEFAULT;
|
||||
node.parent = scene;
|
||||
// 相机
|
||||
const camera = new Node('Camera');
|
||||
camera.addComponent(Camera);
|
||||
camera.layer = Layers.Enum.DEFAULT;
|
||||
camera.parent = node;
|
||||
// 灯光
|
||||
const light = new Node('Light');
|
||||
light.addComponent(DirectionalLight);
|
||||
light.layer = Layers.Enum.DEFAULT;
|
||||
light.parent = node;
|
||||
const com = node.addComponent(fileName);
|
||||
com.resetInEditor && com.resetInEditor();
|
||||
const sceneAsset = new SceneAsset();
|
||||
sceneAsset.scene = scene;
|
||||
const info = EditorExtends.serialize(sceneAsset);
|
||||
camera.destroy();
|
||||
light.destroy();
|
||||
node.destroy();
|
||||
scene.destroy();
|
||||
sceneAsset.destroy();
|
||||
return Editor.Message.request('asset-db', 'create-asset', fileUrl, info);
|
||||
},
|
||||
};
|
||||
190
extensions/app/engine/dist/utils.js
vendored
Normal file
190
extensions/app/engine/dist/utils.js
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.delayFileExistsByUrl = exports.delay = exports.createFolderByUrl = exports.getProjectPath = exports.convertUrlToPath = exports.stringCaseNegate = exports.stringCase = exports.getResPanel = exports.getResMeta = exports.getResReadme = exports.getResJson = void 0;
|
||||
const fs_1 = require("fs");
|
||||
const path_1 = require("path");
|
||||
function getResJson(name) {
|
||||
const Assets = path_1.join(__dirname, '../res/json');
|
||||
const str = fs_1.readFileSync(path_1.join(Assets, `${name}.json`), 'utf-8');
|
||||
return str ? JSON.parse(str) : null;
|
||||
}
|
||||
exports.getResJson = getResJson;
|
||||
function getResReadme(name) {
|
||||
const Assets = path_1.join(__dirname, '../res/readme');
|
||||
return fs_1.readFileSync(path_1.join(Assets, `${name}.md`), 'utf-8');
|
||||
}
|
||||
exports.getResReadme = getResReadme;
|
||||
function getResMeta(name) {
|
||||
const Assets = path_1.join(__dirname, '../res/meta');
|
||||
const str = fs_1.readFileSync(path_1.join(Assets, `${name}.meta`), 'utf-8');
|
||||
return str ? JSON.parse(str) : null;
|
||||
}
|
||||
exports.getResMeta = getResMeta;
|
||||
function getResPanel(name) {
|
||||
const Assets = path_1.join(__dirname, '../res/panel');
|
||||
return fs_1.readFileSync(path_1.join(Assets, `components/${name}.html`), 'utf-8');
|
||||
}
|
||||
exports.getResPanel = getResPanel;
|
||||
/**
|
||||
* 将串式命名转成驼峰命名
|
||||
* @param str 串式字符串
|
||||
* @param lower 首字母是否小写(默认大写)
|
||||
* @returns
|
||||
*/
|
||||
function stringCase(str, lower = false) {
|
||||
str = str.replace(/-/g, '_');
|
||||
const arr = str.split('_');
|
||||
return arr.map(function (str, index) {
|
||||
if (index === 0 && lower) {
|
||||
return str.charAt(0).toLowerCase() + str.slice(1);
|
||||
}
|
||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||
}).join('');
|
||||
}
|
||||
exports.stringCase = stringCase;
|
||||
/**
|
||||
* 将驼峰命名转成串式命名
|
||||
* @param str 驼峰字符串
|
||||
* @returns
|
||||
*/
|
||||
function stringCaseNegate(str) {
|
||||
return str.replace(/[A-Z]/g, (searchStr, startIndex) => {
|
||||
if (startIndex === 0) {
|
||||
return searchStr.toLowerCase();
|
||||
}
|
||||
else {
|
||||
return '-' + searchStr.toLowerCase();
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.stringCaseNegate = stringCaseNegate;
|
||||
/**
|
||||
* db下的路径转换为真实路径
|
||||
*/
|
||||
function convertUrlToPath(url) {
|
||||
if (url.startsWith('db://assets')) {
|
||||
url = Editor.Utils.Path.join(Editor.Project.path, url.slice(5));
|
||||
}
|
||||
else if (url.startsWith('db://app')) {
|
||||
url = Editor.Utils.Path.join(Editor.Project.path, 'extensions/app/assets', url.slice(8));
|
||||
}
|
||||
else if (url.startsWith('db://pkg')) {
|
||||
url = Editor.Utils.Path.join(Editor.Project.path, 'extensions/pkg/node_modules', url.slice(8));
|
||||
}
|
||||
return url;
|
||||
}
|
||||
exports.convertUrlToPath = convertUrlToPath;
|
||||
/**
|
||||
* 获取程序路径
|
||||
*/
|
||||
function getProjectPath() {
|
||||
return Editor.Project.path;
|
||||
}
|
||||
exports.getProjectPath = getProjectPath;
|
||||
/**
|
||||
* 根据db下的路径创建目录(不是文件)
|
||||
* 如果已存在不会重复创建
|
||||
*/
|
||||
async function createFolderByUrl(url, opts) {
|
||||
let pathHead = 'db://assets';
|
||||
if (!url && !url.startsWith(pathHead)) {
|
||||
return false;
|
||||
}
|
||||
// 修剪path
|
||||
const pathTail = url.endsWith('/') ? url.slice(pathHead.length + 1, -1).trim() : url.slice(pathHead.length + 1).trim();
|
||||
// 每一层的路径
|
||||
const pathArr = pathTail.split('/');
|
||||
// 创建主目录
|
||||
for (let index = 0; index < pathArr.length; index++) {
|
||||
pathHead += '/' + pathArr[index];
|
||||
if (!fs_1.existsSync(convertUrlToPath(pathHead))) {
|
||||
const result = await Editor.Message.request('asset-db', 'create-asset', pathHead, null).catch(_ => null);
|
||||
if (!result)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// 主目录meta
|
||||
if (opts === null || opts === void 0 ? void 0 : opts.meta) {
|
||||
await delayFileExistsByUrl(`${url}.meta`);
|
||||
await delay(100);
|
||||
const queryMeta = await Editor.Message.request('asset-db', 'query-asset-meta', url).catch(_ => null);
|
||||
if (!queryMeta)
|
||||
return false;
|
||||
Object.assign(queryMeta.userData, opts.meta.userData);
|
||||
const result = await Editor.Message.request('asset-db', 'save-asset-meta', url, JSON.stringify(queryMeta)).catch(_ => null);
|
||||
if (!result)
|
||||
return false;
|
||||
}
|
||||
// 主目录readme
|
||||
if (opts === null || opts === void 0 ? void 0 : opts.readme) {
|
||||
fs_1.writeFileSync(path_1.join(convertUrlToPath(url), `.${path_1.basename(url)}.md`), opts.readme);
|
||||
}
|
||||
// 创建子目录
|
||||
if (opts === null || opts === void 0 ? void 0 : opts.subPaths) {
|
||||
await delay(100);
|
||||
for (let index = 0; index < opts.subPaths.length; index++) {
|
||||
const subPath = `${pathHead}/${opts.subPaths[index]}`;
|
||||
if (!fs_1.existsSync(convertUrlToPath(subPath))) {
|
||||
const result = await Editor.Message.request('asset-db', 'create-asset', subPath, null).catch(_ => null);
|
||||
if (!result)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (opts === null || opts === void 0 ? void 0 : opts.subFolders) {
|
||||
await delay(100);
|
||||
for (let index = 0; index < opts.subFolders.length; index++) {
|
||||
const subOpts = opts.subFolders[index];
|
||||
const subUrl = `${pathHead}/${subOpts.folder}`;
|
||||
// 判断是否存在
|
||||
if (!fs_1.existsSync(convertUrlToPath(subUrl))) {
|
||||
const result = await Editor.Message.request('asset-db', 'create-asset', subUrl, null).catch(_ => null);
|
||||
if (!result)
|
||||
return false;
|
||||
}
|
||||
// meta
|
||||
if (subOpts.meta) {
|
||||
await delayFileExistsByUrl(`${subUrl}.meta`);
|
||||
const queryMeta = await Editor.Message.request('asset-db', 'query-asset-meta', subUrl).catch(_ => null);
|
||||
if (!queryMeta)
|
||||
return false;
|
||||
Object.assign(queryMeta.userData, subOpts.meta.userData);
|
||||
const result = await Editor.Message.request('asset-db', 'save-asset-meta', subUrl, JSON.stringify(queryMeta)).catch(_ => null);
|
||||
if (!result)
|
||||
return false;
|
||||
}
|
||||
// readme
|
||||
if (subOpts.readme) {
|
||||
fs_1.writeFileSync(path_1.join(convertUrlToPath(subUrl), `.${path_1.basename(subUrl)}.md`), subOpts.readme);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
exports.createFolderByUrl = createFolderByUrl;
|
||||
function delay(time) {
|
||||
return new Promise((next) => {
|
||||
setTimeout(() => {
|
||||
next(null);
|
||||
}, time);
|
||||
});
|
||||
}
|
||||
exports.delay = delay;
|
||||
/**
|
||||
* 等待文件存在
|
||||
*/
|
||||
function delayFileExistsByUrl(url) {
|
||||
const path = convertUrlToPath(url);
|
||||
let timer = null;
|
||||
return new Promise((next) => {
|
||||
timer = setInterval(() => {
|
||||
if (fs_1.existsSync(path)) {
|
||||
if (timer)
|
||||
clearInterval(timer);
|
||||
timer = null;
|
||||
next(null);
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
exports.delayFileExistsByUrl = delayFileExistsByUrl;
|
||||
41
extensions/app/engine/package-lock.json
generated
Normal file
41
extensions/app/engine/package-lock.json
generated
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "engine",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "engine",
|
||||
"devDependencies": {
|
||||
"@types/node": "16.0.1",
|
||||
"typescript": "4.3.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "16.0.1",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "4.3.4",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.2.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/node": {
|
||||
"version": "16.0.1",
|
||||
"dev": true
|
||||
},
|
||||
"typescript": {
|
||||
"version": "4.3.4",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
||||
11
extensions/app/engine/package.json
Executable file
11
extensions/app/engine/package.json
Executable file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "engine",
|
||||
"devDependencies": {
|
||||
"@types/node": "16.0.1",
|
||||
"typescript": "4.3.4"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc -b",
|
||||
"watch": "tsc -w"
|
||||
}
|
||||
}
|
||||
219
extensions/app/engine/res/json/builder.json
Normal file
219
extensions/app/engine/res/json/builder.json
Normal file
@@ -0,0 +1,219 @@
|
||||
{
|
||||
"bundleConfig": {
|
||||
"custom": {
|
||||
"auto_398Ij6Mc1B2Y7sW3e6BgFC": {
|
||||
"displayName": "app-builtin",
|
||||
"configs": {
|
||||
"native": {
|
||||
"preferredOptions": {
|
||||
"compressionType": "merge_all_json",
|
||||
"isRemote": false
|
||||
},
|
||||
"overwriteSettings": {}
|
||||
},
|
||||
"miniGame": {
|
||||
"configMode": "overwrite",
|
||||
"overwriteSettings": {
|
||||
"bytedance-mini-game": {
|
||||
"compressionType": "subpackage",
|
||||
"isRemote": false
|
||||
},
|
||||
"oppo-mini-game": {
|
||||
"compressionType": "subpackage",
|
||||
"isRemote": false
|
||||
},
|
||||
"huawei-quick-game": {
|
||||
"compressionType": "subpackage",
|
||||
"isRemote": false
|
||||
},
|
||||
"vivo-mini-game": {
|
||||
"compressionType": "subpackage",
|
||||
"isRemote": false
|
||||
},
|
||||
"xiaomi-quick-game": {
|
||||
"compressionType": "subpackage",
|
||||
"isRemote": false
|
||||
},
|
||||
"baidu-mini-game": {
|
||||
"compressionType": "subpackage",
|
||||
"isRemote": false
|
||||
},
|
||||
"wechatgame": {
|
||||
"compressionType": "subpackage",
|
||||
"isRemote": false
|
||||
},
|
||||
"alipay-mini-game": {
|
||||
"compressionType": "subpackage",
|
||||
"isRemote": false
|
||||
},
|
||||
"taobao-creative-app": {
|
||||
"compressionType": "merge_all_json",
|
||||
"isRemote": true
|
||||
},
|
||||
"taobao-mini-game": {
|
||||
"compressionType": "subpackage",
|
||||
"isRemote": false
|
||||
},
|
||||
"link-sure": {
|
||||
"compressionType": "merge_dep",
|
||||
"isRemote": false
|
||||
},
|
||||
"qtt": {
|
||||
"compressionType": "merge_dep",
|
||||
"isRemote": false
|
||||
},
|
||||
"cocos-play": {
|
||||
"compressionType": "zip",
|
||||
"isRemote": true
|
||||
},
|
||||
"fb-instant-games": {
|
||||
"compressionType": "merge_all_json",
|
||||
"isRemote": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"web": {
|
||||
"preferredOptions": {
|
||||
"compressionType": "merge_all_json",
|
||||
"isRemote": true
|
||||
},
|
||||
"overwriteSettings": {}
|
||||
}
|
||||
}
|
||||
},
|
||||
"auto_f7NI9WxFVIO6e8LbJGF72k": {
|
||||
"displayName": "app-native",
|
||||
"configs": {
|
||||
"native": {
|
||||
"preferredOptions": {
|
||||
"compressionType": "merge_all_json",
|
||||
"isRemote": false
|
||||
},
|
||||
"overwriteSettings": {}
|
||||
},
|
||||
"miniGame": {
|
||||
"configMode": "overwrite",
|
||||
"overwriteSettings": {
|
||||
"bytedance-mini-game": {
|
||||
"compressionType": "subpackage",
|
||||
"isRemote": false
|
||||
},
|
||||
"oppo-mini-game": {
|
||||
"compressionType": "subpackage",
|
||||
"isRemote": false
|
||||
},
|
||||
"huawei-quick-game": {
|
||||
"compressionType": "subpackage",
|
||||
"isRemote": false
|
||||
},
|
||||
"vivo-mini-game": {
|
||||
"compressionType": "subpackage",
|
||||
"isRemote": false
|
||||
},
|
||||
"xiaomi-quick-game": {
|
||||
"compressionType": "subpackage",
|
||||
"isRemote": false
|
||||
},
|
||||
"baidu-mini-game": {
|
||||
"compressionType": "subpackage",
|
||||
"isRemote": false
|
||||
},
|
||||
"wechatgame": {
|
||||
"compressionType": "subpackage",
|
||||
"isRemote": false
|
||||
},
|
||||
"alipay-mini-game": {
|
||||
"compressionType": "subpackage",
|
||||
"isRemote": false
|
||||
},
|
||||
"taobao-creative-app": {
|
||||
"compressionType": "merge_all_json",
|
||||
"isRemote": true
|
||||
},
|
||||
"taobao-mini-game": {
|
||||
"compressionType": "subpackage",
|
||||
"isRemote": false
|
||||
},
|
||||
"link-sure": {
|
||||
"compressionType": "merge_dep",
|
||||
"isRemote": false
|
||||
},
|
||||
"qtt": {
|
||||
"compressionType": "merge_dep",
|
||||
"isRemote": false
|
||||
},
|
||||
"cocos-play": {
|
||||
"compressionType": "zip",
|
||||
"isRemote": true
|
||||
},
|
||||
"fb-instant-games": {
|
||||
"compressionType": "merge_all_json",
|
||||
"isRemote": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"web": {
|
||||
"preferredOptions": {
|
||||
"compressionType": "merge_all_json",
|
||||
"isRemote": true
|
||||
},
|
||||
"overwriteSettings": {}
|
||||
}
|
||||
}
|
||||
},
|
||||
"auto_11aBEBWDxI/6ryvKvFthEo": {
|
||||
"displayName": "app-res",
|
||||
"configs": {
|
||||
"native": {
|
||||
"preferredOptions": {
|
||||
"compressionType": "merge_dep",
|
||||
"isRemote": false
|
||||
},
|
||||
"overwriteSettings": {}
|
||||
},
|
||||
"miniGame": {
|
||||
"configMode": "fallback",
|
||||
"overwriteSettings": {},
|
||||
"fallbackOptions": {
|
||||
"isRemote": true
|
||||
}
|
||||
},
|
||||
"web": {
|
||||
"preferredOptions": {
|
||||
"compressionType": "merge_dep",
|
||||
"isRemote": true
|
||||
},
|
||||
"overwriteSettings": {}
|
||||
}
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"displayName": "i18n:builder.asset_bundle.defaultConfig",
|
||||
"configs": {
|
||||
"native": {
|
||||
"preferredOptions": {
|
||||
"isRemote": true,
|
||||
"compressionType": "merge_dep"
|
||||
}
|
||||
},
|
||||
"web": {
|
||||
"preferredOptions": {
|
||||
"isRemote": true,
|
||||
"compressionType": "merge_dep"
|
||||
},
|
||||
"fallbackOptions": {
|
||||
"compressionType": "merge_dep"
|
||||
}
|
||||
},
|
||||
"miniGame": {
|
||||
"fallbackOptions": {
|
||||
"isRemote": true,
|
||||
"compressionType": "merge_dep"
|
||||
},
|
||||
"configMode": "fallback"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
220
extensions/app/engine/res/mark.js
Normal file
220
extensions/app/engine/res/mark.js
Normal file
@@ -0,0 +1,220 @@
|
||||
(() => {
|
||||
// const folder = ['app', 'app-appinit', 'app-builtin', 'app-bundle', 'app-scene', 'app-sound', 'app-view', 'page', 'paper', 'pop', 'top'];
|
||||
// function updateAssetMark(assetDock) {
|
||||
// const assetItemList = assetDock.querySelectorAll('div.tree-node > ui-drag-item');
|
||||
// if (!assetItemList) return;
|
||||
|
||||
// const finished = [];
|
||||
|
||||
// assetItemList.forEach((item) => {
|
||||
// const currPaddingLeft = parseInt(item.style.paddingLeft);
|
||||
// if (currPaddingLeft > 50) {
|
||||
// item.style['border-left'] = '2px solid dimgray';
|
||||
// } else {
|
||||
// item.style['border-left'] = '';
|
||||
// }
|
||||
|
||||
// const labelList = item.getElementsByTagName('label');
|
||||
// if (!labelList) return;
|
||||
// const labelEl = Array.from(labelList).find(labelEl => {
|
||||
// labelEl.style.color = '';
|
||||
// return folder.indexOf(labelEl.innerText.trim()) >= 0;
|
||||
// });
|
||||
// if (!labelEl) return;
|
||||
|
||||
// const iconList = item.getElementsByTagName('ui-icon');
|
||||
// if (!iconList || iconList.length < 2) return;
|
||||
// const iconEl = Array.from(iconList).pop();
|
||||
// if (!iconEl) return;
|
||||
// iconEl.style.color = '';
|
||||
|
||||
// if (item.type !== 'cc.Asset') return;
|
||||
|
||||
// if (labelEl.innerText.trim() === 'app') {
|
||||
// iconEl['value'] = 'setting';
|
||||
// iconEl.removeAttribute('color');
|
||||
// iconEl.style.color = 'mediumturquoise';
|
||||
// labelEl.style.color = 'whitesmoke';
|
||||
// }
|
||||
// else if (labelEl.innerText.trim() === 'app-appinit') {
|
||||
// iconEl['value'] = 'home';
|
||||
// iconEl.removeAttribute('color');
|
||||
// iconEl.style.color = 'sandybrown';
|
||||
// labelEl.style.color = 'whitesmoke';
|
||||
// }
|
||||
// else if (labelEl.innerText.trim() === 'app-builtin') {
|
||||
// iconEl['value'] = 'service';
|
||||
// iconEl.removeAttribute('color');
|
||||
// iconEl.style.color = 'deepskyblue';
|
||||
// labelEl.style.color = 'whitesmoke';
|
||||
// }
|
||||
// else if (labelEl.innerText.trim() === 'app-bundle') {
|
||||
// iconEl['value'] = 'extension';
|
||||
// iconEl.removeAttribute('color');
|
||||
// iconEl.style.color = 'mediumseagreen';
|
||||
// labelEl.style.color = 'whitesmoke';
|
||||
// }
|
||||
// else if (labelEl.innerText.trim() === 'app-scene') {
|
||||
// iconEl['value'] = 'mini-game';
|
||||
// iconEl.removeAttribute('color');
|
||||
// iconEl.style.color = 'gold';
|
||||
// labelEl.style.color = 'whitesmoke';
|
||||
// }
|
||||
// else if (labelEl.innerText.trim() === 'app-sound') {
|
||||
// iconEl['value'] = 'music';
|
||||
// iconEl.removeAttribute('color');
|
||||
// iconEl.style.color = 'yellowgreen';
|
||||
// labelEl.style.color = 'yellowgreen';
|
||||
// }
|
||||
// else if (labelEl.innerText.trim() === 'app-view') {
|
||||
// iconEl['value'] = 'particle';
|
||||
// iconEl.removeAttribute('color');
|
||||
// iconEl.style.color = 'tomato';
|
||||
// labelEl.style.color = 'tomato';
|
||||
// }
|
||||
// else if (finished.indexOf(labelEl.innerText.trim()) === -1) {
|
||||
// finished.push(labelEl.innerText.trim());
|
||||
// iconEl.removeAttribute('color');
|
||||
// iconEl.style.color = 'orange';
|
||||
// labelEl.style.color = 'orange';
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
function updateAssetMark(assetDock) {
|
||||
const treeNodeList = assetDock.querySelectorAll('div.tree-node');
|
||||
if (!treeNodeList) return;
|
||||
|
||||
treeNodeList.forEach((treeNode) => {
|
||||
const isExpand = treeNode.__vue__?.$props?.expand;
|
||||
const isDirectory = treeNode.__vue__?.$props?.asset?.isDirectory;
|
||||
const assetUrl = treeNode.__vue__?.$props?.asset?.url || '';
|
||||
const assetName = treeNode.__vue__?.$props?.asset?.name || '';
|
||||
const assetDirUrl = assetUrl.slice(0, assetUrl.length - assetName.length); // 结尾带/
|
||||
|
||||
const itemDiv = treeNode.getElementsByTagName('ui-drag-item')[0];
|
||||
|
||||
// 子节点-label
|
||||
const nameDiv = itemDiv.getElementsByClassName('name')[0];
|
||||
const nameUI = nameDiv ? nameDiv.getElementsByTagName('span')[0] : null;
|
||||
|
||||
// 子节点-icon
|
||||
const iconDiv = itemDiv.getElementsByClassName('icon')[0];
|
||||
const iconUI = iconDiv ? iconDiv.getElementsByTagName('ui-icon')[0] : null;
|
||||
|
||||
if (iconUI) iconUI['color'] = 'true';
|
||||
if (iconUI) iconUI.style.color = '';
|
||||
if (nameUI) nameUI.style.color = '';
|
||||
|
||||
if (iconDiv) iconDiv.style.height = '100%';
|
||||
if (iconDiv) iconDiv.style.backgroundColor = '';
|
||||
if (nameDiv) nameDiv.style.backgroundColor = '';
|
||||
|
||||
if (!isDirectory || !iconUI || !nameUI) return;
|
||||
|
||||
if (assetUrl === 'db://assets/app') {
|
||||
iconUI['value'] = 'setting';
|
||||
iconUI.removeAttribute('color');
|
||||
iconUI.style.color = 'mediumturquoise';
|
||||
nameUI.style.color = 'whitesmoke';
|
||||
}
|
||||
else if (assetUrl === 'db://assets/app-appinit') {
|
||||
iconUI['value'] = 'home';
|
||||
iconUI.removeAttribute('color');
|
||||
iconUI.style.color = 'sandybrown';
|
||||
nameUI.style.color = 'whitesmoke';
|
||||
}
|
||||
else if (assetUrl === 'db://assets/app-builtin') {
|
||||
iconUI['value'] = 'service';
|
||||
iconUI.removeAttribute('color');
|
||||
iconUI.style.color = 'deepskyblue';
|
||||
nameUI.style.color = 'whitesmoke';
|
||||
}
|
||||
else if (assetUrl === 'db://assets/app-bundle') {
|
||||
iconUI['value'] = 'extension';
|
||||
iconUI.removeAttribute('color');
|
||||
iconUI.style.color = 'mediumseagreen';
|
||||
nameUI.style.color = 'whitesmoke';
|
||||
}
|
||||
else if (assetUrl === 'db://assets/app-scene') {
|
||||
iconUI['value'] = 'mini-game';
|
||||
iconUI.removeAttribute('color');
|
||||
iconUI.style.color = 'gold';
|
||||
nameUI.style.color = 'whitesmoke';
|
||||
}
|
||||
else if (assetUrl === 'db://assets/app-bundle/app-sound') {
|
||||
iconUI['value'] = 'music';
|
||||
iconUI.removeAttribute('color');
|
||||
iconUI.style.color = 'yellowgreen';
|
||||
nameUI.style.color = 'yellowgreen';
|
||||
}
|
||||
else if (assetUrl === 'db://assets/app-bundle/app-view') {
|
||||
iconUI['value'] = 'particle';
|
||||
iconUI.removeAttribute('color');
|
||||
iconUI.style.color = 'tomato';
|
||||
nameUI.style.color = 'tomato';
|
||||
}
|
||||
else if (assetDirUrl === 'db://assets/app-bundle/app-view/') {
|
||||
iconUI.removeAttribute('color');
|
||||
iconUI.style.color = 'orange';
|
||||
nameUI.style.color = 'orange';
|
||||
}
|
||||
else if (assetDirUrl === 'db://assets/app-bundle/app-view/page/' ||
|
||||
assetDirUrl === 'db://assets/app-bundle/app-view/paper/' ||
|
||||
assetDirUrl === 'db://assets/app-bundle/app-view/pop/' ||
|
||||
assetDirUrl === 'db://assets/app-bundle/app-view/top/'
|
||||
) {
|
||||
iconUI.removeAttribute('color');
|
||||
if (isExpand) {
|
||||
iconUI.style.color = 'gold';
|
||||
nameUI.style.color = 'whitesmoke';
|
||||
iconDiv.style.backgroundColor = 'brown';
|
||||
nameDiv.style.backgroundColor = 'brown';
|
||||
} else {
|
||||
iconUI.style.color = 'gold';
|
||||
nameUI.style.color = 'whitesmoke';
|
||||
iconDiv.style.backgroundColor = '';
|
||||
nameDiv.style.backgroundColor = '';
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let retryCount = 0;
|
||||
const maxRetryCount = 10;
|
||||
|
||||
function initAssetMark() {
|
||||
// 资源管理器窗口
|
||||
const assetDock = document.querySelector('#dock')?.shadowRoot?.
|
||||
querySelector('dock-layout dock-layout dock-groups dock-panels > panel-frame[name=assets]')?.shadowRoot?.
|
||||
querySelector('div > div.separate-box > div:nth-child(1) > section > ui-drag-area');
|
||||
|
||||
if (!assetDock) {
|
||||
if (retryCount++ < maxRetryCount) {
|
||||
setTimeout(initAssetMark, 500);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof MutationObserver === 'undefined') {
|
||||
setInterval(function () {
|
||||
updateAssetMark(assetDock);
|
||||
}, 50);
|
||||
} else {
|
||||
// 创建一个观察器实例并传入回调函数
|
||||
const observer = new MutationObserver(function () {
|
||||
updateAssetMark(assetDock);
|
||||
});
|
||||
|
||||
// 开始观察已配置的目标节点(观察目标节点的子节点的变化)
|
||||
observer.observe(assetDock, { childList: true, subtree: true });
|
||||
|
||||
// 你可以随时停止观察
|
||||
// observer.disconnect();
|
||||
}
|
||||
|
||||
updateAssetMark(assetDock);
|
||||
}
|
||||
|
||||
initAssetMark();
|
||||
})();
|
||||
7
extensions/app/engine/res/meta/app-admin.meta
Normal file
7
extensions/app/engine/res/meta/app-admin.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"userData": {
|
||||
"isBundle": true,
|
||||
"bundleConfigID": "auto_398Ij6Mc1B2Y7sW3e6BgFC",
|
||||
"priority": 1
|
||||
}
|
||||
}
|
||||
7
extensions/app/engine/res/meta/app-controller.meta
Normal file
7
extensions/app/engine/res/meta/app-controller.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"userData": {
|
||||
"isBundle": true,
|
||||
"bundleConfigID": "auto_398Ij6Mc1B2Y7sW3e6BgFC",
|
||||
"priority": 1
|
||||
}
|
||||
}
|
||||
7
extensions/app/engine/res/meta/app-manager.meta
Normal file
7
extensions/app/engine/res/meta/app-manager.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"userData": {
|
||||
"isBundle": true,
|
||||
"bundleConfigID": "auto_398Ij6Mc1B2Y7sW3e6BgFC",
|
||||
"priority": 1
|
||||
}
|
||||
}
|
||||
7
extensions/app/engine/res/meta/app-model.meta
Normal file
7
extensions/app/engine/res/meta/app-model.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"userData": {
|
||||
"isBundle": true,
|
||||
"bundleConfigID": "auto_398Ij6Mc1B2Y7sW3e6BgFC",
|
||||
"priority": 1
|
||||
}
|
||||
}
|
||||
7
extensions/app/engine/res/meta/app-sound.meta
Normal file
7
extensions/app/engine/res/meta/app-sound.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"userData": {
|
||||
"isBundle": true,
|
||||
"bundleConfigID": "auto_11aBEBWDxI/6ryvKvFthEo",
|
||||
"priority": 8
|
||||
}
|
||||
}
|
||||
7
extensions/app/engine/res/meta/custom-bundle.meta
Normal file
7
extensions/app/engine/res/meta/custom-bundle.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"userData": {
|
||||
"isBundle": true,
|
||||
"bundleConfigID": "default",
|
||||
"priority": 1
|
||||
}
|
||||
}
|
||||
8
extensions/app/engine/res/meta/resources.meta
Normal file
8
extensions/app/engine/res/meta/resources.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"userData": {
|
||||
"isBundle": true,
|
||||
"bundleConfigID": "default",
|
||||
"bundleName": "resources",
|
||||
"priority": 8
|
||||
}
|
||||
}
|
||||
5
extensions/app/engine/res/meta/view-native.meta
Normal file
5
extensions/app/engine/res/meta/view-native.meta
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"isBundle": true,
|
||||
"bundleConfigID": "auto_f7NI9WxFVIO6e8LbJGF72k",
|
||||
"priority": 1
|
||||
}
|
||||
5
extensions/app/engine/res/meta/view-resources.meta
Normal file
5
extensions/app/engine/res/meta/view-resources.meta
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"isBundle": true,
|
||||
"bundleConfigID": "auto_11aBEBWDxI/6ryvKvFthEo",
|
||||
"priority": 4
|
||||
}
|
||||
11
extensions/app/engine/res/panel/components/app.html
Normal file
11
extensions/app/engine/res/panel/components/app.html
Normal file
@@ -0,0 +1,11 @@
|
||||
<div class="container">
|
||||
<ui-tab value="0" @confirm="onClick($event.target.value)">
|
||||
<ui-button>{{menus[0]}}</ui-button>
|
||||
<ui-button>{{menus[1]}}</ui-button>
|
||||
<ui-button>{{menus[2]}}</ui-button>
|
||||
<ui-button>{{menus[3]}}</ui-button>
|
||||
<ui-button>{{menus[4]}}</ui-button>
|
||||
<ui-button>{{menus[5]}}</ui-button>
|
||||
</ui-tab>
|
||||
<component :is="content" />
|
||||
</div>
|
||||
@@ -0,0 +1,26 @@
|
||||
<div class="content">
|
||||
<ui-link class="help" value="https://gitee.com/cocos2d-zp/xforge/wikis/pages?sort_id=13017438&doc_id=6236543">
|
||||
<ui-icon value="help"></ui-icon>
|
||||
</ui-link>
|
||||
|
||||
<ui-section header="输入" expand>
|
||||
<ui-prop class="content-item">
|
||||
<ui-label slot="label">名字</ui-label>
|
||||
<ui-input id="name" slot="content" placeholder="输入名字如: index" :value="inputName"
|
||||
@change="inputName=$event.target.value" show-clear>
|
||||
</ui-input>
|
||||
</ui-prop>
|
||||
|
||||
<ui-button class="content-item" type="primary" @confirm="onClickCreate">
|
||||
创建
|
||||
</ui-button>
|
||||
</ui-section>
|
||||
|
||||
<ui-section header="输出" expand>
|
||||
<ui-label :value="display" style="white-space: pre"></ui-label>
|
||||
</ui-section>
|
||||
|
||||
<div class="loading" v-show="showLoading">
|
||||
<ui-loading class="loading-item"></ui-loading>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,26 @@
|
||||
<div class="content">
|
||||
<ui-link class="help" value="https://gitee.com/cocos2d-zp/xforge/wikis/pages?sort_id=13017441&doc_id=6236543">
|
||||
<ui-icon value="help"></ui-icon>
|
||||
</ui-link>
|
||||
|
||||
<ui-section header="输入" expand>
|
||||
<ui-prop class="content-item">
|
||||
<ui-label slot="label">名字</ui-label>
|
||||
<ui-input id="name" slot="content" placeholder="输入名字如: index" :value="inputName"
|
||||
@change="inputName=$event.target.value" show-clear>
|
||||
</ui-input>
|
||||
</ui-prop>
|
||||
|
||||
<ui-button class="content-item" type="primary" @confirm="onClickCreate">
|
||||
创建
|
||||
</ui-button>
|
||||
</ui-section>
|
||||
|
||||
<ui-section header="输出" expand>
|
||||
<ui-label :value="display" style="white-space: pre"></ui-label>
|
||||
</ui-section>
|
||||
|
||||
<div class="loading" v-show="showLoading">
|
||||
<ui-loading class="loading-item"></ui-loading>
|
||||
</div>
|
||||
</div>
|
||||
36
extensions/app/engine/res/panel/components/create-model.html
Normal file
36
extensions/app/engine/res/panel/components/create-model.html
Normal file
@@ -0,0 +1,36 @@
|
||||
<div class="content">
|
||||
<ui-link class="help" value="https://gitee.com/cocos2d-zp/xforge/wikis/pages?sort_id=13017439&doc_id=6236543">
|
||||
<ui-icon value="help"></ui-icon>
|
||||
</ui-link>
|
||||
|
||||
<ui-section header="输入" expand>
|
||||
<ui-prop class="content-item">
|
||||
<ui-label slot="label">类型</ui-label>
|
||||
<ui-select id="type" slot="content" :value="typeSelectIndex"
|
||||
@confirm="onChangeTypeSelect($event.target.value)">
|
||||
<option :value="index" v-for="(name,index) in typeSelects">
|
||||
{{name}}
|
||||
</option>
|
||||
</ui-select>
|
||||
</ui-prop>
|
||||
|
||||
<ui-prop class="content-item">
|
||||
<ui-label slot="label">名字</ui-label>
|
||||
<ui-input id="name" slot="content" placeholder="输入名字如: index" :value="inputName"
|
||||
@change="inputName=$event.target.value" show-clear>
|
||||
</ui-input>
|
||||
</ui-prop>
|
||||
|
||||
<ui-button class="content-item" type="primary" @confirm="onClickCreate">
|
||||
创建
|
||||
</ui-button>
|
||||
</ui-section>
|
||||
|
||||
<ui-section header="输出" expand>
|
||||
<ui-label :value="display" style="white-space: pre"></ui-label>
|
||||
</ui-section>
|
||||
|
||||
<div class="loading" v-show="showLoading">
|
||||
<ui-loading class="loading-item"></ui-loading>
|
||||
</div>
|
||||
</div>
|
||||
36
extensions/app/engine/res/panel/components/create-res.html
Normal file
36
extensions/app/engine/res/panel/components/create-res.html
Normal file
@@ -0,0 +1,36 @@
|
||||
<div class="content">
|
||||
<ui-link class="help" value="https://gitee.com/cocos2d-zp/xforge/wikis/pages?sort_id=13017429&doc_id=6236543">
|
||||
<ui-icon value="help"></ui-icon>
|
||||
</ui-link>
|
||||
|
||||
<ui-section header="输入" expand>
|
||||
<ui-prop class="content-item">
|
||||
<ui-label slot="label">类型</ui-label>
|
||||
<ui-select id="type" slot="content" :value="typeSelectIndex"
|
||||
@confirm="onChangeTypeSelect($event.target.value)">
|
||||
<option :value="index" v-for="(name,index) in typeSelects">
|
||||
{{name}}
|
||||
</option>
|
||||
</ui-select>
|
||||
</ui-prop>
|
||||
|
||||
<ui-prop class="content-item">
|
||||
<ui-label slot="label">名字</ui-label>
|
||||
<ui-input id="name" slot="content" placeholder="输入文件夹名字如: index" :value="inputName"
|
||||
@change="inputName=$event.target.value" show-clear>
|
||||
</ui-input>
|
||||
</ui-prop>
|
||||
|
||||
<ui-button class="content-item" type="primary" @confirm="onClickCreate">
|
||||
创建
|
||||
</ui-button>
|
||||
</ui-section>
|
||||
|
||||
<ui-section header="输出" expand>
|
||||
<ui-label :value="display" style="white-space: pre"></ui-label>
|
||||
</ui-section>
|
||||
|
||||
<div class="loading" v-show="showLoading">
|
||||
<ui-loading class="loading-item"></ui-loading>
|
||||
</div>
|
||||
</div>
|
||||
29
extensions/app/engine/res/panel/components/create-sound.html
Normal file
29
extensions/app/engine/res/panel/components/create-sound.html
Normal file
@@ -0,0 +1,29 @@
|
||||
<div class="content">
|
||||
<ui-link class="help" value="https://gitee.com/cocos2d-zp/xforge/wikis/pages?sort_id=13017437&doc_id=6236543">
|
||||
<ui-icon value="help"></ui-icon>
|
||||
</ui-link>
|
||||
|
||||
<ui-section header="输入" expand>
|
||||
<ui-prop class="content-item">
|
||||
<ui-label slot="label">类型</ui-label>
|
||||
<ui-select id="type" slot="content" :value="typeSelectIndex"
|
||||
@confirm="onChangeTypeSelect($event.target.value)">
|
||||
<option :value="index" v-for="(name,index) in typeSelects">
|
||||
{{name}}
|
||||
</option>
|
||||
</ui-select>
|
||||
</ui-prop>
|
||||
|
||||
<ui-button class="content-item" type="primary" @confirm="onClickCreate">
|
||||
创建
|
||||
</ui-button>
|
||||
</ui-section>
|
||||
|
||||
<ui-section header="输出" expand>
|
||||
<ui-label :value="display" style="white-space: pre"></ui-label>
|
||||
</ui-section>
|
||||
|
||||
<div class="loading" v-show="showLoading">
|
||||
<ui-loading class="loading-item"></ui-loading>
|
||||
</div>
|
||||
</div>
|
||||
56
extensions/app/engine/res/panel/components/create-view.html
Normal file
56
extensions/app/engine/res/panel/components/create-view.html
Normal file
@@ -0,0 +1,56 @@
|
||||
<div class="content">
|
||||
<ui-link class="help" value="https://gitee.com/cocos2d-zp/xforge/wikis/pages?sort_id=13017440&doc_id=6236543">
|
||||
<ui-icon value="help"></ui-icon>
|
||||
</ui-link>
|
||||
|
||||
<ui-section header="输入" expand>
|
||||
<ui-prop class="content-item">
|
||||
<ui-label slot="label">类型</ui-label>
|
||||
<ui-select id="type" slot="content" :value="typeSelectIndex"
|
||||
@confirm="onChangeTypeSelect($event.target.value)">
|
||||
<option :value="index" v-for="(name,index) in typeSelects">
|
||||
{{name}}
|
||||
</option>
|
||||
</ui-select>
|
||||
</ui-prop>
|
||||
|
||||
<ui-prop class="content-item" v-show="showSelectGroup">
|
||||
<ui-label slot="label">模版</ui-label>
|
||||
<ui-select id="group" slot="content" :value="groupSelectIndex"
|
||||
@confirm="onChangeGroupSelect($event.target.value)">
|
||||
<option :value="index" v-for="(name,index) in groupSelects">
|
||||
{{name}}
|
||||
</option>
|
||||
</ui-select>
|
||||
</ui-prop>
|
||||
|
||||
<ui-prop class="content-item" v-show="showSelectPage">
|
||||
<ui-label slot="label">归属</ui-label>
|
||||
<ui-select id="owner" slot="content" :value="pageSelectIndex"
|
||||
@confirm="onChangePageSelect($event.target.value)">
|
||||
<option :value="index" v-for="(name,index) in pageSelects">
|
||||
{{name}}
|
||||
</option>
|
||||
</ui-select>
|
||||
</ui-prop>
|
||||
|
||||
<ui-prop class="content-item">
|
||||
<ui-label slot="label">名字</ui-label>
|
||||
<ui-input id="name" slot="content" placeholder="输入界面名字如: index" :value="inputName"
|
||||
@change="inputName=$event.target.value" show-clear>
|
||||
</ui-input>
|
||||
</ui-prop>
|
||||
|
||||
<ui-button class="content-item" type="primary" @confirm="onClickCreate">
|
||||
创建
|
||||
</ui-button>
|
||||
</ui-section>
|
||||
|
||||
<ui-section header="输出" expand>
|
||||
<ui-label :value="display" style="white-space: pre"></ui-label>
|
||||
</ui-section>
|
||||
|
||||
<div class="loading" v-show="showLoading">
|
||||
<ui-loading class="loading-item"></ui-loading>
|
||||
</div>
|
||||
</div>
|
||||
1
extensions/app/engine/res/panel/index.html
Normal file
1
extensions/app/engine/res/panel/index.html
Normal file
@@ -0,0 +1 @@
|
||||
<div id="app"></div>
|
||||
42
extensions/app/engine/res/panel/styles/index.css
Normal file
42
extensions/app/engine/res/panel/styles/index.css
Normal file
@@ -0,0 +1,42 @@
|
||||
#app {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.container {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.content {
|
||||
position: relative;
|
||||
width: 80%;
|
||||
margin: 8px auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.content-item {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.help {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.loading {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 9999;
|
||||
background-color: rgba(0, 0, 0, 0.6);
|
||||
/* 背景模糊 */
|
||||
/* backdrop-filter: blur(3px); */
|
||||
}
|
||||
|
||||
.loading-item {
|
||||
margin-top: 50%;
|
||||
}
|
||||
2
extensions/app/engine/res/readme/app-admin.md
Normal file
2
extensions/app/engine/res/readme/app-admin.md
Normal file
@@ -0,0 +1,2 @@
|
||||
1、一些配置类的资产(框架自动维护)
|
||||
2、不可删除此文件夹
|
||||
2
extensions/app/engine/res/readme/app-appinit.md
Normal file
2
extensions/app/engine/res/readme/app-appinit.md
Normal file
@@ -0,0 +1,2 @@
|
||||
1、框架初始化首屏
|
||||
2、不可删除此文件夹
|
||||
2
extensions/app/engine/res/readme/app-builtin.md
Normal file
2
extensions/app/engine/res/readme/app-builtin.md
Normal file
@@ -0,0 +1,2 @@
|
||||
1、存储内置功能的文件夹
|
||||
2、不可删除此文件夹
|
||||
2
extensions/app/engine/res/readme/app-bundle.md
Normal file
2
extensions/app/engine/res/readme/app-bundle.md
Normal file
@@ -0,0 +1,2 @@
|
||||
1、存储内置的Bundle的文件夹
|
||||
2、如不再需要,可以直接删除此文件夹
|
||||
4
extensions/app/engine/res/readme/app-controller.md
Normal file
4
extensions/app/engine/res/readme/app-controller.md
Normal file
@@ -0,0 +1,4 @@
|
||||
存储控制器
|
||||
1、通过app.controller或import来使用(BaseView.bindController的参数只能使用import方式)
|
||||
2、通过菜单「App/创建/Controller」创建
|
||||
3、如不再需要,可以直接删除此文件夹
|
||||
4
extensions/app/engine/res/readme/app-manager.md
Normal file
4
extensions/app/engine/res/readme/app-manager.md
Normal file
@@ -0,0 +1,4 @@
|
||||
存储管理器
|
||||
1、通过app.manager来使用
|
||||
2、通过菜单「App/创建/Manager」创建
|
||||
3、如不再需要,可以直接删除此文件夹
|
||||
5
extensions/app/engine/res/readme/app-model.md
Normal file
5
extensions/app/engine/res/readme/app-model.md
Normal file
@@ -0,0 +1,5 @@
|
||||
存储数据
|
||||
1、通过app.store、app.data或app.config来使用
|
||||
2、export类型数据通过import来使用, 但不可以被主包引用
|
||||
3、通过菜单「App/创建/Model」创建
|
||||
4、如不再需要,可以直接删除此文件夹
|
||||
2
extensions/app/engine/res/readme/app-scene.md
Normal file
2
extensions/app/engine/res/readme/app-scene.md
Normal file
@@ -0,0 +1,2 @@
|
||||
1、存储主场景的文件夹
|
||||
2、不可删除此文件夹
|
||||
4
extensions/app/engine/res/readme/app-sound.md
Normal file
4
extensions/app/engine/res/readme/app-sound.md
Normal file
@@ -0,0 +1,4 @@
|
||||
存储音乐/音效资源的文件夹
|
||||
1、通过app.manager.sound管理
|
||||
2、通过菜单「App/创建/Sound」创建目录
|
||||
3、如不再需要,可以直接删除此文件夹
|
||||
4
extensions/app/engine/res/readme/app-view.md
Normal file
4
extensions/app/engine/res/readme/app-view.md
Normal file
@@ -0,0 +1,4 @@
|
||||
存储UI资源的文件夹
|
||||
1、通过app.manager.ui管理
|
||||
2、通过菜单「App/创建/View」创建
|
||||
3、如不再需要,可以直接删除此文件夹
|
||||
2
extensions/app/engine/res/readme/app.md
Normal file
2
extensions/app/engine/res/readme/app.md
Normal file
@@ -0,0 +1,2 @@
|
||||
1、框架配置、生命周期及全局导出
|
||||
2、不可删除此文件夹
|
||||
4
extensions/app/engine/res/readme/res-bundle.md
Normal file
4
extensions/app/engine/res/readme/res-bundle.md
Normal file
@@ -0,0 +1,4 @@
|
||||
存储动态资源的文件夹
|
||||
1、通过app.manager.loader管理
|
||||
2、所有业务自定义的Bundle文件夹存放在这里面
|
||||
3、如不再需要,可以直接删除此文件夹
|
||||
5
extensions/app/engine/res/readme/res-native.md
Normal file
5
extensions/app/engine/res/readme/res-native.md
Normal file
@@ -0,0 +1,5 @@
|
||||
存储静态资源的文件夹
|
||||
1、非公共脚本资源,尽量不放到主包内
|
||||
3、图片、字体等非脚本类公共资源,尽量不放到主包内(因为构建后这些资源会被拷贝到其它Bundle中)
|
||||
2、如果公共脚本资源体积较大,可以考虑放到Bundle内,保证首屏体积尽量小
|
||||
4、如不再需要,可以直接删除此文件夹
|
||||
4
extensions/app/engine/res/readme/resources.md
Normal file
4
extensions/app/engine/res/readme/resources.md
Normal file
@@ -0,0 +1,4 @@
|
||||
系统动态资源目录
|
||||
1、脚本资源一定不要放在此文件夹内🔥
|
||||
2、可使用app.manager.loader.load动态加载
|
||||
3、如不再需要,可以直接删除此文件夹
|
||||
3
extensions/app/engine/res/readme/sound-effect.md
Normal file
3
extensions/app/engine/res/readme/sound-effect.md
Normal file
@@ -0,0 +1,3 @@
|
||||
存储音效资源的文件夹
|
||||
1、通过app.manager.sound.playEffect播放
|
||||
2、如不再需要,可以直接删除此文件夹
|
||||
3
extensions/app/engine/res/readme/sound-music.md
Normal file
3
extensions/app/engine/res/readme/sound-music.md
Normal file
@@ -0,0 +1,3 @@
|
||||
存储音乐资源的文件夹
|
||||
1、通过app.manager.sound.playMusic播放
|
||||
2、如不再需要,可以直接删除此文件夹
|
||||
2
extensions/app/engine/res/readme/view-expansion.md
Normal file
2
extensions/app/engine/res/readme/view-expansion.md
Normal file
@@ -0,0 +1,2 @@
|
||||
1、只能存放脚本⚠️
|
||||
2、如不再需要,可以直接删除此文件夹
|
||||
4
extensions/app/engine/res/readme/view-native.md
Normal file
4
extensions/app/engine/res/readme/view-native.md
Normal file
@@ -0,0 +1,4 @@
|
||||
存放UI以及脚本的文件夹
|
||||
1、除了UI本身外,不允许存放其它任何预置体或场景资源🔥
|
||||
2、UI脚本在根目录下,其它脚本放到expansion目录下
|
||||
3、不可单独删除此文件夹
|
||||
6
extensions/app/engine/res/readme/view-resources.md
Normal file
6
extensions/app/engine/res/readme/view-resources.md
Normal file
@@ -0,0 +1,6 @@
|
||||
UI资源目录
|
||||
1、脚本资源一定不要放在此文件夹内🔥
|
||||
2、资源会随着UI销毁自动释放
|
||||
3、在UI脚本内可通过this.loadRes动态加载
|
||||
4、在UI子节点的脚本内可通过app.manager.ui.loadRes(this, ...)动态加载
|
||||
5、不可单独删除此文件夹
|
||||
15
extensions/app/engine/src/builder/hooks.ts
Normal file
15
extensions/app/engine/src/builder/hooks.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import path from 'path';
|
||||
import { BuildHook } from '../../@types/packages/builder/@types';
|
||||
import { adaptFileMD5 } from './utils/file';
|
||||
|
||||
export const onAfterBuild: BuildHook.onAfterBuild = async function (options, result) {
|
||||
if (options.platform !== 'web-mobile' && options.platform !== 'web-desktop') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!options.md5Cache) {
|
||||
return;
|
||||
}
|
||||
|
||||
adaptFileMD5(path.join(result.dest, 'index.html'));
|
||||
};
|
||||
7
extensions/app/engine/src/builder/index.ts
Normal file
7
extensions/app/engine/src/builder/index.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { BuildPlugin } from "../../@types/packages/builder/@types";
|
||||
|
||||
export const configs: BuildPlugin.Configs = {
|
||||
'*': {
|
||||
hooks: './hooks',
|
||||
}
|
||||
};
|
||||
255
extensions/app/engine/src/builder/utils/file.ts
Normal file
255
extensions/app/engine/src/builder/utils/file.ts
Normal file
@@ -0,0 +1,255 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import md5 from './md5';
|
||||
|
||||
const includeExts = ['.html', '.css', '.js', '.json'];
|
||||
const regExp = new RegExp('(?<=(\'|"|url\\(|URL\\())(?!//)[a-zA-Z0-9_\./-]+\\.(js|css|json|png|apng|jpg|jpeg|gif|svg)(?=(\'|"|\\)))', 'g');
|
||||
|
||||
/**
|
||||
* 获取文件夹内的文件
|
||||
*/
|
||||
function getFiles(dir: string): string[] {
|
||||
const result: string[] = [];
|
||||
|
||||
// 判断文件是否存在
|
||||
if (!fs.existsSync(dir)) return result;
|
||||
|
||||
// 如果不是文件夹则返回
|
||||
if (!fs.statSync(dir).isDirectory()) return result;
|
||||
|
||||
// 遍历文件夹
|
||||
fs.readdirSync(dir).forEach(item => {
|
||||
const item_path = path.join(dir, item);
|
||||
const isDir = fs.statSync(item_path).isDirectory();
|
||||
if (!isDir) result.push(item_path);
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 以某个文件为起点,对其引用的文件树进行md5
|
||||
* @param filepath 文件路径
|
||||
* @param exclude 排除的文件路径(不带md5,不支持相对路径),排除的文件不会遍历子文件树,默认其本身会进行md5
|
||||
*/
|
||||
export function adaptFileMD5(filepath: string, exclude: { path: string | RegExp, md5?: boolean }[] = []) {
|
||||
// 参数不合法
|
||||
if (!filepath) return false;
|
||||
|
||||
// 修正文件路径
|
||||
filepath = fs.existsSync(filepath) ? filepath : queryFile(filepath);
|
||||
if (!filepath) return false;
|
||||
|
||||
// 排除的文件
|
||||
const fileExt = path.extname(filepath);
|
||||
const filepathNoMD5 = getFilePathRemoveMD5(filepath);
|
||||
const excludeItem = exclude.find(item => {
|
||||
if (item.path instanceof RegExp) return item.path.test(filepath);
|
||||
else return item.path === filepathNoMD5;
|
||||
});
|
||||
const isExcluded = !!excludeItem || includeExts.indexOf(fileExt) === -1;
|
||||
|
||||
// 文件扩展名
|
||||
if (!isExcluded) {
|
||||
// 文件目录
|
||||
const fileDir = path.dirname(filepath);
|
||||
// 文件内容
|
||||
let fileText = fs.readFileSync(filepath, 'utf-8');
|
||||
// 文件内所有引用的相对路径(排重)
|
||||
const subRelativePaths = Array.from(new Set(fileText.match(regExp)));
|
||||
|
||||
for (let index = 0; index < subRelativePaths.length; index++) {
|
||||
// 子文件相对路径(读取到的)
|
||||
const subRelativePath = subRelativePaths[index];
|
||||
// 子文件路径(读取到的)
|
||||
const subFilePath = path.join(fileDir, subRelativePath);
|
||||
|
||||
// 如果当前引用的文件的路径带有md5戳,并且文件存在,则跳过
|
||||
if (isFileNameHasMD5(subFilePath) && fs.existsSync(subFilePath)) continue;
|
||||
|
||||
{
|
||||
// 实际的子文件路径(不确定有没有md5)
|
||||
const subFilePathReal = queryFile(subFilePath);
|
||||
// 实际的子文件不存在
|
||||
if (!subFilePathReal) {
|
||||
// console.warn('[跳过] [文件不存在]', filepath, subRelativePath);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 如果引用的文件路径不带md5,但是实际文件有md5,则
|
||||
if (!isFileNameHasMD5(subFilePath) && isFileNameHasMD5(subFilePathReal)) {
|
||||
|
||||
// 原始的子文件名
|
||||
const subFileBasename = path.basename(subRelativePath);
|
||||
// 实际的子文件名(带md5)
|
||||
const subFileBasenameReal = path.basename(subFilePathReal);
|
||||
// 替换
|
||||
fileText = fileText.replace(new RegExp(subRelativePath, 'g'), subRelativePath.replace(subFileBasename, subFileBasenameReal));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// 对它进行md5处理
|
||||
const result = adaptFileMD5(subFilePath, exclude);
|
||||
// 文件不存在
|
||||
if (!result) {
|
||||
// console.warn('[跳过] [文件不存在]', filepath, subRelativePath);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 实际的子文件路径(已经带上md5了)
|
||||
const subFilepathReal = queryFile(subFilePath);
|
||||
// 原始的子文件名
|
||||
const subFileBasename = path.basename(subRelativePath);
|
||||
// 实际的子文件名(带md5)
|
||||
const subFileBasenameReal = path.basename(subFilepathReal);
|
||||
|
||||
// 替换
|
||||
fileText = fileText.replace(new RegExp(subRelativePath, 'g'), subRelativePath.replace(subFileBasename, subFileBasenameReal));
|
||||
}
|
||||
}
|
||||
|
||||
// 重新写入文件内容
|
||||
fs.writeFileSync(filepath, fileText, 'utf-8');
|
||||
}
|
||||
|
||||
// 将文件md5重命名
|
||||
if (fileExt !== '.html' && excludeItem?.md5 !== false) {
|
||||
renameFileByMD5(filepath);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换某个文件里引用的的文件名
|
||||
* @param {string} filepath 被替换的文件路径
|
||||
* @param {string} adaptDir adaptFile所在的文件夹
|
||||
* @param {string} adaptFile 文件名.后缀,不能包含其他东西
|
||||
*/
|
||||
export function adaptFilename(filepath: string, adaptDir: string, adaptFile: string) {
|
||||
if (!fs.existsSync(filepath)) return false;
|
||||
|
||||
const adaptName = adaptFile.split('.')[0];
|
||||
const adaptExtname = path.extname(adaptFile) || '';
|
||||
|
||||
let text = fs.readFileSync(filepath, 'utf-8');
|
||||
|
||||
const filePaths = getFiles(adaptDir);
|
||||
for (let index = 0; index < filePaths.length; index++) {
|
||||
const filePath = filePaths[index];
|
||||
const basename = path.basename(filePath);
|
||||
const name = basename.split('.')[0];
|
||||
const extname = path.extname(basename) || '';
|
||||
|
||||
if (basename !== adaptFile && name === adaptName && extname === adaptExtname) {
|
||||
const regExp = new RegExp(`(?<=('|"|\/))${name}[\.a-zA-Z0-9]*\\${extname}(?=('|"))`, 'g');
|
||||
text = text.replace(regExp, basename);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fs.writeFileSync(filepath, text, 'utf-8');
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断一个文件是否有md5戳
|
||||
* @param {string} filename
|
||||
*/
|
||||
export function isFileNameHasMD5(filename: string) {
|
||||
filename = path.basename(filename);
|
||||
return filename !== getFileNameRemoveMD5(filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* md5重命名文件名字
|
||||
* @param {string} filePath
|
||||
* @returns
|
||||
*/
|
||||
export function renameFileByMD5(filePath: string) {
|
||||
const basename = getFileNameRemoveMD5(filePath);
|
||||
const extname = path.extname(basename);
|
||||
if (!extname) return filePath;
|
||||
const filename = basename.slice(0, -extname.length);
|
||||
if (!filename) return filePath;
|
||||
const dirname = path.dirname(filePath);
|
||||
|
||||
const txt = fs.readFileSync(filePath, 'utf-8');
|
||||
const renamePath = path.join(dirname, `${filename}.${md5(txt)}${extname}`);
|
||||
fs.renameSync(filePath, renamePath);
|
||||
return renamePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取相同名字相同后缀, 但md5戳不一样的文件数组
|
||||
* @param {string} dir
|
||||
*/
|
||||
export function getFilesBySameNameDiffMD5(dir: string): { name: string; ext: string; files: string[]; }[] {
|
||||
// [ [ {name:'index',ext:'.js',files:['/test/index.js','/test/index.c67d.js']} ]
|
||||
const result = [];
|
||||
const files = getFiles(dir);
|
||||
files.forEach(filepath => {
|
||||
const basename = getFileNameRemoveMD5(filepath);
|
||||
if (!basename) return;
|
||||
const extname = path.extname(basename);
|
||||
if (!extname) return;
|
||||
const filename = basename.slice(0, -extname.length);
|
||||
if (!filename) return;
|
||||
|
||||
const res = result.find(data => data.name === filename && data.ext === extname);
|
||||
if (res) return res.files.push(filepath);
|
||||
|
||||
result.push({
|
||||
name: filename,
|
||||
ext: extname,
|
||||
files: [filepath]
|
||||
});
|
||||
});
|
||||
return result.filter((data) => data.files.length >= 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将文件名中的md5字段去除
|
||||
* @param {string} filename
|
||||
* @returns
|
||||
*/
|
||||
export function getFileNameRemoveMD5(filename: string) {
|
||||
const basename = path.basename(filename)
|
||||
// a-jqw89a.js => a.js
|
||||
// a-jqw89a.min.js => a.min.js
|
||||
.replace(/-[a-z0-9]+\./, '.');
|
||||
|
||||
return basename.split('.').filter((str, index, array) => {
|
||||
if (index === 0 || index === array.length - 1) return true;
|
||||
return index == 1 && str === 'min';
|
||||
}).join('.');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件路径中的md5字段
|
||||
* @param {string} filepath
|
||||
* @returns
|
||||
*/
|
||||
export function getFilePathRemoveMD5(filepath: string) {
|
||||
const dirname = path.dirname(filepath);
|
||||
return path.join(dirname, getFileNameRemoveMD5(filepath));
|
||||
}
|
||||
|
||||
/**
|
||||
* 输入文件路径,可以索引到对应的带有md5的文件路径
|
||||
* @param {string} filepath 文件路径(带后缀)
|
||||
* @returns
|
||||
*/
|
||||
export function queryFile(filepath: string) {
|
||||
// 将文件名中的md5字段去除
|
||||
const filename = getFileNameRemoveMD5(filepath);
|
||||
const fileDir = path.dirname(filepath);
|
||||
|
||||
const filesList = getFiles(fileDir);
|
||||
return filesList.find(filepath => {
|
||||
return path.basename(filepath) === filename;
|
||||
}) || filesList.find(filepath => {
|
||||
return getFileNameRemoveMD5(filepath) === filename;
|
||||
});
|
||||
}
|
||||
388
extensions/app/engine/src/builder/utils/md5.ts
Normal file
388
extensions/app/engine/src/builder/utils/md5.ts
Normal file
@@ -0,0 +1,388 @@
|
||||
/*
|
||||
* JavaScript MD5
|
||||
* https://github.com/blueimp/JavaScript-MD5
|
||||
*
|
||||
* Copyright 2011, Sebastian Tschan
|
||||
* https://blueimp.net
|
||||
*
|
||||
* Licensed under the MIT license:
|
||||
* https://opensource.org/licenses/MIT
|
||||
*
|
||||
* Based on
|
||||
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
|
||||
* Digest Algorithm, as defined in RFC 1321.
|
||||
* Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
|
||||
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
|
||||
* Distributed under the BSD License
|
||||
* See http://pajhome.org.uk/crypt/md5 for more info.
|
||||
*/
|
||||
|
||||
/* global define */
|
||||
|
||||
/* eslint-disable strict */
|
||||
|
||||
/**
|
||||
* Add integers, wrapping at 2^32.
|
||||
* This uses 16-bit operations internally to work around bugs in interpreters.
|
||||
*
|
||||
* @param {number} x First integer
|
||||
* @param {number} y Second integer
|
||||
* @returns {number} Sum
|
||||
*/
|
||||
function safeAdd(x: number, y: number): number {
|
||||
let lsw = (x & 0xffff) + (y & 0xffff);
|
||||
let msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
||||
return (msw << 16) | (lsw & 0xffff);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bitwise rotate a 32-bit number to the left.
|
||||
*
|
||||
* @param {number} num 32-bit number
|
||||
* @param {number} cnt Rotation count
|
||||
* @returns {number} Rotated number
|
||||
*/
|
||||
function bitRotateLeft(num: number, cnt: number): number {
|
||||
return (num << cnt) | (num >>> (32 - cnt));
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic operation the algorithm uses.
|
||||
*
|
||||
* @param {number} q q
|
||||
* @param {number} a a
|
||||
* @param {number} b b
|
||||
* @param {number} x x
|
||||
* @param {number} s s
|
||||
* @param {number} t t
|
||||
* @returns {number} Result
|
||||
*/
|
||||
function md5cmn(q: number, a: number, b: number, x: number, s: number, t: number): number {
|
||||
return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
|
||||
}
|
||||
/**
|
||||
* Basic operation the algorithm uses.
|
||||
*
|
||||
* @param {number} a a
|
||||
* @param {number} b b
|
||||
* @param {number} c c
|
||||
* @param {number} d d
|
||||
* @param {number} x x
|
||||
* @param {number} s s
|
||||
* @param {number} t t
|
||||
* @returns {number} Result
|
||||
*/
|
||||
function md5ff(a: number, b: number, c: number, d: number, x: number, s: number, t: number): number {
|
||||
return md5cmn((b & c) | (~b & d), a, b, x, s, t);
|
||||
}
|
||||
/**
|
||||
* Basic operation the algorithm uses.
|
||||
*
|
||||
* @param {number} a a
|
||||
* @param {number} b b
|
||||
* @param {number} c c
|
||||
* @param {number} d d
|
||||
* @param {number} x x
|
||||
* @param {number} s s
|
||||
* @param {number} t t
|
||||
* @returns {number} Result
|
||||
*/
|
||||
function md5gg(a: number, b: number, c: number, d: number, x: number, s: number, t: number): number {
|
||||
return md5cmn((b & d) | (c & ~d), a, b, x, s, t);
|
||||
}
|
||||
/**
|
||||
* Basic operation the algorithm uses.
|
||||
*
|
||||
* @param {number} a a
|
||||
* @param {number} b b
|
||||
* @param {number} c c
|
||||
* @param {number} d d
|
||||
* @param {number} x x
|
||||
* @param {number} s s
|
||||
* @param {number} t t
|
||||
* @returns {number} Result
|
||||
*/
|
||||
function md5hh(a: number, b: number, c: number, d: number, x: number, s: number, t: number): number {
|
||||
return md5cmn(b ^ c ^ d, a, b, x, s, t);
|
||||
}
|
||||
/**
|
||||
* Basic operation the algorithm uses.
|
||||
*
|
||||
* @param {number} a a
|
||||
* @param {number} b b
|
||||
* @param {number} c c
|
||||
* @param {number} d d
|
||||
* @param {number} x x
|
||||
* @param {number} s s
|
||||
* @param {number} t t
|
||||
* @returns {number} Result
|
||||
*/
|
||||
function md5ii(a: number, b: number, c: number, d: number, x: number, s: number, t: number): number {
|
||||
return md5cmn(c ^ (b | ~d), a, b, x, s, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the MD5 of an array of little-endian words, and a bit length.
|
||||
*
|
||||
* @param {Array} x Array of little-endian words
|
||||
* @param {number} len Bit length
|
||||
* @returns {Array<number>} MD5 Array
|
||||
*/
|
||||
function binlMD5(x: Array<any>, len: number): Array<number> {
|
||||
/* append padding */
|
||||
x[len >> 5] |= 0x80 << len % 32;
|
||||
x[(((len + 64) >>> 9) << 4) + 14] = len;
|
||||
|
||||
let i;
|
||||
let olda;
|
||||
let oldb;
|
||||
let oldc;
|
||||
let oldd;
|
||||
let a = 1732584193;
|
||||
let b = -271733879;
|
||||
let c = -1732584194;
|
||||
let d = 271733878;
|
||||
|
||||
for (i = 0; i < x.length; i += 16) {
|
||||
olda = a;
|
||||
oldb = b;
|
||||
oldc = c;
|
||||
oldd = d;
|
||||
|
||||
a = md5ff(a, b, c, d, x[i], 7, -680876936);
|
||||
d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
|
||||
c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
|
||||
b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
|
||||
a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
|
||||
d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
|
||||
c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
|
||||
b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
|
||||
a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
|
||||
d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
|
||||
c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
|
||||
b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
|
||||
a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
|
||||
d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
|
||||
c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
|
||||
b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
|
||||
|
||||
a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
|
||||
d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
|
||||
c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
|
||||
b = md5gg(b, c, d, a, x[i], 20, -373897302);
|
||||
a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
|
||||
d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
|
||||
c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
|
||||
b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
|
||||
a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
|
||||
d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
|
||||
c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
|
||||
b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
|
||||
a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
|
||||
d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
|
||||
c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
|
||||
b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
|
||||
|
||||
a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
|
||||
d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
|
||||
c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
|
||||
b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
|
||||
a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
|
||||
d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
|
||||
c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
|
||||
b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
|
||||
a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
|
||||
d = md5hh(d, a, b, c, x[i], 11, -358537222);
|
||||
c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
|
||||
b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
|
||||
a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
|
||||
d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
|
||||
c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
|
||||
b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
|
||||
|
||||
a = md5ii(a, b, c, d, x[i], 6, -198630844);
|
||||
d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
|
||||
c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
|
||||
b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
|
||||
a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
|
||||
d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
|
||||
c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
|
||||
b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
|
||||
a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
|
||||
d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
|
||||
c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
|
||||
b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
|
||||
a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
|
||||
d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
|
||||
c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
|
||||
b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
|
||||
|
||||
a = safeAdd(a, olda);
|
||||
b = safeAdd(b, oldb);
|
||||
c = safeAdd(c, oldc);
|
||||
d = safeAdd(d, oldd);
|
||||
}
|
||||
return [a, b, c, d];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an array of little-endian words to a string
|
||||
*
|
||||
* @param {Array<number>} input MD5 Array
|
||||
* @returns {string} MD5 string
|
||||
*/
|
||||
function binl2rstr(input: Array<number>): string {
|
||||
let i;
|
||||
let output = '';
|
||||
let length32 = input.length * 32;
|
||||
for (i = 0; i < length32; i += 8) {
|
||||
output += String.fromCharCode((input[i >> 5] >>> i % 32) & 0xff);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a raw string to an array of little-endian words
|
||||
* Characters >255 have their high-byte silently ignored.
|
||||
*
|
||||
* @param {string} input Raw input string
|
||||
* @returns {Array<number>} Array of little-endian words
|
||||
*/
|
||||
function rstr2binl(input: string): Array<number> {
|
||||
let i;
|
||||
let output = [];
|
||||
output[(input.length >> 2) - 1] = undefined;
|
||||
for (i = 0; i < output.length; i += 1) {
|
||||
output[i] = 0;
|
||||
}
|
||||
let length8 = input.length * 8;
|
||||
for (i = 0; i < length8; i += 8) {
|
||||
output[i >> 5] |= (input.charCodeAt(i / 8) & 0xff) << i % 32;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the MD5 of a raw string
|
||||
*
|
||||
* @param {string} s Input string
|
||||
* @returns {string} Raw MD5 string
|
||||
*/
|
||||
function rstrMD5(s: string): string {
|
||||
return binl2rstr(binlMD5(rstr2binl(s), s.length * 8));
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the HMAC-MD5 of a key and some data (raw strings)
|
||||
*
|
||||
* @param {string} key HMAC key
|
||||
* @param {string} data Raw input string
|
||||
* @returns {string} Raw MD5 string
|
||||
*/
|
||||
function rstrHMACMD5(key: string, data: string): string {
|
||||
let i;
|
||||
let bkey = rstr2binl(key);
|
||||
let ipad = [];
|
||||
let opad = [];
|
||||
let hash;
|
||||
ipad[15] = opad[15] = undefined;
|
||||
if (bkey.length > 16) {
|
||||
bkey = binlMD5(bkey, key.length * 8);
|
||||
}
|
||||
for (i = 0; i < 16; i += 1) {
|
||||
ipad[i] = bkey[i] ^ 0x36363636;
|
||||
opad[i] = bkey[i] ^ 0x5c5c5c5c;
|
||||
}
|
||||
hash = binlMD5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
|
||||
return binl2rstr(binlMD5(opad.concat(hash), 512 + 128));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a raw string to a hex string
|
||||
*
|
||||
* @param {string} input Raw input string
|
||||
* @returns {string} Hex encoded string
|
||||
*/
|
||||
function rstr2hex(input: string): string {
|
||||
let hexTab = '0123456789abcdef';
|
||||
let output = '';
|
||||
let x;
|
||||
let i;
|
||||
for (i = 0; i < input.length; i += 1) {
|
||||
x = input.charCodeAt(i);
|
||||
output += hexTab.charAt((x >>> 4) & 0x0f) + hexTab.charAt(x & 0x0f);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode a string as UTF-8
|
||||
*
|
||||
* @param {string} input Input string
|
||||
* @returns {string} UTF8 string
|
||||
*/
|
||||
function str2rstrUTF8(input: string): string {
|
||||
return unescape(encodeURIComponent(input));
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes input string as raw MD5 string
|
||||
*
|
||||
* @param {string} s Input string
|
||||
* @returns {string} Raw MD5 string
|
||||
*/
|
||||
function rawMD5(s: string): string {
|
||||
return rstrMD5(str2rstrUTF8(s));
|
||||
}
|
||||
/**
|
||||
* Encodes input string as Hex encoded string
|
||||
*
|
||||
* @param {string} s Input string
|
||||
* @returns {string} Hex encoded string
|
||||
*/
|
||||
function hexMD5(s: string): string {
|
||||
return rstr2hex(rawMD5(s));
|
||||
}
|
||||
/**
|
||||
* Calculates the raw HMAC-MD5 for the given key and data
|
||||
*
|
||||
* @param {string} k HMAC key
|
||||
* @param {string} d Input string
|
||||
* @returns {string} Raw MD5 string
|
||||
*/
|
||||
function rawHMACMD5(k: string, d: string): string {
|
||||
return rstrHMACMD5(str2rstrUTF8(k), str2rstrUTF8(d));
|
||||
}
|
||||
/**
|
||||
* Calculates the Hex encoded HMAC-MD5 for the given key and data
|
||||
*
|
||||
* @param {string} k HMAC key
|
||||
* @param {string} d Input string
|
||||
* @returns {string} Raw MD5 string
|
||||
*/
|
||||
function hexHMACMD5(k: string, d: string): string {
|
||||
return rstr2hex(rawHMACMD5(k, d));
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates MD5 value for a given string.
|
||||
* If a key is provided, calculates the HMAC-MD5 value.
|
||||
* Returns a Hex encoded string unless the raw argument is given.
|
||||
*
|
||||
* @param {string} string Input string
|
||||
* @param {string} [key] HMAC key
|
||||
* @param {boolean} [raw] Raw output switch
|
||||
* @returns {string} MD5 output
|
||||
*/
|
||||
export default function md5(string: string, key?: string, raw?: boolean): string {
|
||||
if (!key) {
|
||||
if (!raw) {
|
||||
return hexMD5(string);
|
||||
}
|
||||
return rawMD5(string);
|
||||
}
|
||||
if (!raw) {
|
||||
return hexHMACMD5(key, string);
|
||||
}
|
||||
return rawHMACMD5(key, string);
|
||||
}
|
||||
87
extensions/app/engine/src/inspector/asset-directory.ts
Normal file
87
extensions/app/engine/src/inspector/asset-directory.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
'use strict';
|
||||
|
||||
import { existsSync, readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
interface Asset {
|
||||
displayName: string;
|
||||
file: string;
|
||||
imported: boolean;
|
||||
importer: string;
|
||||
invalid: boolean;
|
||||
isDirectory: boolean;
|
||||
library: {
|
||||
[extname: string]: string;
|
||||
};
|
||||
name: string;
|
||||
url: string;
|
||||
uuid: string;
|
||||
visible: boolean;
|
||||
subAssets: {
|
||||
[id: string]: Asset;
|
||||
};
|
||||
}
|
||||
|
||||
interface Meta {
|
||||
files: string[];
|
||||
imported: boolean;
|
||||
importer: string;
|
||||
subMetas: {
|
||||
[id: string]: Meta;
|
||||
};
|
||||
userData: {
|
||||
[key: string]: any;
|
||||
};
|
||||
uuid: string;
|
||||
ver: string;
|
||||
}
|
||||
|
||||
type Selector<$> = { $: Record<keyof $, HTMLElement> } & { dispatch(str: string): void, assetList: Asset[], metaList: Meta[] };
|
||||
|
||||
export const $ = {
|
||||
'code': '#code',
|
||||
'section': '#section',
|
||||
};
|
||||
|
||||
export const template = `
|
||||
<ui-section id="section" header="文件夹说明" expand>
|
||||
<ui-code id="code"></ui-code>
|
||||
</ui-section>
|
||||
`;
|
||||
|
||||
type PanelThis = Selector<typeof $>;
|
||||
|
||||
export function update(this: PanelThis, assetList: Asset[], metaList: Meta[]) {
|
||||
this.assetList = assetList;
|
||||
this.metaList = metaList;
|
||||
|
||||
if (assetList.length === 0) {
|
||||
this.$.code.innerHTML = '';
|
||||
} else {
|
||||
this.$.code.innerHTML = assetList
|
||||
.filter((asset) => {
|
||||
const mdFile = join(asset.file, `.${asset.name}.md`);
|
||||
return existsSync(mdFile);
|
||||
})
|
||||
.map((asset) => {
|
||||
const mdFile = join(asset.file, `.${asset.name}.md`);
|
||||
const mdStr = readFileSync(mdFile, 'utf-8');
|
||||
return assetList.length > 1 ? `${asset.url}:\n ${mdStr}` : mdStr;
|
||||
})
|
||||
.join('\n') || '';
|
||||
}
|
||||
|
||||
if (this.$.code.innerHTML === '') {
|
||||
this.$.section.hidden = true;
|
||||
} else {
|
||||
this.$.section.hidden = false;
|
||||
}
|
||||
}
|
||||
|
||||
export function ready(this: PanelThis) {
|
||||
// TODO something
|
||||
}
|
||||
|
||||
export function close(this: PanelThis,) {
|
||||
// TODO something
|
||||
}
|
||||
566
extensions/app/engine/src/main.ts
Executable file
566
extensions/app/engine/src/main.ts
Executable file
@@ -0,0 +1,566 @@
|
||||
|
||||
/**
|
||||
* @en Registration method for the main process of Extension
|
||||
* @zh 为扩展的主进程的注册方法
|
||||
*/
|
||||
/**
|
||||
* // 打开panel
|
||||
* Editor.Panel.open(`${插件名}.${panel名}`);
|
||||
* // 调用普通事件
|
||||
* Editor.Message.request(插件名, 消息名, ...args);
|
||||
* // 调用场景方法
|
||||
* Editor.Message.request('scene', 'execute-scene-script', {
|
||||
* //插件名
|
||||
* name: string,
|
||||
* //方法名
|
||||
* method: string,
|
||||
* //参数列表
|
||||
* args: any[]
|
||||
* });
|
||||
*
|
||||
*/
|
||||
|
||||
// path.join不能正确处理'db://'结构,会把'//'变成'/'
|
||||
|
||||
import { existsSync, readFileSync } from 'fs';
|
||||
import path from 'path';
|
||||
import { AssetInfo } from '../@types/packages/asset-db/@types/public';
|
||||
import { convertUrlToPath, createFolderByUrl, getResMeta, getResReadme, stringCase, stringCaseNegate } from './utils';
|
||||
const electron = require('electron');
|
||||
|
||||
const adminFolderName = 'app-admin';
|
||||
const controllerFolderName = 'app-controller';
|
||||
const managerFolderName = 'app-manager';
|
||||
const modelFolderName = 'app-model';
|
||||
const soundFolderName = 'app-sound';
|
||||
const viewFolderName = 'app-view';
|
||||
const builtinFolderName = 'app-builtin';
|
||||
const bundleFolderName = 'app-bundle';
|
||||
|
||||
const pkgFolderUrl = 'db://pkg/';
|
||||
const pkgFolderPath = convertUrlToPath(pkgFolderUrl);
|
||||
|
||||
const builtinFolderUrl = 'db://assets/' + builtinFolderName;
|
||||
const builtinFolderPath = convertUrlToPath(builtinFolderUrl);
|
||||
|
||||
const bundleFolderUrl = 'db://assets/' + bundleFolderName;
|
||||
const bundleFolderPath = convertUrlToPath(bundleFolderUrl);
|
||||
|
||||
const adminFolderUrl = builtinFolderUrl + '/' + adminFolderName;
|
||||
const adminFolderPath = builtinFolderPath + '/' + adminFolderName;
|
||||
|
||||
const controllerFolderUrl = builtinFolderUrl + '/' + controllerFolderName;
|
||||
const controllerFolderPath = builtinFolderPath + '/' + controllerFolderName;
|
||||
|
||||
const managerFolderUrl = builtinFolderUrl + '/' + managerFolderName;
|
||||
const managerFolderPath = builtinFolderPath + '/' + managerFolderName;
|
||||
|
||||
const modelFolderUrl = builtinFolderUrl + '/' + modelFolderName;
|
||||
const modelFolderPath = builtinFolderPath + '/' + modelFolderName;
|
||||
|
||||
const soundFolderUrl = bundleFolderUrl + '/' + soundFolderName;
|
||||
const soundFolderPath = bundleFolderPath + '/' + soundFolderName;
|
||||
|
||||
const viewFolderUrl = bundleFolderUrl + '/' + viewFolderName;
|
||||
const viewFolderPath = bundleFolderPath + '/' + viewFolderName;
|
||||
|
||||
const executorFileUrl = adminFolderUrl + '/executor.ts';
|
||||
const executorFilePath = adminFolderPath + '/executor.ts';
|
||||
|
||||
function isExecutor(info: AssetInfo, strict = true) {
|
||||
if (!strict) {
|
||||
if (info.path.endsWith('Controller') && info.type === 'cc.Script') return true;
|
||||
if (info.path.endsWith('Manager') && (info.type === 'cc.Script' || info.type === 'cc.Prefab')) return true;
|
||||
if ((info.name.startsWith('data.') || info.name.startsWith('config.') || info.name.startsWith('store.')) && info.type === 'cc.Script') return true;
|
||||
if ((info.name.startsWith('Page') || info.name.startsWith('Paper') || info.name.startsWith('Pop') || info.name.startsWith('Top'))
|
||||
&& (info.type === 'cc.Script' || info.type === 'cc.Prefab' || info.type === 'cc.Scene' || info.type === 'cc.SceneAsset')) return true;
|
||||
if (info.type === 'cc.AudioClip') return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (info.path === builtinFolderUrl) return true;
|
||||
if (info.path === bundleFolderUrl) return true;
|
||||
if (info.path === managerFolderUrl) return true;
|
||||
if (info.path === controllerFolderUrl) return true;
|
||||
if (info.path === modelFolderUrl) return true;
|
||||
if (info.path === soundFolderUrl) return true;
|
||||
if (info.path === viewFolderUrl) return true;
|
||||
|
||||
if (info.path.startsWith(controllerFolderUrl)) {
|
||||
return info.path.endsWith('Controller') && info.type === 'cc.Script';
|
||||
}
|
||||
if (info.path.startsWith(managerFolderUrl)) {
|
||||
return info.path.endsWith('Manager') && (info.type === 'cc.Script' || info.type === 'cc.Prefab');
|
||||
}
|
||||
if (info.path.startsWith(modelFolderUrl)) {
|
||||
return (info.name.startsWith('data.') || info.name.startsWith('config.') || info.name.startsWith('store.')) && info.type === 'cc.Script';
|
||||
}
|
||||
if (info.path.startsWith(viewFolderUrl)) {
|
||||
return (info.name.startsWith('Page') || info.name.startsWith('Paper') || info.name.startsWith('Pop') || info.name.startsWith('Top'))
|
||||
&& (info.type === 'cc.Script' || info.type === 'cc.Prefab' || info.type === 'cc.Scene' || info.type === 'cc.SceneAsset');
|
||||
}
|
||||
if (info.path.startsWith(soundFolderUrl)) {
|
||||
return info.type === 'cc.AudioClip';
|
||||
}
|
||||
}
|
||||
|
||||
function compareStr(str1: string, str2: string) {
|
||||
if (str1 === str2) {
|
||||
return 0;
|
||||
}
|
||||
const len = Math.max(str1.length, str2.length);
|
||||
for (let i = 0, code1 = 0, code2 = 0; i < len; i++) {
|
||||
if (str1.length <= i) {
|
||||
return -1;
|
||||
} else if (str2.length <= i) {
|
||||
return 1;
|
||||
} else {
|
||||
code1 = str1.charCodeAt(i);
|
||||
code2 = str2.charCodeAt(i);
|
||||
if (code1 > code2) {
|
||||
return 1;
|
||||
} else if (code1 < code2) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const viewSelect = ['Page', 'Paper', 'Pop', 'Top'];
|
||||
const viewRegExp = RegExp(`^(${viewSelect.join('|')})`);
|
||||
|
||||
function readFileSyncByPath(url: string) {
|
||||
const filepath = convertUrlToPath(url);
|
||||
return existsSync(filepath) ? readFileSync(filepath, 'utf8') : '';
|
||||
}
|
||||
|
||||
function isTSDefault(value: string[]) {
|
||||
// const varname = value[0];
|
||||
const filename = value[1];
|
||||
const dirname = value[2];
|
||||
const extname = value[3];
|
||||
|
||||
if (extname.endsWith('js')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const filepath = path.join(convertUrlToPath(dirname), filename + '.ts');
|
||||
const js = readFileSync(filepath, 'utf8');
|
||||
return js.search(/export\s+default/) >= 0;
|
||||
}
|
||||
|
||||
const keyWords = [
|
||||
'lib', 'manager', 'Manager', 'controller', 'Controller', 'data', 'config', 'store',
|
||||
'IViewName', 'IViewNames', 'IMiniViewName', 'IMiniViewNames', 'IMusicName', 'IMusicNames', 'IEffectName', 'IEffectNames',
|
||||
'ViewName', 'MiniViewName', 'MusicName', 'EffectName'
|
||||
];
|
||||
|
||||
async function clearExecutor() {
|
||||
if (!existsSync(executorFilePath)) return;
|
||||
|
||||
let result = '/* eslint-disable */\n' +
|
||||
'import { Component } from \'cc\';\n' +
|
||||
'import { app } from \'../../app/app\';\n' +
|
||||
'import { EDITOR,EDITOR_NOT_IN_PREVIEW } from \'cc/env\';\n\n';
|
||||
|
||||
result += 'export type IReadOnly<T> = { readonly [P in keyof T]: T[P] extends Function ? T[P] : (T[P] extends Object ? IReadOnly<T[P]> : T[P]); };\n\n';
|
||||
|
||||
result += 'export type IViewName = "never"\n';
|
||||
result += 'export type IViewNames = IViewName[]\n';
|
||||
result += 'export type IMiniViewName = "never"\n';
|
||||
result += 'export type IMiniViewNames = IMiniViewName[]\n';
|
||||
result += 'export type IMusicName = "never"\n';
|
||||
result += 'export type IMusicNames = IMusicName[]\n';
|
||||
result += 'export type IEffectName = "never"\n';
|
||||
result += 'export type IEffectNames = IEffectName[]\n\n';
|
||||
|
||||
result += 'export type IApp = {\n';
|
||||
result += ' Controller: {},\n';
|
||||
result += ' controller: {},\n';
|
||||
result += ' Manager: {},\n';
|
||||
result += ' manager: {},\n';
|
||||
result += ' data: {},\n';
|
||||
result += ' config: {}\n';
|
||||
result += ' store: {}\n';
|
||||
result += '}\n';
|
||||
|
||||
// config
|
||||
result += 'if(!EDITOR||!EDITOR_NOT_IN_PREVIEW) Object.assign(app.config, {})\n';
|
||||
// data
|
||||
result += 'if(!EDITOR||!EDITOR_NOT_IN_PREVIEW) Object.assign(app.data, {})\n';
|
||||
// store
|
||||
result += 'if(!EDITOR||!EDITOR_NOT_IN_PREVIEW) Object.assign(app.store, {})\n\n';
|
||||
// controller
|
||||
result += 'if(!EDITOR||!EDITOR_NOT_IN_PREVIEW) Object.assign(app.Controller, {})\n';
|
||||
result += 'if(!EDITOR||!EDITOR_NOT_IN_PREVIEW) Object.assign(app.controller, {})\n\n';
|
||||
|
||||
// 修正windows系统中的\为/
|
||||
result = result.replace(/\\/g, '/');
|
||||
|
||||
// save
|
||||
if (readFileSyncByPath(executorFileUrl) !== result) {
|
||||
await Editor.Message.request('asset-db', 'create-asset', executorFileUrl, result, {
|
||||
overwrite: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function updateExecutor() {
|
||||
// app-builtin文件夹不存在, 创建
|
||||
if (!existsSync(builtinFolderPath)) await createFolderByUrl(builtinFolderUrl, { readme: getResReadme(builtinFolderName) });
|
||||
// app-admin文件夹不存在, 创建
|
||||
if (!existsSync(adminFolderPath)) await createFolderByUrl(adminFolderUrl, { meta: getResMeta(adminFolderName), readme: getResReadme(adminFolderName) });
|
||||
|
||||
const mgrList: string[][] = [];
|
||||
const ctrList: string[][] = [];
|
||||
const dataList: string[][] = [];
|
||||
const confList: string[][] = [];
|
||||
const storeList: string[][] = [];
|
||||
|
||||
const viewScene: { [name in string]: boolean } = {};
|
||||
const miniViewKeys: { [name in string]: string } = {};
|
||||
const musicKeys: { [name in string]: string } = {};
|
||||
const effectKeys: { [name in string]: string } = {};
|
||||
|
||||
// app-controller app-manager app-model
|
||||
const result1: AssetInfo[] = await Editor.Message.request('asset-db', 'query-assets', { pattern: builtinFolderUrl + '/{app-controller,app-manager/*,app-model}/*.ts' })
|
||||
.then(res => {
|
||||
return res.sort((a, b) => compareStr(a.name, b.name));
|
||||
})
|
||||
.catch(() => []);
|
||||
// app-sound
|
||||
const result2: AssetInfo[] = await Editor.Message.request('asset-db', 'query-assets', { pattern: soundFolderUrl + '/{music,effect}/**/*.*' })
|
||||
.then(res => {
|
||||
return res.sort((a, b) => compareStr(a.name, b.name));
|
||||
})
|
||||
.catch(() => []);
|
||||
// app-view
|
||||
const result3: AssetInfo[] = await Editor.Message.request('asset-db', 'query-assets', { pattern: viewFolderUrl + '/{page,pop,top,paper/*}/*/native/*.{prefab,scene}' })
|
||||
.then(res => {
|
||||
return res.sort((a, b) => compareStr(a.name, b.name));
|
||||
})
|
||||
.catch(() => []);
|
||||
// manager
|
||||
const result4: AssetInfo[] = await Editor.Message.request('asset-db', 'query-assets', { pattern: 'db://app/manager/**/*.ts' })
|
||||
.then(res => {
|
||||
return res.sort((a, b) => compareStr(a.name, b.name));
|
||||
})
|
||||
.catch(() => []);
|
||||
// 集合
|
||||
const results: AssetInfo[] = result1.slice().concat(result2).concat(result3).concat(result4);
|
||||
|
||||
for (let index = 0; index < results.length; index++) {
|
||||
const result = results[index];
|
||||
const fileUrl = result.url;
|
||||
// 文件名.扩展名
|
||||
const basename = path.basename(result.url || '') || '';
|
||||
// 扩展名
|
||||
const extname = path.extname(result.url || '') || '';
|
||||
// 文件名
|
||||
const filename = basename.slice(0, -extname.length);
|
||||
// 文件目录名
|
||||
const dirname = path.dirname(result.url || '') || '';
|
||||
|
||||
if (!basename) continue;
|
||||
if (!extname) continue;
|
||||
if (!filename) continue;
|
||||
if (!dirname) continue;
|
||||
|
||||
if (extname === '.ts') {
|
||||
// 变量名
|
||||
const varname = filename.replace(/[.-]/g, '_');
|
||||
|
||||
if (keyWords.indexOf(varname) >= 0) {
|
||||
console.log(`[跳过此文件] [${filename}] 原因: ${varname}与关键字中(${JSON.stringify(keyWords)})的一个重复`);
|
||||
}
|
||||
else if (fileUrl.startsWith(controllerFolderUrl)) {
|
||||
// 用户controller
|
||||
if (filename.endsWith('Controller')) {
|
||||
ctrList.push([varname, filename, dirname, extname]);
|
||||
}
|
||||
}
|
||||
else if (fileUrl.startsWith(managerFolderUrl)) {
|
||||
// 用户manager
|
||||
if (filename.endsWith('Manager') && dirname.endsWith(stringCaseNegate(filename.slice(0, -7)))) {
|
||||
mgrList.push([varname, filename, dirname, extname]);
|
||||
}
|
||||
}
|
||||
else if (fileUrl.startsWith('db://app/manager/')) {
|
||||
// 系统manager(系统Mgr的文件夹命名为了美观没有那么规范,所以和用户Mgr的逻辑有区别)
|
||||
if (filename.endsWith('Manager') && dirname.endsWith(filename.slice(0, -7).toLowerCase())) {
|
||||
mgrList.push([varname, filename, dirname, extname]);
|
||||
}
|
||||
}
|
||||
else if (fileUrl.startsWith(modelFolderUrl)) {
|
||||
// model
|
||||
if (filename.startsWith('data.')) {
|
||||
dataList.push([varname, filename, dirname, extname]);
|
||||
} else if (filename.startsWith('config.')) {
|
||||
confList.push([varname, filename, dirname, extname]);
|
||||
} else if (filename.startsWith('store.')) {
|
||||
storeList.push([varname, filename, dirname, extname]);
|
||||
}
|
||||
}
|
||||
} else if (extname === '.prefab' || extname === '.scene') {
|
||||
if (fileUrl.startsWith(viewFolderUrl) && viewRegExp.test(filename)) {
|
||||
const dirArray = dirname.split('/');
|
||||
const index = dirArray.indexOf(viewFolderName);
|
||||
const viewDirArray = dirArray.slice(index + 1);
|
||||
|
||||
if (['page', 'paper', 'pop', 'top'].indexOf(viewDirArray[0].toLowerCase()) >= 0) {
|
||||
// 主界面
|
||||
if (filename === `${stringCase(viewDirArray[0], false)}${stringCase(viewDirArray[1], false)}`) {
|
||||
viewScene[filename] = extname === '.scene';
|
||||
}
|
||||
// 子界面
|
||||
else if (filename === `${stringCase(viewDirArray[0], false)}${stringCase(viewDirArray[1], false)}${stringCase(viewDirArray[2], false)}`) {
|
||||
miniViewKeys[filename] = `${stringCase(viewDirArray[0], false)}${stringCase(viewDirArray[1], false)}`;
|
||||
}
|
||||
} else {
|
||||
// 主界面
|
||||
if (filename === `${stringCase(viewDirArray[1], false)}${stringCase(viewDirArray[2], false)}`) {
|
||||
viewScene[filename] = extname === '.scene';
|
||||
}
|
||||
// 子界面
|
||||
else if (filename === `${stringCase(viewDirArray[1], false)}${stringCase(viewDirArray[2], false)}${stringCase(viewDirArray[3], false)}`) {
|
||||
miniViewKeys[filename] = `${stringCase(viewDirArray[0], false)}${stringCase(viewDirArray[1], false)}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (fileUrl.startsWith(soundFolderUrl)) {
|
||||
const dir = path.join(dirname.split(soundFolderName + '/').pop(), filename);
|
||||
if (dir.startsWith('music')) {
|
||||
// musicKeys
|
||||
musicKeys[dir] = dir;
|
||||
} else {
|
||||
// effectKeys
|
||||
effectKeys[dir] = dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// const pkgNames: string[] = [];
|
||||
// if (existsSync(pkgFolderPath)) {
|
||||
// readdirSync(pkgFolderPath).forEach(function (item) {
|
||||
// const item_path = path.join(pkgFolderPath, item);
|
||||
// const item_stat = statSync(item_path);
|
||||
// if (!item_stat.isDirectory()) return;
|
||||
// const item_name = path.basename(item_path);
|
||||
// if (item_name.startsWith('@')) {
|
||||
// readdirSync(item_path).forEach(function (sub) {
|
||||
// const sub_path = path.join(item_path, sub);
|
||||
// const sub_stat = statSync(sub_path);
|
||||
// if (!sub_stat.isDirectory()) return;
|
||||
// const sub_name = path.basename(sub_path);
|
||||
// pkgNames.push(item_name + '/' + sub_name);
|
||||
// });
|
||||
// } else {
|
||||
// pkgNames.push(item_name);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
let result = '/* eslint-disable */\n' +
|
||||
'import { Component,director,Director } from \'cc\';\n' +
|
||||
'import { app } from \'../../app/app\';\n' +
|
||||
'import { EDITOR,EDITOR_NOT_IN_PREVIEW } from \'cc/env\';\n\n';
|
||||
|
||||
result += 'export type IReadOnly<T> = { readonly [P in keyof T]: T[P] extends Function ? T[P] : (T[P] extends Object ? IReadOnly<T[P]> : T[P]); };\n\n';
|
||||
|
||||
result += `export type IViewName = ${Object.keys(viewScene).map(str => `"${str}"`).join('|') || '"never"'}\n`;
|
||||
result += 'export type IViewNames = IViewName[]\n';
|
||||
result += `export type IMiniViewName = ${Object.keys(miniViewKeys).map(str => `"${str}"`).join('|') || '"never"'}\n`;
|
||||
result += 'export type IMiniViewNames = IMiniViewName[]\n';
|
||||
result += `export type IMusicName = ${Object.keys(musicKeys).map(str => `"${str}"`).join('|') || '"never"'}\n`;
|
||||
result += 'export type IMusicNames = IMusicName[]\n';
|
||||
result += `export type IEffectName = ${Object.keys(effectKeys).map(str => `"${str}"`).join('|') || '"never"'}\n`;
|
||||
result += 'export type IEffectNames = IEffectName[]\n\n';
|
||||
|
||||
// pkgNames.forEach(name => result += `import 'db://pkg/${name}'\n`);
|
||||
|
||||
const writeImport = function writeImport(arr: string[][], module: boolean) {
|
||||
return arr.forEach(function (value) {
|
||||
const varname = value[0];
|
||||
const filename = value[1];
|
||||
const dirname = value[2];
|
||||
|
||||
if (isTSDefault(value)) {
|
||||
result += `import ${varname} from '${path.join(path.relative(adminFolderPath, convertUrlToPath(dirname)), filename)}'\n`;
|
||||
} else if (module) {
|
||||
result += `import {${varname}} from '${path.join(path.relative(adminFolderPath, convertUrlToPath(dirname)), filename)}'\n`;
|
||||
} else {
|
||||
result += `import * as ${varname} from '${path.join(path.relative(adminFolderPath, convertUrlToPath(dirname)), filename)}'\n`;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
writeImport(confList, false);
|
||||
writeImport(dataList, false);
|
||||
writeImport(storeList, false);
|
||||
writeImport(ctrList, true);
|
||||
writeImport(mgrList, true);
|
||||
|
||||
// controller
|
||||
let ctrStr = '';
|
||||
let CtrStr = '';
|
||||
ctrList.forEach(function ([varname], index, array) {
|
||||
CtrStr += `${varname.slice(0, -10)}:typeof ${varname}`;
|
||||
ctrStr += `${varname.slice(0, -10).toLowerCase()}:IReadOnly<${varname}>`;
|
||||
if (index < array.length - 1) {
|
||||
CtrStr += ',';
|
||||
ctrStr += ',';
|
||||
}
|
||||
});
|
||||
|
||||
// manager
|
||||
let mgrStr = '';
|
||||
let MgrStr = '';
|
||||
mgrList.forEach(function ([varname], index, array) {
|
||||
MgrStr += `${varname.slice(0, -7)}:Omit<typeof ${varname},keyof Component>`;
|
||||
if (varname === 'UIManager') {
|
||||
mgrStr += `${varname.slice(0, -7).toLowerCase()}:Omit<${varname}<IViewName,IMiniViewName>,keyof Component>`;
|
||||
} else if (varname === 'SoundManager') {
|
||||
mgrStr += `${varname.slice(0, -7).toLowerCase()}:Omit<${varname}<IEffectName,IMusicName>,keyof Component>`;
|
||||
} else {
|
||||
mgrStr += `${varname.slice(0, -7).toLowerCase()}:Omit<${varname},keyof Component>`;
|
||||
}
|
||||
if (index < array.length - 1) {
|
||||
MgrStr += ',';
|
||||
mgrStr += ',';
|
||||
}
|
||||
});
|
||||
|
||||
result += 'export type IApp = {\n';
|
||||
result += ` Controller: {${CtrStr}},\n`;
|
||||
result += ` controller: {${ctrStr}},\n`;
|
||||
result += ` Manager: {${MgrStr}},\n`;
|
||||
result += ` manager: {${mgrStr}},\n`;
|
||||
result += ` data: {${dataList.map(([varname]) => `${varname.slice(5)}:${varname}`).join(',')}},\n`;
|
||||
result += ` config: {${confList.map(([varname]) => `${varname.slice(7)}:IReadOnly<${varname}>`).join(',')}}\n`;
|
||||
result += ` store: {${storeList.map(([varname]) => `${varname.slice(6)}:IReadOnly<${varname}>`).join(',')}}\n`;
|
||||
result += '}\n\n';
|
||||
|
||||
result += 'function init(){\n';
|
||||
// config
|
||||
result += `if(!EDITOR||!EDITOR_NOT_IN_PREVIEW) Object.assign(app.config, {${confList.map(([varname]) => `${varname.slice(7)}:new ${varname}()`).join(',')}})\n`;
|
||||
// data
|
||||
result += `if(!EDITOR||!EDITOR_NOT_IN_PREVIEW) Object.assign(app.data, {${dataList.map(([varname]) => `${varname.slice(5)}:new ${varname}()`).join(',')}})\n`;
|
||||
// store
|
||||
result += `if(!EDITOR||!EDITOR_NOT_IN_PREVIEW) Object.assign(app.store, {${storeList.map(([varname]) => `${varname.slice(6)}:new ${varname}()`).join(',')}})\n\n`;
|
||||
// controller
|
||||
result += `if(!EDITOR||!EDITOR_NOT_IN_PREVIEW) Object.assign(app.Controller, {${ctrList.map(([varname]) => `${varname.slice(0, -10)}:${varname}`).join(',')}})\n`;
|
||||
result += `if(!EDITOR||!EDITOR_NOT_IN_PREVIEW) Object.assign(app.controller, {${ctrList.map(([varname]) => `${varname.slice(0, -10).toLowerCase()}:new ${varname}()`).join(',')}})\n`;
|
||||
result += '}\n';
|
||||
result += 'if(!EDITOR||!EDITOR_NOT_IN_PREVIEW) director.on(Director.EVENT_RESET,init)\n';
|
||||
result += 'if(!EDITOR||!EDITOR_NOT_IN_PREVIEW) init()\n';
|
||||
|
||||
// 修正windows系统中的\为/
|
||||
result = result.replace(/\\/g, '/');
|
||||
|
||||
// save
|
||||
if (readFileSyncByPath(executorFileUrl) !== result) {
|
||||
await Editor.Message.request('asset-db', 'create-asset', executorFileUrl, result, {
|
||||
overwrite: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let timer: NodeJS.Timeout | null = null;
|
||||
function callUpdateExecutor(clear = false) {
|
||||
if (timer) return;
|
||||
if (clear) {
|
||||
clearExecutor();
|
||||
callUpdateExecutor(false);
|
||||
} else {
|
||||
timer = setTimeout(() => {
|
||||
updateExecutor().finally(() => {
|
||||
timer = null;
|
||||
});
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
|
||||
// 获得Creator主窗口
|
||||
function getMainWebContents() {
|
||||
const windows = electron.BrowserWindow.getAllWindows();
|
||||
for (let i = 0; i < windows.length; i++) {
|
||||
const win = windows[i];
|
||||
if (win.webContents.getURL().includes('windows/main.html') || (win.title && win.title.includes('Cocos Creator'))) {
|
||||
return win.webContents;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
function updateMark() {
|
||||
const webContents = getMainWebContents();
|
||||
if (webContents) {
|
||||
const hackCode = readFileSync(path.join(__dirname, '../res/mark.js'), 'utf-8');
|
||||
webContents.executeJavaScript(hackCode);
|
||||
}
|
||||
}
|
||||
|
||||
export const methods: { [key: string]: (...any: any) => any } = {
|
||||
['open-panel']() {
|
||||
Editor.Panel.open('app.open-panel');
|
||||
},
|
||||
['open-wiki']() {
|
||||
const url = 'https://gitee.com/cocos2d-zp/xforge/wikis/pages';
|
||||
Editor.Message.send('program', 'open-url', url);
|
||||
},
|
||||
['open-issues']() {
|
||||
const url = 'https://gitee.com/cocos2d-zp/xforge/issues';
|
||||
Editor.Message.send('program', 'open-url', url);
|
||||
},
|
||||
['open-github']() {
|
||||
const url = 'https://github.com/a1076559139/XForge';
|
||||
Editor.Message.send('program', 'open-url', url);
|
||||
},
|
||||
['open-store']() {
|
||||
const url = 'https://store.cocos.com/app/search?name=xforge';
|
||||
Editor.Message.send('program', 'open-url', url);
|
||||
},
|
||||
['refresh-executor']() {
|
||||
// 点击更新
|
||||
callUpdateExecutor();
|
||||
console.log('[executor.ts] 刷新成功');
|
||||
},
|
||||
['scene:ready']() {
|
||||
//
|
||||
},
|
||||
['asset-db:ready']() {
|
||||
updateExecutor();
|
||||
updateMark();
|
||||
},
|
||||
['asset-db:asset-add'](uuid: string, info: AssetInfo) {
|
||||
if (!isExecutor(info)) return;
|
||||
callUpdateExecutor();
|
||||
},
|
||||
['asset-db:asset-change'](uuid: string, info: AssetInfo) {
|
||||
if (!isExecutor(info, false)) return;
|
||||
callUpdateExecutor();
|
||||
},
|
||||
['asset-db:asset-delete'](uuid: string, info: AssetInfo) {
|
||||
if (!isExecutor(info)) return;
|
||||
callUpdateExecutor(true);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @en Hooks triggered after extension loading is complete
|
||||
* @zh 扩展加载完成后触发的钩子
|
||||
*/
|
||||
export function load() {
|
||||
Editor.Message.request('asset-db', 'query-ready').then(ready => {
|
||||
if (!ready) return;
|
||||
updateExecutor();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @en Hooks triggered after extension uninstallation is complete
|
||||
* @zh 扩展卸载完成后触发的钩子
|
||||
*/
|
||||
export function unload() { }
|
||||
34
extensions/app/engine/src/menu/index.ts
Normal file
34
extensions/app/engine/src/menu/index.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { AssetInfo } from '../../@types/packages/asset-db/@types/public';
|
||||
import tinyPNG from './tinyPNG';
|
||||
|
||||
function getMenu(assetInfo: AssetInfo) {
|
||||
return [
|
||||
{
|
||||
label: 'i18n:app.app',
|
||||
submenu: [
|
||||
{
|
||||
label: 'i18n:app.tiny',
|
||||
click() {
|
||||
tinyPNG(assetInfo.file);
|
||||
},
|
||||
}
|
||||
],
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
export function onCreateMenu(assetInfo: AssetInfo) {
|
||||
// return getMenu();
|
||||
}
|
||||
|
||||
export function onDBMenu(assetInfo: AssetInfo) {
|
||||
// return getMenu();
|
||||
}
|
||||
|
||||
export function onPanelMenu(assetInfo: AssetInfo) {
|
||||
// return getMenu();
|
||||
}
|
||||
|
||||
export function onAssetMenu(assetInfo: AssetInfo) {
|
||||
return getMenu(assetInfo);
|
||||
}
|
||||
204
extensions/app/engine/src/menu/tinyPNG.ts
Normal file
204
extensions/app/engine/src/menu/tinyPNG.ts
Normal file
@@ -0,0 +1,204 @@
|
||||
/**
|
||||
*
|
||||
* 参考: https://segmentfault.com/a/1190000015467084
|
||||
* 优化:通过 X-Forwarded-For 添加了动态随机伪IP,绕过 tinypng 的上传数量限制
|
||||
*
|
||||
*/
|
||||
|
||||
import fs from 'fs';
|
||||
import https from 'https';
|
||||
import path from 'path';
|
||||
import { URL } from 'url';
|
||||
|
||||
const exts = ['.png', '.jpg', '.jpeg'];
|
||||
const max = 5200000; // 5MB == 5242848.754299136
|
||||
|
||||
const options = {
|
||||
method: 'POST',
|
||||
hostname: 'tinypng.com',
|
||||
path: '/backend/opt/shrink',
|
||||
headers: {
|
||||
'rejectUnauthorized': 'false',
|
||||
'Postman-Token': Date.now(),
|
||||
'Cache-Control': 'no-cache',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36'
|
||||
}
|
||||
};
|
||||
|
||||
// 生成随机IP, 赋值给 X-Forwarded-For
|
||||
function getRandomIP() {
|
||||
return Array.from(Array(4)).map(() => Math.floor(Math.random() * 255)).join('.');
|
||||
}
|
||||
|
||||
// 遍历文件列表
|
||||
function fileEach(folder: string, callback: (filePath: string) => any) {
|
||||
fs.readdir(folder, (err, files) => {
|
||||
if (err) console.error(err);
|
||||
files.forEach(file => {
|
||||
const filePath = path.join(folder, file);
|
||||
fs.stat(filePath, (err, stats) => {
|
||||
if (err) return console.error(err);
|
||||
if (stats.isDirectory()) {
|
||||
fileEach(filePath, callback);
|
||||
} else if (
|
||||
// 必须是文件,小于5MB,后缀 jpg||png
|
||||
stats.size <= max &&
|
||||
stats.isFile() &&
|
||||
exts.includes(path.extname(file))
|
||||
) {
|
||||
callback(filePath);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
interface IResponse {
|
||||
input: {
|
||||
size: number;
|
||||
type: string;
|
||||
};
|
||||
output: {
|
||||
size: number;
|
||||
type: string;
|
||||
width: number;
|
||||
height: number;
|
||||
ratio: number;
|
||||
url: string;
|
||||
};
|
||||
error: string;
|
||||
message: string;
|
||||
}
|
||||
// 压缩图片
|
||||
async function fileUpload(img_path: string): Promise<IResponse> {
|
||||
return new Promise((resolve, reject) => {
|
||||
// 通过 X-Forwarded-For 头部伪造客户端IP
|
||||
options.headers['X-Forwarded-For'] = getRandomIP();
|
||||
const req = https.request(options, function (res) {
|
||||
res.on('data', buf => {
|
||||
const data = JSON.parse(buf.toString()) as IResponse;
|
||||
if (data.error) {
|
||||
reject(data.message);
|
||||
} else {
|
||||
resolve(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
req.write(fs.readFileSync(img_path), 'binary');
|
||||
req.on('error', err => {
|
||||
reject(err);
|
||||
});
|
||||
req.end();
|
||||
});
|
||||
}
|
||||
|
||||
// 该方法被循环调用,请求图片数据
|
||||
function fileUpdate(img_path: string, obj: IResponse): Promise<IResponse> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const options = new URL(obj.output.url);
|
||||
const req = https.request(options, res => {
|
||||
let body = '';
|
||||
res.setEncoding('binary');
|
||||
res.on('data', function (data) {
|
||||
body += data;
|
||||
});
|
||||
|
||||
res.on('end', function () {
|
||||
fs.writeFile(img_path, body, 'binary', err => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
resolve(obj);
|
||||
});
|
||||
});
|
||||
});
|
||||
req.on('error', err => {
|
||||
reject(err);
|
||||
});
|
||||
req.end();
|
||||
});
|
||||
}
|
||||
|
||||
// 根据字节大小转成B、KB、MB
|
||||
function toSize(b: number) {
|
||||
if (b < 1024) {
|
||||
return b + 'B';
|
||||
}
|
||||
else if (b < 1024 * 1024) {
|
||||
return (b / 1024).toFixed(2) + 'KB';
|
||||
}
|
||||
else {
|
||||
return (b / 1024 / 1024).toFixed(2) + 'MB';
|
||||
}
|
||||
}
|
||||
|
||||
// 根据小数转成百分比字符串
|
||||
function toPercent(num: number) {
|
||||
return (num * 100).toFixed(2) + '%';
|
||||
}
|
||||
|
||||
async function fileTiny(filePath: string) {
|
||||
return fileUpload(filePath)
|
||||
.then(obj => fileUpdate(filePath, obj));
|
||||
}
|
||||
|
||||
export default function (folder: string) {
|
||||
// 路径是否存在
|
||||
if (!fs.existsSync(folder)) {
|
||||
console.log(`路径不存在:${folder}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const basename = path.basename(folder);
|
||||
console.log(`[${basename}] 压缩中...`);
|
||||
|
||||
// 是文件
|
||||
if (!fs.statSync(folder).isDirectory()) {
|
||||
if (!exts.includes(path.extname(folder))) {
|
||||
console.log(`[${basename}] 压缩失败!报错:只支持png、jpg与jpeg格式`);
|
||||
return;
|
||||
}
|
||||
fileTiny(folder)
|
||||
.then(obj => {
|
||||
console.log(
|
||||
'[1/1]',
|
||||
`[${basename}]`,
|
||||
`压缩成功,原始: ${toSize(obj.input.size)},压缩: ${toSize(obj.output.size)},压缩比: ${toPercent(obj.output.ratio)}`
|
||||
);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(
|
||||
'[1/1]',
|
||||
`[${basename}]`,
|
||||
`压缩失败!报错:${err}`
|
||||
);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let total = 0;
|
||||
let finished = 0;
|
||||
// 是文件夹
|
||||
fileEach(folder, (filePath => {
|
||||
total++;
|
||||
const relativePath = path.relative(folder, filePath);
|
||||
fileTiny(filePath)
|
||||
.then(obj => {
|
||||
console.log(
|
||||
`[${++finished}/${total}]`,
|
||||
`[${relativePath}]`,
|
||||
`压缩成功,原始: ${toSize(obj.input.size)},压缩: ${toSize(obj.output.size)},压缩比: ${toPercent(obj.output.ratio)}`
|
||||
);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(
|
||||
`[${++finished}/${total}]`,
|
||||
`[${relativePath}]`,
|
||||
`压缩失败!报错:${err}`
|
||||
);
|
||||
});
|
||||
}));
|
||||
}
|
||||
29
extensions/app/engine/src/panel/components/app.ts
Normal file
29
extensions/app/engine/src/panel/components/app.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import Vue from '../../../../vue';
|
||||
|
||||
import ControllerComponent from './create-controller';
|
||||
import ManagerComponent from './create-manager';
|
||||
import ModelComponent from './create-model';
|
||||
import ResComponent from './create-res';
|
||||
import SoundComponent from './create-sound';
|
||||
import ViewComponent from './create-view';
|
||||
|
||||
const Assets = join(__dirname, '../../../res/panel');
|
||||
const Menus = ['ViewComponent', 'ManagerComponent', 'ControllerComponent', 'ModelComponent', 'SoundComponent', 'ResComponent'];
|
||||
|
||||
export default Vue.extend({
|
||||
components: { ViewComponent, ManagerComponent, ControllerComponent, ModelComponent, SoundComponent, ResComponent },
|
||||
template: readFileSync(join(Assets, 'components/app.html'), 'utf-8'),
|
||||
data() {
|
||||
return {
|
||||
menus: ['View', 'Manager', 'Controller', 'Model', 'Sound', '资源目录'],
|
||||
content: 'ViewComponent'
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
onClick(index: number) {
|
||||
this.content = Menus[index];
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,91 @@
|
||||
import { existsSync } from 'fs';
|
||||
import Vue from '../../../../vue';
|
||||
import { convertUrlToPath, createFolderByUrl, getResMeta, getResPanel, getResReadme, stringCase } from '../../utils';
|
||||
|
||||
/**
|
||||
* 根据语言获取脚本内容
|
||||
*/
|
||||
function getScript(name: string) {
|
||||
const basePath = '../../../extensions/app/assets/base/BaseController';
|
||||
return 'import BaseController from \'' + basePath + '\';\r\n' +
|
||||
'export class ' + name + ' extends BaseController<' + name + ', {\r\n' +
|
||||
' // 定义了事件,并同时定义参数列表和返回值\r\n' +
|
||||
' Refresh: (a: number) => boolean\r\n' +
|
||||
'}>() {\r\n' +
|
||||
' // Controller中发射事件, UI中监听事件:\r\n' +
|
||||
' // 1、UI中需要将 「extends BaseView」 改为=> 「extends BaseView.bindController(' + name + ')」\r\n' +
|
||||
' // 2、UI中使用「this.controller.on/once」监听事件, 使用「this.controller.emit」发射事件, 使用「this.controller.off/targetOff」取消监听事件\r\n' +
|
||||
' // 3、在外部(无法使用this.controller的地方)可以通过「app.controller.xxx」来调用对外导出的方法, 比如下面的refresh方法\r\n' +
|
||||
' refresh() {\r\n' +
|
||||
' this.emit(' + name + '.Event.Refresh, 1000); // 参数类型正确\r\n' +
|
||||
' this.emit(' + name + '.Event.Refresh, true); // 参数类型错误\r\n' +
|
||||
' const result = this.call(' + name + '.Event.Refresh, 1000); // 自动推导返回值类型\r\n' +
|
||||
' }\r\n' +
|
||||
'}';
|
||||
}
|
||||
|
||||
export default Vue.extend({
|
||||
template: getResPanel('create-controller'),
|
||||
data() {
|
||||
return {
|
||||
inputName: '',
|
||||
display: '',
|
||||
|
||||
showLoading: false
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
async onClickCreate() {
|
||||
const name = this.inputName;
|
||||
|
||||
if (/^[a-z][a-z0-9-]*[a-z0-9]+$/.test(name) === false) {
|
||||
this.display = '[错误] 名字不合法\n1、不能以数字开头\n2、不能有大写字母\n3、分隔符只能使用-\n4、不能以分隔符开头或结尾';
|
||||
return;
|
||||
}
|
||||
|
||||
const rootPath = 'db://assets/app-builtin/app-controller';
|
||||
const controlName = `${stringCase(name)}Controller`;
|
||||
const scriptUrl = `${rootPath}/${controlName}.ts`;
|
||||
|
||||
// 创建前确认
|
||||
const createResponse = await Editor.Dialog.info('请确认', { detail: controlName, buttons: ['创建并打开', '仅创建', '取消'], default: 0, cancel: 2 });
|
||||
if (createResponse.response == 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.display = '创建中';
|
||||
this.showLoading = true;
|
||||
|
||||
if (existsSync(convertUrlToPath(scriptUrl))) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 文件已存在, 请删除\n${scriptUrl}`;
|
||||
return;
|
||||
}
|
||||
|
||||
// 目录如果不存在则创建
|
||||
if (!await createFolderByUrl(rootPath, { meta: getResMeta('app-controller'), readme: getResReadme('app-controller') })) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 创建目录失败\n${rootPath}`;
|
||||
return;
|
||||
}
|
||||
|
||||
// 创建script
|
||||
const createScriptResult = await Editor.Message.request('asset-db', 'create-asset', scriptUrl, getScript(controlName)).catch(_ => null);
|
||||
if (!createScriptResult) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 创建脚本失败\n${scriptUrl}`;
|
||||
return;
|
||||
}
|
||||
|
||||
this.showLoading = false;
|
||||
this.display = `[成功] 创建成功\n${rootPath}`;
|
||||
|
||||
Editor.Message.send('assets', 'twinkle', scriptUrl);
|
||||
|
||||
// 是否打开
|
||||
if (createResponse.response == 0) {
|
||||
Editor.Message.request('asset-db', 'open-asset', scriptUrl);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
116
extensions/app/engine/src/panel/components/create-manager.ts
Normal file
116
extensions/app/engine/src/panel/components/create-manager.ts
Normal file
@@ -0,0 +1,116 @@
|
||||
import { existsSync } from 'fs';
|
||||
import Vue from '../../../../vue';
|
||||
import { convertUrlToPath, createFolderByUrl, getResMeta, getResPanel, getResReadme, stringCase } from '../../utils';
|
||||
|
||||
/**
|
||||
* 根据语言获取脚本内容
|
||||
*/
|
||||
function getScript(name: string) {
|
||||
const basePath = '../../../../extensions/app/assets/base/BaseManager';
|
||||
return 'import { _decorator } from \'cc\';\r\n' +
|
||||
'import BaseManager from \'' + basePath + '\';\r\n' +
|
||||
'const { ccclass, property } = _decorator;\r\n' +
|
||||
'@ccclass(\'' + name + '\')\r\n' +
|
||||
'export class ' + name + ' extends BaseManager {\r\n' +
|
||||
' // [无序] 加载完成时触发\r\n' +
|
||||
' protected onLoad() { }\r\n\r\n' +
|
||||
' // [无序] 自身初始化完成, init执行完毕后被调用\r\n' +
|
||||
' protected onInited() { }\r\n\r\n' +
|
||||
' // [无序] 所有manager初始化完成\r\n' +
|
||||
' protected onFinished() { }\r\n\r\n' +
|
||||
' // [无序] 初始化manager,在初始化完成后,调用finish方法\r\n' +
|
||||
' protected init(finish: Function) {\r\n' +
|
||||
' super.init(finish);\r\n' +
|
||||
' }\r\n' +
|
||||
'}';
|
||||
}
|
||||
|
||||
export default Vue.extend({
|
||||
template: getResPanel('create-manager'),
|
||||
data() {
|
||||
return {
|
||||
inputName: '',
|
||||
display: '',
|
||||
|
||||
showLoading: false
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
async onClickCreate() {
|
||||
const name = this.inputName;
|
||||
|
||||
if (/^[a-z][a-z0-9-]*[a-z0-9]+$/.test(name) === false) {
|
||||
this.display = '[错误] 名字不合法\n1、不能以数字开头\n2、不能有大写字母\n3、分隔符只能使用-\n4、不能以分隔符开头或结尾';
|
||||
return;
|
||||
}
|
||||
|
||||
const rootPath = 'db://assets/app-builtin/app-manager';
|
||||
const managerName = `${stringCase(name)}Manager`;
|
||||
const folderName = name;
|
||||
const folderPath = `${rootPath}/${folderName}`;
|
||||
const scriptUrl = `${folderPath}/${managerName}.ts`;
|
||||
const prefabUrl = `${folderPath}/${managerName}.prefab`;
|
||||
|
||||
// 创建前确认
|
||||
const createResponse = await Editor.Dialog.info('请确认', { detail: managerName, buttons: ['创建并打开', '仅创建', '取消'], default: 0, cancel: 2 });
|
||||
if (createResponse.response == 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.display = '创建中';
|
||||
this.showLoading = true;
|
||||
|
||||
if (existsSync(convertUrlToPath(folderPath))) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 目录已存在, 请删除\n${folderPath}`;
|
||||
return;
|
||||
}
|
||||
|
||||
// 目录如果不存在则创建
|
||||
if (!await createFolderByUrl(rootPath, {
|
||||
meta: getResMeta('app-manager'),
|
||||
readme: getResReadme('app-manager'),
|
||||
subFolders: [
|
||||
{
|
||||
folder: folderName,
|
||||
readme: `1、${managerName}所在文件夹, 通过app.manager.${stringCase(name, true)}的方式调用\n2、如不再需要,可以直接删除此文件夹`
|
||||
}
|
||||
]
|
||||
})) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 创建目录失败\n${folderPath}`;
|
||||
return;
|
||||
}
|
||||
|
||||
// 创建script
|
||||
const createScriptResult = await Editor.Message.request('asset-db', 'create-asset', scriptUrl, getScript(managerName)).catch(_ => null);
|
||||
if (!createScriptResult) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 创建脚本失败\n${scriptUrl}`;
|
||||
return;
|
||||
}
|
||||
|
||||
// 创建prefab
|
||||
const createPrefabResult = await Editor.Message.request('scene', 'execute-scene-script', {
|
||||
name: 'app',
|
||||
method: 'createPrefab',
|
||||
args: [managerName, prefabUrl]
|
||||
});
|
||||
if (!createPrefabResult) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 创建预制体失败\n${prefabUrl}`;
|
||||
return;
|
||||
}
|
||||
|
||||
this.showLoading = false;
|
||||
this.display = `[成功] 创建成功\n${rootPath}`;
|
||||
|
||||
Editor.Message.send('assets', 'twinkle', scriptUrl);
|
||||
|
||||
// 是否打开
|
||||
if (createResponse.response == 0) {
|
||||
Editor.Message.request('asset-db', 'open-asset', scriptUrl);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
111
extensions/app/engine/src/panel/components/create-model.ts
Normal file
111
extensions/app/engine/src/panel/components/create-model.ts
Normal file
@@ -0,0 +1,111 @@
|
||||
import { existsSync } from 'fs';
|
||||
import Vue from '../../../../vue';
|
||||
import { convertUrlToPath, createFolderByUrl, getResMeta, getResPanel, getResReadme, stringCase } from '../../utils';
|
||||
|
||||
/**
|
||||
* 根据语言获取脚本内容
|
||||
*/
|
||||
function getScript(type: string, className: string) {
|
||||
if (type === 'data') {
|
||||
const BaseModel = '../../../extensions/app/assets/base/BaseModel';
|
||||
return 'import { IModel } from \'' + BaseModel + '\';\r\n' +
|
||||
'// data中不能定义任何方法(更建议使用store)\r\n' +
|
||||
'export default class ' + className + ' implements IModel<' + className + '> {\r\n' +
|
||||
'}';
|
||||
} else if (type === 'config') {
|
||||
const BaseModel = '../../../extensions/app/assets/base/BaseModel';
|
||||
return 'import { IModel } from \'' + BaseModel + '\';\r\n' +
|
||||
'// config中不能定义任何方法, 任何变量在外部访问都是readonly\r\n' +
|
||||
'// 如果config中的内容是服务器下发的,可以使用Object.assign覆盖config中的内容\r\n' +
|
||||
'export default class ' + className + ' implements IModel<' + className + '> {\r\n' +
|
||||
'}';
|
||||
} else if (type === 'store') {
|
||||
const BaseModel = '../../../extensions/app/assets/base/BaseModel';
|
||||
return 'import { IStore } from \'' + BaseModel + '\';\r\n' +
|
||||
'// store中只允许在根路径下定义方法,任何变量在外部访问都是readonly\r\n' +
|
||||
'// store类型的引入是借鉴了Web前端框架中全局状态管理的思路,意图是让数据更安全,更可控。同时框架中还提供了数据绑定的扩展包,可以通过pkg的方式安装,实现「数据->视图」的单向绑定。\r\n' +
|
||||
'export default class ' + className + ' implements IStore<' + className + '> {\r\n' +
|
||||
' count = 0;\r\n' +
|
||||
' setCount(v: number) {\r\n' +
|
||||
' this.count = v;\r\n' +
|
||||
' }\r\n' +
|
||||
'}';
|
||||
} else {
|
||||
return '// 🔥切记: 当前文件处于分包中, 由于加载顺序的原因,不可以在「主包」中使用此文件内导出的变量\r\n' +
|
||||
'// 存放直接导出的interface、type或enum等\r\n\r\n' +
|
||||
'// export type IString = string;\r\n' +
|
||||
'// export enum Type { None };';
|
||||
}
|
||||
}
|
||||
|
||||
export default Vue.extend({
|
||||
template: getResPanel('create-model'),
|
||||
data() {
|
||||
return {
|
||||
inputName: '',
|
||||
display: '',
|
||||
|
||||
typeSelects: ['store', 'data', 'config', 'export'],
|
||||
typeSelectIndex: 0,
|
||||
|
||||
showLoading: false
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
onChangeTypeSelect(index: string) {
|
||||
this.typeSelectIndex = Number(index);
|
||||
},
|
||||
async onClickCreate() {
|
||||
const type = this.typeSelects[this.typeSelectIndex];
|
||||
const name = this.inputName;
|
||||
|
||||
if (/^[a-z][a-z0-9-]*[a-z0-9]+$/.test(name) === false) {
|
||||
this.display = '[错误] 名字不合法\n1、不能以数字开头\n2、不能有大写字母\n3、分隔符只能使用-\n4、不能以分隔符开头或结尾';
|
||||
return;
|
||||
}
|
||||
|
||||
const rootPath = 'db://assets/app-builtin/app-model';
|
||||
const modelName = `${type}.${name}`;
|
||||
const scriptUrl = `${rootPath}/${modelName}.ts`;
|
||||
|
||||
// 创建前确认
|
||||
const createResponse = await Editor.Dialog.info('请确认', { detail: modelName, buttons: ['创建并打开', '仅创建', '取消'], default: 0, cancel: 2 });
|
||||
if (createResponse.response == 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.display = '创建中';
|
||||
this.showLoading = true;
|
||||
|
||||
// 目录如果不存在则创建
|
||||
if (!await createFolderByUrl(rootPath, { meta: getResMeta('app-model'), readme: getResReadme('app-model') })) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 创建目录失败\n${rootPath}`;
|
||||
return;
|
||||
}
|
||||
|
||||
if (existsSync(convertUrlToPath(scriptUrl))) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 文件已存在, 请删除\n${scriptUrl}`;
|
||||
return;
|
||||
}
|
||||
|
||||
const createScriptResult = await Editor.Message.request('asset-db', 'create-asset', scriptUrl, getScript(type, stringCase(name))).catch(_ => null);
|
||||
if (!createScriptResult) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 创建脚本失败\n${scriptUrl}`;
|
||||
return;
|
||||
}
|
||||
|
||||
this.showLoading = false;
|
||||
this.display = `[成功] 创建成功\n${rootPath}`;
|
||||
|
||||
Editor.Message.send('assets', 'twinkle', scriptUrl);
|
||||
|
||||
// 是否打开
|
||||
if (createResponse.response == 0) {
|
||||
Editor.Message.request('asset-db', 'open-asset', scriptUrl);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
66
extensions/app/engine/src/panel/components/create-res.ts
Normal file
66
extensions/app/engine/src/panel/components/create-res.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import Vue from '../../../../vue';
|
||||
import { createFolderByUrl, getResMeta, getResPanel, getResReadme, stringCase } from '../../utils';
|
||||
|
||||
const typeNames: ('res-bundle' | 'res-native' | 'resources')[] = ['res-native', 'res-bundle', 'resources'];
|
||||
export default Vue.extend({
|
||||
template: getResPanel('create-res'),
|
||||
data() {
|
||||
return {
|
||||
inputName: '',
|
||||
display: '',
|
||||
|
||||
typeSelects: ['公共静态目录', '公共动态目录', 'resources'],
|
||||
typeSelectIndex: 0,
|
||||
|
||||
showLoading: false
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
onChangeTypeSelect(index: string) {
|
||||
this.typeSelectIndex = Number(index);
|
||||
},
|
||||
async onClickCreate() {
|
||||
const folderName = typeNames[this.typeSelectIndex];
|
||||
const folderPath = `db://assets/${folderName}`;
|
||||
const name = stringCase(this.inputName, true);
|
||||
|
||||
if (/^[a-z][a-z0-9-]*[a-z0-9]+$/.test(this.inputName) === false) {
|
||||
this.display = '[错误] 名字不合法\n1、不能以数字开头\n2、不能有大写字母\n3、分隔符只能使用-\n4、不能以分隔符开头或结尾';
|
||||
return;
|
||||
}
|
||||
if (name === 'resources') {
|
||||
this.display = '[错误] 名字不合法\n1、不能使用resources作为名字';
|
||||
return;
|
||||
}
|
||||
|
||||
// 创建前确认
|
||||
const createResponse = await Editor.Dialog.info('请确认', { detail: name, buttons: ['创建', '取消'], default: 0, cancel: 1 });
|
||||
if (createResponse.response == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.display = '创建中';
|
||||
this.showLoading = true;
|
||||
|
||||
if (!await createFolderByUrl(folderPath, {
|
||||
readme: getResReadme(folderName),
|
||||
meta: folderName === 'resources' ? getResMeta('resources') : undefined,
|
||||
subFolders: [
|
||||
{
|
||||
folder: name,
|
||||
meta: folderName === 'res-bundle' ? getResMeta('custom-bundle') : undefined
|
||||
}
|
||||
]
|
||||
})) {
|
||||
this.showLoading = false;
|
||||
this.display = '[错误] 创建失败';
|
||||
return;
|
||||
}
|
||||
|
||||
this.showLoading = false;
|
||||
this.display = `[成功] 创建成功\n${folderPath}`;
|
||||
|
||||
Editor.Message.send('assets', 'twinkle', folderPath);
|
||||
}
|
||||
},
|
||||
});
|
||||
47
extensions/app/engine/src/panel/components/create-sound.ts
Normal file
47
extensions/app/engine/src/panel/components/create-sound.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import Vue from '../../../../vue';
|
||||
import { createFolderByUrl, getResMeta, getResPanel, getResReadme } from '../../utils';
|
||||
|
||||
export default Vue.extend({
|
||||
template: getResPanel('create-sound'),
|
||||
data() {
|
||||
return {
|
||||
display: '',
|
||||
|
||||
typeSelects: ['音乐', '音效'],
|
||||
typeSelectIndex: 0,
|
||||
|
||||
showLoading: false
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
onChangeTypeSelect(index: string) {
|
||||
this.typeSelectIndex = Number(index);
|
||||
},
|
||||
async onClickCreate() {
|
||||
this.display = '创建中';
|
||||
this.showLoading = true;
|
||||
|
||||
const rootPath = 'db://assets/app-bundle/app-sound';
|
||||
|
||||
if (!await createFolderByUrl(rootPath, {
|
||||
meta: getResMeta('app-sound'),
|
||||
readme: getResReadme('app-sound'),
|
||||
subFolders: [
|
||||
{
|
||||
folder: this.typeSelectIndex === 0 ? 'music' : 'effect',
|
||||
readme: getResReadme(this.typeSelectIndex === 0 ? 'sound-music' : 'sound-effect')
|
||||
}
|
||||
]
|
||||
})) {
|
||||
this.showLoading = false;
|
||||
this.display = '[错误] 创建失败';
|
||||
return;
|
||||
}
|
||||
|
||||
this.showLoading = false;
|
||||
this.display = `[成功] 创建成功\n${rootPath}`;
|
||||
|
||||
Editor.Message.send('assets', 'twinkle', rootPath);
|
||||
}
|
||||
},
|
||||
});
|
||||
280
extensions/app/engine/src/panel/components/create-view.ts
Normal file
280
extensions/app/engine/src/panel/components/create-view.ts
Normal file
@@ -0,0 +1,280 @@
|
||||
import { existsSync, readdirSync, statSync, writeFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import Vue from '../../../../vue';
|
||||
import { convertUrlToPath, createFolderByUrl, delayFileExistsByUrl, getResMeta, getResPanel, getResReadme, stringCase } from '../../utils';
|
||||
|
||||
/**
|
||||
* 获取脚本内容
|
||||
*/
|
||||
function getComScript(name = 'NewClass') {
|
||||
const isPage = name.toLowerCase().startsWith('page');
|
||||
const isPaper = name.toLowerCase().startsWith('paper');
|
||||
|
||||
const basePath = isPaper ? '../../../../../../../extensions/app/assets/base/BaseView' : '../../../../../../extensions/app/assets/base/BaseView';
|
||||
|
||||
return 'import { _decorator, Node } from \'cc\';\r\n' +
|
||||
'import BaseView from \'' + basePath + '\';\r\n' +
|
||||
`${isPage ? 'import { IMiniViewNames } from \'../../../../../app-builtin/app-admin/executor\';\r\n' : ''}` +
|
||||
'const { ccclass, property } = _decorator;\r\n' +
|
||||
'@ccclass(\'' + name + '\')\r\n' +
|
||||
'export class ' + name + ' extends BaseView {\r\n' +
|
||||
` ${isPage ? '// 子界面列表,数组顺序为子界面排列顺序\r\n' : ''}` +
|
||||
` ${isPage ? 'protected miniViews: IMiniViewNames = [];\r\n\r\n' : '\r\n'}` +
|
||||
' // 初始化的相关逻辑写在这\r\n' +
|
||||
' onLoad() {}\r\n\r\n' +
|
||||
' // 界面打开时的相关逻辑写在这(onShow可被多次调用-它与onHide不成对)\r\n' +
|
||||
' onShow(params: any) {\r\n' +
|
||||
` ${isPage ? 'this.showMiniViews({ views: this.miniViews });' : ''}\r\n` +
|
||||
' }\r\n\r\n' +
|
||||
' // 界面关闭时的相关逻辑写在这(已经关闭的界面不会触发onHide)\r\n' +
|
||||
' onHide(result: undefined) {\r\n' +
|
||||
` ${isPaper ? '' : '// app.manager.ui.show<' + name + '>({name: \'' + name + '\', onHide:(result) => { 接收到return的数据,并且有类型提示 }})\r\n'}` +
|
||||
` ${isPaper ? '' : 'return result;'}\r\n` +
|
||||
' }\r\n' +
|
||||
'}';
|
||||
}
|
||||
|
||||
function getNaMetaUserData(name = 'new-class') {
|
||||
return {
|
||||
...getResMeta('view-native'),
|
||||
'bundleName': `${name}`
|
||||
};
|
||||
}
|
||||
|
||||
function getResMetaUserData(name = 'new-class') {
|
||||
return {
|
||||
...getResMeta('view-resources'),
|
||||
'bundleName': `${name}-res`
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* UI类型(小写)
|
||||
*/
|
||||
const TypeSelects = ['page', 'paper', 'pop', 'top'];
|
||||
/**
|
||||
* 大驼峰UI名(带page前缀) => 串式UI目录名(不带page前缀)
|
||||
*/
|
||||
const PageNames: Map<string, string> = new Map();
|
||||
function updatePages() {
|
||||
PageNames.clear();
|
||||
|
||||
// page目录
|
||||
const pageRootPath = join(Editor.Project.path, 'assets/app-bundle/app-view/page');
|
||||
|
||||
// 读取page目录下所有文件
|
||||
const folderNames = existsSync(pageRootPath) ? readdirSync(pageRootPath) : [];
|
||||
|
||||
// 大驼峰命名的UI名
|
||||
folderNames.forEach((folderName) => {
|
||||
// folderName为串式命名法
|
||||
const pagePath = join(pageRootPath, folderName);
|
||||
const isDirectory = statSync(pagePath).isDirectory();
|
||||
if (isDirectory) {
|
||||
PageNames.set(`Page${stringCase(folderName)}`, folderName);
|
||||
}
|
||||
});
|
||||
|
||||
PageNames.set('通用', 'all');
|
||||
|
||||
return Array.from(PageNames.keys());
|
||||
}
|
||||
|
||||
export default Vue.extend({
|
||||
template: getResPanel('create-view'),
|
||||
data() {
|
||||
return {
|
||||
showLoading: false,
|
||||
showSelectPage: false,
|
||||
showSelectGroup: true,
|
||||
|
||||
inputName: '',
|
||||
display: '',
|
||||
|
||||
typeSelects: TypeSelects,
|
||||
typeSelectIndex: 0,
|
||||
|
||||
groupSelects: ['2D', '3D'],
|
||||
groupSelectIndex: 0,
|
||||
|
||||
pageSelects: [] as string[],
|
||||
pageSelectIndex: 0,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
onChangeGroupSelect(index: string) {
|
||||
this.groupSelectIndex = Number(index);
|
||||
},
|
||||
onChangeTypeSelect(index: string) {
|
||||
this.typeSelectIndex = Number(index);
|
||||
|
||||
if (index == '0') {
|
||||
this.showSelectGroup = true;
|
||||
} else {
|
||||
this.showSelectGroup = false;
|
||||
}
|
||||
|
||||
if (index == '1') {
|
||||
this.pageSelectIndex = 0;
|
||||
this.pageSelects = updatePages();
|
||||
this.showSelectPage = true;
|
||||
} else {
|
||||
this.showSelectPage = false;
|
||||
}
|
||||
},
|
||||
onChangePageSelect(index: string) {
|
||||
this.pageSelectIndex = Number(index);
|
||||
},
|
||||
async onClickCreate() {
|
||||
const isPage = this.typeSelectIndex == 0;
|
||||
const isPaper = this.typeSelectIndex == 1;
|
||||
|
||||
// ui归属(大驼峰)
|
||||
const owner = this.pageSelects[this.pageSelectIndex];
|
||||
// ui类型(小写)
|
||||
const type = this.typeSelects[this.typeSelectIndex];
|
||||
// ui名字(串式)
|
||||
const name = this.inputName;
|
||||
|
||||
if (/^[a-z][a-z0-9-]*[a-z0-9]+$/.test(name) === false) {
|
||||
this.display = '[错误] 名字不合法\n1、不能以数字开头\n2、不能有大写字母\n3、分隔符只能使用-\n4、不能以分隔符开头或结尾';
|
||||
return;
|
||||
}
|
||||
if (name === 'all' || name === 'page' || name === 'paper' || name === 'pop' || name === 'top') {
|
||||
this.display = '[错误] 名字不合法\n1、不能使用all、page、paper、pop、top作为名字';
|
||||
return;
|
||||
}
|
||||
|
||||
const is3D = isPage && this.groupSelectIndex == 1;
|
||||
const ownerName = PageNames.get(owner) as string;
|
||||
const uiName = isPaper ?
|
||||
`${stringCase(type)}${stringCase(ownerName)}${stringCase(name)}` :
|
||||
`${stringCase(type)}${stringCase(name)}`;
|
||||
const bundleName = isPaper ?
|
||||
`${type}-${ownerName}-${name}` :
|
||||
`${type}-${name}`;
|
||||
|
||||
const bundleFolderUrl = 'db://assets/app-bundle';
|
||||
const viewFolderUrl = `${bundleFolderUrl}/app-view`;
|
||||
const typeFolderUrl = `${viewFolderUrl}/${type}`;
|
||||
const uiFolderUrl = isPaper ?
|
||||
`${typeFolderUrl}/${ownerName}/${name}` :
|
||||
`${typeFolderUrl}/${name}`;
|
||||
const nativeUrl = `${uiFolderUrl}/native`;
|
||||
const resourcesUrl = `${uiFolderUrl}/resources`;
|
||||
const expansionUrl = `${nativeUrl}/expansion`;
|
||||
const scriptUrl = `${nativeUrl}/${uiName}.ts`;
|
||||
const prefabUrl = `${nativeUrl}/${uiName}.prefab`;
|
||||
const sceneUrl = `${nativeUrl}/${uiName}.scene`;
|
||||
const singleColorUrl = `${resourcesUrl}/singleColor.png`;
|
||||
|
||||
// 创建前确认
|
||||
const createResponse = await Editor.Dialog.info('请确认', { detail: uiName, buttons: ['创建并打开', '仅创建', '取消'], default: 0, cancel: 2 });
|
||||
if (createResponse.response == 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.display = '创建中';
|
||||
this.showLoading = true;
|
||||
|
||||
// 创建目录
|
||||
if (!await createFolderByUrl(uiFolderUrl, { subPaths: ['native', 'resources', 'native/expansion'] })) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 创建目录失败\n${uiFolderUrl}`;
|
||||
return;
|
||||
}
|
||||
|
||||
// 设置native分包
|
||||
await delayFileExistsByUrl(`${nativeUrl}.meta`);
|
||||
const queryNativeMeta = await Editor.Message.request('asset-db', 'query-asset-meta', nativeUrl).catch(_ => null);
|
||||
if (!queryNativeMeta) {
|
||||
this.showLoading = false;
|
||||
this.display = '[错误] 设置native分包配置失败';
|
||||
return;
|
||||
}
|
||||
queryNativeMeta.userData = getNaMetaUserData(bundleName);
|
||||
await Editor.Message.request('asset-db', 'save-asset-meta', nativeUrl, JSON.stringify(queryNativeMeta)).catch(_ => null);
|
||||
|
||||
// 设置resources分包
|
||||
await delayFileExistsByUrl(`${resourcesUrl}.meta`);
|
||||
const queryResMeta = await Editor.Message.request('asset-db', 'query-asset-meta', resourcesUrl).catch(_ => null);
|
||||
if (!queryResMeta) {
|
||||
this.showLoading = false;
|
||||
this.display = '[错误] 设置resources分包配置失败';
|
||||
return;
|
||||
}
|
||||
queryResMeta.userData = getResMetaUserData(bundleName);
|
||||
await Editor.Message.request('asset-db', 'save-asset-meta', resourcesUrl, JSON.stringify(queryResMeta)).catch(_ => null);
|
||||
|
||||
writeFileSync(join(convertUrlToPath(bundleFolderUrl), '.app-bundle.md'), getResReadme('app-bundle'));
|
||||
writeFileSync(join(convertUrlToPath(viewFolderUrl), '.app-view.md'), getResReadme('app-view'));
|
||||
writeFileSync(join(convertUrlToPath(typeFolderUrl), `.${type}.md`), `1、所有${type}类型UI的根目录\n2、如不再需要,可以直接删除此文件夹`);
|
||||
writeFileSync(join(convertUrlToPath(nativeUrl), '.native.md'), getResReadme('view-native'));
|
||||
writeFileSync(join(convertUrlToPath(resourcesUrl), '.resources.md'), getResReadme('view-resources'));
|
||||
writeFileSync(join(convertUrlToPath(expansionUrl), '.expansion.md'), getResReadme('view-expansion'));
|
||||
|
||||
if (isPaper) {
|
||||
writeFileSync(join(convertUrlToPath(`${typeFolderUrl}/${ownerName}`), `.${ownerName}.md`), (ownerName === 'all' ? '1、归属于全体Page' : `1、归属于Page${stringCase(ownerName)}`) + '\n2、如不再需要,可以直接删除此文件夹');
|
||||
writeFileSync(join(convertUrlToPath(uiFolderUrl), `.${name}.md`), `${uiName}所在文件夹\n1、通过${ownerName === 'all' ? '在任意Page中配置miniViews属性并调用showMiniViews方法' : `在${owner}中配置miniViews属性并调用showMiniViews方法`}的方式加载\n2、如不再需要,可以直接删除此文件夹`);
|
||||
} else {
|
||||
writeFileSync(join(convertUrlToPath(uiFolderUrl), `.${name}.md`), `${uiName}所在文件夹\n1、通过app.manager.ui.show({ name:'${uiName}' })的方式加载\n2、如不再需要,可以直接删除此文件夹`);
|
||||
}
|
||||
|
||||
// 创建script
|
||||
if (!existsSync(convertUrlToPath(scriptUrl))) {
|
||||
const createScriptResult = await Editor.Message.request('asset-db', 'create-asset', scriptUrl, getComScript(uiName)).catch(_ => null);
|
||||
if (!createScriptResult) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 创建脚本失败\n${scriptUrl}`;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 创建view
|
||||
if (!existsSync(convertUrlToPath(prefabUrl)) && !existsSync(convertUrlToPath(sceneUrl))) {
|
||||
if (is3D && isPage) {
|
||||
const createSceneResult = await Editor.Message.request('scene', 'execute-scene-script', {
|
||||
name: 'app',
|
||||
method: 'createScene',
|
||||
args: [uiName, sceneUrl]
|
||||
}).catch(_ => null);
|
||||
if (!createSceneResult) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 创建场景失败\n${sceneUrl}`;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
const createPrefabResult = await Editor.Message.request('scene', 'execute-scene-script', {
|
||||
name: 'app',
|
||||
method: 'createPrefab',
|
||||
args: [uiName, prefabUrl, is3D]
|
||||
}).catch(_ => null);
|
||||
if (!createPrefabResult) {
|
||||
this.showLoading = false;
|
||||
this.display = `[错误] 创建预制体失败\n${prefabUrl}`;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.showLoading = false;
|
||||
this.display = `[成功] 创建成功\n${uiFolderUrl}`;
|
||||
|
||||
Editor.Message.send('assets', 'twinkle', scriptUrl);
|
||||
|
||||
// 是否打开
|
||||
if (createResponse.response == 0) {
|
||||
if (is3D) {
|
||||
Editor.Message.request('asset-db', 'open-asset', sceneUrl);
|
||||
} else {
|
||||
Editor.Message.request('asset-db', 'open-asset', prefabUrl);
|
||||
}
|
||||
Editor.Message.request('asset-db', 'open-asset', scriptUrl);
|
||||
}
|
||||
|
||||
const base64 = 'iVBORw0KGgoAAAANSUhEUgAAAAIAAAACAQMAAABIeJ9nAAAAA1BMVEX///+nxBvIAAAACklEQVQI12MAAgAABAABINItbwAAAABJRU5ErkJggg==';
|
||||
writeFileSync(convertUrlToPath(singleColorUrl), new Buffer(base64, 'base64'));
|
||||
Editor.Message.request('asset-db', 'refresh-asset', singleColorUrl).catch(_ => null);
|
||||
}
|
||||
}
|
||||
});
|
||||
27
extensions/app/engine/src/panel/index.ts
Normal file
27
extensions/app/engine/src/panel/index.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
const Assets = join(__dirname, '../../res/panel');
|
||||
|
||||
import App from './components/app';
|
||||
|
||||
module.exports = Editor.Panel.define({
|
||||
template: readFileSync(join(Assets, 'index.html'), 'utf-8'),
|
||||
style: readFileSync(join(Assets, 'styles/index.css'), 'utf-8'),
|
||||
$: {
|
||||
app: '#app'
|
||||
},
|
||||
listeners: {
|
||||
show() { console.log('show'); },
|
||||
hide() { console.log('hide'); },
|
||||
},
|
||||
methods: {},
|
||||
ready() {
|
||||
if (!this.$.app) return;
|
||||
|
||||
const com = new App();
|
||||
com.$mount(this.$.app);
|
||||
},
|
||||
beforeClose() { },
|
||||
close() { },
|
||||
});
|
||||
85
extensions/app/engine/src/scene.ts
Normal file
85
extensions/app/engine/src/scene.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
import { join } from 'path';
|
||||
module.paths.push(join(Editor.App.path, 'node_modules'));
|
||||
|
||||
export function load() { }
|
||||
|
||||
export function unload() { }
|
||||
|
||||
// 在其他扩展脚本中,我们可以使用如下代码调用 rotateCamera 函数
|
||||
// const options: ExecuteSceneScriptMethodOptions = {
|
||||
// name: scene.ts 所在的扩展包名, 如: App,
|
||||
// method: scene.ts 中定义的方法, 如: rotateCamera,
|
||||
// args: 参数,可选, 只传递json
|
||||
// };
|
||||
// const result = await Editor.Message.request('scene', 'execute-scene-script', options);
|
||||
export const methods = {
|
||||
async createPrefab(fileName: string, fileUrl: string, is3D = false) {
|
||||
const { Node, js, Layers } = require('cc');
|
||||
|
||||
const node = new Node(fileName);
|
||||
node.layer = is3D ? Layers.Enum.UI_3D : Layers.Enum.UI_2D;
|
||||
|
||||
while (true) {
|
||||
const result = js.getClassByName(fileName);
|
||||
if (result) break;
|
||||
|
||||
await new Promise((next) => {
|
||||
setTimeout(next, 100);
|
||||
});
|
||||
}
|
||||
|
||||
const com = node.addComponent(fileName);
|
||||
com.resetInEditor && com.resetInEditor();
|
||||
|
||||
const info = cce.Prefab.generatePrefabDataFromNode(node) as any;
|
||||
node.destroy();
|
||||
|
||||
return Editor.Message.request('asset-db', 'create-asset', fileUrl, info.prefabData || info);
|
||||
},
|
||||
async createScene(fileName: string, fileUrl: string) {
|
||||
const { SceneAsset, Scene, Node, js, Layers, Camera, DirectionalLight } = require('cc');
|
||||
|
||||
while (true) {
|
||||
const result = js.getClassByName(fileName);
|
||||
if (result) break;
|
||||
|
||||
await new Promise((next) => {
|
||||
setTimeout(next, 100);
|
||||
});
|
||||
}
|
||||
|
||||
const scene = new Scene(fileName);
|
||||
|
||||
// 根节点
|
||||
const node = new Node(fileName);
|
||||
node.layer = Layers.Enum.DEFAULT;
|
||||
node.parent = scene;
|
||||
|
||||
// 相机
|
||||
const camera = new Node('Camera');
|
||||
camera.addComponent(Camera);
|
||||
camera.layer = Layers.Enum.DEFAULT;
|
||||
camera.parent = node;
|
||||
|
||||
// 灯光
|
||||
const light = new Node('Light');
|
||||
light.addComponent(DirectionalLight);
|
||||
light.layer = Layers.Enum.DEFAULT;
|
||||
light.parent = node;
|
||||
|
||||
const com = node.addComponent(fileName);
|
||||
com.resetInEditor && com.resetInEditor();
|
||||
|
||||
const sceneAsset = new SceneAsset();
|
||||
sceneAsset.scene = scene;
|
||||
|
||||
const info = EditorExtends.serialize(sceneAsset);
|
||||
camera.destroy();
|
||||
light.destroy();
|
||||
node.destroy();
|
||||
scene.destroy();
|
||||
sceneAsset.destroy();
|
||||
|
||||
return Editor.Message.request('asset-db', 'create-asset', fileUrl, info);
|
||||
},
|
||||
};
|
||||
4
extensions/app/engine/src/shims-vue.d.ts
vendored
Executable file
4
extensions/app/engine/src/shims-vue.d.ts
vendored
Executable file
@@ -0,0 +1,4 @@
|
||||
declare module 'vue/dist/vue' {
|
||||
import Vue from 'vue';
|
||||
export default Vue;
|
||||
}
|
||||
192
extensions/app/engine/src/utils.ts
Normal file
192
extensions/app/engine/src/utils.ts
Normal file
@@ -0,0 +1,192 @@
|
||||
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
||||
import { basename, join } from 'path';
|
||||
|
||||
export function getResJson(name: 'builder'): { bundleConfig: object, textureCompressConfig: object } {
|
||||
const Assets = join(__dirname, '../res/json');
|
||||
const str = readFileSync(join(Assets, `${name}.json`), 'utf-8');
|
||||
return str ? JSON.parse(str) : null;
|
||||
}
|
||||
|
||||
export function getResReadme(name: 'resources' | 'app' | 'app-appinit' | 'app-scene' | 'app-builtin' | 'app-bundle' | 'app-view' | 'app-admin' | 'app-controller' | 'app-manager' | 'app-model' | 'app-sound' | 'sound-effect' | 'sound-music' | 'view-expansion' | 'view-native' | 'res-bundle' | 'res-native' | 'view-resources') {
|
||||
const Assets = join(__dirname, '../res/readme');
|
||||
return readFileSync(join(Assets, `${name}.md`), 'utf-8');
|
||||
}
|
||||
|
||||
export function getResMeta(name: 'resources' | 'custom-bundle' | 'app-admin' | 'app-controller' | 'app-manager' | 'app-model' | 'app-sound' | 'view-native' | 'view-resources'): { userData: object } {
|
||||
const Assets = join(__dirname, '../res/meta');
|
||||
const str = readFileSync(join(Assets, `${name}.meta`), 'utf-8');
|
||||
return str ? JSON.parse(str) : null;
|
||||
}
|
||||
|
||||
export function getResPanel(name: string) {
|
||||
const Assets = join(__dirname, '../res/panel');
|
||||
return readFileSync(join(Assets, `components/${name}.html`), 'utf-8');
|
||||
}
|
||||
|
||||
/**
|
||||
* 将串式命名转成驼峰命名
|
||||
* @param str 串式字符串
|
||||
* @param lower 首字母是否小写(默认大写)
|
||||
* @returns
|
||||
*/
|
||||
export function stringCase(str: string, lower = false) {
|
||||
str = str.replace(/-/g, '_');
|
||||
const arr = str.split('_');
|
||||
|
||||
return arr.map(function (str, index) {
|
||||
if (index === 0 && lower) {
|
||||
return str.charAt(0).toLowerCase() + str.slice(1);
|
||||
}
|
||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||
}).join('');
|
||||
}
|
||||
|
||||
/**
|
||||
* 将驼峰命名转成串式命名
|
||||
* @param str 驼峰字符串
|
||||
* @returns
|
||||
*/
|
||||
export function stringCaseNegate(str: string) {
|
||||
return str.replace(/[A-Z]/g, (searchStr, startIndex) => {
|
||||
if (startIndex === 0) {
|
||||
return searchStr.toLowerCase();
|
||||
} else {
|
||||
return '-' + searchStr.toLowerCase();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* db下的路径转换为真实路径
|
||||
*/
|
||||
export function convertUrlToPath(url: string) {
|
||||
if (url.startsWith('db://assets')) {
|
||||
url = Editor.Utils.Path.join(Editor.Project.path, url.slice(5));
|
||||
} else if (url.startsWith('db://app')) {
|
||||
url = Editor.Utils.Path.join(Editor.Project.path, 'extensions/app/assets', url.slice(8));
|
||||
} else if (url.startsWith('db://pkg')) {
|
||||
url = Editor.Utils.Path.join(Editor.Project.path, 'extensions/pkg/node_modules', url.slice(8));
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取程序路径
|
||||
*/
|
||||
export function getProjectPath() {
|
||||
return Editor.Project.path;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据db下的路径创建目录(不是文件)
|
||||
* 如果已存在不会重复创建
|
||||
*/
|
||||
export async function createFolderByUrl(url: string, opts?: { subPaths?: string[], meta?: { userData: object }, readme?: string, subFolders?: { folder: string, meta?: { userData: object }, readme?: string }[] }) {
|
||||
let pathHead = 'db://assets';
|
||||
|
||||
if (!url && !url.startsWith(pathHead)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 修剪path
|
||||
const pathTail = url.endsWith('/') ? url.slice(pathHead.length + 1, -1).trim() : url.slice(pathHead.length + 1).trim();
|
||||
|
||||
// 每一层的路径
|
||||
const pathArr = pathTail.split('/');
|
||||
|
||||
// 创建主目录
|
||||
for (let index = 0; index < pathArr.length; index++) {
|
||||
pathHead += '/' + pathArr[index];
|
||||
|
||||
if (!existsSync(convertUrlToPath(pathHead))) {
|
||||
const result = await Editor.Message.request('asset-db', 'create-asset', pathHead, null).catch(_ => null);
|
||||
if (!result) return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 主目录meta
|
||||
if (opts?.meta) {
|
||||
await delayFileExistsByUrl(`${url}.meta`);
|
||||
await delay(100);
|
||||
const queryMeta = await Editor.Message.request('asset-db', 'query-asset-meta', url).catch(_ => null);
|
||||
if (!queryMeta) return false;
|
||||
Object.assign(queryMeta.userData, opts.meta.userData);
|
||||
|
||||
const result = await Editor.Message.request('asset-db', 'save-asset-meta', url, JSON.stringify(queryMeta)).catch(_ => null);
|
||||
if (!result) return false;
|
||||
}
|
||||
|
||||
// 主目录readme
|
||||
if (opts?.readme) {
|
||||
writeFileSync(join(convertUrlToPath(url), `.${basename(url)}.md`), opts.readme);
|
||||
}
|
||||
|
||||
// 创建子目录
|
||||
if (opts?.subPaths) {
|
||||
await delay(100);
|
||||
for (let index = 0; index < opts.subPaths.length; index++) {
|
||||
const subPath = `${pathHead}/${opts.subPaths[index]}`;
|
||||
if (!existsSync(convertUrlToPath(subPath))) {
|
||||
const result = await Editor.Message.request('asset-db', 'create-asset', subPath, null).catch(_ => null);
|
||||
if (!result) return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (opts?.subFolders) {
|
||||
await delay(100);
|
||||
for (let index = 0; index < opts.subFolders.length; index++) {
|
||||
const subOpts = opts.subFolders[index];
|
||||
const subUrl = `${pathHead}/${subOpts.folder}`;
|
||||
|
||||
// 判断是否存在
|
||||
if (!existsSync(convertUrlToPath(subUrl))) {
|
||||
const result = await Editor.Message.request('asset-db', 'create-asset', subUrl, null).catch(_ => null);
|
||||
if (!result) return false;
|
||||
}
|
||||
|
||||
// meta
|
||||
if (subOpts.meta) {
|
||||
await delayFileExistsByUrl(`${subUrl}.meta`);
|
||||
const queryMeta = await Editor.Message.request('asset-db', 'query-asset-meta', subUrl).catch(_ => null);
|
||||
if (!queryMeta) return false;
|
||||
Object.assign(queryMeta.userData, subOpts.meta.userData);
|
||||
|
||||
const result = await Editor.Message.request('asset-db', 'save-asset-meta', subUrl, JSON.stringify(queryMeta)).catch(_ => null);
|
||||
if (!result) return false;
|
||||
}
|
||||
|
||||
// readme
|
||||
if (subOpts.readme) {
|
||||
writeFileSync(join(convertUrlToPath(subUrl), `.${basename(subUrl)}.md`), subOpts.readme);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export function delay(time: number) {
|
||||
return new Promise((next) => {
|
||||
setTimeout(() => {
|
||||
next(null);
|
||||
}, time);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 等待文件存在
|
||||
*/
|
||||
export function delayFileExistsByUrl(url: string) {
|
||||
const path = convertUrlToPath(url);
|
||||
let timer: NodeJS.Timer | null = null;
|
||||
return new Promise((next) => {
|
||||
timer = setInterval(() => {
|
||||
if (existsSync(path)) {
|
||||
if (timer) clearInterval(timer);
|
||||
timer = null;
|
||||
next(null);
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
15
extensions/app/engine/tsconfig.json
Executable file
15
extensions/app/engine/tsconfig.json
Executable file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2017",
|
||||
"module": "CommonJS",
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src",
|
||||
"strict": false,
|
||||
"moduleResolution": "node",
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true,
|
||||
"experimentalDecorators": true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user