@lcap/nasl-unified-frontend-generator 4.0.1-rc.0 → 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.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, {
@@ -6907,11 +6979,11 @@ async function downloadDependenciesToLcapModules(feDeps, fs, config) {
6907
6979
  }
6908
6980
  let packageJson = fs.read("/package.json")?.toString();
6909
6981
  packageJson = JSON.parse(packageJson);
6910
- if (!packageJson.dependencies) {
6911
- packageJson.dependencies = {};
6982
+ if (!packageJson.lcap_modules) {
6983
+ packageJson.lcap_modules = {};
6912
6984
  }
6913
6985
  downloadedDeps.forEach(({ pkgName, targetPath }) => {
6914
- packageJson.dependencies[pkgName] = `.${targetPath}`;
6986
+ packageJson.lcap_modules[pkgName] = `.${targetPath}`;
6915
6987
  });
6916
6988
  fs.write("/package.json", JSON.stringify(packageJson, null, 2));
6917
6989
  logger13.info("\u4E0B\u8F7D\u524D\u7AEF\u4F9D\u8D56\u5E93\u5230 lcap_modules \u76EE\u5F55\u5B8C\u6210");
@@ -7187,7 +7259,7 @@ export function loadAssets(){
7187
7259
  generateEntry(ir) {
7188
7260
  const entryScript = this.microFrontendManager.produceScript(ir);
7189
7261
  const publicPathScript = this.microFrontendManager.producePublicPathScript(ir);
7190
- const code = `
7262
+ let code = `
7191
7263
  export function startApp(){
7192
7264
  if(window.LcapMicro){
7193
7265
  // \u5DF2\u7ECF\u88AB\u52A0\u8F7D\u4E8E\u5FAE\u524D\u7AEF\u73AF\u5883
@@ -7198,6 +7270,11 @@ export function loadAssets(){
7198
7270
  }
7199
7271
  }
7200
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
+ }
7201
7278
  const imports = [
7202
7279
  {
7203
7280
  from: "../init"
@@ -7375,7 +7452,7 @@ var Vue3EntryBuilderPlugin = class {
7375
7452
  buildEntry(ir) {
7376
7453
  const entryScript = this.microFrontendManager.produceScript(ir);
7377
7454
  const publicPathScript = this.microFrontendManager.producePublicPathScript(ir);
7378
- const code = `
7455
+ let code = `
7379
7456
  if(window.LcapMicro){
7380
7457
  // \u5DF2\u7ECF\u88AB\u52A0\u8F7D\u4E8E\u5FAE\u524D\u7AEF\u73AF\u5883
7381
7458
  renderApp();
@@ -7393,6 +7470,11 @@ var Vue3EntryBuilderPlugin = class {
7393
7470
  from: "./public-path"
7394
7471
  } : void 0
7395
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
+ }
7396
7478
  return [
7397
7479
  new ReactFileDescription("main.ts", imports, [], [code]),
7398
7480
  publicPathScript ? new ReactFileDescription("public-path.ts", [], [], [publicPathScript]) : void 0
@@ -7841,6 +7923,36 @@ async function translateNASLToApp(app, frontend, config, baseDir = "./out", cont
7841
7923
  const logger13 = Logger("\u7FFB\u8BD1\u8FC7\u7A0B");
7842
7924
  logger13.debug({ config });
7843
7925
  async function genCode() {
7926
+ const { needCompileViews = [] } = config;
7927
+ if (needCompileViews?.length > 0) {
7928
+ let traverseChildren2 = function(view, callback) {
7929
+ if (view.children?.length > 0) {
7930
+ [...view.children].forEach((childView) => {
7931
+ const deep = callback(childView);
7932
+ if (deep) {
7933
+ traverseChildren2(childView, callback);
7934
+ }
7935
+ });
7936
+ }
7937
+ };
7938
+ var traverseChildren = traverseChildren2;
7939
+ logger13.info("\u5F00\u59CB\u6309\u9700\u7FFB\u8BD1\u9875\u9762");
7940
+ [...frontend.views].forEach((view) => {
7941
+ if (!needCompileViews.includes(view.nodePath)) {
7942
+ view.delete();
7943
+ console.log(`\u5220\u9664\u9875\u9762 ${view.nodePath}\uFF0C\u56E0\u4E3A\u5B83\u4E0D\u5728 needCompileViews \u4E2D`);
7944
+ } else {
7945
+ traverseChildren2(view, (childView) => {
7946
+ if (!needCompileViews.includes(childView.nodePath)) {
7947
+ childView.delete();
7948
+ return false;
7949
+ }
7950
+ return true;
7951
+ });
7952
+ }
7953
+ });
7954
+ logger13.info("\u7ED3\u675F\u6309\u9700\u7FFB\u8BD1\u9875\u9762");
7955
+ }
7844
7956
  logger13.info("\u5F00\u59CB\u7FFB\u8BD1");
7845
7957
  try {
7846
7958
  const codeList2 = await container.get(ServiceMetaKind.NASLTranspiler).transpile({