Skip to content

Commit

Permalink
chore: merge from develop
Browse files Browse the repository at this point in the history
  • Loading branch information
JackLian committed Feb 1, 2024
2 parents 719dfc0 + 19eb917 commit 170a45d
Show file tree
Hide file tree
Showing 24 changed files with 162 additions and 31 deletions.
2 changes: 1 addition & 1 deletion docs/docs/api/canvas.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: canvas - 画布 API
sidebar_position: 12
sidebar_position: 10
---

> **@types** [IPublicApiCanvas](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/canvas.ts)<br/>
Expand Down
101 changes: 101 additions & 0 deletions docs/docs/api/command.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
---
title: command - 指令 API
sidebar_position: 10
---



## 模块概览

该模块使得与命令系统的交互成为可能,提供了一种全面的方式来处理、执行和管理应用程序中的命令。



## 接口

### IPublicApiCommand

与命令交互的接口。它提供了注册、注销、执行和管理命令的方法。



## 方法

### registerCommand

注册一个新命令及其处理函数。

```
typescriptCopy code
/**
* 注册一个新的命令及其处理程序。
* @param command {IPublicTypeCommand} - 要注册的命令。
*/
registerCommand(command: IPublicTypeCommand): void;
```

### unregisterCommand

注销一个已存在的命令。

```
typescriptCopy code
/**
* 注销一个已存在的命令。
* @param name {string} - 要注销的命令的名称。
*/
unregisterCommand(name: string): void;
```

### executeCommand

根据名称和提供的参数执行命令,确保参数符合命令的定义。

```
typescriptCopy code
/**
* 根据名称和提供的参数执行命令。
* @param name {string} - 要执行的命令的名称。
* @param args {IPublicTypeCommandHandlerArgs} - 命令的参数。
*/
executeCommand(name: string, args?: IPublicTypeCommandHandlerArgs): void;
```

### batchExecuteCommand

批量执行命令,在所有命令执行后进行重绘,历史记录中只记录一次。

```
typescriptCopy code
/**
* 批量执行命令,随后进行重绘,历史记录中只记录一次。
* @param commands {Array} - 命令对象的数组,包含名称和可选参数。
*/
batchExecuteCommand(commands: { name: string; args?: IPublicTypeCommandHandlerArgs }[]): void;
```

### listCommands

列出所有已注册的命令。

```
typescriptCopy code
/**
* 列出所有已注册的命令。
* @returns {IPublicTypeListCommand[]} - 已注册命令的数组。
*/
listCommands(): IPublicTypeListCommand[];
```

### onCommandError

为命令执行过程中的错误注册错误处理回调函数。

```
typescriptCopy code
/**
* 为命令执行过程中的错误注册一个回调函数。
* @param callback {(name: string, error: Error) => void} - 错误处理的回调函数。
*/
onCommandError(callback: (name: string, error: Error) => void): void;
```
2 changes: 1 addition & 1 deletion docs/docs/api/common.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: common - 通用 API
sidebar_position: 11
sidebar_position: 10
---

> **@types** [IPublicApiCommon](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/common.ts)<br/>
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/api/commonUI.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: commonUI - UI 组件库
sidebar_position: 11
sidebar_position: 10
---

## 简介
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/api/config.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: config - 配置 API
sidebar_position: 8
sidebar_position: 5
---

> **@types** [IPublicModelEngineConfig](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/engine-config.ts)<br/>
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/api/configOptions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: config options - 配置列表
sidebar_position: 13
sidebar_position: 5
---

> **@types** [IPublicTypeEngineOptions](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/engine-options.ts)<br/>
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/api/event.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: event - 事件 API
sidebar_position: 7
sidebar_position: 10
---

> **@types** [IPublicApiEvent](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/event.ts)<br/>
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/api/hotkey.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: hotkey - 快捷键 API
sidebar_position: 5
sidebar_position: 10
---

> **@types** [IPublicApiHotkey](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/hotkey.ts)<br/>
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/api/init.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: init - 初始化 API
sidebar_position: 10
sidebar_position: 0
---

> **@since** v1.0.0
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/api/logger.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: logger - 日志 API
sidebar_position: 9
sidebar_position: 10
---

> **@types** [IPublicApiLogger](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/logger.ts)<br/>
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/api/material.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: material - 物料 API
sidebar_position: 2
sidebar_position: 10
---

> **@types** [IPublicApiMaterial](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/material.ts)<br/>
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/api/model/_category_.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"label": "模型定义 Models",
"position": 14,
"position": 100,
"collapsed": false,
"collapsible": true
}
2 changes: 1 addition & 1 deletion docs/docs/api/plugins.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: plugins - 插件 API
sidebar_position: 4
sidebar_position: 2
---
> **@types** [IPublicApiPlugins](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/plugins.ts)<br/>
> **@since** v1.0.0
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/api/project.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: project - 模型 API
sidebar_position: 3
sidebar_position: 10
---
## 模块简介

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/api/setters.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: setters - 设置器 API
sidebar_position: 6
sidebar_position: 10
---
> **@types** [IPublicApiSetters](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/setters.ts)<br/>
> **@since** v1.0.0
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/api/simulatorHost.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: simulatorHost - 模拟器 API
sidebar_position: 3
sidebar_position: 10
---
> **@types** [IPublicApiSimulatorHost](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/simulator-host.ts)<br/>
> **@since** v1.0.0
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/api/skeleton.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: skeleton - 面板 API
sidebar_position: 1
sidebar_position: 10
---
> **@types** [IPublicApiSkeleton](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/api/skeleton.ts)<br/>
> **@since** v1.0.0
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/api/workspace.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: workspace - 应用级 API
sidebar_position: 12
sidebar_position: 10
---

