@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.mjs
CHANGED
|
@@ -4212,7 +4212,7 @@ var ReactCodegenPlugin = class {
|
|
|
4212
4212
|
const exts = packages.filter((x) => x.kind === "extension");
|
|
4213
4213
|
const imports = exts.map((ext) => {
|
|
4214
4214
|
return {
|
|
4215
|
-
from:
|
|
4215
|
+
from: `${ext.name}`,
|
|
4216
4216
|
import: `* as ${kebab2Pascal(ext.name)}`
|
|
4217
4217
|
};
|
|
4218
4218
|
}).filter(isNotNil);
|
|
@@ -4841,7 +4841,7 @@ function getReferencedLibComponent(e) {
|
|
|
4841
4841
|
if (tag === "Router") {
|
|
4842
4842
|
return { kind: "library", libraryName: "react-router-dom", tag: "Outlet" };
|
|
4843
4843
|
}
|
|
4844
|
-
const libraryName = foundExtension ?
|
|
4844
|
+
const libraryName = foundExtension ? `${foundExtension.name}` : DefaultComponentLibraryName;
|
|
4845
4845
|
return { kind: "library", libraryName, tag };
|
|
4846
4846
|
} else if (tag) {
|
|
4847
4847
|
return { kind: "library", libraryName: DefaultComponentLibraryName, tag };
|
|
@@ -5531,14 +5531,14 @@ var NASLAppIRBuilderPlugin = class {
|
|
|
5531
5531
|
}
|
|
5532
5532
|
enchanceHackForAppPackageInfos(app, commonAppConfig) {
|
|
5533
5533
|
app.loadPackageInfos(getPredefinedMaterialConfig());
|
|
5534
|
-
const
|
|
5535
|
-
|
|
5536
|
-
config.allNodesAPI = commonAppConfig.allNodesAPI;
|
|
5537
|
-
}
|
|
5538
|
-
config.allNodesAPI ??= {};
|
|
5534
|
+
const naslStoreConfig = getConfig();
|
|
5535
|
+
naslStoreConfig.allNodesAPI = commonAppConfig.allNodesAPI || {};
|
|
5539
5536
|
initialize({
|
|
5540
5537
|
getConfig: () => {
|
|
5541
|
-
return
|
|
5538
|
+
return {
|
|
5539
|
+
...commonAppConfig || {},
|
|
5540
|
+
...naslStoreConfig || {}
|
|
5541
|
+
};
|
|
5542
5542
|
}
|
|
5543
5543
|
});
|
|
5544
5544
|
}
|
|
@@ -7069,13 +7069,12 @@ var BundlerConfigDataPlugin = class {
|
|
|
7069
7069
|
if (target) {
|
|
7070
7070
|
return {
|
|
7071
7071
|
name: dep.name,
|
|
7072
|
-
resolvedTo: `./src/${target}`.replace(/\/index\.js$/, "")
|
|
7073
|
-
scope: dep.kind === "extension" ? "@extension" : void 0
|
|
7072
|
+
resolvedTo: `./src/${target}`.replace(/\/index\.js$/, "")
|
|
7074
7073
|
};
|
|
7075
7074
|
}
|
|
7076
7075
|
return void 0;
|
|
7077
7076
|
}).filter(isNotNil).map((x) => {
|
|
7078
|
-
const name = x.
|
|
7077
|
+
const name = x.name;
|
|
7079
7078
|
return {
|
|
7080
7079
|
pkgName: name,
|
|
7081
7080
|
...x
|
|
@@ -7138,18 +7137,48 @@ var RspackConfigPlugin = class {
|
|
|
7138
7137
|
);
|
|
7139
7138
|
}
|
|
7140
7139
|
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"}`);
|
|
7141
|
-
if (config.needCompileViews && config.needCompileViews.length > 0 && config.cacheChunksMapCode) {
|
|
7140
|
+
if (config.env === "dev" && config.needCompileViews && config.needCompileViews.length > 0 && config.cacheChunksMapCode) {
|
|
7142
7141
|
rspackConfigSource = rspackConfigSource.replace("isIncremental: false", "isIncremental: true").replace("chunksMap: ''", `chunksMap: \`${config.cacheChunksMapCode}\``);
|
|
7143
7142
|
}
|
|
7144
7143
|
if (config.isExport) {
|
|
7145
7144
|
rspackConfigSource = rspackConfigSource.replace(/\/\/ LcapPlugin start\s+new LcapPlugin\(\{[\s\S]*?\}\),\s+\/\/ LcapPlugin end/g, "");
|
|
7146
7145
|
}
|
|
7146
|
+
rspackConfigSource = await this.processLoadOnDemand(rspackConfigSource, {
|
|
7147
|
+
app,
|
|
7148
|
+
frontend,
|
|
7149
|
+
config,
|
|
7150
|
+
fs,
|
|
7151
|
+
frameworkKind
|
|
7152
|
+
});
|
|
7147
7153
|
fs.write(
|
|
7148
7154
|
"/rspack.config.js",
|
|
7149
7155
|
rspackConfigSource
|
|
7150
7156
|
);
|
|
7151
7157
|
}
|
|
7152
7158
|
}
|
|
7159
|
+
/**
|
|
7160
|
+
* 处理按需加载
|
|
7161
|
+
* 注意:此功能仅在非dev环境下的vue3框架中可以启用。
|
|
7162
|
+
* @param source 源代码
|
|
7163
|
+
* @param options 选项
|
|
7164
|
+
* @returns 处理后的代码
|
|
7165
|
+
*/
|
|
7166
|
+
async processLoadOnDemand(source, options) {
|
|
7167
|
+
let code = source;
|
|
7168
|
+
const { app, frontend, config, fs, frameworkKind } = options;
|
|
7169
|
+
const feLoadDependenciesOnDemand = config.feLoadDependenciesOnDemand;
|
|
7170
|
+
if (config.env !== "dev" && ["vue3"].includes(frameworkKind) && feLoadDependenciesOnDemand) {
|
|
7171
|
+
const feDeps = [...extractAppLevelFrontendDeps(app), ...extractFrontendLevelDeps(frontend)];
|
|
7172
|
+
code = code.replace("// swc plugin placeholder", `experimental: {
|
|
7173
|
+
plugins: [
|
|
7174
|
+
['@lcap/swc-plugin-import', require('./scripts/generateSwcImportPluginConfig')([
|
|
7175
|
+
${feDeps.map((dep) => "'" + dep.name + "'").join(",\n")}
|
|
7176
|
+
])]
|
|
7177
|
+
]
|
|
7178
|
+
}`);
|
|
7179
|
+
}
|
|
7180
|
+
return code;
|
|
7181
|
+
}
|
|
7153
7182
|
static install(c) {
|
|
7154
7183
|
c.bind(ServiceMetaKind.FrontendBundlerFileConfig).to(RspackConfigPlugin).inSingletonScope();
|
|
7155
7184
|
return c;
|
|
@@ -7558,10 +7587,8 @@ var Vue3LibrariesBuilderPlugin = class {
|
|
|
7558
7587
|
const exportArr = [];
|
|
7559
7588
|
const standardLib = ir.packages.find((x) => x.kind === "standard");
|
|
7560
7589
|
if (standardLib) {
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
exportArr.push(`export { ${formattedName} };`);
|
|
7564
|
-
exportArr.push(`window.lcapStandardUI = ${formattedName};`);
|
|
7590
|
+
importArr.push(`import { ConfigProvider, transformKeys } from '${standardLib.name}';`);
|
|
7591
|
+
exportArr.push(`window.lcapStandardUI = { ConfigProvider, transformKeys };`);
|
|
7565
7592
|
const isPackageZipExists = await judgePackageZipExists(standardLib, config.STATIC_URL);
|
|
7566
7593
|
importArr.push(
|
|
7567
7594
|
`import '${standardLib.name}${isPackageZipExists ? "/dist-theme" : ""}/index.css';`
|
|
@@ -7569,18 +7596,23 @@ var Vue3LibrariesBuilderPlugin = class {
|
|
|
7569
7596
|
}
|
|
7570
7597
|
const extensions = ir.packages.filter((x) => x.kind === "extension");
|
|
7571
7598
|
for (const ext of extensions) {
|
|
7572
|
-
const formattedName = kebab2Pascal(ext.name.split("/").at(-1));
|
|
7573
7599
|
const isPackageZipExists = await judgePackageZipExists(ext, config.STATIC_URL);
|
|
7574
|
-
const prefix = isPackageZipExists ? "" : "@extension/";
|
|
7575
|
-
exportArr.push(`export * as ${formattedName} from '${prefix}${ext.name}';`);
|
|
7576
7600
|
if (ext.hasCss) {
|
|
7577
7601
|
importArr.push(
|
|
7578
|
-
`import '${
|
|
7602
|
+
`import '${ext.name}${isPackageZipExists ? "/dist-theme" : ""}/index.css';`
|
|
7579
7603
|
);
|
|
7580
7604
|
}
|
|
7581
7605
|
}
|
|
7582
7606
|
return new ReactFileDescription("libraries.ts", [], [], [[...importArr, ...exportArr].join("\n")]);
|
|
7583
7607
|
}
|
|
7608
|
+
findPackageByNameFromAllNodesAPI(name, allNodesAPI = {}) {
|
|
7609
|
+
for (const key in allNodesAPI) {
|
|
7610
|
+
if (allNodesAPI[key]?.package?.name === name) {
|
|
7611
|
+
return allNodesAPI[key].package;
|
|
7612
|
+
}
|
|
7613
|
+
}
|
|
7614
|
+
return void 0;
|
|
7615
|
+
}
|
|
7584
7616
|
static install(c) {
|
|
7585
7617
|
c.bind(Vue3LibrariesBuilderPlugin).toSelf();
|
|
7586
7618
|
return c;
|
|
@@ -8104,7 +8136,11 @@ async function compileAsProject(app, frontend, config, container) {
|
|
|
8104
8136
|
logger13.info("\u8FDC\u7A0B\u52A0\u8F7D\u6A21\u677F\u6210\u529F");
|
|
8105
8137
|
const files = res.files;
|
|
8106
8138
|
Object.entries(files).forEach(([k, v]) => {
|
|
8107
|
-
|
|
8139
|
+
if (typeof v.code === "string") {
|
|
8140
|
+
fs.write(k, v.code);
|
|
8141
|
+
} else if (v.code?.type === "Buffer") {
|
|
8142
|
+
fs.write(k, Buffer.from(v.code.data));
|
|
8143
|
+
}
|
|
8108
8144
|
});
|
|
8109
8145
|
} catch (error) {
|
|
8110
8146
|
throw new Error(`\u8FDC\u7A0B\u52A0\u8F7D\u6A21\u677F\u5931\u8D25`);
|