GeezerVison is showing github.com — feat: update skeleton ts defined · EasterGit/lowcode-engine@21f74f0
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/editor-core/src/editor.ts +34-25Lines changed: 34 additions & 25 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 | /* eslint-disable max-len */ | 3 | 3 | import { StrictEventEmitter } from 'strict-event-emitter-types'; | 4 | 4 | import { EventEmitter } from 'events'; | 5 | | -import { EventBus } from './event-bus'; | | 5 | +import { EventBus, IEventBus } from './event-bus'; | 6 | 6 | import { | 7 | 7 | IPublicModelEditor, | 8 | 8 | EditorConfig, | @@ -52,15 +52,18 @@ export declare interface Editor extends StrictEventEmitter<EventEmitter, GlobalE | 52 | 52 | eventNames(): Array<string | symbol>; | 53 | 53 | } | 54 | 54 |
| | 55 | +export interface IEditor extends IPublicModelEditor { | | 56 | + config?: EditorConfig; | | 57 | + | | 58 | + components?: PluginClassSet; | | 59 | + | | 60 | + eventBus: IEventBus; | | 61 | + | | 62 | + init(config?: EditorConfig, components?: PluginClassSet): Promise<any>; | | 63 | +} | | 64 | + | 55 | 65 | // eslint-disable-next-line no-redeclare | 56 | | -export class Editor extends (EventEmitter as any) implements IPublicModelEditor { | 57 | | - constructor(readonly viewName: string = 'global', readonly workspaceMode: boolean = false) { | 58 | | - // eslint-disable-next-line constructor-super | 59 | | - super(); | 60 | | - // set global emitter maxListeners | 61 | | - this.setMaxListeners(200); | 62 | | - this.eventBus = new EventBus(this); | 63 | | - } | | 66 | +export class Editor extends EventEmitter implements IEditor { | 64 | 67 |
| 65 | 68 | /** | 66 | 69 | * Ioc Container | @@ -71,10 +74,32 @@ export class Editor extends (EventEmitter as any) implements IPublicModelEditor | 71 | 74 | return globalLocale.getLocale(); | 72 | 75 | } | 73 | 76 |
| | 77 | + config?: EditorConfig; | | 78 | + | | 79 | + eventBus: EventBus; | | 80 | + | | 81 | + components?: PluginClassSet; | | 82 | + | 74 | 83 | // readonly utils = utils; | 75 | 84 |
| 76 | 85 | private hooks: HookConfig[] = []; | 77 | 86 |
| | 87 | + private waits = new Map< | | 88 | + IPublicTypeEditorValueKey, | | 89 | + Array<{ | | 90 | + once?: boolean; | | 91 | + resolve: (data: any) => void; | | 92 | + }> | | 93 | + >(); | | 94 | + | | 95 | + constructor(readonly viewName: string = 'global', readonly workspaceMode: boolean = false) { | | 96 | + // eslint-disable-next-line constructor-super | | 97 | + super(); | | 98 | + // set global emitter maxListeners | | 99 | + this.setMaxListeners(200); | | 100 | + this.eventBus = new EventBus(this); | | 101 | + } | | 102 | + | 78 | 103 | get<T = undefined, KeyOrType = any>( | 79 | 104 | keyOrType: KeyOrType, | 80 | 105 | ): IPublicTypeEditorGetResult<T, KeyOrType> | undefined { | @@ -202,12 +227,6 @@ export class Editor extends (EventEmitter as any) implements IPublicModelEditor | 202 | 227 | this.notifyGot(key || data); | 203 | 228 | } | 204 | 229 |
| 205 | | - config?: EditorConfig; | 206 | | - | 207 | | - eventBus: EventBus; | 208 | | - | 209 | | - components?: PluginClassSet; | 210 | | - | 211 | 230 | async init(config?: EditorConfig, components?: PluginClassSet): Promise<any> { | 212 | 231 | this.config = config || {}; | 213 | 232 | this.components = components || {}; | @@ -270,16 +289,6 @@ export class Editor extends (EventEmitter as any) implements IPublicModelEditor | 270 | 289 | }); | 271 | 290 | }; | 272 | 291 |
| 273 | | - /* eslint-disable */ | 274 | | - private waits = new Map< | 275 | | - IPublicTypeEditorValueKey, | 276 | | - Array<{ | 277 | | - once?: boolean; | 278 | | - resolve: (data: any) => void; | 279 | | - }> | 280 | | - >(); | 281 | | - /* eslint-enable */ | 282 | | - | 283 | 292 | private notifyGot(key: IPublicTypeEditorValueKey) { | 284 | 293 | let waits = this.waits.get(key); | 285 | 294 | if (!waits) { | |
Collapse file Copy file name to clipboardExpand all lines: packages/editor-skeleton/src/area.ts +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3,7 +3,7 @@ import { obx, computed, makeObservable } from '@alilc/lowcode-editor-core'; | 3 | 3 | import { Logger } from '@alilc/lowcode-utils'; | 4 | 4 | import { IPublicTypeWidgetBaseConfig } from '@alilc/lowcode-types'; | 5 | 5 | import { WidgetContainer } from './widget/widget-container'; | 6 | | -import { Skeleton } from './skeleton'; | | 6 | +import { ISkeleton } from './skeleton'; | 7 | 7 | import { IWidget } from './widget/widget'; | 8 | 8 |
| 9 | 9 | const logger = new Logger({ level: 'warn', bizName: 'skeleton:area' }); | @@ -35,7 +35,9 @@ export class Area<C extends IPublicTypeWidgetBaseConfig = any, T extends IWidget | 35 | 35 |
| 36 | 36 | readonly container: WidgetContainer<T, C>; | 37 | 37 |
| 38 | | - constructor(readonly skeleton: Skeleton, readonly name: string, handle: (item: T | C) => T, private exclusive?: boolean, defaultSetCurrent = false) { | | 38 | + private lastCurrent: T | null = null; | | 39 | + | | 40 | + constructor(readonly skeleton: ISkeleton, readonly name: string, handle: (item: T | C) => T, private exclusive?: boolean, defaultSetCurrent = false) { | 39 | 41 | makeObservable(this); | 40 | 42 | this.container = skeleton.createContainer(name, handle, exclusive, () => this.visible, defaultSetCurrent); | 41 | 43 | } | @@ -57,8 +59,6 @@ export class Area<C extends IPublicTypeWidgetBaseConfig = any, T extends IWidget | 57 | 59 | return this.container.remove(config); | 58 | 60 | } | 59 | 61 |
| 60 | | - private lastCurrent: T | null = null; | 61 | | - | 62 | 62 | setVisible(flag: boolean) { | 63 | 63 | if (this.exclusive) { | 64 | 64 | const { current } = this.container; | |
Collapse file Copy file name to clipboardExpand all lines: packages/editor-skeleton/src/components/settings/settings-pane.tsx +4-1Lines changed: 4 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -92,7 +92,10 @@ class SettingFieldView extends Component<SettingFieldViewProps, SettingFieldView | 92 | 92 | const { extraProps } = this.field; | 93 | 93 | const { ignoreDefaultValue } = extraProps; | 94 | 94 | try { | 95 | | - return typeof ignoreDefaultValue === 'function' ? ignoreDefaultValue(this.field.internalToShell()) : false; | | 95 | + if (typeof ignoreDefaultValue === 'function') { | | 96 | + return ignoreDefaultValue(this.field.internalToShellField()); | | 97 | + } | | 98 | + return false; | 96 | 99 | } catch (error) { | 97 | 100 | console.error('exception when ignoreDefaultValue is excuted', error); | 98 | 101 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/editor-skeleton/src/components/stage-box/stage-box.tsx +2-5Lines changed: 2 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import React, { Component } from 'react'; | 2 | 2 | import classNames from 'classnames'; | 3 | 3 | import { observer } from '@alilc/lowcode-editor-core'; | 4 | | -import { SettingTopEntry, SettingField } from '@alilc/lowcode-designer'; | 5 | 4 | import StageChain from './stage-chain'; | 6 | 5 | import Stage from './stage'; | 7 | | -import { Skeleton } from '../../skeleton'; | | 6 | +import { ISkeleton } from '../../skeleton'; | 8 | 7 | import PopupService, { PopupPipe } from '../popup'; | 9 | 8 | import { Stage as StageWidget } from '../../widget/stage'; | 10 | 9 |
| @@ -14,9 +13,7 @@ export type StageBoxProps = typeof StageBoxDefaultProps & { | 14 | 13 | stageChain?: StageChain; | 15 | 14 | className?: string; | 16 | 15 | children: React.ReactNode; | 17 | | - skeleton: Skeleton; | 18 | | - // @todo to remove | 19 | | - target?: SettingTopEntry | SettingField; | | 16 | + skeleton: ISkeleton; | 20 | 17 | }; | 21 | 18 |
| 22 | 19 | type WillDetachMember = () => void; | |
Collapse file Copy file name to clipboard +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { createContext } from 'react'; | 2 | | -import { Skeleton } from './skeleton'; | | 2 | +import { ISkeleton } from './skeleton'; | 3 | 3 |
| 4 | | -export const SkeletonContext = createContext<Skeleton>({} as any); | | 4 | +export const SkeletonContext = createContext<ISkeleton>({} as any); |
Collapse file Copy file name to clipboardExpand all lines: packages/editor-skeleton/src/layouts/left-float-pane.tsx +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -3,9 +3,10 @@ import classNames from 'classnames'; | 3 | 3 | import { observer, Focusable, focusTracker } from '@alilc/lowcode-editor-core'; | 4 | 4 | import { Area } from '../area'; | 5 | 5 | import { Panel } from '../widget/panel'; | | 6 | +import { PanelConfig } from '../types'; | 6 | 7 |
| 7 | 8 | @observer | 8 | | -export default class LeftFloatPane extends Component<{ area: Area<any, Panel> }> { | | 9 | +export default class LeftFloatPane extends Component<{ area: Area<PanelConfig, Panel> }> { | 9 | 10 | private dispose?: () => void; | 10 | 11 |
| 11 | 12 | private focusing?: Focusable; | |
Collapse file Copy file name to clipboardExpand all lines: packages/editor-skeleton/src/layouts/workbench.tsx +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { Component } from 'react'; | 2 | 2 | import { TipContainer, observer } from '@alilc/lowcode-editor-core'; | 3 | 3 | import classNames from 'classnames'; | 4 | | -import { Skeleton } from '../skeleton'; | | 4 | +import { ISkeleton } from '../skeleton'; | 5 | 5 | import TopArea from './top-area'; | 6 | 6 | import LeftArea from './left-area'; | 7 | 7 | import LeftFixedPane from './left-fixed-pane'; | @@ -16,7 +16,7 @@ import { EditorConfig, PluginClassSet } from '@alilc/lowcode-types'; | 16 | 16 |
| 17 | 17 | @observer | 18 | 18 | export class Workbench extends Component<{ | 19 | | - skeleton: Skeleton; | | 19 | + skeleton: ISkeleton; | 20 | 20 | config?: EditorConfig; | 21 | 21 | components?: PluginClassSet; | 22 | 22 | className?: string; | |
Collapse file Copy file name to clipboardExpand all lines: packages/editor-skeleton/src/skeleton.ts +65-4Lines changed: 65 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -import { Editor, action, makeObservable, obx, engineConfig } from '@alilc/lowcode-editor-core'; | | 1 | +import { action, makeObservable, obx, engineConfig, IEditor } from '@alilc/lowcode-editor-core'; | 2 | 2 | import { | 3 | 3 | DockConfig, | 4 | 4 | PanelConfig, | @@ -27,6 +27,7 @@ import { | 27 | 27 | IPublicTypeWidgetBaseConfig, | 28 | 28 | IPublicTypeWidgetConfigArea, | 29 | 29 | IPublicTypeSkeletonConfig, | | 30 | + IPublicApiSkeleton, | 30 | 31 | } from '@alilc/lowcode-types'; | 31 | 32 |
| 32 | 33 | const logger = new Logger({ level: 'warn', bizName: 'skeleton' }); | @@ -42,6 +43,66 @@ export enum SkeletonEvents { | 42 | 43 | WIDGET_ENABLE = 'skeleton.widget.enable', | 43 | 44 | } | 44 | 45 |
| | 46 | +export interface ISkeleton extends Omit<IPublicApiSkeleton, | | 47 | + 'showPanel' | | | 48 | + 'hidePanel' | | | 49 | + 'showWidget' | | | 50 | + 'enableWidget' | | | 51 | + 'hideWidget' | | | 52 | + 'disableWidget' | | | 53 | + 'showArea' | | | 54 | + 'onShowPanel' | | | 55 | + 'onHidePanel' | | | 56 | + 'onShowWidget' | | | 57 | + 'onHideWidget' | | | 58 | + 'remove' | | | 59 | + 'hideArea' | | 60 | +> { | | 61 | + editor: IEditor; | | 62 | + | | 63 | + readonly leftArea: Area<DockConfig | PanelDockConfig | DialogDockConfig>; | | 64 | + | | 65 | + readonly topArea: Area<DockConfig | DividerConfig | PanelDockConfig | DialogDockConfig>; | | 66 | + | | 67 | + readonly subTopArea: Area<DockConfig | DividerConfig | PanelDockConfig | DialogDockConfig>; | | 68 | + | | 69 | + readonly toolbar: Area<DockConfig | DividerConfig | PanelDockConfig | DialogDockConfig>; | | 70 | + | | 71 | + readonly leftFixedArea: Area<PanelConfig, Panel>; | | 72 | + | | 73 | + readonly leftFloatArea: Area<PanelConfig, Panel>; | | 74 | + | | 75 | + readonly rightArea: Area<PanelConfig, Panel>; | | 76 | + | | 77 | + readonly mainArea: Area<WidgetConfig | PanelConfig, Widget | Panel>; | | 78 | + | | 79 | + readonly bottomArea: Area<PanelConfig, Panel>; | | 80 | + | | 81 | + readonly stages: Area<StageConfig, Stage>; | | 82 | + | | 83 | + readonly widgets: IWidget[]; | | 84 | + | | 85 | + getPanel(name: string): Panel | undefined; | | 86 | + | | 87 | + getWidget(name: string): IWidget | undefined; | | 88 | + | | 89 | + buildFromConfig(config?: EditorConfig, components?: PluginClassSet): void; | | 90 | + | | 91 | + createStage(config: any): string | undefined; | | 92 | + | | 93 | + getStage(name: string): Stage | null; | | 94 | + | | 95 | + createContainer( | | 96 | + name: string, | | 97 | + handle: (item: any) => any, | | 98 | + exclusive?: boolean, | | 99 | + checkVisible?: () => boolean, | | 100 | + defaultSetCurrent?: boolean, | | 101 | + ): WidgetContainer; | | 102 | + | | 103 | + createPanel(config: PanelConfig): Panel; | | 104 | +} | | 105 | + | 45 | 106 | export class Skeleton { | 46 | 107 | private panels = new Map<string, Panel>(); | 47 | 108 |
| @@ -69,7 +130,7 @@ export class Skeleton { | 69 | 130 |
| 70 | 131 | readonly widgets: IWidget[] = []; | 71 | 132 |
| 72 | | - constructor(readonly editor: Editor, readonly viewName: string = 'global') { | | 133 | + constructor(readonly editor: IEditor, readonly viewName: string = 'global') { | 73 | 134 | makeObservable(this); | 74 | 135 | this.leftArea = new Area( | 75 | 136 | this, | @@ -244,7 +305,7 @@ export class Skeleton { | 244 | 305 | Object.keys(plugins).forEach((area) => { | 245 | 306 | plugins[area].forEach((item) => { | 246 | 307 | const { pluginKey, type, props = {}, pluginProps } = item; | 247 | | - const config: Partial<IPublicTypeWidgetBaseConfig> = { | | 308 | + const config: IPublicTypeWidgetBaseConfig = { | 248 | 309 | area: area as IPublicTypeWidgetConfigArea, | 249 | 310 | type: 'Widget', | 250 | 311 | name: pluginKey, | @@ -272,7 +333,7 @@ export class Skeleton { | 272 | 333 | if (pluginKey in components) { | 273 | 334 | config.content = components[pluginKey]; | 274 | 335 | } | 275 | | - this.add(config as IPublicTypeWidgetBaseConfig); | | 336 | + this.add(config); | 276 | 337 | }); | 277 | 338 | }); | 278 | 339 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/editor-skeleton/src/transducers/parse-func.ts +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -4,6 +4,7 @@ import { isPlainObject, isJSFunction, getLogger } from '@alilc/lowcode-utils'; | 4 | 4 | const leadingFnRe = /^function/; | 5 | 5 | const leadingFnNameRe = /^\w+\s*\(/; | 6 | 6 | const logger = getLogger({ level: 'warn', bizName: 'skeleton:transducers' }); | | 7 | + | 7 | 8 | /** | 8 | 9 | * 将函数字符串转成函数,支持几种类型 | 9 | 10 | * 类型一:() => {} / val => {} | |
Collapse file Copy file name to clipboardExpand all lines: packages/editor-skeleton/src/types.ts +2-9Lines changed: 2 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { ReactElement, ComponentType } from 'react'; | 2 | 2 | import { | 3 | 3 | IPublicTypeTitleContent, | 4 | | - IPublicTypeIconType, | 5 | 4 | IPublicTypeI18nData, | 6 | | - TipContent, | 7 | 5 | IPublicTypeWidgetConfigArea, | 8 | 6 | IPublicTypeWidgetBaseConfig, | 9 | 7 | IPublicTypePanelDockPanelProps, | | 8 | + IPublicTypePanelDockProps, | 10 | 9 | } from '@alilc/lowcode-types'; | 11 | 10 | import { IWidget } from './widget/widget'; | 12 | 11 |
| @@ -24,13 +23,7 @@ export function isWidgetConfig(obj: any): obj is WidgetConfig { | 24 | 23 | return obj && obj.type === 'Widget'; | 25 | 24 | } | 26 | 25 |
| 27 | | -export interface DockProps { | 28 | | - title?: IPublicTypeTitleContent; | 29 | | - icon?: IPublicTypeIconType; | 30 | | - size?: 'small' | 'medium' | 'large'; | 31 | | - className?: string; | 32 | | - description?: TipContent; | 33 | | - onClick?: () => void; | | 26 | +export interface DockProps extends IPublicTypePanelDockProps { | 34 | 27 | } | 35 | 28 |
| 36 | 29 | export interface DividerConfig extends IPublicTypeWidgetBaseConfig { | |
|