Skip to content

Commit 55c3fc9

Browse files
JackLianliujuping
authored andcommitted
feat: add types for shell, and move functions in types to utils
1 parent aed94f1 commit 55c3fc9

148 files changed

Lines changed: 2808 additions & 711 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/docs/api/project.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ onChangeNodeVisible(fn: (node: Node, visible: boolean) => void)
248248

249249
### onChangeNodeChildren
250250

251-
onChangeNodeChildren(fn: (info?: IOnChangeOptions) => void)
251+
onChangeNodeChildren(fn: (info?: IPublicOnChangeOptions) => void)
252252

253253
当前 document 的节点 children 变更事件
254254

modules/code-generator/src/plugins/component/rax/jsx.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
147147
function __$$eval(expr) {
148148
try {
149149
return expr();
150-
} catch (error) {
150+
} catch (error) {
151151
${evalErrorsHandler}
152152
}
153153
}

packages/designer/src/builtin-simulator/bem-tools/border-container.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import * as React from 'react';
22
import { Component, Fragment, ReactElement, PureComponent } from 'react';
33
import classNames from 'classnames';
44
import { computed, observer, Title, globalLocale } from '@alilc/lowcode-editor-core';
5-
import { I18nData, isI18nData, TitleContent } from '@alilc/lowcode-types';
5+
import { I18nData, TitleContent } from '@alilc/lowcode-types';
6+
import { isI18nData } from '@alilc/lowcode-utils';
67
import { DropLocation } from '../../designer';
78
import { BuiltinSimulatorHost } from '../../builtin-simulator/host';
89
import { ParentalNode } from '../../document/node';

packages/designer/src/builtin-simulator/bem-tools/border-selecting.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import {
99
ComponentType,
1010
} from 'react';
1111
import classNames from 'classnames';
12-
import { observer, computed, Tip, globalContext, makeObservable } from '@alilc/lowcode-editor-core';
13-
import { createIcon, isReactComponent } from '@alilc/lowcode-utils';
14-
import { ActionContentObject, isActionContentObject } from '@alilc/lowcode-types';
12+
import { observer, computed, Tip, globalContext } from '@alilc/lowcode-editor-core';
13+
import { createIcon, isReactComponent, isActionContentObject } from '@alilc/lowcode-utils';
14+
import { ActionContentObject } from '@alilc/lowcode-types';
1515
import { BuiltinSimulatorHost } from '../host';
1616
import { OffsetObserver } from '../../designer';
1717
import { Node } from '../../document';

