diff --git a/deploy-space/tsconfig.json b/deploy-space/tsconfig.json index bae51443b..8a7d7ca15 100644 --- a/deploy-space/tsconfig.json +++ b/deploy-space/tsconfig.json @@ -32,6 +32,7 @@ "resolveJsonModule": true, // skip type checking of declaration files "skipLibCheck": true, + "outDir": "lib" }, "exclude": ["**/test", "**/lib", "**/es", "node_modules"] } diff --git a/lerna.json b/lerna.json index 75c6500a9..a74ab4dc0 100644 --- a/lerna.json +++ b/lerna.json @@ -1,7 +1,7 @@ { "lerna": "2.11.0", "version": "independent", - "npmClient": "yarn", + "npmClient": "tyarn", "registry": "http://registry.npm.alibaba-inc.com", "useWorkspaces": true, "packages": [ diff --git a/package.json b/package.json index 60da5996d..8b8d1a51b 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,34 @@ { "private": true, + "workspaces": { + "packages": [ + "packages/*" + ], + "nohoist": [ + "**/css-modules-typescript-loader", + "**/@alife/theme-lowcode-*" + ] + }, "scripts": { + "build": "lerna run build", "clean": "rm -rf ./packages/*/lib ./packages/*/es ./packages/*/dist ./packages/*/build", + "commit": "git-cz", + "pub": "lerna publish", "setup": "./scripts/setup.sh", "start": "./scripts/start.sh", - "build": "lerna run build", "test": "lerna run test", - "test:snapshot": "lerna run test:snapshot", - "pub": "lerna publish", - "commit": "git-cz" + "test:snapshot": "lerna run test:snapshot" + }, + "lint-staged": { + "*.{tsx,ts}": [ + "eslint --quiet", + "git add" + ] + }, + "config": { + "commitizen": { + "path": "node_modules/cz-conventional-changelog" + } }, "devDependencies": { "@ali/lowcode-config": "^2.0.5", @@ -26,25 +46,7 @@ "tslib": "^1.9.3", "typescript": "^3.2.2" }, - "engines" : { "node" : "^10" }, - "workspaces": { - "packages": [ - "packages/*" - ], - "nohoist": [ - "**/css-modules-typescript-loader", - "**/@alife/theme-lowcode-*" - ] - }, - "lint-staged": { - "*.{tsx,ts}": [ - "eslint --quiet", - "git add" - ] - }, - "config": { - "commitizen": { - "path": "node_modules/cz-conventional-changelog" - } + "engines": { + "node": "^10" } } diff --git a/packages/demo/src/editor/config/components.js b/packages/demo/src/editor/config/components.js index 1ffa95399..87abd9c01 100644 --- a/packages/demo/src/editor/config/components.js +++ b/packages/demo/src/editor/config/components.js @@ -1,21 +1,20 @@ import undoRedo from '@ali/lowcode-plugin-undo-redo'; import zhEn from '@ali/lowcode-plugin-zh-en'; import logo from '@ali/lowcode-plugin-sample-logo'; -import SamplePreview from '@ali/lowcode-plugin-sample-preview'; -import Designer from '@ali/lowcode-plugin-designer'; -import SettingsPane from '@ali/lowcode-plugin-settings-pane'; +import samplePreview from '@ali/lowcode-plugin-sample-preview'; +import designer from '@ali/lowcode-plugin-designer'; +import settingsPane from '@ali/lowcode-plugin-settings-pane'; import componentsPane from '@ali/lowcode-plugin-components-pane'; -import OutlinePane from '@ali/lowcode-plugin-outline-pane'; -import EventBindDialog from '@ali/lowcode-plugin-event-bind-dialog' -import { PluginFactory } from '@ali/lowcode-editor-core'; +import outlinePane from '@ali/lowcode-plugin-outline-pane'; +import eventBindDialog from '@ali/lowcode-plugin-event-bind-dialog' export default { - undoRedo: PluginFactory(undoRedo), - zhEn: PluginFactory(zhEn), - designer: PluginFactory(Designer), - componentsPane: PluginFactory(componentsPane), - settingsPane: PluginFactory(SettingsPane), - outlinePane: PluginFactory(OutlinePane), - eventBindDialog:PluginFactory(EventBindDialog), - logo: PluginFactory(logo), - samplePreview: PluginFactory(SamplePreview) + undoRedo, + zhEn, + designer, + componentsPane, + settingsPane, + outlinePane, + eventBindDialog, + logo, + samplePreview }; diff --git a/packages/demo/tsconfig.json b/packages/demo/tsconfig.json index aa47c4009..c37b76ecc 100644 --- a/packages/demo/tsconfig.json +++ b/packages/demo/tsconfig.json @@ -1,6 +1,8 @@ { "extends": "../../tsconfig.json", - "compilerOptions": {}, + "compilerOptions": { + "outDir": "lib" + }, "include": [ "./src/" ] diff --git a/packages/designer/tsconfig.json b/packages/designer/tsconfig.json index f2973241d..4a965ec62 100644 --- a/packages/designer/tsconfig.json +++ b/packages/designer/tsconfig.json @@ -1,6 +1,8 @@ { "extends": "../../tsconfig.json", - "compilerOptions": {}, + "compilerOptions": { + "outDir": "lib" + }, "include": [ "./src/" ] diff --git a/packages/editor-core/src/editor.ts b/packages/editor-core/src/editor.ts index 6a0b938a0..6f9a1a01f 100644 --- a/packages/editor-core/src/editor.ts +++ b/packages/editor-core/src/editor.ts @@ -11,6 +11,8 @@ import { PluginSet, } from './definitions'; +import pluginFactory from './pluginFactory'; + import * as editorUtils from './utils'; const { registShortCuts, transformToPromise, unRegistShortCuts } = editorUtils; @@ -92,7 +94,10 @@ export default class Editor extends EventEmitter { constructor(config: EditorConfig, components: PluginClassSet, utils?: Utils) { super(); this.config = config; - this.components = components; + this.components = {}; + Object.entries(components).forEach(([key, value]): void => { + this.components[key] = pluginFactory(value); + }); this.utils = { ...editorUtils, ...utils }; instance = this; } diff --git a/packages/editor-core/tsconfig.json b/packages/editor-core/tsconfig.json index aa47c4009..c37b76ecc 100644 --- a/packages/editor-core/tsconfig.json +++ b/packages/editor-core/tsconfig.json @@ -1,6 +1,8 @@ { "extends": "../../tsconfig.json", - "compilerOptions": {}, + "compilerOptions": { + "outDir": "lib" + }, "include": [ "./src/" ] diff --git a/packages/editor-skeleton/tsconfig.json b/packages/editor-skeleton/tsconfig.json index aa47c4009..c37b76ecc 100644 --- a/packages/editor-skeleton/tsconfig.json +++ b/packages/editor-skeleton/tsconfig.json @@ -1,6 +1,8 @@ { "extends": "../../tsconfig.json", - "compilerOptions": {}, + "compilerOptions": { + "outDir": "lib" + }, "include": [ "./src/" ] diff --git a/packages/globals/tsconfig.json b/packages/globals/tsconfig.json index 8e5f1a903..91c180bdd 100644 --- a/packages/globals/tsconfig.json +++ b/packages/globals/tsconfig.json @@ -1,5 +1,7 @@ { "extends": "../../tsconfig.json", - "compilerOptions": {}, + "compilerOptions": { + "outDir": "lib" + }, "include": ["./src/"], } diff --git a/packages/plugin-components-pane/tsconfig.json b/packages/plugin-components-pane/tsconfig.json index f2973241d..4a965ec62 100644 --- a/packages/plugin-components-pane/tsconfig.json +++ b/packages/plugin-components-pane/tsconfig.json @@ -1,6 +1,8 @@ { "extends": "../../tsconfig.json", - "compilerOptions": {}, + "compilerOptions": { + "outDir": "lib" + }, "include": [ "./src/" ] diff --git a/packages/plugin-designer/tsconfig.json b/packages/plugin-designer/tsconfig.json index a4c90a7cd..c37b76ecc 100644 --- a/packages/plugin-designer/tsconfig.json +++ b/packages/plugin-designer/tsconfig.json @@ -1,6 +1,9 @@ { "extends": "../../tsconfig.json", - "compilerOptions": {}, - "include": ["src/*.ts", "src/*.tsx"], - "exclude": ["node_modules", "build", "public"] + "compilerOptions": { + "outDir": "lib" + }, + "include": [ + "./src/" + ] } diff --git a/packages/plugin-outline-pane/tsconfig.json b/packages/plugin-outline-pane/tsconfig.json index aa47c4009..c37b76ecc 100644 --- a/packages/plugin-outline-pane/tsconfig.json +++ b/packages/plugin-outline-pane/tsconfig.json @@ -1,6 +1,8 @@ { "extends": "../../tsconfig.json", - "compilerOptions": {}, + "compilerOptions": { + "outDir": "lib" + }, "include": [ "./src/" ] diff --git a/packages/plugin-sample-logo/tsconfig.json b/packages/plugin-sample-logo/tsconfig.json index aa47c4009..c37b76ecc 100644 --- a/packages/plugin-sample-logo/tsconfig.json +++ b/packages/plugin-sample-logo/tsconfig.json @@ -1,6 +1,8 @@ { "extends": "../../tsconfig.json", - "compilerOptions": {}, + "compilerOptions": { + "outDir": "lib" + }, "include": [ "./src/" ] diff --git a/packages/plugin-sample-preview/tsconfig.json b/packages/plugin-sample-preview/tsconfig.json index aa47c4009..c37b76ecc 100644 --- a/packages/plugin-sample-preview/tsconfig.json +++ b/packages/plugin-sample-preview/tsconfig.json @@ -1,6 +1,8 @@ { "extends": "../../tsconfig.json", - "compilerOptions": {}, + "compilerOptions": { + "outDir": "lib" + }, "include": [ "./src/" ] diff --git a/packages/plugin-sample-save/tsconfig.json b/packages/plugin-sample-save/tsconfig.json index aa47c4009..c37b76ecc 100644 --- a/packages/plugin-sample-save/tsconfig.json +++ b/packages/plugin-sample-save/tsconfig.json @@ -1,6 +1,8 @@ { "extends": "../../tsconfig.json", - "compilerOptions": {}, + "compilerOptions": { + "outDir": "lib" + }, "include": [ "./src/" ] diff --git a/packages/plugin-settings-pane/src/setters/events-setter/event-dialog.tsx b/packages/plugin-settings-pane/src/setters/events-setter/event-dialog.tsx deleted file mode 100644 index 7303f3649..000000000 --- a/packages/plugin-settings-pane/src/setters/events-setter/event-dialog.tsx +++ /dev/null @@ -1,129 +0,0 @@ -import { Component, isValidElement, ReactElement, ReactNode } from 'react'; -import { Dialog, Search, Input } from '@alifd/next'; -import './style.less'; - -export default class EventDialog extends Component<{ - dialigVisiable:?Boolean, - closeDialog:?()=>void, - submitDialog:?()=>void, - bindEventName:?String -}> { - - private eventList : Array = [ - { - name: 'getData', - }, - { - name: 'deleteData', - }, - { - name: 'initData', - }, - { - name: 'editData', - }, - { - name: 'submitData' - }, - ] - - state = { - selectedEventName:'', - eventName:'' - }; - - componentWillReceiveProps(nextProps){ - this.setState({ - eventName:nextProps.bindEventName - }) - } - - initEventName = () => { - const {bindEventName} = this.props; - let eventName = bindEventName; - this.eventList.map((item)=>{ - if (item.name === eventName){ - eventName = `${eventName}_new`; - } - }) - - this.setState({ - eventName - }) - } - - onInputChange = (eventName:String) => { - this.setState({ - eventName - }) - } - - onSelectItem = (eventName:String) => { - this.setState({ - selectedEventName:eventName - }) - - // 为空是新建事件 - if (eventName === ''){ - this.initEventName() - }else{ - this.setState({ - selectedEventName:eventName, - eventName - }) - } - } - - onSearchEvent = (searchEventName:String) => { - - } - - onOk = () => { - this.props.submitDialog(this.state.eventName); - } - - - render() { - const { dialigVisiable, closeDialog} = this.props; - const {selectedEventName,eventName} = this.state; - return ( - - ); - } -} diff --git a/packages/plugin-settings-pane/src/setters/events-setter/index.tsx b/packages/plugin-settings-pane/src/setters/events-setter/index.tsx deleted file mode 100644 index 4aa1fc673..000000000 --- a/packages/plugin-settings-pane/src/setters/events-setter/index.tsx +++ /dev/null @@ -1,408 +0,0 @@ -import { Component, isValidElement, ReactElement, ReactNode } from 'react'; -import { Radio, Menu, Table, Icon, Dialog } from '@alifd/next'; -import { SettingField } from './main'; -import nativeEvents from './native-events'; - -import './style.less'; -import EventDialog from './event-dialog'; -const { SubMenu, Item, Group, Divider } = Menu; -const RadioGroup = Radio.Group; - -const EVENT_CONTENTS = { - COMPONENT_EVENT: 'componentEvent', - NATIVE_EVENT: 'nativeEvent', - LIFE_CYCLE_EVENT: 'lifeCycleEvent', -}; - -const DEFINITION_EVENT_TYPE = { - EVENTS: 'events', - NATIVE_EVENTS: 'nativeEvents', - LIFE_CYCLE_EVENT: 'lifeCycleEvent', -}; - -export default class EventsSetter extends Component<{ - value: any[]; - onChange: (eventList: any[]) => void; -}> { - state = { - showEventList: false, - eventBtns: [], - eventList: [], - selectType: null, - nativeEventList: [], - lifeCycleEventList: [], - eventDataList: this.props.value || [], - isShowEventDialog: false, - bindEventName: '', - relatedEventName: '', - }; - - static getDerivedStateFromProps(nextProps, prevState) { - const { value } = nextProps; - if (value !== prevState.eventDataList) { - return { - value, - }; - } - return null; - } - - componentDidMount() { - this.initEventBtns(); - this.initEventList(); - } - - /** - * 初始化事件按钮 - */ - initEventBtns() { - const { definition } = this.props; - let isRoot = false; - let isCustom = false; - let eventBtns = []; - definition.map(item => { - if (item.type === DEFINITION_EVENT_TYPE.LIFE_CYCLE_EVENT) { - isRoot = true; - } - - if (item.type === DEFINITION_EVENT_TYPE.EVENTS) { - isCustom = true; - } - }); - - if (isRoot) { - eventBtns = [ - { - value: EVENT_CONTENTS.LIFE_CYCLE_EVENT, - label: '生命周期', - }, - ]; - } else if (isCustom) { - eventBtns = [ - { - value: EVENT_CONTENTS.COMPONENT_EVENT, - label: '组件自带事件', - }, - ]; - } else { - eventBtns = [ - { - value: EVENT_CONTENTS.NATIVE_EVENT, - label: '原生事件', - }, - ]; - } - - this.setState({ - eventBtns, - }); - } - - initEventList() { - const { definition } = this.props; - let nativeEventList = []; - definition.map(item => { - if (item.type === DEFINITION_EVENT_TYPE.EVENTS) { - this.checkEventListStatus(item.list, DEFINITION_EVENT_TYPE.EVENTS); - this.setState({ - eventList: item.list, - }); - } - - if (item.type === DEFINITION_EVENT_TYPE.NATIVE_EVENTS) { - this.checkEventListStatus( - item.list, - DEFINITION_EVENT_TYPE.NATIVE_EVENTS, - ); - nativeEventList = item.list; - } - - if (item.type === DEFINITION_EVENT_TYPE.LIFE_CYCLE_EVENT) { - this.checkEventListStatus( - item.list, - DEFINITION_EVENT_TYPE.LIFE_CYCLE_EVENT, - ); - this.setState({ - lifeCycleEventList: item.list, - }); - } - }); - - if (nativeEventList.length == 0) { - nativeEventList = nativeEvents; - this.setState({ - nativeEventList, - }); - } - } - - checkEventListStatus = (eventList: Array, eventType: String) => { - const { eventDataList } = this.state; - if ( - eventType === DEFINITION_EVENT_TYPE.EVENTS || - eventType === DEFINITION_EVENT_TYPE.LIFE_CYCLE_EVENT - ) { - eventList.map(item => { - item.disabled = false; - eventDataList.map(eventDataItem => { - if (item.name === eventDataItem.name) { - item.disabled = true; - } - }); - }); - } else if (eventType === DEFINITION_EVENT_TYPE.NATIVE_EVENTS) { - eventDataList.map(eventDataItem => { - eventList.map(item => { - item.eventList.map(eventItem => { - if (eventItem.name === eventDataItem.name) { - item.disabled = true; - } else { - item.disabled = false; - } - }); - }); - }); - } - }; - - /** - * 渲染事件信息 - */ - renderEventInfoCell = (value, index, record) => { - let eventTagText = ''; - if (record.type === EVENT_CONTENTS.NATIVE_EVENT) { - eventTagText = '原'; - } else if (record.type === EVENT_CONTENTS.COMPONENT_EVENT) { - eventTagText = '组'; - } else if (record.type === EVENT_CONTENTS.LIFE_CYCLE_EVENT) { - eventTagText = '生'; - } - return ( -