@cloudbase/framework-plugin-low-code 1.0.2 → 1.0.3-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/lib/builder/config/common.d.ts +2 -0
  2. package/lib/builder/config/common.d.ts.map +1 -0
  3. package/lib/builder/config/common.js +13 -0
  4. package/lib/builder/config/index.d.ts +3 -0
  5. package/lib/builder/config/index.d.ts.map +1 -0
  6. package/lib/builder/config/index.js +29 -0
  7. package/lib/builder/config/mp.d.ts +2 -0
  8. package/lib/builder/config/mp.d.ts.map +1 -0
  9. package/lib/builder/config/mp.js +13 -0
  10. package/lib/builder/core/copy.d.ts +5 -0
  11. package/lib/builder/core/copy.d.ts.map +1 -0
  12. package/lib/builder/core/copy.js +62 -0
  13. package/lib/builder/core/generate.d.ts +9 -0
  14. package/lib/builder/core/generate.d.ts.map +1 -0
  15. package/lib/builder/core/generate.js +128 -0
  16. package/lib/builder/core/index.d.ts +32 -0
  17. package/lib/builder/core/index.d.ts.map +1 -0
  18. package/lib/builder/core/index.js +149 -0
  19. package/lib/builder/core/material.d.ts +4 -0
  20. package/lib/builder/core/material.d.ts.map +1 -0
  21. package/lib/builder/core/material.js +80 -0
  22. package/lib/builder/core/plugin.d.ts +4 -0
  23. package/lib/builder/core/plugin.d.ts.map +1 -0
  24. package/lib/builder/core/plugin.js +30 -0
  25. package/lib/builder/core/prepare.d.ts +8 -0
  26. package/lib/builder/core/prepare.d.ts.map +1 -0
  27. package/lib/builder/core/prepare.js +108 -0
  28. package/lib/builder/core/webpack.d.ts +15 -0
  29. package/lib/builder/core/webpack.d.ts.map +1 -0
  30. package/lib/builder/core/webpack.js +58 -0
  31. package/lib/builder/mp/BuildContext.d.ts +13 -0
  32. package/lib/builder/mp/BuildContext.d.ts.map +1 -0
  33. package/lib/builder/mp/BuildContext.js +2 -0
  34. package/lib/builder/mp/index.d.ts +33 -0
  35. package/lib/builder/mp/index.d.ts.map +1 -0
  36. package/lib/builder/mp/index.js +450 -0
  37. package/lib/builder/mp/lowcode.d.ts +8 -0
  38. package/lib/builder/mp/lowcode.d.ts.map +1 -0
  39. package/lib/builder/mp/lowcode.js +58 -0
  40. package/lib/builder/mp/materials.d.ts +15 -0
  41. package/lib/builder/mp/materials.d.ts.map +1 -0
  42. package/lib/builder/mp/materials.js +338 -0
  43. package/lib/builder/mp/mixMode.d.ts +10 -0
  44. package/lib/builder/mp/mixMode.d.ts.map +1 -0
  45. package/lib/builder/mp/mixMode.js +215 -0
  46. package/lib/builder/mp/mp_config.d.ts +18 -0
  47. package/lib/builder/mp/mp_config.d.ts.map +1 -0
  48. package/lib/builder/mp/mp_config.js +206 -0
  49. package/lib/builder/mp/util.d.ts +20 -0
  50. package/lib/builder/mp/util.d.ts.map +1 -0
  51. package/lib/builder/mp/util.js +243 -0
  52. package/lib/builder/mp/wxml.d.ts +16 -0
  53. package/lib/builder/mp/wxml.d.ts.map +1 -0
  54. package/lib/builder/mp/wxml.js +300 -0
  55. package/lib/builder/service/builder/copy.d.ts +14 -0
  56. package/lib/builder/service/builder/copy.d.ts.map +1 -0
  57. package/lib/builder/service/builder/copy.js +189 -0
  58. package/lib/builder/service/builder/generate.d.ts +52 -0
  59. package/lib/builder/service/builder/generate.d.ts.map +1 -0
  60. package/lib/builder/service/builder/generate.js +789 -0
  61. package/lib/builder/service/builder/index.d.ts +16 -0
  62. package/lib/builder/service/builder/index.d.ts.map +1 -0
  63. package/lib/builder/service/builder/index.js +69 -0
  64. package/lib/builder/service/builder/plugin.d.ts +8 -0
  65. package/lib/builder/service/builder/plugin.d.ts.map +1 -0
  66. package/lib/builder/service/builder/plugin.js +149 -0
  67. package/lib/builder/service/builder/webpack.d.ts +91 -0
  68. package/lib/builder/service/builder/webpack.d.ts.map +1 -0
  69. package/lib/builder/service/builder/webpack.js +589 -0
  70. package/lib/builder/types/common.d.ts +12 -0
  71. package/lib/builder/types/common.d.ts.map +1 -0
  72. package/lib/builder/types/common.js +7 -0
  73. package/lib/builder/util/common.d.ts +36 -0
  74. package/lib/builder/util/common.d.ts.map +1 -0
  75. package/lib/builder/util/common.js +257 -0
  76. package/lib/builder/util/console.d.ts +2 -0
  77. package/lib/builder/util/console.d.ts.map +1 -0
  78. package/lib/builder/util/console.js +13 -0
  79. package/lib/builder/util/generateFiles.d.ts +6 -0
  80. package/lib/builder/util/generateFiles.d.ts.map +1 -0
  81. package/lib/builder/util/generateFiles.js +94 -0
  82. package/lib/builder/util/index.d.ts +2 -0
  83. package/lib/builder/util/index.d.ts.map +1 -0
  84. package/lib/builder/util/index.js +13 -0
  85. package/lib/builder/util/junk.d.ts +3 -0
  86. package/lib/builder/util/junk.d.ts.map +1 -0
  87. package/lib/builder/util/junk.js +25 -0
  88. package/lib/builder/util/mp.d.ts +5 -0
  89. package/lib/builder/util/mp.d.ts.map +1 -0
  90. package/lib/builder/util/mp.js +99 -0
  91. package/lib/builder/util/name-mangler.d.ts +3 -0
  92. package/lib/builder/util/name-mangler.d.ts.map +1 -0
  93. package/lib/builder/util/name-mangler.js +7 -0
  94. package/lib/builder/util/net.d.ts +3 -0
  95. package/lib/builder/util/net.d.ts.map +1 -0
  96. package/lib/builder/util/net.js +54 -0
  97. package/lib/builder/util/process.d.ts +9 -0
  98. package/lib/builder/util/process.d.ts.map +1 -0
  99. package/lib/builder/util/process.js +28 -0
  100. package/lib/builder/util/style.d.ts +2 -0
  101. package/lib/builder/util/style.d.ts.map +1 -0
  102. package/lib/builder/util/style.js +13 -0
  103. package/lib/builder/util/weapp.d.ts +2 -0
  104. package/lib/builder/util/weapp.d.ts.map +1 -0
  105. package/lib/builder/util/weapp.js +13 -0
  106. package/lib/generator/config/common.d.ts +6 -0
  107. package/lib/generator/config/common.d.ts.map +1 -0
  108. package/lib/generator/config/common.js +25 -0
  109. package/lib/generator/config/index.d.ts +18 -0
  110. package/lib/generator/config/index.d.ts.map +1 -0
  111. package/lib/generator/config/index.js +43 -0
  112. package/lib/generator/config/mp.d.ts +56 -0
  113. package/lib/generator/config/mp.d.ts.map +1 -0
  114. package/lib/generator/config/mp.js +104 -0
  115. package/lib/generator/core/generate.d.ts +59 -0
  116. package/lib/generator/core/generate.d.ts.map +1 -0
  117. package/lib/generator/core/generate.js +669 -0
  118. package/lib/generator/core/index.d.ts +25 -0
  119. package/lib/generator/core/index.d.ts.map +1 -0
  120. package/lib/generator/core/index.js +102 -0
  121. package/lib/generator/core/material.d.ts +14 -0
  122. package/lib/generator/core/material.d.ts.map +1 -0
  123. package/lib/generator/core/material.js +230 -0
  124. package/lib/generator/template.d.ts +3 -0
  125. package/lib/generator/template.d.ts.map +1 -0
  126. package/lib/generator/template.js +3 -0
  127. package/lib/generator/types/common.d.ts +69 -0
  128. package/lib/generator/types/common.d.ts.map +1 -0
  129. package/lib/generator/types/common.js +21 -0
  130. package/lib/generator/util/common.d.ts +36 -0
  131. package/lib/generator/util/common.d.ts.map +1 -0
  132. package/lib/generator/util/common.js +238 -0
  133. package/lib/generator/util/console.d.ts +3 -0
  134. package/lib/generator/util/console.d.ts.map +1 -0
  135. package/lib/generator/util/console.js +17 -0
  136. package/lib/generator/util/index.d.ts +2 -0
  137. package/lib/generator/util/index.d.ts.map +1 -0
  138. package/lib/generator/util/index.js +13 -0
  139. package/lib/generator/util/name-mangler.d.ts +17 -0
  140. package/lib/generator/util/name-mangler.d.ts.map +1 -0
  141. package/lib/generator/util/name-mangler.js +63 -0
  142. package/lib/generator/util/postcss-rpx.d.ts +11 -0
  143. package/lib/generator/util/postcss-rpx.d.ts.map +1 -0
  144. package/lib/generator/util/postcss-rpx.js +16 -0
  145. package/lib/generator/util/style.d.ts +6 -0
  146. package/lib/generator/util/style.d.ts.map +1 -0
  147. package/lib/generator/util/style.js +92 -0
  148. package/lib/generator/util/weapp.d.ts +5 -0
  149. package/lib/generator/util/weapp.d.ts.map +1 -0
  150. package/lib/generator/util/weapp.js +17 -0
  151. package/lib/types.d.ts +14 -0
  152. package/lib/types.d.ts.map +1 -0
  153. package/lib/types.js +19 -0
  154. package/lib/weapps-core/config/index.d.ts +2 -0
  155. package/lib/weapps-core/config/index.d.ts.map +1 -0
  156. package/lib/weapps-core/config/index.js +13 -0
  157. package/lib/weapps-core/config/style.d.ts +7 -0
  158. package/lib/weapps-core/config/style.d.ts.map +1 -0
  159. package/lib/weapps-core/config/style.js +70 -0
  160. package/lib/weapps-core/index.d.ts +6 -0
  161. package/lib/weapps-core/index.d.ts.map +1 -0
  162. package/lib/weapps-core/index.js +31 -0
  163. package/lib/weapps-core/types/action.d.ts +25 -0
  164. package/lib/weapps-core/types/action.d.ts.map +1 -0
  165. package/lib/weapps-core/types/action.js +28 -0
  166. package/lib/weapps-core/types/app.d.ts +142 -0
  167. package/lib/weapps-core/types/app.d.ts.map +1 -0
  168. package/lib/weapps-core/types/app.js +21 -0
  169. package/lib/weapps-core/types/appbuild.d.ts +63 -0
  170. package/lib/weapps-core/types/appbuild.d.ts.map +1 -0
  171. package/lib/weapps-core/types/appbuild.js +78 -0
  172. package/lib/weapps-core/types/code_types.d.ts +26 -0
  173. package/lib/weapps-core/types/code_types.d.ts.map +1 -0
  174. package/lib/weapps-core/types/code_types.js +2 -0
  175. package/lib/weapps-core/types/git.d.ts +7 -0
  176. package/lib/weapps-core/types/git.d.ts.map +1 -0
  177. package/lib/weapps-core/types/git.js +2 -0
  178. package/lib/weapps-core/types/index.d.ts +11 -0
  179. package/lib/weapps-core/types/index.d.ts.map +1 -0
  180. package/lib/weapps-core/types/index.js +22 -0
  181. package/lib/weapps-core/types/lowcode.d.ts +26 -0
  182. package/lib/weapps-core/types/lowcode.d.ts.map +1 -0
  183. package/lib/weapps-core/types/lowcode.js +25 -0
  184. package/lib/weapps-core/types/material.d.ts +90 -0
  185. package/lib/weapps-core/types/material.d.ts.map +1 -0
  186. package/lib/weapps-core/types/material.js +9 -0
  187. package/lib/weapps-core/types/plugins.d.ts +17 -0
  188. package/lib/weapps-core/types/plugins.d.ts.map +1 -0
  189. package/lib/weapps-core/types/plugins.js +2 -0
  190. package/lib/weapps-core/types/style.d.ts +93 -0
  191. package/lib/weapps-core/types/style.d.ts.map +1 -0
  192. package/lib/weapps-core/types/style.js +2 -0
  193. package/lib/weapps-core/types/web.d.ts +120 -0
  194. package/lib/weapps-core/types/web.d.ts.map +1 -0
  195. package/lib/weapps-core/types/web.js +2 -0
  196. package/lib/weapps-core/utils/appbuild.d.ts +6 -0
  197. package/lib/weapps-core/utils/appbuild.d.ts.map +1 -0
  198. package/lib/weapps-core/utils/appbuild.js +40 -0
  199. package/lib/weapps-core/utils/common.d.ts +16 -0
  200. package/lib/weapps-core/utils/common.d.ts.map +1 -0
  201. package/lib/weapps-core/utils/common.js +90 -0
  202. package/lib/weapps-core/utils/file.d.ts +12 -0
  203. package/lib/weapps-core/utils/file.d.ts.map +1 -0
  204. package/lib/weapps-core/utils/file.js +142 -0
  205. package/lib/weapps-core/utils/formily.d.ts +5 -0
  206. package/lib/weapps-core/utils/formily.d.ts.map +1 -0
  207. package/lib/weapps-core/utils/formily.js +416 -0
  208. package/lib/weapps-core/utils/index.d.ts +7 -0
  209. package/lib/weapps-core/utils/index.d.ts.map +1 -0
  210. package/lib/weapps-core/utils/index.js +18 -0
  211. package/lib/weapps-core/utils/lowcdoe.d.ts +4 -0
  212. package/lib/weapps-core/utils/lowcdoe.d.ts.map +1 -0
  213. package/lib/weapps-core/utils/lowcdoe.js +69 -0
  214. package/lib/weapps-core/utils/style.d.ts +17 -0
  215. package/lib/weapps-core/utils/style.d.ts.map +1 -0
  216. package/lib/weapps-core/utils/style.js +330 -0
  217. package/package.json +9 -31
  218. package/scripts/build-plugin-tar.sh +31 -0
  219. package/scripts/generateTemplate.js +31 -0
  220. package/scripts/link-packages.js +11 -0
  221. package/scripts/link.js +91 -0
  222. package/scripts/postinstall.js +43 -0
  223. package/scripts/preinstall.js +16 -0
  224. package/template/html/index.html.ejs +0 -456
  225. package/template/package.json +0 -63
  226. package/template/webpack/devServer.js +0 -119
  227. package/template/webpack/getCSSModuleLocalIdent.js +0 -28
  228. package/template/webpack/web.prod.js +0 -306
