@mavonengine/cli 0.0.7 → 0.0.8

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/dist/index.js CHANGED
@@ -5,14 +5,16 @@ import {
5
5
  SUPPORTED_REGISTRY_VERSION,
6
6
  fetchPluginRegistry,
7
7
  notInProject
8
- } from "./chunk-ZEMFSSJP.js";
8
+ } from "./chunk-GOPDTCJD.js";
9
9
  import {
10
10
  DEFAULT_DOCS_URL,
11
11
  MCP_CONFIG_FILE,
12
- __export,
13
12
  version,
14
13
  writeMcpConfig
15
- } from "./chunk-3VVGSO5T.js";
14
+ } from "./chunk-33OMMYNV.js";
15
+ import {
16
+ __export
17
+ } from "./chunk-K3NQKI34.js";
16
18
 
17
19
  // src/index.ts
18
20
  import process15 from "process";
@@ -44,7 +46,12 @@ function parseVersion(version3) {
44
46
  const match = VERSION_RE.exec(version3.trim());
45
47
  if (!match)
46
48
  return void 0;
47
- return { major: Number(match[1]), minor: Number(match[2]), patch: Number(match[3]), prerelease: prereleaseOf(match[4]) };
49
+ return {
50
+ major: Number(match[1]),
51
+ minor: Number(match[2]),
52
+ patch: Number(match[3]),
53
+ prerelease: prereleaseOf(match[4])
54
+ };
48
55
  }
