@cloudbase/lowcode-builder 1.8.17 → 1.8.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.
@@ -6,12 +6,12 @@ export declare const materialsDirName = "materials";
6
6
  * src/template的代码,在IDE编辑器插件中构建builder
7
7
  * 存放在大账号:100015939275。访问地址:https://console.cloud.tencent.com/cos/bucket?bucket=comp-public-1303824488&region=ap-shanghai&path=%252Flcap-builder%252F
8
8
  */
9
- export declare const builderTemplateURL = "https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/template.1.8.13.zip";
9
+ export declare const builderTemplateURL = "https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/template.1.8.19.zip";
10
10
  /**
11
11
  * miniprogram的代码,IDE插件后续会提供端功能
12
12
  * 存放在大账号:100015939275。访问地址:https://console.cloud.tencent.com/cos/bucket?bucket=comp-public-1303824488&region=ap-shanghai&path=%252Flcap-builder%252F
13
13
  */
14
- export declare const miniprogramURL = "https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/miniprogram_npm_20230606.zip";
14
+ export declare const miniprogramURL = "https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/miniprogram_npm.1.8.19.zip";
15
15
  /**
16
16
  * miniprogram_npm存放目录。IDE插件builder用到
17
17
  */
@@ -45,12 +45,12 @@ exports.materialsDirName = 'materials'; // materials diretory of current project
45
45
  * src/template的代码,在IDE编辑器插件中构建builder
46
46
  * 存放在大账号:100015939275。访问地址:https://console.cloud.tencent.com/cos/bucket?bucket=comp-public-1303824488&region=ap-shanghai&path=%252Flcap-builder%252F
47
47
  */
48
- exports.builderTemplateURL = 'https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/template.1.8.13.zip';
48
+ exports.builderTemplateURL = 'https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/template.1.8.19.zip';
49
49
  /**
50
50
  * miniprogram的代码,IDE插件后续会提供端功能
51
51
  * 存放在大账号:100015939275。访问地址:https://console.cloud.tencent.com/cos/bucket?bucket=comp-public-1303824488&region=ap-shanghai&path=%252Flcap-builder%252F
52
52
  */
53
- exports.miniprogramURL = 'https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/miniprogram_npm_20230606.zip';
53
+ exports.miniprogramURL = 'https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcap-builder/miniprogram_npm.1.8.19.zip';
54
54
  /**
55
55
  * miniprogram_npm存放目录。IDE插件builder用到
56
56
  */
@@ -5,7 +5,7 @@ import { IPlatformApp } from '@cloudbase/cals';
5
5
  import { ICDN_ENDPOINTS_COFIG } from '../config';
6
6
  import { IBuildContext } from '../mp/BuildContext';
7
7
  import { IBuildWedaApp } from '../core';
