brighterscript 0.66.0-alpha.1 → 0.66.0-alpha.11

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 (380) hide show
  1. package/CHANGELOG.md +224 -10
  2. package/README.md +13 -3
  3. package/bsconfig.schema.json +15 -0
  4. package/dist/ActionPipeline.d.ts +10 -0
  5. package/dist/ActionPipeline.js +40 -0
  6. package/dist/ActionPipeline.js.map +1 -0
  7. package/dist/AstValidationSegmenter.d.ts +25 -0
  8. package/dist/AstValidationSegmenter.js +150 -0
  9. package/dist/AstValidationSegmenter.js.map +1 -0
  10. package/dist/BsConfig.d.ts +13 -4
  11. package/dist/BusyStatusTracker.d.ts +31 -0
  12. package/dist/BusyStatusTracker.js +83 -0
  13. package/dist/BusyStatusTracker.js.map +1 -0
  14. package/dist/Cache.js +3 -3
  15. package/dist/Cache.js.map +1 -1
  16. package/dist/CacheVerifier.d.ts +0 -1
  17. package/dist/CodeActionUtil.d.ts +2 -2
  18. package/dist/CommentFlagProcessor.d.ts +4 -3
  19. package/dist/CommentFlagProcessor.js.map +1 -1
  20. package/dist/DiagnosticCollection.js +8 -5
  21. package/dist/DiagnosticCollection.js.map +1 -1
  22. package/dist/DiagnosticMessages.d.ts +34 -4
  23. package/dist/DiagnosticMessages.js +59 -4
  24. package/dist/DiagnosticMessages.js.map +1 -1
  25. package/dist/FunctionScope.d.ts +1 -1
  26. package/dist/LanguageServer.d.ts +23 -1
  27. package/dist/LanguageServer.js +139 -57
  28. package/dist/LanguageServer.js.map +1 -1
  29. package/dist/Logger.d.ts +3 -2
  30. package/dist/Logger.js +10 -2
  31. package/dist/Logger.js.map +1 -1
  32. package/dist/PluginInterface.d.ts +11 -2
  33. package/dist/PluginInterface.js +69 -10
  34. package/dist/PluginInterface.js.map +1 -1
  35. package/dist/Program.d.ts +138 -49
  36. package/dist/Program.js +644 -349
  37. package/dist/Program.js.map +1 -1
  38. package/dist/ProgramBuilder.d.ts +10 -4
  39. package/dist/ProgramBuilder.js +76 -74
  40. package/dist/ProgramBuilder.js.map +1 -1
  41. package/dist/Scope.d.ts +52 -49
  42. package/dist/Scope.js +298 -274
  43. package/dist/Scope.js.map +1 -1
  44. package/dist/SymbolTable.d.ts +35 -14
  45. package/dist/SymbolTable.js +90 -29
  46. package/dist/SymbolTable.js.map +1 -1
  47. package/dist/Throttler.d.ts +12 -0
  48. package/dist/Throttler.js +39 -0
  49. package/dist/Throttler.js.map +1 -1
  50. package/dist/XmlScope.d.ts +7 -4
  51. package/dist/XmlScope.js +52 -12
  52. package/dist/XmlScope.js.map +1 -1
  53. package/dist/astUtils/{AstEditor.d.ts → Editor.d.ts} +6 -1
  54. package/dist/astUtils/{AstEditor.js → Editor.js} +9 -3
  55. package/dist/astUtils/Editor.js.map +1 -0
  56. package/dist/astUtils/{AstEditor.spec.js → Editor.spec.js} +10 -6
  57. package/dist/astUtils/Editor.spec.js.map +1 -0
  58. package/dist/astUtils/creators.d.ts +3 -1
  59. package/dist/astUtils/creators.js +14 -4
  60. package/dist/astUtils/creators.js.map +1 -1
  61. package/dist/astUtils/reflection.d.ts +37 -9
  62. package/dist/astUtils/reflection.js +83 -14
  63. package/dist/astUtils/reflection.js.map +1 -1
  64. package/dist/astUtils/reflection.spec.js +87 -5
  65. package/dist/astUtils/reflection.spec.js.map +1 -1
  66. package/dist/astUtils/visitors.d.ts +14 -3
  67. package/dist/astUtils/visitors.js +22 -2
  68. package/dist/astUtils/visitors.js.map +1 -1
  69. package/dist/astUtils/visitors.spec.js +58 -7
  70. package/dist/astUtils/visitors.spec.js.map +1 -1
  71. package/dist/bscPlugin/BscPlugin.d.ts +10 -2
  72. package/dist/bscPlugin/BscPlugin.js +24 -4
  73. package/dist/bscPlugin/BscPlugin.js.map +1 -1
  74. package/dist/bscPlugin/CallExpressionInfo.d.ts +3 -3
  75. package/dist/bscPlugin/CallExpressionInfo.js.map +1 -1
  76. package/dist/bscPlugin/FileWriter.d.ts +6 -0
  77. package/dist/bscPlugin/FileWriter.js +24 -0
  78. package/dist/bscPlugin/FileWriter.js.map +1 -0
  79. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js +8 -8
  80. package/dist/bscPlugin/codeActions/CodeActionsProcessor.js.map +1 -1
  81. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js +4 -4
  82. package/dist/bscPlugin/codeActions/CodeActionsProcessor.spec.js.map +1 -1
  83. package/dist/bscPlugin/completions/CompletionsProcessor.d.ts +50 -1
  84. package/dist/bscPlugin/completions/CompletionsProcessor.js +445 -23
  85. package/dist/bscPlugin/completions/CompletionsProcessor.js.map +1 -1
  86. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js +1737 -0
  87. package/dist/bscPlugin/completions/CompletionsProcessor.spec.js.map +1 -0
  88. package/dist/bscPlugin/fileProviders/FileProvider.d.ts +9 -0
  89. package/dist/bscPlugin/fileProviders/FileProvider.js +51 -0
  90. package/dist/bscPlugin/fileProviders/FileProvider.js.map +1 -0
  91. package/dist/bscPlugin/hover/HoverProcessor.d.ts +7 -3
  92. package/dist/bscPlugin/hover/HoverProcessor.js +133 -103
  93. package/dist/bscPlugin/hover/HoverProcessor.js.map +1 -1
  94. package/dist/bscPlugin/hover/HoverProcessor.spec.js +241 -29
  95. package/dist/bscPlugin/hover/HoverProcessor.spec.js.map +1 -1
  96. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.d.ts +1 -0
  97. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js +43 -0
  98. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.js.map +1 -1
  99. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js +22 -0
  100. package/dist/bscPlugin/semanticTokens/BrsFileSemanticTokensProcessor.spec.js.map +1 -1
  101. package/dist/bscPlugin/serialize/BslibInjector.spec.js +19 -0
  102. package/dist/bscPlugin/serialize/BslibInjector.spec.js.map +1 -0
  103. package/dist/bscPlugin/serialize/BslibManager.d.ts +9 -0
  104. package/dist/bscPlugin/serialize/BslibManager.js +40 -0
  105. package/dist/bscPlugin/serialize/BslibManager.js.map +1 -0
  106. package/dist/bscPlugin/serialize/FileSerializer.d.ts +9 -0
  107. package/dist/bscPlugin/serialize/FileSerializer.js +72 -0
  108. package/dist/bscPlugin/serialize/FileSerializer.js.map +1 -0
  109. package/dist/bscPlugin/transpile/{BrsFilePreTranspileProcessor.d.ts → BrsFileTranspileProcessor.d.ts} +4 -2
  110. package/dist/bscPlugin/transpile/{BrsFilePreTranspileProcessor.js → BrsFileTranspileProcessor.js} +29 -5
  111. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.js.map +1 -0
  112. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.d.ts +1 -0
  113. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js +41 -0
  114. package/dist/bscPlugin/transpile/BrsFileTranspileProcessor.spec.js.map +1 -0
  115. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.d.ts +2 -2
  116. package/dist/bscPlugin/transpile/XmlFilePreTranspileProcessor.js.map +1 -1
  117. package/dist/bscPlugin/validation/BrsFileValidator.d.ts +0 -4
  118. package/dist/bscPlugin/validation/BrsFileValidator.js +34 -29
  119. package/dist/bscPlugin/validation/BrsFileValidator.js.map +1 -1
  120. package/dist/bscPlugin/validation/BrsFileValidator.spec.js +1 -1
  121. package/dist/bscPlugin/validation/BrsFileValidator.spec.js.map +1 -1
  122. package/dist/bscPlugin/validation/ScopeValidator.d.ts +28 -7
  123. package/dist/bscPlugin/validation/ScopeValidator.js +393 -205
  124. package/dist/bscPlugin/validation/ScopeValidator.js.map +1 -1
  125. package/dist/bscPlugin/validation/ScopeValidator.spec.d.ts +1 -0
  126. package/dist/bscPlugin/validation/ScopeValidator.spec.js +2038 -0
  127. package/dist/bscPlugin/validation/ScopeValidator.spec.js.map +1 -0
  128. package/dist/bscPlugin/validation/XmlFileValidator.js +2 -2
  129. package/dist/bscPlugin/validation/XmlFileValidator.js.map +1 -1
  130. package/dist/cli.js +104 -13
  131. package/dist/cli.js.map +1 -1
  132. package/dist/deferred.d.ts +3 -3
  133. package/dist/deferred.js.map +1 -1
  134. package/dist/diagnosticUtils.d.ts +8 -2
  135. package/dist/diagnosticUtils.js +45 -16
  136. package/dist/diagnosticUtils.js.map +1 -1
  137. package/dist/examples/plugins/removePrint.js +1 -1
  138. package/dist/examples/plugins/removePrint.js.map +1 -1
  139. package/dist/files/AssetFile.d.ts +26 -0
  140. package/dist/files/AssetFile.js +26 -0
  141. package/dist/files/AssetFile.js.map +1 -0
  142. package/dist/files/BrsFile.Class.spec.js +383 -56
  143. package/dist/files/BrsFile.Class.spec.js.map +1 -1
  144. package/dist/files/BrsFile.d.ts +73 -46
  145. package/dist/files/BrsFile.js +370 -534
  146. package/dist/files/BrsFile.js.map +1 -1
  147. package/dist/files/BrsFile.spec.js +1139 -682
  148. package/dist/files/BrsFile.spec.js.map +1 -1
  149. package/dist/files/Factory.d.ts +25 -0
  150. package/dist/files/Factory.js +22 -0
  151. package/dist/files/Factory.js.map +1 -0
  152. package/dist/files/File.d.ts +106 -0
  153. package/dist/files/File.js +16 -0
  154. package/dist/files/File.js.map +1 -0
  155. package/dist/files/LazyFileData.d.ts +20 -0
  156. package/dist/files/LazyFileData.js +54 -0
  157. package/dist/files/LazyFileData.js.map +1 -0
  158. package/dist/files/LazyFileData.spec.d.ts +1 -0
  159. package/dist/files/LazyFileData.spec.js +27 -0
  160. package/dist/files/LazyFileData.spec.js.map +1 -0
  161. package/dist/files/XmlFile.d.ts +56 -23
  162. package/dist/files/XmlFile.js +88 -60
  163. package/dist/files/XmlFile.js.map +1 -1
  164. package/dist/files/XmlFile.spec.js +64 -93
  165. package/dist/files/XmlFile.spec.js.map +1 -1
  166. package/dist/files/tests/imports.spec.js +21 -8
  167. package/dist/files/tests/imports.spec.js.map +1 -1
  168. package/dist/files/tests/optionalChaning.spec.js +14 -14
  169. package/dist/files/tests/optionalChaning.spec.js.map +1 -1
  170. package/dist/globalCallables.js +88 -84
  171. package/dist/globalCallables.js.map +1 -1
  172. package/dist/index.d.ts +9 -1
  173. package/dist/index.js +9 -1
  174. package/dist/index.js.map +1 -1
  175. package/dist/interfaces.d.ts +389 -94
  176. package/dist/interfaces.js +13 -2
  177. package/dist/interfaces.js.map +1 -1
  178. package/dist/lexer/Lexer.d.ts +12 -0
  179. package/dist/lexer/Lexer.js +28 -8
  180. package/dist/lexer/Lexer.js.map +1 -1
  181. package/dist/lexer/Lexer.spec.js +40 -0
  182. package/dist/lexer/Lexer.spec.js.map +1 -1
  183. package/dist/lexer/Token.d.ts +4 -0
  184. package/dist/lexer/Token.js.map +1 -1
  185. package/dist/lexer/TokenKind.d.ts +5 -0
  186. package/dist/lexer/TokenKind.js +14 -2
  187. package/dist/lexer/TokenKind.js.map +1 -1
  188. package/dist/parser/AstNode.d.ts +9 -2
  189. package/dist/parser/AstNode.js +16 -0
  190. package/dist/parser/AstNode.js.map +1 -1
  191. package/dist/parser/BrsTranspileState.d.ts +3 -2
  192. package/dist/parser/BrsTranspileState.js +3 -2
  193. package/dist/parser/BrsTranspileState.js.map +1 -1
  194. package/dist/parser/Expression.d.ts +21 -5
  195. package/dist/parser/Expression.js +130 -35
  196. package/dist/parser/Expression.js.map +1 -1
  197. package/dist/parser/Parser.Class.spec.js +103 -1
  198. package/dist/parser/Parser.Class.spec.js.map +1 -1
  199. package/dist/parser/Parser.d.ts +7 -0
  200. package/dist/parser/Parser.js +117 -21
  201. package/dist/parser/Parser.js.map +1 -1
  202. package/dist/parser/Parser.spec.js +557 -5
  203. package/dist/parser/Parser.spec.js.map +1 -1
  204. package/dist/parser/SGParser.d.ts +4 -4
  205. package/dist/parser/SGParser.js +3 -3
  206. package/dist/parser/SGParser.js.map +1 -1
  207. package/dist/parser/SGParser.spec.js +2 -2
  208. package/dist/parser/SGParser.spec.js.map +1 -1
  209. package/dist/parser/SGTypes.d.ts +2 -2
  210. package/dist/parser/Statement.d.ts +37 -12
  211. package/dist/parser/Statement.js +153 -46
  212. package/dist/parser/Statement.js.map +1 -1
  213. package/dist/parser/tests/Parser.spec.js +2 -1
  214. package/dist/parser/tests/Parser.spec.js.map +1 -1
  215. package/dist/parser/tests/controlFlow/For.spec.js +16 -8
  216. package/dist/parser/tests/controlFlow/For.spec.js.map +1 -1
  217. package/dist/parser/tests/controlFlow/ForEach.spec.js +12 -6
  218. package/dist/parser/tests/controlFlow/ForEach.spec.js.map +1 -1
  219. package/dist/parser/tests/controlFlow/While.spec.js +8 -4
  220. package/dist/parser/tests/controlFlow/While.spec.js.map +1 -1
  221. package/dist/parser/tests/expression/Call.spec.js +4 -4
  222. package/dist/parser/tests/expression/Call.spec.js.map +1 -1
  223. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js +29 -29
  224. package/dist/parser/tests/expression/NullCoalescenceExpression.spec.js.map +1 -1
  225. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js +10 -10
  226. package/dist/parser/tests/expression/RegexLiteralExpression.spec.js.map +1 -1
  227. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js +24 -24
  228. package/dist/parser/tests/expression/SourceLiteralExpression.spec.js.map +1 -1
  229. package/dist/parser/tests/expression/TemplateStringExpression.spec.js +75 -36
  230. package/dist/parser/tests/expression/TemplateStringExpression.spec.js.map +1 -1
  231. package/dist/parser/tests/expression/TernaryExpression.spec.js +36 -36
  232. package/dist/parser/tests/expression/TernaryExpression.spec.js.map +1 -1
  233. package/dist/parser/tests/expression/UnaryExpression.spec.d.ts +1 -0
  234. package/dist/parser/tests/expression/UnaryExpression.spec.js +52 -0
  235. package/dist/parser/tests/expression/UnaryExpression.spec.js.map +1 -0
  236. package/dist/parser/tests/statement/ConstStatement.spec.js +71 -22
  237. package/dist/parser/tests/statement/ConstStatement.spec.js.map +1 -1
  238. package/dist/parser/tests/statement/Continue.spec.js +2 -2
  239. package/dist/parser/tests/statement/Continue.spec.js.map +1 -1
  240. package/dist/parser/tests/statement/Enum.spec.js +38 -285
  241. package/dist/parser/tests/statement/Enum.spec.js.map +1 -1
  242. package/dist/parser/tests/statement/For.spec.js +6 -6
  243. package/dist/parser/tests/statement/For.spec.js.map +1 -1
  244. package/dist/parser/tests/statement/ForEach.spec.js +4 -4
  245. package/dist/parser/tests/statement/ForEach.spec.js.map +1 -1
  246. package/dist/parser/tests/statement/InterfaceStatement.spec.js +26 -10
  247. package/dist/parser/tests/statement/InterfaceStatement.spec.js.map +1 -1
  248. package/dist/parser/tests/statement/PrintStatement.spec.js +16 -13
  249. package/dist/parser/tests/statement/PrintStatement.spec.js.map +1 -1
  250. package/dist/parser/tests/statement/ReturnStatement.spec.js +5 -3
  251. package/dist/parser/tests/statement/ReturnStatement.spec.js.map +1 -1
  252. package/dist/parser/tests/statement/Set.spec.js +26 -13
  253. package/dist/parser/tests/statement/Set.spec.js.map +1 -1
  254. package/dist/preprocessor/Manifest.d.ts +1 -1
  255. package/dist/preprocessor/Manifest.js +2 -2
  256. package/dist/preprocessor/Manifest.js.map +1 -1
  257. package/dist/roku-types/data.json +244 -294
  258. package/dist/roku-types/index.d.ts +17 -38
  259. package/dist/types/ArrayType.d.ts +4 -1
  260. package/dist/types/ArrayType.js +46 -6
  261. package/dist/types/ArrayType.js.map +1 -1
  262. package/dist/types/ArrayType.spec.js +32 -3
  263. package/dist/types/ArrayType.spec.js.map +1 -1
  264. package/dist/types/AssociativeArrayType.d.ts +11 -0
  265. package/dist/types/AssociativeArrayType.js +52 -0
  266. package/dist/types/AssociativeArrayType.js.map +1 -0
  267. package/dist/types/BaseFunctionType.d.ts +9 -0
  268. package/dist/types/BaseFunctionType.js +25 -0
  269. package/dist/types/BaseFunctionType.js.map +1 -0
  270. package/dist/types/BooleanType.d.ts +2 -1
  271. package/dist/types/BooleanType.js +8 -2
  272. package/dist/types/BooleanType.js.map +1 -1
  273. package/dist/types/BscType.d.ts +10 -6
  274. package/dist/types/BscType.js +69 -16
  275. package/dist/types/BscType.js.map +1 -1
  276. package/dist/types/BscTypeKind.d.ts +3 -0
  277. package/dist/types/BscTypeKind.js +3 -0
  278. package/dist/types/BscTypeKind.js.map +1 -1
  279. package/dist/types/BuiltInInterfaceAdder.d.ts +23 -0
  280. package/dist/types/BuiltInInterfaceAdder.js +164 -0
  281. package/dist/types/BuiltInInterfaceAdder.js.map +1 -0
  282. package/dist/types/BuiltInInterfaceAdder.spec.d.ts +1 -0
  283. package/dist/types/BuiltInInterfaceAdder.spec.js +116 -0
  284. package/dist/types/BuiltInInterfaceAdder.spec.js.map +1 -0
  285. package/dist/types/ClassType.d.ts +10 -4
  286. package/dist/types/ClassType.js +32 -5
  287. package/dist/types/ClassType.js.map +1 -1
  288. package/dist/types/ClassType.spec.js +5 -3
  289. package/dist/types/ClassType.spec.js.map +1 -1
  290. package/dist/types/ComponentType.d.ts +26 -0
  291. package/dist/types/ComponentType.js +83 -0
  292. package/dist/types/ComponentType.js.map +1 -0
  293. package/dist/types/DoubleType.d.ts +2 -1
  294. package/dist/types/DoubleType.js +9 -2
  295. package/dist/types/DoubleType.js.map +1 -1
  296. package/dist/types/DynamicType.d.ts +2 -2
  297. package/dist/types/DynamicType.js +3 -1
  298. package/dist/types/DynamicType.js.map +1 -1
  299. package/dist/types/EnumType.d.ts +24 -6
  300. package/dist/types/EnumType.js +29 -7
  301. package/dist/types/EnumType.js.map +1 -1
  302. package/dist/types/FloatType.d.ts +2 -1
  303. package/dist/types/FloatType.js +9 -2
  304. package/dist/types/FloatType.js.map +1 -1
  305. package/dist/types/FunctionType.d.ts +8 -20
  306. package/dist/types/FunctionType.js +17 -45
  307. package/dist/types/FunctionType.js.map +1 -1
  308. package/dist/types/InheritableType.d.ts +7 -4
  309. package/dist/types/InheritableType.js +67 -3
  310. package/dist/types/InheritableType.js.map +1 -1
  311. package/dist/types/IntegerType.d.ts +2 -1
  312. package/dist/types/IntegerType.js +9 -2
  313. package/dist/types/IntegerType.js.map +1 -1
  314. package/dist/types/InterfaceType.d.ts +6 -4
  315. package/dist/types/InterfaceType.js +8 -11
  316. package/dist/types/InterfaceType.js.map +1 -1
  317. package/dist/types/InterfaceType.spec.js +30 -2
  318. package/dist/types/InterfaceType.spec.js.map +1 -1
  319. package/dist/types/InvalidType.d.ts +2 -1
  320. package/dist/types/InvalidType.js +7 -1
  321. package/dist/types/InvalidType.js.map +1 -1
  322. package/dist/types/LongIntegerType.d.ts +2 -1
  323. package/dist/types/LongIntegerType.js +9 -2
  324. package/dist/types/LongIntegerType.js.map +1 -1
  325. package/dist/types/NamespaceType.d.ts +2 -1
  326. package/dist/types/NamespaceType.js +3 -0
  327. package/dist/types/NamespaceType.js.map +1 -1
  328. package/dist/types/ObjectType.d.ts +2 -2
  329. package/dist/types/ObjectType.js +5 -10
  330. package/dist/types/ObjectType.js.map +1 -1
  331. package/dist/types/ReferenceType.d.ts +15 -3
  332. package/dist/types/ReferenceType.js +173 -24
  333. package/dist/types/ReferenceType.js.map +1 -1
  334. package/dist/types/ReferenceType.spec.js +21 -6
  335. package/dist/types/ReferenceType.spec.js.map +1 -1
  336. package/dist/types/StringType.d.ts +2 -1
  337. package/dist/types/StringType.js +9 -2
  338. package/dist/types/StringType.js.map +1 -1
  339. package/dist/types/TypedFunctionType.d.ts +33 -0
  340. package/dist/types/TypedFunctionType.js +106 -0
  341. package/dist/types/TypedFunctionType.js.map +1 -0
  342. package/dist/types/TypedFunctionType.spec.d.ts +1 -0
  343. package/dist/types/TypedFunctionType.spec.js +122 -0
  344. package/dist/types/TypedFunctionType.spec.js.map +1 -0
  345. package/dist/types/UninitializedType.d.ts +2 -1
  346. package/dist/types/UninitializedType.js +1 -1
  347. package/dist/types/UninitializedType.js.map +1 -1
  348. package/dist/types/UnionType.d.ts +4 -2
  349. package/dist/types/UnionType.js +36 -4
  350. package/dist/types/UnionType.js.map +1 -1
  351. package/dist/types/UnionType.spec.js +46 -19
  352. package/dist/types/UnionType.spec.js.map +1 -1
  353. package/dist/types/VoidType.d.ts +2 -1
  354. package/dist/types/VoidType.js +7 -2
  355. package/dist/types/VoidType.js.map +1 -1
  356. package/dist/types/helper.spec.js +15 -0
  357. package/dist/types/helper.spec.js.map +1 -1
  358. package/dist/types/helpers.d.ts +5 -0
  359. package/dist/types/helpers.js +50 -3
  360. package/dist/types/helpers.js.map +1 -1
  361. package/dist/types/index.d.ts +1 -1
  362. package/dist/types/index.js +1 -1
  363. package/dist/types/index.js.map +1 -1
  364. package/dist/util.d.ts +71 -15
  365. package/dist/util.js +578 -150
  366. package/dist/util.js.map +1 -1
  367. package/dist/validators/ClassValidator.d.ts +0 -1
  368. package/dist/validators/ClassValidator.js +0 -22
  369. package/dist/validators/ClassValidator.js.map +1 -1
  370. package/package.json +3 -2
  371. package/dist/astUtils/AstEditor.js.map +0 -1
  372. package/dist/astUtils/AstEditor.spec.js.map +0 -1
  373. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.js.map +0 -1
  374. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js +0 -31
  375. package/dist/bscPlugin/transpile/BrsFilePreTranspileProcessor.spec.js.map +0 -1
  376. package/dist/types/FunctionType.spec.js +0 -23
  377. package/dist/types/FunctionType.spec.js.map +0 -1
  378. /package/dist/astUtils/{AstEditor.spec.d.ts → Editor.spec.d.ts} +0 -0
  379. /package/dist/bscPlugin/{transpile/BrsFilePreTranspileProcessor.spec.d.ts → completions/CompletionsProcessor.spec.d.ts} +0 -0
  380. /package/dist/{types/FunctionType.spec.d.ts → bscPlugin/serialize/BslibInjector.spec.d.ts} +0 -0
