@lcap/nasl-unified-frontend-generator 4.1.0-beta.3 → 4.1.0-beta.5
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 +58 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -21
- package/dist/index.mjs.map +1 -1
- package/dist/playground.js +129267 -22
- package/dist/playground.js.map +1 -1
- package/dist/playground.mjs +129267 -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,49 @@ 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 { env, feLoadDependenciesOnDemand, isExport } = config;
|
|
7170
|
+
const enablePerformance = feLoadDependenciesOnDemand && (isExport || env !== "dev") && ["vue3"].includes(frameworkKind);
|
|
7171
|
+
if (enablePerformance) {
|
|
7172
|
+
const feDeps = [...extractAppLevelFrontendDeps(app), ...extractFrontendLevelDeps(frontend)];
|
|
7173
|
+
code = code.replaceAll("// swc plugin placeholder", `experimental: {
|
|
7174
|
+
plugins: [
|
|
7175
|
+
['@lcap/swc-plugin-import', require('./scripts/generateSwcImportPluginConfig')([
|
|
7176
|
+
${feDeps.map((dep) => "'" + dep.name + "'").join(",\n")}
|
|
7177
|
+
])]
|
|
7178
|
+
]
|
|
7179
|
+
}`);
|
|
7180
|
+
}
|
|
7181
|
+
return code;
|
|
7182
|
+
}
|
|
7153
7183
|
static install(c) {
|
|
7154
7184
|
c.bind(ServiceMetaKind.FrontendBundlerFileConfig).to(RspackConfigPlugin).inSingletonScope();
|
|
7155
7185
|
return c;
|
|
@@ -7558,10 +7588,8 @@ var Vue3LibrariesBuilderPlugin = class {
|
|
|
7558
7588
|
const exportArr = [];
|
|
7559
7589
|
const standardLib = ir.packages.find((x) => x.kind === "standard");
|
|
7560
7590
|
if (standardLib) {
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
exportArr.push(`export { ${formattedName} };`);
|
|
7564
|
-
exportArr.push(`window.lcapStandardUI = ${formattedName};`);
|
|
7591
|
+
importArr.push(`import { ConfigProvider, transformKeys } from '${standardLib.name}';`);
|
|
7592
|
+
exportArr.push(`window.lcapStandardUI = { ConfigProvider, transformKeys };`);
|
|
7565
7593
|
const isPackageZipExists = await judgePackageZipExists(standardLib, config.STATIC_URL);
|
|
7566
7594
|
importArr.push(
|
|
7567
7595
|
`import '${standardLib.name}${isPackageZipExists ? "/dist-theme" : ""}/index.css';`
|
|
@@ -7569,18 +7597,23 @@ var Vue3LibrariesBuilderPlugin = class {
|
|
|
7569
7597
|
}
|
|
7570
7598
|
const extensions = ir.packages.filter((x) => x.kind === "extension");
|
|
7571
7599
|
for (const ext of extensions) {
|
|
7572
|
-
const formattedName = kebab2Pascal(ext.name.split("/").at(-1));
|
|
7573
7600
|
const isPackageZipExists = await judgePackageZipExists(ext, config.STATIC_URL);
|
|
7574
|
-
const prefix = isPackageZipExists ? "" : "@extension/";
|
|
7575
|
-
exportArr.push(`export * as ${formattedName} from '${prefix}${ext.name}';`);
|
|
7576
7601
|
if (ext.hasCss) {
|
|
7577
7602
|
importArr.push(
|
|
7578
|
-
`import '${
|
|
7603
|
+
`import '${ext.name}${isPackageZipExists ? "/dist-theme" : ""}/index.css';`
|
|
7579
7604
|
);
|
|
7580
7605
|
}
|
|
7581
7606
|
}
|
|
7582
7607
|
return new ReactFileDescription("libraries.ts", [], [], [[...importArr, ...exportArr].join("\n")]);
|
|
7583
7608
|
}
|
|
7609
|
+
findPackageByNameFromAllNodesAPI(name, allNodesAPI = {}) {
|
|
7610
|
+
for (const key in allNodesAPI) {
|
|
7611
|
+
if (allNodesAPI[key]?.package?.name === name) {
|
|
7612
|
+
return allNodesAPI[key].package;
|
|
7613
|
+
}
|
|
7614
|
+
}
|
|
7615
|
+
return void 0;
|
|
7616
|
+
}
|
|
7584
7617
|
static install(c) {
|
|
7585
7618
|
c.bind(Vue3LibrariesBuilderPlugin).toSelf();
|
|
7586
7619
|
return c;
|
|
@@ -8104,7 +8137,11 @@ async function compileAsProject(app, frontend, config, container) {
|
|
|
8104
8137
|
logger13.info("\u8FDC\u7A0B\u52A0\u8F7D\u6A21\u677F\u6210\u529F");
|
|
8105
8138
|
const files = res.files;
|
|
8106
8139
|
Object.entries(files).forEach(([k, v]) => {
|
|
8107
|
-
|
|
8140
|
+
if (typeof v.code === "string") {
|
|
8141
|
+
fs.write(k, v.code);
|
|
8142
|
+
} else if (v.code?.type === "Buffer") {
|
|
8143
|
+
fs.write(k, Buffer.from(v.code.data));
|
|
8144
|
+
}
|
|
8108
8145
|
});
|
|
8109
8146
|
} catch (error) {
|
|
8110
8147
|
throw new Error(`\u8FDC\u7A0B\u52A0\u8F7D\u6A21\u677F\u5931\u8D25`);
|