@lcap/nasl 2.18.0 → 2.20.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/out/automate/engine/index.js +3 -3
- package/out/automate/engine/index.js.map +1 -1
- package/out/bak/translator.js +85 -37
- package/out/bak/translator.js.map +1 -1
- package/out/common/BaseNode.d.ts +6 -10
- package/out/common/BaseNode.js +7 -52
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/AnonymousFunction__.js.map +1 -1
- package/out/concepts/App__.d.ts +0 -10
- package/out/concepts/App__.js +0 -74
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Assignee__.js.map +1 -1
- package/out/concepts/AssignmentLine__.d.ts +5 -5
- package/out/concepts/AssignmentLine__.js +6 -6
- package/out/concepts/AssignmentLine__.js.map +1 -1
- package/out/concepts/Assignment__.js +2 -1
- package/out/concepts/Assignment__.js.map +1 -1
- package/out/concepts/BatchAssignment__.d.ts +60 -60
- package/out/concepts/BatchAssignment__.js +11 -21
- package/out/concepts/BatchAssignment__.js.map +1 -1
- package/out/concepts/BindAttribute__.d.ts +0 -19
- package/out/concepts/BindAttribute__.js +2 -39
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BindStyle__.d.ts +2 -2
- package/out/concepts/BindStyle__.js +3 -3
- package/out/concepts/BindStyle__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.js +8 -0
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/CallFunction__.js +25 -58
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallInterface__.d.ts +0 -7
- package/out/concepts/CallInterface__.js +7 -53
- package/out/concepts/CallInterface__.js.map +1 -1
- package/out/concepts/CallLogic__.js +14 -63
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.js +1 -13
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/CompletionProperty__.js +0 -3
- package/out/concepts/CompletionProperty__.js.map +1 -1
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Configuration__.js.map +1 -1
- package/out/concepts/DataSource__.d.ts +0 -6
- package/out/concepts/DataSource__.js +0 -41
- package/out/concepts/DataSource__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +1 -9
- package/out/concepts/Destination__.js +29 -61
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +8 -21
- package/out/concepts/EntityProperty__.js +23 -109
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +0 -32
- package/out/concepts/Entity__.js +2 -117
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/Enum__.js +4 -0
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/ForEachStatement__.d.ts +4 -0
- package/out/concepts/ForEachStatement__.js +8 -4
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.js +4 -16
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.d.ts +0 -8
- package/out/concepts/IfStatement__.js +0 -22
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +1 -1
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +1 -6
- package/out/concepts/Logic__.js +43 -144
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MatchCase__.d.ts +1 -1
- package/out/concepts/MatchCase__.js +8 -15
- package/out/concepts/MatchCase__.js.map +1 -1
- package/out/concepts/Match__.d.ts +19 -21
- package/out/concepts/Match__.js +25 -112
- package/out/concepts/Match__.js.map +1 -1
- package/out/concepts/MemberExpression__.d.ts +1 -4
- package/out/concepts/MemberExpression__.js +15 -30
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/Namespace__.js.map +1 -1
- package/out/concepts/NumericLiteral__.js +1 -1
- package/out/concepts/NumericLiteral__.js.map +1 -1
- package/out/concepts/OqlQueryComponent__.d.ts +3 -7
- package/out/concepts/OqlQueryComponent__.js +95 -56
- package/out/concepts/OqlQueryComponent__.js.map +1 -1
- package/out/concepts/Param__.d.ts +1 -1
- package/out/concepts/Param__.js +4 -40
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessComponent__.js.map +1 -1
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/QueryOrderByExpression__.d.ts +3 -3
- package/out/concepts/QueryOrderByExpression__.js +3 -3
- package/out/concepts/QueryOrderByExpression__.js.map +1 -1
- package/out/concepts/QuerySelectExpression__.js.map +1 -1
- package/out/concepts/Return__.js +2 -38
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/SelectMembers__.d.ts +1 -1
- package/out/concepts/SelectMembers__.js +2 -2
- package/out/concepts/SelectMembers__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.d.ts +4 -2
- package/out/concepts/SqlQueryComponent__.js +88 -9
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/StringLiteral__.js +7 -0
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +0 -1
- package/out/concepts/TypeAnnotation__.js +12 -25
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/TypeParam__.d.ts +0 -1
- package/out/concepts/TypeParam__.js +0 -2
- package/out/concepts/TypeParam__.js.map +1 -1
- package/out/concepts/UnaryExpression__.js +9 -6
- package/out/concepts/UnaryExpression__.js.map +1 -1
- package/out/concepts/ValidationRule__.js +23 -88
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/Variable__.js +2 -38
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewComponent__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +29 -30
- package/out/concepts/ViewElement__.js +51 -117
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +3 -4
- package/out/concepts/View__.js +83 -93
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.js +1 -1
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.browser.js +0 -50
- package/out/concepts/basics/stdlib/nasl.browser.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +4 -36
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +43 -63
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/index__.d.ts +0 -2
- package/out/concepts/index__.js +0 -2
- package/out/concepts/index__.js.map +1 -1
- package/out/generator/genBundleFiles.d.ts +2 -5
- package/out/generator/genBundleFiles.js +45 -148
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/index.d.ts +0 -1
- package/out/generator/index.js +0 -1
- package/out/generator/index.js.map +1 -1
- package/out/index.d.ts +2 -3
- package/out/index.js +1 -5
- package/out/index.js.map +1 -1
- package/out/server/entity2LogicNamespace.js +11 -11
- package/out/server/entity2LogicNamespace.js.map +1 -1
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/formatTsUtils.js +17 -10
- package/out/server/formatTsUtils.js.map +1 -1
- package/out/server/getLogics.js +6 -13
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +7 -7
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.d.ts +1 -1
- package/out/server/index.d.ts +1 -0
- package/out/server/index.js +27 -2
- package/out/server/index.js.map +1 -1
- package/out/server/naslServer.d.ts +7 -47
- package/out/server/naslServer.js +393 -591
- package/out/server/naslServer.js.map +1 -1
- package/out/server/naslStdlibMap.js +28 -30
- package/out/server/naslStdlibMap.js.map +1 -1
- package/out/server/translator.js +7 -40
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.js +3 -33
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +4 -6
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +4 -7
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +5 -7
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEnumSelectBlock.js +2 -5
- package/out/templator/genEnumSelectBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +2 -2
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +2 -2
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genQueryComponent.d.ts +2 -2
- package/out/templator/genQueryComponent.js +1 -4
- package/out/templator/genQueryComponent.js.map +1 -1
- package/out/templator/genTableBlock.js +2 -2
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +3 -4
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.js +1 -1
- package/out/templator/utils.js.map +1 -1
- package/out/test/integration/node-nasl-server.js +38 -10
- package/out/test/integration/node-nasl-server.js.map +1 -1
- package/out/translator/index.d.ts +0 -1
- package/out/translator/index.js +1 -1
- package/out/translator/index.js.map +1 -1
- package/out/utils/index.d.ts +0 -1
- package/out/utils/index.js +1 -38
- package/out/utils/index.js.map +1 -1
- package/out/utils/string.d.ts +2 -15
- package/out/utils/string.js +3 -18
- package/out/utils/string.js.map +1 -1
- package/package.json +2 -2
- package/sandbox/stdlib/nasl.auth.ts +1 -1
- package/sandbox/stdlib/nasl.core.ts +1 -0
- package/sandbox/stdlib/nasl.logging.ts +4 -4
- package/sandbox/stdlib/nasl.util.ts +9 -5
- package/src/automate/engine/index.js +4 -4
- package/src/automate/engine/uniqueName.js +3 -3
- package/src/automate/template/myProcess.js +1 -1
- package/src/automate/upgrader/2.20.js +41 -0
- package/src/bak/translator.js +4 -1
- package/src/common/BaseNode.ts +1 -0
- package/src/concepts/AnonymousFunction__.ts +48 -2
- package/src/concepts/App__.ts +288 -615
- package/src/concepts/BatchAssignment__.ts +111 -51
- package/src/concepts/BindAttribute__.ts +18 -25
- package/src/concepts/BindDirective__.ts +7 -0
- package/src/concepts/BindEvent__.ts +7 -0
- package/src/concepts/BindStyle__.ts +7 -0
- package/src/concepts/CallFunction__.ts +34 -45
- package/src/concepts/CallInterface__.ts +2 -1
- package/src/concepts/CallLogic__.ts +87 -55
- package/src/concepts/CallQueryComponent__.ts +4 -1
- package/src/concepts/Constant__.ts +7 -0
- package/src/concepts/DataSource__.ts +57 -5
- package/src/concepts/Destination__.ts +100 -43
- package/src/concepts/Frontend__.ts +937 -0
- package/src/concepts/Identifier__.ts +18 -16
- package/src/concepts/LogicItem__.ts +8 -1
- package/src/concepts/Logic__.ts +134 -149
- package/src/concepts/Match__.ts +13 -29
- package/src/concepts/NewComposite__.ts +1357 -0
- package/src/concepts/NewList__.ts +440 -0
- package/src/concepts/NewMap__.ts +666 -0
- package/src/concepts/New__.ts +73 -0
- package/src/concepts/Param__.ts +245 -199
- package/src/concepts/ProcessElement__.ts +43 -36
- package/src/concepts/ProcessOutcomes__.ts +90 -0
- package/src/concepts/Process__.ts +1 -23
- package/src/concepts/Return__.ts +11 -1
- package/src/concepts/SelectMembers__.ts +3 -3
- package/src/concepts/Transactional__.ts +7 -0
- package/src/concepts/TypeAnnotation__.ts +54 -49
- package/src/concepts/ValidationRule__.ts +19 -1
- package/src/concepts/Variable__.ts +12 -6
- package/src/concepts/ViewElement__.ts +26 -3
- package/src/concepts/View__.ts +25 -25
- package/src/concepts/basics/stdlib/nasl.auth.ts +1 -1
- package/src/concepts/basics/stdlib/nasl.logging.ts +5 -0
- package/src/concepts/basics/stdlib/nasl.ui.ts +2 -0
- package/src/concepts/basics/stdlib/nasl.util.ts +153 -19
- package/src/concepts/index__.ts +7 -0
- package/src/enums/KEYWORDS.ts +9 -0
- package/src/generator/genBundleFiles.ts +74 -245
- package/src/generator/genMetaData.ts +178 -78
- package/src/generator/genReleaseBody.ts +87 -44
- package/src/generator/index.ts +1 -0
- package/src/generator/permission.ts +261 -0
- package/src/index.ts +1 -1
- package/src/server/entity2LogicNamespace.ts +90 -10
- package/src/server/extendBaseNode.ts +33 -22
- package/src/server/formatTsUtils.ts +36 -46
- package/src/server/getLogics.ts +13 -1
- package/src/server/getMemberIdentifier.ts +5 -5
- package/src/server/getProcesses.ts +1 -1
- package/src/server/naslServer.ts +254 -71
- package/src/server/process2LogicNamespace.ts +8 -0
- package/src/server/translator.ts +51 -5
- package/src/service/creator/add.configs.js +4 -0
- package/src/service/datasource/api.js +11 -0
- package/src/service/datasource/index.js +6 -0
- package/src/service/storage/init.ts +12 -0
- package/src/service/video/VideoTranscribe.js +1 -0
- package/src/templator/genEditTableBlock.ts +8 -16
- package/src/templator/genGetBlock.ts +18 -19
- package/src/templator/genGridViewBlock.ts +18 -18
- package/src/templator/genListViewBlock.ts +8 -11
- package/src/templator/genTableBlock.ts +6 -10
- package/ts-worker/lib/tsserver.js +8 -1
- package/out/automate/engine/2.14-components.d.ts +0 -1115
- package/out/automate/engine/2.14-components.js +0 -1087
- package/out/automate/engine/2.14-components.js.map +0 -1
- package/out/concepts/ExternalDestination__.d.ts +0 -73
- package/out/concepts/ExternalDestination__.js +0 -264
- package/out/concepts/ExternalDestination__.js.map +0 -1
- package/out/concepts/MatchExpression__.d.ts +0 -97
- package/out/concepts/MatchExpression__.js +0 -281
- package/out/concepts/MatchExpression__.js.map +0 -1
- package/out/concepts/StringInterpolation__.d.ts +0 -113
- package/out/concepts/StringInterpolation__.js +0 -227
- package/out/concepts/StringInterpolation__.js.map +0 -1
- package/out/generator/genReleaseBody.d.ts +0 -41
- package/out/generator/genReleaseBody.js +0 -340
- package/out/generator/genReleaseBody.js.map +0 -1
- package/out/service/defaultErrorMessage.json +0 -97
- package/out/service/logic/api.d.ts +0 -9
- package/out/service/logic/api.js +0 -11
- package/out/service/logic/api.js.map +0 -1
- package/out/service/logic/index.d.ts +0 -2
- package/out/service/logic/index.js +0 -10
- package/out/service/logic/index.js.map +0 -1
- package/src/automate/engine/dist/index.dev.js +0 -517
- package/src/common/dist/BaseNode.js +0 -1101
- package/src/concepts/basics/stdlib/dist/reference2TypeAnnotationList.js +0 -24
- package/src/concepts/dist/Anchor__.js +0 -179
- package/src/concepts/dist/Assignment__.js +0 -301
- package/src/concepts/dist/CallFunction__.js +0 -473
- package/src/concepts/dist/CallInterface__.js +0 -533
- package/src/concepts/dist/CallLogic__.js +0 -864
- package/src/concepts/dist/ForEachStatement__.js +0 -426
- package/src/concepts/dist/MatchCase__.js +0 -587
- package/src/concepts/dist/MemberExpression__.js +0 -348
- package/src/concepts/dist/Param__.js +0 -537
- package/src/concepts/dist/Return__.js +0 -493
- package/src/generator/dist/genBundleFiles.js +0 -414
- package/src/server/dist/formatTsUtils.js +0 -683
- package/src/server/dist/naslServer.js +0 -3396
- package/src/service/storage/dist/init.js +0 -541
- package/ts-worker/dist/webpack.config.dev.js +0 -104
- package/ts-worker/lib/dist/tsserver.dev.js +0 -22953
- package/ts-worker/sources/lib/dist/tsserver.dev.js +0 -22912
|
@@ -0,0 +1,937 @@
|
|
|
1
|
+
import { TranslatorState, shiftState, withSourceMap, indent, createCompilerState } from '../translator';
|
|
2
|
+
import Namespace from './Namespace__';
|
|
3
|
+
|
|
4
|
+
//================================================================================
|
|
5
|
+
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
6
|
+
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
7
|
+
//================================================================================
|
|
8
|
+
import { EventPayload, Params } from '../common/EventEmitter';
|
|
9
|
+
import { concept, excludedInJSON, property } from '../decorators';
|
|
10
|
+
|
|
11
|
+
import * as utils from '../utils';
|
|
12
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
13
|
+
import BaseNode from '../common/BaseNode';
|
|
14
|
+
import classMap from '../common/classMap';
|
|
15
|
+
import View from './View__';
|
|
16
|
+
import Variable from './Variable__';
|
|
17
|
+
import Theme from './Theme__';
|
|
18
|
+
import Module from './Module__';
|
|
19
|
+
import App, { AssetsInfo } from './App__';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 端
|
|
23
|
+
*/
|
|
24
|
+
@concept('端')
|
|
25
|
+
export class Frontend extends BaseNode {
|
|
26
|
+
/**
|
|
27
|
+
* 产品概念
|
|
28
|
+
*/
|
|
29
|
+
@property()
|
|
30
|
+
concept: 'Frontend' = 'Frontend';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 端标识
|
|
34
|
+
*/
|
|
35
|
+
@property()
|
|
36
|
+
name: string = undefined;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* pc端
|
|
40
|
+
*/
|
|
41
|
+
@property()
|
|
42
|
+
title: string = undefined;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* PC/H5 端
|
|
46
|
+
*/
|
|
47
|
+
@property()
|
|
48
|
+
type: 'pc' | 'h5' = undefined;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 基础路径
|
|
52
|
+
*/
|
|
53
|
+
@property()
|
|
54
|
+
path: string = undefined;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 制品应用标题
|
|
58
|
+
*/
|
|
59
|
+
@property()
|
|
60
|
+
documentTitle: string = undefined;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 制品应用图标
|
|
64
|
+
*/
|
|
65
|
+
@property()
|
|
66
|
+
documentIcon: string = undefined;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 页面列表
|
|
70
|
+
*/
|
|
71
|
+
@property('View')
|
|
72
|
+
views: Array<View> = [];
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 变量列表
|
|
76
|
+
*/
|
|
77
|
+
@property('Variable')
|
|
78
|
+
variables: Array<Variable> = [];
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 主题配置
|
|
82
|
+
*/
|
|
83
|
+
@property('Theme')
|
|
84
|
+
theme: Theme = new Theme();
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* 扩展组件列表(兼容老版)
|
|
88
|
+
*/
|
|
89
|
+
@property('Module')
|
|
90
|
+
componentDependencies: Array<Module> = [];
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* 祖先 App
|
|
94
|
+
*/
|
|
95
|
+
get app() {
|
|
96
|
+
return this.getAncestor('App') as App;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @param source 需要合并的部分参数
|
|
101
|
+
*/
|
|
102
|
+
constructor(source?: Partial<Frontend>) {
|
|
103
|
+
source = Object.assign({}, Frontend.getDefaultOptions(), source);
|
|
104
|
+
super(source);
|
|
105
|
+
super.subConstructor(source);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
static from(source: any, parentNode?: any, parentKey?: string): Frontend {
|
|
109
|
+
return super.from(source, parentNode, parentKey) as Frontend;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* 从父级删除该节点
|
|
114
|
+
* @internal
|
|
115
|
+
*/
|
|
116
|
+
_delete() {
|
|
117
|
+
let params: Params = null;
|
|
118
|
+
if (this.parentNode) {
|
|
119
|
+
params = (this.parentNode as any)?.__removeFrontend?.(this);
|
|
120
|
+
}
|
|
121
|
+
return params;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* 设置端标识
|
|
125
|
+
*/
|
|
126
|
+
setName(name: string) {
|
|
127
|
+
const object = {
|
|
128
|
+
name,
|
|
129
|
+
};
|
|
130
|
+
this.update({
|
|
131
|
+
...object,
|
|
132
|
+
field: 'name',
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* 设置pc端
|
|
138
|
+
*/
|
|
139
|
+
setTitle(title: string) {
|
|
140
|
+
const object = {
|
|
141
|
+
title,
|
|
142
|
+
};
|
|
143
|
+
this.update({
|
|
144
|
+
...object,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* 设置基础路径
|
|
150
|
+
*/
|
|
151
|
+
setPath(path: string) {
|
|
152
|
+
const object = {
|
|
153
|
+
path,
|
|
154
|
+
};
|
|
155
|
+
this.update({
|
|
156
|
+
...object,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* 设置制品应用标题
|
|
162
|
+
*/
|
|
163
|
+
setDocumentTitle(documentTitle: string) {
|
|
164
|
+
const object = {
|
|
165
|
+
documentTitle,
|
|
166
|
+
};
|
|
167
|
+
this.update({
|
|
168
|
+
...object,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* 设置制品应用图标
|
|
174
|
+
*/
|
|
175
|
+
setDocumentIcon(documentIcon: string) {
|
|
176
|
+
const object = {
|
|
177
|
+
documentIcon,
|
|
178
|
+
};
|
|
179
|
+
this.update({
|
|
180
|
+
...object,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
getViewExistingNames(excludedList: Array<View> = []) {
|
|
185
|
+
const excludedSet = new Set(excludedList);
|
|
186
|
+
return ((this.views as View[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
187
|
+
}
|
|
188
|
+
getViewUniqueName(name = 'view1') {
|
|
189
|
+
return utils.unique(name, this.getViewExistingNames(), undefined, true);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* 插入页面
|
|
194
|
+
* @internal
|
|
195
|
+
* @param name 页面名称,如果不填会自动生成一个唯一名称
|
|
196
|
+
*/
|
|
197
|
+
_insertViewAt(name: string, index: number): View;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* 插入页面
|
|
201
|
+
* @internal
|
|
202
|
+
* @param viewOptions 页面参数
|
|
203
|
+
*/
|
|
204
|
+
_insertViewAt(viewOptions: Partial<View>, index: number): View;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* 插入页面
|
|
208
|
+
* @internal
|
|
209
|
+
* @param view 已有的页面实例
|
|
210
|
+
*/
|
|
211
|
+
_insertViewAt(view: View, index: number): View;
|
|
212
|
+
|
|
213
|
+
_insertViewAt(options: string | Partial<View> | View, index: number) {
|
|
214
|
+
const viewOptions: any = {};
|
|
215
|
+
const relationOptions = { parentNode: this, parentKey: 'views' };
|
|
216
|
+
let view: View;
|
|
217
|
+
if (!options) {
|
|
218
|
+
view = View.from({
|
|
219
|
+
...viewOptions,
|
|
220
|
+
name: this.getViewUniqueName(),
|
|
221
|
+
}, this, 'views');
|
|
222
|
+
} else if (typeof options === 'string') {
|
|
223
|
+
view = View.from({
|
|
224
|
+
...viewOptions,
|
|
225
|
+
name: options,
|
|
226
|
+
}, this, 'views');
|
|
227
|
+
} else if (options instanceof View) {
|
|
228
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
229
|
+
view = options;
|
|
230
|
+
Object.assign(view, relationOptions);
|
|
231
|
+
} else {
|
|
232
|
+
view = View.from({
|
|
233
|
+
...viewOptions,
|
|
234
|
+
...options,
|
|
235
|
+
}, this, 'views');
|
|
236
|
+
}
|
|
237
|
+
this.views.splice(index, 0, view);
|
|
238
|
+
return view;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* 插入页面
|
|
243
|
+
* @param name 页面名称,如果不填会自动生成一个唯一名称
|
|
244
|
+
*/
|
|
245
|
+
insertViewAt(name: string, index: number): View;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* 插入页面
|
|
249
|
+
* @param viewOptions 页面参数
|
|
250
|
+
*/
|
|
251
|
+
insertViewAt(viewOptions: Partial<View>, index: number): View;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* 插入页面
|
|
255
|
+
* @param view 已有的页面实例
|
|
256
|
+
*/
|
|
257
|
+
insertViewAt(view: View, index: number): View;
|
|
258
|
+
|
|
259
|
+
insertViewAt(options: string | Partial<View> | View, index: number) {
|
|
260
|
+
const node = this._insertViewAt(options as any, index);
|
|
261
|
+
node.create({
|
|
262
|
+
index,
|
|
263
|
+
parentNode: this,
|
|
264
|
+
parentKey: 'views',
|
|
265
|
+
});
|
|
266
|
+
return node;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* 添加页面
|
|
271
|
+
* @internal
|
|
272
|
+
* @param name 页面名称,如果不填会自动生成一个唯一名称
|
|
273
|
+
*/
|
|
274
|
+
_addView(name?: string): View;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* 添加页面
|
|
278
|
+
* @internal
|
|
279
|
+
* @param viewOptions 页面参数
|
|
280
|
+
*/
|
|
281
|
+
_addView(viewOptions: Partial<View>): View;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* 添加页面
|
|
285
|
+
* @internal
|
|
286
|
+
* @param view 已有的页面实例
|
|
287
|
+
*/
|
|
288
|
+
_addView(view: View): View;
|
|
289
|
+
|
|
290
|
+
_addView(options?: string | Partial<View> | View) {
|
|
291
|
+
const index = this.views.length;
|
|
292
|
+
return this._insertViewAt(options as any, index);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* 添加页面
|
|
297
|
+
* @internal
|
|
298
|
+
* @param name 页面名称,如果不填会自动生成一个唯一名称
|
|
299
|
+
*/
|
|
300
|
+
addView(name?: string): View;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* 添加页面
|
|
304
|
+
* @param viewOptions 页面参数
|
|
305
|
+
*/
|
|
306
|
+
addView(viewOptions: Partial<View>): View;
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* 添加页面
|
|
310
|
+
* @param view 已有的页面实例
|
|
311
|
+
*/
|
|
312
|
+
addView(view: View): View;
|
|
313
|
+
|
|
314
|
+
addView(options?: string | Partial<View> | View) {
|
|
315
|
+
const node = this._addView(options as any);
|
|
316
|
+
const index = this.views.indexOf(node);
|
|
317
|
+
node.create({
|
|
318
|
+
index,
|
|
319
|
+
parentNode: this,
|
|
320
|
+
parentKey: 'views',
|
|
321
|
+
});
|
|
322
|
+
return node;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
getVarExistingNames(excludedList: Array<Variable> = []) {
|
|
326
|
+
const excludedSet = new Set(excludedList);
|
|
327
|
+
return ((this.variables as Variable[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
328
|
+
}
|
|
329
|
+
getVariableUniqueName(name = 'variable1') {
|
|
330
|
+
return utils.unique(name, this.getVarExistingNames(), undefined, true);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* 插入变量
|
|
335
|
+
* @internal
|
|
336
|
+
* @param name 变量名称,如果不填会自动生成一个唯一名称
|
|
337
|
+
*/
|
|
338
|
+
_insertVariableAt(name: string, index: number): Variable;
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* 插入变量
|
|
342
|
+
* @internal
|
|
343
|
+
* @param variableOptions 变量参数
|
|
344
|
+
*/
|
|
345
|
+
_insertVariableAt(variableOptions: Partial<Variable>, index: number): Variable;
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* 插入变量
|
|
349
|
+
* @internal
|
|
350
|
+
* @param variable 已有的变量实例
|
|
351
|
+
*/
|
|
352
|
+
_insertVariableAt(variable: Variable, index: number): Variable;
|
|
353
|
+
|
|
354
|
+
_insertVariableAt(options: string | Partial<Variable> | Variable, index: number) {
|
|
355
|
+
const variableOptions: any = {};
|
|
356
|
+
const relationOptions = { parentNode: this, parentKey: 'variables' };
|
|
357
|
+
let variable: Variable;
|
|
358
|
+
if (!options) {
|
|
359
|
+
variable = Variable.from({
|
|
360
|
+
...variableOptions,
|
|
361
|
+
name: this.getVariableUniqueName(),
|
|
362
|
+
}, this, 'variables');
|
|
363
|
+
} else if (typeof options === 'string') {
|
|
364
|
+
variable = Variable.from({
|
|
365
|
+
...variableOptions,
|
|
366
|
+
name: options,
|
|
367
|
+
}, this, 'variables');
|
|
368
|
+
} else if (options instanceof Variable) {
|
|
369
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
370
|
+
variable = options;
|
|
371
|
+
Object.assign(variable, relationOptions);
|
|
372
|
+
} else {
|
|
373
|
+
variable = Variable.from({
|
|
374
|
+
...variableOptions,
|
|
375
|
+
...options,
|
|
376
|
+
}, this, 'variables');
|
|
377
|
+
}
|
|
378
|
+
this.variables.splice(index, 0, variable);
|
|
379
|
+
return variable;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* 插入变量
|
|
384
|
+
* @param name 变量名称,如果不填会自动生成一个唯一名称
|
|
385
|
+
*/
|
|
386
|
+
insertVariableAt(name: string, index: number): Variable;
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* 插入变量
|
|
390
|
+
* @param variableOptions 变量参数
|
|
391
|
+
*/
|
|
392
|
+
insertVariableAt(variableOptions: Partial<Variable>, index: number): Variable;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* 插入变量
|
|
396
|
+
* @param variable 已有的变量实例
|
|
397
|
+
*/
|
|
398
|
+
insertVariableAt(variable: Variable, index: number): Variable;
|
|
399
|
+
|
|
400
|
+
insertVariableAt(options: string | Partial<Variable> | Variable, index: number) {
|
|
401
|
+
const node = this._insertVariableAt(options as any, index);
|
|
402
|
+
node.create({
|
|
403
|
+
index,
|
|
404
|
+
parentNode: this,
|
|
405
|
+
parentKey: 'variables',
|
|
406
|
+
});
|
|
407
|
+
return node;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* 添加变量
|
|
412
|
+
* @internal
|
|
413
|
+
* @param name 变量名称,如果不填会自动生成一个唯一名称
|
|
414
|
+
*/
|
|
415
|
+
_addVariable(name?: string): Variable;
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* 添加变量
|
|
419
|
+
* @internal
|
|
420
|
+
* @param variableOptions 变量参数
|
|
421
|
+
*/
|
|
422
|
+
_addVariable(variableOptions: Partial<Variable>): Variable;
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* 添加变量
|
|
426
|
+
* @internal
|
|
427
|
+
* @param variable 已有的变量实例
|
|
428
|
+
*/
|
|
429
|
+
_addVariable(variable: Variable): Variable;
|
|
430
|
+
|
|
431
|
+
_addVariable(options?: string | Partial<Variable> | Variable) {
|
|
432
|
+
const index = this.variables.length;
|
|
433
|
+
return this._insertVariableAt(options as any, index);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* 添加变量
|
|
438
|
+
* @internal
|
|
439
|
+
* @param name 变量名称,如果不填会自动生成一个唯一名称
|
|
440
|
+
*/
|
|
441
|
+
addVariable(name?: string): Variable;
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* 添加变量
|
|
445
|
+
* @param variableOptions 变量参数
|
|
446
|
+
*/
|
|
447
|
+
addVariable(variableOptions: Partial<Variable>): Variable;
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* 添加变量
|
|
451
|
+
* @param variable 已有的变量实例
|
|
452
|
+
*/
|
|
453
|
+
addVariable(variable: Variable): Variable;
|
|
454
|
+
|
|
455
|
+
addVariable(options?: string | Partial<Variable> | Variable) {
|
|
456
|
+
const node = this._addVariable(options as any);
|
|
457
|
+
const index = this.variables.indexOf(node);
|
|
458
|
+
node.create({
|
|
459
|
+
index,
|
|
460
|
+
parentNode: this,
|
|
461
|
+
parentKey: 'variables',
|
|
462
|
+
});
|
|
463
|
+
return node;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
getModuleExistingNames(excludedList: Array<Module> = []) {
|
|
467
|
+
const excludedSet = new Set(excludedList);
|
|
468
|
+
return ((this.componentDependencies as Module[]) || []).filter((item) => !excludedSet.has(item)).map((item) => item.name);
|
|
469
|
+
}
|
|
470
|
+
getModuleUniqueName(name = 'module1') {
|
|
471
|
+
return utils.unique(name, this.getModuleExistingNames(), undefined, false);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* 插入模块
|
|
476
|
+
* @internal
|
|
477
|
+
* @param name 模块名称,如果不填会自动生成一个唯一名称
|
|
478
|
+
*/
|
|
479
|
+
_insertModuleAt(name: string, index: number): Module;
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* 插入模块
|
|
483
|
+
* @internal
|
|
484
|
+
* @param moduleOptions 模块参数
|
|
485
|
+
*/
|
|
486
|
+
_insertModuleAt(moduleOptions: Partial<Module>, index: number): Module;
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* 插入模块
|
|
490
|
+
* @internal
|
|
491
|
+
* @param module 已有的模块实例
|
|
492
|
+
*/
|
|
493
|
+
_insertModuleAt(module: Module, index: number): Module;
|
|
494
|
+
|
|
495
|
+
_insertModuleAt(options: string | Partial<Module> | Module, index: number) {
|
|
496
|
+
const moduleOptions: any = {};
|
|
497
|
+
const relationOptions = { parentNode: this, parentKey: 'componentDependencies' };
|
|
498
|
+
let module: Module;
|
|
499
|
+
if (!options) {
|
|
500
|
+
module = Module.from({
|
|
501
|
+
...moduleOptions,
|
|
502
|
+
name: this.getModuleUniqueName(),
|
|
503
|
+
}, this, 'componentDependencies');
|
|
504
|
+
} else if (typeof options === 'string') {
|
|
505
|
+
module = Module.from({
|
|
506
|
+
...moduleOptions,
|
|
507
|
+
name: options,
|
|
508
|
+
}, this, 'componentDependencies');
|
|
509
|
+
} else if (options instanceof Module) {
|
|
510
|
+
options.ensureDelete(); // 同一实例不支持多处存在
|
|
511
|
+
module = options;
|
|
512
|
+
Object.assign(module, relationOptions);
|
|
513
|
+
} else {
|
|
514
|
+
module = Module.from({
|
|
515
|
+
...moduleOptions,
|
|
516
|
+
...options,
|
|
517
|
+
}, this, 'componentDependencies');
|
|
518
|
+
}
|
|
519
|
+
this.componentDependencies.splice(index, 0, module);
|
|
520
|
+
return module;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* 插入模块
|
|
525
|
+
* @param name 模块名称,如果不填会自动生成一个唯一名称
|
|
526
|
+
*/
|
|
527
|
+
insertModuleAt(name: string, index: number): Module;
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* 插入模块
|
|
531
|
+
* @param moduleOptions 模块参数
|
|
532
|
+
*/
|
|
533
|
+
insertModuleAt(moduleOptions: Partial<Module>, index: number): Module;
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* 插入模块
|
|
537
|
+
* @param module 已有的模块实例
|
|
538
|
+
*/
|
|
539
|
+
insertModuleAt(module: Module, index: number): Module;
|
|
540
|
+
|
|
541
|
+
insertModuleAt(options: string | Partial<Module> | Module, index: number) {
|
|
542
|
+
const node = this._insertModuleAt(options as any, index);
|
|
543
|
+
node.create({
|
|
544
|
+
index,
|
|
545
|
+
parentNode: this,
|
|
546
|
+
parentKey: 'componentDependencies',
|
|
547
|
+
});
|
|
548
|
+
return node;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* 添加模块
|
|
553
|
+
* @internal
|
|
554
|
+
* @param name 模块名称,如果不填会自动生成一个唯一名称
|
|
555
|
+
*/
|
|
556
|
+
_addModule(name?: string): Module;
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* 添加模块
|
|
560
|
+
* @internal
|
|
561
|
+
* @param moduleOptions 模块参数
|
|
562
|
+
*/
|
|
563
|
+
_addModule(moduleOptions: Partial<Module>): Module;
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* 添加模块
|
|
567
|
+
* @internal
|
|
568
|
+
* @param module 已有的模块实例
|
|
569
|
+
*/
|
|
570
|
+
_addModule(module: Module): Module;
|
|
571
|
+
|
|
572
|
+
_addModule(options?: string | Partial<Module> | Module) {
|
|
573
|
+
const index = this.componentDependencies.length;
|
|
574
|
+
return this._insertModuleAt(options as any, index);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* 添加模块
|
|
579
|
+
* @internal
|
|
580
|
+
* @param name 模块名称,如果不填会自动生成一个唯一名称
|
|
581
|
+
*/
|
|
582
|
+
addModule(name?: string): Module;
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* 添加模块
|
|
586
|
+
* @param moduleOptions 模块参数
|
|
587
|
+
*/
|
|
588
|
+
addModule(moduleOptions: Partial<Module>): Module;
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* 添加模块
|
|
592
|
+
* @param module 已有的模块实例
|
|
593
|
+
*/
|
|
594
|
+
addModule(module: Module): Module;
|
|
595
|
+
|
|
596
|
+
addModule(options?: string | Partial<Module> | Module) {
|
|
597
|
+
const node = this._addModule(options as any);
|
|
598
|
+
const index = this.componentDependencies.indexOf(node);
|
|
599
|
+
node.create({
|
|
600
|
+
index,
|
|
601
|
+
parentNode: this,
|
|
602
|
+
parentKey: 'componentDependencies',
|
|
603
|
+
});
|
|
604
|
+
return node;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* 删除页面
|
|
609
|
+
* @param name 页面名称
|
|
610
|
+
*/
|
|
611
|
+
removeView(name: string): void;
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* 删除页面
|
|
615
|
+
* @param view 已有的页面实例
|
|
616
|
+
*/
|
|
617
|
+
removeView(view: View): void;
|
|
618
|
+
|
|
619
|
+
removeView(options: string | View) {
|
|
620
|
+
let view: View;
|
|
621
|
+
if (typeof options === 'string') {
|
|
622
|
+
view = (this.views as View[]).find((item) => item.name === options);
|
|
623
|
+
if (!view) {
|
|
624
|
+
throw new Error('找不到页面 ' + options);
|
|
625
|
+
}
|
|
626
|
+
} else {
|
|
627
|
+
view = options;
|
|
628
|
+
}
|
|
629
|
+
return view.delete();
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
__removeView(view: View) {
|
|
633
|
+
const parentKey = view.parentKey;
|
|
634
|
+
const params: Params = {
|
|
635
|
+
parentNode: this,
|
|
636
|
+
parentKey,
|
|
637
|
+
index: -1,
|
|
638
|
+
object: null,
|
|
639
|
+
oldObject: view,
|
|
640
|
+
};
|
|
641
|
+
if (parentKey) {
|
|
642
|
+
params.parentKey = parentKey;
|
|
643
|
+
if (Array.isArray((this as any)[parentKey])) {
|
|
644
|
+
const index = (this as any)[parentKey].indexOf(view);
|
|
645
|
+
~index && (this as any)[parentKey].splice(index, 1);
|
|
646
|
+
params.index = index;
|
|
647
|
+
} else if ((this as any)[parentKey] === view) {
|
|
648
|
+
params.index = 0;
|
|
649
|
+
(this as any)[parentKey] = undefined;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
return params;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* 删除变量
|
|
657
|
+
* @param name 变量名称
|
|
658
|
+
*/
|
|
659
|
+
removeVariable(name: string): void;
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* 删除变量
|
|
663
|
+
* @param variable 已有的变量实例
|
|
664
|
+
*/
|
|
665
|
+
removeVariable(variable: Variable): void;
|
|
666
|
+
|
|
667
|
+
removeVariable(options: string | Variable) {
|
|
668
|
+
let variable: Variable;
|
|
669
|
+
if (typeof options === 'string') {
|
|
670
|
+
variable = (this.variables as Variable[]).find((item) => item.name === options);
|
|
671
|
+
if (!variable) {
|
|
672
|
+
throw new Error('找不到变量 ' + options);
|
|
673
|
+
}
|
|
674
|
+
} else {
|
|
675
|
+
variable = options;
|
|
676
|
+
}
|
|
677
|
+
return variable.delete();
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
__removeVariable(variable: Variable) {
|
|
681
|
+
const parentKey = variable.parentKey;
|
|
682
|
+
const params: Params = {
|
|
683
|
+
parentNode: this,
|
|
684
|
+
parentKey,
|
|
685
|
+
index: -1,
|
|
686
|
+
object: null,
|
|
687
|
+
oldObject: variable,
|
|
688
|
+
};
|
|
689
|
+
if (parentKey) {
|
|
690
|
+
params.parentKey = parentKey;
|
|
691
|
+
if (Array.isArray((this as any)[parentKey])) {
|
|
692
|
+
const index = (this as any)[parentKey].indexOf(variable);
|
|
693
|
+
~index && (this as any)[parentKey].splice(index, 1);
|
|
694
|
+
params.index = index;
|
|
695
|
+
} else if ((this as any)[parentKey] === variable) {
|
|
696
|
+
params.index = 0;
|
|
697
|
+
(this as any)[parentKey] = undefined;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
return params;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
/**
|
|
704
|
+
* 删除主题
|
|
705
|
+
* @param name 主题名称
|
|
706
|
+
*/
|
|
707
|
+
removeTheme(name: string): void;
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* 删除主题
|
|
711
|
+
* @param theme 已有的主题实例
|
|
712
|
+
*/
|
|
713
|
+
removeTheme(theme: Theme): void;
|
|
714
|
+
|
|
715
|
+
removeTheme(options: string | Theme) {
|
|
716
|
+
let theme: Theme;
|
|
717
|
+
if (typeof options === 'string') {
|
|
718
|
+
theme = this.theme;
|
|
719
|
+
if (!theme) {
|
|
720
|
+
throw new Error('找不到主题 ' + options);
|
|
721
|
+
}
|
|
722
|
+
} else {
|
|
723
|
+
theme = options;
|
|
724
|
+
}
|
|
725
|
+
return theme.delete();
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
__removeTheme(theme: Theme) {
|
|
729
|
+
const parentKey = theme.parentKey;
|
|
730
|
+
const params: Params = {
|
|
731
|
+
parentNode: this,
|
|
732
|
+
parentKey,
|
|
733
|
+
index: -1,
|
|
734
|
+
object: null,
|
|
735
|
+
oldObject: theme,
|
|
736
|
+
};
|
|
737
|
+
if (parentKey) {
|
|
738
|
+
params.parentKey = parentKey;
|
|
739
|
+
if (Array.isArray((this as any)[parentKey])) {
|
|
740
|
+
const index = (this as any)[parentKey].indexOf(theme);
|
|
741
|
+
~index && (this as any)[parentKey].splice(index, 1);
|
|
742
|
+
params.index = index;
|
|
743
|
+
} else if ((this as any)[parentKey] === theme) {
|
|
744
|
+
params.index = 0;
|
|
745
|
+
(this as any)[parentKey] = undefined;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
return params;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
/**
|
|
752
|
+
* 删除模块
|
|
753
|
+
* @param name 模块名称
|
|
754
|
+
*/
|
|
755
|
+
removeModule(name: string): void;
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* 删除模块
|
|
759
|
+
* @param module 已有的模块实例
|
|
760
|
+
*/
|
|
761
|
+
removeModule(module: Module): void;
|
|
762
|
+
|
|
763
|
+
removeModule(options: string | Module) {
|
|
764
|
+
let module: Module;
|
|
765
|
+
if (typeof options === 'string') {
|
|
766
|
+
module = (this.componentDependencies as Module[]).find((item) => item.name === options);
|
|
767
|
+
if (!module) {
|
|
768
|
+
throw new Error('找不到模块 ' + options);
|
|
769
|
+
}
|
|
770
|
+
} else {
|
|
771
|
+
module = options;
|
|
772
|
+
}
|
|
773
|
+
return module.delete();
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
__removeModule(module: Module) {
|
|
777
|
+
const parentKey = module.parentKey;
|
|
778
|
+
const params: Params = {
|
|
779
|
+
parentNode: this,
|
|
780
|
+
parentKey,
|
|
781
|
+
index: -1,
|
|
782
|
+
object: null,
|
|
783
|
+
oldObject: module,
|
|
784
|
+
};
|
|
785
|
+
if (parentKey) {
|
|
786
|
+
params.parentKey = parentKey;
|
|
787
|
+
if (Array.isArray((this as any)[parentKey])) {
|
|
788
|
+
const index = (this as any)[parentKey].indexOf(module);
|
|
789
|
+
~index && (this as any)[parentKey].splice(index, 1);
|
|
790
|
+
params.index = index;
|
|
791
|
+
} else if ((this as any)[parentKey] === module) {
|
|
792
|
+
params.index = 0;
|
|
793
|
+
(this as any)[parentKey] = undefined;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
return params;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
//================================================================================
|
|
800
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
801
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
802
|
+
//================================================================================
|
|
803
|
+
|
|
804
|
+
findComponentDependencyByName(name: string) {
|
|
805
|
+
return this.componentDependencies.find((componentDependency) => componentDependency.name === name);
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
/**
|
|
809
|
+
* @param path 路径
|
|
810
|
+
* path 为要查找路径:如 /dashboard/student/list、/dashboard/student/list
|
|
811
|
+
*/
|
|
812
|
+
findViewByPath(path: string) {
|
|
813
|
+
const arr = path.split('/');
|
|
814
|
+
if (arr[0] === '')
|
|
815
|
+
arr.shift();
|
|
816
|
+
|
|
817
|
+
if (!arr.length)
|
|
818
|
+
throw Error('Cannot find View ' + path);
|
|
819
|
+
const childName = arr.shift();
|
|
820
|
+
const subView = this.views.find((child) => child.name === childName);
|
|
821
|
+
return arr.length ? subView.findViewByPath(arr.join('/')) : subView;
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
findViewByName(name: string): View {
|
|
825
|
+
return utils.traverse((current) => {
|
|
826
|
+
if (current.node.name === name)
|
|
827
|
+
return current.node;
|
|
828
|
+
}, { node: { name: '', children: this.views } });
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
genThemeCSS() {
|
|
832
|
+
const keys = Object.keys(this.theme?.variableMap || {});
|
|
833
|
+
if (!keys.length)
|
|
834
|
+
return;
|
|
835
|
+
|
|
836
|
+
return `:root {
|
|
837
|
+
${keys.map((key) => ` ${key}: ${this.theme?.variableMap[key]};`).join('\n')}
|
|
838
|
+
}`;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
getNamespace() {
|
|
842
|
+
if (this.parentNode && (this.parentNode as Namespace).getNamespace) {
|
|
843
|
+
const parentNamespace = (this.parentNode as Namespace).getNamespace();
|
|
844
|
+
const parentName = this.parentNode.name;
|
|
845
|
+
const arr = [parentNamespace];
|
|
846
|
+
if (this.parentNode.concept !== 'App' && parentName) {
|
|
847
|
+
arr.push(parentName);
|
|
848
|
+
}
|
|
849
|
+
return `${arr.join('.')}.frontends`;
|
|
850
|
+
} else
|
|
851
|
+
throw new Error('无法获取命名空间,请设置 parentNode!');
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* 生成宿主语言的文件路径
|
|
856
|
+
* @param name 一般不用传,用于 rename
|
|
857
|
+
*/
|
|
858
|
+
getEmbeddedFilePath(name = this.name) {
|
|
859
|
+
return `/embedded/${this.rootNode?.name || this.parentNode.name}/frontends/${name}.ts`;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
@withSourceMap()
|
|
863
|
+
toEmbeddedTS(state?: TranslatorState): string {
|
|
864
|
+
let code = `export namespace ${this.name} {\n`;
|
|
865
|
+
code += 'const name = ';
|
|
866
|
+
code += '"' + this.name + '";\n';
|
|
867
|
+
code += '}\n';
|
|
868
|
+
return code;
|
|
869
|
+
}
|
|
870
|
+
toEmbeddedTSFile() {
|
|
871
|
+
let code = `namespace ${this.getNamespace()} {\n`;
|
|
872
|
+
|
|
873
|
+
const state = createCompilerState(code, { tabSize: 1 });
|
|
874
|
+
try {
|
|
875
|
+
code += this.toEmbeddedTS(state);
|
|
876
|
+
} catch (err) {
|
|
877
|
+
code += '';
|
|
878
|
+
console.log(err);
|
|
879
|
+
}
|
|
880
|
+
code += '}\n';
|
|
881
|
+
|
|
882
|
+
return {
|
|
883
|
+
code,
|
|
884
|
+
filePath: this.getEmbeddedFilePath(),
|
|
885
|
+
sourceMap: state.sourceMap,
|
|
886
|
+
};
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
getPath() {
|
|
890
|
+
const path = this.path;
|
|
891
|
+
const finalPath = path && path !== '/' ? path : '';
|
|
892
|
+
return finalPath;
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
/**
|
|
896
|
+
* 为/的转成'',便于url拼接
|
|
897
|
+
*/
|
|
898
|
+
get basePath() {
|
|
899
|
+
const path = this.path;
|
|
900
|
+
const basePath = path && path !== '/' ? path : '';
|
|
901
|
+
return basePath;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
genCustomAssetsInfo(prefix: string) {
|
|
905
|
+
const custom: AssetsInfo = {
|
|
906
|
+
js: [],
|
|
907
|
+
css: [],
|
|
908
|
+
names: [],
|
|
909
|
+
};
|
|
910
|
+
const existingSet = new Set();
|
|
911
|
+
this.componentDependencies.forEach((dep) => {
|
|
912
|
+
const { name, version } = dep;
|
|
913
|
+
const jsName = `${prefix}/packages/${name}@${version}/dist-theme/index.js`;
|
|
914
|
+
if (!existingSet.has(jsName)) {
|
|
915
|
+
existingSet.add(jsName);
|
|
916
|
+
custom.js.push(jsName);
|
|
917
|
+
if (utils.shouldLoadCss(name, version)) {
|
|
918
|
+
custom.css.push(`${prefix}/packages/${name}@${version}/dist-theme/index.css`);
|
|
919
|
+
}
|
|
920
|
+
custom.names.push(name);
|
|
921
|
+
}
|
|
922
|
+
});
|
|
923
|
+
return custom;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
//================================================================================
|
|
927
|
+
// 从这里开始到结尾注释之间的代码由 NASL Workbench 自动生成,请不手动修改!
|
|
928
|
+
// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
|
|
929
|
+
//================================================================================
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
classMap.Frontend = Frontend;
|
|
933
|
+
export default Frontend;
|
|
934
|
+
//================================================================================
|
|
935
|
+
// ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
|
|
936
|
+
// 自动生成的代码已结束。下面可以手动编写。
|
|
937
|
+
//================================================================================
|