@lcap/nasl-unified-frontend-generator 4.1.0-beta.1 → 4.1.0-beta.11
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/dist/index.d.mts +22 -7
- package/dist/index.d.ts +22 -7
- package/dist/index.js +423 -218
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +434 -213
- package/dist/index.mjs.map +1 -1
- package/dist/playground.d.mts +1 -1
- package/dist/playground.d.ts +1 -1
- package/dist/playground.js +129639 -226
- package/dist/playground.js.map +1 -1
- package/dist/playground.mjs +129645 -226
- package/dist/playground.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
+
};
|
|
8
11
|
var __export = (target, all) => {
|
|
9
12
|
for (var name in all)
|
|
10
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -37,6 +40,75 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
37
40
|
};
|
|
38
41
|
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
39
42
|
|
|
43
|
+
// src/plugins/templates/auto-reload.js
|
|
44
|
+
var auto_reload_exports = {};
|
|
45
|
+
__export(auto_reload_exports, {
|
|
46
|
+
default: () => auto_reload_default
|
|
47
|
+
});
|
|
48
|
+
var auto_reload_default;
|
|
49
|
+
var init_auto_reload = __esm({
|
|
50
|
+
"src/plugins/templates/auto-reload.js"() {
|
|
51
|
+
"use strict";
|
|
52
|
+
auto_reload_default = `
|
|
53
|
+
const dom = document.createElement('div');
|
|
54
|
+
dom.classList = "lcap-deploy-loading-container";
|
|
55
|
+
dom.style.display = 'none';
|
|
56
|
+
dom.innerHTML = "<div class='lcap-deploy-loading-icon'></div><div>\u6B63\u5728\u66F4\u65B0\u6700\u65B0\u53D1\u5E03\u5185\u5BB9...</div>";
|
|
57
|
+
document.getElementsByTagName('body')[0].appendChild(dom);
|
|
58
|
+
|
|
59
|
+
const style = document.createElement('style');
|
|
60
|
+
style.innerHTML = \`.lcap-deploy-loading-container {
|
|
61
|
+
width: 208px;
|
|
62
|
+
height: 40px;
|
|
63
|
+
background: rgba(48, 48, 48, 0.8);
|
|
64
|
+
box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.1);
|
|
65
|
+
border-radius: 4px;
|
|
66
|
+
position: fixed;
|
|
67
|
+
top: 120px;
|
|
68
|
+
left: 50%;
|
|
69
|
+
margin-left: -104px;
|
|
70
|
+
color: #FFFFFF;
|
|
71
|
+
font-size: 14px;
|
|
72
|
+
justify-content: center;
|
|
73
|
+
align-items: center;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.lcap-deploy-loading-icon{
|
|
77
|
+
width: 12px;
|
|
78
|
+
height: 12px;
|
|
79
|
+
margin-right: 10px;
|
|
80
|
+
animation: loading-animation 0.8s infinite linear;
|
|
81
|
+
border: 2px solid #f3f3f3;
|
|
82
|
+
border-top: 2px solid rgb(109, 108, 108);
|
|
83
|
+
border-right: 2px solid rgb(109, 108, 108);
|
|
84
|
+
border-bottom: 2px solid rgb(109, 108, 108);
|
|
85
|
+
border-radius: 50%;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@keyframes loading-animation{
|
|
89
|
+
0% {
|
|
90
|
+
transform: rotate(0deg);
|
|
91
|
+
}
|
|
92
|
+
100% {
|
|
93
|
+
transform: rotate(360deg);
|
|
94
|
+
}
|
|
95
|
+
}\`;
|
|
96
|
+
document.getElementsByTagName('body')[0].appendChild(style);
|
|
97
|
+
|
|
98
|
+
window.addEventListener('message', function (e) {
|
|
99
|
+
if(e.data ==="release-start"){
|
|
100
|
+
document.querySelector(".lcap-deploy-loading-container").style.display ="flex"
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if(e.data==="release-end"){
|
|
104
|
+
document.querySelector(".lcap-deploy-loading-container").style.display ="none"
|
|
105
|
+
window.location.reload();
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
`;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
|
|
40
112
|
// src/index.ts
|
|
41
113
|
var src_exports = {};
|
|
42
114
|
__export(src_exports, {
|
|
@@ -103,11 +175,11 @@ var import_axios2 = __toESM(require("axios"));
|
|
|
103
175
|
var import_lodash9 = require("lodash");
|
|
104
176
|
|
|
105
177
|
// src/default-container.ts
|
|
106
|
-
var
|
|
178
|
+
var import_inversify32 = require("inversify");
|
|
107
179
|
|
|
108
180
|
// src/plugins/vue/vue3/vue3-preset-plugin.ts
|
|
109
181
|
var import_reflection6 = require("@abraham/reflection");
|
|
110
|
-
var
|
|
182
|
+
var import_inversify31 = require("inversify");
|
|
111
183
|
|
|
112
184
|
// src/service-metakind.ts
|
|
113
185
|
var ServiceMetaKind = {
|
|
@@ -1305,8 +1377,8 @@ var reactComponentLibHackPlugin = makePlugin({
|
|
|
1305
1377
|
}
|
|
1306
1378
|
|
|
1307
1379
|
Object.assign(utils, {
|
|
1308
|
-
jsonSerialize: JSON.stringify,
|
|
1309
|
-
jsonDeserialize: JSON.parse,
|
|
1380
|
+
jsonSerialize: utils.JsonSerialize || JSON.stringify,
|
|
1381
|
+
jsonDeserialize: utils.JsonDeserialize || JSON.parse,
|
|
1310
1382
|
});
|
|
1311
1383
|
|
|
1312
1384
|
const logging = {
|
|
@@ -2545,6 +2617,9 @@ query: {`;
|
|
|
2545
2617
|
s2.right,
|
|
2546
2618
|
callbackBag
|
|
2547
2619
|
)}`;
|
|
2620
|
+
} else if ((0, import_asserts.isVariadicExpression)(s2)) {
|
|
2621
|
+
const expressions = s2.expressions.map((exp) => getRuntimeStr(exp, callbackBag));
|
|
2622
|
+
return expressions.join(s2.operator);
|
|
2548
2623
|
} else if ((0, import_asserts.isMatchCase)(s2)) {
|
|
2549
2624
|
const p = s2.parentNode;
|
|
2550
2625
|
if (!(0, import_asserts.isMatch)(p)) {
|
|
@@ -4085,7 +4160,7 @@ var ReactCodegenPlugin = class {
|
|
|
4085
4160
|
const exts = packages.filter((x) => x.kind === "extension");
|
|
4086
4161
|
const imports = exts.map((ext) => {
|
|
4087
4162
|
return {
|
|
4088
|
-
from:
|
|
4163
|
+
from: `${ext.name}`,
|
|
4089
4164
|
import: `* as ${kebab2Pascal(ext.name)}`
|
|
4090
4165
|
};
|
|
4091
4166
|
}).filter(isNotNil);
|
|
@@ -4376,7 +4451,7 @@ var materials = {
|
|
|
4376
4451
|
frameworkVersion: "vue@3.5.13",
|
|
4377
4452
|
name: "@lcap/vant",
|
|
4378
4453
|
libName: "LcapVant",
|
|
4379
|
-
version: "1.0.0
|
|
4454
|
+
version: "1.0.0"
|
|
4380
4455
|
}
|
|
4381
4456
|
]
|
|
4382
4457
|
},
|
|
@@ -4399,29 +4474,6 @@ var coreVersion = materials.framework.version;
|
|
|
4399
4474
|
function getPredefinedMaterialConfig() {
|
|
4400
4475
|
return materials;
|
|
4401
4476
|
}
|
|
4402
|
-
function getPredefinedLibConstants() {
|
|
4403
|
-
if (!reactUi || !vue3Ui) {
|
|
4404
|
-
throw new Error("not found");
|
|
4405
|
-
}
|
|
4406
|
-
if (reactUi.name !== "@lcap/pc-react-ui") {
|
|
4407
|
-
throw new Error("cannot find @lcap/pc-react-ui in material.config.js");
|
|
4408
|
-
}
|
|
4409
|
-
return {
|
|
4410
|
-
reactUI: {
|
|
4411
|
-
kind: "standard",
|
|
4412
|
-
name: reactUi.name,
|
|
4413
|
-
version: reactUi.version
|
|
4414
|
-
},
|
|
4415
|
-
vue3Ui: {
|
|
4416
|
-
kind: "standard",
|
|
4417
|
-
name: vue3Ui.name,
|
|
4418
|
-
version: vue3Ui.version
|
|
4419
|
-
},
|
|
4420
|
-
basicTemplate: {
|
|
4421
|
-
version: coreVersion
|
|
4422
|
-
}
|
|
4423
|
-
};
|
|
4424
|
-
}
|
|
4425
4477
|
var getPredefinedMaterialByTags = (() => {
|
|
4426
4478
|
const materialConfig = getPredefinedMaterialConfig();
|
|
4427
4479
|
let allMaterials = [];
|
|
@@ -4445,12 +4497,14 @@ var getPredefinedMaterialByTags = (() => {
|
|
|
4445
4497
|
materialConfig.ui.pc.forEach((item) => {
|
|
4446
4498
|
allMaterials.push({
|
|
4447
4499
|
...item,
|
|
4500
|
+
kind: "standard",
|
|
4448
4501
|
tags: ["ui", "pc", item.frameworkKind, item.libName]
|
|
4449
4502
|
});
|
|
4450
4503
|
});
|
|
4451
4504
|
materialConfig.ui.h5.forEach((item) => {
|
|
4452
4505
|
allMaterials.push({
|
|
4453
4506
|
...item,
|
|
4507
|
+
kind: "standard",
|
|
4454
4508
|
tags: ["ui", "h5", item.frameworkKind, item.libName]
|
|
4455
4509
|
});
|
|
4456
4510
|
});
|
|
@@ -4610,7 +4664,10 @@ function bindAttrToIR(b) {
|
|
|
4610
4664
|
throw new Error("string\u4E0D\u53EF\u4E3Async");
|
|
4611
4665
|
}
|
|
4612
4666
|
if (b.i18nKey && b.value && b.frontend?.i18nInfo?.enabled) {
|
|
4613
|
-
|
|
4667
|
+
const frameworkKind = b.frontend?.frameworkKind;
|
|
4668
|
+
if (!["vue3"].includes(frameworkKind)) {
|
|
4669
|
+
b.type = "dynamic";
|
|
4670
|
+
}
|
|
4614
4671
|
const wrapperExpr = import_nasl_concepts9.CallFunction.from(
|
|
4615
4672
|
{
|
|
4616
4673
|
calleeNamespace: "$i18n",
|
|
@@ -4714,7 +4771,7 @@ function bindEventToAction(b) {
|
|
|
4714
4771
|
kind: "standalone"
|
|
4715
4772
|
};
|
|
4716
4773
|
}
|
|
4717
|
-
var DefaultComponentLibraryName =
|
|
4774
|
+
var DefaultComponentLibraryName = getPredefinedMaterialByTags(["ui", "pc", "react"])?.name;
|
|
4718
4775
|
function getReferencedLibComponent(e) {
|
|
4719
4776
|
const tag = e.tag;
|
|
4720
4777
|
if (tag.startsWith("BS")) {
|
|
@@ -4732,7 +4789,7 @@ function getReferencedLibComponent(e) {
|
|
|
4732
4789
|
if (tag === "Router") {
|
|
4733
4790
|
return { kind: "library", libraryName: "react-router-dom", tag: "Outlet" };
|
|
4734
4791
|
}
|
|
4735
|
-
const libraryName = foundExtension ?
|
|
4792
|
+
const libraryName = foundExtension ? `${foundExtension.name}` : DefaultComponentLibraryName;
|
|
4736
4793
|
return { kind: "library", libraryName, tag };
|
|
4737
4794
|
} else if (tag) {
|
|
4738
4795
|
return { kind: "library", libraryName: DefaultComponentLibraryName, tag };
|
|
@@ -5380,8 +5437,8 @@ var NASLAppIRBuilderPlugin = class {
|
|
|
5380
5437
|
});
|
|
5381
5438
|
logger5.debug({ extensionPackages });
|
|
5382
5439
|
const frameworkKind = frontend.frameworkKind;
|
|
5383
|
-
const
|
|
5384
|
-
return [...extensionPackages,
|
|
5440
|
+
const uiLib = getPredefinedMaterialByTags(["ui", frontend.type, frameworkKind]);
|
|
5441
|
+
return [...extensionPackages, uiLib];
|
|
5385
5442
|
};
|
|
5386
5443
|
var buildConfigs = buildConfigs2, collectPackages = collectPackages2;
|
|
5387
5444
|
config.debug && breakpoint2.genBreakpoints(app);
|
|
@@ -5422,14 +5479,14 @@ var NASLAppIRBuilderPlugin = class {
|
|
|
5422
5479
|
}
|
|
5423
5480
|
enchanceHackForAppPackageInfos(app, commonAppConfig) {
|
|
5424
5481
|
app.loadPackageInfos(getPredefinedMaterialConfig());
|
|
5425
|
-
const
|
|
5426
|
-
|
|
5427
|
-
config.allNodesAPI = commonAppConfig.allNodesAPI;
|
|
5428
|
-
}
|
|
5429
|
-
config.allNodesAPI ??= {};
|
|
5482
|
+
const naslStoreConfig = (0, import_nasl_concepts9.getConfig)();
|
|
5483
|
+
naslStoreConfig.allNodesAPI = commonAppConfig.allNodesAPI || {};
|
|
5430
5484
|
(0, import_nasl_concepts9.initialize)({
|
|
5431
5485
|
getConfig: () => {
|
|
5432
|
-
return
|
|
5486
|
+
return {
|
|
5487
|
+
...commonAppConfig || {},
|
|
5488
|
+
...naslStoreConfig || {}
|
|
5489
|
+
};
|
|
5433
5490
|
}
|
|
5434
5491
|
});
|
|
5435
5492
|
}
|
|
@@ -6750,10 +6807,9 @@ function extractAppLevelFrontendDeps(app) {
|
|
|
6750
6807
|
}
|
|
6751
6808
|
function extractFrontendLevelDeps(frontend) {
|
|
6752
6809
|
const deps = [];
|
|
6753
|
-
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
deps.push(getPredefinedLibConstants().vue3Ui);
|
|
6810
|
+
const uiLib = getPredefinedMaterialByTags(["ui", frontend.type, frontend.frameworkKind]);
|
|
6811
|
+
if (uiLib) {
|
|
6812
|
+
deps.push(uiLib);
|
|
6757
6813
|
}
|
|
6758
6814
|
return deps;
|
|
6759
6815
|
}
|
|
@@ -6926,12 +6982,13 @@ async function downloadDependenciesToLcapModules(feDeps, fs, config) {
|
|
|
6926
6982
|
}
|
|
6927
6983
|
let packageJson = fs.read("/package.json")?.toString();
|
|
6928
6984
|
packageJson = JSON.parse(packageJson);
|
|
6929
|
-
if (!packageJson.
|
|
6930
|
-
packageJson.
|
|
6985
|
+
if (!packageJson.lcap_modules) {
|
|
6986
|
+
packageJson.lcap_modules = {};
|
|
6931
6987
|
}
|
|
6932
6988
|
downloadedDeps.forEach(({ pkgName, targetPath }) => {
|
|
6933
|
-
packageJson.
|
|
6989
|
+
packageJson.lcap_modules[pkgName] = `.${targetPath}`;
|
|
6934
6990
|
});
|
|
6991
|
+
packageJson = setApplicationName(packageJson, config.app?.name || config.app?.id);
|
|
6935
6992
|
fs.write("/package.json", JSON.stringify(packageJson, null, 2));
|
|
6936
6993
|
logger13.info("\u4E0B\u8F7D\u524D\u7AEF\u4F9D\u8D56\u5E93\u5230 lcap_modules \u76EE\u5F55\u5B8C\u6210");
|
|
6937
6994
|
} catch (error) {
|
|
@@ -6940,6 +6997,12 @@ async function downloadDependenciesToLcapModules(feDeps, fs, config) {
|
|
|
6940
6997
|
}
|
|
6941
6998
|
}
|
|
6942
6999
|
}
|
|
7000
|
+
function setApplicationName(packageJson, appName = Date.now().toString()) {
|
|
7001
|
+
if (packageJson && appName) {
|
|
7002
|
+
packageJson.name = appName;
|
|
7003
|
+
}
|
|
7004
|
+
return packageJson;
|
|
7005
|
+
}
|
|
6943
7006
|
|
|
6944
7007
|
// src/plugins/misc/bundler/bundler-config-data-plugin.ts
|
|
6945
7008
|
var logger11 = Logger("BundlerConfigDataPlugin");
|
|
@@ -6951,7 +7014,8 @@ var BundlerConfigDataPlugin = class {
|
|
|
6951
7014
|
const feDeps = [...extractAppLevelFrontendDeps(app), ...extractFrontendLevelDeps(frontend)];
|
|
6952
7015
|
await downloadDependenciesToLcapModules(feDeps, fs, {
|
|
6953
7016
|
STATIC_URL: config.STATIC_URL,
|
|
6954
|
-
frameworkKind
|
|
7017
|
+
frameworkKind,
|
|
7018
|
+
app
|
|
6955
7019
|
});
|
|
6956
7020
|
const orginDependencies = await downloadDependenciesToPackages(feDeps, fs, {
|
|
6957
7021
|
STATIC_URL: config.STATIC_URL
|
|
@@ -6961,13 +7025,12 @@ var BundlerConfigDataPlugin = class {
|
|
|
6961
7025
|
if (target) {
|
|
6962
7026
|
return {
|
|
6963
7027
|
name: dep.name,
|
|
6964
|
-
resolvedTo: `./src/${target}`.replace(/\/index\.js$/, "")
|
|
6965
|
-
scope: dep.kind === "extension" ? "@extension" : void 0
|
|
7028
|
+
resolvedTo: `./src/${target}`.replace(/\/index\.js$/, "")
|
|
6966
7029
|
};
|
|
6967
7030
|
}
|
|
6968
7031
|
return void 0;
|
|
6969
7032
|
}).filter(isNotNil).map((x) => {
|
|
6970
|
-
const name = x.
|
|
7033
|
+
const name = x.name;
|
|
6971
7034
|
return {
|
|
6972
7035
|
pkgName: name,
|
|
6973
7036
|
...x
|
|
@@ -7030,18 +7093,49 @@ var RspackConfigPlugin = class {
|
|
|
7030
7093
|
);
|
|
7031
7094
|
}
|
|
7032
7095
|
rspackConfigSource = rspackConfigSource.replace(`const backendUrl = '';`, `const backendUrl = '${backendUrl}'`).replace(`const publicPath = '';`, `const publicPath = '${publicPath}';`).replace(`sourceMap: false,`, `sourceMap: ${config.env === "dev"},`).replace("alias: {}", `alias: {${aliasMapStr}}`).replace("const isDev = false", `const isDev = ${config.env === "dev"}`);
|
|
7033
|
-
if (config.needCompileViews && config.needCompileViews.length > 0 && config.cacheChunksMapCode) {
|
|
7096
|
+
if (config.env === "dev" && config.needCompileViews && config.needCompileViews.length > 0 && config.cacheChunksMapCode) {
|
|
7034
7097
|
rspackConfigSource = rspackConfigSource.replace("isIncremental: false", "isIncremental: true").replace("chunksMap: ''", `chunksMap: \`${config.cacheChunksMapCode}\``);
|
|
7035
7098
|
}
|
|
7036
7099
|
if (config.isExport) {
|
|
7037
7100
|
rspackConfigSource = rspackConfigSource.replace(/\/\/ LcapPlugin start\s+new LcapPlugin\(\{[\s\S]*?\}\),\s+\/\/ LcapPlugin end/g, "");
|
|
7038
7101
|
}
|
|
7102
|
+
rspackConfigSource = await this.processLoadOnDemand(rspackConfigSource, {
|
|
7103
|
+
app,
|
|
7104
|
+
frontend,
|
|
7105
|
+
config,
|
|
7106
|
+
fs,
|
|
7107
|
+
frameworkKind
|
|
7108
|
+
});
|
|
7039
7109
|
fs.write(
|
|
7040
7110
|
"/rspack.config.js",
|
|
7041
7111
|
rspackConfigSource
|
|
7042
7112
|
);
|
|
7043
7113
|
}
|
|
7044
7114
|
}
|
|
7115
|
+
/**
|
|
7116
|
+
* 处理按需加载
|
|
7117
|
+
* 注意:此功能仅在非dev环境下的vue3框架中可以启用。
|
|
7118
|
+
* @param source 源代码
|
|
7119
|
+
* @param options 选项
|
|
7120
|
+
* @returns 处理后的代码
|
|
7121
|
+
*/
|
|
7122
|
+
async processLoadOnDemand(source, options) {
|
|
7123
|
+
let code = source;
|
|
7124
|
+
const { app, frontend, config, fs, frameworkKind } = options;
|
|
7125
|
+
const { env, feLoadDependenciesOnDemand, isExport } = config;
|
|
7126
|
+
const enablePerformance = feLoadDependenciesOnDemand && (isExport || env !== "dev") && ["vue3"].includes(frameworkKind);
|
|
7127
|
+
if (enablePerformance) {
|
|
7128
|
+
const feDeps = [...extractAppLevelFrontendDeps(app), ...extractFrontendLevelDeps(frontend)];
|
|
7129
|
+
code = code.replaceAll("// swc plugin placeholder", `experimental: {
|
|
7130
|
+
plugins: [
|
|
7131
|
+
['@lcap/swc-plugin-import', require('./scripts/generateSwcImportPluginConfig')([
|
|
7132
|
+
${feDeps.map((dep) => "'" + dep.name + "'").join(",\n")}
|
|
7133
|
+
])]
|
|
7134
|
+
]
|
|
7135
|
+
}`);
|
|
7136
|
+
}
|
|
7137
|
+
return code;
|
|
7138
|
+
}
|
|
7045
7139
|
static install(c) {
|
|
7046
7140
|
c.bind(ServiceMetaKind.FrontendBundlerFileConfig).to(RspackConfigPlugin).inSingletonScope();
|
|
7047
7141
|
return c;
|
|
@@ -7206,7 +7300,7 @@ export function loadAssets(){
|
|
|
7206
7300
|
generateEntry(ir) {
|
|
7207
7301
|
const entryScript = this.microFrontendManager.produceScript(ir);
|
|
7208
7302
|
const publicPathScript = this.microFrontendManager.producePublicPathScript(ir);
|
|
7209
|
-
|
|
7303
|
+
let code = `
|
|
7210
7304
|
export function startApp(){
|
|
7211
7305
|
if(window.LcapMicro){
|
|
7212
7306
|
// \u5DF2\u7ECF\u88AB\u52A0\u8F7D\u4E8E\u5FAE\u524D\u7AEF\u73AF\u5883
|
|
@@ -7217,6 +7311,11 @@ export function loadAssets(){
|
|
|
7217
7311
|
}
|
|
7218
7312
|
}
|
|
7219
7313
|
`;
|
|
7314
|
+
const { env, isExport } = ir.configs.config;
|
|
7315
|
+
if (!isExport && env === "dev") {
|
|
7316
|
+
const autoReloadScript = (init_auto_reload(), __toCommonJS(auto_reload_exports));
|
|
7317
|
+
code += autoReloadScript?.default || autoReloadScript;
|
|
7318
|
+
}
|
|
7220
7319
|
const imports = [
|
|
7221
7320
|
{
|
|
7222
7321
|
from: "../init"
|
|
@@ -7284,23 +7383,28 @@ var VueRouterPlugin = class {
|
|
|
7284
7383
|
}
|
|
7285
7384
|
routeToCode(routes, componentPathManager, config) {
|
|
7286
7385
|
function serializeVueRoute(r, isRoot = false) {
|
|
7287
|
-
const
|
|
7386
|
+
const { accumulativePath, thisLevelPath } = r;
|
|
7387
|
+
const path = isRoot ? accumulativePath : thisLevelPath ?? "/";
|
|
7388
|
+
const basePath = config.basePath;
|
|
7288
7389
|
if (r.kind === "normal") {
|
|
7289
7390
|
const children = r.children?.map((i) => serializeVueRoute(i)).filter(isNotNil) ?? [];
|
|
7290
7391
|
const childrenStr = children.join(",\n");
|
|
7291
7392
|
const componentCode = `component: ${r.elementMangledName ?? r.elementTemplate.identifier}`;
|
|
7292
|
-
return `{path: "${
|
|
7393
|
+
return `{path: "${path}", meta: ${JSON.stringify(
|
|
7293
7394
|
r.meta
|
|
7294
7395
|
)}, children: [${childrenStr}], ${componentCode} }`;
|
|
7295
7396
|
} else if (r.kind === "redirect") {
|
|
7296
|
-
|
|
7297
|
-
|
|
7298
|
-
|
|
7397
|
+
if (["vue3"].includes(config.frameworkKind) && path === "*") {
|
|
7398
|
+
return `{ path: "/:pathMatch(.*)*", redirect: ${JSON.stringify(basePath + r.redirect)} }`;
|
|
7399
|
+
}
|
|
7400
|
+
if (["vue3"].includes(config.frameworkKind) && path === "/") {
|
|
7401
|
+
let result = `{ path: "/", redirect: ${JSON.stringify(basePath + r.redirect)} }`;
|
|
7402
|
+
if (basePath !== "/") {
|
|
7403
|
+
result += `, { path: "${basePath}", redirect: ${JSON.stringify(basePath + r.redirect)} }`;
|
|
7299
7404
|
}
|
|
7300
|
-
return
|
|
7301
|
-
}
|
|
7302
|
-
|
|
7303
|
-
return `{path: "${processedPath}", redirect: ${JSON.stringify(r.redirect)}}`;
|
|
7405
|
+
return result;
|
|
7406
|
+
}
|
|
7407
|
+
return `{ path: "${path}", redirect: to => to.path.replace(/\\/$/, '') + '/' + ${JSON.stringify(r.redirect)} }`;
|
|
7304
7408
|
}
|
|
7305
7409
|
notImplemented(r);
|
|
7306
7410
|
}
|
|
@@ -7389,7 +7493,7 @@ var Vue3EntryBuilderPlugin = class {
|
|
|
7389
7493
|
buildEntry(ir) {
|
|
7390
7494
|
const entryScript = this.microFrontendManager.produceScript(ir);
|
|
7391
7495
|
const publicPathScript = this.microFrontendManager.producePublicPathScript(ir);
|
|
7392
|
-
|
|
7496
|
+
let code = `
|
|
7393
7497
|
if(window.LcapMicro){
|
|
7394
7498
|
// \u5DF2\u7ECF\u88AB\u52A0\u8F7D\u4E8E\u5FAE\u524D\u7AEF\u73AF\u5883
|
|
7395
7499
|
renderApp();
|
|
@@ -7407,6 +7511,11 @@ var Vue3EntryBuilderPlugin = class {
|
|
|
7407
7511
|
from: "./public-path"
|
|
7408
7512
|
} : void 0
|
|
7409
7513
|
].filter(isNotNil);
|
|
7514
|
+
const { env, isExport } = ir.configs.config;
|
|
7515
|
+
if (!isExport && env === "dev") {
|
|
7516
|
+
const autoReloadScript = (init_auto_reload(), __toCommonJS(auto_reload_exports));
|
|
7517
|
+
code += autoReloadScript?.default || autoReloadScript;
|
|
7518
|
+
}
|
|
7410
7519
|
return [
|
|
7411
7520
|
new ReactFileDescription("main.ts", imports, [], [code]),
|
|
7412
7521
|
publicPathScript ? new ReactFileDescription("public-path.ts", [], [], [publicPathScript]) : void 0
|
|
@@ -7432,10 +7541,18 @@ var Vue3LibrariesBuilderPlugin = class {
|
|
|
7432
7541
|
*/
|
|
7433
7542
|
async buildLibrariesImport(ir, config) {
|
|
7434
7543
|
const importArr = [];
|
|
7544
|
+
const exportArr = [];
|
|
7435
7545
|
const standardLib = ir.packages.find((x) => x.kind === "standard");
|
|
7436
7546
|
if (standardLib) {
|
|
7437
|
-
|
|
7438
|
-
|
|
7547
|
+
importArr.push(`import { ConfigProvider, transformKeys, Message } from '${standardLib.name}';`);
|
|
7548
|
+
exportArr.push(`export const LcapStandardUI = window.lcapStandardUI = {
|
|
7549
|
+
ConfigProvider,
|
|
7550
|
+
transformKeys,
|
|
7551
|
+
Message,
|
|
7552
|
+
install: (app) => {
|
|
7553
|
+
app.config.globalProperties.$message = Message;
|
|
7554
|
+
},
|
|
7555
|
+
};`);
|
|
7439
7556
|
const isPackageZipExists = await judgePackageZipExists(standardLib, config.STATIC_URL);
|
|
7440
7557
|
importArr.push(
|
|
7441
7558
|
`import '${standardLib.name}${isPackageZipExists ? "/dist-theme" : ""}/index.css';`
|
|
@@ -7443,17 +7560,30 @@ var Vue3LibrariesBuilderPlugin = class {
|
|
|
7443
7560
|
}
|
|
7444
7561
|
const extensions = ir.packages.filter((x) => x.kind === "extension");
|
|
7445
7562
|
for (const ext of extensions) {
|
|
7446
|
-
const formattedName = kebab2Pascal(ext.name.split("/").at(-1));
|
|
7447
7563
|
const isPackageZipExists = await judgePackageZipExists(ext, config.STATIC_URL);
|
|
7448
|
-
const
|
|
7449
|
-
|
|
7450
|
-
|
|
7564
|
+
const { feLoadDependenciesOnDemand } = config;
|
|
7565
|
+
if (!feLoadDependenciesOnDemand && ext.used) {
|
|
7566
|
+
const formattedName = kebab2Pascal(ext.name.split("/").at(-1));
|
|
7567
|
+
importArr.push(`import { install as ${formattedName}Install } from '${ext.name}';`);
|
|
7568
|
+
exportArr.push(`export const ${formattedName} = {
|
|
7569
|
+
install: ${formattedName}Install || (() => {}),
|
|
7570
|
+
};`);
|
|
7571
|
+
}
|
|
7572
|
+
if (ext.used && ext.hasCss) {
|
|
7451
7573
|
importArr.push(
|
|
7452
|
-
`import '${
|
|
7574
|
+
`import '${ext.name}${isPackageZipExists ? "/dist-theme" : ""}/index.css';`
|
|
7453
7575
|
);
|
|
7454
7576
|
}
|
|
7455
7577
|
}
|
|
7456
|
-
return new ReactFileDescription("libraries.ts", [], [], [importArr.join("\n")]);
|
|
7578
|
+
return new ReactFileDescription("libraries.ts", [], [], [[...importArr, ...exportArr].join("\n")]);
|
|
7579
|
+
}
|
|
7580
|
+
findPackageByNameFromAllNodesAPI(name, allNodesAPI = {}) {
|
|
7581
|
+
for (const key in allNodesAPI) {
|
|
7582
|
+
if (allNodesAPI[key]?.package?.name === name) {
|
|
7583
|
+
return allNodesAPI[key].package;
|
|
7584
|
+
}
|
|
7585
|
+
}
|
|
7586
|
+
return void 0;
|
|
7457
7587
|
}
|
|
7458
7588
|
static install(c) {
|
|
7459
7589
|
c.bind(Vue3LibrariesBuilderPlugin).toSelf();
|
|
@@ -7689,15 +7819,16 @@ var Vue3ApplicationAssemblerPlugin = class {
|
|
|
7689
7819
|
const bizComponents = ir.bizComponents.flatMap((x) => {
|
|
7690
7820
|
return this.vue3CodegenPlugin.genFiles(x, manager);
|
|
7691
7821
|
});
|
|
7692
|
-
let
|
|
7693
|
-
if (!/\/$/.test(
|
|
7694
|
-
|
|
7822
|
+
let basePath = ir.configs.basePlatformConfig.basePath;
|
|
7823
|
+
if (!/\/$/.test(basePath)) {
|
|
7824
|
+
basePath += "/";
|
|
7695
7825
|
}
|
|
7696
|
-
const routesObjects = this.routesExtactor.extractRoute(ir.views,
|
|
7826
|
+
const routesObjects = this.routesExtactor.extractRoute(ir.views, basePath, {
|
|
7697
7827
|
lazy: true
|
|
7698
7828
|
});
|
|
7699
7829
|
const router = this.routerBuilder.routeToCode(routesObjects.routes, manager, {
|
|
7700
|
-
frameworkKind: "vue3"
|
|
7830
|
+
frameworkKind: "vue3",
|
|
7831
|
+
basePath
|
|
7701
7832
|
});
|
|
7702
7833
|
const routerFile = new ReactFileDescription("router.ts", router.imports, [], [router.code]);
|
|
7703
7834
|
const libraries = await this.librariesBuilder.buildLibrariesImport(ir, config);
|
|
@@ -7734,6 +7865,181 @@ Vue3ApplicationAssemblerPlugin = __decorateClass([
|
|
|
7734
7865
|
__decorateParam(9, (0, import_inversify29.inject)(Vue3MetaDataBuilderPlugin))
|
|
7735
7866
|
], Vue3ApplicationAssemblerPlugin);
|
|
7736
7867
|
|
|
7868
|
+
// src/plugins/misc/program-analysis/analyzer-manager-plugin.ts
|
|
7869
|
+
var import_inversify30 = require("inversify");
|
|
7870
|
+
|
|
7871
|
+
// src/plugins/misc/program-analysis/analysis/async-analysis.ts
|
|
7872
|
+
function buildAsyncAnalyzer() {
|
|
7873
|
+
const resultCache = /* @__PURE__ */ new WeakMap();
|
|
7874
|
+
function isSubtreeAsync(node, analyzeFunc = analyze) {
|
|
7875
|
+
let hasAsync = false;
|
|
7876
|
+
node.traverseStrictChildrenWithPruning((n) => {
|
|
7877
|
+
if (n === node) {
|
|
7878
|
+
return false;
|
|
7879
|
+
}
|
|
7880
|
+
if (hasAsync) {
|
|
7881
|
+
return true;
|
|
7882
|
+
} else if (n) {
|
|
7883
|
+
hasAsync = analyzeFunc(n);
|
|
7884
|
+
return hasAsync;
|
|
7885
|
+
}
|
|
7886
|
+
});
|
|
7887
|
+
return hasAsync;
|
|
7888
|
+
}
|
|
7889
|
+
function analyze(node) {
|
|
7890
|
+
if (!node) {
|
|
7891
|
+
return false;
|
|
7892
|
+
}
|
|
7893
|
+
if (resultCache.has(node)) {
|
|
7894
|
+
return resultCache.get(node);
|
|
7895
|
+
}
|
|
7896
|
+
function dispatch(node2) {
|
|
7897
|
+
switch (node2.concept) {
|
|
7898
|
+
case "CallLogic": {
|
|
7899
|
+
const calleeNode = node2.getCallNode();
|
|
7900
|
+
return analyze(calleeNode) || isSubtreeAsync(node2);
|
|
7901
|
+
}
|
|
7902
|
+
case "CallInterface": {
|
|
7903
|
+
return true;
|
|
7904
|
+
}
|
|
7905
|
+
case "CallFunction": {
|
|
7906
|
+
return isSubtreeAsync(node2);
|
|
7907
|
+
}
|
|
7908
|
+
case "Match": {
|
|
7909
|
+
return isSubtreeAsync(node2);
|
|
7910
|
+
}
|
|
7911
|
+
case "Function": {
|
|
7912
|
+
return isSubtreeAsync(node2);
|
|
7913
|
+
}
|
|
7914
|
+
case "JSBlock": {
|
|
7915
|
+
return true;
|
|
7916
|
+
}
|
|
7917
|
+
case "ExternalDestination":
|
|
7918
|
+
case "Destination": {
|
|
7919
|
+
return true;
|
|
7920
|
+
}
|
|
7921
|
+
case "NewStructure":
|
|
7922
|
+
case "NewComposite":
|
|
7923
|
+
case "NewMap":
|
|
7924
|
+
case "NewList": {
|
|
7925
|
+
return isSubtreeAsync(node2);
|
|
7926
|
+
}
|
|
7927
|
+
case "SubLogic": {
|
|
7928
|
+
return true;
|
|
7929
|
+
}
|
|
7930
|
+
case "Logic": {
|
|
7931
|
+
if (node2.likeComponent) {
|
|
7932
|
+
return node2.subLogics?.some(analyze) || isSubtreeAsync(node2);
|
|
7933
|
+
} else {
|
|
7934
|
+
return true;
|
|
7935
|
+
}
|
|
7936
|
+
}
|
|
7937
|
+
case "AnonymousFunction": {
|
|
7938
|
+
return isSubtreeAsync(node2);
|
|
7939
|
+
}
|
|
7940
|
+
case "BindEvent": {
|
|
7941
|
+
return node2.logics?.some(analyze) ?? false;
|
|
7942
|
+
}
|
|
7943
|
+
case "Interface":
|
|
7944
|
+
case "OverriddenLogic": {
|
|
7945
|
+
return true;
|
|
7946
|
+
}
|
|
7947
|
+
default: {
|
|
7948
|
+
return isSubtreeAsync(node2);
|
|
7949
|
+
}
|
|
7950
|
+
}
|
|
7951
|
+
}
|
|
7952
|
+
resultCache.set(node, true);
|
|
7953
|
+
const res = dispatch(node);
|
|
7954
|
+
resultCache.set(node, res);
|
|
7955
|
+
return res;
|
|
7956
|
+
}
|
|
7957
|
+
return {
|
|
7958
|
+
query: (node) => {
|
|
7959
|
+
return { async: analyze(node) };
|
|
7960
|
+
}
|
|
7961
|
+
};
|
|
7962
|
+
}
|
|
7963
|
+
|
|
7964
|
+
// src/plugins/misc/program-analysis/analysis/dep-analysis.ts
|
|
7965
|
+
var import_nasl_concepts12 = require("@lcap/nasl-concepts");
|
|
7966
|
+
function analyzeDeps(ir, config) {
|
|
7967
|
+
const { views, bizComponents, packages } = ir;
|
|
7968
|
+
const deps = {};
|
|
7969
|
+
views.forEach((view) => {
|
|
7970
|
+
const { libs } = (0, import_nasl_concepts12.analyzeDepRef)(view.__raw, config);
|
|
7971
|
+
for (const key in libs) {
|
|
7972
|
+
deps[key] = deps[key] || [];
|
|
7973
|
+
libs[key].forEach((importer) => {
|
|
7974
|
+
if (!deps[key].some((d) => d.key === importer.key)) {
|
|
7975
|
+
deps[key].push(importer);
|
|
7976
|
+
}
|
|
7977
|
+
});
|
|
7978
|
+
}
|
|
7979
|
+
});
|
|
7980
|
+
bizComponents.forEach((component) => {
|
|
7981
|
+
const { libs } = (0, import_nasl_concepts12.analyzeDepRef)(component.__raw, config);
|
|
7982
|
+
for (const key in libs) {
|
|
7983
|
+
deps[key] = deps[key] || [];
|
|
7984
|
+
libs[key].forEach((importer) => {
|
|
7985
|
+
if (!deps[key].some((d) => d.key === importer.key)) {
|
|
7986
|
+
deps[key].push(importer);
|
|
7987
|
+
}
|
|
7988
|
+
});
|
|
7989
|
+
}
|
|
7990
|
+
});
|
|
7991
|
+
packages.forEach((pkg) => {
|
|
7992
|
+
if (deps[pkg.name]) {
|
|
7993
|
+
pkg.used = true;
|
|
7994
|
+
}
|
|
7995
|
+
});
|
|
7996
|
+
}
|
|
7997
|
+
|
|
7998
|
+
// src/plugins/misc/program-analysis/analyzer-manager-plugin.ts
|
|
7999
|
+
var AnalyzerManagerPlugin = class {
|
|
8000
|
+
constructor() {
|
|
8001
|
+
this.options = {
|
|
8002
|
+
depAnalysis: true
|
|
8003
|
+
};
|
|
8004
|
+
}
|
|
8005
|
+
preProcess(app, frontend, config) {
|
|
8006
|
+
const analyzer = buildAsyncAnalyzer();
|
|
8007
|
+
if (this.getOptions().asyncAnalysis) {
|
|
8008
|
+
app.analyzer = analyzer;
|
|
8009
|
+
}
|
|
8010
|
+
return { app, frontend, config };
|
|
8011
|
+
}
|
|
8012
|
+
postProcess(ir, config) {
|
|
8013
|
+
if (this.getOptions().depAnalysis) {
|
|
8014
|
+
analyzeDeps(ir, config);
|
|
8015
|
+
}
|
|
8016
|
+
return ir;
|
|
8017
|
+
}
|
|
8018
|
+
/**
|
|
8019
|
+
* 设置完整的分析选项
|
|
8020
|
+
* @param options
|
|
8021
|
+
*/
|
|
8022
|
+
setOptions(options) {
|
|
8023
|
+
this.options = options;
|
|
8024
|
+
}
|
|
8025
|
+
/**
|
|
8026
|
+
* 获取分析选项
|
|
8027
|
+
* @returns 分析选项
|
|
8028
|
+
*/
|
|
8029
|
+
getOptions() {
|
|
8030
|
+
return this.options;
|
|
8031
|
+
}
|
|
8032
|
+
static install(c) {
|
|
8033
|
+
c.bind(ServiceMetaKind.IRPreProcesser).to(AnalyzerManagerPlugin);
|
|
8034
|
+
c.bind(ServiceMetaKind.IRPostProcesser).to(AnalyzerManagerPlugin);
|
|
8035
|
+
c.bind(ServiceMetaKind.AnalyzerManager).to(AnalyzerManagerPlugin);
|
|
8036
|
+
return c;
|
|
8037
|
+
}
|
|
8038
|
+
};
|
|
8039
|
+
AnalyzerManagerPlugin = __decorateClass([
|
|
8040
|
+
(0, import_inversify30.injectable)()
|
|
8041
|
+
], AnalyzerManagerPlugin);
|
|
8042
|
+
|
|
7737
8043
|
// src/plugins/vue/vue3/vue3-preset-plugin.ts
|
|
7738
8044
|
var logger12 = Logger("Vue3PresetPlugin");
|
|
7739
8045
|
var Vue3PresetPlugin = class {
|
|
@@ -7750,6 +8056,30 @@ var Vue3PresetPlugin = class {
|
|
|
7750
8056
|
const app = deserializeAppWhileKeepTypeAnnotation(appJson);
|
|
7751
8057
|
const frontend = app.findNodeByPath(instruction.frontend.nodePath);
|
|
7752
8058
|
const ir = this.irBuilder.buildIR(app, frontend, instruction.config);
|
|
8059
|
+
const needCompileViews = instruction.config?.needCompileViews ?? [];
|
|
8060
|
+
const isIncremental = needCompileViews.length > 0;
|
|
8061
|
+
if (isIncremental) {
|
|
8062
|
+
const filterChildComponents = (view, needCompileViews2) => {
|
|
8063
|
+
if (!view.childComponents?.length) {
|
|
8064
|
+
return;
|
|
8065
|
+
}
|
|
8066
|
+
view.childComponents = view.childComponents.filter((child) => {
|
|
8067
|
+
if (needCompileViews2.includes(child.__raw.nodePath)) {
|
|
8068
|
+
filterChildComponents(child, needCompileViews2);
|
|
8069
|
+
return true;
|
|
8070
|
+
}
|
|
8071
|
+
return false;
|
|
8072
|
+
});
|
|
8073
|
+
};
|
|
8074
|
+
ir.views = ir.views.filter((view) => {
|
|
8075
|
+
if (needCompileViews.includes(view.__raw.nodePath)) {
|
|
8076
|
+
filterChildComponents(view, needCompileViews);
|
|
8077
|
+
return true;
|
|
8078
|
+
}
|
|
8079
|
+
return false;
|
|
8080
|
+
});
|
|
8081
|
+
ir.bizComponents = [];
|
|
8082
|
+
}
|
|
7753
8083
|
const assembledApplication = await this.applicationAssembler.assemble(ir, instruction.config);
|
|
7754
8084
|
const finalizedFiles = await this.projectOrganizer.organize({
|
|
7755
8085
|
baseDir: instruction.baseDir,
|
|
@@ -7785,6 +8115,7 @@ var Vue3PresetPlugin = class {
|
|
|
7785
8115
|
c = VueRouterPlugin.install(c);
|
|
7786
8116
|
c.bind(ServiceMetaKind.ProjectOrganizer).to(ProjectOrganizerPlugin);
|
|
7787
8117
|
c.bind(ServiceMetaKind.FileSystemProvider).to(FileSystemPlugin).inSingletonScope();
|
|
8118
|
+
c = AnalyzerManagerPlugin.install(c);
|
|
7788
8119
|
c = BundlerConfigDataPlugin.install(c);
|
|
7789
8120
|
c = RspackConfigPlugin.install(c);
|
|
7790
8121
|
c = FrontendBundlerConfigPlugin.install(c);
|
|
@@ -7803,20 +8134,20 @@ var Vue3PresetPlugin = class {
|
|
|
7803
8134
|
}
|
|
7804
8135
|
};
|
|
7805
8136
|
Vue3PresetPlugin = __decorateClass([
|
|
7806
|
-
(0,
|
|
7807
|
-
__decorateParam(0, (0,
|
|
7808
|
-
__decorateParam(1, (0,
|
|
7809
|
-
__decorateParam(2, (0,
|
|
7810
|
-
__decorateParam(3, (0,
|
|
7811
|
-
__decorateParam(4, (0,
|
|
8137
|
+
(0, import_inversify31.injectable)(),
|
|
8138
|
+
__decorateParam(0, (0, import_inversify31.inject)(ServiceMetaKind.IRBuilder)),
|
|
8139
|
+
__decorateParam(1, (0, import_inversify31.inject)(ServiceMetaKind.FileSystemProvider)),
|
|
8140
|
+
__decorateParam(2, (0, import_inversify31.inject)(NpmPackageJSONManagerPlugin)),
|
|
8141
|
+
__decorateParam(3, (0, import_inversify31.inject)(ServiceMetaKind.ProjectOrganizer)),
|
|
8142
|
+
__decorateParam(4, (0, import_inversify31.inject)(Vue3ApplicationAssemblerPlugin))
|
|
7812
8143
|
], Vue3PresetPlugin);
|
|
7813
8144
|
|
|
7814
8145
|
// src/default-container.ts
|
|
7815
8146
|
function makeDefaultContainer(kind = "react") {
|
|
7816
8147
|
if (kind === "react") {
|
|
7817
|
-
return ReactPresetPlugin.install(new
|
|
8148
|
+
return ReactPresetPlugin.install(new import_inversify32.Container());
|
|
7818
8149
|
} else if (kind === "vue3") {
|
|
7819
|
-
return Vue3PresetPlugin.install(new
|
|
8150
|
+
return Vue3PresetPlugin.install(new import_inversify32.Container());
|
|
7820
8151
|
} else {
|
|
7821
8152
|
throw new Error(`\u672A\u5B9E\u73B0${kind}\u7684\u9ED8\u8BA4\u5BB9\u5668`);
|
|
7822
8153
|
}
|
|
@@ -7831,7 +8162,7 @@ async function translateNASLToApp(app, frontend, config, baseDir = "./out", cont
|
|
|
7831
8162
|
if (needCompileViews?.length > 0) {
|
|
7832
8163
|
let traverseChildren2 = function(view, callback) {
|
|
7833
8164
|
if (view.children?.length > 0) {
|
|
7834
|
-
view.children.forEach((childView) => {
|
|
8165
|
+
[...view.children].forEach((childView) => {
|
|
7835
8166
|
const deep = callback(childView);
|
|
7836
8167
|
if (deep) {
|
|
7837
8168
|
traverseChildren2(childView, callback);
|
|
@@ -7841,9 +8172,10 @@ async function translateNASLToApp(app, frontend, config, baseDir = "./out", cont
|
|
|
7841
8172
|
};
|
|
7842
8173
|
var traverseChildren = traverseChildren2;
|
|
7843
8174
|
logger13.info("\u5F00\u59CB\u6309\u9700\u7FFB\u8BD1\u9875\u9762");
|
|
7844
|
-
frontend.views.forEach((view) => {
|
|
8175
|
+
[...frontend.views].forEach((view) => {
|
|
7845
8176
|
if (!needCompileViews.includes(view.nodePath)) {
|
|
7846
8177
|
view.delete();
|
|
8178
|
+
console.log(`\u5220\u9664\u9875\u9762 ${view.nodePath}\uFF0C\u56E0\u4E3A\u5B83\u4E0D\u5728 needCompileViews \u4E2D`);
|
|
7847
8179
|
} else {
|
|
7848
8180
|
traverseChildren2(view, (childView) => {
|
|
7849
8181
|
if (!needCompileViews.includes(childView.nodePath)) {
|
|
@@ -7952,7 +8284,11 @@ async function compileAsProject(app, frontend, config, container) {
|
|
|
7952
8284
|
logger13.info("\u8FDC\u7A0B\u52A0\u8F7D\u6A21\u677F\u6210\u529F");
|
|
7953
8285
|
const files = res.files;
|
|
7954
8286
|
Object.entries(files).forEach(([k, v]) => {
|
|
7955
|
-
|
|
8287
|
+
if (typeof v.code === "string") {
|
|
8288
|
+
fs.write(k, v.code);
|
|
8289
|
+
} else if (v.code?.type === "Buffer") {
|
|
8290
|
+
fs.write(k, Buffer.from(v.code.data));
|
|
8291
|
+
}
|
|
7956
8292
|
});
|
|
7957
8293
|
} catch (error) {
|
|
7958
8294
|
throw new Error(`\u8FDC\u7A0B\u52A0\u8F7D\u6A21\u677F\u5931\u8D25`);
|
|
@@ -8011,137 +8347,6 @@ async function compileNASLToReactDist(app, frontend, config, http) {
|
|
|
8011
8347
|
}
|
|
8012
8348
|
}
|
|
8013
8349
|
|
|
8014
|
-
// src/plugins/misc/program-analysis/analyzer-manager-plugin.ts
|
|
8015
|
-
var import_inversify32 = require("inversify");
|
|
8016
|
-
|
|
8017
|
-
// src/plugins/misc/program-analysis/analysis/async-analysis.ts
|
|
8018
|
-
function buildAsyncAnalyzer() {
|
|
8019
|
-
const resultCache = /* @__PURE__ */ new WeakMap();
|
|
8020
|
-
function isSubtreeAsync(node, analyzeFunc = analyze) {
|
|
8021
|
-
let hasAsync = false;
|
|
8022
|
-
node.traverseStrictChildrenWithPruning((n) => {
|
|
8023
|
-
if (n === node) {
|
|
8024
|
-
return false;
|
|
8025
|
-
}
|
|
8026
|
-
if (hasAsync) {
|
|
8027
|
-
return true;
|
|
8028
|
-
} else if (n) {
|
|
8029
|
-
hasAsync = analyzeFunc(n);
|
|
8030
|
-
return hasAsync;
|
|
8031
|
-
}
|
|
8032
|
-
});
|
|
8033
|
-
return hasAsync;
|
|
8034
|
-
}
|
|
8035
|
-
function analyze(node) {
|
|
8036
|
-
if (!node) {
|
|
8037
|
-
return false;
|
|
8038
|
-
}
|
|
8039
|
-
if (resultCache.has(node)) {
|
|
8040
|
-
return resultCache.get(node);
|
|
8041
|
-
}
|
|
8042
|
-
function dispatch(node2) {
|
|
8043
|
-
switch (node2.concept) {
|
|
8044
|
-
case "CallLogic": {
|
|
8045
|
-
const calleeNode = node2.getCallNode();
|
|
8046
|
-
return analyze(calleeNode) || isSubtreeAsync(node2);
|
|
8047
|
-
}
|
|
8048
|
-
case "CallInterface": {
|
|
8049
|
-
return true;
|
|
8050
|
-
}
|
|
8051
|
-
case "CallFunction": {
|
|
8052
|
-
return isSubtreeAsync(node2);
|
|
8053
|
-
}
|
|
8054
|
-
case "Match": {
|
|
8055
|
-
return isSubtreeAsync(node2);
|
|
8056
|
-
}
|
|
8057
|
-
case "Function": {
|
|
8058
|
-
return isSubtreeAsync(node2);
|
|
8059
|
-
}
|
|
8060
|
-
case "JSBlock": {
|
|
8061
|
-
return true;
|
|
8062
|
-
}
|
|
8063
|
-
case "ExternalDestination":
|
|
8064
|
-
case "Destination": {
|
|
8065
|
-
return true;
|
|
8066
|
-
}
|
|
8067
|
-
case "NewStructure":
|
|
8068
|
-
case "NewComposite":
|
|
8069
|
-
case "NewMap":
|
|
8070
|
-
case "NewList": {
|
|
8071
|
-
return isSubtreeAsync(node2);
|
|
8072
|
-
}
|
|
8073
|
-
case "SubLogic": {
|
|
8074
|
-
return true;
|
|
8075
|
-
}
|
|
8076
|
-
case "Logic": {
|
|
8077
|
-
if (node2.likeComponent) {
|
|
8078
|
-
return node2.subLogics?.some(analyze) || isSubtreeAsync(node2);
|
|
8079
|
-
} else {
|
|
8080
|
-
return true;
|
|
8081
|
-
}
|
|
8082
|
-
}
|
|
8083
|
-
case "AnonymousFunction": {
|
|
8084
|
-
return isSubtreeAsync(node2);
|
|
8085
|
-
}
|
|
8086
|
-
case "BindEvent": {
|
|
8087
|
-
return node2.logics?.some(analyze) ?? false;
|
|
8088
|
-
}
|
|
8089
|
-
case "Interface":
|
|
8090
|
-
case "OverriddenLogic": {
|
|
8091
|
-
return true;
|
|
8092
|
-
}
|
|
8093
|
-
default: {
|
|
8094
|
-
return isSubtreeAsync(node2);
|
|
8095
|
-
}
|
|
8096
|
-
}
|
|
8097
|
-
}
|
|
8098
|
-
resultCache.set(node, true);
|
|
8099
|
-
const res = dispatch(node);
|
|
8100
|
-
resultCache.set(node, res);
|
|
8101
|
-
return res;
|
|
8102
|
-
}
|
|
8103
|
-
return {
|
|
8104
|
-
query: (node) => {
|
|
8105
|
-
return { async: analyze(node) };
|
|
8106
|
-
}
|
|
8107
|
-
};
|
|
8108
|
-
}
|
|
8109
|
-
|
|
8110
|
-
// src/plugins/misc/program-analysis/analyzer-manager-plugin.ts
|
|
8111
|
-
var AnalyzerManagerPlugin = class {
|
|
8112
|
-
constructor() {
|
|
8113
|
-
this.options = {};
|
|
8114
|
-
}
|
|
8115
|
-
preProcess(app, frontend, config) {
|
|
8116
|
-
const analyzer = buildAsyncAnalyzer();
|
|
8117
|
-
if (this.getOptions().asyncAnalysis) {
|
|
8118
|
-
app.analyzer = analyzer;
|
|
8119
|
-
}
|
|
8120
|
-
return { app, frontend, config };
|
|
8121
|
-
}
|
|
8122
|
-
/**
|
|
8123
|
-
* 设置完整的分析选项
|
|
8124
|
-
* @param options
|
|
8125
|
-
*/
|
|
8126
|
-
setOptions(options) {
|
|
8127
|
-
this.options = options;
|
|
8128
|
-
}
|
|
8129
|
-
/**
|
|
8130
|
-
* 获取分析选项
|
|
8131
|
-
* @returns 分析选项
|
|
8132
|
-
*/
|
|
8133
|
-
getOptions() {
|
|
8134
|
-
return this.options;
|
|
8135
|
-
}
|
|
8136
|
-
static install(c) {
|
|
8137
|
-
c.bind(ServiceMetaKind.IRPreProcesser).to(AnalyzerManagerPlugin);
|
|
8138
|
-
c.bind(ServiceMetaKind.AnalyzerManager).to(AnalyzerManagerPlugin);
|
|
8139
|
-
}
|
|
8140
|
-
};
|
|
8141
|
-
AnalyzerManagerPlugin = __decorateClass([
|
|
8142
|
-
(0, import_inversify32.injectable)()
|
|
8143
|
-
], AnalyzerManagerPlugin);
|
|
8144
|
-
|
|
8145
8350
|
// src/plugins/misc/name-mangler/name-mangler-manager-plugin.ts
|
|
8146
8351
|
var import_inversify33 = require("inversify");
|
|
8147
8352
|
|