@lcap/nasl 4.0.0-creator.6 → 4.0.0-creator.7
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genSimpleBundleFile.d.ts","sourceRoot":"","sources":["../../src/generator/genSimpleBundleFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAQ,MAAM,aAAa,CAAC;AAKvD,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE;QACL,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,
|
|
1
|
+
{"version":3,"file":"genSimpleBundleFile.d.ts","sourceRoot":"","sources":["../../src/generator/genSimpleBundleFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAQ,MAAM,aAAa,CAAC;AAKvD,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE;QACL,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;CACH;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE;IACR,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;;EAkFF"}
|
|
@@ -3,13 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.genSimpleBundleFile = void 0;
|
|
4
4
|
const nasl_unified_frontend_generator_1 = require("@lcap/nasl-unified-frontend-generator");
|
|
5
5
|
const genBundleFiles_1 = require("./genBundleFiles");
|
|
6
|
-
const lodash_1 = require("lodash");
|
|
7
6
|
/**
|
|
8
7
|
* 只用于 NASL 沙箱简单打包用
|
|
9
8
|
*/
|
|
10
9
|
function genSimpleBundleFile(app, frontend, options) {
|
|
11
10
|
const views = frontend.views;
|
|
12
11
|
const routes = [];
|
|
12
|
+
const files = {};
|
|
13
|
+
let importStr = '';
|
|
13
14
|
const typeKeyMap = {};
|
|
14
15
|
const enumMap = {};
|
|
15
16
|
app.enums.forEach((enumItem) => {
|
|
@@ -21,57 +22,29 @@ function genSimpleBundleFile(app, frontend, options) {
|
|
|
21
22
|
typeKeyMap[entity.name][property.name] = property.typeAnnotation?.typeKey;
|
|
22
23
|
});
|
|
23
24
|
});
|
|
24
|
-
|
|
25
|
-
function traverseView(view, parentPath = '') {
|
|
25
|
+
function traverseView(view, prefixName = '', parentPath = '') {
|
|
26
26
|
const isRootView = view.parentNode?.concept !== 'View';
|
|
27
27
|
let path = isRootView ? `${frontend.prefixPath}/${view.name}` : view.name;
|
|
28
|
-
let
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
typeKey = typeKeyMap[entityName]?.[$3];
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
typeKey = `app.enums.${(0, lodash_1.upperFirst)($2).replace(/\d+$/, '')}`;
|
|
38
|
-
}
|
|
39
|
-
if (typeKey && enumMap[typeKey])
|
|
40
|
-
return `${$1}, '${typeKey}')`;
|
|
41
|
-
return m;
|
|
42
|
-
}).replace(/('ListTransform'\]\(.+?, \(item\) => \(\$utils\['EnumItemToText'\]\(item\?\.(\w+)(?:\?\.(\w+))?)\)\)/g, (m, $1, $2, $3) => {
|
|
43
|
-
let typeKey = '';
|
|
44
|
-
if ($3) {
|
|
45
|
-
const entityName = (0, lodash_1.upperFirst)($2);
|
|
46
|
-
typeKey = typeKeyMap[entityName]?.[$3];
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
typeKey = `app.enums.${(0, lodash_1.upperFirst)($2).replace(/\d+$/, '')}`;
|
|
50
|
-
}
|
|
51
|
-
if (typeKey && enumMap[typeKey])
|
|
52
|
-
return `${$1}, '${typeKey}'))`;
|
|
53
|
-
return m;
|
|
54
|
-
});
|
|
55
|
-
let viewCode = options.script.replace(/^export default \{/, `const ${fullName} = async () => ({
|
|
56
|
-
template: \`${options.template.replace(/[`$]/g, '\\$&')}\`,
|
|
57
|
-
`).replace(/};?\s*$/, `});`);
|
|
58
|
-
code += viewCode + '\n\n';
|
|
28
|
+
let prefixPath = parentPath ? `${parentPath}/${view.name}` : view.name;
|
|
29
|
+
let fullName = prefixName ? `${prefixName}_${view.name}` : view.name;
|
|
30
|
+
const content = view.toVue({ isComposition: true });
|
|
31
|
+
const fileName = `/${fullName}.vue`;
|
|
32
|
+
files[fileName] = { code: content };
|
|
33
|
+
importStr += `const ${fullName} = () => import('.${fileName}');\n`;
|
|
59
34
|
const children = [];
|
|
60
35
|
view.children.forEach((child) => {
|
|
61
|
-
children.push(traverseView(child, fullName));
|
|
62
|
-
// if (child.isIndex) {
|
|
63
|
-
// children.push({
|
|
64
|
-
// path: '',
|
|
65
|
-
// redirect: child.name,
|
|
66
|
-
// });
|
|
67
|
-
// }
|
|
36
|
+
children.push(traverseView(child, fullName, prefixPath));
|
|
68
37
|
});
|
|
69
|
-
|
|
38
|
+
const route = {
|
|
70
39
|
path,
|
|
71
40
|
component: `##${fullName}##`,
|
|
72
41
|
meta: view.getRouteMeta(),
|
|
73
42
|
children,
|
|
74
43
|
};
|
|
44
|
+
if (route.meta.first) {
|
|
45
|
+
route.redirect = `/${prefixPath}/${route.meta.first}`;
|
|
46
|
+
}
|
|
47
|
+
return route;
|
|
75
48
|
}
|
|
76
49
|
views.forEach((view) => {
|
|
77
50
|
routes.push(traverseView(view));
|
|
@@ -86,29 +59,24 @@ function genSimpleBundleFile(app, frontend, options) {
|
|
|
86
59
|
path: '/:pathMatch(.*)*',
|
|
87
60
|
redirect: options?.notFoundRedirect || '/notFound',
|
|
88
61
|
});
|
|
89
|
-
code = code
|
|
90
|
-
.replace(/(?<!this\.)state\./g, 'this.')
|
|
91
|
-
.replace(/(?<!this\.)\$refs([.[])/g, 'this.$refs$1')
|
|
92
|
-
.replace(/(?<!this\.)\$route([.[])/g, 'this.$route$1')
|
|
93
|
-
.replace(/(?<!this\.)\$router([.[])/g, 'this.$router$1');
|
|
94
62
|
const routesStr = JSON.stringify(routes).replace(/"##|##"/g, '');
|
|
95
63
|
const metaData = (0, nasl_unified_frontend_generator_1.genMetaData)(app, frontend, undefined);
|
|
96
64
|
const metaDataStr = (0, genBundleFiles_1.stringifyMetaData)(metaData);
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
document.head.appendChild(el);
|
|
103
|
-
}
|
|
104
|
-
` : '';
|
|
105
|
-
return `
|
|
106
|
-
${contentStyleCss}
|
|
107
|
-
${code}
|
|
65
|
+
files['/router.js'] = {
|
|
66
|
+
code: `
|
|
67
|
+
${importStr}
|
|
68
|
+
|
|
69
|
+
export const routes = ${routesStr};
|
|
108
70
|
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
71
|
+
export const metaData = ${metaDataStr};
|
|
72
|
+
`,
|
|
73
|
+
};
|
|
74
|
+
files['/index.css'] = {
|
|
75
|
+
code: frontend.genThemeCSS(),
|
|
76
|
+
};
|
|
77
|
+
return {
|
|
78
|
+
files,
|
|
79
|
+
};
|
|
112
80
|
}
|
|
113
81
|
exports.genSimpleBundleFile = genSimpleBundleFile;
|
|
114
82
|
//# sourceMappingURL=genSimpleBundleFile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"genSimpleBundleFile.js","sourceRoot":"","sources":["../../src/generator/genSimpleBundleFile.ts"],"names":[],"mappings":";;;AACA,2FAAoE;AACpE,qDAAqD;
|
|
1
|
+
{"version":3,"file":"genSimpleBundleFile.js","sourceRoot":"","sources":["../../src/generator/genSimpleBundleFile.ts"],"names":[],"mappings":";;;AACA,2FAAoE;AACpE,qDAAqD;AAarD;;GAEG;AACH,SAAgB,mBAAmB,CACjC,GAAQ,EACR,QAAkB,EAClB,OAEC;IAED,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;IAC7B,MAAM,MAAM,GAAkB,EAAE,CAAC;IACjC,MAAM,KAAK,GAAG,EAAS,CAAC;IACxB,IAAI,SAAS,GAAG,EAAE,CAAC;IACnB,MAAM,UAAU,GAA2C,EAAE,CAAC;IAC9D,MAAM,OAAO,GAAyB,EAAE,CAAC;IACzC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;QAC7B,OAAO,CAAC,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC/C,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QAC9C,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACxD,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;YACrC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;QAC5E,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,SAAS,YAAY,CAAC,IAAU,EAAE,aAAqB,EAAE,EAAE,aAAqB,EAAE;QAChF,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE,OA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
"version": "4.0.0-creator.
|
|
4
|
+
"version": "4.0.0-creator.7",
|
|
5
5
|
"author": "Forrest <rainforest92@126.com>",
|
|
6
6
|
"main": "./out",
|
|
7
7
|
"types": "./out/index.d.ts",
|
|
@@ -79,15 +79,15 @@
|
|
|
79
79
|
"vue": "3.4.33",
|
|
80
80
|
"vue-template-compiler": "2.6.14",
|
|
81
81
|
"vue-template-es2015-compiler": "1.9.1",
|
|
82
|
-
"@lcap/nasl-breakpoint": "4.0.0-creator.
|
|
83
|
-
"@lcap/nasl-
|
|
84
|
-
"@lcap/nasl-
|
|
85
|
-
"@lcap/nasl-
|
|
86
|
-
"@lcap/nasl-
|
|
87
|
-
"@lcap/nasl-
|
|
88
|
-
"@lcap/nasl-
|
|
89
|
-
"@lcap/nasl-
|
|
90
|
-
"@lcap/nasl-
|
|
82
|
+
"@lcap/nasl-breakpoint": "4.0.0-creator.7",
|
|
83
|
+
"@lcap/nasl-concepts": "4.0.0-creator.7",
|
|
84
|
+
"@lcap/nasl-translator": "4.0.0-creator.7",
|
|
85
|
+
"@lcap/nasl-types": "4.0.0-creator.7",
|
|
86
|
+
"@lcap/nasl-unified-frontend-generator": "4.0.0-creator.7",
|
|
87
|
+
"@lcap/nasl-utils": "4.0.0-creator.7",
|
|
88
|
+
"@lcap/nasl-language-server-core": "4.0.0-creator.7",
|
|
89
|
+
"@lcap/nasl-sentry": "4.0.0-creator.7",
|
|
90
|
+
"@lcap/nasl-log": "4.0.0-creator.7"
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
93
|
"@babel/preset-react": "7.24.1",
|