Skip to content

Commit c2db198

Browse files
committed
feat: add some big features to engine
1 parent 89f4b11 commit c2db198

File tree

507 files changed

+9261
-5204
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

507 files changed

+9261
-5204
lines changed

docs/docs/api/common.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ sidebar_position: 11
3232
*引擎版本 >= 1.0.16
3333
```typescript
3434
import { common } from '@alilc/lowcode-engine';
35-
import { TransitionType } from '@alilc/lowcode-types';
35+
import { IPublicEnumTransitionType } from '@alilc/lowcode-types';
3636

3737
common.utils.startTransaction(() => {
3838
node1.setProps();
3939
node2.setProps();
4040
node3.setProps();
4141
// ...
42-
}, TransitionType.repaint);
42+
}, IPublicEnumTransitionType.repaint);
4343
```
4444

4545
### createIntl

docs/docs/api/hotkey.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function saveSchema(schema) {
5353
// 保存 schema 相关操作
5454
}
5555

56-
const saveSampleHotKey = (ctx: ILowCodePluginContext) => {
56+
const saveSampleHotKey = (ctx: IPublicModelPluginContext) => {
5757
return {
5858
name: 'saveSample',
5959
async init() {

docs/docs/api/logger.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: logger - 日志 API
33
sidebar_position: 9
44
---
55
## 模块简介
6-
引擎日志模块,可以按照 **日志级别 **** 业务类型 **两个维度来定制日志,基于 [zen-logger](https://web.npm.alibaba-inc.com/package/zen-logger) 封装
6+
引擎日志模块,可以按照 **日志级别 **** 业务类型 **两个维度来定制日志,参考 [zen-logger](https://web.npm.alibaba-inc.com/package/zen-logger) 实现进行封装
77
> 注:日志级别可以通过 url query 动态调整,详见下方使用示例。
88
99
## 变量(variables)
@@ -22,18 +22,18 @@ function debug(args: any[]): void
2222
```
2323
**调用示例**
2424
```typescript
25-
import { logger } from '@alilc/lowcode-engine';
26-
25+
import { Logger } from '@alilc/lowcode-utils';
26+
const logger = new Logger({ level: 'warn', bizName: 'designer:pluginManager' });
2727
logger.log('Awesome Low-Code Engine');
2828
```
2929
## 事件(events)
3030
3131

3232
## 使用示例
3333
```typescript
34-
import { logger } from '@alilc/lowcode-engine';
34+
import { Logger } from '@alilc/lowcode-utils';
3535

36-
// 内部实现:logger = getLogger({ level: 'warn', bizName: 'designer:pluginManager' })
36+
const logger = new Logger({ level: 'warn', bizName: 'designer:pluginManager' });
3737

3838
// 若在 url query 中增加 `__logConf__` 可改变打印日志级别和限定业务类型日志
3939
// 默认:__logConf__=warn:*

docs/docs/api/material.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ material.setAssets(assets);
3030

3131
通过物料中心接口动态引入资产包
3232
```typescript
33-
import { ILowCodePluginContext, material, plugins } from '@alilc/lowcode-engine'
33+
import { material, plugins } from '@alilc/lowcode-engine';
34+
import { IPublicModelPluginContext } from '@alilc/lowcode-types';
3435

3536
// 动态加载 assets
36-
plugins.register((ctx: ILowCodePluginContext) => {
37+
plugins.register((ctx: IPublicModelPluginContext) => {
3738
return {
3839
name: 'ext-assets',
3940
async init() {
@@ -88,9 +89,9 @@ material.loadIncrementalAssets(assets2);
8889
在设计器辅助层增加一个扩展 action
8990
**类型定义**
9091
```typescript
91-
function addBuiltinComponentAction(action: ComponentAction): void;
92+
function addBuiltinComponentAction(action: IPublicTypeComponentAction): void;
9293

93-
export interface ComponentAction {
94+
export interface IPublicTypeComponentAction {
9495
/**
9596
* behaviorName
9697
*/
@@ -102,7 +103,7 @@ export interface ComponentAction {
102103
/**
103104
* 子集
104105
*/
105-
items?: ComponentAction[];
106+
items?: IPublicTypeComponentAction[];
106107
/**
107108
* 显示与否
108109
* always: 无法禁用
@@ -174,7 +175,7 @@ material.removeBuiltinComponentAction('myIconName');
174175
```typescript
175176
function modifyBuiltinComponentAction(
176177
actionName: string,
177-
handle: (action: ComponentAction) => void
178+
handle: (action: IPublicTypeComponentAction) => void
178179
): void;
179180
```
180181
**内置设计器辅助 name**
@@ -293,7 +294,7 @@ material.registerMetadataTransducer(addonCombine, 1, 'parse-func');
293294
获取所有物料元数据管道函数
294295
**类型定义**
295296
```typescript
296-
function getRegisteredMetadataTransducers(): MetadataTransducer[];
297+
function getRegisteredMetadataTransducers(): IPublicTypeMetadataTransducer[];
297298
```
298299

299300
**示例**

docs/docs/api/plugins.md

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ sidebar_position: 4
1313
#### 类型定义
1414
```typescript
1515
async function register(
16-
pluginConfigCreator: (ctx: ILowCodePluginContext) => ILowCodePluginConfig,
16+
pluginConfigCreator: (ctx: IPublicModelPluginContext) => IPublicTypePluginConfig,
1717
options?: ILowCodeRegisterOptions,
1818
): Promise<void>
1919
```
20-
pluginConfigCreator 是一个 ILowCodePluginConfig 生成函数,ILowCodePluginConfig 中包含了该插件的 init / destroy 等钩子函数,以及 exports 函数用于返回插件对外暴露的值。
20+
pluginConfigCreator 是一个 IPublicTypePluginConfig 生成函数,IPublicTypePluginConfig 中包含了该插件的 init / destroy 等钩子函数,以及 exports 函数用于返回插件对外暴露的值。
2121

2222
另外,pluginConfigCreator 还必须挂载 pluginName 字段,全局确保唯一,否则 register 时会报错,可以选择性挂载 meta 字段,用于描述插件的元数据信息,比如兼容的引擎版本、支持的参数配置、依赖插件声明等。
2323
> 注:pluginConfigCreator 挂载 pluginName / meta 可以通过低代码工具链的插件脚手架生成,写如 package.json 后将会自动注入到代码中,具体见 [插件元数据工程化示例](#RO9YY)
@@ -26,8 +26,9 @@ pluginConfigCreator 是一个 ILowCodePluginConfig 生成函数,ILowCodePlugin
2626
#### 简单示例
2727
```typescript
2828
import { plugins } from '@alilc/lowcode-engine';
29+
import { IPublicModelPluginContext } from '@alilc/lowcode-types';
2930
30-
const builtinPluginRegistry = (ctx: ILowCodePluginContext) => {
31+
const builtinPluginRegistry = (ctx: IPublicModelPluginContext) => {
3132
return {
3233
async init() {
3334
const { skeleton } = ctx;
@@ -58,16 +59,17 @@ await plugins.register(builtinPluginRegistry);
5859
#### 使用 exports 示例
5960
```typescript
6061
import { plugins } from '@alilc/lowcode-engine';
62+
import { IPublicModelPluginContext } from '@alilc/lowcode-types';
6163
62-
const pluginA = (ctx: ILowCodePluginContext) => {
64+
const pluginA = (ctx: IPublicModelPluginContext) => {
6365
return {
6466
async init() {},
6567
exports() { return { x: 1, } },
6668
};
6769
}
6870
pluginA.pluginName = 'pluginA';
6971
70-
const pluginB = (ctx: ILowCodePluginContext) => {
72+
const pluginB = (ctx: IPublicModelPluginContext) => {
7173
return {
7274
async init() {
7375
// 获取 pluginA 的导出值
@@ -83,14 +85,15 @@ pluginB.meta = {
8385
await plugins.register(pluginA);
8486
await plugins.register(pluginB);
8587
```
86-
> 注:ctx 是在插件 creator 中获取引擎 API 的上下文,具体定义参见 [ILowCodePluginContext](#qEhTb)
88+
> 注:ctx 是在插件 creator 中获取引擎 API 的上下文,具体定义参见 [IPublicModelPluginContext](#qEhTb)
8789

8890
####
8991
#### 设置兼容引擎版本示例
9092
```typescript
9193
import { plugins } from '@alilc/lowcode-engine';
94+
import { IPublicModelPluginContext } from '@alilc/lowcode-types';
9295
93-
const builtinPluginRegistry = (ctx: ILowCodePluginContext) => {
96+
const builtinPluginRegistry = (ctx: IPublicModelPluginContext) => {
9497
return {
9598
async init() {
9699
...
@@ -108,8 +111,9 @@ await plugins.register(builtinPluginRegistry);
108111
#### 设置插件参数版本示例
109112
```typescript
110113
import { plugins } from '@alilc/lowcode-engine';
114+
import { IPublicModelPluginContext } from '@alilc/lowcode-types';
111115
112-
const builtinPluginRegistry = (ctx: ILowCodePluginContext, options: any) => {
116+
const builtinPluginRegistry = (ctx: IPublicModelPluginContext, options: any) => {
113117
return {
114118
async init() {
115119
// 1.0.4 之后的传值方式,通过 register(xxx, options)
@@ -219,27 +223,27 @@ plugins.delete('builtinPluginRegistry');
219223
## 事件(events
220224
221225
## 相关模块
222-
### ILowCodePluginContext
226+
### IPublicModelPluginContext
223227
**类型定义**
224228
```typescript
225-
export interface ILowCodePluginContext {
226-
skeleton: Skeleton; // 参考面板 API
227-
hotkey: Hotkey; // 参考快捷键 API
228-
setters: Setters; // 参考设置器 API
229-
config: EngineConfig; // 参考配置 API
230-
material: Material; // 参考物料 API
231-
event: Event; // 参考事件 API
232-
project: Project; // 参考模型 API
233-
common: Common; // 参考模型 API
234-
logger: Logger; // 参考日志 API
235-
plugins: ILowCodePluginManager; // 即本文档描述内容
229+
export interface IPublicModelPluginContext {
230+
get skeleton(): IPublicApiSkeleton;
231+
get hotkey(): IPublicApiHotkey;
232+
get setters(): IPublicApiSetters;
233+
get config(): IEngineConfig;
234+
get material(): IPublicApiMaterial;
235+
get event(): IPublicApiEvent;
236+
get project(): IPublicApiProject;
237+
get common(): IPublicApiCommon;
238+
logger: IPublicApiLogger;
239+
plugins: IPublicApiPlugins;
236240
preference: IPluginPreferenceMananger;
237241
}
238242
```
239-
### ILowCodePluginConfig
243+
### IPublicTypePluginConfig
240244
**类型定义**
241245
```typescript
242-
export interface ILowCodePluginConfig {
246+
export interface IPublicTypePluginConfig {
243247
init?(): void;
244248
destroy?(): void;
245249
exports?(): any;
@@ -263,7 +267,7 @@ your-plugin/package.json
263267
```
264268
转换后的结构:
265269
```json
266-
const debug = (ctx: ILowCodePluginContext, options: any) => {
270+
const debug = (ctx: IPublicModelPluginContext, options: any) => {
267271
return {};
268272
}
269273

docs/docs/api/project.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ addPropsTransducer(transducer: PropsTransducer, stage: TransformStage)
7979

8080
**示例 1:在保存的时候删除每一个组件的 props.hidden**
8181
```typescript
82-
import { ILowCodePluginContext, project } from '@alilc/lowcode-engine';
83-
import { CompositeObject, TransformStage } from '@alilc/lowcode-types';
82+
import { project } from '@alilc/lowcode-engine';
83+
import { CompositeObject, TransformStage, IPublicModelPluginContext } from '@alilc/lowcode-types';
8484

85-
export const deleteHiddenTransducer = (ctx: ILowCodePluginContext) => {
85+
export const deleteHiddenTransducer = (ctx: IPublicModelPluginContext) => {
8686
return {
8787
name: 'deleteHiddenTransducer',
8888
async init() {

docs/docs/api/setters.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ function registerSetter(
3838
```typescript
3939
import { setters, skeleton } from '@alilc/lowcode-engine';
4040
import { setterMap, pluginMap } from '@alilc/lowcode-engine-ext';
41+
import { IPublicModelPluginContext } from '@alilc/lowcode-types';
4142
42-
const setterRegistry = (ctx: ILowCodePluginContext) => {
43+
const setterRegistry = (ctx: IPublicModelPluginContext) => {
4344
return {
4445
name: 'ext-setters-registry',
4546
async init() {
@@ -209,8 +210,9 @@ function registerSetter(
209210
```typescript
210211
import { setters, skeleton } from '@alilc/lowcode-engine';
211212
import { setterMap, pluginMap } from '@alilc/lowcode-engine-ext';
213+
import { IPublicModelPluginContext } from '@alilc/lowcode-types';
212214
213-
const setterRegistry = (ctx: ILowCodePluginContext) => {
215+
const setterRegistry = (ctx: IPublicModelPluginContext) => {
214216
return {
215217
name: 'ext-setters-registry',
216218
async init() {

docs/docs/guide/expand/editor/cli.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,13 @@ npm publish
130130
2. 在引擎初始化侧引入插件
131131
```typescript
132132
import Inject, { injectAssets } from '@alilc/lowcode-plugin-inject';
133+
import { IPublicModelPluginContext } from '@alilc/lowcode-types';
133134

134135
export default async () => {
135136
// 注意 Inject 插件必须在其他插件前注册,且所有插件的注册必须 await
136137
await plugins.register(Inject);
137138
await plugins.register(OtherPlugin);
138-
await plugins.register((ctx: ILowCodePluginContext) => {
139+
await plugins.register((ctx: IPublicModelPluginContext) => {
139140
return {
140141
name: "editor-init",
141142
async init() {

docs/docs/guide/expand/editor/material.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,11 @@ npm publish
270270

271271
### 在项目中引入资产包
272272
```typescript
273-
import { ILowCodePluginContext, material, plugins } from '@alilc/lowcode-engine';
273+
import { material, plugins } from '@alilc/lowcode-engine';
274+
import { IPublicModelPluginContext } from '@alilc/lowcode-types';
274275

275276
// 动态加载 assets
276-
plugins.register((ctx: ILowCodePluginContext) => {
277+
plugins.register((ctx: IPublicModelPluginContext) => {
277278
return {
278279
name: 'ext-assets',
279280
async init() {

docs/docs/guide/expand/editor/pluginContextMenu.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ sidebar_position: 6
1010

1111
```typescript
1212
import { plugins } from '@alilc/lowcode-engine';
13+
import { IPublicModelPluginContext } from '@alilc/lowcode-types';
1314
import { Icon, Message } from '@alifd/next';
1415

15-
const addHelloAction = (ctx: ILowCodePluginContext) => {
16+
const addHelloAction = (ctx: IPublicModelPluginContext) => {
1617
return {
1718
async init() {
1819
const { addBuiltinComponentAction } = ctx.material;
@@ -46,8 +47,9 @@ await plugins.register(addHelloAction);
4647

4748
```typescript
4849
import { plugins } from '@alilc/lowcode-engine';
50+
import { IPublicModelPluginContext } from '@alilc/lowcode-types';
4951

50-
const removeCopyAction = (ctx: ILowCodePluginContext) => {
52+
const removeCopyAction = (ctx: IPublicModelPluginContext) => {
5153
return {
5254
async init() {
5355
const { removeBuiltinComponentAction } = ctx.material;

0 commit comments

Comments
 (0)