@cloudbase/lowcode-builder 1.8.17 → 1.8.18
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/dist/builder.web.js +21 -13
- package/lib/builder/h5/webpack.js +1 -1
- package/lib/builder/types/common.d.ts +1 -1
- package/lib/builder/util/common.d.ts +1 -1
- package/lib/builder.web.js +21 -13
- package/package.json +3 -3
- package/template/html/index.html.ejs +2 -2
- package/template/mp/app.js +1 -1
- package/template/mp/common/flow.js +8 -6
- package/template/mp/common/query.js +72 -55
- package/template/mp/common/weapp-page.js +8 -4
- package/template/mp/package.json +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.18",
|
|
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",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"url": "https://github.com/TencentCloudBase/cloudbase-framework/issues"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@cloudbase/cals": "^1.0.
|
|
42
|
-
"@cloudbase/lowcode-generator": "^1.8.
|
|
41
|
+
"@cloudbase/cals": "^1.0.14",
|
|
42
|
+
"@cloudbase/lowcode-generator": "^1.8.8",
|
|
43
43
|
"axios": "^0.21.0",
|
|
44
44
|
"browserfs": "^1.4.3",
|
|
45
45
|
"browserify-zlib": "^0.2.0",
|
|
@@ -525,7 +525,7 @@
|
|
|
525
525
|
crossorigin="anonymous"
|
|
526
526
|
src="<%=
|
|
527
527
|
cdnEndpoints.cdngo
|
|
528
|
-
%>/lcap/lcap-resource-cdngo/-/release/_npm/@cloudbase/weda-cloud-sdk@1.0.
|
|
528
|
+
%>/lcap/lcap-resource-cdngo/-/release/_npm/@cloudbase/weda-cloud-sdk@1.0.39/dist/h5.browser.js"
|
|
529
529
|
></script>
|
|
530
530
|
<script
|
|
531
531
|
crossorigin
|
|
@@ -551,7 +551,7 @@
|
|
|
551
551
|
crossorigin
|
|
552
552
|
src="<%=
|
|
553
553
|
cdnEndpoints.cdngo
|
|
554
|
-
%>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.
|
|
554
|
+
%>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.8bdf2bc04fec833b06b7.bundle.js"
|
|
555
555
|
></script>
|
|
556
556
|
</body>
|
|
557
557
|
</html>
|
package/template/mp/app.js
CHANGED
|
@@ -99,7 +99,7 @@ App({
|
|
|
99
99
|
this.globaldata._beforeCustomLaunchPromise = new Promise(async (resolve)=>{
|
|
100
100
|
try {
|
|
101
101
|
EXTRA_API.setParams('$global', query || {})
|
|
102
|
-
await createStateDataSourceVar('$global', generateParamsParser({ app, $page: {} }));
|
|
102
|
+
await createStateDataSourceVar('$global', generateParamsParser({ app, $page: {}, $w: app.__internal__?.$w }));
|
|
103
103
|
} catch (e) {
|
|
104
104
|
throw e;
|
|
105
105
|
} finally {
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { createEventHandlers, getMpEventHandlerName } from './util';
|
|
2
2
|
import { Event } from './event-emitter';
|
|
3
3
|
export class EventFlow {
|
|
4
|
+
#eventHandlerMap = {};
|
|
5
|
+
#context = {}
|
|
4
6
|
constructor({ schema, context, options }) {
|
|
5
|
-
this
|
|
6
|
-
this
|
|
7
|
+
this.#eventHandlerMap = {};
|
|
8
|
+
this.#context = context;
|
|
7
9
|
const { id, description, eventHandlers = {} } = schema || {};
|
|
8
10
|
this.id = id || '';
|
|
9
11
|
this.description = description || '';
|
|
10
|
-
this
|
|
12
|
+
this.#eventHandlerMap = Object.entries(
|
|
11
13
|
createEventHandlers(eventHandlers, {
|
|
12
14
|
looseError: true,
|
|
13
15
|
isComposite: options?.isComposite || false,
|
|
@@ -19,19 +21,19 @@ export class EventFlow {
|
|
|
19
21
|
return map;
|
|
20
22
|
},
|
|
21
23
|
{
|
|
22
|
-
_getInstance: () => this
|
|
24
|
+
_getInstance: () => this.#context.$page || this.#context.$app,
|
|
23
25
|
},
|
|
24
26
|
);
|
|
25
27
|
return this;
|
|
26
28
|
}
|
|
27
29
|
trigger(additionalScope, options = {}) {
|
|
28
30
|
const mergedContext = {
|
|
29
|
-
...this
|
|
31
|
+
...this.#context,
|
|
30
32
|
...options,
|
|
31
33
|
};
|
|
32
34
|
const { target } = mergedContext;
|
|
33
35
|
const eventName = `${this.id}.start`;
|
|
34
|
-
return this
|
|
36
|
+
return this.#eventHandlerMap[getMpEventHandlerName(this.id, eventName)](
|
|
35
37
|
new Event({
|
|
36
38
|
type: eventName,
|
|
37
39
|
detail: additionalScope,
|
|
@@ -3,25 +3,32 @@ import { createEventHandlers, getMpEventHandlerName, mergeDynamic2StaticData } f
|
|
|
3
3
|
import { Event } from './event-emitter';
|
|
4
4
|
|
|
5
5
|
export class Query {
|
|
6
|
+
_schema = {}
|
|
7
|
+
#schema
|
|
8
|
+
#context = {};
|
|
9
|
+
#disposes = [];
|
|
10
|
+
#dataBinds = {};
|
|
11
|
+
#triggered = false;
|
|
12
|
+
#paramsRef = observable({ current: null });
|
|
13
|
+
#currentRequestKey = null;
|
|
14
|
+
#observableValue = observable({ data: null, error: null });
|
|
15
|
+
#eventHandlerMap = {};
|
|
16
|
+
#action = () => {};
|
|
6
17
|
constructor({ schema, context, options = {} }) {
|
|
7
|
-
this._disposes = [];
|
|
8
|
-
this._dataBinds = {};
|
|
9
|
-
this._triggered = false;
|
|
10
|
-
this._paramsRef = observable({ current: null });
|
|
11
|
-
this._currentRequestKey = null;
|
|
12
|
-
this._observableValue = observable({ data: null, error: null });
|
|
13
|
-
this._eventHandlerMap = {};
|
|
14
18
|
const { looseError = false } = options;
|
|
15
|
-
this
|
|
16
|
-
this.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
this.#schema = schema;
|
|
20
|
+
this._schema = {
|
|
21
|
+
trigger: schema.trigger
|
|
22
|
+
}
|
|
23
|
+
this.#context = context;
|
|
24
|
+
if (this.#schema?.trigger === 'auto') {
|
|
25
|
+
this.#disposes.push(
|
|
19
26
|
autorun(
|
|
20
27
|
(r) => {
|
|
21
28
|
try {
|
|
22
|
-
const data = this
|
|
23
|
-
if (this
|
|
24
|
-
this
|
|
29
|
+
const data = this.#resolveParams();
|
|
30
|
+
if (this.#triggered) {
|
|
31
|
+
this.#debounceTrigger(data);
|
|
25
32
|
}
|
|
26
33
|
} catch (e) {
|
|
27
34
|
console.error(e);
|
|
@@ -31,18 +38,18 @@ export class Query {
|
|
|
31
38
|
),
|
|
32
39
|
);
|
|
33
40
|
}
|
|
34
|
-
this.
|
|
35
|
-
this
|
|
41
|
+
this.#paramsRef.current = this.#schema.data;
|
|
42
|
+
this.#dataBinds = Object.entries(this.#schema.dataBinds || {}).reduce((map, [prop, fn]) => {
|
|
36
43
|
if (!/[\s+\-*/!&|%]*?SERVER\./.test(prop)) {
|
|
37
44
|
map[prop] = fn;
|
|
38
45
|
}
|
|
39
46
|
return map;
|
|
40
47
|
}, {});
|
|
41
48
|
|
|
42
|
-
const { $w } = this
|
|
49
|
+
const { $w } = this.#context;
|
|
43
50
|
|
|
44
|
-
this
|
|
45
|
-
this.
|
|
51
|
+
this.#action =
|
|
52
|
+
this.#schema.type === 'sql'
|
|
46
53
|
? async function (data) {
|
|
47
54
|
const Data = await $w.cloud.callWedaApi({
|
|
48
55
|
action: 'RunPluginQuery',
|
|
@@ -96,9 +103,9 @@ export class Query {
|
|
|
96
103
|
total: Total || ExecuteResultList.length,
|
|
97
104
|
};
|
|
98
105
|
}
|
|
99
|
-
: this.
|
|
100
|
-
this
|
|
101
|
-
createEventHandlers(this.
|
|
106
|
+
: this.#schema.handler;
|
|
107
|
+
this.#eventHandlerMap = Object.entries(
|
|
108
|
+
createEventHandlers(this.#schema.eventHandlers || {}, {
|
|
102
109
|
looseError: looseError,
|
|
103
110
|
isComposite: false,
|
|
104
111
|
}),
|
|
@@ -109,84 +116,94 @@ export class Query {
|
|
|
109
116
|
return map;
|
|
110
117
|
},
|
|
111
118
|
{
|
|
112
|
-
_getInstance: () => this
|
|
119
|
+
_getInstance: () => this.#context.$page || this.#context.$app,
|
|
113
120
|
},
|
|
114
121
|
);
|
|
115
122
|
return this;
|
|
116
123
|
}
|
|
117
124
|
get id() {
|
|
118
|
-
return this
|
|
125
|
+
return this.#schema?.id || '';
|
|
119
126
|
}
|
|
120
127
|
get label() {
|
|
121
|
-
return this
|
|
128
|
+
return this.#schema?.label || '';
|
|
122
129
|
}
|
|
123
130
|
get description() {
|
|
124
|
-
return this
|
|
131
|
+
return this.#schema?.description || '';
|
|
125
132
|
}
|
|
126
133
|
get data() {
|
|
127
|
-
return this.
|
|
134
|
+
return this.#observableValue.data;
|
|
128
135
|
}
|
|
129
136
|
get error() {
|
|
130
|
-
return this.
|
|
137
|
+
return this.#observableValue.error;
|
|
131
138
|
}
|
|
132
139
|
async trigger(additionalScope, options = {}) {
|
|
133
|
-
this
|
|
134
|
-
return this
|
|
140
|
+
this.#triggered = true;
|
|
141
|
+
return this.#innerTrigger(this.#resolveParams(), additionalScope, options);
|
|
135
142
|
}
|
|
136
143
|
reset() {
|
|
137
|
-
this.
|
|
138
|
-
this.
|
|
144
|
+
this.#observableValue.data = null;
|
|
145
|
+
this.#observableValue.error = null;
|
|
146
|
+
}
|
|
147
|
+
destroy() {
|
|
148
|
+
this.#disposes.forEach((dispose) => dispose());
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* 用于调试
|
|
153
|
+
*/
|
|
154
|
+
_toSchema() {
|
|
155
|
+
console.warn('调试使用,结构可能发生更改,请不要用于生产环境');
|
|
156
|
+
return this.#schema;
|
|
139
157
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
158
|
+
|
|
159
|
+
async #innerTrigger(data, additionalScope, options = {}) {
|
|
160
|
+
this.#currentRequestKey = Date.now();
|
|
161
|
+
const key = this.#currentRequestKey;
|
|
143
162
|
try {
|
|
144
|
-
const res = await this
|
|
145
|
-
if (key === this
|
|
146
|
-
this.
|
|
147
|
-
this.
|
|
148
|
-
this
|
|
163
|
+
const res = await this.#action(data);
|
|
164
|
+
if (key === this.#currentRequestKey) {
|
|
165
|
+
this.#observableValue.data = res;
|
|
166
|
+
this.#observableValue.error = null;
|
|
167
|
+
this.#emit(`success`, res);
|
|
149
168
|
}
|
|
150
169
|
return res;
|
|
151
170
|
} catch (e) {
|
|
152
|
-
if (key === this
|
|
153
|
-
this.
|
|
154
|
-
this.
|
|
155
|
-
this
|
|
171
|
+
if (key === this.#currentRequestKey) {
|
|
172
|
+
this.#observableValue.data = null;
|
|
173
|
+
this.#observableValue.error = e;
|
|
174
|
+
this.#emit(`fail`, e);
|
|
156
175
|
}
|
|
157
176
|
throw e;
|
|
158
177
|
}
|
|
159
178
|
}
|
|
160
|
-
|
|
179
|
+
#debounceTrigger(...args) {
|
|
161
180
|
if (this._timer) {
|
|
162
181
|
clearTimeout(this._timer);
|
|
163
182
|
}
|
|
164
183
|
this._timer = setTimeout(() => {
|
|
165
|
-
this
|
|
184
|
+
this.#innerTrigger(...args);
|
|
166
185
|
}, 300);
|
|
167
186
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
_resolveParams() {
|
|
187
|
+
|
|
188
|
+
#resolveParams() {
|
|
172
189
|
/**
|
|
173
190
|
* 这里万一其中某个字段计算失败
|
|
174
191
|
* 好像会阻塞其他字段的计算
|
|
175
192
|
* 从而导致 autorun 没有添加依赖
|
|
176
193
|
*/
|
|
177
|
-
return mergeDynamic2StaticData(toJS(this.
|
|
194
|
+
return mergeDynamic2StaticData(toJS(this.#paramsRef.current), this.#dataBinds, {
|
|
178
195
|
codeContext: {
|
|
179
196
|
/**
|
|
180
197
|
* $page 或 $comp 实例
|
|
181
198
|
*/
|
|
182
|
-
instance: this
|
|
199
|
+
instance: this.#context.$page,
|
|
183
200
|
},
|
|
184
|
-
$w: this
|
|
201
|
+
$w: this.#context.$w,
|
|
185
202
|
// may be additional scope
|
|
186
203
|
});
|
|
187
204
|
}
|
|
188
|
-
async
|
|
189
|
-
return this
|
|
205
|
+
async #emit(eventName, data) {
|
|
206
|
+
return this.#eventHandlerMap[getMpEventHandlerName(this.id, eventName)]?.(
|
|
190
207
|
new Event({
|
|
191
208
|
type: eventName,
|
|
192
209
|
detail: data,
|
|
@@ -53,7 +53,7 @@ export function createPage({
|
|
|
53
53
|
(params ? '?' + params.map((pair) => pair.key + '=' + pair.value).join('&') : '');
|
|
54
54
|
return {
|
|
55
55
|
path: realPath,
|
|
56
|
-
imageUrl,
|
|
56
|
+
imageUrl: app?.__internal__?.resolveStaticResourceUrl?.(imageUrl) || imageUrl,
|
|
57
57
|
title,
|
|
58
58
|
};
|
|
59
59
|
}
|
|
@@ -153,7 +153,7 @@ export function createPage({
|
|
|
153
153
|
this.setData({
|
|
154
154
|
weDaHasLogin: true,
|
|
155
155
|
});
|
|
156
|
-
createStateDataSourceVar($page.uuid, generateParamsParser({ app, $page }));
|
|
156
|
+
createStateDataSourceVar($page.uuid, generateParamsParser({ app, $page, $w: $page.__internal__?.$w }));
|
|
157
157
|
}
|
|
158
158
|
} finally {
|
|
159
159
|
this.setData({ _isCheckingAtuh: false })
|
|
@@ -198,7 +198,7 @@ export function createPage({
|
|
|
198
198
|
const hook = lifecycle.onReady || lifecycle.onPageReady;
|
|
199
199
|
await hook?.call?.($page);
|
|
200
200
|
|
|
201
|
-
this._invokeEventHandler(
|
|
201
|
+
this._invokeEventHandler('ready');
|
|
202
202
|
},
|
|
203
203
|
onUnload() {
|
|
204
204
|
const $page = this._getInstance();
|
|
@@ -253,7 +253,11 @@ export function createPage({
|
|
|
253
253
|
$page = pageContext;
|
|
254
254
|
this.$WEAPPS_PAGE = $page;
|
|
255
255
|
$page.handler = Object.keys(handlers).reduce((result, key) => {
|
|
256
|
-
|
|
256
|
+
try {
|
|
257
|
+
result[key] = handlers[key].bind($page);
|
|
258
|
+
} catch(e) {
|
|
259
|
+
console.error('添加页面handler失败', e)
|
|
260
|
+
}
|
|
257
261
|
return result;
|
|
258
262
|
}, {});
|
|
259
263
|
$page.computed = createComputed(computed, $page);
|
package/template/mp/package.json
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
"@cloudbase/js-sdk": "2.5.6-beta.1",<%
|
|
7
7
|
} %>
|
|
8
8
|
"@cloudbase/oauth": "0.1.1-alpha.5",
|
|
9
|
-
"@cloudbase/weda-client": "1.0.
|
|
10
|
-
"@cloudbase/weda-cloud-sdk": "1.0.
|
|
9
|
+
"@cloudbase/weda-client": "1.0.5",
|
|
10
|
+
"@cloudbase/weda-cloud-sdk": "1.0.40",
|
|
11
11
|
"mobx": "^5.15.4",
|
|
12
12
|
"lodash.get": "^4.4.2",
|
|
13
13
|
"lodash.set": "^4.3.2",
|