@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.mjs
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __esm = (fn, res) => function __init() {
|
|
6
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
7
|
+
};
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
3
21
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
22
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
23
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
@@ -11,16 +29,85 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
11
29
|
};
|
|
12
30
|
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
13
31
|
|
|
32
|
+
// src/plugins/templates/auto-reload.js
|
|
33
|
+
var auto_reload_exports = {};
|
|
34
|
+
__export(auto_reload_exports, {
|
|
35
|
+
default: () => auto_reload_default
|
|
36
|
+
});
|
|
37
|
+
var auto_reload_default;
|
|
38
|
+
var init_auto_reload = __esm({
|
|
39
|
+
"src/plugins/templates/auto-reload.js"() {
|
|
40
|
+
"use strict";
|
|
41
|
+
auto_reload_default = `
|
|
42
|
+
const dom = document.createElement('div');
|
|
43
|
+
dom.classList = "lcap-deploy-loading-container";
|
|
44
|
+
dom.style.display = 'none';
|
|
45
|
+
dom.innerHTML = "<div class='lcap-deploy-loading-icon'></div><div>\u6B63\u5728\u66F4\u65B0\u6700\u65B0\u53D1\u5E03\u5185\u5BB9...</div>";
|
|
46
|
+
document.getElementsByTagName('body')[0].appendChild(dom);
|
|
47
|
+
|
|
48
|
+
const style = document.createElement('style');
|
|
49
|
+
style.innerHTML = \`.lcap-deploy-loading-container {
|
|
50
|
+
width: 208px;
|
|
51
|
+
height: 40px;
|
|
52
|
+
background: rgba(48, 48, 48, 0.8);
|
|
53
|
+
box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.1);
|
|
54
|
+
border-radius: 4px;
|
|
55
|
+
position: fixed;
|
|
56
|
+
top: 120px;
|
|
57
|
+
left: 50%;
|
|
58
|
+
margin-left: -104px;
|
|
59
|
+
color: #FFFFFF;
|
|
60
|
+
font-size: 14px;
|
|
61
|
+
justify-content: center;
|
|
62
|
+
align-items: center;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.lcap-deploy-loading-icon{
|
|
66
|
+
width: 12px;
|
|
67
|
+
height: 12px;
|
|
68
|
+
margin-right: 10px;
|
|
69
|
+
animation: loading-animation 0.8s infinite linear;
|
|
70
|
+
border: 2px solid #f3f3f3;
|
|
71
|
+
border-top: 2px solid rgb(109, 108, 108);
|
|
72
|
+
border-right: 2px solid rgb(109, 108, 108);
|
|
73
|
+
border-bottom: 2px solid rgb(109, 108, 108);
|
|
74
|
+
border-radius: 50%;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@keyframes loading-animation{
|
|
78
|
+
0% {
|
|
79
|
+
transform: rotate(0deg);
|
|
80
|
+
}
|
|
81
|
+
100% {
|
|
82
|
+
transform: rotate(360deg);
|
|
83
|
+
}
|
|
84
|
+
}\`;
|
|
85
|
+
document.getElementsByTagName('body')[0].appendChild(style);
|
|
86
|
+
|
|
87
|
+
window.addEventListener('message', function (e) {
|
|
88
|
+
if(e.data ==="release-start"){
|
|
89
|
+
document.querySelector(".lcap-deploy-loading-container").style.display ="flex"
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if(e.data==="release-end"){
|
|
93
|
+
document.querySelector(".lcap-deploy-loading-container").style.display ="none"
|
|
94
|
+
window.location.reload();
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
`;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
14
101
|
// src/compile.ts
|
|
15
102
|
import axios2 from "axios";
|
|
16
103
|
import { trimStart } from "lodash";
|
|
17
104
|
|
|
18
105
|
// src/default-container.ts
|
|
19
|
-
import { Container as
|
|
106
|
+
import { Container as Container21 } from "inversify";
|
|
20
107
|
|
|
21
108
|
// src/plugins/vue/vue3/vue3-preset-plugin.ts
|
|
22
109
|
import "@abraham/reflection";
|
|
23
|
-
import { inject as inject15, injectable as
|
|
110
|
+
import { inject as inject15, injectable as injectable31 } from "inversify";
|
|
24
111
|
|
|
25
112
|
// src/service-metakind.ts
|
|
26
113
|
var ServiceMetaKind = {
|
|
@@ -1266,8 +1353,8 @@ var reactComponentLibHackPlugin = makePlugin({
|
|
|
1266
1353
|
}
|
|
1267
1354
|
|
|
1268
1355
|
Object.assign(utils, {
|
|
1269
|
-
jsonSerialize: JSON.stringify,
|
|
1270
|
-
jsonDeserialize: JSON.parse,
|
|
1356
|
+
jsonSerialize: utils.JsonSerialize || JSON.stringify,
|
|
1357
|
+
jsonDeserialize: utils.JsonDeserialize || JSON.parse,
|
|
1271
1358
|
});
|
|
1272
1359
|
|
|
1273
1360
|
const logging = {
|
|
@@ -1396,6 +1483,7 @@ import {
|
|
|
1396
1483
|
isUnparsed,
|
|
1397
1484
|
isValidationRule,
|
|
1398
1485
|
isVariable,
|
|
1486
|
+
isVariadicExpression,
|
|
1399
1487
|
isWhileStatement
|
|
1400
1488
|
} from "@lcap/nasl-concepts/asserts";
|
|
1401
1489
|
import { transfromMetadataType, transformUnionTypeAnnotation } from "@lcap/nasl-concepts/service";
|
|
@@ -2585,6 +2673,9 @@ query: {`;
|
|
|
2585
2673
|
s2.right,
|
|
2586
2674
|
callbackBag
|
|
2587
2675
|
)}`;
|
|
2676
|
+
} else if (isVariadicExpression(s2)) {
|
|
2677
|
+
const expressions = s2.expressions.map((exp) => getRuntimeStr(exp, callbackBag));
|
|
2678
|
+
return expressions.join(s2.operator);
|
|
2588
2679
|
} else if (isMatchCase(s2)) {
|
|
2589
2680
|
const p = s2.parentNode;
|
|
2590
2681
|
if (!isMatch(p)) {
|
|
@@ -4125,7 +4216,7 @@ var ReactCodegenPlugin = class {
|
|
|
4125
4216
|
const exts = packages.filter((x) => x.kind === "extension");
|
|
4126
4217
|
const imports = exts.map((ext) => {
|
|
4127
4218
|
return {
|
|
4128
|
-
from:
|
|
4219
|
+
from: `${ext.name}`,
|
|
4129
4220
|
import: `* as ${kebab2Pascal(ext.name)}`
|
|
4130
4221
|
};
|
|
4131
4222
|
}).filter(isNotNil);
|
|
@@ -4416,7 +4507,7 @@ var materials = {
|
|
|
4416
4507
|
frameworkVersion: "vue@3.5.13",
|
|
4417
4508
|
name: "@lcap/vant",
|
|
4418
4509
|
libName: "LcapVant",
|
|
4419
|
-
version: "1.0.0
|
|
4510
|
+
version: "1.0.0"
|
|
4420
4511
|
}
|
|
4421
4512
|
]
|
|
4422
4513
|
},
|
|
@@ -4439,29 +4530,6 @@ var coreVersion = materials.framework.version;
|
|
|
4439
4530
|
function getPredefinedMaterialConfig() {
|
|
4440
4531
|
return materials;
|
|
4441
4532
|
}
|
|
4442
|
-
function getPredefinedLibConstants() {
|
|
4443
|
-
if (!reactUi || !vue3Ui) {
|
|
4444
|
-
throw new Error("not found");
|
|
4445
|
-
}
|
|
4446
|
-
if (reactUi.name !== "@lcap/pc-react-ui") {
|
|
4447
|
-
throw new Error("cannot find @lcap/pc-react-ui in material.config.js");
|
|
4448
|
-
}
|
|
4449
|
-
return {
|
|
4450
|
-
reactUI: {
|
|
4451
|
-
kind: "standard",
|
|
4452
|
-
name: reactUi.name,
|
|
4453
|
-
version: reactUi.version
|
|
4454
|
-
},
|
|
4455
|
-
vue3Ui: {
|
|
4456
|
-
kind: "standard",
|
|
4457
|
-
name: vue3Ui.name,
|
|
4458
|
-
version: vue3Ui.version
|
|
4459
|
-
},
|
|
4460
|
-
basicTemplate: {
|
|
4461
|
-
version: coreVersion
|
|
4462
|
-
}
|
|
4463
|
-
};
|
|
4464
|
-
}
|
|
4465
4533
|
var getPredefinedMaterialByTags = (() => {
|
|
4466
4534
|
const materialConfig = getPredefinedMaterialConfig();
|
|
4467
4535
|
let allMaterials = [];
|
|
@@ -4485,12 +4553,14 @@ var getPredefinedMaterialByTags = (() => {
|
|
|
4485
4553
|
materialConfig.ui.pc.forEach((item) => {
|
|
4486
4554
|
allMaterials.push({
|
|
4487
4555
|
...item,
|
|
4556
|
+
kind: "standard",
|
|
4488
4557
|
tags: ["ui", "pc", item.frameworkKind, item.libName]
|
|
4489
4558
|
});
|
|
4490
4559
|
});
|
|
4491
4560
|
materialConfig.ui.h5.forEach((item) => {
|
|
4492
4561
|
allMaterials.push({
|
|
4493
4562
|
...item,
|
|
4563
|
+
kind: "standard",
|
|
4494
4564
|
tags: ["ui", "h5", item.frameworkKind, item.libName]
|
|
4495
4565
|
});
|
|
4496
4566
|
});
|
|
@@ -4650,7 +4720,10 @@ function bindAttrToIR(b) {
|
|
|
4650
4720
|
throw new Error("string\u4E0D\u53EF\u4E3Async");
|
|
4651
4721
|
}
|
|
4652
4722
|
if (b.i18nKey && b.value && b.frontend?.i18nInfo?.enabled) {
|
|
4653
|
-
|
|
4723
|
+
const frameworkKind = b.frontend?.frameworkKind;
|
|
4724
|
+
if (!["vue3"].includes(frameworkKind)) {
|
|
4725
|
+
b.type = "dynamic";
|
|
4726
|
+
}
|
|
4654
4727
|
const wrapperExpr = CallFunction4.from(
|
|
4655
4728
|
{
|
|
4656
4729
|
calleeNamespace: "$i18n",
|
|
@@ -4754,7 +4827,7 @@ function bindEventToAction(b) {
|
|
|
4754
4827
|
kind: "standalone"
|
|
4755
4828
|
};
|
|
4756
4829
|
}
|
|
4757
|
-
var DefaultComponentLibraryName =
|
|
4830
|
+
var DefaultComponentLibraryName = getPredefinedMaterialByTags(["ui", "pc", "react"])?.name;
|
|
4758
4831
|
function getReferencedLibComponent(e) {
|
|
4759
4832
|
const tag = e.tag;
|
|
4760
4833
|
if (tag.startsWith("BS")) {
|
|
@@ -4772,7 +4845,7 @@ function getReferencedLibComponent(e) {
|
|
|
4772
4845
|
if (tag === "Router") {
|
|
4773
4846
|
return { kind: "library", libraryName: "react-router-dom", tag: "Outlet" };
|
|
4774
4847
|
}
|
|
4775
|
-
const libraryName = foundExtension ?
|
|
4848
|
+
const libraryName = foundExtension ? `${foundExtension.name}` : DefaultComponentLibraryName;
|
|
4776
4849
|
return { kind: "library", libraryName, tag };
|
|
4777
4850
|
} else if (tag) {
|
|
4778
4851
|
return { kind: "library", libraryName: DefaultComponentLibraryName, tag };
|
|
@@ -5420,8 +5493,8 @@ var NASLAppIRBuilderPlugin = class {
|
|
|
5420
5493
|
});
|
|
5421
5494
|
logger5.debug({ extensionPackages });
|
|
5422
5495
|
const frameworkKind = frontend.frameworkKind;
|
|
5423
|
-
const
|
|
5424
|
-
return [...extensionPackages,
|
|
5496
|
+
const uiLib = getPredefinedMaterialByTags(["ui", frontend.type, frameworkKind]);
|
|
5497
|
+
return [...extensionPackages, uiLib];
|
|
5425
5498
|
};
|
|
5426
5499
|
var buildConfigs = buildConfigs2, collectPackages = collectPackages2;
|
|
5427
5500
|
config.debug && breakpoint2.genBreakpoints(app);
|
|
@@ -5462,14 +5535,14 @@ var NASLAppIRBuilderPlugin = class {
|
|
|
5462
5535
|
}
|
|
5463
5536
|
enchanceHackForAppPackageInfos(app, commonAppConfig) {
|
|
5464
5537
|
app.loadPackageInfos(getPredefinedMaterialConfig());
|
|
5465
|
-
const
|
|
5466
|
-
|
|
5467
|
-
config.allNodesAPI = commonAppConfig.allNodesAPI;
|
|
5468
|
-
}
|
|
5469
|
-
config.allNodesAPI ??= {};
|
|
5538
|
+
const naslStoreConfig = getConfig();
|
|
5539
|
+
naslStoreConfig.allNodesAPI = commonAppConfig.allNodesAPI || {};
|
|
5470
5540
|
initialize({
|
|
5471
5541
|
getConfig: () => {
|
|
5472
|
-
return
|
|
5542
|
+
return {
|
|
5543
|
+
...commonAppConfig || {},
|
|
5544
|
+
...naslStoreConfig || {}
|
|
5545
|
+
};
|
|
5473
5546
|
}
|
|
5474
5547
|
});
|
|
5475
5548
|
}
|
|
@@ -6790,10 +6863,9 @@ function extractAppLevelFrontendDeps(app) {
|
|
|
6790
6863
|
}
|
|
6791
6864
|
function extractFrontendLevelDeps(frontend) {
|
|
6792
6865
|
const deps = [];
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
deps.push(getPredefinedLibConstants().vue3Ui);
|
|
6866
|
+
const uiLib = getPredefinedMaterialByTags(["ui", frontend.type, frontend.frameworkKind]);
|
|
6867
|
+
if (uiLib) {
|
|
6868
|
+
deps.push(uiLib);
|
|
6797
6869
|
}
|
|
6798
6870
|
return deps;
|
|
6799
6871
|
}
|
|
@@ -6966,12 +7038,13 @@ async function downloadDependenciesToLcapModules(feDeps, fs, config) {
|
|
|
6966
7038
|
}
|
|
6967
7039
|
let packageJson = fs.read("/package.json")?.toString();
|
|
6968
7040
|
packageJson = JSON.parse(packageJson);
|
|
6969
|
-
if (!packageJson.
|
|
6970
|
-
packageJson.
|
|
7041
|
+
if (!packageJson.lcap_modules) {
|
|
7042
|
+
packageJson.lcap_modules = {};
|
|
6971
7043
|
}
|
|
6972
7044
|
downloadedDeps.forEach(({ pkgName, targetPath }) => {
|
|
6973
|
-
packageJson.
|
|
7045
|
+
packageJson.lcap_modules[pkgName] = `.${targetPath}`;
|
|
6974
7046
|
});
|
|
7047
|
+
packageJson = setApplicationName(packageJson, config.app?.name || config.app?.id);
|
|
6975
7048
|
fs.write("/package.json", JSON.stringify(packageJson, null, 2));
|
|
6976
7049
|
logger13.info("\u4E0B\u8F7D\u524D\u7AEF\u4F9D\u8D56\u5E93\u5230 lcap_modules \u76EE\u5F55\u5B8C\u6210");
|
|
6977
7050
|
} catch (error) {
|
|
@@ -6980,6 +7053,12 @@ async function downloadDependenciesToLcapModules(feDeps, fs, config) {
|
|
|
6980
7053
|
}
|
|
6981
7054
|
}
|
|
6982
7055
|
}
|
|
7056
|
+
function setApplicationName(packageJson, appName = Date.now().toString()) {
|
|
7057
|
+
if (packageJson && appName) {
|
|
7058
|
+
packageJson.name = appName;
|
|
7059
|
+
}
|
|
7060
|
+
return packageJson;
|
|
7061
|
+
}
|
|
6983
7062
|
|
|
6984
7063
|
// src/plugins/misc/bundler/bundler-config-data-plugin.ts
|
|
6985
7064
|
var logger11 = Logger("BundlerConfigDataPlugin");
|
|
@@ -6991,7 +7070,8 @@ var BundlerConfigDataPlugin = class {
|
|
|
6991
7070
|
const feDeps = [...extractAppLevelFrontendDeps(app), ...extractFrontendLevelDeps(frontend)];
|
|
6992
7071
|
await downloadDependenciesToLcapModules(feDeps, fs, {
|
|
6993
7072
|
STATIC_URL: config.STATIC_URL,
|
|
6994
|
-
frameworkKind
|
|
7073
|
+
frameworkKind,
|
|
7074
|
+
app
|
|
6995
7075
|
});
|
|
6996
7076
|
const orginDependencies = await downloadDependenciesToPackages(feDeps, fs, {
|
|
6997
7077
|
STATIC_URL: config.STATIC_URL
|
|
@@ -7001,13 +7081,12 @@ var BundlerConfigDataPlugin = class {
|
|
|
7001
7081
|
if (target) {
|
|
7002
7082
|
return {
|
|
7003
7083
|
name: dep.name,
|
|
7004
|
-
resolvedTo: `./src/${target}`.replace(/\/index\.js$/, "")
|
|
7005
|
-
scope: dep.kind === "extension" ? "@extension" : void 0
|
|
7084
|
+
resolvedTo: `./src/${target}`.replace(/\/index\.js$/, "")
|
|
7006
7085
|
};
|
|
7007
7086
|
}
|
|
7008
7087
|
return void 0;
|
|
7009
7088
|
}).filter(isNotNil).map((x) => {
|
|
7010
|
-
const name = x.
|
|
7089
|
+
const name = x.name;
|
|
7011
7090
|
return {
|
|
7012
7091
|
pkgName: name,
|
|
7013
7092
|
...x
|
|
@@ -7070,18 +7149,49 @@ var RspackConfigPlugin = class {
|
|
|
7070
7149
|
);
|
|
7071
7150
|
}
|
|
7072
7151
|
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"}`);
|
|
7073
|
-
if (config.needCompileViews && config.needCompileViews.length > 0 && config.cacheChunksMapCode) {
|
|
7152
|
+
if (config.env === "dev" && config.needCompileViews && config.needCompileViews.length > 0 && config.cacheChunksMapCode) {
|
|
7074
7153
|
rspackConfigSource = rspackConfigSource.replace("isIncremental: false", "isIncremental: true").replace("chunksMap: ''", `chunksMap: \`${config.cacheChunksMapCode}\``);
|
|
7075
7154
|
}
|
|
7076
7155
|
if (config.isExport) {
|
|
7077
7156
|
rspackConfigSource = rspackConfigSource.replace(/\/\/ LcapPlugin start\s+new LcapPlugin\(\{[\s\S]*?\}\),\s+\/\/ LcapPlugin end/g, "");
|
|
7078
7157
|
}
|
|
7158
|
+
rspackConfigSource = await this.processLoadOnDemand(rspackConfigSource, {
|
|
7159
|
+
app,
|
|
7160
|
+
frontend,
|
|
7161
|
+
config,
|
|
7162
|
+
fs,
|
|
7163
|
+
frameworkKind
|
|
7164
|
+
});
|
|
7079
7165
|
fs.write(
|
|
7080
7166
|
"/rspack.config.js",
|
|
7081
7167
|
rspackConfigSource
|
|
7082
7168
|
);
|
|
7083
7169
|
}
|
|
7084
7170
|
}
|
|
7171
|
+
/**
|
|
7172
|
+
* 处理按需加载
|
|
7173
|
+
* 注意:此功能仅在非dev环境下的vue3框架中可以启用。
|
|
7174
|
+
* @param source 源代码
|
|
7175
|
+
* @param options 选项
|
|
7176
|
+
* @returns 处理后的代码
|
|
7177
|
+
*/
|
|
7178
|
+
async processLoadOnDemand(source, options) {
|
|
7179
|
+
let code = source;
|
|
7180
|
+
const { app, frontend, config, fs, frameworkKind } = options;
|
|
7181
|
+
const { env, feLoadDependenciesOnDemand, isExport } = config;
|
|
7182
|
+
const enablePerformance = feLoadDependenciesOnDemand && (isExport || env !== "dev") && ["vue3"].includes(frameworkKind);
|
|
7183
|
+
if (enablePerformance) {
|
|
7184
|
+
const feDeps = [...extractAppLevelFrontendDeps(app), ...extractFrontendLevelDeps(frontend)];
|
|
7185
|
+
code = code.replaceAll("// swc plugin placeholder", `experimental: {
|
|
7186
|
+
plugins: [
|
|
7187
|
+
['@lcap/swc-plugin-import', require('./scripts/generateSwcImportPluginConfig')([
|
|
7188
|
+
${feDeps.map((dep) => "'" + dep.name + "'").join(",\n")}
|
|
7189
|
+
])]
|
|
7190
|
+
]
|
|
7191
|
+
}`);
|
|
7192
|
+
}
|
|
7193
|
+
return code;
|
|
7194
|
+
}
|
|
7085
7195
|
static install(c) {
|
|
7086
7196
|
c.bind(ServiceMetaKind.FrontendBundlerFileConfig).to(RspackConfigPlugin).inSingletonScope();
|
|
7087
7197
|
return c;
|
|
@@ -7246,7 +7356,7 @@ export function loadAssets(){
|
|
|
7246
7356
|
generateEntry(ir) {
|
|
7247
7357
|
const entryScript = this.microFrontendManager.produceScript(ir);
|
|
7248
7358
|
const publicPathScript = this.microFrontendManager.producePublicPathScript(ir);
|
|
7249
|
-
|
|
7359
|
+
let code = `
|
|
7250
7360
|
export function startApp(){
|
|
7251
7361
|
if(window.LcapMicro){
|
|
7252
7362
|
// \u5DF2\u7ECF\u88AB\u52A0\u8F7D\u4E8E\u5FAE\u524D\u7AEF\u73AF\u5883
|
|
@@ -7257,6 +7367,11 @@ export function loadAssets(){
|
|
|
7257
7367
|
}
|
|
7258
7368
|
}
|
|
7259
7369
|
`;
|
|
7370
|
+
const { env, isExport } = ir.configs.config;
|
|
7371
|
+
if (!isExport && env === "dev") {
|
|
7372
|
+
const autoReloadScript = (init_auto_reload(), __toCommonJS(auto_reload_exports));
|
|
7373
|
+
code += autoReloadScript?.default || autoReloadScript;
|
|
7374
|
+
}
|
|
7260
7375
|
const imports = [
|
|
7261
7376
|
{
|
|
7262
7377
|
from: "../init"
|
|
@@ -7324,23 +7439,28 @@ var VueRouterPlugin = class {
|
|
|
7324
7439
|
}
|
|
7325
7440
|
routeToCode(routes, componentPathManager, config) {
|
|
7326
7441
|
function serializeVueRoute(r, isRoot = false) {
|
|
7327
|
-
const
|
|
7442
|
+
const { accumulativePath, thisLevelPath } = r;
|
|
7443
|
+
const path = isRoot ? accumulativePath : thisLevelPath ?? "/";
|
|
7444
|
+
const basePath = config.basePath;
|
|
7328
7445
|
if (r.kind === "normal") {
|
|
7329
7446
|
const children = r.children?.map((i) => serializeVueRoute(i)).filter(isNotNil) ?? [];
|
|
7330
7447
|
const childrenStr = children.join(",\n");
|
|
7331
7448
|
const componentCode = `component: ${r.elementMangledName ?? r.elementTemplate.identifier}`;
|
|
7332
|
-
return `{path: "${
|
|
7449
|
+
return `{path: "${path}", meta: ${JSON.stringify(
|
|
7333
7450
|
r.meta
|
|
7334
7451
|
)}, children: [${childrenStr}], ${componentCode} }`;
|
|
7335
7452
|
} else if (r.kind === "redirect") {
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
|
|
7453
|
+
if (["vue3"].includes(config.frameworkKind) && path === "*") {
|
|
7454
|
+
return `{ path: "/:pathMatch(.*)*", redirect: ${JSON.stringify(basePath + r.redirect)} }`;
|
|
7455
|
+
}
|
|
7456
|
+
if (["vue3"].includes(config.frameworkKind) && path === "/") {
|
|
7457
|
+
let result = `{ path: "/", redirect: ${JSON.stringify(basePath + r.redirect)} }`;
|
|
7458
|
+
if (basePath !== "/") {
|
|
7459
|
+
result += `, { path: "${basePath}", redirect: ${JSON.stringify(basePath + r.redirect)} }`;
|
|
7339
7460
|
}
|
|
7340
|
-
return
|
|
7341
|
-
}
|
|
7342
|
-
|
|
7343
|
-
return `{path: "${processedPath}", redirect: ${JSON.stringify(r.redirect)}}`;
|
|
7461
|
+
return result;
|
|
7462
|
+
}
|
|
7463
|
+
return `{ path: "${path}", redirect: to => to.path.replace(/\\/$/, '') + '/' + ${JSON.stringify(r.redirect)} }`;
|
|
7344
7464
|
}
|
|
7345
7465
|
notImplemented(r);
|
|
7346
7466
|
}
|
|
@@ -7429,7 +7549,7 @@ var Vue3EntryBuilderPlugin = class {
|
|
|
7429
7549
|
buildEntry(ir) {
|
|
7430
7550
|
const entryScript = this.microFrontendManager.produceScript(ir);
|
|
7431
7551
|
const publicPathScript = this.microFrontendManager.producePublicPathScript(ir);
|
|
7432
|
-
|
|
7552
|
+
let code = `
|
|
7433
7553
|
if(window.LcapMicro){
|
|
7434
7554
|
// \u5DF2\u7ECF\u88AB\u52A0\u8F7D\u4E8E\u5FAE\u524D\u7AEF\u73AF\u5883
|
|
7435
7555
|
renderApp();
|
|
@@ -7447,6 +7567,11 @@ var Vue3EntryBuilderPlugin = class {
|
|
|
7447
7567
|
from: "./public-path"
|
|
7448
7568
|
} : void 0
|
|
7449
7569
|
].filter(isNotNil);
|
|
7570
|
+
const { env, isExport } = ir.configs.config;
|
|
7571
|
+
if (!isExport && env === "dev") {
|
|
7572
|
+
const autoReloadScript = (init_auto_reload(), __toCommonJS(auto_reload_exports));
|
|
7573
|
+
code += autoReloadScript?.default || autoReloadScript;
|
|
7574
|
+
}
|
|
7450
7575
|
return [
|
|
7451
7576
|
new ReactFileDescription("main.ts", imports, [], [code]),
|
|
7452
7577
|
publicPathScript ? new ReactFileDescription("public-path.ts", [], [], [publicPathScript]) : void 0
|
|
@@ -7472,10 +7597,18 @@ var Vue3LibrariesBuilderPlugin = class {
|
|
|
7472
7597
|
*/
|
|
7473
7598
|
async buildLibrariesImport(ir, config) {
|
|
7474
7599
|
const importArr = [];
|
|
7600
|
+
const exportArr = [];
|
|
7475
7601
|
const standardLib = ir.packages.find((x) => x.kind === "standard");
|
|
7476
7602
|
if (standardLib) {
|
|
7477
|
-
|
|
7478
|
-
|
|
7603
|
+
importArr.push(`import { ConfigProvider, transformKeys, Message } from '${standardLib.name}';`);
|
|
7604
|
+
exportArr.push(`export const LcapStandardUI = window.lcapStandardUI = {
|
|
7605
|
+
ConfigProvider,
|
|
7606
|
+
transformKeys,
|
|
7607
|
+
Message,
|
|
7608
|
+
install: (app) => {
|
|
7609
|
+
app.config.globalProperties.$message = Message;
|
|
7610
|
+
},
|
|
7611
|
+
};`);
|
|
7479
7612
|
const isPackageZipExists = await judgePackageZipExists(standardLib, config.STATIC_URL);
|
|
7480
7613
|
importArr.push(
|
|
7481
7614
|
`import '${standardLib.name}${isPackageZipExists ? "/dist-theme" : ""}/index.css';`
|
|
@@ -7483,17 +7616,30 @@ var Vue3LibrariesBuilderPlugin = class {
|
|
|
7483
7616
|
}
|
|
7484
7617
|
const extensions = ir.packages.filter((x) => x.kind === "extension");
|
|
7485
7618
|
for (const ext of extensions) {
|
|
7486
|
-
const formattedName = kebab2Pascal(ext.name.split("/").at(-1));
|
|
7487
7619
|
const isPackageZipExists = await judgePackageZipExists(ext, config.STATIC_URL);
|
|
7488
|
-
const
|
|
7489
|
-
|
|
7490
|
-
|
|
7620
|
+
const { feLoadDependenciesOnDemand } = config;
|
|
7621
|
+
if (!feLoadDependenciesOnDemand && ext.used) {
|
|
7622
|
+
const formattedName = kebab2Pascal(ext.name.split("/").at(-1));
|
|
7623
|
+
importArr.push(`import { install as ${formattedName}Install } from '${ext.name}';`);
|
|
7624
|
+
exportArr.push(`export const ${formattedName} = {
|
|
7625
|
+
install: ${formattedName}Install || (() => {}),
|
|
7626
|
+
};`);
|
|
7627
|
+
}
|
|
7628
|
+
if (ext.used && ext.hasCss) {
|
|
7491
7629
|
importArr.push(
|
|
7492
|
-
`import '${
|
|
7630
|
+
`import '${ext.name}${isPackageZipExists ? "/dist-theme" : ""}/index.css';`
|
|
7493
7631
|
);
|
|
7494
7632
|
}
|
|
7495
7633
|
}
|
|
7496
|
-
return new ReactFileDescription("libraries.ts", [], [], [importArr.join("\n")]);
|
|
7634
|
+
return new ReactFileDescription("libraries.ts", [], [], [[...importArr, ...exportArr].join("\n")]);
|
|
7635
|
+
}
|
|
7636
|
+
findPackageByNameFromAllNodesAPI(name, allNodesAPI = {}) {
|
|
7637
|
+
for (const key in allNodesAPI) {
|
|
7638
|
+
if (allNodesAPI[key]?.package?.name === name) {
|
|
7639
|
+
return allNodesAPI[key].package;
|
|
7640
|
+
}
|
|
7641
|
+
}
|
|
7642
|
+
return void 0;
|
|
7497
7643
|
}
|
|
7498
7644
|
static install(c) {
|
|
7499
7645
|
c.bind(Vue3LibrariesBuilderPlugin).toSelf();
|
|
@@ -7729,15 +7875,16 @@ var Vue3ApplicationAssemblerPlugin = class {
|
|
|
7729
7875
|
const bizComponents = ir.bizComponents.flatMap((x) => {
|
|
7730
7876
|
return this.vue3CodegenPlugin.genFiles(x, manager);
|
|
7731
7877
|
});
|
|
7732
|
-
let
|
|
7733
|
-
if (!/\/$/.test(
|
|
7734
|
-
|
|
7878
|
+
let basePath = ir.configs.basePlatformConfig.basePath;
|
|
7879
|
+
if (!/\/$/.test(basePath)) {
|
|
7880
|
+
basePath += "/";
|
|
7735
7881
|
}
|
|
7736
|
-
const routesObjects = this.routesExtactor.extractRoute(ir.views,
|
|
7882
|
+
const routesObjects = this.routesExtactor.extractRoute(ir.views, basePath, {
|
|
7737
7883
|
lazy: true
|
|
7738
7884
|
});
|
|
7739
7885
|
const router = this.routerBuilder.routeToCode(routesObjects.routes, manager, {
|
|
7740
|
-
frameworkKind: "vue3"
|
|
7886
|
+
frameworkKind: "vue3",
|
|
7887
|
+
basePath
|
|
7741
7888
|
});
|
|
7742
7889
|
const routerFile = new ReactFileDescription("router.ts", router.imports, [], [router.code]);
|
|
7743
7890
|
const libraries = await this.librariesBuilder.buildLibrariesImport(ir, config);
|
|
@@ -7774,6 +7921,181 @@ Vue3ApplicationAssemblerPlugin = __decorateClass([
|
|
|
7774
7921
|
__decorateParam(9, inject14(Vue3MetaDataBuilderPlugin))
|
|
7775
7922
|
], Vue3ApplicationAssemblerPlugin);
|
|
7776
7923
|
|
|
7924
|
+
// src/plugins/misc/program-analysis/analyzer-manager-plugin.ts
|
|
7925
|
+
import { injectable as injectable30 } from "inversify";
|
|
7926
|
+
|
|
7927
|
+
// src/plugins/misc/program-analysis/analysis/async-analysis.ts
|
|
7928
|
+
function buildAsyncAnalyzer() {
|
|
7929
|
+
const resultCache = /* @__PURE__ */ new WeakMap();
|
|
7930
|
+
function isSubtreeAsync(node, analyzeFunc = analyze) {
|
|
7931
|
+
let hasAsync = false;
|
|
7932
|
+
node.traverseStrictChildrenWithPruning((n) => {
|
|
7933
|
+
if (n === node) {
|
|
7934
|
+
return false;
|
|
7935
|
+
}
|
|
7936
|
+
if (hasAsync) {
|
|
7937
|
+
return true;
|
|
7938
|
+
} else if (n) {
|
|
7939
|
+
hasAsync = analyzeFunc(n);
|
|
7940
|
+
return hasAsync;
|
|
7941
|
+
}
|
|
7942
|
+
});
|
|
7943
|
+
return hasAsync;
|
|
7944
|
+
}
|
|
7945
|
+
function analyze(node) {
|
|
7946
|
+
if (!node) {
|
|
7947
|
+
return false;
|
|
7948
|
+
}
|
|
7949
|
+
if (resultCache.has(node)) {
|
|
7950
|
+
return resultCache.get(node);
|
|
7951
|
+
}
|
|
7952
|
+
function dispatch(node2) {
|
|
7953
|
+
switch (node2.concept) {
|
|
7954
|
+
case "CallLogic": {
|
|
7955
|
+
const calleeNode = node2.getCallNode();
|
|
7956
|
+
return analyze(calleeNode) || isSubtreeAsync(node2);
|
|
7957
|
+
}
|
|
7958
|
+
case "CallInterface": {
|
|
7959
|
+
return true;
|
|
7960
|
+
}
|
|
7961
|
+
case "CallFunction": {
|
|
7962
|
+
return isSubtreeAsync(node2);
|
|
7963
|
+
}
|
|
7964
|
+
case "Match": {
|
|
7965
|
+
return isSubtreeAsync(node2);
|
|
7966
|
+
}
|
|
7967
|
+
case "Function": {
|
|
7968
|
+
return isSubtreeAsync(node2);
|
|
7969
|
+
}
|
|
7970
|
+
case "JSBlock": {
|
|
7971
|
+
return true;
|
|
7972
|
+
}
|
|
7973
|
+
case "ExternalDestination":
|
|
7974
|
+
case "Destination": {
|
|
7975
|
+
return true;
|
|
7976
|
+
}
|
|
7977
|
+
case "NewStructure":
|
|
7978
|
+
case "NewComposite":
|
|
7979
|
+
case "NewMap":
|
|
7980
|
+
case "NewList": {
|
|
7981
|
+
return isSubtreeAsync(node2);
|
|
7982
|
+
}
|
|
7983
|
+
case "SubLogic": {
|
|
7984
|
+
return true;
|
|
7985
|
+
}
|
|
7986
|
+
case "Logic": {
|
|
7987
|
+
if (node2.likeComponent) {
|
|
7988
|
+
return node2.subLogics?.some(analyze) || isSubtreeAsync(node2);
|
|
7989
|
+
} else {
|
|
7990
|
+
return true;
|
|
7991
|
+
}
|
|
7992
|
+
}
|
|
7993
|
+
case "AnonymousFunction": {
|
|
7994
|
+
return isSubtreeAsync(node2);
|
|
7995
|
+
}
|
|
7996
|
+
case "BindEvent": {
|
|
7997
|
+
return node2.logics?.some(analyze) ?? false;
|
|
7998
|
+
}
|
|
7999
|
+
case "Interface":
|
|
8000
|
+
case "OverriddenLogic": {
|
|
8001
|
+
return true;
|
|
8002
|
+
}
|
|
8003
|
+
default: {
|
|
8004
|
+
return isSubtreeAsync(node2);
|
|
8005
|
+
}
|
|
8006
|
+
}
|
|
8007
|
+
}
|
|
8008
|
+
resultCache.set(node, true);
|
|
8009
|
+
const res = dispatch(node);
|
|
8010
|
+
resultCache.set(node, res);
|
|
8011
|
+
return res;
|
|
8012
|
+
}
|
|
8013
|
+
return {
|
|
8014
|
+
query: (node) => {
|
|
8015
|
+
return { async: analyze(node) };
|
|
8016
|
+
}
|
|
8017
|
+
};
|
|
8018
|
+
}
|
|
8019
|
+
|
|
8020
|
+
// src/plugins/misc/program-analysis/analysis/dep-analysis.ts
|
|
8021
|
+
import { analyzeDepRef } from "@lcap/nasl-concepts";
|
|
8022
|
+
function analyzeDeps(ir, config) {
|
|
8023
|
+
const { views, bizComponents, packages } = ir;
|
|
8024
|
+
const deps = {};
|
|
8025
|
+
views.forEach((view) => {
|
|
8026
|
+
const { libs } = analyzeDepRef(view.__raw, config);
|
|
8027
|
+
for (const key in libs) {
|
|
8028
|
+
deps[key] = deps[key] || [];
|
|
8029
|
+
libs[key].forEach((importer) => {
|
|
8030
|
+
if (!deps[key].some((d) => d.key === importer.key)) {
|
|
8031
|
+
deps[key].push(importer);
|
|
8032
|
+
}
|
|
8033
|
+
});
|
|
8034
|
+
}
|
|
8035
|
+
});
|
|
8036
|
+
bizComponents.forEach((component) => {
|
|
8037
|
+
const { libs } = analyzeDepRef(component.__raw, config);
|
|
8038
|
+
for (const key in libs) {
|
|
8039
|
+
deps[key] = deps[key] || [];
|
|
8040
|
+
libs[key].forEach((importer) => {
|
|
8041
|
+
if (!deps[key].some((d) => d.key === importer.key)) {
|
|
8042
|
+
deps[key].push(importer);
|
|
8043
|
+
}
|
|
8044
|
+
});
|
|
8045
|
+
}
|
|
8046
|
+
});
|
|
8047
|
+
packages.forEach((pkg) => {
|
|
8048
|
+
if (deps[pkg.name]) {
|
|
8049
|
+
pkg.used = true;
|
|
8050
|
+
}
|
|
8051
|
+
});
|
|
8052
|
+
}
|
|
8053
|
+
|
|
8054
|
+
// src/plugins/misc/program-analysis/analyzer-manager-plugin.ts
|
|
8055
|
+
var AnalyzerManagerPlugin = class {
|
|
8056
|
+
constructor() {
|
|
8057
|
+
this.options = {
|
|
8058
|
+
depAnalysis: true
|
|
8059
|
+
};
|
|
8060
|
+
}
|
|
8061
|
+
preProcess(app, frontend, config) {
|
|
8062
|
+
const analyzer = buildAsyncAnalyzer();
|
|
8063
|
+
if (this.getOptions().asyncAnalysis) {
|
|
8064
|
+
app.analyzer = analyzer;
|
|
8065
|
+
}
|
|
8066
|
+
return { app, frontend, config };
|
|
8067
|
+
}
|
|
8068
|
+
postProcess(ir, config) {
|
|
8069
|
+
if (this.getOptions().depAnalysis) {
|
|
8070
|
+
analyzeDeps(ir, config);
|
|
8071
|
+
}
|
|
8072
|
+
return ir;
|
|
8073
|
+
}
|
|
8074
|
+
/**
|
|
8075
|
+
* 设置完整的分析选项
|
|
8076
|
+
* @param options
|
|
8077
|
+
*/
|
|
8078
|
+
setOptions(options) {
|
|
8079
|
+
this.options = options;
|
|
8080
|
+
}
|
|
8081
|
+
/**
|
|
8082
|
+
* 获取分析选项
|
|
8083
|
+
* @returns 分析选项
|
|
8084
|
+
*/
|
|
8085
|
+
getOptions() {
|
|
8086
|
+
return this.options;
|
|
8087
|
+
}
|
|
8088
|
+
static install(c) {
|
|
8089
|
+
c.bind(ServiceMetaKind.IRPreProcesser).to(AnalyzerManagerPlugin);
|
|
8090
|
+
c.bind(ServiceMetaKind.IRPostProcesser).to(AnalyzerManagerPlugin);
|
|
8091
|
+
c.bind(ServiceMetaKind.AnalyzerManager).to(AnalyzerManagerPlugin);
|
|
8092
|
+
return c;
|
|
8093
|
+
}
|
|
8094
|
+
};
|
|
8095
|
+
AnalyzerManagerPlugin = __decorateClass([
|
|
8096
|
+
injectable30()
|
|
8097
|
+
], AnalyzerManagerPlugin);
|
|
8098
|
+
|
|
7777
8099
|
// src/plugins/vue/vue3/vue3-preset-plugin.ts
|
|
7778
8100
|
var logger12 = Logger("Vue3PresetPlugin");
|
|
7779
8101
|
var Vue3PresetPlugin = class {
|
|
@@ -7790,6 +8112,30 @@ var Vue3PresetPlugin = class {
|
|
|
7790
8112
|
const app = deserializeAppWhileKeepTypeAnnotation(appJson);
|
|
7791
8113
|
const frontend = app.findNodeByPath(instruction.frontend.nodePath);
|
|
7792
8114
|
const ir = this.irBuilder.buildIR(app, frontend, instruction.config);
|
|
8115
|
+
const needCompileViews = instruction.config?.needCompileViews ?? [];
|
|
8116
|
+
const isIncremental = needCompileViews.length > 0;
|
|
8117
|
+
if (isIncremental) {
|
|
8118
|
+
const filterChildComponents = (view, needCompileViews2) => {
|
|
8119
|
+
if (!view.childComponents?.length) {
|
|
8120
|
+
return;
|
|
8121
|
+
}
|
|
8122
|
+
view.childComponents = view.childComponents.filter((child) => {
|
|
8123
|
+
if (needCompileViews2.includes(child.__raw.nodePath)) {
|
|
8124
|
+
filterChildComponents(child, needCompileViews2);
|
|
8125
|
+
return true;
|
|
8126
|
+
}
|
|
8127
|
+
return false;
|
|
8128
|
+
});
|
|
8129
|
+
};
|
|
8130
|
+
ir.views = ir.views.filter((view) => {
|
|
8131
|
+
if (needCompileViews.includes(view.__raw.nodePath)) {
|
|
8132
|
+
filterChildComponents(view, needCompileViews);
|
|
8133
|
+
return true;
|
|
8134
|
+
}
|
|
8135
|
+
return false;
|
|
8136
|
+
});
|
|
8137
|
+
ir.bizComponents = [];
|
|
8138
|
+
}
|
|
7793
8139
|
const assembledApplication = await this.applicationAssembler.assemble(ir, instruction.config);
|
|
7794
8140
|
const finalizedFiles = await this.projectOrganizer.organize({
|
|
7795
8141
|
baseDir: instruction.baseDir,
|
|
@@ -7825,6 +8171,7 @@ var Vue3PresetPlugin = class {
|
|
|
7825
8171
|
c = VueRouterPlugin.install(c);
|
|
7826
8172
|
c.bind(ServiceMetaKind.ProjectOrganizer).to(ProjectOrganizerPlugin);
|
|
7827
8173
|
c.bind(ServiceMetaKind.FileSystemProvider).to(FileSystemPlugin).inSingletonScope();
|
|
8174
|
+
c = AnalyzerManagerPlugin.install(c);
|
|
7828
8175
|
c = BundlerConfigDataPlugin.install(c);
|
|
7829
8176
|
c = RspackConfigPlugin.install(c);
|
|
7830
8177
|
c = FrontendBundlerConfigPlugin.install(c);
|
|
@@ -7843,7 +8190,7 @@ var Vue3PresetPlugin = class {
|
|
|
7843
8190
|
}
|
|
7844
8191
|
};
|
|
7845
8192
|
Vue3PresetPlugin = __decorateClass([
|
|
7846
|
-
|
|
8193
|
+
injectable31(),
|
|
7847
8194
|
__decorateParam(0, inject15(ServiceMetaKind.IRBuilder)),
|
|
7848
8195
|
__decorateParam(1, inject15(ServiceMetaKind.FileSystemProvider)),
|
|
7849
8196
|
__decorateParam(2, inject15(NpmPackageJSONManagerPlugin)),
|
|
@@ -7854,9 +8201,9 @@ Vue3PresetPlugin = __decorateClass([
|
|
|
7854
8201
|
// src/default-container.ts
|
|
7855
8202
|
function makeDefaultContainer(kind = "react") {
|
|
7856
8203
|
if (kind === "react") {
|
|
7857
|
-
return ReactPresetPlugin.install(new
|
|
8204
|
+
return ReactPresetPlugin.install(new Container21());
|
|
7858
8205
|
} else if (kind === "vue3") {
|
|
7859
|
-
return Vue3PresetPlugin.install(new
|
|
8206
|
+
return Vue3PresetPlugin.install(new Container21());
|
|
7860
8207
|
} else {
|
|
7861
8208
|
throw new Error(`\u672A\u5B9E\u73B0${kind}\u7684\u9ED8\u8BA4\u5BB9\u5668`);
|
|
7862
8209
|
}
|
|
@@ -7871,7 +8218,7 @@ async function translateNASLToApp(app, frontend, config, baseDir = "./out", cont
|
|
|
7871
8218
|
if (needCompileViews?.length > 0) {
|
|
7872
8219
|
let traverseChildren2 = function(view, callback) {
|
|
7873
8220
|
if (view.children?.length > 0) {
|
|
7874
|
-
view.children.forEach((childView) => {
|
|
8221
|
+
[...view.children].forEach((childView) => {
|
|
7875
8222
|
const deep = callback(childView);
|
|
7876
8223
|
if (deep) {
|
|
7877
8224
|
traverseChildren2(childView, callback);
|
|
@@ -7881,9 +8228,10 @@ async function translateNASLToApp(app, frontend, config, baseDir = "./out", cont
|
|
|
7881
8228
|
};
|
|
7882
8229
|
var traverseChildren = traverseChildren2;
|
|
7883
8230
|
logger13.info("\u5F00\u59CB\u6309\u9700\u7FFB\u8BD1\u9875\u9762");
|
|
7884
|
-
frontend.views.forEach((view) => {
|
|
8231
|
+
[...frontend.views].forEach((view) => {
|
|
7885
8232
|
if (!needCompileViews.includes(view.nodePath)) {
|
|
7886
8233
|
view.delete();
|
|
8234
|
+
console.log(`\u5220\u9664\u9875\u9762 ${view.nodePath}\uFF0C\u56E0\u4E3A\u5B83\u4E0D\u5728 needCompileViews \u4E2D`);
|
|
7887
8235
|
} else {
|
|
7888
8236
|
traverseChildren2(view, (childView) => {
|
|
7889
8237
|
if (!needCompileViews.includes(childView.nodePath)) {
|
|
@@ -7992,7 +8340,11 @@ async function compileAsProject(app, frontend, config, container) {
|
|
|
7992
8340
|
logger13.info("\u8FDC\u7A0B\u52A0\u8F7D\u6A21\u677F\u6210\u529F");
|
|
7993
8341
|
const files = res.files;
|
|
7994
8342
|
Object.entries(files).forEach(([k, v]) => {
|
|
7995
|
-
|
|
8343
|
+
if (typeof v.code === "string") {
|
|
8344
|
+
fs.write(k, v.code);
|
|
8345
|
+
} else if (v.code?.type === "Buffer") {
|
|
8346
|
+
fs.write(k, Buffer.from(v.code.data));
|
|
8347
|
+
}
|
|
7996
8348
|
});
|
|
7997
8349
|
} catch (error) {
|
|
7998
8350
|
throw new Error(`\u8FDC\u7A0B\u52A0\u8F7D\u6A21\u677F\u5931\u8D25`);
|
|
@@ -8051,137 +8403,6 @@ async function compileNASLToReactDist(app, frontend, config, http) {
|
|
|
8051
8403
|
}
|
|
8052
8404
|
}
|
|
8053
8405
|
|
|
8054
|
-
// src/plugins/misc/program-analysis/analyzer-manager-plugin.ts
|
|
8055
|
-
import { injectable as injectable31 } from "inversify";
|
|
8056
|
-
|
|
8057
|
-
// src/plugins/misc/program-analysis/analysis/async-analysis.ts
|
|
8058
|
-
function buildAsyncAnalyzer() {
|
|
8059
|
-
const resultCache = /* @__PURE__ */ new WeakMap();
|
|
8060
|
-
function isSubtreeAsync(node, analyzeFunc = analyze) {
|
|
8061
|
-
let hasAsync = false;
|
|
8062
|
-
node.traverseStrictChildrenWithPruning((n) => {
|
|
8063
|
-
if (n === node) {
|
|
8064
|
-
return false;
|
|
8065
|
-
}
|
|
8066
|
-
if (hasAsync) {
|
|
8067
|
-
return true;
|
|
8068
|
-
} else if (n) {
|
|
8069
|
-
hasAsync = analyzeFunc(n);
|
|
8070
|
-
return hasAsync;
|
|
8071
|
-
}
|
|
8072
|
-
});
|
|
8073
|
-
return hasAsync;
|
|
8074
|
-
}
|
|
8075
|
-
function analyze(node) {
|
|
8076
|
-
if (!node) {
|
|
8077
|
-
return false;
|
|
8078
|
-
}
|
|
8079
|
-
if (resultCache.has(node)) {
|
|
8080
|
-
return resultCache.get(node);
|
|
8081
|
-
}
|
|
8082
|
-
function dispatch(node2) {
|
|
8083
|
-
switch (node2.concept) {
|
|
8084
|
-
case "CallLogic": {
|
|
8085
|
-
const calleeNode = node2.getCallNode();
|
|
8086
|
-
return analyze(calleeNode) || isSubtreeAsync(node2);
|
|
8087
|
-
}
|
|
8088
|
-
case "CallInterface": {
|
|
8089
|
-
return true;
|
|
8090
|
-
}
|
|
8091
|
-
case "CallFunction": {
|
|
8092
|
-
return isSubtreeAsync(node2);
|
|
8093
|
-
}
|
|
8094
|
-
case "Match": {
|
|
8095
|
-
return isSubtreeAsync(node2);
|
|
8096
|
-
}
|
|
8097
|
-
case "Function": {
|
|
8098
|
-
return isSubtreeAsync(node2);
|
|
8099
|
-
}
|
|
8100
|
-
case "JSBlock": {
|
|
8101
|
-
return true;
|
|
8102
|
-
}
|
|
8103
|
-
case "ExternalDestination":
|
|
8104
|
-
case "Destination": {
|
|
8105
|
-
return true;
|
|
8106
|
-
}
|
|
8107
|
-
case "NewStructure":
|
|
8108
|
-
case "NewComposite":
|
|
8109
|
-
case "NewMap":
|
|
8110
|
-
case "NewList": {
|
|
8111
|
-
return isSubtreeAsync(node2);
|
|
8112
|
-
}
|
|
8113
|
-
case "SubLogic": {
|
|
8114
|
-
return true;
|
|
8115
|
-
}
|
|
8116
|
-
case "Logic": {
|
|
8117
|
-
if (node2.likeComponent) {
|
|
8118
|
-
return node2.subLogics?.some(analyze) || isSubtreeAsync(node2);
|
|
8119
|
-
} else {
|
|
8120
|
-
return true;
|
|
8121
|
-
}
|
|
8122
|
-
}
|
|
8123
|
-
case "AnonymousFunction": {
|
|
8124
|
-
return isSubtreeAsync(node2);
|
|
8125
|
-
}
|
|
8126
|
-
case "BindEvent": {
|
|
8127
|
-
return node2.logics?.some(analyze) ?? false;
|
|
8128
|
-
}
|
|
8129
|
-
case "Interface":
|
|
8130
|
-
case "OverriddenLogic": {
|
|
8131
|
-
return true;
|
|
8132
|
-
}
|
|
8133
|
-
default: {
|
|
8134
|
-
return isSubtreeAsync(node2);
|
|
8135
|
-
}
|
|
8136
|
-
}
|
|
8137
|
-
}
|
|
8138
|
-
resultCache.set(node, true);
|
|
8139
|
-
const res = dispatch(node);
|
|
8140
|
-
resultCache.set(node, res);
|
|
8141
|
-
return res;
|
|
8142
|
-
}
|
|
8143
|
-
return {
|
|
8144
|
-
query: (node) => {
|
|
8145
|
-
return { async: analyze(node) };
|
|
8146
|
-
}
|
|
8147
|
-
};
|
|
8148
|
-
}
|
|
8149
|
-
|
|
8150
|
-
// src/plugins/misc/program-analysis/analyzer-manager-plugin.ts
|
|
8151
|
-
var AnalyzerManagerPlugin = class {
|
|
8152
|
-
constructor() {
|
|
8153
|
-
this.options = {};
|
|
8154
|
-
}
|
|
8155
|
-
preProcess(app, frontend, config) {
|
|
8156
|
-
const analyzer = buildAsyncAnalyzer();
|
|
8157
|
-
if (this.getOptions().asyncAnalysis) {
|
|
8158
|
-
app.analyzer = analyzer;
|
|
8159
|
-
}
|
|
8160
|
-
return { app, frontend, config };
|
|
8161
|
-
}
|
|
8162
|
-
/**
|
|
8163
|
-
* 设置完整的分析选项
|
|
8164
|
-
* @param options
|
|
8165
|
-
*/
|
|
8166
|
-
setOptions(options) {
|
|
8167
|
-
this.options = options;
|
|
8168
|
-
}
|
|
8169
|
-
/**
|
|
8170
|
-
* 获取分析选项
|
|
8171
|
-
* @returns 分析选项
|
|
8172
|
-
*/
|
|
8173
|
-
getOptions() {
|
|
8174
|
-
return this.options;
|
|
8175
|
-
}
|
|
8176
|
-
static install(c) {
|
|
8177
|
-
c.bind(ServiceMetaKind.IRPreProcesser).to(AnalyzerManagerPlugin);
|
|
8178
|
-
c.bind(ServiceMetaKind.AnalyzerManager).to(AnalyzerManagerPlugin);
|
|
8179
|
-
}
|
|
8180
|
-
};
|
|
8181
|
-
AnalyzerManagerPlugin = __decorateClass([
|
|
8182
|
-
injectable31()
|
|
8183
|
-
], AnalyzerManagerPlugin);
|
|
8184
|
-
|
|
8185
8406
|
// src/plugins/misc/name-mangler/name-mangler-manager-plugin.ts
|
|
8186
8407
|
import { injectable as injectable32 } from "inversify";
|
|
8187
8408
|
|