@cloudbase/framework-plugin-low-code 1.7.2 → 1.7.3

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 (238) 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 +54 -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 +792 -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/config/private.d.ts +3 -0
  107. package/lib/config/private.d.ts.map +1 -0
  108. package/lib/config/private.js +14 -0
  109. package/lib/generate.d.ts +2 -0
  110. package/lib/generate.d.ts.map +1 -0
  111. package/lib/generate.js +49 -0
  112. package/lib/generator/config/common.d.ts +6 -0
  113. package/lib/generator/config/common.d.ts.map +1 -0
  114. package/lib/generator/config/common.js +25 -0
  115. package/lib/generator/config/index.d.ts +18 -0
  116. package/lib/generator/config/index.d.ts.map +1 -0
  117. package/lib/generator/config/index.js +43 -0
  118. package/lib/generator/config/mp.d.ts +56 -0
  119. package/lib/generator/config/mp.d.ts.map +1 -0
  120. package/lib/generator/config/mp.js +104 -0
  121. package/lib/generator/core/generate.d.ts +59 -0
  122. package/lib/generator/core/generate.d.ts.map +1 -0
  123. package/lib/generator/core/generate.js +663 -0
  124. package/lib/generator/core/index.d.ts +25 -0
  125. package/lib/generator/core/index.d.ts.map +1 -0
  126. package/lib/generator/core/index.js +102 -0
  127. package/lib/generator/core/material.d.ts +14 -0
  128. package/lib/generator/core/material.d.ts.map +1 -0
  129. package/lib/generator/core/material.js +230 -0
  130. package/lib/generator/template.d.ts +3 -0
  131. package/lib/generator/template.d.ts.map +1 -0
  132. package/lib/generator/template.js +3 -0
  133. package/lib/generator/types/common.d.ts +69 -0
  134. package/lib/generator/types/common.d.ts.map +1 -0
  135. package/lib/generator/types/common.js +21 -0
  136. package/lib/generator/util/common.d.ts +36 -0
  137. package/lib/generator/util/common.d.ts.map +1 -0
  138. package/lib/generator/util/common.js +238 -0
  139. package/lib/generator/util/console.d.ts +3 -0
  140. package/lib/generator/util/console.d.ts.map +1 -0
  141. package/lib/generator/util/console.js +17 -0
  142. package/lib/generator/util/index.d.ts +2 -0
  143. package/lib/generator/util/index.d.ts.map +1 -0
  144. package/lib/generator/util/index.js +13 -0
  145. package/lib/generator/util/name-mangler.d.ts +17 -0
  146. package/lib/generator/util/name-mangler.d.ts.map +1 -0
  147. package/lib/generator/util/name-mangler.js +63 -0
  148. package/lib/generator/util/postcss-rpx.d.ts +11 -0
  149. package/lib/generator/util/postcss-rpx.d.ts.map +1 -0
  150. package/lib/generator/util/postcss-rpx.js +16 -0
  151. package/lib/generator/util/style.d.ts +6 -0
  152. package/lib/generator/util/style.d.ts.map +1 -0
  153. package/lib/generator/util/style.js +92 -0
  154. package/lib/generator/util/weapp.d.ts +5 -0
  155. package/lib/generator/util/weapp.d.ts.map +1 -0
  156. package/lib/generator/util/weapp.js +17 -0
  157. package/lib/index.d.ts +0 -0
  158. package/lib/index.d.ts.map +0 -0
  159. package/lib/index.js +0 -0
  160. package/lib/types.d.ts +14 -0
  161. package/lib/types.d.ts.map +1 -0
  162. package/lib/types.js +19 -0
  163. package/lib/utils/common.d.ts +0 -0
  164. package/lib/utils/common.d.ts.map +0 -0
  165. package/lib/utils/common.js +0 -0
  166. package/lib/utils/dataSource.d.ts +28 -0
  167. package/lib/utils/dataSource.d.ts.map +1 -0
  168. package/lib/utils/dataSource.js +171 -0
  169. package/lib/utils/index.d.ts +0 -0
  170. package/lib/utils/index.d.ts.map +0 -0
  171. package/lib/utils/index.js +0 -0
  172. package/lib/utils/postProcess.d.ts +3 -0
  173. package/lib/utils/postProcess.d.ts.map +1 -0
  174. package/lib/utils/postProcess.js +48 -0
  175. package/lib/weapps-core/config/index.d.ts +2 -0
  176. package/lib/weapps-core/config/index.d.ts.map +1 -0
  177. package/lib/weapps-core/config/index.js +13 -0
  178. package/lib/weapps-core/config/style.d.ts +7 -0
  179. package/lib/weapps-core/config/style.d.ts.map +1 -0
  180. package/lib/weapps-core/config/style.js +70 -0
  181. package/lib/weapps-core/index.d.ts +6 -0
  182. package/lib/weapps-core/index.d.ts.map +1 -0
  183. package/lib/weapps-core/index.js +31 -0
  184. package/lib/weapps-core/types/action.d.ts +25 -0
  185. package/lib/weapps-core/types/action.d.ts.map +1 -0
  186. package/lib/weapps-core/types/action.js +28 -0
  187. package/lib/weapps-core/types/app.d.ts +142 -0
  188. package/lib/weapps-core/types/app.d.ts.map +1 -0
  189. package/lib/weapps-core/types/app.js +21 -0
  190. package/lib/weapps-core/types/appbuild.d.ts +63 -0
  191. package/lib/weapps-core/types/appbuild.d.ts.map +1 -0
  192. package/lib/weapps-core/types/appbuild.js +78 -0
  193. package/lib/weapps-core/types/code_types.d.ts +26 -0
  194. package/lib/weapps-core/types/code_types.d.ts.map +1 -0
  195. package/lib/weapps-core/types/code_types.js +2 -0
  196. package/lib/weapps-core/types/git.d.ts +7 -0
  197. package/lib/weapps-core/types/git.d.ts.map +1 -0
  198. package/lib/weapps-core/types/git.js +2 -0
  199. package/lib/weapps-core/types/index.d.ts +11 -0
  200. package/lib/weapps-core/types/index.d.ts.map +1 -0
  201. package/lib/weapps-core/types/index.js +22 -0
  202. package/lib/weapps-core/types/lowcode.d.ts +26 -0
  203. package/lib/weapps-core/types/lowcode.d.ts.map +1 -0
  204. package/lib/weapps-core/types/lowcode.js +25 -0
  205. package/lib/weapps-core/types/material.d.ts +90 -0
  206. package/lib/weapps-core/types/material.d.ts.map +1 -0
  207. package/lib/weapps-core/types/material.js +9 -0
  208. package/lib/weapps-core/types/plugins.d.ts +17 -0
  209. package/lib/weapps-core/types/plugins.d.ts.map +1 -0
  210. package/lib/weapps-core/types/plugins.js +2 -0
  211. package/lib/weapps-core/types/style.d.ts +93 -0
  212. package/lib/weapps-core/types/style.d.ts.map +1 -0
  213. package/lib/weapps-core/types/style.js +2 -0
  214. package/lib/weapps-core/types/web.d.ts +120 -0
  215. package/lib/weapps-core/types/web.d.ts.map +1 -0
  216. package/lib/weapps-core/types/web.js +2 -0
  217. package/lib/weapps-core/utils/appbuild.d.ts +6 -0
  218. package/lib/weapps-core/utils/appbuild.d.ts.map +1 -0
  219. package/lib/weapps-core/utils/appbuild.js +40 -0
  220. package/lib/weapps-core/utils/common.d.ts +16 -0
  221. package/lib/weapps-core/utils/common.d.ts.map +1 -0
  222. package/lib/weapps-core/utils/common.js +90 -0
  223. package/lib/weapps-core/utils/file.d.ts +12 -0
  224. package/lib/weapps-core/utils/file.d.ts.map +1 -0
  225. package/lib/weapps-core/utils/file.js +142 -0
  226. package/lib/weapps-core/utils/formily.d.ts +5 -0
  227. package/lib/weapps-core/utils/formily.d.ts.map +1 -0
  228. package/lib/weapps-core/utils/formily.js +416 -0
  229. package/lib/weapps-core/utils/index.d.ts +7 -0
  230. package/lib/weapps-core/utils/index.d.ts.map +1 -0
  231. package/lib/weapps-core/utils/index.js +18 -0
  232. package/lib/weapps-core/utils/lowcdoe.d.ts +4 -0
  233. package/lib/weapps-core/utils/lowcdoe.d.ts.map +1 -0
  234. package/lib/weapps-core/utils/lowcdoe.js +69 -0
  235. package/lib/weapps-core/utils/style.d.ts +17 -0
  236. package/lib/weapps-core/utils/style.d.ts.map +1 -0
  237. package/lib/weapps-core/utils/style.js +330 -0
  238. package/package.json +3 -3