49
56
  function compareVersions(a, b) {
50
57
  for (const key of ["major", "minor", "patch"]) {
@@ -56,14 +63,16 @@ function compareVersions(a, b) {
56
63
  for (let i = 0; i < Math.max(a.prerelease.length, b.prerelease.length); i++) {
57
64
  const x = a.prerelease[i];
58
65
  const y = b.prerelease[i];
59
- if (x === void 0 || y === void 0)
66
+ if (x === void 0 || y === void 0) {
60
67
  return x === void 0 ? -1 : 1;
68
+ }
61
69
  if (x === y)
62
70
  continue;
63
71
  if (typeof x === "number" && typeof y === "number")
64
72
  return x - y;
65
- if (typeof x === "number" || typeof y === "number")
73
+ if (typeof x === "number" || typeof y === "number") {
66
74
  return typeof x === "number" ? -1 : 1;
75
+ }
67
76
  return x < y ? -1 : 1;
68
77
  }
69
78
  return 0;
@@ -89,23 +98,46 @@ function desugar(text) {
89
98
  const pre = given === 3 ? prereleaseOf(partial[4]) : [];
90
99
  const exact = version2(major, minor, patch, pre);
91
100
  const make = (o, v, explicit = false) => ({ op: o, version: v, explicit });
92
- if (given === 0)
93
- return op === "<" || op === ">" ? [make("<", floor(0, 0, 0))] : [];
101
+ if (given === 0) {
102
+ return op === "<" || op === ">" ? [
103
+ make("<", floor(0, 0, 0))
104
+ ] : [];
105
+ }
94
106
  const next = given === 1 ? floor(major + 1, 0, 0) : floor(major, minor + 1, 0);
95
107
  switch (op) {
96
108
  case "":
97
109
  case "=":
98
- return given === 3 ? [make("=", exact, true)] : [make(">=", version2(major, minor, 0)), make("<", next)];
110
+ return given === 3 ? [
111
+ make("=", exact, true)
112
+ ] : [
113
+ make(">=", version2(major, minor, 0)),
114
+ make("<", next)
115
+ ];
99
116
  case ">":
100
- return given === 3 ? [make(">", exact, true)] : [make(">=", version2(next.major, next.minor, 0))];
117
+ return given === 3 ? [
118
+ make(">", exact, true)
119
+ ] : [
120
+ make(">=", version2(next.major, next.minor, 0))
121
+ ];
101
122
  case ">=":
102
- return [make(">=", exact, true)];
123
+ return [
124
+ make(">=", exact, true)
125
+ ];
103
126
  case "<":
104
- return [make("<", given === 3 ? exact : floor(major, minor, 0), given === 3)];
127
+ return [
128
+ make("<", given === 3 ? exact : floor(major, minor, 0), given === 3)
129
+ ];
105
130
  case "<=":
106
- return given === 3 ? [make("<=", exact, true)] : [make("<", next)];
131
+ return given === 3 ? [
132
+ make("<=", exact, true)
133
+ ] : [
134
+ make("<", next)
135
+ ];
107
136
  case "~":
108
- return [make(">=", exact, true), make("<", given === 1 ? floor(major + 1, 0, 0) : floor(major, minor + 1, 0))];
137
+ return [
138
+ make(">=", exact, true),
139
+ make("<", given === 1 ? floor(major + 1, 0, 0) : floor(major, minor + 1, 0))
140
+ ];
109
141
  case "^": {
110
142
  let upper;
111
143
  if (major > 0 || given === 1)
@@ -114,7 +146,10 @@ function desugar(text) {
114
146
  upper = floor(0, minor + 1, 0);
115
147
  else
116
148
  upper = floor(0, 0, patch + 1);
117
- return [make(">=", exact, true), make("<", upper)];
149
+ return [
150
+ make(">=", exact, true),
151
+ make("<", upper)
152
+ ];
118
153
  }
119
154
  }
120
155
  return void 0;
@@ -290,6 +325,10 @@ function validateManifest(pkg, value) {
290
325
  }
291
326
  if (manifest.publish !== void 0 && (typeof manifest.publish !== "string" || !manifest.publish))
292
327
  throw new PluginConfigError(`${pkg}: "mavonengine.publish" must be a directory of the package`);
328
+ if (manifest.dev !== void 0 && (typeof manifest.dev !== "string" || !manifest.dev))
329
+ throw new PluginConfigError(`${pkg}: "mavonengine.dev" must be a file of the package`);
330
+ if (manifest.reloadOnOptions !== void 0 && typeof manifest.reloadOnOptions !== "boolean")
331
+ throw new PluginConfigError(`${pkg}: "mavonengine.reloadOnOptions" must be true or false`);
293
332
  return manifest;
294
333
  }
295
334
  function readPluginManifest(root, pkg) {
@@ -299,11 +338,21 @@ function readPluginManifest(root, pkg) {
299
338
  const packageJson = JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
300
339
  if (packageJson.mavonengine === void 0)
301
340
  return void 0;
302
- return { package: pkg, version: packageJson.version, dir, manifest: validateManifest(pkg, packageJson.mavonengine) };
341
+ return {
342
+ package: pkg,
343
+ version: packageJson.version,
344
+ dir,
345
+ manifest: validateManifest(pkg, packageJson.mavonengine)
346
+ };
303
347
  }
304
348
  function runsOn(target, side) {
305
349
  return target === "both" || target === side;
306
350
  }
351
+ function entryFor(manifest, side) {
352
+ if (side === "dev")
353
+ return manifest.dev;
354
+ return runsOn(manifest.target, side) ? manifest[side] : void 0;
355
+ }
307
356
  function resolveInside(base, path) {
308
357
  const full = resolve(base, path);
309
358
  const inside = relative(base, full);
@@ -331,13 +380,15 @@ function enabledPlugins(root, side) {
331
380
  warnings.push(`${pkg} is listed in ${CONFIG_FILE} but is not installed or is not a MavonEngine plugin`);
332
381
  continue;
333
382
  }
334
- if (!runsOn(installed.manifest.target, side))
383
+ const entryFile = entryFor(installed.manifest, side);
384
+ if (!entryFile)
335
385
  continue;
336
- if (engineCompat(installed.manifest.engine, coreVersion) === "incompatible")
386
+ if (engineCompat(installed.manifest.engine, coreVersion) === "incompatible") {
337
387
  incompatible.push(`${pkg}${installed.version ? ` ${installed.version}` : ""} is made for @mavonengine/core ${installed.manifest.engine}, the project has ${coreVersion}, run 'mavonengine doctor'`);
338
- const entryPath = resolveInside(installed.dir, installed.manifest[side]);
388
+ }
389
+ const entryPath = resolveInside(installed.dir, entryFile);
339
390
  if (!entryPath || !existsSync(entryPath)) {
340
- warnings.push(`${pkg}: ${side} entry ${installed.manifest[side]} not found, is the plugin built?`);
391
+ warnings.push(`${pkg}: ${side} entry ${entryFile} not found, is the plugin built?`);
341
392
  continue;
342
393
  }
343
394
  plugins.push({
@@ -351,10 +402,14 @@ function enabledPlugins(root, side) {
351
402
  }
352
403
  function shippedAssetPaths(manifest, usedPrefabs) {
353
404
  const assets = manifest.assets;
354
- const paths = [...assets?.shared ?? []];
405
+ const paths = [
406
+ ...assets?.shared ?? []
407
+ ];
355
408
  for (const prefab of usedPrefabs)
356
409
  paths.push(...assets?.prefabs?.[prefab] ?? []);
357
- return [...new Set(paths)];
410
+ return [
411
+ ...new Set(paths)
412
+ ];
358
413
  }
359
414
  function releaseAssets(root) {
360
415
  const { plugins, warnings } = enabledPlugins(root, "client");
@@ -371,7 +426,12 @@ function releaseAssets(root) {
371
426
  warnings.push(`${plugin.package}: asset ${path} not found`);
372
427
  continue;
373
428
  }
374
- assets.push({ package: plugin.package, from, to: `plugins/${plugin.package}/${path}`, path });
429
+ assets.push({
430
+ package: plugin.package,
431
+ from,
432
+ to: `plugins/${plugin.package}/${path}`,
433
+ path
434
+ });
375
435
  }
376
436
  }
377
437
  return { assets, warnings };
@@ -386,11 +446,27 @@ import { spawn } from "child_process";
386
446
  import process from "process";
387
447
  var AMPERSAND_RE = /&/g;
388
448
  function openCommand(url, platform = process.platform) {
389
- if (platform === "darwin")
390
- return ["open", [url]];
391
- if (platform === "win32")
392
- return ["cmd", ["/c", "start", '""', url.replace(AMPERSAND_RE, "^&")]];
393
- return ["xdg-open", [url]];
449
+ if (platform === "darwin") {
450
+ return [
451
+ "open",
452
+ [url]
453
+ ];
454
+ }
455
+ if (platform === "win32") {
456
+ return [
457
+ "cmd",
458
+ [
459
+ "/c",
460
+ "start",
461
+ '""',
462
+ url.replace(AMPERSAND_RE, "^&")
463
+ ]
464
+ ];
465
+ }
466
+ return [
467
+ "xdg-open",
468
+ [url]
469
+ ];
394
470
  }
395
471
  function openBrowser(url) {
396
472
  const [command, args] = openCommand(url);
@@ -407,7 +483,9 @@ function canOpenBrowserHere(env = process.env) {
407
483
  }
408
484
  async function servesPage(url, { timeoutMs = 3e3, fetch = globalThis.fetch } = {}) {
409
485
  try {
410
- const res = await fetch(url, { signal: AbortSignal.timeout(timeoutMs) });
486
+ const res = await fetch(url, {
487
+ signal: AbortSignal.timeout(timeoutMs)
488
+ });
411
489
  await res.body?.cancel();
412
490
  return res.ok && (res.headers.get("content-type") ?? "").includes("text/html");
413
491
  } catch {
@@ -420,7 +498,12 @@ import process2 from "process";
420
498
  var AvailablePlugins = class {
421
499
  constructor(url = process2.env[PLUGIN_REGISTRY_ENV] ?? PLUGIN_REGISTRY_URL, fetchRegistry = (registryUrl) => fetchPluginRegistry({ url: registryUrl })) {
422
500
  this.fetchRegistry = fetchRegistry;
423
- this.state = { status: "idle", url, plugins: [], error: null };
501
+ this.state = {
502
+ status: "idle",
503
+ url,
504
+ plugins: [],
505
+ error: null
506
+ };
424
507
  }
425
508
  fetchRegistry;
426
509
  state;
@@ -495,7 +578,11 @@ function queueSample(q) {
495
578
  function accountFrom(value) {
496
579
  if (!isRecord(value) || typeof value.id !== "string" || !value.id)
497
580
  return null;
498
- return { id: value.id, name: strOrNull(value.name), guest: value.guest === true };
581
+ return {
582
+ id: value.id,
583
+ name: strOrNull(value.name),
584
+ guest: value.guest === true
585
+ };
499
586
  }
500
587
  function normalizeSnapshot(raw) {
501
588
  const s = section(raw);
@@ -522,7 +609,11 @@ function normalizeSnapshot(raw) {
522
609
  id,
523
610
  // Older servers don't send a name
524
611
  displayName: str(p.displayName, id),
525
- position: { x: num(position.x), y: num(position.y), z: num(position.z) },
612
+ position: {
613
+ x: num(position.x),
614
+ y: num(position.y),
615
+ z: num(position.z)
616
+ },
526
617
  lastProcessedSequenceId: num(p.lastProcessedSequenceId),
527
618
  trackedEntities: num(p.trackedEntities),
528
619
  connectedFor: num(p.connectedFor),
@@ -539,18 +630,28 @@ function normalizeSnapshot(raw) {
539
630
  world: {
540
631
  entities: num(world.entities)
541
632
  },
542
- physics: physics ? { bodies: num(physics.bodies), colliders: num(physics.colliders) } : null,
633
+ physics: physics ? {
634
+ bodies: num(physics.bodies),
635
+ colliders: num(physics.colliders)
636
+ } : null,
543
637
  cpu: {
544
638
  current: num(cpu.current),
545
639
  avg1s: num(cpu.avg1s),
546
640
  avg10s: num(cpu.avg10s),
547
641
  avg60s: num(cpu.avg60s),
548
- history: arr(cpu.history, (h) => ({ timestamp: num(h.timestamp), cpuPercentage: num(h.cpuPercentage) }))
642
+ history: arr(cpu.history, (h) => ({
643
+ timestamp: num(h.timestamp),
644
+ cpuPercentage: num(h.cpuPercentage)
645
+ }))
549
646
  },
550
647
  bandwidth: {
551
648
  sentPerSecond: num(bandwidth.sentPerSecond),
552
649
  receivedPerSecond: num(bandwidth.receivedPerSecond),
553
- history: arr(bandwidth.history, (b) => ({ timestamp: num(b.timestamp), sent: num(b.sent), received: num(b.received) }))
650
+ history: arr(bandwidth.history, (b) => ({
651
+ timestamp: num(b.timestamp),
652
+ sent: num(b.sent),
653
+ received: num(b.received)
654
+ }))
554
655
  },
555
656
  tick: {
556
657
  budgetMs: num(tick.budgetMs),
@@ -563,7 +664,11 @@ function normalizeSnapshot(raw) {
563
664
  heapTotal: num(memory.heapTotal),
564
665
  external: num(memory.external)
565
666
  },
566
- latencySimulation: latency ? { fixedLatency: num(latency.fixedLatency), jitter: num(latency.jitter), packetLoss: num(latency.packetLoss) } : null,
667
+ latencySimulation: latency ? {
668
+ fixedLatency: num(latency.fixedLatency),
669
+ jitter: num(latency.jitter),
670
+ packetLoss: num(latency.packetLoss)
671
+ } : null,
567
672
  // Servers older than the queue have none
568
673
  queue: queue ? {
569
674
  driver: str(queue.driver, "unknown"),
@@ -632,11 +737,18 @@ function normalizeSync(raw) {
632
737
  displayName: str(p.displayName, str(p.id)),
633
738
  tracked: Array.isArray(p.tracked) ? p.tracked.length : 0,
634
739
  ack: num(p.ack),
635
- lastState: lastState && { tick: num(lastState.tick), bytes: num(lastState.bytes), entities: num(lastState.entities) },
740
+ lastState: lastState && {
741
+ tick: num(lastState.tick),
742
+ bytes: num(lastState.bytes),
743
+ entities: num(lastState.entities)
744
+ },
636
745
  account: accountFrom(p.account)
637
746
  };
638
747
  });
639
- const entities = arr(r.entities, (e) => ({ player: e.player === true, trackedBy: num(e.trackedBy) }));
748
+ const entities = arr(r.entities, (e) => ({
749
+ player: e.player === true,
750
+ trackedBy: num(e.trackedBy)
751
+ }));
640
752
  return {
641
753
  tick: num(r.tick),
642
754
  tickRate: num(r.tickRate),
@@ -653,10 +765,20 @@ function normalizePacketDetail(id, raw) {
653
765
  if (!isRecord(record))
654
766
  return { id, status: "gone", lines: [] };
655
767
  const lines = (value) => JSON.stringify(value, null, 2).split("\n");
656
- if (record.payload !== void 0 && record.payload !== null)
657
- return { id, status: "loaded", lines: lines(record.payload) };
658
- if (record.kind === "event" && isRecord(record.info))
659
- return { id, status: "loaded", lines: lines(record.info) };
768
+ if (record.payload !== void 0 && record.payload !== null) {
769
+ return {
770
+ id,
771
+ status: "loaded",
772
+ lines: lines(record.payload)
773
+ };
774
+ }
775
+ if (record.kind === "event" && isRecord(record.info)) {
776
+ return {
777
+ id,
778
+ status: "loaded",
779
+ lines: lines(record.info)
780
+ };
781
+ }
660
782
  if (record.kind !== "event" && num(record.bytes) > 0)
661
783
  return { id, status: "gone", lines: [] };
662
784
  return { id, status: "empty", lines: [] };
@@ -664,7 +786,10 @@ function normalizePacketDetail(id, raw) {
664
786
  function descriptions(value) {
665
787
  if (!isRecord(value))
666
788
  return void 0;
667
- return Object.fromEntries(Object.entries(value).map(([name, description]) => [name, str(description)]));
789
+ return Object.fromEntries(Object.entries(value).map(([name, description]) => [
790
+ name,
791
+ str(description)
792
+ ]));
668
793
  }
669
794
  function normalizeRoutes(raw) {
670
795
  return arr(section(raw).routes, (r) => {
@@ -679,7 +804,12 @@ function normalizeRoutes(raw) {
679
804
  params: descriptions(r.params) ?? {},
680
805
  devOnly: r.devOnly === true,
681
806
  ...query ? { query } : {},
682
- ...Object.fromEntries(["summary", "description", "response", "auth"].filter((key) => typeof r[key] === "string").map((key) => [key, r[key]]))
807
+ ...Object.fromEntries([
808
+ "summary",
809
+ "description",
810
+ "response",
811
+ "auth"
812
+ ].filter((key) => typeof r[key] === "string").map((key) => [key, r[key]]))
683
813
  };
684
814
  });
685
815
  }
@@ -698,7 +828,14 @@ function normalizePlugins(raw) {
698
828
  declaredPrefabs: strings(p.declaredPrefabs),
699
829
  usedPrefabs: strings(p.usedPrefabs),
700
830
  ...target ? { target } : {},
701
- ...Object.fromEntries(["problem", "version", "description", "license", "homepage", "engine"].filter((key) => typeof p[key] === "string").map((key) => [key, p[key]]))
831
+ ...Object.fromEntries([
832
+ "problem",
833
+ "version",
834
+ "description",
835
+ "license",
836
+ "homepage",
837
+ "engine"
838
+ ].filter((key) => typeof p[key] === "string").map((key) => [key, p[key]]))
702
839
  };
703
840
  });
704
841
  }
@@ -715,11 +852,19 @@ function normalizeDatabase(raw) {
715
852
  const data = section(raw);
716
853
  return {
717
854
  provider: strOrNull(data.provider),
718
- tables: arr(data.tables, (t) => ({ name: str(t.name, "?"), plugin: strOrNull(t.plugin), rows: numOrNull(t.rows), columns: columns(t.columns) })),
855
+ tables: arr(data.tables, (t) => ({
856
+ name: str(t.name, "?"),
857
+ plugin: strOrNull(t.plugin),
858
+ rows: numOrNull(t.rows),
859
+ columns: columns(t.columns)
860
+ })),
719
861
  migrations: arr(data.migrations, (m) => ({
720
862
  plugin: strOrNull(m.plugin),
721
863
  table: str(m.table, "?"),
722
- applied: arr(m.applied, (a) => ({ name: str(a.name, "?"), executedAt: strOrNull(a.executedAt) }))
864
+ applied: arr(m.applied, (a) => ({
865
+ name: str(a.name, "?"),
866
+ executedAt: strOrNull(a.executedAt)
867
+ }))
723
868
  }))
724
869
  };
725
870
  }
@@ -917,18 +1062,39 @@ var MetricsClient = class {
917
1062
  }
918
1063
  const previous = this.state.tableDetail?.table === table ? this.state.tableDetail.page : void 0;
919
1064
  if (!this.source.fetchTable) {
920
- this.state.tableDetail = { table, offset, status: "error", error: "This source does not serve database tables" };
1065
+ this.state.tableDetail = {
1066
+ table,
1067
+ offset,
1068
+ status: "error",
1069
+ error: "This source does not serve database tables"
1070
+ };
921
1071
  this.notify();
922
1072
  return;
923
1073
  }
924
- this.state.tableDetail = { table, offset, status: "loading", page: previous };
1074
+ this.state.tableDetail = {
1075
+ table,
1076
+ offset,
1077
+ status: "loading",
1078
+ page: previous
1079
+ };
925
1080
  this.notify();
926
1081
  let detail;
927
1082
  try {
928
- detail = { table, offset, status: "ready", page: normalizeTablePage(await this.source.fetchTable(table, offset, limit)) };
1083
+ detail = {
1084
+ table,
1085
+ offset,
1086
+ status: "ready",
1087
+ page: normalizeTablePage(await this.source.fetchTable(table, offset, limit))
1088
+ };
929
1089
  } catch (err) {
930
1090
  const gone = err instanceof MetricsSourceError && err.status === "disabled";
931
- detail = { table, offset, status: "error", page: previous, error: gone ? `The database has no table ${table} (any more)` : tableError(err) };
1091
+ detail = {
1092
+ table,
1093
+ offset,
1094
+ status: "error",
1095
+ page: previous,
1096
+ error: gone ? `The database has no table ${table} (any more)` : tableError(err)
1097
+ };
932
1098
  }
933
1099
  const current = this.state.tableDetail;
934
1100
  if (current?.table !== table || current.offset !== offset)
@@ -946,7 +1112,12 @@ var MetricsClient = class {
946
1112
  return;
947
1113
  }
948
1114
  if (!this.source.fetchPacket) {
949
- this.state.packetDetail = { id, status: "error", lines: [], error: "This source does not serve packet contents" };
1115
+ this.state.packetDetail = {
1116
+ id,
1117
+ status: "error",
1118
+ lines: [],
1119
+ error: "This source does not serve packet contents"
1120
+ };
950
1121
  this.notify();
951
1122
  return;
952
1123
  }
@@ -956,7 +1127,12 @@ var MetricsClient = class {
956
1127
  try {
957
1128
  detail = normalizePacketDetail(id, await this.source.fetchPacket(id));
958
1129
  } catch (err) {
959
- detail = { id, status: "error", lines: [], error: err.message };
1130
+ detail = {
1131
+ id,
1132
+ status: "error",
1133
+ lines: [],
1134
+ error: err.message
1135
+ };
960
1136
  }
961
1137
  if (this.state.packetDetail?.id !== id)
962
1138
  return;
@@ -1004,13 +1180,20 @@ var MetricsClient = class {
1004
1180
  this.state.lastUpdate = Date.now();
1005
1181
  this.state.error = null;
1006
1182
  this.state.failures = 0;
1007
- await Promise.all([this.logs.poll(), this.requests.poll(), this.pollProject()]);
1183
+ await Promise.all([
1184
+ this.logs.poll(),
1185
+ this.requests.poll(),
1186
+ this.pollProject()
1187
+ ]);
1008
1188
  this.state.logs = this.logs.entries;
1009
1189
  this.state.logsAvailable = this.logs.available;
1010
1190
  this.state.requests = this.requests.entries;
1011
1191
  this.state.requestsAvailable = this.requests.available;
1012
1192
  if (this.watchNetwork) {
1013
- await Promise.all([this.packets.poll(), this.pollSync()]);
1193
+ await Promise.all([
1194
+ this.packets.poll(),
1195
+ this.pollSync()
1196
+ ]);
1014
1197
  this.state.packets = this.packets.entries;
1015
1198
  this.state.packetsAvailable = this.packets.available;
1016
1199
  }
@@ -1153,7 +1336,16 @@ var SIMULATED_PLUGINS = [
1153
1336
  declaredPrefabs: ["Tree", "Rock"],
1154
1337
  usedPrefabs: ["Tree"]
1155
1338
  },
1156
- { package: "chat", enabled: false, installed: true, runningOnServer: false, version: "1.0.0", target: "both", declaredPrefabs: [], usedPrefabs: [] },
1339
+ {
1340
+ package: "chat",
1341
+ enabled: false,
1342
+ installed: true,
1343
+ runningOnServer: false,
1344
+ version: "1.0.0",
1345
+ target: "both",
1346
+ declaredPrefabs: [],
1347
+ usedPrefabs: []
1348
+ },
1157
1349
  {
1158
1350
  package: "@mavonengine/sqlite",
1159
1351
  enabled: true,
@@ -1174,20 +1366,67 @@ var SIMULATED_TABLES = [
1174
1366
  name: "chat_messages",
1175
1367
  plugin: "@mavonengine/chat",
1176
1368
  columns: [
1177
- { name: "id", type: "INTEGER", nullable: false, autoIncrement: true, hasDefault: false },
1178
- { name: "player", type: "TEXT", nullable: false, autoIncrement: false, hasDefault: false },
1179
- { name: "text", type: "TEXT", nullable: false, autoIncrement: false, hasDefault: false },
1180
- { name: "sent_at", type: "TEXT", nullable: false, autoIncrement: false, hasDefault: false }
1369
+ {
1370
+ name: "id",
1371
+ type: "INTEGER",
1372
+ nullable: false,
1373
+ autoIncrement: true,
1374
+ hasDefault: false
1375
+ },
1376
+ {
1377
+ name: "player",
1378
+ type: "TEXT",
1379
+ nullable: false,
1380
+ autoIncrement: false,
1381
+ hasDefault: false
1382
+ },
1383
+ {
1384
+ name: "text",
1385
+ type: "TEXT",
1386
+ nullable: false,
1387
+ autoIncrement: false,
1388
+ hasDefault: false
1389
+ },
1390
+ {
1391
+ name: "sent_at",
1392
+ type: "TEXT",
1393
+ nullable: false,
1394
+ autoIncrement: false,
1395
+ hasDefault: false
1396
+ }
1181
1397
  ],
1182
- rows: Array.from({ length: 137 }, (_, i) => ({ id: i + 1, player: `sim-0${i % 3 + 1}`, text: ["gg", "anyone near the tower?", "brb"][i % 3], sent_at: new Date(Date.UTC(2026, 10, 14, 12, 0, i * 7)).toISOString() }))
1398
+ rows: Array.from({ length: 137 }, (_, i) => ({
1399
+ id: i + 1,
1400
+ player: `sim-0${i % 3 + 1}`,
1401
+ text: ["gg", "anyone near the tower?", "brb"][i % 3],
1402
+ sent_at: new Date(Date.UTC(2026, 10, 14, 12, 0, i * 7)).toISOString()
1403
+ }))
1183
1404
  },
1184
1405
  {
1185
1406
  name: "game_scores",
1186
1407
  plugin: null,
1187
1408
  columns: [
1188
- { name: "player", type: "TEXT", nullable: false, autoIncrement: false, hasDefault: false },
1189
- { name: "score", type: "INTEGER", nullable: false, autoIncrement: false, hasDefault: true },
1190
- { name: "guild", type: "TEXT", nullable: true, autoIncrement: false, hasDefault: false }
1409
+ {
1410
+ name: "player",
1411
+ type: "TEXT",
1412
+ nullable: false,
1413
+ autoIncrement: false,
1414
+ hasDefault: false
1415
+ },
1416
+ {
1417
+ name: "score",
1418
+ type: "INTEGER",
1419
+ nullable: false,
1420
+ autoIncrement: false,
1421
+ hasDefault: true
1422
+ },
1423
+ {
1424
+ name: "guild",
1425
+ type: "TEXT",
1426
+ nullable: true,
1427
+ autoIncrement: false,
1428
+ hasDefault: false
1429
+ }
1191
1430
  ],
1192
1431
  rows: [
1193
1432
  { player: "sim-01", score: 1200, guild: "Wolves" },
@@ -1197,16 +1436,85 @@ var SIMULATED_TABLES = [
1197
1436
  }
1198
1437
  ];
1199
1438
  var SIMULATED_ROUTES = [
1200
- { method: "GET", path: "/api/game/health", source: "engine", params: {}, devOnly: false, summary: "Whether the server is up" },
1201
- { method: "GET", path: "/api/game/metrics", source: "engine", params: {}, devOnly: false, summary: "Server statistics" },
1202
- { method: "GET", path: "/api/game/logs", source: "engine", params: {}, devOnly: false, summary: "Recent server log entries" },
1203
- { method: "GET", path: "/api/game/requests", source: "engine", params: {}, devOnly: false, summary: "Recent HTTP requests to this server" },
1204
- { method: "GET", path: "/api/game/routes", source: "engine", params: {}, devOnly: false, summary: "Every HTTP endpoint of this server" },
1205
- { method: "GET", path: "/api/game/dev/scene", source: "engine", params: {}, devOnly: true, summary: "The active scene" },
1206
- { method: "GET", path: "/api/scores", source: "game", params: {}, devOnly: false, summary: "The high scores" },
1207
- { method: "POST", path: "/api/scores/:player", source: "game", params: { player: "Id of the player" }, devOnly: false },
1208
- { method: "GET", path: "/monitoring", source: "plugin", plugin: "@mavonengine/http-monitoring", params: {}, devOnly: false },
1209
- { method: "GET", path: "/monitoring/api/metrics", source: "plugin", plugin: "@mavonengine/http-monitoring", params: {}, devOnly: false }
1439
+ {
1440
+ method: "GET",
1441
+ path: "/api/game/health",
1442
+ source: "engine",
1443
+ params: {},
1444
+ devOnly: false,
1445
+ summary: "Whether the server is up"
1446
+ },
1447
+ {
1448
+ method: "GET",
1449
+ path: "/api/game/metrics",
1450
+ source: "engine",
1451
+ params: {},
1452
+ devOnly: false,
1453
+ summary: "Server statistics"
1454
+ },
1455
+ {
1456
+ method: "GET",
1457
+ path: "/api/game/logs",
1458
+ source: "engine",
1459
+ params: {},
1460
+ devOnly: false,
1461
+ summary: "Recent server log entries"
1462
+ },
1463
+ {
1464
+ method: "GET",
1465
+ path: "/api/game/requests",
1466
+ source: "engine",
1467
+ params: {},
1468
+ devOnly: false,
1469
+ summary: "Recent HTTP requests to this server"
1470
+ },
1471
+ {
1472
+ method: "GET",
1473
+ path: "/api/game/routes",
1474
+ source: "engine",
1475
+ params: {},
1476
+ devOnly: false,
1477
+ summary: "Every HTTP endpoint of this server"
1478
+ },
1479
+ {
1480
+ method: "GET",
1481
+ path: "/api/game/dev/scene",
1482
+ source: "engine",
1483
+ params: {},
1484
+ devOnly: true,
1485
+ summary: "The active scene"
1486
+ },
1487
+ {
1488
+ method: "GET",
1489
+ path: "/api/scores",
1490
+ source: "game",
1491
+ params: {},
1492
+ devOnly: false,
1493
+ summary: "The high scores"
1494
+ },
1495
+ {
1496
+ method: "POST",
1497
+ path: "/api/scores/:player",
1498
+ source: "game",
1499
+ params: { player: "Id of the player" },
1500
+ devOnly: false
1501
+ },
1502
+ {
1503
+ method: "GET",
1504
+ path: "/monitoring",
1505
+ source: "plugin",
1506
+ plugin: "@mavonengine/http-monitoring",
1507
+ params: {},
1508
+ devOnly: false
1509
+ },
1510
+ {
1511
+ method: "GET",
1512
+ path: "/monitoring/api/metrics",
1513
+ source: "plugin",
1514
+ plugin: "@mavonengine/http-monitoring",
1515
+ params: {},
1516
+ devOnly: false
1517
+ }
1210
1518
  ];
1211
1519
  function mulberry32(seed) {
1212
1520
  return () => {
@@ -1238,18 +1546,37 @@ function simulatedSource(seed = 1, sampleIntervalMs = 1e3) {
1238
1546
  let previousPlayers = 0;
1239
1547
  const joinedAt = [];
1240
1548
  const log = (level, message) => {
1241
- logs.push({ id: logs.length + 1, timestamp: now, level, message });
1549
+ logs.push({
1550
+ id: logs.length + 1,
1551
+ timestamp: now,
1552
+ level,
1553
+ message
1554
+ });
1242
1555
  };
1243
1556
  const requests = [];
1244
1557
  const request = (method, path, status, bytes, address) => {
1245
- requests.push({ id: requests.length + 1, timestamp: now, method, path, status, durationMs: Math.round((1 + random() * 20) * 100) / 100, bytes, address });
1558
+ requests.push({
1559
+ id: requests.length + 1,
1560
+ timestamp: now,
1561
+ method,
1562
+ path,
1563
+ status,
1564
+ durationMs: Math.round((1 + random() * 20) * 100) / 100,
1565
+ bytes,
1566
+ address
1567
+ });
1246
1568
  };
1247
1569
  const packets = [];
1248
1570
  let packetId = 0;
1249
1571
  let tick = 0;
1250
1572
  let syncPlayers = [];
1251
1573
  const record = (entry, offsetMs = 0) => {
1252
- packets.push({ id: ++packetId, timestamp: now + offsetMs, hasPayload: entry.kind === "packet", ...entry });
1574
+ packets.push({
1575
+ id: ++packetId,
1576
+ timestamp: now + offsetMs,
1577
+ hasPayload: entry.kind === "packet",
1578
+ ...entry
1579
+ });
1253
1580
  if (packets.length > PACKET_LIMIT)
1254
1581
  packets.shift();
1255
1582
  };
@@ -1293,8 +1620,21 @@ function simulatedSource(seed = 1, sampleIntervalMs = 1e3) {
1293
1620
  request("POST", "/.wrtc/v2/connections", 200, 2900, address);
1294
1621
  request("POST", `/.wrtc/v2/connections/${players[i].id}/additional-candidates`, 200, 600, address);
1295
1622
  record({ kind: "event", type: "connect", peer: players[i].id });
1296
- record({ kind: "packet", direction: "in", type: "cl_init", peer: players[i].id, bytes: 24, reliable: true });
1297
- record({ kind: "event", type: "sync_enter", peer: players[i].id, tick, info: { count: players[i].trackedEntities } });
1623
+ record({
1624
+ kind: "packet",
1625
+ direction: "in",
1626
+ type: "cl_init",
1627
+ peer: players[i].id,
1628
+ bytes: 24,
1629
+ reliable: true
1630
+ });
1631
+ record({
1632
+ kind: "event",
1633
+ type: "sync_enter",
1634
+ peer: players[i].id,
1635
+ tick,
1636
+ info: { count: players[i].trackedEntities }
1637
+ });
1298
1638
  log("info", `Connected: ${players[i].id}`);
1299
1639
  log("info", `${i + 1} total players connected`);
1300
1640
  }
@@ -1310,22 +1650,75 @@ function simulatedSource(seed = 1, sampleIntervalMs = 1e3) {
1310
1650
  tick += tickRate / STATES_PER_SECOND;
1311
1651
  for (const player of players) {
1312
1652
  const bytes = 180 + player.trackedEntities * 96 + Math.floor(random() * 40);
1313
- if (state % 2 === 0)
1314
- record({ kind: "packet", direction: "in", type: "command", peer: player.id, bytes: 58, sequenceId: player.lastProcessedSequenceId, info: { command: "cl_move" } }, offset);
1315
- record({ kind: "packet", direction: "out", type: "sv_state", peer: player.id, bytes, tick, info: { entities: player.trackedEntities, ack: player.lastProcessedSequenceId } }, offset + 2);
1653
+ if (state % 2 === 0) {
1654
+ record({
1655
+ kind: "packet",
1656
+ direction: "in",
1657
+ type: "command",
1658
+ peer: player.id,
1659
+ bytes: 58,
1660
+ sequenceId: player.lastProcessedSequenceId,
1661
+ info: { command: "cl_move" }
1662
+ }, offset);
1663
+ }
1664
+ record({
1665
+ kind: "packet",
1666
+ direction: "out",
1667
+ type: "sv_state",
1668
+ peer: player.id,
1669
+ bytes,
1670
+ tick,
1671
+ info: { entities: player.trackedEntities, ack: player.lastProcessedSequenceId }
1672
+ }, offset + 2);
1316
1673
  lastStates.set(player.id, { tick, bytes, entities: player.trackedEntities });
1317
1674
  }
1318
1675
  }
1319
1676
  for (const player of players) {
1320
- record({ kind: "packet", direction: "in", type: "ping", peer: player.id, bytes: 0 });
1321
- record({ kind: "packet", direction: "out", type: "pong", peer: player.id, bytes: 0 });
1677
+ record({
1678
+ kind: "packet",
1679
+ direction: "in",
1680
+ type: "ping",
1681
+ peer: player.id,
1682
+ bytes: 0
1683
+ });
1684
+ record({
1685
+ kind: "packet",
1686
+ direction: "out",
1687
+ type: "pong",
1688
+ peer: player.id,
1689
+ bytes: 0
1690
+ });
1691
+ }
1692
+ if (step % 9 === 0) {
1693
+ record({
1694
+ kind: "event",
1695
+ type: "sync_leave",
1696
+ peer: players[0].id,
1697
+ tick,
1698
+ info: {
1699
+ count: 2,
1700
+ entities: ["rock-12", "rock-40"]
1701
+ }
1702
+ });
1703
+ }
1704
+ if (step % 13 === 0) {
1705
+ record({
1706
+ kind: "event",
1707
+ type: "dropped",
1708
+ peer: players.at(-1).id,
1709
+ info: { reason: "DROPPED_FROM_BUFFERING", message: "sv_state" }
1710
+ });
1711
+ }
1712
+ if (step % 4 === 0) {
1713
+ record({
1714
+ kind: "packet",
1715
+ direction: "out",
1716
+ type: "sv_chat",
1717
+ peer: players[0].id,
1718
+ bytes: 74,
1719
+ reliable: true
1720
+ });
1322
1721
  }
1323
- if (step % 9 === 0)
1324
- record({ kind: "event", type: "sync_leave", peer: players[0].id, tick, info: { count: 2, entities: ["rock-12", "rock-40"] } });
1325
- if (step % 13 === 0)
1326
- record({ kind: "event", type: "dropped", peer: players.at(-1).id, info: { reason: "DROPPED_FROM_BUFFERING", message: "sv_state" } });
1327
- if (step % 4 === 0)
1328
- record({ kind: "packet", direction: "out", type: "sv_chat", peer: players[0].id, bytes: 74, reliable: true });
1329
1722
  syncPlayers = players.map((player) => ({
1330
1723
  id: player.id,
1331
1724
  displayName: player.displayName,
@@ -1366,7 +1759,14 @@ function simulatedSource(seed = 1, sampleIntervalMs = 1e3) {
1366
1759
  queued = queued + dispatched - processed;
1367
1760
  if (failed)
1368
1761
  log("error", "Job grant-reward failed all 3 tries: Error: reward service unavailable");
1369
- push(queueHistory, { timestamp: now, size: queued, running: Math.min(queued, 1), processed: processed - failed, retried: step % 7 === 0 ? 1 : 0, failed });
1762
+ push(queueHistory, {
1763
+ timestamp: now,
1764
+ size: queued,
1765
+ running: Math.min(queued, 1),
1766
+ processed: processed - failed,
1767
+ retried: step % 7 === 0 ? 1 : 0,
1768
+ failed
1769
+ });
1370
1770
  const average = (ms) => {
1371
1771
  const recent = cpuHistory.slice(-Math.max(1, Math.round(ms / sampleIntervalMs)));
1372
1772
  return Math.round(recent.reduce((acc, h) => acc + h.cpuPercentage, 0) / recent.length * 100) / 100;
@@ -1406,19 +1806,35 @@ function simulatedSource(seed = 1, sampleIntervalMs = 1e3) {
1406
1806
  external: 5e6
1407
1807
  },
1408
1808
  latencySimulation: null,
1409
- queue: { driver: "database", working: true, latest: queueHistory.at(-1), history: [...queueHistory] }
1809
+ queue: {
1810
+ driver: "database",
1811
+ working: true,
1812
+ latest: queueHistory.at(-1),
1813
+ history: [...queueHistory]
1814
+ }
1410
1815
  };
1411
1816
  return snapshot;
1412
1817
  },
1413
1818
  async fetchLogs(afterId) {
1414
- return { entries: logs.filter((entry) => entry.id > afterId), latestId: logs.length };
1819
+ return {
1820
+ entries: logs.filter((entry) => entry.id > afterId),
1821
+ latestId: logs.length
1822
+ };
1415
1823
  },
1416
1824
  async fetchRequests(afterId) {
1417
- return { entries: requests.filter((entry) => entry.id > afterId), latestId: requests.length };
1825
+ return {
1826
+ entries: requests.filter((entry) => entry.id > afterId),
1827
+ latestId: requests.length
1828
+ };
1418
1829
  },
1419
1830
  async fetchPackets(afterId) {
1420
1831
  const records = packets.filter((entry) => entry.id > afterId);
1421
- return { enabled: true, latestId: packetId, matched: records.length, records };
1832
+ return {
1833
+ enabled: true,
1834
+ latestId: packetId,
1835
+ matched: records.length,
1836
+ records
1837
+ };
1422
1838
  },
1423
1839
  async fetchPacket(id) {
1424
1840
  const found = packets.find((entry) => entry.id === id);
@@ -1440,16 +1856,41 @@ function simulatedSource(seed = 1, sampleIntervalMs = 1e3) {
1440
1856
  rotation: { x: 0, y: i % 6 / 2, z: 0 },
1441
1857
  scale: { x: 1, y: 1, z: 1 }
1442
1858
  }))
1443
- } : found.type === "command" ? { type: "cl_move", sequenceId: found.sequenceId, keys: ["KeyW"], yaw: 1.57 } : found.type === "cl_init" ? { name: `Player ${String(found.peer).slice(-2)}` } : { playerId: found.peer, playerName: "Player 1", message: "hello" };
1444
- return { record: { ...found, payload } };
1859
+ } : found.type === "command" ? {
1860
+ type: "cl_move",
1861
+ sequenceId: found.sequenceId,
1862
+ keys: ["KeyW"],
1863
+ yaw: 1.57
1864
+ } : found.type === "cl_init" ? { name: `Player ${String(found.peer).slice(-2)}` } : { playerId: found.peer, playerName: "Player 1", message: "hello" };
1865
+ return {
1866
+ record: { ...found, payload }
1867
+ };
1445
1868
  },
1446
1869
  async fetchSync() {
1447
1870
  const entities = [
1448
- ...syncPlayers.map((player) => ({ id: player.id, type: "player", player: true, trackedBy: syncPlayers.length })),
1871
+ ...syncPlayers.map((player) => ({
1872
+ id: player.id,
1873
+ type: "player",
1874
+ player: true,
1875
+ trackedBy: syncPlayers.length
1876
+ })),
1449
1877
  // The last few are out of every player's range
1450
- ...Array.from({ length: 140 }, (_, i) => ({ id: `entity-${i}`, type: "rock", player: false, trackedBy: i < 134 ? 1 + i % syncPlayers.length : 0 }))
1878
+ ...Array.from({ length: 140 }, (_, i) => ({
1879
+ id: `entity-${i}`,
1880
+ type: "rock",
1881
+ player: false,
1882
+ trackedBy: i < 134 ? 1 + i % syncPlayers.length : 0
1883
+ }))
1451
1884
  ];
1452
- return { tick, serverTime: now, tickRate, syncDistance: 200, players: syncPlayers, editors: [], entities };
1885
+ return {
1886
+ tick,
1887
+ serverTime: now,
1888
+ tickRate,
1889
+ syncDistance: 200,
1890
+ players: syncPlayers,
1891
+ editors: [],
1892
+ entities
1893
+ };
1453
1894
  },
1454
1895
  async fetchRoutes() {
1455
1896
  return { routes: SIMULATED_ROUTES };
@@ -1461,14 +1902,29 @@ function simulatedSource(seed = 1, sampleIntervalMs = 1e3) {
1461
1902
  return {
1462
1903
  provider: "@mavonengine/sqlite",
1463
1904
  tables: SIMULATED_TABLES.map(({ rows, ...table }) => ({ ...table, rows: rows.length })),
1464
- migrations: [{ plugin: "@mavonengine/chat", table: "chat__migrations", applied: [{ name: "001_init", executedAt: "2026-11-14T12:00:00.000Z" }] }]
1905
+ migrations: [
1906
+ {
1907
+ plugin: "@mavonengine/chat",
1908
+ table: "chat__migrations",
1909
+ applied: [
1910
+ { name: "001_init", executedAt: "2026-11-14T12:00:00.000Z" }
1911
+ ]
1912
+ }
1913
+ ]
1465
1914
  };
1466
1915
  },
1467
1916
  async fetchTable(name, offset, limit) {
1468
1917
  const table = SIMULATED_TABLES.find((t) => t.name === name);
1469
1918
  if (!table)
1470
1919
  throw new MetricsSourceError(`No table ${name}`, "disabled");
1471
- return { table: name, columns: table.columns, rows: table.rows.slice(offset, offset + limit), total: table.rows.length, offset, limit };
1920
+ return {
1921
+ table: name,
1922
+ columns: table.columns,
1923
+ rows: table.rows.slice(offset, offset + limit),
1924
+ total: table.rows.length,
1925
+ offset,
1926
+ limit
1927
+ };
1472
1928
  }
1473
1929
  };
1474
1930
  }
@@ -1496,8 +1952,12 @@ function bootBanner({ version: version3, threeRevision, rapierVersion, mode }) {
1496
1952
  "\u2502 MavonEngine \u2502",
1497
1953
  "\u2502 \u2502",
1498
1954
  row("Version", version3),
1499
- ...threeRevision ? [row("Three.js", `r${threeRevision}`)] : [],
1500
- ...rapierVersion ? [row("Rapier", rapierVersion)] : [],
1955
+ ...threeRevision ? [
1956
+ row("Three.js", `r${threeRevision}`)
1957
+ ] : [],
1958
+ ...rapierVersion ? [
1959
+ row("Rapier", rapierVersion)
1960
+ ] : [],
1501
1961
  row("Mode", mode),
1502
1962
  "\u2502 \u2502",
1503
1963
  "\u2502 https://github.com/MavonEngine/core \u2502",
@@ -1633,7 +2093,20 @@ var LOGO_SIZES = [
1633
2093
 
1634
2094
  // src/dashboard/view.ts
1635
2095
  function initialViewState() {
1636
- return { tab: 0, playerOffset: 0, logFromEnd: 0, requestTopId: null, selectedPlayerId: null, followSelectedPlayer: true, packetTopId: null, showPings: false, eventsOnly: false, selectedPacketId: null, followSelectedPacket: true, payloadOffset: 0 };
2096
+ return {
2097
+ tab: 0,
2098
+ playerOffset: 0,
2099
+ logFromEnd: 0,
2100
+ requestTopId: null,
2101
+ selectedPlayerId: null,
2102
+ followSelectedPlayer: true,
2103
+ packetTopId: null,
2104
+ showPings: false,
2105
+ eventsOnly: false,
2106
+ selectedPacketId: null,
2107
+ followSelectedPacket: true,
2108
+ payloadOffset: 0
2109
+ };
1637
2110
  }
1638
2111
  function accountLabel(account) {
1639
2112
  if (!account)
@@ -1641,7 +2114,16 @@ function accountLabel(account) {
1641
2114
  const name = account.name ?? account.id;
1642
2115
  return account.guest ? `${name} (guest)` : name;
1643
2116
  }
1644
- var DASHBOARD_TABS = ["Overview", "Players", "Logs", "HTTP", "Network", "Routes", "Plugins", "Database"];
2117
+ var DASHBOARD_TABS = [
2118
+ "Overview",
2119
+ "Players",
2120
+ "Logs",
2121
+ "HTTP",
2122
+ "Network",
2123
+ "Routes",
2124
+ "Plugins",
2125
+ "Database"
2126
+ ];
1645
2127
  var DEFAULT_VISIBLE_ROWS = 20;
1646
2128
  function showsDatabase(view) {
1647
2129
  return DASHBOARD_TABS[view.tab] === "Database";
@@ -1761,12 +2243,23 @@ function messageStats(packets, windowMs = MESSAGE_STATS_WINDOW_MS) {
1761
2243
  const groups = /* @__PURE__ */ new Map();
1762
2244
  for (const packet of recent) {
1763
2245
  const key = `${packet.direction} ${packet.type}`;
1764
- const group = groups.get(key) ?? { direction: packet.direction, type: packet.type, count: 0, bytes: 0 };
2246
+ const group = groups.get(key) ?? {
2247
+ direction: packet.direction,
2248
+ type: packet.type,
2249
+ count: 0,
2250
+ bytes: 0
2251
+ };
1765
2252
  group.count++;
1766
2253
  group.bytes += packet.bytes;
1767
2254
  groups.set(key, group);
1768
2255
  }
1769
- return Array.from(groups.values(), ({ direction, type, count, bytes }) => ({ direction, type, rate: count / seconds, bytesPerSecond: bytes / seconds, avgBytes: bytes / count })).sort((a, b) => b.bytesPerSecond - a.bytesPerSecond || b.rate - a.rate || a.type.localeCompare(b.type));
2256
+ return Array.from(groups.values(), ({ direction, type, count, bytes }) => ({
2257
+ direction,
2258
+ type,
2259
+ rate: count / seconds,
2260
+ bytesPerSecond: bytes / seconds,
2261
+ avgBytes: bytes / count
2262
+ })).sort((a, b) => b.bytesPerSecond - a.bytesPerSecond || b.rate - a.rate || a.type.localeCompare(b.type));
1770
2263
  }
1771
2264
  function describePacket(packet) {
1772
2265
  const parts = [];
@@ -1799,7 +2292,10 @@ function handlePluginsKey(view, plugins, key, rest = []) {
1799
2292
  if (DASHBOARD_TABS[view.tab] !== "Plugins" || view.confirmInstall)
1800
2293
  return false;
1801
2294
  const delta = key === "down" || key === "j" ? 1 : key === "up" || key === "k" ? -1 : 0;
1802
- const packages = [...plugins, ...rest].map((p) => p.package);
2295
+ const packages = [
2296
+ ...plugins,
2297
+ ...rest
2298
+ ].map((p) => p.package);
1803
2299
  if (delta === 0 || packages.length === 0)
1804
2300
  return false;
1805
2301
  const shown = selectedPlugin(view, plugins, rest);
@@ -1829,12 +2325,20 @@ function handleInstallKey(view, plugins, key, rest, installer) {
1829
2325
  return true;
1830
2326
  }
1831
2327
  function pluginKeys(state, view, available, installer) {
1832
- if (view.confirmInstall)
1833
- return [{ key: "y", label: "Install" }, { key: "n", label: "Cancel" }];
2328
+ if (view.confirmInstall) {
2329
+ return [
2330
+ { key: "y", label: "Install" },
2331
+ { key: "n", label: "Cancel" }
2332
+ ];
2333
+ }
1834
2334
  const rest = installable(state.plugins, available);
1835
2335
  return [
1836
- ...state.plugins.length + rest.length > 1 ? [{ key: "\u2191\u2193", label: "Select plugin" }] : [],
1837
- ...installer && !installer.busy && selectedPlugin(view, state.plugins, rest).available ? [{ key: "i", label: "Install" }] : []
2336
+ ...state.plugins.length + rest.length > 1 ? [
2337
+ { key: "\u2191\u2193", label: "Select plugin" }
2338
+ ] : [],
2339
+ ...installer && !installer.busy && selectedPlugin(view, state.plugins, rest).available ? [
2340
+ { key: "i", label: "Install" }
2341
+ ] : []
1838
2342
  ];
1839
2343
  }
1840
2344
  function statusColor(status, theme) {
@@ -1852,8 +2356,11 @@ function renderDashboard(ui, theme, state, view, { transparent = false, startup,
1852
2356
  header(root, theme, state);
1853
2357
  if (snapshot?.latencySimulation)
1854
2358
  latencyBanner(root, theme, snapshot.latencySimulation);
1855
- if (state.error && snapshot)
1856
- root.text([{ text: ` ${state.error} \u2014 showing last known values`, fg: theme.danger }], { size: 1 });
2359
+ if (state.error && snapshot) {
2360
+ root.text([
2361
+ { text: ` ${state.error} \u2014 showing last known values`, fg: theme.danger }
2362
+ ], { size: 1 });
2363
+ }
1857
2364
  if (starting) {
1858
2365
  startupScreen(root, theme, startup);
1859
2366
  } else if (!snapshot) {
@@ -1899,18 +2406,47 @@ function renderDashboard(ui, theme, state, view, { transparent = false, startup,
1899
2406
  { key: "q", label: "Quit" },
1900
2407
  { key: "r", label: "Refresh" },
1901
2408
  { key: `1-${tabs.length}`, label: "Tabs" },
1902
- ...openKey && snapshot ? [{ key: "o", label: "Open game" }] : [],
1903
- ...snapshot && DASHBOARD_TABS[view.tab] === "Players" ? [{ key: "\u2191\u2193", label: "Select player" }, ...view.selectedPlayerId ? [{ key: "esc", label: "Close" }] : []] : [],
2409
+ ...openKey && snapshot ? [
2410
+ { key: "o", label: "Open game" }
2411
+ ] : [],
2412
+ ...snapshot && DASHBOARD_TABS[view.tab] === "Players" ? [
2413
+ { key: "\u2191\u2193", label: "Select player" },
2414
+ ...view.selectedPlayerId ? [
2415
+ { key: "esc", label: "Close" }
2416
+ ] : []
2417
+ ] : [],
1904
2418
  ...snapshot && showsNetwork(view) ? [
1905
- { key: "p", label: view.showPings ? "Hide pings" : "Show pings" },
1906
- { key: "e", label: view.eventsOnly ? "All records" : "Events only" },
2419
+ {
2420
+ key: "p",
2421
+ label: view.showPings ? "Hide pings" : "Show pings"
2422
+ },
2423
+ {
2424
+ key: "e",
2425
+ label: view.eventsOnly ? "All records" : "Events only"
2426
+ },
1907
2427
  { key: "\u2191\u2193", label: "Open packet" },
1908
- ...view.selectedPacketId !== null ? [{ key: "esc", label: "Close" }] : []
2428
+ ...view.selectedPacketId !== null ? [
2429
+ { key: "esc", label: "Close" }
2430
+ ] : []
1909
2431
  ] : [],
1910
2432
  ...snapshot && DASHBOARD_TABS[view.tab] === "Plugins" ? pluginKeys(state, view, available, installer) : [],
1911
- ...snapshot && showsDatabase(view) && state.database?.tables.length ? [...state.database.tables.length > 1 ? [{ key: "\u2191\u2193", label: "Select table" }] : [], { key: "\u2190\u2192", label: "Page rows" }] : []
2433
+ ...snapshot && showsDatabase(view) && state.database?.tables.length ? [
2434
+ ...state.database.tables.length > 1 ? [
2435
+ { key: "\u2191\u2193", label: "Select table" }
2436
+ ] : [],
2437
+ { key: "\u2190\u2192", label: "Page rows" }
2438
+ ] : []
1912
2439
  ],
1913
- right: [starting ? { label: "STARTING", color: statusColor("connecting", theme) } : { label: STATUS_LABELS[state.status], color: statusColor(state.status, theme), active: state.status === "live" }]
2440
+ right: [
2441
+ starting ? {
2442
+ label: "STARTING",
2443
+ color: statusColor("connecting", theme)
2444
+ } : {
2445
+ label: STATUS_LABELS[state.status],
2446
+ color: statusColor(state.status, theme),
2447
+ active: state.status === "live"
2448
+ }
2449
+ ]
1914
2450
  });
1915
2451
  });
1916
2452
  }
@@ -1922,7 +2458,9 @@ function header(ui, theme, state) {
1922
2458
  if (state.snapshot) {
1923
2459
  spans.push(
1924
2460
  { text: " uptime ", fg: theme.muted },
1925
- { text: formatDuration(state.snapshot.uptime) },
2461
+ {
2462
+ text: formatDuration(state.snapshot.uptime)
2463
+ },
1926
2464
  { text: " engine ", fg: theme.muted },
1927
2465
  { text: state.snapshot.engineVersion }
1928
2466
  );
@@ -1932,12 +2470,14 @@ function header(ui, theme, state) {
1932
2470
  ui.text(spans, { size: 1 });
1933
2471
  }
1934
2472
  function latencyBanner(ui, theme, latency) {
1935
- ui.text([{
1936
- text: ` LATENCY SIMULATION ON ${latency.fixedLatency}ms \xB1 ${latency.jitter / 2}ms, ${formatPercent(latency.packetLoss * 100)} packet loss `,
1937
- fg: theme.background,
1938
- bg: theme.warning,
1939
- bold: true
1940
- }], { size: 1 });
2473
+ ui.text([
2474
+ {
2475
+ text: ` LATENCY SIMULATION ON ${latency.fixedLatency}ms \xB1 ${latency.jitter / 2}ms, ${formatPercent(latency.packetLoss * 100)} packet loss `,
2476
+ fg: theme.background,
2477
+ bg: theme.warning,
2478
+ bold: true
2479
+ }
2480
+ ], { size: 1 });
1941
2481
  }
1942
2482
  var STARTUP_OUTPUT_LINES = 8;
1943
2483
  function logoLines(pixels) {
@@ -1975,8 +2515,11 @@ function startupScreen(ui, theme, { engineVersion, output, label = "Starting the
1975
2515
  column.text(line, { align: "center", size: 1 });
1976
2516
  column.spacer(1);
1977
2517
  }
1978
- for (const line of banner)
1979
- column.text([{ text: line, fg: theme.primary }], { align: "center", size: 1 });
2518
+ for (const line of banner) {
2519
+ column.text([
2520
+ { text: line, fg: theme.primary }
2521
+ ], { align: "center", size: 1 });
2522
+ }
1980
2523
  column.spacer(1);
1981
2524
  column.row({ size: 1 }, (row) => {
1982
2525
  row.spacer("1fr");
@@ -1990,7 +2533,10 @@ function startupScreen(ui, theme, { engineVersion, output, label = "Starting the
1990
2533
  panel.label("No output yet");
1991
2534
  return;
1992
2535
  }
1993
- panel.log({ entries: lines.slice(-STARTUP_OUTPUT_LINES).map((message) => ({ message })), size: "1fr" });
2536
+ panel.log({
2537
+ entries: lines.slice(-STARTUP_OUTPUT_LINES).map((message) => ({ message })),
2538
+ size: "1fr"
2539
+ });
1994
2540
  });
1995
2541
  }
1996
2542
  function waiting(ui, theme, state) {
@@ -1999,22 +2545,39 @@ function waiting(ui, theme, state) {
1999
2545
  panel.spinner({ label: `Connecting to ${state.source}` });
2000
2546
  return;
2001
2547
  }
2002
- panel.text([{ text: STATUS_LABELS[state.status], fg: statusColor(state.status, theme), bold: true }]);
2548
+ panel.text([
2549
+ {
2550
+ text: STATUS_LABELS[state.status],
2551
+ fg: statusColor(state.status, theme),
2552
+ bold: true
2553
+ }
2554
+ ]);
2003
2555
  panel.text(state.error ?? "", { wrap: true });
2004
2556
  panel.label(`Retrying (attempt ${state.failures})\u2026`);
2005
2557
  });
2006
2558
  }
2007
2559
  function wideLayout(ui, theme, state, snapshot, view, transparent) {
2008
2560
  if (snapshot.queue) {
2009
- ui.grid({ columns: ["1fr", "1fr", "1fr"], rows: [11, 11], size: 22 }, (grid) => {
2561
+ ui.grid({
2562
+ columns: ["1fr", "1fr", "1fr"],
2563
+ rows: [11, 11],
2564
+ size: 22
2565
+ }, (grid) => {
2010
2566
  grid.panel({ title: "CPU" }, (p) => cpuPanel(p, theme, snapshot));
2011
2567
  grid.panel({ title: "Network" }, (p) => networkPanel(p, theme, snapshot));
2012
2568
  grid.panel({ title: "Tick" }, (p) => tickPanel(p, theme, snapshot));
2013
- grid.panel({ title: queueTitle(snapshot.queue), colSpan: 2 }, (p) => queuePanel(p, theme, snapshot.queue));
2569
+ grid.panel({
2570
+ title: queueTitle(snapshot.queue),
2571
+ colSpan: 2
2572
+ }, (p) => queuePanel(p, theme, snapshot.queue));
2014
2573
  grid.panel({ title: "World" }, (p) => worldPanel(p, theme, snapshot));
2015
2574
  });
2016
2575
  } else {
2017
- ui.grid({ columns: ["1fr", "1fr"], rows: [11, 11], size: 22 }, (grid) => {
2576
+ ui.grid({
2577
+ columns: ["1fr", "1fr"],
2578
+ rows: [11, 11],
2579
+ size: 22
2580
+ }, (grid) => {
2018
2581
  grid.panel({ title: "CPU" }, (p) => cpuPanel(p, theme, snapshot));
2019
2582
  grid.panel({ title: "Network" }, (p) => networkPanel(p, theme, snapshot));
2020
2583
  grid.panel({ title: "Tick" }, (p) => tickPanel(p, theme, snapshot));
@@ -2030,8 +2593,12 @@ function narrowLayout(ui, theme, state, snapshot, view, transparent) {
2030
2593
  ui.panel({ title: "CPU", size: 9 }, (p) => cpuPanel(p, theme, snapshot));
2031
2594
  ui.panel({ title: "Network", size: 9 }, (p) => networkPanel(p, theme, snapshot));
2032
2595
  ui.panel({ title: "Tick", size: 9 }, (p) => tickPanel(p, theme, snapshot));
2033
- if (snapshot.queue)
2034
- ui.panel({ title: queueTitle(snapshot.queue), size: 9 }, (p) => queuePanel(p, theme, snapshot.queue));
2596
+ if (snapshot.queue) {
2597
+ ui.panel({
2598
+ title: queueTitle(snapshot.queue),
2599
+ size: 9
2600
+ }, (p) => queuePanel(p, theme, snapshot.queue));
2601
+ }
2035
2602
  ui.panel({ title: "World", size: 11 }, (p) => worldPanel(p, theme, snapshot));
2036
2603
  playersPanel(ui, theme, snapshot, view, transparent);
2037
2604
  logsPanel(ui, theme, state, view);
@@ -2049,16 +2616,39 @@ function cpuPanel(ui, theme, { cpu }) {
2049
2616
  size: "1fr"
2050
2617
  });
2051
2618
  ui.meters([
2052
- { label: "1s", value: cpu.avg1s, max: 100, text: formatPercent(cpu.avg1s) },
2053
- { label: "10s", value: cpu.avg10s, max: 100, text: formatPercent(cpu.avg10s) },
2054
- { label: "1m", value: cpu.avg60s, max: 100, text: formatPercent(cpu.avg60s) }
2619
+ {
2620
+ label: "1s",
2621
+ value: cpu.avg1s,
2622
+ max: 100,
2623
+ text: formatPercent(cpu.avg1s)
2624
+ },
2625
+ {
2626
+ label: "10s",
2627
+ value: cpu.avg10s,
2628
+ max: 100,
2629
+ text: formatPercent(cpu.avg10s)
2630
+ },
2631
+ {
2632
+ label: "1m",
2633
+ value: cpu.avg60s,
2634
+ max: 100,
2635
+ text: formatPercent(cpu.avg60s)
2636
+ }
2055
2637
  ], { columns: 3 });
2056
2638
  }
2057
2639
  function networkPanel(ui, theme, { bandwidth, sampleIntervalMs }) {
2058
2640
  const perSecond = 1e3 / sampleIntervalMs;
2059
2641
  ui.multiGraph([
2060
- { label: "sent", values: bandwidth.history.map((b) => b.sent * perSecond), color: theme.graph[0] },
2061
- { label: "received", values: bandwidth.history.map((b) => b.received * perSecond), color: theme.graph[1] }
2642
+ {
2643
+ label: "sent",
2644
+ values: bandwidth.history.map((b) => b.sent * perSecond),
2645
+ color: theme.graph[0]
2646
+ },
2647
+ {
2648
+ label: "received",
2649
+ values: bandwidth.history.map((b) => b.received * perSecond),
2650
+ color: theme.graph[1]
2651
+ }
2062
2652
  ], {
2063
2653
  min: 0,
2064
2654
  axis: true,
@@ -2068,8 +2658,16 @@ function networkPanel(ui, theme, { bandwidth, sampleIntervalMs }) {
2068
2658
  size: "1fr"
2069
2659
  });
2070
2660
  ui.keyValues([
2071
- { label: "Sent", value: formatRate(bandwidth.sentPerSecond), color: theme.graph[0] },
2072
- { label: "Received", value: formatRate(bandwidth.receivedPerSecond), color: theme.graph[1] }
2661
+ {
2662
+ label: "Sent",
2663
+ value: formatRate(bandwidth.sentPerSecond),
2664
+ color: theme.graph[0]
2665
+ },
2666
+ {
2667
+ label: "Received",
2668
+ value: formatRate(bandwidth.receivedPerSecond),
2669
+ color: theme.graph[1]
2670
+ }
2073
2671
  ], { spread: true });
2074
2672
  }
2075
2673
  function tickPanel(ui, theme, { tick, tickRate }) {
@@ -2095,7 +2693,11 @@ function tickPanel(ui, theme, { tick, tickRate }) {
2095
2693
  text: `${formatMs(latest?.avgMs ?? 0)} / ${formatMs(tick.budgetMs)}`
2096
2694
  });
2097
2695
  ui.keyValues([
2098
- { label: "Ticks/s", value: `${latest?.ticksPerSecond ?? 0} / ${tickRate}`, color: (latest?.ticksPerSecond ?? 0) < tickRate * 0.9 ? theme.danger : void 0 },
2696
+ {
2697
+ label: "Ticks/s",
2698
+ value: `${latest?.ticksPerSecond ?? 0} / ${tickRate}`,
2699
+ color: (latest?.ticksPerSecond ?? 0) < tickRate * 0.9 ? theme.danger : void 0
2700
+ },
2099
2701
  { label: "Commands/s", value: `${latest?.commandsPerSecond ?? 0} (max ${latest?.maxCommandsPerTick ?? 0}/tick)` }
2100
2702
  ], { spread: true });
2101
2703
  }
@@ -2111,9 +2713,21 @@ function queuePanel(ui, theme, queue) {
2111
2713
  const seconds = Math.round(queue.history.length > 1 ? (queue.history.at(-1).timestamp - queue.history[0].timestamp) / 1e3 : 0);
2112
2714
  const window = seconds >= 60 ? `${Math.round(seconds / 60)}m` : `${seconds}s`;
2113
2715
  ui.multiGraph([
2114
- { label: "queued", values: queue.history.map((s) => s.size), color: theme.graph[0] },
2115
- { label: "processed", values: queue.history.map((s) => s.processed), color: theme.graph[1] },
2116
- { label: "failed", values: queue.history.map((s) => s.failed), color: theme.danger }
2716
+ {
2717
+ label: "queued",
2718
+ values: queue.history.map((s) => s.size),
2719
+ color: theme.graph[0]
2720
+ },
2721
+ {
2722
+ label: "processed",
2723
+ values: queue.history.map((s) => s.processed),
2724
+ color: theme.graph[1]
2725
+ },
2726
+ {
2727
+ label: "failed",
2728
+ values: queue.history.map((s) => s.failed),
2729
+ color: theme.danger
2730
+ }
2117
2731
  ], {
2118
2732
  min: 0,
2119
2733
  max: Math.max(4, ...queue.history.map((s) => Math.max(s.size, s.processed, s.failed))),
@@ -2124,21 +2738,59 @@ function queuePanel(ui, theme, queue) {
2124
2738
  size: "1fr"
2125
2739
  });
2126
2740
  ui.keyValues([
2127
- { label: "Queued", value: String(latest?.size ?? 0), color: theme.graph[0] },
2128
- { label: "Running", value: String(latest?.running ?? 0) },
2129
- { label: `Processed ${window}`, value: String(totals.processed), color: theme.graph[1] },
2130
- { label: `Retried ${window}`, value: String(totals.retried), color: totals.retried ? theme.warning : void 0 },
2131
- { label: `Failed ${window}`, value: String(totals.failed), color: totals.failed ? theme.danger : void 0 }
2741
+ {
2742
+ label: "Queued",
2743
+ value: String(latest?.size ?? 0),
2744
+ color: theme.graph[0]
2745
+ },
2746
+ {
2747
+ label: "Running",
2748
+ value: String(latest?.running ?? 0)
2749
+ },
2750
+ {
2751
+ label: `Processed ${window}`,
2752
+ value: String(totals.processed),
2753
+ color: theme.graph[1]
2754
+ },
2755
+ {
2756
+ label: `Retried ${window}`,
2757
+ value: String(totals.retried),
2758
+ color: totals.retried ? theme.warning : void 0
2759
+ },
2760
+ {
2761
+ label: `Failed ${window}`,
2762
+ value: String(totals.failed),
2763
+ color: totals.failed ? theme.danger : void 0
2764
+ }
2132
2765
  ], { spread: true });
2133
2766
  }
2134
2767
  function worldPanel(ui, theme, { players, world, physics, memory }) {
2135
2768
  ui.keyValues([
2136
- { label: "Players", value: String(players.length), color: theme.primary },
2137
- { label: "Entities", value: String(world.entities) },
2138
- { label: "Physics bodies", value: physics ? String(physics.bodies) : "\u2014" },
2139
- { label: "Colliders", value: physics ? String(physics.colliders) : "\u2014" },
2140
- { label: "RSS", value: formatBytes(memory.rss) },
2141
- { label: "External", value: formatBytes(memory.external) }
2769
+ {
2770
+ label: "Players",
2771
+ value: String(players.length),
2772
+ color: theme.primary
2773
+ },
2774
+ {
2775
+ label: "Entities",
2776
+ value: String(world.entities)
2777
+ },
2778
+ {
2779
+ label: "Physics bodies",
2780
+ value: physics ? String(physics.bodies) : "\u2014"
2781
+ },
2782
+ {
2783
+ label: "Colliders",
2784
+ value: physics ? String(physics.colliders) : "\u2014"
2785
+ },
2786
+ {
2787
+ label: "RSS",
2788
+ value: formatBytes(memory.rss)
2789
+ },
2790
+ {
2791
+ label: "External",
2792
+ value: formatBytes(memory.external)
2793
+ }
2142
2794
  ], { spread: true });
2143
2795
  ui.spacer("1fr");
2144
2796
  ui.meter({
@@ -2171,15 +2823,44 @@ function playerDetails(ui, theme, player, size) {
2171
2823
  ui.panel({ title: player.displayName, size }, (panel) => {
2172
2824
  panel.keyValues([
2173
2825
  { label: "ID", value: player.id },
2174
- { label: "Account", value: player.account ? `${accountLabel(player.account)} \xB7 ${player.account.id}` : "none", color: player.account?.guest ? theme.warning : void 0 },
2175
- { label: "Connected", value: formatDuration(player.connectedFor) },
2176
- { label: "IP", value: connection ? connection.address ?? "pending" : "\u2014", color: theme.primary },
2177
- { label: "RTT", value: connection?.rttMs != null ? formatMs(connection.rttMs) : "\u2014" },
2178
- { label: "Sent", value: connection ? formatBytes(connection.bytesSent) : "\u2014" },
2179
- { label: "Received", value: connection ? formatBytes(connection.bytesReceived) : "\u2014" },
2180
- { label: "Position", value: [position.x, position.y, position.z].map((n) => n.toFixed(2)).join(", ") },
2181
- { label: "Last seq", value: String(player.lastProcessedSequenceId) },
2182
- { label: "Tracked", value: String(player.trackedEntities) }
2826
+ {
2827
+ label: "Account",
2828
+ value: player.account ? `${accountLabel(player.account)} \xB7 ${player.account.id}` : "none",
2829
+ color: player.account?.guest ? theme.warning : void 0
2830
+ },
2831
+ {
2832
+ label: "Connected",
2833
+ value: formatDuration(player.connectedFor)
2834
+ },
2835
+ {
2836
+ label: "IP",
2837
+ value: connection ? connection.address ?? "pending" : "\u2014",
2838
+ color: theme.primary
2839
+ },
2840
+ {
2841
+ label: "RTT",
2842
+ value: connection?.rttMs != null ? formatMs(connection.rttMs) : "\u2014"
2843
+ },
2844
+ {
2845
+ label: "Sent",
2846
+ value: connection ? formatBytes(connection.bytesSent) : "\u2014"
2847
+ },
2848
+ {
2849
+ label: "Received",
2850
+ value: connection ? formatBytes(connection.bytesReceived) : "\u2014"
2851
+ },
2852
+ {
2853
+ label: "Position",
2854
+ value: [position.x, position.y, position.z].map((n) => n.toFixed(2)).join(", ")
2855
+ },
2856
+ {
2857
+ label: "Last seq",
2858
+ value: String(player.lastProcessedSequenceId)
2859
+ },
2860
+ {
2861
+ label: "Tracked",
2862
+ value: String(player.trackedEntities)
2863
+ }
2183
2864
  ], { spread: true });
2184
2865
  if (!connection)
2185
2866
  panel.label("No live connection (a bot, or an older server)");
@@ -2223,21 +2904,62 @@ function playersPanel(ui, theme, { players }, view, transparent, selectable = fa
2223
2904
  ui.ctx.invalidate();
2224
2905
  },
2225
2906
  columns: [
2226
- ...showNames ? [{ key: "displayName", title: "Name" }] : [],
2227
- ...showAccounts ? [{ key: "account", title: "Account", render: (p) => accountLabel(p.account), color: (p) => p.account?.guest ? theme.warning : void 0 }] : [],
2907
+ ...showNames ? [
2908
+ { key: "displayName", title: "Name" }
2909
+ ] : [],
2910
+ ...showAccounts ? [
2911
+ {
2912
+ key: "account",
2913
+ title: "Account",
2914
+ render: (p) => accountLabel(p.account),
2915
+ color: (p) => p.account?.guest ? theme.warning : void 0
2916
+ }
2917
+ ] : [],
2228
2918
  { key: "id", title: "ID" },
2229
- { key: "x", title: "X", width: 9, align: "right", render: (p) => p.position.x.toFixed(2) },
2230
- { key: "y", title: "Y", width: 9, align: "right", render: (p) => p.position.y.toFixed(2) },
2231
- { key: "z", title: "Z", width: 9, align: "right", render: (p) => p.position.z.toFixed(2) },
2232
- { key: "lastProcessedSequenceId", title: "Seq", width: 10, align: "right" },
2233
- { key: "trackedEntities", title: "Tracked", width: 8, align: "right" }
2919
+ {
2920
+ key: "x",
2921
+ title: "X",
2922
+ width: 9,
2923
+ align: "right",
2924
+ render: (p) => p.position.x.toFixed(2)
2925
+ },
2926
+ {
2927
+ key: "y",
2928
+ title: "Y",
2929
+ width: 9,
2930
+ align: "right",
2931
+ render: (p) => p.position.y.toFixed(2)
2932
+ },
2933
+ {
2934
+ key: "z",
2935
+ title: "Z",
2936
+ width: 9,
2937
+ align: "right",
2938
+ render: (p) => p.position.z.toFixed(2)
2939
+ },
2940
+ {
2941
+ key: "lastProcessedSequenceId",
2942
+ title: "Seq",
2943
+ width: 10,
2944
+ align: "right"
2945
+ },
2946
+ {
2947
+ key: "trackedEntities",
2948
+ title: "Tracked",
2949
+ width: 8,
2950
+ align: "right"
2951
+ }
2234
2952
  ]
2235
2953
  });
2236
2954
  });
2237
2955
  }
2238
2956
  function formatTime(timestamp) {
2239
2957
  const date = new Date(timestamp);
2240
- return [date.getHours(), date.getMinutes(), date.getSeconds()].map((n) => n.toString().padStart(2, "0")).join(":");
2958
+ return [
2959
+ date.getHours(),
2960
+ date.getMinutes(),
2961
+ date.getSeconds()
2962
+ ].map((n) => n.toString().padStart(2, "0")).join(":");
2241
2963
  }
2242
2964
  function toLogRows(lines) {
2243
2965
  return lines.flatMap(({ timestamp, level, message }) => {
@@ -2246,7 +2968,11 @@ function toLogRows(lines) {
2246
2968
  parts.shift();
2247
2969
  while (parts.length > 1 && parts.at(-1).trim() === "")
2248
2970
  parts.pop();
2249
- return parts.map((part, i) => i === 0 ? { time: formatTime(timestamp), level, message: part } : { message: `${" ".repeat(15)}${part}` });
2971
+ return parts.map((part, i) => i === 0 ? {
2972
+ time: formatTime(timestamp),
2973
+ level,
2974
+ message: part
2975
+ } : { message: `${" ".repeat(15)}${part}` });
2250
2976
  });
2251
2977
  }
2252
2978
  function logsPanel(ui, theme, state, view) {
@@ -2312,8 +3038,9 @@ function requestsPanel(ui, theme, state, view, transparent) {
2312
3038
  size: "1fr",
2313
3039
  // The table won't scroll past the last full page, so keep the anchor on the row it actually drew
2314
3040
  onRow: (_row, index, y) => {
2315
- if (y === 1)
3041
+ if (y === 1) {
2316
3042
  view.requestTopId = index === 0 ? null : rows[index].id;
3043
+ }
2317
3044
  },
2318
3045
  onScroll: (delta) => {
2319
3046
  const next = Math.max(0, Math.min(rows.length - 1, offset + delta));
@@ -2321,12 +3048,48 @@ function requestsPanel(ui, theme, state, view, transparent) {
2321
3048
  ui.ctx.invalidate();
2322
3049
  },
2323
3050
  columns: [
2324
- { key: "time", title: "Time", width: 8, color: theme.muted, render: (r) => formatTime(r.timestamp) },
2325
- { key: "method", title: "Method", width: 7, color: (r) => r.method === "WS" ? theme.primary : void 0 },
2326
- { key: "status", title: "Status", width: 6, align: "right", color: (r) => statusCodeColor(r.status, theme), render: (r) => r.status === null ? "\u2014" : String(r.status) },
2327
- { key: "durationMs", title: "Duration", width: 10, align: "right", render: (r) => formatMs(r.durationMs) },
2328
- { key: "bytes", title: "Size", width: 10, align: "right", render: (r) => formatBytes(r.bytes) },
2329
- { key: "address", title: "Client", width: 18, color: theme.muted, render: (r) => r.address ?? "\u2014" },
3051
+ {
3052
+ key: "time",
3053
+ title: "Time",
3054
+ width: 8,
3055
+ color: theme.muted,
3056
+ render: (r) => formatTime(r.timestamp)
3057
+ },
3058
+ {
3059
+ key: "method",
3060
+ title: "Method",
3061
+ width: 7,
3062
+ color: (r) => r.method === "WS" ? theme.primary : void 0
3063
+ },
3064
+ {
3065
+ key: "status",
3066
+ title: "Status",
3067
+ width: 6,
3068
+ align: "right",
3069
+ color: (r) => statusCodeColor(r.status, theme),
3070
+ render: (r) => r.status === null ? "\u2014" : String(r.status)
3071
+ },
3072
+ {
3073
+ key: "durationMs",
3074
+ title: "Duration",
3075
+ width: 10,
3076
+ align: "right",
3077
+ render: (r) => formatMs(r.durationMs)
3078
+ },
3079
+ {
3080
+ key: "bytes",
3081
+ title: "Size",
3082
+ width: 10,
3083
+ align: "right",
3084
+ render: (r) => formatBytes(r.bytes)
3085
+ },
3086
+ {
3087
+ key: "address",
3088
+ title: "Client",
3089
+ width: 18,
3090
+ color: theme.muted,
3091
+ render: (r) => r.address ?? "\u2014"
3092
+ },
2330
3093
  { key: "path", title: "Path" }
2331
3094
  ]
2332
3095
  });
@@ -2375,9 +3138,16 @@ function packetDetails(ui, theme, state, view, size) {
2375
3138
  if (packet) {
2376
3139
  const facts = describePacket({ ...packet, info: {} });
2377
3140
  panel.text([
2378
- { text: formatTimeMs(packet.timestamp), fg: theme.muted },
2379
- ...packet.peer ? [{ text: ` ${packet.peer}` }] : [],
2380
- ...facts ? [{ text: ` ${facts}`, fg: theme.muted }] : []
3141
+ {
3142
+ text: formatTimeMs(packet.timestamp),
3143
+ fg: theme.muted
3144
+ },
3145
+ ...packet.peer ? [
3146
+ { text: ` ${packet.peer}` }
3147
+ ] : [],
3148
+ ...facts ? [
3149
+ { text: ` ${facts}`, fg: theme.muted }
3150
+ ] : []
2381
3151
  ], { size: 1 });
2382
3152
  }
2383
3153
  if (!detail || detail.status === "loading") {
@@ -2385,7 +3155,9 @@ function packetDetails(ui, theme, state, view, size) {
2385
3155
  return;
2386
3156
  }
2387
3157
  if (detail.status === "error") {
2388
- panel.text([{ text: detail.error ?? "Could not load it", fg: theme.danger }], { wrap: true });
3158
+ panel.text([
3159
+ { text: detail.error ?? "Could not load it", fg: theme.danger }
3160
+ ], { wrap: true });
2389
3161
  return;
2390
3162
  }
2391
3163
  if (detail.status === "gone") {
@@ -2412,18 +3184,30 @@ function packetDetails(ui, theme, state, view, size) {
2412
3184
  });
2413
3185
  }
2414
3186
  function syncPanel(ui, theme, { sync }, transparent, size = "1fr") {
2415
- ui.panel({ title: sync ? `State sync (tick ${sync.tick})` : "State sync", size }, (panel) => {
3187
+ ui.panel({
3188
+ title: sync ? `State sync (tick ${sync.tick})` : "State sync",
3189
+ size
3190
+ }, (panel) => {
2416
3191
  if (!sync) {
2417
3192
  panel.label("Waiting for the server\u2026");
2418
3193
  return;
2419
3194
  }
2420
3195
  panel.text([
2421
3196
  { text: `${sync.entities}`, bold: true },
2422
- { text: sync.entities === 1 ? " synced entity" : " synced entities", fg: theme.muted },
2423
- ...sync.untracked > 0 ? [{ text: `, ${sync.untracked} out of every player's range`, fg: theme.warning }] : [],
3197
+ {
3198
+ text: sync.entities === 1 ? " synced entity" : " synced entities",
3199
+ fg: theme.muted
3200
+ },
3201
+ ...sync.untracked > 0 ? [
3202
+ { text: `, ${sync.untracked} out of every player's range`, fg: theme.warning }
3203
+ ] : [],
2424
3204
  { text: " distance ", fg: theme.muted },
2425
- { text: sync.syncDistance === null ? "unknown" : String(sync.syncDistance) },
2426
- ...sync.editors > 0 ? [{ text: ` ${sync.editors} editor${sync.editors === 1 ? "" : "s"}`, fg: theme.info }] : []
3205
+ {
3206
+ text: sync.syncDistance === null ? "unknown" : String(sync.syncDistance)
3207
+ },
3208
+ ...sync.editors > 0 ? [
3209
+ { text: ` ${sync.editors} editor${sync.editors === 1 ? "" : "s"}`, fg: theme.info }
3210
+ ] : []
2427
3211
  ], { size: 1 });
2428
3212
  if (sync.players.length === 0) {
2429
3213
  panel.label("No players connected");
@@ -2437,10 +3221,32 @@ function syncPanel(ui, theme, { sync }, transparent, size = "1fr") {
2437
3221
  size: "1fr",
2438
3222
  columns: [
2439
3223
  { key: "displayName", title: "Player" },
2440
- ...sync.players.some((p) => p.account) ? [{ key: "account", title: "Account", render: (p) => accountLabel(p.account) }] : [],
2441
- { key: "tracked", title: "Tracked", width: 8, align: "right" },
2442
- { key: "ack", title: "Ack", width: 9, align: "right" },
2443
- { key: "bytes", title: "State", width: 10, align: "right", render: (p) => p.lastState ? formatBytes(p.lastState.bytes) : "\u2014" },
3224
+ ...sync.players.some((p) => p.account) ? [
3225
+ {
3226
+ key: "account",
3227
+ title: "Account",
3228
+ render: (p) => accountLabel(p.account)
3229
+ }
3230
+ ] : [],
3231
+ {
3232
+ key: "tracked",
3233
+ title: "Tracked",
3234
+ width: 8,
3235
+ align: "right"
3236
+ },
3237
+ {
3238
+ key: "ack",
3239
+ title: "Ack",
3240
+ width: 9,
3241
+ align: "right"
3242
+ },
3243
+ {
3244
+ key: "bytes",
3245
+ title: "State",
3246
+ width: 10,
3247
+ align: "right",
3248
+ render: (p) => p.lastState ? formatBytes(p.lastState.bytes) : "\u2014"
3249
+ },
2444
3250
  {
2445
3251
  key: "tick",
2446
3252
  title: "Tick",
@@ -2466,11 +3272,35 @@ function messagesPanel(ui, theme, state, transparent, size = "1fr") {
2466
3272
  zebra: !transparent,
2467
3273
  size: "1fr",
2468
3274
  columns: [
2469
- { key: "direction", title: "", width: 3, color: (s) => s.direction === "out" ? theme.graph[0] : theme.graph[1], render: (s) => s.direction === "out" ? "out" : "in" },
3275
+ {
3276
+ key: "direction",
3277
+ title: "",
3278
+ width: 3,
3279
+ color: (s) => s.direction === "out" ? theme.graph[0] : theme.graph[1],
3280
+ render: (s) => s.direction === "out" ? "out" : "in"
3281
+ },
2470
3282
  { key: "type", title: "Message" },
2471
- { key: "rate", title: "Per s", width: 8, align: "right", render: (s) => s.rate.toFixed(1) },
2472
- { key: "avgBytes", title: "Avg size", width: 10, align: "right", render: (s) => formatBytes(Math.round(s.avgBytes)) },
2473
- { key: "bytesPerSecond", title: "Rate", width: 12, align: "right", render: (s) => formatRate(Math.round(s.bytesPerSecond)) }
3283
+ {
3284
+ key: "rate",
3285
+ title: "Per s",
3286
+ width: 8,
3287
+ align: "right",
3288
+ render: (s) => s.rate.toFixed(1)
3289
+ },
3290
+ {
3291
+ key: "avgBytes",
3292
+ title: "Avg size",
3293
+ width: 10,
3294
+ align: "right",
3295
+ render: (s) => formatBytes(Math.round(s.avgBytes))
3296
+ },
3297
+ {
3298
+ key: "bytesPerSecond",
3299
+ title: "Rate",
3300
+ width: 12,
3301
+ align: "right",
3302
+ render: (s) => formatRate(Math.round(s.bytesPerSecond))
3303
+ }
2474
3304
  ]
2475
3305
  });
2476
3306
  });
@@ -2525,11 +3355,40 @@ function packetsPanel(ui, theme, state, view, transparent) {
2525
3355
  ui.ctx.invalidate();
2526
3356
  },
2527
3357
  columns: [
2528
- { key: "time", title: "Time", width: 12, color: theme.muted, render: (p) => formatTimeMs(p.timestamp) },
2529
- { key: "direction", title: "", width: 3, color: directionColor, render: (p) => p.kind === "event" ? "\u2022" : p.direction === "out" ? "out" : "in" },
2530
- { key: "type", title: "Message", width: narrow ? 12 : 18, color: (p) => p.kind === "event" ? theme.warning : void 0 },
2531
- { key: "peer", title: "Client", width: narrow ? 8 : 26, color: theme.muted, render: (p) => p.peer ?? "\u2014" },
2532
- { key: "bytes", title: "Size", width: narrow ? 9 : 10, align: "right", render: (p) => p.kind === "packet" ? formatBytes(p.bytes) : "" },
3358
+ {
3359
+ key: "time",
3360
+ title: "Time",
3361
+ width: 12,
3362
+ color: theme.muted,
3363
+ render: (p) => formatTimeMs(p.timestamp)
3364
+ },
3365
+ {
3366
+ key: "direction",
3367
+ title: "",
3368
+ width: 3,
3369
+ color: directionColor,
3370
+ render: (p) => p.kind === "event" ? "\u2022" : p.direction === "out" ? "out" : "in"
3371
+ },
3372
+ {
3373
+ key: "type",
3374
+ title: "Message",
3375
+ width: narrow ? 12 : 18,
3376
+ color: (p) => p.kind === "event" ? theme.warning : void 0
3377
+ },
3378
+ {
3379
+ key: "peer",
3380
+ title: "Client",
3381
+ width: narrow ? 8 : 26,
3382
+ color: theme.muted,
3383
+ render: (p) => p.peer ?? "\u2014"
3384
+ },
3385
+ {
3386
+ key: "bytes",
3387
+ title: "Size",
3388
+ width: narrow ? 9 : 10,
3389
+ align: "right",
3390
+ render: (p) => p.kind === "packet" ? formatBytes(p.bytes) : ""
3391
+ },
2533
3392
  { key: "info", title: "Details", render: describePacket }
2534
3393
  ]
2535
3394
  });
@@ -2590,11 +3449,33 @@ function routesPanel(ui, theme, state, view, transparent) {
2590
3449
  ui.ctx.invalidate();
2591
3450
  },
2592
3451
  columns: [
2593
- { key: "method", title: "Method", width: 7, color: (r) => methodColor(r.method, theme) },
3452
+ {
3453
+ key: "method",
3454
+ title: "Method",
3455
+ width: 7,
3456
+ color: (r) => methodColor(r.method, theme)
3457
+ },
2594
3458
  { key: "path", title: "Path" },
2595
- { key: "devOnly", title: "Served in", width: 10, color: (r) => r.devOnly ? theme.warning : theme.success, render: routeEnvironment },
2596
- { key: "source", title: "From", width: 30, color: (r) => r.source === "engine" ? theme.muted : r.source === "plugin" ? theme.primary : void 0, render: routeSource },
2597
- { key: "summary", title: "What it does", color: theme.muted, render: (r) => r.summary ?? "" }
3459
+ {
3460
+ key: "devOnly",
3461
+ title: "Served in",
3462
+ width: 10,
3463
+ color: (r) => r.devOnly ? theme.warning : theme.success,
3464
+ render: routeEnvironment
3465
+ },
3466
+ {
3467
+ key: "source",
3468
+ title: "From",
3469
+ width: 30,
3470
+ color: (r) => r.source === "engine" ? theme.muted : r.source === "plugin" ? theme.primary : void 0,
3471
+ render: routeSource
3472
+ },
3473
+ {
3474
+ key: "summary",
3475
+ title: "What it does",
3476
+ color: theme.muted,
3477
+ render: (r) => r.summary ?? ""
3478
+ }
2598
3479
  ]
2599
3480
  });
2600
3481
  });
@@ -2619,11 +3500,15 @@ function pluginsTab(ui, theme, state, view, transparent, available, installer) {
2619
3500
  if (!confirm)
2620
3501
  view.confirmInstall = null;
2621
3502
  if (state.pluginsAvailable === false || plugins.length === 0) {
2622
- ui.panel({ title: "Plugins", size: available ? 3 : "1fr" }, (panel) => {
2623
- if (state.pluginsAvailable === false)
3503
+ ui.panel({
3504
+ title: "Plugins",
3505
+ size: available ? 3 : "1fr"
3506
+ }, (panel) => {
3507
+ if (state.pluginsAvailable === false) {
2624
3508
  panel.label("Not available: the server runs a @mavonengine/core release without GET /api/game/plugins");
2625
- else
3509
+ } else {
2626
3510
  panel.label(state.pluginsAvailable === null ? "Asking the server for its plugins\u2026" : "The project has no plugins. Add one with: mavonengine install <package>");
3511
+ }
2627
3512
  });
2628
3513
  } else {
2629
3514
  let top = 0;
@@ -2650,11 +3535,42 @@ function pluginsTab(ui, theme, state, view, transparent, available, installer) {
2650
3535
  size: "1fr",
2651
3536
  columns: [
2652
3537
  { key: "package", title: "Package" },
2653
- { key: "version", title: "Version", width: 8, render: (p) => p.version ?? "\u2014" },
2654
- { key: "status", title: "Status", width: 10, color: (p) => pluginStatus(p, theme).color, render: (p) => pluginStatus(p, theme).label },
2655
- { key: "target", title: "Runs on", width: 7, render: (p) => p.target ?? "\u2014" },
2656
- { key: "endpoints", title: "Routes", width: 6, align: "right", render: (p) => state.routesAvailable ? String(endpoints(p).length) : "\u2014" },
2657
- { key: "prefabs", title: "Prefabs", width: 7, align: "right", render: (p) => String((/* @__PURE__ */ new Set([...p.declaredPrefabs, ...p.usedPrefabs])).size) }
3538
+ {
3539
+ key: "version",
3540
+ title: "Version",
3541
+ width: 8,
3542
+ render: (p) => p.version ?? "\u2014"
3543
+ },
3544
+ {
3545
+ key: "status",
3546
+ title: "Status",
3547
+ width: 10,
3548
+ color: (p) => pluginStatus(p, theme).color,
3549
+ render: (p) => pluginStatus(p, theme).label
3550
+ },
3551
+ {
3552
+ key: "target",
3553
+ title: "Runs on",
3554
+ width: 7,
3555
+ render: (p) => p.target ?? "\u2014"
3556
+ },
3557
+ {
3558
+ key: "endpoints",
3559
+ title: "Routes",
3560
+ width: 6,
3561
+ align: "right",
3562
+ render: (p) => state.routesAvailable ? String(endpoints(p).length) : "\u2014"
3563
+ },
3564
+ {
3565
+ key: "prefabs",
3566
+ title: "Prefabs",
3567
+ width: 7,
3568
+ align: "right",
3569
+ render: (p) => String((/* @__PURE__ */ new Set([
3570
+ ...p.declaredPrefabs,
3571
+ ...p.usedPrefabs
3572
+ ])).size)
3573
+ }
2658
3574
  ]
2659
3575
  });
2660
3576
  });
@@ -2667,8 +3583,9 @@ function pluginsTab(ui, theme, state, view, transparent, available, installer) {
2667
3583
  pluginDetails(ui, theme, state, shown.installed, endpoints(shown.installed), "1fr", transparent);
2668
3584
  else if (shown.available)
2669
3585
  availableDetails(ui, theme, shown.available, installer);
2670
- if (available)
3586
+ if (available) {
2671
3587
  availablePanel(ui, theme, available, rest, shown.available, view, shown.installed || confirm || shown.available ? Math.min(Math.max(1, rest.length), 6) + 3 : "1fr", transparent);
3588
+ }
2672
3589
  }
2673
3590
  var INSTALL_OUTPUT_LINES = 6;
2674
3591
  var INSTALL_STATUS = {
@@ -2681,59 +3598,103 @@ function installPanel(ui, theme, job) {
2681
3598
  const lines = stripVTControlCharacters(job.output).split(NEWLINE_RE).filter((line) => line.trim() !== "");
2682
3599
  const color = job.status === "failed" ? theme.danger : job.status === "done" ? theme.success : theme.warning;
2683
3600
  ui.panel({ title: `${INSTALL_STATUS[job.status]} ${job.packages.join(", ")}`, size: INSTALL_OUTPUT_LINES + 3 }, (panel) => {
2684
- if (job.status === "failed")
2685
- panel.text([{ text: job.error ?? "The install failed", fg: color }], { size: 1 });
2686
- else if (job.status === "done")
2687
- panel.text([{ text: "The dev servers were restarted with it", fg: color }], { size: 1 });
2688
- else
2689
- panel.spinner({ label: job.status === "restarting" ? "Stopping and starting the dev script" : "Running the package manager", size: 1 });
2690
- panel.log({ entries: lines.slice(-INSTALL_OUTPUT_LINES).map((message) => ({ message })), size: "1fr" });
3601
+ if (job.status === "failed") {
3602
+ panel.text([
3603
+ { text: job.error ?? "The install failed", fg: color }
3604
+ ], { size: 1 });
3605
+ } else if (job.status === "done") {
3606
+ panel.text([
3607
+ { text: "The dev servers were restarted with it", fg: color }
3608
+ ], { size: 1 });
3609
+ } else {
3610
+ panel.spinner({
3611
+ label: job.status === "restarting" ? "Stopping and starting the dev script" : "Running the package manager",
3612
+ size: 1
3613
+ });
3614
+ }
3615
+ panel.log({
3616
+ entries: lines.slice(-INSTALL_OUTPUT_LINES).map((message) => ({ message })),
3617
+ size: "1fr"
3618
+ });
2691
3619
  });
2692
3620
  }
2693
3621
  function confirmInstallPanel(ui, theme, plugin) {
2694
3622
  ui.panel({ title: `Install ${plugin.package}?`, size: "1fr" }, (panel) => {
2695
- panel.text([{ text: "Installing a package runs its code on this machine.", fg: theme.warning, bold: true }], { wrap: true });
3623
+ panel.text([
3624
+ { text: "Installing a package runs its code on this machine.", fg: theme.warning, bold: true }
3625
+ ], { wrap: true });
2696
3626
  panel.text("Its install scripts run right away, and the plugin runs inside your game and game server from then on, with everything they can reach. The list of plugins is not a review of what is on it.", { wrap: true });
2697
3627
  panel.spacer(1);
2698
3628
  panel.text("Check the source before you install it:", { wrap: true });
2699
- panel.text([{ text: ` ${plugin.homepage ?? `https://www.npmjs.com/package/${plugin.package}`}`, fg: theme.primary }], { wrap: true });
3629
+ panel.text([
3630
+ { text: ` ${plugin.homepage ?? `https://www.npmjs.com/package/${plugin.package}`}`, fg: theme.primary }
3631
+ ], { wrap: true });
2700
3632
  panel.spacer(1);
2701
3633
  panel.text(`It is installed with the project's package manager, added to mavonengine.json, and the dev servers are restarted.`, { wrap: true });
2702
3634
  panel.spacer(1);
2703
3635
  panel.text([
2704
- { text: " y ", fg: theme.background, bg: theme.warning, bold: true },
3636
+ {
3637
+ text: " y ",
3638
+ fg: theme.background,
3639
+ bg: theme.warning,
3640
+ bold: true
3641
+ },
2705
3642
  { text: " I checked the source, install it " },
2706
- { text: " n ", fg: theme.background, bg: theme.muted, bold: true },
3643
+ {
3644
+ text: " n ",
3645
+ fg: theme.background,
3646
+ bg: theme.muted,
3647
+ bold: true
3648
+ },
2707
3649
  { text: " Cancel" }
2708
3650
  ], { size: 1 });
2709
3651
  });
2710
3652
  }
2711
3653
  function availableDetails(ui, theme, plugin, installer) {
2712
- ui.panel({ title: plugin.name === plugin.package ? plugin.package : `${plugin.name} (${plugin.package})`, size: "1fr" }, (panel) => {
3654
+ ui.panel({
3655
+ title: plugin.name === plugin.package ? plugin.package : `${plugin.name} (${plugin.package})`,
3656
+ size: "1fr"
3657
+ }, (panel) => {
2713
3658
  if (plugin.description)
2714
3659
  panel.text(plugin.description, { wrap: true });
2715
3660
  panel.keyValues([
2716
3661
  { label: "Status", value: "not installed", color: theme.muted },
2717
- { label: "Runs on", value: plugin.target ? PLUGIN_TARGETS[plugin.target] : "\u2014" },
2718
- { label: "Engine", value: plugin.engine ? `@mavonengine/core ${plugin.engine}` : "\u2014" },
3662
+ {
3663
+ label: "Runs on",
3664
+ value: plugin.target ? PLUGIN_TARGETS[plugin.target] : "\u2014"
3665
+ },
3666
+ {
3667
+ label: "Engine",
3668
+ value: plugin.engine ? `@mavonengine/core ${plugin.engine}` : "\u2014"
3669
+ },
2719
3670
  { label: "Source", value: plugin.homepage ?? `https://www.npmjs.com/package/${plugin.package}`, color: theme.primary }
2720
3671
  ], { spread: true });
2721
3672
  panel.spacer(1);
2722
- if (!installer)
3673
+ if (!installer) {
2723
3674
  panel.label(`Install it with: mavonengine install ${plugin.package}`);
2724
- else if (installer.busy)
3675
+ } else if (installer.busy) {
2725
3676
  panel.label("Another install is running");
2726
- else
2727
- panel.text([{ text: "Press " }, { text: "i", fg: theme.primary, bold: true }, { text: " to install it and restart the dev servers" }], { size: 1 });
3677
+ } else {
3678
+ panel.text([
3679
+ { text: "Press " },
3680
+ { text: "i", fg: theme.primary, bold: true },
3681
+ { text: " to install it and restart the dev servers" }
3682
+ ], { size: 1 });
3683
+ }
2728
3684
  });
2729
3685
  }
2730
3686
  function availablePanel(ui, theme, available, rows, selected, view, size, transparent) {
2731
3687
  const { status, error, plugins } = available.state;
2732
3688
  const loaded = status === "ready" || plugins.length > 0;
2733
3689
  let top = 0;
2734
- ui.panel({ title: loaded ? `Available to install (${rows.length})` : "Available to install", size }, (panel) => {
3690
+ ui.panel({
3691
+ title: loaded ? `Available to install (${rows.length})` : "Available to install",
3692
+ size
3693
+ }, (panel) => {
2735
3694
  if (error) {
2736
- panel.text([{ text: `Could not read the list of plugins: ${error}`, fg: theme.danger }], { wrap: true });
3695
+ panel.text([
3696
+ { text: `Could not read the list of plugins: ${error}`, fg: theme.danger }
3697
+ ], { wrap: true });
2737
3698
  return;
2738
3699
  }
2739
3700
  if (!loaded) {
@@ -2764,30 +3725,61 @@ function availablePanel(ui, theme, available, rows, selected, view, size, transp
2764
3725
  size: "1fr",
2765
3726
  columns: [
2766
3727
  { key: "package", title: "Package", color: theme.primary },
2767
- { key: "target", title: "Runs on", width: 7, render: (p) => p.target ?? "\u2014" },
2768
- { key: "description", title: "What it is", color: theme.muted, render: (p) => p.description ?? (p.name === p.package ? "" : p.name) }
3728
+ {
3729
+ key: "target",
3730
+ title: "Runs on",
3731
+ width: 7,
3732
+ render: (p) => p.target ?? "\u2014"
3733
+ },
3734
+ {
3735
+ key: "description",
3736
+ title: "What it is",
3737
+ color: theme.muted,
3738
+ render: (p) => p.description ?? (p.name === p.package ? "" : p.name)
3739
+ }
2769
3740
  ]
2770
3741
  });
2771
3742
  });
2772
3743
  }
2773
3744
  function pluginDetails(ui, theme, state, plugin, endpoints, size, transparent) {
2774
3745
  const status = pluginStatus(plugin, theme);
2775
- const prefabs = [.../* @__PURE__ */ new Set([...plugin.declaredPrefabs, ...plugin.usedPrefabs])];
3746
+ const prefabs = [
3747
+ .../* @__PURE__ */ new Set([
3748
+ ...plugin.declaredPrefabs,
3749
+ ...plugin.usedPrefabs
3750
+ ])
3751
+ ];
2776
3752
  ui.panel({ title: plugin.package, size }, (panel) => {
2777
3753
  if (plugin.description)
2778
3754
  panel.text(plugin.description, { wrap: true });
2779
- if (plugin.problem)
2780
- panel.text([{ text: plugin.problem, fg: theme.danger }], { wrap: true });
3755
+ if (plugin.problem) {
3756
+ panel.text([
3757
+ { text: plugin.problem, fg: theme.danger }
3758
+ ], { wrap: true });
3759
+ }
2781
3760
  panel.keyValues([
2782
3761
  { label: "Version", value: plugin.version ?? "\u2014" },
2783
3762
  { label: "Status", value: status.label, color: status.color },
2784
- { label: "Runs on", value: plugin.target ? PLUGIN_TARGETS[plugin.target] : "\u2014" },
3763
+ {
3764
+ label: "Runs on",
3765
+ value: plugin.target ? PLUGIN_TARGETS[plugin.target] : "\u2014"
3766
+ },
2785
3767
  // A client plugin has nothing to run here
2786
- plugin.target === "client" ? { label: "On this server", value: "nothing to run", color: theme.muted } : { label: "On this server", value: plugin.runningOnServer ? "running" : "not running", color: plugin.runningOnServer ? theme.success : theme.warning },
2787
- { label: "Engine", value: plugin.engine ? `@mavonengine/core ${plugin.engine}` : "\u2014" },
3768
+ plugin.target === "client" ? { label: "On this server", value: "nothing to run", color: theme.muted } : {
3769
+ label: "On this server",
3770
+ value: plugin.runningOnServer ? "running" : "not running",
3771
+ color: plugin.runningOnServer ? theme.success : theme.warning
3772
+ },
3773
+ {
3774
+ label: "Engine",
3775
+ value: plugin.engine ? `@mavonengine/core ${plugin.engine}` : "\u2014"
3776
+ },
2788
3777
  { label: "License", value: plugin.license ?? "\u2014" },
2789
3778
  // Used ones ship their assets in a release
2790
- { label: "Prefabs", value: prefabs.length ? prefabs.map((name) => plugin.usedPrefabs.includes(name) ? `${name} (used)` : name).join(", ") : "none" }
3779
+ {
3780
+ label: "Prefabs",
3781
+ value: prefabs.length ? prefabs.map((name) => plugin.usedPrefabs.includes(name) ? `${name} (used)` : name).join(", ") : "none"
3782
+ }
2791
3783
  ], { spread: true });
2792
3784
  panel.spacer(1);
2793
3785
  if (state.routesAvailable !== true) {
@@ -2805,9 +3797,20 @@ function pluginDetails(ui, theme, state, plugin, endpoints, size, transparent) {
2805
3797
  zebra: !transparent,
2806
3798
  size: "1fr",
2807
3799
  columns: [
2808
- { key: "method", title: "Method", width: 7, color: (r) => methodColor(r.method, theme) },
3800
+ {
3801
+ key: "method",
3802
+ title: "Method",
3803
+ width: 7,
3804
+ color: (r) => methodColor(r.method, theme)
3805
+ },
2809
3806
  { key: "path", title: "Path" },
2810
- { key: "devOnly", title: "Served in", width: 10, color: (r) => r.devOnly ? theme.warning : theme.success, render: routeEnvironment }
3807
+ {
3808
+ key: "devOnly",
3809
+ title: "Served in",
3810
+ width: 10,
3811
+ color: (r) => r.devOnly ? theme.warning : theme.success,
3812
+ render: routeEnvironment
3813
+ }
2811
3814
  ]
2812
3815
  });
2813
3816
  });
@@ -2832,15 +3835,23 @@ function databaseTab(ui, theme, state, view, transparent) {
2832
3835
  const notice = state.databaseAvailable === false ? "Not available: the server runs a @mavonengine/core release without GET /api/game/database" : !database ? state.databaseError ?? "Asking the server for its database\u2026" : !database.provider ? "The project has no database plugin. Add one with: mavonengine install @mavonengine/sqlite" : database.tables.length === 0 ? `No tables yet in the database of ${database.provider}` : null;
2833
3836
  if (notice) {
2834
3837
  ui.panel({ title: "Database", size: "1fr" }, (panel) => {
2835
- panel.text([{ text: notice, fg: state.databaseError && !database ? theme.danger : theme.muted }]);
3838
+ panel.text([
3839
+ {
3840
+ text: notice,
3841
+ fg: state.databaseError && !database ? theme.danger : theme.muted
3842
+ }
3843
+ ]);
2836
3844
  });
2837
3845
  return;
2838
3846
  }
2839
3847
  const { tables, migrations } = database;
2840
3848
  const shown = selectedTable(view, database);
2841
3849
  let top = 0;
2842
- if (state.databaseError)
2843
- ui.text([{ text: ` ${state.databaseError} \u2014 showing what was read last`, fg: theme.danger }], { size: 1 });
3850
+ if (state.databaseError) {
3851
+ ui.text([
3852
+ { text: ` ${state.databaseError} \u2014 showing what was read last`, fg: theme.danger }
3853
+ ], { size: 1 });
3854
+ }
2844
3855
  ui.panel({ title: `Tables in ${database.provider} (${tables.length})`, size: Math.min(tables.length, 8) + 3 }, (panel) => {
2845
3856
  panel.table({
2846
3857
  rows: tables,
@@ -2864,9 +3875,26 @@ function databaseTab(ui, theme, state, view, transparent) {
2864
3875
  size: "1fr",
2865
3876
  columns: [
2866
3877
  { key: "name", title: "Table" },
2867
- { key: "plugin", title: "Plugin", color: (t) => t.plugin ? theme.primary : theme.muted, render: tableOwner },
2868
- { key: "rows", title: "Rows", width: 10, align: "right", render: (t) => t.rows === null ? "?" : t.rows.toLocaleString("en-US") },
2869
- { key: "columns", title: "Columns", width: 7, align: "right", render: (t) => String(t.columns.length) }
3878
+ {
3879
+ key: "plugin",
3880
+ title: "Plugin",
3881
+ color: (t) => t.plugin ? theme.primary : theme.muted,
3882
+ render: tableOwner
3883
+ },
3884
+ {
3885
+ key: "rows",
3886
+ title: "Rows",
3887
+ width: 10,
3888
+ align: "right",
3889
+ render: (t) => t.rows === null ? "?" : t.rows.toLocaleString("en-US")
3890
+ },
3891
+ {
3892
+ key: "columns",
3893
+ title: "Columns",
3894
+ width: 7,
3895
+ align: "right",
3896
+ render: (t) => String(t.columns.length)
3897
+ }
2870
3898
  ]
2871
3899
  });
2872
3900
  });
@@ -2876,7 +3904,10 @@ function databaseTab(ui, theme, state, view, transparent) {
2876
3904
  for (const m of migrations.slice(0, 4)) {
2877
3905
  const names = m.applied.map((a) => a.name).join(", ") || "none";
2878
3906
  panel.text([
2879
- { text: `${m.plugin ?? m.table} `, fg: m.plugin ? theme.primary : theme.muted },
3907
+ {
3908
+ text: `${m.plugin ?? m.table} `,
3909
+ fg: m.plugin ? theme.primary : theme.muted
3910
+ },
2880
3911
  { text: `${m.applied.length} ran: `, fg: theme.muted },
2881
3912
  { text: names }
2882
3913
  ]);
@@ -2891,8 +3922,11 @@ function tableRowsPanel(ui, theme, state, view, table, transparent) {
2891
3922
  const shownRows = page ? Math.min(page.rows.length, view.tableVisibleRows || page.rows.length) : 0;
2892
3923
  const range = page && shownRows ? `rows ${(page.offset + 1).toLocaleString("en-US")}\u2013${(page.offset + shownRows).toLocaleString("en-US")} of ${total.toLocaleString("en-US")}` : `${total.toLocaleString("en-US")} rows`;
2893
3924
  ui.panel({ title: `${table.name} \xB7 ${range}${detail?.status === "loading" ? " \xB7 loading\u2026" : ""}`, size: "1fr" }, (panel) => {
2894
- if (detail?.status === "error")
2895
- panel.text([{ text: detail.error ?? "Could not load the rows", fg: theme.danger }], { size: 1 });
3925
+ if (detail?.status === "error") {
3926
+ panel.text([
3927
+ { text: detail.error ?? "Could not load the rows", fg: theme.danger }
3928
+ ], { size: 1 });
3929
+ }
2896
3930
  if (!page) {
2897
3931
  if (detail?.status !== "error")
2898
3932
  panel.label("Loading the rows\u2026");
@@ -2967,8 +4001,14 @@ function parseDashboardArgs(args, env = process3.env) {
2967
4001
  const intervalMs = Number(values.interval);
2968
4002
  if (!Number.isInteger(intervalMs) || intervalMs < 100)
2969
4003
  throw new UsageError("--interval must be a whole number of ms, at least 100");
2970
- if (values.sim)
2971
- return { source: simulatedSource(), intervalMs, theme: values.theme, transparent: values.transparent };
4004
+ if (values.sim) {
4005
+ return {
4006
+ source: simulatedSource(),
4007
+ intervalMs,
4008
+ theme: values.theme,
4009
+ transparent: values.transparent
4010
+ };
4011
+ }
2972
4012
  let url = values.url;
2973
4013
  if (!url) {
2974
4014
  const port = Number(values.port);
@@ -2983,7 +4023,13 @@ function parseDashboardArgs(args, env = process3.env) {
2983
4023
  throw new UsageError(`Invalid --url: ${url}`);
2984
4024
  }
2985
4025
  const token = values.token ?? env.MAVONENGINE_METRICS_TOKEN ?? env.MAVONENGINE_ADMIN_TOKEN;
2986
- return { source: httpSource({ url, token }), clientUrl: new URL("/", url).href, intervalMs, theme: values.theme, transparent: values.transparent };
4026
+ return {
4027
+ source: httpSource({ url, token }),
4028
+ clientUrl: new URL("/", url).href,
4029
+ intervalMs,
4030
+ theme: values.theme,
4031
+ transparent: values.transparent
4032
+ };
2987
4033
  }
2988
4034
  async function runDashboard(options, signal) {
2989
4035
  const { createApp } = await import("@profullstack/hqtui");
@@ -2992,7 +4038,11 @@ async function runDashboard(options, signal) {
2992
4038
  startupIntervalMs: options.startup ? STARTUP_POLL_MS : void 0
2993
4039
  });
2994
4040
  const view = initialViewState();
2995
- const app = await createApp({ fps: 15, theme: readableTheme(options.theme), paintBackground: !options.transparent });
4041
+ const app = await createApp({
4042
+ fps: 15,
4043
+ theme: readableTheme(options.theme),
4044
+ paintBackground: !options.transparent
4045
+ });
2996
4046
  const available = new AvailablePlugins();
2997
4047
  available.onChange(() => app.invalidate());
2998
4048
  const { installer } = options;
@@ -3122,7 +4172,7 @@ import process4 from "process";
3122
4172
  import { Readable, Transform } from "stream";
3123
4173
  import { pipeline } from "stream/promises";
3124
4174
  import AdmZip from "adm-zip";
3125
- var TEMPLATE_URL = "https://github.com/MavonEngine/Core/archive/refs/tags/0.0.21-alpha.zip";
4175
+ var TEMPLATE_URL = "https://github.com/MavonEngine/Core/archive/refs/tags/0.0.22-alpha.zip";
3126
4176
  var TEMPLATE_SUBPATH = "packages/multiplayer-template";
3127
4177
  var PROJECT_NAME_RE = /^[\w@./-][\w@./\- ]*$/;
3128
4178
  var NAME_SEPARATORS_RE = /[-_\s]+/;
@@ -3200,10 +4250,11 @@ function runCommand(command, args, cwd, { report, signal }) {
3200
4250
  reject(err.code === "ENOENT" ? new Error(`'${command}' was not found on your PATH`) : err);
3201
4251
  });
3202
4252
  child.on("exit", (code, exitSignal) => {
3203
- if (code === 0)
4253
+ if (code === 0) {
3204
4254
  resolvePromise();
3205
- else
4255
+ } else {
3206
4256
  reject(new Error(`'${command} ${args.join(" ")}' ${code === null ? `was stopped by ${exitSignal}` : `exited with code ${code}`}`));
4257
+ }
3207
4258
  });
3208
4259
  });
3209
4260
  }
@@ -3292,7 +4343,12 @@ function parseInstallArgs(args, cwd = process5.cwd()) {
3292
4343
  throw new UsageError(`which package? e.g. mavonengine install my-plugin
3293
4344
 
3294
4345
  ${INSTALL_HELP}`);
3295
- return { cwd: resolve3(cwd, values.cwd ?? "."), packages: positionals, yes: values.yes, register: values.register };
4346
+ return {
4347
+ cwd: resolve3(cwd, values.cwd ?? "."),
4348
+ packages: positionals,
4349
+ yes: values.yes,
4350
+ register: values.register
4351
+ };
3296
4352
  }
3297
4353
  function packageNameFromSpec(spec, root) {
3298
4354
  const localPath = spec.startsWith("file:") ? spec.slice("file:".length) : LOCAL_PATH_RE.test(spec) ? spec : void 0;
@@ -3309,14 +4365,20 @@ function packageNameFromSpec(spec, root) {
3309
4365
  return PACKAGE_SPEC_RE2.exec(spec)?.[1];
3310
4366
  }
3311
4367
  function installArgs(pm, packages) {
3312
- return [pm === "npm" ? "install" : "add", ...packages];
4368
+ return [
4369
+ pm === "npm" ? "install" : "add",
4370
+ ...packages
4371
+ ];
3313
4372
  }
3314
4373
  function dependencyNames(root) {
3315
4374
  const path = join3(root, "package.json");
3316
4375
  if (!existsSync3(path))
3317
4376
  return /* @__PURE__ */ new Map();
3318
4377
  const pkg = JSON.parse(readFileSync3(path, "utf8"));
3319
- return new Map(Object.entries({ ...pkg.devDependencies, ...pkg.dependencies }));
4378
+ return new Map(Object.entries({
4379
+ ...pkg.devDependencies,
4380
+ ...pkg.dependencies
4381
+ }));
3320
4382
  }
3321
4383
  function installedNames(specs, root, before, after) {
3322
4384
  const names = specs.map((spec) => packageNameFromSpec(spec, root)).filter((name) => !!name);
@@ -3324,7 +4386,9 @@ function installedNames(specs, root, before, after) {
3324
4386
  if (before.get(name) !== version3)
3325
4387
  names.push(name);
3326
4388
  }
3327
- return [...new Set(names)];
4389
+ return [
4390
+ ...new Set(names)
4391
+ ];
3328
4392
  }
3329
4393
  function describePlugin(plugin, engineVersion) {
3330
4394
  const { manifest } = plugin;
@@ -3332,8 +4396,9 @@ function describePlugin(plugin, engineVersion) {
3332
4396
  const prefabs = Object.keys(manifest.assets?.prefabs ?? {});
3333
4397
  if (prefabs.length)
3334
4398
  lines.push(` Prefabs: ${prefabs.join(", ")}. Their assets ship in the release once you place them in the editor`);
3335
- if (manifest.engine)
4399
+ if (manifest.engine) {
3336
4400
  lines.push(` Made for @mavonengine/core ${manifest.engine}${engineVersion ? `, you have ${engineVersion}` : ""}`);
4401
+ }
3337
4402
  return `${lines.join("\n")}
3338
4403
  `;
3339
4404
  }
@@ -3343,8 +4408,11 @@ function confirmOnTerminal(question) {
3343
4408
  }
3344
4409
  var terminalIO = {
3345
4410
  run: (command, args, cwd) => runCommand(command, args, cwd, {
3346
- report: { step: () => {
3347
- }, output: (chunk) => process5.stdout.write(chunk) }
4411
+ report: {
4412
+ step: () => {
4413
+ },
4414
+ output: (chunk) => process5.stdout.write(chunk)
4415
+ }
3348
4416
  }),
3349
4417
  confirm: confirmOnTerminal,
3350
4418
  get interactive() {
@@ -3427,9 +4495,19 @@ var InstallRefused = class extends Error {
3427
4495
  reason;
3428
4496
  };
3429
4497
  function installWithCli(root, packages, write) {
3430
- return runInstallCommand({ cwd: root, packages, yes: true, register: true }, {
3431
- run: (command, args, cwd) => runCommand(command, args, cwd, { report: { step: () => {
3432
- }, output: write } }),
4498
+ return runInstallCommand({
4499
+ cwd: root,
4500
+ packages,
4501
+ yes: true,
4502
+ register: true
4503
+ }, {
4504
+ run: (command, args, cwd) => runCommand(command, args, cwd, {
4505
+ report: {
4506
+ step: () => {
4507
+ },
4508
+ output: write
4509
+ }
4510
+ }),
3433
4511
  // Whoever asked for the install already agreed to it
3434
4512
  confirm: async () => true,
3435
4513
  interactive: false,
@@ -3463,7 +4541,12 @@ var PluginInstaller = class {
3463
4541
  throw new InstallRefused(invalid, "invalid");
3464
4542
  if (this.busy)
3465
4543
  throw new InstallRefused(`Still installing ${this.job.packages.join(", ")}`, "busy");
3466
- const job = { id: this.nextId++, packages: [...packages], status: "installing", output: "" };
4544
+ const job = {
4545
+ id: this.nextId++,
4546
+ packages: [...packages],
4547
+ status: "installing",
4548
+ output: ""
4549
+ };
3467
4550
  this.job = job;
3468
4551
  this.finished = this.run(job);
3469
4552
  return job;
@@ -3540,7 +4623,9 @@ function startDevControl(installer) {
3540
4623
  return;
3541
4624
  }
3542
4625
  try {
3543
- reply(202, { job: installer.start(packages) });
4626
+ reply(202, {
4627
+ job: installer.start(packages)
4628
+ });
3544
4629
  } catch (err) {
3545
4630
  if (!(err instanceof InstallRefused))
3546
4631
  throw err;
@@ -3638,7 +4723,10 @@ function toDevOptions(values, cwd, env) {
3638
4723
  dashboard = parseDashboardArgs(dashboardArgs, env);
3639
4724
  dashboard.openBrowser = values.open && canOpenBrowserHere(env);
3640
4725
  }
3641
- return { cwd: resolve4(cwd, values.cwd ?? "."), dashboard };
4726
+ return {
4727
+ cwd: resolve4(cwd, values.cwd ?? "."),
4728
+ dashboard
4729
+ };
3642
4730
  }
3643
4731
  function readPackageJson(dir) {
3644
4732
  const path = join4(dir, "package.json");
@@ -3670,7 +4758,10 @@ function checkDevScript(root, env = process6.env) {
3670
4758
  function findProjectRoot(start) {
3671
4759
  for (let dir = resolve4(start); ; dir = dirname3(dir)) {
3672
4760
  const pkg = readPackageJson(dir);
3673
- const deps = { ...pkg?.dependencies, ...pkg?.devDependencies };
4761
+ const deps = {
4762
+ ...pkg?.dependencies,
4763
+ ...pkg?.devDependencies
4764
+ };
3674
4765
  if ("@mavonengine/core" in deps && devScriptOf(pkg))
3675
4766
  return dir;
3676
4767
  if (dirname3(dir) === dir)
@@ -3705,7 +4796,10 @@ function processTree(pid) {
3705
4796
  if (process6.platform === "win32")
3706
4797
  return [];
3707
4798
  try {
3708
- return [pid, ...descendants(pid, execFileSync("ps", ["-A", "-o", "pid=,ppid="], { encoding: "utf8" }))];
4799
+ return [
4800
+ pid,
4801
+ ...descendants(pid, execFileSync("ps", ["-A", "-o", "pid=,ppid="], { encoding: "utf8" }))
4802
+ ];
3709
4803
  } catch {
3710
4804
  return [pid];
3711
4805
  }
@@ -3734,7 +4828,12 @@ async function waitForExit(pids, timeoutMs) {
3734
4828
  function killTree(pid, signal) {
3735
4829
  if (process6.platform === "win32") {
3736
4830
  try {
3737
- execFileSync("taskkill", ["/pid", String(pid), "/T", "/F"], { stdio: "ignore" });
4831
+ execFileSync("taskkill", [
4832
+ "/pid",
4833
+ String(pid),
4834
+ "/T",
4835
+ "/F"
4836
+ ], { stdio: "ignore" });
3738
4837
  } catch {
3739
4838
  }
3740
4839
  return;
@@ -3746,7 +4845,11 @@ function startDev(root, { capture = false, env = {} } = {}) {
3746
4845
  const script = checkDevScript(root);
3747
4846
  const child = spawn3(pm, ["run", script], {
3748
4847
  cwd: root,
3749
- env: { ...process6.env, ...env, [DEV_ENV_FLAG]: "1" },
4848
+ env: {
4849
+ ...process6.env,
4850
+ ...env,
4851
+ [DEV_ENV_FLAG]: "1"
4852
+ },
3750
4853
  stdio: capture ? ["ignore", "pipe", "pipe"] : "inherit",
3751
4854
  // npm, pnpm and yarn are .cmd shims on Windows
3752
4855
  shell: process6.platform === "win32"
@@ -3803,7 +4906,11 @@ function startDev(root, { capture = false, env = {} } = {}) {
3803
4906
  }
3804
4907
  return exited;
3805
4908
  };
3806
- return { exited, stop, output: () => output };
4909
+ return {
4910
+ exited,
4911
+ stop,
4912
+ output: () => output
4913
+ };
3807
4914
  }
3808
4915
  function startDevSession(root, options = {}) {
3809
4916
  let dev = startDev(root, options);
@@ -3836,7 +4943,10 @@ function startDevSession(root, options = {}) {
3836
4943
  }
3837
4944
  async function startDevWithInstaller(root, { capture = false, onOutput } = {}) {
3838
4945
  let session;
3839
- const installer = new PluginInstaller({ root, restart: async () => session?.restart() });
4946
+ const installer = new PluginInstaller({
4947
+ root,
4948
+ restart: async () => session?.restart()
4949
+ });
3840
4950
  const control = await startDevControl(installer);
3841
4951
  let written = 0;
3842
4952
  installer.onChange((job) => {
@@ -3851,10 +4961,16 @@ async function startDevWithInstaller(root, { capture = false, onOutput } = {}) {
3851
4961
  await control.close();
3852
4962
  throw err;
3853
4963
  }
3854
- return { session, installer, close: () => control.close() };
4964
+ return {
4965
+ session,
4966
+ installer,
4967
+ close: () => control.close()
4968
+ };
3855
4969
  }
3856
4970
  async function runDev(root) {
3857
- const { session, close } = await startDevWithInstaller(root, { onOutput: (text) => process6.stdout.write(text) });
4971
+ const { session, close } = await startDevWithInstaller(root, {
4972
+ onOutput: (text) => process6.stdout.write(text)
4973
+ });
3858
4974
  try {
3859
4975
  return await session.exited;
3860
4976
  } finally {
@@ -3864,7 +4980,10 @@ async function runDev(root) {
3864
4980
  async function runDevWithDashboard(root, dashboard) {
3865
4981
  const { session: dev, installer, close } = await startDevWithInstaller(root, { capture: true });
3866
4982
  const engineVersion = installedEngineVersion(root);
3867
- const startup = () => ({ engineVersion, output: dev.output() });
4983
+ const startup = () => ({
4984
+ engineVersion,
4985
+ output: dev.output()
4986
+ });
3868
4987
  const devExited = new AbortController();
3869
4988
  dev.exited.then(() => devExited.abort(), () => devExited.abort());
3870
4989
  let quit = false;
@@ -3919,7 +5038,9 @@ function parseBuildArgs(args, cwd = process7.cwd()) {
3919
5038
  });
3920
5039
  if (values.help)
3921
5040
  return "help";
3922
- return { cwd: resolve5(cwd, values.cwd ?? ".") };
5041
+ return {
5042
+ cwd: resolve5(cwd, values.cwd ?? ".")
5043
+ };
3923
5044
  }
3924
5045
  function summarizeReleaseAssets(root, assets, warnings) {
3925
5046
  const plugins = readConfig(root).plugins;
@@ -4005,7 +5126,10 @@ function parseCreateArgs(args, cwd = process8.cwd(), env = process8.env) {
4005
5126
  const projectName = positionals[0]?.trim() || void 0;
4006
5127
  if (projectName)
4007
5128
  checkProjectName(projectName);
4008
- return { ...toDevOptions(values, cwd, env), projectName };
5129
+ return {
5130
+ ...toDevOptions(values, cwd, env),
5131
+ projectName
5132
+ };
4009
5133
  }
4010
5134
  function checkProjectName(name) {
4011
5135
  if (!PROJECT_NAME_RE.test(name))
@@ -4041,7 +5165,12 @@ async function runCreateWithDashboard(projectName, parentDir, dashboard) {
4041
5165
  const setup = new AbortController();
4042
5166
  const done = new AbortController();
4043
5167
  const work = (async () => {
4044
- const dir = await createProject({ projectName, parentDir, report, signal: setup.signal });
5168
+ const dir = await createProject({
5169
+ projectName,
5170
+ parentDir,
5171
+ report,
5172
+ signal: setup.signal
5173
+ });
4045
5174
  setup.signal.throwIfAborted();
4046
5175
  engineVersion = installedEngineVersion(dir);
4047
5176
  label = "Starting the game server\u2026";
@@ -4049,10 +5178,22 @@ async function runCreateWithDashboard(projectName, parentDir, dashboard) {
4049
5178
  return dev.exited;
4050
5179
  })();
4051
5180
  work.then(() => done.abort(), () => done.abort());
4052
- const startup = () => dev ? { engineVersion, output: dev.output() } : { engineVersion, label, output, outputTitle: "Setup" };
5181
+ const startup = () => dev ? {
5182
+ engineVersion,
5183
+ output: dev.output()
5184
+ } : {
5185
+ engineVersion,
5186
+ label,
5187
+ output,
5188
+ outputTitle: "Setup"
5189
+ };
4053
5190
  let quit = false;
4054
5191
  try {
4055
- await runDashboard({ ...dashboard, source: gatedSource(dashboard.source, () => dev !== void 0), startup }, done.signal);
5192
+ await runDashboard({
5193
+ ...dashboard,
5194
+ source: gatedSource(dashboard.source, () => dev !== void 0),
5195
+ startup
5196
+ }, done.signal);
4056
5197
  } finally {
4057
5198
  quit = !done.signal.aborted;
4058
5199
  if (quit) {
@@ -4144,7 +5285,14 @@ var CONFIG = "mavonengine.json";
4144
5285
  var RUNS_MAVONENGINE_DEV_RE2 = /\bmavonengine\s+dev\b/;
4145
5286
  var TITLE_RE = /(<title[^>]*>)([\s\S]*?)(<\/title>)/i;
4146
5287
  var ENTITY_RE = /&(amp|lt|gt|quot|#39|apos);/g;
4147
- var ENTITIES = { "amp": "&", "lt": "<", "gt": ">", "quot": '"', "#39": "'", "apos": "'" };
5288
+ var ENTITIES = {
5289
+ "amp": "&",
5290
+ "lt": "<",
5291
+ "gt": ">",
5292
+ "quot": '"',
5293
+ "#39": "'",
5294
+ "apos": "'"
5295
+ };
4148
5296
  var APP_NAME_PLACEHOLDER = "%MAVONENGINE_APP_NAME%";
4149
5297
  var INDEX_HTML = ["client/index.html", "index.html"];
4150
5298
  var devScript = {
@@ -4157,7 +5305,12 @@ var devScript = {
4157
5305
  },
4158
5306
  run({ files, versions }) {
4159
5307
  const pkg = files.readJson("package.json");
4160
- pkg.scripts = Object.fromEntries(Object.entries(pkg.scripts).flatMap(([name, script]) => name === "dev" ? [["dev", "mavonengine dev"], ["dev:server", script]] : [[name, script]]));
5308
+ pkg.scripts = Object.fromEntries(Object.entries(pkg.scripts).flatMap(([name, script]) => name === "dev" ? [
5309
+ ["dev", "mavonengine dev"],
5310
+ ["dev:server", script]
5311
+ ] : [
5312
+ [name, script]
5313
+ ]));
4161
5314
  if (!pkg.dependencies?.["@mavonengine/cli"] && !pkg.devDependencies?.["@mavonengine/cli"]) {
4162
5315
  const devDependencies = { ...pkg.devDependencies, "@mavonengine/cli": versions.cli ?? "latest" };
4163
5316
  pkg.devDependencies = Object.fromEntries(Object.entries(devDependencies).sort(([a], [b]) => a.localeCompare(b)));
@@ -4169,7 +5322,9 @@ function titleFiles(files) {
4169
5322
  return INDEX_HTML.flatMap((path) => {
4170
5323
  const html = files.read(path);
4171
5324
  const match = html === void 0 ? void 0 : TITLE_RE.exec(html);
4172
- return match && !match[2].includes(APP_NAME_PLACEHOLDER) ? [{ path, html, title: match[2] }] : [];
5325
+ return match && !match[2].includes(APP_NAME_PLACEHOLDER) ? [
5326
+ { path, html, title: match[2] }
5327
+ ] : [];
4173
5328
  });
4174
5329
  }
4175
5330
  var appNameTitle = {
@@ -4243,7 +5398,11 @@ var ProjectFiles = class {
4243
5398
  }
4244
5399
  /** What `commit()` would write, in the order the files were first changed */
4245
5400
  changes() {
4246
- return Array.from(this.staged, ([path, after]) => ({ path, before: this.onDisk(path), after }));
5401
+ return Array.from(this.staged, ([path, after]) => ({
5402
+ path,
5403
+ before: this.onDisk(path),
5404
+ after
5405
+ }));
4247
5406
  }
4248
5407
  /** Write every change to disk */
4249
5408
  commit() {
@@ -4285,7 +5444,10 @@ function applyMigrations(ctx, pending, migrations = MIGRATIONS) {
4285
5444
  const recorded = new Set(recordedMigrations(ctx.files));
4286
5445
  const ids = migrationsFor(ctx.versions.core, migrations).map((migration) => migration.id);
4287
5446
  if (ids.some((id) => !recorded.has(id))) {
4288
- config.migrations = [...recorded, ...ids.filter((id) => !recorded.has(id))];
5447
+ config.migrations = [
5448
+ ...recorded,
5449
+ ...ids.filter((id) => !recorded.has(id))
5450
+ ];
4289
5451
  ctx.files.writeJson(CONFIG2, config);
4290
5452
  }
4291
5453
  return ctx.files.changes();
@@ -4307,9 +5469,23 @@ async function loadMigrations(root) {
4307
5469
  }
4308
5470
 
4309
5471
  // src/doctor/checks.ts
4310
- var GROUPS = ["Environment", CONFIG_FILE, "Plugins", "Migrations"];
5472
+ var GROUPS = [
5473
+ "Environment",
5474
+ CONFIG_FILE,
5475
+ "Plugins",
5476
+ "Migrations"
5477
+ ];
4311
5478
  var CLI_NODE_RANGE = ">=24";
4312
- var TOP_LEVEL_KEYS = /* @__PURE__ */ new Set(["$schema", "plugins", "database", "auth", "notifications", "appUrl", "appName", "migrations"]);
5479
+ var TOP_LEVEL_KEYS = /* @__PURE__ */ new Set([
5480
+ "$schema",
5481
+ "plugins",
5482
+ "database",
5483
+ "auth",
5484
+ "notifications",
5485
+ "appUrl",
5486
+ "appName",
5487
+ "migrations"
5488
+ ]);
4313
5489
  var PROVIDER_KEYS = ["database", "auth", "notifications"];
4314
5490
  var PLAIN_SPEC_RE = /^[\s\d.<>=^~x*|-]+$/i;
4315
5491
  function readJson(path) {
@@ -4341,8 +5517,18 @@ async function checkEnvironment(ctx) {
4341
5517
  const coreJson = installedPackageJson(ctx.root, "@mavonengine/core");
4342
5518
  const needs = [CLI_NODE_RANGE, coreJson?.engines?.node].filter((range) => typeof range === "string" && validRange(range));
4343
5519
  const unmet = needs.filter((range) => !satisfies(ctx.nodeVersion, range));
4344
- add(unmet.length ? { level: "error", label: `Node ${ctx.nodeVersion}`, detail: `needs ${unmet.join(" and ")}`, fix: "install a newer Node, e.g. from https://nodejs.org" } : { level: "ok", label: `Node ${ctx.nodeVersion}`, detail: `needs ${[...new Set(needs)].join(" and ")}` });
4345
- const declared = { ...ctx.packageJson.devDependencies, ...ctx.packageJson.dependencies };
5520
+ add(unmet.length ? {
5521
+ level: "error",
5522
+ label: `Node ${ctx.nodeVersion}`,
5523
+ detail: `needs ${unmet.join(" and ")}`,
5524
+ fix: "install a newer Node, e.g. from https://nodejs.org"
5525
+ } : { level: "ok", label: `Node ${ctx.nodeVersion}`, detail: `needs ${[
5526
+ ...new Set(needs)
5527
+ ].join(" and ")}` });
5528
+ const declared = {
5529
+ ...ctx.packageJson.devDependencies,
5530
+ ...ctx.packageJson.dependencies
5531
+ };
4346
5532
  const packages = Object.keys(declared).filter((name) => name.startsWith("@mavonengine/"));
4347
5533
  const engine = packages.filter((name) => {
4348
5534
  const json2 = installedPackageJson(ctx.root, name);
@@ -4354,11 +5540,21 @@ async function checkEnvironment(ctx) {
4354
5540
  const json2 = installedPackageJson(ctx.root, name);
4355
5541
  const version3 = typeof json2?.version === "string" ? json2.version : void 0;
4356
5542
  if (!version3) {
4357
- add({ level: "error", label: name, detail: `in package.json (${spec}) but not installed`, fix: installCommand(ctx.packageManager) });
5543
+ add({
5544
+ level: "error",
5545
+ label: name,
5546
+ detail: `in package.json (${spec}) but not installed`,
5547
+ fix: installCommand(ctx.packageManager)
5548
+ });
4358
5549
  continue;
4359
5550
  }
4360
5551
  if (PLAIN_SPEC_RE.test(spec) && validRange(spec) && !satisfies(version3, spec)) {
4361
- add({ level: "error", label: `${name} ${version3}`, detail: `package.json asks for ${spec}`, fix: installCommand(ctx.packageManager) });
5552
+ add({
5553
+ level: "error",
5554
+ label: `${name} ${version3}`,
5555
+ detail: `package.json asks for ${spec}`,
5556
+ fix: installCommand(ctx.packageManager)
5557
+ });
4362
5558
  continue;
4363
5559
  }
4364
5560
  const latest = packuments.get(name)?.latest;
@@ -4367,21 +5563,42 @@ async function checkEnvironment(ctx) {
4367
5563
  else
4368
5564
  add({ level: "ok", label: `${name} ${version3}` });
4369
5565
  }
4370
- if (!packages.includes("@mavonengine/core"))
4371
- add({ level: "error", label: "@mavonengine/core", detail: "not in package.json", fix: installCommand(ctx.packageManager, "@mavonengine/core") });
5566
+ if (!packages.includes("@mavonengine/core")) {
5567
+ add({
5568
+ level: "error",
5569
+ label: "@mavonengine/core",
5570
+ detail: "not in package.json",
5571
+ fix: installCommand(ctx.packageManager, "@mavonengine/core")
5572
+ });
5573
+ }
4372
5574
  return findings;
4373
5575
  }
4374
5576
  function registryFinding(npm) {
4375
- if (npm?.unreachable)
4376
- return { group: "Environment", level: "warn", label: "npm registry", detail: `${npm.unreachable}, so newer versions weren't looked for`, fix: "check the connection, or pass --offline" };
5577
+ if (npm?.unreachable) {
5578
+ return {
5579
+ group: "Environment",
5580
+ level: "warn",
5581
+ label: "npm registry",
5582
+ detail: `${npm.unreachable}, so newer versions weren't looked for`,
5583
+ fix: "check the connection, or pass --offline"
5584
+ };
5585
+ }
4377
5586
  }
4378
5587
  function checkConfig(root, env = {}) {
4379
5588
  const findings = [];
4380
5589
  const add = (finding) => findings.push({ group: CONFIG_FILE, ...finding });
4381
5590
  const path = configPath(root);
4382
5591
  if (!existsSync9(path)) {
4383
- add({ level: "info", label: CONFIG_FILE, detail: "there is none, so no plugins are loaded", fix: "mavonengine install <plugin> creates it" });
4384
- return { findings, config: { plugins: {} } };
5592
+ add({
5593
+ level: "info",
5594
+ label: CONFIG_FILE,
5595
+ detail: "there is none, so no plugins are loaded",
5596
+ fix: "mavonengine install <plugin> creates it"
5597
+ });
5598
+ return {
5599
+ findings,
5600
+ config: { plugins: {} }
5601
+ };
4385
5602
  }
4386
5603
  let raw;
4387
5604
  try {
@@ -4407,10 +5624,20 @@ function checkConfig(root, env = {}) {
4407
5624
  }
4408
5625
  if (config.appUrl !== void 0) {
4409
5626
  const url = parseAppUrl(config.appUrl);
4410
- if (!url)
4411
- add({ level: "error", label: `appUrl ${JSON.stringify(config.appUrl)}`, detail: "is not an http(s) URL", fix: 'e.g. "appUrl": "https://mygame.com"' });
4412
- else
4413
- add({ level: "ok", label: `appUrl ${url}`, detail: env.MAVONENGINE_APP_URL ? `MAVONENGINE_APP_URL overrides it here: ${env.MAVONENGINE_APP_URL}` : void 0 });
5627
+ if (!url) {
5628
+ add({
5629
+ level: "error",
5630
+ label: `appUrl ${JSON.stringify(config.appUrl)}`,
5631
+ detail: "is not an http(s) URL",
5632
+ fix: 'e.g. "appUrl": "https://mygame.com"'
5633
+ });
5634
+ } else {
5635
+ add({
5636
+ level: "ok",
5637
+ label: `appUrl ${url}`,
5638
+ detail: env.MAVONENGINE_APP_URL ? `MAVONENGINE_APP_URL overrides it here: ${env.MAVONENGINE_APP_URL}` : void 0
5639
+ });
5640
+ }
4414
5641
  }
4415
5642
  if (config.appName !== void 0 && (typeof config.appName !== "string" || !config.appName.trim()))
4416
5643
  add({ level: "warn", label: "appName", detail: "should be the game's name, as text" });
@@ -4418,12 +5645,18 @@ function checkConfig(root, env = {}) {
4418
5645
  const pkg = config[key];
4419
5646
  if (pkg === void 0)
4420
5647
  continue;
4421
- if (typeof pkg !== "string")
5648
+ if (typeof pkg !== "string") {
4422
5649
  add({ level: "error", label: `${key}`, detail: 'should be the package name of a plugin in "plugins"' });
4423
- else if (!config.plugins[pkg])
4424
- add({ level: "error", label: `${key}: ${pkg}`, detail: 'is not in "plugins"', fix: `mavonengine install ${pkg}` });
4425
- else if (config.plugins[pkg]?.enabled === false)
5650
+ } else if (!config.plugins[pkg]) {
5651
+ add({
5652
+ level: "error",
5653
+ label: `${key}: ${pkg}`,
5654
+ detail: 'is not in "plugins"',
5655
+ fix: `mavonengine install ${pkg}`
5656
+ });
5657
+ } else if (config.plugins[pkg]?.enabled === false) {
4426
5658
  add({ level: "warn", label: `${key}: ${pkg}`, detail: 'is turned off in "plugins"' });
5659
+ }
4427
5660
  }
4428
5661
  for (const [pkg, entry] of Object.entries(config.plugins)) {
4429
5662
  if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
@@ -4444,7 +5677,11 @@ async function compatibleVersions(npm, pkg, coreVersion) {
4444
5677
  if (!packument)
4445
5678
  return {};
4446
5679
  const supporting = Object.entries(packument.versions).filter(([, json2]) => engineCompat(engineRangeOf(json2), coreVersion) === "compatible").map(([version3]) => version3);
4447
- return { forCore: maxSatisfying(supporting, "*"), latest: packument.latest, packument };
5680
+ return {
5681
+ forCore: maxSatisfying(supporting, "*"),
5682
+ latest: packument.latest,
5683
+ packument
5684
+ };
4448
5685
  }
4449
5686
  async function checkPlugins(ctx, config) {
4450
5687
  const findings = [];
@@ -4457,7 +5694,12 @@ async function checkPlugins(ctx, config) {
4457
5694
  const dir = findPackageDir(ctx.root, pkg);
4458
5695
  const json2 = dir ? readJson(join7(dir, "package.json")) : void 0;
4459
5696
  if (!dir || !json2) {
4460
- found.push({ level: enabled ? "error" : "warn", label: pkg, detail: `in ${CONFIG_FILE} but not installed`, fix: `mavonengine install ${pkg}` });
5697
+ found.push({
5698
+ level: enabled ? "error" : "warn",
5699
+ label: pkg,
5700
+ detail: `in ${CONFIG_FILE} but not installed`,
5701
+ fix: `mavonengine install ${pkg}`
5702
+ });
4461
5703
  return found;
4462
5704
  }
4463
5705
  const label = `${pkg}${json2.version ? ` ${json2.version}` : ""}`;
@@ -4481,14 +5723,21 @@ async function checkPlugins(ctx, config) {
4481
5723
  if (!file || !existsSync9(file))
4482
5724
  found.push({ level: "error", label, detail: `${side} entry ${manifest[side] ?? "(none)"} not found, is the plugin built?` });
4483
5725
  }
5726
+ if (manifest.dev !== void 0) {
5727
+ const file = typeof manifest.dev === "string" && manifest.dev ? resolveInside(dir, manifest.dev) : void 0;
5728
+ if (!file || !existsSync9(file)) {
5729
+ found.push({ level: "warn", label, detail: `dev entry ${typeof manifest.dev === "string" ? manifest.dev : "(invalid)"} not found, is the plugin built?` });
5730
+ }
5731
+ }
4484
5732
  const prefabs = Array.isArray(entry.prefabs) ? entry.prefabs.filter((prefab) => typeof prefab === "string") : [];
4485
5733
  const base = assetsDir({ package: pkg, dir, manifest });
4486
5734
  const missing = shippedAssetPaths(manifest, prefabs).filter((path) => {
4487
5735
  const file = resolveInside(base, path);
4488
5736
  return !file || !existsSync9(file);
4489
5737
  });
4490
- if (missing.length)
5738
+ if (missing.length) {
4491
5739
  found.push({ level: "warn", label, detail: `asset${missing.length === 1 ? "" : "s"} missing from the release: ${missing.join(", ")}` });
5740
+ }
4492
5741
  if (manifest.publish && !existsSync9(join7(dir, manifest.publish)))
4493
5742
  found.push({ level: "warn", label, detail: `"mavonengine.publish" directory ${manifest.publish} is not in the package` });
4494
5743
  const range = engineRangeOf(json2);
@@ -4506,24 +5755,44 @@ async function checkPlugins(ctx, config) {
4506
5755
  });
4507
5756
  } else if (coreVersion) {
4508
5757
  const { forCore } = await compatibleVersions(ctx.npm, pkg, coreVersion);
4509
- if (isNewer(forCore, json2.version))
4510
- found.push({ level: "info", label, detail: `core ${range}; ${forCore} is out and supports core ${coreVersion}`, fix: `mavonengine install ${pkg}@${forCore}` });
5758
+ if (isNewer(forCore, json2.version)) {
5759
+ found.push({
5760
+ level: "info",
5761
+ label,
5762
+ detail: `core ${range}; ${forCore} is out and supports core ${coreVersion}`,
5763
+ fix: `mavonengine install ${pkg}@${forCore}`
5764
+ });
5765
+ }
5766
+ }
5767
+ if (!found.some((finding) => finding.label === label)) {
5768
+ found.push({
5769
+ level: "ok",
5770
+ label,
5771
+ detail: range ? `core ${range}` : void 0
5772
+ });
4511
5773
  }
4512
- if (!found.some((finding) => finding.label === label))
4513
- found.push({ level: "ok", label, detail: range ? `core ${range}` : void 0 });
4514
5774
  return found;
4515
5775
  }));
4516
5776
  for (const found of results) {
4517
5777
  for (const finding of found)
4518
5778
  add(finding);
4519
5779
  }
4520
- const declared = Object.keys({ ...ctx.packageJson.devDependencies, ...ctx.packageJson.dependencies });
5780
+ const declared = Object.keys({
5781
+ ...ctx.packageJson.devDependencies,
5782
+ ...ctx.packageJson.dependencies
5783
+ });
4521
5784
  for (const pkg of declared) {
4522
5785
  if (config.plugins[pkg] !== void 0)
4523
5786
  continue;
4524
5787
  const json2 = installedPackageJson(ctx.root, pkg);
4525
- if (json2?.mavonengine && typeof json2.mavonengine === "object")
4526
- add({ level: "info", label: pkg, detail: `a plugin that is installed but not in ${CONFIG_FILE}, so it isn't loaded`, fix: `mavonengine install ${pkg}` });
5788
+ if (json2?.mavonengine && typeof json2.mavonengine === "object") {
5789
+ add({
5790
+ level: "info",
5791
+ label: pkg,
5792
+ detail: `a plugin that is installed but not in ${CONFIG_FILE}, so it isn't loaded`,
5793
+ fix: `mavonengine install ${pkg}`
5794
+ });
5795
+ }
4527
5796
  }
4528
5797
  if (!findings.length)
4529
5798
  add({ level: "ok", label: "no plugins" });
@@ -4536,12 +5805,25 @@ async function checkMigrations(ctx, cliVersion) {
4536
5805
  const { module } = await loadMigrations(ctx.root);
4537
5806
  let pending;
4538
5807
  try {
4539
- pending = module.pendingMigrations({ files: new module.ProjectFiles(ctx.root), versions: { core: coreVersion, cli: cliVersion } });
5808
+ pending = module.pendingMigrations({
5809
+ files: new module.ProjectFiles(ctx.root),
5810
+ versions: { core: coreVersion, cli: cliVersion }
5811
+ });
4540
5812
  } catch (err) {
4541
- return [{ group: "Migrations", level: "warn", label: "migrations", detail: `can't be checked: ${err.message}` }];
5813
+ return [
5814
+ {
5815
+ group: "Migrations",
5816
+ level: "warn",
5817
+ label: "migrations",
5818
+ detail: `can't be checked: ${err.message}`
5819
+ }
5820
+ ];
5821
+ }
5822
+ if (!pending.length) {
5823
+ return [
5824
+ { group: "Migrations", level: "ok", label: "none pending" }
5825
+ ];
4542
5826
  }
4543
- if (!pending.length)
4544
- return [{ group: "Migrations", level: "ok", label: "none pending" }];
4545
5827
  return pending.map((migration, index) => ({
4546
5828
  group: "Migrations",
4547
5829
  level: "warn",
@@ -4581,7 +5863,10 @@ var NpmRegistry = class {
4581
5863
  const url = `${this.url}/${pkg.replace("/", "%2F")}`;
4582
5864
  let res;
4583
5865
  try {
4584
- res = await this.fetch(url, { headers: { accept: "application/json" }, signal: AbortSignal.timeout(this.timeoutMs) });
5866
+ res = await this.fetch(url, {
5867
+ headers: { accept: "application/json" },
5868
+ signal: AbortSignal.timeout(this.timeoutMs)
5869
+ });
4585
5870
  } catch (err) {
4586
5871
  this.unreachable ??= `can't reach ${this.url}: ${err.message}`;
4587
5872
  return void 0;
@@ -4663,7 +5948,13 @@ async function runDoctor(root, options, io = {}) {
4663
5948
  config ? checkMigrations(ctx, version) : []
4664
5949
  ]);
4665
5950
  const registry = registryFinding(ctx.npm);
4666
- const findings = [...environment, ...registry ? [registry] : [], ...configFindings, ...plugins, ...migrations];
5951
+ const findings = [
5952
+ ...environment,
5953
+ ...registry ? [registry] : [],
5954
+ ...configFindings,
5955
+ ...plugins,
5956
+ ...migrations
5957
+ ];
4667
5958
  return {
4668
5959
  root,
4669
5960
  packageManager: ctx.packageManager,
@@ -4673,8 +5964,18 @@ async function runDoctor(root, options, io = {}) {
4673
5964
  warnings: findings.filter((finding) => finding.level === "warn").length
4674
5965
  };
4675
5966
  }
4676
- var MARKS = { ok: "\u2713", info: "i", warn: "!", error: "\u2717" };
4677
- var COLORS = { ok: "32", info: "36", warn: "33", error: "31" };
5967
+ var MARKS = {
5968
+ ok: "\u2713",
5969
+ info: "i",
5970
+ warn: "!",
5971
+ error: "\u2717"
5972
+ };
5973
+ var COLORS = {
5974
+ ok: "32",
5975
+ info: "36",
5976
+ warn: "33",
5977
+ error: "31"
5978
+ };
4678
5979
  function formatReport(report, { color = false } = {}) {
4679
5980
  const paint = (code, text) => color ? `\x1B[${code}m${text}\x1B[0m` : text;
4680
5981
  const lines = [`MavonEngine project at ${report.root} (${report.packageManager}${report.coreVersion ? `, @mavonengine/core ${report.coreVersion}` : ""})`];
@@ -4696,7 +5997,10 @@ function formatReport(report, { color = false } = {}) {
4696
5997
  return `${lines.join("\n")}
4697
5998
  `;
4698
5999
  }
4699
- async function runDoctorCommand(options, io = { write: (text) => void process9.stdout.write(text), color: !!process9.stdout.isTTY && !process9.env.NO_COLOR }) {
6000
+ async function runDoctorCommand(options, io = {
6001
+ write: (text) => void process9.stdout.write(text),
6002
+ color: !!process9.stdout.isTTY && !process9.env.NO_COLOR
6003
+ }) {
4700
6004
  const root = findProjectRoot(options.cwd);
4701
6005
  if (!root || !existsSync10(join8(root, "package.json")))
4702
6006
  throw new UsageError(`no MavonEngine project found in ${options.cwd} or its parents (looking for a package.json with @mavonengine/core and a dev script)`);
@@ -4774,7 +6078,9 @@ function pluginFiles({ name, target, engine }) {
4774
6078
  scripts: {
4775
6079
  typecheck: "tsc -p tsconfig.json"
4776
6080
  },
4777
- ...engine ? { peerDependencies: { "@mavonengine/core": engine } } : {},
6081
+ ...engine ? {
6082
+ peerDependencies: { "@mavonengine/core": engine }
6083
+ } : {},
4778
6084
  mavonengine: {
4779
6085
  target,
4780
6086
  ...client ? { client: "./src/client.ts" } : {},
@@ -4924,12 +6230,21 @@ ${MAKE_PLUGIN_HELP}`);
4924
6230
  const target = values.target;
4925
6231
  if (!TARGETS2.includes(target))
4926
6232
  throw new UsageError(`--target must be one of ${TARGETS2.join(", ")}`);
4927
- return { cwd: resolve9(cwd, values.cwd ?? "."), name, target, register: values.register, install: values.install };
6233
+ return {
6234
+ cwd: resolve9(cwd, values.cwd ?? "."),
6235
+ name,
6236
+ target,
6237
+ register: values.register,
6238
+ install: values.install
6239
+ };
4928
6240
  }
4929
6241
  var terminalIO2 = {
4930
6242
  run: (command, args, cwd) => runCommand(command, args, cwd, {
4931
- report: { step: () => {
4932
- }, output: (chunk) => process10.stdout.write(chunk) }
6243
+ report: {
6244
+ step: () => {
6245
+ },
6246
+ output: (chunk) => process10.stdout.write(chunk)
6247
+ }
4933
6248
  }),
4934
6249
  write: (text) => process10.stdout.write(text)
4935
6250
  };
@@ -4944,7 +6259,11 @@ async function runMakePluginCommand(options, io = terminalIO2) {
4944
6259
  throw new UsageError(`a package named ${options.name} is already installed, pick another name`);
4945
6260
  const dir = pluginDirFor(options.name);
4946
6261
  const engineVersion = installedEngineVersion(root);
4947
- const files = pluginFiles({ name: options.name, target: options.target, engine: engineVersion ? `>=${engineVersion}` : void 0 });
6262
+ const files = pluginFiles({
6263
+ name: options.name,
6264
+ target: options.target,
6265
+ engine: engineVersion ? `>=${engineVersion}` : void 0
6266
+ });
4948
6267
  let written;
4949
6268
  try {
4950
6269
  written = writeScaffold(join11(root, dir), files);
@@ -4994,12 +6313,18 @@ Next: ${next.join(", then ")}
4994
6313
  import process11 from "process";
4995
6314
  import { parseArgs as parseArgs8 } from "util";
4996
6315
 
6316
+ // ../core/dist/Plugins/types.js
6317
+ var DEV_TOOLS_PATH = "/__mavonengine/mcp/tools";
6318
+
4997
6319
  // src/mcp/GameServerClient.ts
4998
6320
  var GameServerError = class extends Error {
4999
6321
  };
5000
6322
  var NET_UNAVAILABLE = "The network debug endpoints are not available: the game server runs with NODE_ENV=production (they are never served there), or it uses a @mavonengine/core release without them";
5001
6323
  function packetParams(query) {
5002
- return Object.fromEntries(Object.entries(query).filter(([, value]) => value !== void 0 && value !== "").map(([key, value]) => [key, String(value)]));
6324
+ return Object.fromEntries(Object.entries(query).filter(([, value]) => value !== void 0 && value !== "").map(([key, value]) => [
6325
+ key,
6326
+ String(value)
6327
+ ]));
5003
6328
  }
5004
6329
  var DATABASE_UNAVAILABLE = "The game server doesn't show its database: it runs a @mavonengine/core release without GET /api/game/database";
5005
6330
  var DATABASE_DENIED = "The database is only shown with the server's admin token, since it holds what players did: pass it with --token (or MAVONENGINE_METRICS_TOKEN), or run the server on this machine without one";
@@ -5028,10 +6353,14 @@ var GameServerClient = class {
5028
6353
  return this.get("api/game/metrics");
5029
6354
  }
5030
6355
  logs(afterId = 0) {
5031
- return this.get("api/game/logs", { after: String(afterId) }, "The server does not keep logs (metrics.logBufferSize is 0)");
6356
+ return this.get("api/game/logs", {
6357
+ after: String(afterId)
6358
+ }, "The server does not keep logs (metrics.logBufferSize is 0)");
5032
6359
  }
5033
6360
  requests(afterId = 0) {
5034
- return this.get("api/game/requests", { after: String(afterId) }, "The server does not record requests (metrics.requestLogSize is 0)");
6361
+ return this.get("api/game/requests", {
6362
+ after: String(afterId)
6363
+ }, "The server does not record requests (metrics.requestLogSize is 0)");
5035
6364
  }
5036
6365
  scene() {
5037
6366
  return this.get("api/game/dev/scene", {}, DEV_UNAVAILABLE);
@@ -5065,7 +6394,10 @@ var GameServerClient = class {
5065
6394
  }
5066
6395
  /** A page of a table's rows */
5067
6396
  tableRows(table, offset = 0, limit = 50) {
5068
- return this.get(`api/game/database/tables/${encodeURIComponent(table)}`, { offset: String(offset), limit: String(limit) }, `There is no table "${table}". database_overview lists them`, DATABASE_DENIED);
6397
+ return this.get(`api/game/database/tables/${encodeURIComponent(table)}`, {
6398
+ offset: String(offset),
6399
+ limit: String(limit)
6400
+ }, `There is no table "${table}". database_overview lists them`, DATABASE_DENIED);
5069
6401
  }
5070
6402
  /** Packets and network events the server recorded, oldest first */
5071
6403
  packets(query = {}) {
@@ -5079,6 +6411,43 @@ var GameServerClient = class {
5079
6411
  sync() {
5080
6412
  return this.get("api/game/dev/net/sync", {}, NET_UNAVAILABLE);
5081
6413
  }
6414
+ /**
6415
+ * The MCP tools of the plugins' dev entries, from the client's dev server. Null when there is none to ask: it isn't
6416
+ * running, or its @mavonengine/core has no plugin tools
6417
+ */
6418
+ async pluginTools(timeoutMs = 1500) {
6419
+ try {
6420
+ const res = await this.fetchImpl(new URL(DEV_TOOLS_PATH.slice(1), this.clientBase), {
6421
+ signal: AbortSignal.timeout(timeoutMs)
6422
+ });
6423
+ if (!res.ok || !res.headers.get("content-type")?.includes("application/json"))
6424
+ return null;
6425
+ const { tools } = await res.json();
6426
+ return Array.isArray(tools) ? tools : null;
6427
+ } catch {
6428
+ return null;
6429
+ }
6430
+ }
6431
+ /** Run a plugin's tool on the client's dev server. Rejects with the tool's error */
6432
+ async callPluginTool(name, args, timeoutMs = 12e4) {
6433
+ let res;
6434
+ try {
6435
+ res = await this.fetchImpl(new URL(`${DEV_TOOLS_PATH.slice(1)}/${encodeURIComponent(name)}`, this.clientBase), {
6436
+ method: "POST",
6437
+ headers: { "Content-Type": "application/json" },
6438
+ body: JSON.stringify({ arguments: args }),
6439
+ signal: AbortSignal.timeout(timeoutMs)
6440
+ });
6441
+ } catch (err) {
6442
+ throw new GameServerError(`Can't reach the client dev server at ${this.clientUrl}: ${err.message}. Is it running?`);
6443
+ }
6444
+ const body = await res.json().catch(() => null);
6445
+ if (!body)
6446
+ throw new GameServerError(`The client dev server at ${this.clientUrl} answered ${res.status} without JSON`);
6447
+ if (body.error !== void 0 || !res.ok)
6448
+ throw new GameServerError(body.error ?? `The client dev server answered ${res.status}`);
6449
+ return body.result;
6450
+ }
5082
6451
  /** The game tabs open in a browser, through the dev bridge */
5083
6452
  clients() {
5084
6453
  return this.bridge("__mavonengine/clients", {});
@@ -5087,7 +6456,10 @@ var GameServerClient = class {
5087
6456
  * Ask one tab. `clientId` defaults to the only open tab (or the only one not running the editor)
5088
6457
  */
5089
6458
  client(query, params = {}, clientId = "auto") {
5090
- const defined = Object.fromEntries(Object.entries(params).filter(([, v]) => v !== void 0).map(([k, v]) => [k, String(v)]));
6459
+ const defined = Object.fromEntries(Object.entries(params).filter(([, v]) => v !== void 0).map(([k, v]) => [
6460
+ k,
6461
+ String(v)
6462
+ ]));
5091
6463
  const timeoutMs = query === "trace" ? Number(params.durationMs ?? 3e3) + 15e3 : query === "screenshot" ? 15e3 : query === "status" ? 1e4 : 8e3;
5092
6464
  return this.bridge(`__mavonengine/clients/${encodeURIComponent(clientId)}/${query}`, defined, timeoutMs);
5093
6465
  }
@@ -5157,7 +6529,9 @@ It lets the assistant read a running game: the game server (status, metrics,
5157
6529
  players, scene, entities, logs, HTTP requests, plugins) and the game tabs open
5158
6530
  in a browser (renderer stats, entities, network, console, screenshots), compare
5159
6531
  an entity on both sides, and see which official plugins the project could add.
5160
- Every tool is read-only. Server scene and entity tools
6532
+ Its own tools are read-only. The project's plugins can add tools of their own
6533
+ while the client's dev server runs, named <plugin>_<tool>; those may change the
6534
+ project, and say so to the client, which asks before running them. Server scene and entity tools
5161
6535
  need the game server in development (NODE_ENV is not "production"); client
5162
6536
  tools need the client served by Vite in dev.
5163
6537
 
@@ -5182,6 +6556,7 @@ Options:
5182
6556
  plugin_readme (default: plugins.json on the main branch of the
5183
6557
  MavonEngine repository, or MAVONENGINE_PLUGINS_URL)
5184
6558
  --no-plugin-list Leave out available_plugins and plugin_readme, e.g. offline
6559
+ --read-only Leave out the plugins' tools that change something
5185
6560
  -h, --help Show this help
5186
6561
  `;
5187
6562
  function parseMcpArgs(args, env = process11.env) {
@@ -5197,6 +6572,7 @@ function parseMcpArgs(args, env = process11.env) {
5197
6572
  "docs": { type: "boolean", default: true },
5198
6573
  "plugins-url": { type: "string" },
5199
6574
  "plugin-list": { type: "boolean", default: true },
6575
+ "read-only": { type: "boolean", default: false },
5200
6576
  "help": { type: "boolean", short: "h", default: false }
5201
6577
  },
5202
6578
  strict: true,
@@ -5213,7 +6589,12 @@ function parseMcpArgs(args, env = process11.env) {
5213
6589
  const host = values.host.includes(":") && !values.host.startsWith("[") ? `[${values.host}]` : values.host;
5214
6590
  url = `http://${host}:${port}`;
5215
6591
  }
5216
- for (const [flag, value] of [["--url", url], ["--client-url", values["client-url"]], ["--docs-url", values["docs-url"]], ["--plugins-url", values["plugins-url"]]]) {
6592
+ for (const [flag, value] of [
6593
+ ["--url", url],
6594
+ ["--client-url", values["client-url"]],
6595
+ ["--docs-url", values["docs-url"]],
6596
+ ["--plugins-url", values["plugins-url"]]
6597
+ ]) {
5217
6598
  try {
5218
6599
  if (value !== void 0)
5219
6600
  void new URL(value);
@@ -5224,17 +6605,27 @@ function parseMcpArgs(args, env = process11.env) {
5224
6605
  return {
5225
6606
  client: new GameServerClient({ url, clientUrl: values["client-url"], token: values.token ?? env.MAVONENGINE_METRICS_TOKEN ?? env.MAVONENGINE_ADMIN_TOKEN }),
5226
6607
  docsUrl: values.docs ? values["docs-url"] ?? DEFAULT_DOCS_URL : false,
5227
- pluginsUrl: values["plugin-list"] ? values["plugins-url"] ?? env[PLUGIN_REGISTRY_ENV] ?? PLUGIN_REGISTRY_URL : false
6608
+ pluginsUrl: values["plugin-list"] ? values["plugins-url"] ?? env[PLUGIN_REGISTRY_ENV] ?? PLUGIN_REGISTRY_URL : false,
6609
+ readOnly: values["read-only"]
5228
6610
  };
5229
6611
  }
5230
- async function runMcpCommand({ client, docsUrl, pluginsUrl }) {
5231
- const [{ StdioServerTransport }, { createMcpServer }, { DocsClient }] = await Promise.all([
6612
+ async function runMcpCommand({ client, docsUrl, pluginsUrl, readOnly }) {
6613
+ const [{ StdioServerTransport }, { createMcpServer }, { DocsClient }, { ProjectPluginTools }] = await Promise.all([
5232
6614
  import("@modelcontextprotocol/sdk/server/stdio.js"),
5233
- import("./server-JSUVROT5.js"),
5234
- import("./docs-T42UVONR.js")
6615
+ import("./server-KTKAYX65.js"),
6616
+ import("./docs-5J3ZQJSF.js"),
6617
+ import("./projectPluginTools-QWULLUMD.js")
5235
6618
  ]);
5236
6619
  const docs = docsUrl ? new DocsClient(docsUrl) : void 0;
5237
6620
  const server = createMcpServer(client, docs, pluginsUrl ? { url: pluginsUrl } : void 0);
6621
+ const pluginTools = new ProjectPluginTools(server, client, {
6622
+ readOnly,
6623
+ warn: (message) => process11.stderr.write(`mavonengine mcp: ${message}
6624
+ `)
6625
+ });
6626
+ await pluginTools.refresh().catch(() => {
6627
+ });
6628
+ const stopWatching = pluginTools.watch();
5238
6629
  const transport = new StdioServerTransport();
5239
6630
  const closed = new Promise((resolve13) => {
5240
6631
  transport.onclose = resolve13;
@@ -5244,6 +6635,7 @@ async function runMcpCommand({ client, docsUrl, pluginsUrl }) {
5244
6635
  process11.stderr.write(`mavonengine mcp: reading the game server at ${client.url}
5245
6636
  `);
5246
6637
  await closed;
6638
+ stopWatching();
5247
6639
  await server.close().catch(() => {
5248
6640
  });
5249
6641
  await docs?.close();
@@ -5298,8 +6690,9 @@ function projectPlugins(cwd) {
5298
6690
  if (!root)
5299
6691
  return states;
5300
6692
  try {
5301
- for (const [pkg, entry] of Object.entries(readConfig(root).plugins))
6693
+ for (const [pkg, entry] of Object.entries(readConfig(root).plugins)) {
5302
6694
  states.set(pkg, entry?.enabled === false ? "disabled" : "enabled");
6695
+ }
5303
6696
  } catch {
5304
6697
  }
5305
6698
  return states;
@@ -5331,7 +6724,9 @@ function formatPlugins(registry, inProject) {
5331
6724
  return `${lines.join("\n")}
5332
6725
  `;
5333
6726
  }
5334
- async function runPluginsCommand(options, io = { write: (text) => process12.stdout.write(text) }) {
6727
+ async function runPluginsCommand(options, io = {
6728
+ write: (text) => process12.stdout.write(text)
6729
+ }) {
5335
6730
  const registry = await fetchPluginRegistry({ url: options.url, fetch: io.fetch });
5336
6731
  if (options.json) {
5337
6732
  io.write(`${JSON.stringify(registry, null, 2)}
@@ -5389,7 +6784,11 @@ function publishFiles(root, plugin, { force = false } = {}) {
5389
6784
  return { path, to, status: "kept" };
5390
6785
  mkdirSync4(dirname6(to), { recursive: true });
5391
6786
  copyFileSync(from, to);
5392
- return { path, to, status: existed ? "replaced" : "published" };
6787
+ return {
6788
+ path,
6789
+ to,
6790
+ status: existed ? "replaced" : "published"
6791
+ };
5393
6792
  });
5394
6793
  }
5395
6794
 
@@ -5423,9 +6822,15 @@ function parsePublishArgs(args, cwd = process13.cwd()) {
5423
6822
  throw new UsageError(`name the plugin to publish, e.g. mavonengine asset:publish @mavonengine/mail
5424
6823
 
5425
6824
  ${PUBLISH_HELP}`);
5426
- return { cwd: resolve11(cwd, values.cwd ?? "."), packages: positionals, force: values.force };
6825
+ return {
6826
+ cwd: resolve11(cwd, values.cwd ?? "."),
6827
+ packages: positionals,
6828
+ force: values.force
6829
+ };
5427
6830
  }
5428
- async function runPublishCommand(options, io = { write: (text) => void process13.stdout.write(text) }) {
6831
+ async function runPublishCommand(options, io = {
6832
+ write: (text) => void process13.stdout.write(text)
6833
+ }) {
5429
6834
  const root = findProjectRoot(options.cwd);
5430
6835
  if (!root) {
5431
6836
  io.write(`No MavonEngine project found from ${options.cwd}. Run this inside one.
@@ -5491,8 +6896,9 @@ function lineDiff(before, after, context = 2) {
5491
6896
  const b = splitLines(after);
5492
6897
  const lcs = Array.from({ length: a.length + 1 }, () => Array.from({ length: b.length + 1 }).fill(0));
5493
6898
  for (let i2 = a.length - 1; i2 >= 0; i2--) {
5494
- for (let j2 = b.length - 1; j2 >= 0; j2--)
6899
+ for (let j2 = b.length - 1; j2 >= 0; j2--) {
5495
6900
  lcs[i2][j2] = a[i2] === b[j2] ? lcs[i2 + 1][j2 + 1] + 1 : Math.max(lcs[i2 + 1][j2], lcs[i2][j2 + 1]);
6901
+ }
5496
6902
  }
5497
6903
  const ops = [];
5498
6904
  let i = 0;
@@ -5559,19 +6965,34 @@ async function planUpgrade(root, packageJson, npm, to) {
5559
6965
  if (!corePackument)
5560
6966
  throw new UpgradeError(npm.unreachable ?? `${npm.url} doesn't know @mavonengine/core`);
5561
6967
  const target = to ?? corePackument.latest;
5562
- if (!target || !corePackument.versions[target])
6968
+ if (!target || !corePackument.versions[target]) {
5563
6969
  throw new UpgradeError(to ? `@mavonengine/core ${to} isn't published, see 'npm view @mavonengine/core versions'` : `${npm.url} has no latest @mavonengine/core`);
6970
+ }
5564
6971
  const fields = ["dependencies", "devDependencies"];
5565
- const declared = fields.flatMap((field) => Object.entries(packageJson[field] ?? {}).map(([name, spec]) => ({ name, spec: String(spec), field })));
6972
+ const declared = fields.flatMap((field) => Object.entries(packageJson[field] ?? {}).map(([name, spec]) => ({
6973
+ name,
6974
+ spec: String(spec),
6975
+ field
6976
+ })));
5566
6977
  const candidates = declared.filter(({ name }) => name.startsWith("@mavonengine/") || installedJson(root, name)?.mavonengine);
5567
- const packuments = new Map(await Promise.all(candidates.map(async ({ name }) => [name, name === "@mavonengine/core" ? corePackument : await npm.get(name)])));
6978
+ const packuments = new Map(await Promise.all(candidates.map(async ({ name }) => [
6979
+ name,
6980
+ name === "@mavonengine/core" ? corePackument : await npm.get(name)
6981
+ ])));
5568
6982
  if (npm.unreachable)
5569
6983
  throw new UpgradeError(npm.unreachable);
5570
6984
  const bumps = candidates.map(({ name, spec, field }) => {
5571
6985
  const json2 = installedJson(root, name);
5572
6986
  const installed = typeof json2?.version === "string" ? json2.version : void 0;
5573
6987
  const plugin = !!json2?.mavonengine || !!packuments.get(name)?.versions[packuments.get(name)?.latest ?? ""]?.mavonengine;
5574
- const bump = { name, field, spec, installed, plugin, exact: EXACT_RE.test(spec.trim()) };
6988
+ const bump = {
6989
+ name,
6990
+ field,
6991
+ spec,
6992
+ installed,
6993
+ plugin,
6994
+ exact: EXACT_RE.test(spec.trim())
6995
+ };
5575
6996
  if (!REGISTRY_SPEC_RE.test(spec) || !spec.trim())
5576
6997
  return { ...bump, note: `stays: ${spec} isn't from the registry` };
5577
6998
  const packument = packuments.get(name);
@@ -5597,10 +7018,23 @@ async function planUpgrade(root, packageJson, npm, to) {
5597
7018
  return bump;
5598
7019
  return { ...bump, to: version3 };
5599
7020
  });
5600
- return { core: { from: installedJson(root, "@mavonengine/core")?.version, to: target }, bumps };
7021
+ return {
7022
+ core: { from: installedJson(root, "@mavonengine/core")?.version, to: target },
7023
+ bumps
7024
+ };
5601
7025
  }
5602
- var DEV_FLAG = { npm: "--save-dev", pnpm: "--save-dev", yarn: "--dev", bun: "--dev" };
5603
- var EXACT_FLAG = { npm: "--save-exact", pnpm: "--save-exact", yarn: "--exact", bun: "--exact" };
7026
+ var DEV_FLAG = {
7027
+ npm: "--save-dev",
7028
+ pnpm: "--save-dev",
7029
+ yarn: "--dev",
7030
+ bun: "--dev"
7031
+ };
7032
+ var EXACT_FLAG = {
7033
+ npm: "--save-exact",
7034
+ pnpm: "--save-exact",
7035
+ yarn: "--exact",
7036
+ bun: "--exact"
7037
+ };
5604
7038
  function installCommands(pm, bumps) {
5605
7039
  const groups = /* @__PURE__ */ new Map();
5606
7040
  for (const bump of bumps) {
@@ -5684,7 +7118,11 @@ ${UPGRADE_HELP}`);
5684
7118
  }
5685
7119
  function gitStatus(cwd) {
5686
7120
  try {
5687
- return execFileSync2("git", ["status", "--porcelain"], { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
7121
+ return execFileSync2("git", ["status", "--porcelain"], {
7122
+ cwd,
7123
+ encoding: "utf8",
7124
+ stdio: ["ignore", "pipe", "ignore"]
7125
+ });
5688
7126
  } catch {
5689
7127
  return void 0;
5690
7128
  }
@@ -5695,8 +7133,11 @@ function confirmOnTerminal2(question) {
5695
7133
  }
5696
7134
  var terminalIO3 = {
5697
7135
  run: (command, args, cwd) => runCommand(command, args, cwd, {
5698
- report: { step: () => {
5699
- }, output: (chunk) => process14.stdout.write(chunk) }
7136
+ report: {
7137
+ step: () => {
7138
+ },
7139
+ output: (chunk) => process14.stdout.write(chunk)
7140
+ }
5700
7141
  }),
5701
7142
  confirm: confirmOnTerminal2,
5702
7143
  get interactive() {
@@ -5806,7 +7247,10 @@ mavonengine: running '${pm} ${args.join(" ")}'
5806
7247
  return 1;
5807
7248
  }
5808
7249
  const { module, from } = await loadMigrations(root);
5809
- const ctx = { files: new module.ProjectFiles(root), versions: { core: coreVersion, cli: version } };
7250
+ const ctx = {
7251
+ files: new module.ProjectFiles(root),
7252
+ versions: { core: coreVersion, cli: version }
7253
+ };
5810
7254
  const pending = module.pendingMigrations(ctx);
5811
7255
  const dryRunNote = options.dryRun && !options.onlyMigrations ? ", for the core installed now; the new core may bring more" : "";
5812
7256
  io.write(`
@@ -5832,8 +7276,9 @@ Migrations, for @mavonengine/core ${coreVersion}${from === "cli" ? " (from the C
5832
7276
  io.write("\nNothing written (--dry-run)\n");
5833
7277
  return 0;
5834
7278
  }
5835
- if (!await ask(io, options, `Write ${changes.length === 1 ? "this change" : `these ${changes.length} changes`}?`, "write the changes"))
7279
+ if (!await ask(io, options, `Write ${changes.length === 1 ? "this change" : `these ${changes.length} changes`}?`, "write the changes")) {
5836
7280
  return 1;
7281
+ }
5837
7282
  const before = JSON.stringify(readPackageJson2());
5838
7283
  ctx.files.commit();
5839
7284
  migrated = true;