@@ -0,0 +1,17 @@
1
+ import { CSSProperties, ICommonStyle } from '../types';
2
+ export declare function toCssStyle(commonStyle?: ICommonStyle, options?: {
3
+ toRem: boolean;
4
+ ignoreSelf?: boolean;
5
+ addPXUnit?: boolean;
6
+ toRpx?: boolean;
7
+ }): CSSProperties;
8
+ export declare function removeInvalidStyleFormValue(styleForm?: ICommonStyle): ICommonStyle;
9
+ export declare function translateStyleToRpx(style?: CSSProperties): CSSProperties;
10
+ export declare function translateStyleToRem(style?: CSSProperties): CSSProperties;
11
+ export declare function translateStyleByHandler(style: any, handler: (p: string) => string): {};
12
+ export declare function toREM(cssLen: number | string): string;
13
+ export declare function toRPX(cssLen: number | string): string;
14
+ export declare function removeWrapperBadEffectStyle(commonStyle?: CSSProperties): CSSProperties;
15
+ export declare function removeEffectTwiceStyle(commonStyle?: CSSProperties): CSSProperties;
16
+ export declare function toCssText(style: CSSProperties, className?: string): string;
17
+ //# sourceMappingURL=style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../src/weapps-core/utils/style.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAqBvD,wBAAgB,UAAU,CACxB,WAAW,GAAE,YAAiB,EAC9B,OAAO,GAAE;IACP,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;CACoD,GACrE,aAAa,CAgNf;AAED,wBAAgB,2BAA2B,CAAC,SAAS,GAAE,YAAiB,GAAG,YAAY,CAUtF;AAyCD,wBAAgB,mBAAmB,CAAC,KAAK,GAAE,aAAkB,GAAG,aAAa,CAE5E;AAED,wBAAgB,mBAAmB,CAAC,KAAK,GAAE,aAAkB,GAAG,aAAa,CAE5E;AAED,wBAAgB,uBAAuB,CAAC,KAAK,KAAoB,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,MAUhG;AA0BD,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAiBrD;AAED,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAcrD;AAED,wBAAgB,2BAA2B,CAAC,WAAW,GAAE,aAAkB,GAAG,aAAa,CAgB1F;AAED,wBAAgB,sBAAsB,CAAC,WAAW,GAAE,aAAkB,GAAG,aAAa,CAoBrF;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,aAAa,EAAE,SAAS,SAAqB,UAQ7E"}
@@ -0,0 +1,330 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.toCssText = exports.removeEffectTwiceStyle = exports.removeWrapperBadEffectStyle = exports.toRPX = exports.toREM = exports.translateStyleByHandler = exports.translateStyleToRem = exports.translateStyleToRpx = exports.removeInvalidStyleFormValue = exports.toCssStyle = void 0;
18
+ const uniq_1 = __importDefault(require("lodash/uniq"));
19
+ const map_1 = __importDefault(require("lodash/map"));
20
+ const config_1 = require("../config");
21
+ const common_1 = require("./common");
22
+ function _handleStyleNumValue(styleVal, addPXUnit) {
23
+ if (addPXUnit) {
24
+ const value = `${styleVal}`;
25
+ if (value.search(/^\d+$/) >= 0) {
26
+ return value + 'px';
27
+ }
28
+ }
29
+ return styleVal;
30
+ }
31
+ function toCssStyle(commonStyle = {}, options = { toRem: true, ignoreSelf: false, addPXUnit: false, toRpx: false }) {
32
+ const { size, text, border, background, margin, padding, zIndex, position, display, flexConfig, custom, self, } = commonStyle;
33
+ const style = {};
34
+ if (size) {
35
+ setStyleValue(style, 'width', _handleStyleNumValue(size.width, !!options.addPXUnit));
36
+ setStyleValue(style, 'height', _handleStyleNumValue(size.height, !!options.addPXUnit));
37
+ }
38
+ if (margin) {
39
+ setDistanceStyle(style, margin, 'margin', !!options.addPXUnit);
40
+ }
41
+ if (padding) {
42
+ setDistanceStyle(style, padding, 'padding', !!options.addPXUnit);
43
+ }
44
+ if (display) {
45
+ setStyleValue(style, 'display', display);
46
+ }
47
+ if (display === 'flex' && flexConfig) {
48
+ if (flexConfig.justifyContent)
49
+ setStyleValue(style, 'justifyContent', flexConfig.justifyContent);
50
+ if (flexConfig.alignItems)
51
+ setStyleValue(style, 'alignItems', flexConfig.alignItems);
52
+ if (flexConfig.flexWrap && flexConfig.flexDirection) {
53
+ setStyleValue(style, 'flexFlow', `${flexConfig.flexDirection} ${flexConfig.flexWrap}`);
54
+ }
55
+ else {
56
+ if (flexConfig.flexWrap)
57
+ setStyleValue(style, 'flexWrap', flexConfig.flexWrap);
58
+ if (flexConfig.flexDirection)
59
+ setStyleValue(style, 'flexDirection', flexConfig.flexDirection);
60
+ }
61
+ }
62
+ if (typeof zIndex === 'number' || `${zIndex}`.search(/^\d+$/) === 0) {
63
+ style.zIndex = zIndex;
64
+ }
65
+ if (text) {
66
+ setStyleValue(style, 'color', text.color);
67
+ setStyleValue(style, 'fontSize', _handleStyleNumValue(text.fontSize, !!options.addPXUnit));
68
+ setStyleValue(style, 'lineHeight', text.lineHeight);
69
+ setStyleValue(style, 'textAlign', text.textAlign);
70
+ setStyleValue(style, 'fontWeight', text.weight);
71
+ if (text.opacity) {
72
+ setStyleValue(style, 'opacity', text.opacity / 100);
73
+ }
74
+ }
75
+ if (border) {
76
+ const { type, color, width, radius, radiusInfo } = border;
77
+ if (width !== undefined) {
78
+ if (type) {
79
+ setStyleValue(style, 'border', `${_handleStyleNumValue(width, !!options.addPXUnit)} ${type} ${color || ''}`);
80
+ }
81
+ else {
82
+ setStyleValue(style, 'borderWidth', _handleStyleNumValue(width, !!options.addPXUnit));
83
+ if (color)
84
+ setStyleValue(style, 'borderColor', color);
85
+ }
86
+ }
87
+ if (radius !== undefined) {
88
+ setStyleValue(style, 'borderRadius', _handleStyleNumValue(radius, !!options.addPXUnit));
89
+ }
90
+ if (radiusInfo && !(0, common_1.isEmptyObj)(radiusInfo)) {
91
+ if (Object.keys(radiusInfo).length === 4) {
92
+ if ((0, uniq_1.default)((0, map_1.default)(radiusInfo, (val) => val)).length === 1) {
93
+ setStyleValue(style, 'borderRadius', _handleStyleNumValue(radiusInfo.topLeft, !!options.addPXUnit));
94
+ }
95
+ else if (radiusInfo.topLeft === radiusInfo.bottomRight && radiusInfo.topRight === radiusInfo.bottomLeft) {
96
+ setStyleValue(style, 'borderRadius', `${_handleStyleNumValue(radiusInfo.topLeft, !!options.addPXUnit)} ${_handleStyleNumValue(radiusInfo.topRight, !!options.addPXUnit)}`);
97
+ }
98
+ else if (radiusInfo.topRight === radiusInfo.bottomLeft) {
99
+ setStyleValue(style, 'borderRadius', `${_handleStyleNumValue(radiusInfo.topLeft, !!options.addPXUnit)} ${_handleStyleNumValue(radiusInfo.topRight, !!options.addPXUnit)} ${_handleStyleNumValue(radiusInfo.bottomRight, !!options.addPXUnit)}`);
100
+ }
101
+ else {
102
+ setStyleValue(style, 'borderRadius', `${_handleStyleNumValue(radiusInfo.topLeft, !!options.addPXUnit)} ${_handleStyleNumValue(radiusInfo.topRight, !!options.addPXUnit)} ${_handleStyleNumValue(radiusInfo.bottomRight, !!options.addPXUnit)} ${_handleStyleNumValue(radiusInfo.bottomLeft, !!options.addPXUnit)}`);
103
+ }
104
+ }
105
+ else {
106
+ setStyleValue(style, 'borderTopLeftRadius', _handleStyleNumValue(radiusInfo.topLeft, !!options.addPXUnit));
107
+ setStyleValue(style, 'borderTopRightRadius', _handleStyleNumValue(radiusInfo.topRight, !!options.addPXUnit));
108
+ setStyleValue(style, 'borderBottomRightRadius', _handleStyleNumValue(radiusInfo.bottomRight, !!options.addPXUnit));
109
+ setStyleValue(style, 'borderBottomLeftRadius', _handleStyleNumValue(radiusInfo.bottomLeft, !!options.addPXUnit));
110
+ }
111
+ }
112
+ }
113
+ if (background) {
114
+ const { bgType, color, image, size, repeat, position, positionObj } = background;
115
+ if (bgType === 'color') {
116
+ setStyleValue(style, 'background', color);
117
+ }
118
+ else if (bgType === 'image') {
119
+ if (image != null) {
120
+ if (image.search(/[()]/) >= 0) {
121
+ style.background = image;
122
+ }
123
+ else {
124
+ style.background = `url(${image})`;
125
+ }
126
+ }
127
+ if (repeat)
128
+ style.background += ` ${repeat}`;
129
+ if (size) {
130
+ setStyleValue(style, 'backgroundSize', _handleStyleNumValue(size, !!options.addPXUnit));
131
+ }
132
+ setStyleValue(style, 'backgroundPosition', position);
133
+ if (positionObj && !(0, common_1.isEmptyObj)(positionObj)) {
134
+ style.background += ` ${_handleStyleNumValue(positionObj.left, !!options.addPXUnit)} ${_handleStyleNumValue(positionObj.top, !!options.addPXUnit)}`;
135
+ }
136
+ }
137
+ if (bgType === undefined) {
138
+ setStyleValue(style, 'backgroundColor', color);
139
+ if (image != null) {
140
+ style.backgroundImage = `url(${image})`;
141
+ setStyleValue(style, 'backgroundRepeat', repeat);
142
+ setStyleValue(style, 'backgroundSize', _handleStyleNumValue(size, !!options.addPXUnit));
143
+ setStyleValue(style, 'backgroundPosition', position);
144
+ }
145
+ }
146
+ }
147
+ if (position) {
148
+ setStyleValue(style, 'position', position.position);
149
+ if (position.left !== undefined) {
150
+ setStyleValue(style, 'left', _handleStyleNumValue(position.left, !!options.addPXUnit));
151
+ }
152
+ if (position.right !== undefined) {
153
+ setStyleValue(style, 'right', _handleStyleNumValue(position.right, !!options.addPXUnit));
154
+ }
155
+ if (position.top !== undefined) {
156
+ setStyleValue(style, 'top', _handleStyleNumValue(position.top, !!options.addPXUnit));
157
+ }
158
+ if (position.bottom !== undefined) {
159
+ setStyleValue(style, 'bottom', _handleStyleNumValue(position.bottom, !!options.addPXUnit));
160
+ }
161
+ }
162
+ if (custom && custom.length > 0) {
163
+ custom.map((item) => {
164
+ setStyleValue(style, item.key, item.value);
165
+ });
166
+ }
167
+ if (self && !options.ignoreSelf) {
168
+ const _a = self, { cssFloat } = _a, restSelf = __rest(_a, ["cssFloat"]);
169
+ Object.assign(style, restSelf, { float: cssFloat });
170
+ }
171
+ if (options.toRpx) {
172
+ return translateStyleToRpx(style);
173
+ }
174
+ return options.toRem ? translateStyleToRem(style) : style;
175
+ }
176
+ exports.toCssStyle = toCssStyle;
177
+ function removeInvalidStyleFormValue(styleForm = {}) {
178
+ return Object.keys(styleForm).reduce((result, key) => {
179
+ const propStyleFormData = styleForm[key];
180
+ if ((0, common_1.isPlainObject)(propStyleFormData)) {
181
+ setStyleValue(result, key, removeInvalidStyleFormValue(propStyleFormData));
182
+ }
183
+ else {
184
+ setStyleValue(result, key, styleForm[key]);
185
+ }
186
+ return result;
187
+ }, {});
188
+ }
189
+ exports.removeInvalidStyleFormValue = removeInvalidStyleFormValue;
190
+ function setDistanceStyle(style, distance, attr, addPXUnit) {
191
+ if (Object.keys(distance).length === 4) {
192
+ if ((0, uniq_1.default)((0, map_1.default)(distance, (val) => val)).length === 1) {
193
+ setStyleValue(style, (0, common_1.camelcase)(`${attr}`), _handleStyleNumValue(distance.top, addPXUnit));
194
+ }
195
+ else if (distance.top === distance.bottom && distance.left === distance.right) {
196
+ setStyleValue(style, (0, common_1.camelcase)(`${attr}`), `${_handleStyleNumValue(distance.top, addPXUnit)} ${_handleStyleNumValue(distance.right, addPXUnit)}`);
197
+ }
198
+ else if (distance.left === distance.right) {
199
+ setStyleValue(style, (0, common_1.camelcase)(`${attr}`), `${_handleStyleNumValue(distance.top, addPXUnit)} ${_handleStyleNumValue(distance.right, addPXUnit)} ${_handleStyleNumValue(distance.bottom, addPXUnit)}`);
200
+ }
201
+ else {
202
+ setStyleValue(style, (0, common_1.camelcase)(`${attr}`), `${_handleStyleNumValue(distance.top, addPXUnit)} ${_handleStyleNumValue(distance.right, addPXUnit)} ${_handleStyleNumValue(distance.bottom, addPXUnit)} ${_handleStyleNumValue(distance.left, addPXUnit)}`);
203
+ }
204
+ }
205
+ else {
206
+ config_1.DISTANCE_KEY_LIST.forEach((key) => {
207
+ if (distance[key] !== undefined)
208
+ setStyleValue(style, (0, common_1.camelcase)(`${attr}_${key}`), _handleStyleNumValue(distance[key], addPXUnit));
209
+ });
210
+ }
211
+ }
212
+ function translateStyleToRpx(style = {}) {
213
+ return translateStyleByHandler(style, toRPX);
214
+ }
215
+ exports.translateStyleToRpx = translateStyleToRpx;
216
+ function translateStyleToRem(style = {}) {
217
+ return translateStyleByHandler(style, toREM);
218
+ }
219
+ exports.translateStyleToRem = translateStyleToRem;
220
+ function translateStyleByHandler(style = {}, handler) {
221
+ return Object.keys(style).reduce((result, key) => {
222
+ const value = style[key];
223
+ if (config_1.PERCENTAGE_KEY_LIST.includes(key)) {
224
+ setStyleValue(result, key, value);
225
+ }
226
+ else if (value !== undefined && value !== null) {
227
+ setStyleValue(result, key, handler(value));
228
+ }
229
+ return result;
230
+ }, {});
231
+ }
232
+ exports.translateStyleByHandler = translateStyleByHandler;
233
+ function setStyleValue(object, key, value) {
234
+ if (value === undefined || value === null || value === '') {
235
+ return;
236
+ }
237
+ if (key === 'open') {
238
+ return;
239
+ }
240
+ if ((0, common_1.isEmptyObj)(value)) {
241
+ return;
242
+ }
243
+ object[(0, common_1.camelcase)(key)] = value;
244
+ }
245
+ function calPxToREM(px) {
246
+ if (Number.isNaN(px / 28))
247
+ return px.toString();
248
+ if (+px === 0) {
249
+ return '0';
250
+ }
251
+ return (px / 28).toFixed(4) + 'rem';
252
+ }
253
+ function toREM(cssLen) {
254
+ if (typeof cssLen === 'string') {
255
+ const cssLenArr = cssLen.split(' ');
256
+ return cssLenArr
257
+ .map((attr) => {
258
+ const matchResult = attr.match(/^(-?\d+)(px)?$/);
259
+ if (matchResult && matchResult[1]) {
260
+ return calPxToREM(+matchResult[1]);
261
+ }
262
+ return attr;
263
+ })
264
+ .join(' ');
265
+ }
266
+ else if (typeof cssLen === 'number') {
267
+ return calPxToREM(cssLen);
268
+ }
269
+ else {
270
+ throw new Error('cssLen type error');
271
+ }
272
+ }
273
+ exports.toREM = toREM;
274
+ function toRPX(cssLen) {
275
+ if (typeof cssLen === 'string') {
276
+ const cssLenArr = cssLen.split(' ');
277
+ return cssLenArr
278
+ .map((attr) => {
279
+ const matchResult = attr.match(/^(-?\d+)(px)?$/);
280
+ if (matchResult && matchResult[1]) {
281
+ return `${+matchResult[1]}rpx`;
282
+ }
283
+ return attr;
284
+ })
285
+ .join(' ');
286
+ }
287
+ return `${cssLen}rpx`;
288
+ }
289
+ exports.toRPX = toRPX;
290
+ function removeWrapperBadEffectStyle(commonStyle = {}) {
291
+ return Object.keys(commonStyle).reduce((result, key) => {
292
+ const value = commonStyle[key];
293
+ const camelcaseKey = (0, common_1.camelcase)(key);
294
+ if (config_1.WRAPPER_REMOVE_STYLE_KEY_LIST.includes(camelcaseKey)) {
295
+ return result;
296
+ }
297
+ if (key === 'display' && value === 'flex') {
298
+ return result;
299
+ }
300
+ setStyleValue(result, camelcaseKey, value);
301
+ return result;
302
+ }, {});
303
+ }
304
+ exports.removeWrapperBadEffectStyle = removeWrapperBadEffectStyle;
305
+ function removeEffectTwiceStyle(commonStyle = {}) {
306
+ const style = {};
307
+ Object.keys(commonStyle).map((key) => {
308
+ const value = commonStyle[key];
309
+ const camelcaseKey = (0, common_1.camelcase)(key);
310
+ if (config_1.SELF_REMOVE_STYLE_KEY_LIST.includes(camelcaseKey)) {
311
+ return false;
312
+ }
313
+ if (config_1.SELF_REMOVE_WITH_PERCENTAGE_KEY_LIST.includes(camelcaseKey) && String(value).match(/.+%$/)) {
314
+ return false;
315
+ }
316
+ setStyleValue(style, camelcaseKey, value);
317
+ });
318
+ return style;
319
+ }
320
+ exports.removeEffectTwiceStyle = removeEffectTwiceStyle;
321
+ function toCssText(style, className = '.some-class-name') {
322
+ const attrText = Object.keys(style)
323
+ .map((key) => {
324
+ const value = style[key];
325
+ return `${(0, common_1.kebabCase)(key)}: ${value};`;
326
+ })
327
+ .join('\n');
328
+ return `${className} { ${attrText} }\n`;
329
+ }
330
+ exports.toCssText = toCssText;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/framework-plugin-low-code",
3
- "version": "1.0.2",
3
+ "version": "1.0.3-alpha.10",
4
4
  "description": "云开发 Tencent CloudBase Framework Low Code Plugin,将低码配置生成完整项目并一键部署云开发资源。",
