@chamn/engine 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/build.config.js +1 -0
- package/dist/Engine.d.ts +40 -0
- package/dist/component/Workbench/index.d.ts +57 -0
- package/dist/core/pluginManager.d.ts +56 -0
- package/dist/i18n/en_US/index.d.ts +5 -0
- package/dist/i18n/index.d.ts +6 -0
- package/dist/i18n/zh_CN/index.d.ts +5 -0
- package/dist/index.cjs.js +213 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.es.js +13492 -0
- package/dist/index.es.js.map +1 -0
- package/dist/style.css +1 -0
- package/dist/typing.d.ts +4 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/vite-env.d.ts +1 -0
- package/package.json +10 -7
- package/src/typing.d.ts +4 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [0.0.2](https://github.com/ByteCrazy/chameleon/compare/v0.0.1...v0.0.2) (2023-03-27)
|
|
7
|
+
|
|
8
|
+
### 🐛 Bug Fixes | Bug 修复
|
|
9
|
+
|
|
10
|
+
* **engine:** 🐛 fix engine not incluce dist folder ([fc2c39e](https://github.com/ByteCrazy/chameleon/commit/fc2c39e88aa2eeb82ba5e3989e5bdf244d112dfb))
|
package/build.config.js
CHANGED
package/dist/Engine.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Workbench } from './component/Workbench';
|
|
3
|
+
import { CPlugin, PluginManager } from './core/pluginManager';
|
|
4
|
+
import { Emitter } from 'mitt';
|
|
5
|
+
import { AssetPackage, CMaterialType, CNode, CPage, CPageDataType, CRootNode } from '@chamn/model';
|
|
6
|
+
export type EnginContext = {
|
|
7
|
+
pluginManager: PluginManager;
|
|
8
|
+
engine: Engine;
|
|
9
|
+
};
|
|
10
|
+
export type EngineProps = {
|
|
11
|
+
plugins: CPlugin[];
|
|
12
|
+
schema: CPageDataType;
|
|
13
|
+
material?: CMaterialType[];
|
|
14
|
+
assets?: AssetPackage[];
|
|
15
|
+
assetPackagesList?: AssetPackage[];
|
|
16
|
+
beforePluginRun?: (options: {
|
|
17
|
+
pluginManager: PluginManager;
|
|
18
|
+
}) => void;
|
|
19
|
+
onReady?: (ctx: EnginContext) => void;
|
|
20
|
+
};
|
|
21
|
+
declare class Engine extends React.Component<EngineProps> {
|
|
22
|
+
currentSelectNode: CNode | CRootNode | null;
|
|
23
|
+
pluginManager: PluginManager;
|
|
24
|
+
workbenchRef: React.RefObject<Workbench>;
|
|
25
|
+
pageSchema: CPageDataType | undefined;
|
|
26
|
+
pageModel: CPage;
|
|
27
|
+
material: CMaterialType[] | undefined;
|
|
28
|
+
emitter: Emitter<any>;
|
|
29
|
+
constructor(props: EngineProps);
|
|
30
|
+
updateCurrentSelectNode(node: CNode | CRootNode): void;
|
|
31
|
+
componentDidMount(): Promise<void>;
|
|
32
|
+
getActiveNode(): CNode | CRootNode | null;
|
|
33
|
+
updatePage: (page: CPageDataType) => void;
|
|
34
|
+
updateDesignerAssets: (assets: AssetPackage[]) => void;
|
|
35
|
+
updateMaterial: (material: CMaterialType[]) => void;
|
|
36
|
+
refresh: () => void;
|
|
37
|
+
getWorkbench: () => Workbench | null;
|
|
38
|
+
render(): JSX.Element;
|
|
39
|
+
}
|
|
40
|
+
export default Engine;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ResizeCallback } from 're-resizable';
|
|
3
|
+
import { Emitter } from 'mitt';
|
|
4
|
+
export interface PluginContext {
|
|
5
|
+
openPanel: () => void;
|
|
6
|
+
closePanel: () => void;
|
|
7
|
+
getPlugin: (pluginName: string) => any;
|
|
8
|
+
emitter: Emitter<any>;
|
|
9
|
+
}
|
|
10
|
+
type PanelItem = {
|
|
11
|
+
name: string;
|
|
12
|
+
title: string | React.ReactNode;
|
|
13
|
+
icon: React.ReactNode;
|
|
14
|
+
render: React.ReactNode;
|
|
15
|
+
};
|
|
16
|
+
type WorkbenchStateType = {
|
|
17
|
+
leftBoxVisible: boolean;
|
|
18
|
+
leftBoxSize: {
|
|
19
|
+
width: number;
|
|
20
|
+
height: number | string;
|
|
21
|
+
};
|
|
22
|
+
leftBoxFixed: boolean;
|
|
23
|
+
rightBoxSize: {
|
|
24
|
+
width: number;
|
|
25
|
+
height: number | string;
|
|
26
|
+
};
|
|
27
|
+
rightBoxVisible: boolean;
|
|
28
|
+
currentActiveLeftPanel: string;
|
|
29
|
+
leftPanels: PanelItem[];
|
|
30
|
+
bodyView: React.ReactNode | null;
|
|
31
|
+
rightView: React.ReactNode | null;
|
|
32
|
+
topToolBarView: React.ReactNode | null;
|
|
33
|
+
};
|
|
34
|
+
export type WorkbenchPropsType = {
|
|
35
|
+
emitter: Emitter<any>;
|
|
36
|
+
};
|
|
37
|
+
export declare class Workbench extends React.Component<WorkbenchPropsType, WorkbenchStateType> {
|
|
38
|
+
emitter: Emitter<any>;
|
|
39
|
+
leftPanelContentRef: React.RefObject<HTMLDivElement>;
|
|
40
|
+
constructor(props: WorkbenchPropsType);
|
|
41
|
+
addLeftPanel: (panel: PanelItem) => void;
|
|
42
|
+
openLeftPanel: (currentActiveLeftPanel?: string) => Promise<void>;
|
|
43
|
+
closeLeftPanel: () => Promise<void>;
|
|
44
|
+
toggleLeftPanel: () => void;
|
|
45
|
+
onPluginIconClick: (panel: PanelItem) => void;
|
|
46
|
+
openRightPanel: () => void;
|
|
47
|
+
closeRightPanel: () => void;
|
|
48
|
+
replaceBodyView: (newView: React.ReactNode) => void;
|
|
49
|
+
replaceRightView: (newView: React.ReactNode) => void;
|
|
50
|
+
replaceTopBarView: (newView: React.ReactNode) => void;
|
|
51
|
+
toggleRightPanel: () => void;
|
|
52
|
+
onLeftBoxResizeStop: ResizeCallback;
|
|
53
|
+
onGlobalClick: (e: MouseEvent) => void;
|
|
54
|
+
componentDidMount(): void;
|
|
55
|
+
render(): JSX.Element;
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import Engine from '../Engine';
|
|
2
|
+
import { AssetPackage, CPage } from '@chamn/model';
|
|
3
|
+
import { Emitter } from 'mitt';
|
|
4
|
+
import { Workbench } from '../component/Workbench';
|
|
5
|
+
import { CustomI18n } from '../i18n';
|
|
6
|
+
export type PluginObj = {
|
|
7
|
+
name: string;
|
|
8
|
+
init: (ctx: CPluginCtx) => Promise<void>;
|
|
9
|
+
destroy: (ctx: CPluginCtx) => Promise<void>;
|
|
10
|
+
exports: (ctx: CPluginCtx) => any;
|
|
11
|
+
meta: {
|
|
12
|
+
engine: {
|
|
13
|
+
version: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export type CPlugin = PluginObj | ((ctx: CPluginCtx) => PluginObj);
|
|
18
|
+
type PluginManagerOptions = {
|
|
19
|
+
getWorkbench: () => Workbench;
|
|
20
|
+
emitter: Emitter<any>;
|
|
21
|
+
pageModel: CPage;
|
|
22
|
+
i18n: CustomI18n;
|
|
23
|
+
assets: AssetPackage[];
|
|
24
|
+
engine: Engine;
|
|
25
|
+
};
|
|
26
|
+
export type CPluginCtx<C = any> = {
|
|
27
|
+
globalEmitter: Emitter<any>;
|
|
28
|
+
config: C;
|
|
29
|
+
pluginManager: PluginManager;
|
|
30
|
+
pluginReadyOk: () => void;
|
|
31
|
+
} & PluginManagerOptions;
|
|
32
|
+
export type PluginInstance = {
|
|
33
|
+
ctx: CPluginCtx;
|
|
34
|
+
exports: any;
|
|
35
|
+
source: PluginObj;
|
|
36
|
+
ready: boolean;
|
|
37
|
+
};
|
|
38
|
+
export type CustomPluginHook = (pluginInstance: PluginInstance) => PluginInstance;
|
|
39
|
+
export declare class PluginManager {
|
|
40
|
+
plugins: Map<string, PluginInstance>;
|
|
41
|
+
emitter: Emitter<any>;
|
|
42
|
+
getWorkbench: () => Workbench;
|
|
43
|
+
pageModel: CPage;
|
|
44
|
+
i18n: CustomI18n;
|
|
45
|
+
assets: AssetPackage[];
|
|
46
|
+
engine: Engine;
|
|
47
|
+
customPluginHooks: Record<string, CustomPluginHook[]>;
|
|
48
|
+
constructor({ getWorkbench, emitter, pageModel, i18n, assets, engine }: PluginManagerOptions);
|
|
49
|
+
customPlugin: (pluginName: string, customPluginHook: CustomPluginHook) => void;
|
|
50
|
+
createPluginCtx: () => CPluginCtx<any>;
|
|
51
|
+
add(plugin: CPlugin): Promise<void>;
|
|
52
|
+
get(pluginName: string): Promise<PluginInstance | undefined>;
|
|
53
|
+
remove(name: string): Promise<void>;
|
|
54
|
+
onPluginReadyOk(pluginName: string, cb?: (pluginHandle: PluginInstance) => void): Promise<PluginInstance> | undefined;
|
|
55
|
+
}
|
|
56
|
+
export {};
|