@lcap/nasl 2.20.0-beta.3 → 2.20.0-beta.5

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.
Files changed (332) hide show
  1. package/out/automate/engine/index.d.ts +1 -1
  2. package/out/automate/engine/index.js +2 -3
  3. package/out/automate/engine/index.js.map +1 -1
  4. package/out/automate/engine/uniqueName.d.ts +1 -1
  5. package/out/automate/engine/uniqueName.js +2 -2
  6. package/out/automate/engine/uniqueName.js.map +1 -1
  7. package/out/automate/engine/utils.js +4 -1
  8. package/out/automate/engine/utils.js.map +1 -1
  9. package/out/automate/template/myProcess.d.ts +1 -1
  10. package/out/automate/template/myProcess.js +2 -2
  11. package/out/automate/template/myProcess.js.map +1 -1
  12. package/out/bak/translator.js +14 -22
  13. package/out/bak/translator.js.map +1 -1
  14. package/out/common/BaseNode.js +4 -1
  15. package/out/common/BaseNode.js.map +1 -1
  16. package/out/common/Command.d.ts +1 -0
  17. package/out/common/Command.js +5 -1
  18. package/out/common/Command.js.map +1 -1
  19. package/out/concepts/App__.d.ts +4 -0
  20. package/out/concepts/App__.js +30 -6
  21. package/out/concepts/App__.js.map +1 -1
  22. package/out/concepts/Assignee__.js +4 -3
  23. package/out/concepts/Assignee__.js.map +1 -1
  24. package/out/concepts/BatchAssignment__.js +3 -3
  25. package/out/concepts/BatchAssignment__.js.map +1 -1
  26. package/out/concepts/BindAttribute__.d.ts +7 -0
  27. package/out/concepts/BindAttribute__.js +271 -39
  28. package/out/concepts/BindAttribute__.js.map +1 -1
  29. package/out/concepts/BindDirective__.d.ts +7 -0
  30. package/out/concepts/BindDirective__.js +215 -16
  31. package/out/concepts/BindDirective__.js.map +1 -1
  32. package/out/concepts/BindStyle__.d.ts +7 -0
  33. package/out/concepts/BindStyle__.js +192 -2
  34. package/out/concepts/BindStyle__.js.map +1 -1
  35. package/out/concepts/CallFunction__.js +22 -8
  36. package/out/concepts/CallFunction__.js.map +1 -1
  37. package/out/concepts/CallInterface__.js +3 -2
  38. package/out/concepts/CallInterface__.js.map +1 -1
  39. package/out/concepts/CallLogic__.d.ts +3 -0
  40. package/out/concepts/CallLogic__.js +78 -89
  41. package/out/concepts/CallLogic__.js.map +1 -1
  42. package/out/concepts/CallQueryComponent__.js +20 -3
  43. package/out/concepts/CallQueryComponent__.js.map +1 -1
  44. package/out/concepts/ConfigGroup__.d.ts +1 -0
  45. package/out/concepts/ConfigGroup__.js +13 -0
  46. package/out/concepts/ConfigGroup__.js.map +1 -1
  47. package/out/concepts/ConfigProperty__.d.ts +19 -0
  48. package/out/concepts/ConfigProperty__.js +63 -0
  49. package/out/concepts/ConfigProperty__.js.map +1 -1
  50. package/out/concepts/Configuration__.d.ts +1 -0
  51. package/out/concepts/Configuration__.js +13 -0
  52. package/out/concepts/Configuration__.js.map +1 -1
  53. package/out/concepts/DataSource__.js +11 -3
  54. package/out/concepts/DataSource__.js.map +1 -1
  55. package/out/concepts/Destination__.d.ts +1 -0
  56. package/out/concepts/Destination__.js +61 -7
  57. package/out/concepts/Destination__.js.map +1 -1
  58. package/out/concepts/EntityProperty__.js +9 -1
  59. package/out/concepts/EntityProperty__.js.map +1 -1
  60. package/out/concepts/EnumItem__.d.ts +5 -5
  61. package/out/concepts/EnumItem__.js +6 -6
  62. package/out/concepts/Enum__.d.ts +20 -19
  63. package/out/concepts/Enum__.js +28 -1
  64. package/out/concepts/Enum__.js.map +1 -1
  65. package/out/concepts/ExternalDestination__.d.ts +1 -0
  66. package/out/concepts/ExternalDestination__.js +22 -4
  67. package/out/concepts/ExternalDestination__.js.map +1 -1
  68. package/out/concepts/ForEachStatement__.js +2 -0
  69. package/out/concepts/ForEachStatement__.js.map +1 -1
  70. package/out/concepts/Frontend__.d.ts +2 -1
  71. package/out/concepts/Frontend__.js.map +1 -1
  72. package/out/concepts/Identifier__.js +16 -5
  73. package/out/concepts/Identifier__.js.map +1 -1
  74. package/out/concepts/InterfaceParam__.js +9 -1
  75. package/out/concepts/InterfaceParam__.js.map +1 -1
  76. package/out/concepts/JSBlock__.js +5 -1
  77. package/out/concepts/JSBlock__.js.map +1 -1
  78. package/out/concepts/Logic__.d.ts +79 -79
  79. package/out/concepts/Logic__.js +30 -8
  80. package/out/concepts/Logic__.js.map +1 -1
  81. package/out/concepts/Match__.d.ts +2 -2
  82. package/out/concepts/Match__.js +29 -13
  83. package/out/concepts/Match__.js.map +1 -1
  84. package/out/concepts/MemberExpression__.js +9 -0
  85. package/out/concepts/MemberExpression__.js.map +1 -1
  86. package/out/concepts/Module__.d.ts +16 -0
  87. package/out/concepts/Module__.js +43 -0
  88. package/out/concepts/Module__.js.map +1 -1
  89. package/out/concepts/NewComposite__.d.ts +3 -4
  90. package/out/concepts/NewComposite__.js +99 -116
  91. package/out/concepts/NewComposite__.js.map +1 -1
  92. package/out/concepts/NewList__.d.ts +1 -0
  93. package/out/concepts/NewList__.js +22 -2
  94. package/out/concepts/NewList__.js.map +1 -1
  95. package/out/concepts/NewMap__.d.ts +1 -0
  96. package/out/concepts/NewMap__.js +43 -11
  97. package/out/concepts/NewMap__.js.map +1 -1
  98. package/out/concepts/OqlQueryComponent__.js +40 -12
  99. package/out/concepts/OqlQueryComponent__.js.map +1 -1
  100. package/out/concepts/Param__.js +10 -2
  101. package/out/concepts/Param__.js.map +1 -1
  102. package/out/concepts/ProcessElement__.js +2 -1
  103. package/out/concepts/ProcessElement__.js.map +1 -1
  104. package/out/concepts/ProcessOutcome__.js +1 -1
  105. package/out/concepts/ProcessOutcome__.js.map +1 -1
  106. package/out/concepts/ProcessOutcomes__.js +1 -1
  107. package/out/concepts/ProcessOutcomes__.js.map +1 -1
  108. package/out/concepts/Process__.js +1 -0
  109. package/out/concepts/Process__.js.map +1 -1
  110. package/out/concepts/Return__.js +13 -2
  111. package/out/concepts/Return__.js.map +1 -1
  112. package/out/concepts/StringInterpolation__.js +14 -2
  113. package/out/concepts/StringInterpolation__.js.map +1 -1
  114. package/out/concepts/StringLiteral__.js +6 -6
  115. package/out/concepts/StringLiteral__.js.map +1 -1
  116. package/out/concepts/StructureProperty__.js +9 -1
  117. package/out/concepts/StructureProperty__.js.map +1 -1
  118. package/out/concepts/TypeAnnotation__.d.ts +6 -3
  119. package/out/concepts/TypeAnnotation__.js +67 -13
  120. package/out/concepts/TypeAnnotation__.js.map +1 -1
  121. package/out/concepts/ValidationRule__.d.ts +1 -0
  122. package/out/concepts/ValidationRule__.js +53 -0
  123. package/out/concepts/ValidationRule__.js.map +1 -1
  124. package/out/concepts/Variable__.js +12 -1
  125. package/out/concepts/Variable__.js.map +1 -1
  126. package/out/concepts/ViewElement__.d.ts +1 -0
  127. package/out/concepts/ViewElement__.js +24 -1
  128. package/out/concepts/ViewElement__.js.map +1 -1
  129. package/out/concepts/View__.d.ts +1 -3
  130. package/out/concepts/View__.js +33 -12
  131. package/out/concepts/View__.js.map +1 -1
  132. package/out/concepts/basics/stdlib/nasl.collection.js +6 -1
  133. package/out/concepts/basics/stdlib/nasl.collection.js.map +1 -1
  134. package/out/concepts/basics/stdlib/nasl.configuration.js +3 -0
  135. package/out/concepts/basics/stdlib/nasl.configuration.js.map +1 -1
  136. package/out/concepts/basics/stdlib/nasl.core.d.ts +2 -0
  137. package/out/concepts/basics/stdlib/nasl.core.js +34 -0
  138. package/out/concepts/basics/stdlib/nasl.core.js.map +1 -1
  139. package/out/concepts/basics/stdlib/nasl.util.js +4 -2
  140. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  141. package/out/concepts/basics/types/index.d.ts +1 -0
  142. package/out/concepts/basics/types/index.js +3 -1
  143. package/out/concepts/basics/types/index.js.map +1 -1
  144. package/out/concepts/index__.d.ts +0 -1
  145. package/out/concepts/index__.js +0 -1
  146. package/out/concepts/index__.js.map +1 -1
  147. package/out/enums/KEYWORDS.js +8 -0
  148. package/out/enums/KEYWORDS.js.map +1 -1
  149. package/out/generator/genBundleFiles.js +24 -5
  150. package/out/generator/genBundleFiles.js.map +1 -1
  151. package/out/generator/genReleaseBody.d.ts +3 -3
  152. package/out/generator/genReleaseBody.js +98 -23
  153. package/out/generator/genReleaseBody.js.map +1 -1
  154. package/out/generator/permission.d.ts +3 -10
  155. package/out/generator/permission.js +43 -21
  156. package/out/generator/permission.js.map +1 -1
  157. package/out/index.d.ts +1 -1
  158. package/out/index.js +2 -1
  159. package/out/index.js.map +1 -1
  160. package/out/server/entity2LogicNamespace.js +2 -20
  161. package/out/server/entity2LogicNamespace.js.map +1 -1
  162. package/out/server/extendBaseNode.js +16 -5
  163. package/out/server/extendBaseNode.js.map +1 -1
  164. package/out/server/formatTsUtils.d.ts +2 -1
  165. package/out/server/formatTsUtils.js +40 -10
  166. package/out/server/formatTsUtils.js.map +1 -1
  167. package/out/server/getLogics.d.ts +2 -2
  168. package/out/server/getLogics.js +3 -3
  169. package/out/server/getLogics.js.map +1 -1
  170. package/out/server/getMemberIdentifier.d.ts +1 -0
  171. package/out/server/getMemberIdentifier.js +27 -1
  172. package/out/server/getMemberIdentifier.js.map +1 -1
  173. package/out/server/index.js +1 -0
  174. package/out/server/index.js.map +1 -1
  175. package/out/server/naslServer.d.ts +7 -1
  176. package/out/server/naslServer.js +558 -62
  177. package/out/server/naslServer.js.map +1 -1
  178. package/out/server/translator.js +109 -33
  179. package/out/server/translator.js.map +1 -1
  180. package/out/service/storage/init.js +22 -2
  181. package/out/service/storage/init.js.map +1 -1
  182. package/out/templator/genCreateBlock.js +1 -3
  183. package/out/templator/genCreateBlock.js.map +1 -1
  184. package/out/templator/genCurdEditMultipleKeyBlock.js +1 -3
  185. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  186. package/out/templator/genCurdMultipleKeyBlock.js +2 -4
  187. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  188. package/out/templator/genGetBlock.js +1 -1
  189. package/out/templator/genGetBlock.js.map +1 -1
  190. package/out/templator/genGridViewBlock.js +2 -2
  191. package/out/templator/genGridViewBlock.js.map +1 -1
  192. package/out/templator/genListViewBlock.js +7 -1
  193. package/out/templator/genListViewBlock.js.map +1 -1
  194. package/out/templator/genSelectBlock.js +1 -1
  195. package/out/templator/genSelectBlock.js.map +1 -1
  196. package/out/templator/genTableBlock.js +2 -2
  197. package/out/templator/genTableBlock.js.map +1 -1
  198. package/out/templator/genUpdateBlock.js +2 -3
  199. package/out/templator/genUpdateBlock.js.map +1 -1
  200. package/out/translator/index.js +4 -1
  201. package/out/translator/index.js.map +1 -1
  202. package/out/utils/traverse.js +8 -2
  203. package/out/utils/traverse.js.map +1 -1
  204. package/package.json +2 -2
  205. package/sandbox/stdlib/dist/nasl.logging.js +0 -0
  206. package/sandbox/stdlib/dist/nasl.util.js +0 -0
  207. package/sandbox/stdlib/nasl.collection.ts +1 -0
  208. package/sandbox/stdlib/nasl.core.ts +34 -0
  209. package/sandbox/stdlib/nasl.oql.ts +71 -15
  210. package/sandbox/stdlib/nasl.util.ts +9 -3
  211. package/src/automate/engine/dist/index.dev.js +517 -0
  212. package/src/automate/engine/index.js +2 -3
  213. package/src/automate/engine/uniqueName.js +2 -2
  214. package/src/automate/engine/utils.js +4 -2
  215. package/src/automate/template/myProcess.js +2 -2
  216. package/src/bak/translator.js +16 -25
  217. package/src/common/BaseNode.ts +3 -1
  218. package/src/common/Command.ts +4 -0
  219. package/src/common/dist/BaseNode.js +1101 -0
  220. package/src/concepts/App__.ts +36 -7
  221. package/src/concepts/Assignee__.ts +4 -3
  222. package/src/concepts/BatchAssignment__.ts +3 -3
  223. package/src/concepts/BindAttribute__.ts +301 -38
  224. package/src/concepts/BindDirective__.ts +205 -30
  225. package/src/concepts/BindStyle__.ts +188 -24
  226. package/src/concepts/CallFunction__.ts +55 -10
  227. package/src/concepts/CallInterface__.ts +3 -2
  228. package/src/concepts/CallLogic__.ts +110 -90
  229. package/src/concepts/CallQueryComponent__.ts +18 -3
  230. package/src/concepts/ConfigGroup__.ts +17 -4
  231. package/src/concepts/ConfigProperty__.ts +72 -4
  232. package/src/concepts/Configuration__.ts +14 -5
  233. package/src/concepts/DataSource__.ts +10 -3
  234. package/src/concepts/Destination__.ts +61 -7
  235. package/src/concepts/EntityProperty__.ts +7 -1
  236. package/src/concepts/EnumItem__.ts +6 -6
  237. package/src/concepts/Enum__.ts +22 -19
  238. package/src/concepts/ExternalDestination__.ts +29 -9
  239. package/src/concepts/ForEachStatement__.ts +2 -0
  240. package/src/concepts/Frontend__.ts +2 -1
  241. package/src/concepts/Identifier__.ts +16 -5
  242. package/src/concepts/InterfaceParam__.ts +7 -1
  243. package/src/concepts/JSBlock__.ts +3 -2
  244. package/src/concepts/Logic__.ts +110 -89
  245. package/src/concepts/Match__.ts +53 -14
  246. package/src/concepts/MemberExpression__.ts +6 -0
  247. package/src/concepts/Module__.ts +57 -0
  248. package/src/concepts/NewComposite__.ts +104 -131
  249. package/src/concepts/NewList__.ts +23 -2
  250. package/src/concepts/NewMap__.ts +48 -24
  251. package/src/concepts/OqlQueryComponent__.ts +40 -20
  252. package/src/concepts/Param__.ts +178 -176
  253. package/src/concepts/ProcessElement__.ts +2 -1
  254. package/src/concepts/ProcessOutcome__.ts +1 -1
  255. package/src/concepts/ProcessOutcomes__.ts +1 -1
  256. package/src/concepts/Process__.ts +1 -0
  257. package/src/concepts/Return__.ts +10 -2
  258. package/src/concepts/StringInterpolation__.ts +19 -7
  259. package/src/concepts/StringLiteral__.ts +7 -6
  260. package/src/concepts/StructureProperty__.ts +7 -1
  261. package/src/concepts/TypeAnnotation__.ts +102 -15
  262. package/src/concepts/ValidationRule__.ts +58 -9
  263. package/src/concepts/Variable__.ts +13 -1
  264. package/src/concepts/ViewElement__.ts +47 -2
  265. package/src/concepts/View__.ts +39 -18
  266. package/src/concepts/basics/stdlib/dist/nasl.util.js +1602 -0
  267. package/src/concepts/basics/stdlib/dist/reference2TypeAnnotationList.js +24 -0
  268. package/src/concepts/basics/stdlib/nasl.collection.ts +6 -1
  269. package/src/concepts/basics/stdlib/nasl.configuration.ts +3 -0
  270. package/src/concepts/basics/stdlib/nasl.core.ts +33 -2
  271. package/src/concepts/basics/stdlib/nasl.util.ts +4 -2
  272. package/src/concepts/basics/types/index.ts +1 -0
  273. package/src/concepts/dist/BindAttribute__.js +795 -0
  274. package/src/concepts/dist/BindEvent__.js +732 -0
  275. package/src/concepts/dist/CallFunction__.js +527 -0
  276. package/src/concepts/dist/CallLogic__.js +932 -0
  277. package/src/concepts/dist/Destination__.js +708 -0
  278. package/src/concepts/dist/ExternalDestination__.js +298 -0
  279. package/src/concepts/dist/Identifier__.js +311 -0
  280. package/src/concepts/dist/StringInterpolation__.js +231 -0
  281. package/src/concepts/dist/TypeAnnotation__.js +834 -0
  282. package/src/concepts/dist/ViewElement__.js +1692 -0
  283. package/src/concepts/dist/View__.js +1601 -0
  284. package/src/concepts/index__.ts +0 -1
  285. package/src/enums/KEYWORDS.ts +8 -0
  286. package/src/generator/dist/genBundleFiles.js +261 -0
  287. package/src/generator/dist/genMetaData.js +245 -0
  288. package/src/generator/dist/permission.js +405 -0
  289. package/src/generator/genBundleFiles.ts +24 -5
  290. package/src/generator/genReleaseBody.ts +77 -31
  291. package/src/generator/permission.ts +47 -21
  292. package/src/index.ts +1 -1
  293. package/src/server/entity2LogicNamespace.ts +2 -20
  294. package/src/server/extendBaseNode.ts +15 -5
  295. package/src/server/formatTsUtils.ts +41 -10
  296. package/src/server/getLogics.ts +4 -4
  297. package/src/server/getMemberIdentifier.ts +27 -1
  298. package/src/server/index.ts +2 -0
  299. package/src/server/naslServer.ts +555 -63
  300. package/src/server/translator.ts +96 -34
  301. package/src/service/storage/dist/init.js +579 -0
  302. package/src/service/storage/init.ts +23 -3
  303. package/src/templator/dist/genEditTableBlock.js +204 -0
  304. package/src/templator/dist/genGridViewBlock.js +265 -0
  305. package/src/templator/dist/genListViewBlock.js +84 -0
  306. package/src/templator/dist/genTableBlock.js +209 -0
  307. package/src/templator/dist/utils.js +527 -0
  308. package/src/templator/genCreateBlock.ts +1 -3
  309. package/src/templator/genCurdEditMultipleKeyBlock.ts +1 -3
  310. package/src/templator/genCurdMultipleKeyBlock.ts +2 -4
  311. package/src/templator/genGetBlock.ts +1 -1
  312. package/src/templator/genGridViewBlock.ts +3 -4
  313. package/src/templator/genListViewBlock.ts +9 -3
  314. package/src/templator/genSelectBlock.ts +1 -1
  315. package/src/templator/genTableBlock.ts +3 -3
  316. package/src/templator/genUpdateBlock.ts +2 -3
  317. package/src/translator/index.ts +3 -1
  318. package/src/utils/traverse.ts +10 -2
  319. package/ts-worker/lib/tsserver.js +10 -2
  320. package/ts-worker/package.json +1 -0
  321. package/ts-worker/webpack.config.js +11 -2
  322. package/out/concepts/ConstructArgument__.d.ts +0 -40
  323. package/out/concepts/ConstructArgument__.js +0 -108
  324. package/out/concepts/ConstructArgument__.js.map +0 -1
  325. package/out/concepts/Construct__.d.ts +0 -189
  326. package/out/concepts/Construct__.js +0 -340
  327. package/out/concepts/Construct__.js.map +0 -1
  328. package/out/templator/sql-parser/index.d.ts +0 -1
  329. package/out/templator/sql-parser/index.js +0 -228
  330. package/out/templator/sql-parser/index.js.map +0 -1
  331. package/out/templator/sql-parser/parser.js +0 -26664
  332. package/out/templator/sql-parser/parser.js.map +0 -1