5
5
  "author": "yhsunshining@gmail.com",
6
6
  "homepage": "https://github.com/TencentCloudBase/cloudbase-framework#readme",
@@ -13,7 +13,8 @@
13
13
  },
14
14
  "files": [
15
15
  "lib",
16
- "template"
16
+ "template",
17
+ "scripts"
17
18
  ],
18
19
  "publishConfig": {
19
20
  "access": "public"
@@ -29,61 +30,38 @@
29
30
  "prebuild": "rm -rf ./lib && rm -rf ./tsconfig.tsbuildinfo && npm run template",
30
31
  "build": "tsc",
31
32
  "test": "jest",
32
- "link": "node scripts/link-packages.js"
33
+ "link": "node scripts/link-packages.js",
34
+ "preinstall": "node scripts/preinstall.js"
33
35
  },
34
36
  "bugs": {
35
37
  "url": "https://github.com/TencentCloudBase/cloudbase-framework/issues"
36
38
  },
37
39
  "dependencies": {
38
- "@cloudbase/cals": "^0.3.34",
40
+ "@cloudbase/cals": "^0.3.35",
39
41
  "@cloudbase/framework-core": "^1.8.16",
40
42
  "@cloudbase/framework-plugin-auth": "^1.8.16",
41
- "@cloudbase/framework-plugin-mp": "v1.3.6-beta.8",
43
+ "@cloudbase/framework-plugin-mp": "1.9.5-beta.0",
42
44
  "@cloudbase/framework-plugin-website": "^1.8.17",
43
- "@cloudbase/lowcode-builder": "^1.0.5",
45
+ "@cloudbase/lowcode-builder": "^1.0.12",
44
46
  "@formily/react-schema-renderer": "1.1.7",
45
47
  "archiver": "^4.0.1",
46
- "axios": "^0.21.0",
47
- "chalk": "^2.4.2",
48
- "command-exists": "^1.2.9",
49
48
  "compressing": "^1.4.0",
50
49
  "cos-nodejs-sdk-v5": "^2.8.2",
51
50
  "cross-spawn": "^6.0.5",
52
- "electron-to-chromium": "1.4.193",
53
51
  "fs-extra": "^7.0.1",
54
- "json-schema-defaults": "^0.4.0",
55
52
  "less": "^4.0.0",
56
53
  "lodash": "^4.17.11",
57
- "lodash.clone": "^4.5.0",
58
- "lodash.get": "^4.4.2",
59
- "lodash.set": "^4.3.2",
60
- "lodash.template": "^4.5.0",
61
- "lodash.uniqby": "^4.7.0",
62
54
  "merge-package-json": "^0.1.3",
63
55
  "miniprogram-ci": "^1.8.0",
64
- "postcss": "^8.3.6",
65
- "postcss-pxtorem": "^6.0.0",
66
- "prettier": "^2.0.5",
67
- "qrcode": "^1.4.4",
68
- "react": "^16.12.0",
69
- "react-dom": "^16.8.6",
70
- "react-eva": "^1.1.12",
71
- "symlink-dir": "^3.1.1",
72
- "webpack": "^4.41.4",
73
- "xml-js": "^1.6.11"
56
+ "qrcode": "^1.4.4"
74
57
  },
