refactor(types): rename EngineOptions, and adjust related docs

This commit is contained in:
JackLian 2023-01-04 14:16:02 +08:00 committed by 刘菊萍(絮黎)
parent 622b3fd958
commit 4ef61183ef
7 changed files with 56 additions and 22 deletions

View File

@ -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)
## 使用示例 ## 使用示例

View File

@ -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;
} }

View File

@ -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();

View File

@ -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[];

View File

@ -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';

View File

@ -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;
/** /**
* selectorsundefined * selectorsundefined
*/ */
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 tabsfalse * item tabsfalse
*/ */
hideSettingsTabsWhenOnlyOneItem?: boolean; hideSettingsTabsWhenOnlyOneItem?: boolean;
/** /**
* loading * loading
*/ */
loadingComponent?: ComponentType; loadingComponent?: ComponentType;
/** /**
* false * false
*/ */
supportVariableGlobally?: boolean; supportVariableGlobally?: boolean;
/** /**
* simulator urlundefined * simulator urlundefined
*/ */
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 {
}

View File

@ -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';