diff --git a/eslint.config.js b/eslint.config.js index e91d9ff0c..91fa270bc 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -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', diff --git a/packages/designer/src/component-actions.ts b/packages/designer/src/component-actions.ts index 3c0c290a4..859290d2b 100644 --- a/packages/designer/src/component-actions.ts +++ b/packages/designer/src/component-actions.ts @@ -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; }, diff --git a/packages/designer/src/plugin/plugin-manager.ts b/packages/designer/src/plugin/plugin-manager.ts index b6f6b690f..8104d7b17 100644 --- a/packages/designer/src/plugin/plugin-manager.ts +++ b/packages/designer/src/plugin/plugin-manager.ts @@ -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; diff --git a/packages/designer/src/plugin/plugin-types.ts b/packages/designer/src/plugin/plugin-types.ts index d094d2bff..7846ccd52 100644 --- a/packages/designer/src/plugin/plugin-types.ts +++ b/packages/designer/src/plugin/plugin-types.ts @@ -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); diff --git a/packages/editor-core/src/command.ts b/packages/editor-core/src/command.ts index 04bd5ba5a..2ed1e364f 100644 --- a/packages/editor-core/src/command.ts +++ b/packages/editor-core/src/command.ts @@ -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(); + 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 { - 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; -} - export interface IEditor extends IPublicModelEditor { config?: EditorConfig; @@ -65,7 +45,6 @@ export interface IEditor extends IPublicModelEditor { init(config?: EditorConfig, components?: PluginClassSet): Promise; } -// eslint-disable-next-line no-redeclare export class Editor extends EventEmitter implements IEditor { /** * Ioc Container diff --git a/packages/editor-core/src/utils/app-preset.ts b/packages/editor-core/src/utils/app-preset.ts deleted file mode 100644 index 8b22575ec..000000000 --- a/packages/editor-core/src/utils/app-preset.ts +++ /dev/null @@ -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; -}; diff --git a/packages/editor-core/src/utils/assets-transform.ts b/packages/editor-core/src/utils/assets-transform.ts index df51cd5f9..ffefa4947 100644 --- a/packages/editor-core/src/utils/assets-transform.ts +++ b/packages/editor-core/src/utils/assets-transform.ts @@ -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') { diff --git a/packages/editor-core/src/utils/logger.ts b/packages/editor-core/src/utils/logger.ts deleted file mode 100644 index 212dcddab..000000000 --- a/packages/editor-core/src/utils/logger.ts +++ /dev/null @@ -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); -} diff --git a/packages/editor-core/src/utils/obx.ts b/packages/editor-core/src/utils/obx.ts index 82bbe1833..c720ed3df 100644 --- a/packages/editor-core/src/utils/obx.ts +++ b/packages/editor-core/src/utils/obx.ts @@ -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 }; diff --git a/packages/editor-core/src/utils/preference.ts b/packages/editor-core/src/utils/preference.ts index 240e9b199..2d04eea29 100644 --- a/packages/editor-core/src/utils/preference.ts +++ b/packages/editor-core/src/utils/preference.ts @@ -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' }); diff --git a/packages/editor-skeleton/src/icons/exit.tsx b/packages/editor-skeleton/src/icons/exit.tsx index a0d2aa38b..8583ce3a2 100644 --- a/packages/editor-skeleton/src/icons/exit.tsx +++ b/packages/editor-skeleton/src/icons/exit.tsx @@ -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 ( diff --git a/packages/editor-skeleton/src/layouts/workbench.tsx b/packages/editor-skeleton/src/layouts/workbench.tsx index c3a932293..876cfa530 100644 --- a/packages/editor-skeleton/src/layouts/workbench.tsx +++ b/packages/editor-skeleton/src/layouts/workbench.tsx @@ -32,8 +32,8 @@ export class Workbench extends Component<{ render() { const { skeleton, - className, - topAreaItemClassName, + className = 'engine-main', + topAreaItemClassName = 'engine-actionitem', } = this.props; return (
diff --git a/packages/editor-skeleton/src/transducers/addon-combine.ts b/packages/editor-skeleton/src/transducers/addon-combine.ts index 8a25a3324..4441833e5 100644 --- a/packages/editor-skeleton/src/transducers/addon-combine.ts +++ b/packages/editor-skeleton/src/transducers/addon-combine.ts @@ -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' || diff --git a/packages/editor-skeleton/src/transducers/parse-props.ts b/packages/editor-skeleton/src/transducers/parse-props.ts index 60ec4d442..5b0bb5bb2 100644 --- a/packages/editor-skeleton/src/transducers/parse-props.ts +++ b/packages/editor-skeleton/src/transducers/parse-props.ts @@ -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, diff --git a/packages/engine/src/engine-core.ts b/packages/engine/src/engine-core.ts index 159d49730..ad5e0548b 100644 --- a/packages/engine/src/engine-core.ts +++ b/packages/engine/src/engine-core.ts @@ -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,75 +237,45 @@ 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; + engineConfig.setEngineOptions(options); - 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 (engineConfig.get('enableWorkspaceMode')) { + innerWorkspace.enableAutoOpenFirstWindow = engineConfig.get('enableAutoOpenFirstWindow', true); + innerWorkspace.setActive(true); + innerWorkspace.initWindow(); + innerHotkey.activate(false); + await innerWorkspace.plugins.init(pluginPreference); if (!root) { - root = createRoot(engineContainer); + root = createRoot(container); root.render( createElement(WorkSpaceWorkbench, { workspace: innerWorkspace, - // skeleton: workspace.skeleton, - className: 'engine-main', - topAreaItemClassName: 'engine-actionitem', }) ); } + } else { + await registryInnerPlugin(designer, editor, plugins); + await plugins.init(pluginPreference); - 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.render( - createElement(Workbench, { - skeleton: innerSkeleton, - className: 'engine-main', - topAreaItemClassName: 'engine-actionitem', - }) - ); + if (!root) { + root = createRoot(container); + root.render( + createElement(Workbench, { + skeleton: innerSkeleton, + }) + ); + } } } @@ -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(); } diff --git a/packages/engine/src/shell/api/common.tsx b/packages/engine/src/shell/api/common.tsx index 46e546a4b..020639381 100644 --- a/packages/engine/src/shell/api/common.tsx +++ b/packages/engine/src/shell/api/common.tsx @@ -1,221 +1,42 @@ -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; - } - - 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, - }; - } - - /** - * 是否是 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); - } +export interface IPublicApiCommon { + get utils(): IPublicApiCommonUtils; } -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) => ; - } - - /** - * @deprecated - */ - createSettingFieldView(field: IPublicModelSettingField, fieldEntry: any) { - return innerCreateSettingFieldView((field as any)[settingFieldSymbol] || field, fieldEntry); - } +export class Common implements IPublicApiCommon { + private readonly __utils: Utils; - /** - * @deprecated - */ - get PopupContext(): any { - return InnerPopupContext; + constructor() { + this.__utils = new Utils(); } - /** - * @deprecated - */ - get PopupPipe(): any { - return InnerPopupPipe; + get utils(): Utils { + return this.__utils; } } + class Utils implements IPublicApiCommonUtils { isNodeSchema(data: any): data is IPublicTypeNodeSchema { return innerIsNodeSchema(data); @@ -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): 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, - }; - } -} diff --git a/packages/engine/src/workspace/layouts/workbench.tsx b/packages/engine/src/workspace/layouts/workbench.tsx index 4349a86d1..79bc06093 100644 --- a/packages/engine/src/workspace/layouts/workbench.tsx +++ b/packages/engine/src/workspace/layouts/workbench.tsx @@ -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; diff --git a/packages/engine/src/workspace/workspace.ts b/packages/engine/src/workspace/workspace.ts index 6743ec3a7..6ad629648 100644 --- a/packages/engine/src/workspace/workspace.ts +++ b/packages/engine/src/workspace/workspace.ts @@ -71,7 +71,11 @@ export class Workspace implements Omit Promise, + readonly registryInnerPlugin: ( + designer: IDesigner, + editor: IEditor, + plugins: IPublicApiPlugins + ) => Promise, readonly shellModelFactory: any, ) { this.context = new BasicContext(this, '', IPublicEnumPluginRegisterLevel.Workspace); diff --git a/packages/plugin-outline-pane/src/views/tree-branches.tsx b/packages/plugin-outline-pane/src/views/tree-branches.tsx index c0d3597e7..d1f648e4e 100644 --- a/packages/plugin-outline-pane/src/views/tree-branches.tsx +++ b/packages/plugin-outline-pane/src/views/tree-branches.tsx @@ -126,7 +126,6 @@ class TreeNodeChildren extends PureComponent<{ children.push(
- {/* @ts-ignore */} <div className="tree-node-slots-title"> - {/* @ts-ignore */} <Title title={{ type: 'i18n', intl: this.props.treeNode.pluginContext.intlNode('Slots') }} /> </div> {treeNode.slots.map(tnode => ( diff --git a/packages/types/src/shell/api/common.ts b/packages/types/src/shell/api/common.ts index bc2d5a281..7d992d36e 100644 --- a/packages/types/src/shell/api/common.ts +++ b/packages/types/src/shell/api/common.ts @@ -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; -} diff --git a/packages/types/src/shell/api/setters.ts b/packages/types/src/shell/api/setters.ts index 011a9dcac..749c41ee4 100644 --- a/packages/types/src/shell/api/setters.ts +++ b/packages/types/src/shell/api/setters.ts @@ -3,7 +3,6 @@ import { ReactNode } from 'react'; import { IPublicTypeRegisteredSetter, IPublicTypeCustomView } from '../type'; export interface IPublicApiSetters { - /** * 获取指定 setter * get setter by type diff --git a/packages/types/src/shell/type/plugin-creater.ts b/packages/types/src/shell/type/plugin-creater.ts index 713578752..3ffc49811 100644 --- a/packages/types/src/shell/type/plugin-creater.ts +++ b/packages/types/src/shell/type/plugin-creater.ts @@ -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; diff --git a/packages/types/src/shell/type/plugin.ts b/packages/types/src/shell/type/plugin.ts index 6f75de65d..6f1f6c223 100644 --- a/packages/types/src/shell/type/plugin.ts +++ b/packages/types/src/shell/type/plugin.ts @@ -1,4 +1,3 @@ -/* eslint-disable max-len */ import { IPublicTypePluginMeta, IPublicTypePluginCreater } from './'; export interface IPublicTypePlugin extends IPublicTypePluginCreater { diff --git a/packages/utils/src/svg-icon.tsx b/packages/utils/src/svg-icon.tsx index 2513f7bca..c27e24b18 100644 --- a/packages/utils/src/svg-icon.tsx +++ b/packages/utils/src/svg-icon.tsx @@ -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]; } diff --git a/scripts/sync-oss.js b/scripts/sync-oss.js index 2c5cef73e..471777119 100644 --- a/scripts/sync-oss.js +++ b/scripts/sync-oss.js @@ -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;