ticbuild 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (290) hide show
  1. package/.attachments/support_me_on_kofi_beige.png +0 -0
  2. package/.env.example +3 -0
  3. package/.prettierignore +10 -0
  4. package/LICENSE +15 -0
  5. package/README.md +429 -0
  6. package/debug/obj/resolvedManifest.ticbuild.jsonc +108 -0
  7. package/dist/backend/ImportedResource.d.ts +11 -0
  8. package/dist/backend/ImportedResource.d.ts.map +1 -0
  9. package/dist/backend/ImportedResource.js +53 -0
  10. package/dist/backend/ImportedResource.js.map +1 -0
  11. package/dist/backend/ImportedResourceTypes.d.ts +24 -0
  12. package/dist/backend/ImportedResourceTypes.d.ts.map +1 -0
  13. package/dist/backend/ImportedResourceTypes.js +35 -0
  14. package/dist/backend/ImportedResourceTypes.js.map +1 -0
  15. package/dist/backend/codeBanking.test.d.ts +2 -0
  16. package/dist/backend/codeBanking.test.d.ts.map +1 -0
  17. package/dist/backend/codeBanking.test.js.map +1 -0
  18. package/dist/backend/importResources.d.ts +4 -0
  19. package/dist/backend/importResources.d.ts.map +1 -0
  20. package/dist/backend/importResources.js +58 -0
  21. package/dist/backend/importResources.js.map +1 -0
  22. package/dist/backend/importUtils.d.ts +14 -0
  23. package/dist/backend/importUtils.d.ts.map +1 -0
  24. package/dist/backend/importUtils.js +77 -0
  25. package/dist/backend/importUtils.js.map +1 -0
  26. package/dist/backend/importers/LuaCodeImporter.d.ts +47 -0
  27. package/dist/backend/importers/LuaCodeImporter.d.ts.map +1 -0
  28. package/dist/backend/importers/LuaCodeImporter.js +196 -0
  29. package/dist/backend/importers/LuaCodeImporter.js.map +1 -0
  30. package/dist/backend/importers/LuaCodeImporter.test.d.ts +2 -0
  31. package/dist/backend/importers/LuaCodeImporter.test.d.ts.map +1 -0
  32. package/dist/backend/importers/LuaCodeImporter.test.js.map +1 -0
  33. package/dist/backend/importers/binaryResourceImporter.d.ts +22 -0
  34. package/dist/backend/importers/binaryResourceImporter.d.ts.map +1 -0
  35. package/dist/backend/importers/binaryResourceImporter.js +53 -0
  36. package/dist/backend/importers/binaryResourceImporter.js.map +1 -0
  37. package/dist/backend/importers/luaImporter.d.ts +1 -0
  38. package/dist/backend/importers/luaImporter.d.ts.map +1 -0
  39. package/dist/backend/importers/luaImporter.js +3 -0
  40. package/dist/backend/importers/luaImporter.js.map +1 -0
  41. package/dist/backend/importers/textResourceImporter.d.ts +23 -0
  42. package/dist/backend/importers/textResourceImporter.d.ts.map +1 -0
  43. package/dist/backend/importers/textResourceImporter.js +55 -0
  44. package/dist/backend/importers/textResourceImporter.js.map +1 -0
  45. package/dist/backend/importers/tic80CartImporter.d.ts +21 -0
  46. package/dist/backend/importers/tic80CartImporter.d.ts.map +1 -0
  47. package/dist/backend/importers/tic80CartImporter.js +96 -0
  48. package/dist/backend/importers/tic80CartImporter.js.map +1 -0
  49. package/dist/backend/loadAllImports.d.ts +1 -0
  50. package/dist/backend/loadAllImports.d.ts.map +1 -0
  51. package/dist/backend/loadAllImports.js +3 -0
  52. package/dist/backend/loadAllImports.js.map +1 -0
  53. package/dist/backend/luaBinaryEncoding.d.ts +6 -0
  54. package/dist/backend/luaBinaryEncoding.d.ts.map +1 -0
  55. package/dist/backend/luaBinaryEncoding.js +94 -0
  56. package/dist/backend/luaBinaryEncoding.js.map +1 -0
  57. package/dist/backend/luaPreprocessor.d.ts +8 -0
  58. package/dist/backend/luaPreprocessor.d.ts.map +1 -0
  59. package/dist/backend/luaPreprocessor.js +862 -0
  60. package/dist/backend/luaPreprocessor.js.map +1 -0
  61. package/dist/backend/luaPreprocessor.test.d.ts +2 -0
  62. package/dist/backend/luaPreprocessor.test.d.ts.map +1 -0
  63. package/dist/backend/luaPreprocessor.test.js.map +1 -0
  64. package/dist/backend/manifestLoader.d.ts +19 -0
  65. package/dist/backend/manifestLoader.d.ts.map +1 -0
  66. package/dist/backend/manifestLoader.js +142 -0
  67. package/dist/backend/manifestLoader.js.map +1 -0
  68. package/dist/backend/manifestLoader.test.d.ts +2 -0
  69. package/dist/backend/manifestLoader.test.d.ts.map +1 -0
  70. package/dist/backend/manifestLoader.test.js.map +1 -0
  71. package/dist/backend/manifestTypes.d.ts +454 -0
  72. package/dist/backend/manifestTypes.d.ts.map +1 -0
  73. package/dist/backend/manifestTypes.js +28 -0
  74. package/dist/backend/manifestTypes.js.map +1 -0
  75. package/dist/backend/project.d.ts +24 -0
  76. package/dist/backend/project.d.ts.map +1 -0
  77. package/dist/backend/project.js +159 -0
  78. package/dist/backend/project.js.map +1 -0
  79. package/dist/backend/projectCore.d.ts +34 -0
  80. package/dist/backend/projectCore.d.ts.map +1 -0
  81. package/dist/backend/projectCore.js +226 -0
  82. package/dist/backend/projectCore.js.map +1 -0
  83. package/dist/backend/tic80Resolver.d.ts +6 -0
  84. package/dist/backend/tic80Resolver.d.ts.map +1 -0
  85. package/dist/backend/tic80Resolver.js +66 -0
  86. package/dist/backend/tic80Resolver.js.map +1 -0
  87. package/dist/buildInfo.d.ts +9 -0
  88. package/dist/buildInfo.d.ts.map +1 -0
  89. package/dist/buildInfo.js +13 -0
  90. package/dist/buildInfo.js.map +1 -0
  91. package/dist/frontend/build.d.ts +3 -0
  92. package/dist/frontend/build.d.ts.map +1 -0
  93. package/dist/frontend/build.js +8 -0
  94. package/dist/frontend/build.js.map +1 -0
  95. package/dist/frontend/codeBankWarnings.test.d.ts +2 -0
  96. package/dist/frontend/codeBankWarnings.test.d.ts.map +1 -0
  97. package/dist/frontend/codeBankWarnings.test.js.map +1 -0
  98. package/dist/frontend/core.d.ts +3 -0
  99. package/dist/frontend/core.d.ts.map +1 -0
  100. package/dist/frontend/core.js +259 -0
  101. package/dist/frontend/core.js.map +1 -0
  102. package/dist/frontend/init.d.ts +7 -0
  103. package/dist/frontend/init.d.ts.map +1 -0
  104. package/dist/frontend/init.js +95 -0
  105. package/dist/frontend/init.js.map +1 -0
  106. package/dist/frontend/parseOptions.d.ts +7 -0
  107. package/dist/frontend/parseOptions.d.ts.map +1 -0
  108. package/dist/frontend/parseOptions.js +68 -0
  109. package/dist/frontend/parseOptions.js.map +1 -0
  110. package/dist/frontend/run.d.ts +3 -0
  111. package/dist/frontend/run.d.ts.map +1 -0
  112. package/dist/frontend/run.js +63 -0
  113. package/dist/frontend/run.js.map +1 -0
  114. package/dist/frontend/watch.d.ts +3 -0
  115. package/dist/frontend/watch.d.ts.map +1 -0
  116. package/dist/frontend/watch.js +208 -0
  117. package/dist/frontend/watch.js.map +1 -0
  118. package/dist/index.d.ts +3 -0
  119. package/dist/index.d.ts.map +1 -0
  120. package/dist/index.js +191 -0
  121. package/dist/index.js.map +1 -0
  122. package/dist/obj/resolvedManifest.ticbuild.jsonc +110 -0
  123. package/dist/obj/variables.json +19 -0
  124. package/dist/utils/algorithms.d.ts +4 -0
  125. package/dist/utils/algorithms.d.ts.map +1 -0
  126. package/dist/utils/algorithms.js +15 -0
  127. package/dist/utils/algorithms.js.map +1 -0
  128. package/dist/utils/algorithms.test.d.ts +2 -0
  129. package/dist/utils/algorithms.test.d.ts.map +1 -0
  130. package/dist/utils/algorithms.test.js.map +1 -0
  131. package/dist/utils/bin.d.ts +4 -0
  132. package/dist/utils/bin.d.ts.map +1 -0
  133. package/dist/utils/bin.js +16 -0
  134. package/dist/utils/bin.js.map +1 -0
  135. package/dist/utils/charMap.d.ts +28 -0
  136. package/dist/utils/charMap.d.ts.map +1 -0
  137. package/dist/utils/charMap.js +31 -0
  138. package/dist/utils/charMap.js.map +1 -0
  139. package/dist/utils/console.d.ts +10 -0
  140. package/dist/utils/console.d.ts.map +1 -0
  141. package/dist/utils/console.js +66 -0
  142. package/dist/utils/console.js.map +1 -0
  143. package/dist/utils/encoding/b85.d.ts +5 -0
  144. package/dist/utils/encoding/b85.d.ts.map +1 -0
  145. package/dist/utils/encoding/b85.js +136 -0
  146. package/dist/utils/encoding/b85.js.map +1 -0
  147. package/dist/utils/encoding/codecRegistry.d.ts +333 -0
  148. package/dist/utils/encoding/codecRegistry.d.ts.map +1 -0
  149. package/dist/utils/encoding/codecRegistry.js +81 -0
  150. package/dist/utils/encoding/codecRegistry.js.map +1 -0
  151. package/dist/utils/encoding/hex.d.ts +3 -0
  152. package/dist/utils/encoding/hex.d.ts.map +1 -0
  153. package/dist/utils/encoding/hex.js +30 -0
  154. package/dist/utils/encoding/hex.js.map +1 -0
  155. package/dist/utils/encoding/lz.d.ts +12 -0
  156. package/dist/utils/encoding/lz.d.ts.map +1 -0
  157. package/dist/utils/encoding/lz.js +271 -0
  158. package/dist/utils/encoding/lz.js.map +1 -0
  159. package/dist/utils/enum.d.ts +45 -0
  160. package/dist/utils/enum.d.ts.map +1 -0
  161. package/dist/utils/enum.js +135 -0
  162. package/dist/utils/enum.js.map +1 -0
  163. package/dist/utils/errorHandling.d.ts +13 -0
  164. package/dist/utils/errorHandling.d.ts.map +1 -0
  165. package/dist/utils/errorHandling.js +18 -0
  166. package/dist/utils/errorHandling.js.map +1 -0
  167. package/dist/utils/fileSystem.d.ts +16 -0
  168. package/dist/utils/fileSystem.d.ts.map +1 -0
  169. package/dist/utils/fileSystem.js +161 -0
  170. package/dist/utils/fileSystem.js.map +1 -0
  171. package/dist/utils/help.d.ts +7 -0
  172. package/dist/utils/help.d.ts.map +1 -0
  173. package/dist/utils/help.js +87 -0
  174. package/dist/utils/help.js.map +1 -0
  175. package/dist/utils/lua/luaUtils.d.ts +1 -0
  176. package/dist/utils/lua/luaUtils.d.ts.map +1 -0
  177. package/dist/utils/lua/luaUtils.js +3 -0
  178. package/dist/utils/lua/luaUtils.js.map +1 -0
  179. package/dist/utils/lua/lua_alias_expressions.d.ts +20 -0
  180. package/dist/utils/lua/lua_alias_expressions.d.ts.map +1 -0
  181. package/dist/utils/lua/lua_alias_expressions.js +233 -0
  182. package/dist/utils/lua/lua_alias_expressions.js.map +1 -0
  183. package/dist/utils/lua/lua_alias_literals.d.ts +20 -0
  184. package/dist/utils/lua/lua_alias_literals.d.ts.map +1 -0
  185. package/dist/utils/lua/lua_alias_literals.js +165 -0
  186. package/dist/utils/lua/lua_alias_literals.js.map +1 -0
  187. package/dist/utils/lua/lua_alias_shared.d.ts +31 -0
  188. package/dist/utils/lua/lua_alias_shared.d.ts.map +1 -0
  189. package/dist/utils/lua/lua_alias_shared.js +415 -0
  190. package/dist/utils/lua/lua_alias_shared.js.map +1 -0
  191. package/dist/utils/lua/lua_ast.d.ts +9 -0
  192. package/dist/utils/lua/lua_ast.d.ts.map +1 -0
  193. package/dist/utils/lua/lua_ast.js +90 -0
  194. package/dist/utils/lua/lua_ast.js.map +1 -0
  195. package/dist/utils/lua/lua_fundamentals.d.ts +14 -0
  196. package/dist/utils/lua/lua_fundamentals.d.ts.map +1 -0
  197. package/dist/utils/lua/lua_fundamentals.js +93 -0
  198. package/dist/utils/lua/lua_fundamentals.js.map +1 -0
  199. package/dist/utils/lua/lua_pack_locals.d.ts +3 -0
  200. package/dist/utils/lua/lua_pack_locals.d.ts.map +1 -0
  201. package/dist/utils/lua/lua_pack_locals.js +206 -0
  202. package/dist/utils/lua/lua_pack_locals.js.map +1 -0
  203. package/dist/utils/lua/lua_processor.d.ts +65 -0
  204. package/dist/utils/lua/lua_processor.d.ts.map +1 -0
  205. package/dist/utils/lua/lua_processor.js +1153 -0
  206. package/dist/utils/lua/lua_processor.js.map +1 -0
  207. package/dist/utils/lua/lua_processor.test.d.ts +2 -0
  208. package/dist/utils/lua/lua_processor.test.d.ts.map +1 -0
  209. package/dist/utils/lua/lua_processor.test.js.map +1 -0
  210. package/dist/utils/lua/lua_remove_unused_functions.d.ts +6 -0
  211. package/dist/utils/lua/lua_remove_unused_functions.d.ts.map +1 -0
  212. package/dist/utils/lua/lua_remove_unused_functions.js +474 -0
  213. package/dist/utils/lua/lua_remove_unused_functions.js.map +1 -0
  214. package/dist/utils/lua/lua_remove_unused_locals.d.ts +3 -0
  215. package/dist/utils/lua/lua_remove_unused_locals.d.ts.map +1 -0
  216. package/dist/utils/lua/lua_remove_unused_locals.js +303 -0
  217. package/dist/utils/lua/lua_remove_unused_locals.js.map +1 -0
  218. package/dist/utils/lua/lua_rename_allowed_table_keys.d.ts +3 -0
  219. package/dist/utils/lua/lua_rename_allowed_table_keys.d.ts.map +1 -0
  220. package/dist/utils/lua/lua_rename_allowed_table_keys.js +157 -0
  221. package/dist/utils/lua/lua_rename_allowed_table_keys.js.map +1 -0
  222. package/dist/utils/lua/lua_rename_table_fields.d.ts +3 -0
  223. package/dist/utils/lua/lua_rename_table_fields.d.ts.map +1 -0
  224. package/dist/utils/lua/lua_rename_table_fields.js +427 -0
  225. package/dist/utils/lua/lua_rename_table_fields.js.map +1 -0
  226. package/dist/utils/lua/lua_renamer.d.ts +3 -0
  227. package/dist/utils/lua/lua_renamer.d.ts.map +1 -0
  228. package/dist/utils/lua/lua_renamer.js +229 -0
  229. package/dist/utils/lua/lua_renamer.js.map +1 -0
  230. package/dist/utils/lua/lua_simplify.d.ts +3 -0
  231. package/dist/utils/lua/lua_simplify.d.ts.map +1 -0
  232. package/dist/utils/lua/lua_simplify.js +541 -0
  233. package/dist/utils/lua/lua_simplify.js.map +1 -0
  234. package/dist/utils/lua/lua_utils.d.ts +13 -0
  235. package/dist/utils/lua/lua_utils.d.ts.map +1 -0
  236. package/dist/utils/lua/lua_utils.js +58 -0
  237. package/dist/utils/lua/lua_utils.js.map +1 -0
  238. package/dist/utils/math.d.ts +2 -0
  239. package/dist/utils/math.d.ts.map +1 -0
  240. package/dist/utils/math.js +7 -0
  241. package/dist/utils/math.js.map +1 -0
  242. package/dist/utils/math.test.d.ts +2 -0
  243. package/dist/utils/math.test.d.ts.map +1 -0
  244. package/dist/utils/math.test.js.map +1 -0
  245. package/dist/utils/templates.d.ts +3 -0
  246. package/dist/utils/templates.d.ts.map +1 -0
  247. package/dist/utils/templates.js +57 -0
  248. package/dist/utils/templates.js.map +1 -0
  249. package/dist/utils/tic80/bankSupport.test.d.ts +2 -0
  250. package/dist/utils/tic80/bankSupport.test.d.ts.map +1 -0
  251. package/dist/utils/tic80/bankSupport.test.js.map +1 -0
  252. package/dist/utils/tic80/cartLoader.d.ts +3 -0
  253. package/dist/utils/tic80/cartLoader.d.ts.map +1 -0
  254. package/dist/utils/tic80/cartLoader.js +54 -0
  255. package/dist/utils/tic80/cartLoader.js.map +1 -0
  256. package/dist/utils/tic80/cartWriter.d.ts +5 -0
  257. package/dist/utils/tic80/cartWriter.d.ts.map +1 -0
  258. package/dist/utils/tic80/cartWriter.js +95 -0
  259. package/dist/utils/tic80/cartWriter.js.map +1 -0
  260. package/dist/utils/tic80/launch.d.ts +4 -0
  261. package/dist/utils/tic80/launch.d.ts.map +1 -0
  262. package/dist/utils/tic80/launch.js +36 -0
  263. package/dist/utils/tic80/launch.js.map +1 -0
  264. package/dist/utils/tic80/tic80.d.ts +1149 -0
  265. package/dist/utils/tic80/tic80.d.ts.map +1 -0
  266. package/dist/utils/tic80/tic80.js +114 -0
  267. package/dist/utils/tic80/tic80.js.map +1 -0
  268. package/dist/utils/utils.d.ts +13 -0
  269. package/dist/utils/utils.d.ts.map +1 -0
  270. package/dist/utils/utils.js +109 -0
  271. package/dist/utils/utils.js.map +1 -0
  272. package/dist/utils/versionString.d.ts +12 -0
  273. package/dist/utils/versionString.d.ts.map +1 -0
  274. package/dist/utils/versionString.js +33 -0
  275. package/dist/utils/versionString.js.map +1 -0
  276. package/dist/utils/windowPosition.d.ts +10 -0
  277. package/dist/utils/windowPosition.d.ts.map +1 -0
  278. package/dist/utils/windowPosition.js +222 -0
  279. package/dist/utils/windowPosition.js.map +1 -0
  280. package/example.ticbuild.jsonc +94 -0
  281. package/package.json +51 -0
  282. package/templates/help/build.txt +23 -0
  283. package/templates/help/init.txt +23 -0
  284. package/templates/help/main.txt +41 -0
  285. package/templates/help/run.txt +22 -0
  286. package/templates/help/tic80.txt +8 -0
  287. package/templates/help/watch.txt +24 -0
  288. package/templates/minimal/project.ticbuild.jsonc +43 -0
  289. package/ticbuild-1.0.0.tgz +0 -0
  290. package/ticbuild.schema.json +327 -0
