@cloudbase/framework-plugin-low-code 1.7.1 → 1.7.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.
- package/package.json +3 -3
- package/lib/builder/config/common.d.ts +0 -2
- package/lib/builder/config/common.d.ts.map +0 -1
- package/lib/builder/config/common.js +0 -13
- package/lib/builder/config/index.d.ts +0 -3
- package/lib/builder/config/index.d.ts.map +0 -1
- package/lib/builder/config/index.js +0 -29
- package/lib/builder/config/mp.d.ts +0 -2
- package/lib/builder/config/mp.d.ts.map +0 -1
- package/lib/builder/config/mp.js +0 -13
- package/lib/builder/core/copy.d.ts +0 -5
- package/lib/builder/core/copy.d.ts.map +0 -1
- package/lib/builder/core/copy.js +0 -62
- package/lib/builder/core/generate.d.ts +0 -9
- package/lib/builder/core/generate.d.ts.map +0 -1
- package/lib/builder/core/generate.js +0 -128
- package/lib/builder/core/index.d.ts +0 -32
- package/lib/builder/core/index.d.ts.map +0 -1
- package/lib/builder/core/index.js +0 -149
- package/lib/builder/core/material.d.ts +0 -4
- package/lib/builder/core/material.d.ts.map +0 -1
- package/lib/builder/core/material.js +0 -80
- package/lib/builder/core/plugin.d.ts +0 -4
- package/lib/builder/core/plugin.d.ts.map +0 -1
- package/lib/builder/core/plugin.js +0 -30
- package/lib/builder/core/prepare.d.ts +0 -8
- package/lib/builder/core/prepare.d.ts.map +0 -1
- package/lib/builder/core/prepare.js +0 -108
- package/lib/builder/core/webpack.d.ts +0 -15
- package/lib/builder/core/webpack.d.ts.map +0 -1
- package/lib/builder/core/webpack.js +0 -58
- package/lib/builder/mp/BuildContext.d.ts +0 -13
- package/lib/builder/mp/BuildContext.d.ts.map +0 -1
- package/lib/builder/mp/BuildContext.js +0 -2
- package/lib/builder/mp/index.d.ts +0 -33
- package/lib/builder/mp/index.d.ts.map +0 -1
- package/lib/builder/mp/index.js +0 -450
- package/lib/builder/mp/lowcode.d.ts +0 -8
- package/lib/builder/mp/lowcode.d.ts.map +0 -1
- package/lib/builder/mp/lowcode.js +0 -54
- package/lib/builder/mp/materials.d.ts +0 -15
- package/lib/builder/mp/materials.d.ts.map +0 -1
- package/lib/builder/mp/materials.js +0 -338
- package/lib/builder/mp/mixMode.d.ts +0 -10
- package/lib/builder/mp/mixMode.d.ts.map +0 -1
- package/lib/builder/mp/mixMode.js +0 -215
- package/lib/builder/mp/mp_config.d.ts +0 -18
- package/lib/builder/mp/mp_config.d.ts.map +0 -1
- package/lib/builder/mp/mp_config.js +0 -206
- package/lib/builder/mp/util.d.ts +0 -20
- package/lib/builder/mp/util.d.ts.map +0 -1
- package/lib/builder/mp/util.js +0 -243
- package/lib/builder/mp/wxml.d.ts +0 -16
- package/lib/builder/mp/wxml.d.ts.map +0 -1
- package/lib/builder/mp/wxml.js +0 -300
- package/lib/builder/service/builder/copy.d.ts +0 -14
- package/lib/builder/service/builder/copy.d.ts.map +0 -1
- package/lib/builder/service/builder/copy.js +0 -189
- package/lib/builder/service/builder/generate.d.ts +0 -52
- package/lib/builder/service/builder/generate.d.ts.map +0 -1
- package/lib/builder/service/builder/generate.js +0 -792
- package/lib/builder/service/builder/index.d.ts +0 -16
- package/lib/builder/service/builder/index.d.ts.map +0 -1
- package/lib/builder/service/builder/index.js +0 -69
- package/lib/builder/service/builder/plugin.d.ts +0 -8
- package/lib/builder/service/builder/plugin.d.ts.map +0 -1
- package/lib/builder/service/builder/plugin.js +0 -149
- package/lib/builder/service/builder/webpack.d.ts +0 -91
- package/lib/builder/service/builder/webpack.d.ts.map +0 -1
- package/lib/builder/service/builder/webpack.js +0 -589
- package/lib/builder/types/common.d.ts +0 -12
- package/lib/builder/types/common.d.ts.map +0 -1
- package/lib/builder/types/common.js +0 -7
- package/lib/builder/util/common.d.ts +0 -36
- package/lib/builder/util/common.d.ts.map +0 -1
- package/lib/builder/util/common.js +0 -257
- package/lib/builder/util/console.d.ts +0 -2
- package/lib/builder/util/console.d.ts.map +0 -1
- package/lib/builder/util/console.js +0 -13
- package/lib/builder/util/generateFiles.d.ts +0 -6
- package/lib/builder/util/generateFiles.d.ts.map +0 -1
- package/lib/builder/util/generateFiles.js +0 -94
- package/lib/builder/util/index.d.ts +0 -2
- package/lib/builder/util/index.d.ts.map +0 -1
- package/lib/builder/util/index.js +0 -13
- package/lib/builder/util/junk.d.ts +0 -3
- package/lib/builder/util/junk.d.ts.map +0 -1
- package/lib/builder/util/junk.js +0 -25
- package/lib/builder/util/mp.d.ts +0 -5
- package/lib/builder/util/mp.d.ts.map +0 -1
- package/lib/builder/util/mp.js +0 -99
- package/lib/builder/util/name-mangler.d.ts +0 -3
- package/lib/builder/util/name-mangler.d.ts.map +0 -1
- package/lib/builder/util/name-mangler.js +0 -7
- package/lib/builder/util/net.d.ts +0 -3
- package/lib/builder/util/net.d.ts.map +0 -1
- package/lib/builder/util/net.js +0 -54
- package/lib/builder/util/process.d.ts +0 -9
- package/lib/builder/util/process.d.ts.map +0 -1
- package/lib/builder/util/process.js +0 -28
- package/lib/builder/util/style.d.ts +0 -2
- package/lib/builder/util/style.d.ts.map +0 -1
- package/lib/builder/util/style.js +0 -13
- package/lib/builder/util/weapp.d.ts +0 -2
- package/lib/builder/util/weapp.d.ts.map +0 -1
- package/lib/builder/util/weapp.js +0 -13
- package/lib/config/private.d.ts +0 -3
- package/lib/config/private.d.ts.map +0 -1
- package/lib/config/private.js +0 -14
- package/lib/generate.d.ts +0 -2
- package/lib/generate.d.ts.map +0 -1
- package/lib/generate.js +0 -49
- package/lib/generator/config/common.d.ts +0 -6
- package/lib/generator/config/common.d.ts.map +0 -1
- package/lib/generator/config/common.js +0 -25
- package/lib/generator/config/index.d.ts +0 -18
- package/lib/generator/config/index.d.ts.map +0 -1
- package/lib/generator/config/index.js +0 -43
- package/lib/generator/config/mp.d.ts +0 -56
- package/lib/generator/config/mp.d.ts.map +0 -1
- package/lib/generator/config/mp.js +0 -104
- package/lib/generator/core/generate.d.ts +0 -59
- package/lib/generator/core/generate.d.ts.map +0 -1
- package/lib/generator/core/generate.js +0 -663
- package/lib/generator/core/index.d.ts +0 -25
- package/lib/generator/core/index.d.ts.map +0 -1
- package/lib/generator/core/index.js +0 -102
- package/lib/generator/core/material.d.ts +0 -14
- package/lib/generator/core/material.d.ts.map +0 -1
- package/lib/generator/core/material.js +0 -230
- package/lib/generator/template.d.ts +0 -3
- package/lib/generator/template.d.ts.map +0 -1
- package/lib/generator/template.js +0 -3
- package/lib/generator/types/common.d.ts +0 -69
- package/lib/generator/types/common.d.ts.map +0 -1
- package/lib/generator/types/common.js +0 -21
- package/lib/generator/util/common.d.ts +0 -36
- package/lib/generator/util/common.d.ts.map +0 -1
- package/lib/generator/util/common.js +0 -238
- package/lib/generator/util/console.d.ts +0 -3
- package/lib/generator/util/console.d.ts.map +0 -1
- package/lib/generator/util/console.js +0 -17
- package/lib/generator/util/index.d.ts +0 -2
- package/lib/generator/util/index.d.ts.map +0 -1
- package/lib/generator/util/index.js +0 -13
- package/lib/generator/util/name-mangler.d.ts +0 -17
- package/lib/generator/util/name-mangler.d.ts.map +0 -1
- package/lib/generator/util/name-mangler.js +0 -63
- package/lib/generator/util/postcss-rpx.d.ts +0 -11
- package/lib/generator/util/postcss-rpx.d.ts.map +0 -1
- package/lib/generator/util/postcss-rpx.js +0 -16
- package/lib/generator/util/style.d.ts +0 -6
- package/lib/generator/util/style.d.ts.map +0 -1
- package/lib/generator/util/style.js +0 -92
- package/lib/generator/util/weapp.d.ts +0 -5
- package/lib/generator/util/weapp.d.ts.map +0 -1
- package/lib/generator/util/weapp.js +0 -17
- package/lib/types.d.ts +0 -14
- package/lib/types.d.ts.map +0 -1
- package/lib/types.js +0 -19
- package/lib/utils/dataSource.d.ts +0 -28
- package/lib/utils/dataSource.d.ts.map +0 -1
- package/lib/utils/dataSource.js +0 -171
- package/lib/utils/postProcess.d.ts +0 -3
- package/lib/utils/postProcess.d.ts.map +0 -1
- package/lib/utils/postProcess.js +0 -48
- package/lib/weapps-core/config/index.d.ts +0 -2
- package/lib/weapps-core/config/index.d.ts.map +0 -1
- package/lib/weapps-core/config/index.js +0 -13
- package/lib/weapps-core/config/style.d.ts +0 -7
- package/lib/weapps-core/config/style.d.ts.map +0 -1
- package/lib/weapps-core/config/style.js +0 -70
- package/lib/weapps-core/index.d.ts +0 -6
- package/lib/weapps-core/index.d.ts.map +0 -1
- package/lib/weapps-core/index.js +0 -31
- package/lib/weapps-core/types/action.d.ts +0 -25
- package/lib/weapps-core/types/action.d.ts.map +0 -1
- package/lib/weapps-core/types/action.js +0 -28
- package/lib/weapps-core/types/app.d.ts +0 -142
- package/lib/weapps-core/types/app.d.ts.map +0 -1
- package/lib/weapps-core/types/app.js +0 -21
- package/lib/weapps-core/types/appbuild.d.ts +0 -63
- package/lib/weapps-core/types/appbuild.d.ts.map +0 -1
- package/lib/weapps-core/types/appbuild.js +0 -78
- package/lib/weapps-core/types/code_types.d.ts +0 -26
- package/lib/weapps-core/types/code_types.d.ts.map +0 -1
- package/lib/weapps-core/types/code_types.js +0 -2
- package/lib/weapps-core/types/git.d.ts +0 -7
- package/lib/weapps-core/types/git.d.ts.map +0 -1
- package/lib/weapps-core/types/git.js +0 -2
- package/lib/weapps-core/types/index.d.ts +0 -11
- package/lib/weapps-core/types/index.d.ts.map +0 -1
- package/lib/weapps-core/types/index.js +0 -22
- package/lib/weapps-core/types/lowcode.d.ts +0 -26
- package/lib/weapps-core/types/lowcode.d.ts.map +0 -1
- package/lib/weapps-core/types/lowcode.js +0 -25
- package/lib/weapps-core/types/material.d.ts +0 -90
- package/lib/weapps-core/types/material.d.ts.map +0 -1
- package/lib/weapps-core/types/material.js +0 -9
- package/lib/weapps-core/types/plugins.d.ts +0 -17
- package/lib/weapps-core/types/plugins.d.ts.map +0 -1
- package/lib/weapps-core/types/plugins.js +0 -2
- package/lib/weapps-core/types/style.d.ts +0 -93
- package/lib/weapps-core/types/style.d.ts.map +0 -1
- package/lib/weapps-core/types/style.js +0 -2
- package/lib/weapps-core/types/web.d.ts +0 -120
- package/lib/weapps-core/types/web.d.ts.map +0 -1
- package/lib/weapps-core/types/web.js +0 -2
- package/lib/weapps-core/utils/appbuild.d.ts +0 -6
- package/lib/weapps-core/utils/appbuild.d.ts.map +0 -1
- package/lib/weapps-core/utils/appbuild.js +0 -40
- package/lib/weapps-core/utils/common.d.ts +0 -16
- package/lib/weapps-core/utils/common.d.ts.map +0 -1
- package/lib/weapps-core/utils/common.js +0 -90
- package/lib/weapps-core/utils/file.d.ts +0 -12
- package/lib/weapps-core/utils/file.d.ts.map +0 -1
- package/lib/weapps-core/utils/file.js +0 -142
- package/lib/weapps-core/utils/formily.d.ts +0 -5
- package/lib/weapps-core/utils/formily.d.ts.map +0 -1
- package/lib/weapps-core/utils/formily.js +0 -416
- package/lib/weapps-core/utils/index.d.ts +0 -7
- package/lib/weapps-core/utils/index.d.ts.map +0 -1
- package/lib/weapps-core/utils/index.js +0 -18
- package/lib/weapps-core/utils/lowcdoe.d.ts +0 -4
- package/lib/weapps-core/utils/lowcdoe.d.ts.map +0 -1
- package/lib/weapps-core/utils/lowcdoe.js +0 -69
- package/lib/weapps-core/utils/style.d.ts +0 -17
- package/lib/weapps-core/utils/style.d.ts.map +0 -1
- package/lib/weapps-core/utils/style.js +0 -330
|
@@ -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;
|
package/lib/builder/mp/util.d.ts
DELETED
|
@@ -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,CAAC,KAAK,EAAE,QAAQ,CAAC,uBAAuB,CAAC,CAAC,QAAQ,CAAC,OAepF;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAA;CAAE;;;EAa1E;AAGD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,aAAa,UA0CnD;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,uBAAuB,CAAA;CAAE,EAAE,GAAG,EAAE,aAAa,MAuBxG;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,uBAAuB,CAAA;CAAE,EACnD,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,aAAa,MA6FnB;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,uBAAuB,CAAA;CAAE,EAAE,GAAG,EAAE,aAAa,MA2CtG"}
|
package/lib/builder/mp/util.js
DELETED
|
@@ -1,243 +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
|
-
var _a, _b;
|
|
10
|
-
const { classList } = props;
|
|
11
|
-
const staticProps = {
|
|
12
|
-
style: (0, weapps_core_1.toCssStyle)(props.commonStyle, {
|
|
13
|
-
toRpx: true,
|
|
14
|
-
toRem: false,
|
|
15
|
-
}),
|
|
16
|
-
classList: classList || [],
|
|
17
|
-
};
|
|
18
|
-
const { data = {} } = props;
|
|
19
|
-
Object.assign(staticProps, generatedDynamicData(data).staticProps);
|
|
20
|
-
if ((_a = props.directives) === null || _a === void 0 ? void 0 : _a.waForKey) {
|
|
21
|
-
staticProps._waForKey = (_b = props.directives) === null || _b === void 0 ? void 0 : _b.waForKey.value;
|
|
22
|
-
}
|
|
23
|
-
return staticProps;
|
|
24
|
-
}
|
|
25
|
-
exports.extractWidgetProps = extractWidgetProps;
|
|
26
|
-
function generatedDynamicData(data) {
|
|
27
|
-
const staticProps = {};
|
|
28
|
-
const boundProps = {};
|
|
29
|
-
for (const key in data) {
|
|
30
|
-
if (mp_1.builtinWigetProps.indexOf(key) > -1)
|
|
31
|
-
continue;
|
|
32
|
-
const { type, value } = data[key];
|
|
33
|
-
if (!type || type === 'static') {
|
|
34
|
-
staticProps[key] = value;
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
boundProps[key] = generateDataBind(data[key]);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return { staticProps, boundProps };
|
|
41
|
-
}
|
|
42
|
-
exports.generatedDynamicData = generatedDynamicData;
|
|
43
|
-
function generateDataBind(bind) {
|
|
44
|
-
let expr = '';
|
|
45
|
-
const { type, value } = bind;
|
|
46
|
-
if (type === weapps_core_1.PropBindType.forItem) {
|
|
47
|
-
expr = `forItems.${value}`;
|
|
48
|
-
}
|
|
49
|
-
else if (type === weapps_core_1.PropBindType.expression) {
|
|
50
|
-
expr = `${value.replace(/\$comp./g, `${weapps_core_1.COMPONENT_API_PREFIX}.`)}`;
|
|
51
|
-
}
|
|
52
|
-
else if (type === weapps_core_1.PropBindType.prop) {
|
|
53
|
-
const isNegated = value.startsWith('!');
|
|
54
|
-
const originValue = value.replace(/^!/, '');
|
|
55
|
-
expr = `${isNegated ? '!' : ''}${weapps_core_1.COMPONENT_API_PREFIX}.props.data.${originValue}`;
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
const isGlobal = value.startsWith('global.');
|
|
59
|
-
const isCopositive = value.startsWith('comp-') || value.startsWith('$comp_');
|
|
60
|
-
const PREFIX_MAP = {
|
|
61
|
-
[weapps_core_1.PropBindType.state]: 'state',
|
|
62
|
-
[weapps_core_1.PropBindType.computed]: 'computed',
|
|
63
|
-
[weapps_core_1.PropBindType.dataVar]: 'dataVar',
|
|
64
|
-
[weapps_core_1.PropBindType.stateData]: 'dataset.state',
|
|
65
|
-
[weapps_core_1.PropBindType.paramData]: 'dataset.params',
|
|
66
|
-
};
|
|
67
|
-
switch (type) {
|
|
68
|
-
case weapps_core_1.PropBindType.state:
|
|
69
|
-
case weapps_core_1.PropBindType.computed:
|
|
70
|
-
case weapps_core_1.PropBindType.dataVar:
|
|
71
|
-
case weapps_core_1.PropBindType.stateData:
|
|
72
|
-
case weapps_core_1.PropBindType.paramData: {
|
|
73
|
-
if (isCopositive) {
|
|
74
|
-
expr = value
|
|
75
|
-
.replace(/^comp-\w+/, `${weapps_core_1.COMPONENT_API_PREFIX}.${PREFIX_MAP[type]}`)
|
|
76
|
-
.replace(/^\$comp_\w+/, `${weapps_core_1.COMPONENT_API_PREFIX}.${PREFIX_MAP[type]}`);
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
expr = value
|
|
80
|
-
.replace(/^\w+./, `${isGlobal ? 'app' : '$page'}.${PREFIX_MAP[type]}.`)
|
|
81
|
-
.replace(/^comp-\w+/, `${weapps_core_1.COMPONENT_API_PREFIX}.${PREFIX_MAP[type]}`)
|
|
82
|
-
.replace(/^\$comp_\w+/, `${weapps_core_1.COMPONENT_API_PREFIX}.${PREFIX_MAP[type]}`);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return expr;
|
|
88
|
-
}
|
|
89
|
-
exports.generateDataBind = generateDataBind;
|
|
90
|
-
function createWidgetProps(widgets, ctx) {
|
|
91
|
-
const widgetProps = {};
|
|
92
|
-
(0, weapp_1.walkThroughWidgets)(widgets, (id, widget, parentId) => {
|
|
93
|
-
var _a;
|
|
94
|
-
const { xComponent } = widget;
|
|
95
|
-
const xProps = widget.xProps || {};
|
|
96
|
-
if (!xComponent) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
const materialLib = ctx.materialLibs.find((lib) => lib.name === xComponent.moduleName);
|
|
100
|
-
const miniprogramPlugin = (_a = ctx.miniprogramPlugins) === null || _a === void 0 ? void 0 : _a.find((plugin) => plugin.name === xComponent.moduleName);
|
|
101
|
-
if (!materialLib && !miniprogramPlugin) {
|
|
102
|
-
console.error('Component lib not found', xComponent);
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
widgetProps[id] = extractWidgetProps(xProps);
|
|
106
|
-
widgetProps[id]._parentId = parentId;
|
|
107
|
-
widgetProps[id]._order = widget.xIndex;
|
|
108
|
-
widgetProps[id].widgetType = xComponent.moduleName + ':' + xComponent.name;
|
|
109
|
-
});
|
|
110
|
-
return widgetProps;
|
|
111
|
-
}
|
|
112
|
-
exports.createWidgetProps = createWidgetProps;
|
|
113
|
-
function createEventHanlders(widgets, componentApi, ctx) {
|
|
114
|
-
const eventHanlders = {};
|
|
115
|
-
(0, weapp_1.walkThroughWidgets)(widgets, (id, widget, parentId) => {
|
|
116
|
-
var _a, _b, _c;
|
|
117
|
-
const { xComponent } = widget;
|
|
118
|
-
const xProps = widget.xProps || {};
|
|
119
|
-
if (!xComponent) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
const materialLib = ctx.materialLibs.find((lib) => lib.name === xComponent.moduleName);
|
|
123
|
-
const miniprogramPlugin = (_a = ctx.miniprogramPlugins) === null || _a === void 0 ? void 0 : _a.find((plugin) => plugin.name === xComponent.moduleName);
|
|
124
|
-
if (!materialLib && !miniprogramPlugin) {
|
|
125
|
-
console.error('Component lib not found', xComponent);
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
const compProto = materialLib
|
|
129
|
-
? materialLib.components.find((comp) => comp.name === xComponent.name)
|
|
130
|
-
: (_b = miniprogramPlugin === null || miniprogramPlugin === void 0 ? void 0 : miniprogramPlugin.componentConfigs) === null || _b === void 0 ? void 0 : _b.find((comp) => comp.name === xComponent.name);
|
|
131
|
-
if (!compProto) {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
const listeners = (xProps.listeners || []).slice();
|
|
135
|
-
const { inputProps, syncProps } = compProto.meta || {};
|
|
136
|
-
const syncConfigs = syncProps || inputProps || {};
|
|
137
|
-
for (const valuProp in syncConfigs) {
|
|
138
|
-
const config = syncConfigs[valuProp];
|
|
139
|
-
const configs = Array.isArray(config) ? config : [config];
|
|
140
|
-
configs.forEach(({ changeEvent, valueFromEvent = 'event.detail.value' }) => {
|
|
141
|
-
listeners.unshift({
|
|
142
|
-
trigger: changeEvent,
|
|
143
|
-
handler: {
|
|
144
|
-
moduleName: '',
|
|
145
|
-
name: `function({ event }) { mpCompToWidget(this, event.currentTarget).${valuProp} = ${valueFromEvent} }`,
|
|
146
|
-
},
|
|
147
|
-
type: weapps_core_1.ActionType.Inline,
|
|
148
|
-
data: {},
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
listeners.forEach((l) => {
|
|
153
|
-
var _a, _b, _c, _d;
|
|
154
|
-
const handlerName = (0, wxml_1.getMpEventHanlderName)(id, l.trigger, l);
|
|
155
|
-
eventHanlders[handlerName] = eventHanlders[handlerName] || [];
|
|
156
|
-
const params = generatedDynamicData(l.data);
|
|
157
|
-
let handler = (_a = l.handler) === null || _a === void 0 ? void 0 : _a.name;
|
|
158
|
-
switch (l.type) {
|
|
159
|
-
case weapps_core_1.ActionType.Platform: {
|
|
160
|
-
let method = (_b = l.handler) === null || _b === void 0 ? void 0 : _b.name;
|
|
161
|
-
handler = `function({data}){ return app.${method}(data)}`;
|
|
162
|
-
break;
|
|
163
|
-
}
|
|
164
|
-
case weapps_core_1.ActionType.DataSource: {
|
|
165
|
-
handler = `function({data}){ return app.cloud.callDataSource(data)}`;
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
|
-
case weapps_core_1.ActionType.PropEvent: {
|
|
169
|
-
handler = `function({event, data = {}}){ return ${componentApi}.props.events.${(_c = l.handler) === null || _c === void 0 ? void 0 : _c.name}({...event.detail, ...data}) }`;
|
|
170
|
-
break;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
eventHanlders[handlerName].push({
|
|
174
|
-
key: l.key || '',
|
|
175
|
-
handler: handler,
|
|
176
|
-
handlerModule: (_d = l.handler) === null || _d === void 0 ? void 0 : _d.moduleName,
|
|
177
|
-
data: params.staticProps,
|
|
178
|
-
boundData: params.boundProps,
|
|
179
|
-
type: l.type,
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
if ((_c = compProto === null || compProto === void 0 ? void 0 : compProto.compConfig) === null || _c === void 0 ? void 0 : _c.isDataContainer) {
|
|
183
|
-
const customName = (0, wxml_1.getMpEventHanlderName)(id, 'onDataChange', {});
|
|
184
|
-
eventHanlders[customName] = [
|
|
185
|
-
{
|
|
186
|
-
key: `wa${Date.now().toString().slice(-8)}`,
|
|
187
|
-
handler: `({event}) => {
|
|
188
|
-
app.utils.set(context, '${id}.data', event?.detail?.data);
|
|
189
|
-
}`,
|
|
190
|
-
handlerModule: weapps_core_1.ActionType.Platform,
|
|
191
|
-
data: {},
|
|
192
|
-
boundData: {},
|
|
193
|
-
},
|
|
194
|
-
];
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
return eventHanlders;
|
|
198
|
-
}
|
|
199
|
-
exports.createEventHanlders = createEventHanlders;
|
|
200
|
-
function createDataBinds(widgets, ctx) {
|
|
201
|
-
const dataBinds = {};
|
|
202
|
-
(0, weapp_1.walkThroughWidgets)(widgets, (id, widget, parentId) => {
|
|
203
|
-
var _a;
|
|
204
|
-
const { xComponent } = widget;
|
|
205
|
-
const xProps = widget.xProps || {};
|
|
206
|
-
if (!xComponent) {
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
const materialLib = ctx.materialLibs.find((lib) => lib.name === xComponent.moduleName);
|
|
210
|
-
const miniprogramPlugin = (_a = ctx.miniprogramPlugins) === null || _a === void 0 ? void 0 : _a.find((plugin) => plugin.name === xComponent.moduleName);
|
|
211
|
-
if (!materialLib && !miniprogramPlugin) {
|
|
212
|
-
console.error('Component lib not found', xComponent);
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
dataBinds[id] = {};
|
|
216
|
-
Object.entries(xProps.data || {}).map(([prop, val]) => setDataBind(dataBinds[id], prop, val));
|
|
217
|
-
const { directives = {} } = xProps;
|
|
218
|
-
setDataBind(dataBinds[id], '_waFor', directives.waFor);
|
|
219
|
-
setDataBind(dataBinds[id], '_waIf', directives.waIf);
|
|
220
|
-
setDataBind(dataBinds[id], 'classList', xProps.classListBind);
|
|
221
|
-
setDataBind(dataBinds[id], 'style', xProps.styleBind);
|
|
222
|
-
const { classList, style } = dataBinds[id];
|
|
223
|
-
if (classList) {
|
|
224
|
-
dataBinds[id].classList = `concatClassList(${classList}, widgetProps.${id}.classList)`;
|
|
225
|
-
}
|
|
226
|
-
if (style) {
|
|
227
|
-
dataBinds[id].style = `px2rpx({...widgetProps.${id}.style, ...(${style})})`;
|
|
228
|
-
}
|
|
229
|
-
if (Object.keys(dataBinds[id]).length === 0) {
|
|
230
|
-
delete dataBinds[id];
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
return dataBinds;
|
|
234
|
-
}
|
|
235
|
-
exports.createDataBinds = createDataBinds;
|
|
236
|
-
function setDataBind(target, prop, val) {
|
|
237
|
-
if (val && val.type && val.type !== 'static') {
|
|
238
|
-
const jsExpr = generateDataBind(val);
|
|
239
|
-
if (jsExpr) {
|
|
240
|
-
target[prop] = jsExpr;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
package/lib/builder/mp/wxml.d.ts
DELETED
|
@@ -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,EAAiB,uBAAuB,EAAgB,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAU1G,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,UAqS7D;AAyBD,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,GAAE,eAAoB,UAQtG;AAmBD,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"}
|