@cloudbase/lowcode-builder 1.3.12-alpha.1 → 1.3.12-alpha.4

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.
Files changed (44) hide show
  1. package/lib/builder/config/index.d.ts +2 -2
  2. package/lib/builder/config/index.js +3 -3
  3. package/lib/builder/core/index.d.ts +8 -0
  4. package/lib/builder/core/index.js +96 -25
  5. package/lib/builder/h5/generate.d.ts +2 -1
  6. package/lib/builder/h5/generate.js +14 -3
  7. package/lib/builder/h5/index.d.ts +4 -3
  8. package/lib/builder/h5/index.js +54 -3
  9. package/lib/builder/h5/webpack.js +1 -0
  10. package/lib/builder/mp/BuildContext.d.ts +9 -0
  11. package/lib/builder/mp/index.d.ts +8 -3
  12. package/lib/builder/mp/index.js +42 -32
  13. package/lib/builder/mp/materials.js +12 -10
  14. package/lib/builder/mp/util.js +29 -5
  15. package/lib/builder/mp/wxml.js +32 -4
  16. package/lib/builder/util/common.d.ts +1 -1
  17. package/lib/builder/util/common.js +0 -4
  18. package/lib/builder/util/generateFiles.d.ts +1 -2
  19. package/lib/builder/util/generateFiles.js +1 -13
  20. package/lib/index.d.ts +0 -1
  21. package/lib/index.js +1 -2
  22. package/package.json +3 -3
  23. package/template/html/index.html.ejs +72 -4
  24. package/template/mp/app/weapps-api.js +8 -5
  25. package/template/mp/app.js +27 -4
  26. package/template/mp/app.wxss +2 -1
  27. package/template/mp/common/config.js +9 -0
  28. package/template/mp/common/config.wxs +3 -0
  29. package/template/mp/common/util.js +16 -9
  30. package/template/mp/common/utils.wxs +3 -1
  31. package/template/mp/common/weapp-page.js +57 -18
  32. package/template/mp/common/widget.js +42 -13
  33. package/template/mp/component/index.js +1 -0
  34. package/template/mp/datasources/config.js.tpl +4 -3
  35. package/template/mp/package.json +1 -1
  36. package/template/mp/page/api.js +5 -2
  37. package/template/mp/page/index.js +2 -1
  38. package/dist/builder.web.js +0 -71
  39. package/lib/.turbo/turbo-build.log +0 -0
  40. package/lib/.turbo/turbo-develop.log +0 -0
  41. package/lib/builder.web.js +0 -71
  42. package/lib/test.d.ts +0 -11
  43. package/lib/test.js +0 -717
  44. package/template/assets.zip +0 -0
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.handleUsedComponents = exports.writeLowCodeFiles = exports.generateWxMp = void 0;
29
+ exports.handleUsedComponents = exports.writeLowCodeFiles = exports.generateConfig = exports.generateWxMp = void 0;
30
30
  const chalk_1 = __importDefault(require("chalk"));
31
31
  const path_1 = __importDefault(require("path"));
32
32
  const util_1 = require("util");
@@ -54,7 +54,7 @@ const cals_1 = require("@cloudbase/cals");
54
54
  const templateDir = `${config_1.appTemplateDir}/mp/`;
55
55
  const em = chalk_1.default.blue.bold;
56
56
  const error = chalk_1.default.redBright;
