@cloudbase/lowcode-builder 1.9.1 → 1.9.3

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.
@@ -14,7 +14,7 @@ const BASE_DEPS = {
14
14
  const CLOUDBASE_DEPS = {
15
15
  '@cloudbase/oauth': '0.1.1-alpha.15',
16
16
  '@cloudbase/weda-client': '1.1.6',
17
- '@cloudbase/weda-cloud-sdk': '1.0.68',
17
+ '@cloudbase/weda-cloud-sdk': '1.0.76',
18
18
  };
19
19
  function generatePackageDependencies({ importJSSDK, mode, officialLibVersion, uin, }) {
20
20
  const deps = {};
@@ -54,6 +54,7 @@ export interface IBuildWedaApp extends IBaseAppProps {
54
54
  projectConfigJson?: Record<string, any>;
55
55
  };
56
56
  privatelinkConfig?: Record<string, any>;
57
+ __defaultLoginType__?: 'openId' | 'anonymous';
57
58
  }
58
59
  export declare function buildWedaConfig({ output, domain, isPrivateMode, endpointType, buildTypeList, }: {
59
60
  output: Required<IBuildWedaApp['output']>;
@@ -62,7 +63,7 @@ export declare function buildWedaConfig({ output, domain, isPrivateMode, endpoin
62
63
  endpointType?: IBuildWedaApp['endpointType'];
63
64
  buildTypeList?: IBuildWedaApp['buildTypeList'];
64
65
  }): Promise<void>;
65
- export declare function buildWedaApp({ cals, subAppCalsList: _subAppCalsList, dependencies, appKey, runtime, ignoreInstall, buildTypeList, mode, devTool, deployOptions, generateMpType, plugins, extraData, resourceAppId, domain, output, isBrowserMpBuilder, cdnEndpoints: _cdnEndpoints, isPrivateMode, endpointType, enableExpiredTag, enableAd, account, mpConfig, privatelinkConfig, }: IBuildWedaApp, cb?: WebpackBuildCallBack): Promise<any>;
66
+ export declare function buildWedaApp({ cals, subAppCalsList: _subAppCalsList, dependencies, appKey, runtime, ignoreInstall, buildTypeList, mode, devTool, deployOptions, plugins, extraData, resourceAppId, domain, output, isBrowserMpBuilder, cdnEndpoints: _cdnEndpoints, isPrivateMode, endpointType, enableExpiredTag, enableAd, account, mpConfig, privatelinkConfig, __defaultLoginType__, }: IBuildWedaApp, cb?: WebpackBuildCallBack): Promise<any>;
66
67
  export declare function cleanComponentDir(): Promise<void>;
67
68
  export declare const version: any;
68
69
  export { getFiles, fileToZip, strToBuf } from '../util/generateFiles';
@@ -17,6 +17,7 @@ const net_1 = require("../util/net");
17
17
  const config_1 = require("../config");
18
18
  const axios_1 = __importDefault(require("axios"));
19
19
  const materials_1 = require("../mp/materials");
20
+ const common_3 = require("@cloudbase/lowcode-generator/lib/generator/types/common");
20
21
  const pkg = require('../../../package.json');
21
22
  async function buildWedaConfig({ output, domain = undefined, isPrivateMode = undefined, endpointType = undefined, buildTypeList = [common_1.BuildType.WEB], }) {
22
23
  if ((0, common_1.buildAsWebByBuildType)(buildTypeList)) {
@@ -57,10 +58,10 @@ async function buildWedaConfig({ output, domain = undefined, isPrivateMode = und
57
58
  await (0, index_1.generateConfig)(data, outDir);
58
59
  }
59
60
  exports.buildWedaConfig = buildWedaConfig;
60
- async function buildWedaApp({ cals, subAppCalsList: _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 = {
61
+ async function buildWedaApp({ cals, subAppCalsList: _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 }, plugins = [], extraData = {
61
62
  isComposite: false,
62
63
  compProps: {},
63
- }, resourceAppId = undefined, domain = '', output, isBrowserMpBuilder = false, cdnEndpoints: _cdnEndpoints, isPrivateMode = false, endpointType = undefined, enableExpiredTag = false, enableAd = false, account = {}, mpConfig = {}, privatelinkConfig = undefined, }, cb) {
64
+ }, resourceAppId = undefined, domain = '', output, isBrowserMpBuilder = false, cdnEndpoints: _cdnEndpoints, isPrivateMode = false, endpointType = undefined, enableExpiredTag = false, enableAd = false, account = {}, mpConfig = {}, privatelinkConfig = undefined, __defaultLoginType__ = 'anonymous', }, cb) {
64
65
  var _a, _b, _c, _d, _e, _f;
65
66
  const cdnEndpoints = (0, config_1.generateCdnEndpoints)(_cdnEndpoints);
66
67
  if (!cals) {
@@ -101,6 +102,7 @@ async function buildWedaApp({ cals, subAppCalsList: _subAppCalsList = [], depend
101
102
  runtimeDynamicConfig = data;
102
103
  }
103
104
  }
105
+ const officialLib = dependencies.find((item) => item.name === cals_1.OFFICIAL_LIB_KEY);
104
106
  const buildContext = {
105
107
  uin: account === null || account === void 0 ? void 0 : account.uin,
106
108
  projDir: appBuildDir,
@@ -119,6 +121,7 @@ async function buildWedaApp({ cals, subAppCalsList: _subAppCalsList = [], depend
119
121
  disabled: (_c = cals.extra) === null || _c === void 0 ? void 0 : _c.disabled,
120
122
  statusPageId: ((_d = cals.extra) === null || _d === void 0 ? void 0 : _d.statusPageId) || undefined,
121
123
  privatelinkConfig: privatelinkConfig ? { uin: account === null || account === void 0 ? void 0 : account.uin, ...privatelinkConfig } : undefined,
124
+ enableOfficialLibNPM: !!((0, common_3.buildAsLibByBuildType)(buildTypeList) && officialLib),
122
125
  };
123
126
  console.log('domain', domain);
124
127
  console.log('应用名', appKey);
@@ -188,12 +191,13 @@ async function buildWedaApp({ cals, subAppCalsList: _subAppCalsList = [], depend
188
191
  enableLoading: (_e = cals === null || cals === void 0 ? void 0 : cals.extra) === null || _e === void 0 ? void 0 : _e.enableLoading,
189
192
  enableAsyncMaterials: (_f = cals.extra) === null || _f === void 0 ? void 0 : _f.enableAsyncMaterials,
190
193
  disablePageComponentInvoke,
194
+ __defaultLoginType__,
191
195
  // enableAsyncMaterials: true,
192
196
  };
193
197
  const result = await (0, index_1.generateWxMp)({
198
+ buildContext: mpBuildContext,
194
199
  weapps: apps,
195
200
  calses,
196
- buildContext: mpBuildContext,
197
201
  plugins,
198
202
  deployOptions,
199
203
  options: {
@@ -309,6 +313,7 @@ function normalizeInputs(inputs, { envId, getWebRootPath, }) {
309
313
  deployOptions: inputs.deployOptions,
310
314
  appId: inputs.appId || inputs.appKey,
311
315
  getWebRootPath: getWebRootPath || _getWebRootPath,
316
+ webOptions: inputs.webOptions,
312
317
  };
313
318
  if (inputs.mainAppSerializeData) {
314
319
  inputs.mainAppSerializeData = normalizeCals(inputs.mainAppSerializeData, normalizeCalsOptions);
@@ -345,7 +350,7 @@ function normalizeInputs(inputs, { envId, getWebRootPath, }) {
345
350
  return inputs;
346
351
  }
347
352
  exports.normalizeInputs = normalizeInputs;
348
- function normalizeCals(cals, { buildTypeList, envId, deployOptions, appId, getWebRootPath }) {
353
+ function normalizeCals(cals, { buildTypeList, envId, deployOptions, appId, getWebRootPath, webOptions }) {
349
354
  var _a;
350
355
  if (!cals.extra) {
351
356
  cals.extra = {};
@@ -365,6 +370,7 @@ function normalizeCals(cals, { buildTypeList, envId, deployOptions, appId, getWe
365
370
  if (cals.extra.miniprogramPlugins) {
366
371
  cals.extra.miniprogramPlugins = [];
367
372
  }
373
+ const { gatewayConfig = {} } = webOptions || {};
368
374
  let { appConfig = {} } = cals.extra;
369
375
  let { window = {} } = appConfig;
370
376
  let path = getWebRootPath({ appId, name: cals.name, deployOptions });
@@ -380,7 +386,7 @@ function normalizeCals(cals, { buildTypeList, envId, deployOptions, appId, getWe
380
386
  ? `app/${appId}${(deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.mode) !== types_1.DEPLOY_MODE.UPLOAD ? '-preview' : ''}`
381
387
  : (0, common_1.buildAsXPageByBuildType)(buildTypeList)
382
388
  ? '/'
383
- : path,
389
+ : gatewayConfig.path || path,
384
390
  },
385
391
  };
386
392
  }
@@ -44,7 +44,6 @@ async function runCopy(appBuildDir, webRuntimeAppData, i18nConfig) {
44
44
  const dstFile = path.join(appBuildDir, entry);
45
45
  await fs_extra_1.default.copy(path.join(config_1.appTemplateDir, entry), dstFile);
46
46
  }
47
- await (0, generateFiles_1.writeFile)(path.join(appBuildDir, 'mainAppData.json'), JSON.stringify(webRuntimeAppData, null, 2));
48
47
  const fileDir = path.join(appBuildDir, 'src/i18n/');
49
48
  if (!fs_extra_1.default.existsSync(fileDir)) {
50
49
  fs_extra_1.default.mkdirSync(fileDir, { recursive: true });
@@ -46,14 +46,16 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
46
46
  const junk = __importStar(require("../util/junk"));
47
47
  const url_1 = require("url");
48
48
  const semver = __importStar(require("semver"));
49
+ const lodash_1 = require("lodash");
50
+ const common_3 = require("@cloudbase/lowcode-generator/lib/generator/types/common");
49
51
  let BabelTransform = (code, options) => code;
50
52
  if (!process.env.IS_WEB_WORKER) {
51
53
  let transform = require('../../utils/transform');
52
54
  BabelTransform = transform.BabelTransform;
53
55
  }
54
56
  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, }) {
55
- var _a, _b, _c, _d, _e, _f;
56
- const { projDir: buildDir, domain, materialLibs: dependencies, appId: appKey, isPrivateMode, enableExpiredTag, privatelinkConfig, } = buildContext;
57
+ var _a, _b, _c, _d, _e, _f, _g, _h;
58
+ const { projDir: buildDir, domain, materialLibs: dependencies, appId: appKey, isPrivateMode, enableExpiredTag, privatelinkConfig, enableOfficialLibNPM, } = buildContext;
57
59
  if (!deployOptions.mode || deployOptions.mode === types_1.DEPLOY_MODE.DYNAMIC) {
58
60
  deployOptions.mode = types_1.DEPLOY_MODE.PREVIEW;
59
61
  }
@@ -80,17 +82,23 @@ async function buildH5App({ buildContext, i18nConfig, extraData, cals: _cals, bu
80
82
  var _a;
81
83
  return (_a = used.component['$template']) === null || _a === void 0 ? void 0 : _a.has(item.id);
82
84
  });
85
+ const officialLib = dependencies.find((lib) => lib.name === config_1.OFFICIAL_LIB_KEY);
86
+ if (enableOfficialLibNPM) {
87
+ if (!((_d = (_c = cals.extra) === null || _c === void 0 ? void 0 : _c.npmDependencies) === null || _d === void 0 ? void 0 : _d[cals_1.OFFICIAL_LIB_NPM_PACKAGENAME])) {
88
+ (0, lodash_1.set)(cals, `extra.npmDependencies.${cals_1.OFFICIAL_LIB_NPM_PACKAGENAME}`, officialLib === null || officialLib === void 0 ? void 0 : officialLib.version);
89
+ }
90
+ }
83
91
  // 处理应用数据
84
92
  const mainAppData = (0, weapps_core_1.deserialize)((0, common_2.processCals2WeappsData)(cals, dependencies));
85
93
  if (!mainAppData.extra) {
86
94
  mainAppData.extra = { domain };
87
95
  }
88
- if (!((_c = mainAppData.extra) === null || _c === void 0 ? void 0 : _c.domain)) {
96
+ if (!((_e = mainAppData.extra) === null || _e === void 0 ? void 0 : _e.domain)) {
89
97
  mainAppData.extra.domain = domain;
90
98
  }
91
- const subAppDataList = ((_d = subAppCalsList === null || subAppCalsList === void 0 ? void 0 : subAppCalsList.map) === null || _d === void 0 ? void 0 : _d.call(subAppCalsList, (sub) => (0, weapps_core_1.deserialize)((0, common_2.processCals2WeappsData)(sub, dependencies)))) || [];
99
+ const subAppDataList = ((_f = subAppCalsList === null || subAppCalsList === void 0 ? void 0 : subAppCalsList.map) === null || _f === void 0 ? void 0 : _f.call(subAppCalsList, (sub) => (0, weapps_core_1.deserialize)((0, common_2.processCals2WeappsData)(sub, dependencies)))) || [];
92
100
  // 前置操作
93
- const { publicPath, basename, assets = '', _indexPage } = ((_e = mainAppData.appConfig) === null || _e === void 0 ? void 0 : _e.window) || {};
101
+ const { publicPath, basename, assets = '', _indexPage } = ((_g = mainAppData.appConfig) === null || _g === void 0 ? void 0 : _g.window) || {};
94
102
  // 获取 插入的cdn 资源
95
103
  const jsAssets = await (0, generate_1.handleAssets)({
96
104
  appBuildDir: buildDir,
@@ -107,6 +115,9 @@ async function buildH5App({ buildContext, i18nConfig, extraData, cals: _cals, bu
107
115
  // 注意需要包涵官方的(gsd),部分平台方法需要由其补充
108
116
  return lib.name === config_1.OFFICIAL_LIB_KEY || !!(((_a = used.component) === null || _a === void 0 ? void 0 : _a[lib.name]) || ((_b = used.action) === null || _b === void 0 ? void 0 : _b[lib.name]));
109
117
  }), materialsDir, runtime, ignoreInstall);
118
+ if (enableOfficialLibNPM) {
119
+ await fs_extra_1.default.remove(path_1.default.join(h5BuildDir, 'src', 'libraries', `${officialLib === null || officialLib === void 0 ? void 0 : officialLib.name}@${officialLib === null || officialLib === void 0 ? void 0 : officialLib.version}`));
120
+ }
110
121
  const h5LibDirPath = path_1.default.resolve(h5BuildDir, 'src', 'libraries');
111
122
  const libNames = fs_extra_1.default.readdirSync(h5LibDirPath).filter((name) => name !== '.DS_Store');
112
123
  let libNameWithVue;
@@ -172,100 +183,102 @@ async function buildH5App({ buildContext, i18nConfig, extraData, cals: _cals, bu
172
183
  privatelinkConfig,
173
184
  });
174
185
  console.timeEnd(runGenerateTag);
175
- // // 构建 NPM 包
176
- await (0, npm_1.handleNPM)({
177
- appKey,
178
- mainAppData,
179
- subAppDataList,
180
- appBuildDir: h5BuildDir,
181
- dependencies: processedDependencies,
182
- mode,
183
- devTool,
184
- ignoreInstall,
185
- vueVersion,
186
- });
187
- // 生成主题文件
188
- await (0, generate_1.generateThemeVarsFile)(mainAppData.themeVars, h5BuildDir);
189
- // 生成 webpack 配置
190
- const webpackConfigPath = await (0, webpack_1.runWebpackCore)({
191
- buildContext,
192
- cals,
193
- appKey,
194
- mainAppData,
195
- subAppDataList,
196
- appBuildDir: h5BuildDir,
197
- assets: jsAssets,
198
- buildTypeList,
199
- mode,
200
- devTool,
201
- publicPath,
202
- domain,
203
- cdnEndpoints,
204
- vueVersion,
205
- });
206
- if (typeof libNameWithVue === 'string' && !fs_extra_1.default.existsSync(path_1.default.resolve(h5BuildDir, 'node_modules', 'vue'))) {
207
- fs_extra_1.default.symlinkSync(path_1.default.resolve(h5BuildDir, 'src', 'libraries', libNameWithVue, 'node_modules', 'vue'), path_1.default.resolve(h5BuildDir, 'node_modules', 'vue'));
208
- }
209
- await new Promise((resolve, reject) => {
210
- // 开始编译前清理一下 lowcode 内容
211
- (0, compile_1.startCompile)({
186
+ if (!(0, common_3.buildAsLibByBuildType)(buildTypeList)) {
187
+ // // 构建 NPM 包
188
+ await (0, npm_1.handleNPM)({
189
+ appKey,
190
+ mainAppData,
191
+ subAppDataList,
212
192
  appBuildDir: h5BuildDir,
213
- configPath: webpackConfigPath,
193
+ dependencies: processedDependencies,
194
+ mode,
195
+ devTool,
196
+ ignoreInstall,
197
+ vueVersion,
198
+ });
199
+ // 生成主题文件
200
+ await (0, generate_1.generateThemeVarsFile)(mainAppData.themeVars, h5BuildDir);
201
+ // 生成 webpack 配置
202
+ const webpackConfigPath = await (0, webpack_1.runWebpackCore)({
203
+ buildContext,
204
+ cals,
214
205
  appKey,
215
- webpackMode: mode,
216
- }, function (err, data) {
217
- if (err) {
218
- reject(err);
219
- }
220
- else {
221
- resolve(data);
222
- }
206
+ mainAppData,
207
+ subAppDataList,
208
+ appBuildDir: h5BuildDir,
209
+ assets: jsAssets,
210
+ buildTypeList,
211
+ mode,
212
+ devTool,
213
+ publicPath,
214
+ domain,
215
+ cdnEndpoints,
216
+ vueVersion,
223
217
  });
224
- });
225
- const MAINIFAST_FILENAME = 'weda-manifest.json';
226
- const preHeatUrls = fs_extra_1.default
227
- .readdirSync(path_1.default.resolve(h5BuildDir, webpack_2.OUTPUT_DIR))
228
- .filter((file) => junk.not(file) && file !== MAINIFAST_FILENAME)
229
- .map((file) => {
230
- if (/LICENSE\.txt$/.test(file) || /\.map$/.test(file)) {
231
- return '';
232
- }
233
- try {
234
- const url = new url_1.URL(publicPath);
235
- return `${url.origin}${path_1.default.posix.join(url.pathname, file)}`;
218
+ if (typeof libNameWithVue === 'string' && !fs_extra_1.default.existsSync(path_1.default.resolve(h5BuildDir, 'node_modules', 'vue'))) {
219
+ fs_extra_1.default.symlinkSync(path_1.default.resolve(h5BuildDir, 'src', 'libraries', libNameWithVue, 'node_modules', 'vue'), path_1.default.resolve(h5BuildDir, 'node_modules', 'vue'));
236
220
  }
237
- catch (e) {
238
- return path_1.default.posix.join(publicPath || '', file);
239
- }
240
- })
241
- .filter((item) => !!item);
242
- // 普通 web 模式,且非hash模式,根据页面生成多份入口
243
- if (!((_f = cals.extra) === null || _f === void 0 ? void 0 : _f.historyType) || cals.extra.historyType === types_1.HISTORY_TYPE.BROWSER) {
244
- preHeatUrls.push(path_1.default.posix.join(basename || ''));
245
- await Promise.all([
246
- ...(cals.items || []).map((page) => {
247
- preHeatUrls.push(path_1.default.posix.join(basename || '', page.id));
248
- preHeatUrls.push(path_1.default.posix.join(basename || '', page.id, '/'));
249
- return 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'));
250
- }),
251
- ...(subAppCalsList || []).reduce((list, cals) => {
252
- const { rootPath } = cals.extra || {};
253
- const packageName = (0, util_1.normalizePackageName)(rootPath);
254
- if (packageName) {
255
- preHeatUrls.push(path_1.default.posix.join(basename || '', packageName));
256
- preHeatUrls.push(path_1.default.posix.join(basename || '', packageName, '/'));
257
- list.push(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, packageName, 'index.html')));
258
- (cals.items || []).forEach((page) => {
259
- preHeatUrls.push(path_1.default.posix.join(basename || '', packageName, page.id));
260
- preHeatUrls.push(path_1.default.posix.join(basename || '', packageName, page.id, '/'));
261
- list.push(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, packageName, page.id, 'index.html')));
262
- });
221
+ await new Promise((resolve, reject) => {
222
+ // 开始编译前清理一下 lowcode 内容
223
+ (0, compile_1.startCompile)({
224
+ appBuildDir: h5BuildDir,
225
+ configPath: webpackConfigPath,
226
+ appKey,
227
+ webpackMode: mode,
228
+ }, function (err, data) {
229
+ if (err) {
230
+ reject(err);
263
231
  }
264
- return list;
265
- }, []),
266
- ]);
232
+ else {
233
+ resolve(data);
234
+ }
235
+ });
236
+ });
237
+ const MAINIFAST_FILENAME = 'weda-manifest.json';
238
+ const preHeatUrls = fs_extra_1.default
239
+ .readdirSync(path_1.default.resolve(h5BuildDir, webpack_2.OUTPUT_DIR))
240
+ .filter((file) => junk.not(file) && file !== MAINIFAST_FILENAME)
241
+ .map((file) => {
242
+ if (/LICENSE\.txt$/.test(file) || /\.map$/.test(file)) {
243
+ return '';
244
+ }
245
+ try {
246
+ const url = new url_1.URL(publicPath);
247
+ return `${url.origin}${path_1.default.posix.join(url.pathname, file)}`;
248
+ }
249
+ catch (e) {
250
+ return path_1.default.posix.join(publicPath || '', file);
251
+ }
252
+ })
253
+ .filter((item) => !!item);
254
+ // 普通 web 模式,且非hash模式,根据页面生成多份入口
255
+ if (!((_h = cals.extra) === null || _h === void 0 ? void 0 : _h.historyType) || cals.extra.historyType === types_1.HISTORY_TYPE.BROWSER) {
256
+ preHeatUrls.push(path_1.default.posix.join(basename || ''));
257
+ await Promise.all([
258
+ ...(cals.items || []).map((page) => {
259
+ preHeatUrls.push(path_1.default.posix.join(basename || '', page.id));
260
+ preHeatUrls.push(path_1.default.posix.join(basename || '', page.id, '/'));
261
+ return 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'));
262
+ }),
263
+ ...(subAppCalsList || []).reduce((list, cals) => {
264
+ const { rootPath } = cals.extra || {};
265
+ const packageName = (0, util_1.normalizePackageName)(rootPath);
266
+ if (packageName) {
267
+ preHeatUrls.push(path_1.default.posix.join(basename || '', packageName));
268
+ preHeatUrls.push(path_1.default.posix.join(basename || '', packageName, '/'));
269
+ list.push(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, packageName, 'index.html')));
270
+ (cals.items || []).forEach((page) => {
271
+ preHeatUrls.push(path_1.default.posix.join(basename || '', packageName, page.id));
272
+ preHeatUrls.push(path_1.default.posix.join(basename || '', packageName, page.id, '/'));
273
+ list.push(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, packageName, page.id, 'index.html')));
274
+ });
275
+ }
276
+ return list;
277
+ }, []),
278
+ ]);
279
+ }
280
+ await fs_extra_1.default.writeFile(path_1.default.resolve(h5BuildDir, webpack_2.OUTPUT_DIR, MAINIFAST_FILENAME), JSON.stringify({ preHeatUrls }, undefined, 2));
267
281
  }
268
- await fs_extra_1.default.writeFile(path_1.default.resolve(h5BuildDir, webpack_2.OUTPUT_DIR, 'weda-manifest.json'), JSON.stringify({ preHeatUrls }, undefined, 2));
269
282
  return h5BuildDir;
270
283
  }
271
284
  catch (e) {
@@ -60,10 +60,6 @@ async function generatePackageJSON(dependencies = {}, appBuildDir, appKey, mode,
60
60
  vueVersion: vueVersion === 3 ? '^3' : '^2',
61
61
  }));
62
62
  const packageInfo = await fs_extra_1.default.readJSON(dstTempPath);
63
- // weapps-sdk 要与 builder template 版本一致
64
- // govcloud 包废弃
65
- // dependencies['@govcloud/weapps-sdk'] =
66
- // packageInfo.dependencies['@govcloud/weapps-sdk'];
67
63
  Object.keys(dependencies).forEach((key) => {
68
64
  const version = dependencies[key];
69
65
  if (packageInfo.dependencies[key] !== version) {
@@ -39,14 +39,6 @@ async function runWebpackCore({ buildContext, cals, mainAppData, subAppDataList,
39
39
  cdnEndpoints,
40
40
  publicPath,
41
41
  });
42
- if ((0, common_1.buildAsWebByBuildType)(buildTypeList)) {
43
- if (mode !== common_1.WebpackModeType.PRODUCTION) {
44
- await (0, webpack_1.generateWebpackWebDevServerFile)({
45
- appBuildDir,
46
- buildTypeList,
47
- });
48
- }
49
- }
50
42
  console.timeEnd('runWebpackCore');
51
43
  return webWebpackConfigPath;
52
44
  }
@@ -82,6 +82,10 @@ export interface IAppCommonBuildContext extends ICommonBuildContext {
82
82
  * 自定义状态页Id
83
83
  */
84
84
  statusPageId?: string;
85
+ /**
86
+ * use official lib npm
87
+ */
88
+ enableOfficialLibNPM?: boolean;
85
89
  }
86
90
  export interface IMpCommonBuildContext extends ICommonBuildContext {
87
91
  /**
@@ -105,4 +109,9 @@ export interface IBuildContext extends IAppCommonBuildContext, IMpCommonBuildCon
105
109
  * app.json文件window配置
106
110
  */
107
111
  defaultAppWindowConfig?: IDefaultAppWindowConfig;
112
+ /**
113
+ * 内部定义,请勿使用
114
+ * 如必须使用 @rohyang
115
+ */
116
+ __defaultLoginType__?: 'openId' | 'anonymous';
108
117
  }
@@ -243,6 +243,7 @@ async function generateWxMp({ buildContext: _buildContext, weapps, calses, deplo
243
243
  privatelink: buildContext.privatelinkConfig
244
244
  ? JSON.stringify(buildContext.privatelinkConfig, undefined, 2)
245
245
  : undefined,
246
+ defaultLoginType: buildContext.__defaultLoginType__,
246
247
  },
247
248
  'datasources/datasource-profiles.js.tpl': {
248
249
  datasourceProfiles: (0, util_3.JsonToStringWithVariableName)([], { EOL: false }),
@@ -672,10 +673,8 @@ async function generateFramework(ctx, { cals, weapp: appData }, outDir, options)
672
673
  subPackageName: appData.rootPath || '',
673
674
  importor,
674
675
  appConfig: (0, util_3.JsonToStringWithVariableName)({
675
- id: ctx.appId,
676
676
  label: (appData === null || appData === void 0 ? void 0 : appData.label) || '',
677
677
  version: (_a = options === null || options === void 0 ? void 0 : options.deployOptions) === null || _a === void 0 ? void 0 : _a.version,
678
- envId: appData.envId,
679
678
  loginConfigVersion: (_b = cals.extra) === null || _b === void 0 ? void 0 : _b.loginConfigVersion,
680
679
  basename: ctx.wedaRoot,
681
680
  pages: appData.pageInstanceList
@@ -213,12 +213,13 @@ function generateDataContainerListeners() {
213
213
  exports.generateDataContainerListeners = generateDataContainerListeners;
214
214
  function createTemplateQuery(ctx, query = {}) {
215
215
  return Object.entries(query).reduce((map, [key, item]) => {
216
+ var _a, _b;
216
217
  const { listeners = [], handler, data, args, ...rest } = item;
217
218
  const { staticProps, boundProps } = generatedDynamicData(generateArgsDynamicValueFromData(args, data) || {}, undefined, false);
218
219
  map[key] = {
219
220
  ...rest,
220
221
  handler: item.type === cals_1.EQueryType.GeneralFunc
221
- ? `(__data__,__params__) => (${handler['code']})({params:__params__,data:__data__})`
222
+ ? `(__data__,__params__) => (${(_b = (_a = handler['code']) === null || _a === void 0 ? void 0 : _a.replace) === null || _b === void 0 ? void 0 : _b.call(_a, /;\s*$/, '')})({params:__params__,data:__data__})`
222
223
  : `(...args) => $app.${handler === null || handler === void 0 ? void 0 : handler.name}(...args)`,
223
224
  data: staticProps,
224
225
  dataBinds: boundProps,
@@ -250,7 +251,7 @@ function getListenersHandlers(ctx, listeners = [], id, componentApi) {
250
251
  const { enableAsyncMaterials = false } = ctx;
251
252
  const eventHandlers = {};
252
253
  listeners.forEach((l) => {
253
- var _a, _b, _c, _d, _e;
254
+ var _a, _b, _c, _d, _e, _f, _g;
254
255
  const handlerName = (0, wxml_1.getMpEventHandlerName)(id, l.trigger, l);
255
256
  const sourceKey = `${((_a = l.handler) === null || _a === void 0 ? void 0 : _a.moduleName) || ''}:${((_b = l.handler) === null || _b === void 0 ? void 0 : _b.name) || ''}`;
256
257
  eventHandlers[handlerName] = eventHandlers[handlerName] || [];
@@ -304,7 +305,7 @@ function getListenersHandlers(ctx, listeners = [], id, componentApi) {
304
305
  break;
305
306
  }
306
307
  case weapps_core_1.ActionType.GeneralFunc: {
307
- handler = `function({event, $w, params}) { return (\n${((_e = l.handler) === null || _e === void 0 ? void 0 : _e.code) || '()=>{}'}\n)({event}) }`;
308
+ handler = `function({event, $w, params}) { return (\n${((_g = (_f = (_e = l.handler) === null || _e === void 0 ? void 0 : _e.code) === null || _f === void 0 ? void 0 : _f.replace) === null || _g === void 0 ? void 0 : _g.call(_f, /;\s*$/, '')) || '()=>{}'}\n)({event}) }`;
308
309
  break;
309
310
  }
310
311
  }
@@ -50,7 +50,6 @@ export declare function downloadAndWriteTabBarIcon(iconPath: any, pagePath: any,
50
50
  export declare function getMainAppDataByList(allAppDataList: IWebRuntimeAppData[]): IWebRuntimeAppData | undefined;
51
51
  export declare function getHomePageInstance(pageInstanceList: any): any;
52
52
  export declare function getPageName(name: string): string;
53
- export declare function getWebpackWebBuildParams(appId: string, appBuildDir: string, publicPath?: string, mode?: WebpackModeType, buildTypeList?: BuildType[], extraDefine?: {}, assets?: string[], vueVersion?: number): any;
54
53
  export declare function downloadAndInstallDependencies(dependencies: IMaterialItem[] | undefined, materialsDir: string, installOptions?: IInstallOpts): Promise<void>;
55
54
  export declare function downloadDependencies(targetDir: string, srcZipUrl: string): Promise<void>;
56
55
  /**
@@ -77,9 +76,5 @@ interface IFixNodeModulesMap {
77
76
  '@cloudbase/js-sdk'?: boolean;
78
77
  }
79
78
  export declare function getMaterialNodeModulesPathList(dependencies: IMaterialItem[] | undefined, materialsDir: string, base?: string): string[];
80
- export declare function generateWebpackWebDevServerFile({ appBuildDir, buildTypeList }: {
81
- appBuildDir: any;
82
- buildTypeList: any;
83
- }): Promise<void>;
84
79
  export declare function downloadAssets(targetDir: string, assetUrl: string): Promise<unknown>;
85
80
  export {};
@@ -3,10 +3,9 @@ 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.getWebpackWebBuildParams = exports.getPageName = exports.getHomePageInstance = exports.getMainAppDataByList = exports.downloadAndWriteTabBarIcon = exports.generateKboneTabBarConfig = exports.generateWebpackWebBuildParamsFile = exports.fixAppJson = exports.OUTPUT_DIR = exports.PERSISTENT_DEPENDIENCES_MAP = void 0;
6
+ exports.downloadAssets = exports.getMaterialNodeModulesPathList = exports.installDependencies = exports.downloadDependencies = exports.downloadAndInstallDependencies = exports.getPageName = exports.getHomePageInstance = exports.getMainAppDataByList = exports.downloadAndWriteTabBarIcon = exports.generateKboneTabBarConfig = exports.generateWebpackWebBuildParamsFile = exports.fixAppJson = exports.OUTPUT_DIR = 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
- const lodash_1 = require("lodash");
10
9
  const util_1 = require("../util");
11
10
  const axios_1 = __importDefault(require("axios"));
12
11
  const compressing_1 = __importDefault(require("compressing"));
@@ -41,13 +40,22 @@ async function fixAppJson(appBuildDir) {
41
40
  exports.fixAppJson = fixAppJson;
42
41
  async function generateWebpackWebBuildParamsFile({ appId, allAppDataList, appBuildDir, publicPath, mode, buildTypeList, assets = [], vueVersion = 0, }) {
43
42
  let mainAppData = getMainAppDataByList(allAppDataList);
44
- let extraDefine = {
45
- 'process.env.historyType': `"${mainAppData.historyType || types_1.HISTORY_TYPE.BROWSER}"`,
46
- };
47
- const params = getWebpackWebBuildParams(appId, appBuildDir, publicPath, mode, buildTypeList, extraDefine, assets, vueVersion);
48
43
  const webpackConfigPath = path_1.default.resolve(appBuildDir, './webpack/webpack.web.prod.js');
49
- const paramsString = JSON.stringify(params, null, 2);
50
- const webpackConfigContent = `const params = ${paramsString};\nmodule.exports = require('./web.prod.js')(params);`;
44
+ const paramsString = JSON.stringify({
45
+ output: {
46
+ path: exports.OUTPUT_DIR,
47
+ publicPath: buildTypeList.includes(common_1.BuildType.APP) || buildTypeList.includes(common_1.BuildType.ADMIN_PORTAL) ? '' : publicPath,
48
+ },
49
+ definePlugin: {
50
+ 'process.env.historyType': `"${mainAppData.historyType || types_1.HISTORY_TYPE.BROWSER}"`,
51
+ },
52
+ devtool: ['app-nvzcvt10', 'app-msa2ihs9', 'app-PMoFiTuX'].includes(appId)
53
+ ? 'source-map'
54
+ : mode !== common_1.WebpackModeType.PRODUCTION
55
+ ? 'eval'
56
+ : false,
57
+ }, null, 2);
58
+ const webpackConfigContent = `params = ${paramsString};\nmodule.exports = require('./web.prod.js')(params);`;
51
59
  await (0, generateFiles_1.writeFile)(webpackConfigPath, webpackConfigContent);
52
60
  return webpackConfigPath;
53
61
  }
@@ -119,46 +127,6 @@ function getPageName(name) {
119
127
  return `${name}`;
120
128
  }
121
129
  exports.getPageName = getPageName;
122
- function getWebpackWebBuildParams(appId, appBuildDir, publicPath = '/', mode = common_1.WebpackModeType.NONE, buildTypeList = [common_1.BuildType.WEB], extraDefine = {}, assets = [], vueVersion = 0) {
123
- return {
124
- context: appBuildDir,
125
- mode: mode !== common_1.WebpackModeType.PRODUCTION ? 'development' : mode,
126
- watch: false,
127
- entry: path_1.default.resolve(appBuildDir, 'src/index.jsx'),
128
- output: {
129
- path: path_1.default.resolve(appBuildDir, exports.OUTPUT_DIR),
130
- filename: '[name].[hash].bundle.js',
131
- chunkFilename: '[name].[contenthash].chunk.js',
132
- publicPath: buildTypeList.includes(common_1.BuildType.APP) || buildTypeList.includes(common_1.BuildType.ADMIN_PORTAL) ? '' : publicPath,
133
- pathinfo: false,
134
- // clean: mode === WebpackModeType.PRODUCTION,
135
- },
136
- htmlTemplatePath: path_1.default.resolve(appBuildDir, './index.html'),
137
- externals: {
138
- react: 'window.React',
139
- 'react-dom': 'window.ReactDOM',
140
- mobx: 'window.mobx',
141
- '@cloudbase/js-sdk': 'window.cloudbase',
142
- '@cloudbase/weda-cloud-sdk/dist/h5': 'window.CloudSDK',
143
- '@cloudbase/weda-cloud-sdk': 'window.CloudSDK',
144
- '@cloudbase/weda-client': 'window.WedaClientSDK',
145
- '@zxing/library': 'window.ZXing',
146
- '@cloudbase/lowcode-render': 'window["weda-render"]',
147
- },
148
- resolveModules: [path_1.default.resolve(appBuildDir), 'node_modules'],
149
- definePlugin: {
150
- 'process.env.buildType': `"${buildTypeList[0]}"`,
151
- ...extraDefine,
152
- },
153
- devtool: ['app-nvzcvt10', 'app-msa2ihs9', 'app-PMoFiTuX'].includes(appId)
154
- ? 'source-map'
155
- : mode !== common_1.WebpackModeType.PRODUCTION
156
- ? 'eval'
157
- : false,
158
- vueVersion,
159
- };
160
- }
161
- exports.getWebpackWebBuildParams = getWebpackWebBuildParams;
162
130
  async function downloadAndInstallDependencies(dependencies = [], materialsDir, installOptions = {}) {
163
131
  const localPkg = (0, util_1.getCurrentPackageJson)();
164
132
  await Promise.all(dependencies.map(async (item) => {
@@ -369,22 +337,6 @@ function getMaterialNodeModulesPathList(dependencies = [], materialsDir, base) {
369
337
  });
370
338
  }
371
339
  exports.getMaterialNodeModulesPathList = getMaterialNodeModulesPathList;
372
- // 生成devServer 核心依赖
373
- async function generateWebpackWebDevServerFile({ appBuildDir, buildTypeList }) {
374
- const dest = path_1.default.resolve(appBuildDir, `./webpack/devServer.js`);
375
- const template = await fs_extra_1.default.readFile(path_1.default.resolve(config_1.appTemplateDir, './webpack/devServer.js'), {
376
- encoding: 'utf8',
377
- });
378
- const jsContent = (0, lodash_1.template)(template, {
379
- interpolate: /<%=([\s\S]+?)%>/g,
380
- })({
381
- isApp: buildTypeList.includes(common_1.BuildType.APP),
382
- isAdminPortal: (0, common_1.buildAsAdminPortalByBuildType)(buildTypeList),
383
- });
384
- await fs_extra_1.default.ensureFile(dest);
385
- await fs_extra_1.default.writeFile(dest, jsContent);
386
- }
387
- exports.generateWebpackWebDevServerFile = generateWebpackWebDevServerFile;
388
340
  // 下载js 文件
389
341
  async function downloadAssets(targetDir, assetUrl) {
390
342
  const isExist = fs_extra_1.default.existsSync(path_1.default.join(targetDir, 'package.json'));
@@ -10,7 +10,6 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
10
10
  const style_1 = require("@cloudbase/lowcode-generator/lib/generator/util/style");
11
11
  const generateFiles_1 = require("./generateFiles");
12
12
  const cals_1 = require("@cloudbase/cals");
13
- const compare_versions_1 = __importDefault(require("compare-versions"));
14
13
  const config_1 = require("../config");
15
14
  const os_1 = __importDefault(require("os"));
16
15
  var common_1 = require("@cloudbase/lowcode-generator/lib/generator/util/common");
@@ -184,7 +183,6 @@ exports.isOfficialComponentLib = isOfficialComponentLib;
184
183
  */
185
184
  function canUseVite(mode, devTool) {
186
185
  return false;
187
- return devTool === 'vite' && mode !== 'production' && (0, compare_versions_1.default)(process.version, '12.0.0') >= 0;
188
186
  }
189
187
  exports.canUseVite = canUseVite;
190
188
  function deepDealComponentSchemaJson(schema, dealFn) {