@cloudbase/lowcode-builder 1.8.63 → 1.8.65
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/config/index.d.ts +2 -1
- package/lib/builder/config/index.js +3 -2
- package/lib/builder/core/index.js +9 -0
- package/lib/builder/h5/index.js +6 -6
- package/lib/builder/mp/BuildContext.d.ts +4 -0
- package/lib/builder/mp/index.js +4 -0
- package/lib/builder/mp/util.js +1 -1
- package/lib/builder.web.js +13 -13
- package/package.json +3 -3
- package/template/html/index.html.ejs +1 -1
- package/template/mp/app/common.js +27 -1
- package/template/mp/app.js +15 -3
- package/template/mp/common/util.js +76 -9
- package/template/mp/common/weapp-component.js +4 -3
- package/template/mp/common/weapp-page.js +4 -1
- package/template/mp/datasources/index.js.tpl +6 -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.65",
|
|
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",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@babel/core": "7.21.4",
|
|
48
48
|
"@babel/preset-env": "7.21.4",
|
|
49
|
-
"@cloudbase/cals": "^1.0.
|
|
50
|
-
"@cloudbase/lowcode-generator": "^1.8.
|
|
49
|
+
"@cloudbase/cals": "^1.0.51",
|
|
50
|
+
"@cloudbase/lowcode-generator": "^1.8.19",
|
|
51
51
|
"axios": "^0.21.0",
|
|
52
52
|
"browserfs": "^1.4.3",
|
|
53
53
|
"browserify-zlib": "^0.2.0",
|
|
@@ -543,7 +543,7 @@
|
|
|
543
543
|
crossorigin
|
|
544
544
|
src="<%=
|
|
545
545
|
cdnEndpoints.cdngo
|
|
546
|
-
%>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.
|
|
546
|
+
%>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.3897a073a34a755db5d0.bundle.js"
|
|
547
547
|
></script>
|
|
548
548
|
</body>
|
|
549
549
|
</html>
|
|
@@ -3,6 +3,10 @@ import * as $$<%= mod %> from '../lowcode/common/<%= mod %>'<%}) %>
|
|
|
3
3
|
|
|
4
4
|
const _weapps_app_common = {}
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* 合并逻辑主要担心之前存在引用
|
|
8
|
+
* 实际上可以遵照web实现互斥,有 default 则使用 default 否则 module
|
|
9
|
+
*/
|
|
6
10
|
function getDefaultModule(targetModule) {
|
|
7
11
|
if (!targetModule) {
|
|
8
12
|
return
|
|
@@ -11,7 +15,29 @@ function getDefaultModule(targetModule) {
|
|
|
11
15
|
if (keys.length === 1 && keys[0] === 'default') {
|
|
12
16
|
return targetModule.default
|
|
13
17
|
}
|
|
14
|
-
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
if (keys.includes('default')) {
|
|
21
|
+
let module = targetModule.default || {};
|
|
22
|
+
for (const key in targetModule) {
|
|
23
|
+
try {
|
|
24
|
+
if (module[key] !== undefined) {
|
|
25
|
+
// reportEvent(`${tag}.mergeconflict`);
|
|
26
|
+
} else if (key !== 'default') {
|
|
27
|
+
/**
|
|
28
|
+
* 兼容之前写法进行数据合并
|
|
29
|
+
*/
|
|
30
|
+
module[key] = targetModule[key];
|
|
31
|
+
}
|
|
32
|
+
} catch (e) {
|
|
33
|
+
// reportEvent(`${tag}.unmergeable`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return module;
|
|
37
|
+
}
|
|
38
|
+
} catch (e) {}
|
|
39
|
+
|
|
40
|
+
return targetModule;
|
|
15
41
|
}
|
|
16
42
|
|
|
17
43
|
Object.defineProperties(_weapps_app_common, {
|
package/template/mp/app.js
CHANGED
|
@@ -70,14 +70,26 @@ setConfig({
|
|
|
70
70
|
app.showToast({ icon: isSuccess ? 'success' : 'error' });
|
|
71
71
|
},
|
|
72
72
|
async afterCallFunction(params, error, res) {
|
|
73
|
-
|
|
73
|
+
let oauthError =
|
|
74
74
|
error?.message?.includes?.('PERMISSION_DENIED') ||
|
|
75
75
|
error?.code === 'unauthenticated' ||
|
|
76
76
|
error?.error === 'unauthenticated' ||
|
|
77
77
|
error?.code === 'invalid_grant' ||
|
|
78
78
|
error?.error === 'invalid_grant' ||
|
|
79
|
-
error?.code === 'INVALID_ACCESS_TOKEN'
|
|
80
|
-
|
|
79
|
+
error?.code === 'INVALID_ACCESS_TOKEN';
|
|
80
|
+
|
|
81
|
+
if (!oauthError) {
|
|
82
|
+
try {
|
|
83
|
+
/**
|
|
84
|
+
* js-sdk v2 实现上吞了所有错误
|
|
85
|
+
* 返回 new Error(JSON.stringify({code: "OPERATION_FAIL", msg:"[INVALID_ACCESS_TOKEN]XXX"}))
|
|
86
|
+
*/
|
|
87
|
+
let tcbErrorObj = JSON.parse(error.message);
|
|
88
|
+
if (tcbErrorObj?.code === 'OPERATION_FAIL' && /\[INVALID_ACCESS_TOKEN\]/.test(tcbErrorObj.msg)) {
|
|
89
|
+
oauthError = true;
|
|
90
|
+
}
|
|
91
|
+
} catch (e) {}
|
|
92
|
+
}
|
|
81
93
|
|
|
82
94
|
if (
|
|
83
95
|
params?.data?.params?.action != 'DescribeRuntimeResourceStrategy' &&
|
|
@@ -64,6 +64,27 @@ export function createEventHandlers(
|
|
|
64
64
|
) {
|
|
65
65
|
const { looseError = false, isComposite = false, syncCall = false } = options;
|
|
66
66
|
const evtHandlers = {};
|
|
67
|
+
function proxyWrapper(target, compareTarget, key) {
|
|
68
|
+
try {
|
|
69
|
+
return new Proxy(target, {
|
|
70
|
+
get(target, p) {
|
|
71
|
+
if (p !== 'id') {
|
|
72
|
+
if (
|
|
73
|
+
(key === 'currentTarget' || key === 'target') &&
|
|
74
|
+
p !== '_userWidget' &&
|
|
75
|
+
target[p] !== compareTarget?.[p]
|
|
76
|
+
) {
|
|
77
|
+
// console.log(`@deprecated event.${key}.${String(p)}`);
|
|
78
|
+
reportEvent(`event.${key}.${String(p)}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return target[p];
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
} catch (e) {
|
|
85
|
+
return target;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
67
88
|
for (const name in evtListeners) {
|
|
68
89
|
const listeners = evtListeners[name];
|
|
69
90
|
evtHandlers[name] = function (event = {}) {
|
|
@@ -71,8 +92,8 @@ export function createEventHandlers(
|
|
|
71
92
|
const owner = this._getInstance();
|
|
72
93
|
const target = !!event?.target?.id ? getWidget(owner.widgets, event.target.id) : undefined;
|
|
73
94
|
const currentTarget = !!event?.currentTarget?.id ? getWidget(owner.widgets, event.currentTarget.id) : undefined;
|
|
74
|
-
event.target = target;
|
|
75
|
-
event.currentTarget = currentTarget;
|
|
95
|
+
event.target = proxyWrapper(target, target?._userWidget, 'target');
|
|
96
|
+
event.currentTarget = proxyWrapper(currentTarget, currentTarget?._userWidget, 'currentTarget');
|
|
76
97
|
const [prefix = '', trigger] = name.split('$');
|
|
77
98
|
// The page event handler
|
|
78
99
|
const forContext = (!!currentTarget && generateForContextOfWidget(currentTarget)) || {};
|
|
@@ -489,7 +510,8 @@ export function formatErrorMsg(e) {
|
|
|
489
510
|
* 检查页面权限
|
|
490
511
|
**/
|
|
491
512
|
export async function checkAuth(app, appId, $page) {
|
|
492
|
-
return true
|
|
513
|
+
<% if(skipCheckAuth){ %> return true <% } %>
|
|
514
|
+
|
|
493
515
|
const loginPage = findLoginPage(app);
|
|
494
516
|
if (loginPage?.id === $page.id) {
|
|
495
517
|
return true;
|
|
@@ -762,11 +784,13 @@ function formatLifecycle(time) {
|
|
|
762
784
|
return str;
|
|
763
785
|
}
|
|
764
786
|
|
|
765
|
-
const PROMISE = new Promise((resolve,reject)=>{
|
|
787
|
+
const PROMISE = new Promise((resolve, reject)=>{
|
|
766
788
|
wx.request({
|
|
767
|
-
url: '
|
|
789
|
+
url: '<%= RUNTIME_CONFIG_URL %>',
|
|
768
790
|
success: res => resolve(res.data),
|
|
769
|
-
fail:
|
|
791
|
+
fail: e => {
|
|
792
|
+
resolve(<%= JSON.stringify(runtimeDynamicConfig)%>)
|
|
793
|
+
}
|
|
770
794
|
})
|
|
771
795
|
})
|
|
772
796
|
<% } %>
|
|
@@ -779,10 +803,15 @@ export async function getExpiredMessage(createdTime = 0) {
|
|
|
779
803
|
try {
|
|
780
804
|
if (createdTime) {
|
|
781
805
|
const json = await PROMISE;
|
|
782
|
-
const {
|
|
783
|
-
|
|
806
|
+
const { expLifeTime = Infinity } = json;
|
|
807
|
+
const releaseTime = wx.getAccountInfoSync()?.miniProgram?.releaseTime;
|
|
808
|
+
if(releaseTime) {
|
|
809
|
+
let date = new Date(releaseTime);
|
|
810
|
+
createdTime = date.getTime()
|
|
811
|
+
}
|
|
812
|
+
if (Date.now() - createdTime > expLifeTime) {
|
|
784
813
|
return `该版本为体验版,需要再次发布激活,每次发布应用活跃时间为${formatLifecycle(
|
|
785
|
-
|
|
814
|
+
expLifeTime,
|
|
786
815
|
)}。您也可以升级为正式版本,无应用活跃时间限制。`;
|
|
787
816
|
}
|
|
788
817
|
}
|
|
@@ -791,3 +820,41 @@ export async function getExpiredMessage(createdTime = 0) {
|
|
|
791
820
|
}
|
|
792
821
|
<% } %>
|
|
793
822
|
}
|
|
823
|
+
|
|
824
|
+
|
|
825
|
+
export function patchWdigetPropsWithEvtListeners(widgetProps, evtListeners) {
|
|
826
|
+
const actionMap = Object.keys(evtListeners).reduce((map, evtKey = '') => {
|
|
827
|
+
const matched = evtKey.match(/^on(.*?)\$(.*)$/);
|
|
828
|
+
if (matched?.[1] && matched?.[2] && !/[._]/.test(matched?.[2])) {
|
|
829
|
+
if (!map[matched?.[1]]) {
|
|
830
|
+
map[matched?.[1]] = new Set([]);
|
|
831
|
+
}
|
|
832
|
+
map[matched?.[1]].add(matched?.[2]);
|
|
833
|
+
}
|
|
834
|
+
return map;
|
|
835
|
+
}, {});
|
|
836
|
+
for (let key in widgetProps) {
|
|
837
|
+
const props = widgetProps[key];
|
|
838
|
+
if (actionMap[key]) {
|
|
839
|
+
if (!props.classList) {
|
|
840
|
+
props.classList = [];
|
|
841
|
+
}
|
|
842
|
+
props.classList = Array.from(
|
|
843
|
+
new Set([...props.classList, ...Array.from(actionMap[key]).map((trigger) => `wd-event-${trigger}`)]),
|
|
844
|
+
);
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
return widgetProps;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
export function reportEvent(tag) {
|
|
852
|
+
try {
|
|
853
|
+
const { envVersion } = app.__internal__?.getConfig?.() || {};
|
|
854
|
+
// console.log('>>>>>>reportevent:', tag);
|
|
855
|
+
getApp().globalData._aegis?.reportEvent?.({
|
|
856
|
+
name: tag,
|
|
857
|
+
ext2: envVersion,
|
|
858
|
+
});
|
|
859
|
+
} catch (e) {}
|
|
860
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { observable } from 'mobx'
|
|
2
|
-
import { createEventHandlers, createComputed } from './util'
|
|
2
|
+
import { createEventHandlers, createComputed, patchWdigetPropsWithEvtListeners } from './util'
|
|
3
3
|
import { createWidgets, getWidget, disposeWidget } from './widget'
|
|
4
4
|
import mergeRenderer from './merge-renderer'
|
|
5
5
|
import { runWatchers } from './watch'
|
|
@@ -14,7 +14,8 @@ import { $w as baseAPI } from '../app/weapps-api'
|
|
|
14
14
|
export const compLowcodes = {}
|
|
15
15
|
|
|
16
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
|
compLowcodes[key] = {
|
|
19
20
|
index,
|
|
20
21
|
stateFn,
|
|
@@ -46,7 +47,7 @@ export function createComponent(key, behaviors, properties, events, handler, dat
|
|
|
46
47
|
...properties,
|
|
47
48
|
},
|
|
48
49
|
|
|
49
|
-
data:
|
|
50
|
+
data: createInitData(widgetProps, dataBinds, ''),
|
|
50
51
|
|
|
51
52
|
lifetimes: {
|
|
52
53
|
created() {
|
|
@@ -21,7 +21,7 @@ import { runWatchers } from './watch';
|
|
|
21
21
|
import { $w as baseAPI } from '../app/weapps-api';
|
|
22
22
|
import { Event } from './event-emitter';
|
|
23
23
|
import { generatePageUrl } from '@cloudbase/weda-client';
|
|
24
|
-
import { mergeDynamic2StaticData } from './util';
|
|
24
|
+
import { mergeDynamic2StaticData, patchWdigetPropsWithEvtListeners } from './util';
|
|
25
25
|
|
|
26
26
|
export const PAGE_ROOT_SYMBOL = Symbol('@@page_route@@')
|
|
27
27
|
|
|
@@ -114,6 +114,8 @@ export function createPage({
|
|
|
114
114
|
pageAttributes = {},
|
|
115
115
|
resetShare = true,
|
|
116
116
|
}) {
|
|
117
|
+
widgetProps = patchWdigetPropsWithEvtListeners(widgetProps, evtListeners)
|
|
118
|
+
|
|
117
119
|
const evtHandlers = createEventHandlers(evtListeners);
|
|
118
120
|
const {[PAGE_ROOT_SYMBOL]: pageRootDataBinds, ...componentDataBinds} = dataBinds
|
|
119
121
|
|
|
@@ -415,3 +417,4 @@ function decodePageQuery(query) {
|
|
|
415
417
|
return decoded;
|
|
416
418
|
}, {});
|
|
417
419
|
}
|
|
420
|
+
|
|
@@ -32,6 +32,11 @@ initTcb()
|
|
|
32
32
|
|
|
33
33
|
<% if(cdnEndpoints.aegis){ %>
|
|
34
34
|
require.async('../packages/$wd_system/index.js').then(({ Aegis }) => {
|
|
35
|
-
new Aegis(AEGIS_CONFIG)
|
|
35
|
+
let _aegis = new Aegis(AEGIS_CONFIG);
|
|
36
|
+
const app = getApp();
|
|
37
|
+
if(!app.globalData) {
|
|
38
|
+
app.globalData = {}
|
|
39
|
+
}
|
|
40
|
+
app.globalData._aegis = _aegis;
|
|
36
41
|
})
|
|
37
42
|
<% }%>
|