@lcap/nasl 2.22.0-beta.5 → 3.0.0-beta.1

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 (304) hide show
  1. package/README.md +13 -0
  2. package/docs/classes/Module.html +15 -15
  3. package/docs/classes/Namespace.html +15 -15
  4. package/docs/classes/ViewComponent.html +19 -19
  5. package/out/automate/engine/utils.js +4 -0
  6. package/out/automate/engine/utils.js.map +1 -1
  7. package/out/breakpoint/generator/AfterStartNode.d.ts +7 -0
  8. package/out/breakpoint/generator/AfterStartNode.js +27 -0
  9. package/out/breakpoint/generator/AfterStartNode.js.map +1 -0
  10. package/out/breakpoint/generator/BeforeEndNode.d.ts +7 -0
  11. package/out/breakpoint/generator/BeforeEndNode.js +27 -0
  12. package/out/breakpoint/generator/BeforeEndNode.js.map +1 -0
  13. package/out/breakpoint/generator/BreakpointNode.d.ts +14 -0
  14. package/out/breakpoint/generator/BreakpointNode.js +166 -0
  15. package/out/breakpoint/generator/BreakpointNode.js.map +1 -0
  16. package/out/breakpoint/generator/index.d.ts +4 -0
  17. package/out/breakpoint/generator/index.js +98 -0
  18. package/out/breakpoint/generator/index.js.map +1 -0
  19. package/out/breakpoint/index.d.ts +3 -0
  20. package/out/breakpoint/index.js +20 -0
  21. package/out/breakpoint/index.js.map +1 -0
  22. package/out/breakpoint/shared/constants.d.ts +30 -0
  23. package/out/breakpoint/shared/constants.js +87 -0
  24. package/out/breakpoint/shared/constants.js.map +1 -0
  25. package/out/breakpoint/shared/index.d.ts +3 -0
  26. package/out/breakpoint/shared/index.js +33 -0
  27. package/out/breakpoint/shared/index.js.map +1 -0
  28. package/out/breakpoint/shared/operations.d.ts +10 -0
  29. package/out/breakpoint/shared/operations.js +25 -0
  30. package/out/breakpoint/shared/operations.js.map +1 -0
  31. package/out/breakpoint/shared/socket.d.ts +47 -0
  32. package/out/breakpoint/shared/socket.js +210 -0
  33. package/out/breakpoint/shared/socket.js.map +1 -0
  34. package/out/breakpoint/shared/utils.d.ts +20 -0
  35. package/out/breakpoint/shared/utils.js +133 -0
  36. package/out/breakpoint/shared/utils.js.map +1 -0
  37. package/out/breakpoint/store/core.d.ts +30 -0
  38. package/out/breakpoint/store/core.js +341 -0
  39. package/out/breakpoint/store/core.js.map +1 -0
  40. package/out/breakpoint/store/dock.d.ts +1 -0
  41. package/out/breakpoint/store/dock.js +127 -0
  42. package/out/breakpoint/store/dock.js.map +1 -0
  43. package/out/breakpoint/store/index.d.ts +2 -0
  44. package/out/breakpoint/store/index.js +19 -0
  45. package/out/breakpoint/store/index.js.map +1 -0
  46. package/out/common/BaseNode.d.ts +8 -0
  47. package/out/common/BaseNode.js +19 -0
  48. package/out/common/BaseNode.js.map +1 -1
  49. package/out/concepts/App__.d.ts +365 -16
  50. package/out/concepts/App__.js +431 -10
  51. package/out/concepts/App__.js.map +1 -1
  52. package/out/concepts/Assignment__.js +1 -1
  53. package/out/concepts/Assignment__.js.map +1 -1
  54. package/out/concepts/AuthInterface__.d.ts +37 -0
  55. package/out/concepts/AuthInterface__.js +141 -0
  56. package/out/concepts/AuthInterface__.js.map +1 -0
  57. package/out/concepts/AuthLogicForCallInterface__.d.ts +138 -0
  58. package/out/concepts/AuthLogicForCallInterface__.js +493 -0
  59. package/out/concepts/AuthLogicForCallInterface__.js.map +1 -0
  60. package/out/concepts/AuthLogic__.d.ts +66 -0
  61. package/out/concepts/AuthLogic__.js +206 -0
  62. package/out/concepts/AuthLogic__.js.map +1 -0
  63. package/out/concepts/BackendVariable__.d.ts +137 -0
  64. package/out/concepts/BackendVariable__.js +422 -0
  65. package/out/concepts/BackendVariable__.js.map +1 -0
  66. package/out/concepts/Backend__.d.ts +134 -0
  67. package/out/concepts/Backend__.js +274 -0
  68. package/out/concepts/Backend__.js.map +1 -0
  69. package/out/concepts/BindAttribute__.d.ts +1 -1
  70. package/out/concepts/BindAttribute__.js +3 -1
  71. package/out/concepts/BindAttribute__.js.map +1 -1
  72. package/out/concepts/BindEvent__.d.ts +12 -0
  73. package/out/concepts/BindEvent__.js +68 -0
  74. package/out/concepts/BindEvent__.js.map +1 -1
  75. package/out/concepts/CallAuthInterface__.d.ts +126 -0
  76. package/out/concepts/CallAuthInterface__.js +408 -0
  77. package/out/concepts/CallAuthInterface__.js.map +1 -0
  78. package/out/concepts/CallInterface__.d.ts +6 -1
  79. package/out/concepts/CallInterface__.js +9 -1
  80. package/out/concepts/CallInterface__.js.map +1 -1
  81. package/out/concepts/CallLogic__.js +3 -1
  82. package/out/concepts/CallLogic__.js.map +1 -1
  83. package/out/concepts/CallQueryComponent__.js +9 -7
  84. package/out/concepts/CallQueryComponent__.js.map +1 -1
  85. package/out/concepts/Destination__.js +1 -1
  86. package/out/concepts/Destination__.js.map +1 -1
  87. package/out/concepts/End__.js +29 -2
  88. package/out/concepts/End__.js.map +1 -1
  89. package/out/concepts/EntityProperty__.js.map +1 -1
  90. package/out/concepts/Entity__.d.ts +1 -2
  91. package/out/concepts/Entity__.js +1 -31
  92. package/out/concepts/Entity__.js.map +1 -1
  93. package/out/concepts/ForEachStatement__.js +9 -4
  94. package/out/concepts/ForEachStatement__.js.map +1 -1
  95. package/out/concepts/FrontendLibrary__.d.ts +29 -29
  96. package/out/concepts/FrontendLibrary__.js +2 -2
  97. package/out/concepts/FrontendVariable__.d.ts +21 -0
  98. package/out/concepts/FrontendVariable__.js +64 -0
  99. package/out/concepts/FrontendVariable__.js.map +1 -0
  100. package/out/concepts/Frontend__.d.ts +151 -47
  101. package/out/concepts/Frontend__.js +188 -32
  102. package/out/concepts/Frontend__.js.map +1 -1
  103. package/out/concepts/Function__.js +1 -1
  104. package/out/concepts/Function__.js.map +1 -1
  105. package/out/concepts/Identifier__.js +1 -1
  106. package/out/concepts/Identifier__.js.map +1 -1
  107. package/out/concepts/Interface__.d.ts +1 -1
  108. package/out/concepts/Interface__.js.map +1 -1
  109. package/out/concepts/LogicItem__.d.ts +18 -3
  110. package/out/concepts/LogicItem__.js +22 -4
  111. package/out/concepts/LogicItem__.js.map +1 -1
  112. package/out/concepts/Logic__.d.ts +14 -9
  113. package/out/concepts/Logic__.js +43 -5
  114. package/out/concepts/Logic__.js.map +1 -1
  115. package/out/concepts/Module__.js.map +1 -1
  116. package/out/concepts/Namespace__.d.ts +29 -29
  117. package/out/concepts/Namespace__.js +2 -2
  118. package/out/concepts/NewComposite__.js +2 -2
  119. package/out/concepts/NewComposite__.js.map +1 -1
  120. package/out/concepts/OverriddenLogic__.d.ts +643 -0
  121. package/out/concepts/OverriddenLogic__.js +1602 -0
  122. package/out/concepts/OverriddenLogic__.js.map +1 -0
  123. package/out/concepts/Param__.d.ts +6 -0
  124. package/out/concepts/Param__.js +10 -0
  125. package/out/concepts/Param__.js.map +1 -1
  126. package/out/concepts/QueryFieldExpression__.d.ts +2 -0
  127. package/out/concepts/QueryFieldExpression__.js +9 -0
  128. package/out/concepts/QueryFieldExpression__.js.map +1 -1
  129. package/out/concepts/QuerySelectExpression__.d.ts +2 -2
  130. package/out/concepts/QuerySelectExpression__.js +2 -2
  131. package/out/concepts/QuerySelectExpression__.js.map +1 -1
  132. package/out/concepts/TypeAnnotation__.js +6 -6
  133. package/out/concepts/TypeAnnotation__.js.map +1 -1
  134. package/out/concepts/Variable__.d.ts +10 -0
  135. package/out/concepts/Variable__.js +12 -0
  136. package/out/concepts/Variable__.js.map +1 -1
  137. package/out/concepts/ViewComponent__.d.ts +33 -33
  138. package/out/concepts/ViewComponent__.js +7 -7
  139. package/out/concepts/ViewElement__.d.ts +6 -0
  140. package/out/concepts/ViewElement__.js +104 -1
  141. package/out/concepts/ViewElement__.js.map +1 -1
  142. package/out/concepts/View__.js +2 -2
  143. package/out/concepts/View__.js.map +1 -1
  144. package/out/concepts/basics/stdlib/index.js +2 -1
  145. package/out/concepts/basics/stdlib/index.js.map +1 -1
  146. package/out/concepts/basics/stdlib/nasl.auth.js +24 -0
  147. package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
  148. package/out/concepts/basics/stdlib/nasl.http.d.ts +7 -0
  149. package/out/concepts/basics/stdlib/nasl.http.js +167 -0
  150. package/out/concepts/basics/stdlib/nasl.http.js.map +1 -0
  151. package/out/concepts/basics/stdlib/nasl.process.js +68 -0
  152. package/out/concepts/basics/stdlib/nasl.process.js.map +1 -1
  153. package/out/concepts/basics/stdlib/nasl.ui.js +4 -19
  154. package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
  155. package/out/concepts/basics/stdlib/nasl.util.js +83 -17
  156. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  157. package/out/concepts/basics/types/index.d.ts +1 -0
  158. package/out/concepts/basics/types/index.js +4 -1
  159. package/out/concepts/basics/types/index.js.map +1 -1
  160. package/out/concepts/index__.d.ts +8 -0
  161. package/out/concepts/index__.js +8 -0
  162. package/out/concepts/index__.js.map +1 -1
  163. package/out/enums/KEYWORDS.js +0 -1
  164. package/out/enums/KEYWORDS.js.map +1 -1
  165. package/out/generator/genBundleFiles.d.ts +1 -0
  166. package/out/generator/genBundleFiles.js +27 -0
  167. package/out/generator/genBundleFiles.js.map +1 -1
  168. package/out/generator/genMetaData.d.ts +4 -1
  169. package/out/generator/genMetaData.js +14 -0
  170. package/out/generator/genMetaData.js.map +1 -1
  171. package/out/generator/genReleaseBody.d.ts +2 -1
  172. package/out/generator/genReleaseBody.js +2 -1
  173. package/out/generator/genReleaseBody.js.map +1 -1
  174. package/out/index.d.ts +2 -1
  175. package/out/index.js +3 -1
  176. package/out/index.js.map +1 -1
  177. package/out/server/extendBaseNode.js +16 -4
  178. package/out/server/extendBaseNode.js.map +1 -1
  179. package/out/server/formatTsUtils.d.ts +2 -1
  180. package/out/server/formatTsUtils.js +39 -4
  181. package/out/server/formatTsUtils.js.map +1 -1
  182. package/out/server/getExtensionModules.d.ts +2 -2
  183. package/out/server/getExtensionModules.js +16 -2
  184. package/out/server/getExtensionModules.js.map +1 -1
  185. package/out/server/getLogics.js +5 -5
  186. package/out/server/getLogics.js.map +1 -1
  187. package/out/server/getMemberIdentifier.d.ts +1 -0
  188. package/out/server/getMemberIdentifier.js +34 -7
  189. package/out/server/getMemberIdentifier.js.map +1 -1
  190. package/out/server/naslServer.d.ts +64 -64
  191. package/out/server/naslServer.js +249 -121
  192. package/out/server/naslServer.js.map +1 -1
  193. package/out/server/naslStdlibMap.js +2 -0
  194. package/out/server/naslStdlibMap.js.map +1 -1
  195. package/out/server/translator.d.ts +1 -0
  196. package/out/server/translator.js +67 -2
  197. package/out/server/translator.js.map +1 -1
  198. package/out/service/defaultErrorMessage.json +1 -0
  199. package/out/service/storage/api.d.ts +10 -1
  200. package/out/service/storage/api.js +6 -0
  201. package/out/service/storage/api.js.map +1 -1
  202. package/out/service/storage/init.d.ts +4 -0
  203. package/out/service/storage/init.js +55 -35
  204. package/out/service/storage/init.js.map +1 -1
  205. package/out/service/storage/service.d.ts +3 -0
  206. package/out/service/storage/service.js +14 -0
  207. package/out/service/storage/service.js.map +1 -1
  208. package/out/utils/sortTsString.d.ts +1 -0
  209. package/out/utils/sortTsString.js +36 -0
  210. package/out/utils/sortTsString.js.map +1 -0
  211. package/out/utils/traverse.js +2 -2
  212. package/out/utils/traverse.js.map +1 -1
  213. package/package.json +7 -2
  214. package/sandbox/stdlib/nasl.auth.ts +8 -4
  215. package/sandbox/stdlib/nasl.core.d.ts +206 -0
  216. package/sandbox/stdlib/nasl.core.js +1 -0
  217. package/sandbox/stdlib/nasl.core.js.map +1 -0
  218. package/sandbox/stdlib/nasl.http.ts +35 -0
  219. package/sandbox/stdlib/nasl.process.ts +13 -0
  220. package/sandbox/stdlib/nasl.ui.ts +0 -5
  221. package/src/automate/engine/utils.js +4 -1
  222. package/src/breakpoint/generator/AfterStartNode.ts +27 -0
  223. package/src/breakpoint/generator/BeforeEndNode.ts +27 -0
  224. package/src/breakpoint/generator/BreakpointNode.ts +228 -0
  225. package/src/breakpoint/generator/index.ts +114 -0
  226. package/src/breakpoint/index.ts +3 -0
  227. package/src/breakpoint/shared/constants.ts +95 -0
  228. package/src/breakpoint/shared/index.ts +3 -0
  229. package/src/breakpoint/shared/operations.ts +25 -0
  230. package/src/breakpoint/shared/socket.ts +326 -0
  231. package/src/breakpoint/shared/utils.ts +195 -0
  232. package/src/breakpoint/store/core.ts +411 -0
  233. package/src/breakpoint/store/dock.ts +166 -0
  234. package/src/breakpoint/store/index.ts +2 -0
  235. package/src/breakpoint/types/index.d.ts +19 -0
  236. package/src/common/BaseNode.ts +19 -1
  237. package/src/concepts/App__.ts +828 -26
  238. package/src/concepts/Assignment__.ts +1 -1
  239. package/src/concepts/AuthInterface__.ts +148 -0
  240. package/src/concepts/AuthLogicForCallInterface__.ts +573 -0
  241. package/src/concepts/AuthLogic__.ts +225 -0
  242. package/src/concepts/BackendVariable__.ts +466 -0
  243. package/src/concepts/Backend__.ts +347 -0
  244. package/src/concepts/BindAttribute__.ts +4 -3
  245. package/src/concepts/BindEvent__.ts +71 -2
  246. package/src/concepts/CallAuthInterface__.ts +490 -0
  247. package/src/concepts/CallInterface__.ts +10 -2
  248. package/src/concepts/CallLogic__.ts +3 -1
  249. package/src/concepts/CallQueryComponent__.ts +67 -7
  250. package/src/concepts/Destination__.ts +19 -1
  251. package/src/concepts/End__.ts +31 -3
  252. package/src/concepts/EntityProperty__.ts +6 -0
  253. package/src/concepts/Entity__.ts +8 -31
  254. package/src/concepts/ForEachStatement__.ts +9 -4
  255. package/src/concepts/FrontendLibrary__.ts +30 -30
  256. package/src/concepts/FrontendVariable__.ts +76 -0
  257. package/src/concepts/Frontend__.ts +352 -89
  258. package/src/concepts/Function__.ts +1 -1
  259. package/src/concepts/Identifier__.ts +5 -5
  260. package/src/concepts/Interface__.ts +1 -1
  261. package/src/concepts/LogicItem__.ts +26 -6
  262. package/src/concepts/Logic__.ts +86 -8
  263. package/src/concepts/Module__.ts +32 -2
  264. package/src/concepts/Namespace__.ts +30 -30
  265. package/src/concepts/NewComposite__.ts +2 -3
  266. package/src/concepts/OverriddenLogic__.ts +2165 -0
  267. package/src/concepts/Param__.ts +13 -3
  268. package/src/concepts/QueryFieldExpression__.ts +18 -0
  269. package/src/concepts/QuerySelectExpression__.ts +11 -3
  270. package/src/concepts/TypeAnnotation__.ts +45 -6
  271. package/src/concepts/Variable__.ts +14 -0
  272. package/src/concepts/ViewComponent__.ts +35 -35
  273. package/src/concepts/ViewElement__.ts +104 -1
  274. package/src/concepts/View__.ts +24 -2
  275. package/src/concepts/basics/stdlib/index.ts +2 -1
  276. package/src/concepts/basics/stdlib/nasl.auth.ts +24 -0
  277. package/src/concepts/basics/stdlib/nasl.http.ts +166 -0
  278. package/src/concepts/basics/stdlib/nasl.process.ts +68 -0
  279. package/src/concepts/basics/stdlib/nasl.ui.ts +4 -19
  280. package/src/concepts/basics/stdlib/nasl.util.ts +83 -17
  281. package/src/concepts/basics/types/index.ts +5 -4
  282. package/src/concepts/index__.ts +8 -0
  283. package/src/enums/KEYWORDS.ts +0 -1
  284. package/src/generator/genBundleFiles.ts +36 -2
  285. package/src/generator/genMetaData.ts +16 -1
  286. package/src/generator/genReleaseBody.ts +4 -1
  287. package/src/index.ts +2 -1
  288. package/src/server/extendBaseNode.ts +18 -7
  289. package/src/server/formatTsUtils.ts +37 -5
  290. package/src/server/getExtensionModules.ts +18 -3
  291. package/src/server/getLogics.ts +6 -6
  292. package/src/server/getMemberIdentifier.ts +35 -9
  293. package/src/server/naslServer.ts +250 -124
  294. package/src/server/naslStdlibMap.ts +2 -0
  295. package/src/server/translator.ts +67 -1
  296. package/src/service/defaultErrorMessage.json +1 -0
  297. package/src/service/storage/api.js +7 -1
  298. package/src/service/storage/init.ts +66 -35
  299. package/src/service/storage/service.ts +18 -2
  300. package/src/utils/sortTsString.ts +32 -0
  301. package/src/utils/traverse.ts +2 -2
  302. package/test/examples/app-simple.json +73635 -0
  303. package/ts-worker/lib/tsserver.js +3 -3
  304. package/ts-worker/package.json +1 -1
