GeezerVison is showing github.com — feat: add types for shell, and move functions in types to utils · strogo/lowcode-engine@55c3fc9
File treeExpand file treeCollapse file tree Open diff view settings modules/code-generator/src/plugins/component/rax rax-simulator-renderer/src
Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: docs/docs/api/project.md +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -248,7 +248,7 @@ onChangeNodeVisible(fn: (node: Node, visible: boolean) => void) | 248 | 248 |
| 249 | 249 | ### onChangeNodeChildren | 250 | 250 |
| 251 | | -onChangeNodeChildren(fn: (info?: IOnChangeOptions) => void) | | 251 | +onChangeNodeChildren(fn: (info?: IPublicOnChangeOptions) => void) | 252 | 252 |
| 253 | 253 | 当前 document 的节点 children 变更事件 | 254 | 254 |
| |
Collapse file Copy file name to clipboardExpand all lines: modules/code-generator/src/plugins/component/rax/jsx.ts +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -147,7 +147,7 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) => | 147 | 147 | function __$$eval(expr) { | 148 | 148 | try { | 149 | 149 | return expr(); | 150 | | - } catch (error) { | | 150 | + } catch (error) { | 151 | 151 | ${evalErrorsHandler} | 152 | 152 | } | 153 | 153 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/designer/src/builtin-simulator/bem-tools/border-container.tsx +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -2,7 +2,8 @@ import * as React from 'react'; | 2 | 2 | import { Component, Fragment, ReactElement, PureComponent } from 'react'; | 3 | 3 | import classNames from 'classnames'; | 4 | 4 | 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'; | 6 | 7 | import { DropLocation } from '../../designer'; | 7 | 8 | import { BuiltinSimulatorHost } from '../../builtin-simulator/host'; | 8 | 9 | import { ParentalNode } from '../../document/node'; | |
Collapse file Copy file name to clipboardExpand all lines: packages/designer/src/builtin-simulator/bem-tools/border-selecting.tsx +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 9 | 9 | ComponentType, | 10 | 10 | } from 'react'; | 11 | 11 | 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'; | 15 | 15 | import { BuiltinSimulatorHost } from '../host'; | 16 | 16 | import { OffsetObserver } from '../../designer'; | 17 | 17 | import { Node } from '../../document'; | |
Collapse file Copy file name to clipboardExpand all lines: packages/designer/src/builtin-simulator/host.ts +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -39,8 +39,6 @@ import { | 39 | 39 | transactionManager, | 40 | 40 | } from '@alilc/lowcode-utils'; | 41 | 41 | import { | 42 | | - DragObjectType, | 43 | | - DragNodeObject, | 44 | 42 | isShaken, | 45 | 43 | LocateEvent, | 46 | 44 | isDragAnyObject, | @@ -62,6 +60,8 @@ import { | 62 | 60 | ComponentSchema, | 63 | 61 | Package, | 64 | 62 | TransitionType, | | 63 | + DragObjectType, | | 64 | + DragNodeObject, | 65 | 65 | } from '@alilc/lowcode-types'; | 66 | 66 | import { BuiltinSimulatorRenderer } from './renderer'; | 67 | 67 | import clipboard from '../designer/clipboard'; | |
Collapse file Copy file name to clipboardExpand all lines: packages/designer/src/component-meta.ts +7-19Lines changed: 7 additions & 19 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -8,12 +8,12 @@ import { | 8 | 8 | TitleContent, | 9 | 9 | TransformedComponentMetadata, | 10 | 10 | NestingFilter, | 11 | | - isTitleConfig, | 12 | 11 | I18nData, | 13 | 12 | LiveTextEditingConfig, | 14 | 13 | FieldConfig, | | 14 | + MetadataTransducer, | 15 | 15 | } from '@alilc/lowcode-types'; | 16 | | -import { deprecate, isRegExp } from '@alilc/lowcode-utils'; | | 16 | +import { deprecate, isRegExp, isTitleConfig } from '@alilc/lowcode-utils'; | 17 | 17 | import { computed, engineConfig } from '@alilc/lowcode-editor-core'; | 18 | 18 | import EventEmitter from 'events'; | 19 | 19 | import { componentDefaults, legacyIssues } from './transducers'; | @@ -128,8 +128,8 @@ export class ComponentMeta { | 128 | 128 |
| 129 | 129 | private _isTopFixed?: boolean; | 130 | 130 |
| 131 | | - get isTopFixed() { | 132 | | - return this._isTopFixed; | | 131 | + get isTopFixed(): boolean { | | 132 | + return !!(this._isTopFixed); | 133 | 133 | } | 134 | 134 |
| 135 | 135 | private parentWhitelist?: NestingFilter | null; | @@ -279,7 +279,7 @@ export class ComponentMeta { | 279 | 279 | return result as any; | 280 | 280 | } | 281 | 281 |
| 282 | | - isRootComponent(includeBlock = true) { | | 282 | + isRootComponent(includeBlock = true): boolean { | 283 | 283 | return ( | 284 | 284 | this.componentName === 'Page' || | 285 | 285 | this.componentName === 'Component' || | @@ -326,7 +326,7 @@ export class ComponentMeta { | 326 | 326 | return true; | 327 | 327 | } | 328 | 328 |
| 329 | | - checkNestingDown(my: Node, target: Node | NodeSchema | NodeSchema[]) { | | 329 | + checkNestingDown(my: Node, target: Node | NodeSchema | NodeSchema[]): boolean { | 330 | 330 | // 检查父子关系,直接约束型,在画布中拖拽直接掠过目标容器 | 331 | 331 | if (this.childWhitelist) { | 332 | 332 | const _target: any = !Array.isArray(target) ? [target] : target; | @@ -375,19 +375,7 @@ function preprocessMetadata(metadata: ComponentMetadata): TransformedComponentMe | 375 | 375 | }; | 376 | 376 | } | 377 | 377 |
| 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 | + | 391 | 379 | const metadataTransducers: MetadataTransducer[] = []; | 392 | 380 |
| 393 | 381 | export function registerMetadataTransducer( | |
Collapse file Copy file name to clipboardExpand all lines: packages/designer/src/designer/designer.ts +6-13Lines changed: 6 additions & 13 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -8,10 +8,10 @@ import { | 8 | 8 | IEditor, | 9 | 9 | CompositeObject, | 10 | 10 | PropsList, | 11 | | - isNodeSchema, | 12 | 11 | NodeSchema, | | 12 | + PropsTransducer, | 13 | 13 | } from '@alilc/lowcode-types'; | 14 | | -import { megreAssets, AssetsJson } from '@alilc/lowcode-utils'; | | 14 | +import { megreAssets, AssetsJson, isNodeSchema } from '@alilc/lowcode-utils'; | 15 | 15 | import { Project } from '../project'; | 16 | 16 | import { Node, DocumentModel, insertChildren, ParentalNode, TransformStage } from '../document'; | 17 | 17 | import { ComponentMeta } from '../component-meta'; | @@ -494,7 +494,7 @@ export class Designer { | 494 | 494 | getComponentMeta( | 495 | 495 | componentName: string, | 496 | 496 | generateMetadata?: () => ComponentMetadata | null, | 497 | | - ): ComponentMeta { | | 497 | + ) { | 498 | 498 | if (this._componentMetasMap.has(componentName)) { | 499 | 499 | return this._componentMetasMap.get(componentName)!; | 500 | 500 | } | @@ -536,7 +536,7 @@ export class Designer { | 536 | 536 | return maps; | 537 | 537 | } | 538 | 538 |
| 539 | | - private propsReducers = new Map<TransformStage, PropsReducer[]>(); | | 539 | + private propsReducers = new Map<TransformStage, PropsTransducer[]>(); | 540 | 540 |
| 541 | 541 | transformProps(props: CompositeObject | PropsList, node: Node, stage: TransformStage) { | 542 | 542 | if (Array.isArray(props)) { | @@ -560,7 +560,7 @@ export class Designer { | 560 | 560 | }, props); | 561 | 561 | } | 562 | 562 |
| 563 | | - addPropsReducer(reducer: PropsReducer, stage: TransformStage) { | | 563 | + addPropsReducer(reducer: PropsTransducer, stage: TransformStage) { | 564 | 564 | const reducers = this.propsReducers.get(stage); | 565 | 565 | if (reducers) { | 566 | 566 | reducers.push(reducer); | @@ -576,11 +576,4 @@ export class Designer { | 576 | 576 | purge() { | 577 | 577 | // TODO: | 578 | 578 | } | 579 | | -} | 580 | | - | 581 | | -export type PropsReducerContext = { stage: TransformStage }; | 582 | | -export type PropsReducer = ( | 583 | | - props: CompositeObject, | 584 | | - node: Node, | 585 | | - ctx?: PropsReducerContext, | 586 | | -) => CompositeObject; | | 579 | +} |
Collapse file Copy file name to clipboardExpand all lines: packages/designer/src/designer/dragon.ts +1-26Lines changed: 1 addition & 26 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { EventEmitter } from 'events'; | 2 | 2 | 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'; | 4 | 4 | import { Node as ShellNode } from '@alilc/lowcode-shell'; | 5 | 5 | import { setNativeSelection, cursor } from '@alilc/lowcode-utils'; | 6 | 6 | import { DropLocation } from './location'; | @@ -80,31 +80,6 @@ export interface ISensor { | 80 | 80 | getNodeInstanceFromElement(e: Element | null): NodeInstance<ComponentInstance> | null; | 81 | 81 | } | 82 | 82 |
| 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 | | - | 108 | 83 | export function isDragNodeObject(obj: any): obj is DragNodeObject { | 109 | 84 | return obj && obj.type === DragObjectType.Node; | 110 | 85 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/designer/src/designer/setting/setting-field.ts +2-3Lines changed: 2 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 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'; | 2 | 2 | import { Transducer } from './utils'; | 3 | 3 | import { SettingPropEntry } from './setting-prop-entry'; | 4 | 4 | import { SettingEntry } from './setting-entry'; | 5 | 5 | 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'; | 8 | 7 |
| 9 | 8 | function getSettingFieldCollectorKey(parent: SettingEntry, config: FieldConfig) { | 10 | 9 | let cur = parent; | |
Collapse file Copy file name to clipboardExpand all lines: packages/designer/src/designer/setting/setting-prop-entry.ts +2-3Lines changed: 2 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | 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'; | 4 | 4 | import { SettingPropEntry as ShellSettingPropEntry } from '@alilc/lowcode-shell'; | 5 | 5 | import { SettingEntry } from './setting-entry'; | 6 | 6 | import { Node } from '../../document'; | 7 | 7 | import { ComponentMeta } from '../../component-meta'; | 8 | 8 | import { Designer } from '../designer'; | 9 | 9 | import { EventEmitter } from 'events'; | 10 | | -import { ISetValueOptions } from '../../types'; | 11 | 10 | import { isSettingField } from './setting-field'; | 12 | 11 |
| 13 | 12 | export class SettingPropEntry implements SettingEntry { | |
|