@cloudbase/lowcode-builder 1.1.5-alpha.0 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,11 +16,3 @@ export declare const miniprogramURL = "https://comp-public-1303824488.cos.ap-sha
16
16
  * miniprogram_npm存放目录。IDE插件builder用到
17
17
  */
18
18
  export declare const miniprogramDir: string;
19
- export interface ICDN_ENDPOINTS_COFIG {
20
- common?: string;
21
- cloudbase: string;
22
- cdngo?: string;
23
- aegis?: string;
24
- }
25
- export declare const CDN_ENDPONTS_CONFIG: ICDN_ENDPOINTS_COFIG;
26
- export declare function generateCdnEndpoints(endpoints?: ICDN_ENDPOINTS_COFIG): ICDN_ENDPOINTS_COFIG;
@@ -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.generateCdnEndpoints = exports.CDN_ENDPONTS_CONFIG = exports.miniprogramDir = exports.miniprogramURL = exports.builderTemplateURL = exports.materialsDirName = exports.appTemplateDir = exports.sharedMaterialsDir = exports.OFFICIAL_LIB_KEY = exports.rpxConfig = exports.remConfig = exports.npmRegistry = exports.KBONE_PAGE_KEYS = exports.MP_CONFIG_MODULE_NAME = exports.REPLACE_SIGN = void 0;
29
+ exports.miniprogramDir = exports.miniprogramURL = exports.builderTemplateURL = exports.materialsDirName = exports.appTemplateDir = exports.sharedMaterialsDir = exports.OFFICIAL_LIB_KEY = exports.rpxConfig = exports.remConfig = exports.npmRegistry = exports.KBONE_PAGE_KEYS = exports.MP_CONFIG_MODULE_NAME = exports.REPLACE_SIGN = void 0;
30
30
  const path = __importStar(require("path"));
31
31
  const os_1 = __importDefault(require("os"));
32
32
  var index_1 = require("@cloudbase/lowcode-generator/lib/generator/config/index");
@@ -54,18 +54,3 @@ exports.miniprogramURL = 'https://comp-public-1303824488.cos.ap-shanghai.myqclou
54
54
  * miniprogram_npm存放目录。IDE插件builder用到
55
55
  */
56
56
  exports.miniprogramDir = path.join(os_1.default.homedir(), exports.sharedMaterialsDir, 'miniprogram_npm');
57
- exports.CDN_ENDPONTS_CONFIG = {
58
- common: '',
59
- cloudbase: '//static.cloudbase.net',
60
- cdngo: 'https://qbase.cdn-go.cn',
61
- aegis: 'https://cdn-go.cn',
62
- };
63
- function generateCdnEndpoints(endpoints = exports.CDN_ENDPONTS_CONFIG) {
64
- for (const key in exports.CDN_ENDPONTS_CONFIG) {
65
- if (!endpoints[key]) {
66
- endpoints[key] = endpoints.common ? endpoints.common : exports.CDN_ENDPONTS_CONFIG[key];
67
- }
68
- }
69
- return endpoints;
70
- }
71
- exports.generateCdnEndpoints = generateCdnEndpoints;
@@ -2,7 +2,6 @@ import { IMaterialItem, IWeAppData, IPlugin, IExtraData } from '@cloudbase/lowco
2
2
  import { BuildType, GenerateMpType, WebpackBuildCallBack, WebpackModeType } from '../types/common';
3
3
  import { DEPLOY_MODE, RUNTIME } from '../../types';
4
4
  import { IPlatformApp } from '@cloudbase/cals';
5
- import { ICDN_ENDPOINTS_COFIG } from '../config';
6
5
  export interface IBaseAppProps {
7
6
  appKey: string;
8
7
  dependencies?: IMaterialItem[];
@@ -36,39 +35,11 @@ export interface IBuildWedaApp extends IBaseAppProps {
36
35
  path?: string;
37
36
  };
38
37
  isBrowserMpBuilder?: boolean;
39
- cdnEndpoints?: ICDN_ENDPOINTS_COFIG;
40
38
  }
41
- export declare function buildWedaApp({ cals, subAppCalsList, dependencies, appKey, runtime, ignoreInstall, buildTypeList, mode, devTool, deployOptions, generateMpType, plugins, extraData, resourceAppId, domain, output, isBrowserMpBuilder, cdnEndpoints, }: IBuildWedaApp, cb?: WebpackBuildCallBack): Promise<string | undefined>;
39
+ export declare function buildWedaApp({ cals, subAppCalsList, dependencies, appKey, runtime, ignoreInstall, buildTypeList, mode, devTool, deployOptions, generateMpType, plugins, extraData, resourceAppId, domain, output, isBrowserMpBuilder, }: IBuildWedaApp, cb?: WebpackBuildCallBack): Promise<string | undefined>;
42
40
  export declare function cleanComponentDir(): Promise<void>;
43
41
  export declare const version: any;
44
42
  export { getFiles, fileToZip, strToBuf } from '../util/generateFiles';
45
43
  export { downloadZip } from '../util/net';
46
44
  export { getCompileDirs } from '../util';
47
45
  export default buildWedaApp;
