@lcap/nasl 1.0.0-alpha.2 → 1.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/docs/assets/search.js +1 -1
- package/docs/classes/Entity.html +2832 -204
- package/docs/classes/View.html +4567 -365
- package/out/common/BaseNode.js +23 -16
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/App__.d.ts +22 -0
- package/out/concepts/App__.js +77 -15
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Argument__.d.ts +2 -1
- package/out/concepts/Argument__.js +2 -2
- package/out/concepts/Argument__.js.map +1 -1
- package/out/concepts/Assignment__.d.ts +2 -1
- package/out/concepts/Assignment__.js +3 -8
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/Attribute__.js.map +1 -1
- package/out/concepts/BinaryExpression__.d.ts +2 -1
- package/out/concepts/BinaryExpression__.js +5 -5
- package/out/concepts/BinaryExpression__.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts +2 -1
- package/out/concepts/BindAttribute__.js +9 -4
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.d.ts +2 -1
- package/out/concepts/BindDirective__.js +2 -2
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.d.ts +2 -1
- package/out/concepts/BindEvent__.js +4 -3
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.d.ts +2 -1
- package/out/concepts/BooleanLiteral__.js +1 -1
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/CallFunction__.d.ts +57 -1
- package/out/concepts/CallFunction__.js +119 -11
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.d.ts +2 -1
- package/out/concepts/CallInterface__.js +2 -2
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +57 -1
- package/out/concepts/CallLogic__.js +117 -10
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.js +1 -1
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Comment__.js.map +1 -1
- package/out/concepts/CompletionProperty__.js.map +1 -1
- package/out/concepts/ConfigGroup__.d.ts +120 -0
- package/out/concepts/ConfigGroup__.js +214 -0
- package/out/concepts/ConfigGroup__.js.map +1 -0
- package/out/concepts/ConfigPropertyValue__.d.ts +43 -0
- package/out/concepts/ConfigPropertyValue__.js +103 -0
- package/out/concepts/ConfigPropertyValue__.js.map +1 -0
- package/out/concepts/ConfigProperty__.d.ts +128 -0
- package/out/concepts/ConfigProperty__.js +236 -0
- package/out/concepts/ConfigProperty__.js.map +1 -0
- package/out/concepts/Configuration__.d.ts +120 -0
- package/out/concepts/Configuration__.js +210 -0
- package/out/concepts/Configuration__.js.map +1 -0
- package/out/concepts/Constant__.d.ts +2 -1
- package/out/concepts/Constant__.js +1 -1
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/DataElement__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +2 -1
- package/out/concepts/Destination__.js +4 -3
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityIndex__.d.ts +8 -0
- package/out/concepts/EntityIndex__.js +18 -0
- package/out/concepts/EntityIndex__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +5 -5
- package/out/concepts/EntityProperty__.js +10 -9
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +30 -26
- package/out/concepts/Entity__.js +44 -36
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/EnumItem__.js.map +1 -1
- package/out/concepts/Enum__.d.ts +8 -8
- package/out/concepts/Enum__.js +10 -4
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/Event__.js +1 -1
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/ForEachStatement__.d.ts +35 -33
- package/out/concepts/ForEachStatement__.js +103 -36
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Function__.js +1 -1
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.d.ts +2 -1
- package/out/concepts/Identifier__.js +15 -1
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/InterfaceParam__.js +1 -1
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/Interface__.d.ts +5 -1
- package/out/concepts/Interface__.js +19 -5
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +2 -1
- package/out/concepts/LogicItem__.js +2 -2
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.js +9 -7
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MemberExpression__.d.ts +2 -5
- package/out/concepts/MemberExpression__.js +12 -18
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.d.ts +121 -126
- package/out/concepts/Module__.js +10 -17
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/Namespace__.js +12 -12
- package/out/concepts/Namespace__.js.map +1 -1
- package/out/concepts/NullLiteral__.d.ts +2 -1
- package/out/concepts/NullLiteral__.js +1 -1
- package/out/concepts/NullLiteral__.js.map +1 -1
- package/out/concepts/NumericLiteral__.d.ts +2 -1
- package/out/concepts/NumericLiteral__.js +1 -1
- package/out/concepts/NumericLiteral__.js.map +1 -1
- package/out/concepts/Param__.d.ts +1 -1
- package/out/concepts/Param__.js +2 -2
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/Point__.js.map +1 -1
- package/out/concepts/ProcessComponent__.js +2 -2
- package/out/concepts/ProcessComponent__.js.map +1 -1
- package/out/concepts/ProcessElement__.d.ts +82 -81
- package/out/concepts/ProcessElement__.js +19 -6
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/ProcessOutcome__.js.map +1 -1
- package/out/concepts/Process__.d.ts +1 -0
- package/out/concepts/Process__.js +10 -4
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/QueryAggregateExpression__.js.map +1 -1
- package/out/concepts/QueryFieldExpression__.js +1 -1
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryGroupByExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.js +1 -1
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/QueryLimitExpression__.js.map +1 -1
- package/out/concepts/QueryOrderByExpression__.js.map +1 -1
- package/out/concepts/QuerySelectExpression__.js +1 -1
- package/out/concepts/QuerySelectExpression__.js.map +1 -1
- package/out/concepts/Rect__.js.map +1 -1
- package/out/concepts/Return__.d.ts +1 -1
- package/out/concepts/Return__.js +2 -2
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/Role__.d.ts +5 -0
- package/out/concepts/Role__.js +19 -2
- package/out/concepts/Role__.js.map +1 -1
- package/out/concepts/Slot__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.d.ts +2 -0
- package/out/concepts/SqlQueryComponent__.js +16 -0
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/Start__.js.map +1 -1
- package/out/concepts/StringLiteral__.d.ts +2 -1
- package/out/concepts/StringLiteral__.js +1 -1
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.d.ts +1 -1
- package/out/concepts/StructureProperty__.js +1 -1
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.d.ts +1 -1
- package/out/concepts/Structure__.js +4 -4
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SwitchCase__.js.map +1 -1
- package/out/concepts/SwitchStatement__.js.map +1 -1
- package/out/concepts/Theme__.js.map +1 -1
- package/out/concepts/Transactional__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.js +3 -0
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/UnaryExpression__.d.ts +2 -1
- package/out/concepts/UnaryExpression__.js +3 -3
- package/out/concepts/UnaryExpression__.js.map +1 -1
- package/out/concepts/Unparsed__.d.ts +2 -1
- package/out/concepts/Unparsed__.js +1 -1
- package/out/concepts/Unparsed__.js.map +1 -1
- package/out/concepts/UseComponent__.js.map +1 -1
- package/out/concepts/ValidationRule__.d.ts +2 -1
- package/out/concepts/ValidationRule__.js +2 -2
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.d.ts +6 -5
- package/out/concepts/Variable__.js +3 -3
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewComponent__.js +5 -5
- package/out/concepts/ViewComponent__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +5 -4
- package/out/concepts/ViewElement__.js +109 -65
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +97 -90
- package/out/concepts/View__.js +153 -118
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/concepts/basics/stdlib/index.js +2 -2
- package/out/concepts/basics/stdlib/index.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +3 -137
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +21 -5
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.validation.d.ts +3 -0
- package/out/concepts/basics/stdlib/nasl.validation.js +527 -0
- package/out/concepts/basics/stdlib/nasl.validation.js.map +1 -0
- package/out/concepts/index__.d.ts +4 -0
- package/out/concepts/index__.js +4 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/data/Module.d.ts +34 -0
- package/out/data/Module.js +53 -0
- package/out/data/Module.js.map +1 -0
- package/out/generator/compileComponent.d.ts +1 -1
- package/out/generator/genBundleFiles.d.ts +0 -1
- package/out/generator/genBundleFiles.js +1 -1
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.d.ts +35 -0
- package/out/generator/genMetaData.js +78 -0
- package/out/generator/genMetaData.js.map +1 -0
- package/out/generator/index.d.ts +1 -0
- package/out/generator/index.js +1 -0
- package/out/generator/index.js.map +1 -1
- package/out/index.d.ts +2 -2
- package/out/index.js +3 -1
- package/out/index.js.map +1 -1
- package/out/server/createUiTs.d.ts +7 -0
- package/out/server/createUiTs.js +157 -0
- package/out/server/createUiTs.js.map +1 -0
- package/out/server/entity2LogicNamespace.d.ts +9 -1
- package/out/server/entity2LogicNamespace.js +11 -1
- package/out/server/entity2LogicNamespace.js.map +1 -1
- package/out/server/getExtensionModules.d.ts +3 -0
- package/out/server/getExtensionModules.js +18 -0
- package/out/server/getExtensionModules.js.map +1 -0
- package/out/server/getLogics.js +18 -15
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.d.ts +3 -2
- package/out/server/getMemberIdentifier.js +47 -15
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.d.ts +4 -1
- package/out/server/getProcesses.js +16 -7
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/getValidates.js +1 -1
- package/out/server/getValidates.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 +23 -5
- package/out/server/naslServer.js +199 -25
- package/out/server/naslServer.js.map +1 -1
- package/out/server/process2LogicNamespace.d.ts +15 -1
- package/out/server/process2LogicNamespace.js +30 -3
- package/out/server/process2LogicNamespace.js.map +1 -1
- package/out/server/translator.js +28 -0
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.d.ts +5 -0
- package/out/service/storage/init.js +60 -52
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCallComponentLogic.js +2 -2
- package/out/templator/genCallComponentLogic.js.map +1 -1
- package/out/templator/genCreateBlock.js +6 -8
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +3 -3
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +4 -4
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.js +3 -3
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +1 -1
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +2 -2
- 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/genUpdateBlock.js +8 -12
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.d.ts +20 -20
- package/out/templator/utils.js +22 -22
- package/out/templator/utils.js.map +1 -1
- package/package.json +2 -1
- package/src/automate/engine/index.js +37 -3
- package/src/automate/engine/utils.js +68 -64
- package/src/common/BaseNode.ts +24 -17
- package/src/concepts/App__.ts +93 -17
- package/src/concepts/Argument__.ts +4 -2
- package/src/concepts/Assignment__.ts +5 -7
- package/src/concepts/Attribute__.ts +1 -0
- package/src/concepts/BinaryExpression__.ts +7 -5
- package/src/concepts/BindAttribute__.ts +9 -4
- package/src/concepts/BindDirective__.ts +4 -2
- package/src/concepts/BindEvent__.ts +6 -4
- package/src/concepts/BooleanLiteral__.ts +3 -1
- package/src/concepts/CallFunction__.ts +195 -11
- package/src/concepts/CallInterface__.ts +4 -2
- package/src/concepts/CallLogic__.ts +211 -12
- package/src/concepts/CallQueryComponent__.ts +2 -1
- package/src/concepts/Comment__.ts +1 -0
- package/src/concepts/CompletionProperty__.ts +1 -0
- package/src/concepts/ConfigGroup__.ts +290 -0
- package/src/concepts/ConfigPropertyValue__.ts +112 -0
- package/src/concepts/ConfigProperty__.ts +306 -0
- package/src/concepts/Configuration__.ts +286 -0
- package/src/concepts/Constant__.ts +3 -1
- package/src/concepts/DataElement__.ts +1 -0
- package/src/concepts/Destination__.ts +7 -5
- package/src/concepts/End__.ts +1 -0
- package/src/concepts/EntityIndex__.ts +19 -0
- package/src/concepts/EntityProperty__.ts +9 -8
- package/src/concepts/Entity__.ts +66 -59
- package/src/concepts/EnumItem__.ts +1 -0
- package/src/concepts/Enum__.ts +32 -12
- package/src/concepts/Event__.ts +2 -1
- package/src/concepts/ForEachStatement__.ts +115 -69
- package/src/concepts/Function__.ts +2 -1
- package/src/concepts/Identifier__.ts +18 -1
- package/src/concepts/IfStatement__.ts +1 -0
- package/src/concepts/InterfaceParam__.ts +2 -1
- package/src/concepts/Interface__.ts +21 -5
- package/src/concepts/JSBlock__.ts +1 -0
- package/src/concepts/LogicItem__.ts +9 -40
- package/src/concepts/Logic__.ts +48 -9
- package/src/concepts/MemberExpression__.ts +14 -17
- package/src/concepts/Module__.ts +158 -139
- package/src/concepts/Namespace__.ts +13 -12
- package/src/concepts/NullLiteral__.ts +3 -1
- package/src/concepts/NumericLiteral__.ts +3 -1
- package/src/concepts/Param__.ts +3 -2
- package/src/concepts/Point__.ts +1 -0
- package/src/concepts/ProcessComponent__.ts +3 -2
- package/src/concepts/ProcessElement__.ts +102 -107
- package/src/concepts/ProcessOutcome__.ts +1 -0
- package/src/concepts/Process__.ts +12 -4
- package/src/concepts/QueryAggregateExpression__.ts +1 -0
- package/src/concepts/QueryFieldExpression__.ts +2 -1
- package/src/concepts/QueryFromExpression__.ts +1 -0
- package/src/concepts/QueryGroupByExpression__.ts +1 -0
- package/src/concepts/QueryJoinExpression__.ts +2 -1
- package/src/concepts/QueryLimitExpression__.ts +1 -0
- package/src/concepts/QueryOrderByExpression__.ts +1 -0
- package/src/concepts/QuerySelectExpression__.ts +2 -1
- package/src/concepts/Rect__.ts +1 -0
- package/src/concepts/Return__.ts +3 -2
- package/src/concepts/Role__.ts +19 -2
- package/src/concepts/Slot__.ts +1 -0
- package/src/concepts/SqlQueryComponent__.ts +11 -1
- package/src/concepts/Start__.ts +1 -0
- package/src/concepts/StringLiteral__.ts +3 -1
- package/src/concepts/StructureProperty__.ts +2 -1
- package/src/concepts/Structure__.ts +5 -4
- package/src/concepts/SwitchCase__.ts +1 -0
- package/src/concepts/SwitchStatement__.ts +1 -0
- package/src/concepts/Theme__.ts +1 -0
- package/src/concepts/Transactional__.ts +1 -0
- package/src/concepts/TypeAnnotation__.ts +4 -0
- package/src/concepts/TypeParam__.ts +1 -0
- package/src/concepts/UnaryExpression__.ts +6 -3
- package/src/concepts/Unparsed__.ts +3 -1
- package/src/concepts/UseComponent__.ts +1 -0
- package/src/concepts/ValidationRule__.ts +5 -2
- package/src/concepts/Variable__.ts +12 -6
- package/src/concepts/ViewComponent__.ts +6 -5
- package/src/concepts/ViewElement__.ts +109 -80
- package/src/concepts/View__.ts +245 -206
- package/src/concepts/WhileStatement__.ts +1 -0
- package/src/concepts/basics/stdlib/index.ts +2 -2
- package/src/concepts/basics/stdlib/nasl.ui.ts +3 -137
- package/src/concepts/basics/stdlib/nasl.util.ts +21 -5
- package/src/concepts/basics/stdlib/{nasl.validate.ts → nasl.validation.ts} +28 -28
- package/src/concepts/index__.ts +4 -0
- package/src/generator/compileComponent.ts +1 -1
- package/src/generator/genBundleFiles.ts +1 -2
- package/src/generator/genMetaData.ts +111 -0
- package/src/generator/index.ts +1 -0
- package/src/index.ts +2 -2
- package/src/server/createUiTs.ts +153 -0
- package/src/server/entity2LogicNamespace.ts +17 -1
- package/src/server/getExtensionModules.ts +13 -0
- package/src/server/getLogics.ts +19 -18
- package/src/server/getMemberIdentifier.ts +60 -19
- package/src/server/getProcesses.ts +15 -8
- package/src/server/getValidates.ts +1 -1
- package/src/server/index.ts +2 -1
- package/src/server/naslServer.ts +204 -24
- package/src/server/process2LogicNamespace.ts +44 -3
- package/src/server/translator.ts +121 -97
- package/src/service/config/api.js +32 -0
- package/src/service/config/index.js +6 -0
- package/src/service/creator/index.js +2 -2
- package/src/service/logic/checktypeSocket.js +49 -0
- package/src/service/modules/api.js +20 -0
- package/src/service/modules/index.js +6 -0
- package/src/service/storage/init.ts +62 -54
- package/src/templator/genCallComponentLogic.ts +2 -2
- package/src/templator/genCreateBlock.ts +19 -25
- package/src/templator/genCurdEditMultipleKeyBlock.ts +3 -3
- package/src/templator/genCurdMultipleKeyBlock.ts +4 -4
- package/src/templator/genEditTableBlock.ts +3 -3
- package/src/templator/genGetBlock.ts +1 -1
- package/src/templator/genListViewBlock.ts +2 -2
- package/src/templator/genSelectBlock.ts +1 -1
- package/src/templator/genUpdateBlock.ts +19 -25
- package/src/templator/utils.ts +25 -153
package/src/concepts/View__.ts
CHANGED
|
@@ -12,13 +12,14 @@ import { EventPayload, Params } from '../common/EventEmitter';
|
|
|
12
12
|
import { concept, excludedInJSON, property } from '../decorators';
|
|
13
13
|
|
|
14
14
|
import * as utils from '../utils';
|
|
15
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
15
16
|
import BaseNode from '../common/BaseNode';
|
|
16
17
|
import classMap from '../common/classMap';
|
|
17
18
|
import ViewElement from './ViewElement__';
|
|
18
19
|
import Param from './Param__';
|
|
19
20
|
import Variable from './Variable__';
|
|
20
|
-
import BindEvent from './BindEvent__';
|
|
21
21
|
import Logic from './Logic__';
|
|
22
|
+
import BindEvent from './BindEvent__';
|
|
22
23
|
import Module from './Module__';
|
|
23
24
|
import App from './App__';
|
|
24
25
|
|
|
@@ -46,10 +47,10 @@ export class View extends BaseNode {
|
|
|
46
47
|
name: string = undefined;
|
|
47
48
|
|
|
48
49
|
/**
|
|
49
|
-
*
|
|
50
|
+
* 唯一标识
|
|
50
51
|
*/
|
|
51
52
|
@property()
|
|
52
|
-
|
|
53
|
+
uuid: string = undefined;
|
|
53
54
|
|
|
54
55
|
/**
|
|
55
56
|
* 页面标题
|
|
@@ -111,18 +112,18 @@ export class View extends BaseNode {
|
|
|
111
112
|
@property('Variable')
|
|
112
113
|
variables: Array<Variable> = [];
|
|
113
114
|
|
|
114
|
-
/**
|
|
115
|
-
* 元素绑定事件列表
|
|
116
|
-
*/
|
|
117
|
-
@property('BindEvent')
|
|
118
|
-
events: Array<BindEvent> = [];
|
|
119
|
-
|
|
120
115
|
/**
|
|
121
116
|
* 逻辑列表
|
|
122
117
|
*/
|
|
123
118
|
@property('Logic')
|
|
124
119
|
logics: Array<Logic> = [];
|
|
125
120
|
|
|
121
|
+
/**
|
|
122
|
+
* 元素绑定事件列表
|
|
123
|
+
*/
|
|
124
|
+
@property('BindEvent')
|
|
125
|
+
bindEvents: Array<BindEvent> = [];
|
|
126
|
+
|
|
126
127
|
/**
|
|
127
128
|
* 绑定的角色
|
|
128
129
|
*/
|
|
@@ -371,7 +372,7 @@ export class View extends BaseNode {
|
|
|
371
372
|
|
|
372
373
|
getParamExistingNames(excludedList: Array<Param> = []) {
|
|
373
374
|
const excludedSet = new Set(excludedList);
|
|
374
|
-
return this.params.filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
375
|
+
return (this.params || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
375
376
|
}
|
|
376
377
|
getParamUniqueName(name = 'param1') {
|
|
377
378
|
return utils.unique(name, this.getParamExistingNames());
|
|
@@ -513,7 +514,7 @@ export class View extends BaseNode {
|
|
|
513
514
|
|
|
514
515
|
getVariableExistingNames(excludedList: Array<Variable> = []) {
|
|
515
516
|
const excludedSet = new Set(excludedList);
|
|
516
|
-
return this.variables.filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
517
|
+
return (this.variables || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
517
518
|
}
|
|
518
519
|
getVariableUniqueName(name = 'variable1') {
|
|
519
520
|
return utils.unique(name, this.getVariableExistingNames());
|
|
@@ -653,285 +654,285 @@ export class View extends BaseNode {
|
|
|
653
654
|
}
|
|
654
655
|
|
|
655
656
|
|
|
656
|
-
|
|
657
|
+
getLogicExistingNames(excludedList: Array<Logic> = []) {
|
|
657
658
|
const excludedSet = new Set(excludedList);
|
|
658
|
-
return this.
|
|
659
|
+
return (this.logics || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
659
660
|
}
|
|
660
|
-
|
|
661
|
-
return utils.unique(name, this.
|
|
661
|
+
getLogicUniqueName(name = 'logic1') {
|
|
662
|
+
return utils.unique(name, this.getLogicExistingNames());
|
|
662
663
|
}
|
|
663
664
|
|
|
664
665
|
/**
|
|
665
|
-
*
|
|
666
|
+
* 插入逻辑
|
|
666
667
|
* @internal
|
|
667
|
-
* @param name
|
|
668
|
+
* @param name 逻辑名称,如果不填会自动生成一个唯一名称
|
|
668
669
|
*/
|
|
669
|
-
|
|
670
|
+
_insertLogicAt(name: string, index: number): Logic;
|
|
670
671
|
|
|
671
672
|
/**
|
|
672
|
-
*
|
|
673
|
+
* 插入逻辑
|
|
673
674
|
* @internal
|
|
674
|
-
* @param
|
|
675
|
+
* @param logicOptions 逻辑参数
|
|
675
676
|
*/
|
|
676
|
-
|
|
677
|
+
_insertLogicAt(logicOptions: Partial<Logic>, index: number): Logic;
|
|
677
678
|
|
|
678
679
|
/**
|
|
679
|
-
*
|
|
680
|
+
* 插入逻辑
|
|
680
681
|
* @internal
|
|
681
|
-
* @param
|
|
682
|
+
* @param logic 已有的逻辑实例
|
|
682
683
|
*/
|
|
683
|
-
|
|
684
|
+
_insertLogicAt(logic: Logic, index: number): Logic;
|
|
684
685
|
|
|
685
|
-
|
|
686
|
-
const
|
|
687
|
-
const relationOptions = { parentNode: this, parentKey: '
|
|
688
|
-
let
|
|
686
|
+
_insertLogicAt(options: string | Partial<Logic> | Logic, index: number) {
|
|
687
|
+
const logicOptions: any = {};
|
|
688
|
+
const relationOptions = { parentNode: this, parentKey: 'logics' };
|
|
689
|
+
let logic: Logic;
|
|
689
690
|
if (!options) {
|
|
690
|
-
|
|
691
|
-
...
|
|
692
|
-
name: this.
|
|
693
|
-
}, this, '
|
|
691
|
+
logic = Logic.from({
|
|
692
|
+
...logicOptions,
|
|
693
|
+
name: this.getLogicUniqueName(),
|
|
694
|
+
}, this, 'logics');
|
|
694
695
|
} else if (typeof options === 'string') {
|
|
695
|
-
|
|
696
|
-
...
|
|
696
|
+
logic = Logic.from({
|
|
697
|
+
...logicOptions,
|
|
697
698
|
name: options,
|
|
698
|
-
}, this, '
|
|
699
|
-
} else if (options instanceof
|
|
699
|
+
}, this, 'logics');
|
|
700
|
+
} else if (options instanceof Logic) {
|
|
700
701
|
options.delete(); // 同一实例不支持多处存在
|
|
701
|
-
|
|
702
|
-
Object.assign(
|
|
702
|
+
logic = options;
|
|
703
|
+
Object.assign(logic, relationOptions);
|
|
703
704
|
} else {
|
|
704
|
-
|
|
705
|
-
...
|
|
705
|
+
logic = Logic.from({
|
|
706
|
+
...logicOptions,
|
|
706
707
|
...options,
|
|
707
|
-
}, this, '
|
|
708
|
+
}, this, 'logics');
|
|
708
709
|
}
|
|
709
|
-
this.
|
|
710
|
-
return
|
|
710
|
+
this.logics.splice(index, 0, logic);
|
|
711
|
+
return logic;
|
|
711
712
|
}
|
|
712
713
|
|
|
713
714
|
/**
|
|
714
|
-
*
|
|
715
|
-
* @param name
|
|
715
|
+
* 插入逻辑
|
|
716
|
+
* @param name 逻辑名称,如果不填会自动生成一个唯一名称
|
|
716
717
|
*/
|
|
717
|
-
|
|
718
|
+
insertLogicAt(name: string, index: number): Logic;
|
|
718
719
|
|
|
719
720
|
/**
|
|
720
|
-
*
|
|
721
|
-
* @param
|
|
721
|
+
* 插入逻辑
|
|
722
|
+
* @param logicOptions 逻辑参数
|
|
722
723
|
*/
|
|
723
|
-
|
|
724
|
+
insertLogicAt(logicOptions: Partial<Logic>, index: number): Logic;
|
|
724
725
|
|
|
725
726
|
/**
|
|
726
|
-
*
|
|
727
|
-
* @param
|
|
727
|
+
* 插入逻辑
|
|
728
|
+
* @param logic 已有的逻辑实例
|
|
728
729
|
*/
|
|
729
|
-
|
|
730
|
+
insertLogicAt(logic: Logic, index: number): Logic;
|
|
730
731
|
|
|
731
|
-
|
|
732
|
-
const node = this.
|
|
732
|
+
insertLogicAt(options: string | Partial<Logic> | Logic, index: number) {
|
|
733
|
+
const node = this._insertLogicAt(options as any, index);
|
|
733
734
|
node.create({
|
|
734
735
|
index,
|
|
735
736
|
parentNode: this,
|
|
736
|
-
parentKey: '
|
|
737
|
+
parentKey: 'logics',
|
|
737
738
|
});
|
|
738
739
|
return node;
|
|
739
740
|
}
|
|
740
741
|
|
|
741
742
|
/**
|
|
742
|
-
*
|
|
743
|
+
* 添加逻辑
|
|
743
744
|
* @internal
|
|
744
|
-
* @param name
|
|
745
|
+
* @param name 逻辑名称,如果不填会自动生成一个唯一名称
|
|
745
746
|
*/
|
|
746
|
-
|
|
747
|
+
_addLogic(name?: string): Logic;
|
|
747
748
|
|
|
748
749
|
/**
|
|
749
|
-
*
|
|
750
|
+
* 添加逻辑
|
|
750
751
|
* @internal
|
|
751
|
-
* @param
|
|
752
|
+
* @param logicOptions 逻辑参数
|
|
752
753
|
*/
|
|
753
|
-
|
|
754
|
+
_addLogic(logicOptions: Partial<Logic>): Logic;
|
|
754
755
|
|
|
755
756
|
/**
|
|
756
|
-
*
|
|
757
|
+
* 添加逻辑
|
|
757
758
|
* @internal
|
|
758
|
-
* @param
|
|
759
|
+
* @param logic 已有的逻辑实例
|
|
759
760
|
*/
|
|
760
|
-
|
|
761
|
+
_addLogic(logic: Logic): Logic;
|
|
761
762
|
|
|
762
|
-
|
|
763
|
-
const index = this.
|
|
764
|
-
return this.
|
|
763
|
+
_addLogic(options?: string | Partial<Logic> | Logic) {
|
|
764
|
+
const index = this.logics.length;
|
|
765
|
+
return this._insertLogicAt(options as any, index);
|
|
765
766
|
}
|
|
766
767
|
|
|
767
768
|
/**
|
|
768
|
-
*
|
|
769
|
+
* 添加逻辑
|
|
769
770
|
* @internal
|
|
770
|
-
* @param name
|
|
771
|
+
* @param name 逻辑名称,如果不填会自动生成一个唯一名称
|
|
771
772
|
*/
|
|
772
|
-
|
|
773
|
+
addLogic(name?: string): Logic;
|
|
773
774
|
|
|
774
775
|
/**
|
|
775
|
-
*
|
|
776
|
-
* @param
|
|
776
|
+
* 添加逻辑
|
|
777
|
+
* @param logicOptions 逻辑参数
|
|
777
778
|
*/
|
|
778
|
-
|
|
779
|
+
addLogic(logicOptions: Partial<Logic>): Logic;
|
|
779
780
|
|
|
780
781
|
/**
|
|
781
|
-
*
|
|
782
|
-
* @param
|
|
782
|
+
* 添加逻辑
|
|
783
|
+
* @param logic 已有的逻辑实例
|
|
783
784
|
*/
|
|
784
|
-
|
|
785
|
+
addLogic(logic: Logic): Logic;
|
|
785
786
|
|
|
786
|
-
|
|
787
|
-
const node = this.
|
|
788
|
-
const index = this.
|
|
787
|
+
addLogic(options?: string | Partial<Logic> | Logic) {
|
|
788
|
+
const node = this._addLogic(options as any);
|
|
789
|
+
const index = this.logics.length;
|
|
789
790
|
node.create({
|
|
790
791
|
index,
|
|
791
792
|
parentNode: this,
|
|
792
|
-
parentKey: '
|
|
793
|
+
parentKey: 'logics',
|
|
793
794
|
});
|
|
794
795
|
return node;
|
|
795
796
|
}
|
|
796
797
|
|
|
797
798
|
|
|
798
|
-
|
|
799
|
+
getBindEventExistingNames(excludedList: Array<BindEvent> = []) {
|
|
799
800
|
const excludedSet = new Set(excludedList);
|
|
800
|
-
return this.
|
|
801
|
+
return (this.bindEvents || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
801
802
|
}
|
|
802
|
-
|
|
803
|
-
return utils.unique(name, this.
|
|
803
|
+
getBindEventUniqueName(name = 'bindEvent1') {
|
|
804
|
+
return utils.unique(name, this.getBindEventExistingNames());
|
|
804
805
|
}
|
|
805
806
|
|
|
806
807
|
/**
|
|
807
|
-
*
|
|
808
|
+
* 插入元素绑定事件
|
|
808
809
|
* @internal
|
|
809
|
-
* @param name
|
|
810
|
+
* @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
|
|
810
811
|
*/
|
|
811
|
-
|
|
812
|
+
_insertBindEventAt(name: string, index: number): BindEvent;
|
|
812
813
|
|
|
813
814
|
/**
|
|
814
|
-
*
|
|
815
|
+
* 插入元素绑定事件
|
|
815
816
|
* @internal
|
|
816
|
-
* @param
|
|
817
|
+
* @param bindEventOptions 元素绑定事件参数
|
|
817
818
|
*/
|
|
818
|
-
|
|
819
|
+
_insertBindEventAt(bindEventOptions: Partial<BindEvent>, index: number): BindEvent;
|
|
819
820
|
|
|
820
821
|
/**
|
|
821
|
-
*
|
|
822
|
+
* 插入元素绑定事件
|
|
822
823
|
* @internal
|
|
823
|
-
* @param
|
|
824
|
+
* @param bindEvent 已有的元素绑定事件实例
|
|
824
825
|
*/
|
|
825
|
-
|
|
826
|
+
_insertBindEventAt(bindEvent: BindEvent, index: number): BindEvent;
|
|
826
827
|
|
|
827
|
-
|
|
828
|
-
const
|
|
829
|
-
const relationOptions = { parentNode: this, parentKey: '
|
|
830
|
-
let
|
|
828
|
+
_insertBindEventAt(options: string | Partial<BindEvent> | BindEvent, index: number) {
|
|
829
|
+
const bindEventOptions: any = {};
|
|
830
|
+
const relationOptions = { parentNode: this, parentKey: 'bindEvents' };
|
|
831
|
+
let bindEvent: BindEvent;
|
|
831
832
|
if (!options) {
|
|
832
|
-
|
|
833
|
-
...
|
|
834
|
-
name: this.
|
|
835
|
-
}, this, '
|
|
833
|
+
bindEvent = BindEvent.from({
|
|
834
|
+
...bindEventOptions,
|
|
835
|
+
name: this.getBindEventUniqueName(),
|
|
836
|
+
}, this, 'bindEvents');
|
|
836
837
|
} else if (typeof options === 'string') {
|
|
837
|
-
|
|
838
|
-
...
|
|
838
|
+
bindEvent = BindEvent.from({
|
|
839
|
+
...bindEventOptions,
|
|
839
840
|
name: options,
|
|
840
|
-
}, this, '
|
|
841
|
-
} else if (options instanceof
|
|
841
|
+
}, this, 'bindEvents');
|
|
842
|
+
} else if (options instanceof BindEvent) {
|
|
842
843
|
options.delete(); // 同一实例不支持多处存在
|
|
843
|
-
|
|
844
|
-
Object.assign(
|
|
844
|
+
bindEvent = options;
|
|
845
|
+
Object.assign(bindEvent, relationOptions);
|
|
845
846
|
} else {
|
|
846
|
-
|
|
847
|
-
...
|
|
847
|
+
bindEvent = BindEvent.from({
|
|
848
|
+
...bindEventOptions,
|
|
848
849
|
...options,
|
|
849
|
-
}, this, '
|
|
850
|
+
}, this, 'bindEvents');
|
|
850
851
|
}
|
|
851
|
-
this.
|
|
852
|
-
return
|
|
852
|
+
this.bindEvents.splice(index, 0, bindEvent);
|
|
853
|
+
return bindEvent;
|
|
853
854
|
}
|
|
854
855
|
|
|
855
856
|
/**
|
|
856
|
-
*
|
|
857
|
-
* @param name
|
|
857
|
+
* 插入元素绑定事件
|
|
858
|
+
* @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
|
|
858
859
|
*/
|
|
859
|
-
|
|
860
|
+
insertBindEventAt(name: string, index: number): BindEvent;
|
|
860
861
|
|
|
861
862
|
/**
|
|
862
|
-
*
|
|
863
|
-
* @param
|
|
863
|
+
* 插入元素绑定事件
|
|
864
|
+
* @param bindEventOptions 元素绑定事件参数
|
|
864
865
|
*/
|
|
865
|
-
|
|
866
|
+
insertBindEventAt(bindEventOptions: Partial<BindEvent>, index: number): BindEvent;
|
|
866
867
|
|
|
867
868
|
/**
|
|
868
|
-
*
|
|
869
|
-
* @param
|
|
869
|
+
* 插入元素绑定事件
|
|
870
|
+
* @param bindEvent 已有的元素绑定事件实例
|
|
870
871
|
*/
|
|
871
|
-
|
|
872
|
+
insertBindEventAt(bindEvent: BindEvent, index: number): BindEvent;
|
|
872
873
|
|
|
873
|
-
|
|
874
|
-
const node = this.
|
|
874
|
+
insertBindEventAt(options: string | Partial<BindEvent> | BindEvent, index: number) {
|
|
875
|
+
const node = this._insertBindEventAt(options as any, index);
|
|
875
876
|
node.create({
|
|
876
877
|
index,
|
|
877
878
|
parentNode: this,
|
|
878
|
-
parentKey: '
|
|
879
|
+
parentKey: 'bindEvents',
|
|
879
880
|
});
|
|
880
881
|
return node;
|
|
881
882
|
}
|
|
882
883
|
|
|
883
884
|
/**
|
|
884
|
-
*
|
|
885
|
+
* 添加元素绑定事件
|
|
885
886
|
* @internal
|
|
886
|
-
* @param name
|
|
887
|
+
* @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
|
|
887
888
|
*/
|
|
888
|
-
|
|
889
|
+
_addBindEvent(name?: string): BindEvent;
|
|
889
890
|
|
|
890
891
|
/**
|
|
891
|
-
*
|
|
892
|
+
* 添加元素绑定事件
|
|
892
893
|
* @internal
|
|
893
|
-
* @param
|
|
894
|
+
* @param bindEventOptions 元素绑定事件参数
|
|
894
895
|
*/
|
|
895
|
-
|
|
896
|
+
_addBindEvent(bindEventOptions: Partial<BindEvent>): BindEvent;
|
|
896
897
|
|
|
897
898
|
/**
|
|
898
|
-
*
|
|
899
|
+
* 添加元素绑定事件
|
|
899
900
|
* @internal
|
|
900
|
-
* @param
|
|
901
|
+
* @param bindEvent 已有的元素绑定事件实例
|
|
901
902
|
*/
|
|
902
|
-
|
|
903
|
+
_addBindEvent(bindEvent: BindEvent): BindEvent;
|
|
903
904
|
|
|
904
|
-
|
|
905
|
-
const index = this.
|
|
906
|
-
return this.
|
|
905
|
+
_addBindEvent(options?: string | Partial<BindEvent> | BindEvent) {
|
|
906
|
+
const index = this.bindEvents.length;
|
|
907
|
+
return this._insertBindEventAt(options as any, index);
|
|
907
908
|
}
|
|
908
909
|
|
|
909
910
|
/**
|
|
910
|
-
*
|
|
911
|
+
* 添加元素绑定事件
|
|
911
912
|
* @internal
|
|
912
|
-
* @param name
|
|
913
|
+
* @param name 元素绑定事件名称,如果不填会自动生成一个唯一名称
|
|
913
914
|
*/
|
|
914
|
-
|
|
915
|
+
addBindEvent(name?: string): BindEvent;
|
|
915
916
|
|
|
916
917
|
/**
|
|
917
|
-
*
|
|
918
|
-
* @param
|
|
918
|
+
* 添加元素绑定事件
|
|
919
|
+
* @param bindEventOptions 元素绑定事件参数
|
|
919
920
|
*/
|
|
920
|
-
|
|
921
|
+
addBindEvent(bindEventOptions: Partial<BindEvent>): BindEvent;
|
|
921
922
|
|
|
922
923
|
/**
|
|
923
|
-
*
|
|
924
|
-
* @param
|
|
924
|
+
* 添加元素绑定事件
|
|
925
|
+
* @param bindEvent 已有的元素绑定事件实例
|
|
925
926
|
*/
|
|
926
|
-
|
|
927
|
+
addBindEvent(bindEvent: BindEvent): BindEvent;
|
|
927
928
|
|
|
928
|
-
|
|
929
|
-
const node = this.
|
|
930
|
-
const index = this.
|
|
929
|
+
addBindEvent(options?: string | Partial<BindEvent> | BindEvent) {
|
|
930
|
+
const node = this._addBindEvent(options as any);
|
|
931
|
+
const index = this.bindEvents.length;
|
|
931
932
|
node.create({
|
|
932
933
|
index,
|
|
933
934
|
parentNode: this,
|
|
934
|
-
parentKey: '
|
|
935
|
+
parentKey: 'bindEvents',
|
|
935
936
|
});
|
|
936
937
|
return node;
|
|
937
938
|
}
|
|
@@ -941,7 +942,7 @@ export class View extends BaseNode {
|
|
|
941
942
|
|
|
942
943
|
getViewExistingNames(excludedList: Array<View> = []) {
|
|
943
944
|
const excludedSet = new Set(excludedList);
|
|
944
|
-
return this.children.filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
945
|
+
return (this.children || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
945
946
|
}
|
|
946
947
|
getViewUniqueName(name = 'view1') {
|
|
947
948
|
return utils.unique(name, this.getViewExistingNames());
|
|
@@ -1234,46 +1235,46 @@ export class View extends BaseNode {
|
|
|
1234
1235
|
|
|
1235
1236
|
|
|
1236
1237
|
/**
|
|
1237
|
-
*
|
|
1238
|
-
* @param name
|
|
1238
|
+
* 删除逻辑
|
|
1239
|
+
* @param name 逻辑名称
|
|
1239
1240
|
*/
|
|
1240
|
-
|
|
1241
|
+
removeLogic(name: string): void;
|
|
1241
1242
|
|
|
1242
1243
|
/**
|
|
1243
|
-
*
|
|
1244
|
-
* @param
|
|
1244
|
+
* 删除逻辑
|
|
1245
|
+
* @param logic 已有的逻辑实例
|
|
1245
1246
|
*/
|
|
1246
|
-
|
|
1247
|
+
removeLogic(logic: Logic): void;
|
|
1247
1248
|
|
|
1248
|
-
|
|
1249
|
-
let
|
|
1249
|
+
removeLogic(options: string | Logic) {
|
|
1250
|
+
let logic: Logic;
|
|
1250
1251
|
if (typeof options === 'string') {
|
|
1251
|
-
|
|
1252
|
-
if (!
|
|
1253
|
-
throw new Error('
|
|
1252
|
+
logic = this.logics.find((item) => item.name === options);
|
|
1253
|
+
if (!logic) {
|
|
1254
|
+
throw new Error('找不到逻辑 ' + options);
|
|
1254
1255
|
}
|
|
1255
1256
|
} else {
|
|
1256
|
-
|
|
1257
|
+
logic = options;
|
|
1257
1258
|
}
|
|
1258
|
-
return
|
|
1259
|
+
return logic.delete();
|
|
1259
1260
|
}
|
|
1260
1261
|
|
|
1261
|
-
|
|
1262
|
-
const parentKey =
|
|
1262
|
+
__removeLogic(logic: Logic) {
|
|
1263
|
+
const parentKey = logic.parentKey;
|
|
1263
1264
|
const params: Params = {
|
|
1264
1265
|
parentNode: this,
|
|
1265
1266
|
parentKey,
|
|
1266
1267
|
index: -1,
|
|
1267
1268
|
object: null,
|
|
1268
|
-
oldObject:
|
|
1269
|
+
oldObject: logic,
|
|
1269
1270
|
};
|
|
1270
1271
|
if (parentKey) {
|
|
1271
1272
|
params.parentKey = parentKey;
|
|
1272
1273
|
if (Array.isArray((this as any)[parentKey])) {
|
|
1273
|
-
const index = (this as any)[parentKey].indexOf(
|
|
1274
|
+
const index = (this as any)[parentKey].indexOf(logic);
|
|
1274
1275
|
~index && (this as any)[parentKey].splice(index, 1);
|
|
1275
1276
|
params.index = index;
|
|
1276
|
-
} else if ((this as any)[parentKey] ===
|
|
1277
|
+
} else if ((this as any)[parentKey] === logic) {
|
|
1277
1278
|
params.index = 0;
|
|
1278
1279
|
(this as any)[parentKey] = undefined;
|
|
1279
1280
|
}
|
|
@@ -1284,46 +1285,46 @@ export class View extends BaseNode {
|
|
|
1284
1285
|
|
|
1285
1286
|
|
|
1286
1287
|
/**
|
|
1287
|
-
*
|
|
1288
|
-
* @param name
|
|
1288
|
+
* 删除元素绑定事件
|
|
1289
|
+
* @param name 元素绑定事件名称
|
|
1289
1290
|
*/
|
|
1290
|
-
|
|
1291
|
+
removeBindEvent(name: string): void;
|
|
1291
1292
|
|
|
1292
1293
|
/**
|
|
1293
|
-
*
|
|
1294
|
-
* @param
|
|
1294
|
+
* 删除元素绑定事件
|
|
1295
|
+
* @param bindEvent 已有的元素绑定事件实例
|
|
1295
1296
|
*/
|
|
1296
|
-
|
|
1297
|
+
removeBindEvent(bindEvent: BindEvent): void;
|
|
1297
1298
|
|
|
1298
|
-
|
|
1299
|
-
let
|
|
1299
|
+
removeBindEvent(options: string | BindEvent) {
|
|
1300
|
+
let bindEvent: BindEvent;
|
|
1300
1301
|
if (typeof options === 'string') {
|
|
1301
|
-
|
|
1302
|
-
if (!
|
|
1303
|
-
throw new Error('
|
|
1302
|
+
bindEvent = this.bindEvents.find((item) => item.name === options);
|
|
1303
|
+
if (!bindEvent) {
|
|
1304
|
+
throw new Error('找不到元素绑定事件 ' + options);
|
|
1304
1305
|
}
|
|
1305
1306
|
} else {
|
|
1306
|
-
|
|
1307
|
+
bindEvent = options;
|
|
1307
1308
|
}
|
|
1308
|
-
return
|
|
1309
|
+
return bindEvent.delete();
|
|
1309
1310
|
}
|
|
1310
1311
|
|
|
1311
|
-
|
|
1312
|
-
const parentKey =
|
|
1312
|
+
__removeBindEvent(bindEvent: BindEvent) {
|
|
1313
|
+
const parentKey = bindEvent.parentKey;
|
|
1313
1314
|
const params: Params = {
|
|
1314
1315
|
parentNode: this,
|
|
1315
1316
|
parentKey,
|
|
1316
1317
|
index: -1,
|
|
1317
1318
|
object: null,
|
|
1318
|
-
oldObject:
|
|
1319
|
+
oldObject: bindEvent,
|
|
1319
1320
|
};
|
|
1320
1321
|
if (parentKey) {
|
|
1321
1322
|
params.parentKey = parentKey;
|
|
1322
1323
|
if (Array.isArray((this as any)[parentKey])) {
|
|
1323
|
-
const index = (this as any)[parentKey].indexOf(
|
|
1324
|
+
const index = (this as any)[parentKey].indexOf(bindEvent);
|
|
1324
1325
|
~index && (this as any)[parentKey].splice(index, 1);
|
|
1325
1326
|
params.index = index;
|
|
1326
|
-
} else if ((this as any)[parentKey] ===
|
|
1327
|
+
} else if ((this as any)[parentKey] === bindEvent) {
|
|
1327
1328
|
params.index = 0;
|
|
1328
1329
|
(this as any)[parentKey] = undefined;
|
|
1329
1330
|
}
|
|
@@ -1585,7 +1586,7 @@ export class View extends BaseNode {
|
|
|
1585
1586
|
params: this.params,
|
|
1586
1587
|
variables: this.variables,
|
|
1587
1588
|
logics: this.logics,
|
|
1588
|
-
events: this.
|
|
1589
|
+
events: this.bindEvents,
|
|
1589
1590
|
title: this.title,
|
|
1590
1591
|
crumb: this.crumb,
|
|
1591
1592
|
first: this.isIndex,
|
|
@@ -1602,7 +1603,6 @@ export class View extends BaseNode {
|
|
|
1602
1603
|
* 转换成 Vue 文件
|
|
1603
1604
|
*/
|
|
1604
1605
|
toVue(options?: ElementToVueOptions) {
|
|
1605
|
-
console.log(options);
|
|
1606
1606
|
let result = '';
|
|
1607
1607
|
result += `<template>\n${this.genVueTemplate(options)}\n</template>\n`;
|
|
1608
1608
|
result += `<script>\n${this.genScript()}\n</script>\n`;
|
|
@@ -1612,16 +1612,16 @@ export class View extends BaseNode {
|
|
|
1612
1612
|
* 转换成设计器中使用的 Vue template 内容
|
|
1613
1613
|
* @param options
|
|
1614
1614
|
*/
|
|
1615
|
-
genDesignerVueTemplate(
|
|
1616
|
-
return this.elements.map((element) => element.toDesignerVue(
|
|
1615
|
+
genDesignerVueTemplate() {
|
|
1616
|
+
return this.elements.map((element) => element.toDesignerVue() + '\n').join('');
|
|
1617
1617
|
}
|
|
1618
1618
|
/**
|
|
1619
1619
|
* 转换成设计器中使用的 Vue 文件
|
|
1620
1620
|
* 目前不需要 script 和 style
|
|
1621
1621
|
* @param options
|
|
1622
1622
|
*/
|
|
1623
|
-
toDesignerVue(
|
|
1624
|
-
return `<template>\n${this.genDesignerVueTemplate(
|
|
1623
|
+
toDesignerVue() {
|
|
1624
|
+
return `<template>\n${this.genDesignerVueTemplate()}</template>`;
|
|
1625
1625
|
}
|
|
1626
1626
|
/**
|
|
1627
1627
|
* 转换成 VueOptions
|
|
@@ -1638,7 +1638,15 @@ export class View extends BaseNode {
|
|
|
1638
1638
|
* @param name 一般不用传,用于 rename
|
|
1639
1639
|
*/
|
|
1640
1640
|
getEmbeddedFilePath(name = this.name) {
|
|
1641
|
-
|
|
1641
|
+
let pathName = name;
|
|
1642
|
+
let parent = this.parentNode;
|
|
1643
|
+
if (parent) {
|
|
1644
|
+
while (parent && parent instanceof View) {
|
|
1645
|
+
pathName = parent.name + '/' + pathName;
|
|
1646
|
+
parent = parent.parentNode;
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
return `/embedded/${this.app.name}/views/${pathName}.ts`;
|
|
1642
1650
|
}
|
|
1643
1651
|
|
|
1644
1652
|
getNamespace(): string {
|
|
@@ -1657,13 +1665,35 @@ export class View extends BaseNode {
|
|
|
1657
1665
|
if (/^\d/.test(tsName)) {
|
|
1658
1666
|
tsName = '$' + tsName;
|
|
1659
1667
|
}
|
|
1660
|
-
|
|
1668
|
+
// 匹配所有特殊字符都转为_
|
|
1669
|
+
tsName = tsName.replace(/\W/g, '_');
|
|
1661
1670
|
return tsName;
|
|
1662
1671
|
}
|
|
1672
|
+
// 获取当前element,铺平
|
|
1673
|
+
elementsMethods(elements: Array<ViewElement>, allMethods: Array<ViewElement>) {
|
|
1674
|
+
if (elements) {
|
|
1675
|
+
elements.forEach((item: ViewElement) => {
|
|
1676
|
+
allMethods.push(item);
|
|
1677
|
+
if (item.children) {
|
|
1678
|
+
this.elementsMethods(item.children, allMethods);
|
|
1679
|
+
}
|
|
1680
|
+
});
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1663
1684
|
@withSourceMap()
|
|
1664
|
-
toEmbeddedTS(state?: TranslatorState
|
|
1665
|
-
|
|
1666
|
-
|
|
1685
|
+
toEmbeddedTS(state?: TranslatorState): string {
|
|
1686
|
+
function chineseTsName(name: string) {
|
|
1687
|
+
let tsName = name;
|
|
1688
|
+
if (/^\d/.test(tsName)) {
|
|
1689
|
+
tsName = '$' + tsName;
|
|
1690
|
+
}
|
|
1691
|
+
// 匹配所有特殊字符都转为_
|
|
1692
|
+
tsName = tsName.replace(/\W/g, '_');
|
|
1693
|
+
return tsName;
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
let code = `export namespace ${this.tsName} {\n`;
|
|
1667
1697
|
// 角色
|
|
1668
1698
|
// if (this.auth && Array.isArray(this.roles) && this.roles.length) {
|
|
1669
1699
|
// code += indent(state.tabSize + 1);
|
|
@@ -1682,7 +1712,7 @@ export class View extends BaseNode {
|
|
|
1682
1712
|
code += 'export let bindRoles = [\n';
|
|
1683
1713
|
this.bindRoles.forEach((role) => {
|
|
1684
1714
|
code += indent(state.tabSize + 1);
|
|
1685
|
-
code += `${this.app.getNamespace()}.roles.${role}.${role},`;
|
|
1715
|
+
code += `${this.app.getNamespace()}.roles.${chineseTsName(role)}.${chineseTsName(role)},`;
|
|
1686
1716
|
code += '\n';
|
|
1687
1717
|
});
|
|
1688
1718
|
code += '\n';
|
|
@@ -1766,14 +1796,6 @@ export class View extends BaseNode {
|
|
|
1766
1796
|
code += '){}\n';
|
|
1767
1797
|
}
|
|
1768
1798
|
code += indent(state.tabSize) + '}\n';
|
|
1769
|
-
// 子页面
|
|
1770
|
-
if (Array.isArray(this.children)) {
|
|
1771
|
-
this.children.forEach((child) => {
|
|
1772
|
-
code += child.toEmbeddedTS(shiftState(state, code), currentName);
|
|
1773
|
-
code += '\n';
|
|
1774
|
-
});
|
|
1775
|
-
}
|
|
1776
|
-
|
|
1777
1799
|
return code;
|
|
1778
1800
|
}
|
|
1779
1801
|
|
|
@@ -1808,6 +1830,23 @@ export class View extends BaseNode {
|
|
|
1808
1830
|
return path;
|
|
1809
1831
|
}
|
|
1810
1832
|
|
|
1833
|
+
/**
|
|
1834
|
+
* @param path 子路径
|
|
1835
|
+
* 比如当前页面路径为:/dashboard
|
|
1836
|
+
* path 为要查找子路径:如 /student/list、student/list
|
|
1837
|
+
*/
|
|
1838
|
+
findViewByPath(path: string): View {
|
|
1839
|
+
const arr = path.split('/');
|
|
1840
|
+
if (arr[0] === '')
|
|
1841
|
+
arr.shift();
|
|
1842
|
+
|
|
1843
|
+
if (!arr.length)
|
|
1844
|
+
return this;
|
|
1845
|
+
const childName = arr.shift();
|
|
1846
|
+
const subView = this.children.find((child) => child.name === childName);
|
|
1847
|
+
return arr.length ? subView.findViewByPath(arr.join('/')) : subView;
|
|
1848
|
+
}
|
|
1849
|
+
|
|
1811
1850
|
_setAsIndexView(isIndex: boolean) {
|
|
1812
1851
|
let views: View[] = [];
|
|
1813
1852
|
if (this.parentNode.concept !== 'View') {
|