@@ -1,6 +1,7 @@
1
1
  import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
2
2
  import { AssetsInfo } from './App__';
3
3
  import Namespace from './Namespace__';
4
+ import Variable from './Variable__';
4
5
 
5
6
  //================================================================================
6
7
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
@@ -13,8 +14,9 @@ import * as utils from '../utils';
13
14
  import { v4 as uuidv4 } from 'uuid';
14
15
  import BaseNode from '../common/BaseNode';
15
16
  import classMap from '../common/classMap';
17
+ import BindEvent from './BindEvent__';
16
18
  import View from './View__';
17
- import Variable from './Variable__';
19
+ import FrontendVariable from './FrontendVariable__';
18
20
  import Theme from './Theme__';
19
21
  import Module from './Module__';
20
22
  import App from './App__';
@@ -66,6 +68,12 @@ export class Frontend extends BaseNode {
66
68
  @property()
67
69
  documentIcon: string = undefined;
68
70
 
71
+ /**
72
+ * 元素绑定事件列表
73
+ */
74
+ @property('BindEvent')
75
+ bindEvents: Array<BindEvent> = [];
76
+
69
77
  /**
70
78
  * 页面列表
71
79
  */
@@ -73,10 +81,10 @@ export class Frontend extends BaseNode {
73
81
  views: Array<View> = [];
74
82
 
75
83
  /**
76
- * 变量列表
84
+ * 前端全局变量列表
77
85
  */
78
- @property('Variable')
79
- variables: Array<Variable> = [];
86
+ @property('FrontendVariable')
87
+ variables: Array<FrontendVariable> = [];
80
88
 
81
89
  /**
82
90
  * 主题配置
@@ -90,6 +98,18 @@ export class Frontend extends BaseNode {
90
98
  @property('Module')
91
99
  componentDependencies: Array<Module> = [];
92
100
 
101
+ /**
102
+ * 全局缩放开关
103
+ */
104
+ @property()
105
+ globalScaleEnabled: boolean = false;
106
+
107
+ /**
108
+ * 画布宽度
109
+ */
110
+ @property()
111
+ canvasWidth: number = 0;
112
+
93
113
  /**
94
114
  * 祖先 App
95
115
  */
@@ -185,7 +205,172 @@ export class Frontend extends BaseNode {
185
205
  });
186
206
  }
