@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.
@@ -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 __commonJS = (cb, mod) => function __require() {
9
12
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
13
  };
@@ -2244,6 +2247,75 @@ var require_lib = __commonJS({
2244
2247
  }
2245
2248
  });
2246
2249
 
2250
+ // src/plugins/templates/auto-reload.js
2251
+ var auto_reload_exports = {};
2252
+ __export(auto_reload_exports, {
2253
+ default: () => auto_reload_default
2254
+ });
2255
+ var auto_reload_default;
2256
+ var init_auto_reload = __esm({
2257
+ "src/plugins/templates/auto-reload.js"() {
2258
+ "use strict";
2259
+ auto_reload_default = `
2260
+ const dom = document.createElement('div');
2261
+ dom.classList = "lcap-deploy-loading-container";
2262
+ dom.style.display = 'none';
2263
+ dom.innerHTML = "<div class='lcap-deploy-loading-icon'></div><div>\u6B63\u5728\u66F4\u65B0\u6700\u65B0\u53D1\u5E03\u5185\u5BB9...</div>";
2264
+ document.getElementsByTagName('body')[0].appendChild(dom);
2265
+
2266
+ const style = document.createElement('style');
2267
+ style.innerHTML = \`.lcap-deploy-loading-container {
2268
+ width: 208px;
2269
+ height: 40px;
2270
+ background: rgba(48, 48, 48, 0.8);
2271
+ box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.1);
2272
+ border-radius: 4px;
2273
+ position: fixed;
2274
+ top: 120px;
2275
+ left: 50%;
2276
+ margin-left: -104px;
2277
+ color: #FFFFFF;
2278
+ font-size: 14px;
2279
+ justify-content: center;
2280
+ align-items: center;
2281
+ }
2282
+
2283
+ .lcap-deploy-loading-icon{
2284
+ width: 12px;
2285
+ height: 12px;
2286
+ margin-right: 10px;
2287
+ animation: loading-animation 0.8s infinite linear;
2288
+ border: 2px solid #f3f3f3;
2289
+ border-top: 2px solid rgb(109, 108, 108);
2290
+ border-right: 2px solid rgb(109, 108, 108);
2291
+ border-bottom: 2px solid rgb(109, 108, 108);
2292
+ border-radius: 50%;
2293
+ }
2294
+
2295
+ @keyframes loading-animation{
2296
+ 0% {
2297
+ transform: rotate(0deg);
2298
+ }
2299
+ 100% {
2300
+ transform: rotate(360deg);
2301
+ }
2302
+ }\`;
2303
+ document.getElementsByTagName('body')[0].appendChild(style);
2304
+
2305
+ window.addEventListener('message', function (e) {
2306
+ if(e.data ==="release-start"){
2307
+ document.querySelector(".lcap-deploy-loading-container").style.display ="flex"
2308
+ }
2309
+
2310
+ if(e.data==="release-end"){
2311
+ document.querySelector(".lcap-deploy-loading-container").style.display ="none"
2312
+ window.location.reload();
2313
+ }
2314
+ });
2315
+ `;
2316
+ }
2317
+ });
2318
+
2247
2319
  // playground/helper.ts
2248
2320
  var helper_exports = {};
