@cloudbase/lowcode-builder 0.1.24 → 1.0.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/lib/builder/core/index.d.ts +1 -3
- package/lib/builder/core/index.js +42 -52
- package/lib/builder/h5/compile.d.ts +1 -1
- package/lib/builder/h5/compile.js +59 -20
- package/lib/builder/h5/copy.js +2 -4
- package/lib/builder/h5/generate.js +3 -3
- package/lib/builder/h5/index.d.ts +5 -4
- package/lib/builder/h5/index.js +25 -14
- package/lib/builder/h5/material.js +6 -11
- package/lib/builder/h5/npm.js +6 -5
- package/lib/builder/mp/index.js +38 -49
- package/lib/builder/mp/materials.js +25 -18
- package/lib/builder/mp/mixMode.js +7 -10
- package/lib/builder/mp/mp_config.js +2 -3
- package/lib/builder/mp/wxml.js +1 -1
- package/lib/builder/service/webpack.d.ts +7 -1
- package/lib/builder/service/webpack.js +97 -24
- package/lib/builder/types/common.d.ts +1 -1
- package/lib/builder/types/common.js +2 -1
- package/lib/builder/util/common.js +1 -4
- package/lib/builder/util/generateFiles.js +12 -10
- package/lib/builder/util/mp.js +2 -8
- package/lib/builder.web.js +71 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +6 -0
- package/lib/types.d.ts +1 -0
- package/lib/types.js +11 -0
- package/package.json +3 -8
- package/template/html/index.html.ejs +59 -29
- package/template/mp/app.js +11 -0
- package/template/mp/common/weapp-page.js +23 -1
- package/template/mp/package.json +1 -1
- package/template/mp/page/index.js +2 -1
- package/template/package.json +5 -2
- package/template/webpack/getCSSModuleLocalIdent.js +28 -0
- package/template/webpack/web.prod.js +112 -103
- package/template/src/app/common.js +0 -13
- package/template/src/app/global-api.js +0 -99
- package/template/src/app/handlers.js +0 -13
- package/template/src/app/material-actions.js +0 -16
- package/template/src/app/mountAppApis.js +0 -25
- package/template/src/app/mountMpApis.js +0 -4
- package/template/src/datasources/config.js.tpl +0 -23
- package/template/src/datasources/dataset-profiles.js.tpl +0 -5
- package/template/src/datasources/datasource-profiles.js.tpl +0 -4
- package/template/src/datasources/index.js +0 -31
- package/template/src/handlers/FieldMiddleware/renderer.jsx +0 -331
- package/template/src/handlers/HotAreas.js +0 -36
- package/template/src/handlers/PositionHandler.jsx +0 -8
- package/template/src/handlers/actionHandler/utils.js +0 -149
- package/template/src/handlers/componentEventActionEmitter.js +0 -29
- package/template/src/handlers/componentNodeMap.js +0 -24
- package/template/src/handlers/controller.js +0 -5
- package/template/src/handlers/emitComponentEvent.js +0 -8
- package/template/src/handlers/eventListener/componentEventListener.js +0 -15
- package/template/src/handlers/eventListener/hotAreaEventListener.js +0 -32
- package/template/src/handlers/eventListener/index.js +0 -29
- package/template/src/handlers/eventListener/pageEventListener.js +0 -11
- package/template/src/handlers/eventListener/types.js +0 -32
- package/template/src/handlers/hooks/index.js +0 -14
- package/template/src/handlers/initWebEnv.js +0 -4
- package/template/src/handlers/injectStyle.js +0 -14
- package/template/src/handlers/instanceMap.js +0 -39
- package/template/src/handlers/lifecycle.js +0 -232
- package/template/src/handlers/render.jsx +0 -131
- package/template/src/handlers/utils/common.js +0 -151
- package/template/src/handlers/utils/eventProxy.js +0 -64
- package/template/src/handlers/utils/events.js +0 -8
- package/template/src/handlers/utils/index.js +0 -4
- package/template/src/handlers/utils/widgets.js +0 -320
- package/template/src/index.jsx +0 -142
- package/template/src/index.less +0 -119
- package/template/src/libraries/default-lib/wx_yypt_report_v2.js +0 -441
- package/template/src/pages/app.tpl +0 -124
- package/template/src/router/index.tpl +0 -28
- package/template/src/store/computed.js +0 -11
- package/template/src/store/index.js +0 -40
- package/template/src/utils/ScanCodeComponent.js +0 -396
- package/template/src/utils/date.js +0 -324
- package/template/src/utils/history.js +0 -72
- package/template/src/utils/index.js +0 -67
- package/template/src/utils/kbone.js +0 -18
- package/template/src/utils/monitor-jssdk.min.js +0 -763
- package/template/src/utils/request.js +0 -5
- package/template/src/utils/scan-code-action.js +0 -27
package/lib/builder/mp/index.js
CHANGED
|
@@ -54,7 +54,7 @@ async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins
|
|
|
54
54
|
var _a;
|
|
55
55
|
const operationLabel = em('Wexin MiniProgram Generated');
|
|
56
56
|
console.time(operationLabel);
|
|
57
|
-
console.log(
|
|
57
|
+
console.log(`Generating ${em('Wexin MiniProgram')} to ${projDir}`);
|
|
58
58
|
console.log(em('domain') + domain);
|
|
59
59
|
let mainAppData = weapps[0];
|
|
60
60
|
const buildContext = {
|
|
@@ -74,7 +74,7 @@ async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins
|
|
|
74
74
|
weapps,
|
|
75
75
|
materials,
|
|
76
76
|
});
|
|
77
|
-
buildContext
|
|
77
|
+
buildContext.miniprogramPlugins = (mainAppData.miniprogramPlugins || []).filter((plugin) => allAppUsedComps[plugin.name]);
|
|
78
78
|
// 安装依赖库,生成 materials 目录
|
|
79
79
|
await (0, materials_1.installMaterials)(projDir, allAppUsedComps, weapps, buildContext);
|
|
80
80
|
const wxmlDataPrefix = (0, mp_1.getWxmlDataPrefix)(!isProduction);
|
|
@@ -107,7 +107,7 @@ async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins
|
|
|
107
107
|
...appFileData,
|
|
108
108
|
'common/style.js': {},
|
|
109
109
|
'common/utils.wxs': {
|
|
110
|
-
domain
|
|
110
|
+
domain,
|
|
111
111
|
},
|
|
112
112
|
'common/util.js': {
|
|
113
113
|
isAdminPortal: (0, common_1.buildAsAdminPortalByBuildType)(buildTypeList),
|
|
@@ -149,13 +149,11 @@ async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins
|
|
|
149
149
|
appFileData = {
|
|
150
150
|
...appFileData,
|
|
151
151
|
'common/wx_yypt_report_v2.js': {},
|
|
152
|
-
'app.js': { yyptConfig
|
|
152
|
+
'app.js': { yyptConfig, appConfig },
|
|
153
153
|
'app.json': { content: appConfig },
|
|
154
154
|
'app.wxss': {
|
|
155
155
|
importStyles: materials.reduce((styles, lib) => {
|
|
156
|
-
styles = styles.concat((lib.styles || []).map((stylePath) => stylePath && !stylePath.startsWith('/')
|
|
157
|
-
? `/${config_1.materialsDirName}/${lib.name}/${stylePath}`
|
|
158
|
-
: stylePath) || []);
|
|
156
|
+
styles = styles.concat((lib.styles || []).map((stylePath) => stylePath && !stylePath.startsWith('/') ? `/${config_1.materialsDirName}/${lib.name}/${stylePath}` : stylePath) || []);
|
|
159
157
|
return styles;
|
|
160
158
|
}, []),
|
|
161
159
|
},
|
|
@@ -165,15 +163,11 @@ async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins
|
|
|
165
163
|
},
|
|
166
164
|
};
|
|
167
165
|
}
|
|
168
|
-
console.log(
|
|
166
|
+
console.log(`Generating ${em('miniprogramRoot')} files`);
|
|
169
167
|
await (0, generateFiles_1.default)(appFileData, templateDir, miniprogramRoot, buildContext);
|
|
170
168
|
// 若项目目录与小程序根目录不同,则拷贝素材到小程序根目录
|
|
171
|
-
if (miniprogramRoot !== path_1.default.join(projDir, '/') &&
|
|
172
|
-
|
|
173
|
-
console.log('Move ' +
|
|
174
|
-
em(config_1.materialsDirName) +
|
|
175
|
-
' from' +
|
|
176
|
-
`${projDir} to ${miniprogramRoot}`);
|
|
169
|
+
if (miniprogramRoot !== path_1.default.join(projDir, '/') && fs.existsSync(path_1.default.join(projDir, config_1.materialsDirName))) {
|
|
170
|
+
console.log(`Move ${em(config_1.materialsDirName)} from` + `${projDir} to ${miniprogramRoot}`);
|
|
177
171
|
await fs.move(path_1.default.join(projDir, config_1.materialsDirName), path_1.default.join(miniprogramRoot, config_1.materialsDirName));
|
|
178
172
|
}
|
|
179
173
|
// 生成数据源
|
|
@@ -197,7 +191,7 @@ async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins
|
|
|
197
191
|
datasetProfiles: (0, util_3.JsonToStringWithVariableName)((0, lowcode_generator_1.getDatasetProfiles)(mainAppData, weapps), { EOL: true }),
|
|
198
192
|
},
|
|
199
193
|
};
|
|
200
|
-
console.log(
|
|
194
|
+
console.log(`Generating ${em('datasources')} files`);
|
|
201
195
|
await (0, generateFiles_1.default)(datasourceFileData, templateDir, miniprogramRoot, buildContext);
|
|
202
196
|
}
|
|
203
197
|
// 生成子包
|
|
@@ -225,16 +219,14 @@ async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins
|
|
|
225
219
|
}
|
|
226
220
|
}
|
|
227
221
|
}));
|
|
228
|
-
if (!isBrowserMpBuilder &&
|
|
229
|
-
fs.existsSync(path_1.default.join(miniprogramRoot, 'package.json'))) {
|
|
222
|
+
if (!isBrowserMpBuilder && fs.existsSync(path_1.default.join(miniprogramRoot, 'package.json'))) {
|
|
230
223
|
await (0, webpack_1.installDependencies)(miniprogramRoot);
|
|
231
224
|
}
|
|
232
225
|
await handleMpPlugins();
|
|
233
226
|
console.timeEnd(operationLabel);
|
|
234
227
|
// web端的builder不需要清除
|
|
235
228
|
!isBrowserMpBuilder && cleanProj(weapps, miniprogramRoot);
|
|
236
|
-
!isBrowserMpBuilder &&
|
|
237
|
-
cleanMaterils(path_1.default.join(miniprogramRoot, config_1.materialsDirName), allAppUsedComps);
|
|
229
|
+
!isBrowserMpBuilder && cleanMaterils(path_1.default.join(miniprogramRoot, config_1.materialsDirName), allAppUsedComps);
|
|
238
230
|
return { miniprogramRoot };
|
|
239
231
|
function resolveNpmDeps() {
|
|
240
232
|
var _a;
|
|
@@ -248,7 +240,7 @@ async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins
|
|
|
248
240
|
.filter((app) => !!app.rootPath)
|
|
249
241
|
.map((app) => ({
|
|
250
242
|
deps: app.npmDependencies,
|
|
251
|
-
name:
|
|
243
|
+
name: `子包:${app.rootPath}`,
|
|
252
244
|
})));
|
|
253
245
|
deps.push(...materials
|
|
254
246
|
.filter((lib) => lib.isComposite && lib.compLibCommonResource)
|
|
@@ -256,12 +248,12 @@ async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins
|
|
|
256
248
|
var _a;
|
|
257
249
|
return ({
|
|
258
250
|
deps: ((_a = lib.compLibCommonResource) === null || _a === void 0 ? void 0 : _a.npm) || {},
|
|
259
|
-
name:
|
|
251
|
+
name: `组件库级别${lib.name}`,
|
|
260
252
|
});
|
|
261
253
|
}));
|
|
262
254
|
deps.push(...materials.map((lib) => ({
|
|
263
255
|
deps: lib.dependencies || {},
|
|
264
|
-
name:
|
|
256
|
+
name: `组件库${lib.name}`,
|
|
265
257
|
})));
|
|
266
258
|
return deps.reduce((result, cur) => {
|
|
267
259
|
Object.keys(cur.deps || {}).map((npmPkgName) => {
|
|
@@ -269,7 +261,7 @@ async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins
|
|
|
269
261
|
result[npmPkgName] = cur.deps[npmPkgName];
|
|
270
262
|
}
|
|
271
263
|
else if (result[npmPkgName] != cur.deps[npmPkgName]) {
|
|
272
|
-
console.error(error(cur.name
|
|
264
|
+
console.error(error(`${cur.name}的Npm依赖${npmPkgName}已在其他地方定义,将被忽略`));
|
|
273
265
|
}
|
|
274
266
|
});
|
|
275
267
|
return result;
|
|
@@ -285,7 +277,7 @@ async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins
|
|
|
285
277
|
exports.generateWxMp = generateWxMp;
|
|
286
278
|
async function generatePkg(weapp, appRoot, ctx, pageConfigs) {
|
|
287
279
|
const wxmlDataPrefix = (0, mp_1.getWxmlDataPrefix)(!ctx.isProduction);
|
|
288
|
-
console.log(
|
|
280
|
+
console.log(`Generating ${em(weapp.rootPath ? 'subApp' : 'app')} to ${appRoot}`);
|
|
289
281
|
if (weapp.mpPkgUrl) {
|
|
290
282
|
// 清空历史文件,使用zip覆盖
|
|
291
283
|
console.log(`Removing ${appRoot}`);
|
|
@@ -297,10 +289,10 @@ async function generatePkg(weapp, appRoot, ctx, pageConfigs) {
|
|
|
297
289
|
}
|
|
298
290
|
else {
|
|
299
291
|
// #2 generate page files
|
|
300
|
-
console.log(
|
|
292
|
+
console.log(`Generating ${em('page')} files`);
|
|
301
293
|
(0, generateFiles_1.cleanDir)(path_1.default.join(appRoot, 'pages'), []);
|
|
302
294
|
await Promise.all(weapp.pageInstanceList.map(async (page) => {
|
|
303
|
-
var _a;
|
|
295
|
+
var _a, _b;
|
|
304
296
|
// # Generating page
|
|
305
297
|
const rootPath = weapp.rootPath || '';
|
|
306
298
|
const usingComponents = {};
|
|
@@ -313,11 +305,15 @@ async function generatePkg(weapp, appRoot, ctx, pageConfigs) {
|
|
|
313
305
|
widgetProps: (0, util_2.createWidgetProps)(page.componentInstances, ctx),
|
|
314
306
|
pageUUID: rootPath ? `${rootPath}/${page.id}` : page.id,
|
|
315
307
|
pageName: page.id,
|
|
308
|
+
pageSource: page.data.src || '',
|
|
316
309
|
eventHanlders: (0, util_2.createEventHanlders)(page.componentInstances, 'this', ctx),
|
|
317
310
|
dataBinds: (0, util_2.createDataBinds)(page.componentInstances, ctx),
|
|
311
|
+
pageAttributes: {
|
|
312
|
+
...(((_a = page.data) === null || _a === void 0 ? void 0 : _a.appShareMessage) ? { appShareMessage: page.data.appShareMessage.value } : {}),
|
|
313
|
+
},
|
|
318
314
|
debug: ctx.debugMode,
|
|
319
315
|
stringifyObj: util_1.inspect,
|
|
320
|
-
subLevelPath: rootPath ? path_1.default.relative(rootPath, '')
|
|
316
|
+
subLevelPath: rootPath ? `${path_1.default.relative(rootPath, '')}/` : '',
|
|
321
317
|
},
|
|
322
318
|
[`index.json|${pageFileName}.json`]: {
|
|
323
319
|
usingComponents,
|
|
@@ -329,7 +325,7 @@ async function generatePkg(weapp, appRoot, ctx, pageConfigs) {
|
|
|
329
325
|
content: wxml,
|
|
330
326
|
},
|
|
331
327
|
[`index.wxss|${pageFileName}.wxss`]: {
|
|
332
|
-
subWxss: rootPath && !((
|
|
328
|
+
subWxss: rootPath && !((_b = ctx.mainAppData) === null || _b === void 0 ? void 0 : _b.mpPkgUrl)
|
|
333
329
|
? `@import "${path_1.default.relative(`/${rootPath}/pages/${page.id}`, '/lowcode')}/style.wxss";`
|
|
334
330
|
: '',
|
|
335
331
|
content: (0, weapps_core_1.toCssText)((0, weapps_core_1.toCssStyle)(page.commonStyle, {
|
|
@@ -340,7 +336,7 @@ async function generatePkg(weapp, appRoot, ctx, pageConfigs) {
|
|
|
340
336
|
},
|
|
341
337
|
};
|
|
342
338
|
// Generating file by template and data
|
|
343
|
-
await (0, generateFiles_1.default)(pageFileData, templateDir
|
|
339
|
+
await (0, generateFiles_1.default)(pageFileData, `${templateDir}/page`, path_1.default.join(appRoot, 'pages', page.id), ctx);
|
|
344
340
|
}));
|
|
345
341
|
// #3 writing lowcode files
|
|
346
342
|
await writeLowCodeFiles(weapp, appRoot, ctx);
|
|
@@ -384,9 +380,7 @@ async function generateFramework(appData, outDir, ctx) {
|
|
|
384
380
|
'app/weapps-api.js': {
|
|
385
381
|
appId: ctx.appId,
|
|
386
382
|
domain: ctx.domain || '',
|
|
387
|
-
subLevelPath: appData.rootPath
|
|
388
|
-
? path_1.default.relative(`${appData.rootPath}`, '') + '/'
|
|
389
|
-
: '',
|
|
383
|
+
subLevelPath: appData.rootPath ? `${path_1.default.relative(`${appData.rootPath}`, '')}/` : '',
|
|
390
384
|
subPackageName: appData.rootPath || '',
|
|
391
385
|
isBare: false,
|
|
392
386
|
appConfig: (0, util_3.JsonToStringWithVariableName)({
|
|
@@ -446,12 +440,17 @@ async function writeLowCodeFiles(appData, outDir, ctx) {
|
|
|
446
440
|
}
|
|
447
441
|
exports.writeLowCodeFiles = writeLowCodeFiles;
|
|
448
442
|
// {a: 1} -> , "a": 1
|
|
449
|
-
function getAppendableJson(
|
|
443
|
+
function getAppendableJson(json) {
|
|
444
|
+
const obj = { ...json };
|
|
445
|
+
if (obj.reachBottomDistance) {
|
|
446
|
+
obj.onReachBottomDistance = parseInt(obj.reachBottomDistance, 10) || 0;
|
|
447
|
+
delete obj.reachBottomDistance;
|
|
448
|
+
}
|
|
450
449
|
if (obj && Object.keys(obj).length > 0) {
|
|
451
450
|
let str = JSON.stringify(obj);
|
|
452
451
|
str = str.substr(1, str.length - 2).trim();
|
|
453
452
|
if (str) {
|
|
454
|
-
return
|
|
453
|
+
return `,\n${str}`;
|
|
455
454
|
}
|
|
456
455
|
}
|
|
457
456
|
return '';
|
|
@@ -470,10 +469,7 @@ function handleUsedComponents({ buildContext, weapps, materials, }) {
|
|
|
470
469
|
// merge all app/subapp used
|
|
471
470
|
let allAppUsedComps = appUsedComps.reduce((comps, item) => {
|
|
472
471
|
Object.keys(item.usedComps).forEach((libName) => {
|
|
473
|
-
comps[libName] = new Set([
|
|
474
|
-
...Array.from(item.usedComps[libName]),
|
|
475
|
-
...Array.from(comps[libName] || []),
|
|
476
|
-
]);
|
|
472
|
+
comps[libName] = new Set([...Array.from(item.usedComps[libName]), ...Array.from(comps[libName] || [])]);
|
|
477
473
|
});
|
|
478
474
|
return comps;
|
|
479
475
|
}, {});
|
|
@@ -499,9 +495,7 @@ async function cleanPkg(pkg, miniprogramRoot) {
|
|
|
499
495
|
if (pkg.mpPkgUrl) {
|
|
500
496
|
return;
|
|
501
497
|
}
|
|
502
|
-
const pkgDir = [miniprogramRoot, pkg.rootPath]
|
|
503
|
-
.filter((p) => !!p)
|
|
504
|
-
.join(path_1.default.sep);
|
|
498
|
+
const pkgDir = [miniprogramRoot, pkg.rootPath].filter((p) => !!p).join(path_1.default.sep);
|
|
505
499
|
const pagesDir = path_1.default.join(pkgDir, 'pages');
|
|
506
500
|
const lowcodesDir = path_1.default.join(pkgDir, 'lowcode');
|
|
507
501
|
const existedPages = await fs.readdir(pagesDir);
|
|
@@ -518,14 +512,12 @@ async function cleanPkg(pkg, miniprogramRoot) {
|
|
|
518
512
|
else {
|
|
519
513
|
// #2 clean deleted handlers
|
|
520
514
|
const handlersDir = path_1.default.join(lowcodeDir, 'handler');
|
|
521
|
-
const handlers = ((_d = (_c = (_b = (_a = pkg === null || pkg === void 0 ? void 0 : pkg.pageInstanceList) === null || _a === void 0 ? void 0 : _a.find((p) => p.id === pageName)) === null || _b === void 0 ? void 0 : _b.lowCodes) === null || _c === void 0 ? void 0 : _c.filter((m) => m.type === 'handler-fn')) === null || _d === void 0 ? void 0 : _d.map((m) => m.name
|
|
515
|
+
const handlers = ((_d = (_c = (_b = (_a = pkg === null || pkg === void 0 ? void 0 : pkg.pageInstanceList) === null || _a === void 0 ? void 0 : _a.find((p) => p.id === pageName)) === null || _b === void 0 ? void 0 : _b.lowCodes) === null || _c === void 0 ? void 0 : _c.filter((m) => m.type === 'handler-fn')) === null || _d === void 0 ? void 0 : _d.map((m) => `${m.name}.js`)) || [];
|
|
522
516
|
(0, generateFiles_1.cleanDir)(handlersDir, handlers);
|
|
523
517
|
}
|
|
524
518
|
});
|
|
525
519
|
// #3 clean deleted common modules
|
|
526
|
-
const commonModules = pkg.lowCodes
|
|
527
|
-
.filter((m) => m.type === 'normal-module')
|
|
528
|
-
.map((m) => m.name + '.js');
|
|
520
|
+
const commonModules = pkg.lowCodes.filter((m) => m.type === 'normal-module').map((m) => `${m.name}.js`);
|
|
529
521
|
const commonDir = path_1.default.join(lowcodesDir, 'common');
|
|
530
522
|
(0, generateFiles_1.cleanDir)(commonDir, commonModules);
|
|
531
523
|
}
|
|
@@ -550,10 +542,7 @@ function cleanMaterils(materialsDir, usedComps) {
|
|
|
550
542
|
(0, generateFiles_1.removeFile)(libDir);
|
|
551
543
|
return;
|
|
552
544
|
}
|
|
553
|
-
(0, generateFiles_1.cleanDir)(libDir, [
|
|
554
|
-
...Array.from(usedComps[libName]),
|
|
555
|
-
'libCommonRes',
|
|
556
|
-
]);
|
|
545
|
+
(0, generateFiles_1.cleanDir)(libDir, [...Array.from(usedComps[libName]), 'libCommonRes']);
|
|
557
546
|
});
|
|
558
547
|
}
|
|
559
548
|
}
|
|
@@ -87,29 +87,35 @@ async function installMaterials(projDir, usedComps, weapps, ctx) {
|
|
|
87
87
|
// #2 从根目录 copy meta 文件
|
|
88
88
|
const metaJosnPath = path.join(materialsSrcDir, 'meta.json');
|
|
89
89
|
if (fs.existsSync(metaJosnPath)) {
|
|
90
|
-
!isBrowserMpBuilder
|
|
90
|
+
!isBrowserMpBuilder
|
|
91
|
+
? await fs.copy(metaJosnPath, path.join(targetDir, 'meta.json'))
|
|
92
|
+
: (0, generateFiles_1.copyRecursiveSync)(metaJosnPath, path.join(targetDir, 'meta.json'));
|
|
91
93
|
}
|
|
92
94
|
// #3 copy 组件库代码文件到项目目录
|
|
93
|
-
!isBrowserMpBuilder
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
!isBrowserMpBuilder
|
|
96
|
+
? await fs.copy(materialsSrcDirPath, targetDir, {
|
|
97
|
+
filter: function (src, dest) {
|
|
98
|
+
const path = src.split('/');
|
|
99
|
+
return !junk.is(path[path.length - 1]);
|
|
100
|
+
},
|
|
101
|
+
})
|
|
102
|
+
: (0, generateFiles_1.copyRecursiveSync)(materialsSrcDirPath, targetDir, {
|
|
103
|
+
filter: filterMaterial,
|
|
104
|
+
});
|
|
101
105
|
}
|
|
102
106
|
else {
|
|
103
107
|
console.log(`Copying material ${materialId} from ${materialsSrcDir} to ${targetDir}`);
|
|
104
108
|
// #2 link material to current project
|
|
105
|
-
!isBrowserMpBuilder
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
!isBrowserMpBuilder
|
|
110
|
+
? await fs.copy(materialsSrcDir, targetDir, {
|
|
111
|
+
filter: function (src, dest) {
|
|
112
|
+
const path = src.split('/');
|
|
113
|
+
return !junk.is(path[path.length - 1]);
|
|
114
|
+
},
|
|
115
|
+
})
|
|
116
|
+
: (0, generateFiles_1.copyRecursiveSync)(materialsSrcDir, targetDir, {
|
|
117
|
+
filter: filterMaterial,
|
|
118
|
+
});
|
|
113
119
|
}
|
|
114
120
|
}
|
|
115
121
|
const libMeta = (0, util_4.readComponentLibMata)(targetDir);
|
|
@@ -357,7 +363,8 @@ function getWxmlTag(cmp, ctx, nameMangler) {
|
|
|
357
363
|
compPath =
|
|
358
364
|
compPath.startsWith('/') || compPath.indexOf('://') > 0
|
|
359
365
|
? compPath
|
|
360
|
-
:
|
|
366
|
+
: path.posix.join(
|
|
367
|
+
/*ctx.isMixMode ? '/' + rootPath : */ '', `/${config_1.materialsDirName}/${cmp.moduleName}`, compPath);
|
|
361
368
|
tagName = `${moduleName}-${name}`;
|
|
362
369
|
if (nameMangler) {
|
|
363
370
|
tagName = nameMangler.mangle(tagName);
|
|
@@ -26,11 +26,11 @@ exports.handleMixMaterials = exports.handleMixMode = void 0;
|
|
|
26
26
|
const path_1 = __importDefault(require("path"));
|
|
27
27
|
const fs_extra_1 = __importStar(require("fs-extra"));
|
|
28
28
|
const mp_1 = require("../util/mp");
|
|
29
|
-
const core_1 = require("../core");
|
|
30
29
|
const plugin_1 = require("./plugin");
|
|
31
|
-
const lodash_1 =
|
|
30
|
+
const lodash_1 = require("lodash");
|
|
32
31
|
const chalk_1 = __importDefault(require("chalk"));
|
|
33
32
|
const generateFiles_1 = require("../util/generateFiles");
|
|
33
|
+
const webpack_1 = require("../service/webpack");
|
|
34
34
|
// 将 BUILD 目录往混合模式移动
|
|
35
35
|
async function handleMixMode({ apps = [], generateMpPath, miniprogramRoot, plugins = [], }) {
|
|
36
36
|
// await handleMainApp()
|
|
@@ -38,7 +38,7 @@ async function handleMixMode({ apps = [], generateMpPath, miniprogramRoot, plugi
|
|
|
38
38
|
await handleSubApps();
|
|
39
39
|
// await handleAppJson()
|
|
40
40
|
// await handlePkgJson()
|
|
41
|
-
await (0,
|
|
41
|
+
await (0, webpack_1.installDependencies)(miniprogramRoot);
|
|
42
42
|
await handlePlugins();
|
|
43
43
|
// 复制框架公用内容
|
|
44
44
|
async function handleMainApp() {
|
|
@@ -132,9 +132,7 @@ async function handleMixMode({ apps = [], generateMpPath, miniprogramRoot, plugi
|
|
|
132
132
|
'miniprograme_npm',
|
|
133
133
|
].map((name) => {
|
|
134
134
|
let clearPath = path_1.default.join(subAppPath, name);
|
|
135
|
-
return name.includes('.')
|
|
136
|
-
? (0, generateFiles_1.removeFile)(clearPath)
|
|
137
|
-
: (0, generateFiles_1.cleanDir)(clearPath, []);
|
|
135
|
+
return name.includes('.') ? (0, generateFiles_1.removeFile)(clearPath) : (0, generateFiles_1.cleanDir)(clearPath, []);
|
|
138
136
|
}));
|
|
139
137
|
}));
|
|
140
138
|
if (modifiedAppJson) {
|
|
@@ -179,11 +177,10 @@ async function handleMixMaterials(projDir, apps, appUsedComps, compositedLibs) {
|
|
|
179
177
|
var _a;
|
|
180
178
|
const rootPath = app.rootPath || '';
|
|
181
179
|
const materialsDirPath = path_1.default.join(projDir, rootPath, 'materials');
|
|
182
|
-
const usedComps = ((_a = appUsedComps.find((item) => item.rootPath === rootPath)) === null || _a === void 0 ? void 0 : _a.usedComps) ||
|
|
183
|
-
{};
|
|
180
|
+
const usedComps = ((_a = appUsedComps.find((item) => item.rootPath === rootPath)) === null || _a === void 0 ? void 0 : _a.usedComps) || {};
|
|
184
181
|
const materialsLib = await readDirs(materialsDirPath);
|
|
185
182
|
// 清理未使用的组件库
|
|
186
|
-
const cleanLibs = lodash_1.
|
|
183
|
+
const cleanLibs = (0, lodash_1.difference)(materialsLib, Object.keys(usedComps));
|
|
187
184
|
await removeDirs(cleanLibs.map((libName) => path_1.default.join(materialsDirPath, libName)));
|
|
188
185
|
// 清理未使用的组件
|
|
189
186
|
await Promise.all(Object.keys(usedComps).map(async (libName) => {
|
|
@@ -193,7 +190,7 @@ async function handleMixMaterials(projDir, apps, appUsedComps, compositedLibs) {
|
|
|
193
190
|
}
|
|
194
191
|
const libComponents = usedComps[libName];
|
|
195
192
|
const materialsLibComps = await readDirs(path_1.default.join(materialsDirPath, libName));
|
|
196
|
-
const cleanComps = lodash_1.
|
|
193
|
+
const cleanComps = (0, lodash_1.difference)(materialsLibComps, Array.from(libComponents));
|
|
197
194
|
await removeDirs(cleanComps.map((compName) => path_1.default.join(materialsDirPath, libName, compName)));
|
|
198
195
|
}));
|
|
199
196
|
}));
|
|
@@ -43,8 +43,7 @@ function generateMpConfig(weapps, ctx) {
|
|
|
43
43
|
};
|
|
44
44
|
const { miniprogramPlugins = [] } = ctx;
|
|
45
45
|
const projConfig = (0, lodash_1.merge)({}, mp_1.defaultProjConfig, {
|
|
46
|
-
projectname: (ctx.mainAppData && ctx.mainAppData.label) ||
|
|
47
|
-
`WeDa-${ctx.appId}`,
|
|
46
|
+
projectname: (ctx.mainAppData && ctx.mainAppData.label) || `WeDa-${ctx.appId}`,
|
|
48
47
|
});
|
|
49
48
|
const pageConfigs = weapps.map((app) => {
|
|
50
49
|
var _a;
|
|
@@ -202,7 +201,7 @@ function mergeSubPackages(base = [], extra = []) {
|
|
|
202
201
|
const current = baseMap[subpackage.root];
|
|
203
202
|
current.pages = Array.from(new Set([...(current.pages || []), ...(subpackage.pages || [])]));
|
|
204
203
|
if (current.plugins || subpackage.plugins) {
|
|
205
|
-
current.plugins = (0, lodash_1.merge)(current.
|
|
204
|
+
current.plugins = (0, lodash_1.merge)(current.plugins, subpackage.plugins);
|
|
206
205
|
}
|
|
207
206
|
}
|
|
208
207
|
return base;
|
package/lib/builder/mp/wxml.js
CHANGED
|
@@ -202,7 +202,7 @@ function generateWxml(widgets, docTag, wxmlDataPrefix, ctx, usingComponents, com
|
|
|
202
202
|
node.attributes[getMpEventAttr(evtName, modifiers, tagName)] = getMpEventHanlderName(id, evtName, modifiers);
|
|
203
203
|
});
|
|
204
204
|
// 扩展组件配置
|
|
205
|
-
const compConfig = componentProto
|
|
205
|
+
const { compConfig } = componentProto;
|
|
206
206
|
// 如果是数据容器,则增加一个onDataChange事件 bind:onDataChange="onid1$onDataChange"
|
|
207
207
|
if (compConfig === null || compConfig === void 0 ? void 0 : compConfig.isDataContainer) {
|
|
208
208
|
node.attributes['bind:onDataChange'] = getMpEventHanlderName(id, 'onDataChange');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IMaterialItem, IWebRuntimeAppData } from '@cloudbase/lowcode-generator/lib/weapps-core';
|
|
2
2
|
import { BuildType, WebpackModeType } from '../types/common';
|
|
3
3
|
import { RUNTIME } from '../../types';
|
|
4
|
+
export declare const PERSISTENT_DEPENDIENCES_MAP: {};
|
|
4
5
|
export interface IMpConfig {
|
|
5
6
|
origin: string;
|
|
6
7
|
entry: string;
|
|
@@ -68,9 +69,14 @@ export interface IInstallOpts {
|
|
|
68
69
|
runtime?: RUNTIME;
|
|
69
70
|
ignoreInstall?: boolean;
|
|
70
71
|
isDependence?: boolean;
|
|
72
|
+
dependenceMeta?: {
|
|
73
|
+
name: string;
|
|
74
|
+
version: string;
|
|
75
|
+
downloadUrl: string;
|
|
76
|
+
};
|
|
71
77
|
}
|
|
72
78
|
export declare function installDependencies(targetDir: string, options?: IInstallOpts): Promise<void>;
|
|
73
|
-
export declare function getMaterialNodeModulesPathList(dependencies: IMaterialItem[] | undefined, materialsDir: string): string[];
|
|
79
|
+
export declare function getMaterialNodeModulesPathList(dependencies: IMaterialItem[] | undefined, materialsDir: string, base?: string): string[];
|
|
74
80
|
export declare function generateWebpackWebDevServerFile({ appBuildDir, buildTypeList }: {
|
|
75
81
|
appBuildDir: any;
|
|
76
82
|
buildTypeList: any;
|