@lcap/nasl 2.19.0-beta.1 → 2.19.0-beta.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 (178) hide show
  1. package/out/common/BaseNode.js +4 -1
  2. package/out/common/BaseNode.js.map +1 -1
  3. package/out/concepts/Abort__.d.ts +25 -0
  4. package/out/concepts/Abort__.js +80 -0
  5. package/out/concepts/Abort__.js.map +1 -0
  6. package/out/concepts/App__.js.map +1 -1
  7. package/out/concepts/BatchAssignment__.js +3 -3
  8. package/out/concepts/BatchAssignment__.js.map +1 -1
  9. package/out/concepts/CallFunction__.js +23 -7
  10. package/out/concepts/CallFunction__.js.map +1 -1
  11. package/out/concepts/CallInterface__.js +1 -1
  12. package/out/concepts/CallInterface__.js.map +1 -1
  13. package/out/concepts/CallLogic__.js +9 -65
  14. package/out/concepts/CallLogic__.js.map +1 -1
  15. package/out/concepts/DatabaseTypeAnnotation__.d.ts +31 -0
  16. package/out/concepts/DatabaseTypeAnnotation__.js +78 -0
  17. package/out/concepts/DatabaseTypeAnnotation__.js.map +1 -0
  18. package/out/concepts/EnumItem__.d.ts +5 -5
  19. package/out/concepts/EnumItem__.js +6 -6
  20. package/out/concepts/Enum__.d.ts +20 -19
  21. package/out/concepts/Enum__.js +28 -1
  22. package/out/concepts/Enum__.js.map +1 -1
  23. package/out/concepts/ForEachStatement__.js +1 -1
  24. package/out/concepts/ForEachStatement__.js.map +1 -1
  25. package/out/concepts/FrontendLibrary__.d.ts +213 -0
  26. package/out/concepts/FrontendLibrary__.js +352 -0
  27. package/out/concepts/FrontendLibrary__.js.map +1 -0
  28. package/out/concepts/Frontend__.d.ts +373 -0
  29. package/out/concepts/Frontend__.js +685 -0
  30. package/out/concepts/Frontend__.js.map +1 -0
  31. package/out/concepts/Integration__.d.ts +53 -0
  32. package/out/concepts/Integration__.js +143 -0
  33. package/out/concepts/Integration__.js.map +1 -0
  34. package/out/concepts/JavaLogic__.d.ts +42 -0
  35. package/out/concepts/JavaLogic__.js +122 -0
  36. package/out/concepts/JavaLogic__.js.map +1 -0
  37. package/out/concepts/Logic__.js +3 -0
  38. package/out/concepts/Logic__.js.map +1 -1
  39. package/out/concepts/MicroApp__.d.ts +51 -0
  40. package/out/concepts/MicroApp__.js +113 -0
  41. package/out/concepts/MicroApp__.js.map +1 -0
  42. package/out/concepts/NewComposite__.js +14 -14
  43. package/out/concepts/NewComposite__.js.map +1 -1
  44. package/out/concepts/NewList__.d.ts +1 -0
  45. package/out/concepts/NewList__.js +17 -1
  46. package/out/concepts/NewList__.js.map +1 -1
  47. package/out/concepts/NewMap__.d.ts +1 -0
  48. package/out/concepts/NewMap__.js +18 -1
  49. package/out/concepts/NewMap__.js.map +1 -1
  50. package/out/concepts/OqlQueryComponent__.js +2 -0
  51. package/out/concepts/OqlQueryComponent__.js.map +1 -1
  52. package/out/concepts/StringInterpolation__.js +2 -0
  53. package/out/concepts/StringInterpolation__.js.map +1 -1
  54. package/out/concepts/TypeAnnotation__.js +3 -3
  55. package/out/concepts/TypeAnnotation__.js.map +1 -1
  56. package/out/concepts/ViewBlock__.d.ts +35 -0
  57. package/out/concepts/ViewBlock__.js +85 -0
  58. package/out/concepts/ViewBlock__.js.map +1 -0
  59. package/out/concepts/ViewElement__.js +1 -1
  60. package/out/concepts/ViewElement__.js.map +1 -1
  61. package/out/concepts/View__.js +1 -0
  62. package/out/concepts/View__.js.map +1 -1
  63. package/out/concepts/basics/stdlib/nasl.util.js +4 -2
  64. package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
  65. package/out/generator/genBundleFiles.js +10 -1
  66. package/out/generator/genBundleFiles.js.map +1 -1
  67. package/out/generator/genReleaseBody.js +3 -0
  68. package/out/generator/genReleaseBody.js.map +1 -1
  69. package/out/generator/icestark.d.ts +2 -0
  70. package/out/generator/icestark.js +48 -0
  71. package/out/generator/icestark.js.map +1 -0
  72. package/out/generator/microApp.d.ts +2 -0
  73. package/out/generator/microApp.js +35 -0
  74. package/out/generator/microApp.js.map +1 -0
  75. package/out/generator/qiankun.d.ts +2 -0
  76. package/out/generator/qiankun.js +52 -0
  77. package/out/generator/qiankun.js.map +1 -0
  78. package/out/manager/stepRecorder.d.ts +20 -0
  79. package/out/manager/stepRecorder.js +110 -0
  80. package/out/manager/stepRecorder.js.map +1 -0
  81. package/out/sentry/index.d.ts +29 -0
  82. package/out/sentry/index.js +111 -0
  83. package/out/sentry/index.js.map +1 -0
  84. package/out/server/extendBaseNode.js +5 -1
  85. package/out/server/extendBaseNode.js.map +1 -1
  86. package/out/server/formatTsUtils.js +11 -8
  87. package/out/server/formatTsUtils.js.map +1 -1
  88. package/out/server/naslServer.js +118 -9
  89. package/out/server/naslServer.js.map +1 -1
  90. package/out/server/translator.js +43 -10
  91. package/out/server/translator.js.map +1 -1
  92. package/out/service/creator/add.configs.js +2 -0
  93. package/out/service/creator/add.configs.js.map +1 -1
  94. package/out/service/creator/errHandles.js +5 -0
  95. package/out/service/creator/errHandles.js.map +1 -1
  96. package/out/service/creator/index.js +2 -0
  97. package/out/service/creator/index.js.map +1 -1
  98. package/out/service/storage/api.d.ts +18 -0
  99. package/out/service/storage/api.js +12 -0
  100. package/out/service/storage/api.js.map +1 -1
  101. package/out/service/storage/init.d.ts +41 -1
  102. package/out/service/storage/init.js +175 -30
  103. package/out/service/storage/init.js.map +1 -1
  104. package/out/service/storage/service.d.ts +9 -1
  105. package/out/service/storage/service.js +27 -1
  106. package/out/service/storage/service.js.map +1 -1
  107. package/out/templator/genGetBlock.js +1 -1
  108. package/out/templator/genGetBlock.js.map +1 -1
  109. package/out/templator/genListViewBlock.js +6 -0
  110. package/out/templator/genListViewBlock.js.map +1 -1
  111. package/package.json +2 -2
  112. package/sandbox/stdlib/nasl.core.ts +2 -0
  113. package/sandbox/stdlib/nasl.oql.ts +16 -4
  114. package/sandbox/stdlib/nasl.util.ts +2 -1
  115. package/src/common/BaseNode.ts +3 -1
  116. package/src/concepts/App__.ts +41 -1
  117. package/src/concepts/BatchAssignment__.ts +3 -3
  118. package/src/concepts/CallFunction__.ts +34 -20
  119. package/src/concepts/CallInterface__.ts +19 -1
  120. package/src/concepts/CallLogic__.ts +8 -65
  121. package/src/concepts/EnumItem__.ts +6 -6
  122. package/src/concepts/Enum__.ts +22 -19
  123. package/src/concepts/ForEachStatement__.ts +1 -1
  124. package/src/concepts/Logic__.ts +13 -10
  125. package/src/concepts/NewComposite__.ts +14 -14
  126. package/src/concepts/NewList__.ts +18 -1
  127. package/src/concepts/NewMap__.ts +19 -1
  128. package/src/concepts/OqlQueryComponent__.ts +2 -0
  129. package/src/concepts/StringInterpolation__.ts +6 -4
  130. package/src/concepts/TypeAnnotation__.ts +41 -3
  131. package/src/concepts/ViewElement__.ts +1 -1
  132. package/src/concepts/View__.ts +3 -2
  133. package/src/concepts/basics/stdlib/nasl.util.ts +4 -2
  134. package/src/generator/genBundleFiles.ts +10 -1
  135. package/src/generator/genReleaseBody.ts +3 -1
  136. package/src/server/extendBaseNode.ts +4 -1
  137. package/src/server/formatTsUtils.ts +11 -8
  138. package/src/server/naslServer.ts +124 -11
  139. package/src/server/translator.ts +37 -10
  140. package/src/service/creator/add.configs.js +3 -0
  141. package/src/service/creator/errHandles.js +6 -0
  142. package/src/service/creator/index.js +3 -0
  143. package/src/service/storage/api.js +12 -0
  144. package/src/service/storage/init.ts +207 -29
  145. package/src/service/storage/service.ts +29 -1
  146. package/src/templator/genGetBlock.ts +1 -1
  147. package/src/templator/genListViewBlock.ts +6 -0
  148. package/ts-worker/lib/tsserver.js +10 -2
  149. package/ts-worker/package.json +1 -0
  150. package/ts-worker/webpack.config.js +11 -2
  151. package/sandbox/stdlib/dist/nasl.logging.js +0 -0
  152. package/sandbox/stdlib/dist/nasl.util.js +0 -0
  153. package/src/automate/engine/dist/index.dev.js +0 -517
  154. package/src/common/dist/BaseNode.js +0 -1101
  155. package/src/concepts/basics/stdlib/dist/nasl.util.js +0 -1602
  156. package/src/concepts/basics/stdlib/dist/reference2TypeAnnotationList.js +0 -24
  157. package/src/concepts/dist/BindAttribute__.js +0 -760
  158. package/src/concepts/dist/BindEvent__.js +0 -732
  159. package/src/concepts/dist/CallFunction__.js +0 -527
  160. package/src/concepts/dist/CallLogic__.js +0 -932
  161. package/src/concepts/dist/Identifier__.js +0 -311
  162. package/src/concepts/dist/StringInterpolation__.js +0 -231
  163. package/src/concepts/dist/TypeAnnotation__.js +0 -834
  164. package/src/concepts/dist/ViewElement__.js +0 -1692
  165. package/src/concepts/dist/View__.js +0 -1601
  166. package/src/generator/dist/genBundleFiles.js +0 -261
  167. package/src/generator/dist/genMetaData.js +0 -245
  168. package/src/generator/dist/permission.js +0 -392
  169. package/src/server/dist/naslServer.js +0 -3590
  170. package/src/service/storage/dist/init.js +0 -579
  171. package/src/templator/dist/genEditTableBlock.js +0 -204
  172. package/src/templator/dist/genGridViewBlock.js +0 -265
  173. package/src/templator/dist/genListViewBlock.js +0 -84
  174. package/src/templator/dist/genTableBlock.js +0 -209
  175. package/src/templator/dist/utils.js +0 -527
  176. package/ts-worker/dist/webpack.config.dev.js +0 -106
  177. /package/src/service/{dataSource → datasource}/api.js +0 -0
  178. /package/src/service/{dataSource → datasource}/index.js +0 -0
