Skip to content

Commit

Permalink
fix: remove @deprecated apis
Browse files Browse the repository at this point in the history
  • Loading branch information
1ncounter committed Apr 12, 2024
1 parent 1ec54e0 commit 0831277
Show file tree
Hide file tree
Showing 83 changed files with 181 additions and 1,234 deletions.
12 changes: 0 additions & 12 deletions docs/docs/api/workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,6 @@ setResourceList(resourceList: IPublicResourceList) {}
打开视图窗口

```typescript
/**
* 打开视图窗口
* @deprecated
*/
openEditorWindow(resourceName: string, id: string, extra: Object, viewName?: string, sleep?: boolean): Promise<void>;

/** 打开视图窗口 */
openEditorWindow(resource: Resource, sleep?: boolean): Promise<void>;
```
Expand All @@ -117,12 +111,6 @@ openEditorWindowById(id: string): void;
移除视图窗口

```typescript
/**
* 移除视图窗口
* @deprecated
*/
removeEditorWindow(resourceName: string, id: string): void;

/**
* 移除视图窗口
*/
Expand Down
6 changes: 0 additions & 6 deletions docs/docs/specs/material-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -1151,12 +1151,6 @@ export interface Snippet {
* snippet 截图
*/
screenshot?: string;
/**
* snippet 打标
*
* @deprecated 暂未使用
*/
label?: string;
/**
* 待插入的 schema
*/
Expand Down
1 change: 0 additions & 1 deletion modules/code-generator/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export default {
},
plugins: {
common: {

/**
* 处理 ES Module
* @deprecated please use esModule
Expand Down
15 changes: 9 additions & 6 deletions packages/designer/src/builtin-simulator/host.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
obx,
observable,
autorun,
reaction,
computed,
Expand All @@ -12,6 +12,7 @@ import {
makeObservable,
createModuleEventBus,
IEventBus,
action,
} from '@alilc/lowcode-editor-core';

import { ISimulatorHost, Component, DropContainer } from '../simulator';
Expand Down Expand Up @@ -228,17 +229,17 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
return this.get('deviceStyle');
}

@obx.ref _props: BuiltinSimulatorProps = {};
@observable.ref _props: BuiltinSimulatorProps = {};

@obx.ref private _contentWindow?: Window;
@observable.ref private _contentWindow?: Window;

get contentWindow() {
return this._contentWindow;
}

@obx.ref private _contentDocument?: Document;
@observable.ref private _contentDocument?: Document;

@obx.ref private _appHelper?: any;
@observable.ref private _appHelper?: any;

get contentDocument() {
return this._contentDocument;
Expand All @@ -262,7 +263,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp

readonly liveEditing = new LiveEditing();

@obx private instancesMap: {
@observable private instancesMap: {
[docId: string]: Map<string, IPublicTypeComponentInstance[]>;
} = {};

Expand Down Expand Up @@ -322,10 +323,12 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
/**
* @see ISimulator
*/
@action
setProps(props: BuiltinSimulatorProps) {
this._props = props;
}

@action
set(key: string, value: any) {
this._props = {
...this._props,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { obx } from '@alilc/lowcode-editor-core';
import { observable } from '@alilc/lowcode-editor-core';
import { IPublicTypePluginConfig, IPublicTypeLiveTextEditingConfig } from '@alilc/lowcode-types';
import { INode, Prop } from '../../document';

Expand Down Expand Up @@ -45,7 +45,7 @@ export class LiveEditing {
static addLiveEditingSaveHandler = addLiveEditingSaveHandler;
static clearLiveEditingSaveHandler = clearLiveEditingSaveHandler;

@obx.ref private _editing: Prop | null = null;
@observable.ref private _editing: Prop | null = null;

private _dispose?: () => void;

Expand Down
4 changes: 2 additions & 2 deletions packages/designer/src/builtin-simulator/resource-consumer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { autorun, makeObservable, obx, createModuleEventBus, IEventBus } from '@alilc/lowcode-editor-core';
import { autorun, makeObservable, observable, createModuleEventBus, IEventBus } from '@alilc/lowcode-editor-core';
import { BuiltinSimulatorHost } from './host';
import { BuiltinSimulatorRenderer, isSimulatorRenderer } from './renderer';

Expand All @@ -21,7 +21,7 @@ export type RendererConsumer<T> = (renderer: BuiltinSimulatorRenderer, data: T)
export default class ResourceConsumer<T = any> {
private emitter: IEventBus = createModuleEventBus('ResourceConsumer');

@obx.ref private _data: T | typeof UNSET = UNSET;
@observable.ref private _data: T | typeof UNSET = UNSET;

private _providing?: () => void;

Expand Down
17 changes: 9 additions & 8 deletions packages/designer/src/builtin-simulator/viewport.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { obx, computed, makeObservable } from '@alilc/lowcode-editor-core';
import { observable, computed, makeObservable, action } from '@alilc/lowcode-editor-core';
import { Point, ScrollTarget } from '../designer';
import { AutoFit, IViewport } from '../simulator';

export default class Viewport implements IViewport {
@obx.ref private rect?: DOMRect;
@observable.ref private rect?: DOMRect;

private _bounds?: DOMRect;

Expand Down Expand Up @@ -73,7 +73,7 @@ export default class Viewport implements IViewport {
}
}

@obx.ref private _scale = 1;
@observable.ref private _scale = 1;

/**
* 缩放比例
Expand All @@ -92,9 +92,9 @@ export default class Viewport implements IViewport {
this._contentHeight = this.height / this.scale;
}

@obx.ref private _contentWidth: number | AutoFit = AutoFit;
@observable.ref private _contentWidth: number | AutoFit = AutoFit;

@obx.ref private _contentHeight: number | AutoFit = AutoFit;
@observable.ref private _contentHeight: number | AutoFit = AutoFit;

@computed get contentHeight(): number | AutoFit {
return this._contentHeight;
Expand All @@ -112,9 +112,9 @@ export default class Viewport implements IViewport {
this._contentWidth = val;
}

@obx.ref private _scrollX = 0;
@observable.ref private _scrollX = 0;

@obx.ref private _scrollY = 0;
@observable.ref private _scrollY = 0;

get scrollX() {
return this._scrollX;
Expand All @@ -133,12 +133,13 @@ export default class Viewport implements IViewport {
return this._scrollTarget;
}

@obx private _scrolling = false;
@observable private _scrolling = false;

get scrolling(): boolean {
return this._scrolling;
}

@action
setScrollTarget(target: Window) {
const scrollTarget = new ScrollTarget(target);
this._scrollX = scrollTarget.left;
Expand Down
6 changes: 0 additions & 6 deletions packages/designer/src/component-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,6 @@ export class ComponentMeta implements IComponentMeta {
return this.getMetadata().configure.advanced || {};
}

/**
* @legacy compatiable for vision
* @deprecated
*/
prototype?: any;

constructor(
readonly designer: Designer,
metadata: IPublicTypeComponentMetadata,
Expand Down
12 changes: 2 additions & 10 deletions packages/designer/src/designer/active-tracker.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { INode } from '../document/node/node';
import { obx, IEventBus, createModuleEventBus } from '@alilc/lowcode-editor-core';
import { observable, IEventBus, createModuleEventBus } from '@alilc/lowcode-editor-core';
import { IPublicTypeActiveTarget, IPublicModelActiveTracker } from '@alilc/lowcode-types';
import { isNode } from '@alilc/lowcode-utils';

Expand All @@ -17,7 +17,7 @@ export interface ActiveTarget extends Omit<IPublicTypeActiveTarget, 'node'> {

// @ts-ignore
export class ActiveTracker implements IActiveTracker {
@obx.ref private _target?: ActiveTarget | INode;
@observable.ref private _target?: ActiveTarget | INode;

private emitter: IEventBus = createModuleEventBus('ActiveTracker');

Expand All @@ -38,14 +38,6 @@ export class ActiveTracker implements IActiveTracker {
return (this._target as ActiveTarget)?.detail;
}

/**
* @deprecated
*/
/* istanbul ignore next */
get intance() {
return this.instance;
}

get instance() {
return (this._target as ActiveTarget)?.instance;
}
Expand Down
52 changes: 5 additions & 47 deletions packages/designer/src/designer/designer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ComponentType } from 'react';
import { obx, computed, autorun, makeObservable, IReactionPublic, IReactionOptions, IReactionDisposer } from '@alilc/lowcode-editor-core';
import { observable, computed, autorun, makeObservable, IReactionPublic, IReactionOptions, IReactionDisposer } from '@alilc/lowcode-editor-core';
import {
IPublicTypeProjectSchema,
IPublicTypeComponentMetadata,
Expand Down Expand Up @@ -93,13 +93,13 @@ export class Designer {

private selectionDispose: undefined | (() => void);

@obx.ref private _componentMetasMap = new Map<string, IComponentMeta>();
@observable.ref private _componentMetasMap = new Map<string, IComponentMeta>();

@obx.ref private _simulatorComponent?: ComponentType<any>;
@observable.ref private _simulatorComponent?: ComponentType<any>;

@obx.ref private _simulatorProps?: Record<string, any> | ((project: IProject) => object);
@observable.ref private _simulatorProps?: Record<string, any> | ((project: IProject) => object);

@obx.ref private _suspensed = false;
@observable.ref private _suspensed = false;

get currentDocument() {
return this.project.currentDocument;
Expand Down Expand Up @@ -309,48 +309,6 @@ export class Designer {
return new SettingTopEntry(this.editor, nodes);
}

/**
* 获得合适的插入位置
* @deprecated
*/
getSuitableInsertion(
insertNode?: INode | IPublicTypeNodeSchema | IPublicTypeNodeSchema[],
): { target: INode; index?: number } | null {
const activeDoc = this.project.currentDocument;
if (!activeDoc) {
return null;
}
if (
Array.isArray(insertNode) &&
isNodeSchema(insertNode[0]) &&
this.getComponentMeta(insertNode[0].componentName).isModal
) {
return {
target: activeDoc.rootNode as INode,
};
}
const focusNode = activeDoc.focusNode!;
const nodes = activeDoc.selection.getNodes();
const refNode = nodes.find((item) => focusNode.contains(item));
let target;
let index: number | undefined;
if (!refNode || refNode === focusNode) {
target = focusNode;
} else if (refNode.componentMeta.isContainer) {
target = refNode;
} else {
// FIXME!!, parent maybe null
target = refNode.parent!;
index = (refNode.index || 0) + 1;
}

if (target && insertNode && !target.componentMeta.checkNestingDown(target, insertNode)) {
return null;
}

return { target, index };
}

setProps(nextProps: DesignerProps) {
const props = this.props ? { ...this.props, ...nextProps } : nextProps;
if (this.props) {
Expand Down
11 changes: 7 additions & 4 deletions packages/designer/src/designer/detecting.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { makeObservable, obx, IEventBus, createModuleEventBus } from '@alilc/lowcode-editor-core';
import { makeObservable, observable, IEventBus, createModuleEventBus, action } from '@alilc/lowcode-editor-core';
import { IPublicModelDetecting } from '@alilc/lowcode-types';
import type { IDocumentModel } from '../document/document-model';
import type { INode } from '../document/node/node';
Expand All @@ -19,7 +19,7 @@ export interface IDetecting extends Omit<IPublicModelDetecting<INode>,
}

export class Detecting implements IDetecting {
@obx.ref private _enable = true;
@observable.ref private _enable = true;

/**
* 控制大纲树 hover 时是否出现悬停效果
Expand All @@ -36,9 +36,9 @@ export class Detecting implements IDetecting {
}
}

@obx.ref xRayMode = false;
@observable.ref xRayMode = false;

@obx.ref private _current: INode | null = null;
@observable.ref private _current: INode | null = null;

private emitter: IEventBus = createModuleEventBus('Detecting');

Expand All @@ -50,20 +50,23 @@ export class Detecting implements IDetecting {
return this._current;
}

@action
capture(node: INode | null) {
if (this._current !== node) {
this._current = node;
this.emitter.emit(DETECTING_CHANGE_EVENT, this.current);
}
}

@action
release(node: INode | null) {
if (this._current === node) {
this._current = null;
this.emitter.emit(DETECTING_CHANGE_EVENT, this.current);
}
}

@action
leave(document: IDocumentModel | undefined) {
if (this.current && this.current.document === document) {
this._current = null;
Expand Down
12 changes: 6 additions & 6 deletions packages/designer/src/designer/drag-ghost/index.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import { Component, ReactElement } from 'react';
import { observer, obx, Title, makeObservable } from '@alilc/lowcode-editor-core';
import { observer, observable, Title, makeObservable } from '@alilc/lowcode-editor-core';
import { Designer } from '../designer';
import { isDragNodeObject } from '../dragon';
import { isSimulatorHost } from '../../simulator';
import './ghost.less';
import {
IPublicTypeI18nData,
IPublicTypeNodeSchema,
IPublicModelDragObject,
} from '@alilc/lowcode-types';
import { isDragNodeObject } from '@alilc/lowcode-utils';

type offBinding = () => any;

@observer
export default class DragGhost extends Component<{ designer: Designer }> {
private dispose: offBinding[] = [];

@obx.ref private titles: (string | IPublicTypeI18nData | ReactElement)[] | null = null;
@observable.ref private titles: (string | IPublicTypeI18nData | ReactElement)[] | null = null;

@obx.ref private x = 0;
@observable.ref private x = 0;

@obx.ref private y = 0;
@observable.ref private y = 0;

@obx private isAbsoluteLayoutContainer = false;
@observable private isAbsoluteLayoutContainer = false;

private dragon = this.props.designer.dragon;

Expand Down
Loading

0 comments on commit 0831277

Please sign in to comment.