From 25ed0c59979f72a19681477dcf829699a64baa45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A9=98=E7=9A=AE?= Date: Tue, 15 Mar 2022 09:38:38 +0800 Subject: [PATCH 001/169] Update popup.tsx fix: update http to https --- packages/plugin-manual/src/popup.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/plugin-manual/src/popup.tsx b/packages/plugin-manual/src/popup.tsx index e04d9bc..a24981c 100644 --- a/packages/plugin-manual/src/popup.tsx +++ b/packages/plugin-manual/src/popup.tsx @@ -12,7 +12,7 @@ export function Documents() { useEffect(() => { setLoading(true) - fetch('http://lowcode-engine.cn/api/get_usage') + fetch('https://lowcode-engine.cn/api/get_usage') .then((res) => res.json()) .then((val) => { const menu = val.data.filter((a: any) => !isNaN(parseInt(a.title))) @@ -58,7 +58,7 @@ export function Documents() { )} onClick={() => { - window.open('http://lowcode-engine.cn/doc') + window.open('https://lowcode-engine.cn/doc') }} /> )} onClick={() => { - window.open('http://lowcode-engine.cn/doc?url=engine-ext-changelog') + window.open('https://lowcode-engine.cn/doc?url=engine-ext-changelog') }} /> Date: Sat, 26 Mar 2022 14:38:07 +0800 Subject: [PATCH 002/169] =?UTF-8?q?fix:=20=F0=9F=90=9B=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=95=B0=E6=8D=AE=E6=BA=90=E5=8F=82=E6=95=B0=E8=8B=A5?= =?UTF-8?q?=E5=B9=B2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Closes: #127 --- demo/build.json | 38 +++ demo/build.plugin.js | 58 +++++ demo/package.json | 45 ++++ demo/public/assets.json | 139 +++++++++++ demo/public/favicon.png | Bin 0 -> 3612 bytes demo/public/index.html | 41 ++++ demo/public/mock-pages.json | 1 + demo/public/mock/info.json | 3 + demo/public/preview.html | 25 ++ demo/public/schema.json | 291 +++++++++++++++++++++++ demo/src/index.ts | 36 +++ demo/src/preview.tsx | 63 +++++ demo/src/sample-plugins/logo/index.scss | 11 + demo/src/sample-plugins/logo/index.tsx | 18 ++ demo/src/setters/behavior-setter.tsx | 27 +++ demo/src/setters/custom-setter.tsx | 12 + demo/src/universal/global.scss | 55 +++++ demo/src/universal/plugin.tsx | 272 +++++++++++++++++++++ demo/src/universal/utils.ts | 298 ++++++++++++++++++++++++ demo/tsconfig.json | 44 ++++ 20 files changed, 1477 insertions(+) create mode 100644 demo/build.json create mode 100644 demo/build.plugin.js create mode 100644 demo/package.json create mode 100644 demo/public/assets.json create mode 100644 demo/public/favicon.png create mode 100644 demo/public/index.html create mode 100644 demo/public/mock-pages.json create mode 100644 demo/public/mock/info.json create mode 100644 demo/public/preview.html create mode 100644 demo/public/schema.json create mode 100644 demo/src/index.ts create mode 100644 demo/src/preview.tsx create mode 100644 demo/src/sample-plugins/logo/index.scss create mode 100644 demo/src/sample-plugins/logo/index.tsx create mode 100644 demo/src/setters/behavior-setter.tsx create mode 100644 demo/src/setters/custom-setter.tsx create mode 100644 demo/src/universal/global.scss create mode 100644 demo/src/universal/plugin.tsx create mode 100644 demo/src/universal/utils.ts create mode 100644 demo/tsconfig.json diff --git a/demo/build.json b/demo/build.json new file mode 100644 index 0000000..11f88e5 --- /dev/null +++ b/demo/build.json @@ -0,0 +1,38 @@ +{ + "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 new file mode 100644 index 0000000..12882de --- /dev/null +++ b/demo/build.plugin.js @@ -0,0 +1,58 @@ +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 new file mode 100644 index 0000000..6d61e11 --- /dev/null +++ b/demo/package.json @@ -0,0 +1,45 @@ +{ + "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/assets.json b/demo/public/assets.json new file mode 100644 index 0000000..3cd9173 --- /dev/null +++ b/demo/public/assets.json @@ -0,0 +1,139 @@ +{ + "packages": [ + { + "package": "moment", + "version": "2.24.0", + "urls": [ + "https://g.alicdn.com/mylib/moment/2.24.0/min/moment.min.js" + ], + "library": "moment" + }, + { + "package": "lodash", + "library": "_", + "urls": [ + "https://g.alicdn.com/platform/c/lodash/4.6.1/lodash.min.js" + ] + }, + { + "title": "fusion组件库", + "package": "@alifd/next", + "version": "1.24.18", + "urls": [ + "https://g.alicdn.com/code/lib/alifd__next/1.24.18/next.min.css", + "https://g.alicdn.com/code/lib/alifd__next/1.24.18/next-with-locales.min.js" + ], + "library": "Next" + }, + { + "title": "NextTable", + "package": "NextTable", + "version": "1.0.1", + "urls": [ + "https://g.alicdn.com/fusion-platform/pro-table/1.0.1/next-table.js", + "https://g.alicdn.com/fusion-platform/pro-table/1.0.1/next-table.css" + ], + "library": "NextTable" + }, + { + "package": "@alilc/lowcode-materials", + "version": "1.0.2-beta.1", + "library": "AlilcLowcodeMaterials", + "urls": [ + "https://alifd.alicdn.com/npm/@alilc/lowcode-materials@1.0.2-beta.1/dist/AlilcLowcodeMaterials.js", + "https://alifd.alicdn.com/npm/@alilc/lowcode-materials@1.0.2-beta.1/dist/AlilcLowcodeMaterials.css" + ], + "editUrls": [ + "https://alifd.alicdn.com/npm/@alilc/lowcode-materials@1.0.2-beta.1/build/lowcode/view.js", + "https://alifd.alicdn.com/npm/@alilc/lowcode-materials@1.0.2-beta.1/build/lowcode/view.css" + ] + }, + { + "package": "@alifd/pro-layout", + "version": "1.0.1-beta.6", + "library": "AlifdProLayout", + "urls": [ + "https://alifd.alicdn.com/npm/@alifd/pro-layout@1.0.1-beta.6/dist/AlifdProLayout.js", + "https://alifd.alicdn.com/npm/@alifd/pro-layout@1.0.1-beta.6/dist/AlifdProLayout.css" + ], + "editUrls": [ + "https://alifd.alicdn.com/npm/@alifd/pro-layout@1.0.1-beta.6/build/lowcode/view.js", + "https://alifd.alicdn.com/npm/@alifd/pro-layout@1.0.1-beta.6/build/lowcode/view.css" + ] + }, + { + "package": "@alifd/fusion-ui", + "version": "1.0.5-beta.1", + "library": "AlifdFusionUi", + "urls": [ + "https://alifd.alicdn.com/npm/@alifd/fusion-ui@1.0.5-beta.1/dist/AlifdFusionUi.js", + "https://alifd.alicdn.com/npm/@alifd/fusion-ui@1.0.5-beta.1/dist/AlifdFusionUi.css" + ], + "editUrls": [ + "https://alifd.alicdn.com/npm/@alifd/fusion-ui@1.0.5-beta.1/build/lowcode/view.js", + "https://alifd.alicdn.com/npm/@alifd/fusion-ui@1.0.5-beta.1/build/lowcode/view.css" + ] + } + ], + "components": [ + { + "exportName": "AlilcLowcodeMaterialsMeta", + "npm": { + "package": "@alilc/lowcode-materials" + }, + "url": "https://alifd.alicdn.com/npm/@alilc/lowcode-materials@1.0.2-beta.1/build/lowcode/meta.js", + "urls": { + "default": "https://alifd.alicdn.com/npm/@alilc/lowcode-materials@1.0.2-beta.1/build/lowcode/meta.js", + "design": "https://alifd.alicdn.com/npm/@alilc/lowcode-materials@1.0.2-beta.1/build/lowcode/meta.design.js" + } + }, + { + "exportName": "AlifdProLayoutMeta", + "npm": { + "package": "@alifd/pro-layout", + "version": "1.0.1-beta.6" + }, + "url": "https://alifd.alicdn.com/npm/@alifd/pro-layout@1.0.1-beta.6/build/lowcode/meta.js", + "urls": { + "default": "https://alifd.alicdn.com/npm/@alifd/pro-layout@1.0.1-beta.6/build/lowcode/meta.js", + "design": "https://alifd.alicdn.com/npm/@alifd/pro-layout@1.0.1-beta.6/build/lowcode/meta.design.js" + } + }, + { + "exportName": "AlifdFusionUiMeta", + "npm": { + "package": "@alifd/fusion-ui" + }, + "url": "https://alifd.alicdn.com/npm/@alifd/fusion-ui@1.0.5-beta.1/build/lowcode/meta.js", + "urls": { + "default": "https://alifd.alicdn.com/npm/@alifd/fusion-ui@1.0.5-beta.1/build/lowcode/meta.js", + "design": "https://alifd.alicdn.com/npm/@alifd/fusion-ui@1.0.5-beta.1/build/lowcode/meta.design.js" + } + } + ], + "sort": { + "groupList": [ + "精选组件", + "原子组件" + ], + "categoryList": [ + "基础元素", + "布局容器类", + "表格类", + "表单详情类", + "帮助类", + "对话框类", + "业务类", + "通用", + "引导", + "信息输入", + "信息展示", + "信息反馈" + ] + }, + "groupList": [ + "精选组件", + "原子组件" + ], + "ignoreComponents": {} +} diff --git a/demo/public/favicon.png b/demo/public/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..307ffbd82dba398d6db6459102bff331eef7df6b GIT binary patch literal 3612 zcmV+%4&(8OP)Px#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR91TA%{}1ONa40RR91S^xk507-m{w*UYQhDk(0RCodHT?>#D#Towp*}H|i z+dTn!mde8i1wu-BR8XSvS)#mzvO>hDgg^x>qli)9_Kq+LcPJ3Bu+SK-ynID85>dgJ zf)ItMP%%POG)f4F%3HbJz2lbM?R>q<9(%hpvoo`^$1F!z?agfW|Ns5>H@$y%|NT!N z)9I8O0kys}9V_WeB7QCjaV`-)%ss()2JZ3U%EY}OCKh25^exJF;@jsa+eD=m&vNcs z+8Bi@I#8tHdjNF^fEtX}4+gmB!oBs2;z-h|Ic09)=5q&i}FecJ(A2&TE=5fm5G(0gxyZEdH6iu2h_ zJ5PO}Rndte;mJhtI{@%`&ZB5b;y0%*&~w8>C>pyHqyEk4y=A80C>Rkpo_d2}APn0Z z`vpM$ZW1@AMzs8%!l?uF-0&cZ#+Q(YU7a5!1>j~nT>L<*4QEp%S__bGgNbmbDHL?D zc!5q%(PmRq>|XRi*kE^<2+iLE7c0;;;j#2>=t+RvRkLC4%RE$EJ$gCjzI#K9DHglS zeOMZ5R79pjJ=zx_zkpTT#fD9CW1*mZ$u+$jl}p#DIy8xzBJUR^$g&*@ZFlD=odQ`E zK8ge%$2fOuDyulJJixs`2f{tzOEWnqjtV>cMgWq9ydk)0#$pb)OGC2 zyd5S;I^_@Jm(l@C^gfV%VZr9$OrMgxyy6}LKnkatcPA59cwD{W7OGqAKlB1Ib~J_y8w|V z(BsGFq%}`aO$#gQ+ynI7-~fuz1~k&So~-aRs`dZcJSL!&e(UPcGF)d^;?pO-3_x#k z&U92aoJAbJ4vzIcP_j3Es=aY-kL$P40h^Wh2!VU$OZ3`ZRN~o1W#zjmz=tRh9t>Z_ z>u9BOATvK;8Dt3-vw)s60d`MZ^Xu76A?oGdoDeJj*iI_;)*=lf;8d5p7NY@_$GR+x z$|Opy^BHmQR*dw6F$l$ts0_#@IJscGzkIqrLKORm9_ zztJAZQU#|$hDhewd4Vj|Qn?=J)XH1ii4{5CB$7R#tLn#5{1{ehG&Cj1HCN`ZskY)x zNAxN6{RU61$+j$o*QI!^104v>1oNuo95f}yRoB%CJL`l>Du*EE@3urSA0SWp))cQb zpaUV;W3eQ~?9yvu-s+fcEdFg%)=TN;%RJEP(ep7|cpmoHJdaHc^I{X?i@f-=n3a85 zS!ObXcs`xX9B8WWV&(KQ7(1pjyYk-Su|Lz$YLKuK|G|5x&c88ToH?K)p(>b+@1!%j z_FlxhJE|Mg*_P$8cp-C~$PIK&us+@u)9l)7QFbbQk(&@iM-USUU$Y~z z(@$d;<#r>8PM8k)(u@$+wtb8wySYs6ehcd55XeDd&+J^yJpuH=@H`NopNrvic?JTk z%%{4FuQPJ9z9#3<~?2N zQD&F{Spucd2jL%~HxD_DnneVdUZn+?!I(_2(c-5jX-|`-5MaW_ZRw2ES2I@$^hIU} zPt&9!Ab1KbDBGEqlk--=G$*Ga&ncx%5%6+a=zqy-ljZbolU1fROV6|!fjRfvX}^Nu z@L{+EUHnRuon{q;=NsbE3E0_=*pZG{oXU-`)6=llkJ=H?Hh9nx70)E9E!$9Bm&2;z=LrvB2-VO*34&C5jyZdzE$Q1+DZ*F{8q%WHYTlza1|{p z3#rcMNCdzMr;-yb^p<}J(-U(-)Jd1Yw9F}xWm}vDT8_vpcAs>R@>M{-j!{=>V+UNn zVrPL))WiSMudWD6n4hCs-_M-Zv;aWkJ(QwNa!bm0M`k#e6V0&4E`?wy@F}co(!2pRl&bu%6DZ}elcXU z^H%`u2B%du)uRQi#7jV-XHofakfj=lqa){QDx`?zn)$_$8ExuO2sLv8odkKy)2Muc zh61+;3S=u*Te%7gns+tm-Jc~Q+3j&aYeS%6E>OPZcj&znwd;~mrcoSurjb0#beNV# zjS_cf#o5{T>f^1|1v&|G__qN0R%2wubU{nYvS{Y}wjy8!zLO$LOs&_W@#-iBNjdNd z!=R8PgyKx1y^}TJto1#OsgewqES|*FIz2iG@+=uhqYa)GWL@?y6rHA?tyM(5eDZa< z)tY5)%#4e|_vqswBO+2vHHATkZ-{QjI63hTl{9Gc22CCr^HAp>2Q%_uQOvKIr6P=(QnL6x-x1jUm>r*5A3!InnSvDC$&IC3sHSD&_svj zDiL7kND|}`YvA{bXA_n;Fb)03O40qti8uPQ36P`m;e;c-lfM@>4ekNxZ@Ft4h+{1Z zkR-UxNzkkXI1-||IV1Dtyw7lcIL0+t0>iZDoEWVeGm?)y_NF0Ss_+S%aImLwFm`W- zvlo+-HX+xPp1~GY%sTSVjPcA0FY%XasxeJ z+g%C3?6$dG6VY{R+ta|UnEHkH2)ciBY>OL-nU?~%Wok1G@Miq5B zX!tM;xRXV3u)lsIQP7`8D&!!057B-MzI1n5!HHWOZjB(G)=BcT#g0BK)(V%5f$q6; zN?uhU&G{i*9dOdD*b1ju;#cE<$< z0&o(5UJ~32rh|9mS92|??LXI3!>N2-psAr`9xBN>{nJ$BSSisfSc&gAU$gjlCVU?4 z^nb1jOh-WzZ-Drrg|y4*>g$`1PKQRN6PmscV+Qx?c$nXA1}q$ejlP~~!A@NwdCFEn z5>6gaxCa0FZYkUW8h(U=RH{7~iaSfbPo4%KW-;xD&-^tEe4+G#FH1%UIX5sZc_*tR zJtJNK)4}{cdFXbU@6$I~={h)guWdTQzH2Sj!4xH-JVGx{jO73sD=r?%w0Kia`Dd0n zXF6o;xAb9neZy$JztusOZPfZV8PepGabK+9{gy0CdE9B`g}50qGU8c zep{a=tt5F2F&<2wNgmA2%B2ZM5f04GQ<`mdZ5!P=@-pr7?xNC2uNIPV!V&#`cUPJHzcr5%K8(PTA^(8r%Hd@r^OOPu)!m&GEUkz-rMJJ8ESi2>fK*KG6 zRLqJD$JrH+K=37)0&Pd%UrnU|cQL`MrkCJrPI~*&2xKGqMnp8NOUpEOo0#H>mJizu zC-Wz8NKKXJHk%=D4H`|LWyQRRzQSdKMJ3jP{?0TWI67!NK>ll5p7~oAU*RDSG0l*$ z#k7dJ`5x3ea>ukRhY59owpUNZ985VX!Fvln*d zf&lGk3j)CjFdxqWOzD7XnV2`?o$RT!p#7&U3*7h3{Xk31 + + + + + + Codestin Search App + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + diff --git a/demo/public/mock-pages.json b/demo/public/mock-pages.json new file mode 100644 index 0000000..8e20f2f --- /dev/null +++ b/demo/public/mock-pages.json @@ -0,0 +1 @@ +{"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 new file mode 100644 index 0000000..006209b --- /dev/null +++ b/demo/public/mock/info.json @@ -0,0 +1,3 @@ +{ + "info": "Hello AliLowCode!!" +} \ No newline at end of file diff --git a/demo/public/preview.html b/demo/public/preview.html new file mode 100644 index 0000000..798b156 --- /dev/null +++ b/demo/public/preview.html @@ -0,0 +1,25 @@ + + + + + + Codestin Search App + + + + +
+ + + + + + + + + + diff --git a/demo/public/schema.json b/demo/public/schema.json new file mode 100644 index 0000000..4877ead --- /dev/null +++ b/demo/public/schema.json @@ -0,0 +1,291 @@ +{ + "componentName": "Page", + "id": "node_dockcviv8fo1", + "props": { + "ref": "outerView", + "style": { + "height": "100%" + } + }, + "fileName": "/", + "dataSource": { + "list": [ + { + "type": "fetch", + "isInit": true, + "options": { + "params": {}, + "method": "GET", + "isCors": true, + "timeout": 5000, + "headers": {}, + "uri": "mock/info.json" + }, + "id": "info" + } + ] + }, + "state": { + "text": { + "type": "JSExpression", + "value": "\"outer\"" + }, + "isShowDialog": { + "type": "JSExpression", + "value": "false" + } + }, + "css": "body {\n font-size: 12px;\n}\n\n.button {\n width: 100px;\n color: #ff00ff\n}", + "lifeCycles": { + "componentDidMount": { + "type": "JSFunction", + "value": "function componentDidMount() {\n console.log('did mount');\n}" + }, + "componentWillUnmount": { + "type": "JSFunction", + "value": "function componentWillUnmount() {\n console.log('will unmount');\n}" + } + }, + "methods": { + "testFunc": { + "type": "JSFunction", + "value": "function testFunc() {\n console.log('test func');\n}" + }, + "onClick": { + "type": "JSFunction", + "value": "function onClick() {\n this.setState({\n isShowDialog: true\n });\n}" + }, + "closeDialog": { + "type": "JSFunction", + "value": "function closeDialog() {\n this.setState({\n isShowDialog: false\n });\n}" + } + }, + "originCode": "class LowcodeComponent extends Component {\n state = {\n \"text\": \"outer\",\n \"isShowDialog\": false\n }\n componentDidMount() {\n console.log('did mount');\n }\n componentWillUnmount() {\n console.log('will unmount');\n }\n testFunc() {\n console.log('test func');\n }\n onClick() {\n this.setState({\n isShowDialog: true\n })\n }\n closeDialog() {\n this.setState({\n isShowDialog: false\n })\n }\n}", + "hidden": false, + "title": "", + "isLocked": false, + "condition": true, + "conditionGroup": "", + "children": [ + { + "componentName": "NextPage", + "id": "node_ockzs2vw431", + "props": { + "headerDivider": true, + "minHeight": "100vh", + "presetNav": true, + "presetAside": true, + "footer": false, + "nav": false, + "aside": false, + "placeholderStyle": { + "gridRowEnd": "span 1", + "gridColumnEnd": "span 12" + }, + "headerProps": { + "background": "surface" + }, + "header": { + "type": "JSSlot", + "value": [ + { + "componentName": "NextPageHeader", + "id": "node_ockzs2vw433", + "props": {}, + "title": "页面头部", + "hidden": false, + "isLocked": false, + "condition": true, + "conditionGroup": "", + "children": [ + { + "componentName": "NextRowColContainer", + "id": "node_ockzs2vw434", + "props": { + "rowGap": 20, + "colGap": 20 + }, + "title": "行列容器", + "hidden": false, + "isLocked": false, + "condition": true, + "conditionGroup": "", + "children": [ + { + "componentName": "NextRow", + "id": "node_ockzs2vw435", + "props": {}, + "title": "行", + "hidden": false, + "isLocked": false, + "condition": true, + "conditionGroup": "", + "children": [ + { + "componentName": "NextCol", + "id": "node_ockzs2vw436", + "props": { + "colSpan": 1 + }, + "title": "列", + "hidden": false, + "isLocked": false, + "condition": true, + "conditionGroup": "", + "children": [ + { + "componentName": "NextP", + "id": "node_ockzvfoetv17", + "props": { + "wrap": false, + "type": "body2", + "verAlign": "middle", + "textSpacing": true, + "align": "left" + }, + "docId": "dockzvfoetv", + "title": "段落", + "hidden": false, + "isLocked": false, + "condition": true, + "conditionGroup": "", + "children": [ + { + "componentName": "NextText", + "id": "node_ockzvfoetv18", + "props": { + "type": "h5", + "children": { + "type": "JSExpression", + "value": "this.state.info?.info", + "mock": "标题标题" + }, + "mark": false, + "code": false, + "delete": false, + "underline": false, + "strong": false + }, + "docId": "dockzvfoetv", + "hidden": false, + "title": "", + "isLocked": false, + "condition": true, + "conditionGroup": "" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ], + "title": "header" + }, + "isTab": false, + "contentAlignCenter": false, + "contentProps": { + "style": { + "background": "rgba(255,255,255,0)" + } + } + }, + "title": "页面", + "hidden": false, + "isLocked": false, + "condition": true, + "conditionGroup": "", + "children": [ + { + "componentName": "NextBlock", + "id": "node_ockzs2vw437", + "props": { + "placeholderStyle": { + "height": "100%" + }, + "noPadding": false, + "noBorder": false, + "title": "区域标题", + "rowGap": 20, + "colGap": 20, + "background": "surface", + "layoutmode": "O", + "strict": true, + "colSpan": 12, + "rowSpan": 1, + "mode": "transparent", + "childTotalColumns": 12 + }, + "title": "区域", + "hidden": false, + "isLocked": false, + "condition": true, + "conditionGroup": "", + "children": [ + { + "componentName": "NextBlockCell", + "id": "node_ockzs2vw438", + "props": { + "colSpan": 12, + "rowSpan": 1, + "mode": "procard", + "isAutoContainer": true, + "title": "区块标题" + }, + "hidden": false, + "title": "", + "isLocked": false, + "condition": true, + "conditionGroup": "", + "children": [ + { + "componentName": "NextRowColContainer", + "id": "node_ockzs2vw439", + "props": { + "rowGap": 20, + "colGap": 20 + }, + "title": "行列容器", + "hidden": false, + "isLocked": false, + "condition": true, + "conditionGroup": "", + "children": [ + { + "componentName": "NextRow", + "id": "node_ockzs2vw43a", + "props": {}, + "title": "行", + "hidden": false, + "isLocked": false, + "condition": true, + "conditionGroup": "", + "children": [ + { + "componentName": "NextCol", + "id": "node_ockzs2vw43b", + "props": { + "colSpan": 1 + }, + "title": "列", + "hidden": false, + "isLocked": false, + "condition": true, + "conditionGroup": "" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/demo/src/index.ts b/demo/src/index.ts new file mode 100644 index 0000000..d0d58c3 --- /dev/null +++ b/demo/src/index.ts @@ -0,0 +1,36 @@ +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 new file mode 100644 index 0000000..27627ff --- /dev/null +++ b/demo/src/preview.tsx @@ -0,0 +1,63 @@ +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/sample-plugins/logo/index.scss b/demo/src/sample-plugins/logo/index.scss new file mode 100644 index 0000000..3140ac3 --- /dev/null +++ b/demo/src/sample-plugins/logo/index.scss @@ -0,0 +1,11 @@ +.lowcode-plugin-logo { + .logo { + display: block; + width: 139px; + height: 26px; + cursor: pointer; + background-size: contain; + background-position: center; + background-repeat: no-repeat; + } +} diff --git a/demo/src/sample-plugins/logo/index.tsx b/demo/src/sample-plugins/logo/index.tsx new file mode 100644 index 0000000..ff4bbe2 --- /dev/null +++ b/demo/src/sample-plugins/logo/index.tsx @@ -0,0 +1,18 @@ +import React from 'react'; +import './index.scss'; +import { PluginProps } from '@alilc/lowcode-types'; + +export interface IProps { + logo?: string; + href?: string; +} + +const Logo: React.FC = (props): React.ReactElement => { + return ( +
+ +
+ ); +}; + +export default Logo; diff --git a/demo/src/setters/behavior-setter.tsx b/demo/src/setters/behavior-setter.tsx new file mode 100644 index 0000000..1ab0114 --- /dev/null +++ b/demo/src/setters/behavior-setter.tsx @@ -0,0 +1,27 @@ +import * as React from 'react'; +import BehaviorSetter from '@alilc/lowcode-setter-behavior'; + + +const defaultExtraBehaviorActions: any[] = []; +class LocalBehaviorSetter extends React.Component { + render() { + // ignore url && responseFormatter props, use default ones + const { url: propsUrl, responseFormatter: propsFormatter, extraBehaviorActions: propsExtraBehaviorActions = [], ...otherProps } = this.props; + const url = 'https://hn.algolia.com/api/v1/search?query'; + const responseFormatter = (response) => response.hits.map((item) => ({ + label: item.title, + value: item.author + })); + const extraBehaviorActions = propsExtraBehaviorActions.concat(defaultExtraBehaviorActions); + return ( + + ); + } +} + +export default LocalBehaviorSetter; diff --git a/demo/src/setters/custom-setter.tsx b/demo/src/setters/custom-setter.tsx new file mode 100644 index 0000000..0383473 --- /dev/null +++ b/demo/src/setters/custom-setter.tsx @@ -0,0 +1,12 @@ +import React, { Component } from 'react'; // import classNames from 'classnames'; + +class CustomSetter extends Component { + render() { + const { defaultValue, value, onChange } = this.props; + const { editor } = this.props.field; + + return
hello world
; + } +} + +export default CustomSetter; diff --git a/demo/src/universal/global.scss b/demo/src/universal/global.scss new file mode 100644 index 0000000..02906a3 --- /dev/null +++ b/demo/src/universal/global.scss @@ -0,0 +1,55 @@ +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/src/universal/plugin.tsx b/demo/src/universal/plugin.tsx new file mode 100644 index 0000000..9fe6614 --- /dev/null +++ b/demo/src/universal/plugin.tsx @@ -0,0 +1,272 @@ +import React from 'react'; +import { + ILowCodePluginContext, + plugins, + skeleton, + project, + setters, +} from '@alilc/lowcode-engine'; +import { Button } from '@alifd/next'; +import UndoRedoPlugin from '@alilc/lowcode-plugin-undo-redo'; +import ComponentsPane from '@alilc/lowcode-plugin-components-pane'; +import ZhEnPlugin from '@alilc/lowcode-plugin-zh-en'; +import CodeGenPlugin from '@alilc/lowcode-plugin-code-generator'; +import DataSourcePanePlugin from '../../../packages/plugin-datasource-pane/src'; +import SchemaPlugin from '@alilc/lowcode-plugin-schema'; +import CodeEditor from "@alilc/lowcode-plugin-code-editor"; +import ManualPlugin from "@alilc/lowcode-plugin-manual"; +import Inject, { injectAssets } from '@alilc/lowcode-plugin-inject'; +import SimulatorResizer from '@alilc/lowcode-plugin-simulator-select'; + +// 注册到引擎 +import TitleSetter from '@alilc/lowcode-setter-title'; +import BehaviorSetter from '../setters/behavior-setter'; +import CustomSetter from '../setters/custom-setter'; +import Logo from '../sample-plugins/logo'; + +import { + loadIncrementalAssets, + getPageSchema, + saveSchema, + resetSchema, + preview, +} from './utils'; +import assets from '../../public/assets.json' + +export default async function registerPlugins() { + await plugins.register(ManualPlugin); + + await plugins.register(Inject); + + // plugin API 见 https://yuque.antfin.com/ali-lowcode/docs/cdukce + SchemaPlugin.pluginName = 'SchemaPlugin'; + await plugins.register(SchemaPlugin); + + SimulatorResizer.pluginName = 'SimulatorResizer'; + plugins.register(SimulatorResizer); + + const editorInit = (ctx: ILowCodePluginContext) => { + return { + name: 'editor-init', + async init() { + // 修改面包屑组件的分隔符属性setter + // const assets = await ( + // await fetch( + // `https://alifd.alicdn.com/npm/@alilc/lowcode-materials/build/lowcode/assets-prod.json` + // ) + // ).json(); + // 设置物料描述 + const { material, project } = ctx; + + material.setAssets(await injectAssets(assets)); + + const schema = await getPageSchema(); + + // 加载 schema + project.openDocument(schema); + }, + }; + } + editorInit.pluginName = 'editorInit'; + await plugins.register(editorInit); + + const builtinPluginRegistry = (ctx: ILowCodePluginContext) => { + return { + name: 'builtin-plugin-registry', + async init() { + const { skeleton } = ctx; + // 注册 logo 面板 + skeleton.add({ + area: 'topArea', + type: 'Widget', + name: 'logo', + content: Logo, + contentProps: { + logo: 'https://img.alicdn.com/imgextra/i4/O1CN013w2bmQ25WAIha4Hx9_!!6000000007533-55-tps-137-26.svg', + href: '/', + }, + props: { + align: 'left', + }, + }); + + // 注册组件面板 + const componentsPane = skeleton.add({ + area: 'leftArea', + type: 'PanelDock', + name: 'componentsPane', + content: ComponentsPane, + contentProps: {}, + props: { + align: 'top', + icon: 'zujianku', + description: '组件库', + }, + }); + componentsPane?.disable?.(); + project.onSimulatorRendererReady(() => { + componentsPane?.enable?.(); + }) + }, + }; + } + builtinPluginRegistry.pluginName = 'builtinPluginRegistry'; + await plugins.register(builtinPluginRegistry); + + // 设置内置 setter 和事件绑定、插件绑定面板 + const setterRegistry = (ctx: ILowCodePluginContext) => { + const { setterMap, pluginMap } = window.AliLowCodeEngineExt; + return { + name: 'ext-setters-registry', + async init() { + const { setters, skeleton } = ctx; + // 注册setterMap + setters.registerSetter(setterMap); + // 注册插件 + // 注册事件绑定面板 + skeleton.add({ + area: 'centerArea', + type: 'Widget', + content: pluginMap.EventBindDialog, + name: 'eventBindDialog', + props: {}, + }); + + // 注册变量绑定面板 + skeleton.add({ + area: 'centerArea', + type: 'Widget', + content: pluginMap.VariableBindDialog, + name: 'variableBindDialog', + props: {}, + }); + }, + }; + } + setterRegistry.pluginName = 'setterRegistry'; + await plugins.register(setterRegistry); + + // 注册回退/前进 + await plugins.register(UndoRedoPlugin); + + // 注册中英文切换 + await plugins.register(ZhEnPlugin); + + const loadAssetsSample = (ctx: ILowCodePluginContext) => { + return { + name: 'loadAssetsSample', + async init() { + const { skeleton } = ctx; + + skeleton.add({ + name: 'loadAssetsSample', + area: 'topArea', + type: 'Widget', + props: { + align: 'right', + width: 80, + }, + content: ( + + ), + }); + }, + }; + }; + loadAssetsSample.pluginName = 'loadAssetsSample'; + await plugins.register(loadAssetsSample); + + // 注册保存面板 + const saveSample = (ctx: ILowCodePluginContext) => { + return { + name: 'saveSample', + async init() { + const { skeleton, hotkey } = ctx; + + skeleton.add({ + name: 'saveSample', + area: 'topArea', + type: 'Widget', + props: { + align: 'right', + }, + content: ( + + ), + }); + skeleton.add({ + name: 'resetSchema', + area: 'topArea', + type: 'Widget', + props: { + align: 'right', + }, + content: ( + + ), + }); + hotkey.bind('command+s', (e) => { + e.preventDefault(); + saveSchema(); + }); + }, + }; + } + saveSample.pluginName = 'saveSample'; + await plugins.register(saveSample); + + DataSourcePanePlugin.pluginName = 'DataSourcePane'; + await plugins.register(DataSourcePanePlugin); + + CodeEditor.pluginName = 'CodeEditor'; + await plugins.register(CodeEditor); + + // 注册出码插件 + CodeGenPlugin.pluginName = 'CodeGenPlugin'; + await plugins.register(CodeGenPlugin); + + const previewSample = (ctx: ILowCodePluginContext) => { + return { + name: 'previewSample', + async init() { + const { skeleton } = ctx; + skeleton.add({ + name: 'previewSample', + area: 'topArea', + type: 'Widget', + props: { + align: 'right', + }, + content: ( + + ), + }); + }, + }; + }; + previewSample.pluginName = 'previewSample'; + await plugins.register(previewSample); + + const customSetter = (ctx: ILowCodePluginContext) => { + return { + name: '___registerCustomSetter___', + async init() { + const { setters } = ctx; + + setters.registerSetter('TitleSetter', TitleSetter); + setters.registerSetter('BehaviorSetter', BehaviorSetter); + setters.registerSetter('CustomSetter', CustomSetter); + }, + }; + } + customSetter.pluginName = 'customSetter'; + await plugins.register(customSetter); +}; diff --git a/demo/src/universal/utils.ts b/demo/src/universal/utils.ts new file mode 100644 index 0000000..9baf0f8 --- /dev/null +++ b/demo/src/universal/utils.ts @@ -0,0 +1,298 @@ +import { material, project } from '@alilc/lowcode-engine'; +import { filterPackages } from '@alilc/lowcode-plugin-inject' +import { Message, Dialog } from '@alifd/next'; + +export const loadIncrementalAssets = () => { + material?.onChangeAssets(() => { + Message.success('[MCBreadcrumb] 物料加载成功'); + }); + + material.loadIncrementalAssets({ + packages: [ + { + title: 'MCBreadcrumb', + package: 'mc-breadcrumb', + version: '1.0.0', + urls: [ + 'https://unpkg.alibaba-inc.com/mc-breadcrumb@1.0.0/dist/MCBreadcrumb.js', + 'https://unpkg.alibaba-inc.com/mc-breadcrumb@1.0.0/dist/MCBreadcrumb.css', + ], + library: 'MCBreadcrumb', + }, + ], + components: [ + { + componentName: 'MCBreadcrumb', + title: 'MCBreadcrumb', + docUrl: '', + screenshot: '', + npm: { + package: 'mc-breadcrumb', + version: '1.0.0', + exportName: 'MCBreadcrumb', + main: 'lib/index.js', + destructuring: false, + subName: '', + }, + props: [ + { + name: 'prefix', + propType: 'string', + description: '样式类名的品牌前缀', + defaultValue: 'next-', + }, + { + name: 'title', + propType: 'string', + description: '标题', + defaultValue: 'next-', + }, + { + name: 'rtl', + propType: 'bool', + }, + { + name: 'children', + propType: { + type: 'instanceOf', + value: 'node', + }, + description: '面包屑子节点,需传入 Breadcrumb.Item', + }, + { + name: 'maxNode', + propType: { + type: 'oneOfType', + value: [ + 'number', + { + type: 'oneOf', + value: ['auto'], + }, + ], + }, + description: + '面包屑最多显示个数,超出部分会被隐藏, 设置为 auto 会自动根据父元素的宽度适配。', + defaultValue: 100, + }, + { + name: 'separator', + propType: { + type: 'instanceOf', + value: 'node', + }, + description: '分隔符,可以是文本或 Icon', + }, + { + name: 'component', + propType: { + type: 'oneOfType', + value: ['string', 'func'], + }, + description: '设置标签类型', + defaultValue: 'nav', + }, + { + name: 'className', + propType: 'any', + }, + { + name: 'style', + propType: 'object', + }, + ], + configure: { + component: { + isContainer: true, + isModel: true, + rootSelector: 'div.MCBreadcrumb', + }, + }, + }, + ], + + componentList: [ + { + title: '常用', + icon: '', + children: [ + { + componentName: 'MCBreadcrumb', + title: 'MC面包屑', + icon: '', + package: 'mc-breadcrumb', + library: 'MCBreadcrumb', + snippets: [ + { + title: 'MC面包屑', + screenshot: + 'https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_breadcrumb.png', + schema: { + componentName: 'MCBreadcrumb', + props: { + title: '物料中心', + prefix: 'next-', + maxNode: 100, + }, + }, + }, + ], + }, + ], + }, + ], + }); +}; + +export const preview = () => { + saveSchema(); + setTimeout(() => { + window.open(`./preview.html${location.search}`); + }, 500); +}; + +export const saveSchema = async () => { + window.localStorage.setItem( + 'projectSchema', + JSON.stringify(project.exportSchema()) + ); + const packages = await filterPackages(material.getAssets().packages); + window.localStorage.setItem( + 'packages', + JSON.stringify(packages) + ); + Message.success('成功保存到本地'); +}; + +export const resetSchema = async () => { + try { + await new Promise((resolve, reject) => { + Dialog.confirm({ + content: '确定要重置吗?您所有的修改都将消失!', + onOk: () => { + resolve(); + }, + onCancel: () => { + reject() + }, + }) + }) + } catch(err) { + return + } + + let schema + try { + schema = await request('./schema.json') + } catch(err) { + schema = { + componentName: 'Page', + fileName: 'sample', + } + } + + window.localStorage.setItem( + 'projectSchema', + JSON.stringify({ + componentsTree: [schema], + componentsMap: material.componentsMap, + version: '1.0.0', + i18n: {}, + }) + ); + + project.getCurrentDocument()?.importSchema(schema); + project.simulatorHost?.rerender(); + Message.success('成功重置页面'); +} + +export const getPageSchema = async () => { + const schema = JSON.parse( + window.localStorage.getItem('projectSchema') || '{}' + ); + + const pageSchema = schema?.componentsTree?.[0]; + + if (pageSchema) { + return pageSchema; + } + return await request('./schema.json'); +}; + +function request( + dataAPI: string, + method = 'GET', + data?: object | string, + headers?: object, + otherProps?: any, +): Promise { + return new Promise((resolve, reject): void => { + if (otherProps && otherProps.timeout) { + setTimeout((): void => { + reject(new Error('timeout')); + }, otherProps.timeout); + } + fetch(dataAPI, { + method, + credentials: 'include', + headers, + body: data, + ...otherProps, + }) + .then((response: Response): any => { + switch (response.status) { + case 200: + case 201: + case 202: + return response.json(); + case 204: + if (method === 'DELETE') { + return { + success: true, + }; + } else { + return { + __success: false, + code: response.status, + }; + } + case 400: + case 401: + case 403: + case 404: + case 406: + case 410: + case 422: + case 500: + return response + .json() + .then((res: object): any => { + return { + __success: false, + code: response.status, + data: res, + }; + }) + .catch((): object => { + return { + __success: false, + code: response.status, + }; + }); + default: + return null; + } + }) + .then((json: any): void => { + if (json && json.__success !== false) { + resolve(json); + } else { + delete json.__success; + reject(json); + } + }) + .catch((err: Error): void => { + reject(err); + }); + }); +} \ No newline at end of file diff --git a/demo/tsconfig.json b/demo/tsconfig.json new file mode 100644 index 0000000..23314ab --- /dev/null +++ b/demo/tsconfig.json @@ -0,0 +1,44 @@ +{ + "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"] +} From ec4759101f2b5af808b7da88fd852f7418abd1a2 Mon Sep 17 00:00:00 2001 From: xingmolu <591745264@qq.com> Date: Sat, 26 Mar 2022 14:39:25 +0800 Subject: [PATCH 003/169] =?UTF-8?q?fix:=20=F0=9F=90=9B=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=95=B0=E6=8D=AE=E6=BA=90=E5=8F=82=E6=95=B0=E8=8B=A5?= =?UTF-8?q?=E5=B9=B2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/base-monaco-editor/src/index.tsx | 16 +-- .../DataSourceForm/DataSourceForm.tsx | 41 +++--- .../src/components/Forms/jsFunction.tsx | 40 +++--- .../src/components/Forms/json.tsx | 35 ++--- .../components/Forms/lowcode-expression.tsx | 4 +- .../src/components/Forms/param-value.scss | 8 +- .../src/components/Forms/param-value.tsx | 126 ++++++++++++------ .../src/pane/index.scss | 13 +- 8 files changed, 156 insertions(+), 127 deletions(-) diff --git a/packages/base-monaco-editor/src/index.tsx b/packages/base-monaco-editor/src/index.tsx index d9a7dff..e35581c 100644 --- a/packages/base-monaco-editor/src/index.tsx +++ b/packages/base-monaco-editor/src/index.tsx @@ -113,14 +113,14 @@ const SingleMonacoEditor = (props: ISingleMonacoEditorProps) => { return (
{loading && {WORD_EDITOR_INITIALIZING}} - -
- {supportFullScreen &&
} -
+ +
+ {supportFullScreen &&
} +
); }; diff --git a/packages/plugin-datasource-pane/src/components/DataSourceForm/DataSourceForm.tsx b/packages/plugin-datasource-pane/src/components/DataSourceForm/DataSourceForm.tsx index 82376ad..f3e6c12 100644 --- a/packages/plugin-datasource-pane/src/components/DataSourceForm/DataSourceForm.tsx +++ b/packages/plugin-datasource-pane/src/components/DataSourceForm/DataSourceForm.tsx @@ -296,25 +296,18 @@ export class DataSourceForm extends PureComponent { }, 'x-decorator': 'FormItem', items: { - type: 'void', - 'x-component': 'Space', + type: 'object', + // 'x-component': 'Space', properties: { - sort: { - type: 'void', - 'x-decorator': 'FormItem', - 'x-component': 'ArrayItems.SortHandle', - }, - params: { + space: { type: 'void', 'x-component': 'Space', - 'x-component-props': { - /* direction: "vertical", - align: "start", - style: { - alignItems: "flex-start", - }, */ - }, properties: { + sort: { + type: 'void', + 'x-decorator': 'FormItem', + 'x-component': 'ArrayItems.SortHandle', + }, name: { title: '', type: 'string', @@ -334,19 +327,19 @@ export class DataSourceForm extends PureComponent { // type: "string", 'x-component': 'ParamValue', 'x-component-props': { - // types: ["string", "boolean", "expression", "number"], - // placeholder: "value", + types: ['string', 'boolean', 'expression'], + placeholder: 'value', }, }, + remove: { + type: 'void', + 'x-decorator': 'FormItem', + 'x-component': 'ArrayItems.Remove', + }, + }, }, - }, - remove: { - type: 'void', - 'x-decorator': 'FormItem', - 'x-component': 'ArrayItems.Remove', }, }, - }, properties: { addition: { type: 'void', @@ -397,7 +390,7 @@ export class DataSourceForm extends PureComponent { // type: "string", 'x-component': 'ParamValue', 'x-component-props': { - // types: ["string", "boolean", "expression", "number"], + types: ['string', 'boolean', 'expression'], // placeholder: "value", }, }, diff --git a/packages/plugin-datasource-pane/src/components/Forms/jsFunction.tsx b/packages/plugin-datasource-pane/src/components/Forms/jsFunction.tsx index 5d196c4..025e99a 100644 --- a/packages/plugin-datasource-pane/src/components/Forms/jsFunction.tsx +++ b/packages/plugin-datasource-pane/src/components/Forms/jsFunction.tsx @@ -1,15 +1,13 @@ import React, { PureComponent } from 'react'; import { connect } from '@formily/react'; +import { JSFunction as IJSFunction } from '@alilc/lowcode-types'; import MonacoEditor from '@alilc/lowcode-plugin-base-monaco-editor'; import _noop from 'lodash/noop'; -import { editor } from 'monaco-editor'; +// import { editor } from 'monaco-editor'; export interface JSFunctionProps { className: string; - value: { - type: 'JSFunction'; - value: string; - }; + value: IJSFunction; onChange?: (val: any) => void; } @@ -25,37 +23,29 @@ export class JSFunctionComp extends PureComponent< onChange: _noop, }; - private monacoRef: any = null; + // private monacoRef: any = null; - handleEditorChange = (newValue) => { - if (this.monacoRef) { - if ( - !(this.monacoRef as any) - .getModelMarkers() - .find((marker: editor.IMarker) => marker.owner === 'json') - ) { - this.props.onChange?.({ - type: 'JSFunction', - value: newValue, - }); - } - } + handleEditorChange = (newValue: string) => { + this.props.onChange?.({ + type: 'JSFunction', + value: newValue, + }); }; - handleEditorDidMount = (isFullscreen, editor, monaco) => { - this.monacoRef = monaco?.editor; - }; + // handleEditorDidMount = (isFullscreen: boolean, editor, monaco) => { + // this.monacoRef = monaco?.editor; + // }; render() { - const { value } = this.props; + const { value, className } = this.props; return ( -
+
); diff --git a/packages/plugin-datasource-pane/src/components/Forms/json.tsx b/packages/plugin-datasource-pane/src/components/Forms/json.tsx index 04c6cc3..38d68ac 100644 --- a/packages/plugin-datasource-pane/src/components/Forms/json.tsx +++ b/packages/plugin-datasource-pane/src/components/Forms/json.tsx @@ -2,10 +2,10 @@ import React, { PureComponent } from 'react'; import { connect } from '@formily/react'; import MonacoEditor from '@alilc/lowcode-plugin-base-monaco-editor'; import _noop from 'lodash/noop'; -import { editor } from 'monaco-editor'; +// import { editor } from 'monaco-editor'; export interface JSONProps { - className: string; + className?: string; value: Record; onChange?: (val: any) => void; } @@ -19,37 +19,26 @@ export class JSONComp extends PureComponent { onChange: _noop, }; - private monacoRef: any = null; - - handleEditorChange = (newValue) => { - if (this.monacoRef) { - if ( - !(this.monacoRef as any) - .getModelMarkers() - .find((marker: editor.IMarker) => marker.owner === 'json') - ) { - this.props.onChange?.({ - type: 'JSON', - value: newValue, - }); - } - } - }; + // private monacoRef: any = null; - handleEditorDidMount = (isFullscreen, editor, monaco) => { - this.monacoRef = monaco?.editor; + handleEditorChange = (newValue: string) => { + this.props.onChange?.(newValue); }; + // handleEditorDidMount = (editor) => { + // this.monacoRef = editor; + // }; + render() { - const { value } = this.props; + const { value, className } = this.props; return ( -
+
); diff --git a/packages/plugin-datasource-pane/src/components/Forms/lowcode-expression.tsx b/packages/plugin-datasource-pane/src/components/Forms/lowcode-expression.tsx index fcc64c8..7a5cf9d 100644 --- a/packages/plugin-datasource-pane/src/components/Forms/lowcode-expression.tsx +++ b/packages/plugin-datasource-pane/src/components/Forms/lowcode-expression.tsx @@ -26,9 +26,9 @@ export class LowcodeExpressionComp extends PureComponent }; render() { - const { value } = this.props; + const { value, className } = this.props; return ( -
+
{({ setters }) => { const ExpressionSetter = setters?.getSetter('ExpressionSetter').component; diff --git a/packages/plugin-datasource-pane/src/components/Forms/param-value.scss b/packages/plugin-datasource-pane/src/components/Forms/param-value.scss index d587e5d..734278a 100644 --- a/packages/plugin-datasource-pane/src/components/Forms/param-value.scss +++ b/packages/plugin-datasource-pane/src/components/Forms/param-value.scss @@ -10,6 +10,12 @@ $cls-prefix: "lowcode-plugin-datasource-pane"; } } +// .#{$cls-prefix}-component-switchbtn{ +// position: absolute; +// bottom: 0; +// right: 0; +// } + .#{$cls-prefix}-universal-value-typeswitch.next-btn-group { .next-btn { padding: 0 2px; @@ -30,4 +36,4 @@ $cls-prefix: "lowcode-plugin-datasource-pane"; .#{$cls-prefix}-universal-value-jsonstring, .#{$cls-prefix}-universal-value-json { width: 200px !important; -} \ No newline at end of file +} diff --git a/packages/plugin-datasource-pane/src/components/Forms/param-value.tsx b/packages/plugin-datasource-pane/src/components/Forms/param-value.tsx index 4bbdc7e..4c572dc 100644 --- a/packages/plugin-datasource-pane/src/components/Forms/param-value.tsx +++ b/packages/plugin-datasource-pane/src/components/Forms/param-value.tsx @@ -10,6 +10,7 @@ import { Switch, } from '@alifd/next'; import { connect } from '@formily/react'; +import { JSExpression, isJSExpression } from '@alilc/lowcode-types'; import _isPlainObject from 'lodash/isPlainObject'; import _isArray from 'lodash/isArray'; import _isNumber from 'lodash/isNumber'; @@ -22,6 +23,15 @@ import './param-value.scss'; const { Group: RadioGroup } = Radio; +enum ParamValueEnum { + STRING ='string', + NUMBER ='number', + BOOLEAN ='boolean', + EXPRSSION ='expression', + JSON ='json', + JSONSTRING = 'jsonstring', +} + type ParamValueType = | 'string' | 'number' @@ -40,7 +50,11 @@ export interface ParamValueProps { export interface ParamValueState { type: ParamValueType; - value: string | number | { type: 'JSFunction'; value: string } | boolean; + value: string | number | JSExpression | boolean; +} + +function isBoolean(val: boolean | string) { + return _isBoolean(val) || val === 'true' || val === 'false'; } const TYPE_LABEL_MAP = { @@ -86,6 +100,14 @@ class ParamValueComp extends PureComponent { // @todo 需要再 bind 一次? handleChange = (value: any) => { + const { type } = this.state; + if (type === 'json') { + this.props.onChange?.({ + type: 'JSExpression', + value, + }); + return; + } this.setState({ value, }); @@ -101,27 +123,50 @@ class ParamValueComp extends PureComponent { const currentTypeIndex = this.props.types.indexOf(type); nextRealType = types[(currentTypeIndex + 1) % types.length]; } - if (nextRealType === 'string') { - nextValue = nextValue.toString(); - } else if (nextRealType === 'number') { - nextValue *= 1; - } else if (nextRealType === 'boolean') { - nextValue = - nextValue === 'true' || - (nextValue && nextValue.value === 'true') || - false; - } else if (nextRealType === 'expression') { - // ExpressionSetter 的 value 接受 string - nextValue = String(nextValue); - } else if (nextRealType === 'jsonstring') { - nextValue = ''; - } else if (nextRealType === 'object') { - nextValue = safeParse(nextValue); + switch (nextRealType) { + case ParamValueEnum.STRING: + if (isJSExpression(nextValue)) { + nextValue = nextValue.value; + } + // nextValue = nextValue.toString(); + break; + case ParamValueEnum.NUMBER: + nextValue *= 1; + break; + case ParamValueEnum.BOOLEAN: + if (isBoolean(nextValue)) { + nextValue = nextValue === 'true' || (nextValue && nextValue.value === 'true') || false; + } + break; + case ParamValueEnum.JSONSTRING: + nextValue = ''; + break; + case ParamValueEnum.JSON: + if (isJSExpression(nextValue)) { + nextValue = nextValue.value; + } + break; + case ParamValueEnum.EXPRSSION: + if (!isJSExpression(nextValue)) { + nextValue = { + type: 'JSExpression', + value: nextValue, + }; + } + break; + default: } this.setState({ type: nextRealType as ParamValueType, value: nextValue, }); + if (nextRealType === 'json') { + this.props.onChange?.({ + type: 'JSExpression', + value: nextValue, + }); + return; + } this.props.onChange?.(nextValue); }; @@ -129,12 +174,9 @@ class ParamValueComp extends PureComponent { const handleSwitch = () => { this.handleTypeChange(); }; - const handleSwitchTo = (type) => { + const handleSwitchTo = (type: string) => { this.handleTypeChange(type); }; - /* return ( - - ); */ return ( + +

+
+ ); + } +} + +``` + +具体的 component 可参考 DataSourceImportPluginCode + [查看](https://github.com/alibaba/lowcode-plugins/blob/main/packages/plugin-datasource-pane/src/components/DataSourceImportPluginCode/DataSourceImportPluginCode.tsx) + + demo 截图 + ![Alt](https://user-images.githubusercontent.com/14235113/186659341-dff511e8-f032-423c-8be7-e0cc281f3964.png) + + + ## 定制导出插件 From 92eb18ecc7179374df43c44106dde7703f279415 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?LeoYuan=20=E8=A2=81=E5=8A=9B=E7=9A=93?= Date: Tue, 27 Sep 2022 18:18:40 +0800 Subject: [PATCH 044/169] refactor: support inject mode for plugin-datasource-pane --- packages/plugin-datasource-pane/build.js | 23 ++++++++++++++++++++ packages/plugin-datasource-pane/build.json | 12 ---------- packages/plugin-datasource-pane/package.json | 4 ++-- 3 files changed, 25 insertions(+), 14 deletions(-) create mode 100644 packages/plugin-datasource-pane/build.js delete mode 100644 packages/plugin-datasource-pane/build.json diff --git a/packages/plugin-datasource-pane/build.js b/packages/plugin-datasource-pane/build.js new file mode 100644 index 0000000..fc2fa16 --- /dev/null +++ b/packages/plugin-datasource-pane/build.js @@ -0,0 +1,23 @@ +module.exports = { + plugins: [ + 'build-plugin-component', + 'build-plugin-fusion', + [ + 'build-plugin-moment-locales', + { + locales: ['zh-cn'], + }, + ], + [ + '@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', + }, + ], + ], +}; diff --git a/packages/plugin-datasource-pane/build.json b/packages/plugin-datasource-pane/build.json deleted file mode 100644 index b2fe2de..0000000 --- a/packages/plugin-datasource-pane/build.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "plugins": [ - "build-plugin-component", - "build-plugin-fusion", - [ - "build-plugin-moment-locales", - { - "locales": ["zh-cn"] - } - ] - ] -} diff --git a/packages/plugin-datasource-pane/package.json b/packages/plugin-datasource-pane/package.json index eae676c..f3cf576 100644 --- a/packages/plugin-datasource-pane/package.json +++ b/packages/plugin-datasource-pane/package.json @@ -7,7 +7,7 @@ "lib" ], "scripts": { - "start": "build-scripts start", + "start": "build-scripts start --config build.js", "build": "build-scripts build", "test": "ava", "test:snapshot": "ava --update-snapshots" @@ -26,7 +26,7 @@ "devDependencies": { "@alib/build-scripts": "^0.1.32", "@alifd/theme-lowcode-light": "^0.2.1", - "@alilc/build-plugin-alt": "^1.0.0", + "@alilc/build-plugin-alt": "^1.2.2", "@alilc/lowcode-engine": "beta", "@alilc/lowcode-shell": "^1.0.0", "@alilc/lowcode-types": "beta", From 6b142d99ac608fb17ef0b0c7dd7cdd66a702e40f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?LeoYuan=20=E8=A2=81=E5=8A=9B=E7=9A=93?= Date: Tue, 27 Sep 2022 17:55:13 +0800 Subject: [PATCH 045/169] refactor: use standard APIs of LCE --- packages/plugin-simulator-size/build.js | 24 +++++++ packages/plugin-simulator-size/build.json | 19 ----- packages/plugin-simulator-size/package.json | 6 +- packages/plugin-simulator-size/src/index.scss | 4 +- packages/plugin-simulator-size/src/index.tsx | 71 +++++++++---------- 5 files changed, 62 insertions(+), 62 deletions(-) create mode 100644 packages/plugin-simulator-size/build.js delete mode 100644 packages/plugin-simulator-size/build.json diff --git a/packages/plugin-simulator-size/build.js b/packages/plugin-simulator-size/build.js new file mode 100644 index 0000000..912cf3e --- /dev/null +++ b/packages/plugin-simulator-size/build.js @@ -0,0 +1,24 @@ +module.exports = { + externals: { + react: 'React', + moment: 'moment', + 'react-dom': 'ReactDOM', + 'prop-types': 'PropTypes', + '@alifd/next': 'Next', + '@alilc/lowcode-engine': 'AliLowCodeEngine' + }, + plugins: [ + [ + '@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-component' + ] +} diff --git a/packages/plugin-simulator-size/build.json b/packages/plugin-simulator-size/build.json deleted file mode 100644 index 2123027..0000000 --- a/packages/plugin-simulator-size/build.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "externals": { - "react": "React", - "moment": "moment", - "react-dom": "ReactDOM", - "prop-types": "PropTypes", - "@alifd/next": "Next", - "@alilc/lowcode-engine": "AliLowCodeEngine" - }, - "plugins": [ - [ - "@alilc/build-plugin-alt", - { - "type": "plugin" - } - ], - "build-plugin-component" - ] -} diff --git a/packages/plugin-simulator-size/package.json b/packages/plugin-simulator-size/package.json index 8ca79c6..ebe4b04 100644 --- a/packages/plugin-simulator-size/package.json +++ b/packages/plugin-simulator-size/package.json @@ -4,7 +4,7 @@ "description": "画布切换", "main": "lib/index.js", "scripts": { - "start": "build-scripts start", + "start": "build-scripts start --config build.js", "build": "build-scripts build --skip-demo", "prepublishOnly": "npm run build", "test": "echo \"Error: no test specified\" && exit 1" @@ -18,7 +18,7 @@ }, "devDependencies": { "@alib/build-scripts": "^0.1.18", - "@alilc/build-plugin-alt": "^1.1.0", + "@alilc/build-plugin-alt": "^1.2.2", "@alilc/lowcode-engine": "^1.0.0", "@types/react": "^16.8.1", "build-plugin-component": "^1.1.0", @@ -26,5 +26,5 @@ "react-dom": "^16.8.1" }, "author": "mark.ck", - "license": "ISC" + "license": "MIT" } diff --git a/packages/plugin-simulator-size/src/index.scss b/packages/plugin-simulator-size/src/index.scss index 2944507..ca671ae 100644 --- a/packages/plugin-simulator-size/src/index.scss +++ b/packages/plugin-simulator-size/src/index.scss @@ -1,7 +1,7 @@ .lp-simulator-pane { display: flex; align-items: center; - margin: 0 8px; + margin: 0 80px; .lp-simulator-pane-item { display: inline-block; width: 32px; @@ -15,7 +15,7 @@ opacity: 1; } } - &.actived { + &.active { background: #F2F2F2; } } diff --git a/packages/plugin-simulator-size/src/index.tsx b/packages/plugin-simulator-size/src/index.tsx index fba2c5b..73e9e24 100644 --- a/packages/plugin-simulator-size/src/index.tsx +++ b/packages/plugin-simulator-size/src/index.tsx @@ -1,13 +1,11 @@ import React from 'react'; import { NumberPicker, Icon } from '@alifd/next'; -import { ILowCodePluginContext, project, material } from '@alilc/lowcode-engine'; +import { ILowCodePluginContext, project, isOpenSource } from '@alilc/lowcode-engine'; import './index.scss'; -const isNewEngineVersion = !!material; - const devices = [ - { key: 'desktop' }, + { key: 'default' }, { key: 'tablet' }, { key: 'phone' }, ]; @@ -16,36 +14,27 @@ const CustomIcon = Icon.createFromIconfontCN({ scriptUrl: 'https://at.alicdn.com/t/font_2896595_33xhsbg9ux5.js', }); -export class SimulatorPane extends React.Component { - static displayName = 'SimulatorPane'; +export class SimulatorResizePane extends React.Component { + static displayName = 'SimulatorResizePane'; state = { - actived: 'desktop', + active: 'default', currentWidth: null }; componentDidMount() { - if (isNewEngineVersion) { - project.onSimulatorRendererReady(() => { - const currentWidth = document.querySelector('.lc-simulator-canvas')?.clientWidth || this.state.currentWidth || 0; - this.setState({ - currentWidth - }); - }); - } else { - // 兼容老版本引擎 - // @ts-ignore - project.onRendererReady(() => { - const currentWidth = document.querySelector('.lc-simulator-canvas')?.clientWidth || this.state.currentWidth || 0; - this.setState({ - currentWidth - }); + // @ts-ignore + const onSimulatorRendererReady = (project.onSimulatorRendererReady || project.onRendererReady).bind(project); + onSimulatorRendererReady(() => { + const currentWidth = document.querySelector('.lc-simulator-canvas')?.clientWidth || this.state.currentWidth || 0; + this.setState({ + currentWidth }); - } + }); } change = (device: string) => { - const simulator = project.simulator; + const simulator = project.simulatorHost; // 切换画布 simulator?.set('device', device); if (document.querySelector('.lc-simulator-canvas')?.style) { @@ -54,7 +43,7 @@ export class SimulatorPane extends React.Component { setTimeout(() => { const currentWidth = document.querySelector('.lc-simulator-canvas')?.clientWidth || this.state.currentWidth || 0; this.setState({ - actived: device, + active: device, currentWidth }); }, 0); @@ -62,7 +51,7 @@ export class SimulatorPane extends React.Component { renderItemSVG(device: string) { switch (device) { - case 'desktop': + case 'default': return ; case 'tablet': return ; @@ -82,7 +71,7 @@ export class SimulatorPane extends React.Component { return ( {this.renderItemSVG(item.key)} @@ -97,9 +86,12 @@ export class SimulatorPane extends React.Component { }); }} onPressEnter={(event: any) => { const value = event?.target?.value; - if (document.querySelector('.lc-simulator-canvas')?.style) { - document.querySelector('.lc-simulator-canvas').style.width = `${value}px` - } + const simulator = project.simulatorHost; + simulator?.set('deviceStyle', { + canvas: { + width: `${value}px`, + } + }) this.setState({ currentWidth: value }); @@ -109,28 +101,31 @@ export class SimulatorPane extends React.Component { ); } } -export default (ctx: ILowCodePluginContext) => { - const simulatorPaneRef = React.createRef(); +const plugin = (ctx: ILowCodePluginContext) => { + const SimulatorResizePaneRef = React.createRef(); return { - name: 'SimulatorPane', // 插件的初始化函数,在引擎初始化之后会立刻调用 init() { // 往引擎增加工具条 ctx.skeleton.add({ - area: 'top', - name: 'SimulatorPane', + area: 'topArea', + name: 'SimulatorResizePane', type: 'Widget', props: { description: '切换画布尺寸', align: "center", }, content: ( - ), }); } }; -}; \ No newline at end of file +}; + +plugin.pluginName = 'SimulatorResizePane'; + +export default plugin; \ No newline at end of file From 8a8e5159cea65fb1caae0127d280ef3151fd03d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?LeoYuan=20=E8=A2=81=E5=8A=9B=E7=9A=93?= Date: Wed, 28 Sep 2022 09:50:47 +0800 Subject: [PATCH 046/169] refactor: support inject debug mode for plugin-code-editor --- packages/plugin-code-editor/build.js | 22 ++++++++++++++++++++ packages/plugin-code-editor/build.json | 14 ------------- packages/plugin-code-editor/package.json | 4 ++-- packages/plugin-datasource-pane/package.json | 2 +- packages/plugin-simulator-size/package.json | 2 +- 5 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 packages/plugin-code-editor/build.js delete mode 100644 packages/plugin-code-editor/build.json 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/build.json b/packages/plugin-code-editor/build.json deleted file mode 100644 index f9c8757..0000000 --- a/packages/plugin-code-editor/build.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "plugins": [ - [ - "build-plugin-fusion", - { - "themePackage": "@alifd/theme-lowcode-light" - } - ], - ["@alilc/build-plugin-alt", { - "type": "plugin" - }], - "./build.plugin.js" - ] -} diff --git a/packages/plugin-code-editor/package.json b/packages/plugin-code-editor/package.json index 14ef6d9..cb99343 100644 --- a/packages/plugin-code-editor/package.json +++ b/packages/plugin-code-editor/package.json @@ -12,9 +12,9 @@ "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 --skip-demo --config build.js" }, "publishConfig": { "access": "public" diff --git a/packages/plugin-datasource-pane/package.json b/packages/plugin-datasource-pane/package.json index f3cf576..c883cc4 100644 --- a/packages/plugin-datasource-pane/package.json +++ b/packages/plugin-datasource-pane/package.json @@ -8,7 +8,7 @@ ], "scripts": { "start": "build-scripts start --config build.js", - "build": "build-scripts build", + "build": "build-scripts build --config build.js", "test": "ava", "test:snapshot": "ava --update-snapshots" }, diff --git a/packages/plugin-simulator-size/package.json b/packages/plugin-simulator-size/package.json index ebe4b04..dd5e697 100644 --- a/packages/plugin-simulator-size/package.json +++ b/packages/plugin-simulator-size/package.json @@ -5,7 +5,7 @@ "main": "lib/index.js", "scripts": { "start": "build-scripts start --config build.js", - "build": "build-scripts build --skip-demo", + "build": "build-scripts build --skip-demo --config build.js", "prepublishOnly": "npm run build", "test": "echo \"Error: no test specified\" && exit 1" }, From 879215ee35e11285a60278f6206ba0ab5e75d75a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?LeoYuan=20=E8=A2=81=E5=8A=9B=E7=9A=93?= Date: Wed, 28 Sep 2022 14:55:43 +0800 Subject: [PATCH 047/169] feat: get options from the second parameter of PluginCreator --- packages/plugin-datasource-pane/src/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/plugin-datasource-pane/src/index.tsx b/packages/plugin-datasource-pane/src/index.tsx index 9347532..21f8935 100644 --- a/packages/plugin-datasource-pane/src/index.tsx +++ b/packages/plugin-datasource-pane/src/index.tsx @@ -13,7 +13,7 @@ export interface Options { } // TODO: 2.0插件传参修改,不支持直接options: Options -const plugin = (ctx: ILowCodePluginContext) => { +const plugin = (ctx: ILowCodePluginContext, options: Options) => { return { name: 'com.alibaba.lowcode.datasource.pane', width: 300, @@ -25,8 +25,8 @@ const plugin = (ctx: ILowCodePluginContext) => { }, // 插件的初始化函数,在引擎初始化之后会立刻调用 init() { - const dataSourceTypes = ctx.preference.getPreferenceValue('dataSourceTypes'); - const importPlugins = ctx.preference.getPreferenceValue('importPlugins'); + const dataSourceTypes = ctx.preference.getPreferenceValue('dataSourceTypes') || options.dataSourceTypes; + const importPlugins = ctx.preference.getPreferenceValue('importPlugins') || options.importPlugins; const schemaDock = ctx.skeleton.add({ area: 'leftArea', name: 'dataSourcePane', From e0276882934330189190203c523a037b8790b355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?LeoYuan=20=E8=A2=81=E5=8A=9B=E7=9A=93?= Date: Wed, 28 Sep 2022 15:18:36 +0800 Subject: [PATCH 048/169] chore(datasource-pane): bump 1.0.7 --- packages/plugin-datasource-pane/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin-datasource-pane/package.json b/packages/plugin-datasource-pane/package.json index c883cc4..38a797f 100644 --- a/packages/plugin-datasource-pane/package.json +++ b/packages/plugin-datasource-pane/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-plugin-datasource-pane", - "version": "1.0.6", + "version": "1.0.7", "description": "低代码引擎数据源面板", "main": "lib/index.js", "files": [ From bded42604466fdc4c990234ffff29a78becb29a6 Mon Sep 17 00:00:00 2001 From: liujuping Date: Tue, 8 Nov 2022 16:25:51 +0800 Subject: [PATCH 049/169] chore(release): publish lowcode-plugin-simulator-select 1.0.2 --- packages/plugin-simulator-size/package.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/plugin-simulator-size/package.json b/packages/plugin-simulator-size/package.json index dd5e697..844278c 100644 --- a/packages/plugin-simulator-size/package.json +++ b/packages/plugin-simulator-size/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-plugin-simulator-select", - "version": "1.0.0", + "version": "1.0.2", "description": "画布切换", "main": "lib/index.js", "scripts": { @@ -26,5 +26,10 @@ "react-dom": "^16.8.1" }, "author": "mark.ck", + "repository": { + "type": "git", + "url": "https://github.com/alibaba/lowcode-plugins.git", + "directory": "packages/plugin-simulator-size" + }, "license": "MIT" } From 0982f9f9183d7f3f55a8f15d43cf4fba12b36104 Mon Sep 17 00:00:00 2001 From: JackLian Date: Thu, 10 Nov 2022 17:32:05 +0800 Subject: [PATCH 050/169] feat: add plugin plugin-set-ref-prop --- packages/action-block/.gitignore | 104 -------------------- packages/plugin-block/.gitignore | 104 -------------------- packages/plugin-code-editor/.gitignore | 104 -------------------- packages/plugin-components-pane/.gitignore | 26 ----- packages/plugin-datasource-pane/.gitignore | 104 -------------------- packages/plugin-manual/.gitignore | 43 --------- packages/plugin-schema/.gitignore | 43 --------- packages/plugin-set-ref-prop/CHANGELOG.md | 0 packages/plugin-set-ref-prop/README.md | 27 ++++++ packages/plugin-set-ref-prop/build.json | 17 ++++ packages/plugin-set-ref-prop/package.json | 34 +++++++ packages/plugin-set-ref-prop/src/index.tsx | 79 +++++++++++++++ packages/plugin-set-ref-prop/tsconfig.json | 9 ++ packages/plugin-simulator-size/.gitignore | 104 -------------------- packages/plugin-undo-redo/.gitignore | 104 -------------------- packages/plugin-zh-en/.gitignore | 106 --------------------- 16 files changed, 166 insertions(+), 842 deletions(-) delete mode 100644 packages/action-block/.gitignore delete mode 100644 packages/plugin-block/.gitignore delete mode 100644 packages/plugin-code-editor/.gitignore delete mode 100644 packages/plugin-components-pane/.gitignore delete mode 100644 packages/plugin-datasource-pane/.gitignore delete mode 100644 packages/plugin-manual/.gitignore delete mode 100644 packages/plugin-schema/.gitignore create mode 100644 packages/plugin-set-ref-prop/CHANGELOG.md create mode 100644 packages/plugin-set-ref-prop/README.md create mode 100644 packages/plugin-set-ref-prop/build.json create mode 100644 packages/plugin-set-ref-prop/package.json create mode 100644 packages/plugin-set-ref-prop/src/index.tsx create mode 100644 packages/plugin-set-ref-prop/tsconfig.json delete mode 100644 packages/plugin-simulator-size/.gitignore delete mode 100644 packages/plugin-undo-redo/.gitignore delete mode 100644 packages/plugin-zh-en/.gitignore 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/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-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-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-datasource-pane/.gitignore b/packages/plugin-datasource-pane/.gitignore deleted file mode 100644 index 77dfbd1..0000000 --- a/packages/plugin-datasource-pane/.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-manual/.gitignore b/packages/plugin-manual/.gitignore deleted file mode 100644 index 7d916c2..0000000 --- a/packages/plugin-manual/.gitignore +++ /dev/null @@ -1,43 +0,0 @@ -node_modules/ -build/ -es/ -lib/ -.idea/ -.vscode/ -jsconfig.json -typings.json -typings/ -~* - -# Packages # -############ -# it's better to unpack these files and commit the raw source -# git has its own built in compression methods -*.7z -*.dmg -*.gz -*.iso -*.jar -*.rar -*.tar -*.zip - -# Logs and databases # -###################### -*.log -*.sql -*.sqlite - -# OS generated files # -###################### -.DS_Store -*.swp -.DS_Store? -._* -.Spotlight-V100 -.Trashes -ehthumbs.db -Thumbs.db -.lock -package-lock.json -.vdev diff --git a/packages/plugin-schema/.gitignore b/packages/plugin-schema/.gitignore deleted file mode 100644 index 10239e7..0000000 --- a/packages/plugin-schema/.gitignore +++ /dev/null @@ -1,43 +0,0 @@ -node_modules/ -build/ -es/ -lib/ -.idea/ -.vscode/ -jsconfig.json -typings.json -typings/ -~* - -# Packages # -############ -# it's better to unpack these files and commit the raw source -# git has its own built in compression methods -*.7z -*.dmg -*.gz -*.iso -*.jar -*.rar -*.tar -*.zip - -# Logs and databases # -###################### -*.log -*.sql -*.sqlite - -# OS generated files # -###################### -.DS_Store - *.swp -.DS_Store? -._* -.Spotlight-V100 -.Trashes -ehthumbs.db -Thumbs.db -.lock -package-lock.json -.vdev diff --git a/packages/plugin-set-ref-prop/CHANGELOG.md b/packages/plugin-set-ref-prop/CHANGELOG.md new file mode 100644 index 0000000..e69de29 diff --git a/packages/plugin-set-ref-prop/README.md b/packages/plugin-set-ref-prop/README.md new file mode 100644 index 0000000..409106d --- /dev/null +++ b/packages/plugin-set-ref-prop/README.md @@ -0,0 +1,27 @@ +# @alilc/lowcode-plugin-zh-cn [![][npm-image]][npm-url] +为设计提供在高级设置面板中设置ref-id的能力 +plugin for setting ref-id. + +--- + +## 使用 + +### 注册插件 +```jsx +import { plugins } from '@alilc/lowcode-engine'; +import SetRefPropPlugin from '@alilc/lowcode-plugin-set-ref-prop'; + +// 注册到引擎 +plugins.register(SetRefPropPlugin); +``` + +### 插件属性 & 方法 + +无对外暴露的属性和方法 + +### 依赖插件 + +该插件依赖以下插件: + +| 插件名 | 包名 | +| --- | --- | diff --git a/packages/plugin-set-ref-prop/build.json b/packages/plugin-set-ref-prop/build.json new file mode 100644 index 0000000..1767fef --- /dev/null +++ b/packages/plugin-set-ref-prop/build.json @@ -0,0 +1,17 @@ +{ + "plugins": [ + [ + "@alilc/build-plugin-alt", + { + "type": "plugin", + "inject": true + } + ], + [ + "build-plugin-fusion", + { + "themePackage": "@alifd/theme-lowcode-light" + } + ] + ] +} diff --git a/packages/plugin-set-ref-prop/package.json b/packages/plugin-set-ref-prop/package.json new file mode 100644 index 0000000..8f15c9b --- /dev/null +++ b/packages/plugin-set-ref-prop/package.json @@ -0,0 +1,34 @@ +{ + "name": "@alilc/lowcode-plugin-set-ref-prop", + "version": "1.0.0", + "description": "alibaba lowcode editor plugin for setting ref-id", + "files": [ + "es", + "lib" + ], + "main": "lib/index.js", + "module": "es/index.js", + "scripts": { + "start": "build-scripts start", + "build": "build-scripts build", + "prepublishOnly": "npm run build" + }, + "dependencies": { + "@alilc/lowcode-types": "^1.0.0", + "@alilc/lowcode-utils": "^1.0.0", + "react": "^16.8.1", + "react-dom": "^16.8.1", + "uuid": "^8.3.2" + }, + "devDependencies": { + "@alib/build-scripts": "^0.1.3", + "@alilc/build-plugin-alt": "^1.0.0", + "@alilc/lowcode-engine": "^1.0.0", + "@types/react": "^16.9.13", + "@types/react-dom": "^16.9.4", + "build-plugin-fusion": "^0.1.22" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/packages/plugin-set-ref-prop/src/index.tsx b/packages/plugin-set-ref-prop/src/index.tsx new file mode 100644 index 0000000..b51ad2b --- /dev/null +++ b/packages/plugin-set-ref-prop/src/index.tsx @@ -0,0 +1,79 @@ +import { TransformedComponentMetadata, FieldConfig } from '@alilc/lowcode-types'; +import { v4 as uuidv4 } from 'uuid'; +import { material } from '@alilc/lowcode-engine'; + +function addonCombine(metadata: TransformedComponentMetadata) { + const { componentName, configure = {} } = metadata; + + const isRoot: boolean = componentName === 'Page' || componentName === 'Component'; + + if (isRoot) { + return metadata; + } + + let advancedGroup: FieldConfig | undefined; + + const refItem: FieldConfig = { + title: { + label: 'refId', + tip: '用于获取组件实例,调用物料内部方法', + icon: '', + }, + name: 'ref', + setter: { + componentName: 'StringSetter', + }, + defaultValue: () => { + const uuid = uuidv4().replace('-', '').substring(0, 8); + return `${componentName.toLowerCase()}-${uuid}`; + }, + extraProps: { + display: 'block', + supportVariable: false, + }, + }; + + if (!configure.combined) { + configure.combined = []; + } + + advancedGroup = configure.combined?.filter(d => d.name === '#advanced')[0]; + + if (!advancedGroup) { + advancedGroup = { + name: '#advanced', + title: { type: 'i18n', 'zh-CN': '高级', 'en-US': 'Advanced' }, + items: [ + refItem, + ], + }; + + configure.combined.push(advancedGroup); + } + + if (!advancedGroup.items) { + advancedGroup.items = [refItem]; + } + + const advanceItems: FieldConfig[] = advancedGroup.items || []; + + if (!advanceItems || !advanceItems.length || !advanceItems?.filter(d => d.name === 'ref').length) { + advanceItems.push(refItem); + } + + return { + ...metadata, + configure, + }; +} + +const SetRefPropPlugin = () => { + return { + init() { + material.registerMetadataTransducer(addonCombine, 110, 'register-ref-prop'); + }, + }; +}; + +SetRefPropPlugin.pluginName = 'SetRefPropPlugin'; +export default SetRefPropPlugin; \ No newline at end of file diff --git a/packages/plugin-set-ref-prop/tsconfig.json b/packages/plugin-set-ref-prop/tsconfig.json new file mode 100644 index 0000000..c37b76e --- /dev/null +++ b/packages/plugin-set-ref-prop/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "lib" + }, + "include": [ + "./src/" + ] +} diff --git a/packages/plugin-simulator-size/.gitignore b/packages/plugin-simulator-size/.gitignore deleted file mode 100644 index b1a02c7..0000000 --- a/packages/plugin-simulator-size/.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 - -# 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 -.node diff --git a/packages/plugin-undo-redo/.gitignore b/packages/plugin-undo-redo/.gitignore deleted file mode 100644 index 77dfbd1..0000000 --- a/packages/plugin-undo-redo/.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-zh-en/.gitignore b/packages/plugin-zh-en/.gitignore deleted file mode 100644 index 2073a21..0000000 --- a/packages/plugin-zh-en/.gitignore +++ /dev/null @@ -1,106 +0,0 @@ -# project custom -build -dist -packages/*/lib/ -packages/*/es/ -packages/*/dist/ -packages/*/output/ -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 From 071831125bc563a670218effe20ff239e288f16c Mon Sep 17 00:00:00 2001 From: JackLian Date: Thu, 10 Nov 2022 17:45:47 +0800 Subject: [PATCH 051/169] chore: add repo info --- packages/plugin-set-ref-prop/package.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/plugin-set-ref-prop/package.json b/packages/plugin-set-ref-prop/package.json index 8f15c9b..b569466 100644 --- a/packages/plugin-set-ref-prop/package.json +++ b/packages/plugin-set-ref-prop/package.json @@ -2,6 +2,11 @@ "name": "@alilc/lowcode-plugin-set-ref-prop", "version": "1.0.0", "description": "alibaba lowcode editor plugin for setting ref-id", + "repository": { + "type": "git", + "url": "https://github.com/alibaba/lowcode-plugins.git", + "directory": "packages/plugin-set-ref-prop" + }, "files": [ "es", "lib" From 199fc5c5067e748423a6c5c4dc8d23adc65e0fc9 Mon Sep 17 00:00:00 2001 From: JackLian Date: Thu, 10 Nov 2022 18:06:54 +0800 Subject: [PATCH 052/169] chore: add repo info --- packages/action-block/package.json | 5 +++++ packages/base-monaco-editor/package.json | 7 ++++++- packages/plugin-block/package.json | 7 ++++++- packages/plugin-code-editor/package.json | 7 ++++++- packages/plugin-components-pane/package.json | 5 +++++ packages/plugin-datasource-pane/package.json | 7 ++++++- packages/plugin-manual/package.json | 7 ++++++- packages/plugin-schema/package.json | 7 ++++++- packages/plugin-undo-redo/package.json | 5 +++++ packages/plugin-zh-en/package.json | 5 +++++ 10 files changed, 56 insertions(+), 6 deletions(-) diff --git a/packages/action-block/package.json b/packages/action-block/package.json index 25e37fa..80aaf97 100644 --- a/packages/action-block/package.json +++ b/packages/action-block/package.json @@ -3,6 +3,11 @@ "version": "1.0.0-beta.0", "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", diff --git a/packages/base-monaco-editor/package.json b/packages/base-monaco-editor/package.json index bbbf077..c6153a3 100644 --- a/packages/base-monaco-editor/package.json +++ b/packages/base-monaco-editor/package.json @@ -62,5 +62,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.1/build/index.html", + "repository": { + "type": "git", + "url": "https://github.com/alibaba/lowcode-plugins.git", + "directory": "packages/base-monaco-editor" + } } 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-code-editor/package.json b/packages/plugin-code-editor/package.json index cb99343..d16a232 100644 --- a/packages/plugin-code-editor/package.json +++ b/packages/plugin-code-editor/package.json @@ -49,5 +49,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-components-pane/package.json b/packages/plugin-components-pane/package.json index 33b0615..28e9134 100644 --- a/packages/plugin-components-pane/package.json +++ b/packages/plugin-components-pane/package.json @@ -57,5 +57,10 @@ "classnames": "^2.3.1", "lodash.debounce": "^4.0.8", "react": "^16.0.0" + }, + "repository": { + "type": "git", + "url": "https://github.com/alibaba/lowcode-plugins.git", + "directory": "packages/plugin-components-pane" } } diff --git a/packages/plugin-datasource-pane/package.json b/packages/plugin-datasource-pane/package.json index 38a797f..fe5a1db 100644 --- a/packages/plugin-datasource-pane/package.json +++ b/packages/plugin-datasource-pane/package.json @@ -74,5 +74,10 @@ "traverse": "^0.6.6", "xstate": "^4.26.0" }, - "homepage": "https://unpkg.com/@alilc/lowcode-plugin-datasource-pane@1.0.6/build/index.html" + "homepage": "https://unpkg.com/@alilc/lowcode-plugin-datasource-pane@1.0.6/build/index.html", + "repository": { + "type": "git", + "url": "https://github.com/alibaba/lowcode-plugins.git", + "directory": "packages/plugin-datasource-pane" + } } diff --git a/packages/plugin-manual/package.json b/packages/plugin-manual/package.json index 0442c29..84a6bfd 100644 --- a/packages/plugin-manual/package.json +++ b/packages/plugin-manual/package.json @@ -30,5 +30,10 @@ "build-plugin-fusion": "^0.1.19", "@alilc/build-plugin-alt": "^1.0.0" }, - "license": "MIT" + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/alibaba/lowcode-plugins.git", + "directory": "packages/plugin-manual" + } } diff --git a/packages/plugin-schema/package.json b/packages/plugin-schema/package.json index 4aab007..80c15ed 100644 --- a/packages/plugin-schema/package.json +++ b/packages/plugin-schema/package.json @@ -37,5 +37,10 @@ "@types/react": "^16.0.3", "build-plugin-fusion": "^0.1.19" }, - "license": "MIT" + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/alibaba/lowcode-plugins.git", + "directory": "packages/plugin-schema" + } } diff --git a/packages/plugin-undo-redo/package.json b/packages/plugin-undo-redo/package.json index cacf19a..670306a 100644 --- a/packages/plugin-undo-redo/package.json +++ b/packages/plugin-undo-redo/package.json @@ -34,5 +34,10 @@ }, "publishConfig": { "access": "public" + }, + "repository": { + "type": "git", + "url": "https://github.com/alibaba/lowcode-plugins.git", + "directory": "packages/plugin-undo-redo" } } diff --git a/packages/plugin-zh-en/package.json b/packages/plugin-zh-en/package.json index 5c8c057..dcde3fe 100644 --- a/packages/plugin-zh-en/package.json +++ b/packages/plugin-zh-en/package.json @@ -29,5 +29,10 @@ }, "publishConfig": { "access": "public" + }, + "repository": { + "type": "git", + "url": "https://github.com/alibaba/lowcode-plugins.git", + "directory": "packages/plugin-zh-en" } } From f02abc63327f52c977e1da7ffc90b5ae80cf7b47 Mon Sep 17 00:00:00 2001 From: JackLian Date: Thu, 10 Nov 2022 19:10:51 +0800 Subject: [PATCH 053/169] chore: add types to package.json --- packages/plugin-set-ref-prop/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/plugin-set-ref-prop/package.json b/packages/plugin-set-ref-prop/package.json index b569466..8b5a5fe 100644 --- a/packages/plugin-set-ref-prop/package.json +++ b/packages/plugin-set-ref-prop/package.json @@ -1,6 +1,6 @@ { "name": "@alilc/lowcode-plugin-set-ref-prop", - "version": "1.0.0", + "version": "1.0.1", "description": "alibaba lowcode editor plugin for setting ref-id", "repository": { "type": "git", @@ -12,6 +12,7 @@ "lib" ], "main": "lib/index.js", + "types": "lib/index.d.ts", "module": "es/index.js", "scripts": { "start": "build-scripts start", From 857c49745dad4f973349928e4f619dfc02316194 Mon Sep 17 00:00:00 2001 From: sy296565890 <85245446+sy296565890@users.noreply.github.com> Date: Thu, 17 Nov 2022 14:18:17 +0800 Subject: [PATCH 054/169] Update JsEditor.tsx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 接入编辑器=>方法 2.2=> 使用 skeletonCabin.Workbench 方式初始化, 编辑index.js 源码时 光标总是在输入之前 --- .../plugin-code-editor/src/components/JSEditor/JsEditor.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/plugin-code-editor/src/components/JSEditor/JsEditor.tsx b/packages/plugin-code-editor/src/components/JSEditor/JsEditor.tsx index c84a816..f71ba23 100644 --- a/packages/plugin-code-editor/src/components/JSEditor/JsEditor.tsx +++ b/packages/plugin-code-editor/src/components/JSEditor/JsEditor.tsx @@ -250,7 +250,10 @@ export class JsEditor extends PureComponent { const pos = monacoEditor.getPosition(); this.setState({ errorInfo, hasError, code: newCode, errorLocation }, () => { - monacoEditor.setPosition(pos); + if(hasError) { + pos.column += 1; + monacoEditor.setPosition(pos); + } // update error decorations if (this.lastErrorDecoration) { From de6c4c02f1c32b9a7249ce8bfce7f8f5995a1cfa Mon Sep 17 00:00:00 2001 From: sy296565890 <85245446+sy296565890@users.noreply.github.com> Date: Thu, 17 Nov 2022 14:47:58 +0800 Subject: [PATCH 055/169] Update JsEditor.tsx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit monacoEditor.setPosition(pos); 多余的代码 导致每次输入或粘贴之后 光标总是停留在之前的位置 --- .../src/components/JSEditor/JsEditor.tsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/plugin-code-editor/src/components/JSEditor/JsEditor.tsx b/packages/plugin-code-editor/src/components/JSEditor/JsEditor.tsx index f71ba23..6eb275a 100644 --- a/packages/plugin-code-editor/src/components/JSEditor/JsEditor.tsx +++ b/packages/plugin-code-editor/src/components/JSEditor/JsEditor.tsx @@ -248,13 +248,9 @@ export class JsEditor extends PureComponent { return; } - const pos = monacoEditor.getPosition(); + // const pos = monacoEditor.getPosition(); this.setState({ errorInfo, hasError, code: newCode, errorLocation }, () => { - if(hasError) { - pos.column += 1; - monacoEditor.setPosition(pos); - } - + // monacoEditor.setPosition(pos); // update error decorations if (this.lastErrorDecoration) { monacoEditor.deltaDecorations( From 18dbe579310afdc230bd13bd5874019bbe3a6afd Mon Sep 17 00:00:00 2001 From: JackLian Date: Fri, 18 Nov 2022 09:42:12 +0800 Subject: [PATCH 056/169] fix: remove useless demo folder --- demo/build.json | 38 --- demo/build.plugin.js | 58 ----- demo/package.json | 45 ---- demo/public/assets.json | 139 ----------- demo/public/favicon.png | Bin 3612 -> 0 bytes demo/public/index.html | 41 ---- demo/public/mock-pages.json | 1 - demo/public/mock/info.json | 3 - demo/public/preview.html | 25 -- demo/public/schema.json | 291 ----------------------- demo/src/index.ts | 36 --- demo/src/preview.tsx | 63 ----- demo/src/sample-plugins/logo/index.scss | 11 - demo/src/sample-plugins/logo/index.tsx | 18 -- demo/src/setters/behavior-setter.tsx | 27 --- demo/src/setters/custom-setter.tsx | 12 - demo/src/universal/global.scss | 55 ----- demo/src/universal/plugin.tsx | 272 --------------------- demo/src/universal/utils.ts | 298 ------------------------ demo/tsconfig.json | 44 ---- 20 files changed, 1477 deletions(-) delete mode 100644 demo/build.json delete mode 100644 demo/build.plugin.js delete mode 100644 demo/package.json delete mode 100644 demo/public/assets.json delete mode 100644 demo/public/favicon.png delete mode 100644 demo/public/index.html delete mode 100644 demo/public/mock-pages.json delete mode 100644 demo/public/mock/info.json delete mode 100644 demo/public/preview.html delete mode 100644 demo/public/schema.json delete mode 100644 demo/src/index.ts delete mode 100644 demo/src/preview.tsx delete mode 100644 demo/src/sample-plugins/logo/index.scss delete mode 100644 demo/src/sample-plugins/logo/index.tsx delete mode 100644 demo/src/setters/behavior-setter.tsx delete mode 100644 demo/src/setters/custom-setter.tsx delete mode 100644 demo/src/universal/global.scss delete mode 100644 demo/src/universal/plugin.tsx delete mode 100644 demo/src/universal/utils.ts delete mode 100644 demo/tsconfig.json 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/assets.json b/demo/public/assets.json deleted file mode 100644 index 3cd9173..0000000 --- a/demo/public/assets.json +++ /dev/null @@ -1,139 +0,0 @@ -{ - "packages": [ - { - "package": "moment", - "version": "2.24.0", - "urls": [ - "https://g.alicdn.com/mylib/moment/2.24.0/min/moment.min.js" - ], - "library": "moment" - }, - { - "package": "lodash", - "library": "_", - "urls": [ - "https://g.alicdn.com/platform/c/lodash/4.6.1/lodash.min.js" - ] - }, - { - "title": "fusion组件库", - "package": "@alifd/next", - "version": "1.24.18", - "urls": [ - "https://g.alicdn.com/code/lib/alifd__next/1.24.18/next.min.css", - "https://g.alicdn.com/code/lib/alifd__next/1.24.18/next-with-locales.min.js" - ], - "library": "Next" - }, - { - "title": "NextTable", - "package": "NextTable", - "version": "1.0.1", - "urls": [ - "https://g.alicdn.com/fusion-platform/pro-table/1.0.1/next-table.js", - "https://g.alicdn.com/fusion-platform/pro-table/1.0.1/next-table.css" - ], - "library": "NextTable" - }, - { - "package": "@alilc/lowcode-materials", - "version": "1.0.2-beta.1", - "library": "AlilcLowcodeMaterials", - "urls": [ - "https://alifd.alicdn.com/npm/@alilc/lowcode-materials@1.0.2-beta.1/dist/AlilcLowcodeMaterials.js", - "https://alifd.alicdn.com/npm/@alilc/lowcode-materials@1.0.2-beta.1/dist/AlilcLowcodeMaterials.css" - ], - "editUrls": [ - "https://alifd.alicdn.com/npm/@alilc/lowcode-materials@1.0.2-beta.1/build/lowcode/view.js", - "https://alifd.alicdn.com/npm/@alilc/lowcode-materials@1.0.2-beta.1/build/lowcode/view.css" - ] - }, - { - "package": "@alifd/pro-layout", - "version": "1.0.1-beta.6", - "library": "AlifdProLayout", - "urls": [ - "https://alifd.alicdn.com/npm/@alifd/pro-layout@1.0.1-beta.6/dist/AlifdProLayout.js", - "https://alifd.alicdn.com/npm/@alifd/pro-layout@1.0.1-beta.6/dist/AlifdProLayout.css" - ], - "editUrls": [ - "https://alifd.alicdn.com/npm/@alifd/pro-layout@1.0.1-beta.6/build/lowcode/view.js", - "https://alifd.alicdn.com/npm/@alifd/pro-layout@1.0.1-beta.6/build/lowcode/view.css" - ] - }, - { - "package": "@alifd/fusion-ui", - "version": "1.0.5-beta.1", - "library": "AlifdFusionUi", - "urls": [ - "https://alifd.alicdn.com/npm/@alifd/fusion-ui@1.0.5-beta.1/dist/AlifdFusionUi.js", - "https://alifd.alicdn.com/npm/@alifd/fusion-ui@1.0.5-beta.1/dist/AlifdFusionUi.css" - ], - "editUrls": [ - "https://alifd.alicdn.com/npm/@alifd/fusion-ui@1.0.5-beta.1/build/lowcode/view.js", - "https://alifd.alicdn.com/npm/@alifd/fusion-ui@1.0.5-beta.1/build/lowcode/view.css" - ] - } - ], - "components": [ - { - "exportName": "AlilcLowcodeMaterialsMeta", - "npm": { - "package": "@alilc/lowcode-materials" - }, - "url": "https://alifd.alicdn.com/npm/@alilc/lowcode-materials@1.0.2-beta.1/build/lowcode/meta.js", - "urls": { - "default": "https://alifd.alicdn.com/npm/@alilc/lowcode-materials@1.0.2-beta.1/build/lowcode/meta.js", - "design": "https://alifd.alicdn.com/npm/@alilc/lowcode-materials@1.0.2-beta.1/build/lowcode/meta.design.js" - } - }, - { - "exportName": "AlifdProLayoutMeta", - "npm": { - "package": "@alifd/pro-layout", - "version": "1.0.1-beta.6" - }, - "url": "https://alifd.alicdn.com/npm/@alifd/pro-layout@1.0.1-beta.6/build/lowcode/meta.js", - "urls": { - "default": "https://alifd.alicdn.com/npm/@alifd/pro-layout@1.0.1-beta.6/build/lowcode/meta.js", - "design": "https://alifd.alicdn.com/npm/@alifd/pro-layout@1.0.1-beta.6/build/lowcode/meta.design.js" - } - }, - { - "exportName": "AlifdFusionUiMeta", - "npm": { - "package": "@alifd/fusion-ui" - }, - "url": "https://alifd.alicdn.com/npm/@alifd/fusion-ui@1.0.5-beta.1/build/lowcode/meta.js", - "urls": { - "default": "https://alifd.alicdn.com/npm/@alifd/fusion-ui@1.0.5-beta.1/build/lowcode/meta.js", - "design": "https://alifd.alicdn.com/npm/@alifd/fusion-ui@1.0.5-beta.1/build/lowcode/meta.design.js" - } - } - ], - "sort": { - "groupList": [ - "精选组件", - "原子组件" - ], - "categoryList": [ - "基础元素", - "布局容器类", - "表格类", - "表单详情类", - "帮助类", - "对话框类", - "业务类", - "通用", - "引导", - "信息输入", - "信息展示", - "信息反馈" - ] - }, - "groupList": [ - "精选组件", - "原子组件" - ], - "ignoreComponents": {} -} diff --git a/demo/public/favicon.png b/demo/public/favicon.png deleted file mode 100644 index 307ffbd82dba398d6db6459102bff331eef7df6b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3612 zcmV+%4&(8OP)Px#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR91TA%{}1ONa40RR91S^xk507-m{w*UYQhDk(0RCodHT?>#D#Towp*}H|i z+dTn!mde8i1wu-BR8XSvS)#mzvO>hDgg^x>qli)9_Kq+LcPJ3Bu+SK-ynID85>dgJ zf)ItMP%%POG)f4F%3HbJz2lbM?R>q<9(%hpvoo`^$1F!z?agfW|Ns5>H@$y%|NT!N z)9I8O0kys}9V_WeB7QCjaV`-)%ss()2JZ3U%EY}OCKh25^exJF;@jsa+eD=m&vNcs z+8Bi@I#8tHdjNF^fEtX}4+gmB!oBs2;z-h|Ic09)=5q&i}FecJ(A2&TE=5fm5G(0gxyZEdH6iu2h_ zJ5PO}Rndte;mJhtI{@%`&ZB5b;y0%*&~w8>C>pyHqyEk4y=A80C>Rkpo_d2}APn0Z z`vpM$ZW1@AMzs8%!l?uF-0&cZ#+Q(YU7a5!1>j~nT>L<*4QEp%S__bGgNbmbDHL?D zc!5q%(PmRq>|XRi*kE^<2+iLE7c0;;;j#2>=t+RvRkLC4%RE$EJ$gCjzI#K9DHglS zeOMZ5R79pjJ=zx_zkpTT#fD9CW1*mZ$u+$jl}p#DIy8xzBJUR^$g&*@ZFlD=odQ`E zK8ge%$2fOuDyulJJixs`2f{tzOEWnqjtV>cMgWq9ydk)0#$pb)OGC2 zyd5S;I^_@Jm(l@C^gfV%VZr9$OrMgxyy6}LKnkatcPA59cwD{W7OGqAKlB1Ib~J_y8w|V z(BsGFq%}`aO$#gQ+ynI7-~fuz1~k&So~-aRs`dZcJSL!&e(UPcGF)d^;?pO-3_x#k z&U92aoJAbJ4vzIcP_j3Es=aY-kL$P40h^Wh2!VU$OZ3`ZRN~o1W#zjmz=tRh9t>Z_ z>u9BOATvK;8Dt3-vw)s60d`MZ^Xu76A?oGdoDeJj*iI_;)*=lf;8d5p7NY@_$GR+x z$|Opy^BHmQR*dw6F$l$ts0_#@IJscGzkIqrLKORm9_ zztJAZQU#|$hDhewd4Vj|Qn?=J)XH1ii4{5CB$7R#tLn#5{1{ehG&Cj1HCN`ZskY)x zNAxN6{RU61$+j$o*QI!^104v>1oNuo95f}yRoB%CJL`l>Du*EE@3urSA0SWp))cQb zpaUV;W3eQ~?9yvu-s+fcEdFg%)=TN;%RJEP(ep7|cpmoHJdaHc^I{X?i@f-=n3a85 zS!ObXcs`xX9B8WWV&(KQ7(1pjyYk-Su|Lz$YLKuK|G|5x&c88ToH?K)p(>b+@1!%j z_FlxhJE|Mg*_P$8cp-C~$PIK&us+@u)9l)7QFbbQk(&@iM-USUU$Y~z z(@$d;<#r>8PM8k)(u@$+wtb8wySYs6ehcd55XeDd&+J^yJpuH=@H`NopNrvic?JTk z%%{4FuQPJ9z9#3<~?2N zQD&F{Spucd2jL%~HxD_DnneVdUZn+?!I(_2(c-5jX-|`-5MaW_ZRw2ES2I@$^hIU} zPt&9!Ab1KbDBGEqlk--=G$*Ga&ncx%5%6+a=zqy-ljZbolU1fROV6|!fjRfvX}^Nu z@L{+EUHnRuon{q;=NsbE3E0_=*pZG{oXU-`)6=llkJ=H?Hh9nx70)E9E!$9Bm&2;z=LrvB2-VO*34&C5jyZdzE$Q1+DZ*F{8q%WHYTlza1|{p z3#rcMNCdzMr;-yb^p<}J(-U(-)Jd1Yw9F}xWm}vDT8_vpcAs>R@>M{-j!{=>V+UNn zVrPL))WiSMudWD6n4hCs-_M-Zv;aWkJ(QwNa!bm0M`k#e6V0&4E`?wy@F}co(!2pRl&bu%6DZ}elcXU z^H%`u2B%du)uRQi#7jV-XHofakfj=lqa){QDx`?zn)$_$8ExuO2sLv8odkKy)2Muc zh61+;3S=u*Te%7gns+tm-Jc~Q+3j&aYeS%6E>OPZcj&znwd;~mrcoSurjb0#beNV# zjS_cf#o5{T>f^1|1v&|G__qN0R%2wubU{nYvS{Y}wjy8!zLO$LOs&_W@#-iBNjdNd z!=R8PgyKx1y^}TJto1#OsgewqES|*FIz2iG@+=uhqYa)GWL@?y6rHA?tyM(5eDZa< z)tY5)%#4e|_vqswBO+2vHHATkZ-{QjI63hTl{9Gc22CCr^HAp>2Q%_uQOvKIr6P=(QnL6x-x1jUm>r*5A3!InnSvDC$&IC3sHSD&_svj zDiL7kND|}`YvA{bXA_n;Fb)03O40qti8uPQ36P`m;e;c-lfM@>4ekNxZ@Ft4h+{1Z zkR-UxNzkkXI1-||IV1Dtyw7lcIL0+t0>iZDoEWVeGm?)y_NF0Ss_+S%aImLwFm`W- zvlo+-HX+xPp1~GY%sTSVjPcA0FY%XasxeJ z+g%C3?6$dG6VY{R+ta|UnEHkH2)ciBY>OL-nU?~%Wok1G@Miq5B zX!tM;xRXV3u)lsIQP7`8D&!!057B-MzI1n5!HHWOZjB(G)=BcT#g0BK)(V%5f$q6; zN?uhU&G{i*9dOdD*b1ju;#cE<$< z0&o(5UJ~32rh|9mS92|??LXI3!>N2-psAr`9xBN>{nJ$BSSisfSc&gAU$gjlCVU?4 z^nb1jOh-WzZ-Drrg|y4*>g$`1PKQRN6PmscV+Qx?c$nXA1}q$ejlP~~!A@NwdCFEn z5>6gaxCa0FZYkUW8h(U=RH{7~iaSfbPo4%KW-;xD&-^tEe4+G#FH1%UIX5sZc_*tR zJtJNK)4}{cdFXbU@6$I~={h)guWdTQzH2Sj!4xH-JVGx{jO73sD=r?%w0Kia`Dd0n zXF6o;xAb9neZy$JztusOZPfZV8PepGabK+9{gy0CdE9B`g}50qGU8c zep{a=tt5F2F&<2wNgmA2%B2ZM5f04GQ<`mdZ5!P=@-pr7?xNC2uNIPV!V&#`cUPJHzcr5%K8(PTA^(8r%Hd@r^OOPu)!m&GEUkz-rMJJ8ESi2>fK*KG6 zRLqJD$JrH+K=37)0&Pd%UrnU|cQL`MrkCJrPI~*&2xKGqMnp8NOUpEOo0#H>mJizu zC-Wz8NKKXJHk%=D4H`|LWyQRRzQSdKMJ3jP{?0TWI67!NK>ll5p7~oAU*RDSG0l*$ z#k7dJ`5x3ea>ukRhY59owpUNZ985VX!Fvln*d zf&lGk3j)CjFdxqWOzD7XnV2`?o$RT!p#7&U3*7h3{Xk31 - - - - - - Codestin Search App - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - 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 @@ - - - - - - Codestin Search App - - - - -
- - - - - - - - - - diff --git a/demo/public/schema.json b/demo/public/schema.json deleted file mode 100644 index 4877ead..0000000 --- a/demo/public/schema.json +++ /dev/null @@ -1,291 +0,0 @@ -{ - "componentName": "Page", - "id": "node_dockcviv8fo1", - "props": { - "ref": "outerView", - "style": { - "height": "100%" - } - }, - "fileName": "/", - "dataSource": { - "list": [ - { - "type": "fetch", - "isInit": true, - "options": { - "params": {}, - "method": "GET", - "isCors": true, - "timeout": 5000, - "headers": {}, - "uri": "mock/info.json" - }, - "id": "info" - } - ] - }, - "state": { - "text": { - "type": "JSExpression", - "value": "\"outer\"" - }, - "isShowDialog": { - "type": "JSExpression", - "value": "false" - } - }, - "css": "body {\n font-size: 12px;\n}\n\n.button {\n width: 100px;\n color: #ff00ff\n}", - "lifeCycles": { - "componentDidMount": { - "type": "JSFunction", - "value": "function componentDidMount() {\n console.log('did mount');\n}" - }, - "componentWillUnmount": { - "type": "JSFunction", - "value": "function componentWillUnmount() {\n console.log('will unmount');\n}" - } - }, - "methods": { - "testFunc": { - "type": "JSFunction", - "value": "function testFunc() {\n console.log('test func');\n}" - }, - "onClick": { - "type": "JSFunction", - "value": "function onClick() {\n this.setState({\n isShowDialog: true\n });\n}" - }, - "closeDialog": { - "type": "JSFunction", - "value": "function closeDialog() {\n this.setState({\n isShowDialog: false\n });\n}" - } - }, - "originCode": "class LowcodeComponent extends Component {\n state = {\n \"text\": \"outer\",\n \"isShowDialog\": false\n }\n componentDidMount() {\n console.log('did mount');\n }\n componentWillUnmount() {\n console.log('will unmount');\n }\n testFunc() {\n console.log('test func');\n }\n onClick() {\n this.setState({\n isShowDialog: true\n })\n }\n closeDialog() {\n this.setState({\n isShowDialog: false\n })\n }\n}", - "hidden": false, - "title": "", - "isLocked": false, - "condition": true, - "conditionGroup": "", - "children": [ - { - "componentName": "NextPage", - "id": "node_ockzs2vw431", - "props": { - "headerDivider": true, - "minHeight": "100vh", - "presetNav": true, - "presetAside": true, - "footer": false, - "nav": false, - "aside": false, - "placeholderStyle": { - "gridRowEnd": "span 1", - "gridColumnEnd": "span 12" - }, - "headerProps": { - "background": "surface" - }, - "header": { - "type": "JSSlot", - "value": [ - { - "componentName": "NextPageHeader", - "id": "node_ockzs2vw433", - "props": {}, - "title": "页面头部", - "hidden": false, - "isLocked": false, - "condition": true, - "conditionGroup": "", - "children": [ - { - "componentName": "NextRowColContainer", - "id": "node_ockzs2vw434", - "props": { - "rowGap": 20, - "colGap": 20 - }, - "title": "行列容器", - "hidden": false, - "isLocked": false, - "condition": true, - "conditionGroup": "", - "children": [ - { - "componentName": "NextRow", - "id": "node_ockzs2vw435", - "props": {}, - "title": "行", - "hidden": false, - "isLocked": false, - "condition": true, - "conditionGroup": "", - "children": [ - { - "componentName": "NextCol", - "id": "node_ockzs2vw436", - "props": { - "colSpan": 1 - }, - "title": "列", - "hidden": false, - "isLocked": false, - "condition": true, - "conditionGroup": "", - "children": [ - { - "componentName": "NextP", - "id": "node_ockzvfoetv17", - "props": { - "wrap": false, - "type": "body2", - "verAlign": "middle", - "textSpacing": true, - "align": "left" - }, - "docId": "dockzvfoetv", - "title": "段落", - "hidden": false, - "isLocked": false, - "condition": true, - "conditionGroup": "", - "children": [ - { - "componentName": "NextText", - "id": "node_ockzvfoetv18", - "props": { - "type": "h5", - "children": { - "type": "JSExpression", - "value": "this.state.info?.info", - "mock": "标题标题" - }, - "mark": false, - "code": false, - "delete": false, - "underline": false, - "strong": false - }, - "docId": "dockzvfoetv", - "hidden": false, - "title": "", - "isLocked": false, - "condition": true, - "conditionGroup": "" - } - ] - } - ] - } - ] - } - ] - } - ] - } - ], - "title": "header" - }, - "isTab": false, - "contentAlignCenter": false, - "contentProps": { - "style": { - "background": "rgba(255,255,255,0)" - } - } - }, - "title": "页面", - "hidden": false, - "isLocked": false, - "condition": true, - "conditionGroup": "", - "children": [ - { - "componentName": "NextBlock", - "id": "node_ockzs2vw437", - "props": { - "placeholderStyle": { - "height": "100%" - }, - "noPadding": false, - "noBorder": false, - "title": "区域标题", - "rowGap": 20, - "colGap": 20, - "background": "surface", - "layoutmode": "O", - "strict": true, - "colSpan": 12, - "rowSpan": 1, - "mode": "transparent", - "childTotalColumns": 12 - }, - "title": "区域", - "hidden": false, - "isLocked": false, - "condition": true, - "conditionGroup": "", - "children": [ - { - "componentName": "NextBlockCell", - "id": "node_ockzs2vw438", - "props": { - "colSpan": 12, - "rowSpan": 1, - "mode": "procard", - "isAutoContainer": true, - "title": "区块标题" - }, - "hidden": false, - "title": "", - "isLocked": false, - "condition": true, - "conditionGroup": "", - "children": [ - { - "componentName": "NextRowColContainer", - "id": "node_ockzs2vw439", - "props": { - "rowGap": 20, - "colGap": 20 - }, - "title": "行列容器", - "hidden": false, - "isLocked": false, - "condition": true, - "conditionGroup": "", - "children": [ - { - "componentName": "NextRow", - "id": "node_ockzs2vw43a", - "props": {}, - "title": "行", - "hidden": false, - "isLocked": false, - "condition": true, - "conditionGroup": "", - "children": [ - { - "componentName": "NextCol", - "id": "node_ockzs2vw43b", - "props": { - "colSpan": 1 - }, - "title": "列", - "hidden": false, - "isLocked": false, - "condition": true, - "conditionGroup": "" - } - ] - } - ] - } - ] - } - ] - } - ] - } - ] -} \ No newline at end of file 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/sample-plugins/logo/index.scss b/demo/src/sample-plugins/logo/index.scss deleted file mode 100644 index 3140ac3..0000000 --- a/demo/src/sample-plugins/logo/index.scss +++ /dev/null @@ -1,11 +0,0 @@ -.lowcode-plugin-logo { - .logo { - display: block; - width: 139px; - height: 26px; - cursor: pointer; - background-size: contain; - background-position: center; - background-repeat: no-repeat; - } -} diff --git a/demo/src/sample-plugins/logo/index.tsx b/demo/src/sample-plugins/logo/index.tsx deleted file mode 100644 index ff4bbe2..0000000 --- a/demo/src/sample-plugins/logo/index.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import React from 'react'; -import './index.scss'; -import { PluginProps } from '@alilc/lowcode-types'; - -export interface IProps { - logo?: string; - href?: string; -} - -const Logo: React.FC = (props): React.ReactElement => { - return ( -
- ); -}; - -export default Logo; diff --git a/demo/src/setters/behavior-setter.tsx b/demo/src/setters/behavior-setter.tsx deleted file mode 100644 index 1ab0114..0000000 --- a/demo/src/setters/behavior-setter.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import * as React from 'react'; -import BehaviorSetter from '@alilc/lowcode-setter-behavior'; - - -const defaultExtraBehaviorActions: any[] = []; -class LocalBehaviorSetter extends React.Component { - render() { - // ignore url && responseFormatter props, use default ones - const { url: propsUrl, responseFormatter: propsFormatter, extraBehaviorActions: propsExtraBehaviorActions = [], ...otherProps } = this.props; - const url = 'https://hn.algolia.com/api/v1/search?query'; - const responseFormatter = (response) => response.hits.map((item) => ({ - label: item.title, - value: item.author - })); - const extraBehaviorActions = propsExtraBehaviorActions.concat(defaultExtraBehaviorActions); - return ( - - ); - } -} - -export default LocalBehaviorSetter; diff --git a/demo/src/setters/custom-setter.tsx b/demo/src/setters/custom-setter.tsx deleted file mode 100644 index 0383473..0000000 --- a/demo/src/setters/custom-setter.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import React, { Component } from 'react'; // import classNames from 'classnames'; - -class CustomSetter extends Component { - render() { - const { defaultValue, value, onChange } = this.props; - const { editor } = this.props.field; - - return
hello world
; - } -} - -export default CustomSetter; 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/src/universal/plugin.tsx b/demo/src/universal/plugin.tsx deleted file mode 100644 index c79351f..0000000 --- a/demo/src/universal/plugin.tsx +++ /dev/null @@ -1,272 +0,0 @@ -import React from 'react'; -import { - ILowCodePluginContext, - plugins, - skeleton, - project, - setters, -} from '@alilc/lowcode-engine'; -import { Button } from '@alifd/next'; -import UndoRedoPlugin from '@alilc/lowcode-plugin-undo-redo'; -import ComponentsPane from '@alilc/lowcode-plugin-components-pane'; -import ZhEnPlugin from '@alilc/lowcode-plugin-zh-en'; -import CodeGenPlugin from '@alilc/lowcode-plugin-code-generator'; -import DataSourcePanePlugin from '../../../packages/plugin-datasource-pane/src'; -import SchemaPlugin from '@alilc/lowcode-plugin-schema'; -import CodeEditor from "@alilc/lowcode-plugin-code-editor"; -import ManualPlugin from "@alilc/lowcode-plugin-manual"; -import Inject, { injectAssets } from '@alilc/lowcode-plugin-inject'; -import SimulatorResizer from '@alilc/lowcode-plugin-simulator-select'; - -// 注册到引擎 -import TitleSetter from '@alilc/lowcode-setter-title'; -import BehaviorSetter from '../setters/behavior-setter'; -import CustomSetter from '../setters/custom-setter'; -import Logo from '../sample-plugins/logo'; - -import { - loadIncrementalAssets, - getPageSchema, - saveSchema, - resetSchema, - preview, -} from './utils'; -import assets from '../../public/assets.json' - -export default async function registerPlugins() { - await plugins.register(ManualPlugin); - - await plugins.register(Inject); - - // plugin API 见 https://lowcode-engine.cn/docV2/ibh9fh - SchemaPlugin.pluginName = 'SchemaPlugin'; - await plugins.register(SchemaPlugin); - - SimulatorResizer.pluginName = 'SimulatorResizer'; - plugins.register(SimulatorResizer); - - const editorInit = (ctx: ILowCodePluginContext) => { - return { - name: 'editor-init', - async init() { - // 修改面包屑组件的分隔符属性setter - // const assets = await ( - // await fetch( - // `https://alifd.alicdn.com/npm/@alilc/lowcode-materials/build/lowcode/assets-prod.json` - // ) - // ).json(); - // 设置物料描述 - const { material, project } = ctx; - - material.setAssets(await injectAssets(assets)); - - const schema = await getPageSchema(); - - // 加载 schema - project.openDocument(schema); - }, - }; - } - editorInit.pluginName = 'editorInit'; - await plugins.register(editorInit); - - const builtinPluginRegistry = (ctx: ILowCodePluginContext) => { - return { - name: 'builtin-plugin-registry', - async init() { - const { skeleton } = ctx; - // 注册 logo 面板 - skeleton.add({ - area: 'topArea', - type: 'Widget', - name: 'logo', - content: Logo, - contentProps: { - logo: 'https://img.alicdn.com/imgextra/i4/O1CN013w2bmQ25WAIha4Hx9_!!6000000007533-55-tps-137-26.svg', - href: '/', - }, - props: { - align: 'left', - }, - }); - - // 注册组件面板 - const componentsPane = skeleton.add({ - area: 'leftArea', - type: 'PanelDock', - name: 'componentsPane', - content: ComponentsPane, - contentProps: {}, - props: { - align: 'top', - icon: 'zujianku', - description: '组件库', - }, - }); - componentsPane?.disable?.(); - project.onSimulatorRendererReady(() => { - componentsPane?.enable?.(); - }) - }, - }; - } - builtinPluginRegistry.pluginName = 'builtinPluginRegistry'; - await plugins.register(builtinPluginRegistry); - - // 设置内置 setter 和事件绑定、插件绑定面板 - const setterRegistry = (ctx: ILowCodePluginContext) => { - const { setterMap, pluginMap } = window.AliLowCodeEngineExt; - return { - name: 'ext-setters-registry', - async init() { - const { setters, skeleton } = ctx; - // 注册setterMap - setters.registerSetter(setterMap); - // 注册插件 - // 注册事件绑定面板 - skeleton.add({ - area: 'centerArea', - type: 'Widget', - content: pluginMap.EventBindDialog, - name: 'eventBindDialog', - props: {}, - }); - - // 注册变量绑定面板 - skeleton.add({ - area: 'centerArea', - type: 'Widget', - content: pluginMap.VariableBindDialog, - name: 'variableBindDialog', - props: {}, - }); - }, - }; - } - setterRegistry.pluginName = 'setterRegistry'; - await plugins.register(setterRegistry); - - // 注册回退/前进 - await plugins.register(UndoRedoPlugin); - - // 注册中英文切换 - await plugins.register(ZhEnPlugin); - - const loadAssetsSample = (ctx: ILowCodePluginContext) => { - return { - name: 'loadAssetsSample', - async init() { - const { skeleton } = ctx; - - skeleton.add({ - name: 'loadAssetsSample', - area: 'topArea', - type: 'Widget', - props: { - align: 'right', - width: 80, - }, - content: ( - - ), - }); - }, - }; - }; - loadAssetsSample.pluginName = 'loadAssetsSample'; - await plugins.register(loadAssetsSample); - - // 注册保存面板 - const saveSample = (ctx: ILowCodePluginContext) => { - return { - name: 'saveSample', - async init() { - const { skeleton, hotkey } = ctx; - - skeleton.add({ - name: 'saveSample', - area: 'topArea', - type: 'Widget', - props: { - align: 'right', - }, - content: ( - - ), - }); - skeleton.add({ - name: 'resetSchema', - area: 'topArea', - type: 'Widget', - props: { - align: 'right', - }, - content: ( - - ), - }); - hotkey.bind('command+s', (e) => { - e.preventDefault(); - saveSchema(); - }); - }, - }; - } - saveSample.pluginName = 'saveSample'; - await plugins.register(saveSample); - - DataSourcePanePlugin.pluginName = 'DataSourcePane'; - await plugins.register(DataSourcePanePlugin); - - CodeEditor.pluginName = 'CodeEditor'; - await plugins.register(CodeEditor); - - // 注册出码插件 - CodeGenPlugin.pluginName = 'CodeGenPlugin'; - await plugins.register(CodeGenPlugin); - - const previewSample = (ctx: ILowCodePluginContext) => { - return { - name: 'previewSample', - async init() { - const { skeleton } = ctx; - skeleton.add({ - name: 'previewSample', - area: 'topArea', - type: 'Widget', - props: { - align: 'right', - }, - content: ( - - ), - }); - }, - }; - }; - previewSample.pluginName = 'previewSample'; - await plugins.register(previewSample); - - const customSetter = (ctx: ILowCodePluginContext) => { - return { - name: '___registerCustomSetter___', - async init() { - const { setters } = ctx; - - setters.registerSetter('TitleSetter', TitleSetter); - setters.registerSetter('BehaviorSetter', BehaviorSetter); - setters.registerSetter('CustomSetter', CustomSetter); - }, - }; - } - customSetter.pluginName = 'customSetter'; - await plugins.register(customSetter); -}; diff --git a/demo/src/universal/utils.ts b/demo/src/universal/utils.ts deleted file mode 100644 index 9baf0f8..0000000 --- a/demo/src/universal/utils.ts +++ /dev/null @@ -1,298 +0,0 @@ -import { material, project } from '@alilc/lowcode-engine'; -import { filterPackages } from '@alilc/lowcode-plugin-inject' -import { Message, Dialog } from '@alifd/next'; - -export const loadIncrementalAssets = () => { - material?.onChangeAssets(() => { - Message.success('[MCBreadcrumb] 物料加载成功'); - }); - - material.loadIncrementalAssets({ - packages: [ - { - title: 'MCBreadcrumb', - package: 'mc-breadcrumb', - version: '1.0.0', - urls: [ - 'https://unpkg.alibaba-inc.com/mc-breadcrumb@1.0.0/dist/MCBreadcrumb.js', - 'https://unpkg.alibaba-inc.com/mc-breadcrumb@1.0.0/dist/MCBreadcrumb.css', - ], - library: 'MCBreadcrumb', - }, - ], - components: [ - { - componentName: 'MCBreadcrumb', - title: 'MCBreadcrumb', - docUrl: '', - screenshot: '', - npm: { - package: 'mc-breadcrumb', - version: '1.0.0', - exportName: 'MCBreadcrumb', - main: 'lib/index.js', - destructuring: false, - subName: '', - }, - props: [ - { - name: 'prefix', - propType: 'string', - description: '样式类名的品牌前缀', - defaultValue: 'next-', - }, - { - name: 'title', - propType: 'string', - description: '标题', - defaultValue: 'next-', - }, - { - name: 'rtl', - propType: 'bool', - }, - { - name: 'children', - propType: { - type: 'instanceOf', - value: 'node', - }, - description: '面包屑子节点,需传入 Breadcrumb.Item', - }, - { - name: 'maxNode', - propType: { - type: 'oneOfType', - value: [ - 'number', - { - type: 'oneOf', - value: ['auto'], - }, - ], - }, - description: - '面包屑最多显示个数,超出部分会被隐藏, 设置为 auto 会自动根据父元素的宽度适配。', - defaultValue: 100, - }, - { - name: 'separator', - propType: { - type: 'instanceOf', - value: 'node', - }, - description: '分隔符,可以是文本或 Icon', - }, - { - name: 'component', - propType: { - type: 'oneOfType', - value: ['string', 'func'], - }, - description: '设置标签类型', - defaultValue: 'nav', - }, - { - name: 'className', - propType: 'any', - }, - { - name: 'style', - propType: 'object', - }, - ], - configure: { - component: { - isContainer: true, - isModel: true, - rootSelector: 'div.MCBreadcrumb', - }, - }, - }, - ], - - componentList: [ - { - title: '常用', - icon: '', - children: [ - { - componentName: 'MCBreadcrumb', - title: 'MC面包屑', - icon: '', - package: 'mc-breadcrumb', - library: 'MCBreadcrumb', - snippets: [ - { - title: 'MC面包屑', - screenshot: - 'https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_breadcrumb.png', - schema: { - componentName: 'MCBreadcrumb', - props: { - title: '物料中心', - prefix: 'next-', - maxNode: 100, - }, - }, - }, - ], - }, - ], - }, - ], - }); -}; - -export const preview = () => { - saveSchema(); - setTimeout(() => { - window.open(`./preview.html${location.search}`); - }, 500); -}; - -export const saveSchema = async () => { - window.localStorage.setItem( - 'projectSchema', - JSON.stringify(project.exportSchema()) - ); - const packages = await filterPackages(material.getAssets().packages); - window.localStorage.setItem( - 'packages', - JSON.stringify(packages) - ); - Message.success('成功保存到本地'); -}; - -export const resetSchema = async () => { - try { - await new Promise((resolve, reject) => { - Dialog.confirm({ - content: '确定要重置吗?您所有的修改都将消失!', - onOk: () => { - resolve(); - }, - onCancel: () => { - reject() - }, - }) - }) - } catch(err) { - return - } - - let schema - try { - schema = await request('./schema.json') - } catch(err) { - schema = { - componentName: 'Page', - fileName: 'sample', - } - } - - window.localStorage.setItem( - 'projectSchema', - JSON.stringify({ - componentsTree: [schema], - componentsMap: material.componentsMap, - version: '1.0.0', - i18n: {}, - }) - ); - - project.getCurrentDocument()?.importSchema(schema); - project.simulatorHost?.rerender(); - Message.success('成功重置页面'); -} - -export const getPageSchema = async () => { - const schema = JSON.parse( - window.localStorage.getItem('projectSchema') || '{}' - ); - - const pageSchema = schema?.componentsTree?.[0]; - - if (pageSchema) { - return pageSchema; - } - return await request('./schema.json'); -}; - -function request( - dataAPI: string, - method = 'GET', - data?: object | string, - headers?: object, - otherProps?: any, -): Promise { - return new Promise((resolve, reject): void => { - if (otherProps && otherProps.timeout) { - setTimeout((): void => { - reject(new Error('timeout')); - }, otherProps.timeout); - } - fetch(dataAPI, { - method, - credentials: 'include', - headers, - body: data, - ...otherProps, - }) - .then((response: Response): any => { - switch (response.status) { - case 200: - case 201: - case 202: - return response.json(); - case 204: - if (method === 'DELETE') { - return { - success: true, - }; - } else { - return { - __success: false, - code: response.status, - }; - } - case 400: - case 401: - case 403: - case 404: - case 406: - case 410: - case 422: - case 500: - return response - .json() - .then((res: object): any => { - return { - __success: false, - code: response.status, - data: res, - }; - }) - .catch((): object => { - return { - __success: false, - code: response.status, - }; - }); - default: - return null; - } - }) - .then((json: any): void => { - if (json && json.__success !== false) { - resolve(json); - } else { - delete json.__success; - reject(json); - } - }) - .catch((err: Error): void => { - reject(err); - }); - }); -} \ No newline at end of file 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"] -} From 9bdc7fd1033169314d0b8cfefdd6c9c0f41a82e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?LeoYuan=20=E8=A2=81=E5=8A=9B=E7=9A=93?= Date: Wed, 16 Nov 2022 14:29:30 +0800 Subject: [PATCH 057/169] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BB=8E=20sc?= =?UTF-8?q?hema2code=20=E6=97=B6,=20state=20=E6=81=A2=E5=A4=8D=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.js | 14 ++++++-- packages/plugin-code-editor/.editorconfig | 13 ++++++++ packages/plugin-code-editor/.eslintignore | 7 ++++ packages/plugin-code-editor/.eslintrc.js | 11 +++++++ packages/plugin-code-editor/CHANGELOG.md | 4 +++ packages/plugin-code-editor/package.json | 2 +- .../src/config/default-code.ts | 2 +- packages/plugin-code-editor/src/index.tsx | 6 ++-- .../plugin-code-editor/src/types/methods.ts | 11 ++++--- .../plugin-code-editor/src/types/state.ts | 6 ++-- .../src/{typeings.d.ts => typings.d.ts} | 0 .../plugin-code-editor/src/utils/evaluate.ts | 32 +++++++++++++++++++ .../src/utils/get-methods.ts | 3 +- .../src/utils/schema-to-code.ts | 31 +++++++++--------- .../src/utils/state-parser.ts | 3 +- .../plugin-code-editor/src/utils/transform.ts | 1 - 16 files changed, 111 insertions(+), 35 deletions(-) create mode 100644 packages/plugin-code-editor/.editorconfig create mode 100644 packages/plugin-code-editor/.eslintignore create mode 100644 packages/plugin-code-editor/.eslintrc.js rename packages/plugin-code-editor/src/{typeings.d.ts => typings.d.ts} (100%) create mode 100644 packages/plugin-code-editor/src/utils/evaluate.ts 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/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/CHANGELOG.md b/packages/plugin-code-editor/CHANGELOG.md index ce9b400..110aac0 100644 --- a/packages/plugin-code-editor/CHANGELOG.md +++ b/packages/plugin-code-editor/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.4 / 2022-11-18 + +- 修复从 schema2code 时, state 恢复错误的问题 + ## 1.0.3 / 2022-07-11 - Fix 源码面板高度塌陷的 [bug](https://github.com/alibaba/lowcode-engine/issues/803) diff --git a/packages/plugin-code-editor/package.json b/packages/plugin-code-editor/package.json index d16a232..e507c0d 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.4", "description": "CodeEditor", "files": [ "es", 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..d7caf4c 100644 --- a/packages/plugin-code-editor/src/index.tsx +++ b/packages/plugin-code-editor/src/index.tsx @@ -14,7 +14,7 @@ const plugin = (ctx: ILowCodePluginContext) => { }, // 插件的初始化函数,在引擎初始化之后会立刻调用 init() { - const schemaDock = ctx.skeleton.add({ + const codeEditorDock = ctx.skeleton.add({ area: 'leftArea', name: 'codeEditor', type: 'PanelDock', @@ -35,9 +35,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/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..75bddbb 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,23 +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 statesStr = 'state = {\n'; let needNotice = false; - Object.keys(componentSchema.state).forEach((item) => { - const state = componentSchema.state?.[item]; + 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) { + if (!(state as IState).source) { 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({ @@ -54,10 +55,10 @@ function initStateCode(componentSchema: RootSchema | undefined) { content: WORDS.irreparableState, }); } - return `state = ${JSON.stringify(states)}`; + statesStr += '}'; + return statesStr; } - return defaultStateCode; } function initLifeCycleCode(componentSchema: RootSchema | undefined) { @@ -100,10 +101,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'; From 982f9b55d951893078156bb7cb063731a2284d2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?LeoYuan=20=E8=A2=81=E5=8A=9B=E7=9A=93?= Date: Fri, 18 Nov 2022 11:06:07 +0800 Subject: [PATCH 058/169] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4=20skipDemo=20?= =?UTF-8?q?=E7=9A=84=E5=91=BD=E4=BB=A4=E8=A1=8C=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/plugin-code-editor/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin-code-editor/package.json b/packages/plugin-code-editor/package.json index e507c0d..3afea15 100644 --- a/packages/plugin-code-editor/package.json +++ b/packages/plugin-code-editor/package.json @@ -14,7 +14,7 @@ "scripts": { "start": "build-scripts start --config build.js", "prepublishOnly": "npm run build", - "build": "build-scripts build --skip-demo --config build.js" + "build": "build-scripts build --config build.js" }, "publishConfig": { "access": "public" From dfa5bf15b45517b1425947b83484f778c6b44631 Mon Sep 17 00:00:00 2001 From: "humphry.hy" Date: Fri, 18 Nov 2022 11:05:09 +0800 Subject: [PATCH 059/169] docs: update CHANGELOG.md --- packages/plugin-code-editor/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/plugin-code-editor/CHANGELOG.md b/packages/plugin-code-editor/CHANGELOG.md index 110aac0..4fc51e2 100644 --- a/packages/plugin-code-editor/CHANGELOG.md +++ b/packages/plugin-code-editor/CHANGELOG.md @@ -1,6 +1,7 @@ ## 1.0.4 / 2022-11-18 -- 修复从 schema2code 时, state 恢复错误的问题 +- Fix 修正输入 / 粘贴时光标位置错误的 bug +- Fix 修复当上下文没有 originCode 时,通过 schema 中的局部 source 字段无法恢复 state 的问题 ## 1.0.3 / 2022-07-11 From b39f4a48596d060ffa1ef3ba21250ecc29474dc6 Mon Sep 17 00:00:00 2001 From: JackLian Date: Fri, 25 Nov 2022 11:06:11 +0800 Subject: [PATCH 060/169] feat(plugin-schema): add isProjectSchema option --- packages/plugin-schema/README.md | 23 +++++++++++++----- packages/plugin-schema/build.json | 3 ++- packages/plugin-schema/package.json | 2 +- packages/plugin-schema/src/editor.tsx | 35 ++++++++++++++++----------- packages/plugin-schema/src/index.tsx | 26 ++++++++++++++------ 5 files changed, 60 insertions(+), 29 deletions(-) diff --git a/packages/plugin-schema/README.md b/packages/plugin-schema/README.md index 555ba4c..93af452 100644 --- a/packages/plugin-schema/README.md +++ b/packages/plugin-schema/README.md @@ -1,12 +1,14 @@ # lowcode-plugin-@alilc/lowcode-plugin-schema [![][npm-image]][npm-url] -show lowcode schema diff +show lowcode schema +查看低代码引擎 schema --- ## 使用 ### 注册插件 +#### 展示页面级 schema ```jsx import { plugins } from '@alilc/lowcode-engine'; import LowcodePluginAliLowcodePluginSchema from '@alilc/lowcode-plugin-schema'; @@ -14,12 +16,21 @@ import LowcodePluginAliLowcodePluginSchema from '@alilc/lowcode-plugin-schema'; // 注册到引擎 plugins.register(LowcodePluginAliLowcodePluginSchema); ``` +#### 展示项目级 schema +```jsx +import { plugins } from '@alilc/lowcode-engine'; +import LowcodePluginAliLowcodePluginSchema from '@alilc/lowcode-plugin-schema'; + +// 注册到引擎 +plugins.register(LowcodePluginAliLowcodePluginSchema, { isProjectSchema: true }); +``` ### 插件属性 & 方法 -无对外暴露的属性和方法 -### 依赖插件 -该插件依赖以下插件: +#### isProjectSchema +- description: '是否是项目级 schema' +- type: 'boolean' +- default: false -| 插件名 | 包名 | -| --- | --- | +### 依赖插件 +暂无 diff --git a/packages/plugin-schema/build.json b/packages/plugin-schema/build.json index 6a51f0c..05778dd 100644 --- a/packages/plugin-schema/build.json +++ b/packages/plugin-schema/build.json @@ -3,7 +3,8 @@ [ "@alilc/build-plugin-alt", { - "type": "plugin" + "type": "plugin", + "inject": true } ], [ diff --git a/packages/plugin-schema/package.json b/packages/plugin-schema/package.json index 80c15ed..93aa42a 100644 --- a/packages/plugin-schema/package.json +++ b/packages/plugin-schema/package.json @@ -1,7 +1,7 @@ { "name": "@alilc/lowcode-plugin-schema", "author": "alvarto", - "version": "1.0.1", + "version": "1.0.2", "description": "Show schema in lowcode editor", "files": [ "es", diff --git a/packages/plugin-schema/src/editor.tsx b/packages/plugin-schema/src/editor.tsx index e66dedf..2bf382d 100644 --- a/packages/plugin-schema/src/editor.tsx +++ b/packages/plugin-schema/src/editor.tsx @@ -12,13 +12,16 @@ interface PluginCodeDiffProps { project: Project; skeleton: Skeleton; event: Event; + // 是否显示项目级 schema + showProjectSchema: boolean; } -export default function PluginSchema({ project, skeleton, event }: PluginCodeDiffProps) { +export default function PluginSchema({ project, skeleton, event, showProjectSchema = false }: PluginCodeDiffProps) { const [editorSize, setEditorSize] = useState({ width: 0, height: 0 }); const [schemaValue, setSchemaValue] = useState(() => { - const schema = project.exportSchema(common.designerCabin.TransformStage.Save) - return schema?.componentsTree?.[0] ? JSON.stringify(schema.componentsTree[0], null, 2) : '' + const schema = project.exportSchema(common.designerCabin.TransformStage.Save); + const schemaToShow = showProjectSchema? schema : schema?.componentsTree?.[0]; + return schemaToShow? JSON.stringify(schemaToShow, null, 2) : ''; }); const monacoEditorRef = useRef(); @@ -44,7 +47,7 @@ export default function PluginSchema({ project, skeleton, event }: PluginCodeDif window.addEventListener('resize', resize); return () => { window.removeEventListener('resize', resize); - } + }; }, [resize]); const onSave = () => { @@ -52,20 +55,24 @@ export default function PluginSchema({ project, skeleton, event }: PluginCodeDif content: 'Are you 100% sure? Lowcode editor may crash.', footerActions: ['cancel', 'ok'], onOk: () => { - let json + let json; try { - json = JSON.parse(monacoEditorRef.current?.getValue() ?? schemaValue) + json = JSON.parse(monacoEditorRef.current?.getValue() ?? schemaValue); } catch (err) { - Message.error('Cannot save schema. Schema Parse Error.' + err.message) + Message.error('Cannot save schema. Schema Parse Error.' + err.message); return; } - - project.importSchema({ - ...project.exportSchema(common.designerCabin.TransformStage.Save), - componentsTree: [json], - }); + if (showProjectSchema) { + // 当前操作项目级 schema + project.importSchema(json); + } else { + // 当前操作页面级 schema + project.importSchema({ + ...project.exportSchema(common.designerCabin.TransformStage.Save), + componentsTree: [json], + }); + } Message.success('Schema Saved!'); - skeleton.hidePanel('LowcodePluginAliLowcodePluginSchema'); } }); @@ -96,7 +103,7 @@ export default function PluginSchema({ project, skeleton, event }: PluginCodeDif contextMenuGroupId: 'navigation', contextMenuOrder: 1.5, run: onSave, - }); + }); }} /> diff --git a/packages/plugin-schema/src/index.tsx b/packages/plugin-schema/src/index.tsx index ae7bcef..e52acbd 100644 --- a/packages/plugin-schema/src/index.tsx +++ b/packages/plugin-schema/src/index.tsx @@ -2,14 +2,12 @@ import * as React from 'react'; import { ILowCodePluginContext } from '@alilc/lowcode-engine'; import PluginSchema from './editor'; -const plugin = (ctx: ILowCodePluginContext) => { +const plugin = (ctx: ILowCodePluginContext, options: any) => { return { - // 插件名,注册环境下唯一 - name: 'LowcodePluginAliLowcodePluginSchema', - // 依赖的插件(插件名数组) - dep: [], // 插件的初始化函数,在引擎初始化之后会立刻调用 init() { + const isProjectSchema = (options && options['isProjectSchema']) === true; + // 往引擎增加面板 ctx.skeleton.add({ area: 'leftArea', @@ -28,6 +26,7 @@ const plugin = (ctx: ILowCodePluginContext) => { project={ctx.project} skeleton={ctx.skeleton} event={ctx.event} + showProjectSchema={isProjectSchema} /> ), }) @@ -35,6 +34,19 @@ const plugin = (ctx: ILowCodePluginContext) => { }; }; -plugin.pluginName = 'LowcodePluginAliLowcodePluginSchema' +plugin.pluginName = 'LowcodePluginAliLowcodePluginSchema'; +plugin.meta = { + preferenceDeclaration: { + title: 'schema 面板配置', + properties: [ + { + key: 'isProjectSchema', + type: 'boolean', + description: '是否是项目级 schema', + default: false, + }, + ], + }, +}; -export default plugin +export default plugin; From 4a807e6e97bc5f8f72c448ce8c7e07f5ea176d23 Mon Sep 17 00:00:00 2001 From: "humphry.hy" Date: Mon, 28 Nov 2022 16:53:10 +0800 Subject: [PATCH 061/169] fix: uipass compatibility --- packages/plugin-code-editor/CHANGELOG.md | 4 ++++ .../plugin-code-editor/src/utils/schema-to-code.ts | 11 ----------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/packages/plugin-code-editor/CHANGELOG.md b/packages/plugin-code-editor/CHANGELOG.md index 4fc51e2..a8f5cba 100644 --- a/packages/plugin-code-editor/CHANGELOG.md +++ b/packages/plugin-code-editor/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.5 / 2022-11-28 + +- Fix 修正 UIPaaS 中针对 source 的异常提示问题 + ## 1.0.4 / 2022-11-18 - Fix 修正输入 / 粘贴时光标位置错误的 bug 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 75bddbb..986ed9a 100644 --- a/packages/plugin-code-editor/src/utils/schema-to-code.ts +++ b/packages/plugin-code-editor/src/utils/schema-to-code.ts @@ -36,25 +36,14 @@ export const beautifyCSS = (input?: string): string => { function initStateCode(componentSchema: RootSchema | undefined) { if (componentSchema?.state) { let statesStr = 'state = {\n'; - let needNotice = false; Object.keys(componentSchema.state).forEach((key) => { const state = componentSchema.state?.[key]; if (typeof state === 'object' && isJSExpression(state)) { - if (!(state as IState).source) { - needNotice = true; - } statesStr += `"${key}": ${(state as IState).source || state.value},\n`; } else { statesStr += `"${key}": ${typeof state === 'string' ? '"' + state + '"' : state},,\n`; } - }); - if (needNotice) { - Dialog.alert({ - title: WORDS.title, - content: WORDS.irreparableState, - }); - } statesStr += '}'; return statesStr; } From 6e098619bb312d8917f6a3262cb195424850972d Mon Sep 17 00:00:00 2001 From: "humphry.hy" Date: Mon, 28 Nov 2022 16:54:09 +0800 Subject: [PATCH 062/169] chore: bump into next version --- packages/plugin-code-editor/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugin-code-editor/package.json b/packages/plugin-code-editor/package.json index 3afea15..1233684 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.4", + "version": "1.0.5", "description": "CodeEditor", "files": [ "es", From 6782bfb654d0e2229b1b02749514a96fd2e3fc5e Mon Sep 17 00:00:00 2001 From: JackLian Date: Fri, 2 Dec 2022 19:58:27 +0800 Subject: [PATCH 063/169] feat(manual): adjust manual, use manual on lowcode-engine.cn --- packages/plugin-manual/build.json | 3 +- packages/plugin-manual/package.json | 2 +- packages/plugin-manual/src/index.tsx | 24 +--- packages/plugin-manual/src/popup.tsx | 158 --------------------------- 4 files changed, 4 insertions(+), 183 deletions(-) delete mode 100644 packages/plugin-manual/src/popup.tsx diff --git a/packages/plugin-manual/build.json b/packages/plugin-manual/build.json index 1edfc2f..1767fef 100644 --- a/packages/plugin-manual/build.json +++ b/packages/plugin-manual/build.json @@ -3,7 +3,8 @@ [ "@alilc/build-plugin-alt", { - "type": "plugin" + "type": "plugin", + "inject": true } ], [ diff --git a/packages/plugin-manual/package.json b/packages/plugin-manual/package.json index 84a6bfd..522ea29 100644 --- a/packages/plugin-manual/package.json +++ b/packages/plugin-manual/package.json @@ -1,7 +1,7 @@ { "name": "@alilc/lowcode-plugin-manual", "author": "humphry.huang9@gmail.com", - "version": "1.0.3", + "version": "1.0.4", "description": "低代码产品使用手册", "main": "lib/index.js", "module": "es/index.js", diff --git a/packages/plugin-manual/src/index.tsx b/packages/plugin-manual/src/index.tsx index 2c90773..bb57695 100644 --- a/packages/plugin-manual/src/index.tsx +++ b/packages/plugin-manual/src/index.tsx @@ -1,20 +1,8 @@ -import * as React from 'react'; import { ILowCodePluginContext } from '@alilc/lowcode-engine'; import { IconQuestion } from './icon'; -import { Dialog } from '@alifd/next'; -import { Documents } from './popup'; const PluginManual = (ctx: ILowCodePluginContext) => { return { - // 插件名,注册环境下唯一 - name: 'PluginManual', - // 依赖的插件(插件名数组) - dep: [], - // 插件对外暴露的数据和方法 - exports() { - return {}; - }, - // 插件的初始化函数,在引擎初始化之后会立刻调用 init() { // 往引擎增加面板 ctx.skeleton.add({ @@ -26,17 +14,7 @@ const PluginManual = (ctx: ILowCodePluginContext) => { icon: IconQuestion, description: '如何使用', onClick() { - Dialog.show({ - title: '低代码产品使用文档', - content: ( - - ), - height: window.innerHeight - 100 + 'px', - style: { - width: window.innerWidth - 300, - }, - footer: false, - }); + window.open('https://lowcode-engine.cn/site/docs/demoUsage/intro', '_blank').focus(); }, }, }); diff --git a/packages/plugin-manual/src/popup.tsx b/packages/plugin-manual/src/popup.tsx deleted file mode 100644 index 3710ddc..0000000 --- a/packages/plugin-manual/src/popup.tsx +++ /dev/null @@ -1,158 +0,0 @@ -import * as React from 'react'; -import { useEffect, useState } from 'react'; -import { material } from '@alilc/lowcode-engine'; -import { Tree, Tag, Loading } from '@alifd/next'; - -import { IconBug, IconLink } from './icon'; - -export function Documents() { - const [menu, setMenu] = useState([] as Array<{ title: string, url: string }>) - const [loading, setLoading] = useState(false) - const [selection, setSelection] = useState([] as string[]) - - useEffect(() => { - setLoading(true) - fetch('https://lowcode-engine.cn/api/get_usage') - .then((res) => res.json()) - .then((val) => { - const menu = val.data.filter((a: any) => !isNaN(parseInt(a.title))) - menu.sort((a: any, b: any) => parseInt(a.title) > parseInt(b.title) ? 1 : -1) - setMenu(menu) - setSelection(menu.length ? ['0'] : []) - }) - .catch(err => console.error(err)) - .finally(() => { - setLoading(false) - }) - }, []) - - return ( - -
-
- {!loading && ( - { - if (Array.isArray(newSelection) && newSelection.length > 0) { - setSelection(newSelection) - } - }} - isNodeBlock={{ - defaultPadingLeft: 1, - indent: 1, - }} - style={{ lineHeight: '26px' }} - > - {menu.map((item, index) => ( - - ))} - - - {IconLink} - 低代码引擎技术文档 - - )} - onClick={() => { - window.open('https://lowcode-engine.cn/doc') - }} - /> - - {IconLink} - engine - - {getVerionOf('ali-lowcode/ali-lowcode-engine') ?? (window as any).AliLowCodeEngine.version ?? '-'} - - - )} - onClick={() => { - window.open('https://lowcode-engine.cn/doc?url=engine-changelog') - }} - /> - - {IconLink} - ext - - {getVerionOf('ali-lowcode/lowcode-engine-ext') ?? (window as any).AliLowCodeEngineExt.version ?? '-'} - - - )} - onClick={() => { - window.open('https://lowcode-engine.cn/doc?url=engine-ext-changelog') - }} - /> - - {IconBug} - 提交 bug - - )} - onClick={() => { - const assets = material.getAssets() - const message = `## 复现截图 - -## 复现流程与链接 - -## 期望结果 - -## 环境信息 - -- 引擎版本 ${getVerionOf('ali-lowcode/ali-lowcode-engine') ?? (window as any).AliLowCodeEngine.version ?? '-'} -- ext 版本 ${getVerionOf('ali-lowcode/lowcode-engine-ext') ?? (window as any).AliLowCodeEngineExt.version ?? '-'} -- 物料 -${assets.packages - .filter((item: any) => !!item.package) - .map((item: any) => (` - ${item.package}${item.version ? '@' + item.version : ''}`.replace(/@/g, '﹫'))) - .join('\n') -}` - window.open(`https://github.com/alibaba/lowcode-engine/issues/new?body=${ - encodeURIComponent(message) - }`) - }} - /> - - - )} -
- {menu[+selection[0]]?.url && ( -