@cloudbase/lowcode-builder 1.8.23 → 1.8.24-alpha.0
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 +7 -7
- package/lib/builder/config/index.d.ts +2 -2
- package/lib/builder/config/index.js +2 -2
- package/lib/builder/h5/index.d.ts +1 -5
- package/lib/builder/h5/index.js +5 -64
- package/lib/builder/h5/webpack.js +1 -1
- package/lib/builder/mp/index.js +7 -17
- package/lib/builder/mp/util.js +8 -11
- package/lib/builder/types/common.d.ts +1 -1
- package/lib/builder/util/common.d.ts +1 -1
- package/lib/builder/util/process.js +15 -12
- package/lib/builder.web.js +7 -7
- package/package.json +5 -4
- package/template/mp/app/weapps-api.js +1 -1
- package/template/mp/common/query.js +24 -9
- package/template/mp/common/util.js +4 -4
- package/template/mp/page/index.js +1 -1
- package/lib/utils/transform.d.ts +0 -3
- package/lib/utils/transform.js +0 -52
- package/template/.DS_Store +0 -0
- package/template/mp/.DS_Store +0 -0
- package/template/mp/common/.DS_Store +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.24-alpha.0",
|
|
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",
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
"build": "tsc",
|
|
32
32
|
"test": "jest",
|
|
33
33
|
"test:build": "ts-node ./__tests__/build.ts",
|
|
34
|
-
"dev:web": "rm -rf dist && node ./webpack/scripts/web.pre.js && cross-env NODE_ENV=development webpack-dev-server --config ./webpack/web.config.js",
|
|
34
|
+
"dev:web:serve": "rm -rf dist && node ./webpack/scripts/web.pre.js && cross-env NODE_ENV=development webpack-dev-server --config ./webpack/web.config.js",
|
|
35
|
+
"dev:web": "rm -rf dist && node ./webpack/scripts/web.pre.js && cross-env NODE_ENV=development webpack --config ./webpack/web.config.js && node ./webpack/scripts/web.post.js",
|
|
35
36
|
"build:web": "rm -rf dist && node ./webpack/scripts/web.pre.js && cross-env NODE_ENV=production webpack --config ./webpack/web.config.js && node ./webpack/scripts/web.post.js",
|
|
36
37
|
"build:template": "./scripts/buildTemplate.sh"
|
|
37
38
|
},
|
|
@@ -41,8 +42,8 @@
|
|
|
41
42
|
"dependencies": {
|
|
42
43
|
"@babel/core": "7.12.3",
|
|
43
44
|
"@babel/preset-env": "7.12.1",
|
|
44
|
-
"@cloudbase/cals": "
|
|
45
|
-
"@cloudbase/lowcode-generator": "
|
|
45
|
+
"@cloudbase/cals": "1.0.17",
|
|
46
|
+
"@cloudbase/lowcode-generator": "1.8.9",
|
|
46
47
|
"axios": "^0.21.0",
|
|
47
48
|
"browserfs": "^1.4.3",
|
|
48
49
|
"browserify-zlib": "^0.2.0",
|
|
@@ -22,7 +22,7 @@ const mainAppKey = '__weappsMainApp'
|
|
|
22
22
|
*/
|
|
23
23
|
const list = []
|
|
24
24
|
Object.entries(boundData).map(([prop, bindMeta])=>{
|
|
25
|
-
const str = `'${prop}': ($app, lists, forItems, event, $context, $w) => {${bindMeta.imports} return(
|
|
25
|
+
const str = `'${prop}': ($app, lists, forItems, event, $context, $w, params) => {${bindMeta.imports} return(
|
|
26
26
|
${bindMeta.expression === '' ? 'undefined': bindMeta.expression}
|
|
27
27
|
)}`
|
|
28
28
|
list.push(str)
|
|
@@ -3,23 +3,23 @@ import { createEventHandlers, getMpEventHandlerName, mergeDynamic2StaticData } f
|
|
|
3
3
|
import { Event } from './event-emitter';
|
|
4
4
|
|
|
5
5
|
export class Query {
|
|
6
|
-
_schema = {}
|
|
7
|
-
#schema
|
|
6
|
+
_schema = {};
|
|
7
|
+
#schema;
|
|
8
8
|
#context = {};
|
|
9
9
|
#disposes = [];
|
|
10
10
|
#dataBinds = {};
|
|
11
11
|
#triggered = false;
|
|
12
12
|
#paramsRef = observable({ current: null });
|
|
13
13
|
#currentRequestKey = null;
|
|
14
|
-
#observableValue = observable({ data: null, error: null });
|
|
14
|
+
#observableValue = observable({ data: null, error: null, isFetching: false });
|
|
15
15
|
#eventHandlerMap = {};
|
|
16
16
|
#action = () => {};
|
|
17
17
|
constructor({ schema, context, options = {} }) {
|
|
18
18
|
const { looseError = false } = options;
|
|
19
19
|
this.#schema = schema;
|
|
20
20
|
this._schema = {
|
|
21
|
-
trigger: schema.trigger
|
|
22
|
-
}
|
|
21
|
+
trigger: schema.trigger,
|
|
22
|
+
};
|
|
23
23
|
this.#context = context;
|
|
24
24
|
if (this.#schema?.trigger === 'auto') {
|
|
25
25
|
this.#disposes.push(
|
|
@@ -136,13 +136,17 @@ export class Query {
|
|
|
136
136
|
get error() {
|
|
137
137
|
return this.#observableValue.error;
|
|
138
138
|
}
|
|
139
|
+
get isFetching() {
|
|
140
|
+
return this.#observableValue.isFetching;
|
|
141
|
+
}
|
|
139
142
|
async trigger(additionalScope, options = {}) {
|
|
140
143
|
this.#triggered = true;
|
|
141
|
-
return this.#innerTrigger(this.#resolveParams(),
|
|
144
|
+
return this.#innerTrigger(this.#resolveParams(additionalScope), options);
|
|
142
145
|
}
|
|
143
146
|
reset() {
|
|
144
147
|
this.#observableValue.data = null;
|
|
145
148
|
this.#observableValue.error = null;
|
|
149
|
+
this.#observableValue.isFetching = false;
|
|
146
150
|
}
|
|
147
151
|
destroy() {
|
|
148
152
|
this.#disposes.forEach((dispose) => dispose());
|
|
@@ -156,12 +160,14 @@ export class Query {
|
|
|
156
160
|
return this.#schema;
|
|
157
161
|
}
|
|
158
162
|
|
|
159
|
-
async #innerTrigger(data,
|
|
163
|
+
async #innerTrigger(data, options = {}) {
|
|
160
164
|
this.#currentRequestKey = Date.now();
|
|
161
165
|
const key = this.#currentRequestKey;
|
|
162
166
|
try {
|
|
167
|
+
this.#observableValue.isFetching = true;
|
|
163
168
|
const res = await this.#action(data);
|
|
164
169
|
if (key === this.#currentRequestKey) {
|
|
170
|
+
this.#observableValue.isFetching = false;
|
|
165
171
|
this.#observableValue.data = res;
|
|
166
172
|
this.#observableValue.error = null;
|
|
167
173
|
this.#emit(`success`, res);
|
|
@@ -169,6 +175,7 @@ export class Query {
|
|
|
169
175
|
return res;
|
|
170
176
|
} catch (e) {
|
|
171
177
|
if (key === this.#currentRequestKey) {
|
|
178
|
+
this.#observableValue.isFetching = false;
|
|
172
179
|
this.#observableValue.data = null;
|
|
173
180
|
this.#observableValue.error = e;
|
|
174
181
|
this.#emit(`fail`, e);
|
|
@@ -185,7 +192,7 @@ export class Query {
|
|
|
185
192
|
}, 300);
|
|
186
193
|
}
|
|
187
194
|
|
|
188
|
-
#resolveParams() {
|
|
195
|
+
#resolveParams(additionalScope = {}) {
|
|
189
196
|
/**
|
|
190
197
|
* 这里万一其中某个字段计算失败
|
|
191
198
|
* 好像会阻塞其他字段的计算
|
|
@@ -199,7 +206,7 @@ export class Query {
|
|
|
199
206
|
instance: this.#context.$page,
|
|
200
207
|
},
|
|
201
208
|
$w: this.#context.$w,
|
|
202
|
-
|
|
209
|
+
paramsContext: additionalScope,
|
|
203
210
|
});
|
|
204
211
|
}
|
|
205
212
|
async #emit(eventName, data) {
|
|
@@ -212,6 +219,14 @@ export class Query {
|
|
|
212
219
|
}),
|
|
213
220
|
);
|
|
214
221
|
}
|
|
222
|
+
|
|
223
|
+
toJSON() {
|
|
224
|
+
const KEYS = ['id', 'label', 'description', 'data', 'error', 'isFetching', 'trigger', 'reset'];
|
|
225
|
+
return KEYS.reduce((obj, key) => {
|
|
226
|
+
obj[key] = this[key];
|
|
227
|
+
return obj;
|
|
228
|
+
}, {});
|
|
229
|
+
}
|
|
215
230
|
}
|
|
216
231
|
export function generateDatasetQuery(schema, context, options) {
|
|
217
232
|
const result = {};
|
|
@@ -9,7 +9,6 @@ export { generateEventFlows } from './flow';
|
|
|
9
9
|
import lodashGet from 'lodash.get';
|
|
10
10
|
import lodashSet from 'lodash.set';
|
|
11
11
|
|
|
12
|
-
|
|
13
12
|
/**
|
|
14
13
|
* Convert abcWordSnd -> abc-word-snd
|
|
15
14
|
*/
|
|
@@ -162,7 +161,7 @@ export function createEventHandlers(
|
|
|
162
161
|
}
|
|
163
162
|
} catch (e) {
|
|
164
163
|
if (e.message) {
|
|
165
|
-
e._target = `${currentTarget?.id || ''}[${trigger}:${l.key}]
|
|
164
|
+
e._target = `${currentTarget?.id || ''}[${trigger}:${l.key}]`;
|
|
166
165
|
}
|
|
167
166
|
nextEventHandles[0].handlerName = l.key ? `${prefix}$${l.key}_fail` : '';
|
|
168
167
|
nextEventHandles[0].event.detail = isIfAction ? event.detail : e;
|
|
@@ -238,7 +237,6 @@ function generateErrorDebugMessage(error) {
|
|
|
238
237
|
return `${error?._target ? `${error?._target}:` : ''}${error?.message || ''}`;
|
|
239
238
|
}
|
|
240
239
|
|
|
241
|
-
|
|
242
240
|
export function getDeep(target, key, keySeparator = '.') {
|
|
243
241
|
if (key == null) {
|
|
244
242
|
return target;
|
|
@@ -634,9 +632,10 @@ export function mergeDynamic2StaticData(
|
|
|
634
632
|
event?: Event;
|
|
635
633
|
};
|
|
636
634
|
dataContext?: Record<string,any>;
|
|
635
|
+
paramsContext?: Record<string,any>;
|
|
637
636
|
}*/,
|
|
638
637
|
) {
|
|
639
|
-
const { forContext = {}, codeContext = {}, dataContext = {}, $w } = context;
|
|
638
|
+
const { forContext = {}, codeContext = {}, dataContext = {}, $w, paramsContext = {} } = context;
|
|
640
639
|
const { lists = [], forItems = {} } = forContext;
|
|
641
640
|
|
|
642
641
|
const resolvedData = {
|
|
@@ -655,6 +654,7 @@ export function mergeDynamic2StaticData(
|
|
|
655
654
|
codeContext.event,
|
|
656
655
|
dataContext,
|
|
657
656
|
$w,
|
|
657
|
+
paramsContext,
|
|
658
658
|
),
|
|
659
659
|
);
|
|
660
660
|
}
|
|
@@ -12,7 +12,7 @@ import { widgetProps } from './data'
|
|
|
12
12
|
<% function printBoundData(boundData={}) {
|
|
13
13
|
const list = []
|
|
14
14
|
Object.entries(boundData).map(([prop, bindMeta])=>{
|
|
15
|
-
const str = `'${prop}': ($page, lists, forItems, event, $context, $w) => {${bindMeta.imports} return(
|
|
15
|
+
const str = `'${prop}': ($page, lists, forItems, event, $context, $w, params) => {${bindMeta.imports} return(
|
|
16
16
|
${bindMeta.expression === '' ? 'undefined': bindMeta.expression}
|
|
17
17
|
)}`
|
|
18
18
|
list.push(str)
|
package/lib/utils/transform.d.ts
DELETED
package/lib/utils/transform.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BabelTransform = void 0;
|
|
4
|
-
/* eslint-disable no-new-func */
|
|
5
|
-
const core_1 = require("@babel/core");
|
|
6
|
-
function BabelTransform(code, options = {}) {
|
|
7
|
-
var _a;
|
|
8
|
-
const { IIFE = false } = options;
|
|
9
|
-
try {
|
|
10
|
-
const simpleWrapped = `(\n${code || 'undefined'}\n)`;
|
|
11
|
-
const { code: expression } = (0, core_1.transformSync)(IIFE ? `(()=>${simpleWrapped})()` : simpleWrapped, {
|
|
12
|
-
cwd: __dirname,
|
|
13
|
-
sourceType: 'script',
|
|
14
|
-
comments: false,
|
|
15
|
-
// minified: true,
|
|
16
|
-
presets: [
|
|
17
|
-
[
|
|
18
|
-
'@babel/preset-env',
|
|
19
|
-
{
|
|
20
|
-
targets: {
|
|
21
|
-
/**
|
|
22
|
-
* 支持 proxy 的版本
|
|
23
|
-
* 低于这个版本完全无法支持
|
|
24
|
-
*/
|
|
25
|
-
// browsers: ['chrome >= 49', 'iOS >= 10', 'safari >= 10'],
|
|
26
|
-
/**
|
|
27
|
-
* 一个相对较高的版本,包涵解构赋值,这样不用注入太多 polifill
|
|
28
|
-
* 但是不包涵 options chain
|
|
29
|
-
* 基本上是 es2019
|
|
30
|
-
*/
|
|
31
|
-
browsers: ['chrome >= 67', 'iOS >= 12', 'safari >= 12'],
|
|
32
|
-
},
|
|
33
|
-
include: [
|
|
34
|
-
// es2015
|
|
35
|
-
'@babel/plugin-transform-arrow-functions',
|
|
36
|
-
],
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
],
|
|
40
|
-
}) || {};
|
|
41
|
-
const res = ((_a = expression === null || expression === void 0 ? void 0 : expression.replace) === null || _a === void 0 ? void 0 : _a.call(expression, /;$/, '')) || code;
|
|
42
|
-
if (expression) {
|
|
43
|
-
new Function(`return (\n${res}\n)`);
|
|
44
|
-
}
|
|
45
|
-
return res;
|
|
46
|
-
}
|
|
47
|
-
catch (e) {
|
|
48
|
-
console.error(`transform [${code}] fail:`, e === null || e === void 0 ? void 0 : e.message);
|
|
49
|
-
return code;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
exports.BabelTransform = BabelTransform;
|
package/template/.DS_Store
DELETED
|
Binary file
|
package/template/mp/.DS_Store
DELETED
|
Binary file
|
|
Binary file
|