@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.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,6 +29,75 @@ 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";
@@ -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: `@extension/${ext.name}`,
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-beta.1"
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
- b.type = "dynamic";
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 = getPredefinedLibConstants().reactUI.name;
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 ? `@extension/${foundExtension.name}` : DefaultComponentLibraryName;
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 libs = getPredefinedLibConstants();
5424
- return [...extensionPackages, frameworkKind === "vue3" ? libs.vue3Ui : libs.reactUI];
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 config = getConfig();
5466
- if (commonAppConfig.allNodesAPI) {
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 config;
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
- if (frontend.frameworkKind === "react") {
6794
- deps.push(getPredefinedLibConstants().reactUI);
6795
- } else if (frontend.frameworkKind === "vue3") {
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.dependencies) {
6970
- packageJson.dependencies = {};
7041
+ if (!packageJson.lcap_modules) {
7042
+ packageJson.lcap_modules = {};
6971
7043
  }
6972
7044
  downloadedDeps.forEach(({ pkgName, targetPath }) => {
6973
- packageJson.dependencies[pkgName] = `.${targetPath}`;
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.scope ? `${x.scope}/${x.name}` : x.name;
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
- const code = `
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 path = r.thisLevelPath ?? "/";
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: "${isRoot ? r.accumulativePath : path}", meta: ${JSON.stringify(
7449
+ return `{path: "${path}", meta: ${JSON.stringify(
7333
7450
  r.meta
7334
7451
  )}, children: [${childrenStr}], ${componentCode} }`;
7335
7452
  } else if (r.kind === "redirect") {
7336
- const replaceWildCardForVue3 = (frameworkKind, path2) => {
7337
- if (frameworkKind === "vue3" && path2 === "*") {
7338
- return "/:pathMatch(.*)*";
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 path2;
7341
- };
7342
- const processedPath = replaceWildCardForVue3(config.frameworkKind, path);
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
- const code = `
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,11 @@ 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
- const formattedName = kebab2Pascal(standardLib.name.split("/").at(-1));
7478
- importArr.push(`export * as ${formattedName} from '${standardLib.name}';`);
7603
+ importArr.push(`import { ConfigProvider, transformKeys } from '${standardLib.name}';`);
7604
+ exportArr.push(`window.lcapStandardUI = { ConfigProvider, transformKeys };`);
7479
7605
  const isPackageZipExists = await judgePackageZipExists(standardLib, config.STATIC_URL);
7480
7606
  importArr.push(
7481
7607
  `import '${standardLib.name}${isPackageZipExists ? "/dist-theme" : ""}/index.css';`
@@ -7483,17 +7609,22 @@ var Vue3LibrariesBuilderPlugin = class {
7483
7609
  }
7484
7610
  const extensions = ir.packages.filter((x) => x.kind === "extension");
7485
7611
  for (const ext of extensions) {
7486
- const formattedName = kebab2Pascal(ext.name.split("/").at(-1));
7487
7612
  const isPackageZipExists = await judgePackageZipExists(ext, config.STATIC_URL);
7488
- const prefix = isPackageZipExists ? "" : "@extension/";
7489
- importArr.push(`export * as ${formattedName} from '${prefix}${ext.name}';`);
7490
7613
  if (ext.hasCss) {
7491
7614
  importArr.push(
7492
- `import '${prefix}${ext.name}${isPackageZipExists ? "/dist-theme" : ""}/index.css';`
7615
+ `import '${ext.name}${isPackageZipExists ? "/dist-theme" : ""}/index.css';`
7493
7616
  );
7494
7617
  }
7495
7618
  }
7496
- return new ReactFileDescription("libraries.ts", [], [], [importArr.join("\n")]);
7619
+ return new ReactFileDescription("libraries.ts", [], [], [[...importArr, ...exportArr].join("\n")]);
7620
+ }
7621
+ findPackageByNameFromAllNodesAPI(name, allNodesAPI = {}) {
7622
+ for (const key in allNodesAPI) {
7623
+ if (allNodesAPI[key]?.package?.name === name) {
7624
+ return allNodesAPI[key].package;
7625
+ }
7626
+ }
7627
+ return void 0;
7497
7628
  }
7498
7629
  static install(c) {
7499
7630
  c.bind(Vue3LibrariesBuilderPlugin).toSelf();
@@ -7729,15 +7860,16 @@ var Vue3ApplicationAssemblerPlugin = class {
7729
7860
  const bizComponents = ir.bizComponents.flatMap((x) => {
7730
7861
  return this.vue3CodegenPlugin.genFiles(x, manager);
7731
7862
  });
7732
- let routePrefix = ir.configs.frontendDesc.path;
7733
- if (!/\/$/.test(routePrefix)) {
7734
- routePrefix += "/";
7863
+ let basePath = ir.configs.basePlatformConfig.basePath;
7864
+ if (!/\/$/.test(basePath)) {
7865
+ basePath += "/";
7735
7866
  }
7736
- const routesObjects = this.routesExtactor.extractRoute(ir.views, routePrefix, {
7867
+ const routesObjects = this.routesExtactor.extractRoute(ir.views, basePath, {
7737
7868
  lazy: true
7738
7869
  });
7739
7870
  const router = this.routerBuilder.routeToCode(routesObjects.routes, manager, {
7740
- frameworkKind: "vue3"
7871
+ frameworkKind: "vue3",
7872
+ basePath
7741
7873
  });
7742
7874
  const routerFile = new ReactFileDescription("router.ts", router.imports, [], [router.code]);
7743
7875
  const libraries = await this.librariesBuilder.buildLibrariesImport(ir, config);
@@ -7790,6 +7922,30 @@ var Vue3PresetPlugin = class {
7790
7922
  const app = deserializeAppWhileKeepTypeAnnotation(appJson);
7791
7923
  const frontend = app.findNodeByPath(instruction.frontend.nodePath);
7792
7924
  const ir = this.irBuilder.buildIR(app, frontend, instruction.config);
7925
+ const needCompileViews = instruction.config?.needCompileViews ?? [];
7926
+ const isIncremental = needCompileViews.length > 0;
7927
+ if (isIncremental) {
7928
+ const filterChildComponents = (view, needCompileViews2) => {
7929
+ if (!view.childComponents?.length) {
7930
+ return;
7931
+ }
7932
+ view.childComponents = view.childComponents.filter((child) => {
7933
+ if (needCompileViews2.includes(child.__raw.nodePath)) {
7934
+ filterChildComponents(child, needCompileViews2);
7935
+ return true;
7936
+ }
7937
+ return false;
7938
+ });
7939
+ };
7940
+ ir.views = ir.views.filter((view) => {
7941
+ if (needCompileViews.includes(view.__raw.nodePath)) {
7942
+ filterChildComponents(view, needCompileViews);
7943
+ return true;
7944
+ }
7945
+ return false;
7946
+ });
7947
+ ir.bizComponents = [];
7948
+ }
7793
7949
  const assembledApplication = await this.applicationAssembler.assemble(ir, instruction.config);
7794
7950
  const finalizedFiles = await this.projectOrganizer.organize({
7795
7951
  baseDir: instruction.baseDir,
@@ -7871,7 +8027,7 @@ async function translateNASLToApp(app, frontend, config, baseDir = "./out", cont
7871
8027
  if (needCompileViews?.length > 0) {
7872
8028
  let traverseChildren2 = function(view, callback) {
7873
8029
  if (view.children?.length > 0) {
7874
- view.children.forEach((childView) => {
8030
+ [...view.children].forEach((childView) => {
7875
8031
  const deep = callback(childView);
7876
8032
  if (deep) {
7877
8033
  traverseChildren2(childView, callback);
@@ -7881,9 +8037,10 @@ async function translateNASLToApp(app, frontend, config, baseDir = "./out", cont
7881
8037
  };
7882
8038
  var traverseChildren = traverseChildren2;
7883
8039
  logger13.info("\u5F00\u59CB\u6309\u9700\u7FFB\u8BD1\u9875\u9762");
7884
- frontend.views.forEach((view) => {
8040
+ [...frontend.views].forEach((view) => {
7885
8041
  if (!needCompileViews.includes(view.nodePath)) {
7886
8042
  view.delete();
8043
+ console.log(`\u5220\u9664\u9875\u9762 ${view.nodePath}\uFF0C\u56E0\u4E3A\u5B83\u4E0D\u5728 needCompileViews \u4E2D`);
7887
8044
  } else {
7888
8045
  traverseChildren2(view, (childView) => {
7889
8046
  if (!needCompileViews.includes(childView.nodePath)) {
@@ -7992,7 +8149,11 @@ async function compileAsProject(app, frontend, config, container) {
7992
8149
  logger13.info("\u8FDC\u7A0B\u52A0\u8F7D\u6A21\u677F\u6210\u529F");
7993
8150
  const files = res.files;
7994
8151
  Object.entries(files).forEach(([k, v]) => {
7995
- fs.write(k, v.code);
8152
+ if (typeof v.code === "string") {
8153
+ fs.write(k, v.code);
8154
+ } else if (v.code?.type === "Buffer") {
8155
+ fs.write(k, Buffer.from(v.code.data));
8156
+ }
7996
8157
  });
7997
8158
  } catch (error) {
7998
8159
  throw new Error(`\u8FDC\u7A0B\u52A0\u8F7D\u6A21\u677F\u5931\u8D25`);