ticbuild 1.0.21 → 1.0.23

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 (826) hide show
  1. package/README.md +1057 -199
  2. package/dist/backend/ImportedResourceTypes.d.ts +22 -10
  3. package/dist/backend/ImportedResourceTypes.d.ts.map +1 -1
  4. package/dist/backend/ImportedResourceTypes.js +42 -13
  5. package/dist/backend/ImportedResourceTypes.js.map +1 -1
  6. package/dist/backend/assembly.d.ts +11 -0
  7. package/dist/backend/assembly.d.ts.map +1 -0
  8. package/dist/backend/assembly.js +150 -0
  9. package/dist/backend/assembly.js.map +1 -0
  10. package/dist/backend/assetBanking.test.d.ts +2 -0
  11. package/dist/backend/assetBanking.test.d.ts.map +1 -0
  12. package/dist/backend/assetBanking.test.js +242 -0
  13. package/dist/backend/assetBanking.test.js.map +1 -0
  14. package/dist/backend/codeBanking.test.js +7 -5
  15. package/dist/backend/codeBanking.test.js.map +1 -1
  16. package/dist/backend/codeSnippetProcessor.d.ts +78 -0
  17. package/dist/backend/codeSnippetProcessor.d.ts.map +1 -0
  18. package/dist/backend/codeSnippetProcessor.js +241 -0
  19. package/dist/backend/codeSnippetProcessor.js.map +1 -0
  20. package/dist/backend/codeSnippetProcessor.test.d.ts +2 -0
  21. package/dist/backend/codeSnippetProcessor.test.d.ts.map +1 -0
  22. package/dist/backend/codeSnippetProcessor.test.js +221 -0
  23. package/dist/backend/codeSnippetProcessor.test.js.map +1 -0
  24. package/dist/backend/importReference.d.ts +4 -0
  25. package/dist/backend/importReference.d.ts.map +1 -0
  26. package/dist/backend/importReference.js +43 -0
  27. package/dist/backend/importReference.js.map +1 -0
  28. package/dist/backend/importResources.d.ts +3 -1
  29. package/dist/backend/importResources.d.ts.map +1 -1
  30. package/dist/backend/importResources.js +124 -36
  31. package/dist/backend/importResources.js.map +1 -1
  32. package/dist/backend/importResources.test.d.ts +2 -0
  33. package/dist/backend/importResources.test.d.ts.map +1 -0
  34. package/dist/backend/importResources.test.js +87 -0
  35. package/dist/backend/importResources.test.js.map +1 -0
  36. package/dist/backend/importSources.d.ts +51 -0
  37. package/dist/backend/importSources.d.ts.map +1 -0
  38. package/dist/backend/importSources.js +261 -0
  39. package/dist/backend/importSources.js.map +1 -0
  40. package/dist/backend/importSources.test.d.ts +2 -0
  41. package/dist/backend/importSources.test.d.ts.map +1 -0
  42. package/dist/backend/importSources.test.js +271 -0
  43. package/dist/backend/importSources.test.js.map +1 -0
  44. package/dist/backend/importUtils.d.ts +5 -10
  45. package/dist/backend/importUtils.d.ts.map +1 -1
  46. package/dist/backend/importUtils.js +13 -48
  47. package/dist/backend/importUtils.js.map +1 -1
  48. package/dist/backend/importers/CodeDeclarationAnalysis.d.ts +37 -0
  49. package/dist/backend/importers/CodeDeclarationAnalysis.d.ts.map +1 -0
  50. package/dist/backend/importers/CodeDeclarationAnalysis.js +288 -0
  51. package/dist/backend/importers/CodeDeclarationAnalysis.js.map +1 -0
  52. package/dist/backend/importers/CodeResource.d.ts +90 -0
  53. package/dist/backend/importers/CodeResource.d.ts.map +1 -0
  54. package/dist/backend/importers/CodeResource.js +480 -0
  55. package/dist/backend/importers/CodeResource.js.map +1 -0
  56. package/dist/backend/importers/CodeResource.test.d.ts +2 -0
  57. package/dist/backend/importers/CodeResource.test.d.ts.map +1 -0
  58. package/dist/backend/importers/CodeResource.test.js +106 -0
  59. package/dist/backend/importers/CodeResource.test.js.map +1 -0
  60. package/dist/backend/importers/LuaAssetTypeScriptModules.d.ts +38 -0
  61. package/dist/backend/importers/LuaAssetTypeScriptModules.d.ts.map +1 -0
  62. package/dist/backend/importers/LuaAssetTypeScriptModules.js +437 -0
  63. package/dist/backend/importers/LuaAssetTypeScriptModules.js.map +1 -0
  64. package/dist/backend/importers/LuaCodeImporter.d.ts +9 -49
  65. package/dist/backend/importers/LuaCodeImporter.d.ts.map +1 -1
  66. package/dist/backend/importers/LuaCodeImporter.js +28 -255
  67. package/dist/backend/importers/LuaCodeImporter.js.map +1 -1
  68. package/dist/backend/importers/LuaCodeImporter.test.js +89 -46
  69. package/dist/backend/importers/LuaCodeImporter.test.js.map +1 -1
  70. package/dist/backend/importers/LuaTypeCatalog.d.ts +26 -0
  71. package/dist/backend/importers/LuaTypeCatalog.d.ts.map +1 -0
  72. package/dist/backend/importers/LuaTypeCatalog.js +185 -0
  73. package/dist/backend/importers/LuaTypeCatalog.js.map +1 -0
  74. package/dist/backend/importers/ManifestCodeTypeScriptModules.d.ts +10 -0
  75. package/dist/backend/importers/ManifestCodeTypeScriptModules.d.ts.map +1 -0
  76. package/dist/backend/importers/ManifestCodeTypeScriptModules.js +31 -0
  77. package/dist/backend/importers/ManifestCodeTypeScriptModules.js.map +1 -0
  78. package/dist/backend/importers/TypeScriptBuildConstants.d.ts +6 -0
  79. package/dist/backend/importers/TypeScriptBuildConstants.d.ts.map +1 -0
  80. package/dist/backend/importers/TypeScriptBuildConstants.js +79 -0
  81. package/dist/backend/importers/TypeScriptBuildConstants.js.map +1 -0
  82. package/dist/backend/importers/TypeScriptCodeImporter.d.ts +26 -0
  83. package/dist/backend/importers/TypeScriptCodeImporter.d.ts.map +1 -0
  84. package/dist/backend/importers/TypeScriptCodeImporter.js +57 -0
  85. package/dist/backend/importers/TypeScriptCodeImporter.js.map +1 -0
  86. package/dist/backend/importers/TypeScriptCodeImporter.test.d.ts +2 -0
  87. package/dist/backend/importers/TypeScriptCodeImporter.test.d.ts.map +1 -0
  88. package/dist/backend/importers/TypeScriptCodeImporter.test.js +1795 -0
  89. package/dist/backend/importers/TypeScriptCodeImporter.test.js.map +1 -0
  90. package/dist/backend/importers/TypeScriptConstantPlugin.d.ts +8 -0
  91. package/dist/backend/importers/TypeScriptConstantPlugin.d.ts.map +1 -0
  92. package/dist/backend/importers/TypeScriptConstantPlugin.js +412 -0
  93. package/dist/backend/importers/TypeScriptConstantPlugin.js.map +1 -0
  94. package/dist/backend/importers/TypeScriptDeclarationSources.d.ts +19 -0
  95. package/dist/backend/importers/TypeScriptDeclarationSources.d.ts.map +1 -0
  96. package/dist/backend/importers/TypeScriptDeclarationSources.js +119 -0
  97. package/dist/backend/importers/TypeScriptDeclarationSources.js.map +1 -0
  98. package/dist/backend/importers/TypeScriptDeclarationSyntax.d.ts +8 -0
  99. package/dist/backend/importers/TypeScriptDeclarationSyntax.d.ts.map +1 -0
  100. package/dist/backend/importers/TypeScriptDeclarationSyntax.js +29 -0
  101. package/dist/backend/importers/TypeScriptDeclarationSyntax.js.map +1 -0
  102. package/dist/backend/importers/TypeScriptLuaDeclarations.d.ts +23 -0
  103. package/dist/backend/importers/TypeScriptLuaDeclarations.d.ts.map +1 -0
  104. package/dist/backend/importers/TypeScriptLuaDeclarations.js +553 -0
  105. package/dist/backend/importers/TypeScriptLuaDeclarations.js.map +1 -0
  106. package/dist/backend/importers/TypeScriptLuaDeclarations.test.d.ts +2 -0
  107. package/dist/backend/importers/TypeScriptLuaDeclarations.test.d.ts.map +1 -0
  108. package/dist/backend/importers/TypeScriptLuaDeclarations.test.js +29 -0
  109. package/dist/backend/importers/TypeScriptLuaDeclarations.test.js.map +1 -0
  110. package/dist/backend/importers/TypeScriptManifestModules.d.ts +36 -0
  111. package/dist/backend/importers/TypeScriptManifestModules.d.ts.map +1 -0
  112. package/dist/backend/importers/TypeScriptManifestModules.js +347 -0
  113. package/dist/backend/importers/TypeScriptManifestModules.js.map +1 -0
  114. package/dist/backend/importers/TypeScriptNamedTypes.d.ts +22 -0
  115. package/dist/backend/importers/TypeScriptNamedTypes.d.ts.map +1 -0
  116. package/dist/backend/importers/TypeScriptNamedTypes.js +193 -0
  117. package/dist/backend/importers/TypeScriptNamedTypes.js.map +1 -0
  118. package/dist/backend/importers/TypeScriptProgram.d.ts +24 -0
  119. package/dist/backend/importers/TypeScriptProgram.d.ts.map +1 -0
  120. package/dist/backend/importers/TypeScriptProgram.js +141 -0
  121. package/dist/backend/importers/TypeScriptProgram.js.map +1 -0
  122. package/dist/backend/importers/TypeScriptStaticLinker.d.ts +17 -0
  123. package/dist/backend/importers/TypeScriptStaticLinker.d.ts.map +1 -0
  124. package/dist/backend/importers/TypeScriptStaticLinker.js +702 -0
  125. package/dist/backend/importers/TypeScriptStaticLinker.js.map +1 -0
  126. package/dist/backend/importers/TypeScriptTranspilationOptions.d.ts +3 -0
  127. package/dist/backend/importers/TypeScriptTranspilationOptions.d.ts.map +1 -0
  128. package/dist/backend/importers/TypeScriptTranspilationOptions.js +82 -0
  129. package/dist/backend/importers/TypeScriptTranspilationOptions.js.map +1 -0
  130. package/dist/backend/importers/TypeScriptTranspiler.d.ts +13 -0
  131. package/dist/backend/importers/TypeScriptTranspiler.d.ts.map +1 -0
  132. package/dist/backend/importers/TypeScriptTranspiler.js +241 -0
  133. package/dist/backend/importers/TypeScriptTranspiler.js.map +1 -0
  134. package/dist/backend/importers/binaryResourceImporter.d.ts +5 -14
  135. package/dist/backend/importers/binaryResourceImporter.d.ts.map +1 -1
  136. package/dist/backend/importers/binaryResourceImporter.js +6 -34
  137. package/dist/backend/importers/binaryResourceImporter.js.map +1 -1
  138. package/dist/backend/importers/textResourceImporter.d.ts +5 -15
  139. package/dist/backend/importers/textResourceImporter.d.ts.map +1 -1
  140. package/dist/backend/importers/textResourceImporter.js +6 -36
  141. package/dist/backend/importers/textResourceImporter.js.map +1 -1
  142. package/dist/backend/importers/tic80CartImporter.d.ts +12 -15
  143. package/dist/backend/importers/tic80CartImporter.d.ts.map +1 -1
  144. package/dist/backend/importers/tic80CartImporter.js +49 -84
  145. package/dist/backend/importers/tic80CartImporter.js.map +1 -1
  146. package/dist/backend/importers/tsconfigUtils.d.ts +10 -0
  147. package/dist/backend/importers/tsconfigUtils.d.ts.map +1 -0
  148. package/dist/backend/importers/tsconfigUtils.js +152 -0
  149. package/dist/backend/importers/tsconfigUtils.js.map +1 -0
  150. package/dist/backend/luaEncode.d.ts +4 -4
  151. package/dist/backend/luaEncode.d.ts.map +1 -1
  152. package/dist/backend/luaEncode.js +39 -39
  153. package/dist/backend/luaEncode.js.map +1 -1
  154. package/dist/backend/luaEncode.test.js +68 -0
  155. package/dist/backend/luaEncode.test.js.map +1 -1
  156. package/dist/backend/luaPreprocessor.d.ts +18 -1
  157. package/dist/backend/luaPreprocessor.d.ts.map +1 -1
  158. package/dist/backend/luaPreprocessor.js +581 -232
  159. package/dist/backend/luaPreprocessor.js.map +1 -1
  160. package/dist/backend/luaPreprocessor.test.js +293 -12
  161. package/dist/backend/luaPreprocessor.test.js.map +1 -1
  162. package/dist/backend/luaPreprocessorSyntax.d.ts +25 -0
  163. package/dist/backend/luaPreprocessorSyntax.d.ts.map +1 -0
  164. package/dist/backend/luaPreprocessorSyntax.js +74 -0
  165. package/dist/backend/luaPreprocessorSyntax.js.map +1 -0
  166. package/dist/backend/luaPreprocessorSyntax.test.d.ts +2 -0
  167. package/dist/backend/luaPreprocessorSyntax.test.d.ts.map +1 -0
  168. package/dist/backend/luaPreprocessorSyntax.test.js +30 -0
  169. package/dist/backend/luaPreprocessorSyntax.test.js.map +1 -0
  170. package/dist/backend/manifestLoader.test.js +174 -1
  171. package/dist/backend/manifestLoader.test.js.map +1 -1
  172. package/dist/backend/manifestTypes.d.ts +127 -65
  173. package/dist/backend/manifestTypes.d.ts.map +1 -1
  174. package/dist/backend/manifestTypes.js +3 -0
  175. package/dist/backend/manifestTypes.js.map +1 -1
  176. package/dist/backend/preprocessorDefines.d.ts +4 -0
  177. package/dist/backend/preprocessorDefines.d.ts.map +1 -0
  178. package/dist/backend/preprocessorDefines.js +15 -0
  179. package/dist/backend/preprocessorDefines.js.map +1 -0
  180. package/dist/backend/project.d.ts +8 -2
  181. package/dist/backend/project.d.ts.map +1 -1
  182. package/dist/backend/project.js +159 -115
  183. package/dist/backend/project.js.map +1 -1
  184. package/dist/backend/project.test.d.ts +2 -0
  185. package/dist/backend/project.test.d.ts.map +1 -0
  186. package/dist/backend/project.test.js +196 -0
  187. package/dist/backend/project.test.js.map +1 -0
  188. package/dist/backend/projectCore.d.ts +6 -4
  189. package/dist/backend/projectCore.d.ts.map +1 -1
  190. package/dist/backend/projectCore.js +36 -44
  191. package/dist/backend/projectCore.js.map +1 -1
  192. package/dist/backend/projectCore.test.d.ts +2 -0
  193. package/dist/backend/projectCore.test.d.ts.map +1 -0
  194. package/dist/backend/projectCore.test.js +12 -0
  195. package/dist/backend/projectCore.test.js.map +1 -0
  196. package/dist/backend/projectEnvironment.d.ts +8 -0
  197. package/dist/backend/projectEnvironment.d.ts.map +1 -0
  198. package/dist/backend/projectEnvironment.js +70 -0
  199. package/dist/backend/projectEnvironment.js.map +1 -0
  200. package/dist/backend/projectEnvironment.test.d.ts +2 -0
  201. package/dist/backend/projectEnvironment.test.d.ts.map +1 -0
  202. package/dist/backend/projectEnvironment.test.js +90 -0
  203. package/dist/backend/projectEnvironment.test.js.map +1 -0
  204. package/dist/backend/projectFiles.d.ts +32 -0
  205. package/dist/backend/projectFiles.d.ts.map +1 -0
  206. package/dist/backend/projectFiles.js +148 -0
  207. package/dist/backend/projectFiles.js.map +1 -0
  208. package/dist/backend/projectFiles.test.d.ts +2 -0
  209. package/dist/backend/projectFiles.test.d.ts.map +1 -0
  210. package/dist/backend/projectFiles.test.js +136 -0
  211. package/dist/backend/projectFiles.test.js.map +1 -0
  212. package/dist/backend/sourceMap.d.ts +40 -3
  213. package/dist/backend/sourceMap.d.ts.map +1 -1
  214. package/dist/backend/sourceMap.js +333 -64
  215. package/dist/backend/sourceMap.js.map +1 -1
  216. package/dist/backend/sourceMap.test.js +81 -0
  217. package/dist/backend/sourceMap.test.js.map +1 -1
  218. package/dist/backend/sourceMapLookup.d.ts +36 -0
  219. package/dist/backend/sourceMapLookup.d.ts.map +1 -0
  220. package/dist/backend/sourceMapLookup.js +170 -0
  221. package/dist/backend/sourceMapLookup.js.map +1 -0
  222. package/dist/backend/sourceMapLookup.test.d.ts +2 -0
  223. package/dist/backend/sourceMapLookup.test.d.ts.map +1 -0
  224. package/dist/backend/sourceMapLookup.test.js +132 -0
  225. package/dist/backend/sourceMapLookup.test.js.map +1 -0
  226. package/dist/backend/sourceMapV3.d.ts +8 -0
  227. package/dist/backend/sourceMapV3.d.ts.map +1 -0
  228. package/dist/backend/sourceMapV3.js +212 -0
  229. package/dist/backend/sourceMapV3.js.map +1 -0
  230. package/dist/backend/sourceMapV3.test.d.ts +2 -0
  231. package/dist/backend/sourceMapV3.test.d.ts.map +1 -0
  232. package/dist/backend/sourceMapV3.test.js +109 -0
  233. package/dist/backend/sourceMapV3.test.js.map +1 -0
  234. package/dist/backend/symbolIndex.d.ts +2 -12
  235. package/dist/backend/symbolIndex.d.ts.map +1 -1
  236. package/dist/backend/symbolIndex.js +18 -107
  237. package/dist/backend/symbolIndex.js.map +1 -1
  238. package/dist/backend/symbolIndex.test.js +6 -1
  239. package/dist/backend/symbolIndex.test.js.map +1 -1
  240. package/dist/backend/tic80Controller/customController.d.ts +7 -1
  241. package/dist/backend/tic80Controller/customController.d.ts.map +1 -1
  242. package/dist/backend/tic80Controller/customController.js +25 -11
  243. package/dist/backend/tic80Controller/customController.js.map +1 -1
  244. package/dist/backend/tic80Controller/customController.test.js +17 -4
  245. package/dist/backend/tic80Controller/customController.test.js.map +1 -1
  246. package/dist/backend/tic80Controller/remotingClient.d.ts.map +1 -1
  247. package/dist/backend/tic80Controller/remotingClient.js +2 -1
  248. package/dist/backend/tic80Controller/remotingClient.js.map +1 -1
  249. package/dist/backend/tic80Controller/remotingProtocol.d.ts +2 -0
  250. package/dist/backend/tic80Controller/remotingProtocol.d.ts.map +1 -1
  251. package/dist/backend/tic80Controller/remotingProtocol.js +19 -0
  252. package/dist/backend/tic80Controller/remotingProtocol.js.map +1 -1
  253. package/dist/backend/tic80Controller/remotingProtocol.test.js +16 -0
  254. package/dist/backend/tic80Controller/remotingProtocol.test.js.map +1 -1
  255. package/dist/backend/tic80Controller/scriptErrorProtocol.d.ts +41 -0
  256. package/dist/backend/tic80Controller/scriptErrorProtocol.d.ts.map +1 -0
  257. package/dist/backend/tic80Controller/scriptErrorProtocol.js +98 -0
  258. package/dist/backend/tic80Controller/scriptErrorProtocol.js.map +1 -0
  259. package/dist/backend/tic80Controller/scriptErrorProtocol.test.d.ts +2 -0
  260. package/dist/backend/tic80Controller/scriptErrorProtocol.test.d.ts.map +1 -0
  261. package/dist/backend/tic80Controller/scriptErrorProtocol.test.js +78 -0
  262. package/dist/backend/tic80Controller/scriptErrorProtocol.test.js.map +1 -0
  263. package/dist/backend/tic80Controller/tic80Controller.d.ts +7 -0
  264. package/dist/backend/tic80Controller/tic80Controller.d.ts.map +1 -1
  265. package/dist/backend/tic80Controller/vanillaController.d.ts +3 -5
  266. package/dist/backend/tic80Controller/vanillaController.d.ts.map +1 -1
  267. package/dist/backend/tic80Controller/vanillaController.js +19 -18
  268. package/dist/backend/tic80Controller/vanillaController.js.map +1 -1
  269. package/dist/backend/tic80Controller/vanillaController.test.d.ts +2 -0
  270. package/dist/backend/tic80Controller/vanillaController.test.d.ts.map +1 -0
  271. package/dist/backend/tic80Controller/vanillaController.test.js +36 -0
  272. package/dist/backend/tic80Controller/vanillaController.test.js.map +1 -0
  273. package/dist/backend/tic80Resolver.d.ts +2 -0
  274. package/dist/backend/tic80Resolver.d.ts.map +1 -1
  275. package/dist/backend/tic80Resolver.js +15 -47
  276. package/dist/backend/tic80Resolver.js.map +1 -1
  277. package/dist/backend/tic80Resolver.test.d.ts +2 -0
  278. package/dist/backend/tic80Resolver.test.d.ts.map +1 -0
  279. package/dist/backend/tic80Resolver.test.js +34 -0
  280. package/dist/backend/tic80Resolver.test.js.map +1 -0
  281. package/dist/benchmarks/luaMinifiers.d.ts +50 -0
  282. package/dist/benchmarks/luaMinifiers.d.ts.map +1 -0
  283. package/dist/benchmarks/luaMinifiers.js +219 -0
  284. package/dist/benchmarks/luaMinifiers.js.map +1 -0
  285. package/dist/benchmarks/luaMinifiers.test.d.ts +2 -0
  286. package/dist/benchmarks/luaMinifiers.test.d.ts.map +1 -0
  287. package/dist/benchmarks/luaMinifiers.test.js +68 -0
  288. package/dist/benchmarks/luaMinifiers.test.js.map +1 -0
  289. package/dist/buildInfo.d.ts +8 -5
  290. package/dist/buildInfo.d.ts.map +1 -1
  291. package/dist/buildInfo.js +8 -5
  292. package/dist/buildInfo.js.map +1 -1
  293. package/dist/frontend/build.d.ts.map +1 -1
  294. package/dist/frontend/build.js +3 -5
  295. package/dist/frontend/build.js.map +1 -1
  296. package/dist/frontend/buildReporter.d.ts +10 -2
  297. package/dist/frontend/buildReporter.d.ts.map +1 -1
  298. package/dist/frontend/buildReporter.js +4 -1
  299. package/dist/frontend/buildReporter.js.map +1 -1
  300. package/dist/frontend/buildReporter.test.js +51 -2
  301. package/dist/frontend/buildReporter.test.js.map +1 -1
  302. package/dist/frontend/cartUsage.d.ts +20 -0
  303. package/dist/frontend/cartUsage.d.ts.map +1 -0
  304. package/dist/frontend/cartUsage.js +103 -0
  305. package/dist/frontend/cartUsage.js.map +1 -0
  306. package/dist/frontend/codeBankPlacement.test.d.ts +2 -0
  307. package/dist/frontend/codeBankPlacement.test.d.ts.map +1 -0
  308. package/dist/frontend/codeBankPlacement.test.js +89 -0
  309. package/dist/frontend/codeBankPlacement.test.js.map +1 -0
  310. package/dist/frontend/codeBankWarnings.test.js +1 -0
  311. package/dist/frontend/codeBankWarnings.test.js.map +1 -1
  312. package/dist/frontend/core.d.ts +7 -2
  313. package/dist/frontend/core.d.ts.map +1 -1
  314. package/dist/frontend/core.js +301 -300
  315. package/dist/frontend/core.js.map +1 -1
  316. package/dist/frontend/init.d.ts +1 -0
  317. package/dist/frontend/init.d.ts.map +1 -1
  318. package/dist/frontend/init.js +34 -11
  319. package/dist/frontend/init.js.map +1 -1
  320. package/dist/frontend/init.test.d.ts +2 -0
  321. package/dist/frontend/init.test.d.ts.map +1 -0
  322. package/dist/frontend/init.test.js +190 -0
  323. package/dist/frontend/init.test.js.map +1 -0
  324. package/dist/frontend/inspect.d.ts +2 -0
  325. package/dist/frontend/inspect.d.ts.map +1 -0
  326. package/dist/frontend/inspect.js +62 -0
  327. package/dist/frontend/inspect.js.map +1 -0
  328. package/dist/frontend/inspect.test.d.ts +2 -0
  329. package/dist/frontend/inspect.test.d.ts.map +1 -0
  330. package/dist/frontend/inspect.test.js +126 -0
  331. package/dist/frontend/inspect.test.js.map +1 -0
  332. package/dist/frontend/luaCodeArtifacts.test.js +39 -1
  333. package/dist/frontend/luaCodeArtifacts.test.js.map +1 -1
  334. package/dist/frontend/packageInstaller.d.ts +2 -0
  335. package/dist/frontend/packageInstaller.d.ts.map +1 -0
  336. package/dist/frontend/packageInstaller.js +59 -0
  337. package/dist/frontend/packageInstaller.js.map +1 -0
  338. package/dist/frontend/parseOptions.d.ts +4 -1
  339. package/dist/frontend/parseOptions.d.ts.map +1 -1
  340. package/dist/frontend/parseOptions.js +13 -8
  341. package/dist/frontend/parseOptions.js.map +1 -1
  342. package/dist/frontend/parseOptions.test.d.ts +2 -0
  343. package/dist/frontend/parseOptions.test.d.ts.map +1 -0
  344. package/dist/frontend/parseOptions.test.js +65 -0
  345. package/dist/frontend/parseOptions.test.js.map +1 -0
  346. package/dist/frontend/projectFiles.d.ts +4 -0
  347. package/dist/frontend/projectFiles.d.ts.map +1 -0
  348. package/dist/frontend/projectFiles.js +95 -0
  349. package/dist/frontend/projectFiles.js.map +1 -0
  350. package/dist/frontend/projectFiles.test.d.ts +2 -0
  351. package/dist/frontend/projectFiles.test.d.ts.map +1 -0
  352. package/dist/frontend/projectFiles.test.js +106 -0
  353. package/dist/frontend/projectFiles.test.js.map +1 -0
  354. package/dist/frontend/run.d.ts.map +1 -1
  355. package/dist/frontend/run.js +3 -1
  356. package/dist/frontend/run.js.map +1 -1
  357. package/dist/frontend/scriptErrorPresentation.d.ts +9 -0
  358. package/dist/frontend/scriptErrorPresentation.d.ts.map +1 -0
  359. package/dist/frontend/scriptErrorPresentation.js +76 -0
  360. package/dist/frontend/scriptErrorPresentation.js.map +1 -0
  361. package/dist/frontend/scriptErrorPresentation.test.d.ts +2 -0
  362. package/dist/frontend/scriptErrorPresentation.test.d.ts.map +1 -0
  363. package/dist/frontend/scriptErrorPresentation.test.js +137 -0
  364. package/dist/frontend/scriptErrorPresentation.test.js.map +1 -0
  365. package/dist/frontend/scriptErrorSourceMapper.d.ts +15 -0
  366. package/dist/frontend/scriptErrorSourceMapper.d.ts.map +1 -0
  367. package/dist/frontend/scriptErrorSourceMapper.js +177 -0
  368. package/dist/frontend/scriptErrorSourceMapper.js.map +1 -0
  369. package/dist/frontend/scriptErrorSourceMapper.test.d.ts +2 -0
  370. package/dist/frontend/scriptErrorSourceMapper.test.d.ts.map +1 -0
  371. package/dist/frontend/scriptErrorSourceMapper.test.js +189 -0
  372. package/dist/frontend/scriptErrorSourceMapper.test.js.map +1 -0
  373. package/dist/frontend/terminal.d.ts +28 -2
  374. package/dist/frontend/terminal.d.ts.map +1 -1
  375. package/dist/frontend/terminal.js +465 -25
  376. package/dist/frontend/terminal.js.map +1 -1
  377. package/dist/frontend/terminal.test.js +563 -0
  378. package/dist/frontend/terminal.test.js.map +1 -1
  379. package/dist/frontend/typescriptExample.test.d.ts +2 -0
  380. package/dist/frontend/typescriptExample.test.d.ts.map +1 -0
  381. package/dist/frontend/typescriptExample.test.js +92 -0
  382. package/dist/frontend/typescriptExample.test.js.map +1 -0
  383. package/dist/frontend/watch.d.ts.map +1 -1
  384. package/dist/frontend/watch.js +160 -39
  385. package/dist/frontend/watch.js.map +1 -1
  386. package/dist/frontend/watch.test.js +3 -1
  387. package/dist/frontend/watch.test.js.map +1 -1
  388. package/dist/index.js +61 -20
  389. package/dist/index.js.map +1 -1
  390. package/dist/obj/build.jsonl +5 -0
  391. package/dist/obj/build.log +11 -5
  392. package/dist/obj/build.trace.json +89 -0
  393. package/dist/obj/resolvedManifest.ticbuild.jsonc +4 -3
  394. package/dist/obj/variables.json +2 -2
  395. package/dist/projectFileInventory.d.ts +40 -0
  396. package/dist/projectFileInventory.d.ts.map +1 -0
  397. package/dist/projectFileInventory.js +36 -0
  398. package/dist/projectFileInventory.js.map +1 -0
  399. package/dist/utils/console.d.ts +1 -1
  400. package/dist/utils/console.d.ts.map +1 -1
  401. package/dist/utils/console.js +1 -1
  402. package/dist/utils/console.js.map +1 -1
  403. package/dist/utils/encoding/base64.d.ts +3 -0
  404. package/dist/utils/encoding/base64.d.ts.map +1 -0
  405. package/dist/utils/encoding/base64.js +51 -0
  406. package/dist/utils/encoding/base64.js.map +1 -0
  407. package/dist/utils/encoding/codecRegistry.d.ts +69 -12
  408. package/dist/utils/encoding/codecRegistry.d.ts.map +1 -1
  409. package/dist/utils/encoding/codecRegistry.js +6 -0
  410. package/dist/utils/encoding/codecRegistry.js.map +1 -1
  411. package/dist/utils/encoding/hex.d.ts.map +1 -1
  412. package/dist/utils/encoding/hex.js +3 -0
  413. package/dist/utils/encoding/hex.js.map +1 -1
  414. package/dist/utils/encoding/lz.d.ts +25 -5
  415. package/dist/utils/encoding/lz.d.ts.map +1 -1
  416. package/dist/utils/encoding/lz.js +160 -48
  417. package/dist/utils/encoding/lz.js.map +1 -1
  418. package/dist/utils/encoding/lz.test.d.ts +2 -0
  419. package/dist/utils/encoding/lz.test.d.ts.map +1 -0
  420. package/dist/utils/encoding/lz.test.js +95 -0
  421. package/dist/utils/encoding/lz.test.js.map +1 -0
  422. package/dist/utils/encoding/payloadOutput.d.ts +4 -0
  423. package/dist/utils/encoding/payloadOutput.d.ts.map +1 -0
  424. package/dist/utils/encoding/payloadOutput.js +12 -0
  425. package/dist/utils/encoding/payloadOutput.js.map +1 -0
  426. package/dist/utils/encoding/payloadOutput.test.d.ts +2 -0
  427. package/dist/utils/encoding/payloadOutput.test.d.ts.map +1 -0
  428. package/dist/utils/encoding/payloadOutput.test.js +21 -0
  429. package/dist/utils/encoding/payloadOutput.test.js.map +1 -0
  430. package/dist/utils/encoding/payloadTextEncoding.d.ts +6 -0
  431. package/dist/utils/encoding/payloadTextEncoding.d.ts.map +1 -0
  432. package/dist/utils/encoding/payloadTextEncoding.js +39 -0
  433. package/dist/utils/encoding/payloadTextEncoding.js.map +1 -0
  434. package/dist/utils/encoding/payloadTextEncoding.test.d.ts +2 -0
  435. package/dist/utils/encoding/payloadTextEncoding.test.d.ts.map +1 -0
  436. package/dist/utils/encoding/payloadTextEncoding.test.js +31 -0
  437. package/dist/utils/encoding/payloadTextEncoding.test.js.map +1 -0
  438. package/dist/utils/errorHandling.d.ts +1 -0
  439. package/dist/utils/errorHandling.d.ts.map +1 -1
  440. package/dist/utils/errorHandling.js +4 -0
  441. package/dist/utils/errorHandling.js.map +1 -1
  442. package/dist/utils/errorHandling.test.d.ts +2 -0
  443. package/dist/utils/errorHandling.test.d.ts.map +1 -0
  444. package/dist/utils/errorHandling.test.js +17 -0
  445. package/dist/utils/errorHandling.test.js.map +1 -0
  446. package/dist/utils/fileSystem.d.ts +3 -1
  447. package/dist/utils/fileSystem.d.ts.map +1 -1
  448. package/dist/utils/fileSystem.js +16 -16
  449. package/dist/utils/fileSystem.js.map +1 -1
  450. package/dist/utils/help.d.ts +2 -1
  451. package/dist/utils/help.d.ts.map +1 -1
  452. package/dist/utils/help.js +8 -3
  453. package/dist/utils/help.js.map +1 -1
  454. package/dist/utils/lua/LuaCATS.d.ts +31 -0
  455. package/dist/utils/lua/LuaCATS.d.ts.map +1 -0
  456. package/dist/utils/lua/LuaCATS.js +159 -0
  457. package/dist/utils/lua/LuaCATS.js.map +1 -0
  458. package/dist/utils/lua/LuaCATS_declarations.d.ts +22 -0
  459. package/dist/utils/lua/LuaCATS_declarations.d.ts.map +1 -0
  460. package/dist/utils/lua/LuaCATS_declarations.js +107 -0
  461. package/dist/utils/lua/LuaCATS_declarations.js.map +1 -0
  462. package/dist/utils/lua/LuaCATS_declarations.test.d.ts +2 -0
  463. package/dist/utils/lua/LuaCATS_declarations.test.d.ts.map +1 -0
  464. package/dist/utils/lua/LuaCATS_declarations.test.js +38 -0
  465. package/dist/utils/lua/LuaCATS_declarations.test.js.map +1 -0
  466. package/dist/utils/lua/LuaCATS_types.d.ts +52 -0
  467. package/dist/utils/lua/LuaCATS_types.d.ts.map +1 -0
  468. package/dist/utils/lua/LuaCATS_types.js +202 -0
  469. package/dist/utils/lua/LuaCATS_types.js.map +1 -0
  470. package/dist/utils/lua/LuaCATS_types.test.d.ts +2 -0
  471. package/dist/utils/lua/LuaCATS_types.test.d.ts.map +1 -0
  472. package/dist/utils/lua/LuaCATS_types.test.js +38 -0
  473. package/dist/utils/lua/LuaCATS_types.test.js.map +1 -0
  474. package/dist/utils/lua/lua_alias_expressions.d.ts +2 -0
  475. package/dist/utils/lua/lua_alias_expressions.d.ts.map +1 -1
  476. package/dist/utils/lua/lua_alias_expressions.js +12 -1
  477. package/dist/utils/lua/lua_alias_expressions.js.map +1 -1
  478. package/dist/utils/lua/lua_alias_literals.d.ts +2 -0
  479. package/dist/utils/lua/lua_alias_literals.d.ts.map +1 -1
  480. package/dist/utils/lua/lua_alias_literals.js +12 -1
  481. package/dist/utils/lua/lua_alias_literals.js.map +1 -1
  482. package/dist/utils/lua/lua_alias_shared.d.ts +0 -1
  483. package/dist/utils/lua/lua_alias_shared.d.ts.map +1 -1
  484. package/dist/utils/lua/lua_alias_shared.js +60 -56
  485. package/dist/utils/lua/lua_alias_shared.js.map +1 -1
  486. package/dist/utils/lua/lua_ast.d.ts +0 -1
  487. package/dist/utils/lua/lua_ast.d.ts.map +1 -1
  488. package/dist/utils/lua/lua_ast.js +0 -6
  489. package/dist/utils/lua/lua_ast.js.map +1 -1
  490. package/dist/utils/lua/lua_ast_printer.d.ts +55 -0
  491. package/dist/utils/lua/lua_ast_printer.d.ts.map +1 -0
  492. package/dist/utils/lua/lua_ast_printer.js +1043 -0
  493. package/dist/utils/lua/lua_ast_printer.js.map +1 -0
  494. package/dist/utils/lua/lua_ast_provenance.d.ts +13 -0
  495. package/dist/utils/lua/lua_ast_provenance.d.ts.map +1 -0
  496. package/dist/utils/lua/lua_ast_provenance.js +67 -0
  497. package/dist/utils/lua/lua_ast_provenance.js.map +1 -0
  498. package/dist/utils/lua/lua_ast_rewrite.d.ts +20 -0
  499. package/dist/utils/lua/lua_ast_rewrite.d.ts.map +1 -0
  500. package/dist/utils/lua/lua_ast_rewrite.js +198 -0
  501. package/dist/utils/lua/lua_ast_rewrite.js.map +1 -0
  502. package/dist/utils/lua/lua_binding_optimizations.test.d.ts +2 -0
  503. package/dist/utils/lua/lua_binding_optimizations.test.d.ts.map +1 -0
  504. package/dist/utils/lua/lua_binding_optimizations.test.js +247 -0
  505. package/dist/utils/lua/lua_binding_optimizations.test.js.map +1 -0
  506. package/dist/utils/lua/lua_canonicalization_rules.test.d.ts +2 -0
  507. package/dist/utils/lua/lua_canonicalization_rules.test.d.ts.map +1 -0
  508. package/dist/utils/lua/lua_canonicalization_rules.test.js +194 -0
  509. package/dist/utils/lua/lua_canonicalization_rules.test.js.map +1 -0
  510. package/dist/utils/lua/lua_constant_literals.d.ts +7 -0
  511. package/dist/utils/lua/lua_constant_literals.d.ts.map +1 -0
  512. package/dist/utils/lua/lua_constant_literals.js +39 -0
  513. package/dist/utils/lua/lua_constant_literals.js.map +1 -0
  514. package/dist/utils/lua/lua_control_flow_invert_negated_if.d.ts +3 -0
  515. package/dist/utils/lua/lua_control_flow_invert_negated_if.d.ts.map +1 -0
  516. package/dist/utils/lua/lua_control_flow_invert_negated_if.js +37 -0
  517. package/dist/utils/lua/lua_control_flow_invert_negated_if.js.map +1 -0
  518. package/dist/utils/lua/lua_control_flow_remove_false_while.d.ts +3 -0
  519. package/dist/utils/lua/lua_control_flow_remove_false_while.d.ts.map +1 -0
  520. package/dist/utils/lua/lua_control_flow_remove_false_while.js +26 -0
  521. package/dist/utils/lua/lua_control_flow_remove_false_while.js.map +1 -0
  522. package/dist/utils/lua/lua_control_flow_resolve_constant_if.d.ts +3 -0
  523. package/dist/utils/lua/lua_control_flow_resolve_constant_if.d.ts.map +1 -0
  524. package/dist/utils/lua/lua_control_flow_resolve_constant_if.js +83 -0
  525. package/dist/utils/lua/lua_control_flow_resolve_constant_if.js.map +1 -0
  526. package/dist/utils/lua/lua_debug.d.ts +16 -0
  527. package/dist/utils/lua/lua_debug.d.ts.map +1 -0
  528. package/dist/utils/lua/lua_debug.js +42 -0
  529. package/dist/utils/lua/lua_debug.js.map +1 -0
  530. package/dist/utils/lua/lua_debug.test.d.ts +2 -0
  531. package/dist/utils/lua/lua_debug.test.d.ts.map +1 -0
  532. package/dist/utils/lua/lua_debug.test.js +24 -0
  533. package/dist/utils/lua/lua_debug.test.js.map +1 -0
  534. package/dist/utils/lua/lua_doc.d.ts +15 -0
  535. package/dist/utils/lua/lua_doc.d.ts.map +1 -1
  536. package/dist/utils/lua/lua_doc.js +96 -0
  537. package/dist/utils/lua/lua_doc.js.map +1 -1
  538. package/dist/utils/lua/lua_doc_types.d.ts +36 -0
  539. package/dist/utils/lua/lua_doc_types.d.ts.map +1 -0
  540. package/dist/utils/lua/lua_doc_types.js +122 -0
  541. package/dist/utils/lua/lua_doc_types.js.map +1 -0
  542. package/dist/utils/lua/lua_doc_types.test.d.ts +2 -0
  543. package/dist/utils/lua/lua_doc_types.test.d.ts.map +1 -0
  544. package/dist/utils/lua/lua_doc_types.test.js +33 -0
  545. package/dist/utils/lua/lua_doc_types.test.js.map +1 -0
  546. package/dist/utils/lua/lua_expression_effects.d.ts +3 -0
  547. package/dist/utils/lua/lua_expression_effects.d.ts.map +1 -0
  548. package/dist/utils/lua/lua_expression_effects.js +33 -0
  549. package/dist/utils/lua/lua_expression_effects.js.map +1 -0
  550. package/dist/utils/lua/lua_fundamentals.d.ts +4 -0
  551. package/dist/utils/lua/lua_fundamentals.d.ts.map +1 -1
  552. package/dist/utils/lua/lua_fundamentals.js +35 -3
  553. package/dist/utils/lua/lua_fundamentals.js.map +1 -1
  554. package/dist/utils/lua/lua_inline_immutable_aliases.d.ts +3 -0
  555. package/dist/utils/lua/lua_inline_immutable_aliases.d.ts.map +1 -0
  556. package/dist/utils/lua/lua_inline_immutable_aliases.js +124 -0
  557. package/dist/utils/lua/lua_inline_immutable_aliases.js.map +1 -0
  558. package/dist/utils/lua/lua_inline_immutable_scalars.d.ts +3 -0
  559. package/dist/utils/lua/lua_inline_immutable_scalars.d.ts.map +1 -0
  560. package/dist/utils/lua/lua_inline_immutable_scalars.js +230 -0
  561. package/dist/utils/lua/lua_inline_immutable_scalars.js.map +1 -0
  562. package/dist/utils/lua/lua_inline_single_use_expressions.d.ts +3 -0
  563. package/dist/utils/lua/lua_inline_single_use_expressions.d.ts.map +1 -0
  564. package/dist/utils/lua/lua_inline_single_use_expressions.js +105 -0
  565. package/dist/utils/lua/lua_inline_single_use_expressions.js.map +1 -0
  566. package/dist/utils/lua/lua_lexical_bindings.d.ts +25 -0
  567. package/dist/utils/lua/lua_lexical_bindings.d.ts.map +1 -0
  568. package/dist/utils/lua/lua_lexical_bindings.js +233 -0
  569. package/dist/utils/lua/lua_lexical_bindings.js.map +1 -0
  570. package/dist/utils/lua/lua_local_budget.test.js +12 -1
  571. package/dist/utils/lua/lua_local_budget.test.js.map +1 -1
  572. package/dist/utils/lua/lua_optimizer.d.ts +10 -0
  573. package/dist/utils/lua/lua_optimizer.d.ts.map +1 -0
  574. package/dist/utils/lua/lua_optimizer.js +128 -0
  575. package/dist/utils/lua/lua_optimizer.js.map +1 -0
  576. package/dist/utils/lua/lua_optimizer.test.d.ts +2 -0
  577. package/dist/utils/lua/lua_optimizer.test.d.ts.map +1 -0
  578. package/dist/utils/lua/lua_optimizer.test.js +262 -0
  579. package/dist/utils/lua/lua_optimizer.test.js.map +1 -0
  580. package/dist/utils/lua/lua_optimizer_fingerprint.d.ts +3 -0
  581. package/dist/utils/lua/lua_optimizer_fingerprint.d.ts.map +1 -0
  582. package/dist/utils/lua/lua_optimizer_fingerprint.js +50 -0
  583. package/dist/utils/lua/lua_optimizer_fingerprint.js.map +1 -0
  584. package/dist/utils/lua/lua_optimizer_rules.d.ts +3 -0
  585. package/dist/utils/lua/lua_optimizer_rules.d.ts.map +1 -0
  586. package/dist/utils/lua/lua_optimizer_rules.js +57 -0
  587. package/dist/utils/lua/lua_optimizer_rules.js.map +1 -0
  588. package/dist/utils/lua/lua_optimizer_types.d.ts +55 -0
  589. package/dist/utils/lua/lua_optimizer_types.d.ts.map +1 -0
  590. package/dist/utils/lua/lua_optimizer_types.js +31 -0
  591. package/dist/utils/lua/lua_optimizer_types.js.map +1 -0
  592. package/dist/utils/lua/lua_pack_locals.d.ts +2 -0
  593. package/dist/utils/lua/lua_pack_locals.d.ts.map +1 -1
  594. package/dist/utils/lua/lua_pack_locals.js +58 -14
  595. package/dist/utils/lua/lua_pack_locals.js.map +1 -1
  596. package/dist/utils/lua/lua_print_trace.d.ts +4 -0
  597. package/dist/utils/lua/lua_print_trace.d.ts.map +1 -0
  598. package/dist/utils/lua/lua_print_trace.js +166 -0
  599. package/dist/utils/lua/lua_print_trace.js.map +1 -0
  600. package/dist/utils/lua/lua_printer.d.ts +11 -0
  601. package/dist/utils/lua/lua_printer.d.ts.map +1 -0
  602. package/dist/utils/lua/lua_printer.js +105 -0
  603. package/dist/utils/lua/lua_printer.js.map +1 -0
  604. package/dist/utils/lua/lua_printer_lexemes.d.ts +22 -0
  605. package/dist/utils/lua/lua_printer_lexemes.d.ts.map +1 -0
  606. package/dist/utils/lua/lua_printer_lexemes.js +111 -0
  607. package/dist/utils/lua/lua_printer_lexemes.js.map +1 -0
  608. package/dist/utils/lua/lua_printer_tight2.d.ts +2 -0
  609. package/dist/utils/lua/lua_printer_tight2.d.ts.map +1 -0
  610. package/dist/utils/lua/lua_printer_tight2.js +64 -0
  611. package/dist/utils/lua/lua_printer_tight2.js.map +1 -0
  612. package/dist/utils/lua/lua_printer_traceable.d.ts +2 -0
  613. package/dist/utils/lua/lua_printer_traceable.d.ts.map +1 -0
  614. package/dist/utils/lua/lua_printer_traceable.js +107 -0
  615. package/dist/utils/lua/lua_printer_traceable.js.map +1 -0
  616. package/dist/utils/lua/lua_printer_types.d.ts +7 -0
  617. package/dist/utils/lua/lua_printer_types.d.ts.map +1 -0
  618. package/dist/utils/lua/lua_printer_types.js +3 -0
  619. package/dist/utils/lua/lua_printer_types.js.map +1 -0
  620. package/dist/utils/lua/lua_processor.d.ts +15 -72
  621. package/dist/utils/lua/lua_processor.d.ts.map +1 -1
  622. package/dist/utils/lua/lua_processor.js +177 -1205
  623. package/dist/utils/lua/lua_processor.js.map +1 -1
  624. package/dist/utils/lua/lua_processor.test.js +450 -101
  625. package/dist/utils/lua/lua_processor.test.js.map +1 -1
  626. package/dist/utils/lua/lua_remove_dead_stores.d.ts +3 -0
  627. package/dist/utils/lua/lua_remove_dead_stores.d.ts.map +1 -0
  628. package/dist/utils/lua/lua_remove_dead_stores.js +108 -0
  629. package/dist/utils/lua/lua_remove_dead_stores.js.map +1 -0
  630. package/dist/utils/lua/lua_remove_self_assignments.d.ts +3 -0
  631. package/dist/utils/lua/lua_remove_self_assignments.d.ts.map +1 -0
  632. package/dist/utils/lua/lua_remove_self_assignments.js +40 -0
  633. package/dist/utils/lua/lua_remove_self_assignments.js.map +1 -0
  634. package/dist/utils/lua/lua_remove_unused_for_variables.d.ts +3 -0
  635. package/dist/utils/lua/lua_remove_unused_for_variables.d.ts.map +1 -0
  636. package/dist/utils/lua/lua_remove_unused_for_variables.js +40 -0
  637. package/dist/utils/lua/lua_remove_unused_for_variables.js.map +1 -0
  638. package/dist/utils/lua/lua_remove_unused_functions.d.ts +2 -0
  639. package/dist/utils/lua/lua_remove_unused_functions.d.ts.map +1 -1
  640. package/dist/utils/lua/lua_remove_unused_functions.js +29 -6
  641. package/dist/utils/lua/lua_remove_unused_functions.js.map +1 -1
  642. package/dist/utils/lua/lua_remove_unused_locals.d.ts +2 -0
  643. package/dist/utils/lua/lua_remove_unused_locals.d.ts.map +1 -1
  644. package/dist/utils/lua/lua_remove_unused_locals.js +72 -289
  645. package/dist/utils/lua/lua_remove_unused_locals.js.map +1 -1
  646. package/dist/utils/lua/lua_remove_unused_parameters.d.ts +3 -0
  647. package/dist/utils/lua/lua_remove_unused_parameters.d.ts.map +1 -0
  648. package/dist/utils/lua/lua_remove_unused_parameters.js +124 -0
  649. package/dist/utils/lua/lua_remove_unused_parameters.js.map +1 -0
  650. package/dist/utils/lua/lua_rename_allowed_globals.d.ts +3 -0
  651. package/dist/utils/lua/lua_rename_allowed_globals.d.ts.map +1 -1
  652. package/dist/utils/lua/lua_rename_allowed_globals.js +78 -41
  653. package/dist/utils/lua/lua_rename_allowed_globals.js.map +1 -1
  654. package/dist/utils/lua/lua_rename_allowed_table_keys.d.ts +2 -0
  655. package/dist/utils/lua/lua_rename_allowed_table_keys.d.ts.map +1 -1
  656. package/dist/utils/lua/lua_rename_allowed_table_keys.js +57 -20
  657. package/dist/utils/lua/lua_rename_allowed_table_keys.js.map +1 -1
  658. package/dist/utils/lua/lua_rename_table_fields.d.ts +2 -0
  659. package/dist/utils/lua/lua_rename_table_fields.d.ts.map +1 -1
  660. package/dist/utils/lua/lua_rename_table_fields.js +15 -2
  661. package/dist/utils/lua/lua_rename_table_fields.js.map +1 -1
  662. package/dist/utils/lua/lua_renamer.d.ts +2 -0
  663. package/dist/utils/lua/lua_renamer.d.ts.map +1 -1
  664. package/dist/utils/lua/lua_renamer.js +146 -157
  665. package/dist/utils/lua/lua_renamer.js.map +1 -1
  666. package/dist/utils/lua/lua_scalar_simplification.test.d.ts +2 -0
  667. package/dist/utils/lua/lua_scalar_simplification.test.d.ts.map +1 -0
  668. package/dist/utils/lua/lua_scalar_simplification.test.js +293 -0
  669. package/dist/utils/lua/lua_scalar_simplification.test.js.map +1 -0
  670. package/dist/utils/lua/lua_scope_name_reuse.test.d.ts +2 -0
  671. package/dist/utils/lua/lua_scope_name_reuse.test.d.ts.map +1 -0
  672. package/dist/utils/lua/lua_scope_name_reuse.test.js +159 -0
  673. package/dist/utils/lua/lua_scope_name_reuse.test.js.map +1 -0
  674. package/dist/utils/lua/lua_simplify.d.ts +2 -0
  675. package/dist/utils/lua/lua_simplify.d.ts.map +1 -1
  676. package/dist/utils/lua/lua_simplify.js +236 -500
  677. package/dist/utils/lua/lua_simplify.js.map +1 -1
  678. package/dist/utils/lua/lua_source_mapping.test.d.ts +2 -0
  679. package/dist/utils/lua/lua_source_mapping.test.d.ts.map +1 -0
  680. package/dist/utils/lua/lua_source_mapping.test.js +182 -0
  681. package/dist/utils/lua/lua_source_mapping.test.js.map +1 -0
  682. package/dist/utils/lua/lua_string_literal.test.d.ts +2 -0
  683. package/dist/utils/lua/lua_string_literal.test.d.ts.map +1 -0
  684. package/dist/utils/lua/lua_string_literal.test.js +70 -0
  685. package/dist/utils/lua/lua_string_literal.test.js.map +1 -0
  686. package/dist/utils/lua/lua_strip_comments.d.ts +3 -0
  687. package/dist/utils/lua/lua_strip_comments.d.ts.map +1 -0
  688. package/dist/utils/lua/lua_strip_comments.js +15 -0
  689. package/dist/utils/lua/lua_strip_comments.js.map +1 -0
  690. package/dist/utils/lua/lua_symbol_collision.test.d.ts +2 -0
  691. package/dist/utils/lua/lua_symbol_collision.test.d.ts.map +1 -0
  692. package/dist/utils/lua/lua_symbol_collision.test.js +55 -0
  693. package/dist/utils/lua/lua_symbol_collision.test.js.map +1 -0
  694. package/dist/utils/lua/lua_symbols.d.ts +19 -0
  695. package/dist/utils/lua/lua_symbols.d.ts.map +1 -0
  696. package/dist/utils/lua/lua_symbols.js +258 -0
  697. package/dist/utils/lua/lua_symbols.js.map +1 -0
  698. package/dist/utils/lua/lua_symbols.test.d.ts +2 -0
  699. package/dist/utils/lua/lua_symbols.test.d.ts.map +1 -0
  700. package/dist/utils/lua/lua_symbols.test.js +75 -0
  701. package/dist/utils/lua/lua_symbols.test.js.map +1 -0
  702. package/dist/utils/lua/lua_syntax_bare_table_key.d.ts +3 -0
  703. package/dist/utils/lua/lua_syntax_bare_table_key.d.ts.map +1 -0
  704. package/dist/utils/lua/lua_syntax_bare_table_key.js +55 -0
  705. package/dist/utils/lua/lua_syntax_bare_table_key.js.map +1 -0
  706. package/dist/utils/lua/lua_syntax_member_access.d.ts +3 -0
  707. package/dist/utils/lua/lua_syntax_member_access.d.ts.map +1 -0
  708. package/dist/utils/lua/lua_syntax_member_access.js +40 -0
  709. package/dist/utils/lua/lua_syntax_member_access.js.map +1 -0
  710. package/dist/utils/lua/lua_syntax_omit_local_nil.d.ts +3 -0
  711. package/dist/utils/lua/lua_syntax_omit_local_nil.d.ts.map +1 -0
  712. package/dist/utils/lua/lua_syntax_omit_local_nil.js +32 -0
  713. package/dist/utils/lua/lua_syntax_omit_local_nil.js.map +1 -0
  714. package/dist/utils/lua/lua_syntax_remove_redundant_do.d.ts +3 -0
  715. package/dist/utils/lua/lua_syntax_remove_redundant_do.d.ts.map +1 -0
  716. package/dist/utils/lua/lua_syntax_remove_redundant_do.js +50 -0
  717. package/dist/utils/lua/lua_syntax_remove_redundant_do.js.map +1 -0
  718. package/dist/utils/lua/lua_transform_map.d.ts +36 -0
  719. package/dist/utils/lua/lua_transform_map.d.ts.map +1 -0
  720. package/dist/utils/lua/lua_transform_map.js +205 -0
  721. package/dist/utils/lua/lua_transform_map.js.map +1 -0
  722. package/dist/utils/lua/lua_utils.d.ts +2 -4
  723. package/dist/utils/lua/lua_utils.d.ts.map +1 -1
  724. package/dist/utils/lua/lua_utils.js +100 -37
  725. package/dist/utils/lua/lua_utils.js.map +1 -1
  726. package/dist/utils/templates.d.ts +1 -0
  727. package/dist/utils/templates.d.ts.map +1 -1
  728. package/dist/utils/templates.js +4 -0
  729. package/dist/utils/templates.js.map +1 -1
  730. package/dist/utils/tic80/cartLoader.d.ts.map +1 -1
  731. package/dist/utils/tic80/cartLoader.js +7 -5
  732. package/dist/utils/tic80/cartLoader.js.map +1 -1
  733. package/dist/utils/tic80/cartLoader.test.d.ts +2 -0
  734. package/dist/utils/tic80/cartLoader.test.d.ts.map +1 -0
  735. package/dist/utils/tic80/cartLoader.test.js +100 -0
  736. package/dist/utils/tic80/cartLoader.test.js.map +1 -0
  737. package/dist/utils/tic80/cartWriter.d.ts +2 -2
  738. package/dist/utils/tic80/cartWriter.d.ts.map +1 -1
  739. package/dist/utils/tic80/cartWriter.js +22 -17
  740. package/dist/utils/tic80/cartWriter.js.map +1 -1
  741. package/dist/utils/tic80/launch.d.ts +1 -1
  742. package/dist/utils/tic80/launch.d.ts.map +1 -1
  743. package/dist/utils/tic80/launch.js +2 -1
  744. package/dist/utils/tic80/launch.js.map +1 -1
  745. package/dist/utils/tic80/tic80.d.ts +52 -50
  746. package/dist/utils/tic80/tic80.d.ts.map +1 -1
  747. package/dist/utils/tic80/tic80.js +11 -7
  748. package/dist/utils/tic80/tic80.js.map +1 -1
  749. package/dist/utils/traceProfiler.d.ts +86 -0
  750. package/dist/utils/traceProfiler.d.ts.map +1 -0
  751. package/dist/utils/traceProfiler.js +241 -0
  752. package/dist/utils/traceProfiler.js.map +1 -0
  753. package/dist/utils/traceProfiler.test.d.ts +2 -0
  754. package/dist/utils/traceProfiler.test.d.ts.map +1 -0
  755. package/dist/utils/traceProfiler.test.js +236 -0
  756. package/dist/utils/traceProfiler.test.js.map +1 -0
  757. package/dist/utils/utils.d.ts +5 -0
  758. package/dist/utils/utils.d.ts.map +1 -1
  759. package/dist/utils/utils.js +35 -0
  760. package/dist/utils/utils.js.map +1 -1
  761. package/dist/utils/windowPosition.d.ts.map +1 -1
  762. package/dist/utils/windowPosition.js +2 -1
  763. package/dist/utils/windowPosition.js.map +1 -1
  764. package/package.json +31 -4
  765. package/scripts/benchmark-lua-minifiers.js +221 -0
  766. package/scripts/benchmark-lz-configs.js +247 -0
  767. package/scripts/gen-build-info.js +6 -0
  768. package/templates/TIC-80-ticbuild/tic80.exe +0 -0
  769. package/templates/declarations/tic80.d.ts +233 -0
  770. package/templates/env.template +11 -0
  771. package/templates/gitignore.template +7 -3
  772. package/templates/help/build.txt +2 -0
  773. package/templates/help/init.txt +3 -1
  774. package/templates/help/inspect.txt +14 -0
  775. package/templates/help/main.txt +3 -1
  776. package/templates/help/project.txt +27 -0
  777. package/templates/help/run.txt +4 -3
  778. package/templates/help/terminal.txt +32 -18
  779. package/templates/help/watch.txt +19 -5
  780. package/templates/minimal/project.ticbuild.jsonc +2 -1
  781. package/templates/piggybossa/project.ticbuild.jsonc +2 -1
  782. package/templates/pointsphere/project.ticbuild.jsonc +9 -15
  783. package/templates/pointsphere/src/palette.lua +5 -3
  784. package/templates/typescript/.luarc.json +5 -0
  785. package/templates/typescript/.vscode/extensions.json +3 -0
  786. package/templates/typescript/eslint.config.mjs +28 -0
  787. package/templates/typescript/package.json +22 -0
  788. package/templates/typescript/project.ticbuild.jsonc +28 -0
  789. package/templates/typescript/src/main.ts +6 -0
  790. package/templates/typescript/tsconfig.json +10 -0
  791. package/templates/vscode_extensions.template.json +3 -0
  792. package/templates/vscode_settings.template.json +3 -0
  793. package/ticbuild.schema.json +274 -110
  794. package/dist/backend/ImportedResource.d.ts +0 -11
  795. package/dist/backend/ImportedResource.d.ts.map +0 -1
  796. package/dist/backend/ImportedResource.js +0 -53
  797. package/dist/backend/ImportedResource.js.map +0 -1
  798. package/dist/backend/importers/luaImporter.d.ts +0 -1
  799. package/dist/backend/importers/luaImporter.d.ts.map +0 -1
  800. package/dist/backend/importers/luaImporter.js +0 -3
  801. package/dist/backend/importers/luaImporter.js.map +0 -1
  802. package/dist/backend/loadAllImports.d.ts +0 -1
  803. package/dist/backend/loadAllImports.d.ts.map +0 -1
  804. package/dist/backend/loadAllImports.js +0 -3
  805. package/dist/backend/loadAllImports.js.map +0 -1
  806. package/dist/backend/tic80Controller/externalController.d.ts +0 -18
  807. package/dist/backend/tic80Controller/externalController.d.ts.map +0 -1
  808. package/dist/backend/tic80Controller/externalController.js +0 -68
  809. package/dist/backend/tic80Controller/externalController.js.map +0 -1
  810. package/dist/backend/tic80Controller/internalController.d.ts +0 -13
  811. package/dist/backend/tic80Controller/internalController.d.ts.map +0 -1
  812. package/dist/backend/tic80Controller/internalController.js +0 -44
  813. package/dist/backend/tic80Controller/internalController.js.map +0 -1
  814. package/dist/frontend/manifestSchemaSync.test.d.ts +0 -2
  815. package/dist/frontend/manifestSchemaSync.test.d.ts.map +0 -1
  816. package/dist/frontend/manifestSchemaSync.test.js +0 -127
  817. package/dist/frontend/manifestSchemaSync.test.js.map +0 -1
  818. package/dist/frontend/repl.d.ts +0 -7
  819. package/dist/frontend/repl.d.ts.map +0 -1
  820. package/dist/frontend/repl.js +0 -271
  821. package/dist/frontend/repl.js.map +0 -1
  822. package/dist/utils/lua/luaUtils.d.ts +0 -1
  823. package/dist/utils/lua/luaUtils.d.ts.map +0 -1
  824. package/dist/utils/lua/luaUtils.js +0 -3
  825. package/dist/utils/lua/luaUtils.js.map +0 -1
  826. package/templates/help/repl.txt +0 -46
