@lcap/nasl 1.0.0-alpha.2 → 1.0.0-alpha.3

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 (391) hide show
  1. package/README.md +3 -3
  2. package/docs/assets/search.js +1 -1
  3. package/docs/classes/Entity.html +2832 -204
  4. package/docs/classes/View.html +4567 -365
  5. package/out/common/BaseNode.js +23 -16
  6. package/out/common/BaseNode.js.map +1 -1
  7. package/out/concepts/App__.d.ts +22 -0
  8. package/out/concepts/App__.js +77 -15
  9. package/out/concepts/App__.js.map +1 -1
  10. package/out/concepts/Argument__.d.ts +2 -1
  11. package/out/concepts/Argument__.js +2 -2
  12. package/out/concepts/Argument__.js.map +1 -1
  13. package/out/concepts/Assignment__.d.ts +2 -1
  14. package/out/concepts/Assignment__.js +3 -8
  15. package/out/concepts/Assignment__.js.map +1 -1
  16. package/out/concepts/Attribute__.js.map +1 -1
  17. package/out/concepts/BinaryExpression__.d.ts +2 -1
  18. package/out/concepts/BinaryExpression__.js +5 -5
  19. package/out/concepts/BinaryExpression__.js.map +1 -1
  20. package/out/concepts/BindAttribute__.d.ts +2 -1
  21. package/out/concepts/BindAttribute__.js +9 -4
  22. package/out/concepts/BindAttribute__.js.map +1 -1
  23. package/out/concepts/BindDirective__.d.ts +2 -1
  24. package/out/concepts/BindDirective__.js +2 -2
  25. package/out/concepts/BindDirective__.js.map +1 -1
  26. package/out/concepts/BindEvent__.d.ts +2 -1
  27. package/out/concepts/BindEvent__.js +4 -3
  28. package/out/concepts/BindEvent__.js.map +1 -1
  29. package/out/concepts/BooleanLiteral__.d.ts +2 -1
  30. package/out/concepts/BooleanLiteral__.js +1 -1
  31. package/out/concepts/BooleanLiteral__.js.map +1 -1
  32. package/out/concepts/CallFunction__.d.ts +57 -1
  33. package/out/concepts/CallFunction__.js +119 -11
  34. package/out/concepts/CallFunction__.js.map +1 -1
  35. package/out/concepts/CallInterface__.d.ts +2 -1
  36. package/out/concepts/CallInterface__.js +2 -2
  37. package/out/concepts/CallInterface__.js.map +1 -1
  38. package/out/concepts/CallLogic__.d.ts +57 -1
  39. package/out/concepts/CallLogic__.js +117 -10
  40. package/out/concepts/CallLogic__.js.map +1 -1
  41. package/out/concepts/CallQueryComponent__.js +1 -1
  42. package/out/concepts/CallQueryComponent__.js.map +1 -1
  43. package/out/concepts/Comment__.js.map +1 -1
  44. package/out/concepts/CompletionProperty__.js.map +1 -1
  45. package/out/concepts/ConfigGroup__.d.ts +120 -0
  46. package/out/concepts/ConfigGroup__.js +214 -0
  47. package/out/concepts/ConfigGroup__.js.map +1 -0
  48. package/out/concepts/ConfigPropertyValue__.d.ts +43 -0
  49. package/out/concepts/ConfigPropertyValue__.js +103 -0
  50. package/out/concepts/ConfigPropertyValue__.js.map +1 -0
  51. package/out/concepts/ConfigProperty__.d.ts +128 -0
  52. package/out/concepts/ConfigProperty__.js +236 -0
  53. package/out/concepts/ConfigProperty__.js.map +1 -0
  54. package/out/concepts/Configuration__.d.ts +120 -0
  55. package/out/concepts/Configuration__.js +210 -0
  56. package/out/concepts/Configuration__.js.map +1 -0
  57. package/out/concepts/Constant__.d.ts +2 -1
  58. package/out/concepts/Constant__.js +1 -1
  59. package/out/concepts/Constant__.js.map +1 -1
  60. package/out/concepts/DataElement__.js.map +1 -1
  61. package/out/concepts/Destination__.d.ts +2 -1
  62. package/out/concepts/Destination__.js +4 -3
  63. package/out/concepts/Destination__.js.map +1 -1
  64. package/out/concepts/End__.js.map +1 -1
  65. package/out/concepts/EntityIndex__.d.ts +8 -0
  66. package/out/concepts/EntityIndex__.js +18 -0
  67. package/out/concepts/EntityIndex__.js.map +1 -1
  68. package/out/concepts/EntityProperty__.d.ts +5 -5
  69. package/out/concepts/EntityProperty__.js +10 -9
  70. package/out/concepts/EntityProperty__.js.map +1 -1
  71. package/out/concepts/Entity__.d.ts +30 -26
  72. package/out/concepts/Entity__.js +44 -36
  73. package/out/concepts/Entity__.js.map +1 -1
  74. package/out/concepts/EnumItem__.js.map +1 -1
  75. package/out/concepts/Enum__.d.ts +8 -8
  76. package/out/concepts/Enum__.js +10 -4
  77. package/out/concepts/Enum__.js.map +1 -1
  78. package/out/concepts/Event__.js +1 -1
  79. package/out/concepts/Event__.js.map +1 -1
  80. package/out/concepts/ForEachStatement__.d.ts +35 -33
  81. package/out/concepts/ForEachStatement__.js +103 -36
  82. package/out/concepts/ForEachStatement__.js.map +1 -1
  83. package/out/concepts/Function__.js +1 -1
  84. package/out/concepts/Function__.js.map +1 -1
  85. package/out/concepts/Identifier__.d.ts +2 -1
  86. package/out/concepts/Identifier__.js +15 -1
  87. package/out/concepts/Identifier__.js.map +1 -1
  88. package/out/concepts/IfStatement__.js.map +1 -1
  89. package/out/concepts/InterfaceParam__.js +1 -1
  90. package/out/concepts/InterfaceParam__.js.map +1 -1
  91. package/out/concepts/Interface__.d.ts +5 -1
  92. package/out/concepts/Interface__.js +19 -5
  93. package/out/concepts/Interface__.js.map +1 -1
  94. package/out/concepts/JSBlock__.js.map +1 -1
  95. package/out/concepts/LogicItem__.d.ts +2 -1
  96. package/out/concepts/LogicItem__.js +2 -2
  97. package/out/concepts/LogicItem__.js.map +1 -1
  98. package/out/concepts/Logic__.js +9 -7
  99. package/out/concepts/Logic__.js.map +1 -1
  100. package/out/concepts/MemberExpression__.d.ts +2 -5
  101. package/out/concepts/MemberExpression__.js +12 -18
  102. package/out/concepts/MemberExpression__.js.map +1 -1
  103. package/out/concepts/Module__.d.ts +121 -126
  104. package/out/concepts/Module__.js +10 -17
  105. package/out/concepts/Module__.js.map +1 -1
  106. package/out/concepts/Namespace__.js +12 -12
  107. package/out/concepts/Namespace__.js.map +1 -1
  108. package/out/concepts/NullLiteral__.d.ts +2 -1
  109. package/out/concepts/NullLiteral__.js +1 -1
  110. package/out/concepts/NullLiteral__.js.map +1 -1
  111. package/out/concepts/NumericLiteral__.d.ts +2 -1
  112. package/out/concepts/NumericLiteral__.js +1 -1
  113. package/out/concepts/NumericLiteral__.js.map +1 -1
  114. package/out/concepts/Param__.d.ts +1 -1
  115. package/out/concepts/Param__.js +2 -2
  116. package/out/concepts/Param__.js.map +1 -1
  117. package/out/concepts/Point__.js.map +1 -1
  118. package/out/concepts/ProcessComponent__.js +2 -2
  119. package/out/concepts/ProcessComponent__.js.map +1 -1
  120. package/out/concepts/ProcessElement__.d.ts +82 -81
  121. package/out/concepts/ProcessElement__.js +19 -6
  122. package/out/concepts/ProcessElement__.js.map +1 -1
  123. package/out/concepts/ProcessOutcome__.js.map +1 -1
  124. package/out/concepts/Process__.d.ts +1 -0
  125. package/out/concepts/Process__.js +10 -4
  126. package/out/concepts/Process__.js.map +1 -1
  127. package/out/concepts/QueryAggregateExpression__.js.map +1 -1
  128. package/out/concepts/QueryFieldExpression__.js +1 -1
  129. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  130. package/out/concepts/QueryFromExpression__.js.map +1 -1
  131. package/out/concepts/QueryGroupByExpression__.js.map +1 -1
  132. package/out/concepts/QueryJoinExpression__.js +1 -1
  133. package/out/concepts/QueryJoinExpression__.js.map +1 -1
  134. package/out/concepts/QueryLimitExpression__.js.map +1 -1
  135. package/out/concepts/QueryOrderByExpression__.js.map +1 -1
  136. package/out/concepts/QuerySelectExpression__.js +1 -1
  137. package/out/concepts/QuerySelectExpression__.js.map +1 -1
  138. package/out/concepts/Rect__.js.map +1 -1
  139. package/out/concepts/Return__.d.ts +1 -1
  140. package/out/concepts/Return__.js +2 -2
  141. package/out/concepts/Return__.js.map +1 -1
  142. package/out/concepts/Role__.d.ts +5 -0
  143. package/out/concepts/Role__.js +19 -2
  144. package/out/concepts/Role__.js.map +1 -1
  145. package/out/concepts/Slot__.js.map +1 -1
  146. package/out/concepts/SqlQueryComponent__.d.ts +2 -0
  147. package/out/concepts/SqlQueryComponent__.js +16 -0
  148. package/out/concepts/SqlQueryComponent__.js.map +1 -1
  149. package/out/concepts/Start__.js.map +1 -1
  150. package/out/concepts/StringLiteral__.d.ts +2 -1
  151. package/out/concepts/StringLiteral__.js +1 -1
  152. package/out/concepts/StringLiteral__.js.map +1 -1
  153. package/out/concepts/StructureProperty__.d.ts +1 -1
  154. package/out/concepts/StructureProperty__.js +1 -1
  155. package/out/concepts/StructureProperty__.js.map +1 -1
  156. package/out/concepts/Structure__.d.ts +1 -1
  157. package/out/concepts/Structure__.js +4 -4
  158. package/out/concepts/Structure__.js.map +1 -1
  159. package/out/concepts/SwitchCase__.js.map +1 -1
  160. package/out/concepts/SwitchStatement__.js.map +1 -1
  161. package/out/concepts/Theme__.js.map +1 -1
  162. package/out/concepts/Transactional__.js.map +1 -1
  163. package/out/concepts/TypeAnnotation__.js +3 -0
  164. package/out/concepts/TypeAnnotation__.js.map +1 -1
  165. package/out/concepts/TypeParam__.js.map +1 -1
  166. package/out/concepts/UnaryExpression__.d.ts +2 -1
  167. package/out/concepts/UnaryExpression__.js +3 -3
  168. package/out/concepts/UnaryExpression__.js.map +1 -1
  169. package/out/concepts/Unparsed__.d.ts +2 -1
  170. package/out/concepts/Unparsed__.js +1 -1
  171. package/out/concepts/Unparsed__.js.map +1 -1
  172. package/out/concepts/UseComponent__.js.map +1 -1
  173. package/out/concepts/ValidationRule__.d.ts +2 -1
  174. package/out/concepts/ValidationRule__.js +2 -2
  175. package/out/concepts/ValidationRule__.js.map +1 -1
  176. package/out/concepts/Variable__.d.ts +6 -5
  177. package/out/concepts/Variable__.js +3 -3
  178. package/out/concepts/Variable__.js.map +1 -1
  179. package/out/concepts/ViewComponent__.js +5 -5
  180. package/out/concepts/ViewComponent__.js.map +1 -1
  181. package/out/concepts/ViewElement__.d.ts +5 -4
  182. package/out/concepts/ViewElement__.js +109 -65
  183. package/out/concepts/ViewElement__.js.map +1 -1
  184. package/out/concepts/View__.d.ts +97 -90
  185. package/out/concepts/View__.js +153 -118
  186. package/out/concepts/View__.js.map +1 -1
  187. package/out/concepts/WhileStatement__.js.map +1 -1
  188. package/out/concepts/basics/stdlib/index.js +2 -2
  189. package/out/concepts/basics/stdlib/index.js.map +1 -1
  190. package/out/concepts/basics/stdlib/nasl.ui.js +3 -137
  191. package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
  192. package/out/concepts/basics/stdlib/nasl.util.js +21 -5
  193. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  194. package/out/concepts/basics/stdlib/nasl.validation.d.ts +3 -0
  195. package/out/concepts/basics/stdlib/nasl.validation.js +527 -0
  196. package/out/concepts/basics/stdlib/nasl.validation.js.map +1 -0
  197. package/out/concepts/index__.d.ts +4 -0
  198. package/out/concepts/index__.js +4 -0
  199. package/out/concepts/index__.js.map +1 -1
  200. package/out/data/Module.d.ts +34 -0
  201. package/out/data/Module.js +53 -0
  202. package/out/data/Module.js.map +1 -0
  203. package/out/generator/compileComponent.d.ts +1 -1
  204. package/out/generator/genBundleFiles.d.ts +0 -1
  205. package/out/generator/genBundleFiles.js +1 -1
  206. package/out/generator/genBundleFiles.js.map +1 -1
  207. package/out/generator/genMetaData.d.ts +35 -0
  208. package/out/generator/genMetaData.js +78 -0
  209. package/out/generator/genMetaData.js.map +1 -0
  210. package/out/generator/index.d.ts +1 -0
  211. package/out/generator/index.js +1 -0
  212. package/out/generator/index.js.map +1 -1
  213. package/out/index.d.ts +2 -2
  214. package/out/index.js +3 -1
  215. package/out/index.js.map +1 -1
  216. package/out/server/createUiTs.d.ts +7 -0
  217. package/out/server/createUiTs.js +157 -0
  218. package/out/server/createUiTs.js.map +1 -0
  219. package/out/server/entity2LogicNamespace.d.ts +9 -1
  220. package/out/server/entity2LogicNamespace.js +11 -1
  221. package/out/server/entity2LogicNamespace.js.map +1 -1
  222. package/out/server/getExtensionModules.d.ts +3 -0
  223. package/out/server/getExtensionModules.js +18 -0
  224. package/out/server/getExtensionModules.js.map +1 -0
  225. package/out/server/getLogics.js +18 -15
  226. package/out/server/getLogics.js.map +1 -1
  227. package/out/server/getMemberIdentifier.d.ts +3 -2
  228. package/out/server/getMemberIdentifier.js +47 -15
  229. package/out/server/getMemberIdentifier.js.map +1 -1
  230. package/out/server/getProcesses.d.ts +4 -1
  231. package/out/server/getProcesses.js +16 -7
  232. package/out/server/getProcesses.js.map +1 -1
  233. package/out/server/getValidates.js +1 -1
  234. package/out/server/getValidates.js.map +1 -1
  235. package/out/server/index.js +1 -0
  236. package/out/server/index.js.map +1 -1
  237. package/out/server/naslServer.d.ts +23 -5
  238. package/out/server/naslServer.js +199 -25
  239. package/out/server/naslServer.js.map +1 -1
  240. package/out/server/process2LogicNamespace.d.ts +15 -1
  241. package/out/server/process2LogicNamespace.js +30 -3
  242. package/out/server/process2LogicNamespace.js.map +1 -1
  243. package/out/server/translator.js +28 -0
  244. package/out/server/translator.js.map +1 -1
  245. package/out/service/storage/init.d.ts +5 -0
  246. package/out/service/storage/init.js +60 -52
  247. package/out/service/storage/init.js.map +1 -1
  248. package/out/templator/genCallComponentLogic.js +2 -2
  249. package/out/templator/genCallComponentLogic.js.map +1 -1
  250. package/out/templator/genCreateBlock.js +6 -8
  251. package/out/templator/genCreateBlock.js.map +1 -1
  252. package/out/templator/genCurdEditMultipleKeyBlock.js +3 -3
  253. package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
  254. package/out/templator/genCurdMultipleKeyBlock.js +4 -4
  255. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  256. package/out/templator/genEditTableBlock.js +3 -3
  257. package/out/templator/genEditTableBlock.js.map +1 -1
  258. package/out/templator/genGetBlock.js +1 -1
  259. package/out/templator/genGetBlock.js.map +1 -1
  260. package/out/templator/genListViewBlock.js +2 -2
  261. package/out/templator/genListViewBlock.js.map +1 -1
  262. package/out/templator/genSelectBlock.js +1 -1
  263. package/out/templator/genSelectBlock.js.map +1 -1
  264. package/out/templator/genUpdateBlock.js +8 -12
  265. package/out/templator/genUpdateBlock.js.map +1 -1
  266. package/out/templator/utils.d.ts +20 -20
  267. package/out/templator/utils.js +22 -22
  268. package/out/templator/utils.js.map +1 -1
  269. package/package.json +2 -1
  270. package/src/automate/engine/index.js +37 -3
  271. package/src/automate/engine/utils.js +68 -64
  272. package/src/common/BaseNode.ts +24 -17
  273. package/src/concepts/App__.ts +93 -17
  274. package/src/concepts/Argument__.ts +4 -2
  275. package/src/concepts/Assignment__.ts +5 -7
  276. package/src/concepts/Attribute__.ts +1 -0
  277. package/src/concepts/BinaryExpression__.ts +7 -5
  278. package/src/concepts/BindAttribute__.ts +9 -4
  279. package/src/concepts/BindDirective__.ts +4 -2
  280. package/src/concepts/BindEvent__.ts +6 -4
  281. package/src/concepts/BooleanLiteral__.ts +3 -1
  282. package/src/concepts/CallFunction__.ts +195 -11
  283. package/src/concepts/CallInterface__.ts +4 -2
  284. package/src/concepts/CallLogic__.ts +211 -12
  285. package/src/concepts/CallQueryComponent__.ts +2 -1
  286. package/src/concepts/Comment__.ts +1 -0
  287. package/src/concepts/CompletionProperty__.ts +1 -0
  288. package/src/concepts/ConfigGroup__.ts +290 -0
  289. package/src/concepts/ConfigPropertyValue__.ts +112 -0
  290. package/src/concepts/ConfigProperty__.ts +306 -0
  291. package/src/concepts/Configuration__.ts +286 -0
  292. package/src/concepts/Constant__.ts +3 -1
  293. package/src/concepts/DataElement__.ts +1 -0
  294. package/src/concepts/Destination__.ts +7 -5
  295. package/src/concepts/End__.ts +1 -0
  296. package/src/concepts/EntityIndex__.ts +19 -0
  297. package/src/concepts/EntityProperty__.ts +9 -8
  298. package/src/concepts/Entity__.ts +66 -59
  299. package/src/concepts/EnumItem__.ts +1 -0
  300. package/src/concepts/Enum__.ts +32 -12
  301. package/src/concepts/Event__.ts +2 -1
  302. package/src/concepts/ForEachStatement__.ts +115 -69
  303. package/src/concepts/Function__.ts +2 -1
  304. package/src/concepts/Identifier__.ts +18 -1
  305. package/src/concepts/IfStatement__.ts +1 -0
  306. package/src/concepts/InterfaceParam__.ts +2 -1
  307. package/src/concepts/Interface__.ts +21 -5
  308. package/src/concepts/JSBlock__.ts +1 -0
  309. package/src/concepts/LogicItem__.ts +9 -40
  310. package/src/concepts/Logic__.ts +48 -9
  311. package/src/concepts/MemberExpression__.ts +14 -17
  312. package/src/concepts/Module__.ts +158 -139
  313. package/src/concepts/Namespace__.ts +13 -12
  314. package/src/concepts/NullLiteral__.ts +3 -1
  315. package/src/concepts/NumericLiteral__.ts +3 -1
  316. package/src/concepts/Param__.ts +3 -2
  317. package/src/concepts/Point__.ts +1 -0
  318. package/src/concepts/ProcessComponent__.ts +3 -2
  319. package/src/concepts/ProcessElement__.ts +102 -107
  320. package/src/concepts/ProcessOutcome__.ts +1 -0
  321. package/src/concepts/Process__.ts +12 -4
  322. package/src/concepts/QueryAggregateExpression__.ts +1 -0
  323. package/src/concepts/QueryFieldExpression__.ts +2 -1
  324. package/src/concepts/QueryFromExpression__.ts +1 -0
  325. package/src/concepts/QueryGroupByExpression__.ts +1 -0
  326. package/src/concepts/QueryJoinExpression__.ts +2 -1
  327. package/src/concepts/QueryLimitExpression__.ts +1 -0
  328. package/src/concepts/QueryOrderByExpression__.ts +1 -0
  329. package/src/concepts/QuerySelectExpression__.ts +2 -1
  330. package/src/concepts/Rect__.ts +1 -0
  331. package/src/concepts/Return__.ts +3 -2
  332. package/src/concepts/Role__.ts +19 -2
  333. package/src/concepts/Slot__.ts +1 -0
  334. package/src/concepts/SqlQueryComponent__.ts +11 -1
  335. package/src/concepts/Start__.ts +1 -0
  336. package/src/concepts/StringLiteral__.ts +3 -1
  337. package/src/concepts/StructureProperty__.ts +2 -1
  338. package/src/concepts/Structure__.ts +5 -4
  339. package/src/concepts/SwitchCase__.ts +1 -0
  340. package/src/concepts/SwitchStatement__.ts +1 -0
  341. package/src/concepts/Theme__.ts +1 -0
  342. package/src/concepts/Transactional__.ts +1 -0
  343. package/src/concepts/TypeAnnotation__.ts +4 -0
  344. package/src/concepts/TypeParam__.ts +1 -0
  345. package/src/concepts/UnaryExpression__.ts +6 -3
  346. package/src/concepts/Unparsed__.ts +3 -1
  347. package/src/concepts/UseComponent__.ts +1 -0
  348. package/src/concepts/ValidationRule__.ts +5 -2
  349. package/src/concepts/Variable__.ts +12 -6
  350. package/src/concepts/ViewComponent__.ts +6 -5
  351. package/src/concepts/ViewElement__.ts +109 -80
  352. package/src/concepts/View__.ts +245 -206
  353. package/src/concepts/WhileStatement__.ts +1 -0
  354. package/src/concepts/basics/stdlib/index.ts +2 -2
  355. package/src/concepts/basics/stdlib/nasl.ui.ts +3 -137
  356. package/src/concepts/basics/stdlib/nasl.util.ts +21 -5
  357. package/src/concepts/basics/stdlib/{nasl.validate.ts → nasl.validation.ts} +28 -28
  358. package/src/concepts/index__.ts +4 -0
  359. package/src/generator/compileComponent.ts +1 -1
  360. package/src/generator/genBundleFiles.ts +1 -2
  361. package/src/generator/genMetaData.ts +111 -0
  362. package/src/generator/index.ts +1 -0
  363. package/src/index.ts +2 -2
  364. package/src/server/createUiTs.ts +153 -0
  365. package/src/server/entity2LogicNamespace.ts +17 -1
  366. package/src/server/getExtensionModules.ts +13 -0
  367. package/src/server/getLogics.ts +19 -18
  368. package/src/server/getMemberIdentifier.ts +60 -19
  369. package/src/server/getProcesses.ts +15 -8
  370. package/src/server/getValidates.ts +1 -1
  371. package/src/server/index.ts +2 -1
  372. package/src/server/naslServer.ts +204 -24
  373. package/src/server/process2LogicNamespace.ts +44 -3
  374. package/src/server/translator.ts +121 -97
  375. package/src/service/config/api.js +32 -0
  376. package/src/service/config/index.js +6 -0
  377. package/src/service/creator/index.js +2 -2
  378. package/src/service/logic/checktypeSocket.js +49 -0
  379. package/src/service/modules/api.js +20 -0
  380. package/src/service/modules/index.js +6 -0
  381. package/src/service/storage/init.ts +62 -54
  382. package/src/templator/genCallComponentLogic.ts +2 -2
  383. package/src/templator/genCreateBlock.ts +19 -25
  384. package/src/templator/genCurdEditMultipleKeyBlock.ts +3 -3
  385. package/src/templator/genCurdMultipleKeyBlock.ts +4 -4
  386. package/src/templator/genEditTableBlock.ts +3 -3
  387. package/src/templator/genGetBlock.ts +1 -1
  388. package/src/templator/genListViewBlock.ts +2 -2
  389. package/src/templator/genSelectBlock.ts +1 -1
  390. package/src/templator/genUpdateBlock.ts +19 -25
  391. package/src/templator/utils.ts +25 -153