packages/designer/src/builtin-simulator/host.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ import {
3939
transactionManager,
4040
} from '@alilc/lowcode-utils';
4141
import {
42-
DragObjectType,
43-
DragNodeObject,
4442
isShaken,
4543
LocateEvent,
4644
isDragAnyObject,
@@ -62,6 +60,8 @@ import {
6260
ComponentSchema,
6361
Package,
6462
TransitionType,
63+
DragObjectType,
64+
DragNodeObject,
6565
} from '@alilc/lowcode-types';
6666
import { BuiltinSimulatorRenderer } from './renderer';
6767
import clipboard from '../designer/clipboard';

packages/designer/src/component-meta.ts

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import {
88
TitleContent,
99
TransformedComponentMetadata,
1010
NestingFilter,
11-
isTitleConfig,
1211
I18nData,
1312
LiveTextEditingConfig,
1413
FieldConfig,
14+
MetadataTransducer,
1515
} from '@alilc/lowcode-types';
16-
import { deprecate, isRegExp } from '@alilc/lowcode-utils';
16+
import { deprecate, isRegExp, isTitleConfig } from '@alilc/lowcode-utils';
1717
import { computed, engineConfig } from '@alilc/lowcode-editor-core';
1818
import EventEmitter from 'events';
1919
import { componentDefaults, legacyIssues } from './transducers';
@@ -128,8 +128,8 @@ export class ComponentMeta {
128128

129129
private _isTopFixed?: boolean;
130130

131-
get isTopFixed() {
132-
return this._isTopFixed;
131+
get isTopFixed(): boolean {
132+
return !!(this._isTopFixed);
133133
}
134134

135135
private parentWhitelist?: NestingFilter | null;
@@ -279,7 +279,7 @@ export class ComponentMeta {
279279
return result as any;
280280
}
281281

282-
isRootComponent(includeBlock = true) {
282+
isRootComponent(includeBlock = true): boolean {
283283
return (
284284
this.componentName === 'Page' ||
285285
this.componentName === 'Component' ||
@@ -326,7 +326,7 @@ export class ComponentMeta {
326326
return true;
327327
}
328328

329-
checkNestingDown(my: Node, target: Node | NodeSchema | NodeSchema[]) {
329+
checkNestingDown(my: Node, target: Node | NodeSchema | NodeSchema[]): boolean {
330330
// 检查父子关系,直接约束型,在画布中拖拽直接掠过目标容器
331331
if (this.childWhitelist) {
332332
const _target: any = !Array.isArray(target) ? [target] : target;
@@ -375,19 +375,7 @@ function preprocessMetadata(metadata: ComponentMetadata): TransformedComponentMe
375375
};
376376
}
377377

378-
export interface MetadataTransducer {
379-
(prev: TransformedComponentMetadata): TransformedComponentMetadata;
380-
/**
381-
* 0 - 9 system
382-
* 10 - 99 builtin-plugin
383-
* 100 - app & plugin
384-
*/
385-
level?: number;
386-
/**
387-
* use to replace TODO
388-
*/
389-
id?: string;
390-
}
378+
391379
const metadataTransducers: MetadataTransducer[] = [];
392380

393381
export function registerMetadataTransducer(

packages/designer/src/designer/designer.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import {
88
IEditor,
99
CompositeObject,
1010
PropsList,
11-
isNodeSchema,
1211
NodeSchema,
12+
PropsTransducer,
1313
} from '@alilc/lowcode-types';
14-
import { megreAssets, AssetsJson } from '@alilc/lowcode-utils';
14+
import { megreAssets, AssetsJson, isNodeSchema } from '@alilc/lowcode-utils';
1515
import { Project } from '../project';
1616
import { Node, DocumentModel, insertChildren, ParentalNode, TransformStage } from '../document';
1717
import { ComponentMeta } from '../component-meta';
@@ -494,7 +494,7 @@ export class Designer {
494494
getComponentMeta(
495495
componentName: string,
496496
generateMetadata?: () => ComponentMetadata | null,
497-
): ComponentMeta {
497+
) {
498498
if (this._componentMetasMap.has(componentName)) {
499499
return this._componentMetasMap.get(componentName)!;
500500
}
@@ -536,7 +536,7 @@ export class Designer {
536536
return maps;
537537
}
538538

539-
private propsReducers = new Map<TransformStage, PropsReducer[]>();
539+
private propsReducers = new Map<TransformStage, PropsTransducer[]>();
540540

541541
transformProps(props: CompositeObject | PropsList, node: Node, stage: TransformStage) {
542542
if (Array.isArray(props)) {
@@ -560,7 +560,7 @@ export class Designer {
560560
}, props);
561561
}
562562

563-
addPropsReducer(reducer: PropsReducer, stage: TransformStage) {
563+
addPropsReducer(reducer: PropsTransducer, stage: TransformStage) {
564564
const reducers = this.propsReducers.get(stage);
565565
if (reducers) {
566566
reducers.push(reducer);
@@ -576,11 +576,4 @@ export class Designer {
576576
purge() {
577577
// TODO:
578578
}
579-
}
580-
581-
export type PropsReducerContext = { stage: TransformStage };
582-
export type PropsReducer = (
583-
props: CompositeObject,
584-
node: Node,
585-
ctx?: PropsReducerContext,
586-
) => CompositeObject;
579+
}

packages/designer/src/designer/dragon.ts

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { EventEmitter } from 'events';
22
import { obx, makeObservable } from '@alilc/lowcode-editor-core';
3-
import { NodeSchema } from '@alilc/lowcode-types';
3+
import { DragNodeObject, DragAnyObject, DragObjectType, DragNodeDataObject, DragObject } from '@alilc/lowcode-types';
44
import { Node as ShellNode } from '@alilc/lowcode-shell';
55
import { setNativeSelection, cursor } from '@alilc/lowcode-utils';
66
import { DropLocation } from './location';
@@ -80,31 +80,6 @@ export interface ISensor {
8080
getNodeInstanceFromElement(e: Element | null): NodeInstance<ComponentInstance> | null;
8181
}
8282

83-
export type DragObject = DragNodeObject | DragNodeDataObject | DragAnyObject;
84-
85-
export enum DragObjectType {
86-
// eslint-disable-next-line no-shadow
87-
Node = 'node',
88-
NodeData = 'nodedata',
89-
}
90-
91-
export interface DragNodeObject {
92-
type: DragObjectType.Node;
93-
nodes: (Node | ShellNode)[];
94-
}
95-
export interface DragNodeDataObject {
96-
type: DragObjectType.NodeData;
97-
data: NodeSchema | NodeSchema[];
98-
thumbnail?: string;
99-
description?: string;
100-
[extra: string]: any;
101-
}
102-
103-
export interface DragAnyObject {
104-
type: string;
105-
[key: string]: any;
106-
}
107-
10883
export function isDragNodeObject(obj: any): obj is DragNodeObject {
10984
return obj && obj.type === DragObjectType.Node;
11085
}

packages/designer/src/designer/setting/setting-field.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { TitleContent, isDynamicSetter, SetterType, DynamicSetter, FieldExtraProps, FieldConfig, CustomView, isCustomView } from '@alilc/lowcode-types';
1+
import { TitleContent, SetterType, DynamicSetter, FieldExtraProps, FieldConfig, CustomView, ISetValueOptions } from '@alilc/lowcode-types';
22
import { Transducer } from './utils';
33
import { SettingPropEntry } from './setting-prop-entry';
44
import { SettingEntry } from './setting-entry';
55
import { computed, obx, makeObservable, action } from '@alilc/lowcode-editor-core';
6-
import { cloneDeep } from '@alilc/lowcode-utils';
7-
import type { ISetValueOptions } from '../../types';
6+
import { cloneDeep, isCustomView, isDynamicSetter } from '@alilc/lowcode-utils';
87

98
function getSettingFieldCollectorKey(parent: SettingEntry, config: FieldConfig) {
109
let cur = parent;

packages/designer/src/designer/setting/setting-prop-entry.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { obx, computed, makeObservable, runInAction } from '@alilc/lowcode-editor-core';
2-
import { GlobalEvent, IEditor, isJSExpression } from '@alilc/lowcode-types';
3-
import { uniqueId } from '@alilc/lowcode-utils';
2+
import { GlobalEvent, IEditor, ISetValueOptions } from '@alilc/lowcode-types';
3+
import { uniqueId, isJSExpression } from '@alilc/lowcode-utils';
44
import { SettingPropEntry as ShellSettingPropEntry } from '@alilc/lowcode-shell';
55
import { SettingEntry } from './setting-entry';
66
import { Node } from '../../document';
77
import { ComponentMeta } from '../../component-meta';
88
import { Designer } from '../designer';
99
import { EventEmitter } from 'events';
10-
import { ISetValueOptions } from '../../types';
1110
import { isSettingField } from './setting-field';
1211

1312
export class SettingPropEntry implements SettingEntry {

0 commit comments

Comments
 (0)