package/README.md CHANGED
@@ -4,6 +4,7 @@
4
4
  A build & watch system for TIC-80 cart development.
5
5
 
6
6
  * Multi-file Lua dev system
7
+ * TypeScript transpiling natively supported (yes, write TIC-80 carts in a typed language)
7
8
  * Watch system: live-update a running tic80 when dependent files are updated.
8
9
  * Sprites, music, map data import from existing carts
9
10
  * Lua preprocessing (`#include`, `#macro`, `#if`, et al)
@@ -103,15 +104,15 @@ ticbuild build
103
104
  # build and launch in a tic80
104
105
  ticbuild run
105
106
 
106
- # build and live-update with changes in a tic80
107
+ # build, live-update, and attach an interactive TIC-80 terminal
107
108
  ticbuild watch
108
109
 
109
- # interactive Lua preprocessing/minification REPL
110
- ticbuild repl
111
-
112
110
  # create a new empty project
113
111
  ticbuild init
114
112
 
113
+ # inspect an existing cart
114
+ ticbuild inspect path/to/cart.tic
115
+
115
116
  ```
116
117
 
117
118
  ## Machine-readable build output
@@ -123,9 +124,8 @@ reporter when another program needs to consume build messages:
123
124
  ticbuild build --reporter jsonl
124
125
  ```
