brighterscript 0.65.1 → 0.66.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (249) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +8 -0
  3. package/dist/BsConfig.d.ts +5 -11
  4. package/dist/CacheVerifier.d.ts +8 -0
  5. package/dist/CacheVerifier.js +20 -0
  6. package/dist/CacheVerifier.js.map +1 -0
  7. package/dist/DiagnosticMessages.d.ts +9 -4
  8. package/dist/DiagnosticMessages.js +8 -3
  9. package/dist/DiagnosticMessages.js.map +1 -1
  10. package/dist/FunctionScope.d.ts +1 -0
  11. package/dist/FunctionScope.js +3 -0
  12. package/dist/FunctionScope.js.map +1 -1
  13. package/dist/PluginInterface.d.ts +0 -4
  14. package/dist/PluginInterface.js.map +1 -1
  15. package/dist/Program.d.ts +6 -39
  16. package/dist/Program.js +42 -44
  17. package/dist/Program.js.map +1 -1
  18. package/dist/ProgramBuilder.d.ts +4 -0
  19. package/dist/ProgramBuilder.js +12 -7
  20. package/dist/ProgramBuilder.js.map +1 -1
  21. package/dist/Scope.d.ts +1 -5
  22. package/dist/Scope.js +3 -28
  23. package/dist/Scope.js.map +1 -1
  24. package/dist/SymbolTable.d.ts +44 -6
  25. package/dist/SymbolTable.js +151 -25
  26. package/dist/SymbolTable.js.map +1 -1
  27. package/dist/XmlScope.js +11 -12
  28. package/dist/XmlScope.js.map +1 -1
  29. package/dist/astUtils/creators.d.ts +16 -6
  30. package/dist/astUtils/creators.js +39 -16
  31. package/dist/astUtils/creators.js.map +1 -1
  32. package/dist/astUtils/reflection.d.ts +46 -37
  33. package/dist/astUtils/reflection.js +145 -147
  34. package/dist/astUtils/reflection.js.map +1 -1
  35. package/dist/astUtils/reflection.spec.js +1 -6
  36. package/dist/astUtils/reflection.spec.js.map +1 -1
  37. package/dist/astUtils/visitors.d.ts +4 -11
  38. package/dist/astUtils/visitors.js +0 -7
  39. package/dist/astUtils/visitors.js.map +1 -1
  40. package/dist/astUtils/visitors.spec.js +4 -2
  41. package/dist/astUtils/visitors.spec.js.map +1 -1
  42. package/dist/astUtils/xml.d.ts +9 -9
  43. package/dist/astUtils/xml.js +6 -6
  44. package/dist/astUtils/xml.js.map +1 -1
  45. package/dist/bscPlugin/BscPlugin.js +4 -0
  46. package/dist/bscPlugin/BscPlugin.js.map +1 -1
  47. package/dist/bscPlugin/CallExpressionInfo.js.map +1 -1
  48. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +2 -2
  49. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
  50. package/dist/bscPlugin/hover/HoverProcessor.js +71 -59
  51. package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -1
  52. package/dist/bscPlugin/hover/HoverProcessor.spec.js +110 -10
  53. package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -1
  54. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +6 -5
  55. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -1
  56. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js +1 -1
  57. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js.map +1 -1
  58. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.d.ts +11 -0
  59. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js +53 -0
  60. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js.map +1 -0
  61. package/dist/bscPlugin/validation/BrsFileValidator.d.ts +4 -0
  62. package/dist/bscPlugin/validation/BrsFileValidator.js +72 -16
  63. package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
  64. package/dist/bscPlugin/validation/BrsFileValidator.spec.js +1 -1
  65. package/dist/bscPlugin/validation/BrsFileValidator.spec.js.map +1 -1
  66. package/dist/bscPlugin/validation/ScopeValidator.d.ts +1 -0
  67. package/dist/bscPlugin/validation/ScopeValidator.js +72 -18
  68. package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
  69. package/dist/bscPlugin/validation/XmlFileValidator.js +9 -9
  70. package/dist/bscPlugin/validation/XmlFileValidator.js.map +1 -1
  71. package/dist/files/BrsFile.Class.spec.js +9 -10
  72. package/dist/files/BrsFile.Class.spec.js.map +1 -1
  73. package/dist/files/BrsFile.d.ts +8 -10
  74. package/dist/files/BrsFile.js +72 -52
  75. package/dist/files/BrsFile.js.map +1 -1
  76. package/dist/files/BrsFile.spec.js +56 -14
  77. package/dist/files/BrsFile.spec.js.map +1 -1
  78. package/dist/files/XmlFile.d.ts +19 -19
  79. package/dist/files/XmlFile.js +24 -42
  80. package/dist/files/XmlFile.js.map +1 -1
  81. package/dist/files/XmlFile.spec.js +61 -9
  82. package/dist/files/XmlFile.spec.js.map +1 -1
  83. package/dist/files/tests/imports.spec.js +8 -11
  84. package/dist/files/tests/imports.spec.js.map +1 -1
  85. package/dist/globalCallables.js +2 -1
  86. package/dist/globalCallables.js.map +1 -1
  87. package/dist/index.d.ts +2 -0
  88. package/dist/index.js +2 -0
  89. package/dist/index.js.map +1 -1
  90. package/dist/interfaces.d.ts +20 -1
  91. package/dist/interfaces.js +13 -0
  92. package/dist/interfaces.js.map +1 -1
  93. package/dist/lexer/TokenKind.d.ts +2 -0
  94. package/dist/lexer/TokenKind.js +5 -1
  95. package/dist/lexer/TokenKind.js.map +1 -1
  96. package/dist/parser/AstNode.d.ts +78 -1
  97. package/dist/parser/AstNode.js +80 -1
  98. package/dist/parser/AstNode.js.map +1 -1
  99. package/dist/parser/Expression.d.ts +87 -53
  100. package/dist/parser/Expression.js +243 -139
  101. package/dist/parser/Expression.js.map +1 -1
  102. package/dist/parser/Parser.Class.spec.js +10 -7
  103. package/dist/parser/Parser.Class.spec.js.map +1 -1
  104. package/dist/parser/Parser.d.ts +9 -5
  105. package/dist/parser/Parser.js +125 -78
  106. package/dist/parser/Parser.js.map +1 -1
  107. package/dist/parser/Parser.spec.d.ts +2 -0
  108. package/dist/parser/Parser.spec.js +117 -5
  109. package/dist/parser/Parser.spec.js.map +1 -1
  110. package/dist/parser/SGParser.d.ts +42 -4
  111. package/dist/parser/SGParser.js +191 -195
  112. package/dist/parser/SGParser.js.map +1 -1
  113. package/dist/parser/SGParser.spec.js +13 -10
  114. package/dist/parser/SGParser.spec.js.map +1 -1
  115. package/dist/parser/SGTypes.d.ts +279 -51
  116. package/dist/parser/SGTypes.js +562 -185
  117. package/dist/parser/SGTypes.js.map +1 -1
  118. package/dist/parser/Statement.d.ts +88 -70
  119. package/dist/parser/Statement.js +212 -136
  120. package/dist/parser/Statement.js.map +1 -1
  121. package/dist/parser/TranspileState.d.ts +1 -1
  122. package/dist/parser/TranspileState.js +5 -2
  123. package/dist/parser/TranspileState.js.map +1 -1
  124. package/dist/parser/tests/expression/TypeExpression.spec.d.ts +1 -0
  125. package/dist/parser/tests/expression/TypeExpression.spec.js +127 -0
  126. package/dist/parser/tests/expression/TypeExpression.spec.js.map +1 -0
  127. package/dist/types/ArrayType.d.ts +6 -4
  128. package/dist/types/ArrayType.js +30 -22
  129. package/dist/types/ArrayType.js.map +1 -1
  130. package/dist/types/ArrayType.spec.js +8 -8
  131. package/dist/types/ArrayType.spec.js.map +1 -1
  132. package/dist/types/BooleanType.d.ts +7 -4
  133. package/dist/types/BooleanType.js +13 -8
  134. package/dist/types/BooleanType.js.map +1 -1
  135. package/dist/types/BooleanType.spec.js +9 -3
  136. package/dist/types/BooleanType.spec.js.map +1 -1
  137. package/dist/types/BscType.d.ts +25 -2
  138. package/dist/types/BscType.js +64 -0
  139. package/dist/types/BscType.js.map +1 -1
  140. package/dist/types/BscTypeKind.d.ts +22 -0
  141. package/dist/types/BscTypeKind.js +27 -0
  142. package/dist/types/BscTypeKind.js.map +1 -0
  143. package/dist/types/ClassType.d.ts +11 -0
  144. package/dist/types/ClassType.js +31 -0
  145. package/dist/types/ClassType.js.map +1 -0
  146. package/dist/types/ClassType.spec.d.ts +1 -0
  147. package/dist/types/ClassType.spec.js +75 -0
  148. package/dist/types/ClassType.spec.js.map +1 -0
  149. package/dist/types/DoubleType.d.ts +7 -4
  150. package/dist/types/DoubleType.js +16 -20
  151. package/dist/types/DoubleType.js.map +1 -1
  152. package/dist/types/DoubleType.spec.js +11 -3
  153. package/dist/types/DoubleType.spec.js.map +1 -1
  154. package/dist/types/DynamicType.d.ts +9 -3
  155. package/dist/types/DynamicType.js +16 -2
  156. package/dist/types/DynamicType.js.map +1 -1
  157. package/dist/types/DynamicType.spec.js +15 -4
  158. package/dist/types/DynamicType.spec.js.map +1 -1
  159. package/dist/types/EnumType.d.ts +22 -0
  160. package/dist/types/EnumType.js +59 -0
  161. package/dist/types/EnumType.js.map +1 -0
  162. package/dist/types/EnumType.spec.d.ts +1 -0
  163. package/dist/types/EnumType.spec.js +33 -0
  164. package/dist/types/EnumType.spec.js.map +1 -0
  165. package/dist/types/FloatType.d.ts +7 -4
  166. package/dist/types/FloatType.js +16 -20
  167. package/dist/types/FloatType.js.map +1 -1
  168. package/dist/types/FloatType.spec.js +3 -3
  169. package/dist/types/FloatType.spec.js.map +1 -1
  170. package/dist/types/FunctionType.d.ts +6 -4
  171. package/dist/types/FunctionType.js +22 -19
  172. package/dist/types/FunctionType.js.map +1 -1
  173. package/dist/types/FunctionType.spec.js +5 -5
  174. package/dist/types/FunctionType.spec.js.map +1 -1
  175. package/dist/types/InheritableType.d.ts +25 -0
  176. package/dist/types/InheritableType.js +88 -0
  177. package/dist/types/InheritableType.js.map +1 -0
  178. package/dist/types/IntegerType.d.ts +7 -4
  179. package/dist/types/IntegerType.js +16 -20
  180. package/dist/types/IntegerType.js.map +1 -1
  181. package/dist/types/IntegerType.spec.js +7 -3
  182. package/dist/types/IntegerType.spec.js.map +1 -1
  183. package/dist/types/InterfaceType.d.ts +10 -10
  184. package/dist/types/InterfaceType.js +24 -45
  185. package/dist/types/InterfaceType.js.map +1 -1
  186. package/dist/types/InterfaceType.spec.js +59 -45
  187. package/dist/types/InterfaceType.spec.js.map +1 -1
  188. package/dist/types/InvalidType.d.ts +6 -4
  189. package/dist/types/InvalidType.js +12 -8
  190. package/dist/types/InvalidType.js.map +1 -1
  191. package/dist/types/InvalidType.spec.js +7 -3
  192. package/dist/types/InvalidType.spec.js.map +1 -1
  193. package/dist/types/LongIntegerType.d.ts +7 -4
  194. package/dist/types/LongIntegerType.js +16 -20
  195. package/dist/types/LongIntegerType.js.map +1 -1
  196. package/dist/types/LongIntegerType.spec.js +9 -3
  197. package/dist/types/LongIntegerType.spec.js.map +1 -1
  198. package/dist/types/NamespaceType.d.ts +11 -0
  199. package/dist/types/NamespaceType.js +25 -0
  200. package/dist/types/NamespaceType.js.map +1 -0
  201. package/dist/types/ObjectType.d.ts +8 -4
  202. package/dist/types/ObjectType.js +26 -7
  203. package/dist/types/ObjectType.js.map +1 -1
  204. package/dist/types/ObjectType.spec.js +2 -2
  205. package/dist/types/ObjectType.spec.js.map +1 -1
  206. package/dist/types/ReferenceType.d.ts +51 -0
  207. package/dist/types/ReferenceType.js +274 -0
  208. package/dist/types/ReferenceType.js.map +1 -0
  209. package/dist/types/ReferenceType.spec.d.ts +1 -0
  210. package/dist/types/ReferenceType.spec.js +122 -0
  211. package/dist/types/ReferenceType.spec.js.map +1 -0
  212. package/dist/types/StringType.d.ts +10 -4
  213. package/dist/types/StringType.js +16 -8
  214. package/dist/types/StringType.js.map +1 -1
  215. package/dist/types/StringType.spec.js +2 -2
  216. package/dist/types/StringType.spec.js.map +1 -1
  217. package/dist/types/UninitializedType.d.ts +6 -3
  218. package/dist/types/UninitializedType.js +14 -3
  219. package/dist/types/UninitializedType.js.map +1 -1
  220. package/dist/types/UnionType.d.ts +18 -0
  221. package/dist/types/UnionType.js +91 -0
  222. package/dist/types/UnionType.js.map +1 -0
  223. package/dist/types/UnionType.spec.d.ts +1 -0
  224. package/dist/types/UnionType.spec.js +103 -0
  225. package/dist/types/UnionType.spec.js.map +1 -0
  226. package/dist/types/VoidType.d.ts +7 -4
  227. package/dist/types/VoidType.js +13 -8
  228. package/dist/types/VoidType.js.map +1 -1
  229. package/dist/types/VoidType.spec.js +2 -2
  230. package/dist/types/VoidType.spec.js.map +1 -1
  231. package/dist/types/helper.spec.d.ts +1 -0
  232. package/dist/types/helper.spec.js +130 -0
  233. package/dist/types/helper.spec.js.map +1 -0
  234. package/dist/types/helpers.d.ts +19 -0
  235. package/dist/types/helpers.js +131 -0
  236. package/dist/types/helpers.js.map +1 -0
  237. package/dist/types/index.d.ts +22 -0
  238. package/dist/types/index.js +39 -0
  239. package/dist/types/index.js.map +1 -0
  240. package/dist/util.d.ts +9 -8
  241. package/dist/util.js +78 -32
  242. package/dist/util.js.map +1 -1
  243. package/dist/validators/ClassValidator.d.ts +0 -4
  244. package/dist/validators/ClassValidator.js +6 -30
  245. package/dist/validators/ClassValidator.js.map +1 -1
  246. package/package.json +2 -1
  247. package/dist/types/CustomType.d.ts +0 -9
  248. package/dist/types/CustomType.js +0 -32
  249. package/dist/types/CustomType.js.map +0 -1
