mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-12 11:20:11 +00:00
refactor(types): rename EngineOptions, and adjust related docs
This commit is contained in:
parent
622b3fd958
commit
4ef61183ef
@ -14,13 +14,13 @@ sidebar_position: 10
|
|||||||
|
|
||||||
**方法定义**
|
**方法定义**
|
||||||
```typescript
|
```typescript
|
||||||
function init(container?: Element, options?: EngineOptions): void
|
function init(container?: Element, options?: IPublicTypeEngineOptions): void
|
||||||
```
|
```
|
||||||
|
|
||||||
**初始化引擎的参数**
|
**初始化引擎的参数**
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
interface EngineOptions {
|
interface IPublicTypeEngineOptions {
|
||||||
/**
|
/**
|
||||||
* 指定初始化的 device
|
* 指定初始化的 device
|
||||||
*/
|
*/
|
||||||
@ -107,7 +107,7 @@ interface EngineOptions {
|
|||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
> 源码详见 [EngineOptions](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/engine-config.ts)
|
> 源码详见 [IPublicTypeEngineOptions](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/engine-options.ts)
|
||||||
|
|
||||||
|
|
||||||
## 使用示例
|
## 使用示例
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { get as lodashGet } from 'lodash';
|
import { get as lodashGet } from 'lodash';
|
||||||
import { isPlainObject } from '@alilc/lowcode-utils';
|
import { isPlainObject } from '@alilc/lowcode-utils';
|
||||||
import {
|
import {
|
||||||
EngineOptions,
|
IPublicTypeEngineOptions,
|
||||||
IPublicModelEngineConfig,
|
IPublicModelEngineConfig,
|
||||||
IPublicModelPreference,
|
IPublicModelPreference,
|
||||||
} from '@alilc/lowcode-types';
|
} from '@alilc/lowcode-types';
|
||||||
@ -150,7 +150,7 @@ const VALID_ENGINE_OPTIONS = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const getStrictModeValue = (engineOptions: EngineOptions, defaultValue: boolean): boolean => {
|
const getStrictModeValue = (engineOptions: IPublicTypeEngineOptions, defaultValue: boolean): boolean => {
|
||||||
if (!engineOptions || !isPlainObject(engineOptions)) {
|
if (!engineOptions || !isPlainObject(engineOptions)) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
@ -165,10 +165,9 @@ export interface IEngineConfigPrivate {
|
|||||||
/**
|
/**
|
||||||
* if engineOptions.strictPluginMode === true, only accept propertied predefined in EngineOptions.
|
* if engineOptions.strictPluginMode === true, only accept propertied predefined in EngineOptions.
|
||||||
*
|
*
|
||||||
* @param {EngineOptions} engineOptions
|
* @param {IPublicTypeEngineOptions} engineOptions
|
||||||
* @memberof EngineConfig
|
|
||||||
*/
|
*/
|
||||||
setEngineOptions(engineOptions: EngineOptions): void;
|
setEngineOptions(engineOptions: IPublicTypeEngineOptions): void;
|
||||||
|
|
||||||
notifyGot(key: string): void;
|
notifyGot(key: string): void;
|
||||||
|
|
||||||
@ -203,7 +202,6 @@ export class EngineConfig implements IPublicModelEngineConfig, IEngineConfigPriv
|
|||||||
/**
|
/**
|
||||||
* 判断指定 key 是否有值
|
* 判断指定 key 是否有值
|
||||||
* @param key
|
* @param key
|
||||||
* @returns
|
|
||||||
*/
|
*/
|
||||||
has(key: string): boolean {
|
has(key: string): boolean {
|
||||||
return this.config[key] !== undefined;
|
return this.config[key] !== undefined;
|
||||||
@ -213,7 +211,6 @@ export class EngineConfig implements IPublicModelEngineConfig, IEngineConfigPriv
|
|||||||
* 获取指定 key 的值
|
* 获取指定 key 的值
|
||||||
* @param key
|
* @param key
|
||||||
* @param defaultValue
|
* @param defaultValue
|
||||||
* @returns
|
|
||||||
*/
|
*/
|
||||||
get(key: string, defaultValue?: any): any {
|
get(key: string, defaultValue?: any): any {
|
||||||
return lodashGet(this.config, key, defaultValue);
|
return lodashGet(this.config, key, defaultValue);
|
||||||
@ -244,10 +241,9 @@ export class EngineConfig implements IPublicModelEngineConfig, IEngineConfigPriv
|
|||||||
/**
|
/**
|
||||||
* if engineOptions.strictPluginMode === true, only accept propertied predefined in EngineOptions.
|
* if engineOptions.strictPluginMode === true, only accept propertied predefined in EngineOptions.
|
||||||
*
|
*
|
||||||
* @param {EngineOptions} engineOptions
|
* @param {IPublicTypeEngineOptions} engineOptions
|
||||||
* @memberof EngineConfig
|
|
||||||
*/
|
*/
|
||||||
setEngineOptions(engineOptions: EngineOptions) {
|
setEngineOptions(engineOptions: IPublicTypeEngineOptions) {
|
||||||
if (!engineOptions || !isPlainObject(engineOptions)) {
|
if (!engineOptions || !isPlainObject(engineOptions)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import {
|
|||||||
Hotkey as InnerHotkey,
|
Hotkey as InnerHotkey,
|
||||||
} from '@alilc/lowcode-editor-core';
|
} from '@alilc/lowcode-editor-core';
|
||||||
import {
|
import {
|
||||||
EngineOptions,
|
IPublicTypeEngineOptions,
|
||||||
IPublicModelDocumentModel,
|
IPublicModelDocumentModel,
|
||||||
IPublicTypePluginMeta,
|
IPublicTypePluginMeta,
|
||||||
} from '@alilc/lowcode-types';
|
} from '@alilc/lowcode-types';
|
||||||
@ -158,7 +158,7 @@ engineConfig.set('ENGINE_VERSION', version);
|
|||||||
|
|
||||||
export async function init(
|
export async function init(
|
||||||
container?: HTMLElement,
|
container?: HTMLElement,
|
||||||
options?: EngineOptions,
|
options?: IPublicTypeEngineOptions,
|
||||||
pluginPreference?: PluginPreference,
|
pluginPreference?: PluginPreference,
|
||||||
) {
|
) {
|
||||||
await destroy();
|
await destroy();
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { BuiltinSimulatorHost, Node, IPublicTypePropChangeOptions } from '@alilc/lowcode-designer';
|
import { BuiltinSimulatorHost, Node, IPublicTypePropChangeOptions } from '@alilc/lowcode-designer';
|
||||||
import { GlobalEvent, IPublicEnumTransformStage, IPublicTypeNodeSchema, EngineOptions } from '@alilc/lowcode-types';
|
import { GlobalEvent, IPublicEnumTransformStage, IPublicTypeNodeSchema, IPublicTypeEngineOptions } from '@alilc/lowcode-types';
|
||||||
import { isReactComponent, cloneEnumerableProperty } from '@alilc/lowcode-utils';
|
import { isReactComponent, cloneEnumerableProperty } from '@alilc/lowcode-utils';
|
||||||
import { debounce } from '../utils/common';
|
import { debounce } from '../utils/common';
|
||||||
import adapter from '../adapter';
|
import adapter from '../adapter';
|
||||||
@ -30,7 +30,7 @@ export interface IComponentHocState {
|
|||||||
nodeProps: any;
|
nodeProps: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
type DesignMode = Pick<EngineOptions, 'designMode'>['designMode'];
|
type DesignMode = Pick<IPublicTypeEngineOptions, 'designMode'>['designMode'];
|
||||||
|
|
||||||
export interface IComponentHoc {
|
export interface IComponentHoc {
|
||||||
designMode: DesignMode | DesignMode[];
|
designMode: DesignMode | DesignMode[];
|
||||||
|
|||||||
@ -26,6 +26,5 @@ export * from './designer';
|
|||||||
export * from './dragon';
|
export * from './dragon';
|
||||||
export * from './shell';
|
export * from './shell';
|
||||||
export * from './shell-model-factory';
|
export * from './shell-model-factory';
|
||||||
export * from './engine-config';
|
|
||||||
// TODO: remove this in future versions
|
// TODO: remove this in future versions
|
||||||
export * from './deprecated';
|
export * from './deprecated';
|
||||||
|
|||||||
@ -1,99 +1,129 @@
|
|||||||
import { RequestHandlersMap } from '@alilc/lowcode-datasource-types';
|
import { RequestHandlersMap } from '@alilc/lowcode-datasource-types';
|
||||||
import { ComponentType } from 'react';
|
import { ComponentType } from 'react';
|
||||||
|
|
||||||
export interface EngineOptions {
|
export interface IPublicTypeEngineOptions {
|
||||||
/**
|
/**
|
||||||
* 是否开启 condition 的能力,默认在设计器中不管 condition 是啥都正常展示
|
* 是否开启 condition 的能力,默认在设计器中不管 condition 是啥都正常展示
|
||||||
|
* when this is true, node that configured as conditional not renderring
|
||||||
|
* will not display in canvas.
|
||||||
|
* @default false
|
||||||
*/
|
*/
|
||||||
enableCondition?: boolean;
|
enableCondition?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo designMode 无法映射到文档渲染模块
|
* TODO: designMode 无法映射到文档渲染模块
|
||||||
*
|
*
|
||||||
* 设计模式,live 模式将会实时展示变量值,默认值:'design'
|
* 设计模式,live 模式将会实时展示变量值,默认值:'design'
|
||||||
|
*
|
||||||
|
* @default 'design'
|
||||||
|
* @experimental
|
||||||
*/
|
*/
|
||||||
designMode?: 'design' | 'live';
|
designMode?: 'design' | 'live';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备类型,默认值:'default'
|
* 设备类型,默认值:'default'
|
||||||
|
* @default 'default'
|
||||||
*/
|
*/
|
||||||
device?: 'default' | 'mobile' | string;
|
device?: 'default' | 'mobile' | string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 指定初始化的 deviceClassName,挂载到画布的顶层节点上
|
* 指定初始化的 deviceClassName,挂载到画布的顶层节点上
|
||||||
*/
|
*/
|
||||||
deviceClassName?: string;
|
deviceClassName?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 语言,默认值:'zh-CN'
|
* 语言,默认值:'zh-CN'
|
||||||
|
* @default 'zh-CN'
|
||||||
*/
|
*/
|
||||||
locale?: string;
|
locale?: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 渲染器类型,默认值:'react'
|
* 渲染器类型,默认值:'react'
|
||||||
*/
|
*/
|
||||||
renderEnv?: 'react' | 'rax' | string;
|
renderEnv?: 'react' | 'rax' | string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备类型映射器,处理设计器与渲染器中 device 的映射
|
* 设备类型映射器,处理设计器与渲染器中 device 的映射
|
||||||
*/
|
*/
|
||||||
deviceMapper?: {
|
deviceMapper?: {
|
||||||
transform: (originalDevice: string) => string;
|
transform: (originalDevice: string) => string;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开启严格插件模式,默认值:STRICT_PLUGIN_MODE_DEFAULT , 严格模式下,插件将无法通过 engineOptions 传递自定义配置项
|
* 开启严格插件模式,默认值:STRICT_PLUGIN_MODE_DEFAULT , 严格模式下,插件将无法通过 engineOptions 传递自定义配置项
|
||||||
* enable strict plugin mode, default value: false
|
* enable strict plugin mode, default value: false
|
||||||
* under strict mode, customed engineOption is not accepted.
|
* under strict mode, customed engineOption is not accepted.
|
||||||
*/
|
*/
|
||||||
enableStrictPluginMode?: boolean;
|
enableStrictPluginMode?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开启拖拽组件时,即将被放入的容器是否有视觉反馈,默认值:false
|
* 开启拖拽组件时,即将被放入的容器是否有视觉反馈,默认值:false
|
||||||
*/
|
*/
|
||||||
enableReactiveContainer?: boolean;
|
enableReactiveContainer?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关闭画布自动渲染,在资产包多重异步加载的场景有效,默认值:false
|
* 关闭画布自动渲染,在资产包多重异步加载的场景有效,默认值:false
|
||||||
*/
|
*/
|
||||||
disableAutoRender?: boolean;
|
disableAutoRender?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关闭拖拽组件时的虚线响应,性能考虑,默认值:false
|
* 关闭拖拽组件时的虚线响应,性能考虑,默认值:false
|
||||||
*/
|
*/
|
||||||
disableDetecting?: boolean;
|
disableDetecting?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 定制画布中点击被忽略的 selectors,默认值:undefined
|
* 定制画布中点击被忽略的 selectors,默认值:undefined
|
||||||
*/
|
*/
|
||||||
customizeIgnoreSelectors?: (defaultIgnoreSelectors: string[], e: MouseEvent) => string[];
|
customizeIgnoreSelectors?: (defaultIgnoreSelectors: string[], e: MouseEvent) => string[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 禁止默认的设置面板,默认值:false
|
* 禁止默认的设置面板,默认值:false
|
||||||
*/
|
*/
|
||||||
disableDefaultSettingPanel?: boolean;
|
disableDefaultSettingPanel?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 禁止默认的设置器,默认值:false
|
* 禁止默认的设置器,默认值:false
|
||||||
*/
|
*/
|
||||||
disableDefaultSetters?: boolean;
|
disableDefaultSetters?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打开画布的锁定操作,默认值:false
|
* 打开画布的锁定操作,默认值:false
|
||||||
*/
|
*/
|
||||||
enableCanvasLock?: boolean;
|
enableCanvasLock?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 容器锁定后,容器本身是否可以设置属性,仅当画布锁定特性开启时生效,默认值为:false
|
* 容器锁定后,容器本身是否可以设置属性,仅当画布锁定特性开启时生效,默认值为:false
|
||||||
*/
|
*/
|
||||||
enableLockedNodeSetting?: boolean;
|
enableLockedNodeSetting?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当选中节点切换时,是否停留在相同的设置 tab 上,默认值:false
|
* 当选中节点切换时,是否停留在相同的设置 tab 上,默认值:false
|
||||||
*/
|
*/
|
||||||
stayOnTheSameSettingTab?: boolean;
|
stayOnTheSameSettingTab?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否在只有一个 item 的时候隐藏设置 tabs,默认值:false
|
* 是否在只有一个 item 的时候隐藏设置 tabs,默认值:false
|
||||||
*/
|
*/
|
||||||
hideSettingsTabsWhenOnlyOneItem?: boolean;
|
hideSettingsTabsWhenOnlyOneItem?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义 loading 组件
|
* 自定义 loading 组件
|
||||||
*/
|
*/
|
||||||
loadingComponent?: ComponentType;
|
loadingComponent?: ComponentType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置所有属性支持变量配置,默认值:false
|
* 设置所有属性支持变量配置,默认值:false
|
||||||
*/
|
*/
|
||||||
supportVariableGlobally?: boolean;
|
supportVariableGlobally?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置 simulator 相关的 url,默认值:undefined
|
* 设置 simulator 相关的 url,默认值:undefined
|
||||||
*/
|
*/
|
||||||
simulatorUrl?: string[];
|
simulatorUrl?: string[];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vision-polyfill settings
|
* Vision-polyfill settings
|
||||||
|
* @deprecated this exists for some legacy reasons
|
||||||
*/
|
*/
|
||||||
visionSettings?: {
|
visionSettings?: {
|
||||||
// 是否禁用降级 reducer,默认值:false
|
// 是否禁用降级 reducer,默认值:false
|
||||||
@ -101,6 +131,7 @@ export interface EngineOptions {
|
|||||||
// 是否开启在 render 阶段开启 filter reducer,默认值:false
|
// 是否开启在 render 阶段开启 filter reducer,默认值:false
|
||||||
enableFilterReducerInRenderStage?: boolean;
|
enableFilterReducerInRenderStage?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 与 react-renderer 的 appHelper 一致,https://lowcode-engine.cn/site/docs/guide/expand/runtime/renderer#apphelper
|
* 与 react-renderer 的 appHelper 一致,https://lowcode-engine.cn/site/docs/guide/expand/runtime/renderer#apphelper
|
||||||
*/
|
*/
|
||||||
@ -138,3 +169,10 @@ export interface EngineOptions {
|
|||||||
*/
|
*/
|
||||||
enableWorkspaceMode?: boolean;
|
enableWorkspaceMode?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use IPublicTypeEngineOptions instead
|
||||||
|
*/
|
||||||
|
export interface EngineOptions {
|
||||||
|
|
||||||
|
}
|
||||||
@ -73,4 +73,5 @@ export * from './tip-config';
|
|||||||
export * from './widget-config-area';
|
export * from './widget-config-area';
|
||||||
export * from './hotkey-callback';
|
export * from './hotkey-callback';
|
||||||
export * from './plugin-register-options';
|
export * from './plugin-register-options';
|
||||||
export * from './resource-options';
|
export * from './resource-options';
|
||||||
|
export * from './engine-options';
|
||||||
Loading…
x
Reference in New Issue
Block a user