@@ -0,0 +1,685 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ 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;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || function (mod) {
25
+ if (mod && mod.__esModule) return mod;
26
+ var result = {};
27
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
+ __setModuleDefault(result, mod);
29
+ return result;
30
+ };
31
+ var __importDefault = (this && this.__importDefault) || function (mod) {
32
+ return (mod && mod.__esModule) ? mod : { "default": mod };
33
+ };
34
+ var Frontend_1;
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.Frontend = void 0;
37
+ const translator_1 = require("../translator");
38
+ const decorators_1 = require("../decorators");
39
+ const utils = __importStar(require("../utils"));
40
+ const BaseNode_1 = __importDefault(require("../common/BaseNode"));
41
+ const classMap_1 = __importDefault(require("../common/classMap"));
42
+ const View__1 = __importDefault(require("./View__"));
43
+ const Variable__1 = __importDefault(require("./Variable__"));
44
+ const Theme__1 = __importDefault(require("./Theme__"));
45
+ const Module__1 = __importDefault(require("./Module__"));
46
+ /**
47
+ * 端
48
+ */
49
+ let Frontend = Frontend_1 = class Frontend extends BaseNode_1.default {
50
+ /**
51
+ * 产品概念
52
+ */
53
+ concept = 'Frontend';
54
+ /**
55
+ * 端标识
56
+ */
57
+ name = undefined;
58
+ /**
59
+ * pc端
60
+ */
61
+ title = undefined;
62
+ /**
63
+ * PC/H5 端
64
+ */
65
+ type = undefined;
66
+ /**
67
+ * 基础路径
68
+ */
69
+ path = undefined;
70
+ /**
71
+ * 制品应用标题
72
+ */
73
+ documentTitle = undefined;
74
+ /**
75
+ * 制品应用图标
76
+ */
77
+ documentIcon = undefined;
78
+ /**
79
+ * 页面列表
80
+ */
81
+ views = [];
82
+ /**
83
+ * 变量列表
84
+ */
85
+ variables = [];
86
+ /**
87
+ * 主题配置
88
+ */
89
+ theme = new Theme__1.default();
90
+ /**
91
+ * 扩展组件列表(兼容老版)
92
+ */
93
+ componentDependencies = [];
94
+ /**
95
+ * 祖先 App
96
+ */
97
+ get app() {
98
+ return this.getAncestor('App');
99
+ }
100
+ /**
101
+ * @param source 需要合并的部分参数
102
+ */
103
+ constructor(source) {
104
+ source = Object.assign({}, Frontend_1.getDefaultOptions(), source);
105
+ super(source);
106
+ super.subConstructor(source);
107
+ }
108
+ getClassName() {
109
+ return 'Frontend';
110
+ }
111
+ static from(source, parentNode, parentKey) {
112
+ return super.from(source, parentNode, parentKey);
113
+ }
114
+ /**
115
+ * 从父级删除该节点
116
+ * @internal
117
+ */
118
+ _delete() {
119
+ let params = null;
120
+ if (this.parentNode) {
121
+ params = this.parentNode?.__removeFrontend?.(this);
122
+ }
123
+ return params;
124
+ }
125
+ /**
126
+ * 设置端标识
127
+ */
128
+ setName(name) {
129
+ const object = {
130
+ name,
131
+ };
132
+ this.update({
133
+ ...object,
134
+ field: 'name',
135
+ });
136
+ }
137
+ /**
138
+ * 设置pc端
139
+ */
140
+ setTitle(title) {
141
+ const object = {
142
+ title,
143
+ };
144
+ this.update({
145
+ ...object,
146
+ });
147
+ }
148
+ /**
149
+ * 设置基础路径
150
+ */
151
+ setPath(path) {
152
+ const object = {
153
+ path,
154
+ };
155
+ this.update({
156
+ ...object,
157
+ });
158
+ }
159
+ /**
160
+ * 设置制品应用标题
161
+ */
162
+ setDocumentTitle(documentTitle) {
163
+ const object = {
164
+ documentTitle,
165
+ };
166
+ this.update({
167
+ ...object,
168
+ });
169
+ }
170
+ /**
171
+ * 设置制品应用图标
172
+ */
173
+ setDocumentIcon(documentIcon) {
174
+ const object = {
175
+ documentIcon,
176
+ };
177
+ this.update({
178
+ ...object,
179
+ });
180
+ }
181
+ getViewExistingNames(excludedList = []) {
182
+ const excludedSet = new Set(excludedList);
183
+ return (this.views || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
184
+ }
185
+ getViewUniqueName(name = 'view1') {
186
+ return utils.unique(name, this.getViewExistingNames(), undefined, true);
187
+ }
188
+ _insertViewAt(options, index) {
189
+ const viewOptions = {};
190
+ const relationOptions = { parentNode: this, parentKey: 'views' };
191
+ let view;
192
+ if (!options) {
193
+ view = View__1.default.from({
194
+ ...viewOptions,
195
+ name: this.getViewUniqueName(),
196
+ }, this, 'views');
197
+ }
198
+ else if (typeof options === 'string') {
199
+ view = View__1.default.from({
200
+ ...viewOptions,
201
+ name: options,
202
+ }, this, 'views');
203
+ }
204
+ else if (options instanceof View__1.default) {
205
+ options.ensureDelete(); // 同一实例不支持多处存在
206
+ view = options;
207
+ Object.assign(view, relationOptions);
208
+ }
209
+ else {
210
+ view = View__1.default.from({
211
+ ...viewOptions,
212
+ ...options,
213
+ }, this, 'views');
214
+ }
215
+ this.views.splice(index, 0, view);
216
+ return view;
217
+ }
218
+ insertViewAt(options, index) {
219
+ const node = this._insertViewAt(options, index);
220
+ node.create({
221
+ index,
222
+ parentNode: this,
223
+ parentKey: 'views',
224
+ });
225
+ return node;
226
+ }
227
+ _addView(options) {
228
+ const index = this.views.length;
229
+ return this._insertViewAt(options, index);
230
+ }
231
+ addView(options) {
232
+ const node = this._addView(options);
233
+ const index = this.views.indexOf(node);
234
+ node.create({
235
+ index,
236
+ parentNode: this,
237
+ parentKey: 'views',
238
+ });
239
+ return node;
240
+ }
241
+ getVarExistingNames(excludedList = []) {
242
+ const excludedSet = new Set(excludedList);
243
+ return (this.variables || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
244
+ }
245
+ getVariableUniqueName(name = 'variable1') {
246
+ return utils.unique(name, this.getVarExistingNames(), undefined, true);
247
+ }
248
+ _insertVariableAt(options, index) {
249
+ const variableOptions = {};
250
+ const relationOptions = { parentNode: this, parentKey: 'variables' };
251
+ let variable;
252
+ if (!options) {
253
+ variable = Variable__1.default.from({
254
+ ...variableOptions,
255
+ name: this.getVariableUniqueName(),
256
+ }, this, 'variables');
257
+ }
258
+ else if (typeof options === 'string') {
259
+ variable = Variable__1.default.from({
260
+ ...variableOptions,
261
+ name: options,
262
+ }, this, 'variables');
263
+ }
264
+ else if (options instanceof Variable__1.default) {
265
+ options.ensureDelete(); // 同一实例不支持多处存在
266
+ variable = options;
267
+ Object.assign(variable, relationOptions);
268
+ }
269
+ else {
270
+ variable = Variable__1.default.from({
271
+ ...variableOptions,
272
+ ...options,
273
+ }, this, 'variables');
274
+ }
275
+ this.variables.splice(index, 0, variable);
276
+ return variable;
277
+ }
278
+ insertVariableAt(options, index) {
279
+ const node = this._insertVariableAt(options, index);
280
+ node.create({
281
+ index,
282
+ parentNode: this,
283
+ parentKey: 'variables',
284
+ });
285
+ return node;
286
+ }
287
+ _addVariable(options) {
288
+ const index = this.variables.length;
289
+ return this._insertVariableAt(options, index);
290
+ }
291
+ addVariable(options) {
292
+ const node = this._addVariable(options);
293
+ const index = this.variables.indexOf(node);
294
+ node.create({
295
+ index,
296
+ parentNode: this,
297
+ parentKey: 'variables',
298
+ });
299
+ return node;
300
+ }
301
+ getModuleExistingNames(excludedList = []) {
302
+ const excludedSet = new Set(excludedList);
303
+ return (this.componentDependencies || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
304
+ }
305
+ getModuleUniqueName(name = 'module1') {
306
+ return utils.unique(name, this.getModuleExistingNames(), undefined, false);
307
+ }
308
+ _insertModuleAt(options, index) {
309
+ const moduleOptions = {};
310
+ const relationOptions = { parentNode: this, parentKey: 'componentDependencies' };
311
+ let module;
312
+ if (!options) {
313
+ module = Module__1.default.from({
314
+ ...moduleOptions,
315
+ name: this.getModuleUniqueName(),
316
+ }, this, 'componentDependencies');
317
+ }
318
+ else if (typeof options === 'string') {
319
+ module = Module__1.default.from({
320
+ ...moduleOptions,
321
+ name: options,
322
+ }, this, 'componentDependencies');
323
+ }
324
+ else if (options instanceof Module__1.default) {
325
+ options.ensureDelete(); // 同一实例不支持多处存在
326
+ module = options;
327
+ Object.assign(module, relationOptions);
328
+ }
329
+ else {
330
+ module = Module__1.default.from({
331
+ ...moduleOptions,
332
+ ...options,
333
+ }, this, 'componentDependencies');
334
+ }
335
+ this.componentDependencies.splice(index, 0, module);
336
+ return module;
337
+ }
338
+ insertModuleAt(options, index) {
339
+ const node = this._insertModuleAt(options, index);
340
+ node.create({
341
+ index,
342
+ parentNode: this,
343
+ parentKey: 'componentDependencies',
344
+ });
345
+ return node;
346
+ }
347
+ _addModule(options) {
348
+ const index = this.componentDependencies.length;
349
+ return this._insertModuleAt(options, index);
350
+ }
351
+ addModule(options) {
352
+ const node = this._addModule(options);
353
+ const index = this.componentDependencies.indexOf(node);
354
+ node.create({
355
+ index,
356
+ parentNode: this,
357
+ parentKey: 'componentDependencies',
358
+ });
359
+ return node;
360
+ }
361
+ removeView(options) {
362
+ let view;
363
+ if (typeof options === 'string') {
364
+ view = this.views.find((item) => item.name === options);
365
+ if (!view) {
366
+ throw new Error('找不到页面 ' + options);
367
+ }
368
+ }
369
+ else {
370
+ view = options;
371
+ }
372
+ return view.delete();
373
+ }
374
+ __removeView(view) {
375
+ const parentKey = view.parentKey;
376
+ const params = {
377
+ parentNode: this,
378
+ parentKey,
379
+ index: -1,
380
+ object: null,
381
+ oldObject: view,
382
+ };
383
+ if (parentKey) {
384
+ params.parentKey = parentKey;
385
+ if (Array.isArray(this[parentKey])) {
386
+ const index = this[parentKey].indexOf(view);
387
+ ~index && this[parentKey].splice(index, 1);
388
+ params.index = index;
389
+ }
390
+ else if (this[parentKey] === view) {
391
+ params.index = 0;
392
+ this[parentKey] = undefined;
393
+ }
394
+ }
395
+ return params;
396
+ }
397
+ removeVariable(options) {
398
+ let variable;
399
+ if (typeof options === 'string') {
400
+ variable = this.variables.find((item) => item.name === options);
401
+ if (!variable) {
402
+ throw new Error('找不到变量 ' + options);
403
+ }
404
+ }
405
+ else {
406
+ variable = options;
407
+ }
408
+ return variable.delete();
409
+ }
410
+ __removeVariable(variable) {
411
+ const parentKey = variable.parentKey;
412
+ const params = {
413
+ parentNode: this,
414
+ parentKey,
415
+ index: -1,
416
+ object: null,
417
+ oldObject: variable,
418
+ };
419
+ if (parentKey) {
420
+ params.parentKey = parentKey;
421
+ if (Array.isArray(this[parentKey])) {
422
+ const index = this[parentKey].indexOf(variable);
423
+ ~index && this[parentKey].splice(index, 1);
424
+ params.index = index;
425
+ }
426
+ else if (this[parentKey] === variable) {
427
+ params.index = 0;
428
+ this[parentKey] = undefined;
429
+ }
430
+ }
431
+ return params;
432
+ }
433
+ removeTheme(options) {
434
+ let theme;
435
+ if (typeof options === 'string') {
436
+ theme = this.theme;
437
+ if (!theme) {
438
+ throw new Error('找不到主题 ' + options);
439
+ }
440
+ }
441
+ else {
442
+ theme = options;
443
+ }
444
+ return theme.delete();
445
+ }
446
+ __removeTheme(theme) {
447
+ const parentKey = theme.parentKey;
448
+ const params = {
449
+ parentNode: this,
450
+ parentKey,
451
+ index: -1,
452
+ object: null,
453
+ oldObject: theme,
454
+ };
455
+ if (parentKey) {
456
+ params.parentKey = parentKey;
457
+ if (Array.isArray(this[parentKey])) {
458
+ const index = this[parentKey].indexOf(theme);
459
+ ~index && this[parentKey].splice(index, 1);
460
+ params.index = index;
461
+ }
462
+ else if (this[parentKey] === theme) {
463
+ params.index = 0;
464
+ this[parentKey] = undefined;
465
+ }
466
+ }
467
+ return params;
468
+ }
469
+ removeModule(options) {
470
+ let module;
471
+ if (typeof options === 'string') {
472
+ module = this.componentDependencies.find((item) => item.name === options);
473
+ if (!module) {
474
+ throw new Error('找不到模块 ' + options);
475
+ }
476
+ }
477
+ else {
478
+ module = options;
479
+ }
480
+ return module.delete();
481
+ }
482
+ __removeModule(module) {
483
+ const parentKey = module.parentKey;
484
+ const params = {
485
+ parentNode: this,
486
+ parentKey,
487
+ index: -1,
488
+ object: null,
489
+ oldObject: module,
490
+ };
491
+ if (parentKey) {
492
+ params.parentKey = parentKey;
493
+ if (Array.isArray(this[parentKey])) {
494
+ const index = this[parentKey].indexOf(module);
495
+ ~index && this[parentKey].splice(index, 1);
496
+ params.index = index;
497
+ }
498
+ else if (this[parentKey] === module) {
499
+ params.index = 0;
500
+ this[parentKey] = undefined;
501
+ }
502
+ }
503
+ return params;
504
+ }
505
+ //================================================================================
506
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
507
+ // 自动生成的代码已结束。下面可以手动编写。
508
+ //================================================================================
509
+ findComponentDependencyByName(name) {
510
+ return this.componentDependencies.find((componentDependency) => componentDependency.name === name);
511
+ }
512
+ /**
513
+ * @param path 路径
514
+ * path 为要查找路径:如 /dashboard/student/list、/dashboard/student/list
515
+ */
516
+ findViewByPath(path) {
517
+ const arr = path.split('/');
518
+ if (arr[0] === '')
519
+ arr.shift();
520
+ if (!arr.length)
521
+ throw Error('Cannot find View ' + path);
522
+ const childName = arr.shift();
523
+ const subView = this.views.find((child) => child.name === childName);
524
+ return arr.length ? subView.findViewByPath(arr.join('/')) : subView;
525
+ }
526
+ findViewByName(name) {
527
+ return utils.traverse((current) => {
528
+ if (current.node.name === name)
529
+ return current.node;
530
+ }, { node: { name: '', children: this.views } });
531
+ }
532
+ genThemeCSS() {
533
+ const keys = Object.keys(this.theme?.variableMap || {});
534
+ if (!keys.length)
535
+ return;
536
+ return `:root {
537
+ ${keys.map((key) => ` ${key}: ${this.theme?.variableMap[key]};`).join('\n')}
538
+ }`;
539
+ }
540
+ getNamespace() {
541
+ if (this.parentNode && this.parentNode.getNamespace) {
542
+ const parentNamespace = this.parentNode.getNamespace();
543
+ const parentName = this.parentNode.name;
544
+ const arr = [parentNamespace];
545
+ if (this.parentNode.concept !== 'App' && parentName) {
546
+ arr.push(parentName);
547
+ }
548
+ return `${arr.join('.')}.frontends`;
549
+ }
550
+ else
551
+ throw new Error('无法获取命名空间,请设置 parentNode!');
552
+ }
553
+ /**
554
+ * 生成宿主语言的文件路径
555
+ * @param name 一般不用传,用于 rename
556
+ */
557
+ getEmbeddedFilePath(name = this.name) {
558
+ return `/embedded/${this.rootNode?.name || this.parentNode.name}/frontends/${name}.ts`;
559
+ }
560
+ toEmbeddedTS(state) {
561
+ let code = `export namespace ${this.name} {\n`;
562
+ code += 'const name = ';
563
+ code += '"' + this.name + '";\n';
564
+ code += '}\n';
565
+ return code;
566
+ }
567
+ toEmbeddedTSFile() {
568
+ let code = `namespace ${this.getNamespace()} {\n`;
569
+ const state = (0, translator_1.createCompilerState)(code, { tabSize: 1 });
570
+ try {
571
+ code += this.toEmbeddedTS(state);
572
+ }
573
+ catch (err) {
574
+ code += '';
575
+ console.log(err);
576
+ }
577
+ code += '}\n';
578
+ return {
579
+ code,
580
+ filePath: this.getEmbeddedFilePath(),
581
+ sourceMap: state.sourceMap,
582
+ };
583
+ }
584
+ getPath() {
585
+ const path = this.path;
586
+ const finalPath = path && path !== '/' ? path : '';
587
+ return finalPath;
588
+ }
589
+ // 前缀
590
+ get prefixPath() {
591
+ const prefixArr = [];
592
+ [
593
+ this.app.sysPrefixPath,
594
+ this.basePath,
595
+ ].forEach((prefix) => {
596
+ if (prefix) {
597
+ prefixArr.push(prefix);
598
+ }
599
+ });
600
+ return prefixArr.join('');
601
+ }
602
+ /**
603
+ * 为/的转成'',便于url拼接
604
+ */
605
+ get basePath() {
606
+ const path = this.path;
607
+ const basePath = path && path !== '/' ? path : '';
608
+ return basePath;
609
+ }
610
+ genCustomAssetsInfo(prefix) {
611
+ const custom = {
612
+ js: [],
613
+ css: [],
614
+ names: [],
615
+ };
616
+ const existingSet = new Set();
617
+ this.componentDependencies.forEach((dep) => {
618
+ const { name, version } = dep;
619
+ const jsName = `${prefix}/packages/${name}@${version}/dist-theme/index.js`;
620
+ if (!existingSet.has(jsName)) {
621
+ existingSet.add(jsName);
622
+ custom.js.push(jsName);
623
+ if (utils.shouldLoadCss(name, version)) {
624
+ custom.css.push(`${prefix}/packages/${name}@${version}/dist-theme/index.css`);
625
+ }
626
+ custom.names.push(name);
627
+ }
628
+ });
629
+ return custom;
630
+ }
631
+ getExtensionsCallbackLogics() {
632
+ let resultLogics = [];
633
+ this.views.forEach((item) => {
634
+ resultLogics = [...resultLogics, ...item.getViewCallLogics()];
635
+ });
636
+ return Array.from(new Set(resultLogics));
637
+ }
638
+ };
639
+ __decorate([
640
+ (0, decorators_1.property)()
641
+ ], Frontend.prototype, "concept", void 0);
642
+ __decorate([
643
+ (0, decorators_1.property)()
644
+ ], Frontend.prototype, "name", void 0);
645
+ __decorate([
646
+ (0, decorators_1.property)()
647
+ ], Frontend.prototype, "title", void 0);
648
+ __decorate([
649
+ (0, decorators_1.property)()
650
+ ], Frontend.prototype, "type", void 0);
651
+ __decorate([
652
+ (0, decorators_1.property)()
653
+ ], Frontend.prototype, "path", void 0);
654
+ __decorate([
655
+ (0, decorators_1.property)()
656
+ ], Frontend.prototype, "documentTitle", void 0);
657
+ __decorate([
658
+ (0, decorators_1.property)()
659
+ ], Frontend.prototype, "documentIcon", void 0);
660
+ __decorate([
661
+ (0, decorators_1.property)('View')
662
+ ], Frontend.prototype, "views", void 0);
663
+ __decorate([
664
+ (0, decorators_1.property)('Variable')
665
+ ], Frontend.prototype, "variables", void 0);
666
+ __decorate([
667
+ (0, decorators_1.property)('Theme')
668
+ ], Frontend.prototype, "theme", void 0);
669
+ __decorate([
670
+ (0, decorators_1.property)('Module')
671
+ ], Frontend.prototype, "componentDependencies", void 0);
672
+ __decorate([
673
+ (0, translator_1.withSourceMap)()
674
+ ], Frontend.prototype, "toEmbeddedTS", null);
675
+ Frontend = Frontend_1 = __decorate([
676
+ (0, decorators_1.concept)('端')
677
+ ], Frontend);
678
+ exports.Frontend = Frontend;
679
+ classMap_1.default.Frontend = Frontend;
680
+ exports.default = Frontend;
681
+ //================================================================================
682
+ // ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
683
+ // 自动生成的代码已结束。下面可以手动编写。
684
+ //================================================================================
685
+ //# sourceMappingURL=Frontend__.js.map