@serverkgg/bridge 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/package.json +3 -2
  2. package/rules/package.md +60 -0
  3. package/src/blog/articleFrontmatter.test.ts +10 -10
  4. package/src/blog/compile.test.ts +9 -9
  5. package/src/bot/botDeploy.test.ts +16 -16
  6. package/src/bot/botEnvironment.test.ts +8 -8
  7. package/src/bot/botIdentity.test.ts +12 -12
  8. package/src/bot/botPanel.test.ts +41 -11
  9. package/src/bot/botPanel.ts +13 -5
  10. package/src/bot/botState.test.ts +3 -3
  11. package/src/bot/botTerminal.test.ts +5 -5
  12. package/src/bot/botVariables.test.ts +8 -8
  13. package/src/bot/detect/botToken.test.ts +6 -6
  14. package/src/bot/detect/detect.test.ts +21 -21
  15. package/src/bot/detect/detectTable.test.ts +5 -5
  16. package/src/bot/detect/envExample.test.ts +2 -2
  17. package/src/bot/detect/envScan.test.ts +4 -4
  18. package/src/bot/detect/inferBotPlatform.test.ts +4 -4
  19. package/src/bot/detect/keys.test.ts +3 -3
  20. package/src/bot/detect/sensitiveKey.test.ts +5 -5
  21. package/src/bot/detect/serverkJson.test.ts +5 -5
  22. package/src/catalogs/curseforge.test.ts +35 -35
  23. package/src/catalogs/thunderstore.test.ts +9 -9
  24. package/src/cli/detectTable.test.ts +3 -3
  25. package/src/cli/link.test.ts +11 -11
  26. package/src/cli/main.ts +8 -0
  27. package/src/cli/rules.test.ts +198 -0
  28. package/src/cli/rules.ts +188 -0
  29. package/src/cli/validate.test.ts +123 -29
  30. package/src/cli/validate.ts +37 -1
  31. package/src/codecs/ini.test.ts +13 -13
  32. package/src/codecs/javaProperties.test.ts +11 -11
  33. package/src/codecs/sourceCfg.test.ts +14 -14
  34. package/src/codecs/xmlProperties.test.ts +10 -10
  35. package/src/context/bridgeContext.ts +6 -1
  36. package/src/core/bridgeAction.ts +2 -0
  37. package/src/core/bridgeActivity.ts +9 -0
  38. package/src/core/bridgeAvailability.ts +10 -0
  39. package/src/core/bridgePort.test.ts +6 -6
  40. package/src/core/bridgeUserError.test.ts +13 -3
  41. package/src/core/bridgeUserError.ts +6 -2
  42. package/src/core/bridgeValue.test.ts +5 -5
  43. package/src/core/describeDownloadFailure.test.ts +58 -0
  44. package/src/core/describeDownloadFailure.ts +69 -0
  45. package/src/core/index.ts +3 -0
  46. package/src/guides/markdown.test.ts +31 -31
  47. package/src/install/installStamp.test.ts +9 -9
  48. package/src/manifest/extension.ts +36 -0
  49. package/src/manifest/index.ts +1 -0
  50. package/src/manifest/manifest.test.ts +208 -90
  51. package/src/manifest/manifest.ts +34 -0
  52. package/src/modules/bridge.ts +8 -1
  53. package/src/modules/bridgeModule.ts +13 -1
  54. package/src/net/loopback.test.ts +10 -10
  55. package/src/panel/bridgeDetail.ts +2 -1
  56. package/src/presence/rosterSync.test.ts +7 -7
  57. package/src/probes/a2s.test.ts +5 -5
  58. package/src/probes/minecraftPing.test.ts +17 -17
  59. package/src/probes/raknetPing.test.ts +13 -13
  60. package/src/protocol/bridgeActivity.ts +54 -0
  61. package/src/protocol/bridgeEvents.ts +30 -0
  62. package/src/protocol/bridgeFrame.ts +10 -1
  63. package/src/protocol/index.ts +1 -0
  64. package/src/rcon/rconAccess.test.ts +20 -20
  65. package/src/rcon/rconAccess.ts +13 -13
  66. package/src/rcon/rconClient.test.ts +49 -49
  67. package/src/rcon/rconFrame.test.ts +14 -14
  68. package/src/rcon/rconIds.test.ts +4 -4
  69. package/src/rcon/rconWriter.test.ts +6 -6
  70. package/src/runtime/bridgeActions.ts +19 -2
  71. package/src/runtime/bridgeActivity.test.ts +318 -0
  72. package/src/runtime/bridgeActivity.ts +268 -0
  73. package/src/runtime/bridgeBackupLease.test.ts +9 -9
  74. package/src/runtime/bridgeConfigReader.test.ts +5 -5
  75. package/src/runtime/bridgeConsoleHandler.test.ts +8 -8
  76. package/src/runtime/bridgeContext.test.ts +11 -5
  77. package/src/runtime/bridgeContext.ts +8 -1
  78. package/src/runtime/bridgeDriver.test.ts +114 -93
  79. package/src/runtime/bridgeDriver.ts +10 -7
  80. package/src/runtime/bridgeEvents.test.ts +15 -15
  81. package/src/runtime/bridgeFiles.test.ts +54 -54
  82. package/src/runtime/bridgeInstall.test.ts +10 -10
  83. package/src/runtime/bridgeLiveConfig.test.ts +6 -6
  84. package/src/runtime/bridgeLog.ts +10 -0
  85. package/src/runtime/bridgePending.test.ts +6 -6
  86. package/src/runtime/bridgeRedaction.test.ts +16 -16
  87. package/src/runtime/bridgeRefusalError.ts +13 -0
  88. package/src/runtime/bridgeRegistry.test.ts +1077 -34
  89. package/src/runtime/bridgeRegistry.ts +464 -65
  90. package/src/runtime/bridgeScopedContext.ts +55 -0
  91. package/src/runtime/bridgeServer.test.ts +424 -24
  92. package/src/runtime/bridgeServer.ts +125 -35
  93. package/src/runtime/bridgeSetup.test.ts +27 -27
  94. package/src/runtime/bridgeSetup.ts +1 -1
  95. package/src/runtime/bridgeSetupHandlers.test.ts +80 -17
  96. package/src/runtime/bridgeSetupHandlers.ts +45 -10
  97. package/src/runtime/bridgeSignal.test.ts +7 -7
  98. package/src/runtime/bridgeSupervisor.test.ts +42 -42
  99. package/src/runtime/serve.ts +45 -3
  100. package/src/steam/avatars.test.ts +13 -13
  101. package/src/steam/steamApp.test.ts +8 -8
  102. package/src/steam/steamcmd.test.ts +44 -13
  103. package/src/steam/steamcmd.ts +27 -4
  104. package/src/steam/steamcmdNarrator.test.ts +4 -4
  105. package/src/steam/workshop.test.ts +5 -5
  106. package/src/utils/changedSettingKeys.test.ts +65 -0
  107. package/src/utils/changedSettingKeys.ts +6 -0
  108. package/src/utils/describeExecFailure.test.ts +34 -0
  109. package/src/utils/describeExecFailure.ts +9 -0
  110. package/src/utils/index.ts +3 -0
  111. package/src/utils/sameSettingValue.test.ts +35 -0
  112. package/src/utils/sameSettingValue.ts +40 -0
  113. package/src/utils/token.test.ts +7 -7
  114. package/src/wine/protonCommand.test.ts +5 -5
  115. package/src/wine/wineCommand.test.ts +6 -6
  116. package/src/wine/winePrefix.test.ts +6 -6
  117. package/src/wire/activity.test.ts +95 -0
  118. package/src/wire/activity.ts +41 -0
  119. package/src/wire/index.ts +1 -0
  120. package/src/wire/panel.test.ts +91 -25
  121. package/src/wire/panel.ts +11 -0
