omegga 0.1.85 → 1.0.2

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 (467) hide show
  1. package/README.md +142 -62
  2. package/bin/omegga +10 -4
  3. package/dist/brickadia/config.d.ts +3 -0
  4. package/dist/brickadia/config.d.ts.map +1 -0
  5. package/dist/brickadia/config.js +61 -0
  6. package/dist/brickadia/config.js.map +1 -0
  7. package/dist/brickadia/presets.d.ts +65 -0
  8. package/dist/brickadia/presets.js +3 -0
  9. package/dist/brickadia/presets.js.map +1 -0
  10. package/dist/brickadia/server.d.ts +20 -0
  11. package/dist/brickadia/server.d.ts.map +1 -0
  12. package/dist/brickadia/server.js +188 -0
  13. package/dist/brickadia/server.js.map +1 -0
  14. package/dist/brickadia/types.d.ts +45 -0
  15. package/dist/brickadia/types.d.ts.map +1 -0
  16. package/dist/brickadia/types.js +3 -0
  17. package/dist/brickadia/types.js.map +1 -0
  18. package/dist/cli/auth.d.ts +20 -0
  19. package/dist/cli/auth.d.ts.map +1 -0
  20. package/dist/cli/auth.js +115 -0
  21. package/dist/cli/auth.js.map +1 -0
  22. package/dist/cli/config.d.ts +10 -0
  23. package/dist/cli/config.d.ts.map +1 -0
  24. package/dist/cli/config.js +72 -0
  25. package/dist/cli/config.js.map +1 -0
  26. package/dist/cli/index.d.ts +20 -0
  27. package/dist/cli/index.d.ts.map +1 -0
  28. package/dist/cli/index.js +15 -0
  29. package/dist/cli/index.js.map +1 -0
  30. package/dist/cli/installer.d.ts +1 -0
  31. package/dist/cli/installer.d.ts.map +1 -0
  32. package/dist/cli/installer.js +55 -0
  33. package/dist/cli/installer.js.map +1 -0
  34. package/dist/cli/plugin.d.ts +11 -0
  35. package/dist/cli/plugin.d.ts.map +1 -0
  36. package/dist/cli/plugin.js +598 -0
  37. package/dist/cli/plugin.js.map +1 -0
  38. package/dist/cli/terminal.d.ts +34 -0
  39. package/dist/cli/terminal.d.ts.map +1 -0
  40. package/dist/cli/terminal.js +395 -0
  41. package/dist/cli/terminal.js.map +1 -0
  42. package/dist/config/authorizer.d.ts +2 -0
  43. package/dist/config/authorizer.d.ts.map +1 -0
  44. package/dist/config/authorizer.js +38 -0
  45. package/dist/config/authorizer.js.map +1 -0
  46. package/dist/config/formats/format_js.d.ts +3 -0
  47. package/dist/config/formats/format_js.d.ts.map +1 -0
  48. package/dist/config/formats/format_js.js +10 -0
  49. package/dist/config/formats/format_js.js.map +1 -0
  50. package/dist/config/formats/format_yml.d.ts +3 -0
  51. package/dist/config/formats/format_yml.d.ts.map +1 -0
  52. package/dist/config/formats/format_yml.js +14 -0
  53. package/dist/config/formats/format_yml.js.map +1 -0
  54. package/dist/config/index.d.ts +18 -0
  55. package/dist/config/index.d.ts.map +1 -0
  56. package/dist/config/index.js +86 -0
  57. package/dist/config/index.js.map +1 -0
  58. package/dist/config/reader.d.ts +3 -0
  59. package/dist/config/reader.d.ts.map +1 -0
  60. package/dist/config/reader.js +30 -0
  61. package/dist/config/reader.js.map +1 -0
  62. package/dist/config/types.d.ts +37 -0
  63. package/dist/config/types.d.ts.map +1 -0
  64. package/dist/config/types.js +3 -0
  65. package/dist/config/types.js.map +1 -0
  66. package/dist/config/validator.d.ts +6 -0
  67. package/dist/config/validator.d.ts.map +1 -0
  68. package/dist/config/validator.js +26 -0
  69. package/dist/config/validator.js.map +1 -0
  70. package/dist/config/writer.d.ts +3 -0
  71. package/dist/config/writer.d.ts.map +1 -0
  72. package/dist/config/writer.js +25 -0
  73. package/dist/config/writer.js.map +1 -0
  74. package/dist/index.d.ts +22 -0
  75. package/dist/index.js +55 -0
  76. package/dist/index.js.map +1 -0
  77. package/dist/info/default_commands.json +28 -0
  78. package/dist/lib.d.ts +21 -0
  79. package/dist/lib.d.ts.map +1 -0
  80. package/dist/lib.js +54 -0
  81. package/dist/lib.js.map +1 -0
  82. package/dist/logger.d.ts +41 -0
  83. package/dist/logger.js +67 -0
  84. package/dist/logger.js.map +1 -0
  85. package/dist/main.d.ts +1 -0
  86. package/dist/main.d.ts.map +1 -0
  87. package/dist/main.js +284 -0
  88. package/dist/main.js.map +1 -0
  89. package/dist/omegga/auth.d.ts +6 -0
  90. package/dist/omegga/auth.d.ts.map +1 -0
  91. package/dist/omegga/auth.js +139 -0
  92. package/dist/omegga/auth.js.map +1 -0
  93. package/dist/omegga/commandInjector.d.ts +35 -0
  94. package/dist/omegga/commandInjector.d.ts.map +1 -0
  95. package/dist/omegga/commandInjector.js +234 -0
  96. package/dist/omegga/commandInjector.js.map +1 -0
  97. package/dist/omegga/index.d.ts +7 -0
  98. package/dist/omegga/index.d.ts.map +1 -0
  99. package/dist/omegga/index.js +43 -0
  100. package/dist/omegga/index.js.map +1 -0
  101. package/dist/omegga/logWrangler.d.ts +32 -0
  102. package/dist/omegga/logWrangler.d.ts.map +1 -0
  103. package/dist/omegga/logWrangler.js +279 -0
  104. package/dist/omegga/logWrangler.js.map +1 -0
  105. package/dist/omegga/matchers/auth.d.ts +9 -0
  106. package/dist/omegga/matchers/auth.d.ts.map +1 -0
  107. package/dist/omegga/matchers/auth.js +53 -0
  108. package/dist/omegga/matchers/auth.js.map +1 -0
  109. package/dist/omegga/matchers/chat.d.ts +9 -0
  110. package/dist/omegga/matchers/chat.d.ts.map +1 -0
  111. package/dist/omegga/matchers/chat.js +68 -0
  112. package/dist/omegga/matchers/chat.js.map +1 -0
  113. package/dist/omegga/matchers/command.d.ts +7 -0
  114. package/dist/omegga/matchers/command.d.ts.map +1 -0
  115. package/dist/omegga/matchers/command.js +39 -0
  116. package/dist/omegga/matchers/command.js.map +1 -0
  117. package/dist/omegga/matchers/exit.d.ts +3 -0
  118. package/dist/omegga/matchers/exit.d.ts.map +1 -0
  119. package/dist/omegga/matchers/exit.js +21 -0
  120. package/dist/omegga/matchers/exit.js.map +1 -0
  121. package/dist/omegga/matchers/index.d.ts +3 -0
  122. package/dist/omegga/matchers/index.d.ts.map +1 -0
  123. package/dist/omegga/matchers/index.js +39 -0
  124. package/dist/omegga/matchers/index.js.map +1 -0
  125. package/dist/omegga/matchers/init.d.ts +3 -0
  126. package/dist/omegga/matchers/init.d.ts.map +1 -0
  127. package/dist/omegga/matchers/init.js +26 -0
  128. package/dist/omegga/matchers/init.js.map +1 -0
  129. package/dist/omegga/matchers/interact.d.ts +4 -0
  130. package/dist/omegga/matchers/interact.js +39 -0
  131. package/dist/omegga/matchers/interact.js.map +1 -0
  132. package/dist/omegga/matchers/join.d.ts +4 -0
  133. package/dist/omegga/matchers/join.d.ts.map +1 -0
  134. package/dist/omegga/matchers/join.js +95 -0
  135. package/dist/omegga/matchers/join.js.map +1 -0
  136. package/dist/omegga/matchers/leave.d.ts +4 -0
  137. package/dist/omegga/matchers/leave.d.ts.map +1 -0
  138. package/dist/omegga/matchers/leave.js +59 -0
  139. package/dist/omegga/matchers/leave.js.map +1 -0
  140. package/dist/omegga/matchers/mapChange.d.ts +3 -0
  141. package/dist/omegga/matchers/mapChange.d.ts.map +1 -0
  142. package/dist/omegga/matchers/mapChange.js +38 -0
  143. package/dist/omegga/matchers/mapChange.js.map +1 -0
  144. package/dist/omegga/matchers/types.d.ts +5 -0
  145. package/dist/omegga/matchers/types.d.ts.map +1 -0
  146. package/dist/omegga/matchers/types.js +7 -0
  147. package/dist/omegga/matchers/types.js.map +1 -0
  148. package/dist/omegga/matchers/version.d.ts +3 -0
  149. package/dist/omegga/matchers/version.d.ts.map +1 -0
  150. package/dist/omegga/matchers/version.js +45 -0
  151. package/dist/omegga/matchers/version.js.map +1 -0
  152. package/dist/omegga/player.d.ts +71 -0
  153. package/dist/omegga/player.d.ts.map +1 -0
  154. package/dist/omegga/player.js +442 -0
  155. package/dist/omegga/player.js.map +1 -0
  156. package/dist/omegga/plugin/plugin_jsonrpc_stdio.d.ts +23 -0
  157. package/dist/omegga/plugin/plugin_jsonrpc_stdio.d.ts.map +1 -0
  158. package/dist/omegga/plugin/plugin_jsonrpc_stdio.js +441 -0
  159. package/dist/omegga/plugin/plugin_jsonrpc_stdio.js.map +1 -0
  160. package/dist/omegga/plugin/plugin_node_safe/proxyOmegga.d.ts +129 -0
  161. package/dist/omegga/plugin/plugin_node_safe/proxyOmegga.d.ts.map +1 -0
  162. package/dist/omegga/plugin/plugin_node_safe/proxyOmegga.js +260 -0
  163. package/dist/omegga/plugin/plugin_node_safe/proxyOmegga.js.map +1 -0
  164. package/dist/omegga/plugin/plugin_node_safe/worker.d.ts +1 -0
  165. package/dist/omegga/plugin/plugin_node_safe/worker.d.ts.map +1 -0
  166. package/dist/omegga/plugin/plugin_node_safe/worker.js +289 -0
  167. package/dist/omegga/plugin/plugin_node_safe/worker.js.map +1 -0
  168. package/dist/omegga/plugin/plugin_node_safe.d.ts +24 -0
  169. package/dist/omegga/plugin/plugin_node_safe.d.ts.map +1 -0
  170. package/dist/omegga/plugin/plugin_node_safe.js +397 -0
  171. package/dist/omegga/plugin/plugin_node_safe.js.map +1 -0
  172. package/dist/omegga/plugin/plugin_node_unsafe.d.ts +13 -0
  173. package/dist/omegga/plugin/plugin_node_unsafe.d.ts.map +1 -0
  174. package/dist/omegga/plugin/plugin_node_unsafe.js +178 -0
  175. package/dist/omegga/plugin/plugin_node_unsafe.js.map +1 -0
  176. package/dist/omegga/plugin.d.ts +86 -0
  177. package/dist/omegga/plugin.d.ts.map +1 -0
  178. package/dist/omegga/plugin.js +458 -0
  179. package/dist/omegga/plugin.js.map +1 -0
  180. package/dist/omegga/server.d.ts +149 -0
  181. package/dist/omegga/server.d.ts.map +1 -0
  182. package/dist/omegga/server.js +601 -0
  183. package/dist/omegga/server.js.map +1 -0
  184. package/dist/omegga/types.d.ts +48 -0
  185. package/dist/omegga/types.d.ts.map +1 -0
  186. package/dist/omegga/types.js +3 -0
  187. package/dist/omegga/types.js.map +1 -0
  188. package/dist/omegga/wrapper.d.ts +22 -0
  189. package/dist/omegga/wrapper.d.ts.map +1 -0
  190. package/dist/omegga/wrapper.js +75 -0
  191. package/dist/omegga/wrapper.js.map +1 -0
  192. package/dist/omeggaplugin.d.ts +1 -0
  193. package/dist/omeggaplugin.js +4 -0
  194. package/dist/omeggaplugin.js.map +1 -0
  195. package/dist/plugin.d.ts +781 -0
  196. package/dist/plugin.js +41 -0
  197. package/dist/plugin.js.map +1 -0
  198. package/dist/softconfig.d.ts +51 -0
  199. package/dist/softconfig.d.ts.map +1 -0
  200. package/dist/softconfig.js +82 -0
  201. package/dist/softconfig.js.map +1 -0
  202. package/dist/util/brick/checkBounds.d.ts +8 -0
  203. package/dist/util/brick/checkBounds.d.ts.map +1 -0
  204. package/dist/util/brick/checkBounds.js +22 -0
  205. package/dist/util/brick/checkBounds.js.map +1 -0
  206. package/dist/util/brick/constants.d.ts +18 -0
  207. package/dist/util/brick/constants.d.ts.map +1 -0
  208. package/dist/util/brick/constants.js +184 -0
  209. package/dist/util/brick/constants.js.map +1 -0
  210. package/dist/util/brick/getBounds.d.ts +4 -0
  211. package/dist/util/brick/getBounds.d.ts.map +1 -0
  212. package/dist/util/brick/getBounds.js +39 -0
  213. package/dist/util/brick/getBounds.js.map +1 -0
  214. package/dist/util/brick/getBrickSize.d.ts +3 -0
  215. package/dist/util/brick/getBrickSize.d.ts.map +1 -0
  216. package/dist/util/brick/getBrickSize.js +12 -0
  217. package/dist/util/brick/getBrickSize.js.map +1 -0
  218. package/dist/util/brick/getScaleAxis.d.ts +3 -0
  219. package/dist/util/brick/getScaleAxis.d.ts.map +1 -0
  220. package/dist/util/brick/getScaleAxis.js +38 -0
  221. package/dist/util/brick/getScaleAxis.js.map +1 -0
  222. package/dist/util/brick/index.d.ts +13 -0
  223. package/dist/util/brick/index.d.ts.map +1 -0
  224. package/dist/util/brick/index.js +29 -0
  225. package/dist/util/brick/index.js.map +1 -0
  226. package/dist/util/brick/rotate.d.ts +17 -0
  227. package/dist/util/brick/rotate.d.ts.map +1 -0
  228. package/dist/util/brick/rotate.js +38 -0
  229. package/dist/util/brick/rotate.js.map +1 -0
  230. package/dist/util/brick/setOwnership.d.ts +12 -0
  231. package/dist/util/brick/setOwnership.d.ts.map +1 -0
  232. package/dist/util/brick/setOwnership.js +21 -0
  233. package/dist/util/brick/setOwnership.js.map +1 -0
  234. package/dist/util/chat.d.ts +23 -0
  235. package/dist/util/chat.d.ts.map +1 -0
  236. package/dist/util/chat.js +50 -0
  237. package/dist/util/chat.js.map +1 -0
  238. package/dist/util/color.d.ts +13 -0
  239. package/dist/util/color.d.ts.map +1 -0
  240. package/dist/util/color.js +130 -0
  241. package/dist/util/color.js.map +1 -0
  242. package/dist/util/file.d.ts +5 -0
  243. package/dist/util/file.d.ts.map +1 -0
  244. package/dist/util/file.js +114 -0
  245. package/dist/util/file.js.map +1 -0
  246. package/dist/util/index.d.ts +162 -0
  247. package/dist/util/index.d.ts.map +1 -0
  248. package/dist/util/index.js +92 -0
  249. package/dist/util/index.js.map +1 -0
  250. package/dist/util/map.d.ts +6 -0
  251. package/dist/util/map.d.ts.map +1 -0
  252. package/dist/util/map.js +26 -0
  253. package/dist/util/map.js.map +1 -0
  254. package/dist/util/pattern.d.ts +1 -0
  255. package/dist/util/pattern.d.ts.map +1 -0
  256. package/dist/util/pattern.js +11 -0
  257. package/dist/util/pattern.js.map +1 -0
  258. package/dist/util/time.d.ts +4 -0
  259. package/dist/util/time.d.ts.map +1 -0
  260. package/dist/util/time.js +41 -0
  261. package/dist/util/time.js.map +1 -0
  262. package/dist/util/uuid.d.ts +2 -0
  263. package/dist/util/uuid.d.ts.map +1 -0
  264. package/dist/util/uuid.js +8 -0
  265. package/dist/util/uuid.js.map +1 -0
  266. package/dist/util/wsl.d.ts +1 -0
  267. package/dist/util/wsl.d.ts.map +1 -0
  268. package/dist/util/wsl.js +14 -0
  269. package/dist/util/wsl.js.map +1 -0
  270. package/dist/webserver/backend/api.d.ts +3 -0
  271. package/dist/webserver/backend/api.d.ts.map +1 -0
  272. package/dist/webserver/backend/api.js +685 -0
  273. package/dist/webserver/backend/api.js.map +1 -0
  274. package/dist/webserver/backend/calendar.d.ts +5 -0
  275. package/dist/webserver/backend/calendar.d.ts.map +1 -0
  276. package/dist/webserver/backend/calendar.js +21 -0
  277. package/dist/webserver/backend/calendar.js.map +1 -0
  278. package/dist/webserver/backend/database.d.ts +149 -0
  279. package/dist/webserver/backend/database.d.ts.map +1 -0
  280. package/dist/webserver/backend/database.js +575 -0
  281. package/dist/webserver/backend/database.js.map +1 -0
  282. package/dist/webserver/backend/index.d.ts +31 -0
  283. package/dist/webserver/backend/index.d.ts.map +1 -0
  284. package/dist/webserver/backend/index.js +189 -0
  285. package/dist/webserver/backend/index.js.map +1 -0
  286. package/dist/webserver/backend/metrics.d.ts +3 -0
  287. package/dist/webserver/backend/metrics.d.ts.map +1 -0
  288. package/dist/webserver/backend/metrics.js +203 -0
  289. package/dist/webserver/backend/metrics.js.map +1 -0
  290. package/dist/webserver/backend/types.d.ts +115 -0
  291. package/dist/webserver/backend/types.d.ts.map +1 -0
  292. package/dist/webserver/backend/types.js +3 -0
  293. package/dist/webserver/backend/types.js.map +1 -0
  294. package/dist/webserver/backend/util.d.ts +2 -0
  295. package/dist/webserver/backend/util.d.ts.map +1 -0
  296. package/dist/webserver/backend/util.js +78 -0
  297. package/dist/webserver/backend/util.js.map +1 -0
  298. package/dist/webserver/index.d.ts +2 -0
  299. package/dist/webserver/index.d.ts.map +1 -0
  300. package/dist/webserver/index.js +9 -0
  301. package/dist/webserver/index.js.map +1 -0
  302. package/{src/webserver/frontend → frontend}/app.html +0 -0
  303. package/{src/webserver/frontend → frontend}/assets/fonts/GlacialIndifferenceBold.ttf +0 -0
  304. package/{src/webserver/frontend → frontend}/assets/fonts/GlacialIndifferenceItalic.otf +0 -0
  305. package/{src/webserver/frontend → frontend}/assets/fonts/GlacialIndifferenceMedium.otf +0 -0
  306. package/{src/webserver/frontend → frontend}/assets/fonts/GlacialIndifferenceRegular.ttf +0 -0
  307. package/{src/webserver/frontend → frontend}/assets/fonts/RobotoBold.ttf +0 -0
  308. package/{src/webserver/frontend → frontend}/assets/fonts/RobotoItalic.ttf +0 -0
  309. package/{src/webserver/frontend → frontend}/assets/fonts/RobotoRegular.ttf +0 -0
  310. package/{src/webserver/frontend → frontend}/assets/img/auth_bg.webp +0 -0
  311. package/{src/webserver/frontend → frontend}/assets/img/dark_bg.webp +0 -0
  312. package/{src/webserver/frontend → frontend}/assets/img/turkey.webp +0 -0
  313. package/{src/webserver/frontend → frontend}/auth.html +0 -0
  314. package/index.js +10 -2
  315. package/package.json +44 -16
  316. package/public/app.bundle.js +537 -73
  317. package/public/app.bundle.js.map +1 -1
  318. package/public/app.css +727 -2
  319. package/public/app.css.map +1 -1
  320. package/public/auth.bundle.js +18 -18
  321. package/public/auth.bundle.js.map +1 -1
  322. package/public/auth.css +364 -2
  323. package/public/auth.css.map +1 -1
  324. package/templates/rpc/README.md +29 -0
  325. package/templates/rpc/doc.json +7 -0
  326. package/templates/rpc/omegga_plugin +0 -0
  327. package/templates/rpc/plugin.json +4 -0
  328. package/templates/rpc/setup.sh +3 -0
  329. package/templates/safe/README.md +29 -0
  330. package/templates/safe/access.json +1 -0
  331. package/templates/safe/doc.json +7 -0
  332. package/templates/safe/omegga.plugin.js +20 -0
  333. package/templates/safe/plugin.json +4 -0
  334. package/templates/safe/setup.sh +4 -0
  335. package/templates/safe-ts/.gitignore.rename +3 -0
  336. package/templates/safe-ts/README.md +29 -0
  337. package/templates/safe-ts/access.json +1 -0
  338. package/templates/safe-ts/doc.json +7 -0
  339. package/templates/safe-ts/omegga.d.ts +1311 -0
  340. package/templates/safe-ts/omegga.plugin.ts +29 -0
  341. package/templates/safe-ts/plugin.json +4 -0
  342. package/templates/safe-ts/setup.sh +4 -0
  343. package/templates/safe-ts/tsconfig.json +10 -0
  344. package/templates/unsafe/README.md +29 -0
  345. package/templates/unsafe/doc.json +7 -0
  346. package/templates/unsafe/omegga.main.js +15 -0
  347. package/templates/unsafe/plugin.json +4 -0
  348. package/templates/unsafe/setup.sh +4 -0
  349. package/.babelrc.json +0 -5
  350. package/.github/workflows/lint.yml +0 -26
  351. package/.prettierrc +0 -7
  352. package/.vscode/extensions.json +0 -5
  353. package/src/OMEGGA_LEGACY_INSTALL +0 -44
  354. package/src/brickadia/config.js +0 -42
  355. package/src/brickadia/server.js +0 -227
  356. package/src/cli/auth.js +0 -104
  357. package/src/cli/config.js +0 -77
  358. package/src/cli/index.js +0 -6
  359. package/src/cli/installer.js +0 -65
  360. package/src/cli/plugin.js +0 -575
  361. package/src/cli/terminal.js +0 -466
  362. package/src/config/authorizer.js +0 -37
  363. package/src/config/formats/format_js.js +0 -6
  364. package/src/config/formats/format_yml.js +0 -8
  365. package/src/config/index.js +0 -81
  366. package/src/config/reader.js +0 -27
  367. package/src/config/validator.js +0 -32
  368. package/src/config/writer.js +0 -20
  369. package/src/info/default_commands.json +0 -26
  370. package/src/lib.js +0 -23
  371. package/src/main.js +0 -332
  372. package/src/omegga/auth.js +0 -138
  373. package/src/omegga/commandInjector.js +0 -228
  374. package/src/omegga/index.js +0 -22
  375. package/src/omegga/logWrangler.js +0 -323
  376. package/src/omegga/matchers/auth.js +0 -49
  377. package/src/omegga/matchers/chat.js +0 -73
  378. package/src/omegga/matchers/command.js +0 -39
  379. package/src/omegga/matchers/exit.js +0 -19
  380. package/src/omegga/matchers/init.js +0 -23
  381. package/src/omegga/matchers/join.js +0 -115
  382. package/src/omegga/matchers/leave.js +0 -58
  383. package/src/omegga/matchers/mapChange.js +0 -37
  384. package/src/omegga/matchers/version.js +0 -45
  385. package/src/omegga/player.js +0 -585
  386. package/src/omegga/plugin/plugin_jsonrpc_stdio.js +0 -526
  387. package/src/omegga/plugin/plugin_node_safe/proxyOmegga.js +0 -117
  388. package/src/omegga/plugin/plugin_node_safe/worker.js +0 -238
  389. package/src/omegga/plugin/plugin_node_safe.js +0 -473
  390. package/src/omegga/plugin/plugin_node_unsafe.js +0 -177
  391. package/src/omegga/plugin.js +0 -565
  392. package/src/omegga/server.js +0 -658
  393. package/src/omegga/wrapper.js +0 -62
  394. package/src/softconfig.js +0 -64
  395. package/src/util/brick/checkBounds.js +0 -22
  396. package/src/util/brick/constants.js +0 -185
  397. package/src/util/brick/getBounds.js +0 -36
  398. package/src/util/brick/getBrickSize.js +0 -9
  399. package/src/util/brick/getScaleAxis.js +0 -31
  400. package/src/util/brick/index.js +0 -9
  401. package/src/util/brick/rotate.js +0 -43
  402. package/src/util/brick/setOwnership.js +0 -20
  403. package/src/util/chat.js +0 -28
  404. package/src/util/color.js +0 -143
  405. package/src/util/file.js +0 -119
  406. package/src/util/index.js +0 -28
  407. package/src/util/map.js +0 -28
  408. package/src/util/pattern.js +0 -14
  409. package/src/util/time.js +0 -46
  410. package/src/util/uuid.js +0 -8
  411. package/src/util/wsl.js +0 -9
  412. package/src/webserver/backend/api.js +0 -795
  413. package/src/webserver/backend/calendar.js +0 -15
  414. package/src/webserver/backend/database.js +0 -725
  415. package/src/webserver/backend/index.js +0 -206
  416. package/src/webserver/backend/metrics.js +0 -148
  417. package/src/webserver/backend/util.js +0 -75
  418. package/src/webserver/frontend/.eslintrc.yml +0 -26
  419. package/src/webserver/frontend/app.js +0 -78
  420. package/src/webserver/frontend/auth.js +0 -16
  421. package/src/webserver/frontend/components/Background.vue +0 -83
  422. package/src/webserver/frontend/components/Button.vue +0 -105
  423. package/src/webserver/frontend/components/ChatEntry.vue +0 -107
  424. package/src/webserver/frontend/components/ChatTime.vue +0 -40
  425. package/src/webserver/frontend/components/Dimmer.vue +0 -43
  426. package/src/webserver/frontend/components/Dropdown.vue +0 -145
  427. package/src/webserver/frontend/components/Footer.vue +0 -29
  428. package/src/webserver/frontend/components/Header.vue +0 -27
  429. package/src/webserver/frontend/components/InfiniteScroll.vue +0 -51
  430. package/src/webserver/frontend/components/Input.vue +0 -93
  431. package/src/webserver/frontend/components/ListInput.vue +0 -105
  432. package/src/webserver/frontend/components/Loader.vue +0 -98
  433. package/src/webserver/frontend/components/MainMenuButton.vue +0 -83
  434. package/src/webserver/frontend/components/Modal.vue +0 -44
  435. package/src/webserver/frontend/components/NavBar.vue +0 -24
  436. package/src/webserver/frontend/components/PlayerDropdown.vue +0 -210
  437. package/src/webserver/frontend/components/PopoutContent.vue +0 -32
  438. package/src/webserver/frontend/components/RoleDropdown.vue +0 -157
  439. package/src/webserver/frontend/components/Scroll.vue +0 -33
  440. package/src/webserver/frontend/components/Toggle.vue +0 -91
  441. package/src/webserver/frontend/components/index.js +0 -33
  442. package/src/webserver/frontend/css/font.scss +0 -53
  443. package/src/webserver/frontend/css/mixins.scss +0 -49
  444. package/src/webserver/frontend/css/style.scss +0 -166
  445. package/src/webserver/frontend/css/theme.scss +0 -64
  446. package/src/webserver/frontend/partials/NavHeader.vue +0 -55
  447. package/src/webserver/frontend/partials/Page.vue +0 -40
  448. package/src/webserver/frontend/partials/PageContent.vue +0 -31
  449. package/src/webserver/frontend/partials/SideNav.vue +0 -115
  450. package/src/webserver/frontend/partials/index.js +0 -4
  451. package/src/webserver/frontend/router.js +0 -83
  452. package/src/webserver/frontend/views/Auth.vue +0 -190
  453. package/src/webserver/frontend/views/History.vue +0 -462
  454. package/src/webserver/frontend/views/Home.vue +0 -251
  455. package/src/webserver/frontend/views/Main.vue +0 -69
  456. package/src/webserver/frontend/views/NotFound.vue +0 -10
  457. package/src/webserver/frontend/views/Players.vue +0 -425
  458. package/src/webserver/frontend/views/PlayersInspector.vue +0 -538
  459. package/src/webserver/frontend/views/Plugins.vue +0 -217
  460. package/src/webserver/frontend/views/PluginsInspector.vue +0 -418
  461. package/src/webserver/frontend/views/Server.vue +0 -167
  462. package/src/webserver/frontend/views/Users.vue +0 -538
  463. package/src/webserver/frontend/widgets/Chat.vue +0 -124
  464. package/src/webserver/frontend/widgets/Status.vue +0 -91
  465. package/src/webserver/frontend/widgets/index.js +0 -2
  466. package/src/webserver/frontend/widgets/tooltip.js +0 -108
  467. package/src/webserver/index.js +0 -4