@@ -1,55 +1,143 @@
1
1
  import { SourceNode } from 'source-map';
2
2
  import type { Range } from 'vscode-languageserver';
3
- import type { FileReference, TranspileResult } from '../interfaces';
3
+ import type { FileReference } from '../interfaces';
4
+ import { BooleanType } from '../types/BooleanType';
5
+ import { DynamicType } from '../types/DynamicType';
6
+ import { FloatType } from '../types/FloatType';
7
+ import { IntegerType } from '../types/IntegerType';
8
+ import { LongIntegerType } from '../types/LongIntegerType';
9
+ import { StringType } from '../types/StringType';
4
10
  import type { TranspileState } from './TranspileState';
5
11
  export interface SGToken {
6
12
  text: string;
7
13
  range?: Range;
8
14
  }
9
- export interface SGAttribute {
10
- key: SGToken;
11
- openQuote?: SGToken;
12
- value: SGToken;
13
- closeQuote?: SGToken;
14
- range?: Range;
15
+ export declare class SGAttribute {
16
+ constructor(key: SGToken, equals?: SGToken, openingQuote?: SGToken, value?: SGToken, closingQuote?: SGToken);
17
+ tokens: {
18
+ key: SGToken;
19
+ equals?: SGToken;
20
+ openingQuote?: SGToken;
21
+ value?: SGToken;
22
+ closingQuote?: SGToken;
23
+ };
24
+ get key(): string;
25
+ /**
26
+ * The value of this attribute. This does not including the opening or closing quote
27
+ */
28
+ get value(): string | undefined;
29
+ set value(val: string | undefined);
30
+ get range(): Range;
31
+ private _range;
32
+ transpile(state: TranspileState): SourceNode;
33
+ clone(): SGAttribute;
15
34
  }
16
- export declare class SGTag {
17
- tag: SGToken;
35
+ export declare class SGElement {
36
+ constructor(startTagOpen: SGToken, startTagName: SGToken, attributes?: SGAttribute[], startTagClose?: SGToken, elements?: SGElement[], endTagOpen?: SGToken, endTagName?: SGToken, endTagClose?: SGToken);
37
+ tokens: {
38
+ /**
39
+ * The first portion of the startTag. (i.e. `<` or `<?`)
40
+ */
41
+ startTagOpen: SGToken;
42
+ /**
43
+ * The name of the opening tag (i.e. CoolTag in `<CoolTag>`).
44
+ */
45
+ startTagName: SGToken;
46
+ /**
47
+ * The last bit of the startTag (i.e. `/>` for self-closing, `?>` for xml prologue, or `>` for tag with children)
48
+ */
49
+ startTagClose?: SGToken;
50
+ /**
51
+ * The endTag opening char `<`
52
+ */
53
+ endTagOpen?: SGToken;
54
+ /**
55
+ * The name of the ending tag (i.e. CoolTag in `</CoolTag>`)
56
+ */
57
+ endTagName?: SGToken;
58
+ /**
59
+ * The endTag closing char `>`
60
+ */
61
+ endTagClose?: SGToken;
62
+ };
63
+ /**
64
+ * Array of attributes found on this tag
65
+ */
18
66
  attributes: SGAttribute[];
19
- range?: Range;
20
- constructor(tag: SGToken, attributes?: SGAttribute[], range?: Range);
67
+ /**
68
+ * The array of direct children AST elements of this AST node
69
+ */
70
+ elements: SGElement[];
71
+ get range(): Range;
72
+ private _range;
73
+ /**
74
+ * Is this a self-closing tag?
75
+ */
76
+ get isSelfClosing(): boolean;
21
77
  get id(): string;
22
78
  set id(value: string);
79
+ /**
80
+ * Get the name of this tag.
81
+ */
82
+ get tagName(): string;
83
+ /**
84
+ * Find all direct children by their tag name (case insensitive).
85
+ * This does not step into children's children.
86
+ *
87
+ */
88
+ getElementsByTagName<T extends SGElement>(tagName: string): readonly T[];
89
+ /**
90
+ * Add a child to the end of the children array
91
+ */
92
+ addChild<T extends SGElement>(tag: T): T;
93
+ /**
94
+ * Remove a child from the children array.
95
+ * @returns true if node was found and removed, false if the node wasn't there and thus nothing was done
96
+ */
97
+ removeChild(tag: SGElement): boolean;
98
+ /**
99
+ * Does this node have the specified attribute?
100
+ */
101
+ hasAttribute(name: string): boolean;
102
+ /**
103
+ * Get an SGAttribute by its name (case INsensitive)
104
+ */
23
105
  getAttribute(name: string): SGAttribute | undefined;
106
+ /**
107
+ * Get an attribute value by its name
108
+ */
24
109
  getAttributeValue(name: string): string | undefined;
25
- setAttribute(name: string, value: string): void;
110
+ /**
111
+ * Set an attribute value by its name. If no attribute exists with this name, it is created
112
+ */
113
+ setAttributeValue(name: string, value: string): void;
114
+ /**
115
+ * Remove an attribute by its name. DO NOT USE this to edit AST (use ASTEditor)
116
+ * @returns true if an attribute was found and removed. False if no attribute was found
117
+ */
118
+ removeAttribute(name: string): boolean;
26
119
  transpile(state: TranspileState): SourceNode;
27
- protected transpileBody(state: TranspileState): (string | SourceNode)[];
28
- protected transpileAttributes(state: TranspileState, attributes: SGAttribute[]): (string | SourceNode)[];
120
+ protected transpileBody(state: TranspileState): SourceNode;
121
+ protected transpileAttributes(state: TranspileState, attributes: SGAttribute[]): SourceNode;
29
122
  }
30
- export declare class SGProlog extends SGTag {
31
- transpile(state: TranspileState): SourceNode;
123
+ export declare class SGProlog extends SGElement {
32
124
  }
33
- export declare class SGNode extends SGTag {
34
- children: SGNode[];
35
- constructor(tag: SGToken, attributes?: SGAttribute[], children?: SGNode[], range?: Range);
36
- protected transpileBody(state: TranspileState): (string | SourceNode)[];
125
+ export declare class SGNode extends SGElement {
37
126
  }
38
- export declare class SGChildren extends SGNode {
39
- constructor(tag?: SGToken, children?: SGNode[], range?: Range);
127
+ export declare class SGChildren extends SGElement {
40
128
  }
41
- export declare class SGScript extends SGTag {
129
+ export declare class SGCustomization extends SGElement {
130
+ }
131
+ export declare class SGScript extends SGElement {
42
132
  cdata?: SGToken;
43
- constructor(tag?: SGToken, attributes?: SGAttribute[], cdata?: SGToken, range?: Range);
44
133
  get type(): string;
45
134
  set type(value: string);
46
135
  get uri(): string;
47
136
  set uri(value: string);
48
- protected transpileBody(state: TranspileState): (string | SourceNode)[];
49
- protected transpileAttributes(state: TranspileState, attributes: SGAttribute[]): (string | SourceNode)[];
137
+ protected transpileBody(state: TranspileState): SourceNode;
138
+ protected transpileAttributes(state: TranspileState, attributes: SGAttribute[]): SourceNode;
50
139
  }
51
- export declare class SGField extends SGTag {
52
- constructor(tag?: SGToken, attributes?: SGAttribute[], range?: Range);
140
+ export declare class SGInterfaceField extends SGElement {
53
141
  get type(): string;
54
142
  set type(value: string);
55
143
  get alias(): string;
@@ -61,33 +149,173 @@ export declare class SGField extends SGTag {
61
149
  get alwaysNotify(): string;
62
150
  set alwaysNotify(value: string);
63
151
  }
152
+ export declare enum SGFieldType {
153
+ integer = "integer",
154
+ int = "int",
155
+ longinteger = "longinteger",
156
+ float = "float",
157
+ string = "string",
158
+ str = "str",
159
+ boolean = "boolean",
160
+ bool = "bool",
161
+ vector2d = "vector2d",
162
+ color = "color",
163
+ time = "time",
164
+ uri = "uri",
165
+ node = "node",
166
+ floatarray = "floatarray",
167
+ intarray = "intarray",
168
+ boolarray = "boolarray",
169
+ stringarray = "stringarray",
170
+ vector2darray = "vector2darray",
171
+ colorarray = "colorarray",
172
+ timearray = "timearray",
173
+ nodearray = "nodearray",
174
+ assocarray = "assocarray",
175
+ array = "array",
176
+ roarray = "roarray",
177
+ rect2d = "rect2d",
178
+ rect2darray = "rect2darray"
179
+ }
64
180
  export declare const SGFieldTypes: string[];
65
- export declare class SGFunction extends SGTag {
66
- constructor(tag?: SGToken, attributes?: SGAttribute[], range?: Range);
181
+ export declare function getBscTypeFromSGFieldType(sgFieldType: string): DynamicType | FloatType | IntegerType | LongIntegerType | StringType | BooleanType;
182
+ export declare class SGInterfaceFunction extends SGElement {
67
183
  get name(): string;
68
184
  set name(value: string);
69
185
  }
70
- export declare class SGInterface extends SGTag {
71
- fields: SGField[];
72
- functions: SGFunction[];
73
- constructor(tag?: SGToken, content?: SGTag[], range?: Range);
74
- getField(id: string): SGField;
75
- setField(id: string, type: string, onChange?: string, alwaysNotify?: boolean, alias?: string): void;
76
- getFunction(name: string): SGFunction;
77
- setFunction(name: string): void;
78
- protected transpileBody(state: TranspileState): (string | SourceNode)[];
186
+ export declare type SGInterfaceMember = SGInterfaceField | SGInterfaceFunction;
187
+ export declare class SGInterface extends SGElement {
188
+ get fields(): readonly SGInterfaceField[];
189
+ get functions(): readonly SGInterfaceFunction[];
190
+ get members(): readonly SGInterfaceMember[];
191
+ /**
192
+ * Check if there's an SGField with the specified name
193
+ */
194
+ hasField(id: string): boolean;
195
+ /**
196
+ * Check if there's an SGFunction with the specified name
197
+ */
198
+ hasFunction(name: string): boolean;
199
+ /**
200
+ * Find a field by its ID
201
+ */
202
+ getField(id: string): SGInterfaceField;
203
+ /**
204
+ * Set the value of a field. Creates a new field if one does not already exist with this ID
205
+ */
206
+ setField(id: string, type: string, onChange?: string, alwaysNotify?: boolean, alias?: string): SGInterfaceField;
207
+ /**
208
+ * Remove a field from the interface
209
+ * @returns true if a field was found and removed. Returns false if no field was found with that name
210
+ */
211
+ removeField(id: string): boolean;
212
+ /**
213
+ * Get the interface function with the specified name
214
+ */
215
+ getFunction(name: string): SGInterfaceFunction;
216
+ /**
217
+ * Add or replace a function on the interface
218
+ */
219
+ setFunction(name: string): SGInterfaceFunction;
220
+ /**
221
+ * Remove a function from the interface
222
+ * @returns true if a function was found and removed. Returns false if no function was found with that name
223
+ */
224
+ removeFunction(name: string): boolean;
79
225
  }
80
- export declare class SGComponent extends SGTag {
81
- constructor(tag?: SGToken, attributes?: SGAttribute[], content?: SGTag[], range?: Range);
82
- api: SGInterface;
83
- scripts: SGScript[];
84
- children: SGChildren;
85
- customizations: SGNode[];
226
+ /**
227
+ * The `<component>` element in SceneGraph. Not to be confused about usages of components like `<Rectangle>`, those are considered `SGNode` instances.
228
+ */
229
+ export declare class SGComponent extends SGElement {
230
+ /**
231
+ * Get all the <Field> and <Function> elements across all <Interface> nodes in this component
232
+ */
233
+ get interfaceMembers(): readonly SGInterfaceMember[];
234
+ get scriptElements(): readonly SGScript[];
235
+ /**
236
+ * Get the <interface> element from this component (if present), or undefined if not.
237
+ * NOTE: Roku supports and merges multiple <interface> elements in a component, but this
238
+ * property points to the FIRST one. If you need to check whether a member exists,
239
+ * look through `this.interfaceMemebers` instead.
240
+ */
241
+ get interfaceElement(): SGInterface | undefined;
242
+ /**
243
+ * Get the `<children>` element of this component. (not to be confused with the AST `childTags` property).
244
+ * If there are multiope `<children>` elements, this function will return the last `<children>` tag because that's what Roku devices do.
245
+ */
246
+ get childrenElement(): SGChildren;
247
+ get customizationElements(): readonly SGCustomization[];
248
+ /**
249
+ * Specifies the name of the component, that allows you to create the component in your application.
250
+ * For example, if the name of the component is `CastMemberInfo`, you could create instances of the component declaratively
251
+ * in a child node element of a component `<children>` element (`<CastMemberInfo/>`), or using BrightScript in a `<script>`
252
+ * element (`createObject("roSGNode","CastMemberInfo")`).
253
+ *
254
+ * The name attribute is case-sensitive. You cannot successfully create or declare a component unless the component name exactly
255
+ * matches the name attribute, including case. Also be aware that two components with the exact same name in the same application
256
+ * components directory will have undefined and generally undesirable results if you attempt to create a component object with that name in the application.
257
+ */
86
258
  get name(): string;
87
259
  set name(value: string);
260
+ /**
261
+ * Specifies the name of the built-in or extended SceneGraph scene or node class whose functionality is extended by this component.
262
+ *
263
+ * For example, `extends="Group"` specifies that the component has all of the functionality of the Group node class (it can have child nodes, has translation/scale/rotation fields, and so forth).
264
+ *
265
+ * By default, a component extends the Group node class.
266
+ */
88
267
  get extends(): string;
89
268
  set extends(value: string);
90
- protected transpileBody(state: TranspileState): (string | SourceNode)[];
269
+ /**
270
+ * Specifies the ID of a node declared in the XML file to have the initial remote control focus when the component is instantiated.
271
+ */
272
+ get initialFocus(): string;
273
+ set initialFocus(value: string);
274
+ /**
275
+ * Specifies the version of the SceneGraph API. The default is 1.0 if not specified.
276
+ */
277
+ get version(): string;
278
+ set version(value: string);
279
+ /**
280
+ * Does the specified field exist in the component interface?
281
+ */
282
+ hasInterfaceField(id: string): boolean;
283
+ /**
284
+ * Does the specified function exist in the component interface?
285
+ */
286
+ hasInterfaceFunction(name: string): boolean;
287
+ /**
288
+ * Get an interface field with the specified name
289
+ */
290
+ getInterfaceField(name: string): SGInterfaceField | undefined;
291
+ /**
292
+ * Return the first SGInterface node found, or insert a new one then return it
293
+ */
294
+ private ensureInterfaceNode;
295
+ /**
296
+ * Create or update a <field> interface element.
297
+ * This will create a new `<interface>` element if there are none on the component already
298
+ */
299
+ setInterfaceField(id: string, type: string, onChange?: string, alwaysNotify?: boolean, alias?: string): SGInterfaceField;
300
+ /**
301
+ * Create or update a <function> interface element.
302
+ * This will create a new `<interface>` element if there are none on the component already
303
+ */
304
+ setInterfaceFunction(name: string): SGInterfaceFunction;
305
+ /**
306
+ * Remove an interface field.
307
+ * @returns true if a field was found and removed. Returns false if no field was found with that name
308
+ */
309
+ removeInterfaceField(id: string): boolean;
310
+ /**
311
+ * Get an interface field with the specified name
312
+ */
313
+ getInterfaceFunction(name: string): SGInterfaceFunction | undefined;
314
+ /**
315
+ * Remove an interface function.
316
+ * @returns true if a function was found and removed. Returns false if no function was found with that name
317
+ */
318
+ removeInterfaceFunction(name: string): boolean;
91
319
  }
92
320
  export interface SGReferences {
93
321
  name?: SGToken;
@@ -95,9 +323,9 @@ export interface SGReferences {
95
323
  scriptTagImports: Pick<FileReference, 'pkgPath' | 'text' | 'filePathRange'>[];
96
324
  }
97
325
  export declare class SGAst {
98
- prolog?: SGProlog;
99
- root?: SGTag;
100
- component?: SGComponent;
101
- constructor(prolog?: SGProlog, root?: SGTag, component?: SGComponent);
102
- transpile(state: TranspileState): TranspileResult;
326
+ prologElement?: SGProlog;
327
+ rootElement?: SGElement;
328
+ componentElement?: SGComponent;
329
+ constructor(prologElement?: SGProlog, rootElement?: SGElement, componentElement?: SGComponent);
330
+ transpile(state: TranspileState): SourceNode;
103
331
  }