@aiot-toolkit/parser 2.0.5-beta.8 → 2.0.5-widget-provider-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.
Files changed (107) hide show
  1. package/README.md +11 -11
  2. package/lib/index.d.ts +1 -4
  3. package/lib/index.js +0 -27
  4. package/lib/utils/ParserUtil.js +15 -15
  5. package/lib/ux/config/ExtensionConfig.js +2 -2
  6. package/lib/ux/config/FeatureConfig.js +19 -19
  7. package/lib/ux/config/vela/StyleAttributeConfig.js +87 -87
  8. package/lib/ux/enum/StyleSelectorType.js +6 -6
  9. package/lib/ux/enum/TemplateNodeType.js +2 -2
  10. package/lib/ux/enum/android/StyleSelectorName.js +2 -2
  11. package/lib/ux/parser/ScriptParser.js +2 -2
  12. package/lib/ux/parser/StyleParser.js +62 -62
  13. package/lib/ux/parser/TemplateValueParser.js +49 -49
  14. package/lib/ux/parser/UxParser.js +11 -11
  15. package/lib/ux/translate/android/StyleToTypescript.js +51 -51
  16. package/lib/ux/translate/android/TemplateToTypescript.js +51 -51
  17. package/lib/ux/translate/android/UxToTypescript.js +14 -14
  18. package/lib/ux/translate/android/attributeTranslate/ForTranslate.js +17 -17
  19. package/lib/ux/translate/android/attributeTranslate/IfTranslate.js +9 -9
  20. package/lib/ux/translate/vela/ScriptToTypescript.js +13 -12
  21. package/lib/ux/translate/vela/StyleToTypescript.js +10 -10
  22. package/lib/ux/translate/vela/TemplateToTypescript.js +74 -74
  23. package/lib/ux/translate/vela/TranslateCache.js +2 -2
  24. package/lib/ux/translate/vela/UxToTypescript.js +6 -6
  25. package/lib/ux/translate/vela/VelaContext.js +2 -2
  26. package/lib/ux/translate/vela/plugins/e2e.js +61 -61
  27. package/lib/ux/translate/vela/protobuf/BinaryPlugin.js +172 -172
  28. package/lib/ux/translate/vela/protobuf/protobuf.js +235 -235
  29. package/lib/ux/translate/vela/protobuf/protobufControl.js +159 -159
  30. package/lib/ux/translate/vela/protobuf/vdom_pb.js +2374 -2374
  31. package/lib/ux/translate/vela/runtime/velaTestLibrary.js +104 -104
  32. package/lib/ux/translate/vela/utils/AttributeConfig.js +15 -15
  33. package/lib/ux/translate/vela/utils/ExtendedBoxStyle.js +38 -38
  34. package/lib/ux/translate/vela/utils/SourceMapUtil.js +30 -30
  35. package/lib/ux/translate/vela/utils/TemplateUtil.d.ts +10 -8
  36. package/lib/ux/translate/vela/utils/TemplateUtil.js +206 -191
  37. package/lib/ux/translate/vela/wrap/CbTranslate.js +8 -8
  38. package/lib/ux/translate/vela/wrap/CfTranslate.js +14 -14
  39. package/lib/ux/translate/vela/wrap/CiTranslate.js +11 -11
  40. package/lib/ux/utils/BabelUtil.js +35 -35
  41. package/lib/ux/utils/ElementConfigUtil.js +24 -24
  42. package/lib/ux/utils/StyleMapUtil.js +26 -16
  43. package/lib/ux/utils/StyleUtil.js +176 -174
  44. package/lib/ux/utils/UxUtil.js +32 -32
  45. package/lib/ux/validate/ElementValidate.js +2 -2
  46. package/lib/ux/validate/UxFileValidate.js +2 -2
  47. package/package.json +6 -6
  48. package/lib/xts/XtsParser.d.ts +0 -20
  49. package/lib/xts/XtsParser.js +0 -86
  50. package/lib/xts/XtsToTypescript.d.ts +0 -69
  51. package/lib/xts/XtsToTypescript.js +0 -894
  52. package/lib/xts/config/CommonAttributeList.d.ts +0 -6
  53. package/lib/xts/config/CommonAttributeList.js +0 -17
  54. package/lib/xts/config/classCount.json +0 -38
  55. package/lib/xts/config/commonAttribute.json +0 -84
  56. package/lib/xts/config/componentList.d.ts +0 -56
  57. package/lib/xts/config/componentList.js +0 -9
  58. package/lib/xts/config/predefinedComponent.json +0 -91
  59. package/lib/xts/config/render.json +0 -31
  60. package/lib/xts/data/ElementType.d.ts +0 -6
  61. package/lib/xts/data/ElementType.js +0 -5
  62. package/lib/xts/data/element/CommentElement.d.ts +0 -16
  63. package/lib/xts/data/element/CommentElement.js +0 -26
  64. package/lib/xts/data/element/ElementBase.d.ts +0 -14
  65. package/lib/xts/data/element/ElementBase.js +0 -20
  66. package/lib/xts/data/element/ForElement.d.ts +0 -58
  67. package/lib/xts/data/element/ForElement.js +0 -81
  68. package/lib/xts/data/element/IfElement.d.ts +0 -55
  69. package/lib/xts/data/element/IfElement.js +0 -87
  70. package/lib/xts/data/element/NodeElement.d.ts +0 -39
  71. package/lib/xts/data/element/NodeElement.js +0 -86
  72. package/lib/xts/enum/AttributeType.d.ts +0 -31
  73. package/lib/xts/enum/AttributeType.js +0 -53
  74. package/lib/xts/enum/Framework.d.ts +0 -98
  75. package/lib/xts/enum/Framework.js +0 -107
  76. package/lib/xts/interface/IContext.d.ts +0 -11
  77. package/lib/xts/interface/IContext.js +0 -1
  78. package/lib/xts/interface/IElement.d.ts +0 -17
  79. package/lib/xts/interface/IElement.js +0 -5
  80. package/lib/xts/interface/IExpressNode.d.ts +0 -20
  81. package/lib/xts/interface/IExpressNode.js +0 -1
  82. package/lib/xts/interface/config/ICommon.d.ts +0 -23
  83. package/lib/xts/interface/config/ICommon.js +0 -5
  84. package/lib/xts/interface/config/IRenderNode.d.ts +0 -25
  85. package/lib/xts/interface/config/IRenderNode.js +0 -1
  86. package/lib/xts/interface/validate/IAttibuteValidate.d.ts +0 -8
  87. package/lib/xts/interface/validate/IAttibuteValidate.js +0 -1
  88. package/lib/xts/interface/validate/IComponentValidate.d.ts +0 -9
  89. package/lib/xts/interface/validate/IComponentValidate.js +0 -1
  90. package/lib/xts/interface/validate/IRenderValidate.d.ts +0 -10
  91. package/lib/xts/interface/validate/IRenderValidate.js +0 -1
  92. package/lib/xts/interface/validate/ISourceFileValidate.d.ts +0 -7
  93. package/lib/xts/interface/validate/ISourceFileValidate.js +0 -1
  94. package/lib/xts/utils/AttributeUtil.d.ts +0 -73
  95. package/lib/xts/utils/AttributeUtil.js +0 -206
  96. package/lib/xts/utils/TypeUtil.d.ts +0 -60
  97. package/lib/xts/utils/TypeUtil.js +0 -97
  98. package/lib/xts/utils/TypescriptUtil.d.ts +0 -42
  99. package/lib/xts/utils/TypescriptUtil.js +0 -128
  100. package/lib/xts/validate/AttibuteValidate.d.ts +0 -18
  101. package/lib/xts/validate/AttibuteValidate.js +0 -97
  102. package/lib/xts/validate/ComponentValidate.d.ts +0 -19
  103. package/lib/xts/validate/ComponentValidate.js +0 -90
  104. package/lib/xts/validate/RenderValidate.d.ts +0 -63
  105. package/lib/xts/validate/RenderValidate.js +0 -239
  106. package/lib/xts/validate/SourceFileValidate.d.ts +0 -10
  107. package/lib/xts/validate/SourceFileValidate.js +0 -43
