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.
- package/README.md +142 -62
- package/bin/omegga +10 -4
- package/dist/brickadia/config.d.ts +3 -0
- package/dist/brickadia/config.d.ts.map +1 -0
- package/dist/brickadia/config.js +61 -0
- package/dist/brickadia/config.js.map +1 -0
- package/dist/brickadia/presets.d.ts +65 -0
- package/dist/brickadia/presets.js +3 -0
- package/dist/brickadia/presets.js.map +1 -0
- package/dist/brickadia/server.d.ts +20 -0
- package/dist/brickadia/server.d.ts.map +1 -0
- package/dist/brickadia/server.js +188 -0
- package/dist/brickadia/server.js.map +1 -0
- package/dist/brickadia/types.d.ts +45 -0
- package/dist/brickadia/types.d.ts.map +1 -0
- package/dist/brickadia/types.js +3 -0
- package/dist/brickadia/types.js.map +1 -0
- package/dist/cli/auth.d.ts +20 -0
- package/dist/cli/auth.d.ts.map +1 -0
- package/dist/cli/auth.js +115 -0
- package/dist/cli/auth.js.map +1 -0
- package/dist/cli/config.d.ts +10 -0
- package/dist/cli/config.d.ts.map +1 -0
- package/dist/cli/config.js +72 -0
- package/dist/cli/config.js.map +1 -0
- package/dist/cli/index.d.ts +20 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +15 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/installer.d.ts +1 -0
- package/dist/cli/installer.d.ts.map +1 -0
- package/dist/cli/installer.js +55 -0
- package/dist/cli/installer.js.map +1 -0
- package/dist/cli/plugin.d.ts +11 -0
- package/dist/cli/plugin.d.ts.map +1 -0
- package/dist/cli/plugin.js +598 -0
- package/dist/cli/plugin.js.map +1 -0
- package/dist/cli/terminal.d.ts +34 -0
- package/dist/cli/terminal.d.ts.map +1 -0
- package/dist/cli/terminal.js +395 -0
- package/dist/cli/terminal.js.map +1 -0
- package/dist/config/authorizer.d.ts +2 -0
- package/dist/config/authorizer.d.ts.map +1 -0
- package/dist/config/authorizer.js +38 -0
- package/dist/config/authorizer.js.map +1 -0
- package/dist/config/formats/format_js.d.ts +3 -0
- package/dist/config/formats/format_js.d.ts.map +1 -0
- package/dist/config/formats/format_js.js +10 -0
- package/dist/config/formats/format_js.js.map +1 -0
- package/dist/config/formats/format_yml.d.ts +3 -0
- package/dist/config/formats/format_yml.d.ts.map +1 -0
- package/dist/config/formats/format_yml.js +14 -0
- package/dist/config/formats/format_yml.js.map +1 -0
- package/dist/config/index.d.ts +18 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +86 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/reader.d.ts +3 -0
- package/dist/config/reader.d.ts.map +1 -0
- package/dist/config/reader.js +30 -0
- package/dist/config/reader.js.map +1 -0
- package/dist/config/types.d.ts +37 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +3 -0
- package/dist/config/types.js.map +1 -0
- package/dist/config/validator.d.ts +6 -0
- package/dist/config/validator.d.ts.map +1 -0
- package/dist/config/validator.js +26 -0
- package/dist/config/validator.js.map +1 -0
- package/dist/config/writer.d.ts +3 -0
- package/dist/config/writer.d.ts.map +1 -0
- package/dist/config/writer.js +25 -0
- package/dist/config/writer.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +55 -0
- package/dist/index.js.map +1 -0
- package/dist/info/default_commands.json +28 -0
- package/dist/lib.d.ts +21 -0
- package/dist/lib.d.ts.map +1 -0
- package/dist/lib.js +54 -0
- package/dist/lib.js.map +1 -0
- package/dist/logger.d.ts +41 -0
- package/dist/logger.js +67 -0
- package/dist/logger.js.map +1 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +284 -0
- package/dist/main.js.map +1 -0
- package/dist/omegga/auth.d.ts +6 -0
- package/dist/omegga/auth.d.ts.map +1 -0
- package/dist/omegga/auth.js +139 -0
- package/dist/omegga/auth.js.map +1 -0
- package/dist/omegga/commandInjector.d.ts +35 -0
- package/dist/omegga/commandInjector.d.ts.map +1 -0
- package/dist/omegga/commandInjector.js +234 -0
- package/dist/omegga/commandInjector.js.map +1 -0
- package/dist/omegga/index.d.ts +7 -0
- package/dist/omegga/index.d.ts.map +1 -0
- package/dist/omegga/index.js +43 -0
- package/dist/omegga/index.js.map +1 -0
- package/dist/omegga/logWrangler.d.ts +32 -0
- package/dist/omegga/logWrangler.d.ts.map +1 -0
- package/dist/omegga/logWrangler.js +279 -0
- package/dist/omegga/logWrangler.js.map +1 -0
- package/dist/omegga/matchers/auth.d.ts +9 -0
- package/dist/omegga/matchers/auth.d.ts.map +1 -0
- package/dist/omegga/matchers/auth.js +53 -0
- package/dist/omegga/matchers/auth.js.map +1 -0
- package/dist/omegga/matchers/chat.d.ts +9 -0
- package/dist/omegga/matchers/chat.d.ts.map +1 -0
- package/dist/omegga/matchers/chat.js +68 -0
- package/dist/omegga/matchers/chat.js.map +1 -0
- package/dist/omegga/matchers/command.d.ts +7 -0
- package/dist/omegga/matchers/command.d.ts.map +1 -0
- package/dist/omegga/matchers/command.js +39 -0
- package/dist/omegga/matchers/command.js.map +1 -0
- package/dist/omegga/matchers/exit.d.ts +3 -0
- package/dist/omegga/matchers/exit.d.ts.map +1 -0
- package/dist/omegga/matchers/exit.js +21 -0
- package/dist/omegga/matchers/exit.js.map +1 -0
- package/dist/omegga/matchers/index.d.ts +3 -0
- package/dist/omegga/matchers/index.d.ts.map +1 -0
- package/dist/omegga/matchers/index.js +39 -0
- package/dist/omegga/matchers/index.js.map +1 -0
- package/dist/omegga/matchers/init.d.ts +3 -0
- package/dist/omegga/matchers/init.d.ts.map +1 -0
- package/dist/omegga/matchers/init.js +26 -0
- package/dist/omegga/matchers/init.js.map +1 -0
- package/dist/omegga/matchers/interact.d.ts +4 -0
- package/dist/omegga/matchers/interact.js +39 -0
- package/dist/omegga/matchers/interact.js.map +1 -0
- package/dist/omegga/matchers/join.d.ts +4 -0
- package/dist/omegga/matchers/join.d.ts.map +1 -0
- package/dist/omegga/matchers/join.js +95 -0
- package/dist/omegga/matchers/join.js.map +1 -0
- package/dist/omegga/matchers/leave.d.ts +4 -0
- package/dist/omegga/matchers/leave.d.ts.map +1 -0
- package/dist/omegga/matchers/leave.js +59 -0
- package/dist/omegga/matchers/leave.js.map +1 -0
- package/dist/omegga/matchers/mapChange.d.ts +3 -0
- package/dist/omegga/matchers/mapChange.d.ts.map +1 -0
- package/dist/omegga/matchers/mapChange.js +38 -0
- package/dist/omegga/matchers/mapChange.js.map +1 -0
- package/dist/omegga/matchers/types.d.ts +5 -0
- package/dist/omegga/matchers/types.d.ts.map +1 -0
- package/dist/omegga/matchers/types.js +7 -0
- package/dist/omegga/matchers/types.js.map +1 -0
- package/dist/omegga/matchers/version.d.ts +3 -0
- package/dist/omegga/matchers/version.d.ts.map +1 -0
- package/dist/omegga/matchers/version.js +45 -0
- package/dist/omegga/matchers/version.js.map +1 -0
- package/dist/omegga/player.d.ts +71 -0
- package/dist/omegga/player.d.ts.map +1 -0
- package/dist/omegga/player.js +442 -0
- package/dist/omegga/player.js.map +1 -0
- package/dist/omegga/plugin/plugin_jsonrpc_stdio.d.ts +23 -0
- package/dist/omegga/plugin/plugin_jsonrpc_stdio.d.ts.map +1 -0
- package/dist/omegga/plugin/plugin_jsonrpc_stdio.js +441 -0
- package/dist/omegga/plugin/plugin_jsonrpc_stdio.js.map +1 -0
- package/dist/omegga/plugin/plugin_node_safe/proxyOmegga.d.ts +129 -0
- package/dist/omegga/plugin/plugin_node_safe/proxyOmegga.d.ts.map +1 -0
- package/dist/omegga/plugin/plugin_node_safe/proxyOmegga.js +260 -0
- package/dist/omegga/plugin/plugin_node_safe/proxyOmegga.js.map +1 -0
- package/dist/omegga/plugin/plugin_node_safe/worker.d.ts +1 -0
- package/dist/omegga/plugin/plugin_node_safe/worker.d.ts.map +1 -0
- package/dist/omegga/plugin/plugin_node_safe/worker.js +289 -0
- package/dist/omegga/plugin/plugin_node_safe/worker.js.map +1 -0
- package/dist/omegga/plugin/plugin_node_safe.d.ts +24 -0
- package/dist/omegga/plugin/plugin_node_safe.d.ts.map +1 -0
- package/dist/omegga/plugin/plugin_node_safe.js +397 -0
- package/dist/omegga/plugin/plugin_node_safe.js.map +1 -0
- package/dist/omegga/plugin/plugin_node_unsafe.d.ts +13 -0
- package/dist/omegga/plugin/plugin_node_unsafe.d.ts.map +1 -0
- package/dist/omegga/plugin/plugin_node_unsafe.js +178 -0
- package/dist/omegga/plugin/plugin_node_unsafe.js.map +1 -0
- package/dist/omegga/plugin.d.ts +86 -0
- package/dist/omegga/plugin.d.ts.map +1 -0
- package/dist/omegga/plugin.js +458 -0
- package/dist/omegga/plugin.js.map +1 -0
- package/dist/omegga/server.d.ts +149 -0
- package/dist/omegga/server.d.ts.map +1 -0
- package/dist/omegga/server.js +601 -0
- package/dist/omegga/server.js.map +1 -0
- package/dist/omegga/types.d.ts +48 -0
- package/dist/omegga/types.d.ts.map +1 -0
- package/dist/omegga/types.js +3 -0
- package/dist/omegga/types.js.map +1 -0
- package/dist/omegga/wrapper.d.ts +22 -0
- package/dist/omegga/wrapper.d.ts.map +1 -0
- package/dist/omegga/wrapper.js +75 -0
- package/dist/omegga/wrapper.js.map +1 -0
- package/dist/omeggaplugin.d.ts +1 -0
- package/dist/omeggaplugin.js +4 -0
- package/dist/omeggaplugin.js.map +1 -0
- package/dist/plugin.d.ts +781 -0
- package/dist/plugin.js +41 -0
- package/dist/plugin.js.map +1 -0
- package/dist/softconfig.d.ts +51 -0
- package/dist/softconfig.d.ts.map +1 -0
- package/dist/softconfig.js +82 -0
- package/dist/softconfig.js.map +1 -0
- package/dist/util/brick/checkBounds.d.ts +8 -0
- package/dist/util/brick/checkBounds.d.ts.map +1 -0
- package/dist/util/brick/checkBounds.js +22 -0
- package/dist/util/brick/checkBounds.js.map +1 -0
- package/dist/util/brick/constants.d.ts +18 -0
- package/dist/util/brick/constants.d.ts.map +1 -0
- package/dist/util/brick/constants.js +184 -0
- package/dist/util/brick/constants.js.map +1 -0
- package/dist/util/brick/getBounds.d.ts +4 -0
- package/dist/util/brick/getBounds.d.ts.map +1 -0
- package/dist/util/brick/getBounds.js +39 -0
- package/dist/util/brick/getBounds.js.map +1 -0
- package/dist/util/brick/getBrickSize.d.ts +3 -0
- package/dist/util/brick/getBrickSize.d.ts.map +1 -0
- package/dist/util/brick/getBrickSize.js +12 -0
- package/dist/util/brick/getBrickSize.js.map +1 -0
- package/dist/util/brick/getScaleAxis.d.ts +3 -0
- package/dist/util/brick/getScaleAxis.d.ts.map +1 -0
- package/dist/util/brick/getScaleAxis.js +38 -0
- package/dist/util/brick/getScaleAxis.js.map +1 -0
- package/dist/util/brick/index.d.ts +13 -0
- package/dist/util/brick/index.d.ts.map +1 -0
- package/dist/util/brick/index.js +29 -0
- package/dist/util/brick/index.js.map +1 -0
- package/dist/util/brick/rotate.d.ts +17 -0
- package/dist/util/brick/rotate.d.ts.map +1 -0
- package/dist/util/brick/rotate.js +38 -0
- package/dist/util/brick/rotate.js.map +1 -0
- package/dist/util/brick/setOwnership.d.ts +12 -0
- package/dist/util/brick/setOwnership.d.ts.map +1 -0
- package/dist/util/brick/setOwnership.js +21 -0
- package/dist/util/brick/setOwnership.js.map +1 -0
- package/dist/util/chat.d.ts +23 -0
- package/dist/util/chat.d.ts.map +1 -0
- package/dist/util/chat.js +50 -0
- package/dist/util/chat.js.map +1 -0
- package/dist/util/color.d.ts +13 -0
- package/dist/util/color.d.ts.map +1 -0
- package/dist/util/color.js +130 -0
- package/dist/util/color.js.map +1 -0
- package/dist/util/file.d.ts +5 -0
- package/dist/util/file.d.ts.map +1 -0
- package/dist/util/file.js +114 -0
- package/dist/util/file.js.map +1 -0
- package/dist/util/index.d.ts +162 -0
- package/dist/util/index.d.ts.map +1 -0
- package/dist/util/index.js +92 -0
- package/dist/util/index.js.map +1 -0
- package/dist/util/map.d.ts +6 -0
- package/dist/util/map.d.ts.map +1 -0
- package/dist/util/map.js +26 -0
- package/dist/util/map.js.map +1 -0
- package/dist/util/pattern.d.ts +1 -0
- package/dist/util/pattern.d.ts.map +1 -0
- package/dist/util/pattern.js +11 -0
- package/dist/util/pattern.js.map +1 -0
- package/dist/util/time.d.ts +4 -0
- package/dist/util/time.d.ts.map +1 -0
- package/dist/util/time.js +41 -0
- package/dist/util/time.js.map +1 -0
- package/dist/util/uuid.d.ts +2 -0
- package/dist/util/uuid.d.ts.map +1 -0
- package/dist/util/uuid.js +8 -0
- package/dist/util/uuid.js.map +1 -0
- package/dist/util/wsl.d.ts +1 -0
- package/dist/util/wsl.d.ts.map +1 -0
- package/dist/util/wsl.js +14 -0
- package/dist/util/wsl.js.map +1 -0
- package/dist/webserver/backend/api.d.ts +3 -0
- package/dist/webserver/backend/api.d.ts.map +1 -0
- package/dist/webserver/backend/api.js +685 -0
- package/dist/webserver/backend/api.js.map +1 -0
- package/dist/webserver/backend/calendar.d.ts +5 -0
- package/dist/webserver/backend/calendar.d.ts.map +1 -0
- package/dist/webserver/backend/calendar.js +21 -0
- package/dist/webserver/backend/calendar.js.map +1 -0
- package/dist/webserver/backend/database.d.ts +149 -0
- package/dist/webserver/backend/database.d.ts.map +1 -0
- package/dist/webserver/backend/database.js +575 -0
- package/dist/webserver/backend/database.js.map +1 -0
- package/dist/webserver/backend/index.d.ts +31 -0
- package/dist/webserver/backend/index.d.ts.map +1 -0
- package/dist/webserver/backend/index.js +189 -0
- package/dist/webserver/backend/index.js.map +1 -0
- package/dist/webserver/backend/metrics.d.ts +3 -0
- package/dist/webserver/backend/metrics.d.ts.map +1 -0
- package/dist/webserver/backend/metrics.js +203 -0
- package/dist/webserver/backend/metrics.js.map +1 -0
- package/dist/webserver/backend/types.d.ts +115 -0
- package/dist/webserver/backend/types.d.ts.map +1 -0
- package/dist/webserver/backend/types.js +3 -0
- package/dist/webserver/backend/types.js.map +1 -0
- package/dist/webserver/backend/util.d.ts +2 -0
- package/dist/webserver/backend/util.d.ts.map +1 -0
- package/dist/webserver/backend/util.js +78 -0
- package/dist/webserver/backend/util.js.map +1 -0
- package/dist/webserver/index.d.ts +2 -0
- package/dist/webserver/index.d.ts.map +1 -0
- package/dist/webserver/index.js +9 -0
- package/dist/webserver/index.js.map +1 -0
- package/{src/webserver/frontend → frontend}/app.html +0 -0
- package/{src/webserver/frontend → frontend}/assets/fonts/GlacialIndifferenceBold.ttf +0 -0
- package/{src/webserver/frontend → frontend}/assets/fonts/GlacialIndifferenceItalic.otf +0 -0
- package/{src/webserver/frontend → frontend}/assets/fonts/GlacialIndifferenceMedium.otf +0 -0
- package/{src/webserver/frontend → frontend}/assets/fonts/GlacialIndifferenceRegular.ttf +0 -0
- package/{src/webserver/frontend → frontend}/assets/fonts/RobotoBold.ttf +0 -0
- package/{src/webserver/frontend → frontend}/assets/fonts/RobotoItalic.ttf +0 -0
- package/{src/webserver/frontend → frontend}/assets/fonts/RobotoRegular.ttf +0 -0
- package/{src/webserver/frontend → frontend}/assets/img/auth_bg.webp +0 -0
- package/{src/webserver/frontend → frontend}/assets/img/dark_bg.webp +0 -0
- package/{src/webserver/frontend → frontend}/assets/img/turkey.webp +0 -0
- package/{src/webserver/frontend → frontend}/auth.html +0 -0
- package/index.js +10 -2
- package/package.json +44 -16
- package/public/app.bundle.js +537 -73
- package/public/app.bundle.js.map +1 -1
- package/public/app.css +727 -2
- package/public/app.css.map +1 -1
- package/public/auth.bundle.js +18 -18
- package/public/auth.bundle.js.map +1 -1
- package/public/auth.css +364 -2
- package/public/auth.css.map +1 -1
- package/templates/rpc/README.md +29 -0
- package/templates/rpc/doc.json +7 -0
- package/templates/rpc/omegga_plugin +0 -0
- package/templates/rpc/plugin.json +4 -0
- package/templates/rpc/setup.sh +3 -0
- package/templates/safe/README.md +29 -0
- package/templates/safe/access.json +1 -0
- package/templates/safe/doc.json +7 -0
- package/templates/safe/omegga.plugin.js +20 -0
- package/templates/safe/plugin.json +4 -0
- package/templates/safe/setup.sh +4 -0
- package/templates/safe-ts/.gitignore.rename +3 -0
- package/templates/safe-ts/README.md +29 -0
- package/templates/safe-ts/access.json +1 -0
- package/templates/safe-ts/doc.json +7 -0
- package/templates/safe-ts/omegga.d.ts +1311 -0
- package/templates/safe-ts/omegga.plugin.ts +29 -0
- package/templates/safe-ts/plugin.json +4 -0
- package/templates/safe-ts/setup.sh +4 -0
- package/templates/safe-ts/tsconfig.json +10 -0
- package/templates/unsafe/README.md +29 -0
- package/templates/unsafe/doc.json +7 -0
- package/templates/unsafe/omegga.main.js +15 -0
- package/templates/unsafe/plugin.json +4 -0
- package/templates/unsafe/setup.sh +4 -0
- package/.babelrc.json +0 -5
- package/.github/workflows/lint.yml +0 -26
- package/.prettierrc +0 -7
- package/.vscode/extensions.json +0 -5
- package/src/OMEGGA_LEGACY_INSTALL +0 -44
- package/src/brickadia/config.js +0 -42
- package/src/brickadia/server.js +0 -227
- package/src/cli/auth.js +0 -104
- package/src/cli/config.js +0 -77
- package/src/cli/index.js +0 -6
- package/src/cli/installer.js +0 -65
- package/src/cli/plugin.js +0 -575
- package/src/cli/terminal.js +0 -466
- package/src/config/authorizer.js +0 -37
- package/src/config/formats/format_js.js +0 -6
- package/src/config/formats/format_yml.js +0 -8
- package/src/config/index.js +0 -81
- package/src/config/reader.js +0 -27
- package/src/config/validator.js +0 -32
- package/src/config/writer.js +0 -20
- package/src/info/default_commands.json +0 -26
- package/src/lib.js +0 -23
- package/src/main.js +0 -332
- package/src/omegga/auth.js +0 -138
- package/src/omegga/commandInjector.js +0 -228
- package/src/omegga/index.js +0 -22
- package/src/omegga/logWrangler.js +0 -323
- package/src/omegga/matchers/auth.js +0 -49
- package/src/omegga/matchers/chat.js +0 -73
- package/src/omegga/matchers/command.js +0 -39
- package/src/omegga/matchers/exit.js +0 -19
- package/src/omegga/matchers/init.js +0 -23
- package/src/omegga/matchers/join.js +0 -115
- package/src/omegga/matchers/leave.js +0 -58
- package/src/omegga/matchers/mapChange.js +0 -37
- package/src/omegga/matchers/version.js +0 -45
- package/src/omegga/player.js +0 -585
- package/src/omegga/plugin/plugin_jsonrpc_stdio.js +0 -526
- package/src/omegga/plugin/plugin_node_safe/proxyOmegga.js +0 -117
- package/src/omegga/plugin/plugin_node_safe/worker.js +0 -238
- package/src/omegga/plugin/plugin_node_safe.js +0 -473
- package/src/omegga/plugin/plugin_node_unsafe.js +0 -177
- package/src/omegga/plugin.js +0 -565
- package/src/omegga/server.js +0 -658
- package/src/omegga/wrapper.js +0 -62
- package/src/softconfig.js +0 -64
- package/src/util/brick/checkBounds.js +0 -22
- package/src/util/brick/constants.js +0 -185
- package/src/util/brick/getBounds.js +0 -36
- package/src/util/brick/getBrickSize.js +0 -9
- package/src/util/brick/getScaleAxis.js +0 -31
- package/src/util/brick/index.js +0 -9
- package/src/util/brick/rotate.js +0 -43
- package/src/util/brick/setOwnership.js +0 -20
- package/src/util/chat.js +0 -28
- package/src/util/color.js +0 -143
- package/src/util/file.js +0 -119
- package/src/util/index.js +0 -28
- package/src/util/map.js +0 -28
- package/src/util/pattern.js +0 -14
- package/src/util/time.js +0 -46
- package/src/util/uuid.js +0 -8
- package/src/util/wsl.js +0 -9
- package/src/webserver/backend/api.js +0 -795
- package/src/webserver/backend/calendar.js +0 -15
- package/src/webserver/backend/database.js +0 -725
- package/src/webserver/backend/index.js +0 -206
- package/src/webserver/backend/metrics.js +0 -148
- package/src/webserver/backend/util.js +0 -75
- package/src/webserver/frontend/.eslintrc.yml +0 -26
- package/src/webserver/frontend/app.js +0 -78
- package/src/webserver/frontend/auth.js +0 -16
- package/src/webserver/frontend/components/Background.vue +0 -83
- package/src/webserver/frontend/components/Button.vue +0 -105
- package/src/webserver/frontend/components/ChatEntry.vue +0 -107
- package/src/webserver/frontend/components/ChatTime.vue +0 -40
- package/src/webserver/frontend/components/Dimmer.vue +0 -43
- package/src/webserver/frontend/components/Dropdown.vue +0 -145
- package/src/webserver/frontend/components/Footer.vue +0 -29
- package/src/webserver/frontend/components/Header.vue +0 -27
- package/src/webserver/frontend/components/InfiniteScroll.vue +0 -51
- package/src/webserver/frontend/components/Input.vue +0 -93
- package/src/webserver/frontend/components/ListInput.vue +0 -105
- package/src/webserver/frontend/components/Loader.vue +0 -98
- package/src/webserver/frontend/components/MainMenuButton.vue +0 -83
- package/src/webserver/frontend/components/Modal.vue +0 -44
- package/src/webserver/frontend/components/NavBar.vue +0 -24
- package/src/webserver/frontend/components/PlayerDropdown.vue +0 -210
- package/src/webserver/frontend/components/PopoutContent.vue +0 -32
- package/src/webserver/frontend/components/RoleDropdown.vue +0 -157
- package/src/webserver/frontend/components/Scroll.vue +0 -33
- package/src/webserver/frontend/components/Toggle.vue +0 -91
- package/src/webserver/frontend/components/index.js +0 -33
- package/src/webserver/frontend/css/font.scss +0 -53
- package/src/webserver/frontend/css/mixins.scss +0 -49
- package/src/webserver/frontend/css/style.scss +0 -166
- package/src/webserver/frontend/css/theme.scss +0 -64
- package/src/webserver/frontend/partials/NavHeader.vue +0 -55
- package/src/webserver/frontend/partials/Page.vue +0 -40
- package/src/webserver/frontend/partials/PageContent.vue +0 -31
- package/src/webserver/frontend/partials/SideNav.vue +0 -115
- package/src/webserver/frontend/partials/index.js +0 -4
- package/src/webserver/frontend/router.js +0 -83
- package/src/webserver/frontend/views/Auth.vue +0 -190
- package/src/webserver/frontend/views/History.vue +0 -462
- package/src/webserver/frontend/views/Home.vue +0 -251
- package/src/webserver/frontend/views/Main.vue +0 -69
- package/src/webserver/frontend/views/NotFound.vue +0 -10
- package/src/webserver/frontend/views/Players.vue +0 -425
- package/src/webserver/frontend/views/PlayersInspector.vue +0 -538
- package/src/webserver/frontend/views/Plugins.vue +0 -217
- package/src/webserver/frontend/views/PluginsInspector.vue +0 -418
- package/src/webserver/frontend/views/Server.vue +0 -167
- package/src/webserver/frontend/views/Users.vue +0 -538
- package/src/webserver/frontend/widgets/Chat.vue +0 -124
- package/src/webserver/frontend/widgets/Status.vue +0 -91
- package/src/webserver/frontend/widgets/index.js +0 -2
- package/src/webserver/frontend/widgets/tooltip.js +0 -108
- 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;
|