57
- async function generateWxMp({ buildContext, weapps, plugins, deployMode, options, buildTypeList, ignoreInstall = false, }) {
57
+ async function generateWxMp({ buildContext, weapps, plugins, deployOptions, options, buildTypeList, ignoreInstall = false, }) {
58
58
  var _a;
59
59
  const { appId, projDir, materialLibs: materials, isProduction, mainAppData, domain, isPrivateMode = false, endpointType = '', isBrowserMpBuilder = false, } = buildContext;
60
60
  const operationLabel = em('Wexin MiniProgram Generated');
@@ -76,30 +76,33 @@ async function generateWxMp({ buildContext, weapps, plugins, deployMode, options
76
76
  'project.config.json': { content: projConfig },
77
77
  };
78
78
  console.log(`Generating ${em('project')} files`);
79
- await (0, generateFiles_1.default)(buildContext, projectFileData, templateDir, projDir);
79
+ await (0, generateFiles_1.default)(projectFileData, templateDir, projDir);
80
80
  }
81
81
  // #2 生成主包
82
82
  await generatePkg({ ...buildContext, rootPath: mainAppData.rootPath }, mainAppData, path_1.default.join(projDir, '/'), pageConfigs[0]);
83
83
  const projectConfigJsonPath = path_1.default.join(projDir, mainAppData.rootPath || '', 'project.config.json');
84
84
  let projectConfigJson = await fs.readJSON(projectConfigJsonPath);
85
85
  const miniprogramRoot = path_1.default.join(projDir, projectConfigJson.miniprogramRoot || '/');
86
- await generateFramework(buildContext, mainAppData, miniprogramRoot);
86
+ await generateFramework(buildContext, mainAppData, miniprogramRoot, { deployOptions });
87
87
  // #3 生成主包根路径文件
88
88
  let appFileData = {};
89
89
  if (weapps.find((item) => !item.mpPkgUrl)) {
90
- await generateFramework(buildContext, mainAppData, miniprogramRoot);
90
+ await generateFramework(buildContext, mainAppData, miniprogramRoot, { deployOptions });
91
91
  // 有了 framework app 之后,并且是源码的方式,追加 app 引用
92
92
  if (mainAppData.mpPkgUrl) {
93
93
  let appJsPath = path_1.default.join(miniprogramRoot, 'app.js');
94
94
  let appJsContent = await fs.readFile(appJsPath);
95
95
  await (0, generateFiles_1.writeFile)(appJsPath, `import { app as wedaApp } from './app/weapps-api'\n${appJsContent}`);
96
96
  }
97
+ await generateConfig({
98
+ domain,
99
+ isPrivateMode,
100
+ endpointType,
101
+ }, miniprogramRoot);
97
102
  appFileData = {
98
103
  ...appFileData,
99
104
  'common/style.js': {},
100
- 'common/utils.wxs': {
101
- domain,
102
- },
105
+ 'common/utils.wxs': {},
103
106
  'common/util.js': {
104
107
  isAdminPortal: (0, common_1.buildAsAdminPortalByBuildType)(buildTypeList),
105
108
  },
@@ -164,7 +167,7 @@ async function generateWxMp({ buildContext, weapps, plugins, deployMode, options
164
167
  };
165
168
  }
166
169
  console.log(`Generating ${em('miniprogramRoot')} files`);
167
- await (0, generateFiles_1.default)(buildContext, appFileData, templateDir, miniprogramRoot);
170
+ await (0, generateFiles_1.default)(appFileData, templateDir, miniprogramRoot);
168
171
  // 若项目目录与小程序根目录不同,则拷贝素材到小程序根目录
169
172
  if (miniprogramRoot !== path_1.default.join(projDir, '/') && fs.existsSync(path_1.default.join(projDir, config_1.materialsDirName))) {
170
173
  console.log(`Move ${em(config_1.materialsDirName)} from` + `${projDir} to ${miniprogramRoot}`);
@@ -178,25 +181,18 @@ async function generateWxMp({ buildContext, weapps, plugins, deployMode, options
178
181
  envID: mainAppData.envId,
179
182
  appID: appId,
180
183
  resourceAppid: !!options.isCrossAccount ? options.resourceAppId : '',
181
- isProd: deployMode === types_1.DEPLOY_MODE.UPLOAD,
184
+ isProd: (deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.mode) === types_1.DEPLOY_MODE.UPLOAD,
182
185
  clientID: (_a = mainAppData.extra) === null || _a === void 0 ? void 0 : _a.clientId,
183
- isPrivateMode,
184
- endpointType,
185
- tcbApiOrigin: endpointType === 'tcb-api' && isPrivateMode && domain ? `https://${domain}` : '',
186
186
  },
187
187
  'datasources/datasource-profiles.js.tpl': {
188
- datasourceProfiles: (0, util_3.JsonToStringWithVariableName)((0, lowcode_generator_1.getDatasourceProfiles)(
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 }),
196
192
  },
197
193
  };
198
194
  console.log(`Generating ${em('datasources')} files`);
199
- await (0, generateFiles_1.default)(buildContext, datasourceFileData, templateDir, miniprogramRoot);
195
+ await (0, generateFiles_1.default)(datasourceFileData, templateDir, miniprogramRoot);
200
196
  }
201
197
  // 生成子包
202
198
  await Promise.all(weapps.map(async (app, index) => {
@@ -210,11 +206,11 @@ async function generateWxMp({ buildContext, weapps, plugins, deployMode, options
210
206
  rootPath: app.rootPath,
211
207
  };
212
208
  await generatePkg(subpackageBuildCtx, app, subpackageRootPath, pageConfigs[index]);
213
- await generateFramework(subpackageBuildCtx, app, subpackageRootPath);
209
+ await generateFramework(subpackageBuildCtx, app, subpackageRootPath, { deployOptions });
214
210
  // 生成package.json
215
211
  let packageJsonPath = path_1.default.join(subpackageRootPath, 'package.json');
216
212
  if (!fs.existsSync(packageJsonPath)) {
217
- await (0, generateFiles_1.default)(buildContext, {
213
+ await (0, generateFiles_1.default)({
218
214
  'package.json': {
219
215
  appId,
220
216
  importJSSDK: endpointType === 'tcb-api',
@@ -283,6 +279,20 @@ async function generateWxMp({ buildContext, weapps, plugins, deployMode, options
283
279
  }
284
280
  }
285
281
  exports.generateWxMp = generateWxMp;
282
+ async function generateConfig(data, root) {
283
+ const { domain = '', isPrivateMode = false, endpointType = '' } = data;
284
+ await (0, generateFiles_1.default)({
285
+ 'common/config.js': {
286
+ domain,
287
+ isPrivateMode,
288
+ endpointType,
289
+ },
290
+ 'common/config.wxs': {
291
+ domain,
292
+ },
293
+ }, templateDir, root);
294
+ }
295
+ exports.generateConfig = generateConfig;
286
296
  async function generatePkg(ctx, weapp, appRoot, pageConfigs) {
287
297
  const wxmlDataPrefix = (0, mp_1.getWxmlDataPrefix)(!ctx.isProduction);
288
298
  console.log(`Generating ${em(weapp.rootPath ? 'subApp' : 'app')} to ${appRoot}`);
@@ -301,7 +311,7 @@ async function generatePkg(ctx, weapp, appRoot, pageConfigs) {
301
311
  console.log(`Generating ${em('page')} files`);
302
312
  (0, generateFiles_1.cleanDir)(path_1.default.join(appRoot, 'pages'), []);
303
313
  await Promise.all(weapp.pageInstanceList.map(async (page) => {
304
- var _a, _b;
314
+ var _a, _b, _c, _d, _e, _f;
305
315
  // # Generating page
306
316
  const rootPath = weapp.rootPath || '';
307
317
  const usingComponents = {};
@@ -318,11 +328,12 @@ async function generatePkg(ctx, weapp, appRoot, pageConfigs) {
318
328
  widgetProps: (0, util_2.createWidgetProps)(ctx, componentInstances),
319
329
  pageUUID: rootPath ? `${rootPath}/${page.id}` : page.id,
320
330
  pageName: page.id,
331
+ pageTitle: ((_b = (_a = page === null || page === void 0 ? void 0 : page.data) === null || _a === void 0 ? void 0 : _a.navigationBarTitleText) === null || _b === void 0 ? void 0 : _b.value) || ((_d = (_c = page === null || page === void 0 ? void 0 : page.data) === null || _c === void 0 ? void 0 : _c.title) === null || _d === void 0 ? void 0 : _d.value),
321
332
  pageSource: page.data.src || '',
322
333
  eventHanlders: (0, util_2.createEventHanlders)(ctx, componentInstances, 'this', page),
323
334
  dataBinds: (0, util_2.createDataBinds)(ctx, componentInstances),
324
335
  pageAttributes: {
325
- ...(((_a = page.data) === null || _a === void 0 ? void 0 : _a.appShareMessage) ? { appShareMessage: page.data.appShareMessage.value } : {}),
336
+ ...(((_e = page.data) === null || _e === void 0 ? void 0 : _e.appShareMessage) ? { appShareMessage: page.data.appShareMessage.value } : {}),
326
337
  },
327
338
  debug: ctx.debugMode,
328
339
  stringifyObj: util_1.inspect,
@@ -338,7 +349,7 @@ async function generatePkg(ctx, weapp, appRoot, pageConfigs) {
338
349
  content: wxml,
339
350
  },
340
351
  [`index.wxss|${pageFileName}.wxss`]: {
341
- subWxss: rootPath && !((_b = ctx.mainAppData) === null || _b === void 0 ? void 0 : _b.mpPkgUrl)
352
+ subWxss: rootPath && !((_f = ctx.mainAppData) === null || _f === void 0 ? void 0 : _f.mpPkgUrl)
342
353
  ? `@import "${path_1.default.posix.relative(`/${rootPath}/pages/${page.id}`, '/lowcode')}/style.wxss";`
343
354
  : '',
344
355
  content: (0, weapps_core_1.toCssText)((0, cals_1.processCommonStyle2CSSProperties)(page.commonStyle, {
@@ -348,13 +359,14 @@ async function generatePkg(ctx, weapp, appRoot, pageConfigs) {
348
359
  },
349
360
  };
350
361
  // Generating file by template and data
351
- await (0, generateFiles_1.default)(ctx, pageFileData, `${templateDir}/page`, path_1.default.join(appRoot, 'pages', page.id));
362
+ await (0, generateFiles_1.default)(pageFileData, `${templateDir}/page`, path_1.default.join(appRoot, 'pages', page.id));
352
363
  }));
353
364
  // #3 writing lowcode files
354
365
  await writeLowCodeFiles(ctx, weapp, appRoot);
355
366
  }
356
367
  }
357
- async function generateFramework(ctx, appData, outDir) {
368
+ async function generateFramework(ctx, appData, outDir, options) {
369
+ var _a;
358
370
  let fileData = {};
359
371
  if (appData.mpPkgUrl) {
360
372
  if (!appData.rootPath) {
@@ -366,7 +378,6 @@ async function generateFramework(ctx, appData, outDir) {
366
378
  subLevelPath: '',
367
379
  subPackageName: '',
368
380
  importor: (0, util_3.generateLowcodeImportor)([]),
369
- domain: ctx.domain || '',
370
381
  appConfig: JSON.stringify({}),
371
382
  },
372
383
  };
@@ -391,15 +402,14 @@ async function generateFramework(ctx, appData, outDir) {
391
402
  ...fileData,
392
403
  'app/app-global.js': {},
393
404
  'app/weapps-api.js': {
394
- appId: ctx.appId,
395
- domain: ctx.domain || '',
396
405
  subLevelPath: appData.rootPath ? `${path_1.default.posix.relative(`${appData.rootPath}`, '')}/` : '',
397
406
  subPackageName: appData.rootPath || '',
398
407
  importor,
399
408
  appConfig: (0, util_3.JsonToStringWithVariableName)({
400
409
  id: ctx.appId,
410
+ label: (appData === null || appData === void 0 ? void 0 : appData.label) || '',
411
+ version: (_a = options === null || options === void 0 ? void 0 : options.deployOptions) === null || _a === void 0 ? void 0 : _a.version,
401
412
  envId: appData.envId,
402
- staticResourceDomain: ctx.domain || '',
403
413
  envVersion: (ctx === null || ctx === void 0 ? void 0 : ctx.isProduction) ? 'production' : 'preview',
404
414
  pages: appData.pageInstanceList
405
415
  .sort((item) => (item.isHome ? -1 : 1))
@@ -411,7 +421,7 @@ async function generateFramework(ctx, appData, outDir) {
411
421
  },
412
422
  'app/common.js': {
413
423
  mods: appData.lowCodes
414
- .filter((m) => m.type === cals_1.ECodeType.NORMAL_MODULE && m.name !== '____index____')
424
+ .filter((m) => m.type === cals_1.ECodeType.NORMAL_MODULE && m.name !== cals_1.ECodeName.PLACEHOLDER)
415
425
  .map((m) => m.name)
416
426
  .sort(),
417
427
  },
@@ -419,7 +429,7 @@ async function generateFramework(ctx, appData, outDir) {
419
429
  }
420
430
  }
421
431
  console.log('Generate app framework');
422
- await (0, generateFiles_1.default)(ctx, fileData, templateDir, outDir);
432
+ await (0, generateFiles_1.default)(fileData, templateDir, outDir);
423
433
  }
424
434
  async function writeLowCodeFiles(ctx, appData, outDir) {
425
435
  console.log(`Writing ${em('lowcode')} files:`);
@@ -146,9 +146,7 @@ async function installMaterials(ctx, projDir, usedComps, weapps) {
146
146
  comp.materialName = lib.name;
147
147
  });
148
148
  });
149
- // Collection infomation from components to lib meta
150
- const compositedLibs = materialLibs.filter((lib) => lib.isComposite && usedComps[lib.name]);
151
- compositedLibs.map((lib) => {
149
+ materialLibs.map((lib) => {
152
150
  lib.dependencies = lib.dependencies || {};
153
151
  lib.components.map((cmp) => {
154
152
  cmp.meta.syncProps = {};
@@ -159,14 +157,18 @@ async function installMaterials(ctx, projDir, usedComps, weapps) {
159
157
  cmp.meta.syncProps[prop] = syncProp || inputProp;
160
158
  }
161
159
  }
162
- cmp.meta.platforms = {
163
- mp: {
164
- path: `${cmp.name}/index`,
165
- },
166
- };
167
- lib.dependencies = { ...lib.dependencies, ...cmp.npmDependencies };
160
+ if (lib.isComposite) {
161
+ cmp.meta.platforms = {
162
+ mp: {
163
+ path: `${cmp.name}/index`,
164
+ },
165
+ };
166
+ lib.dependencies = { ...lib.dependencies, ...cmp.npmDependencies };
167
+ }
168
168
  });
169
169
  });
170
+ // Collection infomation from components to lib meta
171
+ const compositedLibs = materialLibs.filter((lib) => lib.isComposite && usedComps[lib.name]);
170
172
  // #2 Generate composited libs
171
173
  await Promise.all(compositedLibs.map(async (lib) => {
172
174
  console.log(`Generate composited library ${lib.name}`);
@@ -311,7 +313,7 @@ async function generateCompositeComponent(ctx, compositedComp, compLibCommonReso
311
313
  },
312
314
  };
313
315
  // Generating file by template and data
314
- await (0, generateFiles_1.default)(compositeCtx, pageFileData, `${templateDir}/component`, outDir);
316
+ await (0, generateFiles_1.default)(pageFileData, `${templateDir}/component`, outDir);
315
317
  // #3 writing lowcode files
316
318
  /**
317
319
  * 低码没有开放 index 类别,直接去掉
@@ -200,8 +200,10 @@ function generateDataContainerListeners() {
200
200
  {
201
201
  trigger: 'onDataChange',
202
202
  jsCode: `({event})=>{
203
- app.utils.set(event.currentTarget._scope, 'dataContext.data', event?.detail?.data);
204
- app.utils.set(event.currentTarget._scope, 'dataContext.state', event?.detail?.state);
203
+ if(event.currentTarget) {
204
+ app.utils.set(event.currentTarget._scope, 'dataContext.data', event?.detail?.data);
205
+ app.utils.set(event.currentTarget._scope, 'dataContext.state', event?.detail?.state);
206
+ }
205
207
  }`,
206
208
  type: weapps_core_1.ActionType.Inline,
207
209
  data: {},
@@ -220,7 +222,7 @@ function getListenersHandlers(listeners, id, componentApi) {
220
222
  return {};
221
223
  const eventHandlers = {};
222
224
  listeners.forEach((l) => {
223
- var _a, _b, _c;
225
+ var _a, _b, _c, _d, _e;
224
226
  const handlerName = (0, wxml_1.getMpEventHanlderName)(id, l.trigger, l);
225
227
  eventHandlers[handlerName] = eventHandlers[handlerName] || [];
226
228
  const params = generatedDynamicData(l.data);
@@ -243,6 +245,7 @@ function getListenersHandlers(listeners, id, componentApi) {
243
245
  key: l.key || '',
244
246
  handler,
245
247
  handlerModule: (_c = l.handler) === null || _c === void 0 ? void 0 : _c.moduleName,
248
+ sourceKey: `${((_d = l.handler) === null || _d === void 0 ? void 0 : _d.moduleName) || ''}:${((_e = l.handler) === null || _e === void 0 ? void 0 : _e.name) || ''}`,
246
249
  data: params.staticProps,
247
250
  boundData: params.boundProps,
248
251
  type: l.type,
@@ -273,9 +276,21 @@ function createDataBinds(ctx, widgets) {
273
276
  const { directives = {} } = xProps;
274
277
  setDataBind(dataBinds[id], '_waFor', directives.waFor);
275
278
  setDataBind(dataBinds[id], '_waIf', directives.waIf);
279
+ if (directives.waDisplay) {
280
+ let { type, value } = directives.waDisplay;
281
+ if (!type || type === 'static') {
282
+ type = weapps_core_1.PropBindType.expression;
283
+ value = `${JSON.stringify(value)}`;
284
+ }
285
+ setDataBind(dataBinds[id], '_waDisplay', {
286
+ ...directives.waDisplay,
287
+ type,
288
+ value,
289
+ });
290
+ }
276
291
  setDataBind(dataBinds[id], 'classList', xProps.classListBind);
277
292
  setDataBind(dataBinds[id], 'style', xProps.styleBind);
278
- const { classList, style } = dataBinds[id];
293
+ const { classList, style, _waDisplay } = dataBinds[id];
279
294
  if (classList) {
280
295
  dataBinds[id].classList = {
281
296
  ...classList,
@@ -283,12 +298,21 @@ function createDataBinds(ctx, widgets) {
283
298
  };
284
299
  }
285
300
  if (style) {
286
- const styleExpression = `{...widgetProps.${id}.style, ...(\n${style === null || style === void 0 ? void 0 : style.expression}\n)}`;
301
+ const styleExpression = _waDisplay
302
+ ? `{...widgetProps.${id}.style, ...(\n${style === null || style === void 0 ? void 0 : style.expression}\n), display: (()=>{${_waDisplay === null || _waDisplay === void 0 ? void 0 : _waDisplay.imports}\n return (\n${_waDisplay === null || _waDisplay === void 0 ? void 0 : _waDisplay.expression}\n)})() ? undefined: 'none' }`
303
+ : `{...widgetProps.${id}.style, ...(\n${style === null || style === void 0 ? void 0 : style.expression}\n)}`;
287
304
  dataBinds[id].style = {
288
305
  ...style,
289
306
  expression: processCssUnit === 'rpx' ? `px2rpx(${styleExpression})` : styleExpression,
290
307
  };
291
308
  }
309
+ else if (_waDisplay) {
310
+ const styleExpression = `{...widgetProps.${id}.style, display: (\n${_waDisplay === null || _waDisplay === void 0 ? void 0 : _waDisplay.expression}\n)? undefined: 'none' }`;
311
+ dataBinds[id].style = {
312
+ ..._waDisplay,
313
+ expression: processCssUnit === 'rpx' ? `px2rpx(${styleExpression})` : styleExpression,
314
+ };
315
+ }
292
316
  if (Object.keys(dataBinds[id]).length === 0) {
293
317
  delete dataBinds[id];
294
318
  }
@@ -32,17 +32,36 @@ function generateWxml(ctx, widgets, docTag, wxmlDataPrefix, usingComponents, com
32
32
  ].concat(createXml(widgets)),
33
33
  };
34
34
  if (ctx.isPage) {
35
+ const { enablePageRoot } = ctx;
35
36
  const originElements = xmlJson.elements;
36
37
  // 登录校验: 向其最外层包裹一层block
37
38
  xmlJson.elements = [
38
39
  {
39
40
  type: 'element',
40
- name: 'block',
41
+ name: enablePageRoot ? 'view' : 'block',
41
42
  attributes: {
43
+ id: 'wd-page-root',
42
44
  ['wx:if']: '{{weDaHasLogin}}',
43
45
  ['data-weui-theme']: 'light',
44
46
  },
45
- elements: originElements,
47
+ elements: [
48
+ ...originElements,
49
+ /**
50
+ * 可能需要依赖添加逻辑节点的方式
51
+ * 来触发 page 的 ready
52
+ * 目的是为了让 page 的 ready 在组件的 ready 之后
53
+ */
54
+ // {
55
+ // type: 'element',
56
+ // name: 'readyPlaceHoler',
57
+ // attributes: {
58
+ // ['bind:ready']: '_onReady',
59
+ // },
60
+ // elements: originElements,
61
+ // _order: Infinity,
62
+ // _parent: null,
63
+ // },
64
+ ],
46
65
  _order: -1,
47
66
  _parent: null,
48
67
  },
@@ -164,6 +183,13 @@ function generateWxml(ctx, widgets, docTag, wxmlDataPrefix, usingComponents, com
164
183
  if ((_d = directives.waIf) === null || _d === void 0 ? void 0 : _d.value) {
165
184
  node.attributes['wx:if'] = getAttrBind(directives.waIf, `${attrPrefix}._waIf`);
166
185
  }
186
+ /**
187
+ * 对于 hidden 的支持依赖组件透传对应的属性
188
+ * 为了兼容,采用 style merge 的方式
189
+ */
190
+ // if (directives.waDisplay?.value !== undefined && directives.waDisplay?.value !== true) {
191
+ // node.attributes['hidden'] = getAttrBind(directives.waDisplay, `${attrPrefix}._waDisplay`, false, true);
192
+ // }
167
193
  if ((_e = directives.waFor) === null || _e === void 0 ? void 0 : _e.value) {
168
194
  node.attributes['wx:for'] = getAttrBind(directives.waFor, `${wxmlDataPrefix.widgetProp}${id}${parentForNodes
169
195
  .map((forNodeId) => `[${wxmlDataPrefix.forIndex}${forNodeId}]`)
@@ -368,10 +394,12 @@ function getUsedComponents(widgets, usedCmps = {}) {
368
394
  return usedCmps;
369
395
  }
370
396
  exports.getUsedComponents = getUsedComponents;
371
- function getAttrBind(dVale, widgetBind, isStaticResource) {
397
+ function getAttrBind(dVale, widgetBind, isStaticResource, neg) {
372
398
  const { type, value } = dVale;
373
399
  const attrVal = type === weapps_core_1.PropBindType.prop ? value : widgetBind;
374
- return isStaticResource ? `{{wxsUtils._getStaticResourceAttribute(${attrVal})}}` : `{{${attrVal}}}`;
400
+ return isStaticResource
401
+ ? `{{${neg ? '!' : ''}wxsUtils._getStaticResourceAttribute(${attrVal})}}`
402
+ : `{{${neg ? `!(${attrVal})` : `${attrVal}`}}}`;
375
403
  }
376
404
  function getGenericCompTagName(propName) {
377
405
  return `g--${propName}`;
@@ -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
- export declare type PromiseResult<T> = Promise<[null, T] | [Error, null]>;
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'));
@@ -1,8 +1,7 @@
1
1
  /// <reference types="node" />
2
- import { IBuildContext } from '../mp/BuildContext';
3
2
  import { OutputType } from 'jszip';
4
3
  export declare const generatedFileContents: {};
5
- export default function generateFiles(ctx: IBuildContext, appFileData: any, srcDir: string, dstDir: string): Promise<string[]>;
4
+ export default function generateFiles(appFileData: any, srcDir: string, dstDir: string): Promise<string[]>;
6
5
  export declare function writeFile(outFile: string, content: string): Promise<boolean>;
7
6
  export declare function removeFile(file: string): void;
8
7
  /**
@@ -35,7 +35,7 @@ const glob_1 = __importDefault(require("glob"));
35
35
  const jszip_1 = __importDefault(require("jszip"));
36
36
  const buffer_1 = require("buffer");
37
37
  exports.generatedFileContents = {}; // generated files for incrmental build
38
- async function generateFiles(ctx, appFileData, srcDir, dstDir) {
38
+ async function generateFiles(appFileData, srcDir, dstDir) {
39
39
  const filesGenerated = [];
40
40
  // Generating file by template and data
41
41
  for (const file in appFileData) {
@@ -46,18 +46,6 @@ async function generateFiles(ctx, appFileData, srcDir, dstDir) {
46
46
  encoding: 'utf8',
47
47
  });
48
48
  let generatedCode = (0, lodash_1.template)(tplStr, { interpolate: /<%=([\s\S]+?)%>/ })(appFileData[file]);
49
- // 混合模式下,引用公共路径要多增加一层,并加多一层命名
50
- // 混合子包直接在对应目录上生成,而不采用替换的方式 @royhyang
51
- // if (ctx?.isMixMode && ctx?.rootPath) {
52
- // generatedCode = generatedCode.replace(
53
- // /..\/..\/..\/common\//g,
54
- // '../../../../common/'
55
- // )
56
- // generatedCode = generatedCode.replace(
57
- // /..\/..\/..\/app\//g,
58
- // '../../../../app/'
59
- // )
60
- // }
61
49
  const outFile = path_1.default.resolve(dstDir, outFileName.replace(/\.tpl$/, ''));
62
50
  if (await writeFile(outFile, generatedCode)) {
63
51
  filesGenerated.push(outFileName);
package/lib/index.d.ts CHANGED
@@ -11,4 +11,3 @@ export * from './types';
11
11
  * cache map
12
12
  */
13
13
  export { PERSISTENT_DEPENDIENCES_MAP } from './builder/service/webpack';
14
- export declare const version = "test";
package/lib/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.version = exports.PERSISTENT_DEPENDIENCES_MAP = void 0;
17
+ exports.PERSISTENT_DEPENDIENCES_MAP = void 0;
18
18
  /**
19
19
  * Tencent is pleased to support the open source community by making CloudBaseFramework - 云原生一体化部署工具 available.
20
20
  *
@@ -29,4 +29,3 @@ __exportStar(require("./types"), exports);
29
29
  */
30
30
  var webpack_1 = require("./builder/service/webpack");
31
31
  Object.defineProperty(exports, "PERSISTENT_DEPENDIENCES_MAP", { enumerable: true, get: function () { return webpack_1.PERSISTENT_DEPENDIENCES_MAP; } });
32
- exports.version = 'test';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/lowcode-builder",
3
- "version": "1.3.12-alpha.1",
3
+ "version": "1.3.12-alpha.4",
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.5.11",
42
- "@cloudbase/lowcode-generator": "^1.3.6",
41
+ "@cloudbase/cals": "workspace:^",
42
+ "@cloudbase/lowcode-generator": "workspace:^",
43
43
  "axios": "^0.21.0",
44
44
  "browserfs": "^1.4.3",
45
45
  "browserify-zlib": "^0.2.0",
@@ -19,7 +19,7 @@
19
19
  <% cssStyles.forEach(function(styleUrl){%>
20
20
  <link type="text/css" rel="stylesheet" href="<%=styleUrl %>" />
21
21
  <% })%> <% if(cdnEndpoints.aegis){ %>
22
- <script crossorigin="anonymous" src="<%= cdnEndpoints.aegis %>/aegis/aegis-sdk/latest/aegis.min.js?v=1"></script>
22
+ <script crossorigin="anonymous" src="<%= cdnEndpoints.aegis %>/aegis-sdk/latest/aegis.min.js"></script>
23
23
  <script>
24
24
  <% if(!isAdminPortal){ %>
25
25
  const _aegis = new Aegis({
@@ -386,7 +386,75 @@
386
386
  </head>
387
387
 
388
388
  <body data-weui-theme="light">
389
- <div id="root" class="main-wrap"></div>
389
+ <div id="root" class="main-wrap">
390
+ <% if(enableStaticLoading){ %>
391
+ <style type="text/css">
392
+ .weda-loading-container {
393
+ position: fixed;
394
+ left: 0;
395
+ top: 0;
396
+ width: 100%;
397
+ display: flex;
398
+ justify-content: center;
399
+ align-items: center;
400
+ flex-direction: column;
401
+ height: 100%;
402
+ padding: 0 20px;
403
+ }
404
+ .weda-loading-container .logo {
405
+ width: 100%;
406
+ display: flex;
407
+ justify-content: center;
408
+ text-align: center;
409
+ margin-bottom: 50px;
410
+ }
411
+
412
+ .weda-loading-container .sp {
413
+ width: 48px;
414
+ height: 48px;
415
+ }
416
+
417
+ .weda-loading-container .sp-circle {
418
+ border: 6px rgba(0, 82, 217, 0.25) solid;
419
+ border-top: 6px rgba(0, 82, 217, 1) solid;
420
+ border-radius: 50%;
421
+ -webkit-animation: spCircRot 0.6s infinite linear;
422
+ animation: spCircRot 0.6s infinite linear;
423
+ }
424
+ @-webkit-keyframes spCircRot {
425
+ from {
426
+ -webkit-transform: rotate(0deg);
427
+ }
428
+ to {
429
+ -webkit-transform: rotate(359deg);
430
+ }
431
+ }
432
+ @keyframes spCircRot {
433
+ from {
434
+ transform: rotate(0deg);
435
+ }
436
+ to {
437
+ transform: rotate(359deg);
438
+ }
439
+ }
440
+ </style>
441
+ <div class="weda-loading-container">
442
+ <div class="logo">
443
+ <div class="sp sp-circle"></div>
444
+ </div>
445
+ <div class="text">初始化中...</div>
446
+ <script>
447
+ const ua = navigator.userAgent.toLowerCase();
448
+ if (ua.indexOf('wxwork') !== -1 && /[?&]code=/.test(location.search) && /[?&]state=/.test(location.search)) {
449
+ var el = document.querySelector('#root .weda-loading-container>.text');
450
+ if (el) {
451
+ el.innerHTML = '数据加载中...';
452
+ }
453
+ }
454
+ </script>
455
+ </div>
456
+ <% }%>
457
+ </div>
390
458
  <% jsApis.forEach(function(jsApi){%>
391
459
  <script src="<%=jsApi %>"></script>
392
460
  <% })%> <% if(canUseVite){ %>
@@ -453,7 +521,7 @@
453
521
  crossorigin="anonymous"
454
522
  src="<%=
455
523
  cdnEndpoints.cdngo
456
- %>/lcap/lcap-resource-cdngo/-/release/_npm/@cloudbase/weda-cloud-sdk@1.0.19/dist/h5.browser.js"
524
+ %>/lcap/lcap-resource-cdngo/-/release/_npm/@cloudbase/weda-cloud-sdk@1.0.27-alpha.0/dist/h5.browser.js"
457
525
  ></script>
458
526
  <script>
459
527
  // zxing polifill
@@ -475,7 +543,7 @@
475
543
  crossorigin
476
544
  src="<%=
477
545
  cdnEndpoints.cdngo
478
- %>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.2895317effcdaa894b2d.bundle.js"
546
+ %>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.051bed8f584a31b92c63.bundle.js"
479
547
  ></script>
480
548
  </body>
481
549
  </html>
@@ -4,6 +4,7 @@ import { createComputed, formatEnum, enumOptions } from '<%= subLevelPath %>../c
4
4
  import appGlobal from '<%= subLevelPath %>../app/app-global'
5
5
  import { createDataset } from '<%= subLevelPath %>../datasources/index'
6
6
  import lodashGet from 'lodash.get';
7
+ import config from '<%= subLevelPath %>../common/config';
7
8
 
8
9
 
9
10
  <%= importor.state? `import state from '../lowcode/state'` : "const state = {}" %>
@@ -25,11 +26,13 @@ export const $w = new Proxy(
25
26
 
26
27
  function createGlboalApi() {
27
28
  const mpApp = createMpApp({
28
- appConfig: <%= appConfig %>
29
+ appConfig: {
30
+ staticResourceDomain: config.domain,
31
+ ...(<%= appConfig %>)
32
+ },
29
33
  });
30
- const globalAPI = {
31
- id: '<%= appId %>',
32
- domain: '<%= domain %>',
34
+ const globalAPI = Object.assign(mpApp, {
35
+ domain: config.domain,
33
36
  pages: {},
34
37
  session: {
35
38
  //configure: sdk.configure,
@@ -45,7 +48,7 @@ function createGlboalApi() {
45
48
  return $page.invokeComponentMethod(params)
46
49
  },
47
50
  // ... other sdk apis & apis from mp
48
- } // The global api exposed to lowcode
51
+ }) // The global api exposed to lowcode
49
52
 
50
53
  globalAPI.__internal__.enumOptions = enumOptions
51
54
  globalAPI.utils.formatEnum = formatEnum