@@ -1,238 +0,0 @@
1
- // The safe node plugin is run inside of a worker
2
- // so if the plugin inevitably crashes, only the worker dies
3
- // this also lets plugins get terminated easier by killing the worker
4
- // rather than unloading and reloading code
5
-
6
- const path = require('path');
7
- const fs = require('fs');
8
- const { parentPort } = require('worker_threads');
9
- const { ProxyOmegga } = require('./proxyOmegga.js');
10
- const { EventEmitter } = require('events');
11
-
12
- const { NodeVM } = require('vm2');
13
- require('colors');
14
-
15
- const MAIN_FILE = 'omegga.plugin.js';
16
- let vm, PluginClass, pluginInstance;
17
- let pluginName = 'unnamed plugin';
18
- let messageCounter = 0;
19
- // emitter that receives messages from the parent
20
- const parent = new EventEmitter();
21
-
22
- // handle message passing
23
- parentPort.on('message', ({ action, args }) => parent.emit(action, ...args));
24
-
25
- // emit a message to the parent port - async wait for a reponse
26
- const emit = (action, ...args) => {
27
- const messageId = 'message:' + messageCounter++;
28
-
29
- let rejectFn;
30
- // promise waits for the message to resolve
31
- const promise = new Promise((resolve, reject) => {
32
- parent.once(messageId, resolve);
33
- rejectFn = reject;
34
- });
35
-
36
- try {
37
- // post the message
38
- parentPort.postMessage({ action, args: [messageId, ...args] });
39
- } catch (err) {
40
- rejectFn(err);
41
- }
42
-
43
- // return the promise
44
- return promise;
45
- };
46
-
47
- // tell omegga to exec a command
48
- const exec = cmd => emit('exec', cmd);
49
-
50
- // create the proxy omegga
51
- const omegga = new ProxyOmegga(exec);
52
-
53
- // add plugin fetcher
54
- omegga.getPlugin = async name => {
55
- let plugin = await emit('getPlugin', name);
56
- if (plugin) {
57
- plugin.emit = async (ev, ...args) => {
58
- return await emit('emitPlugin', name, ev, args);
59
- };
60
- return plugin;
61
- } else {
62
- return null;
63
- }
64
- };
65
-
66
- // interface with plugin store
67
- const store = {
68
- get: key => emit('store.get', key),
69
- set: (key, value) => emit('store.set', key, JSON.stringify(value)),
70
- delete: key => emit('store.delete', key),
71
- wipe: () => emit('store.wipe'),
72
- count: () => emit('store.count'),
73
- keys: () => emit('store.keys'),
74
- };
75
-
76
- // generic brickadia events are forwarded to the proxy omegga
77
- parent.on('brickadiaEvent', (type, ...args) => {
78
- if (!vm) return;
79
- try {
80
- omegga.emit(type, ...args);
81
- } catch (e) {
82
- console.log('error in brickadia event', e?.stack ?? e.toString());
83
- }
84
- });
85
-
86
- // create the node vm
87
- function createVm(pluginPath, { builtin = ['*'], external = true } = {}) {
88
- if (vm !== undefined) return [false, 'vm is already created'];
89
-
90
- // create the vm
91
- vm = new NodeVM({
92
- console: 'redirect',
93
- sandbox: {},
94
- require: {
95
- external,
96
- builtin,
97
- root: pluginPath,
98
- },
99
- });
100
-
101
- // plugin log generator function
102
- const ezLog =
103
- (logFn, name, symbol) =>
104
- (...args) =>
105
- console[logFn](name.underline, symbol, ...args);
106
-
107
- // special formatting for stdout
108
- vm.on('console.log', ezLog('log', pluginName, '>>'.green));
109
- vm.on('console.error', ezLog('error', pluginName.brightRed, '!>'.red));
110
- vm.on('console.info', ezLog('info', pluginName, '#>'.blue));
111
- vm.on('console.warn', ezLog('warn', pluginName.brightYellow, ':>'.yellow));
112
- vm.on('console.trace', ezLog('trace', pluginName, 'T>'.grey));
113
-
114
- global.OMEGGA_UTIL = require('../../../util/index.js');
115
- // pass in util functions
116
- vm.freeze(global.OMEGGA_UTIL, 'OMEGGA_UTIL');
117
- vm.freeze(omegga, 'Omegga');
118
-
119
- const file = path.join(pluginPath, MAIN_FILE);
120
- let pluginCode;
121
-
122
- try {
123
- pluginCode = fs.readFileSync(file);
124
- } catch (e) {
125
- emit('error', 'failed to read plugin source: ' + e?.stack ?? e.toString());
126
- throw 'failed to read plugin source: ' + e?.stack ?? e.toString();
127
- }
128
-
129
- // proxy the plugin out of the vm
130
- // potential for performance improvement by using VM.script to precompile plugins
131
- try {
132
- PluginClass = vm.run(pluginCode.toString(), file);
133
- } catch (e) {
134
- emit('error', 'plugin failed to init');
135
- console.log(e);
136
- throw 'plugin failed to init: ' + e?.stack ?? e.toString();
137
- }
138
-
139
- if (
140
- !PluginClass ||
141
- typeof PluginClass !== 'function' ||
142
- typeof PluginClass.prototype !== 'object'
143
- ) {
144
- PluginClass = undefined;
145
- emit('error', 'plugin does not export a class');
146
- throw 'plugin does not export a class';
147
- }
148
-
149
- if (typeof PluginClass.prototype.init !== 'function') {
150
- PluginClass = undefined;
151
- emit('error', 'plugin is missing init() function');
152
- throw 'plugin is missing init() function';
153
- }
154
-
155
- if (typeof PluginClass.prototype.stop !== 'function') {
156
- PluginClass = undefined;
157
- emit('error', 'plugin is missing stop() function');
158
- throw 'plugin is missing stop() function';
159
- }
160
- }
161
-
162
- // kill this plugin
163
- parent.on('kill', resp => {
164
- emit(resp);
165
- process.exit(0);
166
- });
167
-
168
- // set plugin name
169
- parent.on('name', (resp, name) => {
170
- pluginName = name;
171
- // temp save prefix changes to avoid collision
172
- omegga._tempSavePrefix = 'omegga_' + name + '_temp';
173
- emit(resp);
174
- });
175
-
176
- // get memory usage for this plugin
177
- parent.on('mem', resp => emit(resp, 'mem', process.memoryUsage()));
178
-
179
- // create the vm
180
- parent.on('load', (resp, pluginPath, options) => {
181
- try {
182
- createVm(pluginPath, options);
183
- emit(resp, true);
184
- } catch (err) {
185
- console.error('error creating vm', err?.stack ?? err.toString());
186
- emit(resp, false);
187
- }
188
- });
189
-
190
- // start the plugin with a faux omegga
191
- // resp is an action sent back to the parent process
192
- // to coordinate async funcs
193
- parent.on('start', async (resp, config) => {
194
- try {
195
- pluginInstance = new PluginClass(omegga, config, store);
196
- const result = await pluginInstance.init();
197
- // if a plugin init returns a list of strings, treat them as the list of commands
198
- if (typeof result === 'object' && result) {
199
- // if registeredCommands is in the results, register the provided strings as commands
200
- const cmds = result.registeredCommands;
201
- if (
202
- cmds &&
203
- cmds instanceof Array &&
204
- cmds.every(i => typeof i === 'string')
205
- ) {
206
- emit('command.registers', JSON.stringify(cmds));
207
- }
208
- }
209
- emit(resp, true);
210
- } catch (err) {
211
- emit('error', 'error starting plugin', err?.stack ?? JSON.stringify(err));
212
- emit(resp, false);
213
- console.error(err);
214
- }
215
- });
216
-
217
- // stop the plugin
218
- parent.on('stop', async resp => {
219
- try {
220
- if (pluginInstance) {
221
- await pluginInstance.stop();
222
- }
223
- pluginInstance = undefined;
224
- emit(resp, true);
225
- } catch (err) {
226
- emit('error', 'error stopping plugin', err?.stack ?? toString());
227
- emit(resp, false);
228
- }
229
- });
230
-
231
- // handle emitPlugins
232
- parent.on('emitPlugin', async (resp, ev, from, args) => {
233
- if (pluginInstance?.pluginEvent) {
234
- emit(resp, await pluginInstance.pluginEvent(ev, from, ...args));
235
- } else {
236
- emit(resp, null);
237
- }
238
- });
@@ -1,473 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const { EventEmitter } = require('events');
4
- const readline = require('readline');
5
-
6
- const { Worker } = require('worker_threads');
7
-
8
- const { Plugin } = require('../plugin.js');
9
- const { bootstrap } = require('./plugin_node_safe/proxyOmegga.js');
10
- const Omegga = require('../server.js');
11
-
12
- // Main plugin file (like index.js)
13
- // this isn't named 'index.js' or 'plugin.js' because those may be filenames
14
- // used with other loaders (rpc loader) and are too generic
15
- // omegga.main.js is rather unique and helps avoid collision
16
- const MAIN_FILE = 'omegga.plugin.js';
17
-
18
- // Documentation file (contains name, description, author, command helptext)
19
- const DOC_FILE = 'doc.json';
20
- const ACCESS_FILE = 'access.json';
21
- const PLUGIN_FILE = 'plugin.json';
22
-
23
- class NodeVmPlugin extends Plugin {
24
- #worker = undefined;
25
- #outInterface = undefined;
26
- #errInterface = undefined;
27
-
28
- // every node vm plugin requires a main file, a doc file, and an access file
29
- // may evolve this so it checks the contents of the doc file later
30
- static canLoad(pluginPath) {
31
- return (
32
- fs.existsSync(path.join(pluginPath, MAIN_FILE)) &&
33
- fs.existsSync(path.join(pluginPath, DOC_FILE)) &&
34
- fs.existsSync(path.join(pluginPath, ACCESS_FILE))
35
- );
36
- }
37
-
38
- // safe node plugins are limited
39
- static getFormat() {
40
- return 'node_safe';
41
- }
42
-
43
- constructor(pluginPath, omegga) {
44
- super(pluginPath, omegga);
45
-
46
- // event emitter and message counter for keeping track of worker events
47
- this.plugin = new EventEmitter();
48
- this.messageCounter = 0;
49
-
50
- // TODO: validate documentation
51
- this.documentation = Plugin.readJSON(path.join(pluginPath, DOC_FILE));
52
- this.pluginConfig = Plugin.readJSON(path.join(pluginPath, PLUGIN_FILE));
53
-
54
- // access list is a list of builtin requires
55
- // can be ['*'] for everything
56
- this.access = Plugin.readJSON(path.join(pluginPath, ACCESS_FILE)) || [];
57
-
58
- // list of registered commands
59
- this.commands = [];
60
-
61
- // verify access is an array of strings
62
- if (
63
- !(this.access instanceof Array) ||
64
- !this.access.every(s => typeof s === 'string')
65
- ) {
66
- throw new Error('access list not a string array');
67
- }
68
-
69
- // plugin name
70
- const name = this.getName();
71
-
72
- // when the worker emits an error or a log, pass it up to omegga
73
- this.plugin.on('error', (resp, ...args) => {
74
- Omegga.error(name.brightRed.underline, '!>'.red, ...args);
75
- this.notify(resp);
76
- });
77
- this.plugin.on('log', (resp, ...args) => {
78
- Omegga.log(name.underline, '>>'.green, ...args);
79
- this.notify(resp);
80
- });
81
-
82
- // let the worker write commands to brickadia
83
- this.plugin.on('exec', (_, cmd) => omegga.writeln(cmd));
84
-
85
- // storage interface
86
- this.plugin.on('store.get', async (resp, key) => {
87
- try {
88
- this.notify(resp, await this.storage.get(key));
89
- } catch (e) {
90
- Omegga.error(
91
- name.brightRed.underline,
92
- '!>'.red,
93
- 'error in store.get of',
94
- key
95
- );
96
- }
97
- });
98
- this.plugin.on('store.set', async (resp, key, value) => {
99
- try {
100
- await this.storage.set(key, JSON.parse(value));
101
- } catch (e) {
102
- Omegga.error(
103
- name.brightRed.underline,
104
- '!>'.red,
105
- 'error in store.set of',
106
- key,
107
- value
108
- );
109
- }
110
- this.notify(resp);
111
- });
112
- this.plugin.on('store.delete', async (resp, key) => {
113
- try {
114
- await this.storage.delete(key);
115
- } catch (e) {
116
- Omegga.error(
117
- name.brightRed.underline,
118
- '!>'.red,
119
- 'error in store.delete of',
120
- key
121
- );
122
- }
123
- this.notify(resp);
124
- });
125
- this.plugin.on('store.wipe', async resp => {
126
- try {
127
- await this.storage.wipe();
128
- } catch (e) {
129
- Omegga.error(name.brightRed.underline, '!>'.red, 'error in store.wipe');
130
- }
131
- this.notify(resp);
132
- });
133
- this.plugin.on('store.count', async resp => {
134
- try {
135
- this.notify(resp, await this.storage.count());
136
- } catch (e) {
137
- Omegga.error(
138
- name.brightRed.underline,
139
- '!>'.red,
140
- 'error in store.count'
141
- );
142
- }
143
- });
144
- this.plugin.on('store.keys', async resp => {
145
- try {
146
- this.notify(resp, await this.storage.keys());
147
- } catch (e) {
148
- Omegga.error(name.brightRed.underline, '!>'.red, 'error in store.keys');
149
- }
150
- });
151
-
152
- // plugin fetching
153
- this.plugin.on('getPlugin', async (resp, name) => {
154
- const plugin = this.omegga.pluginLoader.plugins.find(
155
- p => p.getName() === name
156
- );
157
-
158
- if (plugin) {
159
- this.notify(resp, {
160
- name,
161
- documentation: plugin.getDocumentation(),
162
- loaded: plugin.isLoaded(),
163
- });
164
- } else {
165
- this.notify(resp);
166
- }
167
- });
168
-
169
- this.plugin.on('emitPlugin', async (resp, target, ev, args) => {
170
- const plugin = this.omegga.pluginLoader.plugins.find(
171
- p => p.getName() === target
172
- );
173
-
174
- if (plugin) {
175
- let r = await plugin.emitPlugin(ev, name, args);
176
- this.notify(resp, r);
177
- } else {
178
- Omegga.error(name.brightRed.underline, '!>'.red, 'error in emitPlugin');
179
- }
180
- });
181
-
182
- // command registration
183
- this.plugin.on('command.registers', async (_, blob) => {
184
- if (typeof blob !== 'string') return;
185
- const registers = JSON.parse(blob);
186
- // ensure registers is an array of strings
187
- if (
188
- !(registers instanceof Array) ||
189
- registers.some(i => typeof i !== 'string')
190
- )
191
- return;
192
-
193
- this.commands = registers;
194
- });
195
-
196
- // listen on every message, post them to to the worker
197
- this.eventPassthrough = this.eventPassthrough.bind(this);
198
- }
199
-
200
- // emit a custom plugin event
201
- async emitPlugin(ev, from, args) {
202
- const [r] = (await this.emit('emitPlugin', ev, from, args)) ?? [];
203
- return r;
204
- }
205
-
206
- // documentation is based on doc.json file
207
- getDocumentation() {
208
- return this.documentation;
209
- }
210
-
211
- // loaded state is based on if a worker exists
212
- isLoaded() {
213
- return !!this.#worker;
214
- }
215
-
216
- // determing if a command is registered
217
- isCommand(cmd) {
218
- return this.commands.includes(cmd);
219
- }
220
-
221
- // require the plugin into the system, run the init func
222
- async load() {
223
- // can't load the plugin if it's already loaded
224
- if (typeof this.#worker !== 'undefined') return false;
225
-
226
- // vm restriction settings, default is access to everything
227
- const vmOptions = {
228
- builtin: this.access, // TODO: reference access file
229
- external: true, // TODO: reference access file
230
- };
231
- this.commands = [];
232
-
233
- try {
234
- const config = await this.storage.getConfig();
235
- if (this.pluginConfig?.emitConfig) {
236
- await fs.promises.writeFile(
237
- path.join(this.path, this.pluginConfig.emitConfig),
238
- JSON.stringify(config)
239
- );
240
- }
241
- this.createWorker();
242
-
243
- // tell the worker its name :)
244
- await this.emit('name', this.getName());
245
-
246
- // create the vm, export the plugin's class
247
- if (!(await this.emit('load', this.path, vmOptions))[0]) throw '';
248
-
249
- // get some initial information to create an omegga proxy
250
- const initialData = bootstrap(this.omegga);
251
- // send all of the mock events to the proxy omegga
252
- for (const ev in initialData) {
253
- try {
254
- this.#worker.postMessage({
255
- action: 'brickadiaEvent',
256
- args: [ev, ...initialData[ev]],
257
- });
258
- } catch (e) {
259
- /* just writing 'safe' code :) */
260
- }
261
- }
262
-
263
- // pass events through
264
- this.omegga.on('*', this.eventPassthrough);
265
-
266
- // actually start the plugin
267
- if (!(await this.emit('start', config))[0]) throw 'plugin failed start';
268
-
269
- this.emitStatus();
270
- return true;
271
- } catch (e) {
272
- // kill the worker
273
- await this.emit('kill');
274
-
275
- Omegga.error(
276
- '!>'.red,
277
- 'error loading node vm plugin',
278
- this.getName().brightRed.underline,
279
- e
280
- );
281
- this.emitStatus();
282
- return false;
283
- }
284
- }
285
-
286
- // disrequire the plugin into the system, run the stop func
287
- unload() {
288
- let frozen = true,
289
- timed = false;
290
-
291
- return Promise.race([
292
- (async () => {
293
- // can't unload the plugin if it hasn't been loaded
294
- if (typeof this.#worker === 'undefined') return false;
295
-
296
- try {
297
- // stop the plugin (cleanly)
298
- await this.emit('stop');
299
-
300
- // remove listeners
301
- this.omegga.off('*', this.eventPassthrough);
302
-
303
- // let the unload function wait for the worker to properly cleanup
304
- const promise = new Promise(res => {
305
- this.#worker.once('exit', res);
306
- });
307
-
308
- // kill the worker
309
- await this.emit('kill');
310
-
311
- // wait for the worker to exit
312
- await promise;
313
-
314
- frozen = false;
315
- if (timed) return;
316
- this.emitStatus();
317
- this.commands = [];
318
- return true;
319
- } catch (e) {
320
- frozen = false;
321
- if (timed) return;
322
-
323
- Omegga.error(
324
- '!>'.red,
325
- 'error unloading node plugin',
326
- this.getName().brightRed.underline,
327
- e
328
- );
329
- this.emitStatus();
330
- return false;
331
- }
332
- })(),
333
- new Promise(resolve => {
334
- // check if the worker is frozen (while true)
335
- setTimeout(() => {
336
- if (!frozen) return;
337
- this.plugin.emit(
338
- 'error',
339
- 0,
340
- 'I appear to be in an unresponsive state - terminating worker'
341
- );
342
-
343
- // remove listeners
344
- this.omegga.off('*', this.eventPassthrough);
345
-
346
- // tell the worker to exit
347
- if (this.#worker) this.#worker.emit('exit');
348
-
349
- // terminate the worker if it still exists
350
- if (this.#worker) this.#worker.terminate();
351
-
352
- timed = true;
353
- resolve(true);
354
- this.emitStatus();
355
- }, 5000);
356
- }),
357
- ]);
358
- }
359
-
360
- // emit an action to the worker and return a promise with its response
361
- emit(action, ...args) {
362
- if (!this.#worker) return;
363
-
364
- const messageId = 'message:' + this.messageCounter++;
365
-
366
- // promise waits for the message to resolve
367
- const promise = new Promise(resolve =>
368
- this.plugin.once(messageId, (_, ...x) => resolve(x))
369
- );
370
-
371
- // post the message
372
- try {
373
- this.#worker.postMessage({
374
- action,
375
- args: [messageId, ...args],
376
- });
377
- } catch (e) {
378
- return Promise.reject(e);
379
- }
380
-
381
- // return the promise
382
- return promise;
383
- }
384
-
385
- // notify a response to the worker
386
- notify(action, ...args) {
387
- if (!this.#worker) return;
388
-
389
- // post the message
390
- try {
391
- this.#worker.postMessage({
392
- action,
393
- args: [...args],
394
- });
395
- } catch (e) {
396
- // do nothing here
397
- }
398
- }
399
-
400
- // create the worker for this plugin, attach emitter
401
- createWorker() {
402
- this.#worker = new Worker(
403
- path.join(__dirname, 'plugin_node_safe/worker.js'),
404
- {
405
- stdout: true,
406
- }
407
- );
408
-
409
- // pipe plugin output into omegga
410
- this.#outInterface = readline.createInterface({
411
- input: this.#worker.stdout,
412
- terminal: false,
413
- });
414
- this.#errInterface = readline.createInterface({
415
- input: this.#worker.stderr,
416
- terminal: false,
417
- });
418
- this.#outInterface.on('line', Omegga.log);
419
- this.#errInterface.on('line', Omegga.error);
420
-
421
- // attach message emitter
422
- this.#worker.on('message', ({ action, args }) =>
423
- this.plugin.emit(action, ...args)
424
- );
425
-
426
- // broadcast an error if there is one
427
- this.#worker.on('error', err => {
428
- Omegga.error(
429
- '!>'.red,
430
- 'error in plugin',
431
- this.getName().brightRed.underline,
432
- err
433
- );
434
- });
435
-
436
- // when the worker exits - set its variable to undefined this knows it's stopped
437
- this.#worker.on('exit', () => {
438
- this.omegga.off('*', this.eventPassthrough);
439
- this.#outInterface.removeAllListeners('line');
440
- this.#errInterface.removeAllListeners('line');
441
- try {
442
- if (this.#worker) this.#worker.terminate();
443
- } catch (err) {
444
- Omegga.error(
445
- '!>'.red,
446
- 'Error terminating worker for',
447
- this.getName().brightRed.underline,
448
- err
449
- );
450
- }
451
- this.#worker = undefined;
452
- this.emitStatus();
453
- });
454
- }
455
-
456
- eventPassthrough(...args) {
457
- // worker does not exist
458
- if (!this.#worker) return;
459
-
460
- try {
461
- // post the message
462
- this.#worker.postMessage({
463
- action: 'brickadiaEvent',
464
- args,
465
- });
466
- } catch (e) {
467
- // make sure post message doesn't crash the entire app
468
- Omegga.error('!>'.red, 'error sending to plugin', ...args, e);
469
- }
470
- }
471
- }
472
-
473
- module.exports = NodeVmPlugin;