yuzuha 0.2.0 → 0.3.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 (692) hide show
  1. package/CHANGELOG.md +29 -1
  2. package/README.md +22 -14
  3. package/VERSIONING.md +56 -7
  4. package/benchmarks/parser.mjs +1 -1
  5. package/benchmarks/run.mjs +3 -2
  6. package/dist/canvas/card.d.ts +10 -0
  7. package/dist/canvas/card.d.ts.map +1 -0
  8. package/dist/canvas/card.js +11 -0
  9. package/dist/canvas/card.js.map +1 -0
  10. package/dist/canvas.d.ts +30 -9
  11. package/dist/canvas.d.ts.map +1 -1
  12. package/dist/canvas.js +64 -9
  13. package/dist/canvas.js.map +1 -1
  14. package/dist/cli/config.d.ts.map +1 -1
  15. package/dist/cli/config.js +2 -1
  16. package/dist/cli/config.js.map +1 -1
  17. package/dist/cli/lint.d.ts.map +1 -1
  18. package/dist/cli/lint.js +1 -2
  19. package/dist/cli/lint.js.map +1 -1
  20. package/dist/cli/main.d.ts.map +1 -1
  21. package/dist/cli/main.js +8 -9
  22. package/dist/cli/main.js.map +1 -1
  23. package/dist/cli/scaffold.js +1 -1
  24. package/dist/cli/scaffold.js.map +1 -1
  25. package/dist/cli/scenarios.d.ts.map +1 -1
  26. package/dist/cli/scenarios.js +2 -1
  27. package/dist/cli/scenarios.js.map +1 -1
  28. package/dist/commands/context.d.ts.map +1 -1
  29. package/dist/commands/context.js +7 -2
  30. package/dist/commands/context.js.map +1 -1
  31. package/dist/domain/resource-batches.d.ts +6 -0
  32. package/dist/domain/resource-batches.d.ts.map +1 -1
  33. package/dist/domain/resource-batches.js +31 -0
  34. package/dist/domain/resource-batches.js.map +1 -1
  35. package/dist/framework/bot.d.ts +9 -5
  36. package/dist/framework/bot.d.ts.map +1 -1
  37. package/dist/framework/bot.js +51 -27
  38. package/dist/framework/bot.js.map +1 -1
  39. package/dist/framework/command-registry.d.ts +8 -7
  40. package/dist/framework/command-registry.d.ts.map +1 -1
  41. package/dist/framework/command-registry.js +14 -11
  42. package/dist/framework/command-registry.js.map +1 -1
  43. package/dist/framework/options.d.ts +3 -3
  44. package/dist/framework/options.d.ts.map +1 -1
  45. package/dist/framework/options.js.map +1 -1
  46. package/dist/{scripting → functions}/builtins/arguments.d.ts.map +1 -1
  47. package/dist/{scripting → functions}/builtins/arguments.js.map +1 -1
  48. package/dist/functions/builtins/canvas.d.ts +2 -0
  49. package/dist/functions/builtins/canvas.d.ts.map +1 -0
  50. package/dist/{scripting → functions}/builtins/canvas.js +1 -1
  51. package/dist/{scripting → functions}/builtins/canvas.js.map +1 -1
  52. package/dist/functions/builtins/context.d.ts +2 -0
  53. package/dist/functions/builtins/context.d.ts.map +1 -0
  54. package/dist/{scripting → functions}/builtins/context.js.map +1 -1
  55. package/dist/{scripting → functions}/builtins/definition.d.ts +1 -1
  56. package/dist/functions/builtins/definition.d.ts.map +1 -0
  57. package/dist/functions/builtins/definition.js.map +1 -0
  58. package/dist/functions/builtins/embeds.d.ts +3 -0
  59. package/dist/{scripting → functions}/builtins/embeds.d.ts.map +1 -1
  60. package/dist/{scripting → functions}/builtins/embeds.js +1 -1
  61. package/dist/functions/builtins/embeds.js.map +1 -0
  62. package/dist/functions/builtins/events.d.ts +2 -0
  63. package/dist/functions/builtins/events.d.ts.map +1 -0
  64. package/dist/{scripting → functions}/builtins/events.js.map +1 -1
  65. package/dist/functions/builtins/flow.d.ts +2 -0
  66. package/dist/functions/builtins/flow.d.ts.map +1 -0
  67. package/dist/{scripting → functions}/builtins/flow.js +2 -2
  68. package/dist/functions/builtins/flow.js.map +1 -0
  69. package/dist/functions/builtins/guards.d.ts +2 -0
  70. package/dist/functions/builtins/guards.d.ts.map +1 -0
  71. package/dist/{scripting → functions}/builtins/guards.js +1 -1
  72. package/dist/functions/builtins/guards.js.map +1 -0
  73. package/dist/functions/builtins/http.d.ts +2 -0
  74. package/dist/functions/builtins/http.d.ts.map +1 -0
  75. package/dist/{scripting → functions}/builtins/http.js +2 -2
  76. package/dist/functions/builtins/http.js.map +1 -0
  77. package/dist/functions/builtins/index.d.ts +5 -0
  78. package/dist/functions/builtins/index.d.ts.map +1 -0
  79. package/dist/functions/builtins/index.js.map +1 -0
  80. package/dist/functions/builtins/language/array-callbacks.d.ts +2 -0
  81. package/dist/functions/builtins/language/array-callbacks.d.ts.map +1 -0
  82. package/dist/{scripting → functions}/builtins/language/array-callbacks.js +1 -1
  83. package/dist/{scripting → functions}/builtins/language/array-callbacks.js.map +1 -1
  84. package/dist/functions/builtins/language/arrays.d.ts +2 -0
  85. package/dist/functions/builtins/language/arrays.d.ts.map +1 -0
  86. package/dist/{scripting → functions}/builtins/language/arrays.js +1 -1
  87. package/dist/{scripting → functions}/builtins/language/arrays.js.map +1 -1
  88. package/dist/{scripting → functions}/builtins/language/common.d.ts.map +1 -1
  89. package/dist/{scripting → functions}/builtins/language/common.js.map +1 -1
  90. package/dist/functions/builtins/language/decimals.d.ts +2 -0
  91. package/dist/functions/builtins/language/decimals.d.ts.map +1 -0
  92. package/dist/{scripting → functions}/builtins/language/decimals.js.map +1 -1
  93. package/dist/functions/builtins/language/index.d.ts +3 -0
  94. package/dist/functions/builtins/language/index.d.ts.map +1 -0
  95. package/dist/functions/builtins/language/index.js.map +1 -0
  96. package/dist/functions/builtins/language/loops.d.ts +4 -0
  97. package/dist/{scripting → functions}/builtins/language/loops.d.ts.map +1 -1
  98. package/dist/{scripting → functions}/builtins/language/loops.js +3 -3
  99. package/dist/{scripting → functions}/builtins/language/loops.js.map +1 -1
  100. package/dist/functions/builtins/language/numbers.d.ts +2 -0
  101. package/dist/functions/builtins/language/numbers.d.ts.map +1 -0
  102. package/dist/{scripting → functions}/builtins/language/numbers.js.map +1 -1
  103. package/dist/{scripting → functions}/builtins/language/objects.d.ts +1 -1
  104. package/dist/{scripting → functions}/builtins/language/objects.d.ts.map +1 -1
  105. package/dist/{scripting → functions}/builtins/language/objects.js.map +1 -1
  106. package/dist/functions/builtins/language/regex.d.ts +2 -0
  107. package/dist/functions/builtins/language/regex.d.ts.map +1 -0
  108. package/dist/{scripting → functions}/builtins/language/regex.js +1 -1
  109. package/dist/{scripting → functions}/builtins/language/regex.js.map +1 -1
  110. package/dist/functions/builtins/language/sort.d.ts +2 -0
  111. package/dist/functions/builtins/language/sort.d.ts.map +1 -0
  112. package/dist/{scripting → functions}/builtins/language/sort.js.map +1 -1
  113. package/dist/{scripting → functions}/builtins/language/state.d.ts +1 -1
  114. package/dist/{scripting → functions}/builtins/language/state.d.ts.map +1 -1
  115. package/dist/{scripting → functions}/builtins/language/state.js.map +1 -1
  116. package/dist/functions/builtins/language/texts.d.ts +2 -0
  117. package/dist/functions/builtins/language/texts.d.ts.map +1 -0
  118. package/dist/{scripting → functions}/builtins/language/texts.js.map +1 -1
  119. package/dist/functions/builtins/messages.d.ts +2 -0
  120. package/dist/functions/builtins/messages.d.ts.map +1 -0
  121. package/dist/{scripting → functions}/builtins/messages.js.map +1 -1
  122. package/dist/functions/builtins/moderation.d.ts +2 -0
  123. package/dist/functions/builtins/moderation.d.ts.map +1 -0
  124. package/dist/{scripting → functions}/builtins/moderation.js.map +1 -1
  125. package/dist/functions/builtins/native-channels.d.ts +2 -0
  126. package/dist/functions/builtins/native-channels.d.ts.map +1 -0
  127. package/dist/{scripting → functions}/builtins/native-channels.js.map +1 -1
  128. package/dist/functions/builtins/native-collectors.d.ts +2 -0
  129. package/dist/functions/builtins/native-collectors.d.ts.map +1 -0
  130. package/dist/{scripting → functions}/builtins/native-collectors.js.map +1 -1
  131. package/dist/functions/builtins/native-expressions.d.ts +2 -0
  132. package/dist/functions/builtins/native-expressions.d.ts.map +1 -0
  133. package/dist/{scripting → functions}/builtins/native-expressions.js.map +1 -1
  134. package/dist/functions/builtins/native-invites.d.ts +2 -0
  135. package/dist/functions/builtins/native-invites.d.ts.map +1 -0
  136. package/dist/{scripting → functions}/builtins/native-invites.js.map +1 -1
  137. package/dist/functions/builtins/native-messages.d.ts +2 -0
  138. package/dist/functions/builtins/native-messages.d.ts.map +1 -0
  139. package/dist/{scripting → functions}/builtins/native-messages.js.map +1 -1
  140. package/dist/functions/builtins/native-roles.d.ts +2 -0
  141. package/dist/functions/builtins/native-roles.d.ts.map +1 -0
  142. package/dist/{scripting → functions}/builtins/native-roles.js.map +1 -1
  143. package/dist/functions/builtins/native-threads.d.ts +2 -0
  144. package/dist/functions/builtins/native-threads.d.ts.map +1 -0
  145. package/dist/{scripting → functions}/builtins/native-threads.js.map +1 -1
  146. package/dist/functions/builtins/native-users.d.ts +2 -0
  147. package/dist/functions/builtins/native-users.d.ts.map +1 -0
  148. package/dist/{scripting → functions}/builtins/native-users.js.map +1 -1
  149. package/dist/functions/builtins/native-webhooks.d.ts +2 -0
  150. package/dist/functions/builtins/native-webhooks.d.ts.map +1 -0
  151. package/dist/{scripting → functions}/builtins/native-webhooks.js.map +1 -1
  152. package/dist/{scripting → functions}/builtins/payload.d.ts +2 -2
  153. package/dist/functions/builtins/payload.d.ts.map +1 -0
  154. package/dist/{scripting → functions}/builtins/payload.js +1 -1
  155. package/dist/functions/builtins/payload.js.map +1 -0
  156. package/dist/functions/builtins/resource-extras.d.ts +2 -0
  157. package/dist/functions/builtins/resource-extras.d.ts.map +1 -0
  158. package/dist/{scripting → functions}/builtins/resource-extras.js.map +1 -1
  159. package/dist/functions/builtins/schedule.d.ts +2 -0
  160. package/dist/functions/builtins/schedule.d.ts.map +1 -0
  161. package/dist/{scripting → functions}/builtins/schedule.js.map +1 -1
  162. package/dist/functions/builtins/storage.d.ts +2 -0
  163. package/dist/functions/builtins/storage.d.ts.map +1 -0
  164. package/dist/{scripting → functions}/builtins/storage.js.map +1 -1
  165. package/dist/functions/builtins/values.d.ts +2 -0
  166. package/dist/functions/builtins/values.d.ts.map +1 -0
  167. package/dist/{scripting → functions}/builtins/values.js +1 -1
  168. package/dist/functions/builtins/values.js.map +1 -0
  169. package/dist/functions/runtime/ast.d.ts.map +1 -0
  170. package/dist/functions/runtime/ast.js.map +1 -0
  171. package/dist/{scripting → functions/runtime}/canvas-execution.d.ts +1 -1
  172. package/dist/functions/runtime/canvas-execution.d.ts.map +1 -0
  173. package/dist/functions/runtime/canvas-execution.js.map +1 -0
  174. package/dist/functions/runtime/control-flow.d.ts.map +1 -0
  175. package/dist/functions/runtime/control-flow.js.map +1 -0
  176. package/dist/{scripting → functions/runtime}/evaluator.d.ts +1 -1
  177. package/dist/functions/runtime/evaluator.d.ts.map +1 -0
  178. package/dist/{scripting → functions/runtime}/evaluator.js +1 -1
  179. package/dist/functions/runtime/evaluator.js.map +1 -0
  180. package/dist/functions/runtime/limits.d.ts.map +1 -0
  181. package/dist/{scripting → functions/runtime}/limits.js +1 -1
  182. package/dist/functions/runtime/limits.js.map +1 -0
  183. package/dist/functions/runtime/parser.d.ts.map +1 -0
  184. package/dist/{scripting → functions/runtime}/parser.js +1 -1
  185. package/dist/functions/runtime/parser.js.map +1 -0
  186. package/dist/functions/runtime/regex.d.ts.map +1 -0
  187. package/dist/{scripting → functions/runtime}/regex.js +1 -1
  188. package/dist/functions/runtime/regex.js.map +1 -0
  189. package/dist/functions/runtime/registry.d.ts.map +1 -0
  190. package/dist/{scripting → functions/runtime}/registry.js +1 -1
  191. package/dist/functions/runtime/registry.js.map +1 -0
  192. package/dist/{scripting → functions/runtime}/runtime.d.ts +3 -1
  193. package/dist/functions/runtime/runtime.d.ts.map +1 -0
  194. package/dist/{scripting → functions/runtime}/runtime.js +3 -0
  195. package/dist/functions/runtime/runtime.js.map +1 -0
  196. package/dist/{scripting → functions/runtime}/types.d.ts +1 -1
  197. package/dist/functions/runtime/types.d.ts.map +1 -0
  198. package/dist/functions/runtime/types.js.map +1 -0
  199. package/dist/functions/runtime/values.d.ts.map +1 -0
  200. package/dist/functions/runtime/values.js.map +1 -0
  201. package/dist/functions.d.ts +19 -8
  202. package/dist/functions.d.ts.map +1 -1
  203. package/dist/functions.js +18 -6
  204. package/dist/functions.js.map +1 -1
  205. package/dist/index.d.ts +7 -2
  206. package/dist/index.d.ts.map +1 -1
  207. package/dist/index.js.map +1 -1
  208. package/dist/infrastructure/canvas/napi.d.ts +4 -0
  209. package/dist/infrastructure/canvas/napi.d.ts.map +1 -0
  210. package/dist/infrastructure/canvas/napi.js +17 -0
  211. package/dist/infrastructure/canvas/napi.js.map +1 -0
  212. package/dist/infrastructure/fluxer/resources/cache.d.ts +4 -0
  213. package/dist/infrastructure/fluxer/resources/cache.d.ts.map +1 -0
  214. package/dist/infrastructure/fluxer/resources/cache.js +68 -0
  215. package/dist/infrastructure/fluxer/resources/cache.js.map +1 -0
  216. package/dist/infrastructure/fluxer/resources/channels.d.ts +3 -2
  217. package/dist/infrastructure/fluxer/resources/channels.d.ts.map +1 -1
  218. package/dist/infrastructure/fluxer/resources/channels.js +54 -2
  219. package/dist/infrastructure/fluxer/resources/channels.js.map +1 -1
  220. package/dist/infrastructure/fluxer/resources/collectors.d.ts.map +1 -1
  221. package/dist/infrastructure/fluxer/resources/collectors.js +86 -4
  222. package/dist/infrastructure/fluxer/resources/collectors.js.map +1 -1
  223. package/dist/infrastructure/fluxer/resources/expressions.d.ts.map +1 -1
  224. package/dist/infrastructure/fluxer/resources/expressions.js +8 -1
  225. package/dist/infrastructure/fluxer/resources/expressions.js.map +1 -1
  226. package/dist/infrastructure/fluxer/resources/gateway.d.ts +4 -0
  227. package/dist/infrastructure/fluxer/resources/gateway.d.ts.map +1 -0
  228. package/dist/infrastructure/fluxer/resources/gateway.js +31 -0
  229. package/dist/infrastructure/fluxer/resources/gateway.js.map +1 -0
  230. package/dist/infrastructure/fluxer/resources/instance.d.ts +4 -0
  231. package/dist/infrastructure/fluxer/resources/instance.d.ts.map +1 -0
  232. package/dist/infrastructure/fluxer/resources/instance.js +96 -0
  233. package/dist/infrastructure/fluxer/resources/instance.js.map +1 -0
  234. package/dist/infrastructure/fluxer/resources/messages.d.ts +3 -1
  235. package/dist/infrastructure/fluxer/resources/messages.d.ts.map +1 -1
  236. package/dist/infrastructure/fluxer/resources/messages.js +91 -36
  237. package/dist/infrastructure/fluxer/resources/messages.js.map +1 -1
  238. package/dist/infrastructure/fluxer/resources/roles.d.ts.map +1 -1
  239. package/dist/infrastructure/fluxer/resources/roles.js +8 -0
  240. package/dist/infrastructure/fluxer/resources/roles.js.map +1 -1
  241. package/dist/infrastructure/fluxer/resources/self.d.ts +4 -0
  242. package/dist/infrastructure/fluxer/resources/self.d.ts.map +1 -0
  243. package/dist/infrastructure/fluxer/resources/self.js +36 -0
  244. package/dist/infrastructure/fluxer/resources/self.js.map +1 -0
  245. package/dist/infrastructure/fluxer/resources/threads.d.ts.map +1 -1
  246. package/dist/infrastructure/fluxer/resources/threads.js +15 -0
  247. package/dist/infrastructure/fluxer/resources/threads.js.map +1 -1
  248. package/dist/infrastructure/fluxer/resources/users.d.ts +5 -2
  249. package/dist/infrastructure/fluxer/resources/users.d.ts.map +1 -1
  250. package/dist/infrastructure/fluxer/resources/users.js +36 -3
  251. package/dist/infrastructure/fluxer/resources/users.js.map +1 -1
  252. package/dist/infrastructure/fluxer/resources/webhooks.d.ts.map +1 -1
  253. package/dist/infrastructure/fluxer/resources/webhooks.js +9 -0
  254. package/dist/infrastructure/fluxer/resources/webhooks.js.map +1 -1
  255. package/dist/infrastructure/fluxer/resources.d.ts +4 -0
  256. package/dist/infrastructure/fluxer/resources.d.ts.map +1 -1
  257. package/dist/infrastructure/fluxer/resources.js +12 -0
  258. package/dist/infrastructure/fluxer/resources.js.map +1 -1
  259. package/dist/ports/resources/cache.d.ts +74 -0
  260. package/dist/ports/resources/cache.d.ts.map +1 -0
  261. package/dist/ports/resources/cache.js +2 -0
  262. package/dist/ports/resources/cache.js.map +1 -0
  263. package/dist/ports/resources/channels.d.ts +17 -0
  264. package/dist/ports/resources/channels.d.ts.map +1 -1
  265. package/dist/ports/resources/channels.js.map +1 -1
  266. package/dist/ports/resources/collectors.d.ts +18 -0
  267. package/dist/ports/resources/collectors.d.ts.map +1 -1
  268. package/dist/ports/resources/collectors.js.map +1 -1
  269. package/dist/ports/resources/common.d.ts +2 -0
  270. package/dist/ports/resources/common.d.ts.map +1 -1
  271. package/dist/ports/resources/common.js.map +1 -1
  272. package/dist/ports/resources/expressions.d.ts +8 -0
  273. package/dist/ports/resources/expressions.d.ts.map +1 -1
  274. package/dist/ports/resources/expressions.js.map +1 -1
  275. package/dist/ports/resources/gateway.d.ts +48 -0
  276. package/dist/ports/resources/gateway.d.ts.map +1 -0
  277. package/dist/ports/resources/gateway.js +2 -0
  278. package/dist/ports/resources/gateway.js.map +1 -0
  279. package/dist/ports/resources/instance.d.ts +101 -0
  280. package/dist/ports/resources/instance.d.ts.map +1 -0
  281. package/dist/ports/resources/instance.js +2 -0
  282. package/dist/ports/resources/instance.js.map +1 -0
  283. package/dist/ports/resources/messages.d.ts +27 -0
  284. package/dist/ports/resources/messages.d.ts.map +1 -1
  285. package/dist/ports/resources/messages.js.map +1 -1
  286. package/dist/ports/resources/roles.d.ts +6 -0
  287. package/dist/ports/resources/roles.d.ts.map +1 -1
  288. package/dist/ports/resources/roles.js.map +1 -1
  289. package/dist/ports/resources/self.d.ts +30 -0
  290. package/dist/ports/resources/self.d.ts.map +1 -0
  291. package/dist/ports/resources/self.js +2 -0
  292. package/dist/ports/resources/self.js.map +1 -0
  293. package/dist/ports/resources/threads.d.ts +16 -0
  294. package/dist/ports/resources/threads.d.ts.map +1 -1
  295. package/dist/ports/resources/threads.js.map +1 -1
  296. package/dist/ports/resources/users.d.ts +30 -0
  297. package/dist/ports/resources/users.d.ts.map +1 -1
  298. package/dist/ports/resources/users.js.map +1 -1
  299. package/dist/ports/resources/webhooks.d.ts +5 -0
  300. package/dist/ports/resources/webhooks.d.ts.map +1 -1
  301. package/dist/ports/resources/webhooks.js.map +1 -1
  302. package/dist/ports/resources.d.ts +8 -0
  303. package/dist/ports/resources.d.ts.map +1 -1
  304. package/dist/ports/resources.js.map +1 -1
  305. package/dist/ports/script-engine.d.ts +45 -0
  306. package/dist/ports/script-engine.d.ts.map +1 -0
  307. package/dist/ports/script-engine.js +2 -0
  308. package/dist/ports/script-engine.js.map +1 -0
  309. package/dist/sdk/builders.d.ts +2 -0
  310. package/dist/sdk/builders.d.ts.map +1 -0
  311. package/dist/sdk/builders.js +2 -0
  312. package/dist/sdk/builders.js.map +1 -0
  313. package/dist/sdk/client.d.ts +2 -0
  314. package/dist/sdk/client.d.ts.map +1 -0
  315. package/dist/sdk/client.js +2 -0
  316. package/dist/sdk/client.js.map +1 -0
  317. package/dist/sdk/cluster.d.ts +2 -0
  318. package/dist/sdk/cluster.d.ts.map +1 -0
  319. package/dist/sdk/cluster.js +2 -0
  320. package/dist/sdk/cluster.js.map +1 -0
  321. package/dist/sdk/collection.d.ts +2 -0
  322. package/dist/sdk/collection.d.ts.map +1 -0
  323. package/dist/sdk/collection.js +2 -0
  324. package/dist/sdk/collection.js.map +1 -0
  325. package/dist/sdk/errors.d.ts +2 -0
  326. package/dist/sdk/errors.d.ts.map +1 -0
  327. package/dist/sdk/errors.js +2 -0
  328. package/dist/sdk/errors.js.map +1 -0
  329. package/dist/sdk/internal.d.ts +2 -0
  330. package/dist/sdk/internal.d.ts.map +1 -0
  331. package/dist/sdk/internal.js +2 -0
  332. package/dist/sdk/internal.js.map +1 -0
  333. package/dist/sdk/message.d.ts +2 -0
  334. package/dist/sdk/message.d.ts.map +1 -0
  335. package/dist/sdk/message.js +2 -0
  336. package/dist/sdk/message.js.map +1 -0
  337. package/dist/sdk/rest/request-manager.d.ts +2 -0
  338. package/dist/sdk/rest/request-manager.d.ts.map +1 -0
  339. package/dist/sdk/rest/request-manager.js +2 -0
  340. package/dist/sdk/rest/request-manager.js.map +1 -0
  341. package/dist/sdk/rest.d.ts +2 -0
  342. package/dist/sdk/rest.d.ts.map +1 -0
  343. package/dist/sdk/rest.js +2 -0
  344. package/dist/sdk/rest.js.map +1 -0
  345. package/dist/sdk/sharding.d.ts +2 -0
  346. package/dist/sdk/sharding.d.ts.map +1 -0
  347. package/dist/sdk/sharding.js +2 -0
  348. package/dist/sdk/sharding.js.map +1 -0
  349. package/dist/sdk/types/routes.d.ts +2 -0
  350. package/dist/sdk/types/routes.d.ts.map +1 -0
  351. package/dist/sdk/types/routes.js +2 -0
  352. package/dist/sdk/types/routes.js.map +1 -0
  353. package/dist/sdk/types.d.ts +2 -0
  354. package/dist/sdk/types.d.ts.map +1 -0
  355. package/dist/sdk/types.js +2 -0
  356. package/dist/sdk/types.js.map +1 -0
  357. package/dist/sdk/util.d.ts +2 -0
  358. package/dist/sdk/util.d.ts.map +1 -0
  359. package/dist/sdk/util.js +2 -0
  360. package/dist/sdk/util.js.map +1 -0
  361. package/dist/sdk/voice.d.ts +2 -0
  362. package/dist/sdk/voice.d.ts.map +1 -0
  363. package/dist/sdk/voice.js +2 -0
  364. package/dist/sdk/voice.js.map +1 -0
  365. package/dist/sdk/ws.d.ts +2 -0
  366. package/dist/sdk/ws.d.ts.map +1 -0
  367. package/dist/sdk/ws.js +2 -0
  368. package/dist/sdk/ws.js.map +1 -0
  369. package/dist/services/canvas-image.d.ts +12 -0
  370. package/dist/services/canvas-image.d.ts.map +1 -0
  371. package/dist/services/canvas-image.js +56 -0
  372. package/dist/services/canvas-image.js.map +1 -0
  373. package/dist/services/canvas.d.ts +12 -2
  374. package/dist/services/canvas.d.ts.map +1 -1
  375. package/dist/services/canvas.js +91 -5
  376. package/dist/services/canvas.js.map +1 -1
  377. package/dist/services/moderation.d.ts +1 -0
  378. package/dist/services/moderation.d.ts.map +1 -1
  379. package/dist/services/moderation.js +11 -0
  380. package/dist/services/moderation.js.map +1 -1
  381. package/dist/services/native-moderation.d.ts +6 -1
  382. package/dist/services/native-moderation.d.ts.map +1 -1
  383. package/dist/services/native-moderation.js +11 -1
  384. package/dist/services/native-moderation.js.map +1 -1
  385. package/dist/services/resource-authorization.d.ts.map +1 -1
  386. package/dist/services/resource-authorization.js +95 -3
  387. package/dist/services/resource-authorization.js.map +1 -1
  388. package/dist/testing.d.ts.map +1 -1
  389. package/dist/testing.js +4 -0
  390. package/dist/testing.js.map +1 -1
  391. package/docs/API.md +8 -7
  392. package/docs/ARCHITECTURE.md +14 -9
  393. package/docs/BENCHMARKS.md +1 -1
  394. package/docs/CANVAS.md +70 -15
  395. package/docs/EDITOR.md +1 -1
  396. package/docs/FRAMEWORK.md +2 -3
  397. package/docs/HTTP.md +1 -1
  398. package/docs/IMAGES.md +2 -1
  399. package/docs/NATIVE.md +45 -14
  400. package/docs/PARITY-MATRIX.md +853 -843
  401. package/docs/PARITY.md +24 -12
  402. package/docs/PLAN.md +14 -3
  403. package/docs/QUICKSTART.md +5 -5
  404. package/docs/README.md +7 -7
  405. package/docs/REPOSITORY.md +1 -1
  406. package/docs/SCHEDULER.md +1 -1
  407. package/docs/TROUBLESHOOTING.md +1 -1
  408. package/docs/VALIDATION.md +5 -5
  409. package/docs/{FUNCTION-GAPS.md → functions/FUNCTION-GAPS.md} +18 -13
  410. package/docs/{LANGUAGE.md → functions/LANGUAGE.md} +7 -7
  411. package/docs/functions/README.md +33 -0
  412. package/docs/tutorials/DATA.md +2 -2
  413. package/docs/tutorials/FUNCTION-MODE.md +2 -2
  414. package/examples/canvas/napi-style.ts +24 -0
  415. package/examples/canvas/output/napi-style.png +0 -0
  416. package/examples/canvas/profile.d.mts +1 -1
  417. package/examples/canvas/profile.mjs +2 -2
  418. package/examples/canvas/profile.ts +3 -3
  419. package/examples/canvas/ranking.d.mts +1 -1
  420. package/examples/canvas/ranking.mjs +2 -2
  421. package/examples/canvas/ranking.ts +3 -3
  422. package/examples/canvas/render.ts +2 -1
  423. package/examples/canvas/welcome.d.mts +1 -1
  424. package/examples/canvas/welcome.mjs +2 -2
  425. package/examples/canvas/welcome.ts +3 -3
  426. package/examples/embeds/complete-embed-functions.ts +2 -2
  427. package/examples/function-mode.ts +3 -3
  428. package/examples/yuzuha.config.js +2 -0
  429. package/package.json +26 -1
  430. package/src/canvas/card.ts +20 -0
  431. package/src/canvas.ts +69 -17
  432. package/src/cli/config.ts +2 -1
  433. package/src/cli/lint.ts +1 -2
  434. package/src/cli/main.ts +8 -9
  435. package/src/cli/scaffold.ts +1 -1
  436. package/src/cli/scenarios.ts +2 -1
  437. package/src/commands/context.ts +9 -2
  438. package/src/domain/resource-batches.ts +31 -0
  439. package/src/framework/bot.ts +44 -27
  440. package/src/framework/command-registry.ts +15 -10
  441. package/src/framework/options.ts +3 -3
  442. package/src/{scripting → functions}/builtins/canvas.ts +2 -2
  443. package/src/{scripting → functions}/builtins/context.ts +1 -1
  444. package/src/{scripting → functions}/builtins/definition.ts +1 -1
  445. package/src/{scripting → functions}/builtins/embeds.ts +1 -1
  446. package/src/{scripting → functions}/builtins/flow.ts +2 -2
  447. package/src/{scripting → functions}/builtins/guards.ts +1 -1
  448. package/src/{scripting → functions}/builtins/http.ts +2 -2
  449. package/src/{scripting → functions}/builtins/index.ts +2 -2
  450. package/src/{scripting → functions}/builtins/language/array-callbacks.ts +2 -2
  451. package/src/{scripting → functions}/builtins/language/arrays.ts +1 -1
  452. package/src/{scripting → functions}/builtins/language/index.ts +1 -1
  453. package/src/{scripting → functions}/builtins/language/loops.ts +4 -4
  454. package/src/{scripting → functions}/builtins/language/regex.ts +1 -1
  455. package/src/{scripting → functions}/builtins/moderation.ts +1 -1
  456. package/src/{scripting → functions}/builtins/native-channels.ts +1 -1
  457. package/src/{scripting → functions}/builtins/native-roles.ts +1 -1
  458. package/src/{scripting → functions}/builtins/native-users.ts +1 -1
  459. package/src/{scripting → functions}/builtins/payload.ts +2 -2
  460. package/src/{scripting → functions}/builtins/resource-extras.ts +1 -1
  461. package/src/{scripting → functions}/builtins/values.ts +1 -1
  462. package/src/{scripting → functions/runtime}/canvas-execution.ts +1 -1
  463. package/src/{scripting → functions/runtime}/evaluator.ts +2 -2
  464. package/src/{scripting → functions/runtime}/limits.ts +1 -1
  465. package/src/{scripting → functions/runtime}/parser.ts +1 -1
  466. package/src/{scripting → functions/runtime}/regex.ts +1 -1
  467. package/src/{scripting → functions/runtime}/registry.ts +1 -1
  468. package/src/{scripting → functions/runtime}/runtime.ts +6 -1
  469. package/src/{scripting → functions/runtime}/types.ts +1 -1
  470. package/src/functions.ts +28 -8
  471. package/src/index.ts +9 -2
  472. package/src/infrastructure/canvas/napi.ts +17 -0
  473. package/src/infrastructure/fluxer/resources/cache.ts +69 -0
  474. package/src/infrastructure/fluxer/resources/channels.ts +51 -3
  475. package/src/infrastructure/fluxer/resources/collectors.ts +87 -4
  476. package/src/infrastructure/fluxer/resources/expressions.ts +7 -1
  477. package/src/infrastructure/fluxer/resources/gateway.ts +33 -0
  478. package/src/infrastructure/fluxer/resources/instance.ts +105 -0
  479. package/src/infrastructure/fluxer/resources/messages.ts +84 -36
  480. package/src/infrastructure/fluxer/resources/roles.ts +8 -0
  481. package/src/infrastructure/fluxer/resources/self.ts +39 -0
  482. package/src/infrastructure/fluxer/resources/threads.ts +14 -0
  483. package/src/infrastructure/fluxer/resources/users.ts +40 -4
  484. package/src/infrastructure/fluxer/resources/webhooks.ts +9 -0
  485. package/src/infrastructure/fluxer/resources.ts +12 -0
  486. package/src/ports/resources/cache.ts +81 -0
  487. package/src/ports/resources/channels.ts +12 -0
  488. package/src/ports/resources/collectors.ts +20 -0
  489. package/src/ports/resources/common.ts +2 -0
  490. package/src/ports/resources/expressions.ts +6 -0
  491. package/src/ports/resources/gateway.ts +49 -0
  492. package/src/ports/resources/instance.ts +109 -0
  493. package/src/ports/resources/messages.ts +30 -0
  494. package/src/ports/resources/roles.ts +3 -0
  495. package/src/ports/resources/self.ts +30 -0
  496. package/src/ports/resources/threads.ts +15 -0
  497. package/src/ports/resources/users.ts +33 -0
  498. package/src/ports/resources/webhooks.ts +6 -0
  499. package/src/ports/resources.ts +8 -0
  500. package/src/ports/script-engine.ts +42 -0
  501. package/src/sdk/builders.ts +1 -0
  502. package/src/sdk/client.ts +1 -0
  503. package/src/sdk/cluster.ts +1 -0
  504. package/src/sdk/collection.ts +1 -0
  505. package/src/sdk/errors.ts +1 -0
  506. package/src/sdk/internal.ts +1 -0
  507. package/src/sdk/message.ts +1 -0
  508. package/src/sdk/rest/request-manager.ts +1 -0
  509. package/src/sdk/rest.ts +1 -0
  510. package/src/sdk/sharding.ts +1 -0
  511. package/src/sdk/types/routes.ts +1 -0
  512. package/src/sdk/types.ts +1 -0
  513. package/src/sdk/util.ts +1 -0
  514. package/src/sdk/voice.ts +1 -0
  515. package/src/sdk/ws.ts +1 -0
  516. package/src/services/canvas-image.ts +54 -0
  517. package/src/services/canvas.ts +89 -6
  518. package/src/services/moderation.ts +4 -0
  519. package/src/services/native-moderation.ts +11 -1
  520. package/src/services/resource-authorization.ts +89 -3
  521. package/src/testing.ts +4 -0
  522. package/dist/parser.d.ts +0 -3
  523. package/dist/parser.d.ts.map +0 -1
  524. package/dist/parser.js +0 -2
  525. package/dist/parser.js.map +0 -1
  526. package/dist/runtime.d.ts +0 -5
  527. package/dist/runtime.d.ts.map +0 -1
  528. package/dist/runtime.js +0 -4
  529. package/dist/runtime.js.map +0 -1
  530. package/dist/scripting/ast.d.ts.map +0 -1
  531. package/dist/scripting/ast.js.map +0 -1
  532. package/dist/scripting/builtins/canvas.d.ts +0 -2
  533. package/dist/scripting/builtins/canvas.d.ts.map +0 -1
  534. package/dist/scripting/builtins/context.d.ts +0 -2
  535. package/dist/scripting/builtins/context.d.ts.map +0 -1
  536. package/dist/scripting/builtins/definition.d.ts.map +0 -1
  537. package/dist/scripting/builtins/definition.js.map +0 -1
  538. package/dist/scripting/builtins/embeds.d.ts +0 -3
  539. package/dist/scripting/builtins/embeds.js.map +0 -1
  540. package/dist/scripting/builtins/events.d.ts +0 -2
  541. package/dist/scripting/builtins/events.d.ts.map +0 -1
  542. package/dist/scripting/builtins/flow.d.ts +0 -2
  543. package/dist/scripting/builtins/flow.d.ts.map +0 -1
  544. package/dist/scripting/builtins/flow.js.map +0 -1
  545. package/dist/scripting/builtins/guards.d.ts +0 -2
  546. package/dist/scripting/builtins/guards.d.ts.map +0 -1
  547. package/dist/scripting/builtins/guards.js.map +0 -1
  548. package/dist/scripting/builtins/http.d.ts +0 -2
  549. package/dist/scripting/builtins/http.d.ts.map +0 -1
  550. package/dist/scripting/builtins/http.js.map +0 -1
  551. package/dist/scripting/builtins/index.d.ts +0 -5
  552. package/dist/scripting/builtins/index.d.ts.map +0 -1
  553. package/dist/scripting/builtins/index.js.map +0 -1
  554. package/dist/scripting/builtins/language/array-callbacks.d.ts +0 -2
  555. package/dist/scripting/builtins/language/array-callbacks.d.ts.map +0 -1
  556. package/dist/scripting/builtins/language/arrays.d.ts +0 -2
  557. package/dist/scripting/builtins/language/arrays.d.ts.map +0 -1
  558. package/dist/scripting/builtins/language/decimals.d.ts +0 -2
  559. package/dist/scripting/builtins/language/decimals.d.ts.map +0 -1
  560. package/dist/scripting/builtins/language/index.d.ts +0 -3
  561. package/dist/scripting/builtins/language/index.d.ts.map +0 -1
  562. package/dist/scripting/builtins/language/index.js.map +0 -1
  563. package/dist/scripting/builtins/language/loops.d.ts +0 -4
  564. package/dist/scripting/builtins/language/numbers.d.ts +0 -2
  565. package/dist/scripting/builtins/language/numbers.d.ts.map +0 -1
  566. package/dist/scripting/builtins/language/regex.d.ts +0 -2
  567. package/dist/scripting/builtins/language/regex.d.ts.map +0 -1
  568. package/dist/scripting/builtins/language/sort.d.ts +0 -2
  569. package/dist/scripting/builtins/language/sort.d.ts.map +0 -1
  570. package/dist/scripting/builtins/language/texts.d.ts +0 -2
  571. package/dist/scripting/builtins/language/texts.d.ts.map +0 -1
  572. package/dist/scripting/builtins/messages.d.ts +0 -2
  573. package/dist/scripting/builtins/messages.d.ts.map +0 -1
  574. package/dist/scripting/builtins/moderation.d.ts +0 -2
  575. package/dist/scripting/builtins/moderation.d.ts.map +0 -1
  576. package/dist/scripting/builtins/native-channels.d.ts +0 -2
  577. package/dist/scripting/builtins/native-channels.d.ts.map +0 -1
  578. package/dist/scripting/builtins/native-collectors.d.ts +0 -2
  579. package/dist/scripting/builtins/native-collectors.d.ts.map +0 -1
  580. package/dist/scripting/builtins/native-expressions.d.ts +0 -2
  581. package/dist/scripting/builtins/native-expressions.d.ts.map +0 -1
  582. package/dist/scripting/builtins/native-invites.d.ts +0 -2
  583. package/dist/scripting/builtins/native-invites.d.ts.map +0 -1
  584. package/dist/scripting/builtins/native-messages.d.ts +0 -2
  585. package/dist/scripting/builtins/native-messages.d.ts.map +0 -1
  586. package/dist/scripting/builtins/native-roles.d.ts +0 -2
  587. package/dist/scripting/builtins/native-roles.d.ts.map +0 -1
  588. package/dist/scripting/builtins/native-threads.d.ts +0 -2
  589. package/dist/scripting/builtins/native-threads.d.ts.map +0 -1
  590. package/dist/scripting/builtins/native-users.d.ts +0 -2
  591. package/dist/scripting/builtins/native-users.d.ts.map +0 -1
  592. package/dist/scripting/builtins/native-webhooks.d.ts +0 -2
  593. package/dist/scripting/builtins/native-webhooks.d.ts.map +0 -1
  594. package/dist/scripting/builtins/payload.d.ts.map +0 -1
  595. package/dist/scripting/builtins/payload.js.map +0 -1
  596. package/dist/scripting/builtins/resource-extras.d.ts +0 -2
  597. package/dist/scripting/builtins/resource-extras.d.ts.map +0 -1
  598. package/dist/scripting/builtins/schedule.d.ts +0 -2
  599. package/dist/scripting/builtins/schedule.d.ts.map +0 -1
  600. package/dist/scripting/builtins/storage.d.ts +0 -2
  601. package/dist/scripting/builtins/storage.d.ts.map +0 -1
  602. package/dist/scripting/builtins/values.d.ts +0 -2
  603. package/dist/scripting/builtins/values.d.ts.map +0 -1
  604. package/dist/scripting/builtins/values.js.map +0 -1
  605. package/dist/scripting/canvas-execution.d.ts.map +0 -1
  606. package/dist/scripting/canvas-execution.js.map +0 -1
  607. package/dist/scripting/control-flow.d.ts.map +0 -1
  608. package/dist/scripting/control-flow.js.map +0 -1
  609. package/dist/scripting/evaluator.d.ts.map +0 -1
  610. package/dist/scripting/evaluator.js.map +0 -1
  611. package/dist/scripting/limits.d.ts.map +0 -1
  612. package/dist/scripting/limits.js.map +0 -1
  613. package/dist/scripting/parser.d.ts.map +0 -1
  614. package/dist/scripting/parser.js.map +0 -1
  615. package/dist/scripting/regex.d.ts.map +0 -1
  616. package/dist/scripting/regex.js.map +0 -1
  617. package/dist/scripting/registry.d.ts.map +0 -1
  618. package/dist/scripting/registry.js.map +0 -1
  619. package/dist/scripting/runtime.d.ts.map +0 -1
  620. package/dist/scripting/runtime.js.map +0 -1
  621. package/dist/scripting/types.d.ts.map +0 -1
  622. package/dist/scripting/types.js.map +0 -1
  623. package/dist/scripting/values.d.ts.map +0 -1
  624. package/dist/scripting/values.js.map +0 -1
  625. package/src/parser.ts +0 -2
  626. package/src/runtime.ts +0 -4
  627. /package/dist/{scripting → functions}/builtins/arguments.d.ts +0 -0
  628. /package/dist/{scripting → functions}/builtins/arguments.js +0 -0
  629. /package/dist/{scripting → functions}/builtins/context.js +0 -0
  630. /package/dist/{scripting → functions}/builtins/definition.js +0 -0
  631. /package/dist/{scripting → functions}/builtins/events.js +0 -0
  632. /package/dist/{scripting → functions}/builtins/index.js +0 -0
  633. /package/dist/{scripting → functions}/builtins/language/common.d.ts +0 -0
  634. /package/dist/{scripting → functions}/builtins/language/common.js +0 -0
  635. /package/dist/{scripting → functions}/builtins/language/decimals.js +0 -0
  636. /package/dist/{scripting → functions}/builtins/language/index.js +0 -0
  637. /package/dist/{scripting → functions}/builtins/language/numbers.js +0 -0
  638. /package/dist/{scripting → functions}/builtins/language/objects.js +0 -0
  639. /package/dist/{scripting → functions}/builtins/language/sort.js +0 -0
  640. /package/dist/{scripting → functions}/builtins/language/state.js +0 -0
  641. /package/dist/{scripting → functions}/builtins/language/texts.js +0 -0
  642. /package/dist/{scripting → functions}/builtins/messages.js +0 -0
  643. /package/dist/{scripting → functions}/builtins/moderation.js +0 -0
  644. /package/dist/{scripting → functions}/builtins/native-channels.js +0 -0
  645. /package/dist/{scripting → functions}/builtins/native-collectors.js +0 -0
  646. /package/dist/{scripting → functions}/builtins/native-expressions.js +0 -0
  647. /package/dist/{scripting → functions}/builtins/native-invites.js +0 -0
  648. /package/dist/{scripting → functions}/builtins/native-messages.js +0 -0
  649. /package/dist/{scripting → functions}/builtins/native-roles.js +0 -0
  650. /package/dist/{scripting → functions}/builtins/native-threads.js +0 -0
  651. /package/dist/{scripting → functions}/builtins/native-users.js +0 -0
  652. /package/dist/{scripting → functions}/builtins/native-webhooks.js +0 -0
  653. /package/dist/{scripting → functions}/builtins/resource-extras.js +0 -0
  654. /package/dist/{scripting → functions}/builtins/schedule.js +0 -0
  655. /package/dist/{scripting → functions}/builtins/storage.js +0 -0
  656. /package/dist/{scripting → functions/runtime}/ast.d.ts +0 -0
  657. /package/dist/{scripting → functions/runtime}/ast.js +0 -0
  658. /package/dist/{scripting → functions/runtime}/canvas-execution.js +0 -0
  659. /package/dist/{scripting → functions/runtime}/control-flow.d.ts +0 -0
  660. /package/dist/{scripting → functions/runtime}/control-flow.js +0 -0
  661. /package/dist/{scripting → functions/runtime}/limits.d.ts +0 -0
  662. /package/dist/{scripting → functions/runtime}/parser.d.ts +0 -0
  663. /package/dist/{scripting → functions/runtime}/regex-worker.mjs +0 -0
  664. /package/dist/{scripting → functions/runtime}/regex.d.ts +0 -0
  665. /package/dist/{scripting → functions/runtime}/registry.d.ts +0 -0
  666. /package/dist/{scripting → functions/runtime}/types.js +0 -0
  667. /package/dist/{scripting → functions/runtime}/values.d.ts +0 -0
  668. /package/dist/{scripting → functions/runtime}/values.js +0 -0
  669. /package/docs/{FUNCTIONS.md → functions/FUNCTIONS.md} +0 -0
  670. /package/docs/{LANGUAGE-EXTENSIONS.md → functions/LANGUAGE-EXTENSIONS.md} +0 -0
  671. /package/src/{scripting → functions}/builtins/arguments.ts +0 -0
  672. /package/src/{scripting → functions}/builtins/events.ts +0 -0
  673. /package/src/{scripting → functions}/builtins/language/common.ts +0 -0
  674. /package/src/{scripting → functions}/builtins/language/decimals.ts +0 -0
  675. /package/src/{scripting → functions}/builtins/language/numbers.ts +0 -0
  676. /package/src/{scripting → functions}/builtins/language/objects.ts +0 -0
  677. /package/src/{scripting → functions}/builtins/language/sort.ts +0 -0
  678. /package/src/{scripting → functions}/builtins/language/state.ts +0 -0
  679. /package/src/{scripting → functions}/builtins/language/texts.ts +0 -0
  680. /package/src/{scripting → functions}/builtins/messages.ts +0 -0
  681. /package/src/{scripting → functions}/builtins/native-collectors.ts +0 -0
  682. /package/src/{scripting → functions}/builtins/native-expressions.ts +0 -0
  683. /package/src/{scripting → functions}/builtins/native-invites.ts +0 -0
  684. /package/src/{scripting → functions}/builtins/native-messages.ts +0 -0
  685. /package/src/{scripting → functions}/builtins/native-threads.ts +0 -0
  686. /package/src/{scripting → functions}/builtins/native-webhooks.ts +0 -0
  687. /package/src/{scripting → functions}/builtins/schedule.ts +0 -0
  688. /package/src/{scripting → functions}/builtins/storage.ts +0 -0
  689. /package/src/{scripting → functions/runtime}/ast.ts +0 -0
  690. /package/src/{scripting → functions/runtime}/control-flow.ts +0 -0
  691. /package/src/{scripting → functions/runtime}/regex-worker.mjs +0 -0
  692. /package/src/{scripting → functions/runtime}/values.ts +0 -0
