diff --git a/.eslintrc.js b/.eslintrc.js
index f1b6c7b..b22d43b 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -31,6 +31,16 @@ module.exports = {
'@typescript-eslint/indent': 0,
'import/no-cycle': 0,
'@typescript-eslint/no-shadow': 0,
- 'max-len': ["error", {"code": 180}]
- }
+ 'max-len': ['error', { code: 180 }],
+ 'comma-dangle': [
+ 'warn',
+ {
+ objects: 'always',
+ arrays: 'always',
+ imports: 'never',
+ functions: 'never',
+ },
+ ],
+ semi: ['error', 'always'],
+ },
};
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index c644ba5..281c877 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -2,13 +2,19 @@
# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence
-* @leoyuan @alvarto
+* @liujuping @JackLian @alvarto
/packages/plugin-manual/ @alvarto
-/packages/base-monaco-editor/ @alvarto @wangshihao111
-/packages/plugin-code-editor/ @alvarto
+/packages/base-monaco-editor/ @alvarto @wangshihao111 @SuSunSam
+/packages/plugin-code-editor/ @alvarto @SuSunSam
/packages/plugin-schema/ @alvarto
-/packages/plugin-components-pane/ @mark-ck
-/packages/plugin-datasource-pane/ @xingmolu
-/packages/plugin-zh-en/ @leoyuan
-/packages/plugin-undo-redo/ @leoyuan
+/packages/plugin-components-pane/ @mark-ck @love999262
+/packages/plugin-datasource-pane/ @YSMJ1994
+/packages/plugin-zh-en/ @JackLian @liujuping
+/packages/plugin-undo-redo/ @JackLian @liujuping
+/packages/plugin-resource-tabs/ @JackLian @liujuping
+/packages/plugin-set-ref-prop/ @JackLian @liujuping
+/packages/plugin-view-manager-pane/ @JackLian @liujuping
+/packages/base-monaco-editor/ @hzd822
+/packages/plugin-multiple-editor/ @hzd822
+/packages/action-block @liujuping
\ No newline at end of file
diff --git a/.github/workflows/deprecate npm.yml b/.github/workflows/deprecate npm.yml
new file mode 100644
index 0000000..ea096ec
--- /dev/null
+++ b/.github/workflows/deprecate npm.yml
@@ -0,0 +1,32 @@
+name: deprecate Package Version
+
+on:
+ workflow_dispatch:
+ inputs:
+ version:
+ description: 'Version to be deleted package@version'
+ required: true
+
+jobs:
+ delete-package-version:
+ runs-on: ubuntu-latest
+ if: >-
+ github.ref == 'refs/heads/main' &&
+ (github.actor == 'JackLian' || github.actor == 'liujuping')
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v2
+
+ - name: Set up Node.js
+ uses: actions/setup-node@v2
+ with:
+ node-version: '14'
+
+ - name: deprecate Package Version
+ run: |
+ git config --local user.email "action@github.com"
+ git config --local user.name "GitHub Action"
+
+ echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
+ npm deprecate ${{ github.event.inputs.version }} "This version is deprecated. Please consider upgrading to a newer version."
diff --git a/.github/workflows/publish beta npm.yml b/.github/workflows/publish beta npm.yml
new file mode 100644
index 0000000..01ab685
--- /dev/null
+++ b/.github/workflows/publish beta npm.yml
@@ -0,0 +1,38 @@
+name: Publish Beta NPM Packages
+on:
+ workflow_dispatch:
+ inputs:
+ packagePath:
+ description: 'Path to the package (e.g., action-block)'
+ required: true
+ betaVersion:
+ description: 'Beta version number (e.g., 1.0.1-beta.0)'
+ required: true
+
+jobs:
+ publish-package:
+ runs-on: ubuntu-latest
+ if: >-
+ github.actor == 'JackLian' || github.actor == 'liujuping'
+
+ steps:
+ - name: Checkout Repository
+ uses: actions/checkout@v2
+
+ - name: Setup Node.js
+ uses: actions/setup-node@v2
+ with:
+ node-version: '16' # 或者您希望的任何版本
+
+ - name: Change to Package Directory
+ run: |
+ git config --local user.email "action@github.com"
+ git config --local user.name "GitHub Action"
+ npm install --legacy-peer-deps
+ echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
+ cd packages/${{ github.event.inputs.packagePath }}
+ npm install --legacy-peer-deps
+ npm run build
+ npm version ${{ github.event.inputs.betaVersion }}
+ echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
+ npm publish --tag beta
\ No newline at end of file
diff --git a/.github/workflows/publish npm.yml b/.github/workflows/publish npm.yml
new file mode 100644
index 0000000..5ada959
--- /dev/null
+++ b/.github/workflows/publish npm.yml
@@ -0,0 +1,51 @@
+name: Publish NPM Packages
+on:
+ workflow_dispatch:
+ inputs:
+ packagePath:
+ description: 'Path to the package (e.g., action-block)'
+ required: true
+ versionType:
+ description: 'Version update type (major, minor, patch)'
+ required: true
+ default: 'patch'
+
+jobs:
+ publish-package:
+ runs-on: ubuntu-latest
+ if: >-
+ github.ref == 'refs/heads/main' &&
+ (github.actor == 'JackLian' || github.actor == 'liujuping')
+
+ steps:
+ - name: Checkout Repository
+ uses: actions/checkout@v2
+
+ - name: Setup Node.js
+ uses: actions/setup-node@v2
+ with:
+ node-version: '16' # 或者您希望的任何版本
+
+ - name: Publish Package
+ run: |
+ git config --local user.email "action@github.com"
+ git config --local user.name "GitHub Action"
+
+ echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
+ npm install --legacy-peer-deps
+ cd packages/${{ github.event.inputs.packagePath }}
+ npm install --legacy-peer-deps
+ npm version ${{ github.event.inputs.versionType }}
+ npm run build
+
+ echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
+ npm publish
+
+ echo "PACKAGE_NAME=$(node -p "require('./package.json').name")" >> $GITHUB_ENV
+ echo "PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
+
+ git add package.json
+ git commit -m "Bump version to ${PACKAGE_VERSION}"
+
+ git tag -a "${PACKAGE_NAME}@${PACKAGE_VERSION}" -m "Release ${PACKAGE_NAME} version ${PACKAGE_VERSION}"
+ git push origin "${PACKAGE_NAME}@${PACKAGE_VERSION}"
\ No newline at end of file
diff --git a/demo/build.json b/demo/build.json
deleted file mode 100644
index 11f88e5..0000000
--- a/demo/build.json
+++ /dev/null
@@ -1,38 +0,0 @@
-{
- "entry": {
- "index": "src/index"
- },
- "vendor": false,
- "devServer": {
- "hot": false
- },
- "publicPath": "public",
- "externals": {
- "react": "var window.React",
- "react-dom": "var window.ReactDOM",
- "prop-types": "var window.PropTypes",
- "@alifd/next": "var window.Next",
- "@alilc/lowcode-engine": "var window.AliLowCodeEngine",
- "@alilc/lowcode-editor-core": "var window.AliLowCodeEngine.common.editorCabin",
- "@alilc/lowcode-editor-skeleton": "var window.AliLowCodeEngine.common.skeletonCabin",
- "@alilc/lowcode-designer": "var window.AliLowCodeEngine.common.designerCabin",
- "@alilc/lowcode-engine-ext": "var window.AliLowCodeEngineExt",
- "@ali/lowcode-engine": "var window.AliLowCodeEngine",
- "moment": "var window.moment",
- "lodash": "var window._"
- },
- "plugins": [
- [
- "build-plugin-react-app"
- ],
- [
- "build-plugin-moment-locales",
- {
- "locales": [
- "zh-cn"
- ]
- }
- ],
- "./build.plugin.js"
- ]
-}
diff --git a/demo/build.plugin.js b/demo/build.plugin.js
deleted file mode 100644
index 12882de..0000000
--- a/demo/build.plugin.js
+++ /dev/null
@@ -1,58 +0,0 @@
-const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
-
-const HtmlWebpackPlugin = require('html-webpack-plugin');
-
-module.exports = ({ onGetWebpackConfig }) => {
- onGetWebpackConfig((config) => {
- config.resolve.plugin('tsconfigpaths').use(TsconfigPathsPlugin, [
- {
- configFile: './tsconfig.json',
- },
- ]);
-
- config.merge({
- node: {
- fs: 'empty',
- },
- });
- config.merge({
- entry: {
- index: require.resolve('./src/index.ts'),
- preview: require.resolve('./src/preview.tsx'),
- },
- });
- config
- .plugin('index')
- .use(HtmlWebpackPlugin, [
- {
- inject: false,
- templateParameters: {
- },
- template: require.resolve('./public/index.html'),
- filename: 'index.html',
- },
- ]);
- config
- .plugin('preview')
- .use(HtmlWebpackPlugin, [
- {
- inject: false,
- templateParameters: {
- },
- template: require.resolve('./public/preview.html'),
- filename: 'preview.html',
- },
- ]);
-
- config.plugins.delete('hot');
- config.devServer.hot(false);
-
- config.module // fixes https://github.com/graphql/graphql-js/issues/1272
- .rule('mjs$')
- .test(/\.mjs$/)
- .include
- .add(/node_modules/)
- .end()
- .type('javascript/auto');
- });
-};
diff --git a/demo/package.json b/demo/package.json
deleted file mode 100644
index 6d61e11..0000000
--- a/demo/package.json
+++ /dev/null
@@ -1,45 +0,0 @@
-{
- "name": "@alilc/lowcode-plugins-demo",
- "version": "1.0.0",
- "description": "Low-Code Engine 低代码搭建引擎 Demo 项目",
- "repository": "git@github.com:alibaba/lowcode-demo.git",
- "license": "MIT",
- "main": "index.js",
- "scripts": {
- "start": "build-scripts start --disable-reload",
- "build": "build-scripts build",
- "pub": "node ./scripts/watchdog.js && npm pub"
- },
- "files": [
- "build"
- ],
- "config": {},
- "dependencies": {
- "@alilc/lowcode-plugin-code-editor": "^1.0.1",
- "@alilc/lowcode-plugin-code-generator": "^1.0.1",
- "@alilc/lowcode-plugin-components-pane": "^1.0.2",
- "@alilc/lowcode-plugin-datasource-pane": "1.0.0",
- "@alilc/lowcode-plugin-inject": "^1.0.0",
- "@alilc/lowcode-plugin-manual": "^1.0.0",
- "@alilc/lowcode-plugin-schema": "^1.0.0",
- "@alilc/lowcode-plugin-simulator-select": "^1.0.0",
- "@alilc/lowcode-plugin-undo-redo": "^1.0.0",
- "@alilc/lowcode-plugin-zh-en": "^1.0.0",
- "@alilc/lowcode-react-renderer": "^1.0.0",
- "@alilc/lowcode-setter-behavior": "^1.0.0",
- "@alilc/lowcode-setter-title": "^1.0.2"
- },
- "devDependencies": {
- "@alilc/lowcode-engine": "^1.0.0",
- "@alilc/lowcode-types": "^1.0.0",
- "@alib/build-scripts": "^0.1.18",
- "@types/events": "^3.0.0",
- "@types/react": "^16.8.3",
- "@types/react-dom": "^16.8.2",
- "@types/streamsaver": "^2.0.0",
- "build-plugin-fusion": "^0.1.0",
- "build-plugin-moment-locales": "^0.1.0",
- "build-plugin-react-app": "^1.1.2",
- "tsconfig-paths-webpack-plugin": "^3.2.0"
- }
-}
diff --git a/demo/public/favicon.png b/demo/public/favicon.png
deleted file mode 100644
index 307ffbd..0000000
Binary files a/demo/public/favicon.png and /dev/null differ
diff --git a/demo/public/index.html b/demo/public/index.html
deleted file mode 100644
index 9695d3d..0000000
--- a/demo/public/index.html
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
- 阿里低代码引擎 Demo
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/demo/public/mock-pages.json b/demo/public/mock-pages.json
deleted file mode 100644
index 8e20f2f..0000000
--- a/demo/public/mock-pages.json
+++ /dev/null
@@ -1 +0,0 @@
-{"success":true,"content":[{"gmtModified":"2021-03-06 00:40:54","formUuid":"FORM-6X866SC1KM4O4BLF3U7879QB0EMT2Z3TGIWLKW","parentNavUuid":"NAV-SYSTEM-PARENT-UUID","hidden":"n","navUuid":"FORM-6X866SC1KM4O4BLF3U7879QB0EMT2Z3TGIWLKW","navType":"PAGE","isIndex":"n","isNew":"n","gmtCreate":"2021-03-06 00:27:26","title":{"en_US":"页面1","zh_CN":"页面1","type":"i18n"},"relateUuid":"FORM-6X866SC1KM4O4BLF3U7879QB0EMT2Z3TGIWLKW","parentId":0,"listOrder":0,"id":556103}]}
\ No newline at end of file
diff --git a/demo/public/mock/info.json b/demo/public/mock/info.json
deleted file mode 100644
index 006209b..0000000
--- a/demo/public/mock/info.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "info": "Hello AliLowCode!!"
-}
\ No newline at end of file
diff --git a/demo/public/preview.html b/demo/public/preview.html
deleted file mode 100644
index 798b156..0000000
--- a/demo/public/preview.html
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
- 预览低代码
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/demo/src/index.ts b/demo/src/index.ts
deleted file mode 100644
index 4607725..0000000
--- a/demo/src/index.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-import { init } from '@alilc/lowcode-engine';
-import registerPlugins from './universal/plugin';
-import './universal/global.scss';
-
-
-const preference = new Map();
-preference.set('DataSourcePane', {
- importPlugins: [],
- dataSourceTypes: [
- {
- type: 'fetch'
- },
- {
- type: 'jsonp',
- }
- ]
-});
-
-(async function main() {
- await registerPlugins();
-
- init(document.getElementById('lce-container')!, {
- // designMode: 'live',
- // locale: 'zh-CN',
- enableCondition: true,
- enableCanvasLock: true,
- // 默认绑定变量
- supportVariableGlobally: true,
- // simulatorUrl 在当 engine-core.js 同一个路径下时是不需要配置的!!!
- // 这里因为用的是 unpkg,在不同 npm 包,engine-core.js 和 react-simulator-renderer.js 是不同路径
- simulatorUrl: [
- 'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@beta/dist/css/react-simulator-renderer.css',
- 'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@beta/dist/js/react-simulator-renderer.js'
- ]
- }, preference);
-})();
diff --git a/demo/src/preview.tsx b/demo/src/preview.tsx
deleted file mode 100644
index 27627ff..0000000
--- a/demo/src/preview.tsx
+++ /dev/null
@@ -1,63 +0,0 @@
-import ReactDOM from 'react-dom';
-import React, { useState } from 'react';
-import { Loading } from '@alifd/next';
-import { buildComponents, assetBundle, AssetLevel, AssetLoader } from '@alilc/lowcode-utils';
-import ReactRenderer from '@alilc/lowcode-react-renderer';
-import { injectComponents } from '@alilc/lowcode-plugin-inject';
-
-const SamplePreview = () => {
- const [data, setData] = useState({});
-
- async function init() {
- const packages = JSON.parse(window.localStorage.getItem('packages') || '');
- const projectSchema = JSON.parse(window.localStorage.getItem('projectSchema') || '');
- const { componentsMap: componentsMapArray, componentsTree } = projectSchema;
- const componentsMap: any = {};
- componentsMapArray.forEach((component: any) => {
- componentsMap[component.componentName] = component;
- });
- const schema = componentsTree[0];
-
- const libraryMap = {};
- const libraryAsset = [];
- packages.forEach(({ package: _package, library, urls, renderUrls }) => {
- libraryMap[_package] = library;
- if (renderUrls) {
- libraryAsset.push(renderUrls);
- } else if (urls) {
- libraryAsset.push(urls);
- }
- });
-
- const vendors = [assetBundle(libraryAsset, AssetLevel.Library)];
-
- // TODO asset may cause pollution
- const assetLoader = new AssetLoader();
- await assetLoader.load(libraryAsset);
- const components = await injectComponents(buildComponents(libraryMap, componentsMap));
-
- setData({
- schema,
- components,
- });
- }
-
- const { schema, components } = data;
-
- if (!schema || !components) {
- init();
- return ;
- }
-
- return (
-
-
-
- );
-};
-
-ReactDOM.render(, document.getElementById('ice-container'));
diff --git a/demo/src/universal/global.scss b/demo/src/universal/global.scss
deleted file mode 100644
index 02906a3..0000000
--- a/demo/src/universal/global.scss
+++ /dev/null
@@ -1,55 +0,0 @@
-body {
- font-family: PingFangSC-Regular, Roboto, Helvetica Neue, Helvetica, Tahoma, Arial, PingFang SC-Light, Microsoft YaHei;
- font-size: 12px;
- * {
- box-sizing: border-box;
- }
-}
-
-body, #lce-container {
- position: fixed;
- left: 0;
- right: 0;
- bottom: 0;
- top: 0;
- box-sizing: border-box;
- padding: 0;
- margin: 0;
- overflow: hidden;
- text-rendering: optimizeLegibility;
- -webkit-user-select: none;
- -webkit-user-drag: none;
- -webkit-text-size-adjust: none;
- -webkit-touch-callout: none;
- -webkit-font-smoothing: antialiased;
- #engine {
- width: 100%;
- height: 100%;
- }
-}
-
-html {
- min-width: 1024px;
-}
-
-.save-sample {
- width: 80px;
- height: 30px;
- background-color: #5584FF;
- border: none;
- outline: none;
- border-radius: 4px;
- color: white;
- cursor: pointer;
-}
-
-.load-assets {
- width: 100px;
- height: 30px;
- background-color: #5584FF;
- border: none;
- outline: none;
- border-radius: 4px;
- color: white;
- cursor: pointer;
-}
diff --git a/demo/tsconfig.json b/demo/tsconfig.json
deleted file mode 100644
index 23314ab..0000000
--- a/demo/tsconfig.json
+++ /dev/null
@@ -1,44 +0,0 @@
-{
- "compilerOptions": {
- "baseUrl": ".",
- "declaration": true,
- "lib": ["es2015", "dom"],
- // Target latest version of ECMAScript.
- "target": "esnext",
- // Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'.
- "module": "esnext",
- // Search under node_modules for non-relative imports.
- "moduleResolution": "node",
- // Process & infer types from .js files.
- "allowJs": true,
- // Report errors in .js files.
- "checkJs": false,
- // Don't emit; allow Babel to transform files.
- // "noEmit": true,
- // Enable strictest settings like strictNullChecks & noImplicitAny.
- "strict": true,
- // Allow default imports from modules with no default export. This does not affect code emit, just typechecking.
- "allowSyntheticDefaultImports": true,
- // Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'.
- "esModuleInterop": true,
- // Specify JSX code generation: 'preserve', 'react-native', or 'react'.
- "jsx": "preserve",
- // Import emit helpers (e.g. __extends, __rest, etc..) from tslib
- "importHelpers": true,
- // Enables experimental support for ES7 decorators.
- "experimentalDecorators": true,
- // Generates corresponding .map file.
- "sourceMap": true,
- // Disallow inconsistently-cased references to the same file.
- "forceConsistentCasingInFileNames": true,
- // Allow json import
- "resolveJsonModule": true,
- // skip type checking of declaration files
- "skipLibCheck": true,
- "outDir": "lib"
- },
- "include": [
- "./src/"
- ],
- "exclude": ["**/test", "**/lib", "**/es", "node_modules"]
-}
diff --git a/package.json b/package.json
index 58231d4..761e9e0 100644
--- a/package.json
+++ b/package.json
@@ -40,9 +40,9 @@
}
},
"devDependencies": {
- "lerna": "^4.x",
"f2elint": "^2.0.1",
"husky": "^7.0.4",
+ "lerna": "^4.x",
"typescript": "^3.2.2"
},
"engines": {
@@ -54,5 +54,6 @@
},
"resolutions": {
"@builder/babel-preset-ice": "1.0.1"
- }
-}
+ },
+ "repository": "https://github.com/alibaba/lowcode-plugins.git"
+}
\ No newline at end of file
diff --git a/packages/action-block/.gitignore b/packages/action-block/.gitignore
deleted file mode 100644
index 77dfbd1..0000000
--- a/packages/action-block/.gitignore
+++ /dev/null
@@ -1,104 +0,0 @@
-# project custom
-build
-dist
-lib
-es
-package-lock.json
-yarn.lock
-deploy-space/packages
-deploy-space/.env
-
-
-# IDE
-.vscode
-.idea
-
-# Logs
-logs
-*.log
-npm-debug.log*
-yarn-debug.log*
-yarn-error.log*
-lerna-debug.log*
-
-# Runtime data
-pids
-*.pid
-*.seed
-*.pid.lock
-
-
-# Directory for instrumented libs generated by jscoverage/JSCover
-lib-cov
-
-# Coverage directory used by tools like istanbul
-coverage
-
-# nyc test coverage
-.nyc_output
-
-# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
-.grunt
-
-# Bower dependency directory (https://bower.io/)
-bower_components
-
-# node-waf configuration
-.lock-wscript
-
-# Compiled binary addons (https://nodejs.org/api/addons.html)
-build/Release
-lib
-
-# Dependency directories
-node_modules/
-jspm_packages/
-
-# TypeScript v1 declaration files
-typings/
-
-# Optional npm cache directory
-.npm
-
-# Optional eslint cache
-.eslintcache
-
-# Optional REPL history
-.node_repl_history
-
-# Output of 'npm pack'
-*.tgz
-
-# Yarn Integrity file
-.yarn-integrity
-
-# dotenv environment variables file
-.env
-.env.test
-
-# parcel-bundler cache (https://parceljs.org/)
-.cache
-
-# next.js build output
-.next
-
-# nuxt.js build output
-.nuxt
-
-# vuepress build output
-.vuepress/dist
-
-# Serverless directories
-.serverless/
-
-# FuseBox cache
-.fusebox/
-
-# DynamoDB Local files
-.dynamodb/
-
-# mac config files
-.DS_Store
-
-# codealike
-codealike.json
diff --git a/packages/action-block/package.json b/packages/action-block/package.json
index 25e37fa..e9c0c00 100644
--- a/packages/action-block/package.json
+++ b/packages/action-block/package.json
@@ -1,8 +1,13 @@
{
"name": "@alilc/action-block",
- "version": "1.0.0-beta.0",
+ "version": "1.0.1",
"description": "",
"main": "lib/index.js",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/alibaba/lowcode-plugins.git",
+ "directory": "packages/action-block"
+ },
"scripts": {
"start": "build-scripts start",
"build": "build-scripts build",
@@ -22,5 +27,5 @@
"build-plugin-fusion": "^0.1.22",
"build-plugin-moment-locales": "^0.1.3"
},
- "homepage": "https://unpkg.com/@alilc/action-block@1.0.0-beta.0/build/index.html"
+ "homepage": "https://unpkg.com/@alilc/action-block@1.0.1/build/index.html"
}
diff --git a/packages/action-block/src/index.tsx b/packages/action-block/src/index.tsx
index 02e69eb..22eaa46 100644
--- a/packages/action-block/src/index.tsx
+++ b/packages/action-block/src/index.tsx
@@ -30,7 +30,7 @@ const SaveAsBlock = (props: SaveAsBlockProps) => {
React.useEffect(() => {
const generateImage = async () => {
let dom2 = node.getDOMNode();
- console.log('html2canvas: ', html2canvas);
+ // console.log('html2canvas: ', html2canvas);
const canvas = await html2canvas?.(dom2, { scale: 0.5 });
const dataUrl = canvas.toDataURL();
setSrc(dataUrl);
@@ -106,7 +106,7 @@ export default {
},
title: '新增',
action(node: Node) {
- console.log('node: ', node);
+ // console.log('node: ', node);
dialog = Dialog.show({
v2: true,
title: "保存为区块",
@@ -116,4 +116,4 @@ export default {
},
},
important: true,
-};
\ No newline at end of file
+};
diff --git a/packages/base-monaco-editor/package.json b/packages/base-monaco-editor/package.json
index bbbf077..6dfa41a 100644
--- a/packages/base-monaco-editor/package.json
+++ b/packages/base-monaco-editor/package.json
@@ -1,8 +1,9 @@
{
"name": "@alilc/lowcode-plugin-base-monaco-editor",
- "version": "1.1.1",
+ "version": "1.1.2",
"description": "代码编辑组件,monaco-editor 的低代码适配封装",
"publishConfig": {
+ "registry": "https://registry.npmjs.org/",
"access": "public"
},
"files": [
@@ -62,5 +63,10 @@
"commit-msg": "f2elint commit-msg-scan"
}
},
- "homepage": "https://unpkg.com/@alilc/lowcode-plugin-base-monaco-editor@1.1.1/build/index.html"
+ "homepage": "https://unpkg.com/@alilc/lowcode-plugin-base-monaco-editor@1.1.2/build/index.html",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/alibaba/lowcode-plugins.git",
+ "directory": "packages/base-monaco-editor"
+ }
}
diff --git a/packages/base-monaco-editor/src/helper.ts b/packages/base-monaco-editor/src/helper.ts
index 614ee8d..5180c52 100644
--- a/packages/base-monaco-editor/src/helper.ts
+++ b/packages/base-monaco-editor/src/helper.ts
@@ -44,6 +44,7 @@ export interface IGeneralManacoEditorProps {
enableOutline?: boolean;
/** style of wrapper */
style?: CSSProperties;
+ overrideServices?: oEditor.IEditorOverrideServices;
enhancers?: EditorEnhancer[];
}
@@ -113,7 +114,7 @@ const DIFF_EDITOR_INITIAL_OPTIONS: oEditor.IStandaloneDiffEditorConstructionOpti
export const useEditor = (type: 'single' | 'diff', props: IGeneralManacoEditorProps) => {
const {
- editorDidMount, editorWillMount, theme, value, path, language, saveViewState, defaultValue, enhancers,
+ editorDidMount, editorWillMount, theme, value, path, language, saveViewState, defaultValue, enhancers, overrideServices
} = props;
const [isEditorReady, setIsEditorReady] = useState(false);
@@ -196,7 +197,7 @@ export const useEditor = (type: 'single' | 'diff', props: I
automaticLayout: true,
...INITIAL_OPTIONS,
...optionRef.current,
- });
+ }, overrideServices);
editor.setModel(model);
} else {
const originalModel = monaco
@@ -211,7 +212,7 @@ export const useEditor = (type: 'single' | 'diff', props: I
automaticLayout: true,
...DIFF_EDITOR_INITIAL_OPTIONS,
...optionRef.current,
- });
+ }, overrideServices);
editor.setModel({ original: originalModel, modified: modifiedModel });
}
diff --git a/packages/plugin-block/.gitignore b/packages/plugin-block/.gitignore
deleted file mode 100644
index 77dfbd1..0000000
--- a/packages/plugin-block/.gitignore
+++ /dev/null
@@ -1,104 +0,0 @@
-# project custom
-build
-dist
-lib
-es
-package-lock.json
-yarn.lock
-deploy-space/packages
-deploy-space/.env
-
-
-# IDE
-.vscode
-.idea
-
-# Logs
-logs
-*.log
-npm-debug.log*
-yarn-debug.log*
-yarn-error.log*
-lerna-debug.log*
-
-# Runtime data
-pids
-*.pid
-*.seed
-*.pid.lock
-
-
-# Directory for instrumented libs generated by jscoverage/JSCover
-lib-cov
-
-# Coverage directory used by tools like istanbul
-coverage
-
-# nyc test coverage
-.nyc_output
-
-# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
-.grunt
-
-# Bower dependency directory (https://bower.io/)
-bower_components
-
-# node-waf configuration
-.lock-wscript
-
-# Compiled binary addons (https://nodejs.org/api/addons.html)
-build/Release
-lib
-
-# Dependency directories
-node_modules/
-jspm_packages/
-
-# TypeScript v1 declaration files
-typings/
-
-# Optional npm cache directory
-.npm
-
-# Optional eslint cache
-.eslintcache
-
-# Optional REPL history
-.node_repl_history
-
-# Output of 'npm pack'
-*.tgz
-
-# Yarn Integrity file
-.yarn-integrity
-
-# dotenv environment variables file
-.env
-.env.test
-
-# parcel-bundler cache (https://parceljs.org/)
-.cache
-
-# next.js build output
-.next
-
-# nuxt.js build output
-.nuxt
-
-# vuepress build output
-.vuepress/dist
-
-# Serverless directories
-.serverless/
-
-# FuseBox cache
-.fusebox/
-
-# DynamoDB Local files
-.dynamodb/
-
-# mac config files
-.DS_Store
-
-# codealike
-codealike.json
diff --git a/packages/plugin-block/package.json b/packages/plugin-block/package.json
index 2c79be7..6c27ed4 100644
--- a/packages/plugin-block/package.json
+++ b/packages/plugin-block/package.json
@@ -22,5 +22,10 @@
"build-plugin-fusion": "^0.1.22",
"build-plugin-moment-locales": "^0.1.3"
},
- "homepage": "https://unpkg.com/@alilc/lowcode-plugin-block@1.0.0-beta.0/build/index.html"
+ "homepage": "https://unpkg.com/@alilc/lowcode-plugin-block@1.0.0-beta.0/build/index.html",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/alibaba/lowcode-plugins.git",
+ "directory": "packages/plugin-block"
+ }
}
diff --git a/packages/plugin-block/src/index.tsx b/packages/plugin-block/src/index.tsx
index afd3b29..dfbbb71 100644
--- a/packages/plugin-block/src/index.tsx
+++ b/packages/plugin-block/src/index.tsx
@@ -1,8 +1,8 @@
import * as React from 'react';
-import { ILowCodePluginContext } from '@alilc/lowcode-engine';
+import { IPublicModelPluginContext } from '@alilc/lowcode-types';
import { default as BlockPane } from './pane';
-const LowcodePluginCusPlugin = (ctx: ILowCodePluginContext) => {
+const LowcodePluginCusPlugin = (ctx: IPublicModelPluginContext) => {
return {
// 插件名,注册环境下唯一
name: 'LowcodePluginCusPlugin',
diff --git a/packages/plugin-code-editor/.editorconfig b/packages/plugin-code-editor/.editorconfig
new file mode 100644
index 0000000..3192996
--- /dev/null
+++ b/packages/plugin-code-editor/.editorconfig
@@ -0,0 +1,13 @@
+root = true
+
+[*]
+indent_style = space
+indent_size = 2
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+quote_type = single
+
+[*.md]
+trim_trailing_whitespace = false
diff --git a/packages/plugin-code-editor/.eslintignore b/packages/plugin-code-editor/.eslintignore
new file mode 100644
index 0000000..36c1703
--- /dev/null
+++ b/packages/plugin-code-editor/.eslintignore
@@ -0,0 +1,7 @@
+node_modules/
+build/
+dist/
+**/*.min.js
+**/*-min.js
+**/*.bundle.js
+*.js
diff --git a/packages/plugin-code-editor/.eslintrc.js b/packages/plugin-code-editor/.eslintrc.js
new file mode 100644
index 0000000..0245b1d
--- /dev/null
+++ b/packages/plugin-code-editor/.eslintrc.js
@@ -0,0 +1,11 @@
+module.exports = {
+ extends: [
+ 'eslint-config-ali/typescript/react',
+ 'prettier',
+ 'prettier/@typescript-eslint',
+ 'prettier/react',
+ ],
+ rules: {
+ 'no-param-reassign': 0,
+ },
+};
diff --git a/packages/plugin-code-editor/.gitignore b/packages/plugin-code-editor/.gitignore
deleted file mode 100644
index 77dfbd1..0000000
--- a/packages/plugin-code-editor/.gitignore
+++ /dev/null
@@ -1,104 +0,0 @@
-# project custom
-build
-dist
-lib
-es
-package-lock.json
-yarn.lock
-deploy-space/packages
-deploy-space/.env
-
-
-# IDE
-.vscode
-.idea
-
-# Logs
-logs
-*.log
-npm-debug.log*
-yarn-debug.log*
-yarn-error.log*
-lerna-debug.log*
-
-# Runtime data
-pids
-*.pid
-*.seed
-*.pid.lock
-
-
-# Directory for instrumented libs generated by jscoverage/JSCover
-lib-cov
-
-# Coverage directory used by tools like istanbul
-coverage
-
-# nyc test coverage
-.nyc_output
-
-# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
-.grunt
-
-# Bower dependency directory (https://bower.io/)
-bower_components
-
-# node-waf configuration
-.lock-wscript
-
-# Compiled binary addons (https://nodejs.org/api/addons.html)
-build/Release
-lib
-
-# Dependency directories
-node_modules/
-jspm_packages/
-
-# TypeScript v1 declaration files
-typings/
-
-# Optional npm cache directory
-.npm
-
-# Optional eslint cache
-.eslintcache
-
-# Optional REPL history
-.node_repl_history
-
-# Output of 'npm pack'
-*.tgz
-
-# Yarn Integrity file
-.yarn-integrity
-
-# dotenv environment variables file
-.env
-.env.test
-
-# parcel-bundler cache (https://parceljs.org/)
-.cache
-
-# next.js build output
-.next
-
-# nuxt.js build output
-.nuxt
-
-# vuepress build output
-.vuepress/dist
-
-# Serverless directories
-.serverless/
-
-# FuseBox cache
-.fusebox/
-
-# DynamoDB Local files
-.dynamodb/
-
-# mac config files
-.DS_Store
-
-# codealike
-codealike.json
diff --git a/packages/plugin-code-editor/CHANGELOG.md b/packages/plugin-code-editor/CHANGELOG.md
index ce9b400..a8f5cba 100644
--- a/packages/plugin-code-editor/CHANGELOG.md
+++ b/packages/plugin-code-editor/CHANGELOG.md
@@ -1,3 +1,12 @@
+## 1.0.5 / 2022-11-28
+
+- Fix 修正 UIPaaS 中针对 source 的异常提示问题
+
+## 1.0.4 / 2022-11-18
+
+- Fix 修正输入 / 粘贴时光标位置错误的 bug
+- Fix 修复当上下文没有 originCode 时,通过 schema 中的局部 source 字段无法恢复 state 的问题
+
## 1.0.3 / 2022-07-11
- Fix 源码面板高度塌陷的 [bug](https://github.com/alibaba/lowcode-engine/issues/803)
diff --git a/packages/plugin-code-editor/build.js b/packages/plugin-code-editor/build.js
new file mode 100644
index 0000000..9bcddea
--- /dev/null
+++ b/packages/plugin-code-editor/build.js
@@ -0,0 +1,22 @@
+module.exports = {
+ plugins: [
+ [
+ 'build-plugin-fusion',
+ {
+ themePackage: '@alifd/theme-lowcode-light',
+ },
+ ],
+ [
+ '@alilc/build-plugin-alt',
+ {
+ type: 'plugin',
+ // 开启注入调试模式,see:https://www.yuque.com/lce/doc/ulvlkz
+ inject: true,
+ // 配置要打开的页面,在注入调试模式下,不配置此项的话不会打开浏览器
+ // 支持直接使用官方 demo 项目:https://lowcode-engine.cn/demo/index.html
+ // openUrl: 'https://lowcode-engine.cn/demo/index.html?debug',
+ },
+ ],
+ './build.plugin.js',
+ ],
+};
diff --git a/packages/plugin-code-editor/package.json b/packages/plugin-code-editor/package.json
index 14ef6d9..340bc01 100644
--- a/packages/plugin-code-editor/package.json
+++ b/packages/plugin-code-editor/package.json
@@ -1,7 +1,7 @@
{
"name": "@alilc/lowcode-plugin-code-editor",
"author": "59174526@qq.com & humphry.huang9@gmail.com",
- "version": "1.0.3",
+ "version": "1.0.9",
"description": "CodeEditor",
"files": [
"es",
@@ -12,11 +12,12 @@
"types": "lib/index.d.ts",
"README": "README.md",
"scripts": {
- "start": "build-scripts start",
+ "start": "build-scripts start --config build.js",
"prepublishOnly": "npm run build",
- "build": "build-scripts build"
+ "build": "build-scripts build --config build.js"
},
"publishConfig": {
+ "registry": "https://registry.npmjs.org/",
"access": "public"
},
"dependencies": {
@@ -24,7 +25,7 @@
"@alilc/lowcode-plugin-base-monaco-editor": "^1.1.1",
"@babel/core": "^7.15.8",
"@babel/parser": "^7.15.8",
- "@babel/preset-env": "^7.15.8",
+ "@babel/preset-env": "7.22.9",
"@babel/preset-react": "^7.14.5",
"@babel/standalone": "^7.15.8",
"@babel/traverse": "^7.15.4",
@@ -49,5 +50,10 @@
"@types/react-dom": "^16.9.4",
"build-plugin-fusion": "^0.1.22"
},
- "license": "MIT"
+ "license": "MIT",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/alibaba/lowcode-plugins.git",
+ "directory": "packages/plugin-code-editor"
+ }
}
diff --git a/packages/plugin-code-editor/src/components/ErrorBoundary/ErrorBoundary.less b/packages/plugin-code-editor/src/components/ErrorBoundary/ErrorBoundary.less
index ab8f7b3..5a9324d 100644
--- a/packages/plugin-code-editor/src/components/ErrorBoundary/ErrorBoundary.less
+++ b/packages/plugin-code-editor/src/components/ErrorBoundary/ErrorBoundary.less
@@ -1,7 +1,4 @@
-.container {
- min-width: 300px;
-}
-.actions {
+.plugin-code-editor-errorBoundary-actions {
margin: 12px auto;
width: fit-content;
text-align: center;
diff --git a/packages/plugin-code-editor/src/components/ErrorBoundary/ErrorBoundary.tsx b/packages/plugin-code-editor/src/components/ErrorBoundary/ErrorBoundary.tsx
index fabd328..72159fd 100644
--- a/packages/plugin-code-editor/src/components/ErrorBoundary/ErrorBoundary.tsx
+++ b/packages/plugin-code-editor/src/components/ErrorBoundary/ErrorBoundary.tsx
@@ -1,7 +1,7 @@
import React, { Component, ErrorInfo, Suspense } from 'react';
import { Loading, Message, Button } from '@alifd/next';
-import styles from './ErrorBoundary.less';
+import './ErrorBoundary.less';
interface ErrorBoundaryProps {
onCatch?: (error: Error, info: ErrorInfo) => void;
@@ -41,7 +41,7 @@ export class ErrorBoundary extends Component
详细错误: {errorInfo || '未知原因'}
-
+
diff --git a/packages/plugin-code-editor/src/components/JSEditor/JsEditor.tsx b/packages/plugin-code-editor/src/components/JSEditor/JsEditor.tsx
index c84a816..4b0acfd 100644
--- a/packages/plugin-code-editor/src/components/JSEditor/JsEditor.tsx
+++ b/packages/plugin-code-editor/src/components/JSEditor/JsEditor.tsx
@@ -178,8 +178,14 @@ export class JsEditor extends PureComponent
{
if (!monacoEditor || !monaco) {
return;
}
- const count = monacoEditor.getModel()?.getLineCount() ?? 0;
- const range = new monaco.Range(count, 1, count, 1);
+
+ // 找到最后一个 },在他前面插入新的 function 字符串
+ const matches = monacoEditor.getModel()?.findMatches('}');
+ let range = {}
+ if(matches && matches.length > 0) {
+ const { startLineNumber, startColumn } = matches[matches.length - 1]?.range || {}
+ range = new monaco.Range(startLineNumber, startColumn, startLineNumber, startColumn);
+ }
const functionCode = params.template ?
params.template :
@@ -248,10 +254,9 @@ export class JsEditor extends PureComponent {
return;
}
- const pos = monacoEditor.getPosition();
+ // const pos = monacoEditor.getPosition();
this.setState({ errorInfo, hasError, code: newCode, errorLocation }, () => {
- monacoEditor.setPosition(pos);
-
+ // monacoEditor.setPosition(pos);
// update error decorations
if (this.lastErrorDecoration) {
monacoEditor.deltaDecorations(
diff --git a/packages/plugin-code-editor/src/config/default-code.ts b/packages/plugin-code-editor/src/config/default-code.ts
index 3765874..bf7ea44 100644
--- a/packages/plugin-code-editor/src/config/default-code.ts
+++ b/packages/plugin-code-editor/src/config/default-code.ts
@@ -1,5 +1,5 @@
export const defaultCode = `
- export default class LowcodeComponent extends Component {
+ export default class Page extends Component {
// 可以在 state 中定义搭建所需要的 State
state = {
test: 1,
diff --git a/packages/plugin-code-editor/src/index.tsx b/packages/plugin-code-editor/src/index.tsx
index 766a74c..c40e74e 100644
--- a/packages/plugin-code-editor/src/index.tsx
+++ b/packages/plugin-code-editor/src/index.tsx
@@ -1,8 +1,9 @@
import { CodeEditorPane } from './pane';
-import { project, ILowCodePluginContext } from '@alilc/lowcode-engine';
+import { project } from '@alilc/lowcode-engine';
import icon from './icon';
+import { IPublicModelPluginContext } from '@alilc/lowcode-types';
-const plugin = (ctx: ILowCodePluginContext) => {
+const plugin = (ctx: IPublicModelPluginContext) => {
return {
name: 'codeEditor',
width: 600,
@@ -14,7 +15,7 @@ const plugin = (ctx: ILowCodePluginContext) => {
},
// 插件的初始化函数,在引擎初始化之后会立刻调用
init() {
- const schemaDock = ctx.skeleton.add({
+ const codeEditorDock = ctx.skeleton.add({
area: 'leftArea',
name: 'codeEditor',
type: 'PanelDock',
@@ -35,9 +36,9 @@ const plugin = (ctx: ILowCodePluginContext) => {
),
});
- schemaDock && schemaDock.disable();
+ codeEditorDock && codeEditorDock.disable();
project.onSimulatorRendererReady(() => {
- schemaDock.enable();
+ codeEditorDock.enable();
});
},
};
diff --git a/packages/plugin-code-editor/src/pane/index.tsx b/packages/plugin-code-editor/src/pane/index.tsx
index 6f229b5..dae3b0c 100644
--- a/packages/plugin-code-editor/src/pane/index.tsx
+++ b/packages/plugin-code-editor/src/pane/index.tsx
@@ -94,7 +94,7 @@ export const CodeEditorPane = memo(({ project, event, skeleton }: CodeEditorPane
useEffect(() => {
// load schema on open
- eventRef.current?.on('skeleton.panel-dock.active', (pluginName) => {
+ skeletonRef.current?.onShowPanel((pluginName: string) => {
if (pluginName === 'codeEditor') {
const schema = lowcodeProjectRef.current?.exportSchema(common.designerCabin.TransformStage.Save);
if (!schema) {
@@ -109,7 +109,7 @@ export const CodeEditorPane = memo(({ project, event, skeleton }: CodeEditorPane
});
// save schema when panel closed
- eventRef.current?.on('skeleton.panel-dock.unactive', (pluginName) => {
+ skeletonRef.current?.onHidePanel((pluginName: string) => {
if (pluginName === 'codeEditor') {
saveSchemaRef.current?.();
}
diff --git a/packages/plugin-code-editor/src/types/methods.ts b/packages/plugin-code-editor/src/types/methods.ts
index 2e62f08..093941f 100644
--- a/packages/plugin-code-editor/src/types/methods.ts
+++ b/packages/plugin-code-editor/src/types/methods.ts
@@ -1,7 +1,8 @@
+import { JSFunction, JSExpression } from '@alilc/lowcode-types';
+export type Method = JSExpression | JSFunction & {
+ source: string;
+}
+
export interface Methods {
- [key: string]: {
- type: 'JSFunction';
- value: string;
- originalCode: string;
- };
+ [key: string]: Method;
}
diff --git a/packages/plugin-code-editor/src/types/state.ts b/packages/plugin-code-editor/src/types/state.ts
index d994852..ff85180 100644
--- a/packages/plugin-code-editor/src/types/state.ts
+++ b/packages/plugin-code-editor/src/types/state.ts
@@ -1,6 +1,6 @@
import { JSExpression } from '@alilc/lowcode-types';
-export interface IState extends JSExpression{
- // 原始代码
- originCode: string;
+export interface IState extends JSExpression {
+ // 原始代码
+ source: string;
}
\ No newline at end of file
diff --git a/packages/plugin-code-editor/src/typeings.d.ts b/packages/plugin-code-editor/src/typings.d.ts
similarity index 100%
rename from packages/plugin-code-editor/src/typeings.d.ts
rename to packages/plugin-code-editor/src/typings.d.ts
diff --git a/packages/plugin-code-editor/src/utils/evaluate.ts b/packages/plugin-code-editor/src/utils/evaluate.ts
new file mode 100644
index 0000000..d4b7db7
--- /dev/null
+++ b/packages/plugin-code-editor/src/utils/evaluate.ts
@@ -0,0 +1,32 @@
+interface Expr {
+ type: string;
+ value: string | number;
+ extType?: string;
+}
+
+type ExprType = Expr | string;
+
+function getExprStr(expr: ExprType) {
+ if (typeof expr === 'string') {
+ return expr;
+ }
+ return expr && (expr as Expr).value;
+}
+
+function getEvalExpressionStr(expr: ExprType): string | undefined {
+ const exprStr = getExprStr(expr);
+ if (exprStr == undefined) {
+ return exprStr;
+ } else if (exprStr === '') {
+ return undefined;
+ }
+ return `(function(){return (${exprStr})}).call($scope)`;
+}
+
+export function evaluate(expr: ExprType) {
+ const evalExprStr = getEvalExpressionStr(expr);
+ const code = `with($scope || {}) { return ${evalExprStr} }`;
+ const fn = new Function('$scope', code);
+ // 暂时不传递 $scope
+ return fn();
+}
diff --git a/packages/plugin-code-editor/src/utils/get-methods.ts b/packages/plugin-code-editor/src/utils/get-methods.ts
index 72579f7..cd890b2 100644
--- a/packages/plugin-code-editor/src/utils/get-methods.ts
+++ b/packages/plugin-code-editor/src/utils/get-methods.ts
@@ -54,8 +54,7 @@ export const getMethods = (ast: Node) => {
methods[name] = {
type: 'JSFunction',
value: compiledCode,
- // 这里的 originalCode 直接放在全局,不挂在局部
- // originalCode: codeStr,
+ source: codeStr,
};
},
});
diff --git a/packages/plugin-code-editor/src/utils/schema-to-code.ts b/packages/plugin-code-editor/src/utils/schema-to-code.ts
index 166ae6b..986ed9a 100644
--- a/packages/plugin-code-editor/src/utils/schema-to-code.ts
+++ b/packages/plugin-code-editor/src/utils/schema-to-code.ts
@@ -1,14 +1,14 @@
-
import { js_beautify, css_beautify } from 'js-beautify';
-import { isJSExpression, ProjectSchema, RootSchema, JSFunction, JSExpression } from '@alilc/lowcode-types';
+import { isJSExpression, ProjectSchema, RootSchema } from '@alilc/lowcode-types';
import { Dialog } from '@alifd/next';
import { IState } from '../types';
-import { defaultStateCode, WORDS } from '../config';
+import { WORDS } from '../config';
+import type { Method } from '../types/methods';
const js_beautify_config = { indent_size: 2, indent_empty_lines: true, e4x: true };
const initCode = (componentSchema: RootSchema | undefined) => {
- const code = `class LowcodeComponent extends Component {
+ const code = `class Page extends Component {
${initStateCode(componentSchema)}
${initLifeCycleCode(componentSchema)}
${initMethodsCode(componentSchema)}
@@ -30,34 +30,24 @@ export const schema2CssCode = (schema: ProjectSchema) => {
};
export const beautifyCSS = (input?: string): string => {
- return input ? css_beautify(input, { indent_size: 2 }) : ''
+ return input ? css_beautify(input, { indent_size: 2 }) : '';
}
function initStateCode(componentSchema: RootSchema | undefined) {
if (componentSchema?.state) {
- let states: Record = {};
- let needNotice = false;
- Object.keys(componentSchema.state).forEach((item) => {
- const state = componentSchema.state?.[item];
+ let statesStr = 'state = {\n';
+ Object.keys(componentSchema.state).forEach((key) => {
+ const state = componentSchema.state?.[key];
if (typeof state === 'object' && isJSExpression(state)) {
- states[item] = (state as IState).originCode || state.value; // 兼容历史数据
- if (!(state as IState).originCode) {
- needNotice = true;
- }
+ statesStr += `"${key}": ${(state as IState).source || state.value},\n`;
} else {
- states[item] = state; // 兼容历史数据
+ statesStr += `"${key}": ${typeof state === 'string' ? '"' + state + '"' : state},,\n`;
}
});
- if (needNotice) {
- Dialog.alert({
- title: WORDS.title,
- content: WORDS.irreparableState,
- });
- }
- return `state = ${JSON.stringify(states)}`;
+ statesStr += '}';
+ return statesStr;
}
- return defaultStateCode;
}
function initLifeCycleCode(componentSchema: RootSchema | undefined) {
@@ -100,10 +90,10 @@ function initMethodsCode(componentSchema: RootSchema | undefined) {
}
}
-function createFunctionCode(functionName: string, functionNode: JSFunction | JSExpression) {
+function createFunctionCode(functionName: string, functionNode: Method) {
if (functionNode?.type === 'JSExpression' || functionNode?.type === 'JSFunction') {
// 读取原始代码
- let functionCode = functionNode.originalCode;
+ let functionCode = functionNode.source;
if (functionCode) {
functionCode = functionCode.replace(/function/, '');
} else {
diff --git a/packages/plugin-code-editor/src/utils/state-parser.ts b/packages/plugin-code-editor/src/utils/state-parser.ts
index 439e964..872eb2b 100644
--- a/packages/plugin-code-editor/src/utils/state-parser.ts
+++ b/packages/plugin-code-editor/src/utils/state-parser.ts
@@ -18,7 +18,6 @@ export const stateParser = (ast: Node) => {
// get state identifier or literal
if (path.isIdentifier({ name: 'state' }) || path.isLiteral({ value: 'state' })) {
const properties = path.container?.value?.properties;
- // console.log('properties', properties);
if (properties) {
properties.forEach((property) => {
// creat empty AST
@@ -26,7 +25,7 @@ export const stateParser = (ast: Node) => {
code.program.body.push(t.variableDeclaration('var', [
t.variableDeclarator(t.identifier('name'), property.value),
]));
-
+
const codeStr = babelTransformFromAst(code).code;
const compiledCode = transformJS(codeStr, defaultBabelConfig).code;
if (compiledCode) {
diff --git a/packages/plugin-code-editor/src/utils/transform.ts b/packages/plugin-code-editor/src/utils/transform.ts
index 7f18e94..faed277 100644
--- a/packages/plugin-code-editor/src/utils/transform.ts
+++ b/packages/plugin-code-editor/src/utils/transform.ts
@@ -1,4 +1,3 @@
-
import { transform } from './babel';
import { TransformResult } from '../types';
diff --git a/packages/plugin-components-pane/.gitignore b/packages/plugin-components-pane/.gitignore
deleted file mode 100644
index 8523c97..0000000
--- a/packages/plugin-components-pane/.gitignore
+++ /dev/null
@@ -1,26 +0,0 @@
-# See https://help.github.com/ignore-files/ for more about ignoring files.
-
-# dependencies
-node_modules/
-
-# production
-build/
-dist/
-tmp/
-lib/
-es/
-
-# misc
-.idea/
-.happypack
-.DS_Store
-*.swp
-*.dia~
-.ice
-
-npm-debug.log*
-yarn-debug.log*
-yarn-error.log*
-index.module.scss.d.ts
-
-node_modules
diff --git a/packages/plugin-components-pane/build.json b/packages/plugin-components-pane/build.json
index 90ae90f..36f5196 100644
--- a/packages/plugin-components-pane/build.json
+++ b/packages/plugin-components-pane/build.json
@@ -1,6 +1,14 @@
{
"plugins": [
"build-plugin-component",
+ [
+ "@alilc/build-plugin-alt",
+ {
+ "type": "plugin",
+ "inject": true,
+ "openUrl": "https://lowcode-engine.cn/demo/index.html?debug"
+ }
+ ],
"build-plugin-fusion",
[
"build-plugin-moment-locales",
diff --git a/packages/plugin-components-pane/demo/demo.hbs b/packages/plugin-components-pane/demo/demo.hbs
index bcca41a..f5147dd 100644
--- a/packages/plugin-components-pane/demo/demo.hbs
+++ b/packages/plugin-components-pane/demo/demo.hbs
@@ -11,9 +11,9 @@
-
-
-
+
+
+
@@ -21,4 +21,4 @@
-