48
- interface INormalizeInput {
49
- appId?: string;
50
- appKey?: string;
51
- dependencies?: IBuildWedaApp['dependencies'];
52
- buildTypeList: IBuildWedaApp['buildTypeList'];
53
- mainAppSerializeData?: IBuildWedaApp['cals'];
54
- cals?: IBuildWedaApp['cals'];
55
- subAppSerializeDataList?: IBuildWedaApp['subAppCalsList'];
56
- subAppCalsList?: IBuildWedaApp['subAppCalsList'];
57
- deployOptions: IBuildWedaApp['deployOptions'];
58
- mpAppId?: string;
59
- extraData?: {
60
- isComposite: boolean;
61
- compProps: {};
62
- };
63
- [key: string]: any;
64
- }
65
- interface InormalizeOutput extends INormalizeInput {
66
- dependencies: Required<INormalizeInput['dependencies']>;
67
- }
68
- export declare function normalizeInputs(inputs: INormalizeInput, { envId, getWebRootPath, }: {
69
- envId: string;
70
- getWebRootPath?: ({ appId, deployOptions }: {
71
- appId: any;
72
- deployOptions: any;
73
- }) => string;
74
- }): InormalizeOutput;
@@ -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.normalizeInputs = exports.getCompileDirs = exports.downloadZip = exports.strToBuf = exports.fileToZip = exports.getFiles = exports.version = exports.cleanComponentDir = exports.buildWedaApp = void 0;
6
+ exports.getCompileDirs = exports.downloadZip = exports.strToBuf = exports.fileToZip = exports.getFiles = exports.version = exports.cleanComponentDir = exports.buildWedaApp = void 0;
7
7
  const fs_extra_1 = __importDefault(require("fs-extra"));
8
8
  const chalk_1 = __importDefault(require("chalk"));
9
9
  const path_1 = __importDefault(require("path"));