125
126
 
126
- Every build also produces `build.jsonl` in the obj dir.
127
-
128
- The JSONL reporter writes one JSON object per line. Lines look like:
127
+ Every build also produces `build.jsonl` in the obj dir. One JSON object per line.
128
+ Lines look like:
129
129
 
130
130
  ```json
131
131
  {"version":1,"type":"comment","data":{"message":"Loading imported resources..."}}
@@ -146,83 +146,169 @@ Version 1 defines these message types:
146
146
  - `lua.minification`: emitted when Lua's 200-active-local limit causes profitable aliases to be omitted;
147
147
  includes the constrained function, peak existing/generated locals, per-rule omissions, and estimated bytes not saved.
148
148
  - `cart.usage`: raw emitted-cart chunk and total-size information.
149
- - `build.completed`: successful terminal message with duration, log path, and cart path.
150
- - `build.failed`: failed terminal message with the error text.
149
+ - `build.completed`: successful terminal message with duration, log path, trace path, and cart path.
150
+ - `build.failed`: failed terminal message with the error text and, when available, the partial trace path.
151
151
 
152
- ## REPL mode (interactive preprocessing/minification)
152
+ `build.trace.json` is also a build output containing a performance profile of
153
+ the build. It uses the Chrome Trace Event JSON format.
153
154
 
154
- Interactive Lua processing on the command line, using the same context as
155
- the build process. Useful for testing / debugging, or just doing some ad-hock
156
- encoding.
155
+ - [Reference 1 Google Doc](https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview?tab=t.0#heading=h.yr4qxyxotyw)
157
156
 
158
- Note: It doesn't actually EXECUTE the Lua. Just outputs the preprocessed + minified
159
- Lua code.
157
+ The profile trace can be opened in various tools for analysis.
160
158
 
161
- ### Usage
159
+ - Chrome dev tools (F12) - performance tab, open profile.
160
+ - [Perfetto](https://ui.perfetto.dev/)
161
+ - I think Speedscope also supports it
162
+
163
+ ## dev-only code pipeline lab
162
164
 
163
165
  ```bash
