@lcap/nasl 4.3.0-beta.24 → 4.3.0-beta.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/generator/genBundleFiles.d.ts +2 -2
- package/out/generator/genBundleFiles.d.ts.map +1 -1
- package/out/generator/genBundleFiles.js +191 -139
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/release-body/utils.d.ts +0 -6
- package/out/generator/release-body/utils.d.ts.map +1 -1
- package/out/generator/release-body/utils.js +3 -1
- package/out/generator/release-body/utils.js.map +1 -1
- package/out/generator/templates/chunk.d.ts +11 -0
- package/out/generator/templates/chunk.d.ts.map +1 -0
- package/out/generator/templates/chunk.js +29 -0
- package/out/generator/templates/chunk.js.map +1 -0
- package/out/generator/templates/runtime.d.ts +7 -0
- package/out/generator/templates/runtime.d.ts.map +1 -0
- package/out/generator/templates/runtime.js +409 -0
- package/out/generator/templates/runtime.js.map +1 -0
- package/out/server/naslServer.d.ts +0 -1
- package/out/server/naslServer.d.ts.map +1 -1
- package/out/server/naslServer.js +34 -30
- package/out/server/naslServer.js.map +1 -1
- package/out/templator/block2nasl/viewMergeBlock.js +3 -2
- package/out/templator/block2nasl/viewMergeBlock.js.map +1 -1
- package/out/utils/can-i-use.d.ts.map +1 -1
- package/out/utils/can-i-use.js +1 -0
- package/out/utils/can-i-use.js.map +1 -1
- package/package.json +9 -9
|
@@ -9,10 +9,10 @@ export interface Route {
|
|
|
9
9
|
component?: RawOptions;
|
|
10
10
|
children?: Array<Route>;
|
|
11
11
|
redirect?: string;
|
|
12
|
-
lazyPath?: string;
|
|
13
12
|
meta?: {
|
|
14
13
|
[key: string]: any;
|
|
15
14
|
};
|
|
15
|
+
fullPath?: string;
|
|
16
16
|
}
|
|
17
17
|
export declare function genBundleFiles(app: App, frontend: Frontend, config: Config): Promise<any[]>;
|
|
18
18
|
export declare function genFrontendBundleFiles(app: App, frontends: Array<Frontend>, config: Config): Promise<any[]>;
|
|
@@ -21,7 +21,7 @@ export declare function getOneFiles(options: {
|
|
|
21
21
|
frontend: Frontend;
|
|
22
22
|
view: View;
|
|
23
23
|
action: 'current' | 'all';
|
|
24
|
-
cacheRouters:
|
|
24
|
+
cacheRouters: string;
|
|
25
25
|
config: Config;
|
|
26
26
|
}): Promise<any[]>;
|
|
27
27
|
//# sourceMappingURL=genBundleFiles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genBundleFiles.d.ts","sourceRoot":"","sources":["../../src/generator/genBundleFiles.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,GAAG,EAAU,IAAI,EAAE,QAAQ,EAAmG,MAAM,aAAa,CAAC;AAC3J,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC;AAM/B,OAAO,KAAK,EAAE,yBAAyB,IAAI,MAAM,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"genBundleFiles.d.ts","sourceRoot":"","sources":["../../src/generator/genBundleFiles.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,GAAG,EAAU,IAAI,EAAE,QAAQ,EAAmG,MAAM,aAAa,CAAC;AAC3J,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC;AAM/B,OAAO,KAAK,EAAE,yBAAyB,IAAI,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAsBhF,eAAO,IAAI,UAAU,UAAgC,CAAA;AACrD,eAAO,IAAI,mBAAmB,UAAyD,CAAA;AAEvF,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,GAAG,WAanD;AACD,MAAM,WAAW,KAAK;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,QAAQ,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE;QACL,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAA;IACD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAuQD,wBAAsB,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBA8/BhF;AAED,wBAAsB,sBAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,kBA2ChG;AA+BD,wBAAsB,WAAW,CAAC,OAAO,EAAE;IACzC,GAAG,EAAE,GAAG,CAAC;IACT,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,EAAE,SAAS,GAAG,KAAK,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB,kBAwKA"}
|
|
@@ -43,6 +43,8 @@ const microApp_1 = require("./microApp");
|
|
|
43
43
|
// @ts-ignore FIXME 类型在构建前找不到的问题
|
|
44
44
|
const nasl_unified_frontend_generator_2 = require("@lcap/nasl-unified-frontend-generator");
|
|
45
45
|
const axios_1 = __importDefault(require("axios"));
|
|
46
|
+
const runtime_1 = require("./templates/runtime");
|
|
47
|
+
const chunk_1 = require("./templates/chunk");
|
|
46
48
|
const officalEntityMap = {
|
|
47
49
|
LCAPUser: ['id', 'createdTime', 'updatedTime', 'userId', 'userName', 'password', 'phone', 'email', 'displayName', 'status', 'source'],
|
|
48
50
|
LCAPLogicViewMapping: ['id', 'logicIdentifier', 'resourceName', 'resourceType', 'group', 'changeTime'],
|
|
@@ -139,8 +141,8 @@ function genComponentCode(component) {
|
|
|
139
141
|
})()`;
|
|
140
142
|
}
|
|
141
143
|
// 生成导入组件代码
|
|
142
|
-
function genImportComponetCode(
|
|
143
|
-
return `() =>
|
|
144
|
+
function genImportComponetCode(chunkId) {
|
|
145
|
+
return `() => __webpack_require__.e("${chunkId}").then(__webpack_require__.bind(__webpack_require__, "./${chunkId}.js"))`;
|
|
144
146
|
}
|
|
145
147
|
// 生成导出组件代码
|
|
146
148
|
function genExportComponetCode(component) {
|
|
@@ -148,12 +150,13 @@ function genExportComponetCode(component) {
|
|
|
148
150
|
const optionCode = renderCode
|
|
149
151
|
? `render: __render__,\n staticRenderFns: __staticRenderFns__,`
|
|
150
152
|
: `template: \`${component.template.replace(/[`$]/g, (m) => `\\${m}`)}\`,`;
|
|
151
|
-
|
|
153
|
+
let code = `var componentOptions = ${component.script ? `(function(){\n${component.script.trim().replace(/export default |module\.exports +=/, 'return ')}\n})()` : '{}'};
|
|
152
154
|
${renderCode}
|
|
153
155
|
Object.assign(componentOptions, {
|
|
154
156
|
${optionCode}
|
|
155
157
|
});
|
|
156
|
-
|
|
158
|
+
`;
|
|
159
|
+
return code;
|
|
157
160
|
}
|
|
158
161
|
// 获取文件路径
|
|
159
162
|
// name 或者 文件 至少有一个必填
|
|
@@ -166,27 +169,44 @@ const getCompletePath = (name, fileContent, config) => {
|
|
|
166
169
|
fileName += `${(0, nasl_utils_1.genHash)(fileContent)}.`;
|
|
167
170
|
}
|
|
168
171
|
fileName += `min.js`;
|
|
169
|
-
// if(config?.isExport && !fileName.includes('bundle')&& !fileName.includes('router')){
|
|
170
|
-
// fileName =`${config.sysPrefixPath}/${fileName}`
|
|
171
|
-
// }
|
|
172
172
|
return fileName;
|
|
173
173
|
};
|
|
174
|
-
function genRouterFileContent(routes, defaultRoute) {
|
|
174
|
+
function genRouterFileContent(routes, defaultRoute, config) {
|
|
175
|
+
// 单页面发布
|
|
176
|
+
if (config.isOneFile) {
|
|
177
|
+
let code = config?.cacheRouters;
|
|
178
|
+
const changedChunks = config?.asyncChunksMap;
|
|
179
|
+
let newRoutesCode = 'window.lcap_routes = [\n';
|
|
180
|
+
routes.forEach((route) => {
|
|
181
|
+
newRoutesCode += `${routeToString(route)},\n`;
|
|
182
|
+
});
|
|
183
|
+
newRoutesCode += '];\n';
|
|
184
|
+
const [start, end] = ['// lcap_routes start', '// lcap_routes end'];
|
|
185
|
+
// 将start和end之间的代码替换掉
|
|
186
|
+
code = code.slice(0, code.indexOf(start) + start.length) + '\n' + newRoutesCode + code.slice(code.indexOf(end));
|
|
187
|
+
const placeholderIdx = code.indexOf('// lcap_changed_chunks placeholder');
|
|
188
|
+
// 前面插入代码
|
|
189
|
+
if (placeholderIdx !== -1) {
|
|
190
|
+
code = code.slice(0, placeholderIdx) + `Object.assign(lcap_changed_chunks, ${JSON.stringify(changedChunks)});\n` + code.slice(placeholderIdx);
|
|
191
|
+
}
|
|
192
|
+
return code;
|
|
193
|
+
}
|
|
175
194
|
function routeToString(route) {
|
|
176
195
|
let content = `{
|
|
177
196
|
path: '${route.path}',\n`;
|
|
178
|
-
if (route?.
|
|
179
|
-
|
|
180
|
-
content += `
|
|
181
|
-
|
|
197
|
+
if (route?.fullPath) {
|
|
198
|
+
// 单页面发布时需要
|
|
199
|
+
content += `fullPath: '${route.fullPath}',\n`;
|
|
200
|
+
const chunkId = (0, nasl_utils_1.genHash)(route.fullPath);
|
|
201
|
+
content += `component: ${genImportComponetCode(chunkId)},\n`;
|
|
182
202
|
}
|
|
183
203
|
if (route?.meta) {
|
|
184
204
|
content += `meta: ${stringifyMetaData(route.meta)},`;
|
|
185
205
|
}
|
|
186
|
-
if (route
|
|
206
|
+
if (route.children?.length) {
|
|
187
207
|
content += `children: [
|
|
188
|
-
|
|
189
|
-
|
|
208
|
+
${route.children?.map?.(routeToString)?.join(',\n')}
|
|
209
|
+
],\n`;
|
|
190
210
|
}
|
|
191
211
|
if (route?.redirect) {
|
|
192
212
|
content += `redirect: '${route?.redirect}',\n`;
|
|
@@ -194,35 +214,64 @@ function genRouterFileContent(routes, defaultRoute) {
|
|
|
194
214
|
content += '}';
|
|
195
215
|
return content;
|
|
196
216
|
}
|
|
217
|
+
// 生成异步块映射表
|
|
218
|
+
const name = config?.app?.name;
|
|
219
|
+
let code = `window["${name}LcapChunksMap"] = ${JSON5.stringify(config?.asyncChunksMap || {})};\n`;
|
|
197
220
|
// 生成路由配置
|
|
198
|
-
|
|
221
|
+
code += `// lcap_routes start
|
|
222
|
+
window.lcap_routes = [\n`;
|
|
199
223
|
routes.forEach((route) => {
|
|
200
|
-
|
|
224
|
+
code += `${routeToString(route)},\n`;
|
|
201
225
|
});
|
|
202
226
|
if (defaultRoute) {
|
|
203
|
-
|
|
227
|
+
code += `{
|
|
204
228
|
path: '*',
|
|
205
229
|
redirect: '${defaultRoute}',
|
|
206
230
|
}\n`;
|
|
207
231
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
232
|
+
code += `];
|
|
233
|
+
// lcap_routes end\n`;
|
|
234
|
+
// changedChunk
|
|
235
|
+
code += `var lcap_changed_chunks = {};
|
|
236
|
+
|
|
237
|
+
// lcap_changed_chunks placeholder
|
|
238
|
+
|
|
239
|
+
Object.keys(lcap_changed_chunks).forEach(function(chunkId) {
|
|
240
|
+
window["${name}LcapChunksMap"][chunkId] = lcap_changed_chunks[chunkId];
|
|
241
|
+
});`;
|
|
242
|
+
return (0, chunk_1.generate)({
|
|
243
|
+
name: config?.app?.name,
|
|
244
|
+
chunkId: 'router',
|
|
245
|
+
moduleId: 'router',
|
|
246
|
+
content: code,
|
|
247
|
+
exports: [],
|
|
248
|
+
exec: false,
|
|
249
|
+
});
|
|
211
250
|
}
|
|
212
251
|
// 生成路由文件
|
|
213
252
|
function genRouteFiles(routes, defaultRoute, config) {
|
|
214
253
|
// 生成路由文件列表
|
|
215
254
|
const routeFiles = [];
|
|
255
|
+
const asyncChunksMap = {};
|
|
216
256
|
function routeToFile(route) {
|
|
217
257
|
if (route?.component?.script) {
|
|
218
258
|
const content = genExportComponetCode(route.component);
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
// let outFilePath =`${config?.sysPrefixPath? config?.sysPrefixPath +'/' :''}${lazyPath}`;
|
|
259
|
+
const chunkId = (0, nasl_utils_1.genHash)(route.fullPath);
|
|
260
|
+
const contentHash = (0, nasl_utils_1.genHash)(content);
|
|
222
261
|
routeFiles.push({
|
|
223
|
-
name:
|
|
224
|
-
content,
|
|
262
|
+
name: chunkId + '.' + contentHash + '.js',
|
|
263
|
+
content: (0, chunk_1.generate)({
|
|
264
|
+
name: config?.app?.name,
|
|
265
|
+
chunkId,
|
|
266
|
+
moduleId: chunkId,
|
|
267
|
+
content,
|
|
268
|
+
exports: [
|
|
269
|
+
['componentOptions', 'default'],
|
|
270
|
+
],
|
|
271
|
+
exec: false,
|
|
272
|
+
}),
|
|
225
273
|
});
|
|
274
|
+
asyncChunksMap[chunkId] = contentHash;
|
|
226
275
|
}
|
|
227
276
|
if (route?.children?.length) {
|
|
228
277
|
route.children.map(routeToFile);
|
|
@@ -231,13 +280,16 @@ function genRouteFiles(routes, defaultRoute, config) {
|
|
|
231
280
|
routes.forEach((route) => {
|
|
232
281
|
routeToFile(route);
|
|
233
282
|
});
|
|
234
|
-
let routerPath = getCompletePath('router', null, config);
|
|
235
283
|
routeFiles.push({
|
|
236
|
-
name:
|
|
284
|
+
name: getCompletePath('router', null, config),
|
|
237
285
|
isRouterFile: true,
|
|
238
|
-
content: genRouterFileContent(routes, defaultRoute),
|
|
286
|
+
content: genRouterFileContent(routes, defaultRoute, Object.assign({}, config, { asyncChunksMap })),
|
|
239
287
|
});
|
|
240
|
-
|
|
288
|
+
const { publicPath } = config;
|
|
289
|
+
return routeFiles.map(file => ({
|
|
290
|
+
...file,
|
|
291
|
+
name: publicPath + file.name,
|
|
292
|
+
}));
|
|
241
293
|
}
|
|
242
294
|
async function genBundleFiles(app, frontend, config) {
|
|
243
295
|
config.sysPrefixPath = app?.sysPrefixPath;
|
|
@@ -252,6 +304,7 @@ async function genBundleFiles(app, frontend, config) {
|
|
|
252
304
|
const fnLowcodeDomain = config?.envLcpDomain?.[config?.env]?.lcpDomain || config?.lowcodeDomain;
|
|
253
305
|
const modules = [];
|
|
254
306
|
const views = [];
|
|
307
|
+
const isExport = !!config.isExport;
|
|
255
308
|
const STATIC_URL = config.isExport ? '' : config.STATIC_URL;
|
|
256
309
|
app.dependencies && modules.push(...app.dependencies);
|
|
257
310
|
app.interfaceDependencies && modules.push(...app.interfaceDependencies);
|
|
@@ -322,24 +375,19 @@ async function genBundleFiles(app, frontend, config) {
|
|
|
322
375
|
(0, nasl_log_1.clearLogs)(app);
|
|
323
376
|
}
|
|
324
377
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
let
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
baseUrl = `${config.USER_STATIC_URL}/asset-center/preview/${config.tenant}/${app.id}/${config.env}`;
|
|
338
|
-
}
|
|
339
|
-
else if (config.isExport) {
|
|
340
|
-
baseUrl = '';
|
|
378
|
+
// @ts-expect-error
|
|
379
|
+
const publicPath = (0, nasl_unified_frontend_generator_2.getPublicPath)(app, config, frontend);
|
|
380
|
+
/**
|
|
381
|
+
* 为什么要加这个呢,因为导出静态资源的场景下,所有资源都会经过一道loadJSWrap
|
|
382
|
+
* 这个loadJSWrap会补上统一前缀,但是不带端路径
|
|
383
|
+
* 所以client.js里的资源需要是:
|
|
384
|
+
* /packages/pc-ui/index.js
|
|
385
|
+
* /m/bundle.js
|
|
386
|
+
*/
|
|
387
|
+
let basePath = frontend.basePath || '/';
|
|
388
|
+
if (!basePath.endsWith('/')) {
|
|
389
|
+
basePath += '/';
|
|
341
390
|
}
|
|
342
|
-
let completePath = `${baseUrl}${basePath || ''}/`;
|
|
343
391
|
/**
|
|
344
392
|
* vue.config.js page options
|
|
345
393
|
*/
|
|
@@ -379,11 +427,18 @@ async function genBundleFiles(app, frontend, config) {
|
|
|
379
427
|
}
|
|
380
428
|
}
|
|
381
429
|
}
|
|
430
|
+
let fullPath = `/${viewName}`;
|
|
431
|
+
let parent = view.parentNode;
|
|
432
|
+
while (parent?.concept === 'View') {
|
|
433
|
+
fullPath = `/${parent.name}${fullPath}`;
|
|
434
|
+
parent = parent.parentNode;
|
|
435
|
+
}
|
|
382
436
|
const route = {
|
|
383
437
|
path: routePath,
|
|
384
438
|
component: (0, compileComponent_1.compileComponent)(componentMap[view.id]),
|
|
385
439
|
children: [],
|
|
386
440
|
meta: view.getRouteMeta(),
|
|
441
|
+
fullPath,
|
|
387
442
|
};
|
|
388
443
|
const viewChildren = view.children;
|
|
389
444
|
if (Array.isArray(viewChildren) && viewChildren.length) {
|
|
@@ -458,15 +513,7 @@ async function genBundleFiles(app, frontend, config) {
|
|
|
458
513
|
// authResourcePathMap={}
|
|
459
514
|
}
|
|
460
515
|
const authResourcePaths = Object.keys(authResourcePathMap);
|
|
461
|
-
const routerFiles = genRouteFiles(routes, defaultRoute, config);
|
|
462
|
-
routerFiles.forEach(item => {
|
|
463
|
-
let temp = completePath;
|
|
464
|
-
// if(completePath=='/'){temp=''}else{temp = `${completePath}/`}
|
|
465
|
-
if (config?.isExport && config?.sysPrefixPath?.length > 0) {
|
|
466
|
-
temp = config?.sysPrefixPath + temp;
|
|
467
|
-
}
|
|
468
|
-
item.name = temp + item.name;
|
|
469
|
-
});
|
|
516
|
+
const routerFiles = genRouteFiles(routes, defaultRoute, Object.assign({}, config, { app, publicPath }));
|
|
470
517
|
let fileI18nInfo = {
|
|
471
518
|
enabled: false,
|
|
472
519
|
locale: 'zh-CN',
|
|
@@ -581,8 +628,6 @@ async function genBundleFiles(app, frontend, config) {
|
|
|
581
628
|
}
|
|
582
629
|
const assetsInfo = app.genAllAssetsInfo(STATIC_URL, frontend.type, frontendType.frameworkKind);
|
|
583
630
|
const customNames = JSON5.stringify(assetsInfo.custom.names);
|
|
584
|
-
let content1 = `(async function(){
|
|
585
|
-
`;
|
|
586
631
|
let contentScale = '';
|
|
587
632
|
if (frontend.globalScaleEnabled)
|
|
588
633
|
contentScale = `{
|
|
@@ -692,67 +737,6 @@ async function genBundleFiles(app, frontend, config) {
|
|
|
692
737
|
let contentImport = `
|
|
693
738
|
var platformConfig = ${platformConfig};
|
|
694
739
|
var metaData = ${metaDataStr};
|
|
695
|
-
|
|
696
|
-
var getCompletePath = (path) => {
|
|
697
|
-
return '${config?.isExport ? config.sysPrefixPath : ''}${completePath}' + path;
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
// 低版本
|
|
701
|
-
function importXMLHttpRequestComponent (scriptUrl) {
|
|
702
|
-
return new Promise(function(resolve, reject) {
|
|
703
|
-
var xhr = new XMLHttpRequest();
|
|
704
|
-
xhr.open('GET', scriptUrl, true);
|
|
705
|
-
xhr.onreadystatechange = function() {
|
|
706
|
-
if (xhr.readyState === 4) {
|
|
707
|
-
if (xhr.status === 200) {
|
|
708
|
-
var scriptContent = xhr.responseText;
|
|
709
|
-
try {
|
|
710
|
-
var func = new Function('importComponent', 'window', scriptContent + '\\n//# sourceURL=' + scriptUrl);
|
|
711
|
-
var result = func(window.importComponent, window);
|
|
712
|
-
resolve(result);
|
|
713
|
-
} catch (error) {
|
|
714
|
-
if (typeof window.$appUtils.createErrorLayout === 'function') {
|
|
715
|
-
window.$appUtils.createErrorLayout(error);
|
|
716
|
-
}
|
|
717
|
-
reject(error);
|
|
718
|
-
}
|
|
719
|
-
} else {
|
|
720
|
-
reject(new Error('Failed to fetch script'));
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
};
|
|
724
|
-
xhr.send();
|
|
725
|
-
});
|
|
726
|
-
};
|
|
727
|
-
function importFetchComponent(scriptUrl) {
|
|
728
|
-
return fetch(scriptUrl)
|
|
729
|
-
.then(function(response) {
|
|
730
|
-
if (!response.ok) {
|
|
731
|
-
throw new Error('Network response was not ok');
|
|
732
|
-
}
|
|
733
|
-
return response.text();
|
|
734
|
-
}).then(function(scriptText) {
|
|
735
|
-
var func = new Function('importComponent', 'window', scriptText + '\\n//# sourceURL=' + scriptUrl);
|
|
736
|
-
var result = func(window.importComponent, window);
|
|
737
|
-
return result;
|
|
738
|
-
})
|
|
739
|
-
.catch(error => {
|
|
740
|
-
console.error('Error loading script:', error);
|
|
741
|
-
if (typeof window.$appUtils.createErrorLayout === 'function') {
|
|
742
|
-
window.$appUtils.createErrorLayout(error);
|
|
743
|
-
}
|
|
744
|
-
});
|
|
745
|
-
}
|
|
746
|
-
window.importComponent = (scriptUrl) => {
|
|
747
|
-
scriptUrl = getCompletePath(scriptUrl);
|
|
748
|
-
// 浏览器支持fetch,直接使用fetch
|
|
749
|
-
if (window.fetch) {
|
|
750
|
-
return importFetchComponent(scriptUrl);
|
|
751
|
-
}
|
|
752
|
-
return importXMLHttpRequestComponent(scriptUrl);
|
|
753
|
-
}
|
|
754
|
-
|
|
755
|
-
var routes = await importComponent('${getCompletePath('router', null, config)}?t=' + Date.now());
|
|
756
740
|
`;
|
|
757
741
|
// 按页面维度发布先不考虑鉴权,页面维度新增的页面都算是不鉴权的数组中
|
|
758
742
|
// 只有完全页面维度新增的才会进入到这个数组中
|
|
@@ -771,11 +755,11 @@ async function genBundleFiles(app, frontend, config) {
|
|
|
771
755
|
}
|
|
772
756
|
});
|
|
773
757
|
}
|
|
774
|
-
iterateRouters(
|
|
758
|
+
iterateRouters(window.lcap_routes);` : '';
|
|
775
759
|
let contentCreateLCAPApp = `
|
|
776
760
|
window.createLcapApp = () => {
|
|
777
761
|
${compRegStr}
|
|
778
|
-
appVM = window.cloudAdminDesigner.init(platformConfig.appConfig, platformConfig,
|
|
762
|
+
var appVM = window.cloudAdminDesigner.init(platformConfig.appConfig, platformConfig, window.lcap_routes, metaData);
|
|
779
763
|
try {
|
|
780
764
|
var push = appVM.$router.history.push;
|
|
781
765
|
appVM.$router.history.push = function (a, b) {
|
|
@@ -854,8 +838,6 @@ async function genBundleFiles(app, frontend, config) {
|
|
|
854
838
|
if(shortcutIconLink) parent.document.head.appendChild(shortcutIconLink);
|
|
855
839
|
}
|
|
856
840
|
` : '';
|
|
857
|
-
let content10 = `
|
|
858
|
-
})();`;
|
|
859
841
|
let contentDevOnly = config.env === 'dev' ? `
|
|
860
842
|
var _div = document.createElement('div');
|
|
861
843
|
_div.classList = "div-load"
|
|
@@ -971,10 +953,21 @@ async function genBundleFiles(app, frontend, config) {
|
|
|
971
953
|
};
|
|
972
954
|
fetchAnnoData();
|
|
973
955
|
` : '';
|
|
974
|
-
let content = [
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
956
|
+
let content = [
|
|
957
|
+
`__webpack_require__('./router.js');`,
|
|
958
|
+
contentScale,
|
|
959
|
+
contentStyleCss,
|
|
960
|
+
contentDocIcon,
|
|
961
|
+
contentCustomNames,
|
|
962
|
+
contentImport,
|
|
963
|
+
contentLogReportCode,
|
|
964
|
+
contentRouter,
|
|
965
|
+
contentCreateLCAPApp,
|
|
966
|
+
contentPCIframe,
|
|
967
|
+
contentDevOnly,
|
|
968
|
+
contentVueDirectives.join(''),
|
|
969
|
+
contentViewElemAnno
|
|
970
|
+
].join('');
|
|
978
971
|
contentScale = null;
|
|
979
972
|
contentStyleCss = null;
|
|
980
973
|
contentDocIcon = null;
|
|
@@ -984,19 +977,35 @@ async function genBundleFiles(app, frontend, config) {
|
|
|
984
977
|
contentRouter = null;
|
|
985
978
|
contentCreateLCAPApp = null;
|
|
986
979
|
contentPCIframe = null;
|
|
987
|
-
content10 = null;
|
|
988
980
|
contentDevOnly = null;
|
|
989
981
|
contentVueDirectives = null;
|
|
990
982
|
contentViewElemAnno = null;
|
|
991
983
|
const timestamp = Date.now();
|
|
992
984
|
utils.delay(100);
|
|
993
|
-
|
|
985
|
+
content = (0, chunk_1.generate)({
|
|
986
|
+
name: app.name,
|
|
987
|
+
chunkId: 'bundle',
|
|
988
|
+
moduleId: 'bundle',
|
|
989
|
+
content,
|
|
990
|
+
exports: [],
|
|
991
|
+
exec: true,
|
|
992
|
+
});
|
|
993
|
+
const routerFileName = getCompletePath('router', null, config);
|
|
994
|
+
const bundleFileName = getCompletePath(getBundleFileName(config), content, config);
|
|
995
|
+
let clientPath = publicPath + 'client.js';
|
|
996
|
+
let runtimePath = publicPath + 'runtime.js';
|
|
997
|
+
let routerPath = publicPath + routerFileName;
|
|
998
|
+
let bundleMinPath = publicPath + bundleFileName;
|
|
994
999
|
const otherJsList = frontend?.appletsConfig?.enable ? ['//res.wx.qq.com/open/js/jweixin-1.3.2.js'] : [];
|
|
995
1000
|
const microAppIntegration = (0, microApp_1.integrateMicroApp)(frontend);
|
|
996
1001
|
if (config?.debug) {
|
|
997
1002
|
otherJsList.push(`${STATIC_URL}/packages/@lcap/breakpoint-client@1.0.0/dist/index.js?time=${timestamp}`);
|
|
998
1003
|
}
|
|
999
|
-
let jsAssetsList = assetsInfo.basic.js.concat(assetsInfo.custom.js, otherJsList).concat([
|
|
1004
|
+
let jsAssetsList = assetsInfo.basic.js.concat(assetsInfo.custom.js, otherJsList).concat([
|
|
1005
|
+
isExport ? (basePath + 'runtime.js') : runtimePath,
|
|
1006
|
+
isExport ? (basePath + routerFileName) : routerPath,
|
|
1007
|
+
isExport ? (basePath + bundleFileName) : bundleMinPath,
|
|
1008
|
+
]);
|
|
1000
1009
|
let cssAssetsList = assetsInfo.basic.css.concat(assetsInfo.custom.css);
|
|
1001
1010
|
if (config.isPreviewFe) {
|
|
1002
1011
|
const changeToRelativePath = (str) => {
|
|
@@ -1108,8 +1117,10 @@ async function genBundleFiles(app, frontend, config) {
|
|
|
1108
1117
|
}));
|
|
1109
1118
|
}
|
|
1110
1119
|
// encode url
|
|
1111
|
-
|
|
1112
|
-
|
|
1120
|
+
if ((0, nasl_unified_frontend_generator_2.isEnabledEncode)()) {
|
|
1121
|
+
jsAssetsList = jsAssetsList.map(nasl_unified_frontend_generator_2.encodeFetchFileURL);
|
|
1122
|
+
cssAssetsList = cssAssetsList.map(nasl_unified_frontend_generator_2.encodeFetchFileURL);
|
|
1123
|
+
}
|
|
1113
1124
|
const dynamicAssets = optimizeAssetClassification(jsAssetsList);
|
|
1114
1125
|
// CSS 资源默认最后
|
|
1115
1126
|
if (cssAssetsList.length > 0) {
|
|
@@ -1190,18 +1201,26 @@ async function genBundleFiles(app, frontend, config) {
|
|
|
1190
1201
|
`;
|
|
1191
1202
|
const outputs = [
|
|
1192
1203
|
{
|
|
1193
|
-
name:
|
|
1194
|
-
content,
|
|
1204
|
+
name: clientPath,
|
|
1205
|
+
content: assetsContent,
|
|
1195
1206
|
},
|
|
1196
1207
|
{
|
|
1197
|
-
name:
|
|
1198
|
-
content:
|
|
1208
|
+
name: runtimePath,
|
|
1209
|
+
content: (0, runtime_1.generate)({
|
|
1210
|
+
name: app.name,
|
|
1211
|
+
publicPath: JSON.stringify(publicPath),
|
|
1212
|
+
}),
|
|
1213
|
+
},
|
|
1214
|
+
{
|
|
1215
|
+
name: bundleMinPath,
|
|
1216
|
+
content,
|
|
1199
1217
|
},
|
|
1200
1218
|
...routerFiles,
|
|
1201
1219
|
];
|
|
1202
1220
|
assetsContent = null;
|
|
1203
1221
|
content = null;
|
|
1204
1222
|
processAssetsInOutputs(outputs, frontend, config);
|
|
1223
|
+
console.info('编译结果', outputs.map((x) => x.name));
|
|
1205
1224
|
return outputs;
|
|
1206
1225
|
}
|
|
1207
1226
|
exports.genBundleFiles = genBundleFiles;
|
|
@@ -1334,16 +1353,23 @@ async function getOneFiles(options) {
|
|
|
1334
1353
|
if (isRootView) {
|
|
1335
1354
|
routePath = `${frontend.prefixPath}/${viewName}`;
|
|
1336
1355
|
}
|
|
1356
|
+
let fullPath = `/${viewName}`;
|
|
1357
|
+
let parent = view.parentNode;
|
|
1358
|
+
while (parent?.concept === 'View') {
|
|
1359
|
+
fullPath = `/${parent.name}${fullPath}`;
|
|
1360
|
+
parent = parent.parentNode;
|
|
1361
|
+
}
|
|
1337
1362
|
const route = {
|
|
1338
1363
|
path: routePath,
|
|
1339
1364
|
component: (0, compileComponent_1.compileComponent)(viewOption),
|
|
1340
1365
|
children: [],
|
|
1341
1366
|
meta: view.getRouteMeta(),
|
|
1367
|
+
fullPath,
|
|
1342
1368
|
};
|
|
1343
1369
|
return route;
|
|
1344
1370
|
}
|
|
1345
|
-
let currentView = view;
|
|
1346
1371
|
let currentRoute = null;
|
|
1372
|
+
let currentView = view;
|
|
1347
1373
|
while (currentView?.concept === 'View') {
|
|
1348
1374
|
if (currentRoute) {
|
|
1349
1375
|
const child = currentRoute;
|
|
@@ -1377,6 +1403,7 @@ async function getOneFiles(options) {
|
|
|
1377
1403
|
// 如果找到了现有路由,更新 component 和 meta
|
|
1378
1404
|
existingRoute.component = newRoute.component;
|
|
1379
1405
|
existingRoute.meta = newRoute.meta;
|
|
1406
|
+
existingRoute.fullPath = newRoute.fullPath;
|
|
1380
1407
|
// 递归合并子路由
|
|
1381
1408
|
if (newRoute.children) {
|
|
1382
1409
|
existingRoute.children = existingRoute.children || [];
|
|
@@ -1393,9 +1420,25 @@ async function getOneFiles(options) {
|
|
|
1393
1420
|
routes.unshift(newRoute);
|
|
1394
1421
|
}
|
|
1395
1422
|
}
|
|
1423
|
+
let existingRoutes = [];
|
|
1424
|
+
try {
|
|
1425
|
+
// 获取// lcap_routes start 到 // lcap_routes end 之间的代码
|
|
1426
|
+
const [start, end] = ['// lcap_routes start', '// lcap_routes end'];
|
|
1427
|
+
const routesCode = cacheRouters
|
|
1428
|
+
.substring(cacheRouters.indexOf(start) + start.length, cacheRouters.indexOf(end))
|
|
1429
|
+
.replace('window.lcap_routes = ', 'return ');
|
|
1430
|
+
const fn = new Function(`${routesCode}`);
|
|
1431
|
+
existingRoutes = fn();
|
|
1432
|
+
}
|
|
1433
|
+
catch (error) {
|
|
1434
|
+
console.error('路由代码 eval 失败:', error);
|
|
1435
|
+
}
|
|
1396
1436
|
// Bug-3156542745982976: 原本直接找到顶层直接删除,在新增节点,遗漏处理中间层也有节点的情况,单页发布就直接增量合并,为了性能,暂时不考虑删除节点
|
|
1397
|
-
addOrUpdateRoute(
|
|
1398
|
-
|
|
1437
|
+
addOrUpdateRoute(existingRoutes, currentRoute);
|
|
1438
|
+
// @ts-expect-error
|
|
1439
|
+
const publicPath = (0, nasl_unified_frontend_generator_2.getPublicPath)(app, config, frontend);
|
|
1440
|
+
const routerFiles = genRouteFiles(existingRoutes, null, Object.assign({}, config, { app, cacheRouters, isOneFile: true, publicPath }));
|
|
1441
|
+
console.info('编译结果', routerFiles.map((x) => x.name));
|
|
1399
1442
|
return routerFiles;
|
|
1400
1443
|
}
|
|
1401
1444
|
exports.getOneFiles = getOneFiles;
|
|
@@ -1489,4 +1532,13 @@ function processAssetsInOutputs(outputs, frontend, config) {
|
|
|
1489
1532
|
});
|
|
1490
1533
|
}
|
|
1491
1534
|
}
|
|
1535
|
+
function getBundleFileName(config) {
|
|
1536
|
+
if (config.isPreviewFe && config.previewVersion) {
|
|
1537
|
+
return `mockBundle-${config.previewVersion}`;
|
|
1538
|
+
}
|
|
1539
|
+
else {
|
|
1540
|
+
return 'bundle';
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
;
|
|
1492
1544
|
//# sourceMappingURL=genBundleFiles.js.map
|