187
207
 
188
- getViewExistingNames(excludedList: Array<View> = []) {
208
+ /**
209
+ * 设置全局缩放开关
210
+ */
211
+ setGlobalScaleEnabled(globalScaleEnabled: boolean) {
212
+ const object = {
213
+ globalScaleEnabled,
214
+ };
215
+ this.update({
216
+ ...object,
217
+ });
218
+ }
219
+
220
+ /**
221
+ * 设置画布宽度
222
+ */
223
+ setCanvasWidth(canvasWidth: number) {
224
+ const object = {
225
+ canvasWidth,
226
+ };
227
+ this.update({
228
+ ...object,
229
+ });
230
+ }
231
+
232
+ getBindEventExistingNames(excludedList: Array<BindEvent> = []) {
233
+ const excludedSet = new Set(excludedList);
234
+ return ((this.bindEvents as BindEvent[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
235
+ }
236
+ getBindEventUniqueName(name = 'bindEvent1') {
237
+ return utils.unique(name, this.getBindEventExistingNames(), undefined, false);
238
+ }
239
+
240
+ /**
241
+ * 插入元素绑定事件
242
+ * @internal
243
+ * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
244
+ */
245
+ _insertBindEventAt(name: string, index: number): BindEvent;
246
+
247
+ /**
248
+ * 插入元素绑定事件
249
+ * @internal
250
+ * @param bindEventOptions 元素绑定事件参数
251
+ */
252
+ _insertBindEventAt(bindEventOptions: Partial<BindEvent>, index: number): BindEvent;
253
+
254
+ /**
255
+ * 插入元素绑定事件
256
+ * @internal
257
+ * @param bindEvent 已有的元素绑定事件实例
258
+ */
259
+ _insertBindEventAt(bindEvent: BindEvent, index: number): BindEvent;
260
+
261
+ _insertBindEventAt(options: string | Partial<BindEvent> | BindEvent, index: number) {
262
+ const bindEventOptions: any = {};
263
+ const relationOptions = { parentNode: this, parentKey: 'bindEvents' };
264
+ let bindEvent: BindEvent;
265
+ if (!options) {
266
+ bindEvent = BindEvent.from({
267
+ ...bindEventOptions,
268
+ name: this.getBindEventUniqueName(),
269
+ }, this, 'bindEvents');
270
+ } else if (typeof options === 'string') {
271
+ bindEvent = BindEvent.from({
272
+ ...bindEventOptions,
273
+ name: options,
274
+ }, this, 'bindEvents');
275
+ } else if (options instanceof BindEvent) {
276
+ options.ensureDelete(); // 同一实例不支持多处存在
277
+ bindEvent = options;
278
+ Object.assign(bindEvent, relationOptions);
279
+ } else {
280
+ bindEvent = BindEvent.from({
281
+ ...bindEventOptions,
282
+ ...options,
283
+ }, this, 'bindEvents');
284
+ }
285
+ this.bindEvents.splice(index, 0, bindEvent);
286
+ return bindEvent;
287
+ }
288
+
289
+ /**
290
+ * 插入元素绑定事件
291
+ * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
292
+ */
293
+ insertBindEventAt(name: string, index: number): BindEvent;
294
+
295
+ /**
296
+ * 插入元素绑定事件
297
+ * @param bindEventOptions 元素绑定事件参数
298
+ */
299
+ insertBindEventAt(bindEventOptions: Partial<BindEvent>, index: number): BindEvent;
300
+
301
+ /**
302
+ * 插入元素绑定事件
303
+ * @param bindEvent 已有的元素绑定事件实例
304
+ */
305
+ insertBindEventAt(bindEvent: BindEvent, index: number): BindEvent;
306
+
307
+ insertBindEventAt(options: string | Partial<BindEvent> | BindEvent, index: number) {
308
+ const node = this._insertBindEventAt(options as any, index);
309
+ node.create({
310
+ index,
311
+ parentNode: this,
312
+ parentKey: 'bindEvents',
313
+ });
314
+ return node;
315
+ }
316
+
317
+ /**
318
+ * 添加元素绑定事件
319
+ * @internal
320
+ * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
321
+ */
322
+ _addBindEvent(name?: string): BindEvent;
323
+
324
+ /**
325
+ * 添加元素绑定事件
326
+ * @internal
327
+ * @param bindEventOptions 元素绑定事件参数
328
+ */
329
+ _addBindEvent(bindEventOptions: Partial<BindEvent>): BindEvent;
330
+
331
+ /**
332
+ * 添加元素绑定事件
333
+ * @internal
334
+ * @param bindEvent 已有的元素绑定事件实例
335
+ */
336
+ _addBindEvent(bindEvent: BindEvent): BindEvent;
337
+
338
+ _addBindEvent(options?: string | Partial<BindEvent> | BindEvent) {
339
+ const index = this.bindEvents.length;
340
+ return this._insertBindEventAt(options as any, index);
341
+ }
342
+
343
+ /**
344
+ * 添加元素绑定事件
345
+ * @internal
346
+ * @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
347
+ */
348
+ addBindEvent(name?: string): BindEvent;
349
+
350
+ /**
351
+ * 添加元素绑定事件
352
+ * @param bindEventOptions 元素绑定事件参数
353
+ */
354
+ addBindEvent(bindEventOptions: Partial<BindEvent>): BindEvent;
355
+
356
+ /**
357
+ * 添加元素绑定事件
358
+ * @param bindEvent 已有的元素绑定事件实例
359
+ */
360
+ addBindEvent(bindEvent: BindEvent): BindEvent;
361
+
362
+ addBindEvent(options?: string | Partial<BindEvent> | BindEvent) {
363
+ const node = this._addBindEvent(options as any);
364
+ const index = this.bindEvents.indexOf(node);
365
+ node.create({
366
+ index,
367
+ parentNode: this,
368
+ parentKey: 'bindEvents',
369
+ });
370
+ return node;
371
+ }
372
+
373
+ getViewExistingNames(excludedList: Array<View> = []) {
189
374
  const excludedSet = new Set(excludedList);
190
375
  return ((this.views as View[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
191
376
  }
@@ -326,84 +511,83 @@ export class Frontend extends BaseNode {
326
511
  return node;
327
512
  }
328
513
 
329
-
330
- getVarExistingNames(excludedList: Array<Variable> = []) {
514
+ getVarExistingNames(excludedList: Array<FrontendVariable> = []) {
331
515
  const excludedSet = new Set(excludedList);
332
- return ((this.variables as Variable[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
516
+ return ((this.variables as FrontendVariable[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
333
517
  }
334
- getVariableUniqueName(name = 'variable1') {
518
+ getFrontendVariableUniqueName(name = 'frontendVariable1') {
335
519
  return utils.unique(name, this.getVarExistingNames(), undefined, true);
336
520
  }
337
521
 
338
522
  /**
339
- * 插入变量
523
+ * 插入前端全局变量
340
524
  * @internal
341
- * @param name 变量名称,如果不填会自动生成一个唯一名称
525
+ * @param name 前端全局变量名称,如果不填会自动生成一个唯一名称
342
526
  */
343
- _insertVariableAt(name: string, index: number): Variable;
527
+ _insertFrontendVariableAt(name: string, index: number): FrontendVariable;
344
528
 
345
529
  /**
346
- * 插入变量
530
+ * 插入前端全局变量
347
531
  * @internal
348
- * @param variableOptions 变量参数
532
+ * @param frontendVariableOptions 前端全局变量参数
349
533
  */
350
- _insertVariableAt(variableOptions: Partial<Variable>, index: number): Variable;
534
+ _insertFrontendVariableAt(frontendVariableOptions: Partial<FrontendVariable>, index: number): FrontendVariable;
351
535
 
352
536
  /**
353
- * 插入变量
537
+ * 插入前端全局变量
354
538
  * @internal
355
- * @param variable 已有的变量实例
539
+ * @param frontendVariable 已有的前端全局变量实例
356
540
  */
357
- _insertVariableAt(variable: Variable, index: number): Variable;
541
+ _insertFrontendVariableAt(frontendVariable: FrontendVariable, index: number): FrontendVariable;
358
542
 
359
- _insertVariableAt(options: string | Partial<Variable> | Variable, index: number) {
360
- const variableOptions: any = {};
543
+ _insertFrontendVariableAt(options: string | Partial<FrontendVariable> | FrontendVariable, index: number) {
544
+ const frontendVariableOptions: any = {};
361
545
  const relationOptions = { parentNode: this, parentKey: 'variables' };
362
- let variable: Variable;
546
+ let frontendVariable: FrontendVariable;
363
547
  if (!options) {
364
- variable = Variable.from({
365
- ...variableOptions,
366
- name: this.getVariableUniqueName(),
548
+ frontendVariable = FrontendVariable.from({
549
+ ...frontendVariableOptions,
550
+ name: this.getFrontendVariableUniqueName(),
367
551
  }, this, 'variables');
368
552
  } else if (typeof options === 'string') {
369
- variable = Variable.from({
370
- ...variableOptions,
553
+ frontendVariable = FrontendVariable.from({
554
+ ...frontendVariableOptions,
371
555
  name: options,
372
556
  }, this, 'variables');
373
- } else if (options instanceof Variable) {
557
+ } else if (options instanceof FrontendVariable) {
374
558
  options.ensureDelete(); // 同一实例不支持多处存在
375
- variable = options;
376
- Object.assign(variable, relationOptions);
559
+ frontendVariable = options;
560
+ Object.assign(frontendVariable, relationOptions);
377
561
  } else {
378
- variable = Variable.from({
379
- ...variableOptions,
562
+ frontendVariable = FrontendVariable.from({
563
+ ...frontendVariableOptions,
380
564
  ...options,
381
565
  }, this, 'variables');
382
566
  }
383
- this.variables.splice(index, 0, variable);
384
- return variable;
567
+ this.variables.splice(index, 0, frontendVariable);
568
+ return frontendVariable;
385
569
  }
386
570
 
387
571
  /**
388
- * 插入变量
389
- * @param name 变量名称,如果不填会自动生成一个唯一名称
572
+ * 插入前端全局变量
573
+ * @param name 前端全局变量名称,如果不填会自动生成一个唯一名称
390
574
  */
391
- insertVariableAt(name: string, index: number): Variable;
575
+ insertFrontendVariableAt(name: string, index: number): FrontendVariable;
392
576
 
393
577
  /**
394
- * 插入变量
395
- * @param variableOptions 变量参数
578
+ * 插入前端全局变量
579
+ * @param frontendVariableOptions 前端全局变量参数
396
580
  */
397
- insertVariableAt(variableOptions: Partial<Variable>, index: number): Variable;
581
+ insertFrontendVariableAt(frontendVariableOptions: Partial<FrontendVariable>, index: number): FrontendVariable;
398
582
 
399
583
  /**
400
- * 插入变量
401
- * @param variable 已有的变量实例
584
+ * 插入前端全局变量
585
+ * @param frontendVariable 已有的前端全局变量实例
402
586
  */
403
- insertVariableAt(variable: Variable, index: number): Variable;
587
+ insertFrontendVariableAt(frontendVariable: FrontendVariable, index: number): FrontendVariable;
404
588
 
405
- insertVariableAt(options: string | Partial<Variable> | Variable, index: number) {
406
- const node = this._insertVariableAt(options as any, index);
589
+ insertFrontendVariableAt(options: string | Partial<FrontendVariable> | FrontendVariable, index: number) {
590
+ const node = this._insertFrontendVariableAt(options as any, index);
407
591
  node.create({
408
592
  index,
409
593
  parentNode: this,
@@ -413,52 +597,52 @@ export class Frontend extends BaseNode {
413
597
  }
414
598
 
415
599
  /**
416
- * 添加变量
600
+ * 添加前端全局变量
417
601
  * @internal
418
- * @param name 变量名称,如果不填会自动生成一个唯一名称
602
+ * @param name 前端全局变量名称,如果不填会自动生成一个唯一名称
419
603
  */
420
- _addVariable(name?: string): Variable;
604
+ _addFrontendVariable(name?: string): FrontendVariable;
421
605
 
422
606
  /**
423
- * 添加变量
607
+ * 添加前端全局变量
424
608
  * @internal
425
- * @param variableOptions 变量参数
609
+ * @param frontendVariableOptions 前端全局变量参数
426
610
  */
427
- _addVariable(variableOptions: Partial<Variable>): Variable;
611
+ _addFrontendVariable(frontendVariableOptions: Partial<FrontendVariable>): FrontendVariable;
428
612
 
429
613
  /**
430
- * 添加变量
614
+ * 添加前端全局变量
431
615
  * @internal
432
- * @param variable 已有的变量实例
616
+ * @param frontendVariable 已有的前端全局变量实例
433
617
  */
434
- _addVariable(variable: Variable): Variable;
618
+ _addFrontendVariable(frontendVariable: FrontendVariable): FrontendVariable;
435
619
 
436
- _addVariable(options?: string | Partial<Variable> | Variable) {
620
+ _addFrontendVariable(options?: string | Partial<FrontendVariable> | FrontendVariable) {
437
621
  const index = this.variables.length;
438
- return this._insertVariableAt(options as any, index);
622
+ return this._insertFrontendVariableAt(options as any, index);
439
623
  }
440
624
 
441
625
  /**
442
- * 添加变量
626
+ * 添加前端全局变量
443
627
  * @internal
444
- * @param name 变量名称,如果不填会自动生成一个唯一名称
628
+ * @param name 前端全局变量名称,如果不填会自动生成一个唯一名称
445
629
  */
446
- addVariable(name?: string): Variable;
630
+ addFrontendVariable(name?: string): FrontendVariable;
447
631
 
448
632
  /**
449
- * 添加变量
450
- * @param variableOptions 变量参数
633
+ * 添加前端全局变量
634
+ * @param frontendVariableOptions 前端全局变量参数
451
635
  */
452
- addVariable(variableOptions: Partial<Variable>): Variable;
636
+ addFrontendVariable(frontendVariableOptions: Partial<FrontendVariable>): FrontendVariable;
453
637
 
454
638
  /**
455
- * 添加变量
456
- * @param variable 已有的变量实例
639
+ * 添加前端全局变量
640
+ * @param frontendVariable 已有的前端全局变量实例
457
641
  */
458
- addVariable(variable: Variable): Variable;
642
+ addFrontendVariable(frontendVariable: FrontendVariable): FrontendVariable;
459
643
 
460
- addVariable(options?: string | Partial<Variable> | Variable) {
461
- const node = this._addVariable(options as any);
644
+ addFrontendVariable(options?: string | Partial<FrontendVariable> | FrontendVariable) {
645
+ const node = this._addFrontendVariable(options as any);
462
646
  const index = this.variables.indexOf(node);
463
647
  node.create({
464
648
  index,
@@ -468,7 +652,6 @@ export class Frontend extends BaseNode {
468
652
  return node;
469
653
  }
470
654
 
471
-
472
655
  getModuleExistingNames(excludedList: Array<Module> = []) {
473
656
  const excludedSet = new Set(excludedList);
474
657
  return ((this.componentDependencies as Module[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
@@ -610,8 +793,53 @@ export class Frontend extends BaseNode {
610
793
  return node;
611
794
  }
612
795
 
796
+ /**
797
+ * 删除元素绑定事件
798
+ * @param name 元素绑定事件名称
799
+ */
800
+ removeBindEvent(name: string): void;
613
801
 
614
-
802
+ /**
803
+ * 删除元素绑定事件
804
+ * @param bindEvent 已有的元素绑定事件实例
805
+ */
806
+ removeBindEvent(bindEvent: BindEvent): void;
807
+
808
+ removeBindEvent(options: string | BindEvent) {
809
+ let bindEvent: BindEvent;
810
+ if (typeof options === 'string') {
811
+ bindEvent = (this.bindEvents as BindEvent[]).find((item) => item.name === options);
812
+ if (!bindEvent) {
813
+ throw new Error('找不到元素绑定事件 ' + options);
814
+ }
815
+ } else {
816
+ bindEvent = options;
817
+ }
818
+ return bindEvent.delete();
819
+ }
820
+
821
+ __removeBindEvent(bindEvent: BindEvent) {
822
+ const parentKey = bindEvent.parentKey;
823
+ const params: Params = {
824
+ parentNode: this,
825
+ parentKey,
826
+ index: -1,
827
+ object: null,
828
+ oldObject: bindEvent,
829
+ };
830
+ if (parentKey) {
831
+ params.parentKey = parentKey;
832
+ if (Array.isArray((this as any)[parentKey])) {
833
+ const index = (this as any)[parentKey].indexOf(bindEvent);
834
+ ~index && (this as any)[parentKey].splice(index, 1);
835
+ params.index = index;
836
+ } else if ((this as any)[parentKey] === bindEvent) {
837
+ params.index = 0;
838
+ (this as any)[parentKey] = undefined;
839
+ }
840
+ }
841
+ return params;
842
+ }
615
843
 
616
844
  /**
617
845
  * 删除页面
@@ -661,31 +889,29 @@ export class Frontend extends BaseNode {
661
889
  return params;
662
890
  }
663
891
 
664
-
665
-
666
892
  /**
667
- * 删除变量
668
- * @param name 变量名称
893
+ * 删除前端全局变量
894
+ * @param name 前端全局变量名称
669
895
  */
670
- removeVariable(name: string): void;
896
+ removeFrontendVariable(name: string): void;
671
897
 
672
898
  /**
673
- * 删除变量
674
- * @param variable 已有的变量实例
899
+ * 删除前端全局变量
900
+ * @param frontendVariable 已有的前端全局变量实例
675
901
  */
676
- removeVariable(variable: Variable): void;
902
+ removeFrontendVariable(frontendVariable: FrontendVariable): void;
677
903
 
678
- removeVariable(options: string | Variable) {
679
- let variable: Variable;
904
+ removeFrontendVariable(options: string | FrontendVariable) {
905
+ let frontendVariable: FrontendVariable;
680
906
  if (typeof options === 'string') {
681
- variable = (this.variables as Variable[]).find((item) => item.name === options);
682
- if (!variable) {
683
- throw new Error('找不到变量 ' + options);
907
+ frontendVariable = (this.variables as FrontendVariable[]).find((item) => item.name === options);
908
+ if (!frontendVariable) {
909
+ throw new Error('找不到前端全局变量 ' + options);
684
910
  }
685
911
  } else {
686
- variable = options;
912
+ frontendVariable = options;
687
913
  }
688
- return variable.delete();
914
+ return frontendVariable.delete();
689
915
  }
690
916
 
691
917
  __removeVariable(variable: Variable) {
@@ -711,8 +937,6 @@ export class Frontend extends BaseNode {
711
937
  return params;
712
938
  }
713
939
 
714
-
715
-
716
940
  /**
717
941
  * 删除主题
718
942
  * @param name 主题名称
@@ -761,8 +985,6 @@ export class Frontend extends BaseNode {
761
985
  return params;
762
986
  }
763
987
 
764
-
765
-
766
988
  /**
767
989
  * 删除模块
768
990
  * @param name 模块名称
@@ -852,6 +1074,18 @@ export class Frontend extends BaseNode {
852
1074
  ${keys.map((key) => ` ${key}: ${this.theme?.variableMap[key]};`).join('\n')}
853
1075
  }`;
854
1076
  }
1077
+ getTsNamespace() {
1078
+ if (this.parentNode && (this.parentNode as Namespace).getNamespace) {
1079
+ const parentNamespace = (this.parentNode as Namespace).getNamespace();
1080
+ const parentName = this.parentNode.name;
1081
+ const arr = [parentNamespace];
1082
+ if (this.parentNode.concept !== 'App' && parentName) {
1083
+ arr.push(parentName);
1084
+ }
1085
+ return `${arr.join('.')}.frontends`;
1086
+ } else
1087
+ throw new Error('无法获取命名空间,请设置 parentNode!');
1088
+ }
855
1089
 
856
1090
  getNamespace() {
857
1091
  if (this.parentNode && (this.parentNode as Namespace).getNamespace) {
@@ -953,13 +1187,42 @@ export class Frontend extends BaseNode {
953
1187
  }
954
1188
 
955
1189
  getExtensionsCallbackLogics() {
956
- let resultLogics:string[] = [];
957
- this.views.forEach((item:View) => {
1190
+ let resultLogics: string[] = [];
1191
+ this.views.forEach((item: View) => {
958
1192
  resultLogics = [...resultLogics, ...item.getViewCallLogics()];
959
1193
  });
960
1194
  return Array.from(new Set(resultLogics));
961
1195
  }
962
1196
 
1197
+ get defaultCanvasWidth() {
1198
+ return this.type === 'pc' ? 1440 : 375;
1199
+ }
1200
+ /**
1201
+ * 获取当前页面下所有elements上bindEvents下的logic
1202
+ */
1203
+ // elementLogicRoot: any[] = [];
1204
+
1205
+ // getElementLogicRoot() {
1206
+ // const logics: Array<Logic> = [];
1207
+ // // 页面上的绑定的事件
1208
+ // this.bindEvents.forEach((bindEvent) => {
1209
+ // bindEvent.logics.forEach((logic) => {
1210
+ // // 声明周期没有event
1211
+ // logics.push(logic);
1212
+ // });
1213
+ // });
1214
+ // if (logics.length) {
1215
+ // const expanded = (this.elementLogicRoot.length && this.elementLogicRoot[0].expanded) || false;
1216
+ // this.elementLogicRoot = [{
1217
+ // concept: 'elementLogicRoot',
1218
+ // expanded,
1219
+ // children: logics,
1220
+ // }];
1221
+ // } else {
1222
+ // this.elementLogicRoot = [];
1223
+ // }
1224
+ // }
1225
+
963
1226
  //================================================================================
964
1227
  // 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
965
1228
  // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
@@ -969,7 +969,7 @@ export class Function extends BaseNode {
969
969
  let code = '';
970
970
  code += '(';
971
971
  this.params.forEach((param, index) => {
972
- code += param.toJS(shiftState(state, code));
972
+ code += param.name;
973
973
  if (index !== this.params.length - 1) {
974
974
  code += ',';
975
975
  }
@@ -75,10 +75,10 @@ export class Identifier extends LogicItem {
75
75
  globalDataMap: {
76
76
  [name: string]: boolean;
77
77
  } = {
78
- $route: true,
79
- $global: true,
80
- $refs: true,
81
- };
78
+ $route: true,
79
+ $global: true,
80
+ $refs: true,
81
+ };
82
82
 
83
83
  isEnum() {
84
84
  return findConceptKeyWordByNamespace(this.namespace) === 'enums';
@@ -209,7 +209,7 @@ export class Identifier extends LogicItem {
209
209
  }
210
210
 
211
211
  // 全局变量在不是页面的地方放置,就会报错
212
- if (this.namespace?.startsWith('app.frontends') && this.namespace?.endsWith('variables') && !this.view) {
212
+ if (this.namespace?.startsWith('app.frontends') && this.namespace?.endsWith('variables') && !this.frontend) {
213
213
  return '__FRONTENDVARIABLES__';
214
214
  }
215
215
 
@@ -28,7 +28,7 @@ export class Interface extends BaseNode {
28
28
  * 产品概念
29
29
  */
30
30
  @property()
31
- concept: 'Interface' = 'Interface';
31
+ concept: 'Interface' | 'AuthInterface' = 'Interface';
32
32
 
33
33
  /**
34
34
  * 接口名称