164
- ticbuild repl [manifest] [--multi-line] [--mode <name>] [--var <key=value>]
166
+ npm run dev:code-pipeline
165
167
  ```
166
168
 
167
- * **Manifest and build configuration**
168
- * The REPL loads the project in the same way as `build`.
169
- * `--mode` and `--var` are supported
169
+ Starts a web app for exploring Lua preprocessing/minification and
170
+ TypeScript-to-Lua pipeline.
171
+
172
+ It's possible to operate the server over a specific project / build configuration:
170
173
 
171
- * **Single-line mode (default)**
172
- * Each line you enter is processed immediately.
173
- * The resulting Lua code is printed to stdout after each line.
174
+ ```powershell
175
+ $env:TICBUILD_PLAYGROUND_MANIFEST = "C:\path\to\project.ticbuild.jsonc"
176
+ $env:TICBUILD_PLAYGROUND_MODE = "release"
177
+ npm run dev:code-pipeline
178
+ ```
174
179
 
175
- * **Multi-line mode**
176
- * Enable with `--multi-line`.
177
- * Input is collected until a terminator is entered on its own line:
178
- * `:end`, `:eof`, or a lone `:`
179
- * Once the terminator is received, the full block is processed and printed.
180
+ Also available are:
180
181
 
181
- ### REPL commands
182
+ - `npm run build:code-pipeline`
183
+ - `npm run preview:code-pipeline`
182
184
 
183
- Commands always start with `:`.
185
+ ## dev-only LZ compressor sandbox
184
186
 
185
- ```
186
- :help
187
- :minify on
188
- :minify off
189
- :minify <rule> on
190
- :minify <rule> off
191
- :end
192
- :eof
193
- :
194
- :quit
187
+ ```bash
188
+ npm run dev:lz-compressor
195
189
  ```
