@runeya/runeya 1.33.8 → 1.33.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/node-red-contrib-runeya.tar +0 -0
  2. package/package.json +1 -1
  3. package/public/assets/{App-ClT0daRA.css → App-BVTb2f1U.css} +1 -1
  4. package/public/assets/App-havugOhG.js +101 -0
  5. package/public/assets/{CurrentEditor-BgkRP7cS.js → CurrentEditor-CGzL3h8U.js} +1 -1
  6. package/public/assets/{Editor-BqvrNzb6.js → Editor-DK3XKnCP.js} +6 -6
  7. package/public/assets/{ImportCreate-B-lRmpLH.js → ImportCreate-Byvpjnq0.js} +1 -1
  8. package/public/assets/{Init-D3C4n99F.js → Init-Dif9nNb1.js} +1 -1
  9. package/public/assets/{LeftLogo-E7dYCAWT.js → LeftLogo-Cbwhm4ku.js} +1 -1
  10. package/public/assets/{Markdown-dzyZ7CTg.js → Markdown-5TtJbvAz.js} +1 -1
  11. package/public/assets/{Overview-YtPSCN3k.js → Overview-Bl8fTVx6.js} +1 -1
  12. package/public/assets/{Section-YBL4Pzic.js → Section-DLhOQaZc.js} +1 -1
  13. package/public/assets/{Settings-DJaMzLUX.js → Settings-BjPflvt4.js} +1 -1
  14. package/public/assets/{StackChooser-DAAV0Rat.js → StackChooser-Dm1JVLNV.js} +1 -1
  15. package/public/assets/{StackChooser-BnNrvv4Y.js → StackChooser-jx7LDKIV.js} +1 -1
  16. package/public/assets/{StackMultiple-D0ozn0Tf.js → StackMultiple-kplS4h1T.js} +1 -1
  17. package/public/assets/{StackSingle-CHHH2rXO.js → StackSingle-vf02csuy.js} +1 -1
  18. package/public/assets/{Tabs-D9ZNelJj.js → Tabs-DnJSk4n2.js} +1 -1
  19. package/public/assets/{cssMode-BEnNoAFz.js → cssMode-BPdPLkVG.js} +1 -1
  20. package/public/assets/{freemarker2-z8zA5ezm.js → freemarker2-3NvUG45O.js} +1 -1
  21. package/public/assets/{handlebars-DTrkysaX.js → handlebars-CFHZlhgH.js} +1 -1
  22. package/public/assets/{html-BiGIRkmo.js → html-Bkw9bGL4.js} +1 -1
  23. package/public/assets/{htmlMode-CGj06Oa8.js → htmlMode-CRd0eLDO.js} +1 -1
  24. package/public/assets/{index-G1ob8hK0.js → index-CWdLNLf2.js} +2 -2
  25. package/public/assets/{javascript-DEAY-G4N.js → javascript-ByJcXg8C.js} +1 -1
  26. package/public/assets/{jsonMode-CLJTah_r.js → jsonMode-eQLqr7ag.js} +1 -1
  27. package/public/assets/{liquid-Bt_q9jyv.js → liquid-D7tDuX3T.js} +1 -1
  28. package/public/assets/{mdx-BtbMy52t.js → mdx-Ct31jTJm.js} +1 -1
  29. package/public/assets/{python-DIVYbK-C.js → python-B9O75g1L.js} +1 -1
  30. package/public/assets/{razor-ztrk2wBu.js → razor-CTgHL3xd.js} +1 -1
  31. package/public/assets/{router-B2S_D5pC.js → router-B5BHMCJX.js} +4 -4
  32. package/public/assets/{system-DYhoWbZ1.js → system-D6n39APF.js} +1 -1
  33. package/public/assets/{tsMode-Fc-Kxr3a.js → tsMode-D-YLfP_n.js} +1 -1
  34. package/public/assets/{typescript-CHa_3xkF.js → typescript-CjO-D8b6.js} +1 -1
  35. package/public/assets/{xml-B2WXRoPu.js → xml-D7AJmN-D.js} +1 -1
  36. package/public/assets/{yaml-6vYkUkh3.js → yaml-Ct88-2x6.js} +1 -1
  37. package/public/index.html +1 -1
  38. package/runeya.vsix +0 -0
  39. package/www.js +235 -173
  40. package/www.js.map +1 -1
  41. package/public/assets/App-Bzzr3d8D.js +0 -101
package/www.js CHANGED
@@ -14,39 +14,6 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
14
14
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
15
15
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
16
16
 
17
- // helpers/args.js
18
- var require_args = __commonJS({
19
- "helpers/args.js"(exports2, module2) {
20
- "use strict";
21
- var path = require("path");
22
- var yargs = require("yargs/yargs");
23
- var { hideBin } = require("yargs/helpers");
24
- var { existsSync } = require("fs");
25
- var yarg = yargs(hideBin(process.argv)).usage("Usage: <path-to-your-stack> [options]").alias("pe", "pull-env").describe("pe", "Pull env from a service (need --environment and --service)").default("pe", false).alias("e", "environment").describe("e", "Choose your environment").default("e", void 0).alias("s", "service").describe("s", "Service").default("s", void 0).alias("ss", "services").describe("ss", "Services").default("ss", []).boolean(["pe"]).string(["e", "s"]).array(["ss"]).help("h").alias("h", "help").parse();
26
- var args2 = Object.assign({
27
- rootPath: path.resolve(yarg["_"]?.[0] || "."),
28
- initialCwd: ""
29
- }, yarg);
30
- if (!existsSync(args2.rootPath)) {
31
- console.error("Error: Runeya was launched with an invalid root path that does not exist. Please check your launch command. \nPath: ", args2.rootPath);
32
- process.exit(1);
33
- }
34
- if (args2.rootPath) {
35
- args2.initialCwd = process.cwd();
36
- process.chdir(args2.rootPath);
37
- }
38
- if (args2.pullEnv && !args2.service) {
39
- console.error("Error: --service needed");
40
- process.exit(1);
41
- }
42
- if (args2.pullEnv && !args2.environment) {
43
- console.error("Error: --environment needed");
44
- process.exit(1);
45
- }
46
- module2.exports = args2;
47
- }
48
- });
49
-
50
17
  // ../../common/socket-server/src/CustomObservable.js