@@ -1,20 +0,0 @@
1
- /**
2
- * xts生成 xts 的 ast 树
3
- * 工作内容为
4
- * 1. 替换component 为 class + 4个空格
5
- * 2. 使用typescript 解析成 ast 树
6
- */
7
- import { Logger } from '@aiot-toolkit/shared-utils';
8
- import { Project, SourceFile } from 'ts-morph';
9
- import IOffset from '../interface/IOffset';
10
- import IParser from '../interface/IParser';
11
- export default class XtsParser implements IParser<SourceFile> {
12
- project: Project;
13
- onLog: Logger;
14
- constructor(project: Project, onLog: Logger);
15
- parser(content: string, fileName: string): {
16
- ast: SourceFile;
17
- offsetList: IOffset[];
18
- };
19
- private replaceKeyWord;
20
- }
@@ -1,86 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _sharedUtils = require("@aiot-toolkit/shared-utils");
8
- var _tsMorph = require("ts-morph");
9
- var _TypeUtil = _interopRequireDefault(require("./utils/TypeUtil"));
10
- var _SourceFileValidate = _interopRequireDefault(require("./validate/SourceFileValidate"));
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- /**
13
- * xts生成 xts 的 ast 树
14
- * 工作内容为
15
- * 1. 替换component 为 class + 4个空格
16
- * 2. 使用typescript 解析成 ast 树
17
- */
18
-
19
- class XtsParser {
20
- constructor(project, onLog) {
21
- this.project = project;
22
- this.onLog = _sharedUtils.WrapCallback.wrapOnLog(onLog);
23
- }
24
- parser(content, fileName) {
25
- const oldFile = this.project.getSourceFile('temp.xts');
26
- if (oldFile) {
27
- this.project.removeSourceFile(oldFile);
28
- }
29
- const sourceFile = this.project.createSourceFile('temp.xts', content);
30
- const offsetList = this.replaceKeyWord(sourceFile);
31
- // // 简单转换后,对内容进行错误检查
32
- // const reFile = this.project.createSourceFile('temp.ts', sourceFile.getFullText())
33
- // const fileDiags = reFile.getPreEmitDiagnostics().filter((item) => {
34
- // return item.getCategory() === DiagnosticCategory.Error
35
- // })
36
- // if (fileDiags.length > 6) {
37
- // throw new Error(`File have many error.\n${fileDiags.join('\n')}`)
38
- // }
39
- // if (this.project.getSourceFile('temp.ts')) {
40
- // this.project.removeSourceFile(reFile)
41
- // }
42
- new _SourceFileValidate.default().validate({
43
- sourceFile,
44
- onLog: this.onLog,
45
- offsetList
46
- }, fileName);
47
- return {
48
- ast: sourceFile,
49
- offsetList
50
- };
51
- }
52
- replaceKeyWord(sourceFile) {
53
- const offsetList = [];
54
- let offsetTotal = 0;
55
- sourceFile.transform(traversal => {
56
- const node = traversal.visitChildren();
57
- if (_tsMorph.ts.isIdentifier(node)) {
58
- const text = node.getText();
59
- const matchedItem = _TypeUtil.default.getSpecialParentDecorator(text);
60
- if (matchedItem) {
61
- /**
62
- * 记录偏移位置, offset: 偏移量, pos:替换后新节点的结束位置
63
- * 例如:`app name` 替换为 `class name`
64
- * offset = app.length - class.length = -2,表示name在新代码的位置=6,则name在源位置=6+(-2) = 4
65
- * pos = 5,表示大于5的标识符,偏移量为-2
66
- */
67
- const newWord = matchedItem.replaceLabel;
68
- const currentOffset = text.length - newWord.length;
69
- offsetTotal += currentOffset;
70
- const nodePosition = sourceFile.getLineAndColumnAtPos(node.getStart());
71
- offsetList.push({
72
- offset: offsetTotal,
73
- line: nodePosition.line,
74
- column: nodePosition.column,
75
- pos: node.getEnd() - offsetTotal,
76
- currentOffset
77
- });
78
- return _tsMorph.ts.factory.createIdentifier(newWord);
79
- }
80
- }
81
- return node;
82
- });
83
- return offsetList;
84
- }
85
- }
86
- exports.default = XtsParser;
@@ -1,69 +0,0 @@
1
- import { ImportDeclaration, Project, SourceFile } from 'ts-morph';
2
- import { Logger, MapData } from '@aiot-toolkit/shared-utils';
3
- import { IFileLaneContext } from 'file-lane';
4
- import IOffset from '../interface/IOffset';
5
- import { tsFrameWork, tsFrameWorkExports } from './enum/Framework';
6
- export type XtsClassType = typeof tsFrameWork.exports.Page | typeof tsFrameWork.exports.Component | typeof tsFrameWork.exports.App | typeof tsFrameWork.exports.Aspect;
7
- declare class XtsToTypescript {
8
- project: Project;
9
- onLog: Logger;
10
- projectContext: IFileLaneContext;
11
- filePath: string;
12
- private mapList;
13
- private elementIndex;
14
- private _offsetList;
15
- private _sourceFile;
16
- private _newFile;
17
- tsFrameWorkImports: Set<string>;
18
- constructor(project: Project, onLog: Logger, projectContext: IFileLaneContext, filePath: string);
19
- get context(): {
20
- sourceFile: SourceFile;
21
- onLog: Logger;
22
- offsetList: IOffset[];
23
- };
24
- translate(xtsTree: SourceFile, offsetList: IOffset[]): {
25
- ast: SourceFile;
26
- mapList: MapData[];
27
- };
28
- translateFeatureImport(node: ImportDeclaration, result: SourceFile): void;
29
- private addMapData;
30
- private getParentClassName;
31
- private isPageOrComponent;
32
- private translateClassNode;
33
- private translateNormalClassNode;
34
- private translateInterfaceNode;
35
- private translateGetOrSet;
36
- private addGetAccesorFunction;
37
- private addSetAccesorFunction;
38
- private addProxySetAccesorFunction;
39
- private translateMemberMethod;
40
- private translateRenderMethod;
41
- private translateElementList;
42
- private translateForElement;
43
- private translateIfElement;
44
- private translateNodeElement;
45
- /**
46
- *
47
- * @param nodeList
48
- * @returns
49
- */
50
- private splitElement;
51
- private translateNormalMethod;
52
- private translateMemberProperty;
53
- /**
54
- * 处理代理类的构造函数赋值
55
- * 需要区分Array,Map,Set和Interface,Class
56
- * @param sourceNode
57
- * @returns
58
- */
59
- private translateComplexInitalizer;
60
- /**
61
- * 处理多层数组在构造函数中的代理和赋值
62
- * @param sourceNode
63
- * @returns
64
- */
65
- private translateMultiLayerArray;
66
- private getStatements;
67
- pushXtsImport(target: tsFrameWorkExports): void;
68
- }
69
- export default XtsToTypescript;