@@ -0,0 +1,454 @@
1
+ import { OptimizationRuleOptions } from "../utils/lua/lua_processor";
2
+ import { SourceEncodingKey } from "../utils/encoding/codecRegistry";
3
+ import { Tic80CartChunkTypeKey } from "../utils/tic80/tic80";
4
+ export declare const kImportKind: {
5
+ readonly $key: "binary" | "LuaCode" | "Tic80Cartridge" | "text";
6
+ readonly $value: "binary" | "LuaCode" | "Tic80Cartridge" | "text";
7
+ readonly $info: ({
8
+ key: "binary";
9
+ } & {
10
+ readonly value: "binary";
11
+ }) | ({
12
+ key: "LuaCode";
13
+ } & {
14
+ readonly value: "LuaCode";
15
+ }) | ({
16
+ key: "Tic80Cartridge";
17
+ } & {
18
+ readonly value: "Tic80Cartridge";
19
+ }) | ({
20
+ key: "text";
21
+ } & {
22
+ readonly value: "text";
23
+ });
24
+ readonly valueByKey: {
25
+ readonly binary: "binary";
26
+ readonly LuaCode: "LuaCode";
27
+ readonly Tic80Cartridge: "Tic80Cartridge";
28
+ readonly text: "text";
29
+ };
30
+ readonly infoByKey: {
31
+ readonly binary: {
32
+ key: "binary";
33
+ } & {
34
+ readonly value: "binary";
35
+ };
36
+ readonly LuaCode: {
37
+ key: "LuaCode";
38
+ } & {
39
+ readonly value: "LuaCode";
40
+ };
41
+ readonly Tic80Cartridge: {
42
+ key: "Tic80Cartridge";
43
+ } & {
44
+ readonly value: "Tic80Cartridge";
45
+ };
46
+ readonly text: {
47
+ key: "text";
48
+ } & {
49
+ readonly value: "text";
50
+ };
51
+ };
52
+ readonly key: {
53
+ readonly binary: "binary";
54
+ readonly LuaCode: "LuaCode";
55
+ readonly Tic80Cartridge: "Tic80Cartridge";
56
+ readonly text: "text";
57
+ };
58
+ readonly byKey: {
59
+ readonly LuaCode: {
60
+ readonly value: "LuaCode";
61
+ };
62
+ readonly Tic80Cartridge: {
63
+ readonly value: "Tic80Cartridge";
64
+ };
65
+ readonly binary: {
66
+ readonly value: "binary";
67
+ };
68
+ readonly text: {
69
+ readonly value: "text";
70
+ };
71
+ };
72
+ readonly infoByValue: Map<"binary" | "LuaCode" | "Tic80Cartridge" | "text", ({
73
+ key: "binary";
74
+ } & {
75
+ readonly value: "binary";
76
+ }) | ({
77
+ key: "LuaCode";
78
+ } & {
79
+ readonly value: "LuaCode";
80
+ }) | ({
81
+ key: "Tic80Cartridge";
82
+ } & {
83
+ readonly value: "Tic80Cartridge";
84
+ }) | ({
85
+ key: "text";
86
+ } & {
87
+ readonly value: "text";
88
+ })>;
89
+ readonly keyByValue: Map<"binary" | "LuaCode" | "Tic80Cartridge" | "text", "binary" | "LuaCode" | "Tic80Cartridge" | "text">;
90
+ readonly keys: ["binary" | "LuaCode" | "Tic80Cartridge" | "text", ...("binary" | "LuaCode" | "Tic80Cartridge" | "text")[]];
91
+ readonly values: ("binary" | "LuaCode" | "Tic80Cartridge" | "text")[];
92
+ readonly infos: (({
93
+ key: "binary";
94
+ } & {
95
+ readonly value: "binary";
96
+ }) | ({
97
+ key: "LuaCode";
98
+ } & {
99
+ readonly value: "LuaCode";
100
+ }) | ({
101
+ key: "Tic80Cartridge";
102
+ } & {
103
+ readonly value: "Tic80Cartridge";
104
+ }) | ({
105
+ key: "text";
106
+ } & {
107
+ readonly value: "text";
108
+ }))[];
109
+ readonly valuesSet: Set<"binary" | "LuaCode" | "Tic80Cartridge" | "text">;
110
+ readonly keysSet: Set<"binary" | "LuaCode" | "Tic80Cartridge" | "text">;
111
+ readonly isValidKey: (k: any) => k is "binary" | "LuaCode" | "Tic80Cartridge" | "text";
112
+ readonly coerceByKey: {
113
+ (k: any): (({
114
+ key: "binary";
115
+ } & {
116
+ readonly value: "binary";
117
+ }) | ({
118
+ key: "LuaCode";
119
+ } & {
120
+ readonly value: "LuaCode";
121
+ }) | ({
122
+ key: "Tic80Cartridge";
123
+ } & {
124
+ readonly value: "Tic80Cartridge";
125
+ }) | ({
126
+ key: "text";
127
+ } & {
128
+ readonly value: "text";
129
+ })) | undefined;
130
+ (k: any, fallbackKey: "binary" | "LuaCode" | "Tic80Cartridge" | "text"): ({
131
+ key: "binary";
132
+ } & {
133
+ readonly value: "binary";
134
+ }) | ({
135
+ key: "LuaCode";
136
+ } & {
137
+ readonly value: "LuaCode";
138
+ }) | ({
139
+ key: "Tic80Cartridge";
140
+ } & {
141
+ readonly value: "Tic80Cartridge";
142
+ }) | ({
143
+ key: "text";
144
+ } & {
145
+ readonly value: "text";
146
+ });
147
+ };
148
+ readonly coerceByValue: {
149
+ (v: any): (({
150
+ key: "binary";
151
+ } & {
152
+ readonly value: "binary";
153
+ }) | ({
154
+ key: "LuaCode";
155
+ } & {
156
+ readonly value: "LuaCode";
157
+ }) | ({
158
+ key: "Tic80Cartridge";
159
+ } & {
160
+ readonly value: "Tic80Cartridge";
161
+ }) | ({
162
+ key: "text";
163
+ } & {
164
+ readonly value: "text";
165
+ })) | undefined;
166
+ (v: any, fallbackKey: "binary" | "LuaCode" | "Tic80Cartridge" | "text"): ({
167
+ key: "binary";
168
+ } & {
169
+ readonly value: "binary";
170
+ }) | ({
171
+ key: "LuaCode";
172
+ } & {
173
+ readonly value: "LuaCode";
174
+ }) | ({
175
+ key: "Tic80Cartridge";
176
+ } & {
177
+ readonly value: "Tic80Cartridge";
178
+ }) | ({
179
+ key: "text";
180
+ } & {
181
+ readonly value: "text";
182
+ });
183
+ };
184
+ readonly coerceByValueOrKey: {
185
+ (vk: any): (({
186
+ key: "binary";
187
+ } & {
188
+ readonly value: "binary";
189
+ }) | ({
190
+ key: "LuaCode";
191
+ } & {
192
+ readonly value: "LuaCode";
193
+ }) | ({
194
+ key: "Tic80Cartridge";
195
+ } & {
196
+ readonly value: "Tic80Cartridge";
197
+ }) | ({
198
+ key: "text";
199
+ } & {
200
+ readonly value: "text";
201
+ })) | undefined;
202
+ (vk: any, fallbackKey: "binary" | "LuaCode" | "Tic80Cartridge" | "text"): ({
203
+ key: "binary";
204
+ } & {
205
+ readonly value: "binary";
206
+ }) | ({
207
+ key: "LuaCode";
208
+ } & {
209
+ readonly value: "LuaCode";
210
+ }) | ({
211
+ key: "Tic80Cartridge";
212
+ } & {
213
+ readonly value: "Tic80Cartridge";
214
+ }) | ({
215
+ key: "text";
216
+ } & {
217
+ readonly value: "text";
218
+ });
219
+ };
220
+ };
221
+ export type ImportKindKey = typeof kImportKind.$key;
222
+ export interface ProjectConfig {
223
+ name: string;
224
+ includeDirs?: string[];
225
+ importDirs?: string[];
226
+ binDir: string;
227
+ objDir: string;
228
+ outputCartName: string;
229
+ }
230
+ export interface ImportDefinition {
231
+ name: string;
232
+ path?: string;
233
+ kind?: ImportKindKey;
234
+ chunks?: Tic80CartChunkTypeKey[];
235
+ sourceEncoding?: SourceEncodingKey;
236
+ value?: string;
237
+ }
238
+ export interface AssetReference {
239
+ import: string;
240
+ chunks?: Tic80CartChunkTypeKey[];
241
+ }
242
+ export interface AssemblyBlock {
243
+ chunks?: Tic80CartChunkTypeKey[];
244
+ bank?: number;
245
+ asset: string | AssetReference;
246
+ code?: CodeAssemblyOptions;
247
+ }
248
+ export type CodeAssemblyOptions = {
249
+ emitGlobals?: boolean;
250
+ };
251
+ export type LuaMinificationConfig = Partial<OptimizationRuleOptions>;
252
+ export interface LuaAssemblyConfig {
253
+ minify?: boolean;
254
+ minification?: LuaMinificationConfig;
255
+ globals?: Record<string, string | number | boolean>;
256
+ }
257
+ export interface AssemblyConfig {
258
+ lua?: LuaAssemblyConfig;
259
+ blocks: AssemblyBlock[];
260
+ }
261
+ export interface BuildConfiguration {
262
+ project?: Partial<ProjectConfig>;
263
+ variables?: Record<string, string>;
264
+ assembly?: Partial<AssemblyConfig>;
265
+ }
266
+ export interface Manifest {
267
+ project: ProjectConfig;
268
+ variables?: Record<string, string>;
269
+ imports: ImportDefinition[];
270
+ assembly: AssemblyConfig;
271
+ buildConfigurations?: Record<string, BuildConfiguration>;
272
+ }
273
+ export type VariableInfo = {
274
+ name: string;
275
+ rawValue: string;
276
+ resolvedValue: string;
277
+ };
278
+ export type ResolvedManifest = {
279
+ manifest: Manifest;
280
+ selectedBuildConfig?: string | undefined;
281
+ variables: Map<string, VariableInfo>;
282
+ };
283
+ export declare const kCommonVariables: {
284
+ readonly $key: "projectDir" | "manifestPath" | "outputCartName";
285
+ readonly $value: "project.projectDir" | "project.manifestPath" | "project.outputCartName";
286
+ readonly $info: ({
287
+ key: "projectDir";
288
+ } & {
289
+ readonly value: "project.projectDir";
290
+ }) | ({
291
+ key: "manifestPath";
292
+ } & {
293
+ readonly value: "project.manifestPath";
294
+ }) | ({
295
+ key: "outputCartName";
296
+ } & {
297
+ readonly value: "project.outputCartName";
298
+ });
299
+ readonly valueByKey: {
300
+ readonly projectDir: "project.projectDir";
301
+ readonly manifestPath: "project.manifestPath";
302
+ readonly outputCartName: "project.outputCartName";
303
+ };
304
+ readonly infoByKey: {
305
+ readonly projectDir: {
306
+ key: "projectDir";
307
+ } & {
308
+ readonly value: "project.projectDir";
309
+ };
310
+ readonly manifestPath: {
311
+ key: "manifestPath";
312
+ } & {
313
+ readonly value: "project.manifestPath";
314
+ };
315
+ readonly outputCartName: {
316
+ key: "outputCartName";
317
+ } & {
318
+ readonly value: "project.outputCartName";
319
+ };
320
+ };
321
+ readonly key: {
322
+ readonly projectDir: "projectDir";
323
+ readonly manifestPath: "manifestPath";
324
+ readonly outputCartName: "outputCartName";
325
+ };
326
+ readonly byKey: {
327
+ readonly projectDir: {
328
+ readonly value: "project.projectDir";
329
+ };
330
+ readonly manifestPath: {
331
+ readonly value: "project.manifestPath";
332
+ };
333
+ readonly outputCartName: {
334
+ readonly value: "project.outputCartName";
335
+ };
336
+ };
337
+ readonly infoByValue: Map<"project.projectDir" | "project.manifestPath" | "project.outputCartName", ({
338
+ key: "projectDir";
339
+ } & {
340
+ readonly value: "project.projectDir";
341
+ }) | ({
342
+ key: "manifestPath";
343
+ } & {
344
+ readonly value: "project.manifestPath";
345
+ }) | ({
346
+ key: "outputCartName";
347
+ } & {
348
+ readonly value: "project.outputCartName";
349
+ })>;
350
+ readonly keyByValue: Map<"project.projectDir" | "project.manifestPath" | "project.outputCartName", "projectDir" | "manifestPath" | "outputCartName">;
351
+ readonly keys: ["projectDir" | "manifestPath" | "outputCartName", ...("projectDir" | "manifestPath" | "outputCartName")[]];
352
+ readonly values: ("project.projectDir" | "project.manifestPath" | "project.outputCartName")[];
353
+ readonly infos: (({
354
+ key: "projectDir";
355
+ } & {
356
+ readonly value: "project.projectDir";
357
+ }) | ({
358
+ key: "manifestPath";
359
+ } & {
360
+ readonly value: "project.manifestPath";
361
+ }) | ({
362
+ key: "outputCartName";
363
+ } & {
364
+ readonly value: "project.outputCartName";
365
+ }))[];
366
+ readonly valuesSet: Set<"project.projectDir" | "project.manifestPath" | "project.outputCartName">;
367
+ readonly keysSet: Set<"projectDir" | "manifestPath" | "outputCartName">;
368
+ readonly isValidKey: (k: any) => k is "projectDir" | "manifestPath" | "outputCartName";
369
+ readonly coerceByKey: {
370
+ (k: any): (({
371
+ key: "projectDir";
372
+ } & {
373
+ readonly value: "project.projectDir";
374
+ }) | ({
375
+ key: "manifestPath";
376
+ } & {
377
+ readonly value: "project.manifestPath";
378
+ }) | ({
379
+ key: "outputCartName";
380
+ } & {
381
+ readonly value: "project.outputCartName";
382
+ })) | undefined;
383
+ (k: any, fallbackKey: "projectDir" | "manifestPath" | "outputCartName"): ({
384
+ key: "projectDir";
385
+ } & {
386
+ readonly value: "project.projectDir";
387
+ }) | ({
388
+ key: "manifestPath";
389
+ } & {
390
+ readonly value: "project.manifestPath";
391
+ }) | ({
392
+ key: "outputCartName";
393
+ } & {
394
+ readonly value: "project.outputCartName";
395
+ });
396
+ };
397
+ readonly coerceByValue: {
398
+ (v: any): (({
399
+ key: "projectDir";
400
+ } & {
401
+ readonly value: "project.projectDir";
402
+ }) | ({
403
+ key: "manifestPath";
404
+ } & {
405
+ readonly value: "project.manifestPath";
406
+ }) | ({
407
+ key: "outputCartName";
408
+ } & {
409
+ readonly value: "project.outputCartName";
410
+ })) | undefined;
411
+ (v: any, fallbackKey: "projectDir" | "manifestPath" | "outputCartName"): ({
412
+ key: "projectDir";
413
+ } & {
414
+ readonly value: "project.projectDir";
415
+ }) | ({
416
+ key: "manifestPath";
417
+ } & {
418
+ readonly value: "project.manifestPath";
419
+ }) | ({
420
+ key: "outputCartName";
421
+ } & {
422
+ readonly value: "project.outputCartName";
423
+ });
424
+ };
425
+ readonly coerceByValueOrKey: {
426
+ (vk: any): (({
427
+ key: "projectDir";
428
+ } & {
429
+ readonly value: "project.projectDir";
430
+ }) | ({
431
+ key: "manifestPath";
432
+ } & {
433
+ readonly value: "project.manifestPath";
434
+ }) | ({
435
+ key: "outputCartName";
436
+ } & {
437
+ readonly value: "project.outputCartName";
438
+ })) | undefined;
439
+ (vk: any, fallbackKey: "projectDir" | "manifestPath" | "outputCartName"): ({
440
+ key: "projectDir";
441
+ } & {
442
+ readonly value: "project.projectDir";
443
+ }) | ({
444
+ key: "manifestPath";
445
+ } & {
446
+ readonly value: "project.manifestPath";
447
+ }) | ({
448
+ key: "outputCartName";
449
+ } & {
450
+ readonly value: "project.outputCartName";
451
+ });
452
+ };
453
+ };
454
+ //# sourceMappingURL=manifestTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifestTypes.d.ts","sourceRoot":"","sources":["../../src/backend/manifestTypes.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ // TODO: make this structured to actually run some rules.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.kCommonVariables = exports.kImportKind = void 0;
5
+ const enum_1 = require("../utils/enum");
6
+ // TIC-80 cartridge chunk types.
7
+ // https://github.com/nesbox/TIC-80/wiki/.tic-File-Format
8
+ // importers... maybe an enum later?
9
+ exports.kImportKind = (0, enum_1.defineEnum)({
10
+ LuaCode: {
11
+ value: "LuaCode",
12
+ },
13
+ Tic80Cartridge: {
14
+ value: "Tic80Cartridge",
15
+ },
16
+ binary: {
17
+ value: "binary",
18
+ },
19
+ text: {
20
+ value: "text",
21
+ },
22
+ }); // "LuaCode" | "Tic80Cartridge";
23
+ exports.kCommonVariables = (0, enum_1.defineEnum)({
24
+ projectDir: { value: "project.projectDir" },
25
+ manifestPath: { value: "project.manifestPath" },
26
+ outputCartName: { value: "project.outputCartName" },
27
+ });
28
+ //# sourceMappingURL=manifestTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifestTypes.js","sourceRoot":"","sources":["../../src/backend/manifestTypes.ts"],"names":[],"mappings":";AAAA,yDAAyD;;;AAEzD,wCAA2C;AAK3C,gCAAgC;AAChC,yDAAyD;AAEzD,oCAAoC;AACvB,QAAA,WAAW,GAAG,IAAA,iBAAU,EAAC;IACpC,OAAO,EAAE;QACP,KAAK,EAAE,SAAS;KACjB;IACD,cAAc,EAAE;QACd,KAAK,EAAE,gBAAgB;KACxB;IACD,MAAM,EAAE;QACN,KAAK,EAAE,QAAQ;KAChB;IACD,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM;KACd;CACO,CAAC,CAAC,CAAC,gCAAgC;AAgFhC,QAAA,gBAAgB,GAAG,IAAA,iBAAU,EAAC;IACzC,UAAU,EAAE,EAAE,KAAK,EAAE,oBAAoB,EAAE;IAC3C,YAAY,EAAE,EAAE,KAAK,EAAE,sBAAsB,EAAE;IAC/C,cAAc,EAAE,EAAE,KAAK,EAAE,wBAAwB,EAAE;CAC3C,CAAC,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { Tic80CartChunk } from "../utils/tic80/tic80";
2
+ import { ResourceManager } from "./ImportedResourceTypes";
3
+ import { TicbuildProjectCore } from "./projectCore";
4
+ export type TicbuildProjectLoadOptions = {
5
+ manifestPath?: string | undefined;
6
+ buildConfigName?: string | undefined;
7
+ overrideVariables?: Record<string, string>;
8
+ };
9
+ export type AssembleOutputResult = {
10
+ output: Uint8Array;
11
+ chunks: Tic80CartChunk[];
12
+ };
13
+ export declare class TicbuildProject {
14
+ unresolvedCore: TicbuildProjectCore;
15
+ resolvedCore: TicbuildProjectCore;
16
+ resourceMgr: ResourceManager | undefined;
17
+ static loadFromManifest(options?: TicbuildProjectLoadOptions): TicbuildProject;
18
+ private constructor();
19
+ private resolveManifest;
20
+ loadImports(): Promise<void>;
21
+ private assembleBlock;
22
+ assembleOutput(): Promise<AssembleOutputResult>;
23
+ }
24
+ //# sourceMappingURL=project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/backend/project.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwB,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE5E,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAI1D,OAAO,EAAoE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEtH,MAAM,MAAM,0BAA0B,GAAG;IACvC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,cAAc,EAAE,CAAC;CAC1B,CAAC;AAGF,qBAAa,eAAe;IAC1B,cAAc,EAAE,mBAAmB,CAAC;IAQpC,YAAY,EAAE,mBAAmB,CAAC;IAElC,WAAW,EAAE,eAAe,GAAG,SAAS,CAAC;IAEzC,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,0BAA0B,GAAG,eAAe;IAU9E,OAAO;IAwBP,OAAO,CAAC,eAAe;IAuEjB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;YAKpB,aAAa;IA+CrB,cAAc,IAAI,OAAO,CAAC,oBAAoB,CAAC;CA0BtD"}
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TicbuildProject = void 0;
4
+ const errorHandling_1 = require("../utils/errorHandling");
5
+ const cartWriter_1 = require("../utils/tic80/cartWriter");
6
+ const tic80_1 = require("../utils/tic80/tic80");
7
+ const utils_1 = require("../utils/utils");
8
+ const importResources_1 = require("./importResources");
9
+ const manifestLoader_1 = require("./manifestLoader");
10
+ const manifestTypes_1 = require("./manifestTypes");
11
+ const projectCore_1 = require("./projectCore");
12
+ ///////////////////////////////////////////////////////////////////////////////////////////////////
13
+ class TicbuildProject {
14
+ static loadFromManifest(options) {
15
+ const loadedManifest = (0, manifestLoader_1.resolveAndLoadManifest)(options?.manifestPath);
16
+ return new TicbuildProject(loadedManifest.manifest, //
17
+ loadedManifest.filePath, loadedManifest.projectDir, options);
18
+ }
19
+ constructor(manifest, manifestPath, projectDir, options) {
20
+ this.unresolvedCore = new projectCore_1.TicbuildProjectCore({
21
+ manifest,
22
+ manifestPath,
23
+ projectDir,
24
+ buildConfigName: options?.buildConfigName,
25
+ overrideVariables: options?.overrideVariables,
26
+ });
27
+ const resolvedManifest = this.resolveManifest(manifestPath, projectDir, options);
28
+ this.resolvedCore = new projectCore_1.TicbuildProjectCore({
29
+ manifest: resolvedManifest.manifest,
30
+ manifestPath,
31
+ projectDir,
32
+ buildConfigName: options?.buildConfigName,
33
+ overrideVariables: options?.overrideVariables,
34
+ });
35
+ }
36
+ resolveManifest(manifestPath, projectDir, options) {
37
+ // avoid mutations
38
+ const resolved = this.unresolvedCore.clone().manifest;
39
+ // in this process, avoid handling of specific fields; general behaviors are preferred
40
+ // for maintainability.
41
+ if (options?.buildConfigName) {
42
+ const buildConfig = this.unresolvedCore.manifest.buildConfigurations?.[options.buildConfigName];
43
+ if (!buildConfig) {
44
+ throw new Error(`Build configuration not found: ${options.buildConfigName}`);
45
+ }
46
+ // for every leaf in project settings, override / add to resolved manifest
47
+ // for example { project: { binDir: "..." } } overrides resolved.project.binDir
48
+ // arrays are considered a leaf value. e.g., { project: { includeDirs: [...] } } substitutes the entire array.
49
+ // we want to avoid handling specific cases; we want generic merge/override behavior.
50
+ (0, utils_1.deepMergeObjects)(resolved, buildConfig);
51
+ // that makes it theoretically possible to override the assembly.blocks array too,
52
+ // so we need to canonicalize asset references again after applying the build config.
53
+ }
54
+ // there's a special case to handle:
55
+ // assembly.blocks[].asset supports a shorthand form.
56
+ // canonical form:
57
+ // "asset": { "import": "music-imported-cart", "chunks": ["MUSIC_WAVEFORMS"] },
58
+ // shorthand:
59
+ // "asset": "import:music-imported-cart:MUSIC_WAVEFORMS",
60
+ for (const block of resolved.assembly.blocks) {
61
+ block.asset = (0, projectCore_1.canonicalizeAssetImport)(block.asset);
62
+ }
63
+ const calculatedVars = (0, projectCore_1.calculateVars)(resolved, manifestPath, projectDir, options?.overrideVariables, options?.buildConfigName);
64
+ // ensure all imports have "kind" -- deduce if missing.
65
+ for (const importDef of resolved.imports) {
66
+ if (!importDef.kind) {
67
+ if (!importDef.path) {
68
+ throw new Error(`Import ${importDef.name} must specify kind when no path is provided`);
69
+ }
70
+ const deducedKind = (0, projectCore_1.deduceImportKindFromPath)(importDef.path);
71
+ if (!deducedKind) {
72
+ throw new Error(`Could not deduce import kind from path: ${importDef.path} (please specify explicitly in manifest)`);
73
+ }
74
+ const coerced = manifestTypes_1.kImportKind.coerceByKey(deducedKind);
75
+ if (!coerced) {
76
+ throw new Error(`Deduced import kind is invalid: ${deducedKind} (please specify explicitly in manifest)`);
77
+ }
78
+ importDef.kind = coerced.key;
79
+ }
80
+ }
81
+ return {
82
+ manifest: resolved, //
83
+ variables: calculatedVars,
84
+ };
85
+ }
86
+ async loadImports() {
87
+ this.resourceMgr = await (0, importResources_1.loadAllImports)(this.resolvedCore);
88
+ }
89
+ // takse a block def and returns the multiple chunks it may produce.
90
+ async assembleBlock(block) {
91
+ (0, errorHandling_1.assert)(!!this.resourceMgr);
92
+ // for binary copy, just retrieve the asset data from the resource manager.
93
+ const assetRef = block.asset;
94
+ const resource = this.resourceMgr.items.get(assetRef.import);
95
+ if (!resource) {
96
+ throw new Error(`Imported resource not found: ${assetRef.import}`);
97
+ }
98
+ const view = resource.getView(this.resolvedCore, block.chunks);
99
+ // extract the bins from the resource view and output as chunks.
100
+ const outputChunks = [];
101
+ const requestedChunks = block.chunks || view.getParallelChunkTypes();
102
+ const bank = block.bank ?? 0;
103
+ for (const chunkType of requestedChunks) {
104
+ const data = view.getDataForChunk(this.resolvedCore, chunkType, block.code);
105
+ if (chunkType === "CODE") {
106
+ const codeInfo = tic80_1.kTic80CartChunkTypes.byKey.CODE;
107
+ const maxChunkSize = codeInfo.sizePerBank;
108
+ if (data.length > maxChunkSize) {
109
+ if (block.bank !== undefined) {
110
+ // it's confusing what you mean if you specify a bank here.
111
+ // exceeding 1 bank = auto-split code into auto banks.
112
+ throw new Error(`CODE chunk exceeds ${maxChunkSize} bytes but bank was specified`);
113
+ }
114
+ const bankCount = Math.ceil(data.length / maxChunkSize);
115
+ for (let i = 0; i < bankCount; i++) {
116
+ const start = i * maxChunkSize;
117
+ const end = Math.min(start + maxChunkSize, data.length);
118
+ outputChunks.push({
119
+ chunkType,
120
+ bank: i,
121
+ data: data.subarray(start, end),
122
+ });
123
+ }
124
+ continue;
125
+ }
126
+ }
127
+ outputChunks.push({
128
+ chunkType,
129
+ bank,
130
+ data,
131
+ });
132
+ }
133
+ return outputChunks;
134
+ }
135
+ async assembleOutput() {
136
+ if (!this.resourceMgr) {
137
+ throw new Error("Resources not loaded. Call loadImports() before assembleOutput().");
138
+ }
139
+ const assembly = this.resolvedCore.manifest.assembly;
140
+ const tasks = [];
141
+ for (const block of assembly.blocks) {
142
+ // generate the binary output for each requested block.
143
+ tasks.push(this.assembleBlock(block));
144
+ }
145
+ // write the final output cartridge
146
+ const results = await Promise.all(tasks);
147
+ const finalChunks = [];
148
+ for (const chunkList of results) {
149
+ finalChunks.push(...chunkList);
150
+ }
151
+ // generate final tic80 cart binary
152
+ const output = await (0, cartWriter_1.AssembleTic80Cart)({
153
+ chunks: finalChunks,
154
+ });
155
+ return { output, chunks: finalChunks };
156
+ }
157
+ }
158
+ exports.TicbuildProject = TicbuildProject;
159
+ //# sourceMappingURL=project.js.map