@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.
- package/lib/builder/config/common.d.ts +2 -0
- package/lib/builder/config/common.d.ts.map +1 -0
- package/lib/builder/config/common.js +13 -0
- package/lib/builder/config/index.d.ts +3 -0
- package/lib/builder/config/index.d.ts.map +1 -0
- package/lib/builder/config/index.js +29 -0
- package/lib/builder/config/mp.d.ts +2 -0
- package/lib/builder/config/mp.d.ts.map +1 -0
- package/lib/builder/config/mp.js +13 -0
- package/lib/builder/core/copy.d.ts +5 -0
- package/lib/builder/core/copy.d.ts.map +1 -0
- package/lib/builder/core/copy.js +62 -0
- package/lib/builder/core/generate.d.ts +9 -0
- package/lib/builder/core/generate.d.ts.map +1 -0
- package/lib/builder/core/generate.js +128 -0
- package/lib/builder/core/index.d.ts +32 -0
- package/lib/builder/core/index.d.ts.map +1 -0
- package/lib/builder/core/index.js +149 -0
- package/lib/builder/core/material.d.ts +4 -0
- package/lib/builder/core/material.d.ts.map +1 -0
- package/lib/builder/core/material.js +80 -0
- package/lib/builder/core/plugin.d.ts +4 -0
- package/lib/builder/core/plugin.d.ts.map +1 -0
- package/lib/builder/core/plugin.js +30 -0
- package/lib/builder/core/prepare.d.ts +8 -0
- package/lib/builder/core/prepare.d.ts.map +1 -0
- package/lib/builder/core/prepare.js +108 -0
- package/lib/builder/core/webpack.d.ts +15 -0
- package/lib/builder/core/webpack.d.ts.map +1 -0
- package/lib/builder/core/webpack.js +58 -0
- package/lib/builder/mp/BuildContext.d.ts +13 -0
- package/lib/builder/mp/BuildContext.d.ts.map +1 -0
- package/lib/builder/mp/BuildContext.js +2 -0
- package/lib/builder/mp/index.d.ts +33 -0
- package/lib/builder/mp/index.d.ts.map +1 -0
- package/lib/builder/mp/index.js +450 -0
- package/lib/builder/mp/lowcode.d.ts +8 -0
- package/lib/builder/mp/lowcode.d.ts.map +1 -0
- package/lib/builder/mp/lowcode.js +54 -0
- package/lib/builder/mp/materials.d.ts +15 -0
- package/lib/builder/mp/materials.d.ts.map +1 -0
- package/lib/builder/mp/materials.js +338 -0
- package/lib/builder/mp/mixMode.d.ts +10 -0
- package/lib/builder/mp/mixMode.d.ts.map +1 -0
- package/lib/builder/mp/mixMode.js +215 -0
- package/lib/builder/mp/mp_config.d.ts +18 -0
- package/lib/builder/mp/mp_config.d.ts.map +1 -0
- package/lib/builder/mp/mp_config.js +206 -0
- package/lib/builder/mp/util.d.ts +20 -0
- package/lib/builder/mp/util.d.ts.map +1 -0
- package/lib/builder/mp/util.js +243 -0
- package/lib/builder/mp/wxml.d.ts +16 -0
- package/lib/builder/mp/wxml.d.ts.map +1 -0
- package/lib/builder/mp/wxml.js +300 -0
- package/lib/builder/service/builder/copy.d.ts +14 -0
- package/lib/builder/service/builder/copy.d.ts.map +1 -0
- package/lib/builder/service/builder/copy.js +189 -0
- package/lib/builder/service/builder/generate.d.ts +52 -0
- package/lib/builder/service/builder/generate.d.ts.map +1 -0
- package/lib/builder/service/builder/generate.js +792 -0
- package/lib/builder/service/builder/index.d.ts +16 -0
- package/lib/builder/service/builder/index.d.ts.map +1 -0
- package/lib/builder/service/builder/index.js +69 -0
- package/lib/builder/service/builder/plugin.d.ts +8 -0
- package/lib/builder/service/builder/plugin.d.ts.map +1 -0
- package/lib/builder/service/builder/plugin.js +149 -0
- package/lib/builder/service/builder/webpack.d.ts +91 -0
- package/lib/builder/service/builder/webpack.d.ts.map +1 -0
- package/lib/builder/service/builder/webpack.js +589 -0
- package/lib/builder/types/common.d.ts +12 -0
- package/lib/builder/types/common.d.ts.map +1 -0
- package/lib/builder/types/common.js +7 -0
- package/lib/builder/util/common.d.ts +36 -0
- package/lib/builder/util/common.d.ts.map +1 -0
- package/lib/builder/util/common.js +257 -0
- package/lib/builder/util/console.d.ts +2 -0
- package/lib/builder/util/console.d.ts.map +1 -0
- package/lib/builder/util/console.js +13 -0
- package/lib/builder/util/generateFiles.d.ts +6 -0
- package/lib/builder/util/generateFiles.d.ts.map +1 -0
- package/lib/builder/util/generateFiles.js +94 -0
- package/lib/builder/util/index.d.ts +2 -0
- package/lib/builder/util/index.d.ts.map +1 -0
- package/lib/builder/util/index.js +13 -0
- package/lib/builder/util/junk.d.ts +3 -0
- package/lib/builder/util/junk.d.ts.map +1 -0
- package/lib/builder/util/junk.js +25 -0
- package/lib/builder/util/mp.d.ts +5 -0
- package/lib/builder/util/mp.d.ts.map +1 -0
- package/lib/builder/util/mp.js +99 -0
- package/lib/builder/util/name-mangler.d.ts +3 -0
- package/lib/builder/util/name-mangler.d.ts.map +1 -0
- package/lib/builder/util/name-mangler.js +7 -0
- package/lib/builder/util/net.d.ts +3 -0
- package/lib/builder/util/net.d.ts.map +1 -0
- package/lib/builder/util/net.js +54 -0
- package/lib/builder/util/process.d.ts +9 -0
- package/lib/builder/util/process.d.ts.map +1 -0
- package/lib/builder/util/process.js +28 -0
- package/lib/builder/util/style.d.ts +2 -0
- package/lib/builder/util/style.d.ts.map +1 -0
- package/lib/builder/util/style.js +13 -0
- package/lib/builder/util/weapp.d.ts +2 -0
- package/lib/builder/util/weapp.d.ts.map +1 -0
- package/lib/builder/util/weapp.js +13 -0
- package/lib/config/private.d.ts +3 -0
- package/lib/config/private.d.ts.map +1 -0
- package/lib/config/private.js +14 -0
- package/lib/generate.d.ts +2 -0
- package/lib/generate.d.ts.map +1 -0
- package/lib/generate.js +49 -0
- package/lib/generator/config/common.d.ts +6 -0
- package/lib/generator/config/common.d.ts.map +1 -0
- package/lib/generator/config/common.js +25 -0
- package/lib/generator/config/index.d.ts +18 -0
- package/lib/generator/config/index.d.ts.map +1 -0
- package/lib/generator/config/index.js +43 -0
- package/lib/generator/config/mp.d.ts +56 -0
- package/lib/generator/config/mp.d.ts.map +1 -0
- package/lib/generator/config/mp.js +104 -0
- package/lib/generator/core/generate.d.ts +59 -0
- package/lib/generator/core/generate.d.ts.map +1 -0
- package/lib/generator/core/generate.js +663 -0
- package/lib/generator/core/index.d.ts +25 -0
- package/lib/generator/core/index.d.ts.map +1 -0
- package/lib/generator/core/index.js +102 -0
- package/lib/generator/core/material.d.ts +14 -0
- package/lib/generator/core/material.d.ts.map +1 -0
- package/lib/generator/core/material.js +230 -0
- package/lib/generator/template.d.ts +3 -0
- package/lib/generator/template.d.ts.map +1 -0
- package/lib/generator/template.js +3 -0
- package/lib/generator/types/common.d.ts +69 -0
- package/lib/generator/types/common.d.ts.map +1 -0
- package/lib/generator/types/common.js +21 -0
- package/lib/generator/util/common.d.ts +36 -0
- package/lib/generator/util/common.d.ts.map +1 -0
- package/lib/generator/util/common.js +238 -0
- package/lib/generator/util/console.d.ts +3 -0
- package/lib/generator/util/console.d.ts.map +1 -0
- package/lib/generator/util/console.js +17 -0
- package/lib/generator/util/index.d.ts +2 -0
- package/lib/generator/util/index.d.ts.map +1 -0
- package/lib/generator/util/index.js +13 -0
- package/lib/generator/util/name-mangler.d.ts +17 -0
- package/lib/generator/util/name-mangler.d.ts.map +1 -0
- package/lib/generator/util/name-mangler.js +63 -0
- package/lib/generator/util/postcss-rpx.d.ts +11 -0
- package/lib/generator/util/postcss-rpx.d.ts.map +1 -0
- package/lib/generator/util/postcss-rpx.js +16 -0
- package/lib/generator/util/style.d.ts +6 -0
- package/lib/generator/util/style.d.ts.map +1 -0
- package/lib/generator/util/style.js +92 -0
- package/lib/generator/util/weapp.d.ts +5 -0
- package/lib/generator/util/weapp.d.ts.map +1 -0
- package/lib/generator/util/weapp.js +17 -0
- package/lib/index.d.ts +0 -0
- package/lib/index.d.ts.map +0 -0
- package/lib/index.js +0 -0
- package/lib/types.d.ts +14 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +19 -0
- package/lib/utils/common.d.ts +0 -0
- package/lib/utils/common.d.ts.map +0 -0
- package/lib/utils/common.js +0 -0
- package/lib/utils/dataSource.d.ts +28 -0
- package/lib/utils/dataSource.d.ts.map +1 -0
- package/lib/utils/dataSource.js +171 -0
- package/lib/utils/index.d.ts +0 -0
- package/lib/utils/index.d.ts.map +0 -0
- package/lib/utils/index.js +0 -0
- package/lib/utils/postProcess.d.ts +3 -0
- package/lib/utils/postProcess.d.ts.map +1 -0
- package/lib/utils/postProcess.js +48 -0
- package/lib/weapps-core/config/index.d.ts +2 -0
- package/lib/weapps-core/config/index.d.ts.map +1 -0
- package/lib/weapps-core/config/index.js +13 -0
- package/lib/weapps-core/config/style.d.ts +7 -0
- package/lib/weapps-core/config/style.d.ts.map +1 -0
- package/lib/weapps-core/config/style.js +70 -0
- package/lib/weapps-core/index.d.ts +6 -0
- package/lib/weapps-core/index.d.ts.map +1 -0
- package/lib/weapps-core/index.js +31 -0
- package/lib/weapps-core/types/action.d.ts +25 -0
- package/lib/weapps-core/types/action.d.ts.map +1 -0
- package/lib/weapps-core/types/action.js +28 -0
- package/lib/weapps-core/types/app.d.ts +142 -0
- package/lib/weapps-core/types/app.d.ts.map +1 -0
- package/lib/weapps-core/types/app.js +21 -0
- package/lib/weapps-core/types/appbuild.d.ts +63 -0
- package/lib/weapps-core/types/appbuild.d.ts.map +1 -0
- package/lib/weapps-core/types/appbuild.js +78 -0
- package/lib/weapps-core/types/code_types.d.ts +26 -0
- package/lib/weapps-core/types/code_types.d.ts.map +1 -0
- package/lib/weapps-core/types/code_types.js +2 -0
- package/lib/weapps-core/types/git.d.ts +7 -0
- package/lib/weapps-core/types/git.d.ts.map +1 -0
- package/lib/weapps-core/types/git.js +2 -0
- package/lib/weapps-core/types/index.d.ts +11 -0
- package/lib/weapps-core/types/index.d.ts.map +1 -0
- package/lib/weapps-core/types/index.js +22 -0
- package/lib/weapps-core/types/lowcode.d.ts +26 -0
- package/lib/weapps-core/types/lowcode.d.ts.map +1 -0
- package/lib/weapps-core/types/lowcode.js +25 -0
- package/lib/weapps-core/types/material.d.ts +90 -0
- package/lib/weapps-core/types/material.d.ts.map +1 -0
- package/lib/weapps-core/types/material.js +9 -0
- package/lib/weapps-core/types/plugins.d.ts +17 -0
- package/lib/weapps-core/types/plugins.d.ts.map +1 -0
- package/lib/weapps-core/types/plugins.js +2 -0
- package/lib/weapps-core/types/style.d.ts +93 -0
- package/lib/weapps-core/types/style.d.ts.map +1 -0
- package/lib/weapps-core/types/style.js +2 -0
- package/lib/weapps-core/types/web.d.ts +120 -0
- package/lib/weapps-core/types/web.d.ts.map +1 -0
- package/lib/weapps-core/types/web.js +2 -0
- package/lib/weapps-core/utils/appbuild.d.ts +6 -0
- package/lib/weapps-core/utils/appbuild.d.ts.map +1 -0
- package/lib/weapps-core/utils/appbuild.js +40 -0
- package/lib/weapps-core/utils/common.d.ts +16 -0
- package/lib/weapps-core/utils/common.d.ts.map +1 -0
- package/lib/weapps-core/utils/common.js +90 -0
- package/lib/weapps-core/utils/file.d.ts +12 -0
- package/lib/weapps-core/utils/file.d.ts.map +1 -0
- package/lib/weapps-core/utils/file.js +142 -0
- package/lib/weapps-core/utils/formily.d.ts +5 -0
- package/lib/weapps-core/utils/formily.d.ts.map +1 -0
- package/lib/weapps-core/utils/formily.js +416 -0
- package/lib/weapps-core/utils/index.d.ts +7 -0
- package/lib/weapps-core/utils/index.d.ts.map +1 -0
- package/lib/weapps-core/utils/index.js +18 -0
- package/lib/weapps-core/utils/lowcdoe.d.ts +4 -0
- package/lib/weapps-core/utils/lowcdoe.d.ts.map +1 -0
- package/lib/weapps-core/utils/lowcdoe.js +69 -0
- package/lib/weapps-core/utils/style.d.ts +17 -0
- package/lib/weapps-core/utils/style.d.ts.map +1 -0
- package/lib/weapps-core/utils/style.js +330 -0
- package/package.json +3 -3
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.getUsedComponents = exports.getMpEventHanlderName = exports.generateWxml = void 0;
|
|
18
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
19
|
+
const weapps_core_1 = require("../../weapps-core");
|
|
20
|
+
const xml_js_1 = require("xml-js");
|
|
21
|
+
const mp_1 = require("../config/mp");
|
|
22
|
+
const materials_1 = require("./materials");
|
|
23
|
+
const weapp_1 = require("../util/weapp");
|
|
24
|
+
const name_mangler_1 = __importDefault(require("../util/name-mangler"));
|
|
25
|
+
const error = chalk_1.default.redBright;
|
|
26
|
+
function generateWxml(widgets, docTag, wxmlDataPrefix, ctx, usingComponents, nodeTransform) {
|
|
27
|
+
var _a;
|
|
28
|
+
const nameMangler = ctx.isProduction ? new name_mangler_1.default({ blackList: mp_1.builtinMpTags }) : undefined;
|
|
29
|
+
const xmlJson = {
|
|
30
|
+
elements: [
|
|
31
|
+
{
|
|
32
|
+
type: 'element',
|
|
33
|
+
name: 'wxs',
|
|
34
|
+
attributes: {
|
|
35
|
+
src: '/common/utils.wxs',
|
|
36
|
+
module: 'wxsUtils',
|
|
37
|
+
},
|
|
38
|
+
elements: [],
|
|
39
|
+
_order: -1,
|
|
40
|
+
_parent: null,
|
|
41
|
+
},
|
|
42
|
+
].concat(createXml(widgets)),
|
|
43
|
+
};
|
|
44
|
+
if (ctx.isPage) {
|
|
45
|
+
const originElements = xmlJson.elements;
|
|
46
|
+
if (originElements === null || originElements === void 0 ? void 0 : originElements.length) {
|
|
47
|
+
if (!((_a = originElements[0]) === null || _a === void 0 ? void 0 : _a.attributes)) {
|
|
48
|
+
originElements[0].attributes = {};
|
|
49
|
+
}
|
|
50
|
+
originElements[0].attributes['data-weui-theme'] = 'light';
|
|
51
|
+
}
|
|
52
|
+
xmlJson.elements = [
|
|
53
|
+
{
|
|
54
|
+
type: 'element',
|
|
55
|
+
name: 'block',
|
|
56
|
+
attributes: {
|
|
57
|
+
['wx:if']: '{{weDaHasLogin}}',
|
|
58
|
+
},
|
|
59
|
+
elements: originElements,
|
|
60
|
+
_order: -1,
|
|
61
|
+
_parent: null,
|
|
62
|
+
},
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
function createXml(widgets, parent = null, parentForNodes = []) {
|
|
66
|
+
var _a, _b;
|
|
67
|
+
const elements = [];
|
|
68
|
+
for (const id in widgets) {
|
|
69
|
+
const { xComponent, xProps, properties, xIndex } = widgets[id];
|
|
70
|
+
const { data: data0 = {}, listeners = [], directives = {}, staticResourceAttribute = ['src'] } = xProps || {};
|
|
71
|
+
const data = Object.assign({}, data0);
|
|
72
|
+
if (directives.waIf && directives.waIf.value === false) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (!xComponent) {
|
|
76
|
+
const slotNodes = createXml(properties, parent, parentForNodes);
|
|
77
|
+
slotNodes.forEach((node) => {
|
|
78
|
+
var _a;
|
|
79
|
+
node.attributes.slot = id;
|
|
80
|
+
(_a = parent === null || parent === void 0 ? void 0 : parent.elements) === null || _a === void 0 ? void 0 : _a.push(node);
|
|
81
|
+
});
|
|
82
|
+
if (parent) {
|
|
83
|
+
delete parent.attributes[id];
|
|
84
|
+
}
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
const componentKey = xComponent.moduleName + ':' + xComponent.name;
|
|
88
|
+
const helpMsg = `Please check component(${id}) in component tree of ${docTag}.`;
|
|
89
|
+
const materialLib = ctx.materialLibs.find((lib) => lib.name === xComponent.moduleName);
|
|
90
|
+
const miniprogramPlugin = (_a = ctx.miniprogramPlugins) === null || _a === void 0 ? void 0 : _a.find((plugin) => plugin.name === xComponent.moduleName);
|
|
91
|
+
if (!materialLib && !miniprogramPlugin) {
|
|
92
|
+
console.error(error(`Component lib(${xComponent.moduleName}) not found. ${helpMsg}`));
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const componentProto = materialLib
|
|
96
|
+
? materialLib.components.find((comp) => comp.name === xComponent.name)
|
|
97
|
+
: miniprogramPlugin === null || miniprogramPlugin === void 0 ? void 0 : miniprogramPlugin.componentConfigs.find((comp) => comp.name === xComponent.name);
|
|
98
|
+
if (!componentProto) {
|
|
99
|
+
console.error(error(`Component(${xComponent.name}) not found in lib(${xComponent.moduleName}). ${helpMsg}`));
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const { tagName, path } = (0, materials_1.getWxmlTag)(xComponent, ctx, nameMangler);
|
|
103
|
+
if (path) {
|
|
104
|
+
usingComponents[tagName] = path;
|
|
105
|
+
}
|
|
106
|
+
let curForNodes = parentForNodes;
|
|
107
|
+
if (directives.waFor && directives.waFor.value) {
|
|
108
|
+
curForNodes = [...curForNodes, id];
|
|
109
|
+
}
|
|
110
|
+
const attrPrefix = `${wxmlDataPrefix.widgetProp}${id}${curForNodes
|
|
111
|
+
.map((forNodeId) => `[${wxmlDataPrefix.forIndex}${forNodeId}]`)
|
|
112
|
+
.join('')}.`;
|
|
113
|
+
const idAttr = curForNodes.length < 1
|
|
114
|
+
? id
|
|
115
|
+
: `{{'${id}'${curForNodes.map((forNodeId) => `+ '-' + ${wxmlDataPrefix.forIndex}${forNodeId}`).join('')}}}`;
|
|
116
|
+
if (tagName === 'slot') {
|
|
117
|
+
const slotNode = {
|
|
118
|
+
type: 'element',
|
|
119
|
+
name: tagName,
|
|
120
|
+
attributes: {
|
|
121
|
+
name: data0.name.type && data0.name.type !== 'static' ? `{{${id}.name}}` : data0.name.value,
|
|
122
|
+
},
|
|
123
|
+
elements: [],
|
|
124
|
+
_order: xIndex || 0,
|
|
125
|
+
_parent: null,
|
|
126
|
+
};
|
|
127
|
+
if (directives.waIf && directives.waIf.value) {
|
|
128
|
+
slotNode.attributes['wx:if'] = getAttrBind(directives.waIf, `${attrPrefix}_waIf`);
|
|
129
|
+
}
|
|
130
|
+
elements.push(slotNode);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
const node = {
|
|
134
|
+
type: 'element',
|
|
135
|
+
name: tagName,
|
|
136
|
+
attributes: {
|
|
137
|
+
id: idAttr,
|
|
138
|
+
'bind:attached': '__handlerAttached__',
|
|
139
|
+
'bind:detached': '__handlerDetached__',
|
|
140
|
+
style: `{{${attrPrefix}style}}`,
|
|
141
|
+
[(0, mp_1.getClassAttrName)(tagName)]: `{{${attrPrefix}className}}`,
|
|
142
|
+
},
|
|
143
|
+
elements: [],
|
|
144
|
+
_order: xIndex || 0,
|
|
145
|
+
_parent: parent,
|
|
146
|
+
};
|
|
147
|
+
const { mustEmptyStyle } = componentProto.meta || {};
|
|
148
|
+
if (mustEmptyStyle) {
|
|
149
|
+
delete node.attributes.style;
|
|
150
|
+
}
|
|
151
|
+
if (directives.waIf && directives.waIf.value) {
|
|
152
|
+
node.attributes['wx:if'] = getAttrBind(directives.waIf, `${attrPrefix}_waIf`);
|
|
153
|
+
}
|
|
154
|
+
if (directives.waFor && directives.waFor.value) {
|
|
155
|
+
node.attributes['wx:for'] = getAttrBind(directives.waFor, `${wxmlDataPrefix.widgetProp}${id}${parentForNodes
|
|
156
|
+
.map((forNodeId) => `[${wxmlDataPrefix.forIndex}${forNodeId}]`)
|
|
157
|
+
.join('')}`);
|
|
158
|
+
node.attributes['wx:for-index'] = wxmlDataPrefix.forIndex + id;
|
|
159
|
+
node.attributes['wx:key'] = node.attributes['wx:key'] = ((_b = directives.waForKey) === null || _b === void 0 ? void 0 : _b.value) ? '_key' : '$$i';
|
|
160
|
+
}
|
|
161
|
+
const compSchema = componentProto.dataForm;
|
|
162
|
+
for (const prop in data) {
|
|
163
|
+
if (compSchema) {
|
|
164
|
+
const fieldDef = compSchema[prop];
|
|
165
|
+
if (!fieldDef) {
|
|
166
|
+
console.log(error(`Prop(${prop}) does not exist on ${componentKey}. ${helpMsg}`));
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
if (fieldDef.readOnly) {
|
|
170
|
+
if (fieldDef.hasOwnProperty('default')) {
|
|
171
|
+
node.attributes[prop] = fieldDef.default;
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
console.error(error(`Readonly property(${prop}) of ${componentKey} must have a default value. ${helpMsg}`));
|
|
175
|
+
}
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
xmlJsonSetCustomAttr(node, prop, getAttrBind(data[prop], `${attrPrefix}${prop}`, staticResourceAttribute.includes(prop)), xComponent);
|
|
180
|
+
}
|
|
181
|
+
const { inputProps, syncProps } = componentProto.meta || {};
|
|
182
|
+
const syncConfigs = syncProps || inputProps || {};
|
|
183
|
+
Object.entries(syncConfigs).map(([prop, config]) => {
|
|
184
|
+
const configs = Array.isArray(config) ? config : [config];
|
|
185
|
+
configs.forEach(({ changeEvent: evtName }) => {
|
|
186
|
+
const sep = getEventBindSep(tagName);
|
|
187
|
+
node.attributes[`bind${sep}${evtName}`] = getMpEventHanlderName(id, evtName);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
listeners.forEach((l) => {
|
|
191
|
+
const evtName = getMpEventName(l.trigger);
|
|
192
|
+
const modifiers = l;
|
|
193
|
+
node.attributes[getMpEventAttr(evtName, modifiers, tagName)] = getMpEventHanlderName(id, evtName, modifiers);
|
|
194
|
+
});
|
|
195
|
+
const compConfig = componentProto.compConfig;
|
|
196
|
+
if (compConfig === null || compConfig === void 0 ? void 0 : compConfig.isDataContainer) {
|
|
197
|
+
node.attributes['bind:onDataChange'] = getMpEventHanlderName(id, 'onDataChange');
|
|
198
|
+
}
|
|
199
|
+
if (compConfig && compConfig.pluginConfig) {
|
|
200
|
+
if (compConfig.pluginConfig.attributes) {
|
|
201
|
+
Object.assign(node.attributes, compConfig.pluginConfig.attributes);
|
|
202
|
+
}
|
|
203
|
+
if (compConfig.pluginConfig.componentPath) {
|
|
204
|
+
usingComponents[tagName] = compConfig.pluginConfig.componentPath;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
node.elements = node.elements.concat(createXml(properties, node, curForNodes));
|
|
208
|
+
if (tagName === 'swiper' || componentKey === 'weda:Swiper' || componentKey === 'gsd-h5-react:Swiper') {
|
|
209
|
+
node.elements = node.elements.map((item, index) => {
|
|
210
|
+
var _a, _b;
|
|
211
|
+
let _c = item.attributes || {}, { ['wx:for']: wxFor, ['wx:for-index']: wxForIndex, ['wx:key']: wxKey, ['wx:if']: wxIf } = _c, itemRestKey = __rest(_c, ['wx:for', 'wx:for-index', 'wx:key', 'wx:if']);
|
|
212
|
+
if (item.name !== 'swiper-item') {
|
|
213
|
+
let SwiperItem = {
|
|
214
|
+
type: 'element',
|
|
215
|
+
name: 'swiper-item',
|
|
216
|
+
attributes: {
|
|
217
|
+
id: `${((_a = item.attributes) === null || _a === void 0 ? void 0 : _a.id) || ((_b = node === null || node === void 0 ? void 0 : node.attributes) === null || _b === void 0 ? void 0 : _b.id) + index}-item`,
|
|
218
|
+
'wx:for': wxFor,
|
|
219
|
+
'wx:for-index': wxForIndex,
|
|
220
|
+
'wx:key': wxKey,
|
|
221
|
+
'wx:if': wxIf,
|
|
222
|
+
},
|
|
223
|
+
elements: [],
|
|
224
|
+
_order: index || 0,
|
|
225
|
+
_parent: node,
|
|
226
|
+
};
|
|
227
|
+
SwiperItem.elements = [
|
|
228
|
+
Object.assign(Object.assign({}, item), { attributes: Object.assign({}, itemRestKey), _parent: SwiperItem }),
|
|
229
|
+
];
|
|
230
|
+
return SwiperItem;
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
return item;
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
nodeTransform && nodeTransform(widgets[id], node);
|
|
238
|
+
elements.push(node);
|
|
239
|
+
}
|
|
240
|
+
return elements.sort((a, b) => a._order - b._order);
|
|
241
|
+
}
|
|
242
|
+
return (0, xml_js_1.js2xml)(xmlJson, {
|
|
243
|
+
spaces: '\t',
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
exports.generateWxml = generateWxml;
|
|
247
|
+
function xmlJsonSetCustomAttr(node, prop, value, comp) {
|
|
248
|
+
if (mp_1.builtinWigetProps.indexOf(prop) > -1) {
|
|
249
|
+
console.error(error('Builtin prop(' + prop + ') is not allowed for custom component'), comp);
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
node.attributes[prop] = value;
|
|
253
|
+
if (prop === mp_1.textContentPropName) {
|
|
254
|
+
node.elements.push({ type: 'text', text: value });
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
const evtNameMap = {
|
|
258
|
+
__weapps_action_trigger_click: 'tap',
|
|
259
|
+
};
|
|
260
|
+
function getMpEventName(originalName) {
|
|
261
|
+
return evtNameMap[originalName] || originalName.replace(/\./g, '_');
|
|
262
|
+
}
|
|
263
|
+
function getMpEventHanlderName(widgetId, evtName, modifier = {}) {
|
|
264
|
+
if (mp_1.builtinMpEvents.indexOf(evtName) === -1) {
|
|
265
|
+
modifier = {};
|
|
266
|
+
}
|
|
267
|
+
return `on${widgetId}$${getMpEventName(evtName)}${modifier.isCapturePhase ? '$cap' : ''}${modifier.noPropagation ? '$cat' : ''}`;
|
|
268
|
+
}
|
|
269
|
+
exports.getMpEventHanlderName = getMpEventHanlderName;
|
|
270
|
+
function getMpEventAttr(evtName, modifier, tagName) {
|
|
271
|
+
if (mp_1.builtinMpEvents.indexOf(evtName) === -1) {
|
|
272
|
+
modifier = {};
|
|
273
|
+
}
|
|
274
|
+
let prefix = modifier.isCapturePhase ? 'capture-' : '';
|
|
275
|
+
prefix += modifier.noPropagation ? 'catch' : 'bind';
|
|
276
|
+
const sep = getEventBindSep(tagName);
|
|
277
|
+
return prefix + sep + evtName;
|
|
278
|
+
}
|
|
279
|
+
function getEventBindSep(tagName) {
|
|
280
|
+
return mp_1.nativeCompWhiteList.includes(tagName.toLowerCase()) ? '' : ':';
|
|
281
|
+
}
|
|
282
|
+
function getUsedComponents(widgets, usedCmps = {}) {
|
|
283
|
+
(0, weapp_1.walkThroughWidgets)(widgets, (id, widget) => {
|
|
284
|
+
const { xComponent } = widget;
|
|
285
|
+
if (!xComponent)
|
|
286
|
+
return;
|
|
287
|
+
const { moduleName, name } = xComponent;
|
|
288
|
+
if (!usedCmps[moduleName]) {
|
|
289
|
+
usedCmps[moduleName] = new Set();
|
|
290
|
+
}
|
|
291
|
+
usedCmps[moduleName].add(name);
|
|
292
|
+
});
|
|
293
|
+
return usedCmps;
|
|
294
|
+
}
|
|
295
|
+
exports.getUsedComponents = getUsedComponents;
|
|
296
|
+
function getAttrBind(dVale, widgetBind, isStaticResource) {
|
|
297
|
+
const { type, value } = dVale;
|
|
298
|
+
const attrVal = type === weapps_core_1.PropBindType.prop ? value : widgetBind;
|
|
299
|
+
return isStaticResource ? `{{wxsUtils._getStaticResourceAttribute(${attrVal})}}` : `{{${attrVal}}}`;
|
|
300
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IMaterialItem, IWebRuntimeAppData, IComponentLibEntry } from '../../../weapps-core';
|
|
2
|
+
import { IComponentsInfoMap } from '../../types/common';
|
|
3
|
+
export declare function copyEntryFile(appBuildDir: string, appContent: IWebRuntimeAppData, adminPortalKey: any): Promise<void>;
|
|
4
|
+
export declare function copyMaterialLibraries(dependencies: IMaterialItem[] | undefined, materialsDir: string, appBuildDir: string): Promise<void>;
|
|
5
|
+
export declare function genCompositeComponentLibraries(dependencies: IMaterialItem[] | undefined, appBuildDir: string, materialGroupInfoMap: {
|
|
6
|
+
[name: string]: {
|
|
7
|
+
isComposite: boolean;
|
|
8
|
+
version?: string | undefined;
|
|
9
|
+
entries?: IComponentLibEntry | undefined;
|
|
10
|
+
schemaVersion?: string | undefined;
|
|
11
|
+
isPlainProps?: boolean | undefined;
|
|
12
|
+
};
|
|
13
|
+
} | undefined, componentsInfoMap: IComponentsInfoMap): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=copy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy.d.ts","sourceRoot":"","sources":["../../../../src/builder/service/builder/copy.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,aAAa,EACb,kBAAkB,EAIlB,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAwB,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAI9E,wBAAsB,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,cAAc,KAAA,iBActG;AAED,wBAAsB,qBAAqB,CACzC,YAAY,6BAAsB,EAClC,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,iBAiEpB;AAED,wBAAsB,8BAA8B,CAClD,YAAY,6BAAsB,EAClC,WAAW,EAAE,MAAM,EACnB,oBAAoB;;qBAEH,OAAO;;;;;;aAMlB,EACN,iBAAiB,EAAE,kBAAkB,iBAkGtC"}
|
|
@@ -0,0 +1,189 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
exports.genCompositeComponentLibraries = exports.copyMaterialLibraries = exports.copyEntryFile = void 0;
|
|
35
|
+
const path_1 = __importDefault(require("path"));
|
|
36
|
+
const fs_extra_1 = __importStar(require("fs-extra"));
|
|
37
|
+
const lodash_template_1 = __importDefault(require("lodash.template"));
|
|
38
|
+
const json_schema_defaults_1 = __importDefault(require("json-schema-defaults"));
|
|
39
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
40
|
+
const util_1 = require("../../util");
|
|
41
|
+
const weapps_core_1 = require("../../../weapps-core");
|
|
42
|
+
const config_1 = require("../../config");
|
|
43
|
+
const generate_1 = require("./generate");
|
|
44
|
+
const junk = __importStar(require("../../util/junk"));
|
|
45
|
+
function copyEntryFile(appBuildDir, appContent, adminPortalKey) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
const entryFilePath = path_1.default.resolve(config_1.appTemplateDir, './src/index.jsx');
|
|
48
|
+
const content = yield fs_extra_1.default.readFile(entryFilePath);
|
|
49
|
+
yield fs_extra_1.default.writeFile(path_1.default.join(appBuildDir, 'src/index.jsx'), (0, lodash_template_1.default)(content + '')(Object.assign({ adminPortalKey, yyptAppKey: '', reportUrl: '', stopReport: false }, appContent)), { flag: 'w' });
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
exports.copyEntryFile = copyEntryFile;
|
|
53
|
+
function copyMaterialLibraries(dependencies = [], materialsDir, appBuildDir) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
const localPkg = (0, util_1.getCurrentPackageJson)();
|
|
56
|
+
yield Promise.all(dependencies.map((componentLib) => __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
var _a, _b, _c, _d, _e;
|
|
58
|
+
const { name, version } = componentLib;
|
|
59
|
+
const materialNameVersion = `${name}@${version}`;
|
|
60
|
+
const materialDir = path_1.default.join(materialsDir, materialNameVersion);
|
|
61
|
+
const srcDir = 'src';
|
|
62
|
+
let targetDir = path_1.default.join(materialDir, srcDir);
|
|
63
|
+
if (localPkg && localPkg.name === name && localPkg.version === version) {
|
|
64
|
+
console.log('当前本地目录是素材库的时候,直接用本地的', materialNameVersion);
|
|
65
|
+
targetDir = path_1.default.join(process.cwd(), 'src');
|
|
66
|
+
}
|
|
67
|
+
const librariesDir = path_1.default.join(appBuildDir, 'src/libraries', materialNameVersion);
|
|
68
|
+
const metaJosnPath = path_1.default.join(materialDir, 'meta.json');
|
|
69
|
+
if (fs_extra_1.default.existsSync(metaJosnPath)) {
|
|
70
|
+
yield fs_extra_1.default.copy(metaJosnPath, path_1.default.join(librariesDir, 'meta.json'));
|
|
71
|
+
}
|
|
72
|
+
yield fs_extra_1.default.copy(targetDir, librariesDir, {
|
|
73
|
+
filter: (src, dest) => {
|
|
74
|
+
let path = src.split('/');
|
|
75
|
+
return !junk.is(path[path.length - 1]);
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
const nodeModulesPath = path_1.default.join(materialDir, 'node_modules');
|
|
79
|
+
const targetNodeModulesPath = path_1.default.join(librariesDir, 'node_modules');
|
|
80
|
+
if (fs_extra_1.default.existsSync(nodeModulesPath) && !fs_extra_1.default.existsSync(targetNodeModulesPath)) {
|
|
81
|
+
yield fs_extra_1.default.symlink(nodeModulesPath, targetNodeModulesPath, 'dir');
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
const meta = (0, util_1.readComponentLibMata)(librariesDir);
|
|
85
|
+
if (meta === null || meta === void 0 ? void 0 : meta.schemaVersion) {
|
|
86
|
+
componentLib['schemaVersion'] = meta === null || meta === void 0 ? void 0 : meta.schemaVersion;
|
|
87
|
+
}
|
|
88
|
+
let [major] = ((_a = meta === null || meta === void 0 ? void 0 : meta.schemaVersion) === null || _a === void 0 ? void 0 : _a.split('.')) || [];
|
|
89
|
+
if (Number(major) >= 3) {
|
|
90
|
+
componentLib['isPlainProps'] = true;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch (e) { }
|
|
94
|
+
try {
|
|
95
|
+
const packageJson = (0, fs_extra_1.readJsonSync)(path_1.default.join(materialDir, 'package.json'));
|
|
96
|
+
if ((_c = (_b = packageJson.weda) === null || _b === void 0 ? void 0 : _b.platform) === null || _c === void 0 ? void 0 : _c.web) {
|
|
97
|
+
const entries = (_e = (_d = packageJson.weda) === null || _d === void 0 ? void 0 : _d.platform) === null || _e === void 0 ? void 0 : _e.web;
|
|
98
|
+
componentLib['entries'] = {
|
|
99
|
+
entry: path_1.default.posix.relative(srcDir, entries.entry),
|
|
100
|
+
components: path_1.default.posix.relative(srcDir, entries.components),
|
|
101
|
+
actions: path_1.default.posix.relative(srcDir, entries.actions),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
else if (packageJson.lowcode) {
|
|
105
|
+
const entry = path_1.default.posix.relative(srcDir, packageJson.lowcode);
|
|
106
|
+
componentLib['entries'] = {
|
|
107
|
+
entry,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
catch (e) { }
|
|
112
|
+
})));
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
exports.copyMaterialLibraries = copyMaterialLibraries;
|
|
116
|
+
function genCompositeComponentLibraries(dependencies = [], appBuildDir, materialGroupInfoMap = {}, componentsInfoMap) {
|
|
117
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
yield Promise.all(dependencies.map(({ name, version, components }) => __awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
const materialNameVersion = `${name}@${version}`;
|
|
120
|
+
const librariesDir = path_1.default.join(appBuildDir, 'src/libraries', materialNameVersion);
|
|
121
|
+
yield Promise.all(components.map((component) => __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
let compItem = component;
|
|
123
|
+
compItem.materialName = name;
|
|
124
|
+
const wrapperClass = (0, weapps_core_1.getCompositedComponentClass)(compItem);
|
|
125
|
+
const componentSchemaJson = {
|
|
126
|
+
type: 'object',
|
|
127
|
+
properties: (0, weapps_core_1.readCmpInstances)(compItem.componentInstances),
|
|
128
|
+
};
|
|
129
|
+
const { widgets, dataBinds, componentSchema } = (0, generate_1.getComponentSchemaString)(componentSchemaJson, true, componentsInfoMap, wrapperClass);
|
|
130
|
+
const templateData = {
|
|
131
|
+
id: compItem.id,
|
|
132
|
+
name: compItem.name,
|
|
133
|
+
defaultProps: (0, json_schema_defaults_1.default)({
|
|
134
|
+
type: 'object',
|
|
135
|
+
properties: compItem.dataForm || {},
|
|
136
|
+
}),
|
|
137
|
+
compConfig: compItem.compConfig || {},
|
|
138
|
+
emitEvents: JSON.stringify(compItem.emitEvents.map((evt) => evt.eventName)),
|
|
139
|
+
handlersImports: compItem.lowCodes.filter((codeItem) => codeItem.type === 'handler-fn' && codeItem.name !== '____index____'),
|
|
140
|
+
useComponents: (function () {
|
|
141
|
+
const list = [];
|
|
142
|
+
JSON.stringify(compItem.componentInstances, (key, value) => {
|
|
143
|
+
var _a;
|
|
144
|
+
if (key === 'xComponent') {
|
|
145
|
+
const { moduleName, name } = value;
|
|
146
|
+
const compLib = materialGroupInfoMap[moduleName];
|
|
147
|
+
let isPlainProps = false;
|
|
148
|
+
if (compLib) {
|
|
149
|
+
const { schemaVersion = '' } = compLib;
|
|
150
|
+
try {
|
|
151
|
+
if (Number((_a = schemaVersion.split('.')) === null || _a === void 0 ? void 0 : _a[0]) >= 3) {
|
|
152
|
+
isPlainProps = true;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
catch (e) { }
|
|
156
|
+
}
|
|
157
|
+
list.push({
|
|
158
|
+
moduleName,
|
|
159
|
+
name,
|
|
160
|
+
key: `${moduleName}:${name}`,
|
|
161
|
+
var: lodash_1.default.upperFirst(lodash_1.default.camelCase(`${moduleName}:${name}`)),
|
|
162
|
+
moduleNameVar: lodash_1.default.camelCase(moduleName),
|
|
163
|
+
version: (compLib === null || compLib === void 0 ? void 0 : compLib.version) || '',
|
|
164
|
+
entries: compLib === null || compLib === void 0 ? void 0 : compLib.entries,
|
|
165
|
+
isPlainProps: isPlainProps,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
return value;
|
|
169
|
+
});
|
|
170
|
+
return lodash_1.default.uniqBy(list, 'key');
|
|
171
|
+
})(),
|
|
172
|
+
widgets,
|
|
173
|
+
dataBinds,
|
|
174
|
+
componentSchema,
|
|
175
|
+
pageListenerInstances: (0, generate_1.getListenersString)(compItem.listeners, true),
|
|
176
|
+
materialName: name,
|
|
177
|
+
};
|
|
178
|
+
const dest = path_1.default.resolve(librariesDir, `./components/${compItem.name}/index.jsx`);
|
|
179
|
+
const template = yield fs_extra_1.default.readFile(path_1.default.resolve(config_1.appTemplateDir, './src/pages/composite.tpl'), {
|
|
180
|
+
encoding: 'utf8',
|
|
181
|
+
});
|
|
182
|
+
const jsx = (0, lodash_template_1.default)(template)(templateData);
|
|
183
|
+
yield fs_extra_1.default.ensureFile(dest);
|
|
184
|
+
yield fs_extra_1.default.writeFile(dest, jsx);
|
|
185
|
+
})));
|
|
186
|
+
})));
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
exports.genCompositeComponentLibraries = genCompositeComponentLibraries;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Schema } from '@formily/react-schema-renderer';
|
|
2
|
+
import { IMaterialItem, IPageInstance, IListenerInstance, IComponentSchemaJson, IPluginInstance, IItemInstance, IWebRuntimeAppData, IComponentLibEntry } from '../../../weapps-core';
|
|
3
|
+
import { BuildType, IComponentsInfoMap } from '../../types/common';
|
|
4
|
+
import { DEPLOY_MODE } from '../../../types';
|
|
5
|
+
import { IOriginKeyInfo as IBaseOriginKeyInfo } from '../../../generator/core/generate';
|
|
6
|
+
export interface IOriginKeyInfo extends IBaseOriginKeyInfo {
|
|
7
|
+
}
|
|
8
|
+
export declare function generateAppStyleLessFile(allAppDataList: IWebRuntimeAppData[], appBuildDir: string): Promise<void>;
|
|
9
|
+
export declare function generateThemeVarsFile(themeVars: object | undefined, appBuildDir: string): Promise<void>;
|
|
10
|
+
export declare function generateAllPageJsxFile(pageInstanceList: IPageInstance[], appBuildDir: string, rootPath: string, dependencies: IMaterialItem[] | undefined, extraData: {
|
|
11
|
+
isComposite: boolean;
|
|
12
|
+
compProps: any;
|
|
13
|
+
} | undefined, buildTypeList: any[]): Promise<void>;
|
|
14
|
+
export declare function generateSinglePageJsxFile(pageInstance: IPageInstance, appBuildDir: string, rootPath: string, dependencies: IMaterialItem[] | undefined, extraData: {
|
|
15
|
+
isComposite: boolean;
|
|
16
|
+
compProps: any;
|
|
17
|
+
} | undefined, buildTypeList: any[]): Promise<void>;
|
|
18
|
+
export declare function getOriginComponentAndActionList(componentSchema: IComponentSchemaJson, fixedDependencies: IMaterialItem[], originComponentList?: IOriginKeyInfo[], originActionList?: IOriginKeyInfo[]): {
|
|
19
|
+
originComponentList: IOriginKeyInfo[];
|
|
20
|
+
originActionList: IOriginKeyInfo[];
|
|
21
|
+
};
|
|
22
|
+
export declare function getOriginPluginList(pluginInstances?: IPluginInstance[], dependencies?: IMaterialItem[], originPluginList?: IOriginKeyInfo[]): IOriginKeyInfo[];
|
|
23
|
+
interface IFixedDependence extends IMaterialItem {
|
|
24
|
+
isPlainProps?: boolean;
|
|
25
|
+
entries?: IComponentLibEntry;
|
|
26
|
+
}
|
|
27
|
+
export declare function pullActionToListByInstances(listenerInstances: any, originActionList: any, fixedDependencies: IFixedDependence[]): void;
|
|
28
|
+
export declare function pullComponentToListByInstance(sourceKey: string, originComponentList: IOriginKeyInfo[], fixedDependencies: IFixedDependence[]): void;
|
|
29
|
+
export declare function getVirtualFieldsString(components: IOriginKeyInfo[]): string;
|
|
30
|
+
export declare function isSlot(comp: Schema): boolean | "" | undefined;
|
|
31
|
+
export declare function getComponentSchemaString(componentSchema: IComponentSchemaJson, isComposite?: boolean, componentsInfoMap?: IComponentsInfoMap, wrapperClass?: string): {
|
|
32
|
+
widgets: string;
|
|
33
|
+
dataBinds: string;
|
|
34
|
+
componentSchema: string;
|
|
35
|
+
};
|
|
36
|
+
export declare function getListenersString(listeners?: IListenerInstance[], isComposite?: boolean): string;
|
|
37
|
+
export declare function getPluginInstancesString(instances: IItemInstance[]): string;
|
|
38
|
+
export declare function getPluginImportStringArr(plugins: any, pluginImportStringArr?: string[]): string[];
|
|
39
|
+
export declare function getComponentImportStringArr(components: IOriginKeyInfo[], componentImportStringArr?: string[]): string[];
|
|
40
|
+
export declare function getEntryImportStringArr(materialInfoList?: {
|
|
41
|
+
materialName: string;
|
|
42
|
+
version: string;
|
|
43
|
+
entries?: IComponentLibEntry;
|
|
44
|
+
}[], entryImportStringArr?: string[]): string[];
|
|
45
|
+
export declare function getActionImportStringArr(originActionList: IOriginKeyInfo[], actionImportStringArr?: string[]): string[];
|
|
46
|
+
export declare function pushActionToImportStringArr(listenerInstance: IOriginKeyInfo, actionImportStringArr: string[]): void;
|
|
47
|
+
export declare function generateRouterFile(allAppDataList: IWebRuntimeAppData[], appBuildDir: string, basename?: string, buildTypeList?: BuildType[]): Promise<void>;
|
|
48
|
+
export declare function writeLowCodeFiles(appData: IWebRuntimeAppData, appBuildDir: string): Promise<void>;
|
|
49
|
+
export declare function writeLowCodeFilesForCompositeComp(compositeGroups: IMaterialItem[], appBuildDir: string): Promise<void>;
|
|
50
|
+
export declare function generateCodeFromTpl(appData: IWebRuntimeAppData, appBuildDir: string, dependencies: IMaterialItem[], appKey: string, rootPath: any, deployMode: DEPLOY_MODE, buildTypeList: BuildType[], extraData: any): Promise<void>;
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../../src/builder/service/builder/generate.ts"],"names":[],"mappings":"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"}
|