mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-12 03:01:16 +00:00
fix(shell/model): fix lint issues in shell/model
This commit is contained in:
parent
0d388a3076
commit
4fd3af10c5
@ -17,7 +17,7 @@ sidebar_position: 13
|
||||
|
||||
拖拽放置位置目标
|
||||
|
||||
`@type {IPublicModelNode}`
|
||||
`@type {IPublicModelNode | null}`
|
||||
|
||||
相关类型:[IPublicModelNode](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/node.ts)
|
||||
|
||||
|
||||
@ -6,16 +6,22 @@ import {
|
||||
} from '@alilc/lowcode-types';
|
||||
import { isNode } from '@alilc/lowcode-utils';
|
||||
|
||||
export interface IActiveTracker extends Omit< IPublicModelActiveTracker, 'track' > {
|
||||
track(originalTarget: IPublicTypeActiveTarget | INode): void;
|
||||
export interface IActiveTracker extends Omit< IPublicModelActiveTracker, 'track' | 'onChange' > {
|
||||
track(originalTarget: ActiveTarget | INode): void;
|
||||
|
||||
onChange(fn: (target: ActiveTarget) => void): () => void;
|
||||
}
|
||||
|
||||
export interface ActiveTarget extends Omit< IPublicTypeActiveTarget, 'node' > {
|
||||
node: INode;
|
||||
}
|
||||
|
||||
export class ActiveTracker implements IActiveTracker {
|
||||
private emitter: IEventBus = createModuleEventBus('ActiveTracker');
|
||||
|
||||
@obx.ref private _target?: IPublicTypeActiveTarget | INode;
|
||||
@obx.ref private _target?: ActiveTarget | INode;
|
||||
|
||||
track(originalTarget: IPublicTypeActiveTarget | INode) {
|
||||
track(originalTarget: ActiveTarget | INode) {
|
||||
let target = originalTarget;
|
||||
if (isNode(originalTarget)) {
|
||||
target = { node: originalTarget as INode };
|
||||
@ -25,11 +31,11 @@ export class ActiveTracker implements IActiveTracker {
|
||||
}
|
||||
|
||||
get currentNode() {
|
||||
return (this._target as IPublicTypeActiveTarget)?.node;
|
||||
return (this._target as ActiveTarget)?.node;
|
||||
}
|
||||
|
||||
get detail() {
|
||||
return (this._target as IPublicTypeActiveTarget)?.detail;
|
||||
return (this._target as ActiveTarget)?.detail;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,10 +47,10 @@ export class ActiveTracker implements IActiveTracker {
|
||||
}
|
||||
|
||||
get instance() {
|
||||
return (this._target as IPublicTypeActiveTarget)?.instance;
|
||||
return (this._target as ActiveTarget)?.instance;
|
||||
}
|
||||
|
||||
onChange(fn: (target: IPublicTypeActiveTarget) => void): () => void {
|
||||
onChange(fn: (target: ActiveTarget) => void): () => void {
|
||||
this.emitter.addListener('change', fn);
|
||||
return () => {
|
||||
this.emitter.removeListener('change', fn);
|
||||
|
||||
@ -7,9 +7,9 @@ import {
|
||||
IPublicTypeRect,
|
||||
IPublicTypeLocationDetail,
|
||||
IPublicTypeLocationData,
|
||||
IPublicModelLocateEvent,
|
||||
} from '@alilc/lowcode-types';
|
||||
|
||||
|
||||
export interface Point {
|
||||
clientX: number;
|
||||
clientY: number;
|
||||
@ -99,11 +99,15 @@ function isDocument(elem: any): elem is Document {
|
||||
export function getWindow(elem: Element | Document): Window {
|
||||
return (isDocument(elem) ? elem : elem.ownerDocument!).defaultView!;
|
||||
}
|
||||
export interface IDropLocation extends IPublicModelDropLocation {
|
||||
export interface IDropLocation extends Omit< IPublicModelDropLocation, 'target' | 'clone' > {
|
||||
|
||||
readonly source: string;
|
||||
|
||||
get target(): INode;
|
||||
|
||||
get document(): IPublicModelDocumentModel;
|
||||
|
||||
clone(event: IPublicModelLocateEvent): IDropLocation;
|
||||
}
|
||||
|
||||
export class DropLocation implements IDropLocation {
|
||||
@ -126,7 +130,7 @@ export class DropLocation implements IDropLocation {
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
clone(event: ILocateEvent): DropLocation {
|
||||
clone(event: ILocateEvent): IDropLocation {
|
||||
return new DropLocation({
|
||||
target: this.target,
|
||||
detail: this.detail,
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import { IPublicModelSettingTarget } from '@alilc/lowcode-types';
|
||||
import { ComponentMeta } from '../../component-meta';
|
||||
import { IComponentMeta } from '../../component-meta';
|
||||
import { Designer } from '../designer';
|
||||
import { Node } from '../../document';
|
||||
import { INode } from '../../document';
|
||||
|
||||
export interface SettingEntry extends IPublicModelSettingTarget {
|
||||
readonly nodes: Node[];
|
||||
readonly componentMeta: ComponentMeta | null;
|
||||
readonly nodes: INode[];
|
||||
readonly componentMeta: IComponentMeta | null;
|
||||
readonly designer: Designer;
|
||||
|
||||
// 顶端
|
||||
|
||||
@ -2,8 +2,8 @@ import { obx, computed, makeObservable, runInAction, IEventBus, createModuleEven
|
||||
import { GlobalEvent, IPublicModelEditor, IPublicTypeSetValueOptions } from '@alilc/lowcode-types';
|
||||
import { uniqueId, isJSExpression, isSettingField } from '@alilc/lowcode-utils';
|
||||
import { SettingEntry } from './setting-entry';
|
||||
import { Node } from '../../document';
|
||||
import { ComponentMeta } from '../../component-meta';
|
||||
import { INode } from '../../document';
|
||||
import { IComponentMeta } from '../../component-meta';
|
||||
import { Designer } from '../designer';
|
||||
import { Setters } from '@alilc/lowcode-shell';
|
||||
|
||||
@ -19,9 +19,9 @@ export class SettingPropEntry implements SettingEntry {
|
||||
|
||||
readonly setters: Setters;
|
||||
|
||||
readonly nodes: Node[];
|
||||
readonly nodes: INode[];
|
||||
|
||||
readonly componentMeta: ComponentMeta | null;
|
||||
readonly componentMeta: IComponentMeta | null;
|
||||
|
||||
readonly designer: Designer;
|
||||
|
||||
|
||||
@ -11,12 +11,14 @@ export const UNSET = Symbol.for('unset');
|
||||
// eslint-disable-next-line no-redeclare
|
||||
export type UNSET = typeof UNSET;
|
||||
|
||||
export interface IProp extends Omit<IPublicModelProp, 'exportSchema' | 'node'> {
|
||||
export interface IProp extends Omit<IPublicModelProp, 'exportSchema' | 'node' | 'slotNode' > {
|
||||
|
||||
readonly props: Props;
|
||||
|
||||
readonly owner: INode;
|
||||
|
||||
get slotNode(): INode | null;
|
||||
|
||||
delete(prop: Prop): void;
|
||||
|
||||
export(stage: IPublicEnumTransformStage): IPublicTypeCompositeValue;
|
||||
@ -113,8 +115,8 @@ export class Prop implements IProp, IPropParent {
|
||||
|
||||
private _slotNode?: INode;
|
||||
|
||||
get slotNode(): INode | undefined | null {
|
||||
return this._slotNode;
|
||||
get slotNode(): INode | null {
|
||||
return this._slotNode || null;
|
||||
}
|
||||
|
||||
@obx.shallow private _items: Prop[] | null = null;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { IPublicModelActiveTracker, IPublicModelNode, IPublicTypeActiveTarget } from '@alilc/lowcode-types';
|
||||
import { IActiveTracker as InnerActiveTracker, INode as InnerNode } from '@alilc/lowcode-designer';
|
||||
import { IActiveTracker as InnerActiveTracker, ActiveTarget } from '@alilc/lowcode-designer';
|
||||
import { Node as ShellNode } from './node';
|
||||
import { nodeSymbol } from '../symbols';
|
||||
|
||||
@ -16,9 +16,9 @@ export class ActiveTracker implements IPublicModelActiveTracker {
|
||||
if (!fn) {
|
||||
return () => {};
|
||||
}
|
||||
return this[activeTrackerSymbol].onChange((t: IPublicTypeActiveTarget) => {
|
||||
return this[activeTrackerSymbol].onChange((t: ActiveTarget) => {
|
||||
const { node: innerNode, detail, instance } = t;
|
||||
const publicNode = ShellNode.create(innerNode as InnerNode);
|
||||
const publicNode = ShellNode.create(innerNode);
|
||||
const publicActiveTarget = {
|
||||
node: publicNode!,
|
||||
detail,
|
||||
|
||||
@ -2,7 +2,7 @@ import {
|
||||
IDropLocation as InnerDropLocation,
|
||||
} from '@alilc/lowcode-designer';
|
||||
import { dropLocationSymbol } from '../symbols';
|
||||
import { Node } from './node';
|
||||
import { Node as ShellNode } from './node';
|
||||
import { IPublicModelDropLocation, IPublicTypeLocationDetail, IPublicModelLocateEvent } from '@alilc/lowcode-types';
|
||||
|
||||
export class DropLocation implements IPublicModelDropLocation {
|
||||
@ -20,7 +20,7 @@ export class DropLocation implements IPublicModelDropLocation {
|
||||
}
|
||||
|
||||
get target() {
|
||||
return Node.create(this[dropLocationSymbol].target);
|
||||
return ShellNode.create(this[dropLocationSymbol].target);
|
||||
}
|
||||
|
||||
get detail(): IPublicTypeLocationDetail {
|
||||
|
||||
@ -335,6 +335,7 @@ export class Node implements IPublicModelNode {
|
||||
}
|
||||
const shellNode = new Node(node);
|
||||
// @ts-ignore 挂载 shell node 实例
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
node[shellNodeSymbol] = shellNode;
|
||||
return shellNode;
|
||||
}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import { IPublicModelResource } from '@alilc/lowcode-types';
|
||||
import { Resource as InnerResource } from '@alilc/lowcode-workspace';
|
||||
import { resourceSymbol } from '../symbols';
|
||||
import { ResourceType } from './resource-type';
|
||||
|
||||
export class Resource implements IPublicModelResource {
|
||||
readonly [resourceSymbol]: InnerResource;
|
||||
|
||||
@ -12,9 +12,9 @@ import {
|
||||
IPublicTypeSetValueOptions,
|
||||
} from '@alilc/lowcode-types';
|
||||
import { settingPropEntrySymbol } from '../symbols';
|
||||
import { Node } from './node';
|
||||
import { SettingTopEntry } from './setting-top-entry';
|
||||
import { ComponentMeta } from './component-meta';
|
||||
import { Node as ShellNode } from './node';
|
||||
import { SettingTopEntry as ShellSettingTopEntry } from './setting-top-entry';
|
||||
import { ComponentMeta as ShellComponentMeta } from './component-meta';
|
||||
import { isCustomView } from '@alilc/lowcode-utils';
|
||||
|
||||
export class SettingPropEntry implements IPublicModelSettingPropEntry {
|
||||
@ -92,14 +92,14 @@ export class SettingPropEntry implements IPublicModelSettingPropEntry {
|
||||
}
|
||||
|
||||
get props(): IPublicModelSettingTopEntry {
|
||||
return SettingTopEntry.create(this[settingPropEntrySymbol].props);
|
||||
return ShellSettingTopEntry.create(this[settingPropEntrySymbol].props);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设置属性对应的节点实例
|
||||
*/
|
||||
get node(): IPublicModelNode | null {
|
||||
return Node.create(this[settingPropEntrySymbol].getNode());
|
||||
return ShellNode.create(this[settingPropEntrySymbol].getNode());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -113,7 +113,7 @@ export class SettingPropEntry implements IPublicModelSettingPropEntry {
|
||||
* 获取顶级设置属性
|
||||
*/
|
||||
get top(): IPublicModelSettingTopEntry {
|
||||
return SettingTopEntry.create(this[settingPropEntrySymbol].top);
|
||||
return ShellSettingTopEntry.create(this[settingPropEntrySymbol].top);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -127,7 +127,7 @@ export class SettingPropEntry implements IPublicModelSettingPropEntry {
|
||||
* componentMeta
|
||||
*/
|
||||
get componentMeta(): IPublicModelComponentMeta | null {
|
||||
return ComponentMeta.create(this[settingPropEntrySymbol].componentMeta);
|
||||
return ShellComponentMeta.create(this[settingPropEntrySymbol].componentMeta);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -233,7 +233,7 @@ export class SettingPropEntry implements IPublicModelSettingPropEntry {
|
||||
* @returns
|
||||
*/
|
||||
getProps(): IPublicModelSettingTopEntry {
|
||||
return SettingTopEntry.create(this[settingPropEntrySymbol].getProps() as SettingEntry) as any;
|
||||
return ShellSettingTopEntry.create(this[settingPropEntrySymbol].getProps() as SettingEntry);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { SettingEntry } from '@alilc/lowcode-designer';
|
||||
import { settingTopEntrySymbol } from '../symbols';
|
||||
import { Node } from './node';
|
||||
import { SettingPropEntry } from './setting-prop-entry';
|
||||
import { Node as ShellNode } from './node';
|
||||
import { SettingPropEntry as ShellSettingPropEntry } from './setting-prop-entry';
|
||||
import { IPublicModelSettingTopEntry, IPublicModelNode, IPublicModelSettingPropEntry } from '@alilc/lowcode-types';
|
||||
|
||||
export class SettingTopEntry implements IPublicModelSettingTopEntry {
|
||||
@ -19,7 +19,7 @@ export class SettingTopEntry implements IPublicModelSettingTopEntry {
|
||||
* 返回所属的节点实例
|
||||
*/
|
||||
get node(): IPublicModelNode | null {
|
||||
return Node.create(this[settingTopEntrySymbol].getNode());
|
||||
return ShellNode.create(this[settingTopEntrySymbol].getNode());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -28,7 +28,7 @@ export class SettingTopEntry implements IPublicModelSettingTopEntry {
|
||||
* @returns
|
||||
*/
|
||||
get(propName: string | number): IPublicModelSettingPropEntry {
|
||||
return SettingPropEntry.create(this[settingTopEntrySymbol].get(propName) as any);
|
||||
return ShellSettingPropEntry.create(this[settingTopEntrySymbol].get(propName) as any);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { windowSymbol } from '../symbols';
|
||||
import { IPublicModelResource, IPublicModelWindow } from '@alilc/lowcode-types';
|
||||
import { EditorWindow } from '@alilc/lowcode-workspace';
|
||||
import { Resource } from './resource';
|
||||
import { Resource as ShellResource } from './resource';
|
||||
|
||||
export class Window implements IPublicModelWindow {
|
||||
private readonly [windowSymbol]: EditorWindow;
|
||||
@ -19,7 +19,7 @@ export class Window implements IPublicModelWindow {
|
||||
}
|
||||
|
||||
get resource(): IPublicModelResource {
|
||||
return new Resource(this[windowSymbol].resource);
|
||||
return new ShellResource(this[windowSymbol].resource);
|
||||
}
|
||||
|
||||
constructor(editorWindow: EditorWindow) {
|
||||
|
||||
@ -7,7 +7,7 @@ export interface IPublicModelDropLocation {
|
||||
* 拖拽位置目标
|
||||
* get target of dropLocation
|
||||
*/
|
||||
get target(): IPublicModelNode;
|
||||
get target(): IPublicModelNode | null;
|
||||
|
||||
/**
|
||||
* 拖拽放置位置详情
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user