@@ -12,13 +12,14 @@ import { EventPayload, Params } from '../common/EventEmitter';
12
12
  import { concept, excludedInJSON, property } from '../decorators';
13
13
 
14
14
  import * as utils from '../utils';
15
+ import { v4 as uuidv4 } from 'uuid';
15
16
  import BaseNode from '../common/BaseNode';
16
17
  import classMap from '../common/classMap';
17
18
  import ViewElement from './ViewElement__';
18
19
  import Param from './Param__';
19
20
  import Variable from './Variable__';
20
- import BindEvent from './BindEvent__';
21
21
  import Logic from './Logic__';
22
+ import BindEvent from './BindEvent__';
22
23
  import Module from './Module__';
23
24
  import App from './App__';
24
25
 
@@ -46,10 +47,10 @@ export class View extends BaseNode {
46
47
  name: string = undefined;
47
48
 
48
49
  /**
49
- * 前后端路径
50
+ * 唯一标识
50
51
  */
51
52
  @property()
52
- tempPath: string = undefined;
53
+ uuid: string = undefined;
53
54
 
54
55
  /**
55
56
  * 页面标题
@@ -111,18 +112,18 @@ export class View extends BaseNode {
111
112
  @property('Variable')
112
113
  variables: Array<Variable> = [];
113
114
 
114
- /**
115
- * 元素绑定事件列表
116
- */
117
- @property('BindEvent')
118
- events: Array<BindEvent> = [];
119
-
120
115
  /**
121
116
  * 逻辑列表
122
117
  */
123
118
  @property('Logic')
124
119
  logics: Array<Logic> = [];
125
120
 
121
+ /**
122
+ * 元素绑定事件列表
123
+ */
124
+ @property('BindEvent')
125
+ bindEvents: Array<BindEvent> = [];
126
+
126
127
  /**
127
128
  * 绑定的角色
128
129
  */
@@ -371,7 +372,7 @@ export class View extends BaseNode {
371
372
 
372
373
  getParamExistingNames(excludedList: Array<Param> = []) {
373
374
  const excludedSet = new Set(excludedList);
374
- return this.params.filter((item) => !excludedSet.has(item)).map((item) => item.name);
375
+ return (this.params || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
375
376
  }
376
377
  getParamUniqueName(name = 'param1') {
377
378
  return utils.unique(name, this.getParamExistingNames());
@@ -513,7 +514,7 @@ export class View extends BaseNode {
513
514
 
514
515
  getVariableExistingNames(excludedList: Array<Variable> = []) {
515
516
  const excludedSet = new Set(excludedList);
516
- return this.variables.filter((item) => !excludedSet.has(item)).map((item) => item.name);
517
+ return (this.variables || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
517
518
  }
518
519
  getVariableUniqueName(name = 'variable1') {
519
520
  return utils.unique(name, this.getVariableExistingNames());
@@ -653,285 +654,285 @@ export class View extends BaseNode {
653
654
  }
654
655
 
655
656
 
656
- getBindEventExistingNames(excludedList: Array<BindEvent> = []) {
657
+ getLogicExistingNames(excludedList: Array<Logic> = []) {
657
658
  const excludedSet = new Set(excludedList);
658
- return this.events.filter((item) => !excludedSet.has(item)).map((item) => item.name);
659
+ return (this.logics || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
659
660
  }
660
- getBindEventUniqueName(name = 'bindEvent1') {
661
- return utils.unique(name, this.getBindEventExistingNames());
661
+ getLogicUniqueName(name = 'logic1') {
662
+ return utils.unique(name, this.getLogicExistingNames());
662
663
  }
663
664
 
664
665
  /**
665
- * 插入元素绑定事件
666
+ * 插入逻辑
666
667
  * @internal
667
- * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
668
+ * @param name 逻辑名称,如果不填会自动生成一个唯一名称
668
669
  */
669
- _insertBindEventAt(name: string, index: number): BindEvent;
670
+ _insertLogicAt(name: string, index: number): Logic;
670
671
 
671
672
  /**
672
- * 插入元素绑定事件
673
+ * 插入逻辑
673
674
  * @internal
674
- * @param bindEventOptions 元素绑定事件参数
675
+ * @param logicOptions 逻辑参数
675
676
  */
676
- _insertBindEventAt(bindEventOptions: Partial<BindEvent>, index: number): BindEvent;
677
+ _insertLogicAt(logicOptions: Partial<Logic>, index: number): Logic;
677
678
 
678
679
  /**
679
- * 插入元素绑定事件
680
+ * 插入逻辑
680
681
  * @internal
681
- * @param bindEvent 已有的元素绑定事件实例
682
+ * @param logic 已有的逻辑实例
682
683
  */
683
- _insertBindEventAt(bindEvent: BindEvent, index: number): BindEvent;
684
+ _insertLogicAt(logic: Logic, index: number): Logic;
684
685
 
685
- _insertBindEventAt(options: string | Partial<BindEvent> | BindEvent, index: number) {
686
- const bindEventOptions: any = {};
687
- const relationOptions = { parentNode: this, parentKey: 'events' };
688
- let bindEvent: BindEvent;
686
+ _insertLogicAt(options: string | Partial<Logic> | Logic, index: number) {
687
+ const logicOptions: any = {};
688
+ const relationOptions = { parentNode: this, parentKey: 'logics' };
689
+ let logic: Logic;
689
690
  if (!options) {
690
- bindEvent = BindEvent.from({
691
- ...bindEventOptions,
692
- name: this.getBindEventUniqueName(),
693
- }, this, 'events');
691
+ logic = Logic.from({
692
+ ...logicOptions,
693
+ name: this.getLogicUniqueName(),
694
+ }, this, 'logics');
694
695
  } else if (typeof options === 'string') {
695
- bindEvent = BindEvent.from({
696
- ...bindEventOptions,
696
+ logic = Logic.from({
697
+ ...logicOptions,
697
698
  name: options,
698
- }, this, 'events');
699
- } else if (options instanceof BindEvent) {
699
+ }, this, 'logics');
700
+ } else if (options instanceof Logic) {
700
701
  options.delete(); // 同一实例不支持多处存在
701
- bindEvent = options;
702
- Object.assign(bindEvent, relationOptions);
702
+ logic = options;
703
+ Object.assign(logic, relationOptions);
703
704
  } else {
704
- bindEvent = BindEvent.from({
705
- ...bindEventOptions,
705
+ logic = Logic.from({
706
+ ...logicOptions,
706
707
  ...options,
707
- }, this, 'events');
708
+ }, this, 'logics');
708
709
  }
709
- this.events.splice(index, 0, bindEvent);
710
- return bindEvent;
710
+ this.logics.splice(index, 0, logic);
711
+ return logic;
711
712
  }
712
713
 
713
714
  /**
714
- * 插入元素绑定事件
715
- * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
715
+ * 插入逻辑
716
+ * @param name 逻辑名称,如果不填会自动生成一个唯一名称
716
717
  */
717
- insertBindEventAt(name: string, index: number): BindEvent;
718
+ insertLogicAt(name: string, index: number): Logic;
718
719
 
719
720
  /**
720
- * 插入元素绑定事件
721
- * @param bindEventOptions 元素绑定事件参数
721
+ * 插入逻辑
722
+ * @param logicOptions 逻辑参数
722
723
  */
723
- insertBindEventAt(bindEventOptions: Partial<BindEvent>, index: number): BindEvent;
724
+ insertLogicAt(logicOptions: Partial<Logic>, index: number): Logic;
724
725
 
725
726
  /**
726
- * 插入元素绑定事件
727
- * @param bindEvent 已有的元素绑定事件实例
727
+ * 插入逻辑
728
+ * @param logic 已有的逻辑实例
728
729
  */
729
- insertBindEventAt(bindEvent: BindEvent, index: number): BindEvent;
730
+ insertLogicAt(logic: Logic, index: number): Logic;
730
731
 
731
- insertBindEventAt(options: string | Partial<BindEvent> | BindEvent, index: number) {
732
- const node = this._insertBindEventAt(options as any, index);
732
+ insertLogicAt(options: string | Partial<Logic> | Logic, index: number) {
733
+ const node = this._insertLogicAt(options as any, index);
733
734
  node.create({
734
735
  index,
735
736
  parentNode: this,
736
- parentKey: 'events',
737
+ parentKey: 'logics',
737
738
  });
738
739
  return node;
739
740
  }
740
741
 
741
742
  /**
742
- * 添加元素绑定事件
743
+ * 添加逻辑
743
744
  * @internal
744
- * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
745
+ * @param name 逻辑名称,如果不填会自动生成一个唯一名称
745
746
  */
746
- _addBindEvent(name?: string): BindEvent;
747
+ _addLogic(name?: string): Logic;
747
748
 
748
749
  /**
749
- * 添加元素绑定事件
750
+ * 添加逻辑
750
751
  * @internal
751
- * @param bindEventOptions 元素绑定事件参数
752
+ * @param logicOptions 逻辑参数
752
753
  */
753
- _addBindEvent(bindEventOptions: Partial<BindEvent>): BindEvent;
754
+ _addLogic(logicOptions: Partial<Logic>): Logic;
754
755
 
755
756
  /**
756
- * 添加元素绑定事件
757
+ * 添加逻辑
757
758
  * @internal
758
- * @param bindEvent 已有的元素绑定事件实例
759
+ * @param logic 已有的逻辑实例
759
760
  */
760
- _addBindEvent(bindEvent: BindEvent): BindEvent;
761
+ _addLogic(logic: Logic): Logic;
761
762
 
762
- _addBindEvent(options?: string | Partial<BindEvent> | BindEvent) {
763
- const index = this.events.length;
764
- return this._insertBindEventAt(options as any, index);
763
+ _addLogic(options?: string | Partial<Logic> | Logic) {
764
+ const index = this.logics.length;
765
+ return this._insertLogicAt(options as any, index);
765
766
  }
766
767
 
767
768
  /**
768
- * 添加元素绑定事件
769
+ * 添加逻辑
769
770
  * @internal
770
- * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
771
+ * @param name 逻辑名称,如果不填会自动生成一个唯一名称
771
772
  */
772
- addBindEvent(name?: string): BindEvent;
773
+ addLogic(name?: string): Logic;
773
774
 
774
775
  /**
775
- * 添加元素绑定事件
776
- * @param bindEventOptions 元素绑定事件参数
776
+ * 添加逻辑
777
+ * @param logicOptions 逻辑参数
777
778
  */
778
- addBindEvent(bindEventOptions: Partial<BindEvent>): BindEvent;
779
+ addLogic(logicOptions: Partial<Logic>): Logic;
779
780
 
780
781
  /**
781
- * 添加元素绑定事件
782
- * @param bindEvent 已有的元素绑定事件实例
782
+ * 添加逻辑
783
+ * @param logic 已有的逻辑实例
783
784
  */
784
- addBindEvent(bindEvent: BindEvent): BindEvent;
785
+ addLogic(logic: Logic): Logic;
785
786
 
786
- addBindEvent(options?: string | Partial<BindEvent> | BindEvent) {
787
- const node = this._addBindEvent(options as any);
788
- const index = this.events.length;
787
+ addLogic(options?: string | Partial<Logic> | Logic) {
788
+ const node = this._addLogic(options as any);
789
+ const index = this.logics.length;
789
790
  node.create({
790
791
  index,
791
792
  parentNode: this,
792
- parentKey: 'events',
793
+ parentKey: 'logics',
793
794
  });
794
795
  return node;
795
796
  }
796
797
 
797
798
 
798
- getLogicExistingNames(excludedList: Array<Logic> = []) {
799
+ getBindEventExistingNames(excludedList: Array<BindEvent> = []) {
799
800
  const excludedSet = new Set(excludedList);
800
- return this.logics.filter((item) => !excludedSet.has(item)).map((item) => item.name);
801
+ return (this.bindEvents || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
801
802
  }
802
- getLogicUniqueName(name = 'logic1') {
803
- return utils.unique(name, this.getLogicExistingNames());
803
+ getBindEventUniqueName(name = 'bindEvent1') {
804
+ return utils.unique(name, this.getBindEventExistingNames());
804
805
  }
805
806
 
806
807
  /**
807
- * 插入逻辑
808
+ * 插入元素绑定事件
808
809
  * @internal
809
- * @param name 逻辑名称,如果不填会自动生成一个唯一名称
810
+ * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
810
811
  */
811
- _insertLogicAt(name: string, index: number): Logic;
812
+ _insertBindEventAt(name: string, index: number): BindEvent;
812
813
 
813
814
  /**
814
- * 插入逻辑
815
+ * 插入元素绑定事件
815
816
  * @internal
816
- * @param logicOptions 逻辑参数
817
+ * @param bindEventOptions 元素绑定事件参数
817
818
  */
818
- _insertLogicAt(logicOptions: Partial<Logic>, index: number): Logic;
819
+ _insertBindEventAt(bindEventOptions: Partial<BindEvent>, index: number): BindEvent;
819
820
 
820
821
  /**
821
- * 插入逻辑
822
+ * 插入元素绑定事件
822
823
  * @internal
823
- * @param logic 已有的逻辑实例
824
+ * @param bindEvent 已有的元素绑定事件实例
824
825
  */
825
- _insertLogicAt(logic: Logic, index: number): Logic;
826
+ _insertBindEventAt(bindEvent: BindEvent, index: number): BindEvent;
826
827
 
827
- _insertLogicAt(options: string | Partial<Logic> | Logic, index: number) {
828
- const logicOptions: any = {};
829
- const relationOptions = { parentNode: this, parentKey: 'logics' };
830
- let logic: Logic;
828
+ _insertBindEventAt(options: string | Partial<BindEvent> | BindEvent, index: number) {
829
+ const bindEventOptions: any = {};
830
+ const relationOptions = { parentNode: this, parentKey: 'bindEvents' };
831
+ let bindEvent: BindEvent;
831
832
  if (!options) {
832
- logic = Logic.from({
833
- ...logicOptions,
834
- name: this.getLogicUniqueName(),
835
- }, this, 'logics');
833
+ bindEvent = BindEvent.from({
834
+ ...bindEventOptions,
835
+ name: this.getBindEventUniqueName(),
836
+ }, this, 'bindEvents');
836
837
  } else if (typeof options === 'string') {
837
- logic = Logic.from({
838
- ...logicOptions,
838
+ bindEvent = BindEvent.from({
839
+ ...bindEventOptions,
839
840
  name: options,
840
- }, this, 'logics');
841
- } else if (options instanceof Logic) {
841
+ }, this, 'bindEvents');
842
+ } else if (options instanceof BindEvent) {
842
843
  options.delete(); // 同一实例不支持多处存在
843
- logic = options;
844
- Object.assign(logic, relationOptions);
844
+ bindEvent = options;
845
+ Object.assign(bindEvent, relationOptions);
845
846
  } else {
846
- logic = Logic.from({
847
- ...logicOptions,
847
+ bindEvent = BindEvent.from({
848
+ ...bindEventOptions,
848
849
  ...options,
849
- }, this, 'logics');
850
+ }, this, 'bindEvents');
850
851
  }
851
- this.logics.splice(index, 0, logic);
852
- return logic;
852
+ this.bindEvents.splice(index, 0, bindEvent);
853
+ return bindEvent;
853
854
  }
854
855
 
855
856
  /**
856
- * 插入逻辑
857
- * @param name 逻辑名称,如果不填会自动生成一个唯一名称
857
+ * 插入元素绑定事件
858
+ * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
858
859
  */
859
- insertLogicAt(name: string, index: number): Logic;
860
+ insertBindEventAt(name: string, index: number): BindEvent;
860
861
 
861
862
  /**
862
- * 插入逻辑
863
- * @param logicOptions 逻辑参数
863
+ * 插入元素绑定事件
864
+ * @param bindEventOptions 元素绑定事件参数
864
865
  */
865
- insertLogicAt(logicOptions: Partial<Logic>, index: number): Logic;
866
+ insertBindEventAt(bindEventOptions: Partial<BindEvent>, index: number): BindEvent;
866
867
 
867
868
  /**
868
- * 插入逻辑
869
- * @param logic 已有的逻辑实例
869
+ * 插入元素绑定事件
870
+ * @param bindEvent 已有的元素绑定事件实例
870
871
  */
871
- insertLogicAt(logic: Logic, index: number): Logic;
872
+ insertBindEventAt(bindEvent: BindEvent, index: number): BindEvent;
872
873
 
873
- insertLogicAt(options: string | Partial<Logic> | Logic, index: number) {
874
- const node = this._insertLogicAt(options as any, index);
874
+ insertBindEventAt(options: string | Partial<BindEvent> | BindEvent, index: number) {
875
+ const node = this._insertBindEventAt(options as any, index);
875
876
  node.create({
876
877
  index,
877
878
  parentNode: this,
878
- parentKey: 'logics',
879
+ parentKey: 'bindEvents',
879
880
  });
880
881
  return node;
881
882
  }
882
883
 
883
884
  /**
884
- * 添加逻辑
885
+ * 添加元素绑定事件
885
886
  * @internal
886
- * @param name 逻辑名称,如果不填会自动生成一个唯一名称
887
+ * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
887
888
  */
888
- _addLogic(name?: string): Logic;
889
+ _addBindEvent(name?: string): BindEvent;
889
890
 
890
891
  /**
891
- * 添加逻辑
892
+ * 添加元素绑定事件
892
893
  * @internal
893
- * @param logicOptions 逻辑参数
894
+ * @param bindEventOptions 元素绑定事件参数
894
895
  */
895
- _addLogic(logicOptions: Partial<Logic>): Logic;
896
+ _addBindEvent(bindEventOptions: Partial<BindEvent>): BindEvent;
896
897
 
897
898
  /**
898
- * 添加逻辑
899
+ * 添加元素绑定事件
899
900
  * @internal
900
- * @param logic 已有的逻辑实例
901
+ * @param bindEvent 已有的元素绑定事件实例
901
902
  */
902
- _addLogic(logic: Logic): Logic;
903
+ _addBindEvent(bindEvent: BindEvent): BindEvent;
903
904
 
904
- _addLogic(options?: string | Partial<Logic> | Logic) {
905
- const index = this.logics.length;
906
- return this._insertLogicAt(options as any, index);
905
+ _addBindEvent(options?: string | Partial<BindEvent> | BindEvent) {
906
+ const index = this.bindEvents.length;
907
+ return this._insertBindEventAt(options as any, index);
907
908
  }
908
909
 
909
910
  /**
910
- * 添加逻辑
911
+ * 添加元素绑定事件
911
912
  * @internal
912
- * @param name 逻辑名称,如果不填会自动生成一个唯一名称
913
+ * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
913
914
  */
914
- addLogic(name?: string): Logic;
915
+ addBindEvent(name?: string): BindEvent;
915
916
 
916
917
  /**
917
- * 添加逻辑
918
- * @param logicOptions 逻辑参数
918
+ * 添加元素绑定事件
919
+ * @param bindEventOptions 元素绑定事件参数
919
920
  */
920
- addLogic(logicOptions: Partial<Logic>): Logic;
921
+ addBindEvent(bindEventOptions: Partial<BindEvent>): BindEvent;
921
922
 
922
923
  /**
923
- * 添加逻辑
924
- * @param logic 已有的逻辑实例
924
+ * 添加元素绑定事件
925
+ * @param bindEvent 已有的元素绑定事件实例
925
926
  */
926
- addLogic(logic: Logic): Logic;
927
+ addBindEvent(bindEvent: BindEvent): BindEvent;
927
928
 
928
- addLogic(options?: string | Partial<Logic> | Logic) {
929
- const node = this._addLogic(options as any);
930
- const index = this.logics.length;
929
+ addBindEvent(options?: string | Partial<BindEvent> | BindEvent) {
930
+ const node = this._addBindEvent(options as any);
931
+ const index = this.bindEvents.length;
931
932
  node.create({
932
933
  index,
933
934
  parentNode: this,
934
- parentKey: 'logics',
935
+ parentKey: 'bindEvents',
935
936
  });
936
937
  return node;
937
938
  }
@@ -941,7 +942,7 @@ export class View extends BaseNode {
941
942
 
942
943
  getViewExistingNames(excludedList: Array<View> = []) {
943
944
  const excludedSet = new Set(excludedList);
944
- return this.children.filter((item) => !excludedSet.has(item)).map((item) => item.name);
945
+ return (this.children || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
945
946
  }
946
947
  getViewUniqueName(name = 'view1') {
947
948
  return utils.unique(name, this.getViewExistingNames());
@@ -1234,46 +1235,46 @@ export class View extends BaseNode {
1234
1235
 
1235
1236
 
1236
1237
  /**
1237
- * 删除元素绑定事件
1238
- * @param name 元素绑定事件名称
1238
+ * 删除逻辑
1239
+ * @param name 逻辑名称
1239
1240
  */
1240
- removeBindEvent(name: string): void;
1241
+ removeLogic(name: string): void;
1241
1242
 
1242
1243
  /**
1243
- * 删除元素绑定事件
1244
- * @param bindEvent 已有的元素绑定事件实例
1244
+ * 删除逻辑
1245
+ * @param logic 已有的逻辑实例
1245
1246
  */
1246
- removeBindEvent(bindEvent: BindEvent): void;
1247
+ removeLogic(logic: Logic): void;
1247
1248
 
1248
- removeBindEvent(options: string | BindEvent) {
1249
- let bindEvent: BindEvent;
1249
+ removeLogic(options: string | Logic) {
1250
+ let logic: Logic;
1250
1251
  if (typeof options === 'string') {
1251
- bindEvent = this.events.find((item) => item.name === options);
1252
- if (!bindEvent) {
1253
- throw new Error('找不到元素绑定事件 ' + options);
1252
+ logic = this.logics.find((item) => item.name === options);
1253
+ if (!logic) {
1254
+ throw new Error('找不到逻辑 ' + options);
1254
1255
  }
1255
1256
  } else {
1256
- bindEvent = options;
1257
+ logic = options;
1257
1258
  }
1258
- return bindEvent.delete();
1259
+ return logic.delete();
1259
1260
  }
1260
1261
 
1261
- __removeBindEvent(bindEvent: BindEvent) {
1262
- const parentKey = bindEvent.parentKey;
1262
+ __removeLogic(logic: Logic) {
1263
+ const parentKey = logic.parentKey;
1263
1264
  const params: Params = {
1264
1265
  parentNode: this,
1265
1266
  parentKey,
1266
1267
  index: -1,
1267
1268
  object: null,
1268
- oldObject: bindEvent,
1269
+ oldObject: logic,
1269
1270
  };
1270
1271
  if (parentKey) {
1271
1272
  params.parentKey = parentKey;
1272
1273
  if (Array.isArray((this as any)[parentKey])) {
1273
- const index = (this as any)[parentKey].indexOf(bindEvent);
1274
+ const index = (this as any)[parentKey].indexOf(logic);
1274
1275
  ~index && (this as any)[parentKey].splice(index, 1);
1275
1276
  params.index = index;
1276
- } else if ((this as any)[parentKey] === bindEvent) {
1277
+ } else if ((this as any)[parentKey] === logic) {
1277
1278
  params.index = 0;
1278
1279
  (this as any)[parentKey] = undefined;
1279
1280
  }
@@ -1284,46 +1285,46 @@ export class View extends BaseNode {
1284
1285
 
1285
1286
 
1286
1287
  /**
1287
- * 删除逻辑
1288
- * @param name 逻辑名称
1288
+ * 删除元素绑定事件
1289
+ * @param name 元素绑定事件名称
1289
1290
  */
1290
- removeLogic(name: string): void;
1291
+ removeBindEvent(name: string): void;
1291
1292
 
1292
1293
  /**
1293
- * 删除逻辑
1294
- * @param logic 已有的逻辑实例
1294
+ * 删除元素绑定事件
1295
+ * @param bindEvent 已有的元素绑定事件实例
1295
1296
  */
1296
- removeLogic(logic: Logic): void;
1297
+ removeBindEvent(bindEvent: BindEvent): void;
1297
1298
 
1298
- removeLogic(options: string | Logic) {
1299
- let logic: Logic;
1299
+ removeBindEvent(options: string | BindEvent) {
1300
+ let bindEvent: BindEvent;
1300
1301
  if (typeof options === 'string') {
1301
- logic = this.logics.find((item) => item.name === options);
1302
- if (!logic) {
1303
- throw new Error('找不到逻辑 ' + options);
1302
+ bindEvent = this.bindEvents.find((item) => item.name === options);
1303
+ if (!bindEvent) {
1304
+ throw new Error('找不到元素绑定事件 ' + options);
1304
1305
  }
1305
1306
  } else {
1306
- logic = options;
1307
+ bindEvent = options;
1307
1308
  }
1308
- return logic.delete();
1309
+ return bindEvent.delete();
1309
1310
  }
1310
1311
 
1311
- __removeLogic(logic: Logic) {
1312
- const parentKey = logic.parentKey;
1312
+ __removeBindEvent(bindEvent: BindEvent) {
1313
+ const parentKey = bindEvent.parentKey;
1313
1314
  const params: Params = {
1314
1315
  parentNode: this,
1315
1316
  parentKey,
1316
1317
  index: -1,
1317
1318
  object: null,
1318
- oldObject: logic,
1319
+ oldObject: bindEvent,
1319
1320
  };
1320
1321
  if (parentKey) {
1321
1322
  params.parentKey = parentKey;
1322
1323
  if (Array.isArray((this as any)[parentKey])) {
1323
- const index = (this as any)[parentKey].indexOf(logic);
1324
+ const index = (this as any)[parentKey].indexOf(bindEvent);
1324
1325
  ~index && (this as any)[parentKey].splice(index, 1);
1325
1326
  params.index = index;
1326
- } else if ((this as any)[parentKey] === logic) {
1327
+ } else if ((this as any)[parentKey] === bindEvent) {
1327
1328
  params.index = 0;
1328
1329
  (this as any)[parentKey] = undefined;
1329
1330
  }
@@ -1585,7 +1586,7 @@ export class View extends BaseNode {
1585
1586
  params: this.params,
1586
1587
  variables: this.variables,
1587
1588
  logics: this.logics,
1588
- events: this.events,
1589
+ events: this.bindEvents,
1589
1590
  title: this.title,
1590
1591
  crumb: this.crumb,
1591
1592
  first: this.isIndex,
@@ -1602,7 +1603,6 @@ export class View extends BaseNode {
1602
1603
  * 转换成 Vue 文件
1603
1604
  */
1604
1605
  toVue(options?: ElementToVueOptions) {
1605
- console.log(options);
1606
1606
  let result = '';
1607
1607
  result += `<template>\n${this.genVueTemplate(options)}\n</template>\n`;
1608
1608
  result += `<script>\n${this.genScript()}\n</script>\n`;
@@ -1612,16 +1612,16 @@ export class View extends BaseNode {
1612
1612
  * 转换成设计器中使用的 Vue template 内容
1613
1613
  * @param options
1614
1614
  */
1615
- genDesignerVueTemplate(options?: ElementToVueOptions) {
1616
- return this.elements.map((element) => element.toDesignerVue(options) + '\n').join('');
1615
+ genDesignerVueTemplate() {
1616
+ return this.elements.map((element) => element.toDesignerVue() + '\n').join('');
1617
1617
  }
1618
1618
  /**
1619
1619
  * 转换成设计器中使用的 Vue 文件
1620
1620
  * 目前不需要 script 和 style
1621
1621
  * @param options
1622
1622
  */
1623
- toDesignerVue(options?: ElementToVueOptions) {
1624
- return `<template>\n${this.genDesignerVueTemplate(options)}</template>`;
1623
+ toDesignerVue() {
1624
+ return `<template>\n${this.genDesignerVueTemplate()}</template>`;
1625
1625
  }
1626
1626
  /**
1627
1627
  * 转换成 VueOptions
@@ -1638,7 +1638,15 @@ export class View extends BaseNode {
1638
1638
  * @param name 一般不用传,用于 rename
1639
1639
  */
1640
1640
  getEmbeddedFilePath(name = this.name) {
1641
- return `/embedded/${this.app.name}/views/${name}.ts`;
1641
+ let pathName = name;
1642
+ let parent = this.parentNode;
1643
+ if (parent) {
1644
+ while (parent && parent instanceof View) {
1645
+ pathName = parent.name + '/' + pathName;
1646
+ parent = parent.parentNode;
1647
+ }
1648
+ }
1649
+ return `/embedded/${this.app.name}/views/${pathName}.ts`;
1642
1650
  }
1643
1651
 
1644
1652
  getNamespace(): string {
@@ -1657,13 +1665,35 @@ export class View extends BaseNode {
1657
1665
  if (/^\d/.test(tsName)) {
1658
1666
  tsName = '$' + tsName;
1659
1667
  }
1660
- tsName = tsName.replaceAll('-', '_');
1668
+ // 匹配所有特殊字符都转为_
1669
+ tsName = tsName.replace(/\W/g, '_');
1661
1670
  return tsName;
1662
1671
  }
1672
+ // 获取当前element,铺平
1673
+ elementsMethods(elements: Array<ViewElement>, allMethods: Array<ViewElement>) {
1674
+ if (elements) {
1675
+ elements.forEach((item: ViewElement) => {
1676
+ allMethods.push(item);
1677
+ if (item.children) {
1678
+ this.elementsMethods(item.children, allMethods);
1679
+ }
1680
+ });
1681
+ }
1682
+ }
1683
+
1663
1684
  @withSourceMap()
1664
- toEmbeddedTS(state?: TranslatorState, parentName?: string): string {
1665
- const currentName = `${parentName ? parentName + '.views.' : ''}${this.tsName}`;
1666
- let code = `export namespace ${currentName} {\n`;
1685
+ toEmbeddedTS(state?: TranslatorState): string {
1686
+ function chineseTsName(name: string) {
1687
+ let tsName = name;
1688
+ if (/^\d/.test(tsName)) {
1689
+ tsName = '$' + tsName;
1690
+ }
1691
+ // 匹配所有特殊字符都转为_
1692
+ tsName = tsName.replace(/\W/g, '_');
1693
+ return tsName;
1694
+ }
1695
+
1696
+ let code = `export namespace ${this.tsName} {\n`;
1667
1697
  // 角色
1668
1698
  // if (this.auth && Array.isArray(this.roles) && this.roles.length) {
1669
1699
  // code += indent(state.tabSize + 1);
@@ -1682,7 +1712,7 @@ export class View extends BaseNode {
1682
1712
  code += 'export let bindRoles = [\n';
1683
1713
  this.bindRoles.forEach((role) => {
1684
1714
  code += indent(state.tabSize + 1);
1685
- code += `${this.app.getNamespace()}.roles.${role}.${role},`;
1715
+ code += `${this.app.getNamespace()}.roles.${chineseTsName(role)}.${chineseTsName(role)},`;
1686
1716
  code += '\n';
1687
1717
  });
1688
1718
  code += '\n';
@@ -1766,14 +1796,6 @@ export class View extends BaseNode {
1766
1796
  code += '){}\n';
1767
1797
  }
1768
1798
  code += indent(state.tabSize) + '}\n';
1769
- // 子页面
1770
- if (Array.isArray(this.children)) {
1771
- this.children.forEach((child) => {
1772
- code += child.toEmbeddedTS(shiftState(state, code), currentName);
1773
- code += '\n';
1774
- });
1775
- }
1776
-
1777
1799
  return code;
1778
1800
  }
1779
1801
 
@@ -1808,6 +1830,23 @@ export class View extends BaseNode {
1808
1830
  return path;
1809
1831
  }
1810
1832
 
1833
+ /**
1834
+ * @param path 子路径
1835
+ * 比如当前页面路径为:/dashboard
1836
+ * path 为要查找子路径:如 /student/list、student/list
1837
+ */
1838
+ findViewByPath(path: string): View {
1839
+ const arr = path.split('/');
1840
+ if (arr[0] === '')
1841
+ arr.shift();
1842
+
1843
+ if (!arr.length)
1844
+ return this;
1845
+ const childName = arr.shift();
1846
+ const subView = this.children.find((child) => child.name === childName);
1847
+ return arr.length ? subView.findViewByPath(arr.join('/')) : subView;
1848
+ }
1849
+
1811
1850
  _setAsIndexView(isIndex: boolean) {
1812
1851
  let views: View[] = [];
1813
1852
  if (this.parentNode.concept !== 'View') {