@lcap/nasl-unified-frontend-generator 4.1.0-beta.1 → 4.1.0-beta.2

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 CHANGED
@@ -117,7 +117,7 @@ interface I18nInfo {
117
117
  declare const metadataPlugin: {
118
118
  name: string;
119
119
  functions: {
120
- makeBasePlatformConfig(app: Pick<App, "name" | "dnsAddr" | "hasUserCenter" | "hasAuth" | "sysPrefixPath" | "id" | "appTimeZone">, frontend: Frontend, config: CommonAppConfig): BasePlatformConfig;
120
+ makeBasePlatformConfig(app: Pick<App, 'name' | 'dnsAddr' | 'hasUserCenter' | 'hasAuth' | 'sysPrefixPath' | 'id' | 'appTimeZone'>, frontend: Frontend, config: CommonAppConfig): BasePlatformConfig;
121
121
  };
122
122
  };
123
123
 
@@ -641,7 +641,7 @@ declare const routesExtractionPlugin: {
641
641
  functions: {
642
642
  extractRoute(components: ViewComponentIR[], routePrefix: string, options?: {
643
643
  lazy?: boolean;
644
- frameworkKind?: "react" | "vue2" | "vue3";
644
+ frameworkKind?: 'react' | 'vue2' | 'vue3';
645
645
  }): {
646
646
  routes: RouteIR[];
647
647
  authResourcePaths: string[];
@@ -1172,10 +1172,18 @@ declare const reactComponentLibHackPlugin: {
1172
1172
  name: string;
1173
1173
  functions: {
1174
1174
  __hooksDefinitions(): ReactFileDescription;
1175
- hackBindAttribute<T extends BindAttributeIR & {
1175
+ hackBindAttribute<T extends {
1176
1176
  kind: "expr";
1177
+ expression: ExprIR;
1178
+ __raw: _lcap_nasl_concepts.BindAttribute;
1179
+ sync: boolean;
1180
+ } & {
1181
+ concept: "BindAttribute";
1182
+ name: string;
1183
+ } & {
1184
+ kind: 'expr';
1177
1185
  }>(b: T): BindAttributeIR & {
1178
- kind: "expr";
1186
+ kind: 'expr';
1179
1187
  };
1180
1188
  };
1181
1189
  };
@@ -1672,7 +1680,7 @@ declare class VirtualProject {
1672
1680
  getFileDict(): {
1673
1681
  files: Record<string, ProjectFile>;
1674
1682
  };
1675
- readFile(path: string): string | Buffer<ArrayBufferLike>;
1683
+ readFile(path: string): string | Buffer;
1676
1684
  }
1677
1685
  declare function compileAsProject(app: App, frontend: Frontend, config: CommonAppConfig, container?: Container): Promise<VirtualProject>;
1678
1686
  declare function compileNASLToReactDist(app: App, frontend: Frontend, config: CommonAppConfig, http: AxiosInstance): Promise<OrganizedFile[]>;
package/dist/index.d.ts CHANGED
@@ -117,7 +117,7 @@ interface I18nInfo {
117
117
  declare const metadataPlugin: {
118
118
  name: string;
119
119
  functions: {
120
- makeBasePlatformConfig(app: Pick<App, "name" | "dnsAddr" | "hasUserCenter" | "hasAuth" | "sysPrefixPath" | "id" | "appTimeZone">, frontend: Frontend, config: CommonAppConfig): BasePlatformConfig;
120
+ makeBasePlatformConfig(app: Pick<App, 'name' | 'dnsAddr' | 'hasUserCenter' | 'hasAuth' | 'sysPrefixPath' | 'id' | 'appTimeZone'>, frontend: Frontend, config: CommonAppConfig): BasePlatformConfig;
121
121
  };
122
122
  };
123
123
 
@@ -641,7 +641,7 @@ declare const routesExtractionPlugin: {
641
641
  functions: {
642
642
  extractRoute(components: ViewComponentIR[], routePrefix: string, options?: {
643
643
  lazy?: boolean;
644
- frameworkKind?: "react" | "vue2" | "vue3";
644
+ frameworkKind?: 'react' | 'vue2' | 'vue3';
645
645
  }): {
646
646
  routes: RouteIR[];
647
647
  authResourcePaths: string[];
@@ -1172,10 +1172,18 @@ declare const reactComponentLibHackPlugin: {
1172
1172
  name: string;
1173
1173
  functions: {
1174
1174
  __hooksDefinitions(): ReactFileDescription;
1175
- hackBindAttribute<T extends BindAttributeIR & {
1175
+ hackBindAttribute<T extends {
1176
1176
  kind: "expr";
1177
+ expression: ExprIR;
1178
+ __raw: _lcap_nasl_concepts.BindAttribute;
1179
+ sync: boolean;
1180
+ } & {
1181
+ concept: "BindAttribute";
1182
+ name: string;
1183
+ } & {
1184
+ kind: 'expr';
1177
1185
  }>(b: T): BindAttributeIR & {
1178
- kind: "expr";
1186
+ kind: 'expr';
1179
1187
  };
1180
1188
  };
1181
1189
  };
@@ -1672,7 +1680,7 @@ declare class VirtualProject {
1672
1680
  getFileDict(): {
1673
1681
  files: Record<string, ProjectFile>;
1674
1682
  };
1675
- readFile(path: string): string | Buffer<ArrayBufferLike>;
1683
+ readFile(path: string): string | Buffer;
1676
1684
  }
1677
1685
  declare function compileAsProject(app: App, frontend: Frontend, config: CommonAppConfig, container?: Container): Promise<VirtualProject>;
1678
1686
  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 = {
@@ -4292,40 +4364,40 @@ var metadataPlugin = makePlugin({
4292
4364
  // src/hack/material-config/material.config.js
4293
4365
  var materials = {
4294
4366
  framework: {
4295
- version: "2.1.0",
4367
+ version: "2.0.1",
4296
4368
  core: "@lcap/basic-template",
4297
4369
  pc: [
4298
4370
  {
4299
4371
  frameworkKind: "vue2",
4300
4372
  name: "@lcap/pc-template",
4301
- version: "2.1.0"
4373
+ version: "2.0.1"
4302
4374
  },
4303
4375
  {
4304
4376
  frameworkKind: "react",
4305
4377
  name: "@lcap/pc-template-react",
4306
- version: "2.1.0"
4378
+ version: "2.0.1"
4307
4379
  },
4308
4380
  {
4309
4381
  frameworkKind: "vue3",
4310
4382
  name: "@lcap/pc-template-vue3",
4311
- version: "2.1.0"
4383
+ version: "2.0.1"
4312
4384
  }
4313
4385
  ],
4314
4386
  h5: [
4315
4387
  {
4316
4388
  frameworkKind: "vue2",
4317
4389
  name: "@lcap/mobile-template",
4318
- version: "2.1.0"
4390
+ version: "2.0.1"
4319
4391
  },
4320
4392
  {
4321
4393
  frameworkKind: "react",
4322
4394
  name: "@lcap/mobile-template-react",
4323
- version: "2.1.0"
4395
+ version: "2.0.1"
4324
4396
  },
4325
4397
  {
4326
4398
  frameworkKind: "vue3",
4327
4399
  name: "@lcap/mobile-template-vue3",
4328
- version: "2.1.0"
4400
+ version: "2.0.1"
4329
4401
  }
4330
4402
  ]
4331
4403
  },
@@ -4399,29 +4471,6 @@ var coreVersion = materials.framework.version;
4399
4471
  function getPredefinedMaterialConfig() {
4400
4472
  return materials;
4401
4473
  }
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
4474
  var getPredefinedMaterialByTags = (() => {
4426
4475
  const materialConfig = getPredefinedMaterialConfig();
4427
4476
  let allMaterials = [];
@@ -4445,12 +4494,14 @@ var getPredefinedMaterialByTags = (() => {
4445
4494
  materialConfig.ui.pc.forEach((item) => {
4446
4495
  allMaterials.push({
4447
4496
  ...item,
4497
+ kind: "standard",
4448
4498
  tags: ["ui", "pc", item.frameworkKind, item.libName]
4449
4499
  });
4450
4500
  });
4451
4501
  materialConfig.ui.h5.forEach((item) => {
4452
4502
  allMaterials.push({
4453
4503
  ...item,
4504
+ kind: "standard",
4454
4505
  tags: ["ui", "h5", item.frameworkKind, item.libName]
4455
4506
  });
4456
4507
  });
@@ -4610,7 +4661,10 @@ function bindAttrToIR(b) {
4610
4661
  throw new Error("string\u4E0D\u53EF\u4E3Async");
4611
4662
  }
4612
4663
  if (b.i18nKey && b.value && b.frontend?.i18nInfo?.enabled) {
4613
- b.type = "dynamic";
4664
+ const frameworkKind = b.frontend?.frameworkKind;
4665
+ if (!["vue3"].includes(frameworkKind)) {
4666
+ b.type = "dynamic";
4667
+ }
4614
4668
  const wrapperExpr = import_nasl_concepts9.CallFunction.from(
4615
4669
  {
4616
4670
  calleeNamespace: "$i18n",
@@ -4714,7 +4768,7 @@ function bindEventToAction(b) {
4714
4768
  kind: "standalone"
4715
4769
  };
4716
4770
  }
4717
- var DefaultComponentLibraryName = getPredefinedLibConstants().reactUI.name;
4771
+ var DefaultComponentLibraryName = getPredefinedMaterialByTags(["ui", "pc", "react"])?.name;
4718
4772
  function getReferencedLibComponent(e) {
4719
4773
  const tag = e.tag;
4720
4774
  if (tag.startsWith("BS")) {
@@ -5380,8 +5434,8 @@ var NASLAppIRBuilderPlugin = class {
5380
5434
  });
5381
5435
  logger5.debug({ extensionPackages });
5382
5436
  const frameworkKind = frontend.frameworkKind;
5383
- const libs = getPredefinedLibConstants();
5384
- return [...extensionPackages, frameworkKind === "vue3" ? libs.vue3Ui : libs.reactUI];
5437
+ const uiLib = getPredefinedMaterialByTags(["ui", frontend.type, frameworkKind]);
5438
+ return [...extensionPackages, uiLib];
5385
5439
  };
5386
5440
  var buildConfigs = buildConfigs2, collectPackages = collectPackages2;
5387
5441
  config.debug && breakpoint2.genBreakpoints(app);
@@ -6750,10 +6804,9 @@ function extractAppLevelFrontendDeps(app) {
6750
6804
  }
6751
6805
  function extractFrontendLevelDeps(frontend) {
6752
6806
  const deps = [];
6753
- if (frontend.frameworkKind === "react") {
6754
- deps.push(getPredefinedLibConstants().reactUI);
6755
- } else if (frontend.frameworkKind === "vue3") {
6756
- deps.push(getPredefinedLibConstants().vue3Ui);
6807
+ const uiLib = getPredefinedMaterialByTags(["ui", frontend.type, frontend.frameworkKind]);
6808
+ if (uiLib) {
6809
+ deps.push(uiLib);
6757
6810
  }
6758
6811
  return deps;
6759
6812
  }
@@ -6926,11 +6979,11 @@ async function downloadDependenciesToLcapModules(feDeps, fs, config) {
6926
6979
  }
6927
6980
  let packageJson = fs.read("/package.json")?.toString();
6928
6981
  packageJson = JSON.parse(packageJson);
6929
- if (!packageJson.dependencies) {
6930
- packageJson.dependencies = {};
6982
+ if (!packageJson.lcap_modules) {
6983
+ packageJson.lcap_modules = {};
6931
6984
  }
6932
6985
  downloadedDeps.forEach(({ pkgName, targetPath }) => {
6933
- packageJson.dependencies[pkgName] = `.${targetPath}`;
6986
+ packageJson.lcap_modules[pkgName] = `.${targetPath}`;
6934
6987
  });
6935
6988
  fs.write("/package.json", JSON.stringify(packageJson, null, 2));
6936
6989
  logger13.info("\u4E0B\u8F7D\u524D\u7AEF\u4F9D\u8D56\u5E93\u5230 lcap_modules \u76EE\u5F55\u5B8C\u6210");
@@ -7206,7 +7259,7 @@ export function loadAssets(){
7206
7259
  generateEntry(ir) {
7207
7260
  const entryScript = this.microFrontendManager.produceScript(ir);
7208
7261
  const publicPathScript = this.microFrontendManager.producePublicPathScript(ir);
7209
- const code = `
7262
+ let code = `
7210
7263
  export function startApp(){
7211
7264
  if(window.LcapMicro){
7212
7265
  // \u5DF2\u7ECF\u88AB\u52A0\u8F7D\u4E8E\u5FAE\u524D\u7AEF\u73AF\u5883
@@ -7217,6 +7270,11 @@ export function loadAssets(){
7217
7270
  }
7218
7271
  }
7219
7272
  `;
7273
+ const { env, isExport } = ir.configs.config;
7274
+ if (!isExport && env === "dev") {
7275
+ const autoReloadScript = (init_auto_reload(), __toCommonJS(auto_reload_exports));
7276
+ code += autoReloadScript?.default || autoReloadScript;
7277
+ }
7220
7278
  const imports = [
7221
7279
  {
7222
7280
  from: "../init"
@@ -7284,23 +7342,28 @@ var VueRouterPlugin = class {
7284
7342
  }
7285
7343
  routeToCode(routes, componentPathManager, config) {
7286
7344
  function serializeVueRoute(r, isRoot = false) {
7287
- const path = r.thisLevelPath ?? "/";
7345
+ const { accumulativePath, thisLevelPath } = r;
7346
+ const path = isRoot ? accumulativePath : thisLevelPath ?? "/";
7347
+ const basePath = config.basePath;
7288
7348
  if (r.kind === "normal") {
7289
7349
  const children = r.children?.map((i) => serializeVueRoute(i)).filter(isNotNil) ?? [];
7290
7350
  const childrenStr = children.join(",\n");
7291
7351
  const componentCode = `component: ${r.elementMangledName ?? r.elementTemplate.identifier}`;
7292
- return `{path: "${isRoot ? r.accumulativePath : path}", meta: ${JSON.stringify(
7352
+ return `{path: "${path}", meta: ${JSON.stringify(
7293
7353
  r.meta
7294
7354
  )}, children: [${childrenStr}], ${componentCode} }`;
7295
7355
  } else if (r.kind === "redirect") {
7296
- const replaceWildCardForVue3 = (frameworkKind, path2) => {
7297
- if (frameworkKind === "vue3" && path2 === "*") {
7298
- return "/:pathMatch(.*)*";
7356
+ if (["vue3"].includes(config.frameworkKind) && path === "*") {
7357
+ return `{ path: "/:pathMatch(.*)*", redirect: ${JSON.stringify(basePath + r.redirect)} }`;
7358
+ }
7359
+ if (["vue3"].includes(config.frameworkKind) && path === "/") {
7360
+ let result = `{ path: "/", redirect: ${JSON.stringify(basePath + r.redirect)} }`;
7361
+ if (basePath !== "/") {
7362
+ result += `, { path: "${basePath}", redirect: ${JSON.stringify(basePath + r.redirect)} }`;
7299
7363
  }
7300
- return path2;
7301
- };
7302
- const processedPath = replaceWildCardForVue3(config.frameworkKind, path);
7303
- return `{path: "${processedPath}", redirect: ${JSON.stringify(r.redirect)}}`;
7364
+ return result;
7365
+ }
7366
+ return `{ path: "${path}", redirect: to => to.path.replace(/\\/$/, '') + '/' + ${JSON.stringify(r.redirect)} }`;
7304
7367
  }
7305
7368
  notImplemented(r);
7306
7369
  }
@@ -7389,7 +7452,7 @@ var Vue3EntryBuilderPlugin = class {
7389
7452
  buildEntry(ir) {
7390
7453
  const entryScript = this.microFrontendManager.produceScript(ir);
7391
7454
  const publicPathScript = this.microFrontendManager.producePublicPathScript(ir);
7392
- const code = `
7455
+ let code = `
7393
7456
  if(window.LcapMicro){
7394
7457
  // \u5DF2\u7ECF\u88AB\u52A0\u8F7D\u4E8E\u5FAE\u524D\u7AEF\u73AF\u5883
7395
7458
  renderApp();
@@ -7407,6 +7470,11 @@ var Vue3EntryBuilderPlugin = class {
7407
7470
  from: "./public-path"
7408
7471
  } : void 0
7409
7472
  ].filter(isNotNil);
7473
+ const { env, isExport } = ir.configs.config;
7474
+ if (!isExport && env === "dev") {
7475
+ const autoReloadScript = (init_auto_reload(), __toCommonJS(auto_reload_exports));
7476
+ code += autoReloadScript?.default || autoReloadScript;
7477
+ }
7410
7478
  return [
7411
7479
  new ReactFileDescription("main.ts", imports, [], [code]),
7412
7480
  publicPathScript ? new ReactFileDescription("public-path.ts", [], [], [publicPathScript]) : void 0
@@ -7432,10 +7500,13 @@ var Vue3LibrariesBuilderPlugin = class {
7432
7500
  */
7433
7501
  async buildLibrariesImport(ir, config) {
7434
7502
  const importArr = [];
7503
+ const exportArr = [];
7435
7504
  const standardLib = ir.packages.find((x) => x.kind === "standard");
7436
7505
  if (standardLib) {
7437
7506
  const formattedName = kebab2Pascal(standardLib.name.split("/").at(-1));
7438
- importArr.push(`export * as ${formattedName} from '${standardLib.name}';`);
7507
+ importArr.push(`import * as ${formattedName} from '${standardLib.name}';`);
7508
+ exportArr.push(`export { ${formattedName} };`);
7509
+ exportArr.push(`window.lcapStandardUI = ${formattedName};`);
7439
7510
  const isPackageZipExists = await judgePackageZipExists(standardLib, config.STATIC_URL);
7440
7511
  importArr.push(
7441
7512
  `import '${standardLib.name}${isPackageZipExists ? "/dist-theme" : ""}/index.css';`
@@ -7446,14 +7517,14 @@ var Vue3LibrariesBuilderPlugin = class {
7446
7517
  const formattedName = kebab2Pascal(ext.name.split("/").at(-1));
7447
7518
  const isPackageZipExists = await judgePackageZipExists(ext, config.STATIC_URL);
7448
7519
  const prefix = isPackageZipExists ? "" : "@extension/";
7449
- importArr.push(`export * as ${formattedName} from '${prefix}${ext.name}';`);
7520
+ exportArr.push(`export * as ${formattedName} from '${prefix}${ext.name}';`);
7450
7521
  if (ext.hasCss) {
7451
7522
  importArr.push(
7452
7523
  `import '${prefix}${ext.name}${isPackageZipExists ? "/dist-theme" : ""}/index.css';`
7453
7524
  );
7454
7525
  }
7455
7526
  }
7456
- return new ReactFileDescription("libraries.ts", [], [], [importArr.join("\n")]);
7527
+ return new ReactFileDescription("libraries.ts", [], [], [[...importArr, ...exportArr].join("\n")]);
7457
7528
  }
7458
7529
  static install(c) {
7459
7530
  c.bind(Vue3LibrariesBuilderPlugin).toSelf();
@@ -7689,15 +7760,16 @@ var Vue3ApplicationAssemblerPlugin = class {
7689
7760
  const bizComponents = ir.bizComponents.flatMap((x) => {
7690
7761
  return this.vue3CodegenPlugin.genFiles(x, manager);
7691
7762
  });
7692
- let routePrefix = ir.configs.frontendDesc.path;
7693
- if (!/\/$/.test(routePrefix)) {
7694
- routePrefix += "/";
7763
+ let basePath = ir.configs.basePlatformConfig.basePath;
7764
+ if (!/\/$/.test(basePath)) {
7765
+ basePath += "/";
7695
7766
  }
7696
- const routesObjects = this.routesExtactor.extractRoute(ir.views, routePrefix, {
7767
+ const routesObjects = this.routesExtactor.extractRoute(ir.views, basePath, {
7697
7768
  lazy: true
7698
7769
  });
7699
7770
  const router = this.routerBuilder.routeToCode(routesObjects.routes, manager, {
7700
- frameworkKind: "vue3"
7771
+ frameworkKind: "vue3",
7772
+ basePath
7701
7773
  });
7702
7774
  const routerFile = new ReactFileDescription("router.ts", router.imports, [], [router.code]);
7703
7775
  const libraries = await this.librariesBuilder.buildLibrariesImport(ir, config);
@@ -7750,6 +7822,30 @@ var Vue3PresetPlugin = class {
7750
7822
  const app = deserializeAppWhileKeepTypeAnnotation(appJson);
7751
7823
  const frontend = app.findNodeByPath(instruction.frontend.nodePath);
7752
7824
  const ir = this.irBuilder.buildIR(app, frontend, instruction.config);
7825
+ const needCompileViews = instruction.config?.needCompileViews ?? [];
7826
+ const isIncremental = needCompileViews.length > 0;
7827
+ if (isIncremental) {
7828
+ const filterChildComponents = (view, needCompileViews2) => {
7829
+ if (!view.childComponents?.length) {
7830
+ return;
7831
+ }
7832
+ view.childComponents = view.childComponents.filter((child) => {
7833
+ if (needCompileViews2.includes(child.__raw.nodePath)) {
7834
+ filterChildComponents(child, needCompileViews2);
7835
+ return true;
7836
+ }
7837
+ return false;
7838
+ });
7839
+ };
7840
+ ir.views = ir.views.filter((view) => {
7841
+ if (needCompileViews.includes(view.__raw.nodePath)) {
7842
+ filterChildComponents(view, needCompileViews);
7843
+ return true;
7844
+ }
7845
+ return false;
7846
+ });
7847
+ ir.bizComponents = [];
7848
+ }
7753
7849
  const assembledApplication = await this.applicationAssembler.assemble(ir, instruction.config);
7754
7850
  const finalizedFiles = await this.projectOrganizer.organize({
7755
7851
  baseDir: instruction.baseDir,
@@ -7831,7 +7927,7 @@ async function translateNASLToApp(app, frontend, config, baseDir = "./out", cont
7831
7927
  if (needCompileViews?.length > 0) {
7832
7928
  let traverseChildren2 = function(view, callback) {
7833
7929
  if (view.children?.length > 0) {
7834
- view.children.forEach((childView) => {
7930
+ [...view.children].forEach((childView) => {
7835
7931
  const deep = callback(childView);
7836
7932
  if (deep) {
7837
7933
  traverseChildren2(childView, callback);
@@ -7841,9 +7937,10 @@ async function translateNASLToApp(app, frontend, config, baseDir = "./out", cont
7841
7937
  };
7842
7938
  var traverseChildren = traverseChildren2;
7843
7939
  logger13.info("\u5F00\u59CB\u6309\u9700\u7FFB\u8BD1\u9875\u9762");
7844
- frontend.views.forEach((view) => {
7940
+ [...frontend.views].forEach((view) => {
7845
7941
  if (!needCompileViews.includes(view.nodePath)) {
7846
7942
  view.delete();
7943
+ console.log(`\u5220\u9664\u9875\u9762 ${view.nodePath}\uFF0C\u56E0\u4E3A\u5B83\u4E0D\u5728 needCompileViews \u4E2D`);
7847
7944
  } else {
7848
7945
  traverseChildren2(view, (childView) => {
7849
7946
  if (!needCompileViews.includes(childView.nodePath)) {