@cloudbase/lowcode-builder 0.1.23 → 0.1.24
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/mp/wxml.js
CHANGED
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getUsedComponents = exports.getMpEventHanlderName = exports.generateWxml = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const weapps_core_1 = require("@cloudbase/lowcode-generator/lib/weapps-core");
|
|
9
8
|
const xml_js_1 = require("xml-js");
|
|
10
9
|
const mp_1 = require("@cloudbase/lowcode-generator/lib/generator/config/mp");
|
|
11
10
|
const materials_1 = require("./materials");
|
|
@@ -14,9 +13,7 @@ const name_mangler_1 = __importDefault(require("@cloudbase/lowcode-generator/lib
|
|
|
14
13
|
const error = chalk_1.default.redBright;
|
|
15
14
|
function generateWxml(widgets, docTag, wxmlDataPrefix, ctx, usingComponents, componentGenerics, nodeTransform) {
|
|
16
15
|
var _a;
|
|
17
|
-
const nameMangler = ctx.isProduction
|
|
18
|
-
? new name_mangler_1.default({ blackList: mp_1.builtinMpTags })
|
|
19
|
-
: undefined;
|
|
16
|
+
const nameMangler = ctx.isProduction ? new name_mangler_1.default({ blackList: mp_1.builtinMpTags }) : undefined;
|
|
20
17
|
const xmlJson = {
|
|
21
18
|
elements: [
|
|
22
19
|
{
|
|
@@ -57,9 +54,9 @@ function generateWxml(widgets, docTag, wxmlDataPrefix, ctx, usingComponents, com
|
|
|
57
54
|
function createXml(widgets, parent = null, parentForNodes = []) {
|
|
58
55
|
var _a, _b, _c, _d, _e;
|
|
59
56
|
const elements = [];
|
|
60
|
-
for (const id
|
|
57
|
+
for (const id of Object.keys(widgets !== null && widgets !== void 0 ? widgets : {})) {
|
|
61
58
|
const { xComponent, xProps, properties, xIndex, genericComp } = widgets[id];
|
|
62
|
-
const { data: data0 = {}, listeners = [], directives = {}, staticResourceAttribute = ['src']
|
|
59
|
+
const { data: data0 = {}, listeners = [], directives = {}, staticResourceAttribute = ['src'] } = xProps || {};
|
|
63
60
|
const data = { ...data0 };
|
|
64
61
|
if (directives.waIf && directives.waIf.value === false) {
|
|
65
62
|
continue;
|
|
@@ -110,17 +107,13 @@ function generateWxml(widgets, docTag, wxmlDataPrefix, ctx, usingComponents, com
|
|
|
110
107
|
.join('')}`;
|
|
111
108
|
const idAttr = curForNodes.length < 1
|
|
112
109
|
? id
|
|
113
|
-
: `{{'${id}'${curForNodes
|
|
114
|
-
.map((forNodeId) => `+ '-' + ${wxmlDataPrefix.forIndex}${forNodeId}`)
|
|
115
|
-
.join('')}}}`;
|
|
110
|
+
: `{{'${id}'${curForNodes.map((forNodeId) => `+ '-' + ${wxmlDataPrefix.forIndex}${forNodeId}`).join('')}}}`;
|
|
116
111
|
if (tagName === 'slot') {
|
|
117
112
|
const slotNode = {
|
|
118
113
|
type: 'element',
|
|
119
114
|
name: tagName,
|
|
120
115
|
attributes: {
|
|
121
|
-
name: data0.name.type && data0.name.type !== 'static'
|
|
122
|
-
? `{{${id}.name}}`
|
|
123
|
-
: data0.name.value,
|
|
116
|
+
name: data0.name.type && data0.name.type !== 'static' ? `{{${id}.name}}` : data0.name.value,
|
|
124
117
|
},
|
|
125
118
|
elements: [],
|
|
126
119
|
_order: xIndex || 0,
|
|
@@ -206,8 +199,7 @@ function generateWxml(widgets, docTag, wxmlDataPrefix, ctx, usingComponents, com
|
|
|
206
199
|
listeners.forEach((l) => {
|
|
207
200
|
const evtName = getMpEventName(l.trigger);
|
|
208
201
|
const modifiers = l;
|
|
209
|
-
node.attributes[getMpEventAttr(evtName, modifiers, tagName)] =
|
|
210
|
-
getMpEventHanlderName(id, evtName, modifiers);
|
|
202
|
+
node.attributes[getMpEventAttr(evtName, modifiers, tagName)] = getMpEventHanlderName(id, evtName, modifiers);
|
|
211
203
|
});
|
|
212
204
|
// 扩展组件配置
|
|
213
205
|
const compConfig = componentProto.compConfig;
|
|
@@ -240,9 +232,7 @@ function generateWxml(widgets, docTag, wxmlDataPrefix, ctx, usingComponents, com
|
|
|
240
232
|
}*/
|
|
241
233
|
node.elements = node.elements.concat(createXml(properties, node, curForNodes));
|
|
242
234
|
// 特殊处理 swiper,对swiper 子节点包裹议程 swiperItem
|
|
243
|
-
if (tagName === 'swiper' ||
|
|
244
|
-
componentKey === 'weda:Swiper' ||
|
|
245
|
-
componentKey === 'gsd-h5-react:Swiper') {
|
|
235
|
+
if (tagName === 'swiper' || componentKey === 'weda:Swiper' || componentKey === 'gsd-h5-react:Swiper') {
|
|
246
236
|
node.elements = node.elements.map((item, index) => {
|
|
247
237
|
var _a, _b;
|
|
248
238
|
let { ['wx:for']: wxFor, ['wx:for-index']: wxForIndex, ['wx:key']: wxKey, ['wx:if']: wxIf, ...itemRestKey } = item.attributes || {};
|
|
@@ -362,10 +352,8 @@ function getUsedComponents(widgets, usedCmps = {}) {
|
|
|
362
352
|
exports.getUsedComponents = getUsedComponents;
|
|
363
353
|
function getAttrBind(dVale, widgetBind, isStaticResource) {
|
|
364
354
|
const { type, value } = dVale;
|
|
365
|
-
const attrVal =
|
|
366
|
-
return isStaticResource
|
|
367
|
-
? `{{wxsUtils._getStaticResourceAttribute(${attrVal})}}`
|
|
368
|
-
: `{{${attrVal}}}`;
|
|
355
|
+
const attrVal = widgetBind;
|
|
356
|
+
return isStaticResource ? `{{wxsUtils._getStaticResourceAttribute(${attrVal})}}` : `{{${attrVal}}}`;
|
|
369
357
|
}
|
|
370
358
|
function getGenericCompTagName(propName) {
|
|
371
359
|
return `g--${propName}`;
|
|
@@ -404,7 +392,5 @@ function isGlobalAttr(prop = '') {
|
|
|
404
392
|
'title',
|
|
405
393
|
'translate',
|
|
406
394
|
];
|
|
407
|
-
return
|
|
408
|
-
prop.startsWith('data-') ||
|
|
409
|
-
prop.startsWith('aria-'));
|
|
395
|
+
return globalAttrs.indexOf(prop) > -1 || prop.startsWith('data-') || prop.startsWith('aria-');
|
|
410
396
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.24",
|
|
4
4
|
"description": "云开发 Tencent CloudBase Framework Low Code Plugin,将低码配置生成完整项目并一键部署云开发资源。",
|
|
5
5
|
"author": "yhsunshining@gmail.com",
|
|
6
6
|
"homepage": "https://github.com/TencentCloudBase/cloudbase-framework#readme",
|
|
@@ -5,7 +5,7 @@ import mergeRenderer from './merge-renderer'
|
|
|
5
5
|
import { runWatchers } from './watch'
|
|
6
6
|
import sdk from './weapp-sdk'
|
|
7
7
|
import lodashGet from 'lodash.get';
|
|
8
|
-
import {
|
|
8
|
+
import { createInitData } from './widget';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Lowcodes of all components
|
|
@@ -13,11 +13,7 @@ import { resolveWidgetData } from './widget';
|
|
|
13
13
|
export const compLowcodes = {}
|
|
14
14
|
|
|
15
15
|
export function createComponent(key, behaviors, properties, events, handler, dataBinds, evtListeners, widgetProps, index, lifeCycle, stateFn, computedFuncs, config, libCommonRes, undefined, context) {
|
|
16
|
-
const initData =
|
|
17
|
-
for (const id in widgetProps) {
|
|
18
|
-
const props = widgetProps[id]
|
|
19
|
-
initData['' + id] = resolveWidgetData(props)
|
|
20
|
-
}
|
|
16
|
+
const initData = createInitData(widgetProps, dataBinds, '');
|
|
21
17
|
compLowcodes[key] = {
|
|
22
18
|
index,
|
|
23
19
|
stateFn,
|
|
@@ -303,6 +303,8 @@ export function createInitData(widgets, dataBinds, keyPrefix = '') {
|
|
|
303
303
|
return Object.keys(widgets).reduce((result, id) => {
|
|
304
304
|
if (!isWidgetInFor(id, widgets, dataBinds)) {
|
|
305
305
|
result[keyPrefix + id] = resolveWidgetData(widgets[id])
|
|
306
|
+
} else {
|
|
307
|
+
result[keyPrefix + id] = []
|
|
306
308
|
}
|
|
307
309
|
return result
|
|
308
310
|
}, {})
|