@@ -0,0 +1,416 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readCmpInstances = exports.deserialize = exports.serialize = void 0;
4
+ const types_1 = require("../types");
5
+ const common_1 = require("./common");
6
+ const style_1 = require("./style");
7
+ const types_2 = require("../../types");
8
+ function serialize(webRuntimeAppData) {
9
+ const weAppData = {
10
+ selectedPageId: webRuntimeAppData.selectedPageId,
11
+ pageInstanceList: [],
12
+ lowCodes: webRuntimeAppData.codeModules,
13
+ npmDependencies: webRuntimeAppData.npmDependencies,
14
+ plugins: webRuntimeAppData.plugins,
15
+ rootPath: webRuntimeAppData.rootPath,
16
+ datasources: webRuntimeAppData.datasources || [],
17
+ vars: webRuntimeAppData.vars || { data: [] },
18
+ dataset: webRuntimeAppData.dataset,
19
+ };
20
+ (0, common_1.setValidValue)(weAppData, 'appConfig', webRuntimeAppData.appConfig);
21
+ (0, common_1.setValidValue)(weAppData, 'themeVars', webRuntimeAppData.themeVars);
22
+ (0, common_1.setValidValue)(weAppData, 'presetColors', webRuntimeAppData.presetColors);
23
+ handlePageInstanceList(webRuntimeAppData.pageInstanceList, weAppData.pageInstanceList);
24
+ function handlePageInstanceList(pageInstanceList, collection) {
25
+ pageInstanceList.map((pageData) => {
26
+ var _a;
27
+ const newPage = {
28
+ id: pageData.id,
29
+ };
30
+ (0, common_1.setValidValue)(newPage, 'isHome', pageData.isHome);
31
+ (0, common_1.setValidValue)(newPage, 'data', readDynamicData(pageData));
32
+ (0, common_1.setValidValue)(newPage, 'commonStyle', (0, style_1.removeInvalidStyleFormValue)(pageData.style));
33
+ (0, common_1.setValidValue)(newPage, 'styleBindPath', pageData.styleBindPath);
34
+ if ((0, common_1.isValidStyleBind)(pageData.styleBind)) {
35
+ (0, common_1.setValidValue)(newPage, 'styleBind', pageData.styleBind);
36
+ }
37
+ if ((0, common_1.isValidClassNameListBind)(pageData.classNameListBind)) {
38
+ (0, common_1.setValidValue)(newPage, 'classNameListBind', pageData.classNameListBind);
39
+ }
40
+ (0, common_1.setValidValue)(newPage, 'componentInstances', readComponents(pageData.componentSchemaJson.properties));
41
+ (0, common_1.setValidValue)(newPage, 'listeners', readListeners(pageData.listenerInstances));
42
+ (0, common_1.setValidValue)(newPage, 'pluginInstances', pageData.pluginInstances);
43
+ (0, common_1.setValidValue)(newPage, 'lowCodes', pageData.codeModules);
44
+ if ((_a = pageData.children) === null || _a === void 0 ? void 0 : _a.length) {
45
+ newPage.children = newPage.children || [];
46
+ handlePageInstanceList(pageData.children, newPage.children);
47
+ }
48
+ collection.push(newPage);
49
+ });
50
+ }
51
+ function readComponents(properties = {}, excludeKeys = []) {
52
+ var _a;
53
+ const cmps = {};
54
+ for (const key in properties) {
55
+ if (excludeKeys.indexOf(key) > -1) {
56
+ continue;
57
+ }
58
+ const srcCmp = properties[key];
59
+ const srcProps = srcCmp['x-props'];
60
+ if (srcProps) {
61
+ const cmpParts = srcProps.sourceKey.split(':');
62
+ cmps[key] = { genericComp: srcCmp['genericComp'] };
63
+ (0, common_1.setValidValue)(cmps[key], 'xComponent', {
64
+ moduleName: cmpParts[0],
65
+ name: cmpParts[1],
66
+ });
67
+ const componentXProps = {};
68
+ (0, common_1.setValidValue)(componentXProps, 'data', readDynamicData(srcProps));
69
+ (0, common_1.setValidValue)(componentXProps, 'listeners', readListeners(srcProps.listenerInstances));
70
+ (0, common_1.setValidValue)(componentXProps, 'staticResourceAttribute', srcProps.staticResourceAttribute);
71
+ (0, common_1.setValidValue)(componentXProps, 'directives', readDirectives(srcProps));
72
+ (0, common_1.setValidValue)(componentXProps, 'customDataForm', srcProps.customDataForm);
73
+ (0, common_1.setValidValue)(componentXProps, 'style', srcProps.style);
74
+ (0, common_1.setValidValue)(componentXProps, 'commonStyle', (0, style_1.removeInvalidStyleFormValue)(srcProps.commonStyle));
75
+ (0, common_1.setValidValue)(componentXProps, 'styleBindPath', srcProps.styleBindPath);
76
+ if ((_a = srcProps.styleBind) === null || _a === void 0 ? void 0 : _a.bindDataPath) {
77
+ componentXProps.styleBind = {
78
+ type: srcProps.styleBind.type,
79
+ value: srcProps.styleBind.bindDataPath,
80
+ };
81
+ }
82
+ if ((0, common_1.isValidClassNameListBind)(srcProps.classNameListBind)) {
83
+ const classList = srcProps.classNameListBind;
84
+ (0, common_1.setValidValue)(componentXProps, 'classListBind', {
85
+ type: classList.type,
86
+ value: classList.bindDataPath,
87
+ });
88
+ }
89
+ if (srcProps.classNameList) {
90
+ (0, common_1.setValidValue)(componentXProps, 'classList', srcProps.classNameList);
91
+ }
92
+ (0, common_1.setValidValue)(cmps[key], 'xProps', componentXProps);
93
+ (0, common_1.setValidValue)(cmps[key], 'xIndex', srcCmp['x-index']);
94
+ const excludeKeys = (srcProps.dataTypes || [])
95
+ .filter((dataType) => dataType.type !== 'slot')
96
+ .map((dataType) => dataType.propertyPath);
97
+ (0, common_1.setValidValue)(cmps[key], 'properties', readComponents(srcCmp.properties, excludeKeys));
98
+ }
99
+ else {
100
+ cmps[key] = { properties: readComponents(srcCmp.properties) };
101
+ }
102
+ }
103
+ return cmps;
104
+ }
105
+ function readDirectives(cmp) {
106
+ var _a, _b, _c;
107
+ const directives = {};
108
+ if (cmp.data && cmp.data._visible !== true) {
109
+ directives.waIf = {
110
+ value: cmp.data._visible,
111
+ };
112
+ }
113
+ if ((_a = cmp.dataBinds) === null || _a === void 0 ? void 0 : _a.length) {
114
+ const bind = cmp.dataBinds.find((bind) => bind.propertyPath === '_visible');
115
+ if (bind) {
116
+ const foundDataType = (cmp.dataTypes || []).find((dataType) => dataType.propertyPath === bind.propertyPath);
117
+ if (foundDataType && foundDataType.type === 'bind') {
118
+ directives.waIf = {
119
+ type: bind.type || types_1.PropBindType.state,
120
+ value: bind.bindDataPath,
121
+ };
122
+ }
123
+ }
124
+ const forBind = cmp.dataBinds.find((bind) => bind.propertyPath === '_waFor');
125
+ if (forBind) {
126
+ directives.waFor = {
127
+ type: forBind.type || types_1.PropBindType.state,
128
+ value: forBind.bindDataPath,
129
+ };
130
+ }
131
+ }
132
+ if (directives.waFor && ((_b = cmp.data) === null || _b === void 0 ? void 0 : _b._waForKey)) {
133
+ directives.waForKey = {
134
+ value: (_c = cmp.data) === null || _c === void 0 ? void 0 : _c._waForKey,
135
+ };
136
+ }
137
+ return directives;
138
+ }
139
+ function readDynamicData(cmp) {
140
+ var _a;
141
+ const data = {};
142
+ const ignoredProps = ['_visible', '_waFor', '_waForKey'];
143
+ for (const prop in cmp.data) {
144
+ if (ignoredProps.indexOf(prop) > -1) {
145
+ continue;
146
+ }
147
+ data[prop] = { value: cmp.data[prop] };
148
+ }
149
+ (_a = cmp.dataBinds) === null || _a === void 0 ? void 0 : _a.forEach((bind) => {
150
+ if (ignoredProps.indexOf(bind.propertyPath) > -1) {
151
+ return;
152
+ }
153
+ const foundDataType = (cmp.dataTypes || []).find((dataType) => dataType.propertyPath === bind.propertyPath);
154
+ if (foundDataType && foundDataType.type === 'bind') {
155
+ data[bind.propertyPath] = {
156
+ type: bind.type || types_1.PropBindType.state,
157
+ value: bind.bindDataPath,
158
+ };
159
+ }
160
+ });
161
+ return data;
162
+ }
163
+ function readListeners(listenerInstances = []) {
164
+ const listeners = listenerInstances.map((act) => {
165
+ const fromParts = act.sourceKey.split(':');
166
+ let handler;
167
+ if (act.type !== types_1.ActionType.Inline) {
168
+ const fromParts = act.sourceKey.split(':');
169
+ handler = {
170
+ handler: {
171
+ moduleName: fromParts[0],
172
+ name: fromParts[1],
173
+ },
174
+ };
175
+ }
176
+ else {
177
+ handler = { jsCode: act.jsCode };
178
+ }
179
+ return Object.assign(Object.assign({ key: act.key || '', trigger: act.trigger, type: act.type }, handler), { data: readDynamicData(act), isCapturePhase: act.isCapturePhase, noPropagation: act.noPropagation });
180
+ });
181
+ return listeners;
182
+ }
183
+ return weAppData;
184
+ }
185
+ exports.serialize = serialize;
186
+ function deserialize(weAppData) {
187
+ const webRuntimeAppData = {
188
+ appTitle: weAppData.label,
189
+ label: weAppData.label,
190
+ selectedPageId: weAppData.selectedPageId,
191
+ historyType: weAppData.historyType || types_2.HISTORY_TYPE.BROWSER,
192
+ pageInstanceList: [],
193
+ codeModules: weAppData.lowCodes || [],
194
+ npmDependencies: weAppData.npmDependencies || {},
195
+ plugins: weAppData.plugins || [],
196
+ rootPath: weAppData.rootPath || '',
197
+ themeVars: weAppData.themeVars || {},
198
+ presetColors: weAppData.presetColors || [],
199
+ appConfig: weAppData.appConfig || {},
200
+ datasources: weAppData.datasources || [],
201
+ vars: weAppData.vars || { data: [] },
202
+ dataset: weAppData.dataset,
203
+ envId: weAppData.envId || '',
204
+ extra: weAppData.extra || {},
205
+ };
206
+ handlePageInstanceList(weAppData.pageInstanceList, webRuntimeAppData.pageInstanceList);
207
+ function handlePageInstanceList(pageInstanceList, collection) {
208
+ pageInstanceList.map((srcPage) => {
209
+ var _a;
210
+ const page = {
211
+ id: srcPage.id,
212
+ data: {},
213
+ dataBinds: [],
214
+ vars: { data: [] },
215
+ dataset: srcPage.dataset,
216
+ };
217
+ page.vars = srcPage.vars ? srcPage.vars : page.vars;
218
+ page.isHome = srcPage.isHome || false;
219
+ page.style = srcPage.commonStyle || {};
220
+ (0, common_1.setValidValue)(page, 'styleBindPath', srcPage.styleBindPath);
221
+ page.codeModules = srcPage.lowCodes || [];
222
+ page.pluginInstances = srcPage.pluginInstances || [];
223
+ page.componentSchemaJson = {
224
+ type: 'object',
225
+ properties: readCmpInstances(srcPage.componentInstances),
226
+ 'x-index': 0,
227
+ };
228
+ page.listenerInstances = readListeners(srcPage.listeners) || [];
229
+ if (srcPage['code']) {
230
+ const target = srcPage['codeType'] === 'page' ? page : webRuntimeAppData;
231
+ target.codeModules.push({
232
+ type: 'rematch',
233
+ code: srcPage['code'],
234
+ name: srcPage.id,
235
+ path: '',
236
+ });
237
+ }
238
+ readDynamicData(srcPage.data, page);
239
+ if ((_a = srcPage.children) === null || _a === void 0 ? void 0 : _a.length) {
240
+ page.children = page.children || [];
241
+ handlePageInstanceList(srcPage.children, page.children);
242
+ }
243
+ collection.push(page);
244
+ });
245
+ }
246
+ return webRuntimeAppData;
247
+ }
248
+ exports.deserialize = deserialize;
249
+ function readCmpInstances(cmps) {
250
+ const properties = {};
251
+ for (const key in cmps) {
252
+ const cmp = cmps[key];
253
+ const target = (properties[key] = {
254
+ key,
255
+ type: 'object',
256
+ properties: readCmpInstances(cmp.properties || {}),
257
+ genericComp: cmp.genericComp,
258
+ });
259
+ if (cmp.xComponent) {
260
+ cmp.xProps = (cmp.xProps || {});
261
+ const xCmp = cmp.xComponent.moduleName + ':' + cmp.xComponent.name;
262
+ const xProps = {
263
+ sourceKey: xCmp,
264
+ data: {},
265
+ };
266
+ xProps.dataBinds = xProps.dataBinds || [];
267
+ xProps.dataTypes = xProps.dataTypes || [];
268
+ xProps.customDataForm = xProps.customDataForm || {};
269
+ xProps.style = cmp.xProps.style || {};
270
+ xProps.commonStyle = cmp.xProps.commonStyle || {};
271
+ xProps.staticResourceAttribute = cmp.xProps.staticResourceAttribute || [];
272
+ (0, common_1.setValidValue)(xProps, 'styleBindPath', cmp.xProps.styleBindPath);
273
+ let { classList, classListBind } = cmp.xProps;
274
+ const { styleBind } = cmp.xProps;
275
+ const legacyClassList = classList;
276
+ if (legacyClassList === null || legacyClassList === void 0 ? void 0 : legacyClassList.value) {
277
+ if (!legacyClassList.type || legacyClassList.type === 'static') {
278
+ classList = legacyClassList.value;
279
+ }
280
+ else {
281
+ classList = [];
282
+ classListBind = classListBind;
283
+ }
284
+ }
285
+ classList && (0, common_1.setValidValue)(xProps, 'classNameList', classList);
286
+ classListBind &&
287
+ (0, common_1.setValidValue)(xProps, 'classNameListBind', {
288
+ type: classListBind.type,
289
+ propertyPath: 'classNameList',
290
+ bindDataPath: classListBind.value,
291
+ });
292
+ if (styleBind && styleBind.type !== 'static') {
293
+ xProps.styleBind = {
294
+ type: styleBind.type,
295
+ propertyPath: 'style',
296
+ bindDataPath: styleBind.value,
297
+ };
298
+ }
299
+ xProps.listenerInstances = readListeners(cmp.xProps.listeners) || [];
300
+ readDynamicData(cmp.xProps.data, xProps, cmp.properties);
301
+ if (cmp.xProps.directives) {
302
+ const { waIf, waFor, waForKey } = cmp.xProps.directives;
303
+ if (waIf) {
304
+ if (waIf.type === 'static' || waIf.type === undefined) {
305
+ xProps.data = xProps.data || {};
306
+ xProps.data._visible = waIf.value;
307
+ }
308
+ else {
309
+ xProps.dataBinds = xProps.dataBinds || [];
310
+ xProps.dataBinds.push({
311
+ type: waIf.type || types_1.PropBindType.state,
312
+ propertyPath: '_visible',
313
+ bindDataPath: waIf.value,
314
+ });
315
+ xProps.dataTypes.push({
316
+ propertyPath: '_visible',
317
+ type: 'bind',
318
+ });
319
+ }
320
+ }
321
+ if (waFor && waFor.type !== 'static') {
322
+ xProps.dataBinds = xProps.dataBinds || [];
323
+ xProps.dataBinds.push({
324
+ type: waFor.type || types_1.PropBindType.state,
325
+ propertyPath: '_waFor',
326
+ bindDataPath: waFor.value,
327
+ });
328
+ xProps.dataTypes.push({
329
+ propertyPath: '_waFor',
330
+ type: 'bind',
331
+ });
332
+ if (waForKey && (waForKey.type === 'static' || waForKey.type === undefined)) {
333
+ xProps.data = xProps.data || {};
334
+ xProps.data._waForKey = waForKey.value;
335
+ }
336
+ }
337
+ }
338
+ else {
339
+ xProps.data = xProps.data || {};
340
+ xProps.data._visible = true;
341
+ }
342
+ (0, common_1.setValidValue)(target, 'x-component', xCmp.toLocaleLowerCase());
343
+ (0, common_1.setValidValue)(xProps, 'customDataForm', cmp.xProps.customDataForm);
344
+ target['x-props'] = xProps;
345
+ (0, common_1.setValidValue)(target, 'x-index', cmp.xIndex);
346
+ }
347
+ }
348
+ return properties;
349
+ }
350
+ exports.readCmpInstances = readCmpInstances;
351
+ function readListeners(listeners = []) {
352
+ return listeners.map((l) => {
353
+ const { handler } = l;
354
+ const act = {
355
+ key: l.key || '',
356
+ sourceKey: handler ? handler.moduleName + ':' + handler.name : '',
357
+ trigger: l.trigger,
358
+ type: l.type,
359
+ data: {},
360
+ dataBinds: [],
361
+ handler: l.handler,
362
+ jsCode: l.jsCode,
363
+ isCapturePhase: l.isCapturePhase,
364
+ noPropagation: l.noPropagation,
365
+ };
366
+ readDynamicData(l.data, act);
367
+ return act;
368
+ });
369
+ }
370
+ function readDynamicData(from = {}, to, properties) {
371
+ to.dataTypes = to.dataTypes || [];
372
+ for (const prop in from) {
373
+ const dv = from[prop];
374
+ if (dv.type === 'static' || dv.type === undefined) {
375
+ to.data = to.data || {};
376
+ to.data[prop] = dv.value;
377
+ to.dataTypes.push({
378
+ propertyPath: prop,
379
+ type: 'static',
380
+ });
381
+ }
382
+ else if (dv.type === 'slot') {
383
+ to.dataTypes.push({
384
+ propertyPath: prop,
385
+ type: 'slot',
386
+ });
387
+ }
388
+ else {
389
+ to.dataBinds = to.dataBinds || [];
390
+ to.dataBinds.push({
391
+ propertyPath: prop,
392
+ bindDataPath: dv.value,
393
+ type: dv.type,
394
+ });
395
+ to.dataTypes.push({
396
+ propertyPath: prop,
397
+ type: 'bind',
398
+ });
399
+ }
400
+ }
401
+ if (properties) {
402
+ Object.keys(properties).forEach((key) => {
403
+ const foundOne = to.dataTypes.find((dataType) => dataType.propertyPath === key);
404
+ if (foundOne) {
405
+ foundOne.type = 'slot';
406
+ }
407
+ else {
408
+ if (!properties[key].xComponent)
409
+ to.dataTypes.push({
410
+ propertyPath: key,
411
+ type: 'slot',
412
+ });
413
+ }
414
+ });
415
+ }
416
+ }
@@ -0,0 +1,7 @@
1
+ export * from './formily';
2
+ export * from './style';
3
+ export * from './common';
4
+ export * from './lowcdoe';
5
+ export * from './file';
6
+ export * from './appbuild';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/weapps-core/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./formily"), exports);
14
+ __exportStar(require("./style"), exports);
15
+ __exportStar(require("./common"), exports);
16
+ __exportStar(require("./lowcdoe"), exports);
17
+ __exportStar(require("./file"), exports);
18
+ __exportStar(require("./appbuild"), exports);
@@ -0,0 +1,4 @@
1
+ import { ILowCodesModifyStatus, IWeAppData, ILockedPage } from '../types';
2
+ export declare function evalExpression(code: string, runtime: any): any;
3
+ export declare function receiveDataByLowcodeDiff(lastestAppData: IWeAppData, appSaveData: IWeAppData, allLowCodes: ILowCodesModifyStatus[], redisLockedPages: ILockedPage[], username: string): void;
4
+ //# sourceMappingURL=lowcdoe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lowcdoe.d.ts","sourceRoot":"","sources":["../../../src/weapps-core/utils/lowcdoe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACzE,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAMxD;AAiBD,wBAAgB,wBAAwB,CACtC,cAAc,EAAE,UAAU,EAC1B,WAAW,EAAE,UAAU,EACvB,WAAW,EAAE,qBAAqB,EAAE,EACpC,gBAAgB,EAAE,WAAW,EAAE,EAC/B,QAAQ,EAAE,MAAM,QAwDjB"}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.receiveDataByLowcodeDiff = exports.evalExpression = void 0;
4
+ function evalExpression(code, runtime) {
5
+ try {
6
+ return runtime.eval(`(function(forItems, $context){const $for = forItems; return ${code};})`);
7
+ }
8
+ catch (e) {
9
+ runtime.console.error(`Error in expression:\t${code}\n\n`, e);
10
+ }
11
+ }
12
+ exports.evalExpression = evalExpression;
13
+ function findLowcodeItem(appData, lowcodeDiff) {
14
+ const pathKeys = lowcodeDiff.path.split('/');
15
+ if (pathKeys[0] === 'global') {
16
+ return appData.lowCodes.find((item) => item.path === lowcodeDiff.path);
17
+ }
18
+ else {
19
+ const pageInstance = appData.pageInstanceList.find((item) => item.id === pathKeys[0]);
20
+ return pageInstance.lowCodes.find((item) => item.path === lowcodeDiff.path);
21
+ }
22
+ }
23
+ function receiveDataByLowcodeDiff(lastestAppData, appSaveData, allLowCodes, redisLockedPages, username) {
24
+ allLowCodes.forEach((lowcodeDiff) => {
25
+ const cannotDel = redisLockedPages.find((lockedPage) => lockedPage.id === lowcodeDiff.path && username !== lockedPage.username);
26
+ if (cannotDel)
27
+ return;
28
+ const pathKeys = lowcodeDiff.path.split('/');
29
+ let index = -1;
30
+ switch (lowcodeDiff.type) {
31
+ case 'add':
32
+ case 'mod':
33
+ if (pathKeys[0] === 'global') {
34
+ const lowcode = findLowcodeItem(appSaveData, lowcodeDiff);
35
+ index = lastestAppData.lowCodes.findIndex((item) => item.path === lowcodeDiff.path);
36
+ if (index === -1) {
37
+ lastestAppData.lowCodes.push(lowcode);
38
+ }
39
+ else {
40
+ lastestAppData.lowCodes[index] = lowcode;
41
+ }
42
+ }
43
+ else {
44
+ const lowcode = findLowcodeItem(appSaveData, lowcodeDiff);
45
+ const pageInstance = lastestAppData.pageInstanceList.find((item) => item.id === pathKeys[0]);
46
+ index = pageInstance.lowCodes.findIndex((item) => item.path === lowcodeDiff.path);
47
+ if (index === -1) {
48
+ pageInstance.lowCodes.push(lowcode);
49
+ }
50
+ else {
51
+ pageInstance.lowCodes[index] = lowcode;
52
+ }
53
+ }
54
+ break;
55
+ case 'del':
56
+ if (pathKeys[0] === 'global') {
57
+ index = lastestAppData.lowCodes.findIndex((item) => item.path === lowcodeDiff.path);
58
+ index > -1 && lastestAppData.lowCodes.splice(index, 1);
59
+ }
60
+ else {
61
+ const pageInstance = lastestAppData.pageInstanceList.find((item) => item.id === pathKeys[0]);
62
+ index = pageInstance.lowCodes.findIndex((item) => item.path === lowcodeDiff.path);
63
+ index > -1 && pageInstance.lowCodes.splice(index, 1);
64
+ }
65
+ break;
66
+ }
67
+ });
68
+ }
69
+ exports.receiveDataByLowcodeDiff = receiveDataByLowcodeDiff;
@@ -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"}