@cloudbase/lowcode-builder 1.5.4 → 1.5.5
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/mp/index.js +5 -6
- package/lib/builder/util/common.d.ts +1 -1
- package/lib/builder/util/common.js +0 -4
- package/package.json +2 -2
- package/template/html/index.html.ejs +1 -1
- package/template/mp/common/widget.js +35 -34
- package/template/mp/package.json +1 -1
- package/template/mp/page/data.js +1 -0
- package/template/mp/page/index.js +1 -1
package/lib/builder/mp/index.js
CHANGED
|
@@ -185,11 +185,7 @@ async function generateWxMp({ buildContext, weapps, plugins, deployMode, options
|
|
|
185
185
|
clientID: (_a = mainAppData.extra) === null || _a === void 0 ? void 0 : _a.clientId,
|
|
186
186
|
},
|
|
187
187
|
'datasources/datasource-profiles.js.tpl': {
|
|
188
|
-
datasourceProfiles: (0, util_3.JsonToStringWithVariableName)(
|
|
189
|
-
/**
|
|
190
|
-
* 精简文件生成,新 cloud-sdk 不依赖 profile 了
|
|
191
|
-
*/
|
|
192
|
-
[]), { EOL: false }),
|
|
188
|
+
datasourceProfiles: (0, util_3.JsonToStringWithVariableName)([], { EOL: false }),
|
|
193
189
|
},
|
|
194
190
|
'datasources/dataset-profiles.js.tpl': {
|
|
195
191
|
datasetProfiles: (0, util_3.JsonToStringWithVariableName)((0, lowcode_generator_1.getDatasetProfiles)(mainAppData, weapps), { EOL: true }),
|
|
@@ -328,8 +324,11 @@ async function generatePkg(ctx, weapp, appRoot, pageConfigs) {
|
|
|
328
324
|
[`api.js|api.js`]: {
|
|
329
325
|
subLevelPath: rootPath ? `${path_1.default.posix.relative(rootPath, '')}/` : '',
|
|
330
326
|
},
|
|
331
|
-
[`
|
|
327
|
+
[`data.js|data.js`]: {
|
|
332
328
|
widgetProps: (0, util_2.createWidgetProps)(ctx, componentInstances),
|
|
329
|
+
stringifyObj: util_1.inspect,
|
|
330
|
+
},
|
|
331
|
+
[`index.js|${pageFileName}.js`]: {
|
|
333
332
|
pageUUID: rootPath ? `${rootPath}/${page.id}` : page.id,
|
|
334
333
|
pageName: page.id,
|
|
335
334
|
pageSource: page.data.src || '',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IComponentInputProps, IComponentsInfoMap, IPackageJson } from '../types/common';
|
|
2
2
|
import { IMaterialItem, IWeAppComponentInstance, IWeAppCode } from '@cloudbase/lowcode-generator/lib/weapps-core';
|
|
3
3
|
export { getMetaInfoBySourceKey, isArray, isPlainObject, deepDeal, simpleDeepClone, deepDealSchema, getFileNameByUrl, } from '@cloudbase/lowcode-generator/lib/generator/util/common';
|
|
4
|
-
|
|
4
|
+
declare type PromiseResult<T> = Promise<[null, T] | [Error, null]>;
|
|
5
5
|
export declare function promiseWrapper<T>(p: Promise<T>): PromiseResult<T>;
|
|
6
6
|
export declare function getCurrentPackageJson(): {
|
|
7
7
|
name: any;
|
|
@@ -34,10 +34,6 @@ function promiseWrapper(p) {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
exports.promiseWrapper = promiseWrapper;
|
|
37
|
-
// export function isEmpty(i: any): boolean {
|
|
38
|
-
// if (typeof i === 'string') return !i.trim()
|
|
39
|
-
// return R.isEmpty(i) || R.isNil(i) || Number.isNaN(i)
|
|
40
|
-
// }
|
|
41
37
|
function getCurrentPackageJson() {
|
|
42
38
|
try {
|
|
43
39
|
const { name, version } = fs_extra_1.default.readJSONSync(path_1.default.resolve(process.cwd(), 'package.json'));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.5",
|
|
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",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@cloudbase/cals": "^0.5.17",
|
|
42
|
-
"@cloudbase/lowcode-generator": "^1.5.
|
|
42
|
+
"@cloudbase/lowcode-generator": "^1.5.4",
|
|
43
43
|
"axios": "^0.21.0",
|
|
44
44
|
"browserfs": "^1.4.3",
|
|
45
45
|
"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.a81adb6beadedd9fd68f.bundle.js"
|
|
547
547
|
></script>
|
|
548
548
|
</body>
|
|
549
549
|
</html>
|
|
@@ -32,6 +32,7 @@ const EXTRA_PROPS_MAP = [
|
|
|
32
32
|
'off',
|
|
33
33
|
'getConfig',
|
|
34
34
|
'_getInstanceRef',
|
|
35
|
+
'_instanceRef',
|
|
35
36
|
'_methods',
|
|
36
37
|
'_userWidget',
|
|
37
38
|
/**
|
|
@@ -85,7 +86,7 @@ export function createWidgets(widgetProps, dataBinds, ownerMpInst, widgetHolder)
|
|
|
85
86
|
{},
|
|
86
87
|
failedBinds,
|
|
87
88
|
undefined,
|
|
88
|
-
widgetHolder
|
|
89
|
+
widgetHolder,
|
|
89
90
|
);
|
|
90
91
|
retryFailedBinds(failedBinds, true);
|
|
91
92
|
return result;
|
|
@@ -105,7 +106,7 @@ function createSubWidgetTree(
|
|
|
105
106
|
forContext = {},
|
|
106
107
|
failedBinds = [],
|
|
107
108
|
parentWidget = { children: observable([]), _disposers: [] },
|
|
108
|
-
widgetHolder = {}
|
|
109
|
+
widgetHolder = {},
|
|
109
110
|
) {
|
|
110
111
|
const { ownerForWidgetHolder = {}, existingWidgetMap = {} } = ctx;
|
|
111
112
|
/**
|
|
@@ -390,10 +391,12 @@ function createWidget(props, nodeId, indexPostfix, parent, ownerMpInst, forConte
|
|
|
390
391
|
});
|
|
391
392
|
|
|
392
393
|
// w._disposers = []
|
|
393
|
-
// w.children = []
|
|
394
|
+
// w.children = [];
|
|
394
395
|
Object.defineProperty(w, 'children', { value: observable([]) });
|
|
395
396
|
Object.defineProperty(w, '_disposers', { value: observable([]) });
|
|
396
397
|
Object.defineProperty(w, '_eventListeners', { value: new EventEmitter() });
|
|
398
|
+
Object.defineProperty(w, '_instanceRef', { value: observable({ current: null }) });
|
|
399
|
+
|
|
397
400
|
if (parent) {
|
|
398
401
|
// w.parent = parent
|
|
399
402
|
Object.defineProperty(w, 'parent', { value: parent });
|
|
@@ -415,6 +418,18 @@ function createWidget(props, nodeId, indexPostfix, parent, ownerMpInst, forConte
|
|
|
415
418
|
},
|
|
416
419
|
});
|
|
417
420
|
}
|
|
421
|
+
// 默认初始值
|
|
422
|
+
w._disposers.push(
|
|
423
|
+
autorun((r) => {
|
|
424
|
+
const ref = {
|
|
425
|
+
data: w.data,
|
|
426
|
+
items: w.items,
|
|
427
|
+
};
|
|
428
|
+
untracked(() => {
|
|
429
|
+
w._instanceRef.current = ref;
|
|
430
|
+
});
|
|
431
|
+
}),
|
|
432
|
+
);
|
|
418
433
|
break;
|
|
419
434
|
}
|
|
420
435
|
}
|
|
@@ -649,32 +664,7 @@ function mountBuiltinWigetsAPI(widget, owner) {
|
|
|
649
664
|
widget.getConfig = () => config;
|
|
650
665
|
}
|
|
651
666
|
|
|
652
|
-
|
|
653
|
-
case `${REPEATER.MODULE_NAME}:${REPEATER.REPEATER_NAME}`: {
|
|
654
|
-
const currentRef = observable({ current: {} });
|
|
655
|
-
widget._getInstanceRef = () => {
|
|
656
|
-
return currentRef;
|
|
657
|
-
}; // 默认初始值
|
|
658
|
-
widget._disposers.push(
|
|
659
|
-
autorun((r) => {
|
|
660
|
-
currentRef.current = {
|
|
661
|
-
data: widget.data,
|
|
662
|
-
items: (widget.children || []).map((item) => {
|
|
663
|
-
const descendants = {};
|
|
664
|
-
Object.keys(item?._descendants || {}).forEach((key) => {
|
|
665
|
-
descendants[key] = item._descendants[key]._userWidget;
|
|
666
|
-
});
|
|
667
|
-
return descendants;
|
|
668
|
-
})
|
|
669
|
-
}
|
|
670
|
-
}),
|
|
671
|
-
);
|
|
672
|
-
break;
|
|
673
|
-
}
|
|
674
|
-
default: {
|
|
675
|
-
widget._getInstanceRef = () => null;
|
|
676
|
-
}
|
|
677
|
-
}
|
|
667
|
+
widget._getInstanceRef = () => widget._instanceRef;
|
|
678
668
|
|
|
679
669
|
/**
|
|
680
670
|
* @deprecated
|
|
@@ -715,8 +705,13 @@ class UserWidget {
|
|
|
715
705
|
return target[prop];
|
|
716
706
|
}
|
|
717
707
|
|
|
718
|
-
|
|
719
|
-
|
|
708
|
+
/**
|
|
709
|
+
* @important
|
|
710
|
+
* 优先 custom
|
|
711
|
+
* 会出现一些 target 时序还不存在的情况
|
|
712
|
+
* 因此 custom[prop] 先添加进依赖
|
|
713
|
+
*/
|
|
714
|
+
if (target.custom?.[prop] && prop in target.custom) {
|
|
720
715
|
return target.custom[prop];
|
|
721
716
|
}
|
|
722
717
|
|
|
@@ -791,12 +786,13 @@ class UserWidget {
|
|
|
791
786
|
|
|
792
787
|
get custom() {
|
|
793
788
|
const widget = this._widget;
|
|
794
|
-
const instance = widget._getInstanceRef?.()?.current || {};
|
|
795
789
|
const userCustomMember = untracked(() => {
|
|
790
|
+
const instanceRef = widget._getInstanceRef?.();
|
|
791
|
+
const instance = instanceRef?.current || {};
|
|
796
792
|
const { methods = {}, ...restInstance } = instance;
|
|
797
793
|
return new Proxy(
|
|
798
794
|
{
|
|
799
|
-
...widget
|
|
795
|
+
...widget?._methods,
|
|
800
796
|
...restInstance,
|
|
801
797
|
...methods,
|
|
802
798
|
},
|
|
@@ -805,7 +801,12 @@ class UserWidget {
|
|
|
805
801
|
if (prop in methods) {
|
|
806
802
|
return methods[prop];
|
|
807
803
|
}
|
|
808
|
-
|
|
804
|
+
/**
|
|
805
|
+
* 此处要保持从 ref 开始访问
|
|
806
|
+
* 因为proxy 内部如果直接从 ref.current 开始访问,刚开始是可能遇到的是空值,并且空对象兜底
|
|
807
|
+
* 那么此处实际上监听的即为兜底的空对象,非 observer 对象
|
|
808
|
+
*/
|
|
809
|
+
if (prop !== 'methods' && prop in (instanceRef.current || {})) {
|
|
809
810
|
return instance[prop];
|
|
810
811
|
}
|
|
811
812
|
return widget?._methods?.[prop];
|
package/template/mp/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"dependencies": {<% if(importJSSDK) {%>
|
|
6
6
|
"@cloudbase/js-sdk": "2.5.6-beta.1",<% } %>
|
|
7
7
|
"@cloudbase/oauth": "0.1.1-alpha.5",
|
|
8
|
-
"@cloudbase/weda-client": "0.2.
|
|
8
|
+
"@cloudbase/weda-client": "0.2.56",
|
|
9
9
|
"@cloudbase/weda-cloud-sdk": "1.0.26",
|
|
10
10
|
"mobx": "^5.15.4",
|
|
11
11
|
"lodash.get": "^4.4.2",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const widgetProps = <%= stringifyObj(widgetProps, {depth: null}) %>
|
|
@@ -7,8 +7,8 @@ import { $$<%= pageName %> as handlers } from '../../app/handlers'
|
|
|
7
7
|
<%= importor.state? `import state from '../../lowcode/${pageName}/state'` : "const state = {}" %>
|
|
8
8
|
<%= importor.computed? `import computed from '../../lowcode/${pageName}/computed'` : "const computed = {}" %>
|
|
9
9
|
import { $page } from './api'
|
|
10
|
+
import { widgetProps } from './data'
|
|
10
11
|
|
|
11
|
-
const widgetProps = <%= stringifyObj(widgetProps, {depth: null}) %>
|
|
12
12
|
/** widget event listeners **/
|
|
13
13
|
const evtListeners = {<% Object.entries(eventHanlders).map(([handlerName, listeners])=>{%>
|
|
14
14
|
<%= handlerName%>: [
|