51
18
  var require_CustomObservable = __commonJS({
52
19
  "../../common/socket-server/src/CustomObservable.js"(exports2, module2) {
@@ -128,6 +95,39 @@ var require_src = __commonJS({
128
95
  }
129
96
  });
130
97
 
98
+ // helpers/args.js
99
+ var require_args = __commonJS({
100
+ "helpers/args.js"(exports2, module2) {
101
+ "use strict";
102
+ var path = require("path");
103
+ var yargs = require("yargs/yargs");
104
+ var { hideBin } = require("yargs/helpers");
105
+ var { existsSync } = require("fs");
106
+ var yarg = yargs(hideBin(process.argv)).usage("Usage: <path-to-your-stack> [options]").alias("pe", "pull-env").describe("pe", "Pull env from a service (need --environment and --service)").default("pe", false).alias("e", "environment").describe("e", "Choose your environment").default("e", void 0).alias("s", "service").describe("s", "Service").default("s", void 0).alias("ss", "services").describe("ss", "Services").default("ss", []).boolean(["pe"]).string(["e", "s"]).array(["ss"]).help("h").alias("h", "help").parse();
107
+ var args2 = Object.assign({
108
+ rootPath: path.resolve(yarg["_"]?.[0] || "."),
109
+ initialCwd: ""
110
+ }, yarg);
111
+ if (!existsSync(args2.rootPath)) {
112
+ console.error("Error: Runeya was launched with an invalid root path that does not exist. Please check your launch command. \nPath: ", args2.rootPath);
113
+ process.exit(1);
114
+ }
115
+ if (args2.rootPath) {
116
+ args2.initialCwd = process.cwd();
117
+ process.chdir(args2.rootPath);
118
+ }
119
+ if (args2.pullEnv && !args2.service) {
120
+ console.error("Error: --service needed");
121
+ process.exit(1);
122
+ }
123
+ if (args2.pullEnv && !args2.environment) {
124
+ console.error("Error: --environment needed");
125
+ process.exit(1);
126
+ }
127
+ module2.exports = args2;
128
+ }
129
+ });
130
+
131
131
  // ../../modules/bugs/backend/routes.js
132
132
  var require_routes = __commonJS({
133
133
  "../../modules/bugs/backend/routes.js"(exports2, module2) {
@@ -358,7 +358,7 @@ var require_crypto = __commonJS({
358
358
  "use strict";
359
359
  var _sodium = require("libsodium-wrappers");
360
360
  var crypto = require("crypto");
361
- var { sockets } = require_src();
361
+ var { sockets: sockets2 } = require_src();
362
362
  var conflictStorage = require_conflictStorage();
363
363
  var path = require("path");
364
364
  module2.exports.generateKey = async () => {
@@ -454,7 +454,7 @@ var require_crypto = __commonJS({
454
454
  };
455
455
  const conflictId = conflictStorage.storeConflict(conflictData);
456
456
  conflictData.id = conflictId;
457
- sockets.emit("crypto:conflict", conflictData);
457
+ sockets2.emit("crypto:conflict", conflictData);
458
458
  return `${JSON.stringify({
459
459
  ourVersion: ourDecrypted,
460
460
  theirVersion: theirDecrypted
@@ -489,7 +489,7 @@ var require_dbs = __commonJS({
489
489
  } = require("fs/promises");
490
490
  var { fdir } = require("fdir");
491
491
  var PromiseB2 = require("bluebird");
492
- var { sockets } = require_src();
492
+ var { sockets: sockets2 } = require_src();
493
493
  var args2 = require_args();
494
494
  var { encrypt, decrypt, decryptFile } = require_crypto();
495
495
  var alasql = require("alasql");
@@ -542,13 +542,13 @@ var require_dbs = __commonJS({
542
542
  } else {
543
543
  db = await decrypt(db, { additionnalNonce }).catch((err) => {
544
544
  console.error(path, err);
545
- sockets.emit("system:wrongKey");
545
+ sockets2.emit("system:wrongKey");
546
546
  throw err;
547
547
  });
548
548
  }
549
549
  } catch (err) {
550
550
  console.error(path, err);
551
- sockets.emit("system:wrongKey");
551
+ sockets2.emit("system:wrongKey");
552
552
  throw err;
553
553
  }
554
554
  }
@@ -2381,7 +2381,7 @@ var require_routes11 = __commonJS({
2381
2381
  "../../modules/workflows/backend/routes.js"(exports2, module2) {
2382
2382
  "use strict";
2383
2383
  var { express, getServer } = require_src6();
2384
- var { sockets } = require_src();
2384
+ var { sockets: sockets2 } = require_src();
2385
2385
  var RED = require("node-red");
2386
2386
  var compressing = require("compressing");
2387
2387
  var router = express.Router();
@@ -2407,7 +2407,7 @@ var require_routes11 = __commonJS({
2407
2407
  paletteCategories: ["Runeya"]
2408
2408
  };
2409
2409
  settings.functionGlobalContext.runeya = {
2410
- sockets,
2410
+ sockets: sockets2,
2411
2411
  url: `http://localhost:${ports.http}`,
2412
2412
  stack: require_stack()
2413
2413
  };
@@ -2476,7 +2476,7 @@ var require_routes11 = __commonJS({
2476
2476
  !package.json
2477
2477
  `);
2478
2478
  await RED.start();
2479
- sockets.emit("scenarios:start");
2479
+ sockets2.emit("scenarios:start");
2480
2480
  });
2481
2481
  return router;
2482
2482
  };
@@ -2877,7 +2877,7 @@ var require_Service = __commonJS({
2877
2877
  var axios = require("axios").default;
2878
2878
  var pathfs = require("path");
2879
2879
  var net = require("net");
2880
- var { sockets } = require_src();
2880
+ var { sockets: sockets2 } = require_src();
2881
2881
  var { mkdir, writeFile } = require("fs/promises");
2882
2882
  var { cloneDeep, over } = require("lodash");
2883
2883
  var CreateInterface = require_readline();
@@ -2980,7 +2980,7 @@ var require_Service = __commonJS({
2980
2980
  Service.prototype.processQueue = function() {
2981
2981
  if (this.queue.length) {
2982
2982
  const messages = this.queue.splice(0, this.queue.length);
2983
- sockets.emit("logs:update", messages);
2983
+ sockets2.emit("logs:update", messages);
2984
2984
  }
2985
2985
  if (this.stopQueue) return;
2986
2986
  setTimeout(() => {
@@ -3049,7 +3049,7 @@ var require_Service = __commonJS({
3049
3049
  await this.launch();
3050
3050
  };
3051
3051
  Service.prototype.sendHasBeenModified = function() {
3052
- sockets.emit("conf:update", [this.label]);
3052
+ sockets2.emit("conf:update", [this.label]);
3053
3053
  };
3054
3054
  Service.prototype.kill = async function(keepEnabled = false) {
3055
3055
  if (this.container?.enabled && this.container?.name) {
@@ -3080,7 +3080,7 @@ var require_Service = __commonJS({
3080
3080
  }
3081
3081
  }
3082
3082
  this.pids = [];
3083
- sockets.emit("logs:clear", { label: this.label });
3083
+ sockets2.emit("logs:clear", { label: this.label });
3084
3084
  this.store = [];
3085
3085
  await wait(100);
3086
3086
  this.enabled = keepEnabled;
@@ -3138,7 +3138,7 @@ var require_Service = __commonJS({
3138
3138
  }, line);
3139
3139
  if (line.hide) return;
3140
3140
  if (line.source === "stderr" && isMainProcess) {
3141
- sockets.emit("alert", { label: this.label, message: line.raw.toString(), type: "error", commandId: command?.id });
3141
+ sockets2.emit("alert", { label: this.label, message: line.raw.toString(), type: "error", commandId: command?.id });
3142
3142
  }
3143
3143
  if (timestamp > (this.lastDatePrinted || Date.now()) + 2e3) {
3144
3144
  const date = `\u{1F551} ${dayjs().format("YYYY-MM-DD HH:mm:ss")}`;
@@ -3229,7 +3229,7 @@ var require_Service = __commonJS({
3229
3229
  if (code) {
3230
3230
  if (launchMessage.cmd) launchMessage.cmd.status = "error";
3231
3231
  if (isMainProcess) {
3232
- sockets.emit("service:crash", {
3232
+ sockets2.emit("service:crash", {
3233
3233
  label: this.label,
3234
3234
  code,
3235
3235
  signal,
@@ -3243,13 +3243,13 @@ var require_Service = __commonJS({
3243
3243
  this.exited = true;
3244
3244
  }
3245
3245
  }
3246
- sockets.emit("service:exit", {
3246
+ sockets2.emit("service:exit", {
3247
3247
  label: this.label,
3248
3248
  code,
3249
3249
  signal,
3250
3250
  pid
3251
3251
  });
3252
- sockets.emit("logs:update:lines", [launchMessage]);
3252
+ sockets2.emit("logs:update:lines", [launchMessage]);
3253
3253
  });
3254
3254
  const date = `\u{1F551} ${dayjs().format("YYYY-MM-DD HH:mm:ss")}`;
3255
3255
  const line = {
@@ -3261,12 +3261,12 @@ var require_Service = __commonJS({
3261
3261
  isSeparator: true
3262
3262
  };
3263
3263
  this.store.push(line, launchMessage);
3264
- sockets.emit("logs:update", [line, launchMessage]);
3264
+ sockets2.emit("logs:update", [line, launchMessage]);
3265
3265
  if (isMainProcess) {
3266
3266
  setTimeout(() => {
3267
3267
  this.launchHealthChecker(spawnProcess);
3268
3268
  }, this.health.startAfter || 0);
3269
- sockets.emit("service:start", {
3269
+ sockets2.emit("service:start", {
3270
3270
  label: this.label,
3271
3271
  pid
3272
3272
  });
@@ -3299,7 +3299,7 @@ var require_Service = __commonJS({
3299
3299
  timestamp: this.lastDatePrinted,
3300
3300
  isSeparator: true
3301
3301
  };
3302
- sockets.emit("logs:update", [line, launchMessage]);
3302
+ sockets2.emit("logs:update", [line, launchMessage]);
3303
3303
  throw error;
3304
3304
  }
3305
3305
  };
@@ -3319,10 +3319,10 @@ var require_Service = __commonJS({
3319
3319
  }).catch(() => false);
3320
3320
  if (!healthy && !this.crashed) {
3321
3321
  this.crashed = true;
3322
- sockets.emit("service:healthcheck:down", { label: this.label, pid: spawnProcess.pid });
3322
+ sockets2.emit("service:healthcheck:down", { label: this.label, pid: spawnProcess.pid });
3323
3323
  } else if (healthy && this.crashed) {
3324
3324
  this.crashed = false;
3325
- sockets.emit("service:healthcheck:up", { label: this.label, pid: spawnProcess.pid });
3325
+ sockets2.emit("service:healthcheck:up", { label: this.label, pid: spawnProcess.pid });
3326
3326
  }
3327
3327
  await wait(+(this.health.interval || 1e3));
3328
3328
  this.launchHealthChecker(spawnProcess);
@@ -3344,7 +3344,7 @@ var require_Service = __commonJS({
3344
3344
  pid
3345
3345
  };
3346
3346
  this.store.push(line);
3347
- sockets.emit("logs:update", [line]);
3347
+ sockets2.emit("logs:update", [line]);
3348
3348
  return null;
3349
3349
  };
3350
3350
  Service.prototype.terminate = function(pid, forceKill = false) {
@@ -3707,7 +3707,7 @@ var require_saves = __commonJS({
3707
3707
  var require_stack = __commonJS({
3708
3708
  "models/stack.js"(exports2, module2) {
3709
3709
  "use strict";
3710
- var { sockets } = require_src();
3710
+ var { sockets: sockets2 } = require_src();
3711
3711
  var plugins = require_plugins();
3712
3712
  var PromiseB2 = require("bluebird");
3713
3713
  var Service = require_Service();
@@ -3742,7 +3742,7 @@ var require_stack = __commonJS({
3742
3742
  Stack.currentStack = null;
3743
3743
  Stack.currentWatches = [];
3744
3744
  Stack.currentEnvironment = null;
3745
- Stack.Socket = sockets;
3745
+ Stack.Socket = sockets2;
3746
3746
  Stack.plugins = plugins;
3747
3747
  Stack.version = require_version().version || "";
3748
3748
  Stack.url = `http://localhost:${ports.http}`;
@@ -3876,7 +3876,7 @@ var require_stack = __commonJS({
3876
3876
  if (service) service.enable();
3877
3877
  });
3878
3878
  }
3879
- return sockets.emit("stack:selectConf");
3879
+ return sockets2.emit("stack:selectConf");
3880
3880
  };
3881
3881
  Stack.prototype.changeEnvironment = async function(envLabel) {
3882
3882
  const environment = await EnvironmentModel.find(envLabel);
@@ -3963,12 +3963,13 @@ var require_plugins2 = __commonJS({
3963
3963
  var path = require("path");
3964
3964
  var { writeFileSync, existsSync } = require("fs");
3965
3965
  var { writeFile, mkdir, readFile, cp, rm, readdir } = require("fs/promises");
3966
+ var { spawn } = require("child_process");
3966
3967
  var dbs2 = require_dbs();
3967
3968
  var HTTPError = require_src2();
3968
3969
  var args2 = require_args();
3969
3970
  var tar = require("tar");
3970
3971
  var dbConfig = dbs2.getDb("plugins", { encrypted: false, defaultData: [] });
3971
- var { sockets } = require_src();
3972
+ var { sockets: sockets2 } = require_src();
3972
3973
  var stack = require_stack();
3973
3974
  var chokidar = require("chokidar");
3974
3975
  var debounce = require("debounce");
@@ -4016,7 +4017,7 @@ var require_plugins2 = __commonJS({
4016
4017
  await tar.extract({ file: packageTmpFilePath, cwd: packageTmpPath });
4017
4018
  const config = JSON.parse(await readFile(path.join(packageTmpPath, "package.json"), "utf8"));
4018
4019
  const plugin = await getInstalledPlugin(config.name, config.version);
4019
- console.log(config.version);
4020
+ console.log("Installing", config.name + "@" + config.version);
4020
4021
  if (plugin && !force) {
4021
4022
  throw new HTTPError("Plugin already installed", "400.68746854743512");
4022
4023
  }
@@ -4031,8 +4032,36 @@ var require_plugins2 = __commonJS({
4031
4032
  config,
4032
4033
  remotePath
4033
4034
  });
4035
+ if (config.runeya.entries.backend) {
4036
+ try {
4037
+ const child = await spawn("npm i --omit=dev", { cwd: path.dirname(path.resolve(diskPath, config.runeya.entries.backend)), shell: true });
4038
+ const installPromise = new Promise((resolve, reject) => {
4039
+ const installLog = [];
4040
+ child.stdout.on("data", (data2) => {
4041
+ installLog.push(data2.toString());
4042
+ console.log(`[${config.name}:${config.version}]`, data2.toString());
4043
+ });
4044
+ child.stderr.on("data", (data2) => {
4045
+ installLog.push(data2.toString());
4046
+ console.error(`[${config.name}:${config.version}]`, data2.toString());
4047
+ });
4048
+ child.on("close", (code) => {
4049
+ if (code !== 0) {
4050
+ reject(installLog.join("\n"));
4051
+ } else {
4052
+ resolve(installLog.join("\n"));
4053
+ }
4054
+ });
4055
+ });
4056
+ await installPromise;
4057
+ } catch (error) {
4058
+ console.error(error);
4059
+ sockets2.emit("plugins:install:error", config.name, error);
4060
+ return null;
4061
+ }
4062
+ }
4034
4063
  await loadPlugin(config.name);
4035
- sockets.emit("plugins:installed", {
4064
+ sockets2.emit("plugins:installed", {
4036
4065
  name: config.name,
4037
4066
  version: config.version,
4038
4067
  diskPath,
@@ -4041,8 +4070,8 @@ var require_plugins2 = __commonJS({
4041
4070
  });
4042
4071
  }
4043
4072
  async function getInstalledPlugins() {
4044
- const installedPlugins = await dbConfig.alasql.simpleSelect({});
4045
- if (process.env.NODE_ENV === "HFBXdZMJxLyJoua28asEaxRixJ6LriR7FnRzX6pwA7pFjZ") {
4073
+ let installedPlugins = [];
4074
+ if (process.env.NODE_ENV === "HFBXdZMJxLyJoua28asEaxRixJ6LriR7FnRzX6pwA7pFjZ" && process.env.PLUGIN_ONLY_PRODUCTION !== "true") {
4046
4075
  const pluginsPath = path.resolve(__dirname, "../../../plugins");
4047
4076
  const pluginsDir = await readdir(pluginsPath);
4048
4077
  await Promise.all(pluginsDir.map(async (pluginDirName) => {
@@ -4061,7 +4090,7 @@ var require_plugins2 = __commonJS({
4061
4090
  ...config.runeya.entries,
4062
4091
  front: {
4063
4092
  ...config.runeya.entries.front,
4064
- js: "./front/dist/index.umd.js"
4093
+ ...config.runeya.entries.front?.js ? { js: "./front/dist/index.umd.js" } : {}
4065
4094
  }
4066
4095
  }
4067
4096
  }
@@ -4069,21 +4098,18 @@ var require_plugins2 = __commonJS({
4069
4098
  "remotePath": "http://127.0.0.1:5469/api/plugins/download/%40runeya%2Fplugins-uuid/1.0.8"
4070
4099
  });
4071
4100
  }));
4101
+ } else {
4102
+ installedPlugins = await dbConfig.alasql.simpleSelect({});
4103
+ installedPlugins = installedPlugins.filter((plugin) => plugin.version !== "development");
4072
4104
  }
4073
- return installedPlugins;
4105
+ const sortedPlugins = installedPlugins.sort((a, b) => a.name.localeCompare(b.name));
4106
+ return sortedPlugins;
4074
4107
  }
4075
4108
  async function getInstalledPlugin(name, version) {
4076
4109
  const [plugin] = (await getInstalledPlugins()).filter((plugin2) => plugin2.name === name);
4077
- if (!plugin) throw new HTTPError("Plugin not found", "404.plugin.not.found");
4078
- if (version && plugin.version !== version) return null;
4110
+ if (version && plugin?.version !== version) return null;
4079
4111
  return plugin;
4080
4112
  }
4081
- async function getInstalledToolboxPlugins() {
4082
- const plugins2 = await getInstalledPlugins();
4083
- const toolboxPlugins = plugins2.filter((plugin) => plugin?.config?.runeya?.toolbox);
4084
- console.log(JSON.stringify(["runeya", plugins2], (_, v) => typeof v === "function" ? `[func]` : v));
4085
- return [];
4086
- }
4087
4113
  async function uninstall(name) {
4088
4114
  const [plugin] = await dbConfig.alasql.simpleSelect({ where: `name='${name}'` });
4089
4115
  if (!plugin) {
@@ -4093,7 +4119,7 @@ var require_plugins2 = __commonJS({
4093
4119
  await rm(plugin.diskPath, { recursive: true, force: true });
4094
4120
  }
4095
4121
  await dbConfig.alasql.delete(`name='${name}'`);
4096
- sockets.emit("plugins:uninstalled", {
4122
+ sockets2.emit("plugins:uninstalled", {
4097
4123
  name
4098
4124
  });
4099
4125
  return { success: true, message: "Plugin uninstalled successfully" };
@@ -4128,96 +4154,121 @@ var require_plugins2 = __commonJS({
4128
4154
  });
4129
4155
  }
4130
4156
  async function loadPlugin(pluginName) {
4131
- const plugin = await getInstalledPlugin(pluginName);
4132
- let backendPath;
4133
- let themePath;
4134
- if (process.env.NODE_ENV === "HFBXdZMJxLyJoua28asEaxRixJ6LriR7FnRzX6pwA7pFjZ" && pluginName.startsWith("@runeya/")) {
4135
- const pluginPath = path.resolve(__dirname, `../../../plugins/${pluginName.replace("@runeya/plugins-", "")}`);
4136
- const frontPath = path.resolve(pluginPath, "front");
4137
- const frontPathDist = path.resolve(`${frontPath}/dist`);
4138
- backendPath = path.resolve(pluginPath, "backend/index.js");
4139
- themePath = path.resolve(pluginPath, "theme/index.js");
4140
- let frontWatcher;
4141
- if (existsSync(frontPath) && existsSync(frontPathDist) && existsSync(backendPath)) {
4142
- const debouncedFrontWatcher = debounce(async () => {
4143
- sockets.emit("plugins:front:building", pluginName);
4144
- console.log("Front changed", pluginName);
4145
- }, 1e3);
4146
- frontWatcher = chokidar.watch(frontPath, { ignored: frontPathDist, ignoreInitial: true }).on("all", debouncedFrontWatcher);
4147
- }
4148
- let frontDistWatcher;
4149
- if (existsSync(frontPathDist)) {
4150
- const debouncedFrontDistWatcher = debounce(async (a, b, c) => {
4151
- sockets.emit("plugins:front:changed", pluginName);
4152
- console.log("Front dist changed", pluginName);
4153
- }, 1e3);
4154
- frontDistWatcher = chokidar.watch(frontPathDist, { ignoreInitial: true }).on("all", debouncedFrontDistWatcher);
4155
- }
4156
- let backendWatcher;
4157
- if (existsSync(backendPath)) {
4158
- const debouncedBackendWatcher = debounce(async () => {
4159
- await frontWatcher.close();
4160
- await frontDistWatcher.close();
4161
- await backendWatcher.close();
4162
- loadPlugin(pluginName);
4163
- console.log("Backend changed", pluginName);
4164
- }, 1e3);
4165
- backendWatcher = chokidar.watch(path.dirname(backendPath), { ignoreInitial: true }).on("all", debouncedBackendWatcher);
4157
+ try {
4158
+ const plugin = await getInstalledPlugin(pluginName);
4159
+ let backendPath;
4160
+ let themePath;
4161
+ if (process.env.NODE_ENV === "HFBXdZMJxLyJoua28asEaxRixJ6LriR7FnRzX6pwA7pFjZ" && process.env.PLUGIN_ONLY_PRODUCTION !== "true" && pluginName.startsWith("@runeya/")) {
4162
+ const pluginPath = path.resolve(__dirname, `../../../plugins/${pluginName.replace("@runeya/plugins-", "")}`);
4163
+ const frontPath = path.resolve(pluginPath, "front");
4164
+ const frontPathDist = path.resolve(`${frontPath}/dist`);
4165
+ backendPath = path.resolve(pluginPath, "backend/index.js");
4166
+ themePath = path.resolve(pluginPath, "theme/index.js");
4167
+ let frontWatcher;
4168
+ if (existsSync(frontPath) && existsSync(frontPathDist) && existsSync(backendPath)) {
4169
+ const debouncedFrontWatcher = debounce(async () => {
4170
+ sockets2.emit("plugins:front:building", pluginName);
4171
+ console.log("Front changed", pluginName);
4172
+ }, 1e3);
4173
+ frontWatcher = chokidar.watch(frontPath, { ignored: frontPathDist, ignoreInitial: true }).on("all", debouncedFrontWatcher);
4174
+ }
4175
+ let frontDistWatcher;
4176
+ if (existsSync(frontPathDist)) {
4177
+ const debouncedFrontDistWatcher = debounce(async (a, b, c) => {
4178
+ sockets2.emit("plugins:front:changed", pluginName);
4179
+ console.log("Front dist changed", pluginName);
4180
+ }, 1e3);
4181
+ frontDistWatcher = chokidar.watch(frontPathDist, { ignoreInitial: true }).on("all", debouncedFrontDistWatcher);
4182
+ }
4183
+ let backendWatcher;
4184
+ if (existsSync(backendPath)) {
4185
+ const debouncedBackendWatcher = debounce(async () => {
4186
+ await frontWatcher.close();
4187
+ await frontDistWatcher.close();
4188
+ await backendWatcher.close();
4189
+ loadPlugin(pluginName);
4190
+ console.log("Backend changed", pluginName);
4191
+ }, 1e3);
4192
+ backendWatcher = chokidar.watch(path.dirname(backendPath), { ignoreInitial: true }).on("all", debouncedBackendWatcher);
4193
+ } else {
4194
+ backendPath = null;
4195
+ }
4196
+ let themeWatcher;
4197
+ if (existsSync(themePath)) {
4198
+ const debouncedThemeWatcher = debounce(async () => {
4199
+ if (frontWatcher) await frontWatcher.close();
4200
+ if (frontDistWatcher) await frontDistWatcher.close();
4201
+ if (themeWatcher) await themeWatcher.close();
4202
+ loadPlugin(pluginName);
4203
+ console.log("Theme changed", pluginName);
4204
+ }, 1e3);
4205
+ themeWatcher = chokidar.watch(path.dirname(themePath), { ignoreInitial: true }).on("all", debouncedThemeWatcher);
4206
+ } else {
4207
+ themePath = null;
4208
+ }
4166
4209
  } else {
4167
- backendPath = null;
4210
+ if (plugin.config.runeya.entries.backend) {
4211
+ backendPath = path.resolve(args2.rootPath, ".runeya", "plugins", pluginName, plugin.config.runeya.entries.backend || "");
4212
+ }
4213
+ if (plugin.config.runeya.entries.theme) {
4214
+ themePath = path.resolve(args2.rootPath, ".runeya", "plugins", pluginName, plugin.config.runeya.entries.theme || "");
4215
+ }
4168
4216
  }
4169
- let themeWatcher;
4170
- if (existsSync(themePath)) {
4171
- const debouncedThemeWatcher = debounce(async () => {
4172
- if (frontWatcher) await frontWatcher.close();
4173
- if (frontDistWatcher) await frontDistWatcher.close();
4174
- if (themeWatcher) await themeWatcher.close();
4175
- loadPlugin(pluginName);
4176
- console.log("Theme changed", pluginName);
4177
- }, 1e3);
4178
- themeWatcher = chokidar.watch(path.dirname(themePath), { ignoreInitial: true }).on("all", debouncedThemeWatcher);
4179
- } else {
4180
- themePath = null;
4217
+ if (backendPath) {
4218
+ clearPluginCache(backendPath);
4219
+ try {
4220
+ const loadedPlugin = safeRequire(backendPath);
4221
+ loadedPlugins[pluginName] = await loadedPlugin(stack, {
4222
+ socket: {
4223
+ emit: (event, ...args3) => {
4224
+ sockets2.emit(encodeURIComponent(pluginName) + "-" + event, ...args3);
4225
+ },
4226
+ on: (event, callback) => {
4227
+ sockets2.on(encodeURIComponent(pluginName) + "-" + event, callback);
4228
+ },
4229
+ off: (event, callback) => {
4230
+ sockets2.off(encodeURIComponent(pluginName) + "-" + event, callback);
4231
+ }
4232
+ }
4233
+ });
4234
+ } catch (error) {
4235
+ console.error(`[${plugin.name}@${plugin.version}]`, error);
4236
+ console.log(Object.getOwnPropertyNames(error));
4237
+ setTimeout(() => {
4238
+ sockets2.emit("plugins:loading:error", pluginName, { ...error, message: error?.message?.split("\n")?.[0] });
4239
+ }, 1e3);
4240
+ return null;
4241
+ }
4181
4242
  }
4182
- } else {
4183
- backendPath = path.resolve(args2.rootPath, ".runeya", "plugins", pluginName, plugin.config.runeya.entries.backend);
4184
- themePath = path.resolve(args2.rootPath, ".runeya", "plugins", pluginName, plugin.config.runeya.entries.theme);
4185
- }
4186
- if (backendPath) {
4187
- clearPluginCache(backendPath);
4188
- const loadedPlugin = require(backendPath);
4189
- loadedPlugins[pluginName] = await loadedPlugin(stack, {
4190
- socket: {
4191
- emit: (event, ...args3) => {
4192
- sockets.emit(encodeURIComponent(pluginName) + "-" + event, ...args3);
4193
- },
4194
- on: (event, callback) => {
4195
- sockets.on(encodeURIComponent(pluginName) + "-" + event, callback);
4196
- },
4197
- off: (event, callback) => {
4198
- sockets.off(encodeURIComponent(pluginName) + "-" + event, callback);
4243
+ if (themePath) {
4244
+ clearPluginCache(themePath);
4245
+ const loadedTheme = require(themePath);
4246
+ themes[pluginName] = await loadedTheme(stack, {
4247
+ socket: {
4248
+ emit: (event, ...args3) => {
4249
+ sockets2.emit(encodeURIComponent(pluginName) + "-" + event, ...args3);
4250
+ },
4251
+ on: (event, callback) => {
4252
+ sockets2.on(encodeURIComponent(pluginName) + "-" + event, callback);
4253
+ },
4254
+ off: (event, callback) => {
4255
+ sockets2.off(encodeURIComponent(pluginName) + "-" + event, callback);
4256
+ }
4199
4257
  }
4200
- }
4201
- });
4258
+ });
4259
+ }
4260
+ return loadedPlugins[pluginName];
4261
+ } catch (error) {
4262
+ console.error(error?.message || error);
4202
4263
  }
4203
- if (themePath) {
4204
- clearPluginCache(themePath);
4205
- const loadedTheme = require(themePath);
4206
- themes[pluginName] = await loadedTheme(stack, {
4207
- socket: {
4208
- emit: (event, ...args3) => {
4209
- sockets.emit(encodeURIComponent(pluginName) + "-" + event, ...args3);
4210
- },
4211
- on: (event, callback) => {
4212
- sockets.on(encodeURIComponent(pluginName) + "-" + event, callback);
4213
- },
4214
- off: (event, callback) => {
4215
- sockets.off(encodeURIComponent(pluginName) + "-" + event, callback);
4216
- }
4217
- }
4218
- });
4264
+ }
4265
+ function safeRequire(path2) {
4266
+ try {
4267
+ return require(path2);
4268
+ } catch (err) {
4269
+ console.error("Erreur dans safeRequire:", err);
4270
+ throw err;
4219
4271
  }
4220
- return loadedPlugins[pluginName];
4221
4272
  }
4222
4273
  async function frontFile(pluginName) {
4223
4274
  const plugin = await getInstalledPlugin(pluginName);
@@ -4242,7 +4293,6 @@ var require_plugins2 = __commonJS({
4242
4293
  getInstalledPlugins,
4243
4294
  getInstalledPlugin,
4244
4295
  registerRoutes,
4245
- getInstalledToolboxPlugins,
4246
4296
  forService,
4247
4297
  ...allPlugins,
4248
4298
  routes
@@ -4291,7 +4341,10 @@ var require_plugins3 = __commonJS({
4291
4341
  res.send(services);
4292
4342
  });
4293
4343
  router.get("/:type", async (req, res) => {
4294
- const services = await PromiseB2.filter(plugins[req.params.type], async (plugin) => plugin.hidden ? !await plugin.hidden(null, Stack, req.params.type) : true);
4344
+ const services = await PromiseB2.filter(
4345
+ plugins[req.params.type] || [],
4346
+ async (plugin) => plugin.hidden ? !await plugin.hidden(null, Stack, req.params.type) : true
4347
+ );
4295
4348
  services.sort((a, b) => (a.order || 1e3) - (b.order || 1e3));
4296
4349
  res.send(services);
4297
4350
  });
@@ -4454,7 +4507,7 @@ var require_stack2 = __commonJS({
4454
4507
  var commandExists = require("command-exists").sync;
4455
4508
  var { Octokit } = require("fix-esm").require("@octokit/core");
4456
4509
  var { restEndpointMethods } = require("fix-esm").require("@octokit/plugin-rest-endpoint-methods");
4457
- var { sockets } = require_src();
4510
+ var { sockets: sockets2 } = require_src();
4458
4511
  var Stack = require_stack();
4459
4512
  var myConfs = require_myConfs();
4460
4513
  var router = express.Router();
@@ -4468,13 +4521,13 @@ var require_stack2 = __commonJS({
4468
4521
  if (existingService) {
4469
4522
  await existingService.constructor(req.body, Stack, { isUpdate: true });
4470
4523
  await existingService.save();
4471
- sockets.emit("conf:update", [existingService.label]);
4524
+ sockets2.emit("conf:update", [existingService.label]);
4472
4525
  res.send(existingService);
4473
4526
  } else {
4474
4527
  const service = await new Service(req.body, Stack);
4475
4528
  await service.save();
4476
4529
  Stack.getStack()?.services.push(service);
4477
- sockets.emit("conf:update", [service.label]);
4530
+ sockets2.emit("conf:update", [service.label]);
4478
4531
  res.send(service);
4479
4532
  }
4480
4533
  });
@@ -4484,14 +4537,14 @@ var require_stack2 = __commonJS({
4484
4537
  service.label = req.body.label;
4485
4538
  await service.save();
4486
4539
  Stack.getStack()?.services.push(service);
4487
- sockets.emit("conf:update");
4540
+ sockets2.emit("conf:update");
4488
4541
  res.send(service);
4489
4542
  });
4490
4543
  router.patch("/:service", async (req, res) => {
4491
4544
  const service = findService(req.params.service);
4492
4545
  await service.save();
4493
4546
  Stack.getStack()?.services.push(service);
4494
- sockets.emit("conf:update");
4547
+ sockets2.emit("conf:update");
4495
4548
  res.send(service);
4496
4549
  });
4497
4550
  router.get("/export-env", async (req, res) => {
@@ -4504,7 +4557,7 @@ var require_stack2 = __commonJS({
4504
4557
  });
4505
4558
  router.delete("/:service", async (req, res) => {
4506
4559
  await Stack.deleteService(req.params.service);
4507
- sockets.emit("conf:update");
4560
+ sockets2.emit("conf:update");
4508
4561
  res.send("ok");
4509
4562
  });
4510
4563
  router.get("/has-update", async (req, res) => {
@@ -4533,14 +4586,14 @@ var require_stack2 = __commonJS({
4533
4586
  const env = await Stack.getStack()?.environments.find((env2) => env2.label === req.params.environmentLabel);
4534
4587
  if (!env) return res.status(404).send("Environment not found");
4535
4588
  await env.update(req.body);
4536
- await sockets.emit("reloadEnvironments");
4589
+ await sockets2.emit("reloadEnvironments");
4537
4590
  res.json(Stack.getCurrentEnvironment());
4538
4591
  });
4539
4592
  router.delete("/environments/:environmentLabel", async (req, res) => {
4540
4593
  const env = await Stack.getStack()?.environments.find((env2) => env2.label === req.params.environmentLabel);
4541
4594
  if (!env) return res.status(404).send("Environment not found");
4542
4595
  await env.delete();
4543
- await sockets.emit("reloadEnvironments");
4596
+ await sockets2.emit("reloadEnvironments");
4544
4597
  res.json("ok");
4545
4598
  });
4546
4599
  router.get("/additional-themes", (req, res) => {
@@ -4558,7 +4611,7 @@ var require_stack2 = __commonJS({
4558
4611
  if (!environment) return res.status(400).send("Provide an environment field in body");
4559
4612
  const newEnvironment = new Environment(environment);
4560
4613
  await newEnvironment.save();
4561
- await sockets.emit("reloadEnvironments");
4614
+ await sockets2.emit("reloadEnvironments");
4562
4615
  return res.json(Stack.getCurrentEnvironment());
4563
4616
  });
4564
4617
  router.get("/environments", async (req, res) => {
@@ -4715,7 +4768,7 @@ var require_crypto2 = __commonJS({
4715
4768
  var fs = require("fs").promises;
4716
4769
  var path = require("path");
4717
4770
  var HTTPError = require_src2();
4718
- var { sockets } = require_src();
4771
+ var { sockets: sockets2 } = require_src();
4719
4772
  var conflictStorage = require_conflictStorage();
4720
4773
  var router = express.Router();
4721
4774
  router.get("/generate-key", async (req, res) => {
@@ -4785,7 +4838,7 @@ var require_crypto2 = __commonJS({
4785
4838
  if (conflictId) {
4786
4839
  conflictStorage.removeConflict(conflictId);
4787
4840
  }
4788
- sockets.emit("crypto:conflict-resolved", { conflictId });
4841
+ sockets2.emit("crypto:conflict-resolved", { conflictId });
4789
4842
  return res.json({
4790
4843
  success: true,
4791
4844
  encryptedResolution,
@@ -4968,7 +5021,7 @@ var require_cpu = __commonJS({
4968
5021
  var os = require("os");
4969
5022
  var { fork } = require("child_process");
4970
5023
  var path = require("path");
4971
- var { sockets } = require_src();
5024
+ var { sockets: sockets2 } = require_src();
4972
5025
  var nbCpus = os.cpus().length;
4973
5026
  var controller = null;
4974
5027
  var child = null;
@@ -4977,7 +5030,7 @@ var require_cpu = __commonJS({
4977
5030
  child = fork(path.resolve(__dirname, "./cpuFork.js"), [], { signal });
4978
5031
  child.on("message", (message) => {
4979
5032
  const { ram, cpu } = JSON.parse(message.toString());
4980
- sockets.emit("infos:global", {
5033
+ sockets2.emit("infos:global", {
4981
5034
  nbCpus,
4982
5035
  memPercentage: ram.memPercentage,
4983
5036
  totalmem: ram.totalmem,
@@ -5083,6 +5136,7 @@ var require_server = __commonJS({
5083
5136
  });
5084
5137
 
5085
5138
  // bin/www
5139
+ var { sockets } = require_src();
5086
5140
  process.title = "runeya";
5087
5141
  var args = require_args();
5088
5142
  require("dotenv").config();
@@ -5106,4 +5160,12 @@ ${key}=${envs[key]}`, "").trim());
5106
5160
  });
5107
5161
  }
5108
5162
  })();
5163
+ process.on("uncaughtException", (err) => {
5164
+ console.error("Uncaught exception:", err);
5165
+ sockets.emit("critical:error", err);
5166
+ });
5167
+ process.on("unhandledRejection", (reason, promise) => {
5168
+ console.error("Unhandled rejection:", reason);
5169
+ sockets.emit("critical:error", reason);
5170
+ });
5109
5171
  //# sourceMappingURL=www.js.map