Feature/tilemap editor (#237)
* feat: 添加 Tilemap 编辑器插件和组件生命周期支持 * feat(editor-core): 添加声明式插件注册 API * feat(editor-core): 改进tiledmap结构合并tileset进tiledmapeditor * feat: 添加 editor-runtime SDK 和插件系统改进 * fix(ci): 修复SceneResourceManager里变量未使用问题
This commit is contained in:
43
packages/editor-runtime/package.json
Normal file
43
packages/editor-runtime/package.json
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "@esengine/editor-runtime",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"main": "dist/editor-runtime.js",
|
||||
"module": "dist/editor-runtime.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/editor-runtime.js"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist/**/*"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
"build:watch": "vite build --watch",
|
||||
"clean": "rimraf dist"
|
||||
},
|
||||
"dependencies": {
|
||||
"@esengine/ecs-framework": "workspace:*",
|
||||
"@esengine/editor-core": "workspace:*",
|
||||
"@tauri-apps/api": "^2.2.0",
|
||||
"@tauri-apps/plugin-dialog": "^2.4.0",
|
||||
"@tauri-apps/plugin-fs": "^2.4.2",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"zustand": "^5.0.8",
|
||||
"lucide-react": "^0.545.0",
|
||||
"tsyringe": "^4.10.0",
|
||||
"reflect-metadata": "^0.2.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.3.12",
|
||||
"@types/react-dom": "^18.3.1",
|
||||
"rimraf": "^5.0.0",
|
||||
"typescript": "^5.8.3",
|
||||
"vite": "^6.0.7",
|
||||
"vite-plugin-dts": "^4.5.0"
|
||||
}
|
||||
}
|
||||
232
packages/editor-runtime/src/index.ts
Normal file
232
packages/editor-runtime/src/index.ts
Normal file
@@ -0,0 +1,232 @@
|
||||
import 'reflect-metadata';
|
||||
|
||||
// =============================================================================
|
||||
// React
|
||||
// =============================================================================
|
||||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
export { React, ReactDOM };
|
||||
|
||||
export {
|
||||
useState,
|
||||
useEffect,
|
||||
useCallback,
|
||||
useMemo,
|
||||
useRef,
|
||||
useContext,
|
||||
useReducer,
|
||||
useLayoutEffect,
|
||||
useImperativeHandle,
|
||||
useDebugValue,
|
||||
useDeferredValue,
|
||||
useTransition,
|
||||
useId,
|
||||
useSyncExternalStore,
|
||||
useInsertionEffect,
|
||||
createContext,
|
||||
forwardRef,
|
||||
memo,
|
||||
lazy,
|
||||
Suspense,
|
||||
Fragment,
|
||||
StrictMode,
|
||||
createElement,
|
||||
cloneElement,
|
||||
isValidElement,
|
||||
Children,
|
||||
createRef,
|
||||
Component as ReactComponent,
|
||||
PureComponent
|
||||
} from 'react';
|
||||
|
||||
export type {
|
||||
FC,
|
||||
ReactNode,
|
||||
ReactElement,
|
||||
ComponentType,
|
||||
ComponentProps,
|
||||
PropsWithChildren,
|
||||
RefObject,
|
||||
MutableRefObject,
|
||||
Dispatch,
|
||||
SetStateAction,
|
||||
CSSProperties,
|
||||
MouseEvent,
|
||||
KeyboardEvent,
|
||||
ChangeEvent,
|
||||
FormEvent,
|
||||
FocusEvent,
|
||||
DragEvent
|
||||
} from 'react';
|
||||
|
||||
// =============================================================================
|
||||
// State Management
|
||||
// =============================================================================
|
||||
export { create as createStore } from 'zustand';
|
||||
export type { StoreApi, UseBoundStore } from 'zustand';
|
||||
|
||||
// =============================================================================
|
||||
// Dependency Injection
|
||||
// =============================================================================
|
||||
export { container, injectable, singleton, inject } from 'tsyringe';
|
||||
export type { DependencyContainer } from 'tsyringe';
|
||||
|
||||
// =============================================================================
|
||||
// ECS Framework Core
|
||||
// =============================================================================
|
||||
export * from '@esengine/ecs-framework';
|
||||
|
||||
// =============================================================================
|
||||
// Editor Core
|
||||
// Rename conflicting exports to avoid collision with ecs-framework
|
||||
// =============================================================================
|
||||
export {
|
||||
ComponentRegistry as EditorComponentRegistry,
|
||||
} from '@esengine/editor-core';
|
||||
|
||||
export type {
|
||||
IEventBus as IEditorEventBus,
|
||||
PluginState as EditorPluginState,
|
||||
PropertyControl as EditorPropertyControl,
|
||||
PropertyType as EditorPropertyType,
|
||||
} from '@esengine/editor-core';
|
||||
|
||||
// Runtime exports from editor-core
|
||||
export {
|
||||
// Enums
|
||||
EditorPluginCategory,
|
||||
PanelPosition,
|
||||
UIExtensionType,
|
||||
|
||||
// Classes
|
||||
EditorPluginManager,
|
||||
PluginRegistry,
|
||||
pluginRegistry,
|
||||
UIRegistry,
|
||||
MessageHub,
|
||||
SerializerRegistry,
|
||||
EntityStoreService,
|
||||
LocaleService,
|
||||
ProjectService,
|
||||
ComponentDiscoveryService,
|
||||
LogService,
|
||||
SettingsRegistry,
|
||||
SceneManagerService,
|
||||
FileActionRegistry,
|
||||
EntityCreationRegistry,
|
||||
CompilerRegistry,
|
||||
CommandManager,
|
||||
InspectorRegistry,
|
||||
PropertyRendererRegistry,
|
||||
FieldEditorRegistry,
|
||||
ComponentActionRegistry,
|
||||
BaseCommand,
|
||||
PropertyMetadataService,
|
||||
|
||||
// Gizmo exports
|
||||
GizmoRegistry,
|
||||
GizmoColors,
|
||||
hasGizmoProvider,
|
||||
hexToGizmoColor,
|
||||
isGizmoProviderRegistered,
|
||||
|
||||
// Symbols (用于跨包插件访问)
|
||||
IFileSystemService,
|
||||
IDialogService,
|
||||
IMessageHub,
|
||||
ICompilerRegistry,
|
||||
IInspectorRegistry,
|
||||
} from '@esengine/editor-core';
|
||||
|
||||
// Type-only exports from editor-core
|
||||
export type {
|
||||
// Plugin types
|
||||
IEditorPlugin,
|
||||
IEditorPluginMetadata,
|
||||
ISerializer,
|
||||
FileContextMenuItem,
|
||||
FileCreationTemplate,
|
||||
FileActionHandler,
|
||||
EditorPluginDefinition,
|
||||
RegisteredPlugin,
|
||||
MenuTreeNode,
|
||||
ComponentRegistration,
|
||||
MenuItemRegistration,
|
||||
PanelRegistration,
|
||||
ToolbarItemRegistration,
|
||||
EntityTemplateRegistration,
|
||||
AssetHandlerRegistration,
|
||||
ComponentActionDefinition,
|
||||
|
||||
// Service interfaces
|
||||
IFileSystem,
|
||||
FileEntry,
|
||||
IDialog,
|
||||
INotification,
|
||||
IInspectorProvider,
|
||||
InspectorContext,
|
||||
IPropertyRenderer,
|
||||
IFieldEditor,
|
||||
FieldEditorContext,
|
||||
ICompiler,
|
||||
CompileResult,
|
||||
CompilerContext,
|
||||
ICommand,
|
||||
IEditorDataStore,
|
||||
|
||||
// Module interfaces
|
||||
ICommandRegistry,
|
||||
IPanelRegistry,
|
||||
IModuleContext,
|
||||
IEditorModule,
|
||||
Unsubscribe,
|
||||
|
||||
// Gizmo types
|
||||
GizmoType,
|
||||
GizmoColor,
|
||||
IRectGizmoData,
|
||||
ICircleGizmoData,
|
||||
ILineGizmoData,
|
||||
IGridGizmoData,
|
||||
IGizmoRenderData,
|
||||
IGizmoProvider,
|
||||
GizmoProviderFn,
|
||||
|
||||
// UI types
|
||||
MenuItem,
|
||||
ToolbarItem,
|
||||
PanelDescriptor,
|
||||
EntityCreationTemplate,
|
||||
IFileAPI,
|
||||
PropertyMetadata,
|
||||
} from '@esengine/editor-core';
|
||||
|
||||
|
||||
// =============================================================================
|
||||
// Tauri API
|
||||
// =============================================================================
|
||||
export { invoke, convertFileSrc } from '@tauri-apps/api/core';
|
||||
export { open, save, message, ask, confirm } from '@tauri-apps/plugin-dialog';
|
||||
export {
|
||||
readTextFile,
|
||||
writeTextFile,
|
||||
readDir,
|
||||
exists,
|
||||
mkdir,
|
||||
remove,
|
||||
rename,
|
||||
copyFile
|
||||
} from '@tauri-apps/plugin-fs';
|
||||
|
||||
// =============================================================================
|
||||
// Icons (Lucide React)
|
||||
// =============================================================================
|
||||
import * as Icons from 'lucide-react';
|
||||
export { Icons };
|
||||
export type { LucideIcon } from 'lucide-react';
|
||||
|
||||
// =============================================================================
|
||||
// SDK Metadata
|
||||
// =============================================================================
|
||||
export const SDK_VERSION = '1.0.0';
|
||||
export const SDK_NAME = '@esengine/editor-runtime';
|
||||
26
packages/editor-runtime/tsconfig.json
Normal file
26
packages/editor-runtime/tsconfig.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"module": "ES2020",
|
||||
"moduleResolution": "bundler",
|
||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "react-jsx",
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true
|
||||
},
|
||||
"include": ["src"],
|
||||
"references": [
|
||||
{ "path": "../core" },
|
||||
{ "path": "../editor-core" },
|
||||
{ "path": "../behavior-tree" }
|
||||
]
|
||||
}
|
||||
44
packages/editor-runtime/vite.config.ts
Normal file
44
packages/editor-runtime/vite.config.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import { resolve } from 'path';
|
||||
import dts from 'vite-plugin-dts';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
dts({
|
||||
include: ['src'],
|
||||
outDir: 'dist',
|
||||
rollupTypes: true
|
||||
})
|
||||
],
|
||||
define: {
|
||||
'process.env.NODE_ENV': JSON.stringify('production')
|
||||
},
|
||||
esbuild: {
|
||||
// 保留类名,用于跨包插件服务匹配
|
||||
keepNames: true,
|
||||
},
|
||||
build: {
|
||||
lib: {
|
||||
entry: resolve(__dirname, 'src/index.ts'),
|
||||
formats: ['es'],
|
||||
fileName: () => 'editor-runtime.js'
|
||||
},
|
||||
rollupOptions: {
|
||||
// 将 React 设为外部依赖,使用主应用提供的 React
|
||||
external: ['react', 'react-dom', 'react/jsx-runtime'],
|
||||
output: {
|
||||
exports: 'named',
|
||||
inlineDynamicImports: true,
|
||||
// 映射外部依赖到全局变量
|
||||
globals: {
|
||||
'react': 'React',
|
||||
'react-dom': 'ReactDOM',
|
||||
'react/jsx-runtime': 'ReactJSXRuntime'
|
||||
}
|
||||
}
|
||||
},
|
||||
target: 'es2020',
|
||||
minify: false,
|
||||
sourcemap: true
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user