mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-12 03:01:16 +00:00
fix: remove common deprecated apis
This commit is contained in:
parent
8beefd3a1c
commit
1ec54e0a5f
@ -29,7 +29,10 @@ export default tseslint.config({
|
||||
rules: {
|
||||
'@stylistic/indent': ['error', 2],
|
||||
'@stylistic/indent-binary-ops': ['error', 2],
|
||||
'@stylistic/max-len': ['error', { code: 100, tabWidth: 2, ignoreStrings: true, ignoreComments: true }],
|
||||
'@stylistic/max-len': [
|
||||
'error',
|
||||
{ code: 100, tabWidth: 2, ignoreStrings: true, ignoreComments: true, ignoreTemplateLiterals: true }
|
||||
],
|
||||
'@stylistic/no-tabs': 'error',
|
||||
'@stylistic/quotes': ['error', 'single'],
|
||||
'@stylistic/quote-props': ['error', 'as-needed'],
|
||||
@ -40,7 +43,7 @@ export default tseslint.config({
|
||||
'@stylistic/jsx-quotes': ['error', 'prefer-double'],
|
||||
|
||||
'@typescript-eslint/ban-ts-comment': ["error", { 'ts-expect-error': 'allow-with-description' }],
|
||||
'@typescript-eslint/no-explicit-any': 'warn',
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
|
||||
'react/jsx-no-undef': 'error',
|
||||
'react/jsx-uses-vars': 'error',
|
||||
|
||||
@ -75,7 +75,10 @@ export class ComponentActions {
|
||||
});
|
||||
rglNode?.setPropValue('layout', layout);
|
||||
// 如果是磁贴块复制,则需要滚动到影响位置
|
||||
setTimeout(() => newNode?.document?.project?.simulatorHost?.scrollToNode(newNode), 10);
|
||||
setTimeout(
|
||||
() => newNode?.document?.project?.simulatorHost?.scrollToNode(newNode),
|
||||
10
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -88,12 +91,10 @@ export class ComponentActions {
|
||||
content: {
|
||||
icon: IconLock, // 锁定 icon
|
||||
title: intlNode('lock'),
|
||||
/* istanbul ignore next */
|
||||
action(node: IPublicModelNode) {
|
||||
node.lock();
|
||||
},
|
||||
},
|
||||
/* istanbul ignore next */
|
||||
condition: (node: IPublicModelNode) => {
|
||||
return engineConfig.get('enableCanvasLock', false) && node.isContainerNode && !node.isLocked;
|
||||
},
|
||||
|
||||
@ -92,7 +92,8 @@ export class LowCodePluginManager implements ILowCodePluginManager {
|
||||
registerOptions = options;
|
||||
options = {};
|
||||
}
|
||||
let { pluginName, meta = {} } = pluginModel;
|
||||
let { pluginName } = pluginModel;
|
||||
const { meta = {} } = pluginModel;
|
||||
const { preferenceDeclaration, engines } = meta;
|
||||
// filter invalid eventPrefix
|
||||
const { eventPrefix } = meta;
|
||||
|
||||
@ -43,8 +43,8 @@ interface ILowCodePluginRuntimeExportsAccessor {
|
||||
[propName: string]: any;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line max-len
|
||||
export type ILowCodePluginRuntime = ILowCodePluginRuntimeCore & ILowCodePluginRuntimeExportsAccessor;
|
||||
export type ILowCodePluginRuntime =
|
||||
ILowCodePluginRuntimeCore & ILowCodePluginRuntimeExportsAccessor;
|
||||
|
||||
export interface ILowCodePluginContextPrivate {
|
||||
set hotkey(hotkey: IPublicApiHotkey);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { IPublicApiCommand, IPublicEnumTransitionType, IPublicModelPluginContext, IPublicTypeCommand, IPublicTypeCommandHandlerArgs, IPublicTypeListCommand } from '@alilc/lowcode-types';
|
||||
import { checkPropTypes } from '@alilc/lowcode-utils';
|
||||
|
||||
export interface ICommand extends Command {}
|
||||
|
||||
export interface ICommandOptions {
|
||||
@ -52,7 +53,10 @@ export class Command implements Omit<IPublicApiCommand, 'registerCommand' | 'bat
|
||||
}
|
||||
}
|
||||
|
||||
batchExecuteCommand(commands: { name: string; args: IPublicTypeCommandHandlerArgs }[], pluginContext: IPublicModelPluginContext): void {
|
||||
batchExecuteCommand(
|
||||
commands: { name: string; args: IPublicTypeCommandHandlerArgs }[],
|
||||
pluginContext: IPublicModelPluginContext
|
||||
): void {
|
||||
if (!commands || !commands.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
import { get as lodashGet } from 'lodash-es';
|
||||
import { isPlainObject } from '@alilc/lowcode-utils';
|
||||
import { isPlainObject, getLogger } from '@alilc/lowcode-utils';
|
||||
import {
|
||||
IPublicTypeEngineOptions,
|
||||
IPublicModelEngineConfig,
|
||||
IPublicModelPreference,
|
||||
} from '@alilc/lowcode-types';
|
||||
import { getLogger } from './utils/logger';
|
||||
import Preference from './utils/preference';
|
||||
|
||||
const logger = getLogger({ level: 'log', bizName: 'config' });
|
||||
|
||||
@ -5,6 +5,7 @@ import { createContent, isCustomView } from '@alilc/lowcode-utils';
|
||||
const settersMap = new Map<string, IPublicTypeRegisteredSetter & {
|
||||
type: string;
|
||||
}>();
|
||||
|
||||
export function registerSetter(
|
||||
typeOrMaps: string | { [key: string]: IPublicTypeCustomView | IPublicTypeRegisteredSetter },
|
||||
setter?: IPublicTypeCustomView | IPublicTypeRegisteredSetter,
|
||||
@ -43,9 +44,7 @@ function getInitialFromSetter(setter: any) {
|
||||
) || null; // eslint-disable-line
|
||||
}
|
||||
|
||||
export interface ISetters extends IPublicApiSetters {
|
||||
|
||||
}
|
||||
export interface ISetters extends IPublicApiSetters {}
|
||||
|
||||
export class Setters implements ISetters {
|
||||
settersMap = new Map<string, IPublicTypeRegisteredSetter & {
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { StrictEventEmitter } from 'strict-event-emitter-types';
|
||||
import { EventEmitter } from 'events';
|
||||
import { EventBus, IEventBus } from './event-bus';
|
||||
import {
|
||||
@ -10,7 +9,6 @@ import {
|
||||
HookConfig,
|
||||
IPublicTypeComponentDescription,
|
||||
IPublicTypeRemoteComponentDescription,
|
||||
GlobalEvent,
|
||||
} from '@alilc/lowcode-types';
|
||||
import { engineConfig } from './config';
|
||||
import { globalLocale } from './intl';
|
||||
@ -37,24 +35,6 @@ const AssetsCache: {
|
||||
[key: string]: IPublicTypeRemoteComponentDescription;
|
||||
} = {};
|
||||
|
||||
// @ts-ignore
|
||||
export declare interface Editor extends StrictEventEmitter<EventEmitter, GlobalEvent.EventConfig> {
|
||||
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
off(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
removeAllListeners(event?: string | symbol): this;
|
||||
setMaxListeners(n: number): this;
|
||||
getMaxListeners(): number;
|
||||
listeners(event: string | symbol): Function[];
|
||||
rawListeners(event: string | symbol): Function[];
|
||||
listenerCount(type: string | symbol): number;
|
||||
// Added in Node 6...
|
||||
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
||||
eventNames(): Array<string | symbol>;
|
||||
}
|
||||
|
||||
export interface IEditor extends IPublicModelEditor {
|
||||
config?: EditorConfig;
|
||||
|
||||
@ -65,7 +45,6 @@ export interface IEditor extends IPublicModelEditor {
|
||||
init(config?: EditorConfig, components?: PluginClassSet): Promise<any>;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-redeclare
|
||||
export class Editor extends EventEmitter implements IEditor {
|
||||
/**
|
||||
* Ioc Container
|
||||
|
||||
@ -1,45 +0,0 @@
|
||||
import store from 'store';
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
__isDebug?: boolean;
|
||||
__newFunc?: (funcStr: string) => (...args: any[]) => any;
|
||||
}
|
||||
}
|
||||
|
||||
// 根据 url 参数设置 debug 选项
|
||||
const debugRegRes = /_?debug=(.*?)(&|$)/.exec(location.search);
|
||||
if (debugRegRes && debugRegRes[1]) {
|
||||
// eslint-disable-next-line no-underscore-dangle
|
||||
window.__isDebug = true;
|
||||
// @ts-ignore
|
||||
store.storage.write('debug', debugRegRes[1] === 'true' ? '*' : debugRegRes[1]);
|
||||
} else {
|
||||
// eslint-disable-next-line no-underscore-dangle
|
||||
window.__isDebug = false;
|
||||
store.remove('debug');
|
||||
}
|
||||
|
||||
// 重要,用于矫正画布执行 new Function 的 window 对象上下文
|
||||
// eslint-disable-next-line no-underscore-dangle
|
||||
window.__newFunc = (funContext: string): ((...args: any[]) => any) => {
|
||||
// eslint-disable-next-line no-new-func
|
||||
return new Function(funContext) as (...args: any[]) => any;
|
||||
};
|
||||
|
||||
// 关闭浏览器前提醒,只有产生过交互才会生效
|
||||
window.onbeforeunload = function (e: Event): string {
|
||||
const ev = e || window.event;
|
||||
// 本地调试不生效
|
||||
if (location.href.indexOf('localhost') > 0) {
|
||||
return '';
|
||||
}
|
||||
const msg = '您确定要离开此页面吗?';
|
||||
ev.cancelBubble = true;
|
||||
ev.returnValue = true;
|
||||
if (e.stopPropagation) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}
|
||||
return msg;
|
||||
};
|
||||
@ -14,11 +14,12 @@ export function assetsTransform(assets: IPublicTypeAssetsJson) {
|
||||
acc[key] = cur;
|
||||
return acc;
|
||||
},
|
||||
{} as any,
|
||||
{},
|
||||
);
|
||||
components.forEach(
|
||||
(componentDesc: IPublicTypeComponentDescription | IPublicTypeRemoteComponentDescription) => {
|
||||
let { devMode, schema, reference } = componentDesc;
|
||||
let { devMode } = componentDesc;
|
||||
const { schema, reference } = componentDesc;
|
||||
if ((devMode as string) === 'lowcode') {
|
||||
devMode = 'lowCode';
|
||||
} else if (devMode === 'proCode') {
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
import { Logger, Level } from '@alilc/lowcode-utils';
|
||||
|
||||
export { Logger };
|
||||
|
||||
export function getLogger(config: { level: Level; bizName: string }): Logger {
|
||||
return new Logger(config);
|
||||
}
|
||||
@ -1,10 +1,8 @@
|
||||
import { observer } from 'mobx-react';
|
||||
import { configure } from 'mobx';
|
||||
import * as mobx from 'mobx';
|
||||
|
||||
configure({ enforceActions: 'never' });
|
||||
|
||||
// 常用的直接导出,其他的以 mobx 命名空间导出
|
||||
export {
|
||||
observable as obx,
|
||||
observable,
|
||||
@ -21,4 +19,4 @@ export {
|
||||
} from 'mobx';
|
||||
export type { IReactionDisposer, IReactionPublic, IReactionOptions } from 'mobx';
|
||||
|
||||
export { observer, mobx };
|
||||
export { observer };
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import store from 'store';
|
||||
import { getLogger } from './logger';
|
||||
import { getLogger } from '@alilc/lowcode-utils';
|
||||
import { IPublicModelPreference } from '@alilc/lowcode-types';
|
||||
|
||||
const logger = getLogger({ level: 'warn', bizName: 'Preference' });
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
|
||||
import { SVGIcon, IconProps } from '@alilc/lowcode-utils';
|
||||
import { SVGIcon, type IconProps } from '@alilc/lowcode-utils';
|
||||
|
||||
export function IconExit(props: IconProps) {
|
||||
return (
|
||||
|
||||
@ -32,8 +32,8 @@ export class Workbench extends Component<{
|
||||
render() {
|
||||
const {
|
||||
skeleton,
|
||||
className,
|
||||
topAreaItemClassName,
|
||||
className = 'engine-main',
|
||||
topAreaItemClassName = 'engine-actionitem',
|
||||
} = this.props;
|
||||
return (
|
||||
<div className={classNames('lc-workbench', className)}>
|
||||
|
||||
@ -56,28 +56,7 @@ export default function (
|
||||
const { props, supports = {} } = configure as any;
|
||||
const isRoot: boolean = componentName === 'Page' || componentName === 'Component';
|
||||
const eventsDefinition: any[] = [];
|
||||
const supportedLifecycles =
|
||||
supports.lifecycles ||
|
||||
(isRoot
|
||||
? /* [
|
||||
{
|
||||
description: '初始化时',
|
||||
name: 'constructor',
|
||||
},
|
||||
{
|
||||
description: '装载后',
|
||||
name: 'componentDidMount',
|
||||
},
|
||||
{
|
||||
description: '更新时',
|
||||
name: 'componentDidUpdate',
|
||||
},
|
||||
{
|
||||
description: '卸载时',
|
||||
name: 'componentWillUnmount',
|
||||
},
|
||||
] */ null
|
||||
: null);
|
||||
const supportedLifecycles = supports.lifecycles;
|
||||
if (supportedLifecycles) {
|
||||
eventsDefinition.push({
|
||||
type: 'lifeCycleEvent',
|
||||
@ -117,43 +96,13 @@ export default function (
|
||||
},
|
||||
];
|
||||
}
|
||||
// propsGroup.push({
|
||||
// name: '#generals',
|
||||
// title: { type: 'i18n', 'zh-CN': '通用', 'en-US': 'General' },
|
||||
// items: [
|
||||
// {
|
||||
// name: 'id',
|
||||
// title: 'ID',
|
||||
// setter: 'StringSetter',
|
||||
// },
|
||||
// {
|
||||
// name: 'key',
|
||||
// title: 'Key',
|
||||
// // todo: use Mixin
|
||||
// setter: 'StringSetter',
|
||||
// },
|
||||
// {
|
||||
// name: 'ref',
|
||||
// title: 'Ref',
|
||||
// setter: 'StringSetter',
|
||||
// },
|
||||
// {
|
||||
// name: '!more',
|
||||
// title: '更多',
|
||||
// setter: 'PropertiesSetter',
|
||||
// },
|
||||
// ],
|
||||
// });
|
||||
|
||||
const stylesGroup: IPublicTypeFieldConfig[] = [];
|
||||
const advancedGroup: IPublicTypeFieldConfig[] = [];
|
||||
if (propsGroup) {
|
||||
let l = propsGroup.length;
|
||||
while (l-- > 0) {
|
||||
const item = propsGroup[l];
|
||||
// if (item.type === 'group' && (item.title === '高级' || item.title?.label === '高级')) {
|
||||
// advancedGroup = item.items || [];
|
||||
// propsGroup.splice(l, 1);
|
||||
// }
|
||||
if (
|
||||
item.name === '__style__' ||
|
||||
item.name === 'style' ||
|
||||
|
||||
@ -70,9 +70,9 @@ function propTypeToSetter(propType: IPublicTypePropType): IPublicTypeSetterType
|
||||
value,
|
||||
};
|
||||
});
|
||||
const componentName = dataSource.length >= 4 ? 'SelectSetter' : 'RadioGroupSetter';
|
||||
|
||||
return {
|
||||
componentName,
|
||||
componentName: dataSource.length >= 4 ? 'SelectSetter' : 'RadioGroupSetter',
|
||||
props: { dataSource, options: dataSource },
|
||||
isRequired,
|
||||
initialValue: dataSource[0] ? dataSource[0].value : null,
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { createElement } from 'react';
|
||||
import { createRoot, type Root } from 'react-dom/client';
|
||||
import { isPlainObject } from '@alilc/lowcode-utils';
|
||||
import {
|
||||
globalContext,
|
||||
Editor,
|
||||
@ -29,7 +28,7 @@ import {
|
||||
PluginPreference,
|
||||
IDesigner,
|
||||
} from '@alilc/lowcode-designer';
|
||||
import { Skeleton as InnerSkeleton, registerDefaults } from '@alilc/lowcode-editor-skeleton';
|
||||
import { Skeleton as InnerSkeleton, registerDefaults, Workbench } from '@alilc/lowcode-editor-skeleton';
|
||||
|
||||
import {
|
||||
Workspace as InnerWorkspace,
|
||||
@ -146,7 +145,7 @@ editor.set('innerHotkey', innerHotkey);
|
||||
const config = new Config(engineConfig);
|
||||
const event = new Event(commonEvent, { prefix: 'common' });
|
||||
const logger = new Logger({ level: 'warn', bizName: 'common' });
|
||||
const common = new Common(editor, innerSkeleton);
|
||||
const common = new Common();
|
||||
const canvas = new Canvas(editor);
|
||||
|
||||
const pluginContextApiAssembler: ILowCodePluginContextApiAssembler = {
|
||||
@ -160,9 +159,10 @@ const pluginContextApiAssembler: ILowCodePluginContextApiAssembler = {
|
||||
context.skeleton = new Skeleton(innerSkeleton, pluginName, false);
|
||||
context.setters = setters;
|
||||
context.material = material;
|
||||
|
||||
const eventPrefix = meta?.eventPrefix || 'common';
|
||||
const commandScope = meta?.commandScope;
|
||||
context.event = new Event(commonEvent, { prefix: eventPrefix });
|
||||
|
||||
context.config = config;
|
||||
context.common = common;
|
||||
context.canvas = canvas;
|
||||
@ -170,10 +170,13 @@ const pluginContextApiAssembler: ILowCodePluginContextApiAssembler = {
|
||||
context.logger = new Logger({ level: 'warn', bizName: `plugin:${pluginName}` });
|
||||
context.workspace = workspace;
|
||||
context.commonUI = commonUI;
|
||||
|
||||
const commandScope = meta?.commandScope;
|
||||
context.command = new Command(
|
||||
innerCommand, context as IPublicModelPluginContext, {
|
||||
commandScope,
|
||||
});
|
||||
|
||||
context.registerLevel = IPublicEnumPluginRegisterLevel.Default;
|
||||
context.isPluginRegisteredInWorkspace = false;
|
||||
editor.set('pluginContext', context);
|
||||
@ -216,7 +219,6 @@ export {
|
||||
command,
|
||||
};
|
||||
|
||||
|
||||
// declare this is open-source version
|
||||
/**
|
||||
* @deprecated
|
||||
@ -235,77 +237,47 @@ export const __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
|
||||
classes,
|
||||
};
|
||||
|
||||
const pluginPromise = registryInnerPlugin(designer, editor, plugins);
|
||||
|
||||
// react root
|
||||
let root: Root | undefined;
|
||||
|
||||
export async function init(
|
||||
container?: HTMLElement,
|
||||
options?: IPublicTypeEngineOptions,
|
||||
container: HTMLElement,
|
||||
options: IPublicTypeEngineOptions = {},
|
||||
pluginPreference?: PluginPreference
|
||||
) {
|
||||
await destroy();
|
||||
|
||||
// container which will host LowCodeEngine DOM
|
||||
let engineContainer: HTMLElement;
|
||||
let engineOptions = null;
|
||||
|
||||
if (isPlainObject(container)) {
|
||||
engineOptions = container;
|
||||
engineContainer = document.createElement('div');
|
||||
engineContainer.id = 'engine';
|
||||
document.body.appendChild(engineContainer);
|
||||
} else {
|
||||
engineOptions = options;
|
||||
engineContainer = container!;
|
||||
if (!container) {
|
||||
engineContainer = document.createElement('div');
|
||||
engineContainer.id = 'engine';
|
||||
document.body.appendChild(engineContainer);
|
||||
}
|
||||
}
|
||||
|
||||
engineConfig.setEngineOptions(engineOptions as any);
|
||||
|
||||
const { Workbench } = common.skeletonCabin;
|
||||
if (options && options.enableWorkspaceMode) {
|
||||
const disposeFun = await pluginPromise;
|
||||
disposeFun && disposeFun();
|
||||
|
||||
if (!root) {
|
||||
root = createRoot(engineContainer);
|
||||
root.render(
|
||||
createElement(WorkSpaceWorkbench, {
|
||||
workspace: innerWorkspace,
|
||||
// skeleton: workspace.skeleton,
|
||||
className: 'engine-main',
|
||||
topAreaItemClassName: 'engine-actionitem',
|
||||
})
|
||||
);
|
||||
}
|
||||
engineConfig.setEngineOptions(options);
|
||||
|
||||
if (engineConfig.get('enableWorkspaceMode')) {
|
||||
innerWorkspace.enableAutoOpenFirstWindow = engineConfig.get('enableAutoOpenFirstWindow', true);
|
||||
innerWorkspace.setActive(true);
|
||||
innerWorkspace.initWindow();
|
||||
innerHotkey.activate(false);
|
||||
await innerWorkspace.plugins.init(pluginPreference);
|
||||
return;
|
||||
}
|
||||
|
||||
await pluginPromise;
|
||||
await plugins.init(pluginPreference as any);
|
||||
|
||||
if (!root) {
|
||||
root = createRoot(engineContainer);
|
||||
root = createRoot(container);
|
||||
root.render(
|
||||
createElement(WorkSpaceWorkbench, {
|
||||
workspace: innerWorkspace,
|
||||
})
|
||||
);
|
||||
}
|
||||
} else {
|
||||
await registryInnerPlugin(designer, editor, plugins);
|
||||
await plugins.init(pluginPreference);
|
||||
|
||||
if (!root) {
|
||||
root = createRoot(container);
|
||||
root.render(
|
||||
createElement(Workbench, {
|
||||
skeleton: innerSkeleton,
|
||||
className: 'engine-main',
|
||||
topAreaItemClassName: 'engine-actionitem',
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function destroy() {
|
||||
// remove all documents
|
||||
@ -320,5 +292,5 @@ export async function destroy() {
|
||||
|
||||
// unmount DOM container, this will trigger React componentWillUnmount lifeCycle,
|
||||
// so necessary cleanups will be done.
|
||||
root && root.unmount();
|
||||
root?.unmount();
|
||||
}
|
||||
|
||||
@ -1,220 +1,41 @@
|
||||
import { editorSymbol, skeletonSymbol, designerCabinSymbol, designerSymbol, settingFieldSymbol, editorCabinSymbol, skeletonCabinSymbol } from '../symbols';
|
||||
import {
|
||||
isFormEvent as innerIsFormEvent,
|
||||
compatibleLegaoSchema as innerCompatibleLegaoSchema,
|
||||
getNodeSchemaById as innerGetNodeSchemaById,
|
||||
transactionManager,
|
||||
isNodeSchema as innerIsNodeSchema,
|
||||
isDragNodeDataObject as innerIsDragNodeDataObject,
|
||||
isDragNodeObject as innerIsDragNodeObject,
|
||||
isDragAnyObject as innerIsDragAnyObject,
|
||||
isLocationChildrenDetail as innerIsLocationChildrenDetail,
|
||||
isNode as innerIsNode,
|
||||
isSettingField,
|
||||
isSettingField as innerIsSettingField,
|
||||
} from '@alilc/lowcode-utils';
|
||||
import {
|
||||
IPublicTypeNodeSchema,
|
||||
IPublicEnumTransitionType,
|
||||
IPublicEnumTransformStage as InnerTransitionStage,
|
||||
IPublicApiCommonDesignerCabin,
|
||||
IPublicApiCommonSkeletonCabin,
|
||||
IPublicApiCommonUtils,
|
||||
IPublicApiCommon,
|
||||
IPublicEnumDragObjectType as InnerDragObjectType,
|
||||
IPublicTypeLocationDetailType as InnerLocationDetailType,
|
||||
IPublicApiCommonEditorCabin,
|
||||
IPublicModelDragon,
|
||||
IPublicModelSettingField,
|
||||
IPublicTypeI18nData,
|
||||
} from '@alilc/lowcode-types';
|
||||
import {
|
||||
SettingField as InnerSettingField,
|
||||
LiveEditing as InnerLiveEditing,
|
||||
isShaken as innerIsShaken,
|
||||
contains as innerContains,
|
||||
ScrollTarget as InnerScrollTarget,
|
||||
getConvertedExtraKey as innerGetConvertedExtraKey,
|
||||
getOriginalExtraKey as innerGetOriginalExtraKey,
|
||||
IDesigner,
|
||||
DropLocation as InnerDropLocation,
|
||||
Designer as InnerDesigner,
|
||||
Node as InnerNode,
|
||||
LowCodePluginManager as InnerLowCodePluginManager,
|
||||
DesignerView as InnerDesignerView,
|
||||
} from '@alilc/lowcode-designer';
|
||||
import {
|
||||
Skeleton as InnerSkeleton,
|
||||
createSettingFieldView as innerCreateSettingFieldView,
|
||||
PopupContext as InnerPopupContext,
|
||||
PopupPipe as InnerPopupPipe,
|
||||
Workbench as InnerWorkbench,
|
||||
SettingsPrimaryPane as InnerSettingsPrimaryPane,
|
||||
registerDefaults as InnerRegisterDefaults,
|
||||
} from '@alilc/lowcode-editor-skeleton';
|
||||
import {
|
||||
Editor,
|
||||
Title as InnerTitle,
|
||||
Tip as InnerTip,
|
||||
shallowIntl as innerShallowIntl,
|
||||
createIntl as innerCreateIntl,
|
||||
intl as innerIntl,
|
||||
globalLocale as innerGlobalLocale,
|
||||
obx as innerObx,
|
||||
observable as innerObservable,
|
||||
makeObservable as innerMakeObservable,
|
||||
untracked as innerUntracked,
|
||||
computed as innerComputed,
|
||||
observer as innerObserver,
|
||||
action as innerAction,
|
||||
runInAction as innerRunInAction,
|
||||
engineConfig as innerEngineConfig,
|
||||
globalContext,
|
||||
} from '@alilc/lowcode-editor-core';
|
||||
import { Dragon as ShellDragon } from '../model';
|
||||
import { ReactNode } from 'react';
|
||||
|
||||
class DesignerCabin implements IPublicApiCommonDesignerCabin {
|
||||
private readonly [editorSymbol]: Editor;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
readonly [designerCabinSymbol]: any;
|
||||
|
||||
private get [designerSymbol](): IDesigner {
|
||||
return this[editorSymbol].get('designer') as IDesigner;
|
||||
export interface IPublicApiCommon {
|
||||
get utils(): IPublicApiCommonUtils;
|
||||
}
|
||||
|
||||
constructor(editor: Editor) {
|
||||
this[editorSymbol] = editor;
|
||||
this[designerCabinSymbol] = {
|
||||
isDragNodeObject: innerIsDragNodeObject,
|
||||
isDragAnyObject: innerIsDragAnyObject,
|
||||
isShaken: innerIsShaken,
|
||||
contains: innerContains,
|
||||
LocationDetailType: InnerLocationDetailType,
|
||||
isLocationChildrenDetail: innerIsLocationChildrenDetail,
|
||||
ScrollTarget: InnerScrollTarget,
|
||||
isSettingField: innerIsSettingField,
|
||||
TransformStage: InnerTransitionStage,
|
||||
SettingField: InnerSettingField,
|
||||
LiveEditing: InnerLiveEditing,
|
||||
DragObjectType: InnerDragObjectType,
|
||||
isDragNodeDataObject: innerIsDragNodeDataObject,
|
||||
isNode: innerIsNode,
|
||||
DropLocation: InnerDropLocation,
|
||||
Designer: InnerDesigner,
|
||||
Node: InnerNode,
|
||||
LowCodePluginManager: InnerLowCodePluginManager,
|
||||
DesignerView: InnerDesignerView,
|
||||
};
|
||||
export class Common implements IPublicApiCommon {
|
||||
private readonly __utils: Utils;
|
||||
|
||||
constructor() {
|
||||
this.__utils = new Utils();
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是 SettingField 实例
|
||||
* @deprecated use same function from @alilc/lowcode-utils directly
|
||||
*/
|
||||
isSettingField(obj: any): boolean {
|
||||
return isSettingField(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 LiveEditing() {
|
||||
return InnerLiveEditing;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
get DragObjectType() {
|
||||
return InnerDragObjectType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
isDragNodeDataObject(obj: any): boolean {
|
||||
return innerIsDragNodeDataObject(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
isNode(node: any): boolean {
|
||||
return innerIsNode(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated please use canvas.dragon
|
||||
*/
|
||||
get dragon(): IPublicModelDragon | null {
|
||||
return ShellDragon.create(this[designerSymbol].dragon, false);
|
||||
get utils(): Utils {
|
||||
return this.__utils;
|
||||
}
|
||||
}
|
||||
|
||||
class SkeletonCabin implements IPublicApiCommonSkeletonCabin {
|
||||
private readonly [skeletonSymbol]: InnerSkeleton;
|
||||
|
||||
readonly [skeletonCabinSymbol]: any;
|
||||
|
||||
constructor(skeleton: InnerSkeleton) {
|
||||
this[skeletonSymbol] = skeleton;
|
||||
this[skeletonCabinSymbol] = {
|
||||
Workbench: InnerWorkbench,
|
||||
createSettingFieldView: this.createSettingFieldView,
|
||||
PopupContext: InnerPopupContext,
|
||||
PopupPipe: InnerPopupPipe,
|
||||
SettingsPrimaryPane: InnerSettingsPrimaryPane,
|
||||
registerDefaults: InnerRegisterDefaults,
|
||||
Skeleton: InnerSkeleton,
|
||||
};
|
||||
}
|
||||
|
||||
get Workbench(): any {
|
||||
const innerSkeleton = this[skeletonSymbol];
|
||||
return (props: any) => <InnerWorkbench {...props} skeleton={innerSkeleton} />;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
createSettingFieldView(field: IPublicModelSettingField, fieldEntry: any) {
|
||||
return innerCreateSettingFieldView((field as any)[settingFieldSymbol] || field, fieldEntry);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
get PopupContext(): any {
|
||||
return InnerPopupContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
get PopupPipe(): any {
|
||||
return InnerPopupPipe;
|
||||
}
|
||||
}
|
||||
|
||||
class Utils implements IPublicApiCommonUtils {
|
||||
isNodeSchema(data: any): data is IPublicTypeNodeSchema {
|
||||
@ -225,13 +46,6 @@ class Utils implements IPublicApiCommonUtils {
|
||||
return innerIsFormEvent(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated this is a legacy api, do not use this if not using is already
|
||||
*/
|
||||
compatibleLegaoSchema(props: any): any {
|
||||
return innerCompatibleLegaoSchema(props);
|
||||
}
|
||||
|
||||
getNodeSchemaById(
|
||||
schema: IPublicTypeNodeSchema,
|
||||
nodeId: string,
|
||||
@ -267,202 +81,3 @@ class Utils implements IPublicApiCommonUtils {
|
||||
return innerIntl(data, params);
|
||||
}
|
||||
}
|
||||
|
||||
class EditorCabin implements IPublicApiCommonEditorCabin {
|
||||
private readonly [editorSymbol]: Editor;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
readonly [editorCabinSymbol]: any;
|
||||
|
||||
constructor(editor: Editor) {
|
||||
this[editorSymbol] = editor;
|
||||
this[editorCabinSymbol] = {
|
||||
Editor,
|
||||
globalContext,
|
||||
runInAction: innerRunInAction,
|
||||
Title: InnerTitle,
|
||||
Tip: InnerTip,
|
||||
shallowIntl: innerShallowIntl,
|
||||
createIntl: innerCreateIntl,
|
||||
intl: innerIntl,
|
||||
createSetterContent: this.createSetterContent.bind(this),
|
||||
globalLocale: innerGlobalLocale,
|
||||
obx: innerObx,
|
||||
action: innerAction,
|
||||
engineConfig: innerEngineConfig,
|
||||
observable: innerObservable,
|
||||
makeObservable: innerMakeObservable,
|
||||
untracked: innerUntracked,
|
||||
computed: innerComputed,
|
||||
observer: innerObserver,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Title 组件
|
||||
* @experimental unstable API, pay extra caution when trying to use this
|
||||
*/
|
||||
get Title() {
|
||||
return InnerTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tip 组件
|
||||
* @experimental unstable API, pay extra caution when trying to use this
|
||||
*/
|
||||
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 => {
|
||||
const setters = this[editorSymbol].get('setters');
|
||||
return setters.createSetterContent(setter, props);
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated use common.utils.createIntl instead
|
||||
*/
|
||||
get globalLocale(): any {
|
||||
return innerGlobalLocale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
get obx() {
|
||||
return innerObx;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
get action() {
|
||||
return innerAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
get engineConfig() {
|
||||
return innerEngineConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
get runInAction() {
|
||||
return innerRunInAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 class Common implements IPublicApiCommon {
|
||||
private readonly __designerCabin: DesignerCabin;
|
||||
private readonly __skeletonCabin: SkeletonCabin;
|
||||
private readonly __editorCabin: EditorCabin;
|
||||
private readonly __utils: Utils;
|
||||
|
||||
constructor(editor: Editor, skeleton: InnerSkeleton) {
|
||||
this.__designerCabin = new DesignerCabin(editor);
|
||||
this.__skeletonCabin = new SkeletonCabin(skeleton);
|
||||
this.__editorCabin = new EditorCabin(editor);
|
||||
this.__utils = new Utils();
|
||||
}
|
||||
|
||||
get utils(): any {
|
||||
return this.__utils;
|
||||
}
|
||||
|
||||
/**
|
||||
* 历史原因导致此处设计不合理,慎用。
|
||||
* this load of crap will be removed in some future versions, don`t use it.
|
||||
* @deprecated
|
||||
*/
|
||||
get editorCabin(): EditorCabin {
|
||||
return this.__editorCabin;
|
||||
}
|
||||
|
||||
/**
|
||||
* 历史原因导致此处设计不合理,慎用。
|
||||
* this load of crap will be removed in some future versions, don`t use it.
|
||||
* @deprecated use canvas api instead
|
||||
*/
|
||||
get designerCabin(): DesignerCabin {
|
||||
return this.__designerCabin;
|
||||
}
|
||||
|
||||
get skeletonCabin(): 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() {
|
||||
return {
|
||||
TransformStage: InnerTransitionStage,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ export class Workbench extends Component<{
|
||||
}
|
||||
|
||||
render() {
|
||||
const { workspace, className, topAreaItemClassName } = this.props;
|
||||
const { workspace, className = 'engine-main', topAreaItemClassName = 'engine-actionitem' } = this.props;
|
||||
const { skeleton } = workspace;
|
||||
const { workspaceEmptyComponent: WorkspaceEmptyComponent, theme } = this.state;
|
||||
|
||||
|
||||
@ -71,7 +71,11 @@ export class Workspace implements Omit<IPublicApiWorkspace<
|
||||
} | IResource)[] = [];
|
||||
|
||||
constructor(
|
||||
readonly registryInnerPlugin: (designer: IDesigner, editor: IEditor, plugins: IPublicApiPlugins) => Promise<IPublicTypeDisposable>,
|
||||
readonly registryInnerPlugin: (
|
||||
designer: IDesigner,
|
||||
editor: IEditor,
|
||||
plugins: IPublicApiPlugins
|
||||
) => Promise<IPublicTypeDisposable>,
|
||||
readonly shellModelFactory: any,
|
||||
) {
|
||||
this.context = new BasicContext(this, '', IPublicEnumPluginRegisterLevel.Workspace);
|
||||
|
||||
@ -126,7 +126,6 @@ class TreeNodeChildren extends PureComponent<{
|
||||
children.push(
|
||||
<div key={currentGrp.id} className="condition-group-container" data-id={currentGrp.firstNode?.id}>
|
||||
<div className="condition-group-title">
|
||||
{/* @ts-ignore */}
|
||||
<Title
|
||||
title={currentGrp.title}
|
||||
match={filterWorking && matchSelf}
|
||||
@ -204,7 +203,6 @@ class TreeNodeSlots extends PureComponent<{
|
||||
data-id={treeNode.nodeId}
|
||||
>
|
||||
<div className="tree-node-slots-title">
|
||||
{/* @ts-ignore */}
|
||||
<Title title={{ type: 'i18n', intl: this.props.treeNode.pluginContext.intlNode('Slots') }} />
|
||||
</div>
|
||||
{treeNode.slots.map(tnode => (
|
||||
|
||||
@ -4,7 +4,6 @@ import { IPublicTypeI18nData, IPublicTypeNodeSchema, IPublicTypeTitleContent } f
|
||||
import { IPublicEnumTransitionType } from '../enum';
|
||||
|
||||
export interface IPublicApiCommonUtils {
|
||||
|
||||
/**
|
||||
* 是否为合法的 schema 结构
|
||||
* check if data is valid NodeSchema
|
||||
@ -90,7 +89,7 @@ export interface IPublicApiCommonEditorCabin {
|
||||
* Title 组件
|
||||
* @experimental unstable API, pay extra caution when trying to use this
|
||||
*/
|
||||
get Tip(): React.ComponentClass<{}>;
|
||||
get Tip(): React.ComponentClass;
|
||||
|
||||
/**
|
||||
* Tip 组件
|
||||
@ -102,23 +101,3 @@ export interface IPublicApiCommonEditorCabin {
|
||||
keywords?: string | null;
|
||||
}>;
|
||||
}
|
||||
|
||||
export interface IPublicApiCommonDesignerCabin {
|
||||
}
|
||||
|
||||
export interface IPublicApiCommon {
|
||||
|
||||
get utils(): IPublicApiCommonUtils;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
get designerCabin(): IPublicApiCommonDesignerCabin;
|
||||
|
||||
/**
|
||||
* @experimental unstable API, pay extra caution when trying to use this
|
||||
*/
|
||||
get editorCabin(): IPublicApiCommonEditorCabin;
|
||||
|
||||
get skeletonCabin(): IPublicApiCommonSkeletonCabin;
|
||||
}
|
||||
|
||||
@ -3,7 +3,6 @@ import { ReactNode } from 'react';
|
||||
import { IPublicTypeRegisteredSetter, IPublicTypeCustomView } from '../type';
|
||||
|
||||
export interface IPublicApiSetters {
|
||||
|
||||
/**
|
||||
* 获取指定 setter
|
||||
* get setter by type
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { IPublicTypePluginConfig } from './';
|
||||
import { IPublicModelPluginContext } from '../model';
|
||||
|
||||
// eslint-disable-next-line max-len
|
||||
export type IPublicTypePluginCreater = (ctx: IPublicModelPluginContext, options: any) => IPublicTypePluginConfig;
|
||||
export type IPublicTypePluginCreater = (
|
||||
ctx: IPublicModelPluginContext, options: any
|
||||
) => IPublicTypePluginConfig;
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
/* eslint-disable max-len */
|
||||
import { IPublicTypePluginMeta, IPublicTypePluginCreater } from './';
|
||||
|
||||
export interface IPublicTypePlugin extends IPublicTypePluginCreater {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import React, { ReactNode } from 'react';
|
||||
|
||||
const SizePresets: any = {
|
||||
const SizePresets = {
|
||||
xsmall: 8,
|
||||
small: 12,
|
||||
medium: 16,
|
||||
@ -26,8 +26,7 @@ export function SVGIcon({
|
||||
}: IconProps & {
|
||||
viewBox: string;
|
||||
}) {
|
||||
// eslint-disable-next-line no-prototype-builtins
|
||||
if (SizePresets.hasOwnProperty(size)) {
|
||||
if (typeof size === 'string' && size in SizePresets) {
|
||||
size = SizePresets[size];
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
import { request } from 'node:http';
|
||||
import packageJson from '../packages/engine/package.json';
|
||||
import console from 'node:console';
|
||||
import { Buffer } from 'node:buffer'
|
||||
import { Buffer } from 'node:buffer';
|
||||
|
||||
const { version, name } = packageJson;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user