@lcap/nasl-unified-frontend-generator 4.1.0-beta.3 → 4.1.0-beta.4
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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +57 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +57 -21
- package/dist/index.mjs.map +1 -1
- package/dist/playground.js +129266 -22
- package/dist/playground.js.map +1 -1
- package/dist/playground.mjs +129266 -22
- package/dist/playground.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -4157,7 +4157,7 @@ var ReactCodegenPlugin = class {
|
|
|
4157
4157
|
const exts = packages.filter((x) => x.kind === "extension");
|
|
4158
4158
|
const imports = exts.map((ext) => {
|
|
4159
4159
|
return {
|
|
4160
|
-
from:
|
|
4160
|
+
from: `${ext.name}`,
|
|
4161
4161
|
import: `* as ${kebab2Pascal(ext.name)}`
|
|
4162
4162
|
};
|
|
4163
4163
|
}).filter(isNotNil);
|
|
@@ -4786,7 +4786,7 @@ function getReferencedLibComponent(e) {
|
|
|
4786
4786
|
if (tag === "Router") {
|
|
4787
4787
|
return { kind: "library", libraryName: "react-router-dom", tag: "Outlet" };
|
|
4788
4788
|
}
|
|
4789
|
-
const libraryName = foundExtension ?
|
|
4789
|
+
const libraryName = foundExtension ? `${foundExtension.name}` : DefaultComponentLibraryName;
|
|
4790
4790
|
return { kind: "library", libraryName, tag };
|
|
4791
4791
|
} else if (tag) {
|
|
4792
4792
|
return { kind: "library", libraryName: DefaultComponentLibraryName, tag };
|
|
@@ -5476,14 +5476,14 @@ var NASLAppIRBuilderPlugin = class {
|
|
|
5476
5476
|
}
|
|
5477
5477
|
enchanceHackForAppPackageInfos(app, commonAppConfig) {
|
|
5478
5478
|
app.loadPackageInfos(getPredefinedMaterialConfig());
|
|
5479
|
-
const
|
|
5480
|
-
|
|
5481
|
-
config.allNodesAPI = commonAppConfig.allNodesAPI;
|
|
5482
|
-
}
|
|
5483
|
-
config.allNodesAPI ??= {};
|
|
5479
|
+
const naslStoreConfig = (0, import_nasl_concepts9.getConfig)();
|
|
5480
|
+
naslStoreConfig.allNodesAPI = commonAppConfig.allNodesAPI || {};
|
|
5484
5481
|
(0, import_nasl_concepts9.initialize)({
|
|
5485
5482
|
getConfig: () => {
|
|
5486
|
-
return
|
|
5483
|
+
return {
|
|
5484
|
+
...commonAppConfig || {},
|
|
5485
|
+
...naslStoreConfig || {}
|
|
5486
|
+
};
|
|
5487
5487
|
}
|
|
5488
5488
|
});
|
|
5489
5489
|
}
|
|
@@ -7014,13 +7014,12 @@ var BundlerConfigDataPlugin = class {
|
|
|
7014
7014
|
if (target) {
|
|
7015
7015
|
return {
|
|
7016
7016
|
name: dep.name,
|
|
7017
|
-
resolvedTo: `./src/${target}`.replace(/\/index\.js$/, "")
|
|
7018
|
-
scope: dep.kind === "extension" ? "@extension" : void 0
|
|
7017
|
+
resolvedTo: `./src/${target}`.replace(/\/index\.js$/, "")
|
|
7019
7018
|
};
|
|
7020
7019
|
}
|
|
7021
7020
|
return void 0;
|
|
7022
7021
|
}).filter(isNotNil).map((x) => {
|
|
7023
|
-
const name = x.
|
|
7022
|
+
const name = x.name;
|
|
7024
7023
|
return {
|
|
7025
7024
|
pkgName: name,
|
|
7026
7025
|
...x
|
|
@@ -7083,18 +7082,48 @@ var RspackConfigPlugin = class {
|
|
|
7083
7082
|
);
|
|
7084
7083
|
}
|
|
7085
7084
|
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"}`);
|
|
7086
|
-
if (config.needCompileViews && config.needCompileViews.length > 0 && config.cacheChunksMapCode) {
|
|
7085
|
+
if (config.env === "dev" && config.needCompileViews && config.needCompileViews.length > 0 && config.cacheChunksMapCode) {
|
|
7087
7086
|
rspackConfigSource = rspackConfigSource.replace("isIncremental: false", "isIncremental: true").replace("chunksMap: ''", `chunksMap: \`${config.cacheChunksMapCode}\``);
|
|
7088
7087
|
}
|
|
7089
7088
|
if (config.isExport) {
|
|
7090
7089
|
rspackConfigSource = rspackConfigSource.replace(/\/\/ LcapPlugin start\s+new LcapPlugin\(\{[\s\S]*?\}\),\s+\/\/ LcapPlugin end/g, "");
|
|
7091
7090
|
}
|
|
7091
|
+
rspackConfigSource = await this.processLoadOnDemand(rspackConfigSource, {
|
|
7092
|
+
app,
|
|
7093
|
+
frontend,
|
|
7094
|
+
config,
|
|
7095
|
+
fs,
|
|
7096
|
+
frameworkKind
|
|
7097
|
+
});
|
|
7092
7098
|
fs.write(
|
|
7093
7099
|
"/rspack.config.js",
|
|
7094
7100
|
rspackConfigSource
|
|
7095
7101
|
);
|
|
7096
7102
|
}
|
|
7097
7103
|
}
|
|
7104
|
+
/**
|
|
7105
|
+
* 处理按需加载
|
|
7106
|
+
* 注意:此功能仅在非dev环境下的vue3框架中可以启用。
|
|
7107
|
+
* @param source 源代码
|
|
7108
|
+
* @param options 选项
|
|
7109
|
+
* @returns 处理后的代码
|
|
7110
|
+
*/
|
|
7111
|
+
async processLoadOnDemand(source, options) {
|
|
7112
|
+
let code = source;
|
|
7113
|
+
const { app, frontend, config, fs, frameworkKind } = options;
|
|
7114
|
+
const feLoadDependenciesOnDemand = config.feLoadDependenciesOnDemand;
|
|
7115
|
+
if (config.env !== "dev" && ["vue3"].includes(frameworkKind) && feLoadDependenciesOnDemand) {
|
|
7116
|
+
const feDeps = [...extractAppLevelFrontendDeps(app), ...extractFrontendLevelDeps(frontend)];
|
|
7117
|
+
code = code.replace("// swc plugin placeholder", `experimental: {
|
|
7118
|
+
plugins: [
|
|
7119
|
+
['@lcap/swc-plugin-import', require('./scripts/generateSwcImportPluginConfig')([
|
|
7120
|
+
${feDeps.map((dep) => "'" + dep.name + "'").join(",\n")}
|
|
7121
|
+
])]
|
|
7122
|
+
]
|
|
7123
|
+
}`);
|
|
7124
|
+
}
|
|
7125
|
+
return code;
|
|
7126
|
+
}
|
|
7098
7127
|
static install(c) {
|
|
7099
7128
|
c.bind(ServiceMetaKind.FrontendBundlerFileConfig).to(RspackConfigPlugin).inSingletonScope();
|
|
7100
7129
|
return c;
|
|
@@ -7503,10 +7532,8 @@ var Vue3LibrariesBuilderPlugin = class {
|
|
|
7503
7532
|
const exportArr = [];
|
|
7504
7533
|
const standardLib = ir.packages.find((x) => x.kind === "standard");
|
|
7505
7534
|
if (standardLib) {
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
exportArr.push(`export { ${formattedName} };`);
|
|
7509
|
-
exportArr.push(`window.lcapStandardUI = ${formattedName};`);
|
|
7535
|
+
importArr.push(`import { ConfigProvider, transformKeys } from '${standardLib.name}';`);
|
|
7536
|
+
exportArr.push(`window.lcapStandardUI = { ConfigProvider, transformKeys };`);
|
|
7510
7537
|
const isPackageZipExists = await judgePackageZipExists(standardLib, config.STATIC_URL);
|
|
7511
7538
|
importArr.push(
|
|
7512
7539
|
`import '${standardLib.name}${isPackageZipExists ? "/dist-theme" : ""}/index.css';`
|
|
@@ -7514,18 +7541,23 @@ var Vue3LibrariesBuilderPlugin = class {
|
|
|
7514
7541
|
}
|
|
7515
7542
|
const extensions = ir.packages.filter((x) => x.kind === "extension");
|
|
7516
7543
|
for (const ext of extensions) {
|
|
7517
|
-
const formattedName = kebab2Pascal(ext.name.split("/").at(-1));
|
|
7518
7544
|
const isPackageZipExists = await judgePackageZipExists(ext, config.STATIC_URL);
|
|
7519
|
-
const prefix = isPackageZipExists ? "" : "@extension/";
|
|
7520
|
-
exportArr.push(`export * as ${formattedName} from '${prefix}${ext.name}';`);
|
|
7521
7545
|
if (ext.hasCss) {
|
|
7522
7546
|
importArr.push(
|
|
7523
|
-
`import '${
|
|
7547
|
+
`import '${ext.name}${isPackageZipExists ? "/dist-theme" : ""}/index.css';`
|
|
7524
7548
|
);
|
|
7525
7549
|
}
|
|
7526
7550
|
}
|
|
7527
7551
|
return new ReactFileDescription("libraries.ts", [], [], [[...importArr, ...exportArr].join("\n")]);
|
|
7528
7552
|
}
|
|
7553
|
+
findPackageByNameFromAllNodesAPI(name, allNodesAPI = {}) {
|
|
7554
|
+
for (const key in allNodesAPI) {
|
|
7555
|
+
if (allNodesAPI[key]?.package?.name === name) {
|
|
7556
|
+
return allNodesAPI[key].package;
|
|
7557
|
+
}
|
|
7558
|
+
}
|
|
7559
|
+
return void 0;
|
|
7560
|
+
}
|
|
7529
7561
|
static install(c) {
|
|
7530
7562
|
c.bind(Vue3LibrariesBuilderPlugin).toSelf();
|
|
7531
7563
|
return c;
|
|
@@ -8049,7 +8081,11 @@ async function compileAsProject(app, frontend, config, container) {
|
|
|
8049
8081
|
logger13.info("\u8FDC\u7A0B\u52A0\u8F7D\u6A21\u677F\u6210\u529F");
|
|
8050
8082
|
const files = res.files;
|
|
8051
8083
|
Object.entries(files).forEach(([k, v]) => {
|
|
8052
|
-
|
|
8084
|
+
if (typeof v.code === "string") {
|
|
8085
|
+
fs.write(k, v.code);
|
|
8086
|
+
} else if (v.code?.type === "Buffer") {
|
|
8087
|
+
fs.write(k, Buffer.from(v.code.data));
|
|
8088
|
+
}
|
|
8053
8089
|
});
|
|
8054
8090
|
} catch (error) {
|
|
8055
8091
|
throw new Error(`\u8FDC\u7A0B\u52A0\u8F7D\u6A21\u677F\u5931\u8D25`);
|