refactor: reorganize package structure and decouple framework packages (#338)
* refactor: reorganize package structure and decouple framework packages ## Package Structure Reorganization - Reorganized 55 packages into categorized subdirectories: - packages/framework/ - Generic framework (Laya/Cocos compatible) - packages/engine/ - ESEngine core modules - packages/rendering/ - Rendering modules (WASM dependent) - packages/physics/ - Physics modules - packages/streaming/ - World streaming - packages/network-ext/ - Network extensions - packages/editor/ - Editor framework and plugins - packages/rust/ - Rust WASM engine - packages/tools/ - Build tools and SDK ## Framework Package Decoupling - Decoupled behavior-tree and blueprint packages from ESEngine dependencies - Created abstracted interfaces (IBTAssetManager, IBehaviorTreeAssetContent) - ESEngine-specific code moved to esengine/ subpath exports - Framework packages now usable with Cocos/Laya without ESEngine ## CI Configuration - Updated CI to only type-check and lint framework packages - Added type-check:framework and lint:framework scripts ## Breaking Changes - Package import paths changed due to directory reorganization - ESEngine integrations now use subpath imports (e.g., '@esengine/behavior-tree/esengine') * fix: update es-engine file path after directory reorganization * docs: update README to focus on framework over engine * ci: only build framework packages, remove Rust/WASM dependencies * fix: remove esengine subpath from behavior-tree and blueprint builds ESEngine integration code will only be available in full engine builds. Framework packages are now purely engine-agnostic. * fix: move network-protocols to framework, build both in CI * fix: update workflow paths from packages/core to packages/framework/core * fix: exclude esengine folder from type-check in behavior-tree and blueprint * fix: update network tsconfig references to new paths * fix: add test:ci:framework to only test framework packages in CI * fix: only build core and math npm packages in CI * fix: exclude test files from CodeQL and fix string escaping security issue
This commit is contained in:
@@ -0,0 +1,204 @@
|
||||
/**
|
||||
* 微信小游戏文件系统子系统
|
||||
*/
|
||||
|
||||
import type {
|
||||
IPlatformFileSubsystem,
|
||||
FileInfo
|
||||
} from '@esengine/platform-common';
|
||||
import { getWx } from '../utils';
|
||||
|
||||
/**
|
||||
* 微信小游戏文件系统子系统实现
|
||||
*/
|
||||
export class WeChatFileSubsystem implements IPlatformFileSubsystem {
|
||||
private _fs: WechatMinigame.FileSystemManager;
|
||||
|
||||
constructor() {
|
||||
this._fs = getWx().getFileSystemManager();
|
||||
}
|
||||
|
||||
async readFile(options: {
|
||||
filePath: string;
|
||||
encoding?: 'ascii' | 'base64' | 'binary' | 'hex' | 'ucs2' | 'utf-8' | 'utf8';
|
||||
position?: number;
|
||||
length?: number;
|
||||
}): Promise<string | ArrayBuffer> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._fs.readFile({
|
||||
filePath: options.filePath,
|
||||
encoding: options.encoding as any,
|
||||
position: options.position,
|
||||
length: options.length,
|
||||
success: (res) => resolve(res.data),
|
||||
fail: reject
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
readFileSync(
|
||||
filePath: string,
|
||||
encoding?: 'ascii' | 'base64' | 'binary' | 'hex' | 'ucs2' | 'utf-8' | 'utf8',
|
||||
position?: number,
|
||||
length?: number
|
||||
): string | ArrayBuffer {
|
||||
return this._fs.readFileSync(filePath, encoding as any, position, length);
|
||||
}
|
||||
|
||||
async writeFile(options: {
|
||||
filePath: string;
|
||||
data: string | ArrayBuffer;
|
||||
encoding?: 'ascii' | 'base64' | 'binary' | 'hex' | 'ucs2' | 'utf-8' | 'utf8';
|
||||
}): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._fs.writeFile({
|
||||
filePath: options.filePath,
|
||||
data: options.data,
|
||||
encoding: options.encoding as any,
|
||||
success: () => resolve(),
|
||||
fail: reject
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
writeFileSync(
|
||||
filePath: string,
|
||||
data: string | ArrayBuffer,
|
||||
encoding?: 'ascii' | 'base64' | 'binary' | 'hex' | 'ucs2' | 'utf-8' | 'utf8'
|
||||
): void {
|
||||
this._fs.writeFileSync(filePath, data, encoding as any);
|
||||
}
|
||||
|
||||
async appendFile(options: {
|
||||
filePath: string;
|
||||
data: string | ArrayBuffer;
|
||||
encoding?: 'ascii' | 'base64' | 'binary' | 'hex' | 'ucs2' | 'utf-8' | 'utf8';
|
||||
}): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._fs.appendFile({
|
||||
filePath: options.filePath,
|
||||
data: options.data,
|
||||
encoding: options.encoding as any,
|
||||
success: () => resolve(),
|
||||
fail: reject
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async unlink(filePath: string): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._fs.unlink({
|
||||
filePath,
|
||||
success: () => resolve(),
|
||||
fail: reject
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async mkdir(options: {
|
||||
dirPath: string;
|
||||
recursive?: boolean;
|
||||
}): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._fs.mkdir({
|
||||
dirPath: options.dirPath,
|
||||
recursive: options.recursive,
|
||||
success: () => resolve(),
|
||||
fail: reject
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async rmdir(options: {
|
||||
dirPath: string;
|
||||
recursive?: boolean;
|
||||
}): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._fs.rmdir({
|
||||
dirPath: options.dirPath,
|
||||
recursive: options.recursive,
|
||||
success: () => resolve(),
|
||||
fail: reject
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async readdir(dirPath: string): Promise<string[]> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._fs.readdir({
|
||||
dirPath,
|
||||
success: (res) => resolve(res.files),
|
||||
fail: reject
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async stat(path: string): Promise<FileInfo> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._fs.stat({
|
||||
path,
|
||||
success: (res) => {
|
||||
const stats = res.stats as WechatMinigame.Stats;
|
||||
resolve({
|
||||
size: stats.size,
|
||||
createTime: stats.lastAccessedTime,
|
||||
modifyTime: stats.lastModifiedTime,
|
||||
isDirectory: stats.isDirectory(),
|
||||
isFile: stats.isFile()
|
||||
});
|
||||
},
|
||||
fail: reject
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async access(path: string): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._fs.access({
|
||||
path,
|
||||
success: () => resolve(),
|
||||
fail: reject
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async rename(oldPath: string, newPath: string): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._fs.rename({
|
||||
oldPath,
|
||||
newPath,
|
||||
success: () => resolve(),
|
||||
fail: reject
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async copyFile(srcPath: string, destPath: string): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._fs.copyFile({
|
||||
srcPath,
|
||||
destPath,
|
||||
success: () => resolve(),
|
||||
fail: reject
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
getUserDataPath(): string {
|
||||
return `${getWx().env.USER_DATA_PATH}`;
|
||||
}
|
||||
|
||||
async unzip(options: {
|
||||
zipFilePath: string;
|
||||
targetPath: string;
|
||||
}): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._fs.unzip({
|
||||
zipFilePath: options.zipFilePath,
|
||||
targetPath: options.targetPath,
|
||||
success: () => resolve(),
|
||||
fail: reject
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user