75
58
  "devDependencies": {
76
59
  "@lerna/create-symlink": "^4.0.0",
77
60
  "@types/archiver": "^3.1.0",
78
- "@types/command-exists": "^1.2.0",
79
61
  "@types/cross-spawn": "^6.0.2",
80
62
  "@types/fs-extra": "^9.0.1",
81
63
  "@types/less": "^3.0.1",
82
- "@types/lodash.get": "^4.4.6",
83
- "@types/lodash.template": "^4.5.0",
84
64
  "@types/node": "^13.9.8",
85
- "@types/react": "^16.9.49",
86
- "@types/webpack": "^4.41.22",
87
65
  "@types/weixin-app": "^2.9.0",
88
66
  "csstype": "^2.6.10",
89
67
  "jest": "^26.0.1",
@@ -0,0 +1,31 @@
1
+ #!/bin/bash
2
+ set -x
3
+
4
+ NPM_VERSION=$(node -e "(function () { console.log(require('./package.json').version) })()")
5
+ NPM_NAME=$(node -e "(function () { console.log(require('./package.json').name) })()")
6
+ # 现网版本号
7
+ VERSION=0.6.17
8
+ # 产出文件名
9
+ NAME=plugin.tar.gz
10
+ # 产出目录,默认:脚本执行目录
11
+ DIST_PATH=`pwd`
12
+
13
+ cd $TMPDIR
14
+ # 清理历史目录
15
+ rm -rf $NPM_NAME/$NPM_VERSION
16
+ # 创建产出目录
17
+ mkdir -p $NPM_NAME/$NPM_VERSION
18
+ cd $NPM_NAME/$NPM_VERSION
19
+ pwd
20
+ # 安装包,@todo 目前保持老打包逻辑(安装方式),这块是否可以考虑不安装直接使用项目构建产出
21
+ npm i $NPM_NAME@$NPM_VERSION
22
+ cd node_modules/$NPM_NAME
23
+ pwd
24
+ # 安装生产依赖
25
+ yarn --production
26
+ # 更换版本号为现网版本号 0.6.17
27
+ npm version $VERSION
28
+ # 打包
29
+ tar -zcvf $NAME ./*
30
+ # 拷贝到产出目录
31
+ mv ./$NAME $DIST_PATH
@@ -0,0 +1,31 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const glob = require('glob');
4
+
5
+ const chokidar = require('chokidar');
6
+ const TEMPLATE_PATH = path.join(__dirname, '../template/generator');
7
+
8
+ // One-liner for current directory
9
+ generateTemplate();
10
+ if (process.env.npm_config_watch) {
11
+ chokidar.watch(TEMPLATE_PATH).on('all', (event, path) => {
12
+ console.log(event, path);
13
+ generateTemplate();
14
+ });
15
+ }
16
+
17
+ function generateTemplate() {
18
+ const files = glob.sync('**/*', { cwd: TEMPLATE_PATH, nodir: true });
19
+ const filesObj = files.reduce((obj, file) => {
20
+ obj[`/src/${file}`] = {
21
+ code: fs.readFileSync(path.join(TEMPLATE_PATH, file), {
22
+ encoding: 'utf8',
23
+ }),
24
+ };
25
+ return obj;
26
+ }, {});
27
+ fs.writeFileSync(
28
+ path.join(__dirname, '../src/generator/template.ts'),
29
+ `export default ${JSON.stringify(filesObj, null, 2)}`
30
+ );
31
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Tencent is pleased to support the open source community by making CloudBaseFramework - 云原生一体化部署工具 available.
3
+ *
4
+ * Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
5
+ *
6
+ * Please refer to license text included with this package for license details.
7
+ */
8
+
9
+ const link = require('./link');
10
+
11
+ link();
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Tencent is pleased to support the open source community by making CloudBaseFramework - 云原生一体化部署工具 available.
3
+ *
4
+ * Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
5
+ *
6
+ * Please refer to license text included with this package for license details.
7
+ */
8
+
9
+ const os = require('os');
10
+ const fs = require('fs');
11
+ const del = require('del');
12
+ const path = require('path');
13
+ const mkdirp = require('mkdirp');
14
+ const { execSync } = require('child_process');
15
+ const { createSymlink } = require('@lerna/create-symlink');
16
+
17
+ const globalNpmPath = execSync('npm root -g', {
18
+ encoding: 'utf-8',
19
+ }).trim();
20
+ // 如果不支持workspace 可以用下面写死
21
+ // const globalNpmPath = '/usr/local/lib/node_modules';
22
+
23
+ const pluginRegistry = path.join(os.homedir(), 'cloudbase-framework/registry');
24
+
25
+ module.exports = async function main() {
26
+ // await linkCore();
27
+ initRegistry();
28
+ await linkPlugins();
29
+ };
30
+
31
+ async function linkCore() {
32
+ await link(
33
+ path.join(process.cwd(), 'packages/framework-core'),
34
+ path.join(globalNpmPath, '@cloudbase/cli'),
35
+ '@cloudbase/framework-core'
36
+ );
37
+ }
38
+
39
+ function initRegistry() {
40
+ if (!fs.existsSync(pluginRegistry)) {
41
+ mkdirp.sync(pluginRegistry, { recursive: true });
42
+ }
43
+ const packageJSON = path.join(pluginRegistry, 'package.json');
44
+ if (!fs.existsSync(packageJSON)) {
45
+ fs.writeFileSync(
46
+ packageJSON,
47
+ JSON.stringify({
48
+ name: 'cloudbase-framework-registry',
49
+ })
50
+ );
51
+ }
52
+ }
53
+
54
+ async function linkPlugins() {
55
+ const files = ['framework-plugin-low-code'];
56
+
57
+ const plugins = files.filter((file) => file.includes('plugin'));
58
+ // 插件列表
59
+ console.log(plugins);
60
+
61
+ for (const plugin of plugins) {
62
+ console.log('\n', 'Link Plugin', plugin, '\n');
63
+ // 创建软连接
64
+ await link(
65
+ path.join(process.cwd()),
66
+ pluginRegistry,
67
+ `@cloudbase/${plugin}`
68
+ );
69
+ }
70
+ }
71
+
72
+ // 将 global tcb cli 工具中的 framework-core link 到 packages/framework-core
73
+ async function link(src, dest, packageName) {
74
+ const prevCwd = process.cwd();
75
+ const destPlugin = path.join(dest, 'node_modules', '@cloudbase');
76
+ // 确保目录存在
77
+ mkdirp.sync(destPlugin);
78
+ // 切换 cwd
79
+ process.chdir(destPlugin);
80
+ console.log('创建软连接:', process.cwd());
81
+ const pathName = packageName.replace('@cloudbase/', '');
82
+ // 删除已存在的文件
83
+ if (fs.existsSync(pathName)) {
84
+ del.sync([pathName]);
85
+ }
86
+ console.log('src', src);
87
+ console.log('pathName', pathName);
88
+ await createSymlink(src, pathName, 'junction');
89
+ // 切回源目录
90
+ process.chdir(prevCwd);
91
+ }
@@ -0,0 +1,43 @@
1
+ const spawn = require('cross-spawn');
2
+ const fs = require('fs-extra');
3
+ const path = require('path');
4
+
5
+ const packageName = '';
6
+ function installDependencies(targetDir) {
7
+ if (!process.env.CLOUDBASE_CIID) {
8
+ return;
9
+ }
10
+
11
+ let yarnExists = false;
12
+ // try {
13
+ // let { stdout } = spawn.sync('yarn', ['-v']);
14
+ // let str = stdout.toString();
15
+ // if (Number(str.split('.')?.[0]) <= 1) {
16
+ // yarnExists = true;
17
+ // }
18
+ // } catch (e) {}
19
+
20
+ const npmOptions = ['--prefer-offline', '--no-audit', '--progress=false', '--production', '--no-package-lock'];
21
+
22
+ let installProcess;
23
+ // 云端构建, 选用 npm
24
+ const installlProcessOptions = {
25
+ cwd: targetDir,
26
+ env: { ...process.env, NODE_ENV: '' },
27
+ stdio: 'inherit',
28
+ };
29
+
30
+ if (yarnExists && !process.env.CLOUDBASE_CIID) {
31
+ const addPackage = packageName ? ['add', packageName] : [];
32
+
33
+ installProcess = spawn.sync('yarn', [...addPackage], installlProcessOptions);
34
+ } else {
35
+ installProcess = spawn.sync('npm', ['install', packageName, ...npmOptions], installlProcessOptions);
36
+ }
37
+
38
+ try {
39
+ fs.removeSync(path.join(path.join(targetDir, 'yarn.lock')));
40
+ } catch (e) {}
41
+ }
42
+
43
+ installDependencies(path.join(__dirname, '../'));
@@ -0,0 +1,16 @@
1
+ const fs = require('fs-extra');
2
+ const path = require('path');
3
+
4
+ function installDependencies(targetDir) {
5
+ if (!process.env.CLOUDBASE_CIID) {
6
+ return;
7
+ }
8
+
9
+ try {
10
+ const lockPath = path.join(path.join(targetDir, 'package-lock.json'));
11
+ console.log('delete ' + lockPath);
12
+ fs.removeSync(lockPath);
13
+ } catch (e) {}
14
+ }
15
+
16
+ installDependencies('~/test/aaa/ttt/registry');