@@ -1,10 +1,12 @@
1
1
  import { defineConfig, defineEvent } from 'yuzuha';
2
+ import { functions } from 'yuzuha/functions';
2
3
  import { Events } from 'yuzuha/sdk';
3
4
 
4
5
  export default defineConfig({
5
6
  name: 'yuzuha-example',
6
7
  prefix: ['!', 'y!'],
7
8
  commands: './commands',
9
+ engine: functions(),
8
10
  setup(bot) {
9
11
  bot.plugin({
10
12
  name: 'greetings',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yuzuha",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Fluxer bots with simple scripts and typed JavaScript/TypeScript.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -26,6 +26,10 @@
26
26
  "types": "./dist/sdk.d.ts",
27
27
  "import": "./dist/sdk.js"
28
28
  },
29
+ "./sdk/*": {
30
+ "types": "./dist/sdk/*.d.ts",
31
+ "import": "./dist/sdk/*.js"
32
+ },
29
33
  "./testing": {
30
34
  "types": "./dist/testing.d.ts",
31
35
  "import": "./dist/testing.js"
@@ -49,6 +53,10 @@
49
53
  "./canvas": {
50
54
  "types": "./dist/canvas.d.ts",
51
55
  "import": "./dist/canvas.js"
56
+ },
57
+ "./canvas/card": {
58
+ "types": "./dist/canvas/card.d.ts",
59
+ "import": "./dist/canvas/card.js"
52
60
  }
53
61
  },
54
62
  "bin": {
@@ -93,11 +101,19 @@
93
101
  "package:editor": "node scripts/package-editor.mjs"
94
102
  },
95
103
  "dependencies": {
104
+ "@fluxerjs/builders": "3.0.0",
105
+ "@fluxerjs/collection": "3.0.0",
96
106
  "@fluxerjs/core": "3.3.0",
107
+ "@fluxerjs/rest": "3.1.0",
108
+ "@fluxerjs/types": "3.3.0",
109
+ "@fluxerjs/util": "3.1.0",
110
+ "@fluxerjs/ws": "3.1.0",
97
111
  "tsx": "^4.20.0",
98
112
  "ws": "^8.22.0"
99
113
  },
100
114
  "devDependencies": {
115
+ "@fluxerjs/sharding": "^3.0.0",
116
+ "@fluxerjs/voice": "^3.1.0",
101
117
  "@napi-rs/canvas": "1.0.13",
102
118
  "@types/node": "^22.0.0",
103
119
  "@types/vscode": "^1.140.0",
@@ -106,11 +122,15 @@
106
122
  "typescript": "^5.9.0"
107
123
  },
108
124
  "peerDependencies": {
125
+ "@fluxerjs/sharding": "^3.0.0",
109
126
  "@fluxerjs/voice": "^3.1.0",
110
127
  "@napi-rs/canvas": "^1.0.13",
111
128
  "sharp": "^0.35.5"
112
129
  },
113
130
  "peerDependenciesMeta": {
131
+ "@fluxerjs/sharding": {
132
+ "optional": true
133
+ },
114
134
  "@fluxerjs/voice": {
115
135
  "optional": true
116
136
  },
@@ -120,5 +140,10 @@
120
140
  "@napi-rs/canvas": {
121
141
  "optional": true
122
142
  }
143
+ },
144
+ "overrides": {
145
+ "@fluxerjs/sharding": {
146
+ "@fluxerjs/core": "3.3.0"
147
+ }
123
148
  }
124
149
  }
@@ -0,0 +1,20 @@
1
+ import { CANVAS_LIMITS } from '../domain/canvas.js';
2
+ import type { CanvasConfig, CanvasCreateOptions } from '../domain/canvas.js';
3
+ import { canvasRenderer } from '../infrastructure/canvas/render.js';
4
+ import { CanvasService } from '../services/canvas.js';
5
+ import type { CanvasBuilder, CanvasRuntimeOptions } from '../services/canvas.js';
6
+
7
+ export function createCard(
8
+ width: number,
9
+ height: number,
10
+ options: CanvasCreateOptions & CanvasRuntimeOptions = {},
11
+ ): CanvasBuilder {
12
+ const { scale, background, signal, http, assets, fonts, timeoutMs } = options;
13
+ const service = new CanvasService({ renderer: canvasRenderer, signal, http, assets, fonts, timeoutMs });
14
+ return service.create(width, height, { scale, background });
15
+ }
16
+
17
+ export { CanvasService };
18
+ export type { CanvasBuilder, CanvasRuntimeOptions, CanvasHostOptions, CanvasSendOptions } from '../services/canvas.js';
19
+ export type * from '../domain/canvas.js';
20
+ export { CANVAS_LIMITS };
package/src/canvas.ts CHANGED
@@ -1,20 +1,72 @@
1
1
  import { CANVAS_LIMITS } from './domain/canvas.js';
2
- import type { CanvasConfig, CanvasCreateOptions } from './domain/canvas.js';
3
- import { canvasRenderer } from './infrastructure/canvas/render.js';
4
- import { CanvasService } from './services/canvas.js';
5
- import type { CanvasBuilder, CanvasRuntimeOptions } from './services/canvas.js';
6
-
7
- export function createCanvas(
8
- width: number,
9
- height: number,
10
- options: CanvasCreateOptions & CanvasRuntimeOptions = {},
11
- ): CanvasBuilder {
12
- const { scale, background, signal, http, assets, fonts, timeoutMs } = options;
13
- const service = new CanvasService({ renderer: canvasRenderer, signal, http, assets, fonts, timeoutMs });
14
- return service.create(width, height, { scale, background });
2
+ import { canvasDependency, napi } from './infrastructure/canvas/napi.js';
3
+ import { loadCanvasImage, registerCanvasFonts } from './services/canvas-image.js';
4
+ import type { CanvasLoadImageOptions, CanvasLoadImageSource } from './services/canvas-image.js';
5
+ import { YuzuhaError } from './shared/errors.js';
6
+
7
+ export type { CanvasLoadImageOptions };
8
+ export type * from '@napi-rs/canvas';
9
+
10
+ const missing = () => new Proxy(function () { throw canvasDependency(); }, {
11
+ get(target, property) {
12
+ if (property === 'prototype') return target.prototype;
13
+ throw canvasDependency();
14
+ },
15
+ construct() { throw canvasDependency(); },
16
+ });
17
+
18
+ export const Canvas = (napi?.Canvas ?? missing()) as typeof import('@napi-rs/canvas').Canvas;
19
+ export const Image = (napi?.Image ?? missing()) as typeof import('@napi-rs/canvas').Image;
20
+ export const Path2D = (napi?.Path2D ?? missing()) as typeof import('@napi-rs/canvas').Path2D;
21
+ export const ImageData = (napi?.ImageData ?? missing()) as typeof import('@napi-rs/canvas').ImageData;
22
+ export const DOMMatrix = (napi?.DOMMatrix ?? missing()) as typeof import('@napi-rs/canvas').DOMMatrix;
23
+ export const DOMRect = (napi?.DOMRect ?? missing()) as typeof import('@napi-rs/canvas').DOMRect;
24
+ export const DOMPoint = (napi?.DOMPoint ?? missing()) as typeof import('@napi-rs/canvas').DOMPoint;
25
+ export const FontKey = (napi?.FontKey ?? missing()) as typeof import('@napi-rs/canvas').FontKey;
26
+ export const PDFDocument = (napi?.PDFDocument ?? missing()) as typeof import('@napi-rs/canvas').PDFDocument;
27
+ export const GifEncoder = (napi?.GifEncoder ?? missing()) as typeof import('@napi-rs/canvas').GifEncoder;
28
+ export const LottieAnimation = (napi?.LottieAnimation ?? missing()) as typeof import('@napi-rs/canvas').LottieAnimation;
29
+ export const GlobalFonts = (napi?.GlobalFonts ?? missing()) as typeof import('@napi-rs/canvas').GlobalFonts;
30
+ export const PathOp = (napi?.PathOp ?? missing()) as typeof import('@napi-rs/canvas').PathOp;
31
+ export const FillType = (napi?.FillType ?? missing()) as typeof import('@napi-rs/canvas').FillType;
32
+ export const StrokeCap = (napi?.StrokeCap ?? missing()) as typeof import('@napi-rs/canvas').StrokeCap;
33
+ export const StrokeJoin = (napi?.StrokeJoin ?? missing()) as typeof import('@napi-rs/canvas').StrokeJoin;
34
+ export const SvgExportFlag = (napi?.SvgExportFlag ?? missing()) as typeof import('@napi-rs/canvas').SvgExportFlag;
35
+ export const GifDisposal = (napi?.GifDisposal ?? missing()) as typeof import('@napi-rs/canvas').GifDisposal;
36
+ export const ChromaSubsampling = (napi?.ChromaSubsampling ?? missing()) as typeof import('@napi-rs/canvas').ChromaSubsampling;
37
+ export const SVGCanvas: any = (napi as any)?.SVGCanvas ?? missing();
38
+ export const CanvasElement: any = (napi as any)?.CanvasElement ?? missing();
39
+
40
+ export function createCanvas(width: number, height: number): import('@napi-rs/canvas').Canvas;
41
+ export function createCanvas(width: number, height: number, svgExportFlag: import('@napi-rs/canvas').SvgExportFlag): import('@napi-rs/canvas').SvgCanvas;
42
+ export function createCanvas(width: number, height: number, svgExportFlag?: import('@napi-rs/canvas').SvgExportFlag) {
43
+ if (!Number.isSafeInteger(width) || !Number.isSafeInteger(height) || width < 1 || height < 1) {
44
+ throw new YuzuhaError('CANVAS_OPTIONS', 'Largura e altura devem ser inteiros positivos.');
45
+ }
46
+ if (width > CANVAS_LIMITS.maxPhysicalDimension || height > CANVAS_LIMITS.maxPhysicalDimension
47
+ || width * height > CANVAS_LIMITS.maxPixels) {
48
+ throw new YuzuhaError('CANVAS_OPTIONS', 'Dimensões físicas excedem os limites do Canvas.');
49
+ }
50
+ if (!napi) throw canvasDependency();
51
+ return svgExportFlag === undefined ? napi.createCanvas(width, height) : napi.createCanvas(width, height, svgExportFlag);
52
+ }
53
+
54
+ export async function loadImage(source: CanvasLoadImageSource, options: CanvasLoadImageOptions = {}): Promise<import('@napi-rs/canvas').Image> {
55
+ if (!napi) throw canvasDependency();
56
+ return loadCanvasImage(napi, source, options);
15
57
  }
16
58
 
17
- export { CanvasService };
18
- export type { CanvasBuilder, CanvasRuntimeOptions, CanvasHostOptions, CanvasSendOptions } from './services/canvas.js';
19
- export type * from './domain/canvas.js';
20
- export { CANVAS_LIMITS };
59
+ export function clearAllCache(): void {
60
+ if (!napi) throw canvasDependency();
61
+ napi.clearAllCache();
62
+ }
63
+
64
+ export function convertSVGTextToPath(svg: Buffer | string): Buffer {
65
+ if (!napi) throw canvasDependency();
66
+ return napi.convertSVGTextToPath(svg);
67
+ }
68
+
69
+ export function registerFonts(dir: string): number {
70
+ if (!napi) throw canvasDependency();
71
+ return registerCanvasFonts(napi, dir);
72
+ }
package/src/cli/config.ts CHANGED
@@ -4,6 +4,7 @@ import { pathToFileURL } from 'node:url';
4
4
  import { parseEnv } from 'node:util';
5
5
  import { importModule } from '../framework/module-loader.js';
6
6
  import { Yuzuha } from '../bot.js';
7
+ import { functions } from '../functions.js';
7
8
  import type { YuzuhaConfig } from '../config.js';
8
9
  import { YuzuhaError } from '../errors.js';
9
10
 
@@ -33,7 +34,7 @@ export async function configuredBot(path: string, environment: boolean, loadComm
33
34
  if (!module.default || typeof module.default !== 'object' || Array.isArray(module.default)) throw new YuzuhaError('CONFIG_INVALID', 'Config deve exportar um objeto default.');
34
35
  const config = module.default as YuzuhaConfig;
35
36
  if ((config.commands !== undefined && typeof config.commands !== 'string') || (config.setup !== undefined && typeof config.setup !== 'function')) throw new YuzuhaError('CONFIG_INVALID', 'commands deve ser texto e setup deve ser uma função.');
36
- const bot = new Yuzuha(config);
37
+ const bot = new Yuzuha({ ...config, engine: config.engine ?? functions() });
37
38
  try {
38
39
  await config.setup?.(bot);
39
40
  const commandsPath = resolve(directory, config.commands ?? 'commands');
package/src/cli/lint.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { lstat, readFile, readdir } from 'node:fs/promises';
2
2
  import { extname, join, resolve } from 'node:path';
3
- import { registerBuiltins } from '../functions.js';
4
- import { Runtime } from '../runtime.js';
3
+ import { registerBuiltins, Runtime } from '../functions.js';
5
4
  import { YuzuhaError } from '../errors.js';
6
5
  import { documentDiagnostics, mergeFunctionCatalogs, parseFunctionCatalog } from '../tooling/language.js';
7
6
  import type { FunctionMetadata, ScriptDiagnostic } from '../tooling/language.js';
package/src/cli/main.ts CHANGED
@@ -6,8 +6,7 @@ import { stat } from 'node:fs/promises';
6
6
  import { resolve } from 'node:path';
7
7
  import { Yuzuha } from '../bot.js';
8
8
  import { ScriptError, YuzuhaError } from '../errors.js';
9
- import { registerBuiltins } from '../functions.js';
10
- import { Runtime } from '../runtime.js';
9
+ import { functions, registerBuiltins, Runtime } from '../functions.js';
11
10
  import { parseArguments, usage } from './arguments.js';
12
11
  import { configuredBot, findConfig } from './config.js';
13
12
  import { runBot } from './runner.js';
@@ -58,25 +57,25 @@ export async function main(args = process.argv.slice(2)): Promise<void> {
58
57
  try {
59
58
  if (options.config) {
60
59
  ({ bot: catalogBot } = await configuredBot(await findConfig(options.config), false, false));
61
- all = catalogBot.enableFunctions().runtime.functions();
60
+ all = catalogBot.engine!.functions();
62
61
  } else all = registerBuiltins(new Runtime()).functions();
63
62
  } finally { if (catalogBot) { await catalogBot.destroy(); await catalogBot.options.store?.close?.(); } }
64
63
 
65
64
  const builtinNames = options.pluginsOnly ? new Set(registerBuiltins(new Runtime()).functions().map(fn => fn.name.replace(/^\$/, '').toLowerCase())) : undefined;
66
65
  const visible = builtinNames ? all.filter(fn => !builtinNames.has(fn.name.replace(/^\$/, '').toLowerCase())) : all;
67
- let functions = options.category ? visible.filter(fn => fn.category === options.category) : visible;
68
- if (options.category && !functions.length) throw new YuzuhaError('CATEGORY', `Categoria desconhecida. Escolha: ${[...new Set(all.map(fn => fn.category))].join(', ')}.`);
66
+ let entries = options.category ? visible.filter(fn => fn.category === options.category) : visible;
67
+ if (options.category && !entries.length) throw new YuzuhaError('CATEGORY', `Categoria desconhecida. Escolha: ${[...new Set(all.map(fn => fn.category))].join(', ')}.`);
69
68
  if (options.search !== undefined) {
70
69
  const term = options.search.toLowerCase();
71
- functions = functions.filter(fn => [fn.name, ...(fn.aliases ?? []), fn.description].some(value => value.toLowerCase().includes(term)));
70
+ entries = entries.filter(fn => [fn.name, ...(fn.aliases ?? []), fn.description].some(value => value.toLowerCase().includes(term)));
72
71
  }
73
- const metadata = functions.map(({ execute: _execute, ...value }) => value);
74
- console.log(options.catalog ? JSON.stringify({ version: 1, functions: metadata }, null, 2) : options.json ? JSON.stringify(metadata, null, 2) : options.search !== undefined && !functions.length ? 'Nenhuma função encontrada.' : functions.map(fn => `${fn.usage.padEnd(52)} ${fn.description}`).join('\n'));
72
+ const metadata = entries.map(({ execute: _execute, ...value }) => value);
73
+ console.log(options.catalog ? JSON.stringify({ version: 1, functions: metadata }, null, 2) : options.json ? JSON.stringify(metadata, null, 2) : options.search !== undefined && !entries.length ? 'Nenhuma função encontrada.' : entries.map(fn => `${fn.usage.padEnd(52)} ${fn.description}`).join('\n'));
75
74
  return;
76
75
  }
77
76
  let bot: Yuzuha, commandsPath: string;
78
77
  if (options.action === 'check' && options.input && (await stat(resolve(options.input))).isDirectory()) {
79
- bot = new Yuzuha(); commandsPath = resolve(options.input);
78
+ bot = new Yuzuha({ engine: functions() }); commandsPath = resolve(options.input);
80
79
  try { await bot.load(commandsPath); } catch (error) { await bot.destroy(); throw error; }
81
80
  } else ({ bot, commandsPath } = await configuredBot(await findConfig(options.input), options.action !== 'check'));
82
81
  if (options.action === 'check') {
@@ -47,7 +47,7 @@ export async function scaffold(directory: string, language: 'js' | 'ts', functio
47
47
  'package.json': `${JSON.stringify(manifest, null, 2)}\n`,
48
48
  '.env.example': 'FLUXER_BOT_TOKEN=\n',
49
49
  '.gitignore': 'node_modules/\n.env\ndata/\n',
50
- [`yuzuha.config.${language}`]: `import { defineConfig } from 'yuzuha';\n\nexport default defineConfig({\n name: ${JSON.stringify(name)},\n prefix: '!',\n commands: './commands',\n});\n`,
50
+ [`yuzuha.config.${language}`]: `import { defineConfig } from 'yuzuha';\n${functions ? "import { functions } from 'yuzuha/functions';\n" : ''}\nexport default defineConfig({\n name: ${JSON.stringify(name)},\n prefix: '!',\n commands: './commands',${functions ? '\n engine: functions(),' : ''}\n});\n`,
51
51
  'README.md': `# ${name}\n\nBot do Fluxer com Yuzuha.\n\n1. Execute \`npm install\`.\n2. Execute \`npm run check\` e \`npm test\` para validar offline.\n3. Copie \`.env.example\` para \`.env\` e preencha o token.\n4. Execute \`npm run dev\` ou \`npm start\`.\n\n${template ? templateReadme(template) : 'Comandos: `!ping`, `!hello`, `!ban @membro motivo`.'}${functions ? '\nFunction mode: `!eco texto`.' : ''}\n\n${local ? 'A dependência local aponta para a instalação que gerou este projeto. Para compartilhar, troque-a pela versão publicada no npm.' : 'A dependência do Yuzuha usa a versão do npm, permitindo instalar o projeto em outra máquina.'}\nO teste de exemplo usa \`yuzuha/testing\`, sem token nem conexão ao Fluxer.\nCasos e variáveis ficam no diretório XDG de dados do Yuzuha, sob o nome deste bot.\n`,
52
52
  };
53
53
  if (template) {
@@ -4,6 +4,7 @@ import { Yuzuha } from '../bot.js';
4
4
  import type { DispatchResult } from '../framework/options.js';
5
5
  import type { Command } from '../commands/definition.js';
6
6
  import type { Payload } from '../domain/messages.js';
7
+ import { functions } from '../functions.js';
7
8
  import { MemoryStore } from '../infrastructure/storage/memory.js';
8
9
  import { permission } from '../domain/permissions.js';
9
10
  import { YuzuhaError } from '../errors.js';
@@ -124,7 +125,7 @@ export async function executeScenarios(suite: ScenarioSuite): Promise<ScenarioRe
124
125
  ...(member.topRoleID === undefined ? {} : { topRoleID: member.topRoleID }) });
125
126
  }
126
127
  const bot = new Yuzuha({ prefix: scenario.prefix ?? '!', store, transport, resources: mockResources(),
127
- scheduler: false, http: false, limits: { timeoutMs: 1000, calls: 10_000, output: 100_000 },
128
+ scheduler: false, http: false, engine: functions({ limits: { timeoutMs: 1000, calls: 10_000, output: 100_000 } }),
128
129
  onError: error => { errors.push(error instanceof YuzuhaError ? error.code : 'ERROR'); } });
129
130
  const result: ScenarioResult = { name: scenario.name, passed: true, messages: [] };
130
131
  try {
@@ -153,7 +153,9 @@ export class CommandContext {
153
153
  await this.resources.users.leaveGuild(guildID);
154
154
  }
155
155
  get mod(): NativeModeration {
156
- return this.nativeMod ??= new NativeModeration((action, target, reason, options) => this.moderate(action, target, reason, options));
156
+ return this.nativeMod ??= new NativeModeration(
157
+ (action, target, reason, options) => this.moderate(action, target, reason, options),
158
+ (action, targetID) => this.moderation.canModerate(action, targetID));
157
159
  }
158
160
  get data(): NativeData {
159
161
  return this.nativeData ??= Object.freeze({
@@ -186,11 +188,16 @@ export class CommandContext {
186
188
  const source = bindAuthorizedResources(this.nativeResources, this.transport, { guildID: this.guildID, authorID: this.authorID }), collectors = source.collectors;
187
189
  return this.scopedResources = { users: source.users, roles: source.roles, channels: source.channels,
188
190
  messages: source.messages, webhooks: source.webhooks, expressions: source.expressions,
189
- threads: source.threads, invites: source.invites, collectors: {
191
+ threads: source.threads, invites: source.invites, gateway: source.gateway,
192
+ instance: source.instance, self: source.self, cache: source.cache, collectors: {
190
193
  awaitMessage: (channelID, input) => collectors.awaitMessage(channelID, { ...input,
191
194
  signal: input.signal ? AbortSignal.any([this.signal, input.signal]) : this.signal }),
192
195
  awaitReaction: (channelID, messageID, emojis, timeMs, userID, signal) => collectors.awaitReaction(
193
196
  channelID, messageID, emojis, timeMs, userID, signal ? AbortSignal.any([this.signal, signal]) : this.signal),
197
+ collectMessages: (channelID, input) => collectors.collectMessages(channelID, { ...input,
198
+ signal: input.signal ? AbortSignal.any([this.signal, input.signal]) : this.signal }),
199
+ collectReactions: (channelID, input) => collectors.collectReactions(channelID, { ...input,
200
+ signal: input.signal ? AbortSignal.any([this.signal, input.signal]) : this.signal }),
194
201
  } };
195
202
  }
196
203
  get scheduler(): Scheduler {
@@ -32,3 +32,34 @@ export function emojiBatch(input: unknown): { name: string; image: string }[] {
32
32
  return { name, image };
33
33
  });
34
34
  }
35
+
36
+ export function stickerBatch(input: unknown): { name: string; image: string; description?: string; tags?: string[] }[] {
37
+ if (!Array.isArray(input) || input.length < 1 || input.length > 50) {
38
+ throw new YuzuhaError('STICKER_BATCH', 'Informe de 1 a 50 figurinhas.');
39
+ }
40
+ let bytes = 0;
41
+ const names = new Set<string>();
42
+ return input.map((item: unknown) => {
43
+ if (!item || typeof item !== 'object' || !Object.hasOwn(item, 'name') || !Object.hasOwn(item, 'image')) {
44
+ throw new YuzuhaError('STICKER_BATCH', 'Cada figurinha deve informar name e image em base64.');
45
+ }
46
+ const { name, image, description, tags } = item as { name: unknown; image: unknown; description: unknown; tags: unknown };
47
+ if (typeof name !== 'string' || name.length < 2 || name.length > 32 || names.has(name)) {
48
+ throw new YuzuhaError('STICKER_NAME', 'Nomes de figurinhas devem ser únicos, com 2 a 32 caracteres.');
49
+ }
50
+ names.add(name);
51
+ if (typeof image !== 'string' || !image || image.length > 13_333_336
52
+ || image.length % 4 !== 0 || !/^[A-Za-z0-9+/]+={0,2}$/.test(image)) {
53
+ throw new YuzuhaError('STICKER_IMAGE', 'Imagem deve ser base64 válido, sem prefixo data:.');
54
+ }
55
+ if (description !== undefined && typeof description !== 'string') {
56
+ throw new YuzuhaError('STICKER_BATCH', 'description deve ser texto.');
57
+ }
58
+ if (tags !== undefined && (!Array.isArray(tags) || tags.some(tag => typeof tag !== 'string'))) {
59
+ throw new YuzuhaError('STICKER_BATCH', 'tags deve ser uma lista de textos.');
60
+ }
61
+ bytes += image.length / 4 * 3 - (image.endsWith('==') ? 2 : image.endsWith('=') ? 1 : 0);
62
+ if (bytes > 10_000_000) throw new YuzuhaError('STICKER_BATCH', 'Imagens devem somar até 10 MB.');
63
+ return { name, image, ...(description === undefined ? {} : { description }), ...(tags === undefined ? {} : { tags }) };
64
+ });
65
+ }
@@ -12,10 +12,8 @@ import type { NativeCommandDefinition } from '../commands/definition.js';
12
12
  import type { ArgumentSchema } from '../commands/builders.js';
13
13
  import type { IncomingMessage, Store, Transport } from '../contracts.js';
14
14
  import { GuardError, PartialModerationError, YuzuhaError } from '../errors.js';
15
- import { registerBuiltins } from '../functions.js';
16
- import { Runtime, defaultLimits, text } from '../runtime.js';
17
15
  import { JsonStore, defaultDataPath } from '../store.js';
18
- import { CommandRegistry } from './command-registry.js';
16
+ import { CommandRegistry, functionsRequired } from './command-registry.js';
19
17
  import type { CompiledCommand } from './command-registry.js';
20
18
  import { runMiddleware } from './middleware.js';
21
19
  import type { DispatchResult, Middleware, YuzuhaOptions, YuzuhaPlugin } from './options.js';
@@ -32,7 +30,7 @@ import { cancellationError } from '../services/cancellation.js';
32
30
  import { EventContext } from '../commands/event-context.js';
33
31
  import { adaptScriptEvent, scriptEventNames, validateScriptEvent } from './script-events.js';
34
32
  import type { ScriptEventDefinition } from './script-events.js';
35
- import type { Program } from '../scripting/ast.js';
33
+ import type { ScriptEngine } from '../ports/script-engine.js';
36
34
  import type { MusicManager } from '../services/music.js';
37
35
  import type { NativeVoice } from '../ports/voice.js';
38
36
  import { canvasRenderer } from '../infrastructure/canvas/render.js';
@@ -40,6 +38,14 @@ import { canvasRenderer } from '../infrastructure/canvas/render.js';
40
38
  type RoutedCommand = { compiled: CompiledCommand; input: string; prefix: string };
41
39
  const ignored: Promise<DispatchResult> = Promise.resolve('ignored');
42
40
 
41
+ function assertEngine(engine: unknown): ScriptEngine {
42
+ const candidate = engine as Partial<Record<keyof ScriptEngine, unknown>> | null | undefined;
43
+ if (!candidate || (['compile', 'execute', 'functions', 'registerAll', 'fork', 'text'] as const).some(key => typeof candidate[key] !== 'function')) {
44
+ throw new YuzuhaError('ENGINE_INVALID', 'Engine de function mode inválido: precisa de compile, execute, functions, registerAll, fork e text.');
45
+ }
46
+ return engine as ScriptEngine;
47
+ }
48
+
43
49
  export class Yuzuha {
44
50
  readonly client: Client;
45
51
  readonly transport: Transport;
@@ -49,7 +55,7 @@ export class Yuzuha {
49
55
  readonly http?: HttpService;
50
56
  readonly music?: MusicManager;
51
57
  readonly voice?: NativeVoice;
52
- readonly runtime: Runtime;
58
+ private scriptEngine?: ScriptEngine;
53
59
  private readonly registry: CommandRegistry;
54
60
  private readonly middleware: Middleware[] = [];
55
61
  private readonly plugins = new Set<string>();
@@ -59,7 +65,6 @@ export class Yuzuha {
59
65
  private readonly events: NativeEvents;
60
66
  private readonly execution = new AsyncLocalStorage<boolean>();
61
67
  private listening = false;
62
- private functionsReady = false;
63
68
  private closing = false;
64
69
  private closeTask?: Promise<void>;
65
70
  private loginTask?: Promise<void>;
@@ -103,8 +108,8 @@ export class Yuzuha {
103
108
  this.http = options.http === false ? undefined : options.http ?? new HttpService();
104
109
  this.music = options.music;
105
110
  this.voice = options.voice;
106
- this.runtime = new Runtime({ ...defaultLimits, ...options.limits });
107
- this.registry = new CommandRegistry(this.runtime, () => this.enableFunctions(), command => {
111
+ if (options.engine !== undefined) this.scriptEngine = assertEngine(options.engine);
112
+ this.registry = new CommandRegistry(() => this.scriptEngine, command => {
108
113
  if (command.http) (this.http ?? new HttpService()).withPolicy(command.http);
109
114
  });
110
115
  this.events = new NativeEvents(this.client, work => this.scheduleEvent(work));
@@ -114,12 +119,14 @@ export class Yuzuha {
114
119
  this.client.on(Events.ShardError, this.shardErrorListener);
115
120
  }
116
121
 
117
- /** Ativa o function mode (parser, evaluator e builtins) antes de usar `code`. */
118
- enableFunctions(): this {
119
- if (!this.functionsReady) {
120
- registerBuiltins(this.runtime);
121
- this.functionsReady = true;
122
- }
122
+ /** Engine de function mode instalado, quando presente. */
123
+ get engine(): ScriptEngine | undefined { return this.scriptEngine; }
124
+
125
+ /** Instala o motor de function mode; exigido por comandos com `code` e eventos de script. */
126
+ useEngine(engine: ScriptEngine): this {
127
+ if (this.closing) throw new YuzuhaError('BOT_CLOSED', 'O bot está encerrado.');
128
+ if (this.scriptEngine) throw new YuzuhaError('ENGINE_INSTALLED', 'O bot já tem um engine de function mode.');
129
+ this.scriptEngine = assertEngine(engine);
123
130
  return this;
124
131
  }
125
132
 
@@ -140,13 +147,15 @@ export class Yuzuha {
140
147
  hasScript = typeof command.code === 'string';
141
148
  if (Array.isArray(command.subcommands)) pending.push(...command.subcommands);
142
149
  }
143
- if (hasScript) this.enableFunctions();
144
- const stagedRuntime = new Runtime(this.runtime.limits);
145
- stagedRuntime.registerAll([...this.runtime.functions(), ...(plugin.functions ?? [])]);
146
- const commitCommands = this.registry.prepare(plugin.commands ?? [], stagedRuntime);
150
+ if (hasScript || plugin.functions?.length) {
151
+ if (!this.scriptEngine) throw functionsRequired();
152
+ }
153
+ const stagedEngine = this.scriptEngine?.fork();
154
+ stagedEngine?.registerAll(plugin.functions ?? []);
155
+ const commitCommands = this.registry.prepare(plugin.commands ?? [], stagedEngine);
147
156
  for (const event of plugin.events ?? []) this.events.validate(event);
148
- const scriptEvents = (plugin.scriptEvents ?? []).map(event => this.prepareScriptEvent(event, stagedRuntime));
149
- this.runtime.registerAll(plugin.functions ?? []);
157
+ const scriptEvents = (plugin.scriptEvents ?? []).map(event => this.prepareScriptEvent(event, stagedEngine));
158
+ this.scriptEngine?.registerAll(plugin.functions ?? []);
150
159
  commitCommands();
151
160
  this.middleware.push(...(plugin.middleware ?? []));
152
161
  for (const event of plugin.events ?? []) this.events.add(event);
@@ -166,6 +175,12 @@ export class Yuzuha {
166
175
  listCommands(): Command[] { return this.registry.list(); }
167
176
  help(command?: string, prefix = ''): string { return this.registry.help(command, prefix); }
168
177
  get signal(): AbortSignal { return this.shutdown.signal; }
178
+ isReady(): boolean { return this.client.isReady(); }
179
+ get uptime(): number | null { return this.client.uptime; }
180
+ assertReady(): void {
181
+ try { this.client.assertReady(); }
182
+ catch { throw new YuzuhaError('BOT_NOT_READY', 'O bot ainda não está pronto.'); }
183
+ }
169
184
 
170
185
  on<K extends ClientEventName>(event: K, listener: NativeListener<K>): this {
171
186
  this.events.add(defineEvent({ event, run: listener }), listener); return this;
@@ -202,18 +217,19 @@ export class Yuzuha {
202
217
 
203
218
  scriptEvent(definition: ScriptEventDefinition): this {
204
219
  if (this.closing) throw new YuzuhaError('BOT_CLOSED', 'O bot está encerrado.');
205
- this.enableFunctions();
220
+ if (!this.scriptEngine) throw functionsRequired();
206
221
  this.events.add(this.prepareScriptEvent(definition));
207
222
  return this;
208
223
  }
209
- private prepareScriptEvent(definition: ScriptEventDefinition, runtime = this.runtime): NativeEvent {
224
+ private prepareScriptEvent(definition: ScriptEventDefinition, engine = this.scriptEngine): NativeEvent {
225
+ if (!engine) throw functionsRequired();
210
226
  validateScriptEvent(definition);
211
227
  const options = structuredClone(definition);
212
228
  if (options.http) (this.http ?? new HttpService()).withPolicy(options.http);
213
- const program = runtime.compile(options.code, `<event:${options.event}>`);
214
- return { event: options.event, once: options.once ?? false, invoke: args => this.runScriptEvent(options, program, args) };
229
+ const program = engine.compile(options.code, `<event:${options.event}>`);
230
+ return { event: options.event, once: options.once ?? false, invoke: args => this.runScriptEvent(options, program, args, engine) };
215
231
  }
216
- private async runScriptEvent(definition: ScriptEventDefinition, program: Program, args: unknown[]): Promise<void> {
232
+ private async runScriptEvent(definition: ScriptEventDefinition, program: unknown, args: unknown[], engine: ScriptEngine): Promise<void> {
217
233
  const source = adaptScriptEvent(definition.event, args);
218
234
  if ((definition.ignoreBots ?? true) && source.event.userBot) return;
219
235
  const signal = this.shutdown.signal;
@@ -225,7 +241,7 @@ export class Yuzuha {
225
241
  let outcome: DispatchResult = 'success';
226
242
  try {
227
243
  if (this.options.onLog) await emitLog(this.options, { event: 'event.start', executionID: ctx.executionID, command: ctx.command.name });
228
- const output = text(await this.runtime.execute(program, ctx)).trim();
244
+ const output = engine.text(await engine.execute(program, ctx)).trim();
229
245
  if (output) {
230
246
  if (!ctx.channelID) throw new GuardError('Defina um canal para a saída deste evento.');
231
247
  await ctx.send(output, ctx.channelID);
@@ -394,7 +410,8 @@ export class Yuzuha {
394
410
  }
395
411
  const execute = async () => {
396
412
  if (compiled.program) {
397
- const output = text(await this.runtime.execute(compiled.program, current)).trim();
413
+ const programEngine = (compiled as { programEngine?: ScriptEngine }).programEngine ?? this.scriptEngine!;
414
+ const output = programEngine.text(await programEngine.execute(compiled.program, current)).trim();
398
415
  if (output) await current.reply(output);
399
416
  } else if (compiled.command.run) await compiled.command.run(current);
400
417
  else throw new GuardError(`${resolved.input ? 'Subcomando desconhecido.\n' : ''}${this.help(compiled.command.name, prefix)}`);
@@ -5,15 +5,15 @@ import type { Command } from '../context.js';
5
5
  import { parseDuration } from '../context.js';
6
6
  import { YuzuhaError } from '../errors.js';
7
7
  import { loadCommands } from '../loader.js';
8
- import type { Program } from '../parser.js';
9
8
  import { permission } from '../permissions.js';
10
- import type { Runtime } from '../runtime.js';
9
+ import type { ScriptEngine } from '../ports/script-engine.js';
11
10
  import type { HttpPolicy } from '../services/http.js';
12
11
 
13
12
  export interface CompiledCommand {
14
13
  command: Command;
15
14
  definition: Command;
16
- program?: Program;
15
+ program?: unknown;
16
+ programEngine?: ScriptEngine;
17
17
  directory?: string;
18
18
  children: Map<string, CompiledCommand>;
19
19
  lineage: Command[];
@@ -62,13 +62,17 @@ function inheritedHttp(parent?: HttpPolicy, child?: HttpPolicy): HttpPolicy | un
62
62
  return policy;
63
63
  }
64
64
 
65
+ export function functionsRequired(): YuzuhaError {
66
+ return new YuzuhaError('FUNCTIONS_REQUIRED', 'Function mode requer um engine. Use import { functions } from \'yuzuha/functions\' e passe engine: functions() nas opções do bot.');
67
+ }
68
+
65
69
  export class CommandRegistry {
66
70
  private entries = new Map<string, CompiledCommand>();
67
71
  private loading: Promise<unknown> = Promise.resolve();
68
- constructor(private readonly runtime: Runtime, private readonly onScript: () => void = () => {},
72
+ constructor(private readonly engine: () => ScriptEngine | undefined,
69
73
  private readonly validate: (command: Command) => void = () => {}) {}
70
74
 
71
- private compile(input: Command, directory?: string, runtime = this.runtime, ancestors: CompiledCommand[] = [], seen = new Set<Command>()): CompiledCommand {
75
+ private compile(input: Command, directory?: string, engine = this.engine(), ancestors: CompiledCommand[] = [], seen = new Set<Command>()): CompiledCommand {
72
76
  if (ancestors.length >= 32 || seen.has(input)) throw new YuzuhaError('COMMAND_TREE', 'Árvore de comandos cíclica ou com mais de 32 níveis.');
73
77
  validateMetadata(input);
74
78
  this.validate(input);
@@ -93,12 +97,13 @@ export class CommandRegistry {
93
97
  const ownGuard = { ...definition, name: command.name };
94
98
  const entry: CompiledCommand = { command, definition, directory, children: new Map(), lineage: [...ancestors.at(-1)?.lineage ?? [], ownGuard] };
95
99
  const visiting = new Set(seen).add(input);
96
- for (const child of input.subcommands ?? []) this.insert(entry.children, this.compile(child, directory, runtime, [...ancestors, entry], visiting));
100
+ for (const child of input.subcommands ?? []) this.insert(entry.children, this.compile(child, directory, engine, [...ancestors, entry], visiting));
97
101
  definition.subcommands = [...new Set(entry.children.values())].map(child => child.definition);
98
102
  command.subcommands = definition.subcommands;
99
103
  if (command.code !== undefined) {
100
- this.onScript();
101
- entry.program = runtime.compile(command.code, command.file ?? command.name);
104
+ if (!engine) throw functionsRequired();
105
+ entry.program = engine.compile(command.code, command.file ?? command.name);
106
+ entry.programEngine = engine;
102
107
  }
103
108
  return entry;
104
109
  }
@@ -116,9 +121,9 @@ export class CommandRegistry {
116
121
  }
117
122
  this.insert(this.entries, entry);
118
123
  }
119
- prepare(commands: Command[], runtime = this.runtime): () => void {
124
+ prepare(commands: Command[], engine = this.engine()): () => void {
120
125
  const next = new Map(this.entries);
121
- for (const command of commands) this.insert(next, this.compile(command, undefined, runtime));
126
+ for (const command of commands) this.insert(next, this.compile(command, undefined, engine));
122
127
  return () => { this.entries = next; };
123
128
  }
124
129
  load(directory: string, mode: 'replace' | 'append' | 'reload'): Promise<void> {
@@ -1,7 +1,7 @@
1
1
  import type { Client, ClientOptions } from '@fluxerjs/core';
2
2
  import type { CommandContext } from '../context.js';
3
3
  import type { IncomingMessage, Store, Transport } from '../contracts.js';
4
- import type { FunctionDefinition, Limits } from '../runtime.js';
4
+ import type { ScriptEngine, ScriptFunctionDefinition } from '../ports/script-engine.js';
5
5
  import type { Command } from '../context.js';
6
6
  import type { Resources } from '../ports/resources.js';
7
7
  import type { HttpService } from '../services/http.js';
@@ -17,7 +17,7 @@ export type DispatchResult = 'ignored' | 'success' | 'guarded' | 'error';
17
17
  export type Middleware = (ctx: CommandContext, next: () => Promise<void>) => Promise<void>;
18
18
  export interface YuzuhaPlugin {
19
19
  name: string;
20
- functions?: FunctionDefinition[];
20
+ functions?: ScriptFunctionDefinition[];
21
21
  middleware?: Middleware[];
22
22
  commands?: Command[];
23
23
  events?: NativeEvent[];
@@ -33,7 +33,7 @@ export interface YuzuhaOptions {
33
33
  name?: string;
34
34
  /** Clock shared by cooldowns, variable TTLs and the default scheduler. */
35
35
  now?: () => number;
36
- limits?: Partial<Limits>;
36
+ engine?: ScriptEngine;
37
37
  scheduler?: Scheduler | false;
38
38
  http?: HttpService | false;
39
39
  music?: MusicManager;