@lcap/nasl 2.20.0-beta.2 → 2.20.0
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.
- package/out/automate/engine/index.d.ts +1 -1
- package/out/automate/engine/index.js +2 -3
- package/out/automate/engine/index.js.map +1 -1
- package/out/automate/engine/uniqueName.d.ts +1 -1
- package/out/automate/engine/uniqueName.js +2 -2
- package/out/automate/engine/uniqueName.js.map +1 -1
- package/out/automate/engine/utils.js +4 -1
- package/out/automate/engine/utils.js.map +1 -1
- package/out/automate/template/myProcess.d.ts +1 -1
- package/out/automate/template/myProcess.js +2 -2
- package/out/automate/template/myProcess.js.map +1 -1
- package/out/bak/translator.js +14 -22
- package/out/bak/translator.js.map +1 -1
- package/out/common/BaseNode.js +4 -1
- package/out/common/BaseNode.js.map +1 -1
- package/out/common/Command.d.ts +1 -0
- package/out/common/Command.js +5 -1
- package/out/common/Command.js.map +1 -1
- package/out/concepts/App__.d.ts +4 -0
- package/out/concepts/App__.js +30 -6
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Assignee__.js +4 -3
- package/out/concepts/Assignee__.js.map +1 -1
- package/out/concepts/BatchAssignment__.js +3 -3
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts +7 -0
- package/out/concepts/BindAttribute__.js +270 -39
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.d.ts +7 -0
- package/out/concepts/BindDirective__.js +215 -17
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindStyle__.d.ts +7 -0
- package/out/concepts/BindStyle__.js +194 -4
- package/out/concepts/BindStyle__.js.map +1 -1
- package/out/concepts/CallFunction__.js +22 -8
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.js +3 -2
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +3 -0
- package/out/concepts/CallLogic__.js +78 -89
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.js +20 -3
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/ConfigGroup__.d.ts +1 -0
- package/out/concepts/ConfigGroup__.js +13 -0
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/ConfigProperty__.d.ts +19 -0
- package/out/concepts/ConfigProperty__.js +61 -0
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Configuration__.d.ts +1 -0
- package/out/concepts/Configuration__.js +13 -0
- package/out/concepts/Configuration__.js.map +1 -1
- package/out/concepts/DataSource__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +1 -0
- package/out/concepts/Destination__.js +61 -7
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/EntityProperty__.js +9 -1
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/EnumItem__.d.ts +5 -5
- package/out/concepts/EnumItem__.js +6 -6
- package/out/concepts/Enum__.d.ts +20 -19
- package/out/concepts/Enum__.js +28 -1
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/ExternalDestination__.d.ts +1 -0
- package/out/concepts/ExternalDestination__.js +21 -3
- package/out/concepts/ExternalDestination__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +2 -0
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Frontend__.d.ts +2 -1
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/Identifier__.js +16 -5
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/InterfaceParam__.js +9 -1
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/JSBlock__.js +5 -1
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +79 -79
- package/out/concepts/Logic__.js +16 -3
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Match__.d.ts +0 -3
- package/out/concepts/Match__.js +11 -66
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/MemberExpression__.js +9 -0
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.d.ts +16 -0
- package/out/concepts/Module__.js +43 -0
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/NewComposite__.d.ts +2 -4
- package/out/concepts/NewComposite__.js +91 -126
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/NewList__.d.ts +1 -0
- package/out/concepts/NewList__.js +22 -2
- package/out/concepts/NewList__.js.map +1 -1
- package/out/concepts/NewMap__.d.ts +1 -0
- package/out/concepts/NewMap__.js +43 -11
- package/out/concepts/NewMap__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.js +40 -12
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/Param__.js +10 -2
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +2 -1
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/ProcessOutcome__.js +1 -1
- package/out/concepts/ProcessOutcome__.js.map +1 -1
- package/out/concepts/ProcessOutcomes__.js +1 -1
- package/out/concepts/ProcessOutcomes__.js.map +1 -1
- package/out/concepts/Process__.js +1 -0
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/Return__.js +10 -2
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/StringInterpolation__.js +14 -2
- package/out/concepts/StringInterpolation__.js.map +1 -1
- package/out/concepts/StringLiteral__.js +6 -6
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.js +9 -1
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +6 -3
- package/out/concepts/TypeAnnotation__.js +67 -13
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/ValidationRule__.d.ts +1 -0
- package/out/concepts/ValidationRule__.js +53 -0
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.js +9 -1
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.js +17 -1
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +1 -3
- package/out/concepts/View__.js +22 -11
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.collection.js +6 -1
- package/out/concepts/basics/stdlib/nasl.collection.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.configuration.js +3 -0
- package/out/concepts/basics/stdlib/nasl.configuration.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.core.d.ts +2 -0
- package/out/concepts/basics/stdlib/nasl.core.js +34 -0
- package/out/concepts/basics/stdlib/nasl.core.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +4 -2
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/basics/types/index.d.ts +1 -0
- package/out/concepts/basics/types/index.js +3 -1
- package/out/concepts/basics/types/index.js.map +1 -1
- package/out/concepts/index__.d.ts +0 -1
- package/out/concepts/index__.js +0 -1
- package/out/concepts/index__.js.map +1 -1
- package/out/enums/KEYWORDS.js +8 -0
- package/out/enums/KEYWORDS.js.map +1 -1
- package/out/generator/genBundleFiles.js +24 -5
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genReleaseBody.d.ts +2 -3
- package/out/generator/genReleaseBody.js +97 -23
- package/out/generator/genReleaseBody.js.map +1 -1
- package/out/generator/permission.d.ts +2 -10
- package/out/generator/permission.js +27 -14
- package/out/generator/permission.js.map +1 -1
- package/out/server/entity2LogicNamespace.js +2 -20
- package/out/server/entity2LogicNamespace.js.map +1 -1
- package/out/server/extendBaseNode.js +16 -5
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/formatTsUtils.d.ts +2 -1
- package/out/server/formatTsUtils.js +40 -10
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getLogics.d.ts +2 -2
- package/out/server/getLogics.js +3 -3
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.d.ts +1 -0
- package/out/server/getMemberIdentifier.js +27 -1
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/index.js +1 -0
- package/out/server/index.js.map +1 -1
- package/out/server/naslServer.d.ts +7 -1
- package/out/server/naslServer.js +519 -46
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +109 -33
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.js +21 -1
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +1 -3
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +1 -3
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +2 -4
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +1 -1
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +2 -2
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +7 -1
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genSelectBlock.js +1 -1
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +2 -2
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +2 -3
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/utils/traverse.js +8 -2
- package/out/utils/traverse.js.map +1 -1
- package/package.json +2 -2
- package/sandbox/stdlib/dist/nasl.logging.js +0 -0
- package/sandbox/stdlib/dist/nasl.util.js +0 -0
- package/sandbox/stdlib/nasl.collection.ts +1 -0
- package/sandbox/stdlib/nasl.core.ts +34 -0
- package/sandbox/stdlib/nasl.oql.ts +71 -15
- package/sandbox/stdlib/nasl.util.ts +9 -3
- package/src/automate/engine/dist/index.dev.js +517 -0
- package/src/automate/engine/index.js +2 -3
- package/src/automate/engine/uniqueName.js +2 -2
- package/src/automate/engine/utils.js +4 -2
- package/src/automate/template/myProcess.js +2 -2
- package/src/bak/translator.js +16 -25
- package/src/common/BaseNode.ts +3 -1
- package/src/common/Command.ts +4 -0
- package/src/common/dist/BaseNode.js +1101 -0
- package/src/concepts/App__.ts +36 -7
- package/src/concepts/Assignee__.ts +4 -3
- package/src/concepts/BatchAssignment__.ts +3 -3
- package/src/concepts/BindAttribute__.ts +299 -38
- package/src/concepts/BindDirective__.ts +204 -31
- package/src/concepts/BindStyle__.ts +187 -24
- package/src/concepts/CallFunction__.ts +55 -10
- package/src/concepts/CallInterface__.ts +3 -2
- package/src/concepts/CallLogic__.ts +110 -90
- package/src/concepts/CallQueryComponent__.ts +18 -3
- package/src/concepts/ConfigGroup__.ts +17 -4
- package/src/concepts/ConfigProperty__.ts +70 -4
- package/src/concepts/Configuration__.ts +14 -5
- package/src/concepts/DataSource__.ts +4 -1
- package/src/concepts/Destination__.ts +61 -7
- package/src/concepts/EntityProperty__.ts +7 -1
- package/src/concepts/EnumItem__.ts +6 -6
- package/src/concepts/Enum__.ts +22 -19
- package/src/concepts/ExternalDestination__.ts +28 -8
- package/src/concepts/ForEachStatement__.ts +2 -0
- package/src/concepts/Frontend__.ts +2 -1
- package/src/concepts/Identifier__.ts +16 -5
- package/src/concepts/InterfaceParam__.ts +7 -1
- package/src/concepts/JSBlock__.ts +3 -2
- package/src/concepts/Logic__.ts +95 -83
- package/src/concepts/Match__.ts +31 -67
- package/src/concepts/MemberExpression__.ts +6 -0
- package/src/concepts/Module__.ts +57 -0
- package/src/concepts/NewComposite__.ts +95 -140
- package/src/concepts/NewList__.ts +23 -2
- package/src/concepts/NewMap__.ts +48 -24
- package/src/concepts/OqlQueryComponent__.ts +40 -20
- package/src/concepts/Param__.ts +178 -176
- package/src/concepts/ProcessElement__.ts +2 -1
- package/src/concepts/ProcessOutcome__.ts +1 -1
- package/src/concepts/ProcessOutcomes__.ts +1 -1
- package/src/concepts/Process__.ts +1 -0
- package/src/concepts/Return__.ts +8 -2
- package/src/concepts/StringInterpolation__.ts +19 -7
- package/src/concepts/StringLiteral__.ts +7 -6
- package/src/concepts/StructureProperty__.ts +7 -1
- package/src/concepts/TypeAnnotation__.ts +101 -14
- package/src/concepts/ValidationRule__.ts +58 -9
- package/src/concepts/Variable__.ts +11 -1
- package/src/concepts/ViewElement__.ts +39 -2
- package/src/concepts/View__.ts +26 -14
- package/src/concepts/basics/stdlib/dist/nasl.util.js +1602 -0
- package/src/concepts/basics/stdlib/dist/reference2TypeAnnotationList.js +24 -0
- package/src/concepts/basics/stdlib/nasl.collection.ts +6 -1
- package/src/concepts/basics/stdlib/nasl.configuration.ts +3 -0
- package/src/concepts/basics/stdlib/nasl.core.ts +33 -2
- package/src/concepts/basics/stdlib/nasl.util.ts +4 -2
- package/src/concepts/basics/types/index.ts +1 -0
- package/src/concepts/dist/BindAttribute__.js +795 -0
- package/src/concepts/dist/BindEvent__.js +732 -0
- package/src/concepts/dist/CallFunction__.js +527 -0
- package/src/concepts/dist/CallLogic__.js +932 -0
- package/src/concepts/dist/Destination__.js +708 -0
- package/src/concepts/dist/ExternalDestination__.js +298 -0
- package/src/concepts/dist/Identifier__.js +311 -0
- package/src/concepts/dist/StringInterpolation__.js +231 -0
- package/src/concepts/dist/TypeAnnotation__.js +834 -0
- package/src/concepts/dist/ViewElement__.js +1692 -0
- package/src/concepts/dist/View__.js +1601 -0
- package/src/concepts/index__.ts +0 -1
- package/src/enums/KEYWORDS.ts +8 -0
- package/src/generator/dist/genBundleFiles.js +261 -0
- package/src/generator/dist/genMetaData.js +245 -0
- package/src/generator/dist/permission.js +405 -0
- package/src/generator/genBundleFiles.ts +24 -5
- package/src/generator/genReleaseBody.ts +75 -30
- package/src/generator/permission.ts +31 -15
- package/src/server/entity2LogicNamespace.ts +2 -20
- package/src/server/extendBaseNode.ts +15 -5
- package/src/server/formatTsUtils.ts +41 -10
- package/src/server/getLogics.ts +4 -4
- package/src/server/getMemberIdentifier.ts +27 -1
- package/src/server/index.ts +2 -0
- package/src/server/naslServer.ts +520 -48
- package/src/server/translator.ts +96 -34
- package/src/service/storage/dist/init.js +579 -0
- package/src/service/storage/init.ts +22 -2
- package/src/templator/dist/genEditTableBlock.js +204 -0
- package/src/templator/dist/genGridViewBlock.js +265 -0
- package/src/templator/dist/genListViewBlock.js +84 -0
- package/src/templator/dist/genTableBlock.js +209 -0
- package/src/templator/dist/utils.js +527 -0
- package/src/templator/genCreateBlock.ts +1 -3
- package/src/templator/genCurdEditMultipleKeyBlock.ts +1 -3
- package/src/templator/genCurdMultipleKeyBlock.ts +2 -4
- package/src/templator/genGetBlock.ts +1 -1
- package/src/templator/genGridViewBlock.ts +3 -4
- package/src/templator/genListViewBlock.ts +9 -3
- package/src/templator/genSelectBlock.ts +1 -1
- package/src/templator/genTableBlock.ts +3 -3
- package/src/templator/genUpdateBlock.ts +2 -3
- package/src/utils/traverse.ts +10 -2
- package/ts-worker/lib/tsserver.js +10 -2
- package/ts-worker/package.json +1 -0
- package/ts-worker/webpack.config.js +11 -2
- package/out/concepts/ConstructArgument__.d.ts +0 -40
- package/out/concepts/ConstructArgument__.js +0 -108
- package/out/concepts/ConstructArgument__.js.map +0 -1
- package/out/concepts/Construct__.d.ts +0 -189
- package/out/concepts/Construct__.js +0 -340
- package/out/concepts/Construct__.js.map +0 -1
- package/out/templator/sql-parser/index.d.ts +0 -1
- package/out/templator/sql-parser/index.js +0 -228
- package/out/templator/sql-parser/index.js.map +0 -1
- package/out/templator/sql-parser/parser.js +0 -26664
- package/out/templator/sql-parser/parser.js.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TranslatorState, shiftState, withSourceMap } from '../translator';
|
|
2
2
|
import { ElementToVueOptions } from './ViewElement__';
|
|
3
|
+
import MemberExpression from './MemberExpression__';
|
|
3
4
|
//================================================================================
|
|
4
5
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
5
6
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -147,10 +148,6 @@ export class BindDirective extends BaseNode {
|
|
|
147
148
|
});
|
|
148
149
|
}
|
|
149
150
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
151
|
/**
|
|
155
152
|
* 插入逻辑项
|
|
156
153
|
* @internal
|
|
@@ -183,8 +180,6 @@ export class BindDirective extends BaseNode {
|
|
|
183
180
|
return logicItem;
|
|
184
181
|
}
|
|
185
182
|
|
|
186
|
-
|
|
187
|
-
|
|
188
183
|
/**
|
|
189
184
|
* 插入逻辑项
|
|
190
185
|
* @param logicItemOptions 逻辑项参数
|
|
@@ -207,8 +202,6 @@ export class BindDirective extends BaseNode {
|
|
|
207
202
|
return node;
|
|
208
203
|
}
|
|
209
204
|
|
|
210
|
-
|
|
211
|
-
|
|
212
205
|
/**
|
|
213
206
|
* 添加逻辑项
|
|
214
207
|
* @internal
|
|
@@ -228,8 +221,6 @@ export class BindDirective extends BaseNode {
|
|
|
228
221
|
return this._insertItemInPlaygroundAt(options as any, index);
|
|
229
222
|
}
|
|
230
223
|
|
|
231
|
-
|
|
232
|
-
|
|
233
224
|
/**
|
|
234
225
|
* 添加逻辑项
|
|
235
226
|
* @param logicItemOptions 逻辑项参数
|
|
@@ -253,9 +244,6 @@ export class BindDirective extends BaseNode {
|
|
|
253
244
|
return node;
|
|
254
245
|
}
|
|
255
246
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
247
|
/**
|
|
260
248
|
* 删除逻辑项
|
|
261
249
|
* @param name 逻辑项名称
|
|
@@ -281,8 +269,6 @@ export class BindDirective extends BaseNode {
|
|
|
281
269
|
return expression.delete();
|
|
282
270
|
}
|
|
283
271
|
|
|
284
|
-
|
|
285
|
-
|
|
286
272
|
/**
|
|
287
273
|
* 删除逻辑项
|
|
288
274
|
* @param logicItem 已有的逻辑项实例
|
|
@@ -290,7 +276,7 @@ export class BindDirective extends BaseNode {
|
|
|
290
276
|
removeItemInPlayground(logicItem: LogicItem): void;
|
|
291
277
|
|
|
292
278
|
removeItemInPlayground(options: LogicItem) {
|
|
293
|
-
|
|
279
|
+
const logicItem: LogicItem = options;
|
|
294
280
|
return logicItem.delete();
|
|
295
281
|
}
|
|
296
282
|
|
|
@@ -335,25 +321,192 @@ export class BindDirective extends BaseNode {
|
|
|
335
321
|
});
|
|
336
322
|
}
|
|
337
323
|
|
|
324
|
+
// 属性上绑定的表达式
|
|
325
|
+
get bindExpressions() {
|
|
326
|
+
return [this.expression];
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// 是否需要用标识符替换
|
|
330
|
+
get needReplaceWithIdentifier() {
|
|
331
|
+
let bindExpression = false;
|
|
332
|
+
if (this.expression) {
|
|
333
|
+
let rootMemberExpression: any;
|
|
334
|
+
let tempNode = this.expression;
|
|
335
|
+
while (tempNode?.concept === 'MemberExpression') {
|
|
336
|
+
rootMemberExpression = tempNode;
|
|
337
|
+
tempNode = (tempNode as MemberExpression)?.object;
|
|
338
|
+
}
|
|
339
|
+
// 变量和变量的成员表达式不进行替换
|
|
340
|
+
if (
|
|
341
|
+
!(
|
|
342
|
+
this.expression?.concept === 'Identifier'
|
|
343
|
+
|| (rootMemberExpression && rootMemberExpression.object?.concept === 'Identifier')
|
|
344
|
+
)
|
|
345
|
+
&& (this.type === 'dynamic' || (this.name === 'rules' && (this as any).rules))
|
|
346
|
+
) {
|
|
347
|
+
bindExpression = true;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return bindExpression;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// 获取表达式在页面中的名字
|
|
354
|
+
get expressionNameInView() {
|
|
355
|
+
const nameList: string[] = [];
|
|
356
|
+
let node: BaseNode = this;
|
|
357
|
+
while (node) {
|
|
358
|
+
nameList.unshift(node.name);
|
|
359
|
+
if (node.concept === 'ViewElement') {
|
|
360
|
+
node = null;
|
|
361
|
+
} else {
|
|
362
|
+
nameList.unshift(node.parentKey);
|
|
363
|
+
node = node.parentNode;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
return nameList.join('_').replace(/-/g, '_');
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// 获取表达式生成器名称
|
|
370
|
+
get expressionBuilderName() {
|
|
371
|
+
let expressionInViewName = this.expressionNameInView;
|
|
372
|
+
expressionInViewName = expressionInViewName.charAt(0).toUpperCase() + expressionInViewName.slice(1);
|
|
373
|
+
return `gen${expressionInViewName}`;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// 获取参数列表
|
|
377
|
+
getArgsList() {
|
|
378
|
+
const viewElement = this?.getAncestor('ViewElement');
|
|
379
|
+
const argsList = [];
|
|
380
|
+
let parent = viewElement?.parentNode;
|
|
381
|
+
let index = 0;
|
|
382
|
+
while (parent && parent.concept !== 'View') {
|
|
383
|
+
if ((parent as ViewElement).slotScope) {
|
|
384
|
+
argsList.unshift(index === 0 ? 'current' : 'current' + index);
|
|
385
|
+
index++;
|
|
386
|
+
}
|
|
387
|
+
parent = parent.parentNode;
|
|
388
|
+
}
|
|
389
|
+
return argsList;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// 表达式中需要被监听的变量
|
|
393
|
+
get watchedVariableMap() {
|
|
394
|
+
const map: any = {};
|
|
395
|
+
// 页面中表达式用到的变量需要监听,从而重新执行match表达式
|
|
396
|
+
utils.traverse((current: any) => {
|
|
397
|
+
const { node } = current || {};
|
|
398
|
+
const { concept } = node || {};
|
|
399
|
+
if (['Identifier'].includes(concept)) {
|
|
400
|
+
let expressionNode = node;
|
|
401
|
+
let memberExpressionNode = node?.parentNode;
|
|
402
|
+
while (memberExpressionNode?.concept === 'MemberExpression') {
|
|
403
|
+
expressionNode = memberExpressionNode;
|
|
404
|
+
const { concept: objConcept } = memberExpressionNode.object || {};
|
|
405
|
+
if (!['MemberExpression', 'Identifier'].includes(objConcept)) {
|
|
406
|
+
memberExpressionNode = null;
|
|
407
|
+
expressionNode = null;
|
|
408
|
+
} else {
|
|
409
|
+
memberExpressionNode = memberExpressionNode.object;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
if (expressionNode) {
|
|
413
|
+
map[expressionNode.toJS()] = true;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}, {
|
|
417
|
+
node: this,
|
|
418
|
+
}, {
|
|
419
|
+
mode: 'anyObject',
|
|
420
|
+
excludedKeySet: new Set([
|
|
421
|
+
'parentNode',
|
|
422
|
+
'sourceMap',
|
|
423
|
+
'storageJSON',
|
|
424
|
+
'tsErrorDetail',
|
|
425
|
+
'NaslAnnotatedJSON',
|
|
426
|
+
'calledFrom',
|
|
427
|
+
'_events',
|
|
428
|
+
'_collectingList',
|
|
429
|
+
'_historyList',
|
|
430
|
+
]),
|
|
431
|
+
});
|
|
432
|
+
return map;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
getInViewMethod(state?: TranslatorState) {
|
|
436
|
+
const argsList = this.getArgsList() || [];
|
|
437
|
+
const hasArgs = !!argsList.length;
|
|
438
|
+
let argStr = '';
|
|
439
|
+
|
|
440
|
+
// 容错代码
|
|
441
|
+
let ftCode = '';
|
|
442
|
+
if (hasArgs) {
|
|
443
|
+
argsList.forEach((arg) => {
|
|
444
|
+
ftCode += `if (!this.${this.expressionNameInView}${argStr}) {
|
|
445
|
+
this.${this.expressionNameInView}${argStr} = {};
|
|
446
|
+
}\n`;
|
|
447
|
+
argStr += `[${arg}.hasOwnProperty('__nodeKey') ? ${arg}.__nodeKey : ${arg}.index]`;
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
ftCode += `if (!this.${this.expressionNameInView}${argStr}) {
|
|
451
|
+
this.${this.expressionNameInView}${argStr} = {};
|
|
452
|
+
}`;
|
|
453
|
+
|
|
454
|
+
// 新的参数
|
|
455
|
+
const paramList = Object.keys(this.watchedVariableMap);
|
|
456
|
+
let newParams = `const newParams = [];`;
|
|
457
|
+
if (Array.isArray(paramList) && paramList.length) {
|
|
458
|
+
paramList.forEach((param) => {
|
|
459
|
+
newParams += `newParams.push(${param});\n`;
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// 表达式主体
|
|
464
|
+
let expressionStr = '';
|
|
465
|
+
if (this.type === 'dynamic') {
|
|
466
|
+
expressionStr = this.expression?.toJS() || '';
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// 变量重新设置,为了触发重新调用
|
|
470
|
+
let setVarStr = `this.${this.expressionNameInView}${argStr} = {
|
|
471
|
+
...(this.${this.expressionNameInView}${argStr} || {}),
|
|
472
|
+
value: value,
|
|
473
|
+
};`;
|
|
474
|
+
if (Array.isArray(argsList) && argsList.length) {
|
|
475
|
+
setVarStr += `this.${this.expressionNameInView} = {...this.${this.expressionNameInView}};\n`;
|
|
476
|
+
}
|
|
477
|
+
const code = `${this.expressionBuilderName} (${argsList.join(', ')}) {
|
|
478
|
+
// 容错代码
|
|
479
|
+
${ftCode}
|
|
480
|
+
(async () => {
|
|
481
|
+
// 旧的参数
|
|
482
|
+
const oldParams = this.${this.expressionNameInView}${argStr}.params;
|
|
483
|
+
// 新的参数
|
|
484
|
+
${newParams}
|
|
485
|
+
const isLooseEqual = this.$isLooseEqualFn(oldParams, newParams);
|
|
486
|
+
if (!isLooseEqual) {
|
|
487
|
+
this.${this.expressionNameInView}${argStr}.params = newParams;
|
|
488
|
+
const value = ${expressionStr};
|
|
489
|
+
${setVarStr}
|
|
490
|
+
}
|
|
491
|
+
})();
|
|
492
|
+
return this.${this.expressionNameInView}${argStr}.value;
|
|
493
|
+
}`;
|
|
494
|
+
|
|
495
|
+
return code;
|
|
496
|
+
}
|
|
497
|
+
|
|
338
498
|
/**
|
|
339
499
|
* 转换成 Vue 的模板格式
|
|
340
500
|
*/
|
|
341
501
|
toVue(options?: ElementToVueOptions) {
|
|
342
|
-
let
|
|
343
|
-
let modifiers = {};
|
|
344
|
-
try {
|
|
345
|
-
modifiers = JSON.parse(this.modifiers || '{}');
|
|
346
|
-
} catch (err) {
|
|
347
|
-
modifiers = {};
|
|
348
|
-
}
|
|
349
|
-
Object.keys(modifiers).forEach((key) => {
|
|
350
|
-
const value = (modifiers as any)[key];
|
|
351
|
-
if (value)
|
|
352
|
-
modifiersString += '.' + key;
|
|
353
|
-
});
|
|
502
|
+
let str = '';
|
|
354
503
|
// eslint-disable-next-line no-nested-ternary
|
|
355
504
|
let value = (this.type ?? 'string') !== 'string' ? this.value : this.value ? `'${this.value}'` : '';
|
|
356
|
-
|
|
505
|
+
// 需要用标识符替换
|
|
506
|
+
if (options.finalCode !== false && this.needReplaceWithIdentifier) {
|
|
507
|
+
const argsList = this.getArgsList();
|
|
508
|
+
value = `${this.expressionBuilderName}(${argsList.join(', ')})`;
|
|
509
|
+
} else if (this.expression) {
|
|
357
510
|
value = this.expression.toVue(options);
|
|
358
511
|
if (this.expression.concept === 'StringLiteral') {
|
|
359
512
|
value = `${value}`;
|
|
@@ -376,13 +529,33 @@ export class BindDirective extends BaseNode {
|
|
|
376
529
|
if (isElement) {
|
|
377
530
|
pathArr = [...pathArr, ...paths.slice(-1)];
|
|
378
531
|
}
|
|
379
|
-
|
|
532
|
+
// 数组的第一个是端名称
|
|
533
|
+
pathArr.shift();
|
|
534
|
+
let _path = pathArr.reduce((str, item) => {
|
|
380
535
|
const c = item.match(regex1);
|
|
381
536
|
return str + '/' + c[1];
|
|
382
537
|
}, '');
|
|
538
|
+
if (this.frontend && this.frontend.basePath) {
|
|
539
|
+
_path = `${this.frontend.basePath}${_path}`;
|
|
540
|
+
}
|
|
383
541
|
value = `'${_path}'`;
|
|
384
542
|
}
|
|
385
|
-
|
|
543
|
+
let modifiersString = '';
|
|
544
|
+
let modifiers = {};
|
|
545
|
+
try {
|
|
546
|
+
modifiers = JSON.parse(this.modifiers || '{}');
|
|
547
|
+
} catch (err) {
|
|
548
|
+
modifiers = {};
|
|
549
|
+
}
|
|
550
|
+
Object.keys(modifiers).forEach((key) => {
|
|
551
|
+
const value = (modifiers as any)[key];
|
|
552
|
+
if (value)
|
|
553
|
+
modifiersString += '.' + key;
|
|
554
|
+
});
|
|
555
|
+
if (value !== '' && value !== undefined && value !== null) {
|
|
556
|
+
str += `v-${this.name}${modifiersString}${this.arg ? ':' + this.arg : ''}="${value}"`;
|
|
557
|
+
}
|
|
558
|
+
return str;
|
|
386
559
|
}
|
|
387
560
|
|
|
388
561
|
@withSourceMap()
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TranslatorState, shiftState, withSourceMap } from '../translator';
|
|
2
2
|
import { ElementToVueOptions } from './ViewElement__';
|
|
3
|
+
import MemberExpression from './MemberExpression__';
|
|
3
4
|
//================================================================================
|
|
4
5
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
5
6
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -117,10 +118,6 @@ export class BindStyle extends BaseNode {
|
|
|
117
118
|
});
|
|
118
119
|
}
|
|
119
120
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
121
|
/**
|
|
125
122
|
* 插入逻辑项
|
|
126
123
|
* @internal
|
|
@@ -153,8 +150,6 @@ export class BindStyle extends BaseNode {
|
|
|
153
150
|
return logicItem;
|
|
154
151
|
}
|
|
155
152
|
|
|
156
|
-
|
|
157
|
-
|
|
158
153
|
/**
|
|
159
154
|
* 插入逻辑项
|
|
160
155
|
* @param logicItemOptions 逻辑项参数
|
|
@@ -177,8 +172,6 @@ export class BindStyle extends BaseNode {
|
|
|
177
172
|
return node;
|
|
178
173
|
}
|
|
179
174
|
|
|
180
|
-
|
|
181
|
-
|
|
182
175
|
/**
|
|
183
176
|
* 添加逻辑项
|
|
184
177
|
* @internal
|
|
@@ -198,8 +191,6 @@ export class BindStyle extends BaseNode {
|
|
|
198
191
|
return this._insertItemInPlaygroundAt(options as any, index);
|
|
199
192
|
}
|
|
200
193
|
|
|
201
|
-
|
|
202
|
-
|
|
203
194
|
/**
|
|
204
195
|
* 添加逻辑项
|
|
205
196
|
* @param logicItemOptions 逻辑项参数
|
|
@@ -223,9 +214,6 @@ export class BindStyle extends BaseNode {
|
|
|
223
214
|
return node;
|
|
224
215
|
}
|
|
225
216
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
217
|
/**
|
|
230
218
|
* 删除逻辑项
|
|
231
219
|
* @param name 逻辑项名称
|
|
@@ -251,8 +239,6 @@ export class BindStyle extends BaseNode {
|
|
|
251
239
|
return expression.delete();
|
|
252
240
|
}
|
|
253
241
|
|
|
254
|
-
|
|
255
|
-
|
|
256
242
|
/**
|
|
257
243
|
* 删除逻辑项
|
|
258
244
|
* @param logicItem 已有的逻辑项实例
|
|
@@ -260,7 +246,7 @@ export class BindStyle extends BaseNode {
|
|
|
260
246
|
removeItemInPlayground(logicItem: LogicItem): void;
|
|
261
247
|
|
|
262
248
|
removeItemInPlayground(options: LogicItem) {
|
|
263
|
-
|
|
249
|
+
const logicItem: LogicItem = options;
|
|
264
250
|
return logicItem.delete();
|
|
265
251
|
}
|
|
266
252
|
|
|
@@ -292,19 +278,196 @@ export class BindStyle extends BaseNode {
|
|
|
292
278
|
// 自动生成的代码已结束。下面可以手动编写。
|
|
293
279
|
//================================================================================
|
|
294
280
|
|
|
281
|
+
// 属性上绑定的表达式
|
|
282
|
+
get bindExpressions() {
|
|
283
|
+
return [this.expression];
|
|
284
|
+
}
|
|
295
285
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
286
|
+
// 是否需要用标识符替换
|
|
287
|
+
get needReplaceWithIdentifier() {
|
|
288
|
+
let bindExpression = false;
|
|
289
|
+
if (this.expression) {
|
|
290
|
+
let rootMemberExpression: any;
|
|
291
|
+
let tempNode = this.expression;
|
|
292
|
+
while (tempNode?.concept === 'MemberExpression') {
|
|
293
|
+
rootMemberExpression = tempNode;
|
|
294
|
+
tempNode = (tempNode as MemberExpression)?.object;
|
|
295
|
+
}
|
|
296
|
+
// 变量和变量的成员表达式不进行替换
|
|
297
|
+
if (
|
|
298
|
+
!(
|
|
299
|
+
this.expression?.concept === 'Identifier'
|
|
300
|
+
|| (rootMemberExpression && rootMemberExpression.object?.concept === 'Identifier')
|
|
301
|
+
)
|
|
302
|
+
) {
|
|
303
|
+
bindExpression = true;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
return bindExpression;
|
|
307
|
+
}
|
|
301
308
|
|
|
302
|
-
|
|
303
|
-
|
|
309
|
+
// 获取表达式在页面中的名字
|
|
310
|
+
get expressionNameInView() {
|
|
311
|
+
const nameList: string[] = [];
|
|
312
|
+
let node: BaseNode = this;
|
|
313
|
+
while (node) {
|
|
314
|
+
nameList.unshift(node.name);
|
|
315
|
+
if (node.concept === 'ViewElement') {
|
|
316
|
+
node = null;
|
|
317
|
+
} else {
|
|
318
|
+
nameList.unshift(node.parentKey);
|
|
319
|
+
node = node.parentNode;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return nameList.join('_').replace(/-/g, '_');
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// 获取表达式生成器名称
|
|
326
|
+
get expressionBuilderName() {
|
|
327
|
+
let expressionInViewName = this.expressionNameInView;
|
|
328
|
+
expressionInViewName = expressionInViewName.charAt(0).toUpperCase() + expressionInViewName.slice(1);
|
|
329
|
+
return `gen${expressionInViewName}`;
|
|
330
|
+
}
|
|
304
331
|
|
|
332
|
+
// 获取参数列表
|
|
333
|
+
getArgsList() {
|
|
334
|
+
const viewElement = this?.getAncestor('ViewElement');
|
|
335
|
+
const argsList = [];
|
|
336
|
+
let parent = viewElement?.parentNode;
|
|
337
|
+
let index = 0;
|
|
338
|
+
while (parent && parent.concept !== 'View') {
|
|
339
|
+
if ((parent as ViewElement).slotScope) {
|
|
340
|
+
argsList.unshift(index === 0 ? 'current' : 'current' + index);
|
|
341
|
+
index++;
|
|
342
|
+
}
|
|
343
|
+
parent = parent.parentNode;
|
|
344
|
+
}
|
|
345
|
+
return argsList;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// 表达式中需要被监听的变量
|
|
349
|
+
get watchedVariableMap() {
|
|
350
|
+
const map: any = {};
|
|
351
|
+
// 页面中表达式用到的变量需要监听,从而重新执行match表达式
|
|
352
|
+
utils.traverse((current: any) => {
|
|
353
|
+
const { node } = current || {};
|
|
354
|
+
const { concept } = node || {};
|
|
355
|
+
if (['Identifier'].includes(concept)) {
|
|
356
|
+
let expressionNode = node;
|
|
357
|
+
let memberExpressionNode = node?.parentNode;
|
|
358
|
+
while (memberExpressionNode?.concept === 'MemberExpression') {
|
|
359
|
+
expressionNode = memberExpressionNode;
|
|
360
|
+
const { concept: objConcept } = memberExpressionNode.object || {};
|
|
361
|
+
if (!['MemberExpression', 'Identifier'].includes(objConcept)) {
|
|
362
|
+
memberExpressionNode = null;
|
|
363
|
+
expressionNode = null;
|
|
364
|
+
} else {
|
|
365
|
+
memberExpressionNode = memberExpressionNode.object;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
if (expressionNode) {
|
|
369
|
+
map[expressionNode.toJS()] = true;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}, {
|
|
373
|
+
node: this,
|
|
374
|
+
}, {
|
|
375
|
+
mode: 'anyObject',
|
|
376
|
+
excludedKeySet: new Set([
|
|
377
|
+
'parentNode',
|
|
378
|
+
'sourceMap',
|
|
379
|
+
'storageJSON',
|
|
380
|
+
'tsErrorDetail',
|
|
381
|
+
'NaslAnnotatedJSON',
|
|
382
|
+
'calledFrom',
|
|
383
|
+
'_events',
|
|
384
|
+
'_collectingList',
|
|
385
|
+
'_historyList',
|
|
386
|
+
]),
|
|
387
|
+
});
|
|
388
|
+
return map;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
getInViewMethod(state?: TranslatorState) {
|
|
392
|
+
const argsList = this.getArgsList() || [];
|
|
393
|
+
const hasArgs = !!argsList.length;
|
|
394
|
+
let argStr = '';
|
|
395
|
+
|
|
396
|
+
// 容错代码
|
|
397
|
+
let ftCode = '';
|
|
398
|
+
if (hasArgs) {
|
|
399
|
+
argsList.forEach((arg) => {
|
|
400
|
+
ftCode += `if (!this.${this.expressionNameInView}${argStr}) {
|
|
401
|
+
this.${this.expressionNameInView}${argStr} = {};
|
|
402
|
+
}\n`;
|
|
403
|
+
argStr += `[${arg}.hasOwnProperty('__nodeKey') ? ${arg}.__nodeKey : ${arg}.index]`;
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
ftCode += `if (!this.${this.expressionNameInView}${argStr}) {
|
|
407
|
+
this.${this.expressionNameInView}${argStr} = {};
|
|
408
|
+
}`;
|
|
409
|
+
|
|
410
|
+
// 新的参数
|
|
411
|
+
const paramList = Object.keys(this.watchedVariableMap);
|
|
412
|
+
let newParams = `const newParams = [];`;
|
|
413
|
+
if (Array.isArray(paramList) && paramList.length) {
|
|
414
|
+
paramList.forEach((param) => {
|
|
415
|
+
newParams += `newParams.push(${param});\n`;
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// 表达式主体
|
|
420
|
+
let expressionStr = this.expression?.toJS() || '';
|
|
421
|
+
if (this.name?.endsWith('background-image') && expressionStr)
|
|
422
|
+
expressionStr = `\`url(\${${expressionStr}})\``;
|
|
423
|
+
|
|
424
|
+
// 变量重新设置,为了触发重新调用
|
|
425
|
+
let setVarStr = `this.${this.expressionNameInView}${argStr} = {
|
|
426
|
+
...(this.${this.expressionNameInView}${argStr} || {}),
|
|
427
|
+
value: value,
|
|
428
|
+
};`;
|
|
429
|
+
if (Array.isArray(argsList) && argsList.length) {
|
|
430
|
+
setVarStr += `this.${this.expressionNameInView} = {...this.${this.expressionNameInView}};\n`;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
const code = `${this.expressionBuilderName} (${argsList.join(', ')}) {
|
|
434
|
+
// 容错代码
|
|
435
|
+
${ftCode}
|
|
436
|
+
(async () => {
|
|
437
|
+
// 旧的参数
|
|
438
|
+
const oldParams = this.${this.expressionNameInView}${argStr}.params;
|
|
439
|
+
// 新的参数
|
|
440
|
+
${newParams}
|
|
441
|
+
const isLooseEqual = this.$isLooseEqualFn(oldParams, newParams);
|
|
442
|
+
if (!isLooseEqual) {
|
|
443
|
+
this.${this.expressionNameInView}${argStr}.params = newParams;
|
|
444
|
+
const value = ${expressionStr};
|
|
445
|
+
${setVarStr}
|
|
446
|
+
}
|
|
447
|
+
})();
|
|
448
|
+
return this.${this.expressionNameInView}${argStr}.value;
|
|
449
|
+
}`;
|
|
450
|
+
|
|
451
|
+
return code;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* 转换成 Vue 的模板格式
|
|
456
|
+
*/
|
|
457
|
+
toVue(options?: ElementToVueOptions) {
|
|
458
|
+
let value: string;
|
|
459
|
+
// 需要用标识符替换
|
|
460
|
+
if (options?.finalCode !== false && this.needReplaceWithIdentifier) {
|
|
461
|
+
const argsList = this.getArgsList();
|
|
462
|
+
value = `${this.expressionBuilderName} (${argsList.join(', ')})`;
|
|
463
|
+
} else {
|
|
464
|
+
value = this.expression?.toVue(options);
|
|
465
|
+
if (this.name?.endsWith('background-image') && value)
|
|
466
|
+
value = `\`url(\${${value}})\``;
|
|
467
|
+
}
|
|
305
468
|
return value && `'${this.name}': ${value}`;
|
|
306
469
|
}
|
|
307
|
-
|
|
470
|
+
|
|
308
471
|
@withSourceMap()
|
|
309
472
|
toEmbeddedTS(state?: TranslatorState): string {
|
|
310
473
|
let code = '()=>{';
|