@@ -0,0 +1,1601 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ var __assign = (this && this.__assign) || function () {
16
+ __assign = Object.assign || function(t) {
17
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
18
+ s = arguments[i];
19
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
20
+ t[p] = s[p];
21
+ }
22
+ return t;
23
+ };
24
+ return __assign.apply(this, arguments);
25
+ };
26
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
27
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
28
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
29
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
30
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
31
+ };
32
+ exports.__esModule = true;
33
+ exports.View = void 0;
34
+ var translator_1 = require("../translator");
35
+ var translator_2 = require("../bak/translator");
36
+ var Structure__1 = require("./Structure__");
37
+ var Identifier__1 = require("./Identifier__");
38
+ var Assignment__1 = require("./Assignment__");
39
+ var BatchAssignment__1 = require("./BatchAssignment__");
40
+ var CallInterface__1 = require("./CallInterface__");
41
+ var CallLogic__1 = require("./CallLogic__");
42
+ var decorators_1 = require("../decorators");
43
+ var utils = require("../utils");
44
+ var BaseNode_1 = require("../common/BaseNode");
45
+ var classMap_1 = require("../common/classMap");
46
+ var ViewElement__1 = require("./ViewElement__");
47
+ var Param__1 = require("./Param__");
48
+ var Variable__1 = require("./Variable__");
49
+ var Logic__1 = require("./Logic__");
50
+ var BindEvent__1 = require("./BindEvent__");
51
+ /**
52
+ * 页面
53
+ */
54
+ var View = /** @class */ (function (_super) {
55
+ __extends(View, _super);
56
+ /**
57
+ * @param source 需要合并的部分参数
58
+ */
59
+ function View(source) {
60
+ var _this = this;
61
+ source = Object.assign({}, View_1.getDefaultOptions(), source);
62
+ _this = _super.call(this, source) || this;
63
+ /**
64
+ * 产品概念
65
+ */
66
+ _this.concept = 'View';
67
+ /**
68
+ * 页面模板 Id
69
+ */
70
+ _this.pageTemplateId = undefined;
71
+ /**
72
+ * 页面名称
73
+ */
74
+ _this.name = undefined;
75
+ /**
76
+ * 唯一标识
77
+ */
78
+ _this.uuid = undefined;
79
+ /**
80
+ * 页面标题
81
+ */
82
+ _this.title = undefined;
83
+ /**
84
+ * 面包屑
85
+ */
86
+ _this.crumb = undefined;
87
+ /**
88
+ * 权限控制
89
+ */
90
+ _this.auth = undefined;
91
+ /**
92
+ * 权限资源描述
93
+ */
94
+ _this.authDescription = undefined;
95
+ /**
96
+ * 是否是默认跳转的页面
97
+ */
98
+ _this.isIndex = undefined;
99
+ /**
100
+ * 未解析的模板代码
101
+ */
102
+ _this.template = undefined;
103
+ /**
104
+ * 未解析的逻辑代码
105
+ */
106
+ _this.script = undefined;
107
+ /**
108
+ * 未解析的样式代码
109
+ */
110
+ _this.style = undefined;
111
+ /**
112
+ * 页面元素列表
113
+ */
114
+ _this.elements = [];
115
+ /**
116
+ * 输入参数列表
117
+ */
118
+ _this.params = [];
119
+ /**
120
+ * 变量列表
121
+ */
122
+ _this.variables = [];
123
+ /**
124
+ * 逻辑列表
125
+ */
126
+ _this.logics = [];
127
+ /**
128
+ * 元素绑定事件列表
129
+ */
130
+ _this.bindEvents = [];
131
+ /**
132
+ * 绑定的角色
133
+ */
134
+ _this.bindRoles = [];
135
+ /**
136
+ * 页面列表
137
+ */
138
+ _this.children = [];
139
+ _this.existingViewElement = new Set();
140
+ /**
141
+ * 获取当前页面下所有elements上bindEvents下的logic
142
+ */
143
+ _this.elementLogicRoot = [];
144
+ _super.prototype.subConstructor.call(_this, source);
145
+ return _this;
146
+ }
147
+ View_1 = View;
148
+ Object.defineProperty(View.prototype, "module", {
149
+ /**
150
+ * 祖先 Module
151
+ */
152
+ get: function () {
153
+ return this.getAncestor('Module');
154
+ },
155
+ enumerable: false,
156
+ configurable: true
157
+ });
158
+ Object.defineProperty(View.prototype, "app", {
159
+ /**
160
+ * 祖先 App
161
+ */
162
+ get: function () {
163
+ return this.getAncestor('App');
164
+ },
165
+ enumerable: false,
166
+ configurable: true
167
+ });
168
+ View.from = function (source, parentNode, parentKey) {
169
+ return _super.from.call(this, source, parentNode, parentKey);
170
+ };
171
+ /**
172
+ * 从父级删除该节点
173
+ * @internal
174
+ */
175
+ View.prototype._delete = function () {
176
+ var _a, _b;
177
+ var params = null;
178
+ if (this.parentNode) {
179
+ params = (_b = (_a = this.parentNode) === null || _a === void 0 ? void 0 : _a.__removeView) === null || _b === void 0 ? void 0 : _b.call(_a, this);
180
+ }
181
+ return params;
182
+ };
183
+ /**
184
+ * 设置页面名称
185
+ */
186
+ View.prototype.setName = function (name) {
187
+ var object = {
188
+ name: name
189
+ };
190
+ this.update(__assign(__assign({}, object), { field: 'name' }));
191
+ };
192
+ /**
193
+ * 设置页面标题
194
+ */
195
+ View.prototype.setTitle = function (title) {
196
+ var object = {
197
+ title: title
198
+ };
199
+ this.update(__assign({}, object));
200
+ };
201
+ /**
202
+ * 设置面包屑
203
+ */
204
+ View.prototype.setCrumb = function (crumb) {
205
+ var object = {
206
+ crumb: crumb
207
+ };
208
+ this.update(__assign({}, object));
209
+ };
210
+ /**
211
+ * 设置权限控制
212
+ */
213
+ View.prototype.setAuth = function (auth) {
214
+ var object = {
215
+ auth: auth
216
+ };
217
+ this.update(__assign({}, object));
218
+ };
219
+ /**
220
+ * 设置权限资源描述
221
+ */
222
+ View.prototype.setAuthDescription = function (authDescription) {
223
+ var object = {
224
+ authDescription: authDescription
225
+ };
226
+ this.update(__assign({}, object));
227
+ };
228
+ /**
229
+ * 设置是否是默认跳转的页面
230
+ */
231
+ View.prototype.setIsIndex = function (isIndex) {
232
+ var object = {
233
+ isIndex: isIndex
234
+ };
235
+ this.update(__assign({}, object));
236
+ };
237
+ View.prototype._insertViewElementAt = function (options, index) {
238
+ var viewElementOptions = {};
239
+ var relationOptions = { parentNode: this, parentKey: 'elements' };
240
+ var viewElement;
241
+ if (!options) {
242
+ viewElement = ViewElement__1["default"].from(__assign(__assign({}, viewElementOptions), { name: this.getViewElementUniqueName() }), this, 'elements');
243
+ }
244
+ else if (typeof options === 'string') {
245
+ viewElement = ViewElement__1["default"].from(__assign(__assign({}, viewElementOptions), { name: options }), this, 'elements');
246
+ }
247
+ else if (options instanceof ViewElement__1["default"]) {
248
+ options.ensureDelete(); // 同一实例不支持多处存在
249
+ viewElement = options;
250
+ Object.assign(viewElement, relationOptions);
251
+ }
252
+ else {
253
+ viewElement = ViewElement__1["default"].from(__assign(__assign({}, viewElementOptions), options), this, 'elements');
254
+ }
255
+ this.elements.splice(index, 0, viewElement);
256
+ return viewElement;
257
+ };
258
+ View.prototype.insertViewElementAt = function (options, index) {
259
+ var node = this._insertViewElementAt(options, index);
260
+ node.create({
261
+ index: index,
262
+ parentNode: this,
263
+ parentKey: 'elements'
264
+ });
265
+ return node;
266
+ };
267
+ View.prototype._addViewElement = function (options) {
268
+ var index = this.elements.length;
269
+ return this._insertViewElementAt(options, index);
270
+ };
271
+ View.prototype.addViewElement = function (options) {
272
+ var node = this._addViewElement(options);
273
+ var index = this.elements.indexOf(node);
274
+ node.create({
275
+ index: index,
276
+ parentNode: this,
277
+ parentKey: 'elements'
278
+ });
279
+ return node;
280
+ };
281
+ View.prototype.getParamUniqueName = function (name) {
282
+ if (name === void 0) { name = 'param1'; }
283
+ return utils.unique(name, this.getVarExistingNames(), undefined, false);
284
+ };
285
+ View.prototype._insertParamAt = function (options, index) {
286
+ var paramOptions = {};
287
+ var relationOptions = { parentNode: this, parentKey: 'params' };
288
+ var param;
289
+ if (!options) {
290
+ param = Param__1["default"].from(__assign(__assign({}, paramOptions), { name: this.getParamUniqueName() }), this, 'params');
291
+ }
292
+ else if (typeof options === 'string') {
293
+ param = Param__1["default"].from(__assign(__assign({}, paramOptions), { name: options }), this, 'params');
294
+ }
295
+ else if (options instanceof Param__1["default"]) {
296
+ options.ensureDelete(); // 同一实例不支持多处存在
297
+ param = options;
298
+ Object.assign(param, relationOptions);
299
+ }
300
+ else {
301
+ param = Param__1["default"].from(__assign(__assign({}, paramOptions), options), this, 'params');
302
+ }
303
+ this.params.splice(index, 0, param);
304
+ return param;
305
+ };
306
+ View.prototype.insertParamAt = function (options, index) {
307
+ var node = this._insertParamAt(options, index);
308
+ node.create({
309
+ index: index,
310
+ parentNode: this,
311
+ parentKey: 'params'
312
+ });
313
+ return node;
314
+ };
315
+ View.prototype._addParam = function (options) {
316
+ var index = this.params.length;
317
+ return this._insertParamAt(options, index);
318
+ };
319
+ View.prototype.addParam = function (options) {
320
+ var node = this._addParam(options);
321
+ var index = this.params.indexOf(node);
322
+ node.create({
323
+ index: index,
324
+ parentNode: this,
325
+ parentKey: 'params'
326
+ });
327
+ return node;
328
+ };
329
+ View.prototype.getVariableUniqueName = function (name) {
330
+ if (name === void 0) { name = 'variable1'; }
331
+ return utils.unique(name, this.getVarExistingNames(), undefined, false);
332
+ };
333
+ View.prototype._insertVariableAt = function (options, index) {
334
+ var variableOptions = {};
335
+ var relationOptions = { parentNode: this, parentKey: 'variables' };
336
+ var variable;
337
+ if (!options) {
338
+ variable = Variable__1["default"].from(__assign(__assign({}, variableOptions), { name: this.getVariableUniqueName() }), this, 'variables');
339
+ }
340
+ else if (typeof options === 'string') {
341
+ variable = Variable__1["default"].from(__assign(__assign({}, variableOptions), { name: options }), this, 'variables');
342
+ }
343
+ else if (options instanceof Variable__1["default"]) {
344
+ options.ensureDelete(); // 同一实例不支持多处存在
345
+ variable = options;
346
+ Object.assign(variable, relationOptions);
347
+ }
348
+ else {
349
+ variable = Variable__1["default"].from(__assign(__assign({}, variableOptions), options), this, 'variables');
350
+ }
351
+ this.variables.splice(index, 0, variable);
352
+ return variable;
353
+ };
354
+ View.prototype.insertVariableAt = function (options, index) {
355
+ var node = this._insertVariableAt(options, index);
356
+ node.create({
357
+ index: index,
358
+ parentNode: this,
359
+ parentKey: 'variables'
360
+ });
361
+ return node;
362
+ };
363
+ View.prototype._addVariable = function (options) {
364
+ var index = this.variables.length;
365
+ return this._insertVariableAt(options, index);
366
+ };
367
+ View.prototype.addVariable = function (options) {
368
+ var node = this._addVariable(options);
369
+ var index = this.variables.indexOf(node);
370
+ node.create({
371
+ index: index,
372
+ parentNode: this,
373
+ parentKey: 'variables'
374
+ });
375
+ return node;
376
+ };
377
+ View.prototype.getLogicUniqueName = function (name) {
378
+ if (name === void 0) { name = 'logic1'; }
379
+ return utils.unique(name, this.getLogicExistingNames(), undefined, false);
380
+ };
381
+ View.prototype._insertLogicAt = function (options, index) {
382
+ var logicOptions = {};
383
+ var relationOptions = { parentNode: this, parentKey: 'logics' };
384
+ var logic;
385
+ if (!options) {
386
+ logic = Logic__1["default"].from(__assign(__assign({}, logicOptions), { name: this.getLogicUniqueName() }), this, 'logics');
387
+ }
388
+ else if (typeof options === 'string') {
389
+ logic = Logic__1["default"].from(__assign(__assign({}, logicOptions), { name: options }), this, 'logics');
390
+ }
391
+ else if (options instanceof Logic__1["default"]) {
392
+ options.ensureDelete(); // 同一实例不支持多处存在
393
+ logic = options;
394
+ Object.assign(logic, relationOptions);
395
+ }
396
+ else {
397
+ logic = Logic__1["default"].from(__assign(__assign({}, logicOptions), options), this, 'logics');
398
+ }
399
+ this.logics.splice(index, 0, logic);
400
+ return logic;
401
+ };
402
+ View.prototype.insertLogicAt = function (options, index) {
403
+ var node = this._insertLogicAt(options, index);
404
+ node.create({
405
+ index: index,
406
+ parentNode: this,
407
+ parentKey: 'logics'
408
+ });
409
+ return node;
410
+ };
411
+ View.prototype._addLogic = function (options) {
412
+ var index = this.logics.length;
413
+ return this._insertLogicAt(options, index);
414
+ };
415
+ View.prototype.addLogic = function (options) {
416
+ var node = this._addLogic(options);
417
+ var index = this.logics.indexOf(node);
418
+ node.create({
419
+ index: index,
420
+ parentNode: this,
421
+ parentKey: 'logics'
422
+ });
423
+ return node;
424
+ };
425
+ View.prototype.getBindEventExistingNames = function (excludedList) {
426
+ if (excludedList === void 0) { excludedList = []; }
427
+ var excludedSet = new Set(excludedList);
428
+ return (this.bindEvents || []).filter(function (item) { return !excludedSet.has(item); }).map(function (item) { return item.name; });
429
+ };
430
+ View.prototype.getBindEventUniqueName = function (name) {
431
+ if (name === void 0) { name = 'bindEvent1'; }
432
+ return utils.unique(name, this.getBindEventExistingNames(), undefined, false);
433
+ };
434
+ View.prototype._insertBindEventAt = function (options, index) {
435
+ var bindEventOptions = {};
436
+ var relationOptions = { parentNode: this, parentKey: 'bindEvents' };
437
+ var bindEvent;
438
+ if (!options) {
439
+ bindEvent = BindEvent__1["default"].from(__assign(__assign({}, bindEventOptions), { name: this.getBindEventUniqueName() }), this, 'bindEvents');
440
+ }
441
+ else if (typeof options === 'string') {
442
+ bindEvent = BindEvent__1["default"].from(__assign(__assign({}, bindEventOptions), { name: options }), this, 'bindEvents');
443
+ }
444
+ else if (options instanceof BindEvent__1["default"]) {
445
+ options.ensureDelete(); // 同一实例不支持多处存在
446
+ bindEvent = options;
447
+ Object.assign(bindEvent, relationOptions);
448
+ }
449
+ else {
450
+ bindEvent = BindEvent__1["default"].from(__assign(__assign({}, bindEventOptions), options), this, 'bindEvents');
451
+ }
452
+ this.bindEvents.splice(index, 0, bindEvent);
453
+ return bindEvent;
454
+ };
455
+ View.prototype.insertBindEventAt = function (options, index) {
456
+ var node = this._insertBindEventAt(options, index);
457
+ node.create({
458
+ index: index,
459
+ parentNode: this,
460
+ parentKey: 'bindEvents'
461
+ });
462
+ return node;
463
+ };
464
+ View.prototype._addBindEvent = function (options) {
465
+ var index = this.bindEvents.length;
466
+ return this._insertBindEventAt(options, index);
467
+ };
468
+ View.prototype.addBindEvent = function (options) {
469
+ var node = this._addBindEvent(options);
470
+ var index = this.bindEvents.indexOf(node);
471
+ node.create({
472
+ index: index,
473
+ parentNode: this,
474
+ parentKey: 'bindEvents'
475
+ });
476
+ return node;
477
+ };
478
+ View.prototype.getViewExistingNames = function (excludedList) {
479
+ if (excludedList === void 0) { excludedList = []; }
480
+ var excludedSet = new Set(excludedList);
481
+ return (this.children || []).filter(function (item) { return !excludedSet.has(item); }).map(function (item) { return item.name; });
482
+ };
483
+ View.prototype.getViewUniqueName = function (name) {
484
+ if (name === void 0) { name = 'view1'; }
485
+ return utils.unique(name, this.getViewExistingNames(), undefined, false);
486
+ };
487
+ View.prototype._insertViewAt = function (options, index) {
488
+ var viewOptions = {};
489
+ var relationOptions = { parentNode: this, parentKey: 'children' };
490
+ var view;
491
+ if (!options) {
492
+ view = View_1.from(__assign(__assign({}, viewOptions), { name: this.getViewUniqueName() }), this, 'children');
493
+ }
494
+ else if (typeof options === 'string') {
495
+ view = View_1.from(__assign(__assign({}, viewOptions), { name: options }), this, 'children');
496
+ }
497
+ else if (options instanceof View_1) {
498
+ options.ensureDelete(); // 同一实例不支持多处存在
499
+ view = options;
500
+ Object.assign(view, relationOptions);
501
+ }
502
+ else {
503
+ view = View_1.from(__assign(__assign({}, viewOptions), options), this, 'children');
504
+ }
505
+ this.children.splice(index, 0, view);
506
+ return view;
507
+ };
508
+ View.prototype.insertViewAt = function (options, index) {
509
+ var node = this._insertViewAt(options, index);
510
+ node.create({
511
+ index: index,
512
+ parentNode: this,
513
+ parentKey: 'children'
514
+ });
515
+ return node;
516
+ };
517
+ View.prototype._addView = function (options) {
518
+ var index = this.children.length;
519
+ return this._insertViewAt(options, index);
520
+ };
521
+ View.prototype.addView = function (options) {
522
+ var node = this._addView(options);
523
+ var index = this.children.indexOf(node);
524
+ node.create({
525
+ index: index,
526
+ parentNode: this,
527
+ parentKey: 'children'
528
+ });
529
+ return node;
530
+ };
531
+ View.prototype.removeViewElement = function (options) {
532
+ var viewElement;
533
+ if (typeof options === 'string') {
534
+ viewElement = this.elements.find(function (item) { return item.name === options; });
535
+ if (!viewElement) {
536
+ throw new Error('找不到页面元素 ' + options);
537
+ }
538
+ }
539
+ else {
540
+ viewElement = options;
541
+ }
542
+ return viewElement["delete"]();
543
+ };
544
+ View.prototype.__removeViewElement = function (viewElement) {
545
+ var parentKey = viewElement.parentKey;
546
+ var params = {
547
+ parentNode: this,
548
+ parentKey: parentKey,
549
+ index: -1,
550
+ object: null,
551
+ oldObject: viewElement
552
+ };
553
+ if (parentKey) {
554
+ params.parentKey = parentKey;
555
+ if (Array.isArray(this[parentKey])) {
556
+ var index = this[parentKey].indexOf(viewElement);
557
+ ~index && this[parentKey].splice(index, 1);
558
+ params.index = index;
559
+ }
560
+ else if (this[parentKey] === viewElement) {
561
+ params.index = 0;
562
+ this[parentKey] = undefined;
563
+ }
564
+ }
565
+ return params;
566
+ };
567
+ View.prototype.removeParam = function (options) {
568
+ var param;
569
+ if (typeof options === 'string') {
570
+ param = this.params.find(function (item) { return item.name === options; });
571
+ if (!param) {
572
+ throw new Error('找不到输入参数 ' + options);
573
+ }
574
+ }
575
+ else {
576
+ param = options;
577
+ }
578
+ return param["delete"]();
579
+ };
580
+ View.prototype.__removeParam = function (param) {
581
+ var parentKey = param.parentKey;
582
+ var params = {
583
+ parentNode: this,
584
+ parentKey: parentKey,
585
+ index: -1,
586
+ object: null,
587
+ oldObject: param
588
+ };
589
+ if (parentKey) {
590
+ params.parentKey = parentKey;
591
+ if (Array.isArray(this[parentKey])) {
592
+ var index = this[parentKey].indexOf(param);
593
+ ~index && this[parentKey].splice(index, 1);
594
+ params.index = index;
595
+ }
596
+ else if (this[parentKey] === param) {
597
+ params.index = 0;
598
+ this[parentKey] = undefined;
599
+ }
600
+ }
601
+ return params;
602
+ };
603
+ View.prototype.removeVariable = function (options) {
604
+ var variable;
605
+ if (typeof options === 'string') {
606
+ variable = this.variables.find(function (item) { return item.name === options; });
607
+ if (!variable) {
608
+ throw new Error('找不到变量 ' + options);
609
+ }
610
+ }
611
+ else {
612
+ variable = options;
613
+ }
614
+ return variable["delete"]();
615
+ };
616
+ View.prototype.__removeVariable = function (variable) {
617
+ var parentKey = variable.parentKey;
618
+ var params = {
619
+ parentNode: this,
620
+ parentKey: parentKey,
621
+ index: -1,
622
+ object: null,
623
+ oldObject: variable
624
+ };
625
+ if (parentKey) {
626
+ params.parentKey = parentKey;
627
+ if (Array.isArray(this[parentKey])) {
628
+ var index = this[parentKey].indexOf(variable);
629
+ ~index && this[parentKey].splice(index, 1);
630
+ params.index = index;
631
+ }
632
+ else if (this[parentKey] === variable) {
633
+ params.index = 0;
634
+ this[parentKey] = undefined;
635
+ }
636
+ }
637
+ return params;
638
+ };
639
+ View.prototype.removeLogic = function (options) {
640
+ var logic;
641
+ if (typeof options === 'string') {
642
+ logic = this.logics.find(function (item) { return item.name === options; });
643
+ if (!logic) {
644
+ throw new Error('找不到逻辑 ' + options);
645
+ }
646
+ }
647
+ else {
648
+ logic = options;
649
+ }
650
+ return logic["delete"]();
651
+ };
652
+ View.prototype.__removeLogic = function (logic) {
653
+ var parentKey = logic.parentKey;
654
+ var params = {
655
+ parentNode: this,
656
+ parentKey: parentKey,
657
+ index: -1,
658
+ object: null,
659
+ oldObject: logic
660
+ };
661
+ if (parentKey) {
662
+ params.parentKey = parentKey;
663
+ if (Array.isArray(this[parentKey])) {
664
+ var index = this[parentKey].indexOf(logic);
665
+ ~index && this[parentKey].splice(index, 1);
666
+ params.index = index;
667
+ }
668
+ else if (this[parentKey] === logic) {
669
+ params.index = 0;
670
+ this[parentKey] = undefined;
671
+ }
672
+ }
673
+ return params;
674
+ };
675
+ View.prototype.removeBindEvent = function (options) {
676
+ var bindEvent;
677
+ if (typeof options === 'string') {
678
+ bindEvent = this.bindEvents.find(function (item) { return item.name === options; });
679
+ if (!bindEvent) {
680
+ throw new Error('找不到元素绑定事件 ' + options);
681
+ }
682
+ }
683
+ else {
684
+ bindEvent = options;
685
+ }
686
+ return bindEvent["delete"]();
687
+ };
688
+ View.prototype.__removeBindEvent = function (bindEvent) {
689
+ var parentKey = bindEvent.parentKey;
690
+ var params = {
691
+ parentNode: this,
692
+ parentKey: parentKey,
693
+ index: -1,
694
+ object: null,
695
+ oldObject: bindEvent
696
+ };
697
+ if (parentKey) {
698
+ params.parentKey = parentKey;
699
+ if (Array.isArray(this[parentKey])) {
700
+ var index = this[parentKey].indexOf(bindEvent);
701
+ ~index && this[parentKey].splice(index, 1);
702
+ params.index = index;
703
+ }
704
+ else if (this[parentKey] === bindEvent) {
705
+ params.index = 0;
706
+ this[parentKey] = undefined;
707
+ }
708
+ }
709
+ return params;
710
+ };
711
+ View.prototype.removeView = function (options) {
712
+ var view;
713
+ if (typeof options === 'string') {
714
+ view = this.children.find(function (item) { return item.name === options; });
715
+ if (!view) {
716
+ throw new Error('找不到页面 ' + options);
717
+ }
718
+ }
719
+ else {
720
+ view = options;
721
+ }
722
+ return view["delete"]();
723
+ };
724
+ View.prototype.__removeView = function (view) {
725
+ var parentKey = view.parentKey;
726
+ var params = {
727
+ parentNode: this,
728
+ parentKey: parentKey,
729
+ index: -1,
730
+ object: null,
731
+ oldObject: view
732
+ };
733
+ if (parentKey) {
734
+ params.parentKey = parentKey;
735
+ if (Array.isArray(this[parentKey])) {
736
+ var index = this[parentKey].indexOf(view);
737
+ ~index && this[parentKey].splice(index, 1);
738
+ params.index = index;
739
+ }
740
+ else if (this[parentKey] === view) {
741
+ params.index = 0;
742
+ this[parentKey] = undefined;
743
+ }
744
+ }
745
+ return params;
746
+ };
747
+ Object.defineProperty(View.prototype, "parentAuth", {
748
+ //================================================================================
749
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
750
+ // 自动生成的代码已结束。下面可以手动编写。
751
+ //================================================================================
752
+ /* 主页面有没有权限 */
753
+ get: function () {
754
+ var _a;
755
+ var _nameSpace = this.getTsNamespace();
756
+ var mainViewName = _nameSpace.split('.')[2];
757
+ return mainViewName ? (_a = this.app.views.find(function (item) { return item.name === mainViewName; })) === null || _a === void 0 ? void 0 : _a.auth : this.auth;
758
+ },
759
+ enumerable: false,
760
+ configurable: true
761
+ });
762
+ /**
763
+ * 设置页面权限
764
+ */
765
+ View.prototype.setBindRoles = function (bindRoles) {
766
+ var object = {
767
+ bindRoles: bindRoles
768
+ };
769
+ this.update(__assign({}, object));
770
+ };
771
+ View.prototype.findLogicByName = function (name) {
772
+ return this.logics.find(function (logic) { return logic.name === name; });
773
+ };
774
+ // 收集已经存在的ViewElement
775
+ View.prototype.collectExistingViewElementName = function (excludedList) {
776
+ var _this = this;
777
+ if (excludedList === void 0) { excludedList = []; }
778
+ var excludedSet = new Set(excludedList);
779
+ this.elements.forEach(function (element) {
780
+ utils.traverse(function (_a) {
781
+ var node = _a.node;
782
+ if (!excludedSet.has(node)) {
783
+ _this.existingViewElement.add(node.name);
784
+ }
785
+ }, {
786
+ node: element
787
+ });
788
+ });
789
+ };
790
+ // 获取当前页面的所有组件的名字
791
+ View.prototype.getViewElementExistingNames = function (excludedList) {
792
+ if (excludedList === void 0) { excludedList = []; }
793
+ if (!this.existingViewElement.size) {
794
+ this.collectExistingViewElementName();
795
+ }
796
+ return Array.from(this.existingViewElement);
797
+ };
798
+ View.prototype.getViewElementUniqueName = function (name) {
799
+ if (name === void 0) { name = 'viewElement1'; }
800
+ this.collectExistingViewElementName();
801
+ var viewElementUniqueName = utils.unique(name, this.existingViewElement);
802
+ this.existingViewElement.add(viewElementUniqueName);
803
+ return viewElementUniqueName;
804
+ };
805
+ // 组件名是否有效
806
+ View.prototype.isValidElementName = function (name) {
807
+ if (name) {
808
+ return !this.getViewElementExistingNames().find(function (existingName) { return existingName === name; });
809
+ }
810
+ return false;
811
+ };
812
+ View.prototype.mergeBlock = function (_a) {
813
+ var _this = this;
814
+ var code = _a.code, nodePath = _a.nodePath, position = _a.position, cb = _a.cb;
815
+ var template = utils.sliceTagContent(code, 'template');
816
+ var targetNode = this.app.findNodeByPath(nodePath);
817
+ var parentNode = position === 'append' ? targetNode : targetNode.parentNode;
818
+ if (parentNode.concept === 'View') {
819
+ parentNode = targetNode;
820
+ if (position === 'insertBefore') {
821
+ targetNode = parentNode.children[0];
822
+ }
823
+ else if (position === 'insertAfter') {
824
+ var len = parentNode.children.length;
825
+ targetNode = parentNode.children[len - 1];
826
+ }
827
+ }
828
+ var definitionStr = utils.sliceTagContent(code, 'definition') || '{}';
829
+ var definition = JSON.parse(definitionStr);
830
+ if (template) {
831
+ var node = ViewElement__1["default"].fromHTML(template, {
832
+ view: this,
833
+ definition: definition
834
+ });
835
+ if (!parentNode) {
836
+ return;
837
+ }
838
+ if (position === 'append') {
839
+ parentNode.addViewElement(node);
840
+ cb && cb(parentNode, node);
841
+ }
842
+ else {
843
+ var index = targetNode.getIndexOfParent();
844
+ if (position === 'insertBefore') {
845
+ parentNode.insertViewElementAt(node, index);
846
+ }
847
+ else if (position === 'insertAfter') {
848
+ parentNode.insertViewElementAt(node, index + 1);
849
+ }
850
+ }
851
+ }
852
+ // 全局逻辑
853
+ if (Array.isArray(definition.logics)) {
854
+ definition.logics.forEach(function (logicOption) {
855
+ var logic = Logic__1["default"].from(__assign({}, logicOption), _this.rootNode, 'logics');
856
+ _this.rootNode.addLogic(logic);
857
+ });
858
+ }
859
+ // 全局结构体
860
+ if (Array.isArray(definition.structures)) {
861
+ definition.structures.forEach(function (structureOption) {
862
+ var structure = Structure__1.Structure.from(__assign({}, structureOption), _this.rootNode, 'structures');
863
+ _this.rootNode.addStructure(structure);
864
+ });
865
+ }
866
+ // 页面入参
867
+ if (Array.isArray(definition.viewParams)) {
868
+ definition.viewParams.forEach(function (paramsOption) {
869
+ var param = Param__1["default"].from(__assign({}, paramsOption), _this, 'params');
870
+ _this.addParam(param);
871
+ });
872
+ }
873
+ // 页面变量
874
+ if (Array.isArray(definition.viewVariables)) {
875
+ definition.viewVariables.forEach(function (variableOption) {
876
+ var variable = Variable__1["default"].from(__assign({}, variableOption), _this, 'variables');
877
+ _this.addVariable(variable);
878
+ });
879
+ }
880
+ // 页面逻辑
881
+ if (Array.isArray(definition.viewLogics)) {
882
+ definition.viewLogics.forEach(function (logicOption) {
883
+ // 页面逻辑只有load函数的走之前的逻辑其余不用创建
884
+ if (logicOption.name.startsWith('load')) {
885
+ var logic = Logic__1["default"].from(__assign({}, logicOption), _this, 'logics');
886
+ _this.addLogic(logic);
887
+ }
888
+ });
889
+ }
890
+ // 页面事件
891
+ if (Array.isArray(definition.viewBindEvents)) {
892
+ definition.viewBindEvents.forEach(function (eventOption) {
893
+ var newLogic = definition.viewLogics.find(function (logic) { return eventOption.calleeName === logic.name; });
894
+ var bindEvent = _this.bindEvents.find(function (currentEventItem) { return currentEventItem.name === eventOption.name; });
895
+ // 如果没有event对象就先新增一个,如果已经有了就在内部添加logic
896
+ if (!bindEvent) {
897
+ var event = BindEvent__1["default"].from(__assign(__assign({}, eventOption), { calleeName: '', logics: [newLogic] }), _this, 'events');
898
+ _this.addBindEvent(event);
899
+ }
900
+ else {
901
+ var index = bindEvent.logics.length;
902
+ newLogic.name = newLogic.name + index;
903
+ bindEvent.addLogic(newLogic);
904
+ }
905
+ });
906
+ }
907
+ };
908
+ View.prototype.onChange = function ($event) {
909
+ this.emit('change', $event);
910
+ };
911
+ View.prototype.getLogicExistingNames = function (excludedList) {
912
+ if (excludedList === void 0) { excludedList = []; }
913
+ var excludedSet = new Set(excludedList);
914
+ var varList = [];
915
+ if (Array.isArray(this.params)) {
916
+ varList.push.apply(varList, this.params);
917
+ }
918
+ if (Array.isArray(this.variables)) {
919
+ varList.push.apply(varList, this.variables);
920
+ }
921
+ if (Array.isArray(this.logics)) {
922
+ varList.push.apply(varList, this.logics);
923
+ }
924
+ return varList.filter(function (item) { return !excludedSet.has(item); }).map(function (item) { return item.name; });
925
+ };
926
+ View.prototype.getVarExistingNames = function (excludedList) {
927
+ var _a;
928
+ if (excludedList === void 0) { excludedList = []; }
929
+ var excludedSet = new Set(excludedList);
930
+ var varList = [];
931
+ if (Array.isArray(this.params)) {
932
+ varList.push.apply(varList, this.params);
933
+ }
934
+ if (Array.isArray(this.variables)) {
935
+ varList.push.apply(varList, this.variables);
936
+ }
937
+ if (Array.isArray(this.logics)) {
938
+ this.logics.forEach(function (logic) {
939
+ varList.push(logic);
940
+ if (Array.isArray(logic.params)) {
941
+ varList.push.apply(varList, logic.params);
942
+ }
943
+ if (Array.isArray(logic.returns)) {
944
+ varList.push.apply(varList, logic.returns);
945
+ }
946
+ if (Array.isArray(logic.variables)) {
947
+ varList.push.apply(varList, logic.variables);
948
+ }
949
+ });
950
+ }
951
+ // 事件逻辑的变量不允许和页面逻辑下的重复
952
+ if (Array.isArray(this.elementLogicRoot) && this.elementLogicRoot.length) {
953
+ (_a = this.elementLogicRoot[0]) === null || _a === void 0 ? void 0 : _a.children.forEach(function (logic) {
954
+ if (Array.isArray(logic.variables)) {
955
+ varList.push.apply(varList, logic.variables);
956
+ }
957
+ });
958
+ }
959
+ return varList.filter(function (item) { return !excludedSet.has(item); }).map(function (item) { return item.name; });
960
+ };
961
+ /**
962
+ * 生成 Vue 中需要的 JS 代码
963
+ * @TODO 这一版先做成 componentOptions 式的,后面再美化
964
+ */
965
+ View.prototype.genScript = function () {
966
+ var _a;
967
+ var definition = {
968
+ params: this.params,
969
+ variables: this.variables,
970
+ logics: this.logics,
971
+ events: this.bindEvents,
972
+ title: this.title,
973
+ crumb: this.crumb,
974
+ first: (_a = this.children.find(function (child) { return child.isIndex; })) === null || _a === void 0 ? void 0 : _a.name,
975
+ auth: this.auth ? 'loginAuth' : undefined,
976
+ viewBindEvents: this.getViewBindEvents(),
977
+ viewExpressions: this.getViewExpressions()
978
+ };
979
+ var code = '';
980
+ var mixin = '';
981
+ if (this.script) {
982
+ mixin = this.script.trim().replace(/export default |module\.exports +=/, 'const mixin = ');
983
+ }
984
+ if (mixin) {
985
+ code += mixin;
986
+ }
987
+ code += 'export default {\n';
988
+ if (mixin) {
989
+ code += 'mixins: [mixin],';
990
+ }
991
+ code += translator_2["default"](definition);
992
+ code += '};\n';
993
+ return code;
994
+ };
995
+ View.prototype.genVueTemplate = function (options) {
996
+ var _a;
997
+ return (_a = this.elements) === null || _a === void 0 ? void 0 : _a.map(function (element) { return (element === null || element === void 0 ? void 0 : element.toVue(options)) + '\n'; }).join('');
998
+ };
999
+ /**
1000
+ * 转换成 Vue 文件
1001
+ */
1002
+ View.prototype.toVue = function (options) {
1003
+ var result = '';
1004
+ result += "<template>\n" + this.genVueTemplate(options) + "\n</template>\n";
1005
+ result += "<script>\n" + this.genScript() + "\n</script>\n";
1006
+ return result;
1007
+ };
1008
+ /**
1009
+ * 转换成设计器中使用的 Vue template 内容
1010
+ * @param options
1011
+ */
1012
+ View.prototype.genDesignerVueTemplate = function () {
1013
+ return this.elements.map(function (element) { return element.toDesignerVue() + '\n'; }).join('');
1014
+ };
1015
+ /**
1016
+ * 转换成设计器中使用的 Vue 文件
1017
+ * 目前不需要 script 和 style
1018
+ * @param options
1019
+ */
1020
+ View.prototype.toDesignerVue = function () {
1021
+ return "<template>\n" + this.genDesignerVueTemplate() + "</template>";
1022
+ };
1023
+ /**
1024
+ * 转换成 VueOptions
1025
+ * @TODO 后面 template 可以优化成 render 函数
1026
+ */
1027
+ View.prototype.toVueOptions = function (options) {
1028
+ return {
1029
+ template: this.genVueTemplate(options),
1030
+ script: this.genScript()
1031
+ };
1032
+ };
1033
+ /**
1034
+ * 生成宿主语言的文件路径
1035
+ * @param name 一般不用传,用于 rename
1036
+ */
1037
+ View.prototype.getEmbeddedFilePath = function (name) {
1038
+ if (name === void 0) { name = this.name; }
1039
+ var pathName = name;
1040
+ var parent = this.parentNode;
1041
+ if (parent) {
1042
+ while (parent && parent instanceof View_1) {
1043
+ pathName = parent.name + '/' + pathName;
1044
+ parent = parent.parentNode;
1045
+ }
1046
+ }
1047
+ return "/embedded/" + this.app.name + "/views/" + pathName + ".ts";
1048
+ };
1049
+ View.prototype.getNamespace = function () {
1050
+ if (this.parentNode && this.parentNode.getNamespace) {
1051
+ var parentNamespace = this.parentNode.getNamespace();
1052
+ var parentName = this.parentNode.name;
1053
+ var arr = [parentNamespace];
1054
+ if (this.parentNode.concept !== 'App' && parentName) {
1055
+ arr.push(parentName);
1056
+ }
1057
+ return arr.join('.') + ".views";
1058
+ }
1059
+ else
1060
+ throw new Error('无法获取命名空间,请设置 parentNode!');
1061
+ };
1062
+ View.prototype.getTsNamespace = function () {
1063
+ var parentNodeNamespace = this.getNamespace();
1064
+ var tsCalleeNamespace = parentNodeNamespace.replace(/\.[0-9]/g, function (m) { return m.replace('.', '.$'); });
1065
+ tsCalleeNamespace = tsCalleeNamespace.replace(/-/g, '_');
1066
+ return tsCalleeNamespace;
1067
+ };
1068
+ // 获取当前element,铺平
1069
+ View.prototype.elementsMethods = function (elements, allMethods) {
1070
+ var _this = this;
1071
+ if (elements) {
1072
+ elements.forEach(function (item) {
1073
+ allMethods.push(item);
1074
+ if (item.children) {
1075
+ _this.elementsMethods(item.children, allMethods);
1076
+ }
1077
+ });
1078
+ }
1079
+ };
1080
+ View.prototype.toEmbeddedTS = function (state) {
1081
+ var _this = this;
1082
+ function chineseTsName(name) {
1083
+ var tsName = name;
1084
+ // 匹配所有特殊字符都转为_
1085
+ tsName = tsName.replace(/[^\u4e00-\u9fa5a-zA-Z0-9]/g, '_');
1086
+ return tsName;
1087
+ }
1088
+ // 获取虚拟logic的参数和内容
1089
+ // 用作展示和tots查找引用
1090
+ this.getElementLogicRoot();
1091
+ var code = "export namespace " + this.tsName + " {\n";
1092
+ // 角色
1093
+ if (Array.isArray(this.bindRoles) && this.bindRoles.length) {
1094
+ code += translator_1.indent(((state === null || state === void 0 ? void 0 : state.tabSize) || 0) + 1);
1095
+ code += 'export let __bindRoles = [\n';
1096
+ this.bindRoles.forEach(function (role) {
1097
+ code += translator_1.indent(((state === null || state === void 0 ? void 0 : state.tabSize) || 0) + 1);
1098
+ code += _this.app.getNamespace() + ".roles." + chineseTsName(role) + "." + chineseTsName(role) + ",";
1099
+ code += '\n';
1100
+ });
1101
+ code += '\n';
1102
+ code += translator_1.indent(((state === null || state === void 0 ? void 0 : state.tabSize) || 0) + 1);
1103
+ code += '];\n';
1104
+ }
1105
+ // 需要类型推导的局部变量/返回值需要调整申明顺序
1106
+ var advanceMap = new Map();
1107
+ this.traverseChildren(function (el) {
1108
+ var _a, _b;
1109
+ if (el && (el instanceof BatchAssignment__1["default"] || (el instanceof Assignment__1["default"] && ((_a = el.left) === null || _a === void 0 ? void 0 : _a.name)))) {
1110
+ // 子页面内部逻辑过滤
1111
+ if (el.view !== _this)
1112
+ return;
1113
+ var jsCode_1 = el.toJS();
1114
+ var advanceVar = (_b = _this.variables) === null || _b === void 0 ? void 0 : _b.find(function (variable) {
1115
+ return !variable.typeAnnotation && jsCode_1.includes("this." + variable.name + " = ");
1116
+ });
1117
+ if (advanceVar && !advanceMap.get(advanceVar)) {
1118
+ advanceMap.set(advanceVar, el);
1119
+ }
1120
+ }
1121
+ });
1122
+ if (Array.isArray(this.params)) {
1123
+ this.params.forEach(function (param) {
1124
+ code += translator_1.indent(((state === null || state === void 0 ? void 0 : state.tabSize) || 0) + 1) + 'let ';
1125
+ code += param.toEmbeddedTS(translator_1.shiftState(state, code, { inline: true }));
1126
+ code += ';\n';
1127
+ });
1128
+ }
1129
+ if (Array.isArray(this.variables)) {
1130
+ this.variables.forEach(function (variable) {
1131
+ if (!advanceMap.get(variable)) {
1132
+ code += translator_1.indent(((state === null || state === void 0 ? void 0 : state.tabSize) || 0) + 1) + 'let ';
1133
+ code += variable.toEmbeddedTS(translator_1.shiftState(state, code, { inline: true }));
1134
+ code += ';\n';
1135
+ }
1136
+ });
1137
+ }
1138
+ advanceMap.forEach(function (assignment, variable) {
1139
+ code += translator_1.indent(((state === null || state === void 0 ? void 0 : state.tabSize) || 0) + 1) + '// @ts-ignore\n';
1140
+ code += translator_1.indent(((state === null || state === void 0 ? void 0 : state.tabSize) || 0) + 1) + 'let ';
1141
+ code += variable.toEmbeddedTS(translator_1.shiftState(state, code, { inline: true }));
1142
+ code += ' = ';
1143
+ if (assignment instanceof BatchAssignment__1["default"]) {
1144
+ assignment.assignmentLines.forEach(function (_a) {
1145
+ var _b, _c, _d;
1146
+ var leftIndex = _a.leftIndex, rightIndex = _a.rightIndex;
1147
+ var leftCode = leftIndex.length === 1 ? assignment.left.expression.toEmbeddedTS(translator_1.shiftState(state, code, { inline: true })) : (_b = assignment.left.members[leftIndex[1]]) === null || _b === void 0 ? void 0 : _b.toEmbeddedTS(translator_1.shiftState(state, code, { inline: true }));
1148
+ if (leftCode === variable.name) {
1149
+ var rightNode = rightIndex.length === 1 ? (_c = assignment.rights[rightIndex[0]]) === null || _c === void 0 ? void 0 : _c.expression : (_d = assignment.rights[rightIndex[0]]) === null || _d === void 0 ? void 0 : _d.members[rightIndex[1]];
1150
+ var rightCode = rightNode === null || rightNode === void 0 ? void 0 : rightNode.toEmbeddedTS(translator_1.shiftState(state, code, { inline: true }));
1151
+ code += _this.getRightCode(rightCode, assignment, rightNode);
1152
+ }
1153
+ });
1154
+ }
1155
+ else {
1156
+ var rightCode = '';
1157
+ // 因为右侧枚举要赋值就得new 一下;
1158
+ if (assignment.right && assignment.right instanceof Identifier__1["default"] && assignment.right.namespace && assignment.right.namespace.endsWith('enums')) {
1159
+ rightCode += 'new ';
1160
+ }
1161
+ rightCode += (assignment.right && assignment.right.toEmbeddedTS) ? assignment.right.toEmbeddedTS(translator_1.shiftState(state, code, { inline: true })) : '__RIGHT__';
1162
+ code += _this.getRightCode(rightCode, assignment, assignment.right);
1163
+ }
1164
+ code += ';\n';
1165
+ });
1166
+ // elements类型声明定义
1167
+ code += "interface __elements {\n";
1168
+ // 生成所有的name和类型定义
1169
+ this.elements.forEach(function (element) {
1170
+ code += element.toEmbeddedTSDefinition(translator_1.shiftState(state, code, {
1171
+ tabSize: ((state === null || state === void 0 ? void 0 : state.tabSize) || 0) + 1
1172
+ }));
1173
+ });
1174
+ code += translator_1.indent(((state === null || state === void 0 ? void 0 : state.tabSize) || 0) + 1) + '}\n';
1175
+ code += "let __elements: __elements;\n";
1176
+ // 逻辑
1177
+ if (Array.isArray(this.logics) && this.logics.length) {
1178
+ code += translator_1.indent(((state === null || state === void 0 ? void 0 : state.tabSize) || 0) + 1);
1179
+ this.logics.forEach(function (logic) {
1180
+ code += logic.toEmbeddedTS(translator_1.shiftState(state, code, {
1181
+ tabSize: ((state === null || state === void 0 ? void 0 : state.tabSize) || 0) + 2
1182
+ }), 'noExport');
1183
+ code += '\n';
1184
+ });
1185
+ code += translator_1.indent(((state === null || state === void 0 ? void 0 : state.tabSize) || 0) + 1);
1186
+ }
1187
+ // 事件
1188
+ if (Array.isArray(this.bindEvents)) {
1189
+ this.bindEvents.forEach(function (event) {
1190
+ code += event.toEmbeddedTS(translator_1.shiftState(state, code, {
1191
+ tabSize: ((state === null || state === void 0 ? void 0 : state.tabSize) || 0)
1192
+ }), true);
1193
+ code += '\n';
1194
+ });
1195
+ }
1196
+ // render函数
1197
+ code += '\n' + translator_1.indent(((state === null || state === void 0 ? void 0 : state.tabSize) || 0) + 1);
1198
+ code += "export function __render(";
1199
+ code += "){\n";
1200
+ code += translator_1.indent(((state === null || state === void 0 ? void 0 : state.tabSize) || 0));
1201
+ // elements 元素
1202
+ if (Array.isArray(this.elements)) {
1203
+ // 生成嵌套式的内容
1204
+ this.elements.forEach(function (element) {
1205
+ code += element.toEmbeddedTS(translator_1.shiftState(state, code, {
1206
+ tabSize: ((state === null || state === void 0 ? void 0 : state.tabSize) || 0) + 3
1207
+ }));
1208
+ code += '\n';
1209
+ });
1210
+ }
1211
+ code += '\n' + translator_1.indent(((state === null || state === void 0 ? void 0 : state.tabSize) || 0) + 1) + '}\n';
1212
+ if (Array.isArray(this.params)) {
1213
+ code += translator_1.indent(((state === null || state === void 0 ? void 0 : state.tabSize) || 0) + 1) + "export function $destination(options: {";
1214
+ this.params.forEach(function (param, index) {
1215
+ code += param.name + '?: ';
1216
+ code += param.typeAnnotation.toEmbeddedTS(translator_1.shiftState(state, code));
1217
+ code += ', ';
1218
+ });
1219
+ // 锚点
1220
+ code += "_anchor?: nasl.core.String";
1221
+ code += '}){}\n';
1222
+ }
1223
+ code += translator_1.indent(((state === null || state === void 0 ? void 0 : state.tabSize) || 0)) + '}\n';
1224
+ return code;
1225
+ };
1226
+ View.prototype.toEmbeddedTSFile = function () {
1227
+ var code = "namespace " + this.getTsNamespace() + " {\n";
1228
+ var state = translator_1.createCompilerState(code, {
1229
+ tabSize: 1
1230
+ });
1231
+ try {
1232
+ code += this.toEmbeddedTS(state);
1233
+ }
1234
+ catch (err) {
1235
+ code += '';
1236
+ console.log(err);
1237
+ }
1238
+ code += '}\n';
1239
+ return {
1240
+ code: code,
1241
+ filePath: this.getEmbeddedFilePath(),
1242
+ sourceMap: state.sourceMap
1243
+ };
1244
+ };
1245
+ Object.defineProperty(View.prototype, "path", {
1246
+ get: function () {
1247
+ var _path = [];
1248
+ var view = this;
1249
+ while (view.concept === 'View') {
1250
+ _path.push(view.name);
1251
+ view = view.parentNode;
1252
+ }
1253
+ var path = '/';
1254
+ if (_path.length) {
1255
+ path += "" + _path.reverse().join('/');
1256
+ }
1257
+ return path;
1258
+ },
1259
+ enumerable: false,
1260
+ configurable: true
1261
+ });
1262
+ Object.defineProperty(View.prototype, "authPath", {
1263
+ /**
1264
+ * 权限领域的资源路径
1265
+ */
1266
+ get: function () {
1267
+ return this.path;
1268
+ },
1269
+ enumerable: false,
1270
+ configurable: true
1271
+ });
1272
+ View.prototype.getElementLogicRoot = function () {
1273
+ var logics = [];
1274
+ // 页面上的绑定的事件
1275
+ this.bindEvents.forEach(function (bindEvent) {
1276
+ bindEvent.logics.forEach(function (logic) {
1277
+ // 声明周期没有event
1278
+ logics.push(logic);
1279
+ });
1280
+ });
1281
+ this.elements.forEach(function (item) {
1282
+ utils.traverse(function (current) {
1283
+ current.node.bindEvents.forEach(function (bindEvent) {
1284
+ bindEvent.logics.forEach(function (logic) {
1285
+ if (logic.name.startsWith('__')) {
1286
+ return;
1287
+ }
1288
+ // 绑定参数才有 event 的 current
1289
+ logic.virtualParams = bindEvent.getContextRenderLogicParams(logic);
1290
+ logics.push(logic);
1291
+ });
1292
+ });
1293
+ }, { node: item });
1294
+ });
1295
+ if (logics.length) {
1296
+ var expanded = (this.elementLogicRoot.length && this.elementLogicRoot[0].expanded) || false;
1297
+ this.elementLogicRoot = [{
1298
+ concept: 'elementLogicRoot',
1299
+ expanded: expanded,
1300
+ children: logics
1301
+ }];
1302
+ }
1303
+ else {
1304
+ this.elementLogicRoot = [];
1305
+ }
1306
+ };
1307
+ View.prototype.getViewBindEvents = function () {
1308
+ var bindEvents = [];
1309
+ // 页面上的绑定的事件
1310
+ this.bindEvents.forEach(function (bindEvent) {
1311
+ bindEvents.push(bindEvent);
1312
+ });
1313
+ this.elements.forEach(function (item) {
1314
+ utils.traverse(function (current) {
1315
+ current.node.bindEvents.forEach(function (bindEvent) {
1316
+ bindEvents.push(bindEvent);
1317
+ });
1318
+ }, { node: item });
1319
+ });
1320
+ return bindEvents;
1321
+ };
1322
+ // 获取页面上需要替换的表达式
1323
+ View.prototype.getViewExpressions = function () {
1324
+ var bindExpressions = [];
1325
+ this.elements.forEach(function (item) {
1326
+ utils.traverse(function (current) {
1327
+ var node = current.node;
1328
+ // 处理三种情况
1329
+ if (['BindAttribute', 'BindDirective', 'BindStyle'].includes(node.concept)
1330
+ && node.needReplaceWithIdentifier) {
1331
+ bindExpressions.push(node);
1332
+ }
1333
+ }, {
1334
+ node: item
1335
+ }, {
1336
+ mode: 'anyObject',
1337
+ depthFirst: true,
1338
+ excludedKeySet: new Set([
1339
+ 'bindEvents',
1340
+ 'parentNode',
1341
+ 'sourceMap',
1342
+ 'storageJSON',
1343
+ 'tsErrorDetail',
1344
+ 'NaslAnnotatedJSON',
1345
+ 'calledFrom',
1346
+ '_events',
1347
+ '_collectingList',
1348
+ '_historyList',
1349
+ ])
1350
+ });
1351
+ });
1352
+ return bindExpressions;
1353
+ };
1354
+ /**
1355
+ * @param path 子路径
1356
+ * 比如当前页面路径为:/dashboard
1357
+ * path 为要查找子路径:如 /student/list、student/list
1358
+ */
1359
+ View.prototype.findViewByPath = function (path) {
1360
+ var arr = path.split('/');
1361
+ if (arr[0] === '')
1362
+ arr.shift();
1363
+ if (!arr.length)
1364
+ return this;
1365
+ var childName = arr.shift();
1366
+ var subView = this.children.find(function (child) { return child.name === childName; });
1367
+ return arr.length ? subView.findViewByPath(arr.join('/')) : subView;
1368
+ };
1369
+ View.prototype.findViewByName = function (name) {
1370
+ return utils.traverse(function (current) {
1371
+ if (current.node.name === name)
1372
+ return current.node;
1373
+ }, { node: this });
1374
+ };
1375
+ View.prototype.findElementByName = function (name) {
1376
+ var _a;
1377
+ return (_a = this.elements[0]) === null || _a === void 0 ? void 0 : _a.findElementByName(name);
1378
+ };
1379
+ View.prototype.findElementByTag = function (tag) {
1380
+ var _a;
1381
+ return (_a = this.elements[0]) === null || _a === void 0 ? void 0 : _a.findElementByName(tag);
1382
+ };
1383
+ View.prototype.findElementByAttr = function (name, value) {
1384
+ var _a;
1385
+ return (_a = this.elements[0]) === null || _a === void 0 ? void 0 : _a.findElementByAttr(name, value);
1386
+ };
1387
+ View.prototype._setAsIndexView = function (isIndex) {
1388
+ var _this = this;
1389
+ var views = [];
1390
+ if (this.parentNode.concept !== 'View') {
1391
+ views = this.parentNode.views;
1392
+ }
1393
+ else if (this.parentNode.concept === 'View') {
1394
+ views = this.parentNode.children;
1395
+ }
1396
+ if (views.length) {
1397
+ if (this.isIndex !== isIndex) {
1398
+ this.setIsIndex(isIndex);
1399
+ }
1400
+ // 设为默认跳转页时,将之前的默认跳转页取消设置
1401
+ if (isIndex) {
1402
+ views.forEach(function (view) {
1403
+ if (view !== _this && view.isIndex) {
1404
+ view.setIsIndex(false);
1405
+ }
1406
+ });
1407
+ }
1408
+ }
1409
+ };
1410
+ View.prototype.setAsIndexView = function (isIndex) {
1411
+ var actionMsg = "\u8BBE\u7F6E\u9875\u9762\u201C" + this.name + "\u201D\u4E3A\u9ED8\u8BA4\u8DF3\u8F6C\u9875";
1412
+ if (this.parentNode.concept !== 'View') {
1413
+ actionMsg = "\u8BBE\u7F6E\u9875\u9762\u201C" + this.name + "\u201D\u4E3A\u9996\u9875";
1414
+ }
1415
+ this.rootNode.emit('collect:start', {
1416
+ actionMsg: actionMsg
1417
+ });
1418
+ this._setAsIndexView(isIndex);
1419
+ this.rootNode.emit('collect:end');
1420
+ };
1421
+ View.prototype.removeExistingViewElement = function (viewElement) {
1422
+ if (this.existingViewElement.has(viewElement.name)) {
1423
+ this.existingViewElement["delete"](viewElement.name);
1424
+ }
1425
+ };
1426
+ View.prototype.getRightCode = function (code, assignment, rightNode) {
1427
+ var _this = this;
1428
+ var logic = assignment.logic;
1429
+ var logicRtn = logic === null || logic === void 0 ? void 0 : logic.returns[0];
1430
+ // 调用接口,参数替换成 null
1431
+ if (rightNode instanceof CallInterface__1["default"]) {
1432
+ var _interface = rightNode.getModuleInterface()._interface;
1433
+ return _interface ? rightNode.tsCalleeKey + "(" + _interface.params.map(function () { return 'null'; }).join(',') + ")" : null;
1434
+ }
1435
+ // 调用全局逻辑,参数替换成 null
1436
+ if (rightNode instanceof CallLogic__1["default"] && rightNode.calleeNamespace === 'app.logics') {
1437
+ var calleeName_1 = rightNode === null || rightNode === void 0 ? void 0 : rightNode.calleeName;
1438
+ var calleeLogic = this.app.logics.find(function (l) { return l.name === calleeName_1; });
1439
+ return calleeLogic ? "app.logics." + calleeName_1 + "(" + calleeLogic.params.map(function () { return 'null'; }).join(',') + ")" : null;
1440
+ }
1441
+ // view 局部变量,申明提升前增加判断,使用 logic 内的 result 直接替换成对应 logic,logic 内部变量替换成 null
1442
+ if (logicRtn && code.includes(logicRtn.name)) {
1443
+ if (code === logicRtn.name)
1444
+ return logic.name + "(" + logic.params.map(function () { return 'null'; }).join(',') + ")";
1445
+ code = this.handleReplaceCode(code, logicRtn.name, logic.name + "(" + logic.params.map(function () { return 'null'; }).join(',') + ")");
1446
+ logic.params.forEach(function (param) {
1447
+ if (code.includes(param.name))
1448
+ code = _this.handleReplaceCode(code, param.name, 'null');
1449
+ });
1450
+ logic.variables.forEach(function (variable) {
1451
+ if (code.includes(variable.name))
1452
+ code = _this.handleReplaceCode(code, variable.name, 'null');
1453
+ });
1454
+ return code;
1455
+ }
1456
+ // 处理 current.item、current1.item 等数据
1457
+ if (/current(\d)*\.item/.test(code)) {
1458
+ code = this.handleCurrentItemCode(code, logic);
1459
+ return code;
1460
+ }
1461
+ // 直接赋值 logic 内局部变量、输入参数直接提示系统无法推断类型
1462
+ var useLogicVar = logic.params.find(function (param) { return (code.includes(param.name)); })
1463
+ || logic.variables.find(function (variable) { return (code.includes(variable.name)); });
1464
+ return useLogicVar ? 'null' : code;
1465
+ };
1466
+ View.prototype.handleReplaceCode = function (code, variable, replaceCode) {
1467
+ return code.replace(/\S+/g, function ($1) {
1468
+ if ($1 === variable + ",")
1469
+ return replaceCode + ",";
1470
+ if ($1 === variable)
1471
+ return replaceCode;
1472
+ var fnCode = $1;
1473
+ if ($1.startsWith(variable + "."))
1474
+ fnCode = $1.replaceAll(variable + ".", replaceCode + ".");
1475
+ if ($1.startsWith(variable + ","))
1476
+ fnCode = $1.replaceAll(variable + ",", replaceCode + ",");
1477
+ if ($1.includes("(" + variable + ","))
1478
+ fnCode = $1.replaceAll("(" + variable + ",", "(" + replaceCode + ",");
1479
+ if ($1.includes("(" + variable + "."))
1480
+ fnCode = $1.replaceAll("(" + variable + ".", "(" + replaceCode + ".");
1481
+ if ($1.includes("(" + variable + ")"))
1482
+ fnCode = $1.replaceAll("(" + variable + ")", "(" + replaceCode + ")");
1483
+ if ($1.includes("," + variable + ","))
1484
+ fnCode = $1.replaceAll("," + variable + ",", "," + replaceCode + ",");
1485
+ if ($1.includes("," + variable + "."))
1486
+ fnCode = $1.replaceAll("," + variable + ".", "," + replaceCode + ".");
1487
+ if ($1.includes("," + variable + ")"))
1488
+ fnCode = $1.replaceAll("," + variable + ")", "," + replaceCode + ")");
1489
+ return fnCode;
1490
+ });
1491
+ };
1492
+ View.prototype.getAncestorViewElementsWithDataSource = function (logic) {
1493
+ var element = logic;
1494
+ var viewElements = [];
1495
+ while (element) {
1496
+ if (element.concept
1497
+ && element.concept === 'ViewElement'
1498
+ && element.bindAttrs.find(function (bAttr) { return bAttr.name === 'data-source'; })) {
1499
+ viewElements.push(element);
1500
+ }
1501
+ element = element.parentNode;
1502
+ }
1503
+ return viewElements;
1504
+ };
1505
+ View.prototype.handleCurrentItemCode = function (code, logic) {
1506
+ var viewElementsWithDataSource = this.getAncestorViewElementsWithDataSource(logic);
1507
+ viewElementsWithDataSource.forEach(function (viewElement, index) {
1508
+ var currentIndex = viewElementsWithDataSource.length - 1 - index;
1509
+ var currentItemCode = "current" + (currentIndex === 0 ? '' : currentIndex) + ".item";
1510
+ if (code.includes(currentItemCode)) {
1511
+ var dataSource = viewElement.bindAttrs.find(function (bAttr) { return bAttr.name === 'data-source'; });
1512
+ if (dataSource) {
1513
+ var view = viewElement.getAncestor('View');
1514
+ var dataSourceTS_1 = dataSource.expression.toEmbeddedTS();
1515
+ var logic_1 = view.logics.find(function (logic) { return logic.name === dataSourceTS_1; });
1516
+ if (logic_1) {
1517
+ code = code.replaceAll(currentItemCode, "nasl.ui.getCurrentItemType(" + dataSourceTS_1 + "(" + logic_1.params.map(function () { return 'null'; }).join(',') + "))");
1518
+ }
1519
+ else {
1520
+ var variable = view.variables.find(function (variable) { return variable.name === dataSourceTS_1; });
1521
+ code = code.replaceAll(currentItemCode, "nasl.ui.getCurrentItemType(" + (variable ? variable.name : dataSourceTS_1) + ")");
1522
+ }
1523
+ }
1524
+ }
1525
+ });
1526
+ return code;
1527
+ };
1528
+ var View_1;
1529
+ View.TAG_NAME_PREFIX_REG = /^([lieu]|van)[-_]/;
1530
+ __decorate([
1531
+ decorators_1.property()
1532
+ ], View.prototype, "concept");
1533
+ __decorate([
1534
+ decorators_1.property()
1535
+ ], View.prototype, "pageTemplateId");
1536
+ __decorate([
1537
+ decorators_1.property()
1538
+ ], View.prototype, "name");
1539
+ __decorate([
1540
+ decorators_1.property()
1541
+ ], View.prototype, "uuid");
1542
+ __decorate([
1543
+ decorators_1.property()
1544
+ ], View.prototype, "title");
1545
+ __decorate([
1546
+ decorators_1.property()
1547
+ ], View.prototype, "crumb");
1548
+ __decorate([
1549
+ decorators_1.property()
1550
+ ], View.prototype, "auth");
1551
+ __decorate([
1552
+ decorators_1.property()
1553
+ ], View.prototype, "authDescription");
1554
+ __decorate([
1555
+ decorators_1.property()
1556
+ ], View.prototype, "isIndex");
1557
+ __decorate([
1558
+ decorators_1.property()
1559
+ ], View.prototype, "template");
1560
+ __decorate([
1561
+ decorators_1.property()
1562
+ ], View.prototype, "script");
1563
+ __decorate([
1564
+ decorators_1.property()
1565
+ ], View.prototype, "style");
1566
+ __decorate([
1567
+ decorators_1.property('ViewElement')
1568
+ ], View.prototype, "elements");
1569
+ __decorate([
1570
+ decorators_1.property('Param')
1571
+ ], View.prototype, "params");
1572
+ __decorate([
1573
+ decorators_1.property('Variable')
1574
+ ], View.prototype, "variables");
1575
+ __decorate([
1576
+ decorators_1.property('Logic')
1577
+ ], View.prototype, "logics");
1578
+ __decorate([
1579
+ decorators_1.property('BindEvent')
1580
+ ], View.prototype, "bindEvents");
1581
+ __decorate([
1582
+ decorators_1.property()
1583
+ ], View.prototype, "bindRoles");
1584
+ __decorate([
1585
+ decorators_1.property('View')
1586
+ ], View.prototype, "children");
1587
+ __decorate([
1588
+ translator_1.withSourceMap()
1589
+ ], View.prototype, "toEmbeddedTS");
1590
+ View = View_1 = __decorate([
1591
+ decorators_1.concept('页面')
1592
+ ], View);
1593
+ return View;
1594
+ }(BaseNode_1["default"]));
1595
+ exports.View = View;
1596
+ classMap_1["default"].View = View;
1597
+ exports["default"] = View;
1598
+ //================================================================================
1599
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
1600
+ // 自动生成的代码已结束。下面可以手动编写。
1601
+ //================================================================================