@@ -2,11 +2,11 @@ import type { CompilerPlugin } from './interfaces';
2
2
  import type { Logger } from './Logger';
3
3
  export declare type Arguments<T> = [T] extends [(...args: infer U) => any] ? U : [T] extends [void] ? [] : [T];
4
4
  export default class PluginInterface<T extends CompilerPlugin = CompilerPlugin> {
5
- private plugins;
6
5
  constructor(plugins: CompilerPlugin[], options: {
7
6
  logger: Logger;
8
7
  suppressErrors?: boolean;
9
8
  });
9
+ private plugins;
10
10
  private logger;
11
11
  /**
12
12
  * Should plugin errors cause the program to fail, or should they be caught and simply logged
@@ -15,7 +15,11 @@ export default class PluginInterface<T extends CompilerPlugin = CompilerPlugin>
15
15
  /**
16
16
  * Call `event` on plugins
17
17
  */
18
- emit<K extends keyof T & string>(event: K, ...args: Arguments<T[K]>): void;
18
+ emit<K extends keyof T & string>(event: K, ...args: Arguments<T[K]>): Arguments<T[K]>[0];
19
+ /**
20
+ * Call `event` on plugins, but allow the plugins to return promises that will be awaited before the next plugin is notified
21
+ */
22
+ emitAsync<K extends keyof T & string>(event: K, ...args: Arguments<T[K]>): Promise<Arguments<T[K]>[0]>;
19
23
  /**
20
24
  * Add a plugin to the beginning of the list of plugins
21
25
  */
@@ -24,6 +28,11 @@ export default class PluginInterface<T extends CompilerPlugin = CompilerPlugin>
24
28
  * Add a plugin to the end of the list of plugins
25
29
  */
26
30
  add<T extends CompilerPlugin = CompilerPlugin>(plugin: T): T;
31
+ /**
32
+ * Find deprecated or removed historic plugin hooks, and warn about them.
33
+ * Some events can be forwards-converted
34
+ */
35
+ private sanitizePlugin;
27
36
  has(plugin: CompilerPlugin): boolean;
28
37
  remove<T extends CompilerPlugin = CompilerPlugin>(plugin: T): T;
29
38
  /**
@@ -3,34 +3,53 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const Logger_1 = require("./Logger");
4
4
  class PluginInterface {
5
5
  constructor(plugins, options) {
6
- this.plugins = plugins;
7
- if ((options === null || options === void 0 ? void 0 : options.constructor.name) === 'Logger') {
8
- this.logger = options;
9
- }
10
- else {
11
- this.logger = options === null || options === void 0 ? void 0 : options.logger;
12
- this.suppressErrors = (options === null || options === void 0 ? void 0 : options.suppressErrors) === false ? false : true;
6
+ this.plugins = [];
7
+ this.logger = options === null || options === void 0 ? void 0 : options.logger;
8
+ this.suppressErrors = (options === null || options === void 0 ? void 0 : options.suppressErrors) === false ? false : true;
9
+ for (const plugin of plugins) {
10
+ this.add(plugin);
13
11
  }
14
12
  }
15
13
  /**
16
14
  * Call `event` on plugins
17
15
  */
18
16
  emit(event, ...args) {
17
+ var _a, _b;
19
18
  for (let plugin of this.plugins) {
20
19
  if (plugin[event]) {
21
20
  try {
22
- this.logger.time(Logger_1.LogLevel.debug, [plugin.name, event], () => {
21
+ (_a = this.logger) === null || _a === void 0 ? void 0 : _a.time(Logger_1.LogLevel.debug, [plugin.name, event], () => {
23
22
  plugin[event](...args);
24
23
  });
25
24
  }
26
25
  catch (err) {
27
- this.logger.error(`Error when calling plugin ${plugin.name}.${event}:`, err);
26
+ (_b = this.logger) === null || _b === void 0 ? void 0 : _b.error(`Error when calling plugin ${plugin.name}.${event}:`, err);
28
27
  if (!this.suppressErrors) {
29
28
  throw err;
30
29
  }
31
30
  }
32
31
  }
33
32
  }
33
+ return args[0];
34
+ }
35
+ /**
36
+ * Call `event` on plugins, but allow the plugins to return promises that will be awaited before the next plugin is notified
37
+ */
38
+ async emitAsync(event, ...args) {
39
+ var _a, _b;
40
+ for (let plugin of this.plugins) {
41
+ if (plugin[event]) {
42
+ try {
43
+ await ((_a = this.logger) === null || _a === void 0 ? void 0 : _a.time(Logger_1.LogLevel.debug, [plugin.name, event], async () => {
44
+ await Promise.resolve(plugin[event](...args));
45
+ }));
46
+ }
47
+ catch (err) {
48
+ (_b = this.logger) === null || _b === void 0 ? void 0 : _b.error(`Error when calling plugin ${plugin.name}.${event}:`, err);
49
+ }
50
+ }
51
+ }
52
+ return args[0];
34
53
  }
35
54
  /**
36
55
  * Add a plugin to the beginning of the list of plugins
@@ -46,16 +65,56 @@ class PluginInterface {
46
65
  */
47
66
  add(plugin) {
48
67
  if (!this.has(plugin)) {
68
+ this.sanitizePlugin(plugin);
49
69
  this.plugins.push(plugin);
50
70
  }
51
71
  return plugin;
52
72
  }
73
+ /**
74
+ * Find deprecated or removed historic plugin hooks, and warn about them.
75
+ * Some events can be forwards-converted
76
+ */
77
+ sanitizePlugin(plugin) {
78
+ var _a, _b, _c;
79
+ const removedHooks = [
80
+ 'beforePrepublish',
81
+ 'afterPrepublish'
82
+ ];
83
+ for (const removedHook of removedHooks) {
84
+ if (plugin[removedHook]) {
85
+ (_a = this.logger) === null || _a === void 0 ? void 0 : _a.error(`Plugin "${plugin.name}": event ${removedHook} is no longer supported and will never be called`);
86
+ }
87
+ }
88
+ const upgradeWithWarn = {
89
+ beforePublish: 'beforeSerializeProgram',
90
+ afterPublish: 'afterSerializeProgram',
91
+ beforeProgramTranspile: 'beforeBuildProgram',
92
+ afterProgramTranspile: 'afterBuildProgram',
93
+ beforeFileParse: 'beforeProvideFile',
94
+ afterFileParse: 'afterProvideFile',
95
+ beforeFileTranspile: 'beforePrepareFile',
96
+ afterFileTranspile: 'afterPrepareFile',
97
+ beforeFileDispose: 'beforeFileRemove',
98
+ afterFileDispose: 'afterFileRemove'
99
+ };
100
+ for (const [oldEvent, newEvent] of Object.entries(upgradeWithWarn)) {
101
+ if (plugin[oldEvent]) {
102
+ if (!plugin[newEvent]) {
103
+ plugin[newEvent] = plugin[oldEvent];
104
+ (_b = this.logger) === null || _b === void 0 ? void 0 : _b.warn(`Plugin '${plugin.name}': event '${oldEvent}' is no longer supported. It has been converted to '${newEvent}' but you may encounter issues as their signatures do not match.`);
105
+ }
106
+ else {
107
+ (_c = this.logger) === null || _c === void 0 ? void 0 : _c.warn(`Plugin "${plugin.name}": event '${oldEvent}' is no longer supported and will never be called`);
108
+ }
109
+ }
110
+ }
111
+ }
53
112
  has(plugin) {
54
113
  return this.plugins.includes(plugin);
55
114
  }
56
115
  remove(plugin) {
57
116
  if (this.has(plugin)) {
58
- this.plugins.splice(this.plugins.indexOf(plugin));
117
+ this.plugins.splice(this.plugins.indexOf(plugin), 1);
59
118
  }
60
119
  return plugin;
61
120
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PluginInterface.js","sourceRoot":"","sources":["../src/PluginInterface.ts"],"names":[],"mappings":";;AAEA,qCAAoC;AAOpC,MAAqB,eAAe;IAQhC,YACY,OAAyB,EACjC,OAGU;QAJF,YAAO,GAA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,CAAC,QAAQ,CAAC,EAAE;gBAClB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;oBACnB,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;oBACpC,MAAA,IAAI,CAAC,MAAM,0CAAE,IAAI,CAAC,WAAW,MAAM,CAAC,IAAI,aAAa,QAAQ,uDAAuD,QAAQ,kEAAkE,CAAC,CAAC;iBACnM;qBAAM;oBACH,MAAA,IAAI,CAAC,MAAM,0CAAE,IAAI,CAAC,WAAW,MAAM,CAAC,IAAI,aAAa,QAAQ,mDAAmD,CAAC,CAAC;iBACrH;aACJ;SACJ;IACL,CAAC;IAEM,GAAG,CAAC,MAAsB;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAEM,MAAM,CAA4C,MAAS;QAC9D,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;YAClB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;SACxD;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;OAEG;IACI,KAAK;QACR,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACtB,CAAC;CACJ;AA9ID,kCA8IC"}
package/dist/Program.d.ts CHANGED
@@ -1,25 +1,18 @@
1
- import type { CodeAction, CompletionItem, Position, Range, SignatureInformation, Location } from 'vscode-languageserver';
1
+ import type { CodeAction, Position, Range, SignatureInformation, Location } from 'vscode-languageserver';
2
2
  import type { BsConfig } from './BsConfig';
3
3
  import { Scope } from './Scope';
4
- import { BrsFile } from './files/BrsFile';
5
- import { XmlFile } from './files/XmlFile';
6
- import type { BsDiagnostic, File, FileReference, FileObj, BscFile, SemanticToken, FileLink, Hover } from './interfaces';
4
+ import type { BrsFile, ProvidedSymbolInfo } from './files/BrsFile';
5
+ import type { XmlFile } from './files/XmlFile';
6
+ import type { BsDiagnostic, FileObj, SemanticToken, FileLink, Hover } from './interfaces';
7
+ import type { File } from './files/File';
7
8
  import { XmlScope } from './XmlScope';
8
9
  import { Logger } from './Logger';
9
10
  import PluginInterface from './PluginInterface';
10
11
  import type { FunctionStatement } from './parser/Statement';
11
- import type { SourceMapGenerator } from 'source-map';
12
+ import { Editor } from './astUtils/Editor';
12
13
  import type { Statement } from './parser/AstNode';
13
- import { CacheVerifier } from './CacheVerifier';
14
- export interface SourceObj {
15
- srcPath: string;
16
- source: string;
17
- definitions?: string;
18
- }
19
- export interface TranspileObj {
20
- file: BscFile;
21
- outputPath: string;
22
- }
14
+ import type { FileData } from './files/LazyFileData';
15
+ import type { UnresolvedSymbol } from './AstValidationSegmenter';
23
16
  export interface SignatureInfoObj {
24
17
  index: number;
25
18
  key: string;
@@ -36,8 +29,16 @@ export declare class Program {
36
29
  */
37
30
  options: BsConfig, logger?: Logger, plugins?: PluginInterface);
38
31
  logger: Logger;
39
- typeCacheVerifier: CacheVerifier;
32
+ /**
33
+ * An editor that plugins can use to modify program-level things during the build flow. Don't use this to edit files (they have their own `.editor`)
34
+ */
35
+ editor: Editor;
36
+ /**
37
+ * A factory that creates `File` instances
38
+ */
39
+ private fileFactory;
40
40
  private createGlobalScope;
41
+ private recursivelyAddNodeToSymbolTable;
41
42
  /**
42
43
  * Do all setup required for the global symbol table.
43
44
  */
@@ -65,6 +66,12 @@ export declare class Program {
65
66
  * Should only be set from `this.validate()`
66
67
  */
67
68
  private diagnostics;
69
+ private fileSymbolInformation;
70
+ addFileSymbolInfo(file: BrsFile): void;
71
+ getFileSymbolInfo(file: BrsFile): {
72
+ provides: ProvidedSymbolInfo;
73
+ requires: UnresolvedSymbol[];
74
+ };
68
75
  /**
69
76
  * The path to bslib.brs (the BrightScript runtime for certain BrighterScript features)
70
77
  */
@@ -73,8 +80,17 @@ export declare class Program {
73
80
  /**
74
81
  * A map of every file loaded into this program, indexed by its original file location
75
82
  */
76
- files: Record<string, BscFile>;
77
- private pkgMap;
83
+ files: Record<string, File>;
84
+ /**
85
+ * A map of every file loaded into this program, indexed by its destPath
86
+ */
87
+ private destMap;
88
+ /**
89
+ * Plugins can contribute multiple virtual files for a single physical file.
90
+ * This collection links the virtual files back to the physical file that produced them.
91
+ * The key is the standardized and lower-cased srcPath
92
+ */
93
+ private fileClusters;
78
94
  private scopes;
79
95
  protected addScope(scope: Scope): void;
80
96
  /**
@@ -91,6 +107,10 @@ export declare class Program {
91
107
  file: XmlFile;
92
108
  scope: XmlScope;
93
109
  };
110
+ /**
111
+ * Keeps a set of all the components that need to have their types updated during the current validation cycle
112
+ */
113
+ private componentSymbolsToUpdate;
94
114
  /**
95
115
  * Register (or replace) the reference to a component in the component map
96
116
  */
@@ -99,6 +119,18 @@ export declare class Program {
99
119
  * Remove the specified component from the components map
100
120
  */
101
121
  private unregisterComponent;
122
+ /**
123
+ * Adds a component described in an XML to the set of components that needs to be updated this validation cycle.
124
+ * @param xmlFile XML file with <component> tag
125
+ */
126
+ private addDeferredComponentTypeSymbolCreation;
127
+ private getComponentKey;
128
+ /**
129
+ * Updates the global symbol table with the first component in this.components to have the same name as the component in the file
130
+ * @param componentKey key getting a component from `this.components`
131
+ * @param componentName the unprefixed name of the component that will be added (e.g. 'MyLabel' NOT 'roSgNodeMyLabel')
132
+ */
133
+ private updateComponentSymbolInGlobalScope;
102
134
  /**
103
135
  * re-attach the dependency graph with a new key for any component who changed
104
136
  * their position in their own named array (only matters when there are multiple
@@ -122,9 +154,9 @@ export declare class Program {
122
154
  * @param normalizePath should the provided path be normalized before use
123
155
  */
124
156
  hasFile(filePath: string, normalizePath?: boolean): boolean;
125
- getPkgPath(...args: any[]): any;
126
157
  /**
127
158
  * roku filesystem is case INsensitive, so find the scope by key case insensitive
159
+ * @param scopeName xml scope names are their `destPath`. Source scope is stored with the key `"source"`
128
160
  */
129
161
  getScopeByName(scopeName: string): Scope;
130
162
  /**
@@ -147,17 +179,17 @@ export declare class Program {
147
179
  * Load a file into the program. If that file already exists, it is replaced.
148
180
  * If file contents are provided, those are used, Otherwise, the file is loaded from the file system
149
181
  * @param srcDestOrPkgPath the absolute path, the pkg path (i.e. `pkg:/path/to/file.brs`), or the destPath (i.e. `path/to/file.brs` relative to `pkg:/`)
150
- * @param fileContents the file contents
182
+ * @param fileData the file contents. omit or pass `undefined` to prevent loading the data at this time
151
183
  */
152
- setFile<T extends BscFile>(srcDestOrPkgPath: string, fileContents: string): T;
184
+ setFile<T extends File>(srcDestOrPkgPath: string, fileData?: FileData): T;
153
185
  /**
154
186
  * Load a file into the program. If that file already exists, it is replaced.
155
187
  * @param fileEntry an object that specifies src and dest for the file.
156
- * @param fileContents the file contents. If not provided, the file will be loaded from disk
188
+ * @param fileData the file contents. omit or pass `undefined` to prevent loading the data at this time
157
189
  */
158
- setFile<T extends BscFile>(fileEntry: FileObj, fileContents: string): T;
190
+ setFile<T extends File>(fileEntry: FileObj, fileData: FileData): T;
159
191
  /**
160
- * Given a srcPath, a pkgPath, or both, resolve whichever is missing, relative to rootDir.
192
+ * Given a srcPath, a destPath, or both, resolve whichever is missing, relative to rootDir.
161
193
  * @param fileParam an object representing file paths
162
194
  * @param rootDir must be a pre-normalized path
163
195
  */
@@ -166,6 +198,14 @@ export declare class Program {
166
198
  * Remove any leading `pkg:/` found in the path
167
199
  */
168
200
  private removePkgPrefix;
201
+ /**
202
+ * Is this file a .brs file found somewhere within the `pkg:/source/` folder?
203
+ */
204
+ private isSourceBrsFile;
205
+ /**
206
+ * Is this file a .brs file found somewhere within the `pkg:/source/` folder?
207
+ */
208
+ private isComponentsXmlFile;
169
209
  /**
170
210
  * Ensure source scope is created.
171
211
  * Note: automatically called internally, and no-op if it exists already.
@@ -179,14 +219,29 @@ export declare class Program {
179
219
  removeFiles(srcPaths: string[], normalizePath?: boolean): void;
180
220
  /**
181
221
  * Remove a file from the program
182
- * @param filePath can be a srcPath, a pkgPath, or a destPath (same as pkgPath but without `pkg:/`)
222
+ * @param filePath can be a srcPath, a destPath, or a destPath with leading `pkg:/`
183
223
  * @param normalizePath should this function repair and standardize the path? Passing false should have a performance boost if you can guarantee your path is already sanitized
184
224
  */
185
- removeFile(filePath: string, normalizePath?: boolean): void;
225
+ removeFile(filePath: string, normalizePath?: boolean, keepSymbolInformation?: boolean): void;
226
+ lastValidationInfo: Map<string, {
227
+ symbolsNotDefinedInEveryScope: {
228
+ symbol: UnresolvedSymbol;
229
+ scope: Scope;
230
+ }[];
231
+ duplicateSymbolsInSameScope: {
232
+ symbol: UnresolvedSymbol;
233
+ scope: Scope;
234
+ }[];
235
+ symbolsNotConsistentAcrossScopes: {
236
+ symbol: UnresolvedSymbol;
237
+ scopes: Scope[];
238
+ }[];
239
+ }>;
186
240
  /**
187
241
  * Traverse the entire project, and validate all scopes
188
242
  */
189
243
  validate(): void;
244
+ private detectIncompatibleSymbolsAcrossScopes;
190
245
  /**
191
246
  * Flag all duplicate component names
192
247
  */
@@ -196,22 +251,22 @@ export declare class Program {
196
251
  * @param filePaths can be an array of srcPath or a destPath strings
197
252
  * @param normalizePath should this function repair and standardize the paths? Passing false should have a performance boost if you can guarantee your paths are already sanitized
198
253
  */
199
- getFiles<T extends BscFile>(filePaths: string[], normalizePath?: boolean): T[];
254
+ getFiles<T extends File>(filePaths: string[], normalizePath?: boolean): T[];
200
255
  /**
201
256
  * Get the file at the given path
202
257
  * @param filePath can be a srcPath or a destPath
203
258
  * @param normalizePath should this function repair and standardize the path? Passing false should have a performance boost if you can guarantee your path is already sanitized
204
259
  */
205
- getFile<T extends BscFile>(filePath: string, normalizePath?: boolean): T;
260
+ getFile<T extends File>(filePath: string, normalizePath?: boolean): T;
206
261
  /**
207
262
  * Get a list of all scopes the file is loaded into
208
263
  * @param file the file
209
264
  */
210
- getScopesForFile(file: XmlFile | BrsFile | string): Scope[];
265
+ getScopesForFile(file: File | string): Scope[];
211
266
  /**
212
267
  * Get the first found scope for a file.
213
268
  */
214
- getFirstScopeForFile(file: XmlFile | BrsFile): Scope;
269
+ getFirstScopeForFile(file: File): Scope;
215
270
  getStatementsByName(name: string, originFile: BrsFile, namespaceName?: string): FileLink<Statement>[];
216
271
  getStatementsForXmlFile(scope: XmlScope, filterName?: string): FileLink<FunctionStatement>[];
217
272
  /**
@@ -219,11 +274,11 @@ export declare class Program {
219
274
  * @param filePath can be a srcPath or a destPath
220
275
  * @param position the position (line & column) where completions should be found
221
276
  */
222
- getCompletions(filePath: string, position: Position): CompletionItem[];
277
+ getCompletions(filePath: string, position: Position): import("vscode-languageserver").CompletionItem[];
223
278
  /**
224
279
  * Goes through each file and builds a list of workspace symbols for the program. Used by LanguageServer's onWorkspaceSymbol functionality
225
280
  */
226
- getWorkspaceSymbols(): import("vscode-languageserver-types").SymbolInformation[];
281
+ getWorkspaceSymbols(): import("vscode-languageserver").SymbolInformation[];
227
282
  /**
228
283
  * Given a position in a file, if the position is sitting on some type of identifier,
229
284
  * go to the definition of that identifier (where this thing was first defined)
@@ -243,11 +298,6 @@ export declare class Program {
243
298
  getSemanticTokens(srcPath: string): SemanticToken[];
244
299
  getSignatureHelp(filepath: string, position: Position): SignatureInfoObj[];
245
300
  getReferences(srcPath: string, position: Position): Location[] | Promise<Location[]>;
246
- /**
247
- * Get a list of all script imports, relative to the specified pkgPath
248
- * @param sourcePkgPath - the pkgPath of the source that wants to resolve script imports.
249
- */
250
- getScriptImportCompletions(sourcePkgPath: string, scriptImport: FileReference): CompletionItem[];
251
301
  /**
252
302
  * Transpile a single file and get the result as a string.
253
303
  * This does not write anything to the file system.
@@ -257,35 +307,74 @@ export declare class Program {
257
307
  * @param filePath can be a srcPath or a destPath
258
308
  */
259
309
  getTranspiledFileContents(filePath: string): Promise<FileTranspileResult>;
310
+ private getTranspiledFileContentsPipeline;
311
+ /**
312
+ * Get the absolute output path for a file
313
+ */
314
+ private getOutputPath;
315
+ private getStagingDir;
316
+ /**
317
+ * Prepare the program for building
318
+ * @param files the list of files that should be prepared
319
+ */
320
+ private prepare;
260
321
  /**
261
- * Internal function used to transpile files.
262
- * This does not write anything to the file system
322
+ * Generate the contents of every file
263
323
  */
264
- private _getTranspiledFileContents;
265
- private beforeProgramTranspile;
266
- transpile(fileEntries: FileObj[], stagingDir: string): Promise<void>;
267
- private afterProgramTranspile;
324
+ private serialize;
325
+ /**
326
+ * Write the entire project to disk
327
+ */
328
+ private write;
329
+ private buildPipeline;
330
+ /**
331
+ * Build the project. This transpiles/transforms/copies all files and moves them to the staging directory
332
+ * @param options the list of options used to build the program
333
+ */
334
+ build(options?: ProgramBuildOptions): Promise<void>;
268
335
  /**
269
336
  * Find a list of files in the program that have a function with the given name (case INsensitive)
270
337
  */
271
- findFilesForFunction(functionName: string): BscFile[];
338
+ findFilesForFunction(functionName: string): File[];
272
339
  /**
273
340
  * Find a list of files in the program that have a class with the given name (case INsensitive)
274
341
  */
275
- findFilesForClass(className: string): BscFile[];
276
- findFilesForNamespace(name: string): BscFile[];
277
- findFilesForEnum(name: string): BscFile[];
342
+ findFilesForClass(className: string): File[];
343
+ findFilesForNamespace(name: string): File[];
344
+ findFilesForEnum(name: string): File[];
345
+ private _manifest;
346
+ /**
347
+ * Modify a parsed manifest map by reading `bs_const` and injecting values from `options.manifest.bs_const`
348
+ * @param parsedManifest The manifest map to read from and modify
349
+ */
350
+ private buildBsConstsIntoParsedManifest;
351
+ /**
352
+ * Try to find and load the manifest into memory
353
+ * @param manifestFileObj A pointer to a potential manifest file object found during loading
354
+ */
355
+ loadManifest(manifestFileObj?: FileObj): void;
278
356
  /**
279
357
  * Get a map of the manifest information
280
358
  */
281
359
  getManifest(): Map<string, string>;
282
- private _manifest;
283
360
  dispose(): void;
284
361
  }
285
362
  export interface FileTranspileResult {
286
363
  srcPath: string;
364
+ destPath: string;
287
365
  pkgPath: string;
288
366
  code: string;
289
- map: SourceMapGenerator;
367
+ map: string;
290
368
  typedef: string;
291
369
  }
370
+ export interface ProgramBuildOptions {
371
+ /**
372
+ * The directory where the final built files should be placed. This directory will be cleared before running
373
+ */
374
+ stagingDir?: string;
375
+ /**
376
+ * An array of files to build. If omitted, the entire list of files from the program will be used instead.
377
+ * Typically you will want to leave this blank
378
+ */
379
+ files?: File[];
380
+ }