8
- export declare function buildH5App({ buildContext, i18nConfig, extraData, cals, buildTypeList, subAppCalsList, mode, devTool, runtime, deployOptions, ignoreInstall, cdnEndpoints, }: {
8
+ export declare function buildH5App({ buildContext, i18nConfig, extraData, cals: _cals, buildTypeList, subAppCalsList, mode, devTool, runtime, deployOptions, ignoreInstall, cdnEndpoints, }: {
9
9
  buildContext: Omit<IBuildContext, 'mainAppData'>;
10
10
  cals: IPlatformApp;
11
11
  subAppCalsList: IPlatformApp[];
@@ -45,7 +45,8 @@ const config_1 = require("../config");
45
45
  const fs_extra_1 = __importDefault(require("fs-extra"));
46
46
  const junk = __importStar(require("../util/junk"));
47
47
  const url_1 = require("url");
48
- async function buildH5App({ buildContext, i18nConfig, extraData, cals, buildTypeList = [common_1.BuildType.WEB], subAppCalsList, mode, devTool, runtime = types_1.RUNTIME.NONE, deployOptions = { mode: types_1.DEPLOY_MODE.PREVIEW }, ignoreInstall = false, cdnEndpoints, }) {
48
+ const transform_1 = require("../../utils/transform");
49
+ async function buildH5App({ buildContext, i18nConfig, extraData, cals: _cals, buildTypeList = [common_1.BuildType.WEB], subAppCalsList, mode, devTool, runtime = types_1.RUNTIME.NONE, deployOptions = { mode: types_1.DEPLOY_MODE.PREVIEW }, ignoreInstall = false, cdnEndpoints, }) {
49
50
  var _a, _b, _c;
50
51
  const { projDir: buildDir, domain, materialLibs: dependencies, appId: appKey, isPrivateMode } = buildContext;
51
52
  if (!deployOptions.mode) {
@@ -57,11 +58,12 @@ async function buildH5App({ buildContext, i18nConfig, extraData, cals, buildType
57
58
  if (buildTypeList.includes(common_1.BuildType.APP) ||
58
59
  buildTypeList.includes(common_1.BuildType.XPAGE_PC) ||
59
60
  buildTypeList.includes(common_1.BuildType.ADMIN_PORTAL)) {
60
- if (!cals.extra) {
61
- cals.extra = {};
61
+ if (!_cals.extra) {
62
+ _cals.extra = {};
62
63
  }
63
- cals.extra.historyType = types_1.HISTORY_TYPE.HASH;
64
+ _cals.extra.historyType = types_1.HISTORY_TYPE.HASH;
64
65
  }
66
+ const cals = processCals(_cals);
65
67
  const mainAppSerializeData = (0, common_2.processCals2WeappsData)(cals, dependencies);
66
68
  const subAppSerializeDataList = (subAppCalsList === null || subAppCalsList === void 0 ? void 0 : subAppCalsList.map((item) => (0, common_2.processCals2WeappsData)(item, dependencies))) || [];
67
69
  const { allAppUsedComps } = (0, mp_1.handleUsedComponents)({
@@ -199,3 +201,39 @@ async function buildH5App({ buildContext, i18nConfig, extraData, cals, buildType
199
201
  }
200
202
  }
201
203
  exports.buildH5App = buildH5App;
204
+ function processCals(cals) {
205
+ return walkThroughJson(cals, (key, value, prefix) => {
206
+ if (/^:(.*)$/.test(key)) {
207
+ try {
208
+ return (0, transform_1.BabelTransform)(value, { IIFE: true });
209
+ }
210
+ catch (e) {
211
+ return value;
212
+ }
213
+ }
214
+ return value;
215
+ });
216
+ }
217
+ function _isPlainObj(obj) {
218
+ return typeof obj === 'object' && obj !== null;
219
+ }
220
+ function walkThroughJson(obj, callback, path = '') {
221
+ /**
222
+ * 跳过数据源 state 的处理
223
+ */
224
+ if (/dataset\.state$/.test(path)) {
225
+ return obj;
226
+ }
227
+ if (typeof obj === 'object' && Array.isArray(obj)) {
228
+ return obj.map((item, index) => {
229
+ const prefix = path ? `${path}.${index}` : String(index);
230
+ return _isPlainObj(item) ? walkThroughJson(item, callback, prefix) : callback(index, item, prefix);
231
+ });
232
+ }
233
+ for (const key in obj) {
234
+ const value = obj[key];
235
+ const prefix = path ? `${path}.${key}` : key;
236
+ obj[key] = _isPlainObj(value) ? walkThroughJson(value, callback, prefix) : callback(key, value, prefix);
237
+ }
238
+ return obj;
239
+ }
@@ -30,7 +30,7 @@ async function runWebpackCore({ cals, mainAppData, subAppDataList, appBuildDir,
30
30
  await (0, generate_1.generateHTML)({
31
31
  appId: mainAppData.id || appKey,
32
32
  envId: mainAppData.envId || '',
33
- description: cals.description /* || cals.label */ || '',
33
+ description: cals.description || cals.label || '',
34
34
  enableLoading: (_a = cals.extra) === null || _a === void 0 ? void 0 : _a.enableLoading,
35
35
  appBuildDir,
36
36
  externalResources: (cals.externalResources || []).concat(assets.map((url) => ({
@@ -106,11 +106,7 @@ async function generateWxMp({ buildContext, weapps, plugins, deployOptions, opti
106
106
  isAdminPortal: (0, common_1.buildAsAdminPortalByBuildType)(buildTypeList),
107
107
  },
108
108
  'common/widget.js': {},
109
- 'common/url.js': {},
110
- 'common/weapp-page.js': {
111
- dataPropNames: wxmlDataPrefix,
112
- debug: buildContext.debugMode,
113
- },
109
+ 'common/weapp-page.js': {},
114
110
  'common/weapp-component.js': {},
115
111
  'common/merge-renderer.js': {
116
112
  dataPropNames: wxmlDataPrefix,
@@ -310,12 +306,21 @@ async function generatePkg(ctx, weapp, appRoot, pageConfigs) {
310
306
  console.log(`Generating ${em('page')} files`);
311
307
  (0, generateFiles_1.cleanDir)(path_1.default.join(appRoot, 'pages'), []);
312
308
  await Promise.all(weapp.pageInstanceList.map(async (page) => {
313
- var _a, _b, _c, _d, _e, _f, _g;
309
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
314
310
  // # Generating page
315
311
  const rootPath = weapp.rootPath || '';
316
312
  const usingComponents = {};
317
313
  const componentGenerics = {};
318
314
  const componentInstances = (0, util_2.processRepeaterSchema)(ctx, page.componentInstances);
315
+ const { allAppUsedComps = [] } = handleUsedComponents({
316
+ buildContext: ctx,
317
+ weapps: [
318
+ {
319
+ ...weapp,
320
+ pageInstanceList: [page],
321
+ },
322
+ ],
323
+ });
319
324
  const wxml = (0, wxml_1.generateWxml)({ ...ctx, rootPath, isPage: true }, componentInstances, `Page ${rootPath ? path_1.default.join(rootPath, 'pages') : ''}/${page.id}`, wxmlDataPrefix, usingComponents, componentGenerics);
320
325
  const importor = (0, util_3.generateLowcodeImportor)(page.lowCodes);
321
326
  const pageFileName = (0, lodash_1.get)(pageConfigs, `${page.id}.pageFileName`, 'index');
@@ -343,6 +348,11 @@ async function generatePkg(ctx, weapp, appRoot, pageConfigs) {
343
348
  importor,
344
349
  query: (0, util_2.createTemplateQuery)(ctx, (_f = page.dataset) === null || _f === void 0 ? void 0 : _f.query),
345
350
  eventFlows: (0, util_2.createTemplateEventFlows)(ctx, page.eventFlows),
351
+ resetShare: ((_j = (_h = (_g = page === null || page === void 0 ? void 0 : page.data) === null || _g === void 0 ? void 0 : _g.appShareMessage) === null || _h === void 0 ? void 0 : _h.value) === null || _j === void 0 ? void 0 : _j.enable) ||
352
+ ((_k = allAppUsedComps === null || allAppUsedComps === void 0 ? void 0 : allAppUsedComps[cals_1.OFFICIAL_LIB_KEY]) === null || _k === void 0 ? void 0 : _k.has('Share')) ||
353
+ /* 从 enablePageRoot 的版本开始支持按需reset share
354
+ * 否则默认都开启
355
+ */ !ctx.enablePageRoot,
346
356
  },
347
357
  [`index.json|${pageFileName}.json`]: {
348
358
  usingComponents,
@@ -353,7 +363,7 @@ async function generatePkg(ctx, weapp, appRoot, pageConfigs) {
353
363
  content: wxml,
354
364
  },
355
365
  [`index.wxss|${pageFileName}.wxss`]: {
356
- subWxss: rootPath && !((_g = ctx.mainAppData) === null || _g === void 0 ? void 0 : _g.mpPkgUrl)
366
+ subWxss: rootPath && !((_l = ctx.mainAppData) === null || _l === void 0 ? void 0 : _l.mpPkgUrl)
357
367
  ? `@import "${path_1.default.posix.relative(`/${rootPath}/pages/${page.id}`, '/lowcode')}/style.wxss";`
358
368
  : '',
359
369
  content: (0, weapps_core_1.toCssText)((0, cals_1.processCommonStyle2CSSProperties)(page.commonStyle, {
@@ -9,21 +9,24 @@ const mp_1 = require("@cloudbase/lowcode-generator/lib/generator/config/mp");
9
9
  const cals_1 = require("@cloudbase/cals");
10
10
  const config_1 = require("../config");
11
11
  function extractWidgetProps(props, compInfo, processCssUnit = 'rpx') {
12
- var _a, _b;
13
- const { classList, staticResourceAttribute = [] } = props;
12
+ var _a, _b, _c;
13
+ const { classList, staticResourceAttribute = [], data = {}, style } = props;
14
14
  const staticProps = {
15
- style: (0, cals_1.processCommonStyle2CSSProperties)(props.commonStyle, {
16
- defaultUnit: processCssUnit,
17
- }),
15
+ style: style && ((_a = Object.keys(style || {})) === null || _a === void 0 ? void 0 : _a.length)
16
+ ? (0, cals_1.processCSSPropertiesUnit)(style || {}, processCssUnit)
17
+ : {
18
+ ...(0, cals_1.processCommonStyle2CSSProperties)(props.commonStyle || {}, {
19
+ defaultUnit: processCssUnit,
20
+ }),
21
+ },
18
22
  classList: classList || [],
19
23
  };
20
24
  if (staticResourceAttribute === null || staticResourceAttribute === void 0 ? void 0 : staticResourceAttribute.length) {
21
25
  staticProps._staticResourceAttribute = staticResourceAttribute;
22
26
  }
23
- const { data = {} } = props;
24
27
  Object.assign(staticProps, generatedDynamicData(data, compInfo).staticProps);
25
- if ((_a = props.directives) === null || _a === void 0 ? void 0 : _a.waForKey) {
26
- staticProps._waForKey = (_b = props.directives) === null || _b === void 0 ? void 0 : _b.waForKey.value;
28
+ if ((_b = props.directives) === null || _b === void 0 ? void 0 : _b.waForKey) {
29
+ staticProps._waForKey = (_c = props.directives) === null || _c === void 0 ? void 0 : _c.waForKey.value;
27
30
  }
28
31
  return staticProps;
29
32
  }
@@ -1,6 +1,6 @@
1
1
  export { BuildType, GenerateMpType, WebpackModeType, WebpackBuildCallBack, IPackageJson, buildAsWebByBuildType, buildAsAdminPortalByBuildType, buildAsXPageByBuildType, IAppUsedComp, IUsedComps, ISyncProp, IComponentInputProps, IFileCodeMap, } from '@cloudbase/lowcode-generator/lib/generator/types/common';
2
2
  import { IComponentMeta, ICompositedComponent } from '@cloudbase/lowcode-generator/lib/weapps-core';
3
- export type IComponentsInfoMap = {
3
+ export declare type IComponentsInfoMap = {
4
4
  [componentSourceKey: string]: ({
5
5
  meta: IComponentMeta;
6
6
  } & {
@@ -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
- 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;
@@ -3,25 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.promisifyProcess = void 0;
4
4
  function promisifyProcess(p, opts = {}) {
5
5
  return new Promise((resolve, reject) => {
6
+ var _a, _b, _c, _d;
6
7
  let stdout = '';
7
8
  let stderr = '';
8
- p.stdout &&
9
- p.stdout.on('data', opts.onStdout ||
10
- ((data) => {
11
- console.log(data + '');
12
- stdout += data;
13
- }));
14
- p.stderr &&
15
- p.stderr.on('data', opts.onStderr ||
16
- ((data) => {
17
- console.error(data + '');
18
- stderr += data;
19
- }));
9
+ (_b = (_a = p.stdout) === null || _a === void 0 ? void 0 : _a.on) === null || _b === void 0 ? void 0 : _b.call(_a, 'data', opts.onStdout ||
10
+ ((data) => {
11
+ console.log(`${data}`);
12
+ stdout += data;
13
+ }));
14
+ (_d = (_c = p.stderr) === null || _c === void 0 ? void 0 : _c.on) === null || _d === void 0 ? void 0 : _d.call(_c, 'data', opts.onStderr ||
15
+ ((data) => {
16
+ console.error(`${data}`);
17
+ stderr += data;
18
+ }));
20
19
  p.on('error', reject);
21
20
  p.on('exit', (exitCode) => {
22
- exitCode === 0
23
- ? resolve(exitCode)
24
- : reject(new Error(stderr || String(exitCode)));
21
+ exitCode === 0 ? resolve(exitCode) : reject(new Error(stderr || String(exitCode)));
25
22
  });
26
23
  });
27
24
  }