Skip to content

Commit

Permalink
fix: remove common deprecated apis
Browse files Browse the repository at this point in the history
  • Loading branch information
1ncounter committed Apr 12, 2024
1 parent 8beefd3 commit 1ec54e0
Show file tree
Hide file tree
Showing 28 changed files with 85 additions and 637 deletions.
7 changes: 5 additions & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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',
Expand Down
7 changes: 4 additions & 3 deletions packages/designer/src/component-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
}
Expand All @@ -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;
},
Expand Down
3 changes: 2 additions & 1 deletion packages/designer/src/plugin/plugin-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions packages/designer/src/plugin/plugin-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion packages/editor-core/src/command.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 1 addition & 2 deletions packages/editor-core/src/config.ts
Original file line number Diff line number Diff line change
@@ -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' });
Expand Down
5 changes: 2 additions & 3 deletions packages/editor-core/src/di/setter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 & {
Expand Down
21 changes: 0 additions & 21 deletions packages/editor-core/src/editor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { StrictEventEmitter } from 'strict-event-emitter-types';
import { EventEmitter } from 'events';
import { EventBus, IEventBus } from './event-bus';
import {
Expand All @@ -10,7 +9,6 @@ import {
HookConfig,
IPublicTypeComponentDescription,
IPublicTypeRemoteComponentDescription,
GlobalEvent,
} from '@alilc/lowcode-types';
import { engineConfig } from './config';
import { globalLocale } from './intl';
Expand All @@ -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;

Expand All @@ -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
Expand Down
45 changes: 0 additions & 45 deletions packages/editor-core/src/utils/app-preset.ts

This file was deleted.

5 changes: 3 additions & 2 deletions packages/editor-core/src/utils/assets-transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
7 changes: 0 additions & 7 deletions packages/editor-core/src/utils/logger.ts

This file was deleted.

4 changes: 1 addition & 3 deletions packages/editor-core/src/utils/obx.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -21,4 +19,4 @@ export {
} from 'mobx';
export type { IReactionDisposer, IReactionPublic, IReactionOptions } from 'mobx';

export { observer, mobx };
export { observer };
2 changes: 1 addition & 1 deletion packages/editor-core/src/utils/preference.ts
Original file line number Diff line number Diff line change
@@ -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' });
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-skeleton/src/icons/exit.tsx
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down
4 changes: 2 additions & 2 deletions packages/editor-skeleton/src/layouts/workbench.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)}>
Expand Down
55 changes: 2 additions & 53 deletions packages/editor-skeleton/src/transducers/addon-combine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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' ||
Expand Down
4 changes: 2 additions & 2 deletions packages/editor-skeleton/src/transducers/parse-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 1ec54e0

Please sign in to comment.