From 0014b6aae81bd42b349969837e881e16cb24df59 Mon Sep 17 00:00:00 2001 From: 1ncounter <1ncounter.100@gmail.com> Date: Wed, 27 Mar 2024 17:28:53 +0800 Subject: [PATCH] chore: change build scripts --- packages/designer/package.json | 4 +- packages/editor-core/package.json | 4 +- packages/editor-skeleton/package.json | 13 ++--- packages/engine/package.json | 47 +++++++++---------- packages/engine/tsconfig.json | 6 +-- packages/plugin-command/package.json | 4 +- packages/plugin-designer/package.json | 4 +- packages/plugin-outline-pane/package.json | 4 +- .../react-simulator-renderer/babel.config.js | 1 - packages/react-simulator-renderer/build.json | 3 -- .../react-simulator-renderer/build.plugin.js | 5 -- .../react-simulator-renderer/build.test.json | 6 --- .../react-simulator-renderer/build.umd.json | 37 --------------- .../react-simulator-renderer/jest.config.js | 33 ------------- .../react-simulator-renderer/package.json | 36 +++++++------- .../{src => src.bak}/README.md | 0 .../builtin-components/builtin-components.ts | 0 .../builtin-components/leaf.tsx | 0 .../builtin-components/slot.tsx | 0 .../{src => src.bak}/host.ts | 0 .../react-simulator-renderer/src.bak/index.ts | 17 +++++++ .../{src => src.bak}/locale/en-US.json | 0 .../{src => src.bak}/locale/index.ts | 0 .../{src => src.bak}/locale/zh-CN.json | 0 .../{src => src.bak}/renderer-view.tsx | 0 .../{src => src.bak}/renderer.less | 0 .../{src => src.bak}/renderer.ts | 0 .../utils/get-client-rects.ts | 0 .../{src => src.bak}/utils/is-dom-node.ts | 0 .../{src => src.bak}/utils/misc.ts | 0 .../utils/react-find-dom-nodes.ts | 0 .../{src => src.bak}/utils/url.ts | 0 .../react-simulator-renderer/src/index.ts | 17 ------- .../react-simulator-renderer/vite.config.ts | 30 ++++++++++++ .../react-simulator-renderer/vitest.config.ts | 0 packages/renderer-core/package.json | 4 +- packages/renderer-react/package.json | 4 +- packages/renderer-react/vite.config.ts | 4 +- packages/renderer-router/package.json | 4 +- packages/shell/package.json | 4 +- packages/shell/src/api/material.ts | 22 +++++---- packages/types/package.json | 4 +- packages/utils/package.json | 4 +- packages/workspace/package.json | 4 +- scripts/build.sh | 29 ------------ scripts/dev.mjs | 0 46 files changed, 133 insertions(+), 221 deletions(-) delete mode 100644 packages/react-simulator-renderer/babel.config.js delete mode 100644 packages/react-simulator-renderer/build.json delete mode 100644 packages/react-simulator-renderer/build.plugin.js delete mode 100644 packages/react-simulator-renderer/build.test.json delete mode 100644 packages/react-simulator-renderer/build.umd.json delete mode 100644 packages/react-simulator-renderer/jest.config.js rename packages/react-simulator-renderer/{src => src.bak}/README.md (100%) rename packages/react-simulator-renderer/{src => src.bak}/builtin-components/builtin-components.ts (100%) rename packages/react-simulator-renderer/{src => src.bak}/builtin-components/leaf.tsx (100%) rename packages/react-simulator-renderer/{src => src.bak}/builtin-components/slot.tsx (100%) rename packages/react-simulator-renderer/{src => src.bak}/host.ts (100%) create mode 100644 packages/react-simulator-renderer/src.bak/index.ts rename packages/react-simulator-renderer/{src => src.bak}/locale/en-US.json (100%) rename packages/react-simulator-renderer/{src => src.bak}/locale/index.ts (100%) rename packages/react-simulator-renderer/{src => src.bak}/locale/zh-CN.json (100%) rename packages/react-simulator-renderer/{src => src.bak}/renderer-view.tsx (100%) rename packages/react-simulator-renderer/{src => src.bak}/renderer.less (100%) rename packages/react-simulator-renderer/{src => src.bak}/renderer.ts (100%) rename packages/react-simulator-renderer/{src => src.bak}/utils/get-client-rects.ts (100%) rename packages/react-simulator-renderer/{src => src.bak}/utils/is-dom-node.ts (100%) rename packages/react-simulator-renderer/{src => src.bak}/utils/misc.ts (100%) rename packages/react-simulator-renderer/{src => src.bak}/utils/react-find-dom-nodes.ts (100%) rename packages/react-simulator-renderer/{src => src.bak}/utils/url.ts (100%) create mode 100644 packages/react-simulator-renderer/vite.config.ts create mode 100644 packages/react-simulator-renderer/vitest.config.ts delete mode 100755 scripts/build.sh create mode 100644 scripts/dev.mjs diff --git a/packages/designer/package.json b/packages/designer/package.json index 891a7dee8..f6e9a2e87 100644 --- a/packages/designer/package.json +++ b/packages/designer/package.json @@ -19,8 +19,8 @@ "package.json" ], "scripts": { - "build": "vite build", - "build-dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs", + "build:target": "vite build", + "build:dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs", "test": "vitest", "test:cov": "" }, diff --git a/packages/editor-core/package.json b/packages/editor-core/package.json index 3030d25bf..0161bce6e 100644 --- a/packages/editor-core/package.json +++ b/packages/editor-core/package.json @@ -23,8 +23,8 @@ "package.json" ], "scripts": { - "build": "vite build", - "build-dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs", + "build:target": "vite build", + "build:dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs", "test": "vitest", "test:cov": "" }, diff --git a/packages/editor-skeleton/package.json b/packages/editor-skeleton/package.json index 84d19e64d..30ae3a978 100644 --- a/packages/editor-skeleton/package.json +++ b/packages/editor-skeleton/package.json @@ -3,13 +3,13 @@ "version": "2.0.0-beta.0", "description": "alibaba lowcode editor skeleton", "type": "module", - "main": "dist/designer.cjs", - "module": "dist/designer.js", + "main": "dist/editorSkeleton.cjs", + "module": "dist/editorSkeleton.js", "types": "dist/index.d.ts", "exports": { ".": { - "import": "./dist/designer.js", - "require": "./dist/designer.cjs", + "import": "./dist/editorSkeleton.js", + "require": "./dist/editorSkeleton.cjs", "types": "./dist/index.d.ts" } }, @@ -22,8 +22,9 @@ "package.json" ], "scripts": { - "build": "vite build", - "build-dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs", + "build": "pnpm run --stream \"/^build:.*/\"", + "build:target": "vite build", + "build:dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs", "test": "vitest" }, "keywords": [ diff --git a/packages/engine/package.json b/packages/engine/package.json index 38c955eed..4562e36c9 100644 --- a/packages/engine/package.json +++ b/packages/engine/package.json @@ -1,50 +1,45 @@ { "name": "@alilc/lowcode-engine", - "version": "1.3.2", + "version": "2.0.0-beta.0", "description": "An enterprise-class low-code technology stack with scale-out design / 一套面向扩展设计的企业级低代码技术体系", - "main": "lib/engine-core.js", - "module": "es/engine-core.js", + "main": "dist/engine-core.js", + "module": "dist/engine-core.js", "files": [ "dist", "es", "lib" ], "scripts": { - "start": "build-scripts start", "version:update": "node ./scripts/version.js", - "build": "NODE_OPTIONS=--max_old_space_size=8192 build-scripts build", - "build:umd": "NODE_OPTIONS=--max_old_space_size=8192 build-scripts build --config build.umd.json", - "test": "build-scripts test --config build.test.json --jest-passWithNoTests" + "test": "vitest" }, "license": "MIT", "dependencies": { - "@alifd/next": "^1.19.12", - "@alilc/lowcode-designer": "1.3.2", - "@alilc/lowcode-editor-core": "1.3.2", - "@alilc/lowcode-editor-skeleton": "1.3.2", + "@alifd/next": "^1.27.8", + "@alilc/lowcode-designer": "workspace:*", + "@alilc/lowcode-editor-core": "workspace:*", + "@alilc/lowcode-editor-skeleton": "workspace:*", "@alilc/lowcode-engine-ext": "^1.0.0", - "@alilc/lowcode-plugin-command": "1.3.2", - "@alilc/lowcode-plugin-designer": "1.3.2", - "@alilc/lowcode-plugin-outline-pane": "1.3.2", - "@alilc/lowcode-shell": "1.3.2", - "@alilc/lowcode-utils": "1.3.2", - "@alilc/lowcode-workspace": "1.3.2", + "@alilc/lowcode-plugin-command": "workspace:*", + "@alilc/lowcode-plugin-designer": "workspace:*", + "@alilc/lowcode-plugin-outline-pane": "workspace:*", + "@alilc/lowcode-shell": "workspace:*", + "@alilc/lowcode-utils": "workspace:*", + "@alilc/lowcode-workspace": "workspace:*", + "prop-types": "^15.7.2", "react": "^18.2.0", "react-dom": "^18.2.0" }, "devDependencies": { - "@alib/build-scripts": "^0.1.18", "@alifd/theme-lowcode-dark": "^0.2.0", "@alifd/theme-lowcode-light": "^0.2.0", - "@types/domready": "^1.0.0", "@types/react": "^18.2.0", - "@types/react-dom": "^18.2.0", - "build-plugin-fusion": "0.1.17-beta.0", - "build-plugin-moment-locales": "^0.1.0", - "build-plugin-react-app": "^1.8.0", - "fs-extra": "^10.0.0", - "prop-types": "^15.7.2", - "tsconfig-paths-webpack-plugin": "^3.2.0" + "@types/react-dom": "^18.2.0" + }, + "peerDependencies": { + "@alifd/next": "^1.27.8", + "react": "^18.2.0", + "react-dom": "^18.2.0" }, "publishConfig": { "access": "public", diff --git a/packages/engine/tsconfig.json b/packages/engine/tsconfig.json index c37b76ecc..039e0b4d1 100644 --- a/packages/engine/tsconfig.json +++ b/packages/engine/tsconfig.json @@ -1,9 +1,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "outDir": "lib" + "outDir": "dist" }, - "include": [ - "./src/" - ] + "include": ["src"] } diff --git a/packages/plugin-command/package.json b/packages/plugin-command/package.json index 953d0ad09..5bf1e0a39 100644 --- a/packages/plugin-command/package.json +++ b/packages/plugin-command/package.json @@ -25,8 +25,8 @@ "*.css" ], "scripts": { - "build": "vite build", - "build-dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs", + "build:target": "vite build", + "build:dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs", "test": "vitest" }, "bugs": { diff --git a/packages/plugin-designer/package.json b/packages/plugin-designer/package.json index 191ea0144..e01f28f7f 100644 --- a/packages/plugin-designer/package.json +++ b/packages/plugin-designer/package.json @@ -19,8 +19,8 @@ "package.json" ], "scripts": { - "build": "vite build", - "build-dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs", + "build:target": "vite build", + "build:dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs", "test": "vitest" }, "keywords": [ diff --git a/packages/plugin-outline-pane/package.json b/packages/plugin-outline-pane/package.json index f99776ec5..2e3d35520 100644 --- a/packages/plugin-outline-pane/package.json +++ b/packages/plugin-outline-pane/package.json @@ -19,8 +19,8 @@ "package.json" ], "scripts": { - "build": "vite build", - "build-dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs", + "build:target": "vite build", + "build:dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs", "test": "vitest" }, "dependencies": { diff --git a/packages/react-simulator-renderer/babel.config.js b/packages/react-simulator-renderer/babel.config.js deleted file mode 100644 index c5986f2bc..000000000 --- a/packages/react-simulator-renderer/babel.config.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('../../babel.config'); \ No newline at end of file diff --git a/packages/react-simulator-renderer/build.json b/packages/react-simulator-renderer/build.json deleted file mode 100644 index e7ae1dcf7..000000000 --- a/packages/react-simulator-renderer/build.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "plugins": ["@alilc/build-plugin-lce", "./build.plugin.js"] -} diff --git a/packages/react-simulator-renderer/build.plugin.js b/packages/react-simulator-renderer/build.plugin.js deleted file mode 100644 index d613f1f56..000000000 --- a/packages/react-simulator-renderer/build.plugin.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = ({ onGetWebpackConfig }) => { - onGetWebpackConfig((config) => { - config.performance.hints(false); - }); -}; diff --git a/packages/react-simulator-renderer/build.test.json b/packages/react-simulator-renderer/build.test.json deleted file mode 100644 index 9cc30d746..000000000 --- a/packages/react-simulator-renderer/build.test.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "plugins": [ - "@alilc/build-plugin-lce", - "@alilc/lowcode-test-mate/plugin/index.ts" - ] -} diff --git a/packages/react-simulator-renderer/build.umd.json b/packages/react-simulator-renderer/build.umd.json deleted file mode 100644 index 1052bb076..000000000 --- a/packages/react-simulator-renderer/build.umd.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "entry": { - "react-simulator-renderer": "src/index" - }, - "sourceMap": true, - "library": "___ReactSimulatorRenderer___", - "libraryTarget": "umd", - "externals": { - "react": "var window.React", - "react-dom": "var window.ReactDOM", - "prop-types": "var window.PropTypes", - "@alifd/next": "var Next", - "@alilc/lowcode-engine-ext": "var window.AliLowCodeEngineExt", - "moment": "var moment", - "lodash": "var _" - }, - "polyfill": false, - "outputDir": "dist", - "vendor": false, - "ignoreHtmlTemplate": true, - "plugins": [ - "build-plugin-react-app", - [ - "build-plugin-fusion", - { - "externalNext": "umd" - } - ], - [ - "build-plugin-moment-locales", - { - "locales": ["zh-cn"] - } - ], - "./build.plugin.js" - ] -} diff --git a/packages/react-simulator-renderer/jest.config.js b/packages/react-simulator-renderer/jest.config.js deleted file mode 100644 index 5378ef538..000000000 --- a/packages/react-simulator-renderer/jest.config.js +++ /dev/null @@ -1,33 +0,0 @@ -const fs = require('fs'); -const { join } = require('path'); -const esModules = [].join('|'); -const pkgNames = fs.readdirSync(join('..')).filter(pkgName => !pkgName.startsWith('.')); - -const jestConfig = { - // transform: { - // '^.+\\.[jt]sx?$': 'babel-jest', - // // '^.+\\.(ts|tsx)$': 'ts-jest', - // // '^.+\\.(js|jsx)$': 'babel-jest', - // }, - // testMatch: ['**/document/node/node.test.ts'], - // testMatch: ['**/designer/builtin-hotkey.test.ts'], - // testMatch: ['**/plugin/plugin-manager.test.ts'], - // testMatch: ['(/tests?/.*(test))\\.[jt]s$'], - transformIgnorePatterns: [ - `/node_modules/(?!${esModules})/`, - ], - setupFiles: ['./test/utils/host.ts'], - moduleFileExtensions: ['ts', 'tsx', 'js', 'json'], - collectCoverage: true, - collectCoverageFrom: [ - 'src/**/*.ts', - '!src/**/*.d.ts', - '!**/node_modules/**', - ], -}; - -// 只对本仓库内的 pkg 做 mapping -jestConfig.moduleNameMapper = {}; -jestConfig.moduleNameMapper[`^@alilc/lowcode\\-(${pkgNames.join('|')})$`] = '/../$1/src'; - -module.exports = jestConfig; \ No newline at end of file diff --git a/packages/react-simulator-renderer/package.json b/packages/react-simulator-renderer/package.json index 8045f012b..b31b4f6e3 100644 --- a/packages/react-simulator-renderer/package.json +++ b/packages/react-simulator-renderer/package.json @@ -1,39 +1,37 @@ { "name": "@alilc/lowcode-react-simulator-renderer", - "version": "1.3.2", + "version": "2.0.0-beta.0", "description": "react simulator renderer for alibaba lowcode designer", + "type": "module", "main": "lib/index.js", "module": "es/index.js", + "types": "", "license": "MIT", "files": [ - "es", - "lib", - "dist" + "dist", + "src", + "package.json" ], "scripts": { - "test": "build-scripts test --config build.test.json", - "build": "NODE_OPTIONS=--max_old_space_size=8192 build-scripts build", - "build:umd": "NODE_OPTIONS=--max_old_space_size=8192 build-scripts build --config build.umd.json", + "build:target": "vite build", + "build:dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs", + "test": "vitest", "test:cov": "build-scripts test --config build.test.json --jest-coverage" }, "dependencies": { - "@alilc/lowcode-designer": "1.3.2", - "@alilc/lowcode-react-renderer": "1.3.2", - "@alilc/lowcode-types": "1.3.2", - "@alilc/lowcode-utils": "1.3.2", - "classnames": "^2.2.6", - "mobx": "^6.3.0", - "mobx-react": "^7.2.0", + "@alilc/lowcode-designer": "workspace:*", + "@alilc/lowcode-react-renderer": "workspace:*", + "classnames": "^2.5.1", "react": "^18.2.0", "react-dom": "^18.2.0" }, "devDependencies": { - "@alib/build-scripts": "^0.1.18", - "@types/classnames": "^2.2.7", - "@types/node": "^13.7.1", "@types/react": "^18.2.0", - "@types/react-dom": "^18.2.0", - "@types/react-router": "5.1.18" + "@types/react-dom": "^18.2.0" + }, + "peerDependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" }, "publishConfig": { "access": "public", diff --git a/packages/react-simulator-renderer/src/README.md b/packages/react-simulator-renderer/src.bak/README.md similarity index 100% rename from packages/react-simulator-renderer/src/README.md rename to packages/react-simulator-renderer/src.bak/README.md diff --git a/packages/react-simulator-renderer/src/builtin-components/builtin-components.ts b/packages/react-simulator-renderer/src.bak/builtin-components/builtin-components.ts similarity index 100% rename from packages/react-simulator-renderer/src/builtin-components/builtin-components.ts rename to packages/react-simulator-renderer/src.bak/builtin-components/builtin-components.ts diff --git a/packages/react-simulator-renderer/src/builtin-components/leaf.tsx b/packages/react-simulator-renderer/src.bak/builtin-components/leaf.tsx similarity index 100% rename from packages/react-simulator-renderer/src/builtin-components/leaf.tsx rename to packages/react-simulator-renderer/src.bak/builtin-components/leaf.tsx diff --git a/packages/react-simulator-renderer/src/builtin-components/slot.tsx b/packages/react-simulator-renderer/src.bak/builtin-components/slot.tsx similarity index 100% rename from packages/react-simulator-renderer/src/builtin-components/slot.tsx rename to packages/react-simulator-renderer/src.bak/builtin-components/slot.tsx diff --git a/packages/react-simulator-renderer/src/host.ts b/packages/react-simulator-renderer/src.bak/host.ts similarity index 100% rename from packages/react-simulator-renderer/src/host.ts rename to packages/react-simulator-renderer/src.bak/host.ts diff --git a/packages/react-simulator-renderer/src.bak/index.ts b/packages/react-simulator-renderer/src.bak/index.ts new file mode 100644 index 000000000..5f2ecae78 --- /dev/null +++ b/packages/react-simulator-renderer/src.bak/index.ts @@ -0,0 +1,17 @@ +import { runInAction } from 'mobx'; +import renderer from './renderer'; + +if (typeof window !== 'undefined') { + (window as any).SimulatorRenderer = renderer; +} + +window.addEventListener('beforeunload', () => { + runInAction(() => { + (window as any).LCSimulatorHost = null; + renderer.dispose?.(); + (window as any).SimulatorRenderer = null; + (window as any).ReactDOM.unmountComponentAtNode(document.getElementById('app')); + }); +}); + +export default renderer; diff --git a/packages/react-simulator-renderer/src/locale/en-US.json b/packages/react-simulator-renderer/src.bak/locale/en-US.json similarity index 100% rename from packages/react-simulator-renderer/src/locale/en-US.json rename to packages/react-simulator-renderer/src.bak/locale/en-US.json diff --git a/packages/react-simulator-renderer/src/locale/index.ts b/packages/react-simulator-renderer/src.bak/locale/index.ts similarity index 100% rename from packages/react-simulator-renderer/src/locale/index.ts rename to packages/react-simulator-renderer/src.bak/locale/index.ts diff --git a/packages/react-simulator-renderer/src/locale/zh-CN.json b/packages/react-simulator-renderer/src.bak/locale/zh-CN.json similarity index 100% rename from packages/react-simulator-renderer/src/locale/zh-CN.json rename to packages/react-simulator-renderer/src.bak/locale/zh-CN.json diff --git a/packages/react-simulator-renderer/src/renderer-view.tsx b/packages/react-simulator-renderer/src.bak/renderer-view.tsx similarity index 100% rename from packages/react-simulator-renderer/src/renderer-view.tsx rename to packages/react-simulator-renderer/src.bak/renderer-view.tsx diff --git a/packages/react-simulator-renderer/src/renderer.less b/packages/react-simulator-renderer/src.bak/renderer.less similarity index 100% rename from packages/react-simulator-renderer/src/renderer.less rename to packages/react-simulator-renderer/src.bak/renderer.less diff --git a/packages/react-simulator-renderer/src/renderer.ts b/packages/react-simulator-renderer/src.bak/renderer.ts similarity index 100% rename from packages/react-simulator-renderer/src/renderer.ts rename to packages/react-simulator-renderer/src.bak/renderer.ts diff --git a/packages/react-simulator-renderer/src/utils/get-client-rects.ts b/packages/react-simulator-renderer/src.bak/utils/get-client-rects.ts similarity index 100% rename from packages/react-simulator-renderer/src/utils/get-client-rects.ts rename to packages/react-simulator-renderer/src.bak/utils/get-client-rects.ts diff --git a/packages/react-simulator-renderer/src/utils/is-dom-node.ts b/packages/react-simulator-renderer/src.bak/utils/is-dom-node.ts similarity index 100% rename from packages/react-simulator-renderer/src/utils/is-dom-node.ts rename to packages/react-simulator-renderer/src.bak/utils/is-dom-node.ts diff --git a/packages/react-simulator-renderer/src/utils/misc.ts b/packages/react-simulator-renderer/src.bak/utils/misc.ts similarity index 100% rename from packages/react-simulator-renderer/src/utils/misc.ts rename to packages/react-simulator-renderer/src.bak/utils/misc.ts diff --git a/packages/react-simulator-renderer/src/utils/react-find-dom-nodes.ts b/packages/react-simulator-renderer/src.bak/utils/react-find-dom-nodes.ts similarity index 100% rename from packages/react-simulator-renderer/src/utils/react-find-dom-nodes.ts rename to packages/react-simulator-renderer/src.bak/utils/react-find-dom-nodes.ts diff --git a/packages/react-simulator-renderer/src/utils/url.ts b/packages/react-simulator-renderer/src.bak/utils/url.ts similarity index 100% rename from packages/react-simulator-renderer/src/utils/url.ts rename to packages/react-simulator-renderer/src.bak/utils/url.ts diff --git a/packages/react-simulator-renderer/src/index.ts b/packages/react-simulator-renderer/src/index.ts index 5f2ecae78..e69de29bb 100644 --- a/packages/react-simulator-renderer/src/index.ts +++ b/packages/react-simulator-renderer/src/index.ts @@ -1,17 +0,0 @@ -import { runInAction } from 'mobx'; -import renderer from './renderer'; - -if (typeof window !== 'undefined') { - (window as any).SimulatorRenderer = renderer; -} - -window.addEventListener('beforeunload', () => { - runInAction(() => { - (window as any).LCSimulatorHost = null; - renderer.dispose?.(); - (window as any).SimulatorRenderer = null; - (window as any).ReactDOM.unmountComponentAtNode(document.getElementById('app')); - }); -}); - -export default renderer; diff --git a/packages/react-simulator-renderer/vite.config.ts b/packages/react-simulator-renderer/vite.config.ts new file mode 100644 index 000000000..94a43d655 --- /dev/null +++ b/packages/react-simulator-renderer/vite.config.ts @@ -0,0 +1,30 @@ +import { defineConfig } from 'vite'; +import { resolve } from 'node:path'; +import react from '@vitejs/plugin-react'; +import { devDependencies, peerDependencies } from './package.json'; + +const externals = [...Object.keys(devDependencies), ...Object.keys(peerDependencies)]; + +export default defineConfig({ + build: { + lib: { + // Could also be a dictionary or array of multiple entry points + entry: resolve(import.meta.dirname, 'src/index.ts'), + name: 'LowCodeSimulatorReactRenderer', + formats: ['es', 'cjs', 'iife'], + // the proper extensions will be added + fileName: 'SimulatorReactRenderer', + }, + rollupOptions: { + external: externals, + output: { + // for UMD + globals: { + react: 'React', + 'react-dom': 'ReactDOM', + }, + }, + }, + }, + plugins: [react()], +}); diff --git a/packages/react-simulator-renderer/vitest.config.ts b/packages/react-simulator-renderer/vitest.config.ts new file mode 100644 index 000000000..e69de29bb diff --git a/packages/renderer-core/package.json b/packages/renderer-core/package.json index 7c364e87a..e1f5fbd91 100644 --- a/packages/renderer-core/package.json +++ b/packages/renderer-core/package.json @@ -21,8 +21,8 @@ "package.json" ], "scripts": { - "build": "vite build", - "build-dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs", + "build:target": "vite build", + "build:dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs", "test": "vitest --run", "test:watch": "vitest" }, diff --git a/packages/renderer-react/package.json b/packages/renderer-react/package.json index d32e3fe87..75f6987a6 100644 --- a/packages/renderer-react/package.json +++ b/packages/renderer-react/package.json @@ -17,8 +17,8 @@ } }, "scripts": { - "build": "vite build", - "build-dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs", + "build:target": "vite build", + "build:dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs", "test": "vitest" }, "dependencies": { diff --git a/packages/renderer-react/vite.config.ts b/packages/renderer-react/vite.config.ts index c63c91f89..54a512669 100644 --- a/packages/renderer-react/vite.config.ts +++ b/packages/renderer-react/vite.config.ts @@ -10,10 +10,10 @@ export default defineConfig({ lib: { // Could also be a dictionary or array of multiple entry points entry: resolve(import.meta.dirname, 'src/index.ts'), - name: 'LowCodeRendererCore', + name: 'LowCodeReactRenderer', formats: ['es', 'cjs', 'iife'], // the proper extensions will be added - fileName: 'rendererReact', + fileName: 'reactRenderer', }, rollupOptions: { external: externals, diff --git a/packages/renderer-router/package.json b/packages/renderer-router/package.json index 3a92412e4..e17067d78 100644 --- a/packages/renderer-router/package.json +++ b/packages/renderer-router/package.json @@ -15,8 +15,8 @@ } }, "scripts": { - "build": "vite build", - "build-dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs", + "build:target": "vite build", + "build:dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs", "test": "vitest" }, "dependencies": { diff --git a/packages/shell/package.json b/packages/shell/package.json index 6dd9a743c..c87b74ce8 100644 --- a/packages/shell/package.json +++ b/packages/shell/package.json @@ -10,8 +10,8 @@ "es" ], "scripts": { - "build": "vite build", - "build-dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs", + "build:target": "vite build", + "build:dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs", "test": "vitest" }, "license": "MIT", diff --git a/packages/shell/src/api/material.ts b/packages/shell/src/api/material.ts index 284b88fbb..9c0ae73ab 100644 --- a/packages/shell/src/api/material.ts +++ b/packages/shell/src/api/material.ts @@ -1,8 +1,5 @@ import { globalContext } from '@alilc/lowcode-editor-core'; -import { - IDesigner, - isComponentMeta, -} from '@alilc/lowcode-designer'; +import { IDesigner, isComponentMeta } from '@alilc/lowcode-designer'; import { IPublicTypeAssetsJson, getLogger } from '@alilc/lowcode-utils'; import { IPublicTypeComponentAction, @@ -47,7 +44,10 @@ export class Material implements IPublicApiMaterial { return this[editorSymbol].get('designer')!; } - constructor(editor: IPublicModelEditor, readonly workspaceMode: boolean = false) { + constructor( + editor: IPublicModelEditor, + readonly workspaceMode: boolean = false, + ) { this[innerEditorSymbol] = editor; } @@ -176,9 +176,9 @@ export class Material implements IPublicApiMaterial { * @param handle */ modifyBuiltinComponentAction( - actionName: string, - handle: (action: IPublicTypeComponentAction) => void, - ) { + actionName: string, + handle: (action: IPublicTypeComponentAction) => void, + ) { this[designerSymbol].componentActions.modifyBuiltinComponentAction(actionName, handle); } @@ -195,7 +195,7 @@ export class Material implements IPublicApiMaterial { ]; return () => { - dispose.forEach(d => d && d()); + dispose.forEach((d) => d && d()); }; } @@ -207,7 +207,9 @@ export class Material implements IPublicApiMaterial { this[designerSymbol].contextMenuActions.removeMenuAction(name); } - adjustContextMenuLayout(fn: (actions: IPublicTypeContextMenuItem[]) => IPublicTypeContextMenuItem[]) { + adjustContextMenuLayout( + fn: (actions: IPublicTypeContextMenuItem[]) => IPublicTypeContextMenuItem[], + ) { this[designerSymbol].contextMenuActions.adjustMenuLayout(fn); } } diff --git a/packages/types/package.json b/packages/types/package.json index 1c11110f1..f3edf6eb8 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -20,8 +20,8 @@ "package.json" ], "scripts": { - "build": "vite build", - "build-dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs", + "build:target": "vite build", + "build:dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs", "test": "vitest" }, "dependencies": { diff --git a/packages/utils/package.json b/packages/utils/package.json index eee08b245..08563f981 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -22,8 +22,8 @@ "package.json" ], "scripts": { - "build": "vite build", - "build-dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs", + "build:target": "vite build", + "build:dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs", "test": "vitest" }, "dependencies": { diff --git a/packages/workspace/package.json b/packages/workspace/package.json index 37a8cf49e..56b9cdb6b 100644 --- a/packages/workspace/package.json +++ b/packages/workspace/package.json @@ -15,7 +15,9 @@ "package.json" ], "scripts": { - "build": "vite build", + "build": "pnpm run \"/^build:.*/\"", + "build:target": "vite build", + "build:dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs", "test": "vitest", "test:cov": "" }, diff --git a/scripts/build.sh b/scripts/build.sh deleted file mode 100755 index 751e9094f..000000000 --- a/scripts/build.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -set -e - -lerna run build \ - --scope @alilc/lowcode-types \ - --scope @alilc/lowcode-utils \ - --scope @alilc/lowcode-shell \ - --scope @alilc/lowcode-editor-core \ - --scope @alilc/lowcode-editor-skeleton \ - --scope @alilc/lowcode-designer \ - --scope @alilc/lowcode-plugin-designer \ - --scope @alilc/lowcode-plugin-command \ - --scope @alilc/lowcode-plugin-outline-pane \ - --scope @alilc/lowcode-react-renderer \ - --scope @alilc/lowcode-react-simulator-renderer \ - --scope @alilc/lowcode-renderer-core \ - --scope @alilc/lowcode-workspace \ - --scope @alilc/lowcode-engine \ - --stream - -lerna run build:umd \ - --scope @alilc/lowcode-engine \ - --scope @alilc/lowcode-react-simulator-renderer \ - --scope @alilc/lowcode-react-renderer \ - --stream - -cp ./packages/react-simulator-renderer/dist/js/* ./packages/engine/dist/js/ -cp ./packages/react-simulator-renderer/dist/css/* ./packages/engine/dist/css/ diff --git a/scripts/dev.mjs b/scripts/dev.mjs new file mode 100644 index 000000000..e69de29bb