@cloudbase/framework-plugin-low-code 1.0.1 → 1.0.2-beta.2

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 (218) hide show
  1. package/package.json +4 -4
  2. package/template/src/datasources/index.js.tpl +0 -2
  3. package/lib/builder/config/common.d.ts +0 -2
  4. package/lib/builder/config/common.d.ts.map +0 -1
  5. package/lib/builder/config/common.js +0 -13
  6. package/lib/builder/config/index.d.ts +0 -3
  7. package/lib/builder/config/index.d.ts.map +0 -1
  8. package/lib/builder/config/index.js +0 -29
  9. package/lib/builder/config/mp.d.ts +0 -2
  10. package/lib/builder/config/mp.d.ts.map +0 -1
  11. package/lib/builder/config/mp.js +0 -13
  12. package/lib/builder/core/copy.d.ts +0 -5
  13. package/lib/builder/core/copy.d.ts.map +0 -1
  14. package/lib/builder/core/copy.js +0 -62
  15. package/lib/builder/core/generate.d.ts +0 -9
  16. package/lib/builder/core/generate.d.ts.map +0 -1
  17. package/lib/builder/core/generate.js +0 -128
  18. package/lib/builder/core/index.d.ts +0 -32
  19. package/lib/builder/core/index.d.ts.map +0 -1
  20. package/lib/builder/core/index.js +0 -149
  21. package/lib/builder/core/material.d.ts +0 -4
  22. package/lib/builder/core/material.d.ts.map +0 -1
  23. package/lib/builder/core/material.js +0 -80
  24. package/lib/builder/core/plugin.d.ts +0 -4
  25. package/lib/builder/core/plugin.d.ts.map +0 -1
  26. package/lib/builder/core/plugin.js +0 -30
  27. package/lib/builder/core/prepare.d.ts +0 -8
  28. package/lib/builder/core/prepare.d.ts.map +0 -1
  29. package/lib/builder/core/prepare.js +0 -108
  30. package/lib/builder/core/webpack.d.ts +0 -15
  31. package/lib/builder/core/webpack.d.ts.map +0 -1
  32. package/lib/builder/core/webpack.js +0 -58
  33. package/lib/builder/mp/BuildContext.d.ts +0 -13
  34. package/lib/builder/mp/BuildContext.d.ts.map +0 -1
  35. package/lib/builder/mp/BuildContext.js +0 -2
  36. package/lib/builder/mp/index.d.ts +0 -33
  37. package/lib/builder/mp/index.d.ts.map +0 -1
  38. package/lib/builder/mp/index.js +0 -453
  39. package/lib/builder/mp/lowcode.d.ts +0 -8
  40. package/lib/builder/mp/lowcode.d.ts.map +0 -1
  41. package/lib/builder/mp/lowcode.js +0 -58
  42. package/lib/builder/mp/materials.d.ts +0 -15
  43. package/lib/builder/mp/materials.d.ts.map +0 -1
  44. package/lib/builder/mp/materials.js +0 -338
  45. package/lib/builder/mp/mixMode.d.ts +0 -10
  46. package/lib/builder/mp/mixMode.d.ts.map +0 -1
  47. package/lib/builder/mp/mixMode.js +0 -215
  48. package/lib/builder/mp/mp_config.d.ts +0 -18
  49. package/lib/builder/mp/mp_config.d.ts.map +0 -1
  50. package/lib/builder/mp/mp_config.js +0 -206
  51. package/lib/builder/mp/util.d.ts +0 -20
  52. package/lib/builder/mp/util.d.ts.map +0 -1
  53. package/lib/builder/mp/util.js +0 -239
  54. package/lib/builder/mp/wxml.d.ts +0 -16
  55. package/lib/builder/mp/wxml.d.ts.map +0 -1
  56. package/lib/builder/mp/wxml.js +0 -310
  57. package/lib/builder/service/builder/copy.d.ts +0 -14
  58. package/lib/builder/service/builder/copy.d.ts.map +0 -1
  59. package/lib/builder/service/builder/copy.js +0 -185
  60. package/lib/builder/service/builder/generate.d.ts +0 -52
  61. package/lib/builder/service/builder/generate.d.ts.map +0 -1
  62. package/lib/builder/service/builder/generate.js +0 -800
  63. package/lib/builder/service/builder/index.d.ts +0 -16
  64. package/lib/builder/service/builder/index.d.ts.map +0 -1
  65. package/lib/builder/service/builder/index.js +0 -69
  66. package/lib/builder/service/builder/plugin.d.ts +0 -8
  67. package/lib/builder/service/builder/plugin.d.ts.map +0 -1
  68. package/lib/builder/service/builder/plugin.js +0 -149
  69. package/lib/builder/service/builder/webpack.d.ts +0 -91
  70. package/lib/builder/service/builder/webpack.d.ts.map +0 -1
  71. package/lib/builder/service/builder/webpack.js +0 -594
  72. package/lib/builder/types/common.d.ts +0 -12
  73. package/lib/builder/types/common.d.ts.map +0 -1
  74. package/lib/builder/types/common.js +0 -7
  75. package/lib/builder/util/common.d.ts +0 -36
  76. package/lib/builder/util/common.d.ts.map +0 -1
  77. package/lib/builder/util/common.js +0 -257
  78. package/lib/builder/util/console.d.ts +0 -2
  79. package/lib/builder/util/console.d.ts.map +0 -1
  80. package/lib/builder/util/console.js +0 -13
  81. package/lib/builder/util/generateFiles.d.ts +0 -6
  82. package/lib/builder/util/generateFiles.d.ts.map +0 -1
  83. package/lib/builder/util/generateFiles.js +0 -94
  84. package/lib/builder/util/index.d.ts +0 -2
  85. package/lib/builder/util/index.d.ts.map +0 -1
  86. package/lib/builder/util/index.js +0 -13
  87. package/lib/builder/util/junk.d.ts +0 -3
  88. package/lib/builder/util/junk.d.ts.map +0 -1
  89. package/lib/builder/util/junk.js +0 -25
  90. package/lib/builder/util/mp.d.ts +0 -5
  91. package/lib/builder/util/mp.d.ts.map +0 -1
  92. package/lib/builder/util/mp.js +0 -99
  93. package/lib/builder/util/name-mangler.d.ts +0 -3
  94. package/lib/builder/util/name-mangler.d.ts.map +0 -1
  95. package/lib/builder/util/name-mangler.js +0 -7
  96. package/lib/builder/util/net.d.ts +0 -3
  97. package/lib/builder/util/net.d.ts.map +0 -1
  98. package/lib/builder/util/net.js +0 -54
  99. package/lib/builder/util/process.d.ts +0 -9
  100. package/lib/builder/util/process.d.ts.map +0 -1
  101. package/lib/builder/util/process.js +0 -28
  102. package/lib/builder/util/style.d.ts +0 -2
  103. package/lib/builder/util/style.d.ts.map +0 -1
  104. package/lib/builder/util/style.js +0 -13
  105. package/lib/builder/util/weapp.d.ts +0 -2
  106. package/lib/builder/util/weapp.d.ts.map +0 -1
  107. package/lib/builder/util/weapp.js +0 -13
  108. package/lib/generator/config/common.d.ts +0 -6
  109. package/lib/generator/config/common.d.ts.map +0 -1
  110. package/lib/generator/config/common.js +0 -25
  111. package/lib/generator/config/index.d.ts +0 -18
  112. package/lib/generator/config/index.d.ts.map +0 -1
  113. package/lib/generator/config/index.js +0 -43
  114. package/lib/generator/config/mp.d.ts +0 -56
  115. package/lib/generator/config/mp.d.ts.map +0 -1
  116. package/lib/generator/config/mp.js +0 -104
  117. package/lib/generator/core/generate.d.ts +0 -59
  118. package/lib/generator/core/generate.d.ts.map +0 -1
  119. package/lib/generator/core/generate.js +0 -669
  120. package/lib/generator/core/index.d.ts +0 -25
  121. package/lib/generator/core/index.d.ts.map +0 -1
  122. package/lib/generator/core/index.js +0 -102
  123. package/lib/generator/core/material.d.ts +0 -14
  124. package/lib/generator/core/material.d.ts.map +0 -1
  125. package/lib/generator/core/material.js +0 -230
  126. package/lib/generator/template.d.ts +0 -3
  127. package/lib/generator/template.d.ts.map +0 -1
  128. package/lib/generator/template.js +0 -3
  129. package/lib/generator/types/common.d.ts +0 -69
  130. package/lib/generator/types/common.d.ts.map +0 -1
  131. package/lib/generator/types/common.js +0 -21
  132. package/lib/generator/util/common.d.ts +0 -36
  133. package/lib/generator/util/common.d.ts.map +0 -1
  134. package/lib/generator/util/common.js +0 -238
  135. package/lib/generator/util/console.d.ts +0 -3
  136. package/lib/generator/util/console.d.ts.map +0 -1
  137. package/lib/generator/util/console.js +0 -17
  138. package/lib/generator/util/index.d.ts +0 -2
  139. package/lib/generator/util/index.d.ts.map +0 -1
  140. package/lib/generator/util/index.js +0 -13
  141. package/lib/generator/util/name-mangler.d.ts +0 -17
  142. package/lib/generator/util/name-mangler.d.ts.map +0 -1
  143. package/lib/generator/util/name-mangler.js +0 -63
  144. package/lib/generator/util/postcss-rpx.d.ts +0 -11
  145. package/lib/generator/util/postcss-rpx.d.ts.map +0 -1
  146. package/lib/generator/util/postcss-rpx.js +0 -16
  147. package/lib/generator/util/style.d.ts +0 -6
  148. package/lib/generator/util/style.d.ts.map +0 -1
  149. package/lib/generator/util/style.js +0 -92
  150. package/lib/generator/util/weapp.d.ts +0 -5
  151. package/lib/generator/util/weapp.d.ts.map +0 -1
  152. package/lib/generator/util/weapp.js +0 -17
  153. package/lib/types.d.ts +0 -14
  154. package/lib/types.d.ts.map +0 -1
  155. package/lib/types.js +0 -19
  156. package/lib/weapps-core/config/index.d.ts +0 -2
  157. package/lib/weapps-core/config/index.d.ts.map +0 -1
  158. package/lib/weapps-core/config/index.js +0 -13
  159. package/lib/weapps-core/config/style.d.ts +0 -7
  160. package/lib/weapps-core/config/style.d.ts.map +0 -1
  161. package/lib/weapps-core/config/style.js +0 -70
  162. package/lib/weapps-core/index.d.ts +0 -6
  163. package/lib/weapps-core/index.d.ts.map +0 -1
  164. package/lib/weapps-core/index.js +0 -31
  165. package/lib/weapps-core/types/action.d.ts +0 -25
  166. package/lib/weapps-core/types/action.d.ts.map +0 -1
  167. package/lib/weapps-core/types/action.js +0 -28
  168. package/lib/weapps-core/types/app.d.ts +0 -141
  169. package/lib/weapps-core/types/app.d.ts.map +0 -1
  170. package/lib/weapps-core/types/app.js +0 -21
  171. package/lib/weapps-core/types/appbuild.d.ts +0 -63
  172. package/lib/weapps-core/types/appbuild.d.ts.map +0 -1
  173. package/lib/weapps-core/types/appbuild.js +0 -78
  174. package/lib/weapps-core/types/code_types.d.ts +0 -26
  175. package/lib/weapps-core/types/code_types.d.ts.map +0 -1
  176. package/lib/weapps-core/types/code_types.js +0 -2
  177. package/lib/weapps-core/types/git.d.ts +0 -7
  178. package/lib/weapps-core/types/git.d.ts.map +0 -1
  179. package/lib/weapps-core/types/git.js +0 -2
  180. package/lib/weapps-core/types/index.d.ts +0 -11
  181. package/lib/weapps-core/types/index.d.ts.map +0 -1
  182. package/lib/weapps-core/types/index.js +0 -22
  183. package/lib/weapps-core/types/lowcode.d.ts +0 -26
  184. package/lib/weapps-core/types/lowcode.d.ts.map +0 -1
  185. package/lib/weapps-core/types/lowcode.js +0 -25
  186. package/lib/weapps-core/types/material.d.ts +0 -90
  187. package/lib/weapps-core/types/material.d.ts.map +0 -1
  188. package/lib/weapps-core/types/material.js +0 -9
  189. package/lib/weapps-core/types/plugins.d.ts +0 -17
  190. package/lib/weapps-core/types/plugins.d.ts.map +0 -1
  191. package/lib/weapps-core/types/plugins.js +0 -2
  192. package/lib/weapps-core/types/style.d.ts +0 -93
  193. package/lib/weapps-core/types/style.d.ts.map +0 -1
  194. package/lib/weapps-core/types/style.js +0 -2
  195. package/lib/weapps-core/types/web.d.ts +0 -120
  196. package/lib/weapps-core/types/web.d.ts.map +0 -1
  197. package/lib/weapps-core/types/web.js +0 -2
  198. package/lib/weapps-core/utils/appbuild.d.ts +0 -6
  199. package/lib/weapps-core/utils/appbuild.d.ts.map +0 -1
  200. package/lib/weapps-core/utils/appbuild.js +0 -40
  201. package/lib/weapps-core/utils/common.d.ts +0 -16
  202. package/lib/weapps-core/utils/common.d.ts.map +0 -1
  203. package/lib/weapps-core/utils/common.js +0 -90
  204. package/lib/weapps-core/utils/file.d.ts +0 -12
  205. package/lib/weapps-core/utils/file.d.ts.map +0 -1
  206. package/lib/weapps-core/utils/file.js +0 -142
  207. package/lib/weapps-core/utils/formily.d.ts +0 -5
  208. package/lib/weapps-core/utils/formily.d.ts.map +0 -1
  209. package/lib/weapps-core/utils/formily.js +0 -407
  210. package/lib/weapps-core/utils/index.d.ts +0 -7
  211. package/lib/weapps-core/utils/index.d.ts.map +0 -1
  212. package/lib/weapps-core/utils/index.js +0 -18
  213. package/lib/weapps-core/utils/lowcdoe.d.ts +0 -4
  214. package/lib/weapps-core/utils/lowcdoe.d.ts.map +0 -1
  215. package/lib/weapps-core/utils/lowcdoe.js +0 -69
  216. package/lib/weapps-core/utils/style.d.ts +0 -17
  217. package/lib/weapps-core/utils/style.d.ts.map +0 -1
  218. package/lib/weapps-core/utils/style.js +0 -321
