@lcap/nasl 2.22.0-beta.5 → 3.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/docs/classes/Module.html +15 -15
- package/docs/classes/Namespace.html +15 -15
- package/docs/classes/ViewComponent.html +19 -19
- package/out/automate/engine/utils.js +4 -0
- package/out/automate/engine/utils.js.map +1 -1
- package/out/breakpoint/generator/AfterStartNode.d.ts +7 -0
- package/out/breakpoint/generator/AfterStartNode.js +27 -0
- package/out/breakpoint/generator/AfterStartNode.js.map +1 -0
- package/out/breakpoint/generator/BeforeEndNode.d.ts +7 -0
- package/out/breakpoint/generator/BeforeEndNode.js +27 -0
- package/out/breakpoint/generator/BeforeEndNode.js.map +1 -0
- package/out/breakpoint/generator/BreakpointNode.d.ts +14 -0
- package/out/breakpoint/generator/BreakpointNode.js +166 -0
- package/out/breakpoint/generator/BreakpointNode.js.map +1 -0
- package/out/breakpoint/generator/index.d.ts +4 -0
- package/out/breakpoint/generator/index.js +98 -0
- package/out/breakpoint/generator/index.js.map +1 -0
- package/out/breakpoint/index.d.ts +3 -0
- package/out/breakpoint/index.js +20 -0
- package/out/breakpoint/index.js.map +1 -0
- package/out/breakpoint/shared/constants.d.ts +30 -0
- package/out/breakpoint/shared/constants.js +87 -0
- package/out/breakpoint/shared/constants.js.map +1 -0
- package/out/breakpoint/shared/index.d.ts +3 -0
- package/out/breakpoint/shared/index.js +33 -0
- package/out/breakpoint/shared/index.js.map +1 -0
- package/out/breakpoint/shared/operations.d.ts +10 -0
- package/out/breakpoint/shared/operations.js +25 -0
- package/out/breakpoint/shared/operations.js.map +1 -0
- package/out/breakpoint/shared/socket.d.ts +47 -0
- package/out/breakpoint/shared/socket.js +210 -0
- package/out/breakpoint/shared/socket.js.map +1 -0
- package/out/breakpoint/shared/utils.d.ts +20 -0
- package/out/breakpoint/shared/utils.js +133 -0
- package/out/breakpoint/shared/utils.js.map +1 -0
- package/out/breakpoint/store/core.d.ts +30 -0
- package/out/breakpoint/store/core.js +341 -0
- package/out/breakpoint/store/core.js.map +1 -0
- package/out/breakpoint/store/dock.d.ts +1 -0
- package/out/breakpoint/store/dock.js +127 -0
- package/out/breakpoint/store/dock.js.map +1 -0
- package/out/breakpoint/store/index.d.ts +2 -0
- package/out/breakpoint/store/index.js +19 -0
- package/out/breakpoint/store/index.js.map +1 -0
- package/out/common/BaseNode.d.ts +8 -0
- package/out/common/BaseNode.js +19 -0
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/App__.d.ts +365 -16
- package/out/concepts/App__.js +431 -10
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Assignment__.js +1 -1
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/AuthInterface__.d.ts +37 -0
- package/out/concepts/AuthInterface__.js +141 -0
- package/out/concepts/AuthInterface__.js.map +1 -0
- package/out/concepts/AuthLogicForCallInterface__.d.ts +138 -0
- package/out/concepts/AuthLogicForCallInterface__.js +493 -0
- package/out/concepts/AuthLogicForCallInterface__.js.map +1 -0
- package/out/concepts/AuthLogic__.d.ts +66 -0
- package/out/concepts/AuthLogic__.js +206 -0
- package/out/concepts/AuthLogic__.js.map +1 -0
- package/out/concepts/BackendVariable__.d.ts +137 -0
- package/out/concepts/BackendVariable__.js +422 -0
- package/out/concepts/BackendVariable__.js.map +1 -0
- package/out/concepts/Backend__.d.ts +134 -0
- package/out/concepts/Backend__.js +274 -0
- package/out/concepts/Backend__.js.map +1 -0
- package/out/concepts/BindAttribute__.d.ts +1 -1
- package/out/concepts/BindAttribute__.js +3 -1
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindEvent__.d.ts +12 -0
- package/out/concepts/BindEvent__.js +68 -0
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/CallAuthInterface__.d.ts +126 -0
- package/out/concepts/CallAuthInterface__.js +408 -0
- package/out/concepts/CallAuthInterface__.js.map +1 -0
- package/out/concepts/CallInterface__.d.ts +6 -1
- package/out/concepts/CallInterface__.js +9 -1
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.js +3 -1
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.js +9 -7
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Destination__.js +1 -1
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +29 -2
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +1 -2
- package/out/concepts/Entity__.js +1 -31
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +9 -4
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/FrontendLibrary__.d.ts +29 -29
- package/out/concepts/FrontendLibrary__.js +2 -2
- package/out/concepts/FrontendVariable__.d.ts +21 -0
- package/out/concepts/FrontendVariable__.js +64 -0
- package/out/concepts/FrontendVariable__.js.map +1 -0
- package/out/concepts/Frontend__.d.ts +151 -47
- package/out/concepts/Frontend__.js +188 -32
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/Function__.js +1 -1
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.js +1 -1
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/Interface__.d.ts +1 -1
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +18 -3
- package/out/concepts/LogicItem__.js +22 -4
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +14 -9
- package/out/concepts/Logic__.js +43 -5
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/Namespace__.d.ts +29 -29
- package/out/concepts/Namespace__.js +2 -2
- package/out/concepts/NewComposite__.js +2 -2
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/OverriddenLogic__.d.ts +643 -0
- package/out/concepts/OverriddenLogic__.js +1602 -0
- package/out/concepts/OverriddenLogic__.js.map +1 -0
- package/out/concepts/Param__.d.ts +6 -0
- package/out/concepts/Param__.js +10 -0
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/QueryFieldExpression__.d.ts +2 -0
- package/out/concepts/QueryFieldExpression__.js +9 -0
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QuerySelectExpression__.d.ts +2 -2
- package/out/concepts/QuerySelectExpression__.js +2 -2
- package/out/concepts/QuerySelectExpression__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.js +6 -6
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/Variable__.d.ts +10 -0
- package/out/concepts/Variable__.js +12 -0
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewComponent__.d.ts +33 -33
- package/out/concepts/ViewComponent__.js +7 -7
- package/out/concepts/ViewElement__.d.ts +6 -0
- package/out/concepts/ViewElement__.js +104 -1
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.js +2 -2
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/basics/stdlib/index.js +2 -1
- package/out/concepts/basics/stdlib/index.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.auth.js +24 -0
- package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.http.d.ts +7 -0
- package/out/concepts/basics/stdlib/nasl.http.js +167 -0
- package/out/concepts/basics/stdlib/nasl.http.js.map +1 -0
- package/out/concepts/basics/stdlib/nasl.process.js +68 -0
- package/out/concepts/basics/stdlib/nasl.process.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +4 -19
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +83 -17
- 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 +4 -1
- package/out/concepts/basics/types/index.js.map +1 -1
- package/out/concepts/index__.d.ts +8 -0
- package/out/concepts/index__.js +8 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/enums/KEYWORDS.js +0 -1
- package/out/enums/KEYWORDS.js.map +1 -1
- package/out/generator/genBundleFiles.d.ts +1 -0
- package/out/generator/genBundleFiles.js +27 -0
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.d.ts +4 -1
- package/out/generator/genMetaData.js +14 -0
- package/out/generator/genMetaData.js.map +1 -1
- package/out/generator/genReleaseBody.d.ts +2 -1
- package/out/generator/genReleaseBody.js +2 -1
- package/out/generator/genReleaseBody.js.map +1 -1
- package/out/index.d.ts +2 -1
- package/out/index.js +3 -1
- package/out/index.js.map +1 -1
- package/out/server/extendBaseNode.js +16 -4
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/formatTsUtils.d.ts +2 -1
- package/out/server/formatTsUtils.js +39 -4
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getExtensionModules.d.ts +2 -2
- package/out/server/getExtensionModules.js +16 -2
- package/out/server/getExtensionModules.js.map +1 -1
- package/out/server/getLogics.js +5 -5
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.d.ts +1 -0
- package/out/server/getMemberIdentifier.js +34 -7
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/naslServer.d.ts +64 -64
- package/out/server/naslServer.js +249 -121
- package/out/server/naslServer.js.map +1 -1
- package/out/server/naslStdlibMap.js +2 -0
- package/out/server/naslStdlibMap.js.map +1 -1
- package/out/server/translator.d.ts +1 -0
- package/out/server/translator.js +67 -2
- package/out/server/translator.js.map +1 -1
- package/out/service/defaultErrorMessage.json +1 -0
- package/out/service/storage/api.d.ts +10 -1
- package/out/service/storage/api.js +6 -0
- package/out/service/storage/api.js.map +1 -1
- package/out/service/storage/init.d.ts +4 -0
- package/out/service/storage/init.js +55 -35
- package/out/service/storage/init.js.map +1 -1
- package/out/service/storage/service.d.ts +3 -0
- package/out/service/storage/service.js +14 -0
- package/out/service/storage/service.js.map +1 -1
- package/out/utils/sortTsString.d.ts +1 -0
- package/out/utils/sortTsString.js +36 -0
- package/out/utils/sortTsString.js.map +1 -0
- package/out/utils/traverse.js +2 -2
- package/out/utils/traverse.js.map +1 -1
- package/package.json +7 -2
- package/sandbox/stdlib/nasl.auth.ts +8 -4
- package/sandbox/stdlib/nasl.core.d.ts +206 -0
- package/sandbox/stdlib/nasl.core.js +1 -0
- package/sandbox/stdlib/nasl.core.js.map +1 -0
- package/sandbox/stdlib/nasl.http.ts +35 -0
- package/sandbox/stdlib/nasl.process.ts +13 -0
- package/sandbox/stdlib/nasl.ui.ts +0 -5
- package/src/automate/engine/utils.js +4 -1
- package/src/breakpoint/generator/AfterStartNode.ts +27 -0
- package/src/breakpoint/generator/BeforeEndNode.ts +27 -0
- package/src/breakpoint/generator/BreakpointNode.ts +228 -0
- package/src/breakpoint/generator/index.ts +114 -0
- package/src/breakpoint/index.ts +3 -0
- package/src/breakpoint/shared/constants.ts +95 -0
- package/src/breakpoint/shared/index.ts +3 -0
- package/src/breakpoint/shared/operations.ts +25 -0
- package/src/breakpoint/shared/socket.ts +326 -0
- package/src/breakpoint/shared/utils.ts +195 -0
- package/src/breakpoint/store/core.ts +411 -0
- package/src/breakpoint/store/dock.ts +166 -0
- package/src/breakpoint/store/index.ts +2 -0
- package/src/breakpoint/types/index.d.ts +19 -0
- package/src/common/BaseNode.ts +19 -1
- package/src/concepts/App__.ts +828 -26
- package/src/concepts/Assignment__.ts +1 -1
- package/src/concepts/AuthInterface__.ts +148 -0
- package/src/concepts/AuthLogicForCallInterface__.ts +573 -0
- package/src/concepts/AuthLogic__.ts +225 -0
- package/src/concepts/BackendVariable__.ts +466 -0
- package/src/concepts/Backend__.ts +347 -0
- package/src/concepts/BindAttribute__.ts +4 -3
- package/src/concepts/BindEvent__.ts +71 -2
- package/src/concepts/CallAuthInterface__.ts +490 -0
- package/src/concepts/CallInterface__.ts +10 -2
- package/src/concepts/CallLogic__.ts +3 -1
- package/src/concepts/CallQueryComponent__.ts +67 -7
- package/src/concepts/Destination__.ts +19 -1
- package/src/concepts/End__.ts +31 -3
- package/src/concepts/EntityProperty__.ts +6 -0
- package/src/concepts/Entity__.ts +8 -31
- package/src/concepts/ForEachStatement__.ts +9 -4
- package/src/concepts/FrontendLibrary__.ts +30 -30
- package/src/concepts/FrontendVariable__.ts +76 -0
- package/src/concepts/Frontend__.ts +352 -89
- package/src/concepts/Function__.ts +1 -1
- package/src/concepts/Identifier__.ts +5 -5
- package/src/concepts/Interface__.ts +1 -1
- package/src/concepts/LogicItem__.ts +26 -6
- package/src/concepts/Logic__.ts +86 -8
- package/src/concepts/Module__.ts +32 -2
- package/src/concepts/Namespace__.ts +30 -30
- package/src/concepts/NewComposite__.ts +2 -3
- package/src/concepts/OverriddenLogic__.ts +2165 -0
- package/src/concepts/Param__.ts +13 -3
- package/src/concepts/QueryFieldExpression__.ts +18 -0
- package/src/concepts/QuerySelectExpression__.ts +11 -3
- package/src/concepts/TypeAnnotation__.ts +45 -6
- package/src/concepts/Variable__.ts +14 -0
- package/src/concepts/ViewComponent__.ts +35 -35
- package/src/concepts/ViewElement__.ts +104 -1
- package/src/concepts/View__.ts +24 -2
- package/src/concepts/basics/stdlib/index.ts +2 -1
- package/src/concepts/basics/stdlib/nasl.auth.ts +24 -0
- package/src/concepts/basics/stdlib/nasl.http.ts +166 -0
- package/src/concepts/basics/stdlib/nasl.process.ts +68 -0
- package/src/concepts/basics/stdlib/nasl.ui.ts +4 -19
- package/src/concepts/basics/stdlib/nasl.util.ts +83 -17
- package/src/concepts/basics/types/index.ts +5 -4
- package/src/concepts/index__.ts +8 -0
- package/src/enums/KEYWORDS.ts +0 -1
- package/src/generator/genBundleFiles.ts +36 -2
- package/src/generator/genMetaData.ts +16 -1
- package/src/generator/genReleaseBody.ts +4 -1
- package/src/index.ts +2 -1
- package/src/server/extendBaseNode.ts +18 -7
- package/src/server/formatTsUtils.ts +37 -5
- package/src/server/getExtensionModules.ts +18 -3
- package/src/server/getLogics.ts +6 -6
- package/src/server/getMemberIdentifier.ts +35 -9
- package/src/server/naslServer.ts +250 -124
- package/src/server/naslStdlibMap.ts +2 -0
- package/src/server/translator.ts +67 -1
- package/src/service/defaultErrorMessage.json +1 -0
- package/src/service/storage/api.js +7 -1
- package/src/service/storage/init.ts +66 -35
- package/src/service/storage/service.ts +18 -2
- package/src/utils/sortTsString.ts +32 -0
- package/src/utils/traverse.ts +2 -2
- package/test/examples/app-simple.json +73635 -0
- package/ts-worker/lib/tsserver.js +3 -3
- package/ts-worker/package.json +1 -1
package/src/concepts/Param__.ts
CHANGED
|
@@ -259,7 +259,7 @@ export class Param extends BaseNode {
|
|
|
259
259
|
defaultExpression: LogicItem | Function | AnonymousFunction = undefined;
|
|
260
260
|
@excludedInJSON()
|
|
261
261
|
@property()
|
|
262
|
-
options: Array<{ text?: string; value: string }> = undefined;
|
|
262
|
+
options: Array<{ text?: string; value: string, description?: string }> = undefined;
|
|
263
263
|
@excludedInJSON()
|
|
264
264
|
@property()
|
|
265
265
|
useComponent: {
|
|
@@ -350,6 +350,7 @@ export class Param extends BaseNode {
|
|
|
350
350
|
code += this.required ? ': ' : '?: ';
|
|
351
351
|
code += this.defaultExpression.toEmbeddedTSDefinition(shiftState(state, code));
|
|
352
352
|
} else if (!dontType && this.typeAnnotation) {
|
|
353
|
+
// TODO
|
|
353
354
|
code += ': ';
|
|
354
355
|
code += this.typeAnnotation.toEmbeddedTS(shiftState(state, code));
|
|
355
356
|
// toTS暂时只需要翻译引用数据类型的,因为值都是字符串
|
|
@@ -434,8 +435,6 @@ export class Param extends BaseNode {
|
|
|
434
435
|
this._readonly = val;
|
|
435
436
|
}
|
|
436
437
|
|
|
437
|
-
|
|
438
|
-
|
|
439
438
|
setnNewTypeAnnotation(oldTypeAnnotation: TypeAnnotation) {
|
|
440
439
|
const json = oldTypeAnnotation.toJSON();
|
|
441
440
|
const typeAnnotation = TypeAnnotation.from(json);
|
|
@@ -458,6 +457,17 @@ export class Param extends BaseNode {
|
|
|
458
457
|
}
|
|
459
458
|
}
|
|
460
459
|
|
|
460
|
+
/**
|
|
461
|
+
* 祖先 Logic
|
|
462
|
+
*/
|
|
463
|
+
get AuthLogic() {
|
|
464
|
+
return this.getAncestor('AuthLogic') as Logic;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
get AuthLogicForCallInterface() {
|
|
468
|
+
return this.getAncestor('AuthLogicForCallInterface') as Logic;
|
|
469
|
+
}
|
|
470
|
+
|
|
461
471
|
//================================================================================
|
|
462
472
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
463
473
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
@@ -48,6 +48,8 @@ export class QueryFieldExpression extends LogicItem {
|
|
|
48
48
|
@property()
|
|
49
49
|
propertyName: string = undefined;
|
|
50
50
|
|
|
51
|
+
|
|
52
|
+
|
|
51
53
|
/**
|
|
52
54
|
* @param source 需要合并的部分参数
|
|
53
55
|
*/
|
|
@@ -64,6 +66,7 @@ export class QueryFieldExpression extends LogicItem {
|
|
|
64
66
|
return super.from(source, parentNode, parentKey) as QueryFieldExpression;
|
|
65
67
|
}
|
|
66
68
|
|
|
69
|
+
|
|
67
70
|
/**
|
|
68
71
|
* 设置entityAsName
|
|
69
72
|
*/
|
|
@@ -88,6 +91,10 @@ export class QueryFieldExpression extends LogicItem {
|
|
|
88
91
|
});
|
|
89
92
|
}
|
|
90
93
|
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
91
98
|
//================================================================================
|
|
92
99
|
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
93
100
|
// 自动生成的代码已结束。下面可以手动编写。
|
|
@@ -109,6 +116,17 @@ export class QueryFieldExpression extends LogicItem {
|
|
|
109
116
|
};
|
|
110
117
|
}
|
|
111
118
|
|
|
119
|
+
setEntityAsNameAndEffect(entityAsName: string) {
|
|
120
|
+
this.setEntityAsName(entityAsName);
|
|
121
|
+
this.effect();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
effect() {
|
|
125
|
+
// 处理选中的此实体的 CallQueryComponent
|
|
126
|
+
const callQueryComponent = this.getAncestor('CallQueryComponent') as CallQueryComponent;
|
|
127
|
+
callQueryComponent.saveStructure();
|
|
128
|
+
}
|
|
129
|
+
|
|
112
130
|
setName(asName: string) {
|
|
113
131
|
this.update({ asName });
|
|
114
132
|
}
|
|
@@ -37,11 +37,13 @@ export class QuerySelectExpression extends LogicItem {
|
|
|
37
37
|
star: boolean = true;
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* selectElements
|
|
41
41
|
*/
|
|
42
42
|
@property('QueryAggregateExpression | QueryFieldExpression')
|
|
43
43
|
selectElements: Array<QueryAggregateExpression | QueryFieldExpression> = [];
|
|
44
44
|
|
|
45
|
+
|
|
46
|
+
|
|
45
47
|
/**
|
|
46
48
|
* @param source 需要合并的部分参数
|
|
47
49
|
*/
|
|
@@ -58,8 +60,9 @@ export class QuerySelectExpression extends LogicItem {
|
|
|
58
60
|
return super.from(source, parentNode, parentKey) as QuerySelectExpression;
|
|
59
61
|
}
|
|
60
62
|
|
|
63
|
+
|
|
61
64
|
/**
|
|
62
|
-
*
|
|
65
|
+
* 设置selectElements
|
|
63
66
|
*/
|
|
64
67
|
setSelectElements(selectElements: Array<QueryAggregateExpression | QueryFieldExpression>) {
|
|
65
68
|
const object = {
|
|
@@ -70,7 +73,7 @@ export class QuerySelectExpression extends LogicItem {
|
|
|
70
73
|
});
|
|
71
74
|
}
|
|
72
75
|
|
|
73
|
-
|
|
76
|
+
getQueryAggregateExpressionExistingNames(excludedList: Array<QueryAggregateExpression> = []) {
|
|
74
77
|
const excludedSet = new Set(excludedList);
|
|
75
78
|
return ((this.selectElements as QueryAggregateExpression[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
76
79
|
}
|
|
@@ -344,6 +347,9 @@ export class QuerySelectExpression extends LogicItem {
|
|
|
344
347
|
return node;
|
|
345
348
|
}
|
|
346
349
|
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
347
353
|
/**
|
|
348
354
|
* 删除查询聚合函数
|
|
349
355
|
* @param name 查询聚合函数名称
|
|
@@ -369,6 +375,8 @@ export class QuerySelectExpression extends LogicItem {
|
|
|
369
375
|
return queryAggregateExpression.delete();
|
|
370
376
|
}
|
|
371
377
|
|
|
378
|
+
|
|
379
|
+
|
|
372
380
|
/**
|
|
373
381
|
* 删除查询属性
|
|
374
382
|
* @param name 查询属性名称
|
|
@@ -73,6 +73,7 @@ export const GENERIC_DESC: Record<string, string> = {
|
|
|
73
73
|
Map: '从K类型到V类型的映射',
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
+
|
|
76
77
|
/**
|
|
77
78
|
* 判断是否是联合类型
|
|
78
79
|
* @param typeAnnotation
|
|
@@ -157,6 +158,8 @@ export class TypeAnnotation extends BaseNode {
|
|
|
157
158
|
@property()
|
|
158
159
|
ruleMap: Object = undefined;
|
|
159
160
|
|
|
161
|
+
|
|
162
|
+
|
|
160
163
|
/**
|
|
161
164
|
* @param source 需要合并的部分参数
|
|
162
165
|
*/
|
|
@@ -196,6 +199,10 @@ export class TypeAnnotation extends BaseNode {
|
|
|
196
199
|
});
|
|
197
200
|
}
|
|
198
201
|
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
199
206
|
/**
|
|
200
207
|
* 插入类型标注
|
|
201
208
|
* @internal
|
|
@@ -228,6 +235,8 @@ export class TypeAnnotation extends BaseNode {
|
|
|
228
235
|
return typeAnnotation;
|
|
229
236
|
}
|
|
230
237
|
|
|
238
|
+
|
|
239
|
+
|
|
231
240
|
/**
|
|
232
241
|
* 插入类型标注
|
|
233
242
|
* @param typeAnnotationOptions 类型标注参数
|
|
@@ -250,6 +259,8 @@ export class TypeAnnotation extends BaseNode {
|
|
|
250
259
|
return node;
|
|
251
260
|
}
|
|
252
261
|
|
|
262
|
+
|
|
263
|
+
|
|
253
264
|
/**
|
|
254
265
|
* 添加类型标注
|
|
255
266
|
* @internal
|
|
@@ -269,6 +280,8 @@ export class TypeAnnotation extends BaseNode {
|
|
|
269
280
|
return this._insertTypeAnnotationInTypeArgumentsAt(options as any, index);
|
|
270
281
|
}
|
|
271
282
|
|
|
283
|
+
|
|
284
|
+
|
|
272
285
|
/**
|
|
273
286
|
* 添加类型标注
|
|
274
287
|
* @param typeAnnotationOptions 类型标注参数
|
|
@@ -292,6 +305,8 @@ export class TypeAnnotation extends BaseNode {
|
|
|
292
305
|
return node;
|
|
293
306
|
}
|
|
294
307
|
|
|
308
|
+
|
|
309
|
+
|
|
295
310
|
/**
|
|
296
311
|
* 插入类型标注
|
|
297
312
|
* @internal
|
|
@@ -324,6 +339,8 @@ export class TypeAnnotation extends BaseNode {
|
|
|
324
339
|
return typeAnnotation;
|
|
325
340
|
}
|
|
326
341
|
|
|
342
|
+
|
|
343
|
+
|
|
327
344
|
/**
|
|
328
345
|
* 插入类型标注
|
|
329
346
|
* @param typeAnnotationOptions 类型标注参数
|
|
@@ -346,6 +363,8 @@ export class TypeAnnotation extends BaseNode {
|
|
|
346
363
|
return node;
|
|
347
364
|
}
|
|
348
365
|
|
|
366
|
+
|
|
367
|
+
|
|
349
368
|
/**
|
|
350
369
|
* 添加类型标注
|
|
351
370
|
* @internal
|
|
@@ -365,6 +384,8 @@ export class TypeAnnotation extends BaseNode {
|
|
|
365
384
|
return this._insertTypeAnnotationInReturnTypeAt(options as any, index);
|
|
366
385
|
}
|
|
367
386
|
|
|
387
|
+
|
|
388
|
+
|
|
368
389
|
/**
|
|
369
390
|
* 添加类型标注
|
|
370
391
|
* @param typeAnnotationOptions 类型标注参数
|
|
@@ -388,6 +409,11 @@ export class TypeAnnotation extends BaseNode {
|
|
|
388
409
|
return node;
|
|
389
410
|
}
|
|
390
411
|
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
|
|
391
417
|
/**
|
|
392
418
|
* 插入数据结构属性
|
|
393
419
|
* @internal
|
|
@@ -420,6 +446,8 @@ export class TypeAnnotation extends BaseNode {
|
|
|
420
446
|
return structureProperty;
|
|
421
447
|
}
|
|
422
448
|
|
|
449
|
+
|
|
450
|
+
|
|
423
451
|
/**
|
|
424
452
|
* 插入数据结构属性
|
|
425
453
|
* @param structurePropertyOptions 数据结构属性参数
|
|
@@ -442,6 +470,8 @@ export class TypeAnnotation extends BaseNode {
|
|
|
442
470
|
return node;
|
|
443
471
|
}
|
|
444
472
|
|
|
473
|
+
|
|
474
|
+
|
|
445
475
|
/**
|
|
446
476
|
* 添加数据结构属性
|
|
447
477
|
* @internal
|
|
@@ -461,6 +491,8 @@ export class TypeAnnotation extends BaseNode {
|
|
|
461
491
|
return this._insertStructurePropertyAt(options as any, index);
|
|
462
492
|
}
|
|
463
493
|
|
|
494
|
+
|
|
495
|
+
|
|
464
496
|
/**
|
|
465
497
|
* 添加数据结构属性
|
|
466
498
|
* @param structurePropertyOptions 数据结构属性参数
|
|
@@ -484,6 +516,9 @@ export class TypeAnnotation extends BaseNode {
|
|
|
484
516
|
return node;
|
|
485
517
|
}
|
|
486
518
|
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
|
|
487
522
|
/**
|
|
488
523
|
* 删除类型标注
|
|
489
524
|
* @param typeAnnotation 已有的类型标注实例
|
|
@@ -491,10 +526,12 @@ export class TypeAnnotation extends BaseNode {
|
|
|
491
526
|
removeTypeAnnotationInTypeArguments(typeAnnotation: TypeAnnotation): void;
|
|
492
527
|
|
|
493
528
|
removeTypeAnnotationInTypeArguments(options: TypeAnnotation) {
|
|
494
|
-
|
|
529
|
+
let typeAnnotation: TypeAnnotation = options;
|
|
495
530
|
return typeAnnotation.delete();
|
|
496
531
|
}
|
|
497
532
|
|
|
533
|
+
|
|
534
|
+
|
|
498
535
|
/**
|
|
499
536
|
* 删除类型标注
|
|
500
537
|
* @param typeAnnotation 已有的类型标注实例
|
|
@@ -502,7 +539,7 @@ export class TypeAnnotation extends BaseNode {
|
|
|
502
539
|
removeTypeAnnotationInReturnType(typeAnnotation: TypeAnnotation): void;
|
|
503
540
|
|
|
504
541
|
removeTypeAnnotationInReturnType(options: TypeAnnotation) {
|
|
505
|
-
|
|
542
|
+
let typeAnnotation: TypeAnnotation = options;
|
|
506
543
|
return typeAnnotation.delete();
|
|
507
544
|
}
|
|
508
545
|
|
|
@@ -529,6 +566,8 @@ export class TypeAnnotation extends BaseNode {
|
|
|
529
566
|
return params;
|
|
530
567
|
}
|
|
531
568
|
|
|
569
|
+
|
|
570
|
+
|
|
532
571
|
/**
|
|
533
572
|
* 删除数据结构属性
|
|
534
573
|
* @param structureProperty 已有的数据结构属性实例
|
|
@@ -536,7 +575,7 @@ export class TypeAnnotation extends BaseNode {
|
|
|
536
575
|
removeStructureProperty(structureProperty: StructureProperty): void;
|
|
537
576
|
|
|
538
577
|
removeStructureProperty(options: StructureProperty) {
|
|
539
|
-
|
|
578
|
+
let structureProperty: StructureProperty = options;
|
|
540
579
|
return structureProperty.delete();
|
|
541
580
|
}
|
|
542
581
|
|
|
@@ -858,13 +897,13 @@ export class TypeAnnotation extends BaseNode {
|
|
|
858
897
|
});
|
|
859
898
|
return code;
|
|
860
899
|
} else if (this.typeKind === 'anonymousStructure') {
|
|
861
|
-
let code = `{
|
|
900
|
+
let code = `{ `;
|
|
862
901
|
(this.properties || []).forEach((property, i) => {
|
|
863
902
|
code += `${property.name}: `;
|
|
864
903
|
code += `${property.typeAnnotation ? property.typeAnnotation.toEmbeddedTS(shiftState(state, code, { inline: true, tabSize: (state?.tabSize || 0) + 1 })) : '`未知`'}`;
|
|
865
|
-
|
|
866
|
-
code += ', ';
|
|
904
|
+
code += ', ';
|
|
867
905
|
});
|
|
906
|
+
code += `__name: "AStructure_${this.hash}" `;
|
|
868
907
|
code += ' }';
|
|
869
908
|
return code;
|
|
870
909
|
} else {
|
|
@@ -29,6 +29,8 @@ import BaseNode from '../common/BaseNode';
|
|
|
29
29
|
import classMap from '../common/classMap';
|
|
30
30
|
import TypeAnnotation from './TypeAnnotation__';
|
|
31
31
|
import Logic from './Logic__';
|
|
32
|
+
import AuthInterface from './AuthInterface__';
|
|
33
|
+
import AuthLogicForCallInterface from './AuthLogicForCallInterface__';
|
|
32
34
|
import View from './View__';
|
|
33
35
|
import Module from './Module__';
|
|
34
36
|
import App from './App__';
|
|
@@ -113,6 +115,18 @@ export class Variable extends BaseNode {
|
|
|
113
115
|
get process() {
|
|
114
116
|
return this.getAncestor('Process') as Process;
|
|
115
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* 祖先 AuthInterface
|
|
120
|
+
*/
|
|
121
|
+
get AuthLogic() {
|
|
122
|
+
return this.getAncestor('AuthInterface') as AuthInterface;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* 祖先 AuthLogicForCallInterface
|
|
126
|
+
*/
|
|
127
|
+
get AuthLogicForCallInterface() {
|
|
128
|
+
return this.getAncestor('AuthLogicForCallInterface') as AuthLogicForCallInterface;
|
|
129
|
+
}
|
|
116
130
|
|
|
117
131
|
/**
|
|
118
132
|
* @param source 需要合并的部分参数
|
|
@@ -18,9 +18,9 @@ import Module from './Module__';
|
|
|
18
18
|
import App from './App__';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* 平台类型
|
|
22
22
|
*/
|
|
23
|
-
@concept('
|
|
23
|
+
@concept('平台类型')
|
|
24
24
|
export class ViewComponent extends BaseNode {
|
|
25
25
|
/**
|
|
26
26
|
* 产品概念
|
|
@@ -29,19 +29,19 @@ export class ViewComponent extends BaseNode {
|
|
|
29
29
|
concept: 'ViewComponent' = 'ViewComponent';
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
32
|
+
* 平台类型名称
|
|
33
33
|
*/
|
|
34
34
|
@property()
|
|
35
35
|
name: string = undefined;
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* 平台类型标题
|
|
39
39
|
*/
|
|
40
40
|
@property()
|
|
41
41
|
title: string = undefined;
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
44
|
+
* 平台类型描述
|
|
45
45
|
*/
|
|
46
46
|
@property()
|
|
47
47
|
description: string = undefined;
|
|
@@ -77,7 +77,7 @@ export class ViewComponent extends BaseNode {
|
|
|
77
77
|
methods: Array<Logic> = [];
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
80
|
+
* 平台类型列表
|
|
81
81
|
*/
|
|
82
82
|
@property('ViewComponent')
|
|
83
83
|
children: Array<ViewComponent> = [];
|
|
@@ -713,23 +713,23 @@ export class ViewComponent extends BaseNode {
|
|
|
713
713
|
}
|
|
714
714
|
|
|
715
715
|
/**
|
|
716
|
-
*
|
|
716
|
+
* 插入平台类型
|
|
717
717
|
* @internal
|
|
718
|
-
* @param name
|
|
718
|
+
* @param name 平台类型名称,如果不填会自动生成一个唯一名称
|
|
719
719
|
*/
|
|
720
720
|
_insertViewComponentAt(name: string, index: number): ViewComponent;
|
|
721
721
|
|
|
722
722
|
/**
|
|
723
|
-
*
|
|
723
|
+
* 插入平台类型
|
|
724
724
|
* @internal
|
|
725
|
-
* @param viewComponentOptions
|
|
725
|
+
* @param viewComponentOptions 平台类型参数
|
|
726
726
|
*/
|
|
727
727
|
_insertViewComponentAt(viewComponentOptions: Partial<ViewComponent>, index: number): ViewComponent;
|
|
728
728
|
|
|
729
729
|
/**
|
|
730
|
-
*
|
|
730
|
+
* 插入平台类型
|
|
731
731
|
* @internal
|
|
732
|
-
* @param viewComponent
|
|
732
|
+
* @param viewComponent 已有的平台类型实例
|
|
733
733
|
*/
|
|
734
734
|
_insertViewComponentAt(viewComponent: ViewComponent, index: number): ViewComponent;
|
|
735
735
|
|
|
@@ -762,20 +762,20 @@ export class ViewComponent extends BaseNode {
|
|
|
762
762
|
}
|
|
763
763
|
|
|
764
764
|
/**
|
|
765
|
-
*
|
|
766
|
-
* @param name
|
|
765
|
+
* 插入平台类型
|
|
766
|
+
* @param name 平台类型名称,如果不填会自动生成一个唯一名称
|
|
767
767
|
*/
|
|
768
768
|
insertViewComponentAt(name: string, index: number): ViewComponent;
|
|
769
769
|
|
|
770
770
|
/**
|
|
771
|
-
*
|
|
772
|
-
* @param viewComponentOptions
|
|
771
|
+
* 插入平台类型
|
|
772
|
+
* @param viewComponentOptions 平台类型参数
|
|
773
773
|
*/
|
|
774
774
|
insertViewComponentAt(viewComponentOptions: Partial<ViewComponent>, index: number): ViewComponent;
|
|
775
775
|
|
|
776
776
|
/**
|
|
777
|
-
*
|
|
778
|
-
* @param viewComponent
|
|
777
|
+
* 插入平台类型
|
|
778
|
+
* @param viewComponent 已有的平台类型实例
|
|
779
779
|
*/
|
|
780
780
|
insertViewComponentAt(viewComponent: ViewComponent, index: number): ViewComponent;
|
|
781
781
|
|
|
@@ -790,23 +790,23 @@ export class ViewComponent extends BaseNode {
|
|
|
790
790
|
}
|
|
791
791
|
|
|
792
792
|
/**
|
|
793
|
-
*
|
|
793
|
+
* 添加平台类型
|
|
794
794
|
* @internal
|
|
795
|
-
* @param name
|
|
795
|
+
* @param name 平台类型名称,如果不填会自动生成一个唯一名称
|
|
796
796
|
*/
|
|
797
797
|
_addViewComponent(name?: string): ViewComponent;
|
|
798
798
|
|
|
799
799
|
/**
|
|
800
|
-
*
|
|
800
|
+
* 添加平台类型
|
|
801
801
|
* @internal
|
|
802
|
-
* @param viewComponentOptions
|
|
802
|
+
* @param viewComponentOptions 平台类型参数
|
|
803
803
|
*/
|
|
804
804
|
_addViewComponent(viewComponentOptions: Partial<ViewComponent>): ViewComponent;
|
|
805
805
|
|
|
806
806
|
/**
|
|
807
|
-
*
|
|
807
|
+
* 添加平台类型
|
|
808
808
|
* @internal
|
|
809
|
-
* @param viewComponent
|
|
809
|
+
* @param viewComponent 已有的平台类型实例
|
|
810
810
|
*/
|
|
811
811
|
_addViewComponent(viewComponent: ViewComponent): ViewComponent;
|
|
812
812
|
|
|
@@ -816,21 +816,21 @@ export class ViewComponent extends BaseNode {
|
|
|
816
816
|
}
|
|
817
817
|
|
|
818
818
|
/**
|
|
819
|
-
*
|
|
819
|
+
* 添加平台类型
|
|
820
820
|
* @internal
|
|
821
|
-
* @param name
|
|
821
|
+
* @param name 平台类型名称,如果不填会自动生成一个唯一名称
|
|
822
822
|
*/
|
|
823
823
|
addViewComponent(name?: string): ViewComponent;
|
|
824
824
|
|
|
825
825
|
/**
|
|
826
|
-
*
|
|
827
|
-
* @param viewComponentOptions
|
|
826
|
+
* 添加平台类型
|
|
827
|
+
* @param viewComponentOptions 平台类型参数
|
|
828
828
|
*/
|
|
829
829
|
addViewComponent(viewComponentOptions: Partial<ViewComponent>): ViewComponent;
|
|
830
830
|
|
|
831
831
|
/**
|
|
832
|
-
*
|
|
833
|
-
* @param viewComponent
|
|
832
|
+
* 添加平台类型
|
|
833
|
+
* @param viewComponent 已有的平台类型实例
|
|
834
834
|
*/
|
|
835
835
|
addViewComponent(viewComponent: ViewComponent): ViewComponent;
|
|
836
836
|
|
|
@@ -1191,14 +1191,14 @@ export class ViewComponent extends BaseNode {
|
|
|
1191
1191
|
|
|
1192
1192
|
|
|
1193
1193
|
/**
|
|
1194
|
-
*
|
|
1195
|
-
* @param name
|
|
1194
|
+
* 删除平台类型
|
|
1195
|
+
* @param name 平台类型名称
|
|
1196
1196
|
*/
|
|
1197
1197
|
removeViewComponent(name: string): void;
|
|
1198
1198
|
|
|
1199
1199
|
/**
|
|
1200
|
-
*
|
|
1201
|
-
* @param viewComponent
|
|
1200
|
+
* 删除平台类型
|
|
1201
|
+
* @param viewComponent 已有的平台类型实例
|
|
1202
1202
|
*/
|
|
1203
1203
|
removeViewComponent(viewComponent: ViewComponent): void;
|
|
1204
1204
|
|
|
@@ -1207,7 +1207,7 @@ export class ViewComponent extends BaseNode {
|
|
|
1207
1207
|
if (typeof options === 'string') {
|
|
1208
1208
|
viewComponent = (this.children as ViewComponent[]).find((item) => item.name === options);
|
|
1209
1209
|
if (!viewComponent) {
|
|
1210
|
-
throw new Error('
|
|
1210
|
+
throw new Error('找不到平台类型 ' + options);
|
|
1211
1211
|
}
|
|
1212
1212
|
} else {
|
|
1213
1213
|
viewComponent = options;
|
|
@@ -1406,7 +1406,7 @@ export class ViewElement extends BaseNode {
|
|
|
1406
1406
|
}
|
|
1407
1407
|
|
|
1408
1408
|
toHump(name: string): string {
|
|
1409
|
-
return name.replace(
|
|
1409
|
+
return name.replace(/-(\w)/g, (all, letter) => letter.toUpperCase());
|
|
1410
1410
|
}
|
|
1411
1411
|
toFirstUpper(name: string): string {
|
|
1412
1412
|
return name.replace(/^\S/, (s) => s.toUpperCase());
|
|
@@ -2242,6 +2242,109 @@ export class ViewElement extends BaseNode {
|
|
|
2242
2242
|
current = (index === 0 ? 'current' : 'current' + index);
|
|
2243
2243
|
return current;
|
|
2244
2244
|
}
|
|
2245
|
+
|
|
2246
|
+
/**
|
|
2247
|
+
* 计算约束样式
|
|
2248
|
+
*/
|
|
2249
|
+
computeConstraintStyle(nodeRect: DOMRect, parentRect: DOMRect) {
|
|
2250
|
+
const constraintWidth = nodeRect.width;
|
|
2251
|
+
const constraintHeight = nodeRect.height;
|
|
2252
|
+
const constraintLeft = nodeRect.x - parentRect.x;
|
|
2253
|
+
const constraintTop = nodeRect.y - parentRect.y;
|
|
2254
|
+
const constraintRight = (parentRect.width - nodeRect.width - constraintLeft);
|
|
2255
|
+
const constraintBottom = (parentRect.height - nodeRect.height - constraintTop);
|
|
2256
|
+
const styleObj = this.parseStyleToObject(this.staticStyle);
|
|
2257
|
+
const { '--constraint-x': constraintHorizontal = 'left',
|
|
2258
|
+
'--constraint-y': constraintVertical = 'top',
|
|
2259
|
+
width: staticWidth = '',
|
|
2260
|
+
height: staticHeight = '' } = styleObj;
|
|
2261
|
+
let left = '';
|
|
2262
|
+
let right = '';
|
|
2263
|
+
let top = '';
|
|
2264
|
+
let bottom = '';
|
|
2265
|
+
let transform = '';
|
|
2266
|
+
let width = staticWidth;
|
|
2267
|
+
let height = staticHeight;
|
|
2268
|
+
|
|
2269
|
+
const parentWidth = constraintLeft + constraintWidth + constraintRight;
|
|
2270
|
+
const parentHeight = constraintTop + constraintHeight + constraintBottom;
|
|
2271
|
+
|
|
2272
|
+
if (constraintHorizontal === 'left') {
|
|
2273
|
+
left = constraintLeft + 'px';
|
|
2274
|
+
right = '';
|
|
2275
|
+
} else if (constraintHorizontal === 'right') {
|
|
2276
|
+
left = '';
|
|
2277
|
+
right = constraintRight + 'px';
|
|
2278
|
+
} else if (constraintHorizontal === 'center') {
|
|
2279
|
+
const offset = constraintLeft + constraintWidth / 2 - parentWidth / 2;
|
|
2280
|
+
left = `calc(50% ${offset > 0 ? '+' : '-'} ${Math.abs(offset)}px)`;
|
|
2281
|
+
right = '';
|
|
2282
|
+
transform = 'translateX(-50%)';
|
|
2283
|
+
} else if (constraintHorizontal === 'scale') {
|
|
2284
|
+
left = constraintLeft * 100 / parentWidth + '%';
|
|
2285
|
+
right = constraintRight * 100 / parentWidth + '%';
|
|
2286
|
+
width = 'auto';
|
|
2287
|
+
} else if (constraintHorizontal === 'left-right') {
|
|
2288
|
+
left = constraintLeft + 'px';
|
|
2289
|
+
right = constraintRight + 'px';
|
|
2290
|
+
width = 'auto';
|
|
2291
|
+
}
|
|
2292
|
+
|
|
2293
|
+
if (constraintVertical === 'top') {
|
|
2294
|
+
top = constraintTop + 'px';
|
|
2295
|
+
bottom = '';
|
|
2296
|
+
} else if (constraintVertical === 'bottom') {
|
|
2297
|
+
top = '';
|
|
2298
|
+
bottom = constraintBottom + 'px';
|
|
2299
|
+
} else if (constraintVertical === 'center') {
|
|
2300
|
+
const offset = constraintTop + constraintHeight / 2 - parentHeight / 2;
|
|
2301
|
+
top = `calc(50% ${offset > 0 ? '+' : '-'} ${Math.abs(offset)}px)`;
|
|
2302
|
+
bottom = '';
|
|
2303
|
+
transform = transform ? 'translate(-50%, -50%)' : 'translateY(-50%)';
|
|
2304
|
+
} else if (constraintVertical === 'scale') {
|
|
2305
|
+
top = constraintTop * 100 / parentHeight + '%';
|
|
2306
|
+
bottom = constraintBottom * 100 / parentHeight + '%';
|
|
2307
|
+
height = 'auto';
|
|
2308
|
+
} else if (constraintVertical === 'top-bottom') {
|
|
2309
|
+
top = constraintTop + 'px';
|
|
2310
|
+
bottom = constraintBottom + 'px';
|
|
2311
|
+
height = 'auto';
|
|
2312
|
+
}
|
|
2313
|
+
const newStyleObj: Record<string, any> = {
|
|
2314
|
+
...styleObj,
|
|
2315
|
+
left,
|
|
2316
|
+
right,
|
|
2317
|
+
top,
|
|
2318
|
+
bottom,
|
|
2319
|
+
transform,
|
|
2320
|
+
width,
|
|
2321
|
+
height,
|
|
2322
|
+
};
|
|
2323
|
+
const newStaticStyle = this.stringifyStyleAttr(newStyleObj);
|
|
2324
|
+
this.update({
|
|
2325
|
+
staticStyle: newStaticStyle,
|
|
2326
|
+
});
|
|
2327
|
+
}
|
|
2328
|
+
|
|
2329
|
+
parseStyleToObject(styleStr: string = '') {
|
|
2330
|
+
const styleObj = styleStr.split(/;/gim).reduce((obj:Record<string, string | number>, item) => {
|
|
2331
|
+
// background-image:url(http://www...)
|
|
2332
|
+
item = item.trim();
|
|
2333
|
+
const pos = item.indexOf(':');
|
|
2334
|
+
if (pos >= 0) {
|
|
2335
|
+
const key = item.slice(0, pos).trim();
|
|
2336
|
+
const value = item.slice(pos + 1).trim();
|
|
2337
|
+
obj[key] = value;
|
|
2338
|
+
}
|
|
2339
|
+
return obj;
|
|
2340
|
+
}, {});
|
|
2341
|
+
return styleObj;
|
|
2342
|
+
}
|
|
2343
|
+
stringifyStyleAttr(styleObj: Record<string, string | number>) {
|
|
2344
|
+
return Object.keys(styleObj)
|
|
2345
|
+
.map((key) => `${key}:${String(styleObj[key]).trim()};`)
|
|
2346
|
+
.join('');
|
|
2347
|
+
}
|
|
2245
2348
|
//================================================================================
|
|
2246
2349
|
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
2247
2350
|
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|