> **[@experimental](./#experimental)**<br/>
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-engine-docs",
"version": "1.2.30",
"version": "1.2.31",
"description": "低代码引擎版本化文档",
"license": "MIT",
"files": [
Expand Down
11 changes: 6 additions & 5 deletions packages/engine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
"@alilc/lowcode-editor-core": "1.3.2-beta.4",
"@alilc/lowcode-editor-skeleton": "1.3.2-beta.4",
"@alilc/lowcode-engine-ext": "^1.0.0",
"@alilc/lowcode-plugin-designer": "1.3.2-beta.4",
"@alilc/lowcode-plugin-outline-pane": "1.3.2-beta.4",
"@alilc/lowcode-shell": "1.3.2-beta.4",
"@alilc/lowcode-utils": "1.3.2-beta.4",
"@alilc/lowcode-workspace": "1.3.2-beta.4",
"@alilc/lowcode-plugin-designer": "1.3.1",
"@alilc/lowcode-plugin-outline-pane": "1.3.1",
"@alilc/lowcode-shell": "1.3.1",
"@alilc/lowcode-utils": "1.3.1",
"@alilc/lowcode-workspace": "1.3.1",
"@alilc/lowcode-plugin-command": "1.3.1",
"react": "^16.8.1",
"react-dom": "^16.8.1"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/engine/src/engine-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import { defaultPanelRegistry } from './inner-plugins/default-panel-registry';
import { shellModelFactory } from './modules/shell-model-factory';
import { builtinHotkey } from './inner-plugins/builtin-hotkey';
import { defaultContextMenu } from './inner-plugins/default-context-menu';
import { defaultCommand } from '@alilc/lowcode-plugin-command';
import { CommandPlugin } from '@alilc/lowcode-plugin-command';
import { OutlinePlugin } from '@alilc/lowcode-plugin-outline-pane';

export * from './modules/skeleton-types';
Expand All @@ -84,7 +84,7 @@ async function registryInnerPlugin(designer: IDesigner, editor: IEditor, plugins
await plugins.register(builtinHotkey);
await plugins.register(registerDefaults, {}, { autoInit: true });
await plugins.register(defaultContextMenu);
await plugins.register(defaultCommand, {});
await plugins.register(CommandPlugin, {});

return () => {
plugins.delete(OutlinePlugin.pluginName);
Expand All @@ -94,7 +94,7 @@ async function registryInnerPlugin(designer: IDesigner, editor: IEditor, plugins
plugins.delete(builtinHotkey.pluginName);
plugins.delete(registerDefaults.pluginName);
plugins.delete(defaultContextMenu.pluginName);
plugins.delete(defaultCommand.pluginName);
plugins.delete(CommandPlugin.pluginName);
};
}

Expand Down
22 changes: 22 additions & 0 deletions packages/plugin-command/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const fs = require('fs');
const { join } = require('path');
const esModules = [].join('|');
const pkgNames = fs.readdirSync(join('..')).filter(pkgName => !pkgName.startsWith('.'));

const jestConfig = {
transformIgnorePatterns: [
`/node_modules/(?!${esModules})/`,
],
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
collectCoverage: true,
collectCoverageFrom: [
'src/**/*.ts',
'src/**/*.tsx',
],
};

// 只对本仓库内的 pkg 做 mapping
jestConfig.moduleNameMapper = {};
jestConfig.moduleNameMapper[`^@alilc/lowcode\\-(${pkgNames.join('|')})$`] = '<rootDir>/../$1/src';

module.exports = jestConfig;
9 changes: 7 additions & 2 deletions packages/plugin-command/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
"author": "liujuping <[email protected]>",
"homepage": "https://github.com/alibaba/lowcode-engine#readme",
"license": "ISC",
"main": "lib/plugin-command.js",
"main": "lib/index.js",
"module": "es/index.js",
"directories": {
"lib": "lib",
"test": "__tests__"
},
"files": [
"lib"
"lib",
"es"
],
"publishConfig": {
"access": "public"
Expand All @@ -30,5 +32,8 @@
"dependencies": {
"@alilc/lowcode-types": "^1.3.1",
"@alilc/lowcode-utils": "^1.3.1"
},
"devDependencies": {
"@alib/build-scripts": "^0.1.18"
}
}
8 changes: 5 additions & 3 deletions packages/plugin-command/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { IPublicModelPluginContext, IPublicTypePlugin } from '@alilc/lowcode-typ
import { nodeCommand } from './node-command';
import { historyCommand } from './history-command';

export const defaultCommand: IPublicTypePlugin = (ctx: IPublicModelPluginContext) => {
export const CommandPlugin: IPublicTypePlugin = (ctx: IPublicModelPluginContext) => {
const { plugins } = ctx;

return {
Expand All @@ -17,7 +17,9 @@ export const defaultCommand: IPublicTypePlugin = (ctx: IPublicModelPluginContext
};
};

defaultCommand.pluginName = '___default_command___';
defaultCommand.meta = {
CommandPlugin.pluginName = '___default_command___';
CommandPlugin.meta = {
commandScope: 'common',
};

export default CommandPlugin;

0 comments on commit 170a45d

Please sign in to comment.