@cloudbase/lowcode-builder 1.0.16 → 1.0.19
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 +3 -4
- package/lib/builder/mp/lowcode.js +2 -2
- package/lib/builder/mp/materials.js +16 -14
- package/lib/builder/util/common.d.ts +1 -2
- package/lib/builder/util/common.js +1 -15
- package/package.json +3 -3
- package/template/html/index.html.ejs +1 -1
- package/template/mp/app/weapps-api.js +4 -10
- package/template/mp/app.js +5 -13
- package/template/mp/app.wxss +1 -4
- package/template/mp/component/index.js +4 -5
- package/template/mp/component/index.wxss +2 -1
- package/template/mp/page/index.js +4 -4
package/lib/builder/mp/index.js
CHANGED
|
@@ -51,7 +51,6 @@ const lodash_1 = require("lodash");
|
|
|
51
51
|
const junk = __importStar(require("../util/junk"));
|
|
52
52
|
const net_1 = require("../util/net");
|
|
53
53
|
const cals_1 = require("@cloudbase/cals");
|
|
54
|
-
const common_2 = require("@cloudbase/lowcode-generator/lib/generator/util/common");
|
|
55
54
|
const templateDir = `${config_1.appTemplateDir}/mp/`;
|
|
56
55
|
const em = chalk_1.default.blue.bold;
|
|
57
56
|
const error = chalk_1.default.redBright;
|
|
@@ -410,7 +409,7 @@ async function generateFramework(appData, outDir, ctx) {
|
|
|
410
409
|
},
|
|
411
410
|
'app/common.js': {
|
|
412
411
|
mods: appData.lowCodes
|
|
413
|
-
.filter((m) => m.type ===
|
|
412
|
+
.filter((m) => m.type === cals_1.ECodeType.NORMAL_MODULE && m.name !== '____index____')
|
|
414
413
|
.map((m) => m.name)
|
|
415
414
|
.sort(),
|
|
416
415
|
},
|
|
@@ -423,7 +422,7 @@ async function generateFramework(appData, outDir, ctx) {
|
|
|
423
422
|
async function writeLowCodeFiles(appData, outDir, ctx) {
|
|
424
423
|
console.log(`Writing ${em('lowcode')} files:`);
|
|
425
424
|
const lowcodeRootDir = path_1.default.join(outDir, 'lowcode');
|
|
426
|
-
const lowCodes = (0,
|
|
425
|
+
const lowCodes = (0, cals_1.processRuntimeCodeResources)({ id: 'global' }, appData.lowCodes || appData.codeModules, 'app');
|
|
427
426
|
const themeStyle = lowCodes.find((mod) => mod.type === cals_1.ECodeType.THEME);
|
|
428
427
|
// 混合模式,子包不生成顶级(应用级)的 lowcodes
|
|
429
428
|
if (!(ctx.isMixMode && appData.rootPath)) {
|
|
@@ -434,7 +433,7 @@ async function writeLowCodeFiles(appData, outDir, ctx) {
|
|
|
434
433
|
}));
|
|
435
434
|
}
|
|
436
435
|
await Promise.all((0, weapps_core_1.loopDealWithFn)(appData.pageInstanceList, async (page) => {
|
|
437
|
-
const codes = (0,
|
|
436
|
+
const codes = (0, cals_1.processRuntimeCodeResources)({ id: page.id }, page.lowCodes || page.codeModules, 'page');
|
|
438
437
|
await codes
|
|
439
438
|
.filter((mod) => mod.type !== 'renderer')
|
|
440
439
|
.forEach((m) => {
|
|
@@ -21,7 +21,7 @@ async function writeCode2file(mod, lowcodeRootDir, opts = {}, themeCode, ctx) {
|
|
|
21
21
|
const relativeRoot = (ctx === null || ctx === void 0 ? void 0 : ctx.isMixMode) && ctx.rootPath ? `${path_1.default.relative(ctx.rootPath, '')}/` : '';
|
|
22
22
|
let weappsApiPrefix = [
|
|
23
23
|
`import { app, process } from '${relativeRoot}${baseDir}/app/weapps-api';`,
|
|
24
|
-
'const $app = app
|
|
24
|
+
'const $app = new Proxy({}, { get: function(obj, prop){ return app[prop] }})',
|
|
25
25
|
]; // windows compatibility
|
|
26
26
|
if (pageId !== 'global') {
|
|
27
27
|
weappsApiPrefix.push(`import { $page } from '${baseDir}/pages/${pageId}/api'`);
|
|
@@ -30,7 +30,7 @@ async function writeCode2file(mod, lowcodeRootDir, opts = {}, themeCode, ctx) {
|
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
32
32
|
// Generate component lowcode
|
|
33
|
-
code = `import process from '${mod.type === 'handler-fn' ? '../' : ''}../../../../common/process'\nimport app from '${mod.type === 'handler-fn' ? '../' : ''}../../../../common/weapp-sdk';\nconst $app = app;\n${code.replace(/\$comp/g, weapps_core_1.COMPONENT_API_PREFIX)}`;
|
|
33
|
+
code = `import process from '${mod.type === 'handler-fn' ? '../' : ''}../../../../common/process'\nimport app from '${mod.type === 'handler-fn' ? '../' : ''}../../../../common/weapp-sdk';\nconst $app = new Proxy({}, { get: function(obj, prop){ return app[prop] }});\n${code.replace(/\$comp/g, weapps_core_1.COMPONENT_API_PREFIX)}`;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
@@ -37,6 +37,7 @@ const generateFiles_1 = __importStar(require("../util/generateFiles"));
|
|
|
37
37
|
const lowcode_1 = require("./lowcode");
|
|
38
38
|
const net_1 = require("../util/net");
|
|
39
39
|
const junk = __importStar(require("../util/junk"));
|
|
40
|
+
const cals_1 = require("@cloudbase/cals");
|
|
40
41
|
const templateDir = `${config_1.appTemplateDir}/mp/`;
|
|
41
42
|
async function installMaterials(projDir, usedComps, weapps, ctx) {
|
|
42
43
|
let { materialLibs, isBrowserMpBuilder } = ctx;
|
|
@@ -269,7 +270,8 @@ async function generateCompositeComponent(compositedComp, ctx, compLibCommonReso
|
|
|
269
270
|
delete propDefs[p];
|
|
270
271
|
}
|
|
271
272
|
});
|
|
272
|
-
const
|
|
273
|
+
const codes = (0, cals_1.processRuntimeCodeResources)({ id: '$comp' }, compositedComp.lowCodes, 'component');
|
|
274
|
+
const importor = (0, util_2.generateLowcodeImportor)(codes);
|
|
273
275
|
const pageFileData = {
|
|
274
276
|
'index.js': {
|
|
275
277
|
materialName,
|
|
@@ -305,20 +307,20 @@ async function generateCompositeComponent(compositedComp, ctx, compLibCommonReso
|
|
|
305
307
|
// Generating file by template and data
|
|
306
308
|
await (0, generateFiles_1.default)(pageFileData, `${templateDir}/component`, outDir, ctx);
|
|
307
309
|
// #3 writing lowcode files
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
310
|
+
/**
|
|
311
|
+
* 低码没有开放 index 类别,直接去掉
|
|
312
|
+
*/
|
|
313
|
+
// if (!codes.find((m) => m.name === 'index')) {
|
|
314
|
+
// // @ts-ignore
|
|
315
|
+
// codes.push({
|
|
316
|
+
// code: 'export default {}',
|
|
317
|
+
// name: 'index',
|
|
318
|
+
// path: 'index',
|
|
319
|
+
// });
|
|
320
|
+
// }
|
|
321
|
+
codes.map((mod) => {
|
|
320
322
|
let themeCode;
|
|
321
|
-
if (mod.type ===
|
|
323
|
+
if (mod.type === cals_1.ECodeType.STYLE && compLibCommonResource) {
|
|
322
324
|
themeCode = `
|
|
323
325
|
${compLibCommonResource.theme.variable || ''}
|
|
324
326
|
${compLibCommonResource.class || ''}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IComponentInputProps, IComponentsInfoMap, IPackageJson } from '../types/common';
|
|
2
|
-
import {
|
|
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
|
export declare type PromiseResult<T> = Promise<[null, T] | [Error, null]>;
|
|
5
5
|
export declare function promiseWrapper<T>(p: Promise<T>): PromiseResult<T>;
|
|
@@ -37,7 +37,6 @@ export declare function readComponentLibMata(libDir: any): {
|
|
|
37
37
|
};
|
|
38
38
|
} | null;
|
|
39
39
|
export declare function isOfficialComponentLib(name: any, version: any): boolean;
|
|
40
|
-
export declare function gererateIndexAPI(data: IPageInstance | ICompositedComponent, isComponent?: boolean): void;
|
|
41
40
|
/**
|
|
42
41
|
* 能否使用 Vite
|
|
43
42
|
* @param mode 当前 mode 模式
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.generateLowcodeImportor = exports.getCompileDirs = exports.deepDealComponentSchemaJson = exports.canUseVite = exports.
|
|
6
|
+
exports.generateLowcodeImportor = exports.getCompileDirs = exports.deepDealComponentSchemaJson = exports.canUseVite = exports.isOfficialComponentLib = exports.readComponentLibMata = exports.writeLibCommonRes2file = exports.getYyptConfigInfo = exports.getComponentsInfo = exports.getInputProps = exports.removeRequireUncached = exports.requireUncached = exports.JsonToStringWithVariableName = exports.getSelfPackageJson = exports.getCurrentPackageJson = exports.promiseWrapper = exports.getFileNameByUrl = exports.deepDealSchema = exports.simpleDeepClone = exports.deepDeal = exports.isPlainObject = exports.isArray = exports.getMetaInfoBySourceKey = void 0;
|
|
7
7
|
// import * as R from 'ramda'
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
@@ -225,20 +225,6 @@ function isOfficialComponentLib(name, version) {
|
|
|
225
225
|
return !!((_a = _OFFICIAL_COMPONENT_LIB[name]) === null || _a === void 0 ? void 0 : _a.includes(version)) || ((_b = _OFFICIAL_COMPONENT_LIB[name]) === null || _b === void 0 ? void 0 : _b.includes('*'));
|
|
226
226
|
}
|
|
227
227
|
exports.isOfficialComponentLib = isOfficialComponentLib;
|
|
228
|
-
function gererateIndexAPI(data, isComponent) {
|
|
229
|
-
const lowCodes = data.lowCodes || data.codeModules || [];
|
|
230
|
-
if (!lowCodes.find(({ name }) => name === 'index')) {
|
|
231
|
-
// 补充组件不存在的 index 类型代码
|
|
232
|
-
lowCodes.push({
|
|
233
|
-
type: 'index',
|
|
234
|
-
path: isComponent ? 'index' : `${data.id}/index`,
|
|
235
|
-
name: 'index',
|
|
236
|
-
code: 'export default {}',
|
|
237
|
-
system: true,
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
exports.gererateIndexAPI = gererateIndexAPI;
|
|
242
228
|
/**
|
|
243
229
|
* 能否使用 Vite
|
|
244
230
|
* @param mode 当前 mode 模式
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.19",
|
|
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": "^0.
|
|
42
|
-
"@cloudbase/lowcode-generator": "^1.0.
|
|
41
|
+
"@cloudbase/cals": "^0.4.1",
|
|
42
|
+
"@cloudbase/lowcode-generator": "^1.0.6",
|
|
43
43
|
"axios": "^0.21.0",
|
|
44
44
|
"browserfs": "^1.4.3",
|
|
45
45
|
"browserify-zlib": "^0.2.0",
|
|
@@ -461,7 +461,7 @@
|
|
|
461
461
|
></script>
|
|
462
462
|
<script
|
|
463
463
|
crossorigin
|
|
464
|
-
src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.
|
|
464
|
+
src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.aa184d8a35d646df4cc0.bundle.js"
|
|
465
465
|
></script>
|
|
466
466
|
</body>
|
|
467
467
|
</html>
|
|
@@ -3,17 +3,11 @@ import { createMpApp } from '@cloudbase/weda-client';
|
|
|
3
3
|
import { createComputed, formatEnum, enumOptions } from '<%= subLevelPath %>../common/util'
|
|
4
4
|
import process from '<%= subLevelPath %>../common/process'
|
|
5
5
|
import appGlobal from '<%= subLevelPath %>../app/app-global'
|
|
6
|
-
import { createDataset
|
|
6
|
+
import { createDataset } from '<%= subLevelPath %>../datasources/index'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import common from './common'
|
|
12
|
-
<%} else {%>
|
|
13
|
-
const state = {}
|
|
14
|
-
const computed = {}
|
|
15
|
-
const common = {}
|
|
16
|
-
<%}%>
|
|
8
|
+
<%= importor.state? `import state from '../lowcode/state'` : "const state = {}" %>
|
|
9
|
+
<%= importor.computed? `import computed from '../lowcode/computed'` : "const computed = {}" %>
|
|
10
|
+
<%= importor.common? `import common from './common'` : "const common = {}" %>
|
|
17
11
|
|
|
18
12
|
const mainAppKey = '__weappsMainApp'
|
|
19
13
|
|
package/template/mp/app.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import lifeCycle from './lowcode/lifecycle'
|
|
1
|
+
<%= importor.lifecycle? "import lifeCycle from './lowcode/lifecycle'" : "const lifeCycle = {}" %>
|
|
2
2
|
import { app } from './app/weapps-api'
|
|
3
3
|
// 引入数据源管理器并进行初始化
|
|
4
4
|
import { setConfig, getAccessToken, EXTRA_API, createStateDataSourceVar, generateParamsParser } from './datasources/index'
|
|
@@ -15,7 +15,7 @@ console.warn = (...args) => {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const $app = app;
|
|
18
|
+
const $app = new Proxy({}, { get: function(obj, prop){ return app[prop] }});
|
|
19
19
|
// 设置数据源请求的 loading 及 toast 处理
|
|
20
20
|
setConfig({
|
|
21
21
|
beforeDSRequest: (cfg) => {
|
|
@@ -95,23 +95,15 @@ App({
|
|
|
95
95
|
createStateDataSourceVar('$global', generateParamsParser({ app }))
|
|
96
96
|
|
|
97
97
|
onLaunch && onLaunch.call(this, options)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
app.yyptReport = wxReport
|
|
101
|
-
<% }%>
|
|
102
|
-
|
|
103
|
-
// 初始私有全局数据
|
|
104
|
-
this.$$global = {
|
|
98
|
+
// 初始私有全局数据
|
|
99
|
+
this.$$global = {
|
|
105
100
|
homePageId: '<%= appConfig.homePageId %>'
|
|
106
101
|
}
|
|
107
102
|
},
|
|
108
103
|
onShow(options) {
|
|
109
104
|
const fn = lifeCycle.onShow || lifeCycle.onAppShow
|
|
110
105
|
fn && fn.call(this, options)
|
|
111
|
-
|
|
112
|
-
wxReport.startReport()
|
|
113
|
-
<% }%>
|
|
114
|
-
},
|
|
106
|
+
},
|
|
115
107
|
onHide() {
|
|
116
108
|
const fn = lifeCycle.onHide || lifeCycle.onAppHide
|
|
117
109
|
fn && fn.call(this)
|
package/template/mp/app.wxss
CHANGED
|
@@ -8,8 +8,5 @@ page view, page element, page text, page image {
|
|
|
8
8
|
box-sizing: border-box;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
/** import styles specified by material libs*/<% importStyles.map(style => {%>
|
|
11
|
+
/** import styles specified by material libs & lowcode styles if exist*/<% importStyles.map(style => {%>
|
|
12
12
|
@import '<%= style %>';<%})%>
|
|
13
|
-
|
|
14
|
-
/** import lowcode styles */
|
|
15
|
-
@import 'lowcode/style.wxss';
|
|
@@ -2,10 +2,9 @@ import { observable } from 'mobx';
|
|
|
2
2
|
import { createComponent } from '../../../common/weapp-component'
|
|
3
3
|
import { concatClassList, px2rpx } from '../../../common/style'
|
|
4
4
|
import app from '../../../common/weapp-sdk'
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import computedFuncs from './lowcode/computed'
|
|
5
|
+
<%= importor.lifecycle? "import lifeCycle from './lowcode/lifecycle'" : "const lifeCycle = {}" %>
|
|
6
|
+
<%= importor.state? "import stateFn from './lowcode/state'" : "const stateFn = {}" %>
|
|
7
|
+
<%= importor.computed? "import computedFuncs from './lowcode/computed'" : "const computedFuncs = {}" %>
|
|
9
8
|
<% handlers.forEach(h => {%>
|
|
10
9
|
import _handler<%= h %> from './lowcode/handler/<%= h %>' <%}) %>
|
|
11
10
|
import * as constObj from '../libCommonRes/const'
|
|
@@ -61,4 +60,4 @@ const dataBinds = {<% Object.entries(dataBinds).map(([id, widgetBinds])=>{%>
|
|
|
61
60
|
const config = <%= JSON.stringify(config || {})%>
|
|
62
61
|
|
|
63
62
|
createComponent('<%= key %>', behaviors, properties, events, handler, dataBinds, evtListeners, widgetProps,
|
|
64
|
-
|
|
63
|
+
{}, lifeCycle, stateFn, computedFuncs, config, { const: constObj, tools: toolsObj }, libCode, context)
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
<% importStyles.map(style => {%>
|
|
2
|
+
@import '<%= style %>';<%})%>
|
|
@@ -3,12 +3,12 @@ import { createPage } from '<%= subLevelPath %>../../common/weapp-page'
|
|
|
3
3
|
import { concatClassList, px2rpx } from '<%= subLevelPath %>../../common/style'
|
|
4
4
|
import { app } from '<%= subLevelPath %>../../app/weapps-api'
|
|
5
5
|
import { <%= pageName %> as handlers } from '../../app/handlers'
|
|
6
|
-
import lifecyle from '../../lowcode
|
|
7
|
-
import state from '../../lowcode
|
|
8
|
-
import computed from '../../lowcode
|
|
6
|
+
<%= importor.lifecycle? `import lifecyle from '../../lowcode/${pageName}/lifecycle'` : "const lifecyle = {}" %>
|
|
7
|
+
<%= importor.state? `import state from '../../lowcode/${pageName}/state'` : "const state = {}" %>
|
|
8
|
+
<%= importor.computed? `import computed from '../../lowcode/${pageName}/computed'` : "const computed = {}" %>
|
|
9
9
|
import { $page } from './api'
|
|
10
10
|
|
|
11
|
-
const $app = app;
|
|
11
|
+
const $app = new Proxy({}, { get: function(obj, prop){ return app[prop] }});
|
|
12
12
|
const context = observable({});
|
|
13
13
|
|
|
14
14
|
const widgetProps = <%= stringifyObj(widgetProps, {depth: null}) %>
|