196
190
 
197
- #### `:minify` details
191
+ Starts a web app for testing LZ/LZRLE compression and other import stream encodings. Input source binary in various encodings:
192
+ HEX, UTF-8, BASE64, and ticbuild BASE85+1 payloads,
193
+ and perform the same LZ/LZRLE compression preset search used by `__IMPORT` / `__ENCODE`.
198
194
 
199
- * `:minify on|off` toggles overall minification for the session.
200
- * `:minify <rule> on|off` overrides individual minification rules. rules:
195
+ Also available are:
201
196
 
202
- ```
203
- stripComments
204
- renameLocalVariables
205
- aliasRepeatedExpressions
206
- aliasLiterals
207
- simplifyExpressions
208
- removeUnusedLocals
209
- removeUnusedFunctions
210
- renameTableFields
211
- packLocalDeclarations
212
- renameSpecifiedGlobalSymbols
197
+ - `npm run build:lz-compressor`
198
+ - `npm run preview:lz-compressor`
199
+ - `npm run benchmark:lz-configs`
200
+
201
+ ## LZ and LZRLE stream format
202
+
203
+ Both formats are byte streams made from tagged operations. Every integer field is an
204
+ unsigned LEB128 varint. The decoder stops after consuming the complete compressed byte
205
+ sequence; there is no terminator or decompressed-size header.
206
+
207
+ | Tag | Fields | Operation |
208
+ | ---- | ----------------------------- | --------- |
209
+ | `00` | `length`, then `length` bytes | Copy literal bytes from the stream. |
210
+ | `80` | `length`, `distance` | Copy from `distance` bytes behind the current output position. Overlapping copies are allowed. |
211
+ | `81` | `length`, `value` | Write `value` repeatedly. Only allowed for LZRLE profiles |
212
+
213
+ Every LZ stream is a valid LZRLE stream. The LZRLE encoder searches both
214
+ the base and RLE-enabled form of each numeric preset, so it emits `81` only when doing so
215
+ actually makes the payload smaller.
216
+
217
+ Runtime code using base `LZ` may omit the `81` branch; runtime code using `LZRLE` must include it.
218
+
219
+ This plain Lua reference decoder accepts both profiles. It takes a dense, 1-based
220
+ array-like table of compressed bytes and returns a new dense, 1-based byte table.
221
+
222
+ ```lua
223
+ local function lz_varint(src, si)
224
+ local value, factor = 0, 1
225
+ while true do
226
+ local byte = src[si]
227
+ -- skip error checking if you're certain the payload is correct
228
+ if byte == nil then error("truncated LZ varint") end
229
+ si = si + 1
230
+ value = value + (byte % 0x80) * factor
231
+ if byte < 0x80 then return value, si end
232
+ factor = factor * 0x80
233
+ end
234
+ end
235
+
236
+ -- Decode a dense 1-based byte table into a new dense 1-based byte table.
237
+ function unlzrle(src)
238
+ local dst = {}
239
+ local si = 1
240
+ while si <= #src do
241
+ local tag = src[si]
242
+ si = si + 1
243
+
244
+ if tag == 0x00 then
245
+ local length
246
+ length, si = lz_varint(src, si)
247
+ if si + length - 1 > #src then error("truncated LZ literal") end -- skip error checking if you're certain the payload is correct
248
+ for _ = 1, length do
249
+ dst[#dst + 1] = src[si]
250
+ si = si + 1
251
+ end
252
+ elseif tag == 0x80 then
253
+ local length, distance
254
+ length, si = lz_varint(src, si)
255
+ distance, si = lz_varint(src, si)
256
+ if distance < 1 or distance > #dst then error("invalid LZ distance") end
257
+ for _ = 1, length do
258
+ dst[#dst + 1] = dst[#dst - distance + 1]
259
+ end
260
+ elseif tag == 0x81 then -- this branch can be omitted if you are not using RLE
261
+ local length
262
+ length, si = lz_varint(src, si)
263
+ local value = src[si]
264
+ if value == nil then error("truncated LZRLE run") end
265
+ si = si + 1
266
+ for _ = 1, length do
267
+ dst[#dst + 1] = value
268
+ end
269
+ else -- again, skipping error handling is optional.
270
+ error("unknown LZ tag: " .. tag)
271
+ end
272
+ end
273
+ return dst
274
+ end
213
275
  ```
214
276
 
215
- These overrides are applied on top of the manifest’s
216
- `assembly.lua.minification` settings.
277
+ ## Project variables (in manifest) vs. environment (`.env`, `.env.local`)
217
278
 
218
- ### Examples
279
+ Project variables and environment values are in separate buckets but both available
280
+ in your project:
281
+
282
+ Environment is applied in this priority (high to low):
283
+
284
+ 1. `--env NAME=value` via command line
285
+ 2. Actuall calling process environment variables
286
+ 2. `.env.local` file
287
+ 3. `.env` file
219
288
 
220
289
  ```bash
221
- # default single-line mode
222
- ticbuild repl
290
+ ticbuild build --env BUILD_MODE=debug --env FEATURE_X=1
291
+ ```
292
+
293
+ From Lua:
294
+
295
+ ```lua
296
+ -- Accessing environment variable:
297
+ local x = __EXPAND("$(env:TIC80_LOCATION)")
298
+ -- Accessing a project var:
299
+ local x = __EXPAND("$(project.name)")
300
+ ```
301
+
302
+ From TypeScript:
223
303
 
224
- # multi-line input mode
225
- ticbuild repl --multi-line
304
+ ```typescript
305
+ // environment variable
306
+ const x = ticbuild.Expand("$(env:TIC80_LOCATION)");
307
+
308
+ // project var:
309
+ const x = ticbuild.Expand("$(project.name)");
310
+ // or,
311
+ const x = ticbuild.Vars["project.name"];
226
312
  ```
227
313
 
228
314
  ## TIC-80 binary location
@@ -230,18 +316,33 @@ ticbuild repl --multi-line
230
316
  By default, `ticbuild` will use a special build of TIC-80 which allows profiling and
231
317
  interop to support remote control.
232
318
 
233
- If you want to use your own or external TIC-80, set an environment variable
234
- (via `.env` and `.env.local`) `USE_EXTERNAL_TIC80=1`.
235
-
236
- The TIC-80 location is searched in the `%PATH%`, but otherwise it can be overridden
237
- via `.env` / `.env.local` in the project directory, with the key `TIC80_LOCATION`,
238
- as a full path to `tic80.exe`.
319
+ To specify which TIC-80 executable to launch, set `USE_EXTERNAL_TIC80=1`, and
320
+ set `TIC80_LOCATION`.
239
321
 
240
322
  ```bash
241
323
  USE_EXTERNAL_TIC80=1 # use own build of tic80.exe. defaults to falsy
242
324
  TIC80_LOCATION=c:\my\custom\tic80.exe # optional. ignored without USE_EXTERNAL_TIC80=1
243
325
  ```
244
326
 
327
+ # Project files
328
+
329
+ ticbuild projects contain some files that ticbuild depends on or
330
+ publishes updates to. After updating ticbuild, you can check these assets:
331
+
332
+ ```bash
333
+ ticbuild project check [manifest]
334
+ ```
335
+
336
+ Something need updating? Perform the update automatically:
337
+
338
+ ```bash
339
+ ticbuild project update [manifest]
340
+ ```
341
+
342
+ User-editable config like `.env`, `.vscode/*` are not modified by
343
+ `project update`, ticbuild assumes you own that config. But if missing, they get
344
+ replaced.
345
+
245
346
  # Project manifest
246
347
 
247
348
  The manifest file is canonically `*.ticbuild.jsonc`. Its location defines the project root.
@@ -250,7 +351,8 @@ The manifest file is canonically `*.ticbuild.jsonc`. Its location defines the pr
250
351
  // paths are always relative to the manifest file's dir (which defines the project root dir)
251
352
  // fyi, reference: https://github.com/nesbox/TIC-80/wiki/.tic-File-Format
252
353
  {
253
- "$schema": "./ticbuild.schema.json",
354
+ "$schema": "./.ticbuild/ticbuild.schema.json",
355
+ "buildConfiguration": "release", // base configuration name (required, gets overridden by other configs)
254
356
  "project": {
255
357
  "name": "my demo",
256
358
  "launchArgs": ["--fs=./", "--skip"], // args that are passed to the tic80 when launched.
@@ -270,37 +372,14 @@ The manifest file is canonically `*.ticbuild.jsonc`. Its location defines the pr
270
372
  },
271
373
  "binDir": "./dist/bin",
272
374
  "objDir": "./dist/obj",
273
- "outputCartName": "$(project.name).tic", // leaf name only
274
-
275
- // Upon build, ticbuild checks that your manifest schema is in sync with the expected
276
- // schema. This schema doesn't affect the build, but it helps editors understand
277
- // the manifest structure, provide auto-complete, validation, etc.
278
- //
279
- // This is true by default. If the project's schema file is different than
280
- // what ticbuild is expecting, then ticbuild will update it.
281
- // Setting to false will leave your existing schema untouched. Could be useful to
282
- // keep commits cleaner?
283
- //
284
- // Note that this is only done at build-time. So if you want to manually update the schema,
285
- // you need to trigger a build. Even if the build doesn't complete, the sync is performed.
286
- //
287
- // Q: why check content, not a version?
288
- // A: - versions are annoying to track, room for error
289
- // - there is no scenario where the content check would be less accurate
290
- // Q: what if the schema doesn't exist in the first place? will it get placed?
291
- // A: Yes. Ticbuild will create `.ticbuild/` and place the schema there.
292
- //
293
- // Q: What if $schema points elsewhere?
294
- // A: Ticbuild will assume the user is managing it; do the check, warn if content mismatch.
295
- // Ticbuild in this case will not change the $schema path, and won't touch the schema file.
296
- "autoUpdateManifestSchema": true,
375
+ "outputCartName": "$(project.name).tic" // leaf name only
297
376
  },
298
377
  "variables": {
299
378
  "anything": "here", // variables can be referred to in values via $(variablename)
300
379
  },
301
380
  "preprocessor": {
302
381
  "defines": {
303
- "DEBUG": true,
382
+ "RELEASE": true,
304
383
  "GEOSPHERE_SUBDIVISIONS": 3,
305
384
  "CURVE_BETA": 0.998,
306
385
  "TITLE": "$(project.name)", // variable substitutions is performed just like most things in the manifest.
@@ -336,34 +415,47 @@ The manifest file is canonically `*.ticbuild.jsonc`. Its location defines the pr
336
415
  // but you can also just specify the value here. Again, string substitution is supported.
337
416
  "value": "greetz to everyone at the party",
338
417
  },
418
+ {
419
+ // A command source produces an asset via a system command.
420
+ // The command runs once per build when used.
421
+ // CWD = project directory
422
+ "name": "shipLarge_png",
423
+ "kind": "binary",
424
+ "command": {
425
+ "executable": "python",
426
+ "args": ["./scripts/processImage.py", "./images/shipLarge.png"],
427
+ "outputFile": "./generated/shipLarge.png.bin", // the asset binary
428
+ // These inputs trigger watch rebuilds. outputFile is generated and is not watched.
429
+ "fileDependencies": ["./scripts/processImage.py", "./images/shipLarge.png"],
430
+ },
431
+ },
339
432
  // it is not necessary to specify all source files here; main.lua can import
340
433
  // files directly by relative path.
341
434
  {
342
435
  "name": "myGraphics",
343
436
  "path": "./carts/sprites.tic", // imports from some other cartridge
344
- // you can specify which chunks to bring in. The chunk types are hard-coded
437
+
438
+ // you can filter which chunks to include. The chunk types are hard-coded
345
439
  // corresponding to the TIC-80 cart chunks.
346
- // Bringing in multiple chunks though means that 1 import can have multiple
347
- // sub-assets. In this case, "myGraphics" contains tiles and sprites.
348
- // asset types are so far just mapped directly to tic80 cart chunk types.
349
- // but in the future it could be that we support our own types of imports
350
- // for example a .MOD, or a .TTF or graphics.
440
+ // see chunk types @ https://github.com/nesbox/TIC-80/wiki/.tic-File-Format
441
+ // see elsewhere in this README for details on specific chunk type behaviors.
351
442
  //
352
- // It means when you refer to an import ("myGraphics") you need to specify
353
- // which sub asset you actually want. Scenarios:
354
- // 1. the requseted chunks matches exactly the asset chunks: e.g. for cart
355
- // assembly, you specify blockTypes:["TILES", "SPRITES"], and asset "myGraphics",
356
- // it will just both sub-assets without needing to specify.
357
- // 2. if you don't specify the chunks desired, all will be used. Errors would
358
- // be produced if the destination doesn't support that chunk type.
359
- // 3. if the requested chunks don't match the available, this is an error.
360
- // In this case you must be explicit about what you want to import.
361
- // (that's the idea...)
443
+ // Bringing in multiple chunks though means that 1 import can have multiple
444
+ // sub-assets (payloads). In this case, "myGraphics" contains tiles and sprites.
362
445
  //
363
- // if import.chunks is omitted, extract all chunks from source.
364
- // if block.chunks is omitted, use all chunks the asset provides.
446
+ // When you refer to an import ("myGraphics" in #import, __IMPORT, or the `assembly` section),
447
+ // you can specify sub asset(s) you actually want. Typically that means
448
+ // omitting chunks[] / bank will use all available; specifying will filter.
449
+ //
450
+ // NOTE: CODE is handled specially: concatenated on load;
451
+ // viewable only as a bank 0 code chunk
452
+ // and auto-split into banks on cart saving.
453
+ // see elsewhere in this readme for details about CODE behavior.
365
454
  "chunks": ["TILES", "SPRITES"],
366
455
  "kind": "Tic80Cartridge", // again this could be deduced.
456
+
457
+ // filter to a specific 0-based source bank. if omitted, all present banks are pulled in.
458
+ "bank": 4,
367
459
  },
368
460
  {
369
461
  "name": "music-imported-cart",
@@ -371,10 +463,10 @@ The manifest file is canonically `*.ticbuild.jsonc`. Its location defines the pr
371
463
  // you can also omit the chunks and we'll just import all available from a cart.
372
464
  "chunks": [
373
465
  "CODE",
374
- "MUSIC_WAVEFORMS",
466
+ "WAVEFORMS",
375
467
  "MUSIC_PATTERNS",
376
- "MUSIC_SFX",
377
- "MUSIC_SONG",
468
+ "SFX",
469
+ "MUSIC_TRACKS",
378
470
  ],
379
471
  // MAYBE in the future we can add other ways to query like to pull in a specific sprite.
380
472
  // but for now not necessary.
@@ -389,10 +481,13 @@ The manifest file is canonically `*.ticbuild.jsonc`. Its location defines the pr
389
481
  "minify": true,
390
482
  "minification": {
391
483
  // options here are exactly those of OptimizationRuleOptions
392
- // these are all the default values if not specified.
484
+ // Defaults are LUA_RELEASE_OPTIMIZATION_OPTIONS
393
485
  "stripComments": true,
394
486
  "maxIndentLevel": 1,
395
- "lineBehavior": "tight", // "pretty" | "tight" | "single-line-blocks";
487
+ // "traceable" puts each diagnostic Lua anchor on its own generated line
488
+ // for precise source mapping of line-only runtime errors. Intended for debug builds.
489
+ // "tight2" removes all lexically optional whitespace while respecting maxLineLength.
490
+ "lineBehavior": "tight", // "pretty" | "tight" | "tight2" | "single-line-blocks" | "traceable";
396
491
  "maxLineLength": 180,
397
492
  "aliasRepeatedExpressions": true,
398
493
  "renameLocalVariables": true,
@@ -404,30 +499,59 @@ The manifest file is canonically `*.ticbuild.jsonc`. Its location defines the pr
404
499
  "functionNamesToKeep": ["TIC", "BDR", "SCN"], // TIC-80 constants by default
405
500
  "renameTableFields": false,
406
501
  "tableEntryKeysToRename": [],
407
- },
408
-
409
- // optional global variables to emit in lua code.
410
- // they are written out as `local variableName = xyz` at the top of the code.
411
- // you cannot specify where it gets emitted.
412
- // what datatype though? string, number, or boolean?
413
- "globals": {
414
- "PROJECT_NAME": "$(project.name)", // by default everything is a string.
415
- "ENABLE_HUD": true, // this can be a boolean to emit as boolean.
416
- "PI": 3.14159, // emits as a number.
417
- // no way currently to emit substituted variables as anything but strings.
502
+ // default "opt-in" when this is omitted. New
503
+ // projects use "opt-out" so globals defined by the final Lua file are
504
+ // renamed unless explicitly preserved.
505
+ "globalSymbolRenaming": "opt-in", // "off" | "opt-in" | "opt-out"
506
+ "globalSymbolsToRename": [],
507
+ "globalSymbolsToKeep": [],
418
508
  },
419
509
  },
420
510
  "blocks": [
421
511
  {
422
- // error if overlapping chunks.
423
- // this chunk type "CODE" is technically redundant because the asset already has the chunk type attached.
512
+ // error if overlapping/colliding chunks.
424
513
  // you can specify CODE_COMPRESSED for the ZLIB compressed version.
514
+
515
+ // "chunks" is slightly ambiguous but effectively it defines the OUTPUT CHUNK(s),
516
+ // which can be implicit from the source.
517
+ // an empty array therefore does specify, albeit no output. Allowed but will output a
518
+ // warning.
519
+ //
520
+ // for single input payloads (single-bank-single-chunk) AND single output payload (bank-chunk),
521
+ // this enables the possibility of "remapping" chunk types.
522
+ //
523
+ // single input payload + multiple output payload is an error (e.g. it's not possible to map
524
+ // a single TILES to multiple chunk types in 1 block entry)
525
+ //
526
+ // for multiple input payloads, this list filters the selected payloads by type.
527
+ // At least one type must match.
425
528
  "chunks": ["CODE"],
426
- "bank": 0,
529
+
530
+ // An explicit destination bank requires one selected payload per output type.
531
+ // Omit it to preserve the selected asset banks (note: CODE will bank-split automatically).
532
+ // Rationale:
533
+ // - this allows multi-bank imports to output also as multiple banks
534
+ // use-case: basically using ticbuild in a daisy-chain flow; minimally
535
+ // taking an existing cart and outputting the same cart without having
536
+ // to specify every chunk & bank.
537
+ // - it allows retaining the original bank without having to repeat that info.
538
+ // if you want to move something from bank 4 to bank 2, it's natural that you
539
+ // must be explicit. But if you want to move from bank 4 to <same bank>, this
540
+ // allows doing that.
541
+ // that's the only way to output multiple banks in 1 block entry.
542
+ // Q: what if they overlap with other assembly entries?
543
+ // -> same logic as specifying dupe chunk/bank in separate entries. error; do not concat or override
544
+ // Q: if two payloads of the same type would both land in the destination bank?
545
+ // -> error; select a single source bank.
546
+ // Q: multiple chunks specified, each spanning only 1 bank, but they're different banks?
547
+ // -> then specifying a bank here will "flatten" them so they all end up in this bank.
548
+ // Q: what if the payload doesn't fit in the destination chunk?
549
+ // -> error. CODE and CODE_COMPRESSED can split automatically when bank is omitted.
550
+ //
551
+ // if the import asset doesn't have a bank (e.g. a raw binary file) then
552
+ // defaults to bank 0.
427
553
  "asset": "maincode",
428
554
  "code": { // optional code assemblyl options
429
- // if true, emits the globals defined in assembly.lua.globals.
430
- "emitGlobals": true,
431
555
  // when applicable (currently only CODE_COMPRESSED), high-level compression options.
432
556
  "compressionMode": "default", // "default" | "zlib-max" | "zopfli"
433
557
  // private TIC-80 extension: allow uncompressed CODE to span up to 16 banks.
@@ -437,28 +561,47 @@ The manifest file is canonically `*.ticbuild.jsonc`. Its location defines the pr
437
561
  },
438
562
  },
439
563
  {
440
- // Note: Binary resources can be output to any chunk type. they just get placed there
441
- // with no regards of format / packing. Often you want to store custom resources in places like
442
- // the large MAP area.
564
+ // Binary and text resources need one explicit destination chunk type.
565
+ // this example uses MAP to store custom data.
443
566
  "chunks": ["MAP"],
444
- "asset": "some_binary_file"
567
+ "asset": "twilight_bog_palette"
445
568
  },
446
569
  {
447
- // produces a view of the import with just the 1 MUSIC_WAVEFORMS sub-asset
448
- // Without specifying the chunks to produce, this automatically implies chunks: ["MUSIC_WAVEFORMS"].
449
- // if you explicitly specify "chunks":["TILES"], this would binary copy the waveforms to the tiles.
570
+ // Copy waveforms from source bank 1 into MAP at output bank 4.
571
+ // Q: what if the imported selection contains WAVEFORMS in *multiple* banks, and you specify
572
+ // outputting to just "TILES"?
573
+ // -> invalid; "remapping" only works for single payloads. it's too obscure to attempt doing some
574
+ // kind of smart mapping. if you have 7 banks of tiles and you want to output them as waveforms (why?),
575
+ // that means you'll need 7 assembly output entries, each remapping the individual banks
450
576
 
451
577
  // canonical form:
452
- "asset": { "import": "music-imported-cart", "chunks": ["MUSIC_WAVEFORMS"] },
578
+ "asset": {
579
+ "import": "music-imported-cart",
580
+
581
+ // chunks & bank are thought of as filter criteria. must match chunks AND bank.
582
+ // so if import contains:
583
+ // - bank 0 WAVEFORMS
584
+ // - bank 1 WAVEFORMS
585
+ // - bank 1 MUSIC_PATTERNS
586
+ // then if you specify:
587
+ // chunks:["WAVEFORMS"] -> both banks of waveforms.
588
+ // chunks:["WAVEFORMS"], bank:0 -> WAVEFORMS:0
589
+ // chunks:["WAVEFORMS", "MUSIC_PATTERNS"], bank:0 -> WAVEFORMS:0
590
+ // chunks:["WAVEFORMS", "MUSIC_PATTERNS"] -> all 3 payloads
591
+ // ! at least 1 payload must result. if no payloads are present in the result, error.
592
+ "chunks": ["WAVEFORMS"],
593
+ "bank": 1
594
+ },
453
595
 
454
- // optional sugar method that resembles how Lua includes assets.
455
- //asset: "import:music-imported-cart:MUSIC_WAVEFORMS",
596
+ // equivalent shorthand for asset: "import:music-imported-cart:WAVEFORMS:1"
597
+ "chunks": ["MAP"],
598
+ "bank": 4,
456
599
  },
457
600
  ],
458
601
  },
459
602
 
460
603
  "buildConfigurations": {
461
- // build configurations allow overriding things in the base config above.
604
+ // build configurations are named overrides of the base config above.
462
605
  // you cannot override individual elements of arrays. for example, `assembly.blocks`
463
606
  // if you override that, you must overwrite the whole value.
464
607
  // similar with includeDirs / additionalWatchGlobs, you can't "add 1" or so; you have to replace the whole array.
@@ -470,6 +613,12 @@ The manifest file is canonically `*.ticbuild.jsonc`. Its location defines the pr
470
613
  "variables": {
471
614
  "anything": "overridden",
472
615
  },
616
+ "preprocessor": {
617
+ "defines": {
618
+ "RELEASE": null, // null removes a define from the base config
619
+ "DEBUG": true,
620
+ },
621
+ },
473
622
  "assembly": {
474
623
  "lua": {
475
624
  "minify": false, // overrides
@@ -480,10 +629,533 @@ The manifest file is canonically `*.ticbuild.jsonc`. Its location defines the pr
480
629
  };
481
630
  ```
482
631
 
483
- When running `ticbuild watch`, ticbuild always watches the manifest file and the dependencies discovered during build and preprocessing. Use `project.additionalWatchGlobs` to add extra glob-based watch targets, relative to the manifest directory unless you provide an absolute pattern. These extra globs can trigger rebuilds on file changes, file additions, and file removals.
632
+ When running `ticbuild watch`, ticbuild watches the manifest file and
633
+ project dependencies discovered during build. With the bundled TIC-80, it
634
+ also displays events such as `trace` and `script_error` in
635
+ real time and accepts remoting commands such as `ping`.
636
+
637
+ `script_error` events and `script_error_last` responses are made to be more
638
+ human-readible than the raw protocol JSON/encoded value. These specifically
639
+ are rendered as readable stack traces and mapped
640
+ back to authored sources when the running cart matches the build source maps.
641
+
642
+ Request ID prefixes are optional (e.g. `1 ping`).
643
+
644
+ Use `--on-connect` options with `terminal` or `watch` to send
645
+ remoting commands immediately after terminal setup.
646
+
647
+ An `ERR` response, timeout, or disconnect stops the sequence and ticbuild exits
648
+ non-zero.
649
+
650
+ Use `--hide-trace-containing "my.token"` or
651
+ `--hide-trace-matching "reg.*ex"` with `terminal` or `watch` to suppress noisy
652
+ `trace` events by payload. Case-sensitive; the matching form
653
+ uses JavaScript regular-expression syntax. When both are supplied, either match
654
+ hides the event.
655
+
656
+ Prefix a command to select how its response is presented:
657
+
658
+ - `!script_error_last` decodes and prints the structured JSON value without
659
+ human-readable stack-trace formatting.
660
+ - `#script_error_last` prints the exact raw protocol response, including its
661
+ hex-encoded binary value.
662
+
663
+ The presentation prefix follows an explicit request ID when one is supplied,
664
+ for example `42 !script_error_last`.
665
+
666
+ Use `project.additionalWatchGlobs` to add extra glob-based watch targets,
667
+ relative to the manifest directory unless you provide an absolute pattern.
668
+ These extra globs can trigger rebuilds on file changes, file additions, and file removals.
484
669
 
485
670
  `additionalWatchGlobs` is an array value, so build configurations replace the whole array when overriding it.
486
671
 
672
+ # Chunk types
673
+
674
+ TIC-80 carts contain specific semantic chunks; see https://github.com/nesbox/TIC-80/wiki/.tic-File-Format.
675
+
676
+ Cart imports retain chunk & bank info except for `CODE`.
677
+
678
+ | ID | Manifest name | Banks | Maximum bytes per bank |
679
+ | ---: | --- | --- | ---: |
680
+ | 1 | `TILES` | 0–7 | 8,192 |
681
+ | 2 | `SPRITES` | 0–7 | 8,192 |
682
+ | 4 | `MAP` | 0–7 | 32,640 |
683
+ | 5 | `CODE` | Logical bank 0. Assembly splits across banks. | 65,536 |
684
+ | 6 | `FLAGS` | 0–7 | 512 |
685
+ | 9 | `SFX` | 0–7 | 4,224 |
686
+ | 10 | `WAVEFORMS` | 0–7 | 256 |
687
+ | 12 | `PALETTE` | 0–7 | 96 |
688
+ | 14 | `MUSIC_TRACKS` | 0–7 | 408 |
689
+ | 15 | `MUSIC_PATTERNS` | 0–7 | 11,520 |
690
+ | 16 | `CODE_COMPRESSED` | Bank 0 in stock carts; Banks 0–15 in the private format. | 65,535 |
691
+ | 17 | `DEFAULT` | 0–7 | 0 |
692
+ | 18 | `SCREEN` | 0–7 | 16,320 |
693
+ | 19 | `CODE_WASM` | Recognized on import. Nonempty output is unsupported. | — |
694
+
695
+ `DEFAULT` carries the marker for TIC-80's built-in palette and waveforms. It is
696
+ copied as a marker. Import `DEFAULT` to retain it in your output.
697
+
698
+ # TypeScript code
699
+
700
+ Start a TypeScript project with:
701
+
702
+ ```bash
703
+ ticbuild init my-demo --template typescript
704
+ cd my-demo
705
+ ```
706
+
707
+ `ticbuild init` installs the generated project's npm dependencies automatically.
708
+ The generated TypeScript project includes TIC-80 and ticbuild declarations plus
709
+ ESLint rules [recommended by TypeScriptToLua](https://typescripttolua.github.io/docs/caveats).
710
+
711
+ ```bash
712
+ npm run check # to typecheck and lint
713
+ npm run lint # lint only
714
+ ```
715
+
716
+ Linting remains independent from `ticbuild`.
717
+ The lint toolchain requires Node.js 20.19 or newer.
718
+
719
+ To add a `.ts` source asset manually:
720
+
721
+ ```jsonc
722
+ {
723
+ "name": "maincode",
724
+ "path": "src/main.ts",
725
+ "kind": "TypeScriptCode",
726
+ "typescript": { // optional
727
+ "tsconfig": "./tsconfig.json"
728
+ }
729
+ }
730
+ ```
731
+
732
+ Compiler plugins, TypeScriptToLua plugins, project references,
733
+ and `noResolvePaths` are not supported yet.
734
+
735
+ ticbuild uses [TypeScriptToLua](https://github.com/TypeScriptToLua/TypeScriptToLua) to
736
+ provide native transpiling to Lua. So yes the output cart is in Lua.
737
+
738
+ - See the [TypeScriptToLua documentation](https://typescripttolua.github.io/) for how the system works.
739
+ - See especially [the caveats section](https://typescripttolua.github.io/docs/caveats) to understand
740
+ how to avoid problems when doing so.
741
+
742
+ # TypeScript caveat: preprocessor and compile-time constants
743
+
744
+ ticbuild preprocessor directives kinda sorta work in typescript, with a lot of asterisks.
745
+ They are NOT evaluated in typescript; they pass through to Lua and are evaluated normally
746
+ there. Use `//--#...` spelling.
747
+
748
+ ```ts
749
+ // This works:
750
+ const TIC = () => {
751
+ //--#ifdef DEBUG
752
+ trace(__EXPAND("$(project.name) debug build"));
753
+ //--#endif
754
+ };
755
+ ```
756
+
757
+ However there are a LOT of asterisks. The typescript source must actually be correct
758
+ typescript because preprocessor directives are only evaluated after tsc and transpilation.
759
+
760
+ ```ts
761
+ // This fails:
762
+ const TIC = () => {
763
+ //--#ifdef DEBUG
764
+ const a = 1;
765
+ //--#else
766
+ const a = 2; // duplicate definition of `a`.
767
+ //--#endif
768
+ };
769
+ ```
770
+
771
+ Another caveat is that in order for these directives to survive through transpilation,
772
+ we mark their location with a generated marker, do the tsc & transpile step, then
773
+ replace the markers with the source directives.
774
+
775
+ Those internal markers:
776
+
777
+ - look like function calls (because it's the safest syntax i could think of)
778
+ - cannot be comments themselves; they must be "live-looking code".
779
+
780
+ But a "function call" marker fails in many contexts. So the following also fails:
781
+
782
+ ```ts
783
+ // This fails:
784
+ const Strings = {
785
+ //--#ifdef DEBUG
786
+ DebugName: "James",
787
+ //--#else
788
+ ReleaseName: "Ensor",
789
+ //--#endif
790
+ };
791
+ ```
792
+
793
+ Even though there are no collisions or other conflicts / broken syntax, the
794
+ intermediate representation will produce something like,
795
+
796
+ ```ts
797
+ // This fails:
798
+ const Strings = {
799
+ __PREPROCESSOR_MARKER("key")
800
+ DebugName: "James",
801
+ __PREPROCESSOR_MARKER("key")
802
+ ReleaseName: "Ensor",
803
+ __PREPROCESSOR_MARKER("key")
804
+ };
805
+ ```
806
+
807
+ Which will fail compilation.
808
+
809
+ Solving this is non-trivial: Doing actual preprocessing before tstl is not as
810
+ easy as it first seems. Even if the preprocessing itself is easy, tooling won't
811
+ recognized it as valid typescript. IDE syntax highlighting will be effectively
812
+ dead.
813
+
814
+ Or we continue finding workarounds. Even if the marker issue is solved, there
815
+ are other issues. A root issue is that preprocessor directives in TS are just
816
+ confusing because they are evaluated in Lua. Example:
817
+
818
+ TSTL actually supports `const enum` inlining, but we can't use it for defines
819
+ because `const enum` doesn't support `boolean` or `undefined`.
820
+
821
+ ```
822
+ // code.ts
823
+ //--#macro FLOOR(x) => x // 1 -- the expression here is Lua, not TypeScript
824
+ declare function FLOOR(x : number) : number; // you also need this in order for TypeScript to know it's accessible.
825
+ ```
826
+
827
+ Lua makes it easy to introduce things like oddball `--#ifdef`s because it's such
828
+ a permissive language that these constructs don't break language servers.
829
+
830
+ The most common cases i try to facilitate:
831
+
832
+ - Preprocessor defines
833
+ - Compile-time constant creation
834
+ - Conditional code blocks
835
+
836
+ ## Compile-time constants in TypeScript
837
+
838
+ ticbuild's Typescript processor supports a special type for compile-time constants.
839
+ Preprocessor "defines" are made available using this mechanism. See the `ticbuild`
840
+ namespace (in `.ticbuild/declarations/tic80.d.ts`) for the various utilities around this.
841
+
842
+ ```ts
843
+ type DebugValue = ticbuild.Defines["DEBUG"];
844
+ type BuildLabel = ticbuild.IfDefined<"DEBUG", "debug", "release">;
845
+
846
+ const ENABLE_LOGGING = ticbuild.IsDefined("DEBUG");
847
+ // ENABLE_LOGGING: ticbuild.Constant<true> in a build where DEBUG is present
848
+ ```
849
+
850
+ `ticbuild.Constant<T>` is a compiler instruction as well as a TypeScript type.
851
+ Every value expression with that type is emitted as the exact string, number,
852
+ or boolean literal `T`; the original expression is not evaluated at runtime.
853
+ `IsDefined()` returns such a constant, and `MakeConstant()` creates general
854
+ constants that are independent of preprocessor defines:
855
+
856
+ ```ts
857
+ export const AGE = ticbuild.MakeConstant<8>();
858
+ ticbuild.assert_const(AGE); // checked by TypeScript, emits no Lua
859
+ ```
860
+
861
+ **Project variables and string expansion**
862
+
863
+ Project substitution variables are exposed similarly, but separately,
864
+ from preprocessor defines. Access them via `ticbuild.Vars` in Typescript code.
865
+
866
+ ```ts
867
+ type ProjectName = ticbuild.Vars["project.name"]; // "MyProject"
868
+
869
+ const PROJECT_NAME = ticbuild.Vars["project.name"];
870
+ // PROJECT_NAME: ticbuild.Constant<"MyProject">
871
+ ```
872
+
873
+ `ticbuild.Expand()` performs the same recursive substitution as Lua's
874
+ `__EXPAND()`, while preserving the exact result for project variables in
875
+ TypeScript:
876
+
877
+ ```ts
878
+ const DESCRIPTION = ticbuild.Expand("this project is $(project.name)");
879
+ // for project vars, the output type is the fully-resolved string:
880
+ // DESCRIPTION: ticbuild.Constant<"this project is MyProject">
881
+
882
+ const MODE = ticbuild.Expand("mode: $(env:BUILD_MODE)");
883
+
884
+ // Unlike project vars, environment is not brought into code declarations en masse;
885
+ // therefore the emitted value type is:
886
+ // ticbuild.Constant<`mode: ${string}`>
887
+
888
+ // Its argument a single compile-time string literal (string vars are not accepted).
889
+
890
+ // this is also acceptible for interpolated strings, but only for compile-time literal
891
+ // arguments, such as:
892
+ const X = ticbuild.Expand(`$(project.name) version ${12.34}}`);
893
+
894
+ // Not valid (not compiletime literal)
895
+ const X = ticbuild.Expand("this project is" + "$(project.name)");
896
+ const verString : string = "1.0.1";
897
+ const X = ticbuild.Expand(verString);
898
+
899
+ // Not valid (not compiletime literal)
900
+ const verString : string = "1.0.1";
901
+ const X = ticbuild.Expand(`$(project.name) version ${verString}}`);
902
+ ```
903
+
904
+ The main motivators for introducing `Constant<>`:
905
+
906
+ - allow typescript to be able to work with compile-time constants beyond just
907
+ read-only defines (e.g., `#define` is just not functional in typescript)
908
+ - lift constant manips out of weird unnerving `//#define` and into real TS syntax,
909
+ where it feels more natural and tooling-supported.
910
+
911
+ For example this is a `Constant<>`:
912
+
913
+ ```ts
914
+ //--#ifdef DEBUG
915
+ //--#define ENABLE_EDITOR
916
+ //--#endif
917
+
918
+ //--#ifdef ENABLE_EDITOR
919
+ initEditor();
920
+ //--#endif
921
+ ```
922
+
923
+ **const enum**
924
+
925
+ This is also not possible:
926
+
927
+ ```ts
928
+ const enum XYZ {
929
+ HUD_HEIGHT = ticbuild.IfDefined("DEBUG", 9, 0)
930
+ };
931
+ ```
932
+
933
+ But then again, `const enum` is always very restrictive, even the following is
934
+ also invalid TypeScript: `const enum XYZ { HUD_HEIGHT = true ? 9 : 0 }`.
935
+
936
+ Conclusion: we don't support that.
937
+
938
+ **Selecting an expression with `IfDefined()`**
939
+
940
+ `IfDefined()` is a compile-time conditional expression, value-level. Its
941
+ branches can be ordinary TS expressions; only the selected expression
942
+ is emitted and evaluated:
943
+
944
+ ```ts
945
+ print(ticbuild.IfDefined(
946
+ "DEBUG",
947
+ getDebugString(),
948
+ getReleaseString(),
949
+ ));
950
+ ```
951
+
952
+ This emits either `print(getDebugString())` or
953
+ `print(getReleaseString())`. TypeScript still checks both expressions, and
954
+ static imports retain their normal eager module semantics.
955
+
956
+ The selected expression keeps its ordinary TypeScript type. `IfDefined()` does
957
+ not turn a runtime `string` or `number` into a `Constant<>`. To make the result
958
+ a transportable constant, supply constant branches explicitly:
959
+
960
+ ```ts
961
+ const VALUE = ticbuild.IfDefined(
962
+ "DEBUG",
963
+ ticbuild.MakeConstant<1>(),
964
+ ticbuild.MakeConstant<0>(),
965
+ );
966
+ ```
967
+
968
+ Constants can be exported and imported normally. The imported reference keeps
969
+ its `Constant<T>` type and is inlined at each use; its declaration and import
970
+ plumbing are omitted from Lua. A module imported only for constants is therefore
971
+ not executed at runtime. If that module also has intended side effects, import
972
+ it separately with `import "./module"`.
973
+
974
+ The mechanism is deliberately available to user-authored types and assertions,
975
+ not restricted to ticbuild-created values. This is powerful: asserting that an
976
+ expression is `ticbuild.Constant<8>` tells the compiler to emit `8` and discard
977
+ that expression, including any side effects. `T` must resolve to one exact
978
+ string, number, or boolean literal; broad primitive types and unions are errors.
979
+ Constant bindings must use `const`. Operations normally strip the `Constant<>`
980
+ wrap (`const x = ticbuild.MakeConstant<8> + 1` becomes `number`), so
981
+ `ticbuild.assert_const(value)` can verify that a value is still compile-time constant.
982
+
983
+ The emitted condition in `if (ticbuild.IsDefined("DEBUG"))` is currently a Lua
984
+ literal condition. Guaranteed removal of the unreachable branch is a separate
985
+ optimization and is not part of this first constant-inlining slice.
986
+
987
+ ticbuild writes the active definition and resolved variable maps to
988
+ `.ticbuild/declarations/build-constants.d.ts` for ordinary TypeScript tooling
989
+ (like IDE syntax highlighting / error reporting).
990
+ As with other generated declarations, build once after changing configuration
991
+ if the editor has not refreshed it yet.
992
+
993
+ ---
994
+
995
+ Lua and TypeScript code assets declared in the project manifest are available
996
+ as TypeScript modules under `ticbuild-assets/<manifest import name>`.
997
+
998
+ ```jsonc
999
+ {
1000
+ "name": "LuaUtils",
1001
+ "path": "src/luaUtils.lua"
1002
+ }
1003
+ ```
1004
+
1005
+ and Lua globals with optional LuaCATS annotations:
1006
+
1007
+ ```lua
1008
+ ---@param value number
1009
+ ---@return number
1010
+ function Floor(value)
1011
+ return value // 1
1012
+ end
1013
+ ```
1014
+
1015
+ TypeScript can import Lua globals by manifest import name:
1016
+
1017
+ ```ts
1018
+ import { Floor } from "ticbuild-assets/LuaUtils";
1019
+ ```
1020
+
1021
+ TypeScript manifest imports can be imported the same way:
1022
+
1023
+ ```jsonc
1024
+ // manifest
1025
+ {
1026
+ "name": "helpers",
1027
+ "path": "src/helpers.ts",
1028
+ "typescript": { "tsconfig": "./tsconfig.json" }
1029
+ }
1030
+ ```
1031
+
1032
+ ```ts
1033
+ import { Inc, type IncOptions } from "ticbuild-assets/helpers";
1034
+ ```
1035
+
1036
+ Repeated runtime imports include either kind of code asset only once (pragma once implicit).
1037
+ The import owns that runtime inclusion, so the Lua dependency should not also
1038
+ be added as a separate code assembly block.
1039
+
1040
+ **NOTE**: Your IDE won't be able to auto-discover the module until it's built.
1041
+ So if you have trouble with your IDE not understanding where a symbol can be imported from,
1042
+ try building once, and trying again. You shouldn't have to manually type the `import`
1043
+ statement.
1044
+
1045
+ The generated Lua declaration includes direct globals (`function Name`,
1046
+ `Name = function` / `Name = value`).
1047
+ LuaCATS parameter, return, and `@type` annotations are supported.
1048
+
1049
+ Re-exports of manifest code assets are not supported. Since the
1050
+ runtime surface is Lua's global namespace, ticbuild rejects colliding globals
1051
+ and cycles between manifest TypeScript modules.
1052
+
1053
+ `//--#include "import:luaHelper"` remains available, maybe if you want to use the
1054
+ `with { BAYER_SIZE = 4, DEBUG = true }` facilities for lexical behavior. But it
1055
+ does not provide the typed module contract or linker-level behaviors of
1056
+ `ticbuild-assets/...`.
1057
+
1058
+ Lua code can also include TypeScript code with `--#include "import:typescriptAsset"`.
1059
+ ticbuild statically links all dependent TypeScript modules.
1060
+ Every module becomes enclosed in a Lua `do ... end` scope.
1061
+
1062
+ For Lua editor tooling, ticbuild also generates
1063
+ `.ticbuild/declarations/typescript-globals.d.lua`. This
1064
+ [LuaCATS](https://github.com/LuaCATS) definition file
1065
+ describes exported TypeScript globals. TypeScript JSDoc is preserved,
1066
+ and [LuaLS](https://github.com/LuaLS/lua-language-server/wiki)
1067
+ navigation points back to the authored TypeScript source.
1068
+
1069
+ LuaLS projects should include the generated declarations as a workspace
1070
+ library. The TypeScript project template supplies this in `.luarc.json`:
1071
+
1072
+ ```json
1073
+ {
1074
+ "runtime.version": "Lua 5.3",
1075
+ "workspace.library": [".ticbuild/declarations"]
1076
+ }
1077
+ ```
1078
+
1079
+ Build once after creating a project so the definition file exists. Types which
1080
+ do not have a LuaCATS representation are exposed as `any`.
1081
+
1082
+ **For this to work in VSCode** you must install a LuaCATS capable Lua server
1083
+ (as of 2026-09-01) -- namely, [sumneko.lua](https://marketplace.visualstudio.com/items?itemName=sumneko.lua)
1084
+
1085
+ Reference: [Lua definition files](https://luals.github.io/wiki/definition-files/)
1086
+
1087
+ LuaLS syntax highlighting [conflicts](https://github.com/thenfour/ticbuild_vscode/issues/11)
1088
+ with the ticbuild VS Code extension's
1089
+ preprocessor syntax highlighting. Projects created by `ticbuild init`
1090
+ disable LuaLS semantic highlighting in the generated
1091
+ `.vscode/settings.json`.
1092
+
1093
+ TypeScript value exports become Lua globals.
1094
+ Non-exported symbols stay local to their module scope:
1095
+
1096
+ ```ts
1097
+ const privateScale = 2; // -> local privateScale = 2
1098
+
1099
+ export function scale(value: number): number { // -> function scale(value)
1100
+ return value * privateScale;
1101
+ }
1102
+ ```
1103
+
1104
+ Named imports are linked directly to those globals, including aliases.
1105
+ All exported ts module symbols share Lua global namespace, so ticbuild rejects
1106
+ different modules that export the same global name. Module cycles are also rejected.
1107
+ TIC-80 callbacks (`TIC`, `BOOT`, `BDR`, et al) are always made global.
1108
+
1109
+ Default imports/exports, namespace imports/exports, `export *`,
1110
+ and dynamic `import()` are not allowed.
1111
+
1112
+ You can still opt-in to global renaming in the minifier:
1113
+
1114
+ ```ts
1115
+ //--#minify allow_rename
1116
+ export function longInternalApiName(): number {
1117
+ return 1;
1118
+ }
1119
+ ```
1120
+
1121
+ A filesystem include (`--#include "main.ts"`) does not invoke the TypeScript
1122
+ compiler - it will pass through to the later Lua pipeline. That example would
1123
+ include `main.ts` verbatim and fail because it's not Lua.
1124
+
1125
+ ticbuild emits Source Map v3 files for generated, preprocessed, and minified Lua:
1126
+
1127
+ ```text
1128
+ build/release-obj/maincode.00.generated.lua.map
1129
+ build/release-obj/maincode.01.preprocessed.lua.map
1130
+ build/release-obj/maincode.02.minified.lua.map
1131
+ ```
1132
+
1133
+ These maps lead all the way back to the source origin (TypeScript or Lua).
1134
+
1135
+ ## Some notable typescript patterns
1136
+
1137
+ Typescript gives free inlining of constants via `const enum`:
1138
+
1139
+ ```ts
1140
+ const enum TicDefs {
1141
+ WIDTH = 240,
1142
+ HEIGHT = 136,
1143
+ PALETTE_SIZE = 16,
1144
+ DEMO_TITLE = "Monkeys on a branch",
1145
+ }
1146
+ ...
1147
+ const p = y * TicDefs.WIDTH;
1148
+ print(`title = ${DEMO_TITLE}`)
1149
+ ```
1150
+
1151
+ transpiles to simply:
1152
+ ```lua
1153
+ local p = y * 240
1154
+ print("title = " .. "aoeuaoeu")
1155
+ ```
1156
+
1157
+ So that reduces the need for `//--#macro`, though that still exists.
1158
+
487
1159
  # Lua preprocessor
488
1160
 
489
1161
  ticbuild supports a fairly sophisticated Lua preprocessor, so you can have interaction
@@ -511,8 +1183,23 @@ print() --#define XYZ -- note that here #define will not be processed.
511
1183
  -- not macros, they are only recognized in other preprocessor directives.
512
1184
 
513
1185
  --#include "utils/math.lua" -- extra comments are allowed in directive lines.
514
- --#include "import:music-imported-cart:CODE" -- includes the imported code sub-asset from that cart
515
- --#include "import:cart-with-only-code-chunk" -- implicit code-only import. If that cart contains more than CODE chunks, then you MUST specify ":CODE".
1186
+
1187
+ -- includes the imported code sub-asset from that cart.
1188
+ -- chunks that span multiple banks > behavior depends on the bank. CODE will
1189
+ -- produce a concatenated version.
1190
+ -- and YES it's very odd to specify SPRITES here, but:
1191
+ -- 1. you might actually decide for some crazy reason to put code in other banks, maybe if you hit a size limit
1192
+ -- 2. the point is to describe the `import:` syntax that can also be used elsewhere.
1193
+ -- so CODE is the only chunk type that produces a concatenated-over-banks output.
1194
+ -- - if the import chunk spans multiple banks and you don't specify, this is an error.
1195
+ -- (for an import with TILES:0 and TILES:1, you must specify the bank.)
1196
+ -- (for an import with only TILES:1, bank is optional; bank 1 is implicit)
1197
+ -- - if you specify a bank that doesn't exist in the import, error.
1198
+ --#include "import:music-imported-cart:CODE"
1199
+ --#include "import:music-imported-cart:SPRITES:2" -- additional token for specifying explicit source bank (0-7)
1200
+
1201
+ -- implicit code-only import. If that cart contains more than CODE chunks, then you MUST specify ":CODE".
1202
+ --#include "import:cart-with-only-code-chunk"
516
1203
 
517
1204
  -- you can set variables that the included file can read
518
1205
  -- note that #pragma once will key against the filename AND its input variables.
@@ -579,9 +1266,9 @@ local s = __EXPAND("the project name is: $(project.name)")
579
1266
  -- f16le, f16be, f32le, f32be, f64le, f64be
580
1267
  -- hex, b85+1, ascii, utf8, base64
581
1268
  -- Source codecs (binary input only):
582
- -- raw, lz
1269
+ -- raw, lz, lzrle
583
1270
  -- Byte transforms:
584
- -- lz, unlz, rle, unrle, ttz, take(start,length)
1271
+ -- lz, unlz, lzrle, unlzrle, rle, unrle, ttz, take(start,length)
585
1272
  --
586
1273
  -- start is 0-based.
587
1274
  --
@@ -617,6 +1304,9 @@ local paletteCompressed = __IMPORT("ascii,lz,b85+1", "import:creditstxt")
617
1304
  -- generates:
618
1305
  local paletteCompressed = "..."
619
1306
 
1307
+ -- LZRLE uses the extended decoder above and can additionally emit repeat-byte runs.
1308
+ local maskCompressed = __IMPORT("raw,lzrle,b85+1", "import:mask")
1309
+
620
1310
  -- NOTE: string substitution is performed on spec strings and import/literal values.
621
1311
 
622
1312
  -- LZ compression possible. The payload is compressed, then encoded with base85+1.
@@ -643,21 +1333,26 @@ local paletteString = "!*u>VJ3C?PFD-`-qM7Tatcae[uGB.gq3'TBA94Oi0E4D-maM5LKk3Ab%[
643
1333
  local s = __ENCODE("b85+1,lz", "hex", "#!&,K2'Jqg;:0ML?NM;9@X16KdK:I.+F[e>T3,hN#VIXYUP`Ei\"^Z\">?UlDg->*]-g")
644
1334
 
645
1335
  -- allows emitting a string literal from an imported text resource.
646
- local scrollText = __IMPORT("", "", "import:somecart:")
1336
+ local scrollText = __IMPORT("", "", "import:somecart:CODE")
1337
+
1338
+ -- Select source bank 1 explicitly
1339
+ local waveformBytes = __IMPORT("hex", "import:music-imported-cart:WAVEFORMS:1")
647
1340
 
648
1341
  -- once again, "import:" is required for consistency, and to allow literals (though it's not much
649
1342
  -- value but there for completeness.)
650
1343
  local s = __ENCODE("ascii", "ascii", "the project name is: $(project.name)") -- effectively the same as __EXPAND
651
1344
 
652
- -- macros are handy esp for writing optimized code (avoid symbol lookups, plus give
653
- -- the minifier the chance to simplify / reduce expressions.
654
- -- note that the macro call site should still be valid lua. similar reasoning
655
- -- as preprocessor directives, and for example if the call site is `@clamp`,
656
- -- things like autocomplete & formatting just won't work.
657
- -- so like C, just blend in as a normal symbol and it's up to developers to avoid
658
- -- conflicts.
659
- -- by convention i'm guessing best to go all upper-case, and/or double-underscore prefix.
660
- --#macro CLAMP(x, lo, hi) -- or __CLAMP
1345
+ -- Macros perform compile-time source substitution at the AST level (not textual
1346
+ -- like in C macros.
1347
+
1348
+ -- An object-like macro (no parameter list) is invoked as a bare identifier.
1349
+ -- Its body must be one Lua expression.
1350
+ --#macro TIC_WIDTH => 240
1351
+ local width = TIC_WIDTH
1352
+ local width = TIC_WIDTH() -- NOT allowed
1353
+
1354
+ -- A function-like expression macro has a parameter list and is invoked as a call.
1355
+ --#macro CLAMP(x, lo, hi)
661
1356
  ((x) < (lo) and (lo) or (x) > (hi) and (hi) or (x))
662
1357
  --#endmacro
663
1358
 
@@ -669,47 +1364,110 @@ local y = CLAMP(x + blah(y),
669
1364
  -- single-line macro syntax uses the arrow operator.
670
1365
  --#macro ADD(a, b) => ((a) + (b))
671
1366
 
672
- -- point to nothing for a nop.
673
- --#macro ADD(a, b) => -- nop
1367
+ -- Function-like bodies can be statement lists. Statement list
1368
+ -- macros must be invoked as standalone call statements.
1369
+ --#macro REQUIRE_OR_RETURN(condition, returnVal)
1370
+ if not (condition) then
1371
+ return (returnVal)
1372
+ end
1373
+ --#endmacro
1374
+ REQUIRE_OR_RETURN(isReady(), nil)
1375
+
1376
+ -- An empty function-like body erases a standalone call, useful for nops.
1377
+ --#macro ASSERT(condition, message) => -- nop
674
1378
 
675
- -- parameterless syntax is possible
1379
+ -- A zero-parameter function-like macro remains distinct and requires `()`.
676
1380
  --#macro PROJECT_NAME => __EXPAND("the project name is: $(project.name)")
1381
+ --#macro PROJECT_NAME_CALL() => __EXPAND("the project name is: $(project.name)")
1382
+ local projectName = PROJECT_NAME
1383
+ local projectNameFromCall = PROJECT_NAME_CALL()
677
1384
 
678
1385
  -- Minifier: renaming globals
679
- -- Globals are not renamed by default. Renaming (minifying) them requires the
680
- -- renameSpecifiedGlobalSymbols minification option to be set (on by default in
681
- -- release), and you need to specify individually which symbols are allowed to be
682
- -- renamed. This is done via the --#minify allow_rename directive.
683
- -- `--#minify allow_rename` will mark the following global symbol name as
684
- -- renameable.
1386
+ -- Global renaming is controlled by assembly.lua.minification.globalSymbolRenaming
1387
+ -- "off" leaves every global name unchanged
1388
+ -- "opt-in" renames only names listed in globalSymbolsToRename or marked with
1389
+ -- --#minify allow_rename (the default for existing manifests);
1390
+ -- "opt-out" renames global symbols defined in the final preprocessed Lua file,
1391
+ -- except names listed in globalSymbolsToKeep or marked with
1392
+ -- --#minify no_rename.
1393
+ --
1394
+ -- Automatic opt-out discovery considers plain global function declarations and
1395
+ -- assignments. Read-only runtime globals such as print, math, and cls are not
1396
+ -- renamed. TIC-80 callbacks and _G/_ENV are always protected.
1397
+ --
1398
+ -- Use no_rename for names accessed externally or dynamically (for example through
1399
+ -- _G["PublicApi"]), because string contents cannot be rewritten with identifiers.
685
1400
 
686
1401
  -- e.g.,
687
1402
 
688
- --#minify allow_rename
1403
+ --#minify no_rename
689
1404
  -- a regular comment can sit between the annotation and declaration
690
- function Demo_LongName() end
1405
+ function PublicApi() end
691
1406
 
692
- local y = Demo_LongName() -- call it
1407
+ function Internal_LongName() end
1408
+ local y = Internal_LongName()
693
1409
 
1410
+ -- In opt-in mode...
694
1411
  --#minify allow_rename
695
1412
  Demo_AssignedLongName = function() end
696
1413
 
697
- local x = Demo_AssignedLongName() -- call it
1414
+ ```
1415
+
1416
+ ## Macro behavior
1417
+
1418
+ - `--#macro NAME => expression` defines an object-like macro expanded from bare
1419
+ `NAME` identifiers.
1420
+ - `--#macro NAME(...)` defines a function-like macro expanded from `NAME(...)` calls.
1421
+ `NAME` and `NAME()` are deliberately distinct.
1422
+
1423
+ A macro body is one of:
1424
+
1425
+ - **Empty:** erases a standalone function-like call statement.
1426
+ - **Expression:** replaces an object-like identifier or function-like call expression.
1427
+ - **Lua statement list:** replaces a standalone function-like call statement.
698
1428
 
699
- -- both of these examples are eligible for minification and will end up like,
700
- function a() end
701
- local y = a()
702
- function b() end
703
- local x = b()
1429
+ Object-like macros must be an expression (not a statement list). The reason for
1430
+ this is because the original Lua source must be valid Lua, and the following is not:
704
1431
 
1432
+ ```lua
1433
+ --#macro EARLY_RETURN => return -- not allowed: object-like macro contains statements
1434
+ function MyFunc()
1435
+ if not isReady() then
1436
+ EARLY_RETURN -- invalid Lua; this is why it's not allowed.
1437
+ end
1438
+ end
705
1439
  ```
706
1440
 
707
- ## Preprocessor variable behavior (`#if` vs `#ifdef`) and what you can use in `--#macro`
1441
+ Definitions follow flattened source order, including `--#include` contents. A
1442
+ definition affects only later invocations; a redefinition affects only invocations
1443
+ after that redefinition. Nested macro calls use the definitions active where the
1444
+ outer macro was invoked.
1445
+
1446
+ Argument substitution is C-like, not function-like: an argument can be repeated,
1447
+ reordered, or unused, so it can be evaluated multiple times or not at all. Macro
1448
+ authors should parenthesize the complete expression body and every parameter use
1449
+ where precedence matters.
1450
+
1451
+ ```lua
1452
+ --#macro DOUBLE(a) => a * b
1453
+ local c = MUL(1+2,3+4) -- hope you don't expect 3*7 = 21 here.
1454
+ -- expands to:
1455
+ -- local c = 1 + 2 * 3 + 4
1456
+ -- => 11
1457
+ ```
1458
+
1459
+ Names in a macro share the caller's scope.
1460
+
1461
+ Expansion is syntax-aware rather than arbitrary token replacement. It does not
1462
+ replace text in strings or comments, member names such as `object.NAME`, or named
1463
+ table keys such as `{ NAME = value }`. Computed table keys such as `{ [NAME] = value }`
1464
+ are expanded.
1465
+
1466
+ ## Preprocessor variable behavior (`#if` vs `#ifdef`)
708
1467
 
709
1468
  Don't get confused by C/C++-like language. "Macros" are different from defines.
710
- Macros in C/C++ share semantics, acting both as callables and as values with no arguments.
711
- Ticbuild distinguishes between thos. Macros are callable, preprocessor defines are
712
- values.
1469
+ Macros substitute Lua tokens. Preprocessor defines are values used only by
1470
+ preprocessor directives.
713
1471
 
714
1472
  Preprocessor defines are used by `#if`, `#ifdef`, `#ifndef`, `defined(...)`, `#undef`.
715
1473
 
@@ -717,6 +1475,28 @@ They can be overridden during `#include` via ` with { ... }` overrides.
717
1475
 
718
1476
  They can be string, number, or boolean.
719
1477
 
1478
+ Build configurations may also set an inherited define to `null` to remove it from
1479
+ the effective configuration. This makes both `#ifdef` and `defined(...)` report
1480
+ the symbol as undefined:
1481
+
1482
+ ```jsonc
1483
+ "buildConfiguration": "debug",
1484
+ "preprocessor": {
1485
+ "defines": {
1486
+ "DEBUG": true
1487
+ }
1488
+ },
1489
+ "buildConfigurations": {
1490
+ "release": {
1491
+ "preprocessor": {
1492
+ "defines": {
1493
+ "DEBUG": null
1494
+ }
1495
+ }
1496
+ }
1497
+ }
1498
+ ```
1499
+
720
1500
  - `#if X` asks if the preprocessor variable evaluates to true
721
1501
  - `#ifdef X` asks if it's defined at all
722
1502
 
@@ -740,19 +1520,15 @@ available to Lua code; this is a different system than macros or preprocessor de
740
1520
  # Code chunk behavior
741
1521
 
742
1522
  Code chunk banks on cart are semantically slightly different than other chunk
743
- types. Most of the time it's the simple, independent banks.
744
-
745
- But when code is loaded by TIC-80, all code banks are concatenated, in reverse
1523
+ types. When code is loaded by TIC-80, all code banks are concatenated, in reverse
746
1524
  bank order (bank7 + bank6 + ... bank0).
747
1525
 
748
- Therefore, it's a warning to specify the bank explicitly for code chunks. But still
749
- allowed as long as there's no conflict.
1526
+ ticbuild combines cartridge `CODE` payloads (just as TIC-80 natively does).
1527
+ The resulting payload can be selected at source bank 0.
750
1528
 
751
- But if code wants to span multiple banks (larger than 1 bank), then no specified code banks should be
752
- allowed (this is an error).
1529
+ CODE bank info is therefore clobbered on cart import load.
753
1530
 
754
- For the code chunk alone, if code is larger than 1 bank, ticbuild automatically
755
- splits it across multiple banks.
1531
+ For output assembly, code is automatically always split into banks.
756
1532
 
757
1533
  By default, ticbuild keeps the stock TIC-80 limit: up to 8 uncompressed CODE
758
1534
  banks. ticbuild's private TIC-80 build can opt into 16 uncompressed CODE banks:
@@ -989,21 +1765,38 @@ internally the structure is effectively a bunch of segments and define where the
989
1765
 
990
1766
  ```jsonc
991
1767
  {
992
- "preprocessedFile": { "byteLength": 12345, "hash": "sha1:..." },
1768
+ "preprocessedFile": { "charLength": 12345, "hash": "..." },
993
1769
  "segments": [
994
- { "ppBegin": 0, "ppEnd": 53, "originalFile": "src/utils.lua", "originalOffset": 0 },
995
- { "ppBegin": 53, "ppEnd": 150, "originalFile": "src/math.lua", "originalOffset": 24 },
996
- { "ppBegin": 150, "ppEnd": 200, "originalFile": "src/main.lua", "originalOffset": 18 }
1770
+ {
1771
+ "ppBegin": 0,
1772
+ "ppEnd": 53,
1773
+ "originalFile": "src/utils.lua",
1774
+ "originalOffset": 0,
1775
+ "kind": "identity"
1776
+ },
1777
+ {
1778
+ "ppBegin": 53,
1779
+ "ppEnd": 150,
1780
+ "originalFile": "src/main.ts",
1781
+ "originalOffset": 24,
1782
+ "kind": "anchor"
1783
+ }
997
1784
  ]
998
1785
  }
999
1786
  ```
1000
1787
 
1788
+ Identity segments represent copied text. Anchor segments associate generated
1789
+ text with one authored location without pretending their character offsets are
1790
+ equivalent. Internal offsets are UTF-16 code-unit offsets, matching TypeScript
1791
+ and JavaScript string offsets. Public sidecars use standard line/column source
1792
+ map mappings and retain the exact segments under `x_ticbuild`.
1793
+
1001
1794
  The map functional interface is effectively just
1002
1795
 
1003
1796
  ```ts
1004
1797
  interface ISourceMap {
1005
- preprocessedOffsetToOriginal(expandedByteOffset)
1006
- : { file, fileByteOffset } | null;
1798
+ preprocessedOffsetToOriginal(expandedCharacterOffset)
1799
+ : { file, fileCharacterOffset } | null;
1007
1800
  }
1008
1801
  ```
1009
1802
 
@@ -1140,7 +1933,7 @@ correct signatures and doc comments // enough info to produce the correct index.
1140
1933
  "range": { /*...*/ }, // full span of the declaration statement (for function, the whole body of the function)
1141
1934
  "selectionRange": { /*...*/ }, // just name, for definition UX
1142
1935
 
1143
- // parsed luadoc/emmylua docs
1936
+ // parsed LuaCATS/emmylua docs
1144
1937
  "doc": {
1145
1938
  "name": "...", // probably should never use this; if it differs from the real name then more likely a bad copy/paste.
1146
1939
  "description": "...",
@@ -1154,7 +1947,7 @@ correct signatures and doc comments // enough info to produce the correct index.
1154
1947
  // "global"
1155
1948
  "visibility": "local",
1156
1949
 
1157
- // for LuaDoc / EmmyLua, this could point to its doc
1950
+ // for LuaCATS/emmylua, this could point to its doc
1158
1951
  // without doc comments, basically everything is guesswork; it's probably
1159
1952
  // worth it in order to for example understand types. Without
1160
1953
  // doc comments we just kinda can't touch types.
@@ -1173,6 +1966,71 @@ correct signatures and doc comments // enough info to produce the correct index.
1173
1966
 
1174
1967
  ```
1175
1968
 
1176
- # FAQ
1969
+ # typescript tips
1177
1970
 
1178
- gotta be asked questions in order to answer them.
1971
+ The TypeScript transpiler needs to be respected; check the generated code in your
1972
+ `obj` dir to make sure nothing is happening you weren't expecting. It can easily
1973
+ introduce bloaty code or performance less than expected.
1974
+
1975
+ ## Language extensions
1976
+
1977
+ Read about [TypeScriptToLua language extensions](https://typescripttolua.github.io/docs/advanced/language-extensions/);
1978
+ these let you emit Lua code that uses more native Lua syntax (floor division, multiple return values...)
1979
+
1980
+ ```ts
1981
+ declare const floorDiv: LuaFloorDivision<number, number, number>;
1982
+ const y = floorDiv(val, 1);
1983
+ // emits:
1984
+ // local y = val // 1
1985
+ ```
1986
+
1987
+
1988
+ ## Array manipulation
1989
+
1990
+ ```ts
1991
+ // ARRAY manips
1992
+
1993
+ // Fine
1994
+ const x = [...a]; // -> local c = {table.unpack(a)}
1995
+ a.push(b); // -> a[#a + 1] = b
1996
+
1997
+ // Avoid: introduces 4 SparseArray helpers
1998
+ const x = [...a, 1];
1999
+
2000
+ // Avoid: introduces __TS__ArrayConcat
2001
+ const b = a.concat(c);
2002
+ ```
2003
+
2004
+ ## Method invocation; receivers
2005
+
2006
+ ```ts
2007
+ // SELF calls
2008
+ const obj = {
2009
+ method: () => {}
2010
+ };
2011
+
2012
+ // transpiles as obj.method(), as expected
2013
+ obj.method();
2014
+
2015
+ const obj : { method: () => void; } = {
2016
+ method: () => {}
2017
+ }
2018
+ obj.method(); // transpiles as obj:method()
2019
+ obj['method'](); // transpiles as obj.method(obj)
2020
+
2021
+ // Why? even though the types are the same, the first object uses arrow syntax in the declaration
2022
+ // and therefore TSTL knows it's receiverless.
2023
+ // In the 2nd example, the arrow notation is only in the type declaration and there's
2024
+ // no guarantee (type-wise) that it's receiverless.
2025
+ // This would also be legal:
2026
+ const obj : { method: () => void; } = {
2027
+ method() {} // no arrow syntax; receiver-aware.
2028
+ }
2029
+ obj.method(); // transpiles correctly as obj:method()
2030
+
2031
+ // The safest is to add `this:void` to the type decl.
2032
+ const obj : { method: (this:void) => void; } = {
2033
+ method() {} // no arrow syntax; receiver-aware.
2034
+ }
2035
+ obj.method(); // transpiles to obj.method()
2036
+ ```