@@ -1,4 +1,4 @@
1
- import { describe, expect, test } from "bun:test";
1
+ import { describe, expect, it } from "bun:test";
2
2
  import type { BridgeCommandOptions, BridgeContext, BridgeReply } from "../context";
3
3
  import { BridgeKind, BridgeUserError } from "../core";
4
4
  import type { BridgeDriver, BridgeTerminalModule } from "../modules";
@@ -60,7 +60,7 @@ const handlerFor = (driver: BridgeDriver) => {
60
60
  };
61
61
 
62
62
  describe("routing a console line to the driver before the game's stdin", () => {
63
- test("answers with the driver's reply when the driver handles the line", async () => {
63
+ it("answers with the driver's reply when the driver handles the line", async () => {
64
64
  const { handler, written } = handlerFor(
65
65
  driverWith(
66
66
  terminalWith(async (_context, input) => {
@@ -81,7 +81,7 @@ describe("routing a console line to the driver before the game's stdin", () => {
81
81
  expect(written).toEqual([]);
82
82
  });
83
83
 
84
- test("hands the driver the same line the caller typed", async () => {
84
+ it("hands the driver the same line the caller typed", async () => {
85
85
  const seen: string[] = [];
86
86
 
87
87
  const { handler } = handlerFor(
@@ -105,7 +105,7 @@ describe("routing a console line to the driver before the game's stdin", () => {
105
105
  ]);
106
106
  });
107
107
 
108
- test("writes the line to stdin when the driver answers null", async () => {
108
+ it("writes the line to stdin when the driver answers null", async () => {
109
109
  const { handler, written } = handlerFor(
110
110
  driverWith(
111
111
  terminalWith(async () => {
@@ -124,7 +124,7 @@ describe("routing a console line to the driver before the game's stdin", () => {
124
124
  ]);
125
125
  });
126
126
 
127
- test("keeps the expect and timeout of a line the driver leaves alone", async () => {
127
+ it("keeps the expect and timeout of a line the driver leaves alone", async () => {
128
128
  const { handler } = handlerFor(
129
129
  driverWith(
130
130
  terminalWith(async () => {
@@ -143,7 +143,7 @@ describe("routing a console line to the driver before the game's stdin", () => {
143
143
  ).toBe("matched");
144
144
  });
145
145
 
146
- test("writes the line to stdin when the driver declares no handler", async () => {
146
+ it("writes the line to stdin when the driver declares no handler", async () => {
147
147
  const { handler, written } = handlerFor(
148
148
  driverWith({
149
149
  kind: BridgeKind.Terminal,
@@ -158,7 +158,7 @@ describe("routing a console line to the driver before the game's stdin", () => {
158
158
  ]);
159
159
  });
160
160
 
161
- test("writes the line to stdin when the game declares no terminal at all", async () => {
161
+ it("writes the line to stdin when the game declares no terminal at all", async () => {
162
162
  const { handler, written } = handlerFor(driverWith(undefined));
163
163
 
164
164
  await handler("list", {});
@@ -168,7 +168,7 @@ describe("routing a console line to the driver before the game's stdin", () => {
168
168
  ]);
169
169
  });
170
170
 
171
- test("refuses the line with the driver's own text when the driver rejects it", async () => {
171
+ it("refuses the line with the driver's own text when the driver rejects it", async () => {
172
172
  const refusal = {
173
173
  ar: "هذا الأمر يشتغل داخل اللعبة بس.",
174
174
  en: "That command only works inside the game.",
@@ -1,4 +1,4 @@
1
- import { afterEach, beforeEach, describe, expect, test } from "bun:test";
1
+ import { afterEach, beforeEach, describe, expect, it } from "bun:test";
2
2
  import { mkdtemp, rm, writeFile } from "node:fs/promises";
3
3
  import { tmpdir } from "node:os";
4
4
  import { join } from "node:path";
@@ -38,7 +38,7 @@ describe("the context's variable maps", () => {
38
38
  });
39
39
  });
40
40
 
41
- test("hand a driver every variable and secret the agent wrote, and follow a rewrite", async () => {
41
+ it("hand a driver every variable and secret the agent wrote, and follow a rewrite", async () => {
42
42
  const boot = configWith(
43
43
  {
44
44
  MY_VAR: "1",
@@ -72,6 +72,9 @@ describe("the context's variable maps", () => {
72
72
  onSetup() {
73
73
  return;
74
74
  },
75
+ onActivity() {
76
+ return;
77
+ },
75
78
  async onRestart() {
76
79
  return;
77
80
  },
@@ -158,6 +161,9 @@ describe("the context's ports and address", () => {
158
161
  onSetup() {
159
162
  return;
160
163
  },
164
+ onActivity() {
165
+ return;
166
+ },
161
167
  async onRestart() {
162
168
  return;
163
169
  },
@@ -179,7 +185,7 @@ describe("the context's ports and address", () => {
179
185
  });
180
186
  });
181
187
 
182
- test("hand a driver the block the agent published and its public address", async () => {
188
+ it("hand a driver the block the agent published and its public address", async () => {
183
189
  const boot = configWith({
184
190
  portCounts: {
185
191
  game: 1,
@@ -203,7 +209,7 @@ describe("the context's ports and address", () => {
203
209
  expect(context.server.publicAddress).toBe("203.0.113.7");
204
210
  });
205
211
 
206
- test("treat every port as a single one and the address as unknown for a file an older agent wrote", async () => {
212
+ it("treat every port as a single one and the address as unknown for a file an older agent wrote", async () => {
207
213
  const boot = configWith({});
208
214
 
209
215
  await writeFile(path, JSON.stringify(boot));
@@ -218,7 +224,7 @@ describe("the context's ports and address", () => {
218
224
  expect(() => context.portBlock("query")).toThrow('this game declares no port named "query"');
219
225
  });
220
226
 
221
- test("follow a rewrite of the public address", async () => {
227
+ it("follow a rewrite of the public address", async () => {
222
228
  const boot = configWith({});
223
229
 
224
230
  await writeFile(path, JSON.stringify(boot));
@@ -1,5 +1,5 @@
1
1
  import type { BridgeContext } from "../context";
2
- import type { BridgeValues } from "../core";
2
+ import type { BridgeActivity, BridgeValues } from "../core";
3
3
  import type { BridgeConfig, BridgeSetupRuntime } from "../protocol";
4
4
  import { stripAnsi } from "../utils";
5
5
  import { createBridgeCodecs } from "./bridgeCodec";
@@ -18,6 +18,7 @@ export interface ContextHooks {
18
18
  onLog: BridgeLeveledLogger;
19
19
  onEmit: (event: string, payload?: BridgeValues) => void;
20
20
  onSetup: (runtime: BridgeSetupRuntime | null) => void;
21
+ onActivity: (entry: BridgeActivity) => void;
21
22
  onRestart: () => Promise<void>;
22
23
  }
23
24
 
@@ -141,6 +142,12 @@ export const createContext = (
141
142
  },
142
143
  },
143
144
 
145
+ activity: {
146
+ report(entry) {
147
+ hooks.onActivity(entry);
148
+ },
149
+ },
150
+
144
151
  emit(event, payload) {
145
152
  hooks.onEmit(event, payload);
146
153
  },