@lcap/nasl-unified-frontend-generator 4.1.0-beta.1 → 4.1.0-beta.10
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 +14 -5
- package/dist/index.d.ts +14 -5
- package/dist/index.js +221 -76
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +237 -76
- 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 +129430 -77
- package/dist/playground.js.map +1 -1
- package/dist/playground.mjs +129436 -77
- package/dist/playground.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -28,6 +28,7 @@ interface CommonAppConfig {
|
|
|
28
28
|
isExport?: boolean;
|
|
29
29
|
needCompileViews?: string[];
|
|
30
30
|
cacheChunksMapCode?: string;
|
|
31
|
+
feLoadDependenciesOnDemand?: boolean;
|
|
31
32
|
/**
|
|
32
33
|
* 插件用的配置项
|
|
33
34
|
*/
|
|
@@ -117,7 +118,7 @@ interface I18nInfo {
|
|
|
117
118
|
declare const metadataPlugin: {
|
|
118
119
|
name: string;
|
|
119
120
|
functions: {
|
|
120
|
-
makeBasePlatformConfig(app: Pick<App,
|
|
121
|
+
makeBasePlatformConfig(app: Pick<App, 'name' | 'dnsAddr' | 'hasUserCenter' | 'hasAuth' | 'sysPrefixPath' | 'id' | 'appTimeZone'>, frontend: Frontend, config: CommonAppConfig): BasePlatformConfig;
|
|
121
122
|
};
|
|
122
123
|
};
|
|
123
124
|
|
|
@@ -641,7 +642,7 @@ declare const routesExtractionPlugin: {
|
|
|
641
642
|
functions: {
|
|
642
643
|
extractRoute(components: ViewComponentIR[], routePrefix: string, options?: {
|
|
643
644
|
lazy?: boolean;
|
|
644
|
-
frameworkKind?:
|
|
645
|
+
frameworkKind?: 'react' | 'vue2' | 'vue3';
|
|
645
646
|
}): {
|
|
646
647
|
routes: RouteIR[];
|
|
647
648
|
authResourcePaths: string[];
|
|
@@ -1172,10 +1173,18 @@ declare const reactComponentLibHackPlugin: {
|
|
|
1172
1173
|
name: string;
|
|
1173
1174
|
functions: {
|
|
1174
1175
|
__hooksDefinitions(): ReactFileDescription;
|
|
1175
|
-
hackBindAttribute<T extends
|
|
1176
|
+
hackBindAttribute<T extends {
|
|
1176
1177
|
kind: "expr";
|
|
1178
|
+
expression: ExprIR;
|
|
1179
|
+
__raw: _lcap_nasl_concepts.BindAttribute;
|
|
1180
|
+
sync: boolean;
|
|
1181
|
+
} & {
|
|
1182
|
+
concept: "BindAttribute";
|
|
1183
|
+
name: string;
|
|
1184
|
+
} & {
|
|
1185
|
+
kind: 'expr';
|
|
1177
1186
|
}>(b: T): BindAttributeIR & {
|
|
1178
|
-
kind:
|
|
1187
|
+
kind: 'expr';
|
|
1179
1188
|
};
|
|
1180
1189
|
};
|
|
1181
1190
|
};
|
|
@@ -1672,7 +1681,7 @@ declare class VirtualProject {
|
|
|
1672
1681
|
getFileDict(): {
|
|
1673
1682
|
files: Record<string, ProjectFile>;
|
|
1674
1683
|
};
|
|
1675
|
-
readFile(path: string): string | Buffer
|
|
1684
|
+
readFile(path: string): string | Buffer;
|
|
1676
1685
|
}
|
|
1677
1686
|
declare function compileAsProject(app: App, frontend: Frontend, config: CommonAppConfig, container?: Container): Promise<VirtualProject>;
|
|
1678
1687
|
declare function compileNASLToReactDist(app: App, frontend: Frontend, config: CommonAppConfig, http: AxiosInstance): Promise<OrganizedFile[]>;
|
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ interface CommonAppConfig {
|
|
|
28
28
|
isExport?: boolean;
|
|
29
29
|
needCompileViews?: string[];
|
|
30
30
|
cacheChunksMapCode?: string;
|
|
31
|
+
feLoadDependenciesOnDemand?: boolean;
|
|
31
32
|
/**
|
|
32
33
|
* 插件用的配置项
|
|
33
34
|
*/
|
|
@@ -117,7 +118,7 @@ interface I18nInfo {
|
|
|
117
118
|
declare const metadataPlugin: {
|
|
118
119
|
name: string;
|
|
119
120
|
functions: {
|
|
120
|
-
makeBasePlatformConfig(app: Pick<App,
|
|
121
|
+
makeBasePlatformConfig(app: Pick<App, 'name' | 'dnsAddr' | 'hasUserCenter' | 'hasAuth' | 'sysPrefixPath' | 'id' | 'appTimeZone'>, frontend: Frontend, config: CommonAppConfig): BasePlatformConfig;
|
|
121
122
|
};
|
|
122
123
|
};
|
|
123
124
|
|
|
@@ -641,7 +642,7 @@ declare const routesExtractionPlugin: {
|
|
|
641
642
|
functions: {
|
|
642
643
|
extractRoute(components: ViewComponentIR[], routePrefix: string, options?: {
|
|
643
644
|
lazy?: boolean;
|
|
644
|
-
frameworkKind?:
|
|
645
|
+
frameworkKind?: 'react' | 'vue2' | 'vue3';
|
|
645
646
|
}): {
|
|
646
647
|
routes: RouteIR[];
|
|
647
648
|
authResourcePaths: string[];
|
|
@@ -1172,10 +1173,18 @@ declare const reactComponentLibHackPlugin: {
|
|
|
1172
1173
|
name: string;
|
|
1173
1174
|
functions: {
|
|
1174
1175
|
__hooksDefinitions(): ReactFileDescription;
|
|
1175
|
-
hackBindAttribute<T extends
|
|
1176
|
+
hackBindAttribute<T extends {
|
|
1176
1177
|
kind: "expr";
|
|
1178
|
+
expression: ExprIR;
|
|
1179
|
+
__raw: _lcap_nasl_concepts.BindAttribute;
|
|
1180
|
+
sync: boolean;
|
|
1181
|
+
} & {
|
|
1182
|
+
concept: "BindAttribute";
|
|
1183
|
+
name: string;
|
|
1184
|
+
} & {
|
|
1185
|
+
kind: 'expr';
|
|
1177
1186
|
}>(b: T): BindAttributeIR & {
|
|
1178
|
-
kind:
|
|
1187
|
+
kind: 'expr';
|
|
1179
1188
|
};
|
|
1180
1189
|
};
|
|
1181
1190
|
};
|
|
@@ -1672,7 +1681,7 @@ declare class VirtualProject {
|
|
|
1672
1681
|
getFileDict(): {
|
|
1673
1682
|
files: Record<string, ProjectFile>;
|
|
1674
1683
|
};
|
|
1675
|
-
readFile(path: string): string | Buffer
|
|
1684
|
+
readFile(path: string): string | Buffer;
|
|
1676
1685
|
}
|
|
1677
1686
|
declare function compileAsProject(app: App, frontend: Frontend, config: CommonAppConfig, container?: Container): Promise<VirtualProject>;
|
|
1678
1687
|
declare function compileNASLToReactDist(app: App, frontend: Frontend, config: CommonAppConfig, http: AxiosInstance): Promise<OrganizedFile[]>;
|
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, {
|
|
@@ -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,11 @@ 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 } from '${standardLib.name}';`);
|
|
7548
|
+
exportArr.push(`window.lcapStandardUI = { ConfigProvider, transformKeys };`);
|
|
7439
7549
|
const isPackageZipExists = await judgePackageZipExists(standardLib, config.STATIC_URL);
|
|
7440
7550
|
importArr.push(
|
|
7441
7551
|
`import '${standardLib.name}${isPackageZipExists ? "/dist-theme" : ""}/index.css';`
|
|
@@ -7443,17 +7553,22 @@ var Vue3LibrariesBuilderPlugin = class {
|
|
|
7443
7553
|
}
|
|
7444
7554
|
const extensions = ir.packages.filter((x) => x.kind === "extension");
|
|
7445
7555
|
for (const ext of extensions) {
|
|
7446
|
-
const formattedName = kebab2Pascal(ext.name.split("/").at(-1));
|
|
7447
7556
|
const isPackageZipExists = await judgePackageZipExists(ext, config.STATIC_URL);
|
|
7448
|
-
const prefix = isPackageZipExists ? "" : "@extension/";
|
|
7449
|
-
importArr.push(`export * as ${formattedName} from '${prefix}${ext.name}';`);
|
|
7450
7557
|
if (ext.hasCss) {
|
|
7451
7558
|
importArr.push(
|
|
7452
|
-
`import '${
|
|
7559
|
+
`import '${ext.name}${isPackageZipExists ? "/dist-theme" : ""}/index.css';`
|
|
7453
7560
|
);
|
|
7454
7561
|
}
|
|
7455
7562
|
}
|
|
7456
|
-
return new ReactFileDescription("libraries.ts", [], [], [importArr.join("\n")]);
|
|
7563
|
+
return new ReactFileDescription("libraries.ts", [], [], [[...importArr, ...exportArr].join("\n")]);
|
|
7564
|
+
}
|
|
7565
|
+
findPackageByNameFromAllNodesAPI(name, allNodesAPI = {}) {
|
|
7566
|
+
for (const key in allNodesAPI) {
|
|
7567
|
+
if (allNodesAPI[key]?.package?.name === name) {
|
|
7568
|
+
return allNodesAPI[key].package;
|
|
7569
|
+
}
|
|
7570
|
+
}
|
|
7571
|
+
return void 0;
|
|
7457
7572
|
}
|
|
7458
7573
|
static install(c) {
|
|
7459
7574
|
c.bind(Vue3LibrariesBuilderPlugin).toSelf();
|
|
@@ -7689,15 +7804,16 @@ var Vue3ApplicationAssemblerPlugin = class {
|
|
|
7689
7804
|
const bizComponents = ir.bizComponents.flatMap((x) => {
|
|
7690
7805
|
return this.vue3CodegenPlugin.genFiles(x, manager);
|
|
7691
7806
|
});
|
|
7692
|
-
let
|
|
7693
|
-
if (!/\/$/.test(
|
|
7694
|
-
|
|
7807
|
+
let basePath = ir.configs.basePlatformConfig.basePath;
|
|
7808
|
+
if (!/\/$/.test(basePath)) {
|
|
7809
|
+
basePath += "/";
|
|
7695
7810
|
}
|
|
7696
|
-
const routesObjects = this.routesExtactor.extractRoute(ir.views,
|
|
7811
|
+
const routesObjects = this.routesExtactor.extractRoute(ir.views, basePath, {
|
|
7697
7812
|
lazy: true
|
|
7698
7813
|
});
|
|
7699
7814
|
const router = this.routerBuilder.routeToCode(routesObjects.routes, manager, {
|
|
7700
|
-
frameworkKind: "vue3"
|
|
7815
|
+
frameworkKind: "vue3",
|
|
7816
|
+
basePath
|
|
7701
7817
|
});
|
|
7702
7818
|
const routerFile = new ReactFileDescription("router.ts", router.imports, [], [router.code]);
|
|
7703
7819
|
const libraries = await this.librariesBuilder.buildLibrariesImport(ir, config);
|
|
@@ -7750,6 +7866,30 @@ var Vue3PresetPlugin = class {
|
|
|
7750
7866
|
const app = deserializeAppWhileKeepTypeAnnotation(appJson);
|
|
7751
7867
|
const frontend = app.findNodeByPath(instruction.frontend.nodePath);
|
|
7752
7868
|
const ir = this.irBuilder.buildIR(app, frontend, instruction.config);
|
|
7869
|
+
const needCompileViews = instruction.config?.needCompileViews ?? [];
|
|
7870
|
+
const isIncremental = needCompileViews.length > 0;
|
|
7871
|
+
if (isIncremental) {
|
|
7872
|
+
const filterChildComponents = (view, needCompileViews2) => {
|
|
7873
|
+
if (!view.childComponents?.length) {
|
|
7874
|
+
return;
|
|
7875
|
+
}
|
|
7876
|
+
view.childComponents = view.childComponents.filter((child) => {
|
|
7877
|
+
if (needCompileViews2.includes(child.__raw.nodePath)) {
|
|
7878
|
+
filterChildComponents(child, needCompileViews2);
|
|
7879
|
+
return true;
|
|
7880
|
+
}
|
|
7881
|
+
return false;
|
|
7882
|
+
});
|
|
7883
|
+
};
|
|
7884
|
+
ir.views = ir.views.filter((view) => {
|
|
7885
|
+
if (needCompileViews.includes(view.__raw.nodePath)) {
|
|
7886
|
+
filterChildComponents(view, needCompileViews);
|
|
7887
|
+
return true;
|
|
7888
|
+
}
|
|
7889
|
+
return false;
|
|
7890
|
+
});
|
|
7891
|
+
ir.bizComponents = [];
|
|
7892
|
+
}
|
|
7753
7893
|
const assembledApplication = await this.applicationAssembler.assemble(ir, instruction.config);
|
|
7754
7894
|
const finalizedFiles = await this.projectOrganizer.organize({
|
|
7755
7895
|
baseDir: instruction.baseDir,
|
|
@@ -7831,7 +7971,7 @@ async function translateNASLToApp(app, frontend, config, baseDir = "./out", cont
|
|
|
7831
7971
|
if (needCompileViews?.length > 0) {
|
|
7832
7972
|
let traverseChildren2 = function(view, callback) {
|
|
7833
7973
|
if (view.children?.length > 0) {
|
|
7834
|
-
view.children.forEach((childView) => {
|
|
7974
|
+
[...view.children].forEach((childView) => {
|
|
7835
7975
|
const deep = callback(childView);
|
|
7836
7976
|
if (deep) {
|
|
7837
7977
|
traverseChildren2(childView, callback);
|
|
@@ -7841,9 +7981,10 @@ async function translateNASLToApp(app, frontend, config, baseDir = "./out", cont
|
|
|
7841
7981
|
};
|
|
7842
7982
|
var traverseChildren = traverseChildren2;
|
|
7843
7983
|
logger13.info("\u5F00\u59CB\u6309\u9700\u7FFB\u8BD1\u9875\u9762");
|
|
7844
|
-
frontend.views.forEach((view) => {
|
|
7984
|
+
[...frontend.views].forEach((view) => {
|
|
7845
7985
|
if (!needCompileViews.includes(view.nodePath)) {
|
|
7846
7986
|
view.delete();
|
|
7987
|
+
console.log(`\u5220\u9664\u9875\u9762 ${view.nodePath}\uFF0C\u56E0\u4E3A\u5B83\u4E0D\u5728 needCompileViews \u4E2D`);
|
|
7847
7988
|
} else {
|
|
7848
7989
|
traverseChildren2(view, (childView) => {
|
|
7849
7990
|
if (!needCompileViews.includes(childView.nodePath)) {
|
|
@@ -7952,7 +8093,11 @@ async function compileAsProject(app, frontend, config, container) {
|
|
|
7952
8093
|
logger13.info("\u8FDC\u7A0B\u52A0\u8F7D\u6A21\u677F\u6210\u529F");
|
|
7953
8094
|
const files = res.files;
|
|
7954
8095
|
Object.entries(files).forEach(([k, v]) => {
|
|
7955
|
-
|
|
8096
|
+
if (typeof v.code === "string") {
|
|
8097
|
+
fs.write(k, v.code);
|
|
8098
|
+
} else if (v.code?.type === "Buffer") {
|
|
8099
|
+
fs.write(k, Buffer.from(v.code.data));
|
|
8100
|
+
}
|
|
7956
8101
|
});
|
|
7957
8102
|
} catch (error) {
|
|
7958
8103
|
throw new Error(`\u8FDC\u7A0B\u52A0\u8F7D\u6A21\u677F\u5931\u8D25`);
|