@serverkgg/bridge 0.0.8 → 0.0.10
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/package.json +3 -3
- package/src/cli/validate.ts +2 -0
- package/src/context/bridgeContext.ts +17 -0
- package/src/context/index.ts +1 -0
- package/src/core/bridgeDownloadError.ts +10 -0
- package/src/core/bridgeHold.ts +12 -0
- package/src/core/bridgeKind.ts +3 -0
- package/src/core/bridgeProbeError.ts +16 -0
- package/src/core/bridgeSetup.ts +20 -0
- package/src/core/bridgeUserError.test.ts +23 -0
- package/src/core/bridgeUserError.ts +12 -0
- package/src/core/bridgeValue.test.ts +29 -0
- package/src/core/bridgeValue.ts +12 -0
- package/src/core/index.ts +5 -0
- package/src/guides/blocks.ts +8 -0
- package/src/guides/markdown.test.ts +18 -0
- package/src/guides/markdown.ts +7 -1
- package/src/manifest/index.ts +1 -0
- package/src/manifest/manifest.test.ts +132 -0
- package/src/manifest/manifest.ts +21 -0
- package/src/manifest/presence.ts +56 -0
- package/src/manifest/primitives.ts +6 -0
- package/src/modules/bridge.ts +65 -2
- package/src/modules/bridgeDriver.ts +4 -0
- package/src/modules/bridgeModule.ts +32 -3
- package/src/panel/bridgeDetail.ts +49 -0
- package/src/panel/bridgeLayout.ts +1 -0
- package/src/panel/bridgePanel.ts +30 -0
- package/src/panel/bridgeUploadMode.ts +4 -0
- package/src/panel/index.ts +2 -0
- package/src/probes/a2s.test.ts +71 -0
- package/src/probes/a2s.ts +38 -11
- package/src/protocol/bridgeEgress.ts +8 -1
- package/src/protocol/bridgeEvents.ts +4 -0
- package/src/protocol/bridgeFrame.ts +33 -1
- package/src/protocol/bridgeLimits.ts +12 -0
- package/src/protocol/bridgeManifest.ts +2 -0
- package/src/protocol/bridgeSetup.ts +97 -0
- package/src/protocol/index.ts +1 -0
- package/src/runtime/bridgeActions.ts +7 -0
- package/src/runtime/bridgeConfigReader.ts +12 -8
- package/src/runtime/bridgeContext.ts +28 -2
- package/src/runtime/bridgeDriver.test.ts +748 -3
- package/src/runtime/bridgeDriver.ts +198 -4
- package/src/runtime/bridgeEgress.ts +3 -0
- package/src/runtime/bridgeEvents.test.ts +96 -0
- package/src/runtime/bridgeEvents.ts +11 -6
- package/src/runtime/bridgeFiles.test.ts +625 -15
- package/src/runtime/bridgeFiles.ts +152 -45
- package/src/runtime/bridgeInstall.test.ts +118 -0
- package/src/runtime/bridgeInstall.ts +55 -0
- package/src/runtime/bridgeNet.ts +32 -3
- package/src/runtime/bridgePending.test.ts +148 -0
- package/src/runtime/bridgePending.ts +43 -0
- package/src/runtime/bridgeRegistry.test.ts +172 -1
- package/src/runtime/bridgeRegistry.ts +40 -5
- package/src/runtime/bridgeSecrets.test.ts +121 -0
- package/src/runtime/bridgeSecrets.ts +43 -0
- package/src/runtime/bridgeServer.test.ts +598 -0
- package/src/runtime/bridgeServer.ts +42 -3
- package/src/runtime/bridgeSetup.test.ts +189 -0
- package/src/runtime/bridgeSetup.ts +63 -0
- package/src/runtime/bridgeSignal.test.ts +114 -0
- package/src/runtime/bridgeSignal.ts +31 -0
- package/src/runtime/bridgeSupervisor.test.ts +111 -0
- package/src/runtime/bridgeSupervisor.ts +55 -5
- package/src/runtime/bridgeZip.ts +179 -58
- package/src/runtime/serve.ts +115 -4
- package/src/utils/index.ts +1 -0
- package/src/utils/stripAnsi.ts +12 -0
- package/src/wire/panel.test.ts +259 -0
- package/src/wire/panel.ts +72 -0
|
@@ -18,6 +18,14 @@ export const BRIDGE_VISIBLE_VALUES_LIMIT = 16;
|
|
|
18
18
|
|
|
19
19
|
export const BRIDGE_PREVIEW_LINES_LIMIT = 8;
|
|
20
20
|
|
|
21
|
+
export const BRIDGE_DETAIL_STATS_LIMIT = 12;
|
|
22
|
+
|
|
23
|
+
export const BRIDGE_DETAIL_BADGES_LIMIT = 4;
|
|
24
|
+
|
|
25
|
+
export const BRIDGE_DETAIL_LINKS_LIMIT = 4;
|
|
26
|
+
|
|
27
|
+
export const BRIDGE_FORM_CLEARS_LIMIT = 8;
|
|
28
|
+
|
|
21
29
|
export const BRIDGE_UPLOAD_EXTENSIONS_LIMIT = 8;
|
|
22
30
|
|
|
23
31
|
export const BRIDGE_MODULES_LIMIT = 32;
|
|
@@ -28,6 +36,10 @@ export const BRIDGE_DEPENDS_ON_LIMIT = 8;
|
|
|
28
36
|
|
|
29
37
|
export const BRIDGE_EVENTS_LIMIT = 32;
|
|
30
38
|
|
|
39
|
+
export const BRIDGE_PENDING_FILES_LIMIT = 64;
|
|
40
|
+
|
|
41
|
+
export const BRIDGE_SETUP_STEPS_LIMIT = 8;
|
|
42
|
+
|
|
31
43
|
export const BRIDGE_ID_LENGTH_LIMIT = 32;
|
|
32
44
|
|
|
33
45
|
export const BRIDGE_KEY_LENGTH_LIMIT = 64;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { BridgeKind, BridgeStream } from "../core";
|
|
2
2
|
import type { BridgePanel } from "../panel";
|
|
3
3
|
import type { BridgeTerminalCommand, BridgeTerminalLevel } from "../terminal";
|
|
4
|
+
import type { BridgeSetupManifest } from "./bridgeSetup";
|
|
4
5
|
|
|
5
6
|
export interface BridgeTerminalRuleManifest {
|
|
6
7
|
match: string;
|
|
@@ -28,6 +29,7 @@ export interface BridgeManifest {
|
|
|
28
29
|
version: string;
|
|
29
30
|
panel: BridgePanel | null;
|
|
30
31
|
terminal: BridgeTerminalManifest | null;
|
|
32
|
+
setup: BridgeSetupManifest | null;
|
|
31
33
|
modules: BridgeModuleManifest[];
|
|
32
34
|
events: string[];
|
|
33
35
|
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { BridgeSetupPromptKind, BridgeSetupStepKind, BridgeSetupStepState, LocalizedText } from "../core";
|
|
2
|
+
import type { GuideOpenTarget } from "../guides";
|
|
3
|
+
|
|
4
|
+
interface BridgeSetupStepBase {
|
|
5
|
+
id: string;
|
|
6
|
+
title: LocalizedText;
|
|
7
|
+
help?: LocalizedText;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface BridgeSetupDriverStep extends BridgeSetupStepBase {
|
|
12
|
+
kind: BridgeSetupStepKind.Driver;
|
|
13
|
+
requiresRunning?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface BridgeSetupFormStep extends BridgeSetupStepBase {
|
|
17
|
+
kind: BridgeSetupStepKind.Form;
|
|
18
|
+
tab: string;
|
|
19
|
+
section: string;
|
|
20
|
+
fields?: string[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface BridgeSetupOpenStep extends BridgeSetupStepBase {
|
|
24
|
+
kind: BridgeSetupStepKind.Open;
|
|
25
|
+
target: GuideOpenTarget;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type BridgeSetupStep = BridgeSetupDriverStep | BridgeSetupFormStep | BridgeSetupOpenStep;
|
|
29
|
+
|
|
30
|
+
export interface BridgeSetupManifest {
|
|
31
|
+
steps: BridgeSetupStep[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface BridgeSetupAction {
|
|
35
|
+
id: string;
|
|
36
|
+
label: LocalizedText;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface BridgeSetupWaitPrompt {
|
|
40
|
+
kind: BridgeSetupPromptKind.Wait;
|
|
41
|
+
message: LocalizedText;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface BridgeSetupProgressPrompt {
|
|
45
|
+
kind: BridgeSetupPromptKind.Progress;
|
|
46
|
+
message: LocalizedText;
|
|
47
|
+
percent: number | null;
|
|
48
|
+
detail: string | null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface BridgeSetupLinkPrompt {
|
|
52
|
+
kind: BridgeSetupPromptKind.Link;
|
|
53
|
+
message: LocalizedText;
|
|
54
|
+
url: string;
|
|
55
|
+
code: string | null;
|
|
56
|
+
expiresAt: string | null;
|
|
57
|
+
actions: BridgeSetupAction[];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface BridgeSetupActionPrompt {
|
|
61
|
+
kind: BridgeSetupPromptKind.Action;
|
|
62
|
+
message: LocalizedText;
|
|
63
|
+
actions: BridgeSetupAction[];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface BridgeSetupFailedPrompt {
|
|
67
|
+
kind: BridgeSetupPromptKind.Failed;
|
|
68
|
+
message: LocalizedText;
|
|
69
|
+
actions: BridgeSetupAction[];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export type BridgeSetupPrompt =
|
|
73
|
+
| BridgeSetupActionPrompt
|
|
74
|
+
| BridgeSetupFailedPrompt
|
|
75
|
+
| BridgeSetupLinkPrompt
|
|
76
|
+
| BridgeSetupProgressPrompt
|
|
77
|
+
| BridgeSetupWaitPrompt;
|
|
78
|
+
|
|
79
|
+
export interface BridgeSetupStepStatus {
|
|
80
|
+
id: string;
|
|
81
|
+
state: BridgeSetupStepState;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface BridgeSetupRuntime {
|
|
85
|
+
steps: BridgeSetupStepStatus[];
|
|
86
|
+
prompt: BridgeSetupPrompt | null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface BridgeSetupSummary {
|
|
90
|
+
step: string | null;
|
|
91
|
+
attention: boolean;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface BridgeSetupResult {
|
|
95
|
+
supported: boolean;
|
|
96
|
+
runtime: BridgeSetupRuntime | null;
|
|
97
|
+
}
|
package/src/protocol/index.ts
CHANGED
|
@@ -42,6 +42,13 @@ export const actionsOf = (module: BridgePanelModule): string[] => {
|
|
|
42
42
|
];
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
case BridgeKind.Detail: {
|
|
46
|
+
return [
|
|
47
|
+
BridgeAction.Read,
|
|
48
|
+
...Object.keys(module.actions ?? {}),
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
|
|
45
52
|
case BridgeKind.Catalog: {
|
|
46
53
|
return [
|
|
47
54
|
BridgeAction.Install,
|
|
@@ -82,14 +82,8 @@ export const statePath = (config: BridgeConfig) => {
|
|
|
82
82
|
return `${config.run}/${BRIDGE_STATE_NAME}`;
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
export const
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
if (!(await file.exists())) {
|
|
89
|
-
throw new BridgeConfigError(`no bridge config at "${path}"`);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const parsed: unknown = JSON.parse(await file.text());
|
|
85
|
+
export const parseConfig = (text: string): BridgeConfig => {
|
|
86
|
+
const parsed: unknown = JSON.parse(text);
|
|
93
87
|
|
|
94
88
|
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
95
89
|
throw new BridgeConfigError("bridge config must be an object");
|
|
@@ -117,3 +111,13 @@ export const readConfig = async (path: string): Promise<BridgeConfig> => {
|
|
|
117
111
|
|
|
118
112
|
return config;
|
|
119
113
|
};
|
|
114
|
+
|
|
115
|
+
export const readConfig = async (path: string): Promise<BridgeConfig> => {
|
|
116
|
+
const file = Bun.file(path);
|
|
117
|
+
|
|
118
|
+
if (!(await file.exists())) {
|
|
119
|
+
throw new BridgeConfigError(`no bridge config at "${path}"`);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return parseConfig(await file.text());
|
|
123
|
+
};
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import type { BridgeContext } from "../context";
|
|
2
2
|
import type { BridgeValues } from "../core";
|
|
3
|
-
import type { BridgeConfig } from "../protocol";
|
|
3
|
+
import type { BridgeConfig, BridgeSetupRuntime } from "../protocol";
|
|
4
|
+
import { stripAnsi } from "../utils";
|
|
4
5
|
import { createBridgeCodecs } from "./bridgeCodec";
|
|
6
|
+
import { configPath } from "./bridgeConfigReader";
|
|
5
7
|
import { createBridgeEgress } from "./bridgeEgress";
|
|
6
8
|
import { createBridgeExec } from "./bridgeExec";
|
|
7
9
|
import { createBridgeFiles } from "./bridgeFiles";
|
|
8
10
|
import type { BridgeLeveledLogger } from "./bridgeLog";
|
|
9
11
|
import { createBridgeNet } from "./bridgeNet";
|
|
10
12
|
import { createBridgeProbes } from "./bridgeProbe";
|
|
13
|
+
import { createBridgeSecrets } from "./bridgeSecrets";
|
|
11
14
|
import type { BridgeSupervisor } from "./bridgeSupervisor";
|
|
12
15
|
|
|
13
16
|
export interface ContextHooks {
|
|
14
17
|
onLog: BridgeLeveledLogger;
|
|
15
18
|
onEmit: (event: string, payload?: BridgeValues) => void;
|
|
19
|
+
onSetup: (runtime: BridgeSetupRuntime | null) => void;
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
export const createContext = (
|
|
@@ -22,6 +26,8 @@ export const createContext = (
|
|
|
22
26
|
): BridgeContext => {
|
|
23
27
|
const egress = createBridgeEgress(config);
|
|
24
28
|
|
|
29
|
+
const secrets = createBridgeSecrets(configPath(), config);
|
|
30
|
+
|
|
25
31
|
const files = createBridgeFiles({
|
|
26
32
|
root: config.cwd,
|
|
27
33
|
uid: config.gameUid,
|
|
@@ -45,7 +51,7 @@ export const createContext = (
|
|
|
45
51
|
},
|
|
46
52
|
|
|
47
53
|
secret(key) {
|
|
48
|
-
return
|
|
54
|
+
return secrets.read(key);
|
|
49
55
|
},
|
|
50
56
|
|
|
51
57
|
port(key) {
|
|
@@ -84,6 +90,26 @@ export const createContext = (
|
|
|
84
90
|
async watch(pattern, timeoutMs) {
|
|
85
91
|
return await supervisor.watch(pattern, timeoutMs);
|
|
86
92
|
},
|
|
93
|
+
|
|
94
|
+
follow(pattern, onMatch) {
|
|
95
|
+
return supervisor.subscribe((entry) => {
|
|
96
|
+
const match = stripAnsi(entry.line).match(pattern);
|
|
97
|
+
|
|
98
|
+
if (match) {
|
|
99
|
+
onMatch(match);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
setup: {
|
|
106
|
+
report(runtime) {
|
|
107
|
+
hooks.onSetup(runtime);
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
clear() {
|
|
111
|
+
hooks.onSetup(null);
|
|
112
|
+
},
|
|
87
113
|
},
|
|
88
114
|
|
|
89
115
|
emit(event, payload) {
|