2249
2321
  __export(helper_exports, {
@@ -9062,11 +9134,11 @@ async function downloadDependenciesToLcapModules(feDeps, fs, config2) {
9062
9134
  }
9063
9135
  let packageJson = fs.read("/package.json")?.toString();
9064
9136
  packageJson = JSON.parse(packageJson);
9065
- if (!packageJson.dependencies) {
9066
- packageJson.dependencies = {};
9137
+ if (!packageJson.lcap_modules) {
9138
+ packageJson.lcap_modules = {};
9067
9139
  }
9068
9140
  downloadedDeps.forEach(({ pkgName, targetPath }) => {
9069
- packageJson.dependencies[pkgName] = `.${targetPath}`;
9141
+ packageJson.lcap_modules[pkgName] = `.${targetPath}`;
9070
9142
  });
9071
9143
  fs.write("/package.json", JSON.stringify(packageJson, null, 2));
9072
9144
  logger15.info("\u4E0B\u8F7D\u524D\u7AEF\u4F9D\u8D56\u5E93\u5230 lcap_modules \u76EE\u5F55\u5B8C\u6210");
@@ -9342,7 +9414,7 @@ export function loadAssets(){
9342
9414
  generateEntry(ir) {
9343
9415
  const entryScript = this.microFrontendManager.produceScript(ir);
9344
9416
  const publicPathScript = this.microFrontendManager.producePublicPathScript(ir);
9345
- const code = `
9417
+ let code = `
9346
9418
  export function startApp(){
9347
9419
  if(window.LcapMicro){
9348
9420
  // \u5DF2\u7ECF\u88AB\u52A0\u8F7D\u4E8E\u5FAE\u524D\u7AEF\u73AF\u5883
@@ -9353,6 +9425,11 @@ export function loadAssets(){
9353
9425
  }
9354
9426
  }
9355
9427
  `;
9428
+ const { env, isExport } = ir.configs.config;
9429
+ if (!isExport && env === "dev") {
9430
+ const autoReloadScript = (init_auto_reload(), __toCommonJS(auto_reload_exports));
9431
+ code += autoReloadScript?.default || autoReloadScript;
9432
+ }
9356
9433
  const imports = [
9357
9434
  {
9358
9435
  from: "../init"
@@ -9530,7 +9607,7 @@ var Vue3EntryBuilderPlugin = class {
9530
9607
  buildEntry(ir) {
9531
9608
  const entryScript = this.microFrontendManager.produceScript(ir);
9532
9609
  const publicPathScript = this.microFrontendManager.producePublicPathScript(ir);
9533
- const code = `
9610
+ let code = `
9534
9611
  if(window.LcapMicro){
9535
9612
  // \u5DF2\u7ECF\u88AB\u52A0\u8F7D\u4E8E\u5FAE\u524D\u7AEF\u73AF\u5883
9536
9613
  renderApp();
@@ -9548,6 +9625,11 @@ var Vue3EntryBuilderPlugin = class {
9548
9625
  from: "./public-path"
9549
9626
  } : void 0
9550
9627
  ].filter(isNotNil);
9628
+ const { env, isExport } = ir.configs.config;
9629
+ if (!isExport && env === "dev") {
9630
+ const autoReloadScript = (init_auto_reload(), __toCommonJS(auto_reload_exports));
9631
+ code += autoReloadScript?.default || autoReloadScript;
9632
+ }
9551
9633
  return [
9552
9634
  new ReactFileDescription("main.ts", imports, [], [code]),
9553
9635
  publicPathScript ? new ReactFileDescription("public-path.ts", [], [], [publicPathScript]) : void 0
@@ -9996,6 +10078,36 @@ async function translateNASLToApp(app, frontend, config2, baseDir = "./out", con
9996
10078
  const logger15 = Logger("\u7FFB\u8BD1\u8FC7\u7A0B");
9997
10079
  logger15.debug({ config: config2 });
9998
10080
  async function genCode() {
10081
+ const { needCompileViews = [] } = config2;
10082
+ if (needCompileViews?.length > 0) {
10083
+ let traverseChildren2 = function(view, callback) {
10084
+ if (view.children?.length > 0) {
10085
+ [...view.children].forEach((childView) => {
10086
+ const deep = callback(childView);
10087
+ if (deep) {
10088
+ traverseChildren2(childView, callback);
10089
+ }
10090
+ });
10091
+ }
10092
+ };
10093
+ var traverseChildren = traverseChildren2;
10094
+ logger15.info("\u5F00\u59CB\u6309\u9700\u7FFB\u8BD1\u9875\u9762");
10095
+ [...frontend.views].forEach((view) => {
10096
+ if (!needCompileViews.includes(view.nodePath)) {
10097
+ view.delete();
10098
+ console.log(`\u5220\u9664\u9875\u9762 ${view.nodePath}\uFF0C\u56E0\u4E3A\u5B83\u4E0D\u5728 needCompileViews \u4E2D`);
10099
+ } else {
10100
+ traverseChildren2(view, (childView) => {
10101
+ if (!needCompileViews.includes(childView.nodePath)) {
10102
+ childView.delete();
10103
+ return false;
10104
+ }
10105
+ return true;
10106
+ });
10107
+ }
10108
+ });
10109
+ logger15.info("\u7ED3\u675F\u6309\u9700\u7FFB\u8BD1\u9875\u9762");
10110
+ }
9999
10111
  logger15.info("\u5F00\u59CB\u7FFB\u8BD1");
10000
10112
  try {
10001
10113
  const codeList2 = await container.get(ServiceMetaKind.NASLTranspiler).transpile({