@cloudbase/lowcode-builder 1.8.44-alpha.2 → 1.8.45-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 +1 -1
- package/lib/builder/h5/index.js +6 -2
- package/lib/builder/mp/index.js +1 -0
- package/lib/builder.web.js +1 -1
- package/lib/utils/transform.d.ts +1 -1
- package/lib/utils/transform.js +63 -69
- package/package.json +4 -3
- package/template/mp/common/util.js +11 -3
- package/template/mp/page/api.js +2 -1
package/lib/utils/transform.d.ts
CHANGED
package/lib/utils/transform.js
CHANGED
|
@@ -1,75 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable no-new-func */
|
|
3
|
-
// import { transformSync } from '@babel/core';
|
|
4
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
3
|
exports.BabelTransform = void 0;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// options: {
|
|
9
|
-
// IIFE?: boolean;
|
|
10
|
-
// } = {},
|
|
11
|
-
// ) {
|
|
12
|
-
// const { IIFE = false } = options;
|
|
13
|
-
// /**
|
|
14
|
-
// * 如果 trim 完为空
|
|
15
|
-
// * 则原样不用再编译了
|
|
16
|
-
// */
|
|
17
|
-
// if (!code?.trim?.()) {
|
|
18
|
-
// return code;
|
|
19
|
-
// }
|
|
20
|
-
// try {
|
|
21
|
-
// /**
|
|
22
|
-
// * 如果是基础字面量的话
|
|
23
|
-
// * 可以直接使用原值,不用过babel
|
|
24
|
-
// */
|
|
25
|
-
// if (typeof code === 'string' && JSON.parse(code?.trim?.())) {
|
|
26
|
-
// return code;
|
|
27
|
-
// }
|
|
28
|
-
// } catch (e) {}
|
|
29
|
-
// try {
|
|
30
|
-
// const simpleWrapped = `(\n${code || 'undefined'}\n)`;
|
|
31
|
-
// const { code: expression } =
|
|
32
|
-
// transformSync(IIFE ? `(()=>${simpleWrapped})()` : simpleWrapped, {
|
|
33
|
-
// cwd: __dirname,
|
|
34
|
-
// sourceType: 'script',
|
|
35
|
-
// comments: false,
|
|
36
|
-
// // minified: true,
|
|
37
|
-
// presets: [
|
|
38
|
-
// [
|
|
39
|
-
// '@babel/preset-env',
|
|
40
|
-
// {
|
|
41
|
-
// targets: {
|
|
42
|
-
// /**
|
|
43
|
-
// * 支持 proxy 的版本
|
|
44
|
-
// * 低于这个版本完全无法支持
|
|
45
|
-
// */
|
|
46
|
-
// // browsers: ['chrome >= 49', 'iOS >= 10', 'safari >= 10'],
|
|
47
|
-
// /**
|
|
48
|
-
// * 一个相对较高的版本,包涵解构赋值,这样不用注入太多 polifill
|
|
49
|
-
// * 但是不包涵 options chain
|
|
50
|
-
// * 基本上是 es2019
|
|
51
|
-
// */
|
|
52
|
-
// browsers: ['chrome >= 67', 'iOS >= 12', 'safari >= 12'],
|
|
53
|
-
// },
|
|
54
|
-
// include: [
|
|
55
|
-
// // es2015
|
|
56
|
-
// '@babel/plugin-transform-arrow-functions',
|
|
57
|
-
// ],
|
|
58
|
-
// },
|
|
59
|
-
// ],
|
|
60
|
-
// ],
|
|
61
|
-
// }) || {};
|
|
62
|
-
// const res = expression?.replace?.(/;$/, '') || code;
|
|
63
|
-
// if (expression) {
|
|
64
|
-
// new Function(`return (\n${res}\n)`);
|
|
65
|
-
// }
|
|
66
|
-
// return res;
|
|
67
|
-
// } catch (e: any) {
|
|
68
|
-
// console.error(`transform [${code}] fail:`, e?.message);
|
|
69
|
-
// return code;
|
|
70
|
-
// }
|
|
71
|
-
// }
|
|
4
|
+
/* eslint-disable no-new-func */
|
|
5
|
+
const core_1 = require("@babel/core");
|
|
72
6
|
function BabelTransform(code, options = {}) {
|
|
73
|
-
|
|
7
|
+
var _a, _b, _c;
|
|
8
|
+
const { IIFE = false } = options;
|
|
9
|
+
/**
|
|
10
|
+
* 如果 trim 完为空
|
|
11
|
+
* 则原样不用再编译了
|
|
12
|
+
*/
|
|
13
|
+
if (!((_a = code === null || code === void 0 ? void 0 : code.trim) === null || _a === void 0 ? void 0 : _a.call(code))) {
|
|
14
|
+
return code;
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
/**
|
|
18
|
+
* 如果是基础字面量的话
|
|
19
|
+
* 可以直接使用原值,不用过babel
|
|
20
|
+
*/
|
|
21
|
+
if (typeof code === 'string' && JSON.parse((_b = code === null || code === void 0 ? void 0 : code.trim) === null || _b === void 0 ? void 0 : _b.call(code))) {
|
|
22
|
+
return code;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch (e) { }
|
|
26
|
+
try {
|
|
27
|
+
const simpleWrapped = `(\n${code || 'undefined'}\n)`;
|
|
28
|
+
const { code: expression } = (0, core_1.transformSync)(IIFE ? `(()=>${simpleWrapped})()` : simpleWrapped, {
|
|
29
|
+
cwd: __dirname,
|
|
30
|
+
sourceType: 'script',
|
|
31
|
+
comments: false,
|
|
32
|
+
// minified: true,
|
|
33
|
+
presets: [
|
|
34
|
+
[
|
|
35
|
+
'@babel/preset-env',
|
|
36
|
+
{
|
|
37
|
+
targets: {
|
|
38
|
+
/**
|
|
39
|
+
* 支持 proxy 的版本
|
|
40
|
+
* 低于这个版本完全无法支持
|
|
41
|
+
*/
|
|
42
|
+
// browsers: ['chrome >= 49', 'iOS >= 10', 'safari >= 10'],
|
|
43
|
+
/**
|
|
44
|
+
* 一个相对较高的版本,包涵解构赋值,这样不用注入太多 polifill
|
|
45
|
+
* 但是不包涵 options chain
|
|
46
|
+
* 基本上是 es2019
|
|
47
|
+
*/
|
|
48
|
+
browsers: ['chrome >= 67', 'iOS >= 12', 'safari >= 12'],
|
|
49
|
+
},
|
|
50
|
+
include: [
|
|
51
|
+
// es2015
|
|
52
|
+
'@babel/plugin-transform-arrow-functions',
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
],
|
|
57
|
+
}) || {};
|
|
58
|
+
const res = ((_c = expression === null || expression === void 0 ? void 0 : expression.replace) === null || _c === void 0 ? void 0 : _c.call(expression, /;$/, '')) || code;
|
|
59
|
+
if (expression) {
|
|
60
|
+
new Function(`return (\n${res}\n)`);
|
|
61
|
+
}
|
|
62
|
+
return res;
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
console.error(`transform [${code}] fail:`, e === null || e === void 0 ? void 0 : e.message);
|
|
66
|
+
return code;
|
|
67
|
+
}
|
|
74
68
|
}
|
|
75
69
|
exports.BabelTransform = BabelTransform;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.45-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",
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
"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",
|
|
34
34
|
"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
35
|
"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
|
-
"build:template": "./scripts/buildTemplate.sh"
|
|
36
|
+
"build:template": "./scripts/buildTemplate.sh",
|
|
37
|
+
"publish:web": "node ./scripts/publish.ide.js"
|
|
37
38
|
},
|
|
38
39
|
"bugs": {
|
|
39
40
|
"url": "https://github.com/TencentCloudBase/cloudbase-framework/issues"
|
|
@@ -41,7 +42,7 @@
|
|
|
41
42
|
"dependencies": {
|
|
42
43
|
"@babel/core": "7.21.4",
|
|
43
44
|
"@babel/preset-env": "7.21.4",
|
|
44
|
-
"@cloudbase/cals": "^1.0.
|
|
45
|
+
"@cloudbase/cals": "^1.0.32",
|
|
45
46
|
"@cloudbase/lowcode-generator": "^1.8.14",
|
|
46
47
|
"axios": "^0.21.0",
|
|
47
48
|
"browserfs": "^1.4.3",
|
|
@@ -419,8 +419,15 @@ export async function getAuthConfig() {
|
|
|
419
419
|
|
|
420
420
|
let _AUTH_CACHE_MAP = {};
|
|
421
421
|
|
|
422
|
-
async function getAccessPermission(app, appId, pageId) {
|
|
423
|
-
|
|
422
|
+
async function getAccessPermission(app, appId, packageName = "", pageId) {
|
|
423
|
+
let cacheKey = `${appId}-${pageId}`;
|
|
424
|
+
if (packageName) {
|
|
425
|
+
const matched = packageName.match(/packages\/(.*)$/);
|
|
426
|
+
if (matched?.[1]) {
|
|
427
|
+
cacheKey = `${appId}-${matched?.[1]}-${pageId}`
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
424
431
|
if (_AUTH_CACHE_MAP[cacheKey] !== undefined) {
|
|
425
432
|
return _AUTH_CACHE_MAP[cacheKey];
|
|
426
433
|
}
|
|
@@ -482,7 +489,7 @@ export async function checkAuth(app, appId, $page) {
|
|
|
482
489
|
return true;
|
|
483
490
|
}
|
|
484
491
|
wx.showNavigationBarLoading();
|
|
485
|
-
const requestList = [getAccessPermission(app, appId, $page.id)];
|
|
492
|
+
const requestList = [getAccessPermission(app, appId, $page.packageName, $page.id)];
|
|
486
493
|
// 暂时先认为有登录页则自定义登录功能开启且生效
|
|
487
494
|
if (loginPage) {
|
|
488
495
|
requestList.push(getAuthConfig(app));
|
|
@@ -541,6 +548,7 @@ export function redirectToLogin(currentPage) {
|
|
|
541
548
|
app.redirectTo({
|
|
542
549
|
pageId: loginPage.id,
|
|
543
550
|
params: {
|
|
551
|
+
packageName: currentPage.packageName || undefined,
|
|
544
552
|
sourcePageId: currentPage.id,
|
|
545
553
|
sourcePageParams: currentPage.params || currentPage.dataset?.params,
|
|
546
554
|
},
|
package/template/mp/page/api.js
CHANGED