@@ -20,7 +20,7 @@ const pkg = require('../../../package.json');
20
20
  async function buildWedaApp({ cals, subAppCalsList = [], dependencies = [], appKey = 'test', runtime = types_1.RUNTIME.NONE, ignoreInstall = false, buildTypeList = [common_1.BuildType.WEB], mode = common_1.WebpackModeType.PRODUCTION, devTool = 'webpack', deployOptions = { mode: types_1.DEPLOY_MODE.PREVIEW }, generateMpType = common_1.GenerateMpType.APP, plugins = [], extraData = {
21
21
  isComposite: false,
22
22
  compProps: {},
23
- }, resourceAppId = undefined, domain = '', output, isBrowserMpBuilder = false, cdnEndpoints, }, cb) {
23
+ }, resourceAppId = undefined, domain = '', output, isBrowserMpBuilder = false, }, cb) {
24
24
  var _a, _b;
25
25
  if (!cals) {
26
26
  console.error('无效的应用配置');
@@ -48,15 +48,15 @@ async function buildWedaApp({ cals, subAppCalsList = [], dependencies = [], appK
48
48
  weapps: apps,
49
49
  projDir: appBuildDir,
50
50
  appId: appKey,
51
- domain,
51
+ domain: domain,
52
52
  materials: dependencies,
53
53
  plugins,
54
54
  isProduction: mode === common_1.WebpackModeType.PRODUCTION,
55
55
  deployMode,
56
+ extraData,
56
57
  isMixMode,
57
58
  options: {
58
59
  isCrossAccount: resourceAppId !== deployOptions.targetMpAppId,
59
- mpAppId: deployOptions.mpAppId || '',
60
60
  resourceAppId,
61
61
  },
62
62
  buildTypeList,
@@ -86,11 +86,11 @@ async function buildWedaApp({ cals, subAppCalsList = [], dependencies = [], appK
86
86
  // 模板需要占位保证 mp 文件夹存在
87
87
  fs_extra_1.default.removeSync(path_1.default.resolve(outDir, 'miniprogram_npm'));
88
88
  }
89
- await (cb === null || cb === void 0 ? void 0 : cb(null, {
89
+ cb === null || cb === void 0 ? void 0 : cb(null, {
90
90
  ...result,
91
91
  outDir,
92
92
  timeElapsed: Date.now() - startTime,
93
- }));
93
+ });
94
94
  return outDir;
95
95
  }
96
96
  else {
@@ -108,36 +108,17 @@ async function buildWedaApp({ cals, subAppCalsList = [], dependencies = [], appK
108
108
  deployMode,
109
109
  ignoreInstall,
110
110
  domain,
111
- cdnEndpoints,
112
111
  });
113
- await (cb === null || cb === void 0 ? void 0 : cb(null, {
112
+ cb === null || cb === void 0 ? void 0 : cb(null, {
114
113
  outDir: h5BuildDir,
115
114
  timeElapsed: Date.now() - startTime,
116
- }));
115
+ });
117
116
  return h5BuildDir;
118
117
  }
119
118
  }
120
- catch (err) {
121
- if (err.length) {
122
- let messageList = (err[0] || '').split('\n');
123
- let lineIndex = 0;
124
- let reg = /node_modules\/@babel/;
125
- messageList.find((str, index) => {
126
- if (reg.test(str)) {
127
- lineIndex = index;
128
- return true;
129
- }
130
- else {
131
- return false;
132
- }
133
- });
134
- if (lineIndex) {
135
- messageList = messageList.slice(0, lineIndex);
136
- }
137
- err = new Error(messageList.join('\n'));
138
- }
139
- cb === null || cb === void 0 ? void 0 : cb(err);
140
- throw err;
119
+ catch (e) {
120
+ cb === null || cb === void 0 ? void 0 : cb(e);
121
+ throw e;
141
122
  }
142
123
  }
143
124
  exports.buildWedaApp = buildWedaApp;
@@ -155,98 +136,3 @@ Object.defineProperty(exports, "downloadZip", { enumerable: true, get: function
155
136
  var util_2 = require("../util");
156
137
  Object.defineProperty(exports, "getCompileDirs", { enumerable: true, get: function () { return util_2.getCompileDirs; } });
157
138
  exports.default = buildWedaApp;
158
- function normalizeInputs(inputs, { envId, getWebRootPath, }) {
159
- const { extraData = { isComposite: false, compProps: {} } } = inputs;
160
- /**
161
- * 过滤处理 dependencies
162
- */
163
- let map = {};
164
- inputs.dependencies = (inputs.dependencies || []).reduce((list, item) => {
165
- if (!map[`${item.name}@${item.version}`]) {
166
- map[`${item.name}@${item.version}`] = true;
167
- list.push(item);
168
- }
169
- return list;
170
- }, []);
171
- const normalizeCalsOptions = {
172
- buildTypeList: inputs.buildTypeList,
173
- envId,
174
- deployOptions: inputs.deployOptions,
175
- appId: inputs.appId || inputs.appKey,
176
- getWebRootPath: getWebRootPath || _getWebRootPath,
177
- };
178
- if (inputs.mainAppSerializeData) {
179
- inputs.mainAppSerializeData = normalizeCals(inputs.mainAppSerializeData, normalizeCalsOptions);
180
- if ((0, common_1.buildAsWebByBuildType)(inputs.buildTypeList)) {
181
- inputs.subAppSerializeDataList = [];
182
- }
183
- }
184
- if (inputs.cals) {
185
- inputs.cals = normalizeCals(inputs.cals, normalizeCalsOptions);
186
- if ((0, common_1.buildAsWebByBuildType)(inputs.buildTypeList)) {
187
- inputs.subAppCalsList = [];
188
- }
189
- }
190
- if (!(0, common_1.buildAsWebByBuildType)(inputs.buildTypeList)) {
191
- // 小程序构建
192
- const { mpAppId, deployOptions = { mode: types_1.DEPLOY_MODE.PREVIEW } } = inputs;
193
- inputs.deployOptions = {
194
- ...deployOptions,
195
- mpAppId: deployOptions.mpAppId || mpAppId,
196
- };
197
- if (inputs.deployOptions.targetMpAppId === undefined) {
198
- inputs.deployOptions.targetMpAppId = inputs.deployOptions.mpAppId;
199
- }
200
- }
201
- if (extraData.isComposite) {
202
- Object.keys(extraData.compProps.events).forEach((eName) => {
203
- extraData.compProps.events[eName] = `$$EVENT_${eName}$$`;
204
- });
205
- }
206
- return inputs;
207
- }
208
- exports.normalizeInputs = normalizeInputs;
209
- function normalizeCals(cals, { buildTypeList, envId, deployOptions, appId, getWebRootPath }) {
210
- var _a, _b;
211
- if (!cals.extra) {
212
- cals.extra = {};
213
- }
214
- if (!cals.mpPkgUrl) {
215
- if (buildTypeList.includes(common_1.BuildType.APP) ||
216
- buildTypeList.includes(common_1.BuildType.XPAGE_PC) ||
217
- buildTypeList.includes(common_1.BuildType.ADMIN_PORTAL)) {
218
- cals.extra.historyType = types_1.HISTORY_TYPE.HASH;
219
- }
220
- }
221
- if (!((_a = cals === null || cals === void 0 ? void 0 : cals.extra) === null || _a === void 0 ? void 0 : _a.envId)) {
222
- cals.extra.envId = envId;
223
- }
224
- if ((0, common_1.buildAsWebByBuildType)(buildTypeList)) {
225
- // web 构建不处理小程序插件
226
- if (cals.extra.miniprogramPlugins) {
227
- cals.extra.miniprogramPlugins = [];
228
- }
229
- let { appConfig = {} } = cals.extra;
230
- let { window = {} } = appConfig;
231
- let path = getWebRootPath({ appId, deployOptions });
232
- cals.extra.appConfig = {
233
- ...appConfig,
234
- window: {
235
- ...window,
236
- // Todo: 处理自定义域名逻辑
237
- publicPath: (0, common_1.buildAsXPageByBuildType)(buildTypeList)
238
- ? (deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.publicPath) || `https://${(_b = cals.extra) === null || _b === void 0 ? void 0 : _b.domain}${path}`
239
- : path,
240
- basename: (0, common_1.buildAsAdminPortalByBuildType)(buildTypeList)
241
- ? `app/${appId}${(deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.mode) !== types_1.DEPLOY_MODE.UPLOAD ? '-preview' : ''}`
242
- : (0, common_1.buildAsXPageByBuildType)(buildTypeList)
243
- ? '/'
244
- : path,
245
- },
246
- };
247
- }
248
- return cals;
249
- }
250
- function _getWebRootPath({ appId, deployOptions }) {
251
- return (deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.mode) === types_1.DEPLOY_MODE.PREVIEW ? `/${appId}/preview/` : `/${appId}/production/`;
252
- }
@@ -1,11 +1,10 @@
1
1
  import { BuildAppProps } from '@cloudbase/lowcode-generator';
2
- import { ICDN_ENDPOINTS_COFIG } from '../config';
3
2
  import { BuildType } from '../types/common';
4
3
  /**
5
4
  * 该函数从 @govcloud/generate 取到需要的模版文件
6
5
  */
7
6
  export declare function generateProjectFiles(buildData: BuildAppProps): Promise<void>;
8
- export declare function generateHTML({ appId, appBuildDir, jsApis, mode, devTool, isBuildApp, buildTypeList, cdnEndpoints, }: {
7
+ export declare function generateHTML({ appId, appBuildDir, jsApis, mode, devTool, isBuildApp, buildTypeList, }: {
9
8
  appId: string;
10
9
  jsApis: string[];
11
10
  appBuildDir: string;
@@ -13,7 +12,6 @@ export declare function generateHTML({ appId, appBuildDir, jsApis, mode, devTool
13
12
  devTool: string;
14
13
  isBuildApp: boolean;
15
14
  buildTypeList: BuildType[];
16
- cdnEndpoints?: ICDN_ENDPOINTS_COFIG;
17
15
  }): Promise<void>;
18
16
  export declare function handleAssets({ appBuildDir, buildTypeList, assets, }: {
19
17
  appBuildDir: string;
@@ -24,7 +24,7 @@ async function generateProjectFiles(buildData) {
24
24
  }));
25
25
  }
26
26
  exports.generateProjectFiles = generateProjectFiles;
27
- async function generateHTML({ appId, appBuildDir, jsApis, mode, devTool, isBuildApp, buildTypeList, cdnEndpoints, }) {
27
+ async function generateHTML({ appId, appBuildDir, jsApis, mode, devTool, isBuildApp, buildTypeList, }) {
28
28
  const templatePath = path_1.default.join(config_1.appTemplateDir, 'html', 'index.html.ejs');
29
29
  const dstFilePath = path_1.default.join(appBuildDir, 'index.html');
30
30
  const packageTpl = await fs_extra_1.default.readFile(templatePath, { encoding: 'utf8' });
@@ -37,7 +37,6 @@ async function generateHTML({ appId, appBuildDir, jsApis, mode, devTool, isBuild
37
37
  mode,
38
38
  isBuildApp,
39
39
  isAdminPortal: (0, common_2.buildAsAdminPortalByBuildType)(buildTypeList),
40
- cdnEndpoints: (0, config_1.generateCdnEndpoints)(cdnEndpoints),
41
40
  }));
42
41
  }
43
42
  exports.generateHTML = generateHTML;
@@ -2,8 +2,7 @@ import { IMaterialItem, II18nConfig, IExtraData } from '@cloudbase/lowcode-gener
2
2
  import { BuildType, WebpackModeType } from '../types/common';
3
3
  import { DEPLOY_MODE, RUNTIME } from '../../types';
4
4
  import { IPlatformApp } from '@cloudbase/cals';
5
- import { ICDN_ENDPOINTS_COFIG } from '../config';
6
- export declare function buildH5App({ appKey, buildDir, dependencies, i18nConfig, extraData, cals, buildTypeList, subAppCalsList, mode, devTool, runtime, deployMode, ignoreInstall, domain, cdnEndpoints, }: {
5
+ export declare function buildH5App({ appKey, buildDir, dependencies, i18nConfig, extraData, cals, buildTypeList, subAppCalsList, mode, devTool, runtime, deployMode, ignoreInstall, domain, }: {
7
6
  appKey: string;
8
7
  buildDir: string;
9
8
  cals: IPlatformApp;
@@ -18,5 +17,4 @@ export declare function buildH5App({ appKey, buildDir, dependencies, i18nConfig,
18
17
  deployMode?: DEPLOY_MODE;
19
18
  ignoreInstall?: boolean;
20
19
  domain: string;
21
- cdnEndpoints?: ICDN_ENDPOINTS_COFIG;
22
20
  }): Promise<string>;
@@ -19,20 +19,11 @@ const types_1 = require("../../types");
19
19
  const mp_1 = require("../mp");
20
20
  const common_2 = require("../../utils/common");
21
21
  const config_1 = require("../config");
22
- const fs_extra_1 = __importDefault(require("fs-extra"));
23
- async function buildH5App({ appKey, buildDir, dependencies, i18nConfig, extraData, cals, buildTypeList = [common_1.BuildType.WEB], subAppCalsList, mode, devTool, runtime = types_1.RUNTIME.NONE, deployMode = types_1.DEPLOY_MODE.PREVIEW, ignoreInstall = false, domain = '', cdnEndpoints, }) {
24
- var _a, _b, _c;
22
+ async function buildH5App({ appKey, buildDir, dependencies, i18nConfig, extraData, cals, buildTypeList = [common_1.BuildType.WEB], subAppCalsList, mode, devTool, runtime = types_1.RUNTIME.NONE, deployMode = types_1.DEPLOY_MODE.PREVIEW, ignoreInstall = false, domain = '', }) {
23
+ var _a, _b;
25
24
  try {
26
25
  const { materialsDir } = runtime === types_1.RUNTIME.CI ? (0, util_1.getCompileDirs)(appKey) : (0, util_1.getCompileDirs)('app');
27
26
  const h5BuildDir = path_1.default.join(buildDir, 'h5');
28
- if (buildTypeList.includes(common_1.BuildType.APP) ||
29
- buildTypeList.includes(common_1.BuildType.XPAGE_PC) ||
30
- buildTypeList.includes(common_1.BuildType.ADMIN_PORTAL)) {
31
- if (!cals.extra) {
32
- cals.extra = {};
33
- }
34
- cals.extra.historyType = types_1.HISTORY_TYPE.HASH;
35
- }
36
27
  const mainAppSerializeData = (0, common_2.processCals2WeappsData)(cals, dependencies);
37
28
  const subAppSerializeDataList = (subAppCalsList === null || subAppCalsList === void 0 ? void 0 : subAppCalsList.map((item) => (0, common_2.processCals2WeappsData)(item, dependencies))) || [];
38
29
  const buildContext = {
@@ -52,7 +43,7 @@ async function buildH5App({ appKey, buildDir, dependencies, i18nConfig, extraDat
52
43
  // 处理应用数据
53
44
  const mainAppData = (0, weapps_core_1.deserialize)(mainAppSerializeData);
54
45
  if (!mainAppData.extra) {
55
- mainAppData.extra = { domain };
46
+ mainAppData.extra = { domain: domain };
56
47
  }
57
48
  if (!((_a = mainAppData.extra) === null || _a === void 0 ? void 0 : _a.domain)) {
58
49
  mainAppData.extra.domain = domain;
@@ -125,7 +116,6 @@ async function buildH5App({ appKey, buildDir, dependencies, i18nConfig, extraDat
125
116
  devTool,
126
117
  publicPath,
127
118
  domain,
128
- cdnEndpoints,
129
119
  });
130
120
  await new Promise((resolve, reject) => {
131
121
  // 开始编译前清理一下 lowcode 内容
@@ -143,10 +133,6 @@ async function buildH5App({ appKey, buildDir, dependencies, i18nConfig, extraDat
143
133
  }
144
134
  });
145
135
  });
146
- // 普通 web 模式,且非hash模式,根据页面生成多份入口
147
- if (!((_c = cals.extra) === null || _c === void 0 ? void 0 : _c.historyType) || cals.extra.historyType === types_1.HISTORY_TYPE.BROWSER) {
148
- await Promise.all((cals.items || []).map((page) => fs_extra_1.default.copy(path_1.default.resolve(h5BuildDir, webpack_2.OUTPUT_DIR, 'index.html'), path_1.default.resolve(h5BuildDir, webpack_2.OUTPUT_DIR, page.id, 'index.html'))));
149
- }
150
136
  return h5BuildDir;
151
137
  }
152
138
  catch (e) {
@@ -1,13 +1,11 @@
1
1
  import { IWebRuntimeAppData } from '@cloudbase/lowcode-generator/lib/weapps-core';
2
2
  import { BuildAppProps } from '../core/index';
3
- import { ICDN_ENDPOINTS_COFIG } from '../config';
4
3
  interface IWebpackCoreProps extends BuildAppProps {
5
4
  appBuildDir: string;
6
5
  mpConfig: any;
7
6
  mainAppData: IWebRuntimeAppData;
8
7
  subAppDataList: IWebRuntimeAppData[];
9
8
  assets: string[];
10
- cdnEndpoints?: ICDN_ENDPOINTS_COFIG;
11
9
  }
12
- export declare function runWebpackCore({ mainAppData, subAppDataList, appBuildDir, publicPath, mode, appKey, buildTypeList, mpConfig, assets, devTool, generateMpType, cdnEndpoints, }: IWebpackCoreProps): Promise<string>;
10
+ export declare function runWebpackCore({ mainAppData, subAppDataList, appBuildDir, publicPath, mode, appKey, buildTypeList, mpConfig, assets, devTool, generateMpType, }: IWebpackCoreProps): Promise<string>;
13
11
  export {};
@@ -4,7 +4,7 @@ exports.runWebpackCore = void 0;
4
4
  const common_1 = require("../types/common");
5
5
  const webpack_1 = require("../service/webpack");
6
6
  const generate_1 = require("./generate");
7
- async function runWebpackCore({ mainAppData, subAppDataList, appBuildDir, publicPath, mode = common_1.WebpackModeType.NONE, appKey, buildTypeList = [common_1.BuildType.WEB], mpConfig, assets = [], devTool = 'vite', generateMpType = common_1.GenerateMpType.APP, cdnEndpoints, }) {
7
+ async function runWebpackCore({ mainAppData, subAppDataList, appBuildDir, publicPath, mode = common_1.WebpackModeType.NONE, appKey, buildTypeList = [common_1.BuildType.WEB], mpConfig, assets = [], devTool = 'vite', generateMpType = common_1.GenerateMpType.APP, }) {
8
8
  console.time('runWebpackCore');
9
9
  console.time('webpackGenerate');
10
10
  const allAppDataList = subAppDataList.concat(mainAppData);
@@ -33,7 +33,6 @@ async function runWebpackCore({ mainAppData, subAppDataList, appBuildDir, public
33
33
  devTool,
34
34
  isBuildApp: buildTypeList.includes(common_1.BuildType.APP),
35
35
  buildTypeList,
36
- cdnEndpoints,
37
36
  });
38
37
  if ((0, common_1.buildAsWebByBuildType)(buildTypeList)) {
39
38
  if (mode !== common_1.WebpackModeType.PRODUCTION) {
@@ -2,7 +2,7 @@ import { IMaterialItem, IWeAppData, IPlugin } from '@cloudbase/lowcode-generator
2
2
  import { IBuildContext } from './BuildContext';
3
3
  import { DEPLOY_MODE } from '../../types';
4
4
  import { BuildType, IAppUsedComp, IUsedComps } from '../types/common';
5
- export declare function generateWxMp({ weapps, projDir, appId, domain, materials, plugins, isProduction, deployMode, isMixMode, options, buildTypeList, isBrowserMpBuilder, }: {
5
+ export declare function generateWxMp({ weapps, projDir, appId, domain, materials, plugins, isProduction, deployMode, extraData, isMixMode, options, buildTypeList, isBrowserMpBuilder, }: {
6
6
  weapps: IWeAppData[];
7
7
  projDir: string;
8
8
  appId: string;
@@ -11,9 +11,9 @@ export declare function generateWxMp({ weapps, projDir, appId, domain, materials
11
11
  plugins: IPlugin[];
12
12
  isProduction: boolean;
13
13
  deployMode: DEPLOY_MODE;
14
+ extraData: any;
14
15
  isMixMode: boolean;
15
16
  options: {
16
- mpAppId: string;
17
17
  resourceAppId?: string;
18
18
  isCrossAccount: boolean;
19
19
  };
@@ -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({ weapps, projDir, appId, domain, materials, plugins, isProduction, deployMode, isMixMode, options, buildTypeList, isBrowserMpBuilder = false, }) {
57
+ async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins, isProduction, deployMode, extraData, isMixMode, options, buildTypeList, isBrowserMpBuilder = false, }) {
58
58
  var _a;
59
59
  const operationLabel = em('Wexin MiniProgram Generated');
60
60
  console.time(operationLabel);
@@ -72,6 +72,7 @@ async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins
72
72
  domain,
73
73
  isBrowserMpBuilder,
74
74
  };
75
+ const yyptConfig = await (0, util_3.getYyptConfigInfo)(extraData);
75
76
  const { allAppUsedComps } = handleUsedComponents({
76
77
  buildContext,
77
78
  weapps,
@@ -81,7 +82,7 @@ async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins
81
82
  // 安装依赖库,生成 materials 目录
82
83
  await (0, materials_1.installMaterials)(projDir, allAppUsedComps, weapps, buildContext);
83
84
  const wxmlDataPrefix = (0, mp_1.getWxmlDataPrefix)(!isProduction);
84
- const { projConfig, appConfig, pageConfigs } = (0, mp_config_1.generateMpConfig)(weapps, buildContext, { mpAppId: options.mpAppId });
85
+ const { projConfig, appConfig, pageConfigs } = (0, mp_config_1.generateMpConfig)(weapps, buildContext);
85
86
  // #1 generate project files
86
87
  if (!mainAppData.mpPkgUrl) {
87
88
  const projectFileData = {
@@ -134,8 +135,7 @@ async function generateWxMp({ weapps, projDir, appId, domain, materials, plugins
134
135
  };
135
136
  }
136
137
  if (mainAppData.mpPkgUrl) {
137
- // 合并 project 和 app json,复写 appId
138
- projectConfigJson.appId = projConfig.appId;
138
+ // 合并 project 和 app json
139
139
  if (!projectConfigJson.setting) {
140
140
  projectConfigJson.setting = {};
141
141
  }
@@ -6,9 +6,7 @@ import { IBuildContext } from './BuildContext';
6
6
  * @param kboneConfig https://wechat-miniprogram.github.io/kbone/docs/config/
7
7
  * @param appConfigs app config from prop edit panel
8
8
  */
9
- export declare function generateMpConfig(weapps: IWeAppData[], ctx: IBuildContext, options: {
10
- mpAppId?: string;
11
- }): {
9
+ export declare function generateMpConfig(weapps: IWeAppData[], ctx: IBuildContext): {
12
10
  appConfig: any;
13
11
  projConfig: any;
14
12
  pageConfigs: {}[];
@@ -40,7 +40,7 @@ const chalk_1 = __importDefault(require("chalk"));
40
40
  * @param kboneConfig https://wechat-miniprogram.github.io/kbone/docs/config/
41
41
  * @param appConfigs app config from prop edit panel
42
42
  */
43
- function generateMpConfig(weapps, ctx, options) {
43
+ function generateMpConfig(weapps, ctx) {
44
44
  var _a;
45
45
  const appConfig = {
46
46
  useExtendedLib: { weui: true },
@@ -116,9 +116,6 @@ function generateMpConfig(weapps, ctx, options) {
116
116
  });
117
117
  }
118
118
  });
119
- if (options.mpAppId) {
120
- projConfig.appId = options.mpAppId;
121
- }
122
119
  // merge(pageConfigs, extractAllPagesConfig())
123
120
  return { appConfig, projConfig, pageConfigs };
124
121
  }
@@ -67,7 +67,7 @@ function generateDataBindMeta(bind) {
67
67
  imports += (0, lowcode_generator_1.generateExpressionAlias)(value);
68
68
  }
69
69
  catch (e) {
70
- console.error('parse expression error', value);
70
+ console.error('parse expression error', value, e === null || e === void 0 ? void 0 : e.message);
71
71
  }
72
72
  expr = value;
73
73
  }
@@ -2,7 +2,6 @@ import { IMaterialItem, IWebRuntimeAppData } from '@cloudbase/lowcode-generator/
2
2
  import { BuildType, WebpackModeType } from '../types/common';
3
3
  import { RUNTIME } from '../../types';
4
4
  export declare const PERSISTENT_DEPENDIENCES_MAP: {};
5
- export declare const OUTPUT_DIR = "preview";
6
5
  export interface IMpConfig {
7
6
  origin: string;
8
7
  entry: string;
@@ -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.downloadAssets = exports.generateWebpackWebDevServerFile = exports.getMaterialNodeModulesPathList = exports.installDependencies = exports.downloadDependencies = exports.downloadAndInstallDependencies = exports.getAllPageMpEntryPath = exports.getWebpackMpBuildParams = exports.getWebpackWebBuildParams = exports.getMpAllRouterConfig = exports.getPageName = exports.getHomePageInstance = exports.getMainAppDataByList = exports.generateMpJsonConfigFile = exports.generateKboneAppConfig = exports.generateKbonePageConfig = exports.downloadAndWriteTabBarIcon = exports.generateKboneTabBarConfig = exports.generateAppConfig = exports.generateWebpackWebBuildParamsFile = exports.fixAppJson = exports.OUTPUT_DIR = exports.PERSISTENT_DEPENDIENCES_MAP = void 0;
6
+ exports.downloadAssets = exports.generateWebpackWebDevServerFile = exports.getMaterialNodeModulesPathList = exports.installDependencies = exports.downloadDependencies = exports.downloadAndInstallDependencies = exports.getAllPageMpEntryPath = exports.getWebpackMpBuildParams = exports.getWebpackWebBuildParams = exports.getMpAllRouterConfig = exports.getPageName = exports.getHomePageInstance = exports.getMainAppDataByList = exports.generateMpJsonConfigFile = exports.generateKboneAppConfig = exports.generateKbonePageConfig = exports.downloadAndWriteTabBarIcon = exports.generateKboneTabBarConfig = exports.generateAppConfig = exports.generateWebpackWebBuildParamsFile = exports.fixAppJson = exports.PERSISTENT_DEPENDIENCES_MAP = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const fs_extra_1 = __importDefault(require("fs-extra"));
9
9
  const lodash_1 = require("lodash");
@@ -18,7 +18,6 @@ const common_2 = require("../util/common");
18
18
  const types_1 = require("../../types");
19
19
  const generateFiles_1 = require("../util/generateFiles");
20
20
  exports.PERSISTENT_DEPENDIENCES_MAP = {};
21
- exports.OUTPUT_DIR = 'preview';
22
21
  async function fixAppJson(appBuildDir) {
23
22
  const appJsonPath = path_1.default.resolve(appBuildDir, 'dist/mp/app.json');
24
23
  if (!fs_extra_1.default.existsSync(appJsonPath)) {
@@ -274,7 +273,7 @@ function getWebpackWebBuildParams(appId, appBuildDir, publicPath = '/', mode = c
274
273
  watch: false,
275
274
  entry: path_1.default.resolve(appBuildDir, 'src/index.jsx'),
276
275
  output: {
277
- path: path_1.default.resolve(appBuildDir, exports.OUTPUT_DIR),
276
+ path: path_1.default.resolve(appBuildDir, './preview'),
278
277
  filename: '[name].[contenthash].bundle.js',
279
278
  chunkFilename: '[name].[contenthash].chunk.js',
280
279
  publicPath: buildTypeList.includes(common_1.BuildType.APP) || buildTypeList.includes(common_1.BuildType.ADMIN_PORTAL) ? '' : publicPath,
@@ -295,6 +294,8 @@ function getWebpackWebBuildParams(appId, appBuildDir, publicPath = '/', mode = c
295
294
  resolveModules: [path_1.default.resolve(appBuildDir), 'node_modules'],
296
295
  definePlugin: {
297
296
  'process.env.buildType': `"${buildTypeList[0]}"`,
297
+ 'process.env.isApp': buildTypeList.includes(common_1.BuildType.APP),
298
+ 'process.env.isAdminPortal': (0, common_1.buildAsAdminPortalByBuildType)(buildTypeList),
298
299
  ...extraDefine,
299
300
  },
300
301
  devtool: ['app-nvzcvt10', 'app-msa2ihs9'].includes(appId)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/lowcode-builder",
3
- "version": "1.1.5-alpha.0",
3
+ "version": "1.1.5",
4
4
  "description": "云开发 Tencent CloudBase Framework Low Code Plugin,将低码配置生成完整项目并一键部署云开发资源。",
5
5
  "author": "yhsunshining@gmail.com",
6
6
  "homepage": "https://github.com/TencentCloudBase/cloudbase-framework#readme",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@cloudbase/cals": "^0.4.10",
42
- "@cloudbase/lowcode-generator": "^1.1.2-alpha.0",
42
+ "@cloudbase/lowcode-generator": "^1.1.2",
43
43
  "axios": "^0.21.0",
44
44
  "browserfs": "^1.4.3",
45
45
  "browserify-zlib": "^0.2.0",
@@ -12,12 +12,9 @@
12
12
  <meta name="description" content="<%= desc %>" />
13
13
  <link
14
14
  rel="stylesheet"
15
- href="<%=
16
- cdnEndpoints.cdngo
17
- %>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.ba91c21b0d605c84ac7f.css"
15
+ href="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.ba91c21b0d605c84ac7f.css"
18
16
  />
19
- <% if(cdnEndpoints.aegis){ %>
20
- <script crossorigin="anonymous" src="<%= cdnEndpoints.aegis %>/aegis/aegis-sdk/latest/aegis.min.js?v=1"></script>
17
+ <script crossorigin="anonymous" src="https://cdn-go.cn/aegis/aegis-sdk/latest/aegis.min.js?v=1"></script>
21
18
  <script>
22
19
  <% if(!isAdminPortal){ %>
23
20
  const _aegis = new Aegis({
@@ -39,7 +36,6 @@
39
36
  window._aegis = _aegis;
40
37
  window._aegis_inited = Date.now()
41
38
  </script>
42
- <% }%>
43
39
  <title><%= title %></title>
44
40
  <% if(mode !== 'production'){ %>
45
41
  <!-- <script src="https://cdn.bootcdn.net/ajax/libs/vConsole/3.3.4/vconsole.min.js"></script>
@@ -391,10 +387,10 @@
391
387
  <script type="module" src="/src/index.jsx"></script>
392
388
  <% } %> <% if(!isAdminPortal){ %>
393
389
  <script src="/weda-config/weda-private.js"></script>
394
- <script src="<%= cdnEndpoints.cloudbase %>/cloudbase-js-sdk/2.4.7-beta.0/cloudbase.full.js?v=1"></script>
390
+ <script src="//static.cloudbase.net/cloudbase-js-sdk/2.4.7-beta.0/cloudbase.full.js?v=1"></script>
395
391
  <% }%>
396
392
  <script>
397
- if (window.cloudbase && window._aegis) {
393
+ if (window.cloudbase) {
398
394
  const _callFunction = window.cloudbase.__proto__.callFunction;
399
395
  window.cloudbase.__proto__.callFunction = function (args) {
400
396
  let promise = _callFunction.call(window.cloudbase, ...arguments);
@@ -435,23 +431,19 @@
435
431
  </script>
436
432
  <script
437
433
  crossorigin
438
- src="<%= cdnEndpoints.cdngo %>/lcap/lcap-resource-cdngo/-/release/_npm/react@16.14.0/umd/react.production.min.js"
434
+ src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/release/_npm/react@16.14.0/umd/react.production.min.js"
439
435
  ></script>
440
436
  <script
441
437
  crossorigin
442
- src="<%=
443
- cdnEndpoints.cdngo
444
- %>/lcap/lcap-resource-cdngo/-/release/_npm/react-dom@16.14.0/umd/react-dom.production.min.js"
438
+ src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/release/_npm/react-dom@16.14.0/umd/react-dom.production.min.js"
445
439
  ></script>
446
440
  <script
447
- src="<%= cdnEndpoints.cdngo %>/lcap/lcap-resource-cdngo/-/0.1.2/_url/ajax/libs/mobx/5.15.7/mobx.umd.js"
441
+ src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/0.1.2/_url/ajax/libs/mobx/5.15.7/mobx.umd.js"
448
442
  crossorigin="anonymous"
449
443
  ></script>
450
444
  <script
451
445
  crossorigin="anonymous"
452
- src="<%=
453
- cdnEndpoints.cdngo
454
- %>/lcap/lcap-resource-cdngo/-/release/_npm/@cloudbase/weda-cloud-sdk@1.0.19/dist/h5.browser.js"
446
+ src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/release/_npm/@cloudbase/weda-cloud-sdk@1.0.19/dist/h5.browser.js"
455
447
  ></script>
456
448
  <script>
457
449
  // zxing polifill
@@ -461,19 +453,15 @@
461
453
  </script>
462
454
  <script
463
455
  crossorigin="anonymous"
464
- src="<%= cdnEndpoints.cdngo %>/lcap/lcap-resource-cdngo/-/0.1.2/_url/npm/@zxing/library@0.18.6/umd/index.min.js"
456
+ src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/0.1.2/_url/npm/@zxing/library@0.18.6/umd/index.min.js"
465
457
  ></script>
466
458
  <script
467
459
  crossorigin
468
- src="<%=
469
- cdnEndpoints.cdngo
470
- %>/lcap/lcap-resource-cdngo/-/release/_url/qcloud/lowcode/static/ide/assets/js/babel.min.js"
460
+ src="https://qbase.cdn-go.cn//lcap/lcap-resource-cdngo/-/release/_url/qcloud/lowcode/static/ide/assets/js/babel.min.js"
471
461
  ></script>
472
462
  <script
473
463
  crossorigin
474
- src="<%=
475
- cdnEndpoints.cdngo
476
- %>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.90a1845eb61a012b3d66.bundle.js"
464
+ src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.90a1845eb61a012b3d66.bundle.js"
477
465
  ></script>
478
466
  </body>
479
467
  </html>
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  import { findForItemsOfWidget, getWidget } from './widget'
3
- import { observable } from 'mobx';
3
+ import { observable, untracked } from 'mobx';
4
4
  import { getAccessToken } from '../datasources/index'
5
5
  import { app } from '../app/weapps-api'
6
6
 
@@ -31,9 +31,13 @@ export function createComputed(funcs, bindContext = null) {
31
31
  export function generateDataContext(widget) {
32
32
  const dataContext = {};
33
33
  while (widget?._scope) {
34
- if (widget._scope.dataContext && !isEmptyObj(widget._scope.dataContext)) {
35
- dataContext[widget._scope.id] = widget._scope.dataContext;
36
- }
34
+ const current = widget
35
+ // 此处采用代理的方式,是为了可以获取到最新的 _scope.dataContext 防止 dataContext 引用被重新赋值
36
+ Object.defineProperty(dataContext, current._scope.id, {
37
+ get() {
38
+ return current._scope.dataContext;
39
+ },
40
+ });
37
41
  widget = widget.parent;
38
42
  }
39
43
  return dataContext;
@@ -57,7 +61,7 @@ export function createEventHandlers(evtListeners) {
57
61
  const [prefix = ''] = name.split('$');
58
62
  // The page event handler
59
63
  const { lists = [], itemsById = {} } = !!currentTarget && findForItemsOfWidget(currentTarget) || {}
60
- const dataContext = generateDataContext(currentTarget)
64
+ const dataContext = untracked(()=>generateDataContext(currentTarget))
61
65
 
62
66
  listeners.forEach(async l => {
63
67
  let { data = {}, boundData = {} } = l;
@@ -221,7 +221,7 @@ function runFor(
221
221
  clearTimeout(_FOR_ERROR_CACHE_MAP[nodeId]);
222
222
 
223
223
  const $instance = ownerMpInst.getWeAppInst();
224
- const dataContext = generateDataContext(defaultParent);
224
+ const dataContext = untracked(()=>generateDataContext(defaultParent));
225
225
 
226
226
  forList = dataBinds[nodeId]._waFor.call(
227
227
  $instance,
@@ -364,7 +364,7 @@ function setUpWidgetDataBinds(w, dataBinds, forItems, failedBinds, ctx) {
364
364
  try {
365
365
  clearTimeout(timer);
366
366
 
367
- const dataContext = generateDataContext(w);
367
+ const dataContext = untracked(()=>generateDataContext(w));
368
368
 
369
369
  // Computed data bind in the next tick since data bind may read widgets data
370
370
  const value = dataBinds[prop].call(ctx, ctx, forItems.lists, forItems.itemsById, undefined, dataContext);
@@ -7,7 +7,7 @@
7
7
  "dependencies": {
8
8
  "@cloudbase/js-sdk": "2.4.0-beta.0",
9
9
  "@tcwd/weapps-core": "2.2.6",
10
- "@tcwd/weapps-sdk": "1.2.12",
10
+ "@tcwd/weapps-sdk": "1.2.10",
11
11
  "@zxing/library": "^0.18.6",
12
12
  "@cloudbase/weda-client": "^0.2.4",
13
13
  "lodash": "^4.17.19",