@cloudbase/lowcode-builder 1.8.88 → 1.8.89
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.89",
|
|
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",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@babel/core": "7.21.4",
|
|
49
49
|
"@babel/preset-env": "7.21.4",
|
|
50
|
-
"@cloudbase/cals": "^1.0.
|
|
50
|
+
"@cloudbase/cals": "^1.0.71",
|
|
51
51
|
"@cloudbase/lowcode-generator": "^1.8.25",
|
|
52
52
|
"axios": "^0.21.0",
|
|
53
53
|
"browserfs": "^1.4.3",
|
|
@@ -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
|
|
7
|
+
import { createInitData } 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
|
|
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,7 +53,6 @@ export function createComponent(key, behaviors, properties={}, events, handler,
|
|
|
53
53
|
created() {
|
|
54
54
|
this._pageActive = true
|
|
55
55
|
this._disposers = []
|
|
56
|
-
this._nativeObserver = false
|
|
57
56
|
},
|
|
58
57
|
attached() {
|
|
59
58
|
const $comp = this._getInstance()
|
|
@@ -61,7 +60,7 @@ export function createComponent(key, behaviors, properties={}, events, handler,
|
|
|
61
60
|
$comp.__internal__.active = this._pageActive
|
|
62
61
|
|
|
63
62
|
$comp.props.events = createPropEvents(events, this)
|
|
64
|
-
const { widgets, rootWidget: virtualRootWidget } = createWidgets(widgetProps, dataBinds, this,
|
|
63
|
+
const { widgets, rootWidget: virtualRootWidget } = createWidgets(widgetProps, dataBinds, this, $comp.widgets)
|
|
65
64
|
$comp.widgets = widgets
|
|
66
65
|
this._virtualRootWidget = virtualRootWidget
|
|
67
66
|
|
|
@@ -99,7 +98,7 @@ export function createComponent(key, behaviors, properties={}, events, handler,
|
|
|
99
98
|
$comp.__internal__.active = this._pageActive
|
|
100
99
|
|
|
101
100
|
$comp.widgets = null
|
|
102
|
-
$comp.node._eventListeners
|
|
101
|
+
$comp.node._eventListeners.clear();
|
|
103
102
|
disposeWidget(this._virtualRootWidget)
|
|
104
103
|
this._disposers.forEach(dispose => dispose())
|
|
105
104
|
lifeCycle.onDetached && lifeCycle.onDetached.call($comp)
|
|
@@ -131,34 +130,19 @@ export function createComponent(key, behaviors, properties={}, events, handler,
|
|
|
131
130
|
...createEventHandlers(evtListeners, { looseError: true, isComposite: true }),
|
|
132
131
|
...mergeRenderer,
|
|
133
132
|
_getInstance() {
|
|
134
|
-
if
|
|
135
|
-
|
|
133
|
+
if(!this.$WEAPPS_COMP){
|
|
134
|
+
const widget = this.$node
|
|
136
135
|
if (!widget) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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
|
-
}
|
|
136
|
+
console.error('Fatal error: weapps component instance not created', this.is, this.id)
|
|
137
|
+
}else {
|
|
138
|
+
widget.getDom = (fields) => this._virtualRootWidget.children[0].getDom(fields)
|
|
139
|
+
this.$WEAPPS_COMP = create$comp(widget)
|
|
154
140
|
}
|
|
155
|
-
widget.getDom = (fields) => this._virtualRootWidget.children[0].getDom(fields)
|
|
156
|
-
this.$WEAPPS_COMP = create$comp(widget)
|
|
157
141
|
}
|
|
158
142
|
return this.$WEAPPS_COMP
|
|
159
143
|
},
|
|
160
144
|
},
|
|
161
|
-
observers: createObservers(Object.keys(properties))
|
|
145
|
+
// observers: createObservers(Object.keys(properties))
|
|
162
146
|
})
|
|
163
147
|
}
|
|
164
148
|
|
|
@@ -168,6 +152,7 @@ export function create$comp(w) {
|
|
|
168
152
|
if (!lowcode) {
|
|
169
153
|
return
|
|
170
154
|
}
|
|
155
|
+
const libCode = w.widgetType.split(':')[0]
|
|
171
156
|
const { stateFn, computedFuncs, handler, lib } = lowcode
|
|
172
157
|
|
|
173
158
|
const $comp = {
|
|
@@ -176,15 +161,21 @@ export function create$comp(w) {
|
|
|
176
161
|
state: {},
|
|
177
162
|
computed: {},
|
|
178
163
|
widgets: {},
|
|
179
|
-
node: w
|
|
164
|
+
node: w,
|
|
180
165
|
props: {
|
|
181
|
-
data: w
|
|
166
|
+
data: w,
|
|
182
167
|
events: {},
|
|
183
168
|
get style() { return w.style },
|
|
184
169
|
get classList() { return w.classList },
|
|
185
170
|
},
|
|
186
171
|
handler: {},
|
|
187
|
-
lib
|
|
172
|
+
lib,
|
|
173
|
+
// i18n: {
|
|
174
|
+
// t(key, data) {
|
|
175
|
+
// const ns = libCode;
|
|
176
|
+
// return sdk.i18n.t(`${ns}:${key}`, data)
|
|
177
|
+
// },
|
|
178
|
+
// }
|
|
188
179
|
}
|
|
189
180
|
$comp.$WEAPPS_COMP = $comp // TODO $comp will replaced to this.$WEAPPS_COMP
|
|
190
181
|
$comp.computed = createComputed(computedFuncs, $comp)
|
|
@@ -199,7 +190,7 @@ export function create$comp(w) {
|
|
|
199
190
|
baseAPI,
|
|
200
191
|
{
|
|
201
192
|
get(target, prop) {
|
|
202
|
-
if
|
|
193
|
+
if(prop === '$comp'){
|
|
203
194
|
return $comp
|
|
204
195
|
}
|
|
205
196
|
// 尝试代理组件级别组件实例
|
|
@@ -216,29 +207,13 @@ export function create$comp(w) {
|
|
|
216
207
|
}
|
|
217
208
|
|
|
218
209
|
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
|
-
}
|
|
227
210
|
return props.reduce((observers, prop) => {
|
|
228
|
-
observers[prop] = function (
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
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
|
-
// }
|
|
211
|
+
observers[prop] = function (newVal) {
|
|
212
|
+
const data = this._getInstance().props.data
|
|
213
|
+
if (!deepEqual(data[prop], newVal)) {
|
|
214
|
+
data[prop] = newVal
|
|
215
|
+
} else {
|
|
216
|
+
// console.log('Same comp prop will not trigger observer', prop, newVal)
|
|
242
217
|
}
|
|
243
218
|
}
|
|
244
219
|
return observers
|
|
@@ -281,7 +256,7 @@ function createPropEvents(events, mpInst) {
|
|
|
281
256
|
mpInst.setData({ value: evt.getValueFromEvent({ detail: evtDetail }) })
|
|
282
257
|
}
|
|
283
258
|
mpInst.triggerEvent(evt.name, evtDetail)
|
|
284
|
-
mpInst._getInstance().node
|
|
259
|
+
mpInst._getInstance().node._eventListeners.emit(evt.name, evtDetail)
|
|
285
260
|
}
|
|
286
261
|
}
|
|
287
262
|
})
|
|
@@ -377,7 +377,7 @@ function runFor(curForNode, dataBinds, ownerMpInst, forContext, ownerForWidgetHo
|
|
|
377
377
|
return dispose;
|
|
378
378
|
}
|
|
379
379
|
|
|
380
|
-
|
|
380
|
+
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}`;
|