mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-12 11:20:11 +00:00
refactor: wrap cabins in order to mark deprecated apis
This commit is contained in:
parent
8e13f0cee1
commit
1f3c697a27
@ -9,31 +9,31 @@ import {
|
|||||||
isNodeSchema as innerIsNodeSchema,
|
isNodeSchema as innerIsNodeSchema,
|
||||||
NodeSchema,
|
NodeSchema,
|
||||||
TransitionType,
|
TransitionType,
|
||||||
|
TransformStage as InnerTransitionStage,
|
||||||
} from '@alilc/lowcode-types';
|
} from '@alilc/lowcode-types';
|
||||||
import {
|
import {
|
||||||
SettingField,
|
SettingField as InnerSettingField,
|
||||||
isSettingField,
|
isSettingField as innerIsSettingField,
|
||||||
Designer,
|
Designer,
|
||||||
TransformStage,
|
LiveEditing as InnerLiveEditing,
|
||||||
LiveEditing,
|
isDragNodeDataObject as innerIsDragNodeDataObject,
|
||||||
isDragNodeDataObject,
|
isDragNodeObject as innerIsDragNodeObject,
|
||||||
isDragNodeObject,
|
isDragAnyObject as innerIsDragAnyObject,
|
||||||
isDragAnyObject,
|
DragObjectType as InnerDragObjectType,
|
||||||
DragObjectType,
|
isNode as innerIsNode,
|
||||||
isNode,
|
isShaken as innerIsShaken,
|
||||||
isShaken,
|
contains as innerContains,
|
||||||
contains,
|
LocationDetailType as InnerLocationDetailType,
|
||||||
LocationDetailType,
|
isLocationChildrenDetail as innerIsLocationChildrenDetail,
|
||||||
isLocationChildrenDetail,
|
ScrollTarget as InnerScrollTarget,
|
||||||
ScrollTarget,
|
|
||||||
getConvertedExtraKey as innerGetConvertedExtraKey,
|
getConvertedExtraKey as innerGetConvertedExtraKey,
|
||||||
getOriginalExtraKey as innerGetOriginalExtraKey,
|
getOriginalExtraKey as innerGetOriginalExtraKey,
|
||||||
} from '@alilc/lowcode-designer';
|
} from '@alilc/lowcode-designer';
|
||||||
import {
|
import {
|
||||||
Skeleton as InnerSkeleton,
|
Skeleton as InnerSkeleton,
|
||||||
createSettingFieldView,
|
createSettingFieldView as innerCreateSettingFieldView,
|
||||||
PopupContext,
|
PopupContext as InnerPopupContext,
|
||||||
PopupPipe,
|
PopupPipe as InnerPopupPipe,
|
||||||
Workbench as InnerWorkbench,
|
Workbench as InnerWorkbench,
|
||||||
} from '@alilc/lowcode-editor-skeleton';
|
} from '@alilc/lowcode-editor-skeleton';
|
||||||
import Dragon from './dragon';
|
import Dragon from './dragon';
|
||||||
@ -41,60 +41,145 @@ import {
|
|||||||
Editor,
|
Editor,
|
||||||
Title as InnerTitle,
|
Title as InnerTitle,
|
||||||
Tip as InnerTip,
|
Tip as InnerTip,
|
||||||
shallowIntl,
|
shallowIntl as innerShallowIntl,
|
||||||
createIntl as innerCreateIntl,
|
createIntl as innerCreateIntl,
|
||||||
intl,
|
intl as innerIntl,
|
||||||
createSetterContent,
|
createSetterContent as innerCreateSetterContent,
|
||||||
obx,
|
globalLocale as innerGlobalLocale,
|
||||||
observable,
|
obx as innerObx,
|
||||||
makeObservable,
|
observable as innerObservable,
|
||||||
untracked,
|
makeObservable as innerMakeObservable,
|
||||||
computed,
|
untracked as innerUntracked,
|
||||||
observer,
|
computed as innerComputed,
|
||||||
globalLocale,
|
observer as innerObserver,
|
||||||
} from '@alilc/lowcode-editor-core';
|
} from '@alilc/lowcode-editor-core';
|
||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
|
|
||||||
|
|
||||||
const getDesignerCabin = (editor: Editor) => {
|
class DesignerCabin {
|
||||||
const designer = editor.get('designer') as Designer;
|
private readonly [editorSymbol]: Editor;
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
readonly [designerCabinSymbol]: any;
|
||||||
|
|
||||||
return {
|
constructor(editor: Editor) {
|
||||||
SettingField,
|
this[editorSymbol] = editor;
|
||||||
isSettingField,
|
this[designerCabinSymbol] = {
|
||||||
dragon: Dragon.create(designer.dragon),
|
isDragNodeObject: innerIsDragNodeObject,
|
||||||
TransformStage,
|
isDragAnyObject: innerIsDragAnyObject,
|
||||||
LiveEditing,
|
isShaken: innerIsShaken,
|
||||||
DragObjectType,
|
contains: innerContains,
|
||||||
isDragNodeDataObject,
|
LocationDetailType: InnerLocationDetailType,
|
||||||
isNode,
|
isLocationChildrenDetail: innerIsLocationChildrenDetail,
|
||||||
[designerCabinSymbol]: {
|
ScrollTarget: InnerScrollTarget,
|
||||||
isDragNodeObject,
|
isSettingField: innerIsSettingField,
|
||||||
isDragAnyObject,
|
TransformStage: InnerTransitionStage,
|
||||||
isShaken,
|
SettingField: InnerSettingField,
|
||||||
contains,
|
LiveEditing: InnerLiveEditing,
|
||||||
LocationDetailType,
|
DragObjectType: InnerDragObjectType,
|
||||||
isLocationChildrenDetail,
|
isDragNodeDataObject: innerIsDragNodeDataObject,
|
||||||
ScrollTarget,
|
isNode: innerIsNode,
|
||||||
isSettingField,
|
|
||||||
TransformStage,
|
|
||||||
SettingField,
|
|
||||||
LiveEditing,
|
|
||||||
DragObjectType,
|
|
||||||
isDragNodeDataObject,
|
|
||||||
isNode,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const getSkeletonCabin = (skeleton: InnerSkeleton) => {
|
/**
|
||||||
return {
|
* 是否是 SettingField 实例
|
||||||
createSettingFieldView,
|
*
|
||||||
PopupContext,
|
* @param {*} obj
|
||||||
PopupPipe,
|
* @returns {obj is SettingField}
|
||||||
Workbench: (props: any) => <InnerWorkbench {...props} skeleton={skeleton} />, // hijack skeleton
|
* @memberof DesignerCabin
|
||||||
};
|
*/
|
||||||
};
|
isSettingField(obj: any): obj is InnerSettingField {
|
||||||
|
return innerIsSettingField(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转换类型枚举对象,包含 init / upgrade / render 等类型
|
||||||
|
* [参考](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/transform-stage.ts)
|
||||||
|
* @deprecated use { TransformStage } from '@alilc/lowcode-types' instead
|
||||||
|
*/
|
||||||
|
get TransformStage() {
|
||||||
|
return InnerTransitionStage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
get SettingField() {
|
||||||
|
return InnerSettingField;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
get dragon() {
|
||||||
|
const designer = this[editorSymbol].get('designer') as Designer;
|
||||||
|
return Dragon.create(designer.dragon);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
get LiveEditing() {
|
||||||
|
return InnerLiveEditing;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
get DragObjectType() {
|
||||||
|
return InnerDragObjectType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
isDragNodeDataObject(obj: any): boolean {
|
||||||
|
return innerIsDragNodeDataObject(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
isNode(node: any): boolean {
|
||||||
|
return innerIsNode(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SkeletonCabin {
|
||||||
|
private readonly [skeletonSymbol]: InnerSkeleton;
|
||||||
|
|
||||||
|
constructor(skeleton: InnerSkeleton) {
|
||||||
|
this[skeletonSymbol] = skeleton;
|
||||||
|
}
|
||||||
|
|
||||||
|
get Workbench(): any {
|
||||||
|
const innerSkeleton = this[skeletonSymbol];
|
||||||
|
return (props: any) => <InnerWorkbench {...props} skeleton={innerSkeleton} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
createSettingFieldView(item: any, field: any) {
|
||||||
|
return innerCreateSettingFieldView(item, field);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
get PopupContext(): any {
|
||||||
|
return InnerPopupContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
get PopupPipe(): any {
|
||||||
|
return InnerPopupPipe;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class Utils {
|
class Utils {
|
||||||
isNodeSchema(data: any): data is NodeSchema {
|
isNodeSchema(data: any): data is NodeSchema {
|
||||||
@ -135,19 +220,110 @@ class Utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class EditorCabin {
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
get Title() {
|
||||||
|
return InnerTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
get Tip() {
|
||||||
|
return InnerTip;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
shallowIntl(data: any): any {
|
||||||
|
return innerShallowIntl(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use common.utils.createIntl instead
|
||||||
|
*/
|
||||||
|
createIntl(instance: any): any {
|
||||||
|
return innerCreateIntl(instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
intl(data: any, params?: object): any {
|
||||||
|
return innerIntl(data, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
createSetterContent(setter: any, props: Record<string, any>): ReactNode {
|
||||||
|
return innerCreateSetterContent(setter, props);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
get globalLocale() {
|
||||||
|
return innerGlobalLocale;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
get obx() {
|
||||||
|
return innerObx;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
get observable() {
|
||||||
|
return innerObservable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
makeObservable(target: any, annotations: any, options: any) {
|
||||||
|
return innerMakeObservable(target, annotations, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
untracked(action: any) {
|
||||||
|
return innerUntracked(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
get computed() {
|
||||||
|
return innerComputed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
observer(component: any) {
|
||||||
|
return innerObserver(component);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export default class Common {
|
export default class Common {
|
||||||
private readonly [editorSymbol]: Editor;
|
|
||||||
private readonly [skeletonSymbol]: InnerSkeleton;
|
|
||||||
private readonly __designerCabin: any;
|
private readonly __designerCabin: any;
|
||||||
private readonly __skeletonCabin: any;
|
private readonly __skeletonCabin: any;
|
||||||
private readonly __editorCabin: any;
|
private readonly __editorCabin: any;
|
||||||
private readonly __utils: Utils;
|
private readonly __utils: Utils;
|
||||||
|
|
||||||
constructor(editor: Editor, skeleton: InnerSkeleton) {
|
constructor(editor: Editor, skeleton: InnerSkeleton) {
|
||||||
this[editorSymbol] = editor;
|
this.__designerCabin = new DesignerCabin(editor);
|
||||||
this[skeletonSymbol] = skeleton;
|
this.__skeletonCabin = new SkeletonCabin(skeleton);
|
||||||
this.__designerCabin = getDesignerCabin(this[editorSymbol]);
|
this.__editorCabin = new EditorCabin();
|
||||||
this.__skeletonCabin = getSkeletonCabin(this[skeletonSymbol]);
|
|
||||||
this.__utils = new Utils();
|
this.__utils = new Utils();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,22 +331,13 @@ export default class Common {
|
|||||||
return this.__utils;
|
return this.__utils;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 历史原因导致此处设计不合理,慎用。
|
||||||
|
* this load of crap will be removed in some future versions, don`t use it.
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
get editorCabin(): any {
|
get editorCabin(): any {
|
||||||
return {
|
return this.__editorCabin;
|
||||||
Title: InnerTitle,
|
|
||||||
Tip: InnerTip,
|
|
||||||
shallowIntl,
|
|
||||||
createIntl: innerCreateIntl,
|
|
||||||
intl,
|
|
||||||
createSetterContent,
|
|
||||||
obx,
|
|
||||||
observable,
|
|
||||||
makeObservable,
|
|
||||||
untracked,
|
|
||||||
computed,
|
|
||||||
observer,
|
|
||||||
globalLocale,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get designerCabin(): any {
|
get designerCabin(): any {
|
||||||
@ -180,4 +347,15 @@ export default class Common {
|
|||||||
get skeletonCabin(): any {
|
get skeletonCabin(): any {
|
||||||
return this.__skeletonCabin;
|
return this.__skeletonCabin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 历史原因导致此处设计不合理,慎用。
|
||||||
|
* this load of crap will be removed in some future versions, don`t use it.
|
||||||
|
* @deprecated use { TransformStage } from '@alilc/lowcode-types' instead
|
||||||
|
*/
|
||||||
|
get objects(): any {
|
||||||
|
return {
|
||||||
|
TransformStage: InnerTransitionStage,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user