omegga 1.2.8 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -1
- package/dist/brickadia/config.js +26 -90
- package/dist/brickadia/config.js.map +1 -1
- package/dist/brickadia/server.js +294 -293
- package/dist/brickadia/server.js.map +1 -1
- package/dist/cli/auth.js +149 -177
- package/dist/cli/auth.js.map +1 -1
- package/dist/cli/config.js +64 -66
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/index.js +14 -14
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/installer.js +37 -43
- package/dist/cli/installer.js.map +1 -1
- package/dist/cli/plugin.js +651 -682
- package/dist/cli/plugin.js.map +1 -1
- package/dist/cli/terminal.js +811 -733
- package/dist/cli/terminal.js.map +1 -1
- package/dist/config/formats/format_js.js +6 -6
- package/dist/config/formats/format_js.js.map +1 -1
- package/dist/config/formats/format_yml.js +7 -10
- package/dist/config/formats/format_yml.js.map +1 -1
- package/dist/config/index.js +46 -68
- package/dist/config/index.js.map +1 -1
- package/dist/config/reader.js +16 -27
- package/dist/config/reader.js.map +1 -1
- package/dist/config/validator.js +23 -25
- package/dist/config/validator.js.map +1 -1
- package/dist/config/writer.js +11 -21
- package/dist/config/writer.js.map +1 -1
- package/dist/index.js +18 -64
- package/dist/index.js.map +1 -1
- package/dist/info/default_commands.json.js +39 -0
- package/dist/info/default_commands.json.js.map +1 -0
- package/dist/logger.js +61 -60
- package/dist/logger.js.map +1 -1
- package/dist/main.js +424 -471
- package/dist/main.js.map +1 -1
- package/dist/omegga/auth.js +101 -148
- package/dist/omegga/auth.js.map +1 -1
- package/dist/omegga/commandInjector.js +261 -251
- package/dist/omegga/commandInjector.js.map +1 -1
- package/dist/omegga/index.js +14 -52
- package/dist/omegga/index.js.map +1 -1
- package/dist/omegga/logWrangler.js +224 -275
- package/dist/omegga/logWrangler.js.map +1 -1
- package/dist/omegga/matchers/auth.js +36 -50
- package/dist/omegga/matchers/auth.js.map +1 -1
- package/dist/omegga/matchers/chat.js +49 -71
- package/dist/omegga/matchers/chat.js.map +1 -1
- package/dist/omegga/matchers/command.js +25 -36
- package/dist/omegga/matchers/command.js.map +1 -1
- package/dist/omegga/matchers/exit.js +15 -18
- package/dist/omegga/matchers/exit.js.map +1 -1
- package/dist/omegga/matchers/index.js +26 -40
- package/dist/omegga/matchers/index.js.map +1 -1
- package/dist/omegga/matchers/init.js +20 -23
- package/dist/omegga/matchers/init.js.map +1 -1
- package/dist/omegga/matchers/interact.js +58 -64
- package/dist/omegga/matchers/interact.js.map +1 -1
- package/dist/omegga/matchers/join.js +74 -95
- package/dist/omegga/matchers/join.js.map +1 -1
- package/dist/omegga/matchers/leave.js +43 -56
- package/dist/omegga/matchers/leave.js.map +1 -1
- package/dist/omegga/matchers/mapChange.js +26 -35
- package/dist/omegga/matchers/mapChange.js.map +1 -1
- package/dist/omegga/matchers/minigameJoin.js +24 -31
- package/dist/omegga/matchers/minigameJoin.js.map +1 -1
- package/dist/omegga/matchers/version.js +42 -49
- package/dist/omegga/matchers/version.js.map +1 -1
- package/dist/omegga/player.js +527 -527
- package/dist/omegga/player.js.map +1 -1
- package/dist/omegga/plugin/interface.js +91 -98
- package/dist/omegga/plugin/interface.js.map +1 -1
- package/dist/omegga/plugin/plugin_jsonrpc_stdio.js +524 -429
- package/dist/omegga/plugin/plugin_jsonrpc_stdio.js.map +1 -1
- package/dist/omegga/plugin/plugin_node_safe/proxyOmegga.js +282 -294
- package/dist/omegga/plugin/plugin_node_safe/proxyOmegga.js.map +1 -1
- package/dist/omegga/plugin/plugin_node_safe.js +365 -393
- package/dist/omegga/plugin/plugin_node_safe.js.map +1 -1
- package/dist/omegga/plugin/plugin_node_unsafe.js +119 -179
- package/dist/omegga/plugin/plugin_node_unsafe.js.map +1 -1
- package/dist/omegga/plugin.js +402 -347
- package/dist/omegga/plugin.js.map +1 -1
- package/dist/omegga/server.js +742 -774
- package/dist/omegga/server.js.map +1 -1
- package/dist/omegga/wrapper.js +64 -91
- package/dist/omegga/wrapper.js.map +1 -1
- package/dist/plugin.js +11 -31
- package/dist/plugin.js.map +1 -1
- package/dist/softconfig.js +121 -100
- package/dist/softconfig.js.map +1 -1
- package/dist/updater/steam.js +97 -112
- package/dist/updater/steam.js.map +1 -1
- package/dist/util/brdb.js +496 -528
- package/dist/util/brdb.js.map +1 -1
- package/dist/util/brick/checkBounds.js +11 -15
- package/dist/util/brick/checkBounds.js.map +1 -1
- package/dist/util/brick/constants.js +723 -174
- package/dist/util/brick/constants.js.map +1 -1
- package/dist/util/brick/displayName.js +204 -211
- package/dist/util/brick/displayName.js.map +1 -1
- package/dist/util/brick/getBounds.js +29 -41
- package/dist/util/brick/getBounds.js.map +1 -1
- package/dist/util/brick/getBrickSize.js +6 -7
- package/dist/util/brick/getBrickSize.js.map +1 -1
- package/dist/util/brick/getScaleAxis.js +24 -30
- package/dist/util/brick/getScaleAxis.js.map +1 -1
- package/dist/util/brick/index.js +8 -29
- package/dist/util/brick/index.js.map +1 -1
- package/dist/util/brick/rotate.js +29 -34
- package/dist/util/brick/rotate.js.map +1 -1
- package/dist/util/brick/setOwnership.js +13 -19
- package/dist/util/brick/setOwnership.js.map +1 -1
- package/dist/util/chat.js +53 -44
- package/dist/util/chat.js.map +1 -1
- package/dist/util/color.js +112 -124
- package/dist/util/color.js.map +1 -1
- package/dist/util/file.js +54 -98
- package/dist/util/file.js.map +1 -1
- package/dist/util/index.js +84 -106
- package/dist/util/index.js.map +1 -1
- package/dist/util/map.js +18 -20
- package/dist/util/map.js.map +1 -1
- package/dist/util/pattern.js +6 -9
- package/dist/util/pattern.js.map +1 -1
- package/dist/util/time.js +31 -34
- package/dist/util/time.js.map +1 -1
- package/dist/util/uuid.js +10 -8
- package/dist/util/uuid.js.map +1 -1
- package/dist/util/wsl.js +19 -25
- package/dist/util/wsl.js.map +1 -1
- package/dist/version.js +7 -9
- package/dist/version.js.map +1 -1
- package/dist/webserver/backend/api.js +784 -874
- package/dist/webserver/backend/api.js.map +1 -1
- package/dist/webserver/backend/calendar.js +14 -17
- package/dist/webserver/backend/calendar.js.map +1 -1
- package/dist/webserver/backend/database.js +563 -613
- package/dist/webserver/backend/database.js.map +1 -1
- package/dist/webserver/backend/index.js +153 -191
- package/dist/webserver/backend/index.js.map +1 -1
- package/dist/webserver/backend/metrics.js +219 -248
- package/dist/webserver/backend/metrics.js.map +1 -1
- package/dist/webserver/backend/util.js +47 -68
- package/dist/webserver/backend/util.js.map +1 -1
- package/dist/worker.js +322 -0
- package/dist/worker.js.map +1 -0
- package/package.json +14 -10
- package/templates/safe-ts/omegga.d.ts +2 -2
- package/vite.backend.config.mts +46 -0
- package/vite.frontend.config.mts +58 -0
- package/vitest.backend.config.mts +7 -0
- package/dist/brickadia/config.d.ts +0 -3
- package/dist/brickadia/presets.d.ts +0 -65
- package/dist/brickadia/presets.js +0 -3
- package/dist/brickadia/presets.js.map +0 -1
- package/dist/brickadia/server.d.ts +0 -36
- package/dist/brickadia/types.d.ts +0 -45
- package/dist/brickadia/types.js +0 -3
- package/dist/brickadia/types.js.map +0 -1
- package/dist/cli/auth.d.ts +0 -26
- package/dist/cli/config.d.ts +0 -10
- package/dist/cli/index.d.ts +0 -30
- package/dist/cli/installer.d.ts +0 -1
- package/dist/cli/plugin.d.ts +0 -22
- package/dist/cli/terminal.d.ts +0 -25
- package/dist/config/authorizer.d.ts +0 -2
- package/dist/config/authorizer.js +0 -38
- package/dist/config/authorizer.js.map +0 -1
- package/dist/config/formats/format_js.d.ts +0 -3
- package/dist/config/formats/format_yml.d.ts +0 -3
- package/dist/config/index.d.ts +0 -18
- package/dist/config/reader.d.ts +0 -3
- package/dist/config/types.d.ts +0 -50
- package/dist/config/types.js +0 -3
- package/dist/config/types.js.map +0 -1
- package/dist/config/validator.d.ts +0 -6
- package/dist/config/writer.d.ts +0 -3
- package/dist/index.d.ts +0 -22
- package/dist/info/default_commands.json +0 -29
- package/dist/logger.d.ts +0 -41
- package/dist/main.d.ts +0 -1
- package/dist/omegga/auth.d.ts +0 -9
- package/dist/omegga/commandInjector.d.ts +0 -35
- package/dist/omegga/index.d.ts +0 -7
- package/dist/omegga/logWrangler.d.ts +0 -32
- package/dist/omegga/matchers/auth.d.ts +0 -10
- package/dist/omegga/matchers/chat.d.ts +0 -10
- package/dist/omegga/matchers/command.d.ts +0 -7
- package/dist/omegga/matchers/exit.d.ts +0 -3
- package/dist/omegga/matchers/index.d.ts +0 -3
- package/dist/omegga/matchers/init.d.ts +0 -3
- package/dist/omegga/matchers/interact.d.ts +0 -4
- package/dist/omegga/matchers/join.d.ts +0 -4
- package/dist/omegga/matchers/leave.d.ts +0 -4
- package/dist/omegga/matchers/mapChange.d.ts +0 -3
- package/dist/omegga/matchers/minigameJoin.d.ts +0 -9
- package/dist/omegga/matchers/types.d.ts +0 -5
- package/dist/omegga/matchers/types.js +0 -3
- package/dist/omegga/matchers/types.js.map +0 -1
- package/dist/omegga/matchers/version.d.ts +0 -3
- package/dist/omegga/player.d.ts +0 -81
- package/dist/omegga/plugin/interface.d.ts +0 -30
- package/dist/omegga/plugin/plugin_jsonrpc_stdio.d.ts +0 -23
- package/dist/omegga/plugin/plugin_node_safe/proxyOmegga.d.ts +0 -145
- package/dist/omegga/plugin/plugin_node_safe/worker.d.ts +0 -1
- package/dist/omegga/plugin/plugin_node_safe/worker.js +0 -367
- package/dist/omegga/plugin/plugin_node_safe/worker.js.map +0 -1
- package/dist/omegga/plugin/plugin_node_safe.d.ts +0 -23
- package/dist/omegga/plugin/plugin_node_unsafe.d.ts +0 -13
- package/dist/omegga/plugin.d.ts +0 -63
- package/dist/omegga/server.d.ts +0 -166
- package/dist/omegga/types.d.ts +0 -49
- package/dist/omegga/types.js +0 -3
- package/dist/omegga/types.js.map +0 -1
- package/dist/omegga/wrapper.d.ts +0 -32
- package/dist/plugin.d.ts +0 -916
- package/dist/softconfig.d.ts +0 -67
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/updater/index.d.ts +0 -1
- package/dist/updater/index.js +0 -10
- package/dist/updater/index.js.map +0 -1
- package/dist/updater/steam.d.ts +0 -52
- package/dist/util/brdb.d.ts +0 -31
- package/dist/util/brick/checkBounds.d.ts +0 -8
- package/dist/util/brick/constants.d.ts +0 -18
- package/dist/util/brick/displayName.d.ts +0 -7
- package/dist/util/brick/getBounds.d.ts +0 -5
- package/dist/util/brick/getBrickSize.d.ts +0 -3
- package/dist/util/brick/getScaleAxis.d.ts +0 -3
- package/dist/util/brick/index.d.ts +0 -14
- package/dist/util/brick/rotate.d.ts +0 -16
- package/dist/util/brick/setOwnership.d.ts +0 -12
- package/dist/util/chat.d.ts +0 -23
- package/dist/util/color.d.ts +0 -13
- package/dist/util/file.d.ts +0 -5
- package/dist/util/index.d.ts +0 -183
- package/dist/util/map.d.ts +0 -6
- package/dist/util/pattern.d.ts +0 -1
- package/dist/util/time.d.ts +0 -39
- package/dist/util/uuid.d.ts +0 -3
- package/dist/util/wsl.d.ts +0 -2
- package/dist/version.d.ts +0 -2
- package/dist/webserver/backend/api.d.ts +0 -115
- package/dist/webserver/backend/calendar.d.ts +0 -5
- package/dist/webserver/backend/database.d.ts +0 -150
- package/dist/webserver/backend/index.d.ts +0 -30
- package/dist/webserver/backend/metrics.d.ts +0 -3
- package/dist/webserver/backend/types.d.ts +0 -114
- package/dist/webserver/backend/types.js +0 -3
- package/dist/webserver/backend/types.js.map +0 -1
- package/dist/webserver/backend/util.d.ts +0 -2
- package/dist/webserver/index.d.ts +0 -2
- package/dist/webserver/index.js +0 -9
- package/dist/webserver/index.js.map +0 -1
|
@@ -1,77 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const path_1 = __importDefault(require("path"));
|
|
11
|
-
const pem_1 = __importDefault(require("pem"));
|
|
12
|
-
const util_1 = require("util");
|
|
13
|
-
const softconfig_1 = __importDefault(require("../../softconfig"));
|
|
14
|
-
const createCertificate = (0, util_1.promisify)(pem_1.default.createCertificate);
|
|
15
|
-
// generate SSL certs for the https server
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const softconfig = require("../../softconfig.js");
|
|
4
|
+
const crypto = require("node:crypto");
|
|
5
|
+
const fs = require("node:fs");
|
|
6
|
+
const path = require("node:path");
|
|
7
|
+
const node_util = require("node:util");
|
|
8
|
+
const pem = require("pem");
|
|
9
|
+
const createCertificate = node_util.promisify(pem.createCertificate);
|
|
16
10
|
async function getSSLKeys(dataPath) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (certData.expires < now)
|
|
26
|
-
certData = undefined;
|
|
27
|
-
}
|
|
28
|
-
catch (e) {
|
|
29
|
-
// nothing to do here - probably bad json
|
|
30
|
-
}
|
|
11
|
+
const certsPath = path.join(dataPath, softconfig.default.WEB_CERTS_DATA);
|
|
12
|
+
let certData;
|
|
13
|
+
const now = Date.now();
|
|
14
|
+
if (fs.existsSync(certsPath)) {
|
|
15
|
+
try {
|
|
16
|
+
certData = JSON.parse(fs.readFileSync(certsPath, "utf8"));
|
|
17
|
+
if (certData.expires < now) certData = void 0;
|
|
18
|
+
} catch (e) {
|
|
31
19
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
catch (e) {
|
|
44
|
-
// probably missing openssl or something
|
|
45
|
-
}
|
|
20
|
+
}
|
|
21
|
+
if (!certData) {
|
|
22
|
+
const days = 360;
|
|
23
|
+
const expires = now + days / 2 * 24 * 60 * 60 * 1e3;
|
|
24
|
+
try {
|
|
25
|
+
const keys = await createCertificate({ days, selfSigned: true });
|
|
26
|
+
certData = { keys, expires, new: false };
|
|
27
|
+
fs.writeFileSync(certsPath, JSON.stringify(certData));
|
|
28
|
+
certData.new = true;
|
|
29
|
+
} catch (e) {
|
|
46
30
|
}
|
|
47
|
-
|
|
31
|
+
}
|
|
32
|
+
return certData;
|
|
48
33
|
}
|
|
49
|
-
// generate a session secret for the cookies
|
|
50
34
|
function getSessionSecret(dataPath) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
catch (e) {
|
|
60
|
-
// nothing to do here - probably file is a folder or something
|
|
61
|
-
}
|
|
35
|
+
const tokenPath = path.join(dataPath, softconfig.default.WEB_SESSION_TOKEN);
|
|
36
|
+
const secretSize = 64;
|
|
37
|
+
let secret;
|
|
38
|
+
if (fs.existsSync(tokenPath)) {
|
|
39
|
+
try {
|
|
40
|
+
secret = fs.readFileSync(tokenPath, "utf8");
|
|
41
|
+
} catch (e) {
|
|
62
42
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
catch (e) {
|
|
72
|
-
// nothing to do here - maybe missing perms?
|
|
73
|
-
}
|
|
43
|
+
}
|
|
44
|
+
if (!secret) {
|
|
45
|
+
const buf = Buffer.alloc(secretSize);
|
|
46
|
+
secret = crypto.randomFillSync(buf).toString("hex");
|
|
47
|
+
try {
|
|
48
|
+
fs.writeFileSync(tokenPath, secret);
|
|
49
|
+
} catch (e) {
|
|
74
50
|
}
|
|
75
|
-
|
|
51
|
+
}
|
|
52
|
+
return secret;
|
|
76
53
|
}
|
|
77
|
-
|
|
54
|
+
exports.getSSLKeys = getSSLKeys;
|
|
55
|
+
exports.getSessionSecret = getSessionSecret;
|
|
56
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","
|
|
1
|
+
{"version":3,"file":"util.js","sources":["../../../src/webserver/backend/util.ts"],"sourcesContent":["import soft from '@/softconfig';\nimport crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { promisify } from 'node:util';\nimport pem from 'pem';\n\nconst createCertificate: (\n options: pem.CertificateCreationOptions,\n) => Promise<pem.CertificateCreationResult> = promisify(pem.createCertificate);\n\n// generate SSL certs for the https server\nexport async function getSSLKeys(dataPath: string) {\n const certsPath = path.join(dataPath, soft.WEB_CERTS_DATA);\n let certData;\n const now = Date.now();\n\n // read cert data from json file\n if (fs.existsSync(certsPath)) {\n try {\n certData = JSON.parse(fs.readFileSync(certsPath, 'utf8'));\n\n // make sure the cert is not expired\n if (certData.expires < now) certData = undefined;\n } catch (e) {\n // nothing to do here - probably bad json\n }\n }\n\n // otherwise generate it\n if (!certData) {\n // expires in half the real duration time\n const days = 360;\n const expires = now + (days / 2) * 24 * 60 * 60 * 1000;\n try {\n const keys = await createCertificate({ days, selfSigned: true });\n certData = { keys, expires, new: false };\n\n fs.writeFileSync(certsPath, JSON.stringify(certData));\n certData.new = true;\n } catch (e) {\n // probably missing openssl or something\n }\n }\n\n return certData;\n}\n\n// generate a session secret for the cookies\nexport function getSessionSecret(dataPath: string) {\n const tokenPath = path.join(dataPath, soft.WEB_SESSION_TOKEN);\n const secretSize = 64;\n let secret;\n // read secret from file\n if (fs.existsSync(tokenPath)) {\n try {\n secret = fs.readFileSync(tokenPath, 'utf8');\n } catch (e) {\n // nothing to do here - probably file is a folder or something\n }\n }\n\n if (!secret) {\n // generate a new secret\n const buf = Buffer.alloc(secretSize);\n secret = crypto.randomFillSync(buf).toString('hex');\n try {\n // write secret to file\n fs.writeFileSync(tokenPath, secret);\n } catch (e) {\n // nothing to do here - maybe missing perms?\n }\n }\n\n return secret;\n}\n"],"names":["promisify","soft"],"mappings":";;;;;;;;AAOA,MAAM,oBAEwCA,UAAAA,UAAU,IAAI,iBAAiB;AAG7E,eA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./omegga/player.js");
|
|
4
|
+
const server = require("./omegga/server.js");
|
|
5
|
+
const index = require("./util/index.js");
|
|
6
|
+
const file = require("./util/file.js");
|
|
7
|
+
require("colors");
|
|
8
|
+
const _ = require("lodash");
|
|
9
|
+
const EventEmitter = require("node:events");
|
|
10
|
+
const fs = require("node:fs");
|
|
11
|
+
const path = require("node:path");
|
|
12
|
+
const node_worker_threads = require("node:worker_threads");
|
|
13
|
+
const vm2 = require("vm2");
|
|
14
|
+
const webpack = require("webpack");
|
|
15
|
+
const proxyOmegga = require("./omegga/plugin/plugin_node_safe/proxyOmegga.js");
|
|
16
|
+
logger.default.VERBOSE = process.env.VERBOSE === "true";
|
|
17
|
+
const MAIN_FILE = "omegga.plugin.js";
|
|
18
|
+
const MAIN_FILE_TS = "omegga.plugin.ts";
|
|
19
|
+
const TS_BUILD_DIR = ".build";
|
|
20
|
+
const TS_BUILD_FILE = "plugin.js";
|
|
21
|
+
let vm, PluginClass, pluginInstance;
|
|
22
|
+
let pluginName = "unnamed plugin";
|
|
23
|
+
let messageCounter = 0;
|
|
24
|
+
const parent = new EventEmitter();
|
|
25
|
+
node_worker_threads.parentPort.on("message", ({ action, args }) => parent.emit(action, ...args));
|
|
26
|
+
const emit = (action, ...args) => {
|
|
27
|
+
const messageId = "message:" + messageCounter++;
|
|
28
|
+
let rejectFn;
|
|
29
|
+
const promise = new Promise((resolve, reject) => {
|
|
30
|
+
parent.once(messageId, resolve);
|
|
31
|
+
rejectFn = reject;
|
|
32
|
+
});
|
|
33
|
+
try {
|
|
34
|
+
node_worker_threads.parentPort.postMessage({ action, args: [messageId, ...args] });
|
|
35
|
+
} catch (err) {
|
|
36
|
+
rejectFn(err);
|
|
37
|
+
}
|
|
38
|
+
return promise;
|
|
39
|
+
};
|
|
40
|
+
const exec = (cmd) => emit("exec", cmd);
|
|
41
|
+
proxyOmegga.injectOmeggaPrototypes(proxyOmegga.ProxyOmegga, server.default);
|
|
42
|
+
const omegga = new proxyOmegga.ProxyOmegga(exec);
|
|
43
|
+
omegga.getPlugin = async (name) => {
|
|
44
|
+
let plugin = await emit("getPlugin", name);
|
|
45
|
+
if (plugin) {
|
|
46
|
+
plugin.emitPlugin = async (ev, ...args) => {
|
|
47
|
+
return await emit("emitPlugin", name, ev, _.cloneDeep(args));
|
|
48
|
+
};
|
|
49
|
+
return plugin;
|
|
50
|
+
} else {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const store = {
|
|
55
|
+
get: (key) => emit("store.get", key),
|
|
56
|
+
set: (key, value) => emit("store.set", key, JSON.stringify(value)),
|
|
57
|
+
delete: (key) => emit("store.delete", key),
|
|
58
|
+
wipe: () => emit("store.wipe"),
|
|
59
|
+
count: () => emit("store.count"),
|
|
60
|
+
keys: () => emit("store.keys")
|
|
61
|
+
};
|
|
62
|
+
parent.on("brickadiaEvent", (type, ...args) => {
|
|
63
|
+
if (!vm) return;
|
|
64
|
+
if (type === "error") {
|
|
65
|
+
logger.default.errorp(pluginName.brightRed, "Received error", ...args);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
omegga.emit(type, ...args);
|
|
70
|
+
} catch (e) {
|
|
71
|
+
logger.default.errorp(
|
|
72
|
+
pluginName.brightRed,
|
|
73
|
+
`Error in safe plugin worker's brickadiaEvent (${type}):`,
|
|
74
|
+
e?.stack ?? e.toString()
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
async function createVm(pluginPath, { builtin = ["*"], external = true, isTypeScript = false } = {}) {
|
|
79
|
+
let pluginCode;
|
|
80
|
+
if (isTypeScript) {
|
|
81
|
+
const tsBuildPath = path.join(pluginPath, TS_BUILD_DIR);
|
|
82
|
+
const sourceFileName = path.join(pluginPath, MAIN_FILE_TS);
|
|
83
|
+
const outputPath = path.join(tsBuildPath, TS_BUILD_FILE);
|
|
84
|
+
try {
|
|
85
|
+
file.mkdir(tsBuildPath);
|
|
86
|
+
file.mkdir(path.join(tsBuildPath, ".cache"));
|
|
87
|
+
const stats = await new Promise((resolve, reject) => {
|
|
88
|
+
webpack(
|
|
89
|
+
Object.freeze({
|
|
90
|
+
target: "node",
|
|
91
|
+
context: __dirname,
|
|
92
|
+
mode: fs.existsSync(path.resolve(pluginPath, ".development")) ? "development" : "production",
|
|
93
|
+
entry: sourceFileName,
|
|
94
|
+
devtool: "source-map",
|
|
95
|
+
output: {
|
|
96
|
+
iife: false,
|
|
97
|
+
library: {
|
|
98
|
+
type: "commonjs"
|
|
99
|
+
},
|
|
100
|
+
path: tsBuildPath,
|
|
101
|
+
filename: TS_BUILD_FILE
|
|
102
|
+
},
|
|
103
|
+
externals: [
|
|
104
|
+
function({ request }, callback) {
|
|
105
|
+
if (request.match(/\.node$/)) {
|
|
106
|
+
return callback(
|
|
107
|
+
null,
|
|
108
|
+
"commonjs " + path.resolve(pluginPath, request)
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
callback();
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
resolve: {
|
|
115
|
+
extensions: [".ts", ".js", ".json", ".node"],
|
|
116
|
+
alias: {
|
|
117
|
+
// src is the only hard coded path
|
|
118
|
+
src: path.resolve(pluginPath, "src")
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
cache: {
|
|
122
|
+
type: "filesystem",
|
|
123
|
+
cacheLocation: path.join(tsBuildPath, ".cache"),
|
|
124
|
+
allowCollectingMemory: false,
|
|
125
|
+
idleTimeout: 0,
|
|
126
|
+
idleTimeoutForInitialStore: 0,
|
|
127
|
+
// cache age is one week. plugins probably do not need
|
|
128
|
+
// to be rebuilt every day
|
|
129
|
+
maxAge: 1e3 * 60 * 60 * 24 * 7,
|
|
130
|
+
profile: true
|
|
131
|
+
},
|
|
132
|
+
module: {
|
|
133
|
+
rules: [
|
|
134
|
+
{
|
|
135
|
+
test: /\.[jt]s$/,
|
|
136
|
+
exclude: /(node_modules)/,
|
|
137
|
+
use: {
|
|
138
|
+
loader: "swc-loader",
|
|
139
|
+
options: {
|
|
140
|
+
sourceMaps: true,
|
|
141
|
+
cwd: pluginPath,
|
|
142
|
+
isModule: true,
|
|
143
|
+
jsc: {
|
|
144
|
+
target: "es2020",
|
|
145
|
+
parser: {
|
|
146
|
+
syntax: "typescript"
|
|
147
|
+
},
|
|
148
|
+
transform: {}
|
|
149
|
+
},
|
|
150
|
+
module: {
|
|
151
|
+
type: "commonjs",
|
|
152
|
+
strictMode: false
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
]
|
|
158
|
+
}
|
|
159
|
+
}),
|
|
160
|
+
(err, stats2) => err ? reject(err) : resolve(stats2)
|
|
161
|
+
);
|
|
162
|
+
});
|
|
163
|
+
if (stats.hasErrors()) {
|
|
164
|
+
for (const err of stats.toJson().errors) {
|
|
165
|
+
logger.default.errorp(err.moduleName, err.file);
|
|
166
|
+
logger.default.errorp(err.message);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (stats.hasWarnings()) {
|
|
170
|
+
for (const warning of stats.toJson().warnings) {
|
|
171
|
+
logger.default.warnp(warning.moduleName, warning.file);
|
|
172
|
+
logger.default.warnp(warning.message);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
pluginCode = fs.readFileSync(outputPath).toString();
|
|
176
|
+
} catch (err) {
|
|
177
|
+
logger.default.errorp(pluginName.brightRed, err);
|
|
178
|
+
return [false, "failed compiling building typescript"];
|
|
179
|
+
}
|
|
180
|
+
try {
|
|
181
|
+
const gitIgnore = path.join(pluginPath, ".gitignore");
|
|
182
|
+
const omeggaTypesDst = path.join(pluginPath, "omegga.d.ts");
|
|
183
|
+
const omeggaTypesSrc = path.join(
|
|
184
|
+
__dirname,
|
|
185
|
+
"../../../../templates/safe-ts/omegga.d.ts"
|
|
186
|
+
);
|
|
187
|
+
if (fs.existsSync(gitIgnore) && fs.existsSync(omeggaTypesSrc)) {
|
|
188
|
+
const hasOmeggaTypesIgnored = fs.readFileSync(gitIgnore).toString().match(/(\.\/)?omegga\.d\.ts/);
|
|
189
|
+
const srcLastModified = fs.statSync(omeggaTypesSrc).mtime.getTime();
|
|
190
|
+
const dstLastModified = fs.existsSync(omeggaTypesDst) ? fs.statSync(omeggaTypesDst).mtime.getTime() : null;
|
|
191
|
+
if (hasOmeggaTypesIgnored && (!dstLastModified || srcLastModified > dstLastModified)) {
|
|
192
|
+
fs.copyFileSync(omeggaTypesSrc, omeggaTypesDst);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
} catch (err) {
|
|
196
|
+
logger.default.errorp(
|
|
197
|
+
pluginName.brightRed,
|
|
198
|
+
"error copying latest omegga.d.ts to typescript plugin",
|
|
199
|
+
err
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (vm !== void 0) return [false, "vm is already created"];
|
|
204
|
+
vm = new vm2.NodeVM({
|
|
205
|
+
console: "redirect",
|
|
206
|
+
sandbox: {},
|
|
207
|
+
require: {
|
|
208
|
+
external,
|
|
209
|
+
builtin,
|
|
210
|
+
root: pluginPath
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
const ezLog = (logFn, name, symbol) => (...args) => console[logFn](name.underline, symbol, ...args);
|
|
214
|
+
vm.on("console.log", ezLog("log", pluginName, ">>".green));
|
|
215
|
+
vm.on("console.error", ezLog("error", pluginName.brightRed, "!>".red));
|
|
216
|
+
vm.on("console.info", ezLog("info", pluginName, "#>".blue));
|
|
217
|
+
vm.on("console.debug", ezLog("debug", pluginName, "?>".blue));
|
|
218
|
+
vm.on("console.warn", ezLog("warn", pluginName.brightYellow, ":>".yellow));
|
|
219
|
+
vm.on("console.trace", ezLog("trace", pluginName, "T>".grey));
|
|
220
|
+
global.OMEGGA_UTIL = index.default;
|
|
221
|
+
vm.freeze(global.OMEGGA_UTIL, "OMEGGA_UTIL");
|
|
222
|
+
vm.freeze(omegga, "Omegga");
|
|
223
|
+
vm.freeze(player.default, "Player");
|
|
224
|
+
const file$1 = path.join(
|
|
225
|
+
pluginPath,
|
|
226
|
+
isTypeScript ? path.join(TS_BUILD_DIR, TS_BUILD_FILE) : MAIN_FILE
|
|
227
|
+
);
|
|
228
|
+
if (!isTypeScript) {
|
|
229
|
+
try {
|
|
230
|
+
pluginCode = fs.readFileSync(file$1).toString();
|
|
231
|
+
} catch (e) {
|
|
232
|
+
emit(
|
|
233
|
+
"error",
|
|
234
|
+
"failed to read plugin source: " + (e?.stack ?? e.toString())
|
|
235
|
+
);
|
|
236
|
+
throw "failed to read plugin source: " + (e?.stack ?? e.toString());
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
try {
|
|
240
|
+
const pluginOutput = vm.run(pluginCode, file$1);
|
|
241
|
+
PluginClass = pluginOutput?.default ?? pluginOutput;
|
|
242
|
+
} catch (e) {
|
|
243
|
+
emit("error", "plugin failed to init");
|
|
244
|
+
logger.default.errorp(pluginName.brightRed, e);
|
|
245
|
+
throw "plugin failed to init: " + (e?.stack ?? e.toString());
|
|
246
|
+
}
|
|
247
|
+
if (!PluginClass || typeof PluginClass !== "function" || typeof PluginClass.prototype !== "object") {
|
|
248
|
+
PluginClass = void 0;
|
|
249
|
+
emit("error", "plugin does not export a class");
|
|
250
|
+
throw "plugin does not export a class";
|
|
251
|
+
}
|
|
252
|
+
if (typeof PluginClass.prototype.init !== "function") {
|
|
253
|
+
PluginClass = void 0;
|
|
254
|
+
emit("error", "plugin is missing init() function");
|
|
255
|
+
throw "plugin is missing init() function";
|
|
256
|
+
}
|
|
257
|
+
if (typeof PluginClass.prototype.stop !== "function") {
|
|
258
|
+
PluginClass = void 0;
|
|
259
|
+
emit("error", "plugin is missing stop() function");
|
|
260
|
+
throw "plugin is missing stop() function";
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
parent.on("kill", (resp) => {
|
|
264
|
+
emit(resp);
|
|
265
|
+
process.exit(0);
|
|
266
|
+
});
|
|
267
|
+
parent.on("name", (resp, name) => {
|
|
268
|
+
pluginName = name;
|
|
269
|
+
omegga._tempSavePrefix = "omegga_" + name + "_temp";
|
|
270
|
+
emit(resp);
|
|
271
|
+
});
|
|
272
|
+
parent.on("mem", (resp) => emit(resp, "mem", process.memoryUsage()));
|
|
273
|
+
parent.on("load", async (resp, pluginPath, options) => {
|
|
274
|
+
try {
|
|
275
|
+
await createVm(pluginPath, options);
|
|
276
|
+
emit(resp, true);
|
|
277
|
+
} catch (err) {
|
|
278
|
+
logger.default.errorp(
|
|
279
|
+
pluginName.brightRed,
|
|
280
|
+
"error creating vm",
|
|
281
|
+
err?.stack ?? err.toString()
|
|
282
|
+
);
|
|
283
|
+
emit(resp, false);
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
parent.on("start", async (resp, config) => {
|
|
287
|
+
try {
|
|
288
|
+
pluginInstance = new PluginClass(omegga, config, store);
|
|
289
|
+
const result = await pluginInstance.init();
|
|
290
|
+
if (typeof result === "object" && result) {
|
|
291
|
+
const cmds = result.registeredCommands;
|
|
292
|
+
if (cmds && cmds instanceof Array && cmds.every((i) => typeof i === "string")) {
|
|
293
|
+
emit("command.registers", JSON.stringify(cmds));
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
emit(resp, true);
|
|
297
|
+
} catch (err) {
|
|
298
|
+
emit("error", "error starting plugin", err?.stack ?? JSON.stringify(err));
|
|
299
|
+
emit(resp, false);
|
|
300
|
+
logger.default.errorp(pluginName.brightRed, "Error starting plugin", err);
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
parent.on("stop", async (resp) => {
|
|
304
|
+
try {
|
|
305
|
+
if (pluginInstance) {
|
|
306
|
+
await pluginInstance.stop.bind(pluginInstance)();
|
|
307
|
+
}
|
|
308
|
+
pluginInstance = void 0;
|
|
309
|
+
emit(resp, true);
|
|
310
|
+
} catch (err) {
|
|
311
|
+
emit("error", "error stopping plugin", err?.stack ?? err.toString());
|
|
312
|
+
emit(resp, false);
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
parent.on("emitPlugin", async (resp, ev, from, args) => {
|
|
316
|
+
if (pluginInstance?.pluginEvent) {
|
|
317
|
+
emit(resp, await pluginInstance.pluginEvent(ev, from, ...args));
|
|
318
|
+
} else {
|
|
319
|
+
emit(resp, null);
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
//# sourceMappingURL=worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.js","sources":["../src/omegga/plugin/plugin_node_safe/worker.ts"],"sourcesContent":["// The safe node plugin is run inside of a worker\n// so if the plugin inevitably crashes, only the worker dies\n// this also lets plugins get terminated easier by killing the worker\n// rather than unloading and reloading code\n\nimport Logger from '@/logger';\nimport OmeggaPlugin, {\n OmeggaLike,\n PluginConfig,\n PluginInterop,\n PluginStore,\n} from '@/plugin';\nimport Player from '@omegga/player';\nimport Omegga from '@omegga/server';\nimport OmeggaUtil from '@util';\nimport { mkdir } from '@util/file';\nimport 'colors';\nimport { cloneDeep } from 'lodash';\nimport EventEmitter from 'node:events';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { parentPort } from 'node:worker_threads';\nimport { NodeVM } from 'vm2';\nimport webpack, { ExternalItemFunctionData, Stats } from 'webpack';\nimport { injectOmeggaPrototypes, ProxyOmegga } from './proxyOmegga';\nLogger.VERBOSE = process.env.VERBOSE === 'true';\n\nconst MAIN_FILE = 'omegga.plugin.js';\nconst MAIN_FILE_TS = 'omegga.plugin.ts';\nconst TS_BUILD_DIR = '.build';\nconst TS_BUILD_FILE = 'plugin.js';\nlet vm: NodeVM,\n PluginClass: {\n new (\n omegga: OmeggaLike,\n config: PluginConfig,\n store: PluginStore,\n ): OmeggaPlugin;\n },\n pluginInstance: OmeggaPlugin;\nlet pluginName = 'unnamed plugin';\nlet messageCounter = 0;\n// emitter that receives messages from the parent\nconst parent = new EventEmitter();\n\n// handle message passing\nparentPort.on('message', ({ action, args }) => parent.emit(action, ...args));\n\n// emit a message to the parent port - async wait for a reponse\nconst emit = (action: string, ...args: any[]) => {\n const messageId = 'message:' + messageCounter++;\n\n let rejectFn: (reason?: any) => void;\n // promise waits for the message to resolve\n const promise = new Promise((resolve, reject) => {\n parent.once(messageId, resolve);\n rejectFn = reject;\n });\n\n try {\n // post the message\n parentPort.postMessage({ action, args: [messageId, ...args] });\n } catch (err) {\n rejectFn(err);\n }\n\n // return the promise\n return promise;\n};\n\n// tell omegga to exec a command\nconst exec = (cmd: string) => emit('exec', cmd);\n\n// create the proxy omegga\ninjectOmeggaPrototypes(ProxyOmegga, Omegga);\nconst omegga = new ProxyOmegga(exec);\n\n// add plugin fetcher\nomegga.getPlugin = async name => {\n let plugin = (await emit('getPlugin', name)) as PluginInterop & {\n emitPlugin(event: string, ...args: any[]): Promise<any>;\n };\n if (plugin) {\n plugin.emitPlugin = async (ev: string, ...args: any[]) => {\n return await emit('emitPlugin', name, ev, cloneDeep(args));\n };\n return plugin;\n } else {\n return null;\n }\n};\n\n// interface with plugin store\nconst store: PluginStore = {\n get: <T>(key: string) => emit('store.get', key) as Promise<T>,\n set: <T>(key: string, value: T) =>\n emit('store.set', key, JSON.stringify(value)) as Promise<void>,\n delete: (key: string) => emit('store.delete', key) as Promise<void>,\n wipe: () => emit('store.wipe') as Promise<void>,\n count: () => emit('store.count') as Promise<number>,\n keys: () => emit('store.keys') as Promise<string[]>,\n};\n\n// generic brickadia events are forwarded to the proxy omegga\nparent.on('brickadiaEvent', (type, ...args) => {\n if (!vm) return;\n if (type === 'error') {\n Logger.errorp(pluginName.brightRed, 'Received error', ...args);\n return;\n }\n try {\n omegga.emit(type, ...args);\n } catch (e) {\n Logger.errorp(\n pluginName.brightRed,\n `Error in safe plugin worker's brickadiaEvent (${type}):`,\n e?.stack ?? e.toString(),\n );\n }\n});\n\n// create the node vm\nasync function createVm(\n pluginPath: string,\n { builtin = ['*'], external = true, isTypeScript = false } = {},\n): Promise<[boolean, string]> {\n let pluginCode: string;\n\n if (isTypeScript) {\n const tsBuildPath = path.join(pluginPath, TS_BUILD_DIR);\n const sourceFileName = path.join(pluginPath, MAIN_FILE_TS);\n const outputPath = path.join(tsBuildPath, TS_BUILD_FILE);\n try {\n mkdir(tsBuildPath);\n mkdir(path.join(tsBuildPath, '.cache'));\n\n const stats = await new Promise<Stats>((resolve, reject) => {\n webpack(\n Object.freeze({\n target: 'node',\n context: __dirname,\n mode: fs.existsSync(path.resolve(pluginPath, '.development'))\n ? 'development'\n : 'production',\n entry: sourceFileName,\n devtool: 'source-map',\n output: {\n iife: false,\n library: {\n type: 'commonjs',\n },\n path: tsBuildPath,\n filename: TS_BUILD_FILE,\n },\n externals: [\n function (\n { request }: ExternalItemFunctionData,\n callback: (err?: Error, result?: string) => void,\n ) {\n if (request.match(/\\.node$/)) {\n return callback(\n null,\n 'commonjs ' + path.resolve(pluginPath, request),\n );\n }\n callback();\n },\n ],\n resolve: {\n extensions: ['.ts', '.js', '.json', '.node'],\n alias: {\n // src is the only hard coded path\n src: path.resolve(pluginPath, 'src'),\n },\n },\n cache: {\n type: 'filesystem' as 'filesystem',\n cacheLocation: path.join(tsBuildPath, '.cache'),\n allowCollectingMemory: false,\n idleTimeout: 0,\n idleTimeoutForInitialStore: 0,\n // cache age is one week. plugins probably do not need\n // to be rebuilt every day\n maxAge: 1000 * 60 * 60 * 24 * 7,\n profile: true,\n },\n module: {\n rules: [\n {\n test: /\\.[jt]s$/,\n exclude: /(node_modules)/,\n use: {\n loader: 'swc-loader',\n options: {\n sourceMaps: true,\n cwd: pluginPath,\n isModule: true,\n jsc: {\n target: 'es2020',\n parser: {\n syntax: 'typescript',\n },\n transform: {},\n },\n\n module: {\n type: 'commonjs',\n strictMode: false,\n },\n },\n },\n },\n ],\n },\n }),\n (err, stats) => (err ? reject(err) : resolve(stats)),\n );\n });\n\n if (stats.hasErrors()) {\n for (const err of stats.toJson().errors) {\n Logger.errorp(err.moduleName, err.file);\n Logger.errorp(err.message);\n }\n }\n\n if (stats.hasWarnings()) {\n for (const warning of stats.toJson().warnings) {\n Logger.warnp(warning.moduleName, warning.file);\n Logger.warnp(warning.message);\n }\n }\n\n pluginCode = fs.readFileSync(outputPath).toString();\n } catch (err) {\n Logger.errorp(pluginName.brightRed, err);\n return [false, 'failed compiling building typescript'];\n }\n\n // update omegga.d.ts to latest on plugin compile\n try {\n const gitIgnore = path.join(pluginPath, '.gitignore');\n const omeggaTypesDst = path.join(pluginPath, 'omegga.d.ts');\n const omeggaTypesSrc = path.join(\n __dirname,\n '../../../../templates/safe-ts/omegga.d.ts',\n );\n\n // plugin has gitignore with \"omegga.d.ts\" in it and omegga has omegga.d.ts\n if (fs.existsSync(gitIgnore) && fs.existsSync(omeggaTypesSrc)) {\n // and the gitignore covers the omegga.d.ts\n const hasOmeggaTypesIgnored = fs\n .readFileSync(gitIgnore)\n .toString()\n .match(/(\\.\\/)?omegga\\.d\\.ts/);\n\n // compare last modified times to avoid unnecessary copies\n const srcLastModified = fs.statSync(omeggaTypesSrc).mtime.getTime();\n const dstLastModified = fs.existsSync(omeggaTypesDst)\n ? fs.statSync(omeggaTypesDst).mtime.getTime()\n : null;\n if (\n hasOmeggaTypesIgnored &&\n (!dstLastModified || srcLastModified > dstLastModified)\n ) {\n fs.copyFileSync(omeggaTypesSrc, omeggaTypesDst);\n }\n }\n } catch (err) {\n Logger.errorp(\n pluginName.brightRed,\n 'error copying latest omegga.d.ts to typescript plugin',\n err,\n );\n }\n }\n if (vm !== undefined) return [false, 'vm is already created'];\n\n // create the vm\n vm = new NodeVM({\n console: 'redirect',\n sandbox: {},\n require: {\n external,\n builtin,\n root: pluginPath,\n },\n });\n\n // plugin log generator function\n const ezLog =\n (\n logFn: 'log' | 'error' | 'info' | 'debug' | 'warn' | 'trace',\n name: string,\n symbol: string,\n ) =>\n (...args: any[]) =>\n console[logFn](name.underline, symbol, ...args);\n\n // special formatting for stdout\n vm.on('console.log', ezLog('log', pluginName, '>>'.green));\n vm.on('console.error', ezLog('error', pluginName.brightRed, '!>'.red));\n vm.on('console.info', ezLog('info', pluginName, '#>'.blue));\n vm.on('console.debug', ezLog('debug', pluginName, '?>'.blue));\n vm.on('console.warn', ezLog('warn', pluginName.brightYellow, ':>'.yellow));\n vm.on('console.trace', ezLog('trace', pluginName, 'T>'.grey));\n\n global.OMEGGA_UTIL = OmeggaUtil;\n // pass in util functions\n vm.freeze(global.OMEGGA_UTIL, 'OMEGGA_UTIL');\n vm.freeze(omegga, 'Omegga');\n vm.freeze(Player, 'Player');\n\n const file = path.join(\n pluginPath,\n isTypeScript ? path.join(TS_BUILD_DIR, TS_BUILD_FILE) : MAIN_FILE,\n );\n if (!isTypeScript) {\n try {\n pluginCode = fs.readFileSync(file).toString();\n } catch (e) {\n emit(\n 'error',\n 'failed to read plugin source: ' + (e?.stack ?? e.toString()),\n );\n throw 'failed to read plugin source: ' + (e?.stack ?? e.toString());\n }\n }\n\n // proxy the plugin out of the vm\n // potential for performance improvement by using VM.script to precompile plugins\n try {\n const pluginOutput = vm.run(pluginCode, file);\n PluginClass = pluginOutput?.default ?? pluginOutput;\n } catch (e) {\n emit('error', 'plugin failed to init');\n Logger.errorp(pluginName.brightRed, e);\n throw 'plugin failed to init: ' + (e?.stack ?? e.toString());\n }\n\n if (\n !PluginClass ||\n typeof PluginClass !== 'function' ||\n typeof PluginClass.prototype !== 'object'\n ) {\n PluginClass = undefined;\n emit('error', 'plugin does not export a class');\n throw 'plugin does not export a class';\n }\n\n if (typeof PluginClass.prototype.init !== 'function') {\n PluginClass = undefined;\n emit('error', 'plugin is missing init() function');\n throw 'plugin is missing init() function';\n }\n\n if (typeof PluginClass.prototype.stop !== 'function') {\n PluginClass = undefined;\n emit('error', 'plugin is missing stop() function');\n throw 'plugin is missing stop() function';\n }\n}\n\n// kill this plugin\nparent.on('kill', resp => {\n emit(resp);\n process.exit(0);\n});\n\n// set plugin name\nparent.on('name', (resp, name) => {\n pluginName = name;\n // temp save prefix changes to avoid collision\n omegga._tempSavePrefix = 'omegga_' + name + '_temp';\n emit(resp);\n});\n\n// get memory usage for this plugin\nparent.on('mem', resp => emit(resp, 'mem', process.memoryUsage()));\n\n// create the vm\nparent.on('load', async (resp, pluginPath, options) => {\n try {\n await createVm(pluginPath, options);\n\n emit(resp, true);\n } catch (err) {\n Logger.errorp(\n pluginName.brightRed,\n 'error creating vm',\n err?.stack ?? err.toString(),\n );\n emit(resp, false);\n }\n});\n\n// start the plugin with a faux omegga\n// resp is an action sent back to the parent process\n// to coordinate async funcs\nparent.on('start', async (resp, config) => {\n try {\n pluginInstance = new PluginClass(omegga as any as Omegga, config, store);\n const result = await pluginInstance.init();\n // if a plugin init returns a list of strings, treat them as the list of commands\n if (typeof result === 'object' && result) {\n // if registeredCommands is in the results, register the provided strings as commands\n const cmds = result.registeredCommands;\n if (\n cmds &&\n cmds instanceof Array &&\n cmds.every(i => typeof i === 'string')\n ) {\n emit('command.registers', JSON.stringify(cmds));\n }\n }\n emit(resp, true);\n } catch (err) {\n emit('error', 'error starting plugin', err?.stack ?? JSON.stringify(err));\n emit(resp, false);\n Logger.errorp(pluginName.brightRed, 'Error starting plugin', err);\n }\n});\n\n// stop the plugin\nparent.on('stop', async resp => {\n try {\n if (pluginInstance) {\n await pluginInstance.stop.bind(pluginInstance)();\n }\n pluginInstance = undefined;\n emit(resp, true);\n } catch (err) {\n emit('error', 'error stopping plugin', err?.stack ?? err.toString());\n emit(resp, false);\n }\n});\n\n// handle emitPlugins\nparent.on('emitPlugin', async (resp, ev, from, args) => {\n if (pluginInstance?.pluginEvent) {\n emit(resp, await pluginInstance.pluginEvent(ev, from, ...args));\n } else {\n emit(resp, null);\n }\n});\n"],"names":["Logger","parentPort","injectOmeggaPrototypes","ProxyOmegga","Omegga","cloneDeep","mkdir","stats","NodeVM","OmeggaUtil","Player","file"],"mappings":";;;;;;;;;;;;;;;AAyBAA,OAAAA,QAAO,UAAU,QAAQ,IAAI,YAAY;AAEzC,MAAM,YAAY;AAClB,MAAM,eAAe;AACrB,MAAM,eAAe;AACrB,MAAM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jB,SAAS,KAAK;AACZ,SAAK,SAAS,yBAAyB,KAAK,SAAS,KAAK,UAAU,GAAG,CAAC;AACxE,SAAK,MAAM,KAAK;AAChBA,WAAAA,QAAO,OAAO,WAAW,WAAW,yBAAyB,GAAG;AAAA,EAClE;AACF,CAAC;AAGD,OAAO,GAAG,QAAQ,OAAM,SAAQ;AAC9B,MAAI;AACF,QAAI,gBAAgB;AAClB,YAAM,eAAe,KAAK,KAAK,cAAc,EAAA;AAAA,IAC/C;AACA,qBAAiB;AACjB,SAAK,MAAM,IAAI;AAAA,EACjB,SAAS,KAAK;AACZ,SAAK,SAAS,yBAAyB,KAAK,SAAS,IAAI,UAAU;AACnE,SAAK,MAAM,KAAK;AAAA,EAClB;AACF,CAAC;AAGD,OAAO,GAAG,cAAc,OAAO,MAAM,IAAI,MAAM,SAAS;AACtD,MAAI,gBAAgB,aAAa;AAC/B,SAAK,MAAM,MAAM,eAAe,YAAY,IAAI,MAAM,GAAG,IAAI,CAAC;AAAA,EAChE,OAAO;AACL,SAAK,MAAM,IAAI;AAAA,EACjB;AACF,CAAC;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omegga",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Brickadia server installer, updater, manager, wrapper, configurator, and automator",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=23.0.0"
|
|
@@ -95,20 +95,24 @@
|
|
|
95
95
|
"vite-plugin-module-alias": "^1.3.5",
|
|
96
96
|
"vite-plugin-native-import-maps": "^0.0.4",
|
|
97
97
|
"vite-plugin-sass": "^0.1.0",
|
|
98
|
+
"vitest": "^3.2.4",
|
|
98
99
|
"webpack-cli": "^5.0.2",
|
|
99
100
|
"wouter": "^3.7.1"
|
|
100
101
|
},
|
|
101
102
|
"scripts": {
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
"
|
|
107
|
-
"dist": "npx vite build && npm run build && npm run dts",
|
|
108
|
-
"build:frontend": "npx vite build",
|
|
109
|
-
"build": "npx tspc --build \"src/\"",
|
|
103
|
+
"build:frontend": "npx vite build -c vite.frontend.config.mts",
|
|
104
|
+
"build:old": "npx tspc --build \"src/\"",
|
|
105
|
+
"build": "npx vite build -c vite.backend.config.mts",
|
|
106
|
+
"check": "eslint",
|
|
107
|
+
"dist": "npm run build:frontend && npm run build && npm run dts",
|
|
110
108
|
"dts": "npx dts-bundle-generator --inline-declare-global --no-banner --no-check --external-inlines brs-js -o templates/safe-ts/omegga.d.ts -- ./src/plugin.ts",
|
|
111
|
-
"
|
|
109
|
+
"lint:fix": "npx prettier --write \"src/\" \"frontend/src/\"",
|
|
110
|
+
"lint": "npx prettier --check \"src/\" \"frontend/src\"",
|
|
111
|
+
"prepare": "ts-patch install",
|
|
112
|
+
"start": "node --enable-source-maps index.js",
|
|
113
|
+
"test:backend": "vitest --config vitest.backend.config.mts --dir ./src",
|
|
114
|
+
"test": "npm run test:backend",
|
|
115
|
+
"watch": "npm run build:frontend -- --watch"
|
|
112
116
|
},
|
|
113
117
|
"author": "Meshiest",
|
|
114
118
|
"license": "ISC",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { randomUUID as random } from 'crypto';
|
|
1
|
+
import { randomUUID as random } from 'node:crypto';
|
|
2
2
|
|
|
3
3
|
export interface BRColor {
|
|
4
4
|
r: number;
|
|
@@ -2226,7 +2226,7 @@ export interface PluginInterop {
|
|
|
2226
2226
|
loaded: boolean;
|
|
2227
2227
|
emitPlugin?(event: string, args: any[]): Promise<any>;
|
|
2228
2228
|
}
|
|
2229
|
-
export type WeaponClass = "Weapon_AntiMaterielRifle" | "Weapon_ArmingSword" | "Weapon_AssaultRifle" | "Weapon_AutoShotgun" | "Weapon_Battleaxe" | "Weapon_Bazooka" | "Weapon_Bow" | "Weapon_BullpupRifle" | "Weapon_BullpupSMG" | "Weapon_ChargedLongsword" | "Weapon_CrystalKalis" | "Weapon_Derringer" | "Weapon_FlintlockPistol" | "Weapon_GrenadeLauncher" | "Weapon_Handaxe" | "Weapon_HealthPotion" | "Weapon_HeavyAssaultRifle" | "Weapon_HeavySMG" | "Weapon_HeroSword" | "Weapon_HighPowerPistol" | "Weapon_HoloBlade" | "Weapon_HuntingShotgun" | "Weapon_Ikakalaka" | "Weapon_ImpactGrenade" | "Weapon_ImpactGrenadeLauncher" | "Weapon_ImpulseGrenade" | "Weapon_Khopesh" | "Weapon_Knife" | "Weapon_LeverActionRifle" | "Weapon_LightMachineGun" | "Weapon_LongSword" | "Weapon_MagnumPistol" | "Weapon_MicroSMG" | "Weapon_Minigun" | "Weapon_Pistol" | "Weapon_PulseCarbine" | "Weapon_QuadLauncher" | "Weapon_Revolver" | "Weapon_RocketJumper" | "Weapon_RocketLauncher" | "Weapon_Sabre" | "Weapon_SemiAutoRifle" | "Weapon_ServiceRifle" | "Weapon_Shotgun" | "Weapon_SlugShotgun" | "Weapon_Sniper" | "Weapon_Spatha" | "Weapon_StandardSubmachineGun" | "Weapon_StickGrenade" | "Weapon_SubmachineGun" | "Weapon_SuperShotgun" | "Weapon_SuppressedAssaultRifle" | "Weapon_SuppressedBullpupSMG" | "Weapon_SuppressedPistol" | "Weapon_SuppressedServiceRifle" | "
|
|
2229
|
+
export type WeaponClass = "Weapon_APCarbine" | "Weapon_AntiMaterielRifle" | "Weapon_ArmingSword" | "Weapon_AssaultRifle" | "Weapon_AutoShotgun" | "Weapon_Battleaxe" | "Weapon_Bazooka" | "Weapon_BoltActionRifle" | "Weapon_Bow" | "Weapon_BoxPistol" | "Weapon_BullpupRifle" | "Weapon_BullpupSMG" | "Weapon_ChargedLongsword" | "Weapon_CrystalKalis" | "Weapon_Derringer" | "Weapon_Dynamite" | "Weapon_FlintlockPistol" | "Weapon_GrenadeLauncher" | "Weapon_GuardPistol" | "Weapon_Handaxe" | "Weapon_HealthPotion" | "Weapon_HeavyAssaultRifle" | "Weapon_HeavySMG" | "Weapon_HeroSword" | "Weapon_HighPowerPistol" | "Weapon_HoloBlade" | "Weapon_HuntingShotgun" | "Weapon_Ikakalaka" | "Weapon_ImpactGrenade" | "Weapon_ImpactGrenadeLauncher" | "Weapon_ImpulseGrenade" | "Weapon_Khopesh" | "Weapon_Knife" | "Weapon_LeverActionRifle" | "Weapon_LightMachineGun" | "Weapon_LongSword" | "Weapon_MagnumPistol" | "Weapon_MicroSMG" | "Weapon_Minigun" | "Weapon_Minigun" | "Weapon_MissileLauncher" | "Weapon_PDW" | "Weapon_Pickaxe" | "Weapon_PipeBomb" | "Weapon_Pistol" | "Weapon_PlasmaPistol" | "Weapon_PlasmaSMG" | "Weapon_PulseCarbine" | "Weapon_PulseRifle" | "Weapon_QuadLauncher" | "Weapon_Revolver" | "Weapon_RocketJumper" | "Weapon_RocketLauncher" | "Weapon_Sabre" | "Weapon_SemiAutoRifle" | "Weapon_ServiceRifle" | "Weapon_Shotgun" | "Weapon_SlugShotgun" | "Weapon_Sniper" | "Weapon_SodaCan" | "Weapon_Spatha" | "Weapon_SportingShotgun" | "Weapon_StampedSMG" | "Weapon_StandardSubmachineGun" | "Weapon_StickGrenade" | "Weapon_SubmachineGun" | "Weapon_SuperShotgun" | "Weapon_SuppressedAssaultRifle" | "Weapon_SuppressedBullpupSMG" | "Weapon_SuppressedGuardPistol" | "Weapon_SuppressedHeavySMG" | "Weapon_SuppressedMicroSMG" | "Weapon_SuppressedPistol" | "Weapon_SuppressedServiceRifle" | "Weapon_TacticalSMG" | "Weapon_TacticalShotgun" | "Weapon_Tomahawk" | "Weapon_TwinCannon" | "Weapon_TypewriterSMG" | "Weapon_Zweihander";
|
|
2230
2230
|
|
|
2231
2231
|
export {
|
|
2232
2232
|
OmeggaPlugin as default,
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import path, { resolve } from 'path';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
root: 'src',
|
|
6
|
+
build: {
|
|
7
|
+
outDir: resolve(__dirname, 'dist'),
|
|
8
|
+
emptyOutDir: true,
|
|
9
|
+
sourcemap: true,
|
|
10
|
+
minify: false,
|
|
11
|
+
ssr: true,
|
|
12
|
+
target: 'node23',
|
|
13
|
+
rollupOptions: {
|
|
14
|
+
input: {
|
|
15
|
+
main: path.resolve(__dirname, 'src/main.ts'),
|
|
16
|
+
index: path.resolve(__dirname, 'src/index.ts'),
|
|
17
|
+
worker: path.resolve(
|
|
18
|
+
__dirname,
|
|
19
|
+
'src/omegga/plugin/plugin_node_safe/worker.ts',
|
|
20
|
+
),
|
|
21
|
+
},
|
|
22
|
+
output: {
|
|
23
|
+
format: 'cjs',
|
|
24
|
+
exports: 'named',
|
|
25
|
+
entryFileNames: '[name].js',
|
|
26
|
+
// Preserve module structure instead of bundling
|
|
27
|
+
preserveModules: true,
|
|
28
|
+
preserveModulesRoot: 'src',
|
|
29
|
+
},
|
|
30
|
+
// Keep Node.js modules and dependencies external to avoid dynamic require issues
|
|
31
|
+
external: [/^node:/, /node_modules/],
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
resolve: {
|
|
35
|
+
alias: {
|
|
36
|
+
'@omegga': path.resolve(__dirname, 'src/omegga'),
|
|
37
|
+
'@cli': path.resolve(__dirname, 'src/cli'),
|
|
38
|
+
'@util': path.resolve(__dirname, 'src/util'),
|
|
39
|
+
'@webserver': path.resolve(__dirname, 'src/webserver'),
|
|
40
|
+
'@brickadia': path.resolve(__dirname, 'src/brickadia'),
|
|
41
|
+
'@config': path.resolve(__dirname, 'src/config'),
|
|
42
|
+
'@': path.resolve(__dirname, 'src'),
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
ssr: { noExternal: /node_modules/ },
|
|
46
|
+
});
|