@cloudbase/lowcode-builder 1.8.89 → 1.8.91
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/index.js +33 -17
- package/lib/builder/mp/mp_config.js +1 -1
- package/lib/builder.web.js +2 -2
- package/package.json +1 -1
- package/template/html/index.html.ejs +1 -1
- package/template/mp/common/weapp-component.js +54 -29
- package/template/mp/common/widget.js +1 -1
- package/template/mp/package.json +1 -1
- package/template/mp/packages/$wd_system/pages/login/methods/loginByWXPhone.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.91",
|
|
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",
|
|
@@ -545,7 +545,7 @@
|
|
|
545
545
|
crossorigin
|
|
546
546
|
src="<%=
|
|
547
547
|
cdnEndpoints.cdngo
|
|
548
|
-
%>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.
|
|
548
|
+
%>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.7b502f20fb4429d008f11.bundle.js"
|
|
549
549
|
></script>
|
|
550
550
|
</body>
|
|
551
551
|
</html>
|
|
@@ -4,7 +4,7 @@ import { createWidgets, getWidget, disposeWidget } from './widget'
|
|
|
4
4
|
import mergeRenderer from './merge-renderer'
|
|
5
5
|
import { runWatchers } from './watch'
|
|
6
6
|
import lodashGet from 'lodash.get';
|
|
7
|
-
import { createInitData } from './widget';
|
|
7
|
+
import { createInitData, createWidget } from './widget';
|
|
8
8
|
import { commonCompBehavior } from '@cloudbase/weda-client';
|
|
9
9
|
import { $w as baseAPI } from '../app/weapps-api'
|
|
10
10
|
|
|
@@ -13,7 +13,7 @@ import { $w as baseAPI } from '../app/weapps-api'
|
|
|
13
13
|
*/
|
|
14
14
|
export const compLowcodes = {}
|
|
15
15
|
|
|
16
|
-
export function createComponent(key, behaviors, properties, events, handler, dataBinds, evtListeners, widgetProps, index, lifeCycle, stateFn, computedFuncs, config, libCommonRes, libCode) {
|
|
16
|
+
export function createComponent(key, behaviors, properties={}, events, handler, dataBinds, evtListeners, widgetProps, index, lifeCycle, stateFn, computedFuncs, config, libCommonRes, libCode) {
|
|
17
17
|
widgetProps = patchWdigetPropsWithEvtListeners(widgetProps, evtListeners)
|
|
18
18
|
|
|
19
19
|
compLowcodes[key] = {
|
|
@@ -53,6 +53,7 @@ export function createComponent(key, behaviors, properties, events, handler, dat
|
|
|
53
53
|
created() {
|
|
54
54
|
this._pageActive = true
|
|
55
55
|
this._disposers = []
|
|
56
|
+
this._nativeObserver = false
|
|
56
57
|
},
|
|
57
58
|
attached() {
|
|
58
59
|
const $comp = this._getInstance()
|
|
@@ -60,7 +61,7 @@ export function createComponent(key, behaviors, properties, events, handler, dat
|
|
|
60
61
|
$comp.__internal__.active = this._pageActive
|
|
61
62
|
|
|
62
63
|
$comp.props.events = createPropEvents(events, this)
|
|
63
|
-
const { widgets, rootWidget: virtualRootWidget } = createWidgets(widgetProps, dataBinds, this,
|
|
64
|
+
const { widgets, rootWidget: virtualRootWidget } = createWidgets(widgetProps, dataBinds, this, $comp.widgets)
|
|
64
65
|
$comp.widgets = widgets
|
|
65
66
|
this._virtualRootWidget = virtualRootWidget
|
|
66
67
|
|
|
@@ -98,7 +99,7 @@ export function createComponent(key, behaviors, properties, events, handler, dat
|
|
|
98
99
|
$comp.__internal__.active = this._pageActive
|
|
99
100
|
|
|
100
101
|
$comp.widgets = null
|
|
101
|
-
$comp.node._eventListeners
|
|
102
|
+
$comp.node._eventListeners?.clear?.();
|
|
102
103
|
disposeWidget(this._virtualRootWidget)
|
|
103
104
|
this._disposers.forEach(dispose => dispose())
|
|
104
105
|
lifeCycle.onDetached && lifeCycle.onDetached.call($comp)
|
|
@@ -130,19 +131,34 @@ export function createComponent(key, behaviors, properties, events, handler, dat
|
|
|
130
131
|
...createEventHandlers(evtListeners, { looseError: true, isComposite: true }),
|
|
131
132
|
...mergeRenderer,
|
|
132
133
|
_getInstance() {
|
|
133
|
-
if(!this.$WEAPPS_COMP){
|
|
134
|
-
|
|
134
|
+
if (!this.$WEAPPS_COMP) {
|
|
135
|
+
let widget = this.$node
|
|
135
136
|
if (!widget) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
if(this.selectOwnerComponent && !this.selectOwnerComponent?.()) {
|
|
138
|
+
const widgetValue = {}
|
|
139
|
+
for (const key in properties) {
|
|
140
|
+
if (properties[key]?.value !== undefined) {
|
|
141
|
+
widgetValue[key] = properties[key]?.value
|
|
142
|
+
}
|
|
143
|
+
if (this.data[key] !== undefined) {
|
|
144
|
+
widgetValue[key] = this.data[key]
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
this.$node = createWidget({ widgetType: key, ...widgetValue }, this.id || `id${Date.now()}`, '', undefined, {})
|
|
148
|
+
widget = this.$node
|
|
149
|
+
this._nativeObserver = true;
|
|
150
|
+
} else {
|
|
151
|
+
console.error('Fatal error: weapps component instance not created', this.is, this.id);
|
|
152
|
+
return
|
|
153
|
+
}
|
|
140
154
|
}
|
|
155
|
+
widget.getDom = (fields) => this._virtualRootWidget.children[0].getDom(fields)
|
|
156
|
+
this.$WEAPPS_COMP = create$comp(widget)
|
|
141
157
|
}
|
|
142
158
|
return this.$WEAPPS_COMP
|
|
143
159
|
},
|
|
144
160
|
},
|
|
145
|
-
|
|
161
|
+
observers: createObservers(Object.keys(properties))
|
|
146
162
|
})
|
|
147
163
|
}
|
|
148
164
|
|
|
@@ -152,7 +168,6 @@ export function create$comp(w) {
|
|
|
152
168
|
if (!lowcode) {
|
|
153
169
|
return
|
|
154
170
|
}
|
|
155
|
-
const libCode = w.widgetType.split(':')[0]
|
|
156
171
|
const { stateFn, computedFuncs, handler, lib } = lowcode
|
|
157
172
|
|
|
158
173
|
const $comp = {
|
|
@@ -161,21 +176,15 @@ export function create$comp(w) {
|
|
|
161
176
|
state: {},
|
|
162
177
|
computed: {},
|
|
163
178
|
widgets: {},
|
|
164
|
-
node: w,
|
|
179
|
+
node: w || {},
|
|
165
180
|
props: {
|
|
166
|
-
data: w,
|
|
181
|
+
data: w || {},
|
|
167
182
|
events: {},
|
|
168
183
|
get style() { return w.style },
|
|
169
184
|
get classList() { return w.classList },
|
|
170
185
|
},
|
|
171
186
|
handler: {},
|
|
172
|
-
lib
|
|
173
|
-
// i18n: {
|
|
174
|
-
// t(key, data) {
|
|
175
|
-
// const ns = libCode;
|
|
176
|
-
// return sdk.i18n.t(`${ns}:${key}`, data)
|
|
177
|
-
// },
|
|
178
|
-
// }
|
|
187
|
+
lib
|
|
179
188
|
}
|
|
180
189
|
$comp.$WEAPPS_COMP = $comp // TODO $comp will replaced to this.$WEAPPS_COMP
|
|
181
190
|
$comp.computed = createComputed(computedFuncs, $comp)
|
|
@@ -190,7 +199,7 @@ export function create$comp(w) {
|
|
|
190
199
|
baseAPI,
|
|
191
200
|
{
|
|
192
201
|
get(target, prop) {
|
|
193
|
-
if(prop === '$comp'){
|
|
202
|
+
if (prop === '$comp') {
|
|
194
203
|
return $comp
|
|
195
204
|
}
|
|
196
205
|
// 尝试代理组件级别组件实例
|
|
@@ -207,13 +216,29 @@ export function create$comp(w) {
|
|
|
207
216
|
}
|
|
208
217
|
|
|
209
218
|
function createObservers(props) {
|
|
219
|
+
const MAP = {
|
|
220
|
+
className: {
|
|
221
|
+
alias: 'classList',
|
|
222
|
+
format: function(value='') {
|
|
223
|
+
return Array.from(new Set(value.split(' ').filter(item=>!!item)))
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
}
|
|
210
227
|
return props.reduce((observers, prop) => {
|
|
211
|
-
observers[prop] = function (
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
228
|
+
observers[prop] = function (value) {
|
|
229
|
+
if (!this._nativeObserver) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
const $comp = this._getInstance()
|
|
233
|
+
if ($comp) {
|
|
234
|
+
const data = $comp.props.data || {}
|
|
235
|
+
const dataKey = MAP[prop]?.alias || prop;
|
|
236
|
+
const formatValue = MAP[prop]?.format ? MAP[prop].format(value) : value;
|
|
237
|
+
// if (!deepEqual(data[prop], formatValue)) {
|
|
238
|
+
data[dataKey] = formatValue
|
|
239
|
+
// } else {
|
|
240
|
+
// // console.log(`Same comp prop will not trigger observer. ${prop}->${dataKey}`, formatValue)
|
|
241
|
+
// }
|
|
217
242
|
}
|
|
218
243
|
}
|
|
219
244
|
return observers
|
|
@@ -256,7 +281,7 @@ function createPropEvents(events, mpInst) {
|
|
|
256
281
|
mpInst.setData({ value: evt.getValueFromEvent({ detail: evtDetail }) })
|
|
257
282
|
}
|
|
258
283
|
mpInst.triggerEvent(evt.name, evtDetail)
|
|
259
|
-
mpInst._getInstance().node
|
|
284
|
+
mpInst._getInstance().node?._eventListeners?.emit?.(evt.name, evtDetail)
|
|
260
285
|
}
|
|
261
286
|
}
|
|
262
287
|
})
|
|
@@ -377,7 +377,7 @@ function runFor(curForNode, dataBinds, ownerMpInst, forContext, ownerForWidgetHo
|
|
|
377
377
|
return dispose;
|
|
378
378
|
}
|
|
379
379
|
|
|
380
|
-
function createWidget(props, nodeId, indexPostfix, parent, ownerMpInst, forContext) {
|
|
380
|
+
export function createWidget(props, nodeId, indexPostfix, parent, ownerMpInst, forContext) {
|
|
381
381
|
const { widgetType, _parentId, ...restProps } = props;
|
|
382
382
|
const w = observable(restProps);
|
|
383
383
|
const id = `${nodeId}${indexPostfix}`;
|
package/template/mp/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"dependencies": {<% if(importJSSDK) {%>
|
|
6
6
|
"@cloudbase/js-sdk": "2.5.6-beta.1",<% } %>
|
|
7
7
|
"@cloudbase/oauth": "0.1.1-alpha.5",
|
|
8
|
-
"@cloudbase/weda-client": "1.0.
|
|
8
|
+
"@cloudbase/weda-client": "1.0.25",
|
|
9
9
|
"@cloudbase/weda-cloud-sdk": "1.0.57",
|
|
10
10
|
"mobx": "^5.15.4",
|
|
11
11
|
"lodash.get": "^4.4.2",
|
|
@@ -25,7 +25,7 @@ export default async function (instance, { event }) {
|
|
|
25
25
|
});
|
|
26
26
|
const token = tokenRes?.token || tokenRes;
|
|
27
27
|
if (!token) {
|
|
28
|
-
throw new Error('
|
|
28
|
+
throw new Error('请在控制台检查小程序相关配置');
|
|
29
29
|
}
|
|
30
30
|
providerInfo.provider_id = 'weda';
|
|
31
31
|
providerInfo.provider_access_token = `${
|