@@ -1,206 +0,0 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __rest = (this && this.__rest) || function (s, e) {
22
- var t = {};
23
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
24
- t[p] = s[p];
25
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
26
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
27
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
28
- t[p[i]] = s[p[i]];
29
- }
30
- return t;
31
- };
32
- var __importDefault = (this && this.__importDefault) || function (mod) {
33
- return (mod && mod.__esModule) ? mod : { "default": mod };
34
- };
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.mergeSubPackages = exports.generateMpConfig = void 0;
37
- const path = __importStar(require("path"));
38
- const lodash_1 = require("lodash");
39
- const mp_1 = require("../config/mp");
40
- const weapps_core_1 = require("../../weapps-core");
41
- const config_1 = require("../config");
42
- const net_1 = require("../util/net");
43
- const chalk_1 = __importDefault(require("chalk"));
44
- function generateMpConfig(weapps, ctx) {
45
- var _a;
46
- const appConfig = {
47
- useExtendedLib: { weui: true },
48
- };
49
- const { miniprogramPlugins = [] } = ctx;
50
- const projConfig = (0, lodash_1.merge)({}, mp_1.defaultProjConfig, {
51
- projectname: `WeDa-${ctx.appId}`,
52
- });
53
- const pageConfigs = weapps.map((app) => {
54
- var _a;
55
- const pageConfig = {};
56
- const kbConfig = (_a = app.lowCodes) === null || _a === void 0 ? void 0 : _a.find((m) => m.name === config_1.MP_CONFIG_MODULE_NAME);
57
- if (kbConfig) {
58
- const { pagesConfigJson = {} } = eval(`(${kbConfig.code.replace(/export\s+default/, '')})`);
59
- (0, lodash_1.merge)(pageConfig, pagesConfigJson);
60
- }
61
- (0, lodash_1.merge)(pageConfig, getAppPagesConfig((app === null || app === void 0 ? void 0 : app.pageInstanceList) || []));
62
- return pageConfig;
63
- });
64
- const kbConfig = (_a = weapps[0].lowCodes) === null || _a === void 0 ? void 0 : _a.find((m) => m.name === config_1.MP_CONFIG_MODULE_NAME);
65
- if (kbConfig) {
66
- const { projectConfigJson = {}, appJson = {} } = eval(`(${kbConfig.code.replace(/export\s+default/, '')})`);
67
- (0, lodash_1.merge)(projConfig, projectConfigJson);
68
- const matertialMetaIgnores = ctx.materialLibs
69
- .filter((lib) => !lib.isComposite)
70
- .reduce((arr, lib) => {
71
- arr.push({ type: 'file', value: `materials/${lib.name}/meta.json` });
72
- return arr;
73
- }, []);
74
- projConfig.packOptions.ignore.push(...matertialMetaIgnores);
75
- if (appJson.tabBar) {
76
- parseTabConfig(appJson.tabBar, ctx.projDir);
77
- }
78
- (0, lodash_1.merge)(appConfig, appJson);
79
- }
80
- const _b = weapps[0].appConfig || {}, { tradingCapability } = _b, mainAppConfig = __rest(_b, ["tradingCapability"]);
81
- const _c = extractPages(weapps, pageConfigs), { subpackages } = _c, extra = __rest(_c, ["subpackages"]);
82
- (0, lodash_1.merge)(appConfig, mainAppConfig, extra);
83
- appConfig.subpackages = mergeSubPackages(appConfig.subpackages, subpackages);
84
- if (tradingCapability) {
85
- const tradePluginKey = `weda-mini-shop-plugin`;
86
- const pluginMeta = {
87
- version: 'latest',
88
- provider: 'wx34345ae5855f892d',
89
- };
90
- let { plugins = {} } = appConfig;
91
- let find = false;
92
- for (let key in plugins) {
93
- let value = plugins[key];
94
- if (key === tradePluginKey || value.provider === pluginMeta.provider) {
95
- find = true;
96
- break;
97
- }
98
- }
99
- if (!find) {
100
- plugins[tradePluginKey] = pluginMeta;
101
- }
102
- appConfig.plugins = plugins;
103
- }
104
- miniprogramPlugins.forEach((plugin) => {
105
- var _a, _b;
106
- if (!((_b = (_a = appConfig) === null || _a === void 0 ? void 0 : _a.plugins) === null || _b === void 0 ? void 0 : _b[plugin.name])) {
107
- (0, lodash_1.set)(appConfig, `plugins.${plugin.name}`, {
108
- version: plugin.version,
109
- provider: plugin.pluginAppId,
110
- });
111
- }
112
- });
113
- return { appConfig, projConfig, pageConfigs };
114
- }
115
- exports.generateMpConfig = generateMpConfig;
116
- function extractPages(weapps, pageConfigs) {
117
- const pages = [];
118
- const subpackages = [];
119
- let homePage = '';
120
- let homePageId = '';
121
- weapps.forEach((weapp, index) => {
122
- const { rootPath } = weapp;
123
- const subPackage = { root: rootPath, pages: [] };
124
- if (rootPath) {
125
- subpackages.push(subPackage);
126
- }
127
- (0, weapps_core_1.loopDealWithFn)(weapp.pageInstanceList || [], (page) => {
128
- const pageConfig = pageConfigs[index];
129
- const pageFileName = (0, lodash_1.get)(pageConfig, `${page.id}.pageFileName`, 'index');
130
- if (rootPath) {
131
- subPackage.pages.push(`pages/${page.id}/${pageFileName}`);
132
- }
133
- else if (!page.isHome) {
134
- pages.push(`pages/${page.id}/${pageFileName}`);
135
- }
136
- else {
137
- homePage = `pages/${page.id}/${pageFileName}`;
138
- homePageId = page.id;
139
- }
140
- });
141
- });
142
- if (homePage) {
143
- pages.unshift(homePage);
144
- }
145
- return { pages, subpackages, homePageId };
146
- }
147
- function getAppPagesConfig(pages) {
148
- const pagesConfig = {};
149
- pages.map((page) => {
150
- const pageConfig = transformDynamicData(page.data);
151
- delete pageConfig['title'];
152
- pagesConfig[page.id] = pageConfig;
153
- });
154
- return pagesConfig;
155
- }
156
- function transformDynamicData(originData) {
157
- const temp = {};
158
- for (const key in originData) {
159
- const target = originData[key];
160
- if (target === null || target === void 0 ? void 0 : target.value) {
161
- temp[key] = target.value;
162
- }
163
- }
164
- return temp;
165
- }
166
- function parseTabConfig(tabBar, projDir) {
167
- tabBar.list.map((tab, index) => {
168
- const { iconPath, selectedIconPath } = tab;
169
- if (iconPath) {
170
- tab.iconPath = parseTabIcon(iconPath, index, 'icon');
171
- }
172
- if (selectedIconPath) {
173
- tab.selectedIconPath = parseTabIcon(selectedIconPath, index, 'selectedIcon');
174
- }
175
- });
176
- function parseTabIcon(iconUrl, index, filename) {
177
- if (typeof iconUrl !== 'string') {
178
- console.error(chalk_1.default.red('App.json invalid tabbar icon path'), iconUrl);
179
- return;
180
- }
181
- const iconPath = 'assets/tab' + index + '/' + filename + path.extname(iconUrl);
182
- (0, net_1.downloadFile)(iconUrl, projDir + '/' + iconPath).catch((e) => {
183
- console.error(chalk_1.default.red(`Fail to download tabBar icon from ${iconUrl}`), e);
184
- });
185
- return iconPath;
186
- }
187
- }
188
- function mergeSubPackages(base = [], extra = []) {
189
- const baseMap = base.reduce((map, item) => {
190
- map[item.root] = item;
191
- return map;
192
- }, {});
193
- for (const subpackage of extra) {
194
- if (!baseMap[subpackage.root]) {
195
- base.push(subpackage);
196
- continue;
197
- }
198
- const current = baseMap[subpackage.root];
199
- current.pages = Array.from(new Set([...(current.pages || []), ...(subpackage.pages || [])]));
200
- if (current.plugins || subpackage.plugins) {
201
- current.plugins = (0, lodash_1.merge)(current.pplugins, subpackage.plugins);
202
- }
203
- }
204
- return base;
205
- }
206
- exports.mergeSubPackages = mergeSubPackages;
@@ -1,20 +0,0 @@
1
- import { IDynamicValue, IWeAppComponentInstance } from '../../weapps-core';
2
- import { IBuildContext } from './BuildContext';
3
- export declare function extractWidgetProps(props: Required<IWeAppComponentInstance>['xProps']): any;
4
- export declare function generatedDynamicData(data: {
5
- [key: string]: IDynamicValue;
6
- }): {
7
- staticProps: {};
8
- boundProps: {};
9
- };
10
- export declare function generateDataBind(bind: IDynamicValue): string;
11
- export declare function createWidgetProps(widgets: {
12
- [key: string]: IWeAppComponentInstance;
13
- }, ctx: IBuildContext): {};
14
- export declare function createEventHanlders(widgets: {
15
- [key: string]: IWeAppComponentInstance;
16
- }, componentApi: string, ctx: IBuildContext): {};
17
- export declare function createDataBinds(widgets: {
18
- [key: string]: IWeAppComponentInstance;
19
- }, ctx: IBuildContext): {};
20
- //# sourceMappingURL=util.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/builder/mp/util.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,uBAAuB,EAKxB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAI/C,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,QAAQ,CAAC,uBAAuB,CAAC,CAAC,QAAQ,CAAC,OAanD;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAA;CAAE;;;EAa1E;AAGD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,aAAa,UAsDnD;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,uBAAuB,CAAA;CAAE,EACnD,GAAG,EAAE,aAAa,MA4BnB;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,uBAAuB,CAAA;CAAE,EACnD,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,aAAa,MAsGnB;AAED,wBAAgB,eAAe,CAC7B,OAAO,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,uBAAuB,CAAA;CAAE,EACnD,GAAG,EAAE,aAAa,MAuDnB"}
@@ -1,239 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createDataBinds = exports.createEventHanlders = exports.createWidgetProps = exports.generateDataBind = exports.generatedDynamicData = exports.extractWidgetProps = void 0;
4
- const weapps_core_1 = require("../../weapps-core");
5
- const weapp_1 = require("../util/weapp");
6
- const wxml_1 = require("./wxml");
7
- const mp_1 = require("../config/mp");
8
- function extractWidgetProps(props) {
9
- const { classList } = props;
10
- const staticProps = {
11
- style: (0, weapps_core_1.toCssStyle)(props.commonStyle, {
12
- toRpx: true,
13
- toRem: false,
14
- }),
15
- classList: classList || [],
16
- };
17
- const { data = {} } = props;
18
- Object.assign(staticProps, generatedDynamicData(data).staticProps);
19
- return staticProps;
20
- }
21
- exports.extractWidgetProps = extractWidgetProps;
22
- function generatedDynamicData(data) {
23
- const staticProps = {};
24
- const boundProps = {};
25
- for (const key in data) {
26
- if (mp_1.builtinWigetProps.indexOf(key) > -1)
27
- continue;
28
- const { type, value } = data[key];
29
- if (!type || type === 'static') {
30
- staticProps[key] = value;
31
- }
32
- else {
33
- boundProps[key] = generateDataBind(data[key]);
34
- }
35
- }
36
- return { staticProps, boundProps };
37
- }
38
- exports.generatedDynamicData = generatedDynamicData;
39
- function generateDataBind(bind) {
40
- let expr = '';
41
- const { type, value } = bind;
42
- if (type === weapps_core_1.PropBindType.forItem) {
43
- expr = `forItems.${value}`;
44
- }
45
- else if (type === weapps_core_1.PropBindType.expression) {
46
- expr = `${value.replace(/\$comp./g, `${weapps_core_1.COMPONENT_API_PREFIX}.`)}`;
47
- }
48
- else if (type === weapps_core_1.PropBindType.prop) {
49
- const isNegated = value.startsWith('!');
50
- const originValue = value.replace(/^!/, '');
51
- expr = `${isNegated ? '!' : ''}${weapps_core_1.COMPONENT_API_PREFIX}.props.data.${originValue}`;
52
- }
53
- else {
54
- const isGlobal = value.startsWith('global.');
55
- const isCopositive = value.startsWith('comp-') || value.startsWith('$comp_');
56
- const PREFIX_MAP = {
57
- [weapps_core_1.PropBindType.state]: 'state',
58
- [weapps_core_1.PropBindType.computed]: 'computed',
59
- [weapps_core_1.PropBindType.dataVar]: 'dataVar',
60
- [weapps_core_1.PropBindType.stateData]: 'dataset.state',
61
- [weapps_core_1.PropBindType.paramData]: 'dataset.params',
62
- };
63
- switch (type) {
64
- case weapps_core_1.PropBindType.state:
65
- case weapps_core_1.PropBindType.computed:
66
- case weapps_core_1.PropBindType.dataVar:
67
- case weapps_core_1.PropBindType.stateData:
68
- case weapps_core_1.PropBindType.paramData: {
69
- if (isCopositive) {
70
- expr = value
71
- .replace(/^comp-\w+/, `${weapps_core_1.COMPONENT_API_PREFIX}.${PREFIX_MAP[type]}`)
72
- .replace(/^\$comp_\w+/, `${weapps_core_1.COMPONENT_API_PREFIX}.${PREFIX_MAP[type]}`);
73
- }
74
- else {
75
- expr = value
76
- .replace(/^\w+./, `${isGlobal ? 'app' : '$page'}.${PREFIX_MAP[type]}.`)
77
- .replace(/^comp-\w+/, `${weapps_core_1.COMPONENT_API_PREFIX}.${PREFIX_MAP[type]}`)
78
- .replace(/^\$comp_\w+/, `${weapps_core_1.COMPONENT_API_PREFIX}.${PREFIX_MAP[type]}`);
79
- }
80
- }
81
- }
82
- }
83
- return expr;
84
- }
85
- exports.generateDataBind = generateDataBind;
86
- function createWidgetProps(widgets, ctx) {
87
- const widgetProps = {};
88
- (0, weapp_1.walkThroughWidgets)(widgets, (id, widget, parentId) => {
89
- var _a;
90
- const { xComponent } = widget;
91
- const xProps = widget.xProps || {};
92
- if (!xComponent) {
93
- return;
94
- }
95
- const materialLib = ctx.materialLibs.find((lib) => lib.name === xComponent.moduleName);
96
- const miniprogramPlugin = (_a = ctx.miniprogramPlugins) === null || _a === void 0 ? void 0 : _a.find((plugin) => plugin.name === xComponent.moduleName);
97
- if (!materialLib && !miniprogramPlugin) {
98
- console.error('Component lib not found', xComponent);
99
- return;
100
- }
101
- widgetProps[id] = extractWidgetProps(xProps);
102
- widgetProps[id]._parentId = parentId;
103
- widgetProps[id]._order = widget.xIndex;
104
- widgetProps[id].widgetType = xComponent.moduleName + ':' + xComponent.name;
105
- });
106
- return widgetProps;
107
- }
108
- exports.createWidgetProps = createWidgetProps;
109
- function createEventHanlders(widgets, componentApi, ctx) {
110
- const eventHanlders = {};
111
- (0, weapp_1.walkThroughWidgets)(widgets, (id, widget, parentId) => {
112
- var _a, _b, _c;
113
- const { xComponent } = widget;
114
- const xProps = widget.xProps || {};
115
- if (!xComponent) {
116
- return;
117
- }
118
- const materialLib = ctx.materialLibs.find((lib) => lib.name === xComponent.moduleName);
119
- const miniprogramPlugin = (_a = ctx.miniprogramPlugins) === null || _a === void 0 ? void 0 : _a.find((plugin) => plugin.name === xComponent.moduleName);
120
- if (!materialLib && !miniprogramPlugin) {
121
- console.error('Component lib not found', xComponent);
122
- return;
123
- }
124
- const compProto = materialLib
125
- ? materialLib.components.find((comp) => comp.name === xComponent.name)
126
- : (_b = miniprogramPlugin === null || miniprogramPlugin === void 0 ? void 0 : miniprogramPlugin.componentConfigs) === null || _b === void 0 ? void 0 : _b.find((comp) => comp.name === xComponent.name);
127
- if (!compProto) {
128
- return;
129
- }
130
- const listeners = (xProps.listeners || []).slice();
131
- const { inputProps, syncProps } = compProto.meta || {};
132
- const syncConfigs = syncProps || inputProps || {};
133
- for (const valuProp in syncConfigs) {
134
- const config = syncConfigs[valuProp];
135
- const configs = Array.isArray(config) ? config : [config];
136
- configs.forEach(({ changeEvent, valueFromEvent = 'event.detail.value' }) => {
137
- listeners.unshift({
138
- trigger: changeEvent,
139
- handler: {
140
- moduleName: '',
141
- name: `function({ event }) { mpCompToWidget(this, event.currentTarget).${valuProp} = ${valueFromEvent} }`,
142
- },
143
- type: weapps_core_1.ActionType.Inline,
144
- data: {},
145
- });
146
- });
147
- }
148
- listeners.forEach((l) => {
149
- var _a, _b, _c, _d;
150
- const handlerName = (0, wxml_1.getMpEventHanlderName)(id, l.trigger, l);
151
- eventHanlders[handlerName] = eventHanlders[handlerName] || [];
152
- const params = generatedDynamicData(l.data);
153
- let handler = (_a = l.handler) === null || _a === void 0 ? void 0 : _a.name;
154
- switch (l.type) {
155
- case weapps_core_1.ActionType.Platform: {
156
- let method = (_b = l.handler) === null || _b === void 0 ? void 0 : _b.name;
157
- handler = `function({data}){ return app.${method}(data)}`;
158
- break;
159
- }
160
- case weapps_core_1.ActionType.DataSource: {
161
- handler = `function({data}){ return app.cloud.callDataSource(data)}`;
162
- break;
163
- }
164
- case weapps_core_1.ActionType.PropEvent: {
165
- handler = `function({event, data = {}}){ return ${componentApi}.props.events.${(_c = l.handler) === null || _c === void 0 ? void 0 : _c.name}({...event.detail, ...data}) }`;
166
- break;
167
- }
168
- }
169
- eventHanlders[handlerName].push({
170
- key: l.key || '',
171
- handler: handler,
172
- handlerModule: (_d = l.handler) === null || _d === void 0 ? void 0 : _d.moduleName,
173
- data: params.staticProps,
174
- boundData: params.boundProps,
175
- type: l.type,
176
- });
177
- });
178
- if ((_c = compProto === null || compProto === void 0 ? void 0 : compProto.compConfig) === null || _c === void 0 ? void 0 : _c.isDataContainer) {
179
- const customName = (0, wxml_1.getMpEventHanlderName)(id, 'onDataChange', {});
180
- eventHanlders[customName] = [
181
- {
182
- key: `wa${Date.now().toString().slice(-8)}`,
183
- handler: `({event}) => {
184
- app.utils.set(context, '${id}.data', event?.detail?.data);
185
- }`,
186
- handlerModule: weapps_core_1.ActionType.Platform,
187
- data: {},
188
- boundData: {},
189
- },
190
- ];
191
- }
192
- });
193
- return eventHanlders;
194
- }
195
- exports.createEventHanlders = createEventHanlders;
196
- function createDataBinds(widgets, ctx) {
197
- const dataBinds = {};
198
- (0, weapp_1.walkThroughWidgets)(widgets, (id, widget, parentId) => {
199
- var _a;
200
- const { xComponent } = widget;
201
- const xProps = widget.xProps || {};
202
- if (!xComponent) {
203
- return;
204
- }
205
- const materialLib = ctx.materialLibs.find((lib) => lib.name === xComponent.moduleName);
206
- const miniprogramPlugin = (_a = ctx.miniprogramPlugins) === null || _a === void 0 ? void 0 : _a.find((plugin) => plugin.name === xComponent.moduleName);
207
- if (!materialLib && !miniprogramPlugin) {
208
- console.error('Component lib not found', xComponent);
209
- return;
210
- }
211
- dataBinds[id] = {};
212
- Object.entries(xProps.data || {}).map(([prop, val]) => setDataBind(dataBinds[id], prop, val));
213
- const { directives = {} } = xProps;
214
- setDataBind(dataBinds[id], '_waFor', directives.waFor);
215
- setDataBind(dataBinds[id], '_waIf', directives.waIf);
216
- setDataBind(dataBinds[id], 'classList', xProps.classListBind);
217
- setDataBind(dataBinds[id], 'style', xProps.styleBind);
218
- const { classList, style } = dataBinds[id];
219
- if (classList) {
220
- dataBinds[id].classList = `concatClassList(${classList}, widgetProps.${id}.classList)`;
221
- }
222
- if (style) {
223
- dataBinds[id].style = `px2rpx({...widgetProps.${id}.style, ...(${style})})`;
224
- }
225
- if (Object.keys(dataBinds[id]).length === 0) {
226
- delete dataBinds[id];
227
- }
228
- });
229
- return dataBinds;
230
- }
231
- exports.createDataBinds = createDataBinds;
232
- function setDataBind(target, prop, val) {
233
- if (val && val.type && val.type !== 'static') {
234
- const jsExpr = generateDataBind(val);
235
- if (jsExpr) {
236
- target[prop] = jsExpr;
237
- }
238
- }
239
- }
@@ -1,16 +0,0 @@
1
- import { IWeAppComponentInstance, IEventModifiers } from '../../weapps-core';
2
- import { IBuildContext } from './BuildContext';
3
- export declare function generateWxml(widgets: {
4
- [key: string]: IWeAppComponentInstance;
5
- }, docTag: string, wxmlDataPrefix: any, ctx: IBuildContext & {
6
- isPage: boolean;
7
- }, usingComponents: any, nodeTransform?: (cmp: IWeAppComponentInstance, node: any) => void): string;
8
- export declare function getMpEventHanlderName(widgetId: string, evtName: string, modifier?: IEventModifiers): string;
9
- export declare function getUsedComponents(widgets: {
10
- [key: string]: IWeAppComponentInstance;
11
- }, usedCmps?: {
12
- [libName: string]: Set<string>;
13
- }): {
14
- [libName: string]: Set<string>;
15
- };
16
- //# sourceMappingURL=wxml.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wxml.d.ts","sourceRoot":"","sources":["../../../src/builder/mp/wxml.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,uBAAuB,EAEvB,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAU3B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAkB/C,wBAAgB,YAAY,CAC1B,OAAO,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,uBAAuB,CAAA;CAAE,EACnD,MAAM,EAAE,MAAM,EACd,cAAc,KAAA,EACd,GAAG,EAAE,aAAa,GAAG;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,EACxC,eAAe,KAAA,EACf,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,uBAAuB,EAAE,IAAI,KAAA,KAAK,IAAI,UAiW7D;AA4BD,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,QAAQ,GAAE,eAAoB,UAS/B;AAuBD,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,uBAAuB,CAAA;CAAE,EACnD,QAAQ,GAAE;IAAE,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAAA;CAAO;;EAYlD"}