@unbound-app/debugger-protocol 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/controller.d.mts +8 -2
- package/dist/controller.mjs +12 -2
- package/dist/index-CxErH5OQ.d.mts +768 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/pending-requests.d.mts +2 -2
- package/dist/pending-requests.mjs +2 -2
- package/dist/registry.d.mts +22 -3
- package/dist/registry.mjs +27 -1
- package/dist/src-D7-HmLkb.mjs +492 -0
- package/package.json +1 -1
- package/dist/index-DwVwBIbm.d.mts +0 -234
- package/dist/src-D0Oi4NXs.mjs +0 -139
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
import { PushedManifest } from "@unbound-app/types";
|
|
2
|
-
/**
|
|
3
|
-
* React DevTools over the debugger socket: the device's backend and the frontend (the DevTools app's
|
|
4
|
-
* controller) swap React DevTools' own `{ event, payload }` messages, each wrapped in one frame.
|
|
5
|
-
*/
|
|
6
|
-
/** Device ↔ bridge ↔ the frontend controller: one React DevTools message. */
|
|
7
|
-
type ReactDevtoolsFrame = {
|
|
8
|
-
type: 'react-devtools';
|
|
9
|
-
event: string;
|
|
10
|
-
payload?: unknown;
|
|
11
|
-
};
|
|
12
|
-
/** The payload of {@link REACT_DEVTOOLS_STATUS_EVENT}. */
|
|
13
|
-
type ReactDevtoolsStatus = {
|
|
14
|
-
connected: boolean;
|
|
15
|
-
/** Why the backend is unavailable, such as the loader not having run it. */
|
|
16
|
-
error?: string;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* The event the device sends the frontend, with a {@link ReactDevtoolsStatus}, when its backend
|
|
20
|
-
* starts a session, cannot start one, or ends one.
|
|
21
|
-
*/
|
|
22
|
-
declare const REACT_DEVTOOLS_STATUS_EVENT = "unbound:backend-status";
|
|
23
|
-
/** React DevTools' own event that ends a backend session; the bridge sends it when the frontend leaves. */
|
|
24
|
-
declare const REACT_DEVTOOLS_SHUTDOWN_EVENT = "shutdown";
|
|
25
|
-
/**
|
|
26
|
-
* The view finder's frames: a controller asks the device for one level of its native view tree at a
|
|
27
|
-
* time, and names the view the device should outline on screen.
|
|
28
|
-
*/
|
|
29
|
-
/** A rectangle in screen coordinates, in dp on Android and points on iOS. */
|
|
30
|
-
type ViewFrame = {
|
|
31
|
-
x: number;
|
|
32
|
-
y: number;
|
|
33
|
-
width: number;
|
|
34
|
-
height: number;
|
|
35
|
-
};
|
|
36
|
-
/** One native view, with only its top-level properties. */
|
|
37
|
-
type ViewNode = {
|
|
38
|
-
/** The device's id for the view, valid until the next request for the roots. */
|
|
39
|
-
id: string;
|
|
40
|
-
/** The fully qualified Java class name, or the Objective-C class name. */
|
|
41
|
-
className: string;
|
|
42
|
-
/** The Android resource entry name of the view's id, or the iOS accessibility identifier. */
|
|
43
|
-
resourceName: string | null;
|
|
44
|
-
frame: ViewFrame;
|
|
45
|
-
visibility: 'visible' | 'invisible' | 'gone';
|
|
46
|
-
/** The view's opacity from 0 to 1, or `null` when the platform did not report it. */
|
|
47
|
-
alpha: number | null;
|
|
48
|
-
/** The text a text view shows, cut to a few hundred characters. */
|
|
49
|
-
text: string | null;
|
|
50
|
-
/** How many direct children the view has. */
|
|
51
|
-
childCount: number;
|
|
52
|
-
};
|
|
53
|
-
/** Controller → bridge → device: list the children of `parent`, or the root views when it is omitted. */
|
|
54
|
-
type ViewsRequest = {
|
|
55
|
-
type: 'views-request';
|
|
56
|
-
/** Correlation id echoed back on the matching {@link ViewsResult}. */
|
|
57
|
-
id: string;
|
|
58
|
-
parent?: string;
|
|
59
|
-
};
|
|
60
|
-
/** The answer to a {@link ViewsRequest}, sent device → bridge → the controller that asked. */
|
|
61
|
-
type ViewsResult = {
|
|
62
|
-
type: 'views-result';
|
|
63
|
-
/** The `id` of the {@link ViewsRequest} this answers. */
|
|
64
|
-
id: string;
|
|
65
|
-
} & ({
|
|
66
|
-
ok: true;
|
|
67
|
-
nodes: ViewNode[];
|
|
68
|
-
} | {
|
|
69
|
-
ok: false;
|
|
70
|
-
error: string;
|
|
71
|
-
});
|
|
72
|
-
/** Controller → bridge → device: outline the view with this id on screen, or clear the outline when `null`. */
|
|
73
|
-
type ViewHighlight = {
|
|
74
|
-
type: 'view-highlight';
|
|
75
|
-
node: string | null;
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* The wire protocol shared by the bridge, the device and controllers: every frame is a JSON-encoded
|
|
79
|
-
* {@link BridgeMessage}. Dependency-free at runtime so the React Native client can bundle it.
|
|
80
|
-
*/
|
|
81
|
-
/** A request to evaluate code on the device, sent controller → bridge → device. */
|
|
82
|
-
type EvalRequest = {
|
|
83
|
-
type: 'eval';
|
|
84
|
-
/** Correlation id echoed back on the matching {@link EvalResult}. */
|
|
85
|
-
id: string;
|
|
86
|
-
code: string;
|
|
87
|
-
timeout?: number;
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* Why a request failed before the device answered it, so callers branch on a code instead of the error text.
|
|
91
|
-
*/
|
|
92
|
-
type RequestFailureCode =
|
|
93
|
-
/** The bridge has no device. */
|
|
94
|
-
'no-device' |
|
|
95
|
-
/** The device dropped mid-request. */
|
|
96
|
-
'device-disconnected' | 'timeout' |
|
|
97
|
-
/** The controller has no socket to the bridge. */
|
|
98
|
-
'bridge-unreachable' |
|
|
99
|
-
/** The controller closed. */
|
|
100
|
-
'shut-down';
|
|
101
|
-
/** The outcome of an {@link EvalRequest}, sent device → bridge → the one waiting controller. */
|
|
102
|
-
type EvalResult = {
|
|
103
|
-
type: 'eval-result';
|
|
104
|
-
/** The `id` of the {@link EvalRequest} this answers. */
|
|
105
|
-
id: string;
|
|
106
|
-
/**
|
|
107
|
-
* Console output captured during this eval, so callers see its side effects too. Populated by
|
|
108
|
-
* the controller that owns the request, not sent by the device.
|
|
109
|
-
*/
|
|
110
|
-
logs?: LogMessage[];
|
|
111
|
-
} & ({
|
|
112
|
-
ok: true;
|
|
113
|
-
/** The inspected return value. */
|
|
114
|
-
value: string;
|
|
115
|
-
} | {
|
|
116
|
-
ok: false;
|
|
117
|
-
/** The inspected error. */
|
|
118
|
-
error: string;
|
|
119
|
-
/** Set when the bridge or controller failed the eval; absent when the code itself threw on the device. */
|
|
120
|
-
code?: RequestFailureCode;
|
|
121
|
-
});
|
|
122
|
-
/** The addon managers a push can reload into. */
|
|
123
|
-
type PushedAddonKind = 'plugin' | 'theme';
|
|
124
|
-
/**
|
|
125
|
-
* A request to hot-reload a plugin or theme on the device, sent controller → bridge → device. Carries
|
|
126
|
-
* the freshly built bundle and manifest so the device swaps them in without a re-fetch.
|
|
127
|
-
*/
|
|
128
|
-
type PushRequest = {
|
|
129
|
-
type: 'plugin-push';
|
|
130
|
-
/** Correlation id echoed back on the matching {@link PushResult}. */
|
|
131
|
-
id: string;
|
|
132
|
-
addonId: string;
|
|
133
|
-
/** Which manager reloads the addon; a plugin when omitted, as pushes from older CLIs are. */
|
|
134
|
-
kind?: PushedAddonKind;
|
|
135
|
-
bundle: string;
|
|
136
|
-
/** The manifest as authored; the device validates it before swapping anything in. */
|
|
137
|
-
manifest: PushedManifest;
|
|
138
|
-
/** The bundle compiled to Hermes bytecode, base64-encoded, by bytecode version; its digests are in `manifest.bytecode`. */
|
|
139
|
-
bytecode?: Record<string, string>;
|
|
140
|
-
/** Each extra file the manifest lists beside the bundle, such as an image, base64-encoded, by path. */
|
|
141
|
-
files?: Record<string, string>;
|
|
142
|
-
};
|
|
143
|
-
/** The outcome of a {@link PushRequest}, sent device → bridge → the one waiting controller. */
|
|
144
|
-
type PushResult = {
|
|
145
|
-
type: 'plugin-push-result';
|
|
146
|
-
/** The `id` of the {@link PushRequest} this answers. */
|
|
147
|
-
id: string;
|
|
148
|
-
} & ({
|
|
149
|
-
ok: true;
|
|
150
|
-
} | {
|
|
151
|
-
ok: false;
|
|
152
|
-
/** The reload failure, inspected. */
|
|
153
|
-
error: string;
|
|
154
|
-
/** Set when the bridge or controller failed the push; absent when the device's reload failed. */
|
|
155
|
-
code?: RequestFailureCode;
|
|
156
|
-
});
|
|
157
|
-
/** A `console.*` / `nativeLoggingHook` line, streamed device → bridge → all controllers. */
|
|
158
|
-
type LogMessage = {
|
|
159
|
-
type: 'log';
|
|
160
|
-
/** 1 = log/gray, 2 = warn/yellow, 3 = error/red. */
|
|
161
|
-
level: 1 | 2 | 3;
|
|
162
|
-
message: string;
|
|
163
|
-
};
|
|
164
|
-
/** What a device reports about itself when it connects. */
|
|
165
|
-
type DeviceInfo = {
|
|
166
|
-
platform: string;
|
|
167
|
-
discordVersion: string;
|
|
168
|
-
loaderVersion: string;
|
|
169
|
-
clientVersion: string;
|
|
170
|
-
};
|
|
171
|
-
/** Device → bridge, once its socket opens, so the bridge can say which device is attached. */
|
|
172
|
-
type DeviceHello = {
|
|
173
|
-
type: 'hello';
|
|
174
|
-
device: DeviceInfo;
|
|
175
|
-
};
|
|
176
|
-
/** Bridge → controller, once on attach and whenever the device connects, drops or says hello. */
|
|
177
|
-
type DeviceStatus = {
|
|
178
|
-
type: 'device-status';
|
|
179
|
-
} & ({
|
|
180
|
-
connected: false;
|
|
181
|
-
} | {
|
|
182
|
-
connected: true;
|
|
183
|
-
/** Present once the connected device has said hello. */
|
|
184
|
-
device?: DeviceInfo;
|
|
185
|
-
});
|
|
186
|
-
/** Every framed message on the wire. */
|
|
187
|
-
type BridgeMessage = EvalRequest | EvalResult | PushRequest | PushResult | LogMessage | DeviceHello | DeviceStatus | ViewsRequest | ViewsResult | ViewHighlight | ReactDevtoolsFrame;
|
|
188
|
-
/** The default port the bridge listens on and controllers dial. */
|
|
189
|
-
declare const DEFAULT_BRIDGE_PORT = 9090;
|
|
190
|
-
declare const DEFAULT_EVAL_TIMEOUT_MS = 10000;
|
|
191
|
-
declare const MAX_EVAL_TIMEOUT_MS = 86400000;
|
|
192
|
-
/** How long the bridge waits for the device to reload a pushed addon. */
|
|
193
|
-
declare const PUSH_TIMEOUT_MS = 60000;
|
|
194
|
-
/**
|
|
195
|
-
* How much longer a controller waits than the bridge, so the bridge's own timeout reply always
|
|
196
|
-
* arrives before the controller gives up on its own.
|
|
197
|
-
*/
|
|
198
|
-
declare const BRIDGE_REPLY_GRACE_MS = 5000;
|
|
199
|
-
/**
|
|
200
|
-
* @description Picks how long an eval may run: the requested timeout when it is a positive number of
|
|
201
|
-
* milliseconds, capped at {@link MAX_EVAL_TIMEOUT_MS}, otherwise {@link DEFAULT_EVAL_TIMEOUT_MS}.
|
|
202
|
-
* @param requested The timeout the controller asked for, if any.
|
|
203
|
-
* @returns The timeout to apply, in milliseconds.
|
|
204
|
-
*/
|
|
205
|
-
declare function resolveEvalTimeout(requested: number | undefined): number;
|
|
206
|
-
/** The query marker a controller appends to its URL so the bridge routes it as a controller, not a device. */
|
|
207
|
-
declare const CONTROLLER_ENDPOINT_MARKER = "mcp";
|
|
208
|
-
/**
|
|
209
|
-
* @description Safely parses a raw wire frame into a {@link BridgeMessage}, guarding against invalid
|
|
210
|
-
* JSON and unknown shapes so both ends can trust what they route.
|
|
211
|
-
* @param raw The JSON string received off the socket.
|
|
212
|
-
* @returns The parsed message, or `undefined` if it isn't a recognised frame.
|
|
213
|
-
*/
|
|
214
|
-
declare function parseMessage(raw: string): BridgeMessage | undefined;
|
|
215
|
-
/**
|
|
216
|
-
* @description Serialises a {@link BridgeMessage} into its wire form. Inverse of {@link parseMessage}.
|
|
217
|
-
* @param message The message to frame.
|
|
218
|
-
* @returns The JSON string to send over the socket.
|
|
219
|
-
*/
|
|
220
|
-
declare function serializeMessage(message: BridgeMessage): string;
|
|
221
|
-
declare const _default: {
|
|
222
|
-
DEFAULT_BRIDGE_PORT: number;
|
|
223
|
-
DEFAULT_EVAL_TIMEOUT_MS: number;
|
|
224
|
-
MAX_EVAL_TIMEOUT_MS: number;
|
|
225
|
-
PUSH_TIMEOUT_MS: number;
|
|
226
|
-
BRIDGE_REPLY_GRACE_MS: number;
|
|
227
|
-
CONTROLLER_ENDPOINT_MARKER: string;
|
|
228
|
-
REACT_DEVTOOLS_SHUTDOWN_EVENT: string;
|
|
229
|
-
REACT_DEVTOOLS_STATUS_EVENT: string;
|
|
230
|
-
resolveEvalTimeout: typeof resolveEvalTimeout;
|
|
231
|
-
parseMessage: typeof parseMessage;
|
|
232
|
-
serializeMessage: typeof serializeMessage;
|
|
233
|
-
};
|
|
234
|
-
export { ReactDevtoolsStatus as A, ViewHighlight as C, REACT_DEVTOOLS_SHUTDOWN_EVENT as D, ViewsResult as E, REACT_DEVTOOLS_STATUS_EVENT as O, ViewFrame as S, ViewsRequest as T, RequestFailureCode as _, DEFAULT_EVAL_TIMEOUT_MS as a, resolveEvalTimeout as b, DeviceStatus as c, LogMessage as d, MAX_EVAL_TIMEOUT_MS as f, PushedAddonKind as g, PushResult as h, DEFAULT_BRIDGE_PORT as i, ReactDevtoolsFrame as k, EvalRequest as l, PushRequest as m, BridgeMessage as n, DeviceHello as o, PUSH_TIMEOUT_MS as p, CONTROLLER_ENDPOINT_MARKER as r, DeviceInfo as s, BRIDGE_REPLY_GRACE_MS as t, EvalResult as u, _default as v, ViewNode as w, serializeMessage as x, parseMessage as y };
|
package/dist/src-D0Oi4NXs.mjs
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
// src/react-devtools.ts
|
|
2
|
-
/**
|
|
3
|
-
* The event the device sends the frontend, with a {@link ReactDevtoolsStatus}, when its backend
|
|
4
|
-
* starts a session, cannot start one, or ends one.
|
|
5
|
-
*/
|
|
6
|
-
const REACT_DEVTOOLS_STATUS_EVENT = "unbound:backend-status";
|
|
7
|
-
/** React DevTools' own event that ends a backend session; the bridge sends it when the frontend leaves. */
|
|
8
|
-
const REACT_DEVTOOLS_SHUTDOWN_EVENT = "shutdown";
|
|
9
|
-
/**
|
|
10
|
-
* @description Checks the fields of a React DevTools frame whose `type` is already known.
|
|
11
|
-
* @param frame The parsed frame.
|
|
12
|
-
* @returns Whether the frame names an event.
|
|
13
|
-
*/
|
|
14
|
-
function isReactDevtoolsFrame(frame) {
|
|
15
|
-
return typeof frame === "object" && frame !== null && "event" in frame && typeof frame.event === "string";
|
|
16
|
-
}
|
|
17
|
-
// src/views.ts
|
|
18
|
-
const VISIBILITIES = /* @__PURE__ */ new Set([
|
|
19
|
-
"visible",
|
|
20
|
-
"invisible",
|
|
21
|
-
"gone"
|
|
22
|
-
]);
|
|
23
|
-
function isObject(value) {
|
|
24
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25
|
-
}
|
|
26
|
-
function isNullableString(value) {
|
|
27
|
-
return value === null || typeof value === "string";
|
|
28
|
-
}
|
|
29
|
-
function isViewFrame(value) {
|
|
30
|
-
return isObject(value) && "x" in value && typeof value.x === "number" && "y" in value && typeof value.y === "number" && "width" in value && typeof value.width === "number" && "height" in value && typeof value.height === "number";
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* @description Checks that a value has every field a {@link ViewNode} needs.
|
|
34
|
-
* @param value The parsed value.
|
|
35
|
-
* @returns Whether it is a view node.
|
|
36
|
-
*/
|
|
37
|
-
function isViewNode(value) {
|
|
38
|
-
return isObject(value) && "id" in value && typeof value.id === "string" && "className" in value && typeof value.className === "string" && "resourceName" in value && isNullableString(value.resourceName) && "frame" in value && isViewFrame(value.frame) && "visibility" in value && VISIBILITIES.has(value.visibility) && "alpha" in value && (value.alpha === null || typeof value.alpha === "number") && "text" in value && isNullableString(value.text) && "childCount" in value && typeof value.childCount === "number";
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* @description Checks the fields of a view finder frame whose `type` is already known.
|
|
42
|
-
* @param frame The parsed frame.
|
|
43
|
-
* @returns Whether the frame is a valid view request, result or highlight.
|
|
44
|
-
*/
|
|
45
|
-
function isViewFrameMessage(frame) {
|
|
46
|
-
if (!isObject(frame) || !("type" in frame)) return false;
|
|
47
|
-
switch (frame.type) {
|
|
48
|
-
case "views-request": return "id" in frame && typeof frame.id === "string" && (!("parent" in frame) || frame.parent === void 0 || typeof frame.parent === "string");
|
|
49
|
-
case "views-result": return "id" in frame && typeof frame.id === "string" && "ok" in frame && (frame.ok === true ? "nodes" in frame && Array.isArray(frame.nodes) && frame.nodes.every(isViewNode) : frame.ok === false && "error" in frame && typeof frame.error === "string");
|
|
50
|
-
case "view-highlight": return "node" in frame && isNullableString(frame.node);
|
|
51
|
-
default: return false;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
// src/index.ts
|
|
55
|
-
/** The default port the bridge listens on and controllers dial. */
|
|
56
|
-
const DEFAULT_BRIDGE_PORT = 9090;
|
|
57
|
-
const DEFAULT_EVAL_TIMEOUT_MS = 1e4;
|
|
58
|
-
const MAX_EVAL_TIMEOUT_MS = 864e5;
|
|
59
|
-
/** How long the bridge waits for the device to reload a pushed addon. */
|
|
60
|
-
const PUSH_TIMEOUT_MS = 6e4;
|
|
61
|
-
/**
|
|
62
|
-
* How much longer a controller waits than the bridge, so the bridge's own timeout reply always
|
|
63
|
-
* arrives before the controller gives up on its own.
|
|
64
|
-
*/
|
|
65
|
-
const BRIDGE_REPLY_GRACE_MS = 5e3;
|
|
66
|
-
/**
|
|
67
|
-
* @description Picks how long an eval may run: the requested timeout when it is a positive number of
|
|
68
|
-
* milliseconds, capped at {@link MAX_EVAL_TIMEOUT_MS}, otherwise {@link DEFAULT_EVAL_TIMEOUT_MS}.
|
|
69
|
-
* @param requested The timeout the controller asked for, if any.
|
|
70
|
-
* @returns The timeout to apply, in milliseconds.
|
|
71
|
-
*/
|
|
72
|
-
function resolveEvalTimeout(requested) {
|
|
73
|
-
return typeof requested === "number" && requested > 0 ? Math.min(requested, MAX_EVAL_TIMEOUT_MS) : DEFAULT_EVAL_TIMEOUT_MS;
|
|
74
|
-
}
|
|
75
|
-
/** The query marker a controller appends to its URL so the bridge routes it as a controller, not a device. */
|
|
76
|
-
const CONTROLLER_ENDPOINT_MARKER = "mcp";
|
|
77
|
-
/**
|
|
78
|
-
* @description Safely parses a raw wire frame into a {@link BridgeMessage}, guarding against invalid
|
|
79
|
-
* JSON and unknown shapes so both ends can trust what they route.
|
|
80
|
-
* @param raw The JSON string received off the socket.
|
|
81
|
-
* @returns The parsed message, or `undefined` if it isn't a recognised frame.
|
|
82
|
-
*/
|
|
83
|
-
function parseMessage(raw) {
|
|
84
|
-
let value;
|
|
85
|
-
try {
|
|
86
|
-
value = JSON.parse(raw);
|
|
87
|
-
} catch {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
return hasRequiredFields(value) ? value : void 0;
|
|
91
|
-
}
|
|
92
|
-
function hasRequiredFields(frame) {
|
|
93
|
-
if (typeof frame !== "object" || frame === null || !("type" in frame)) return false;
|
|
94
|
-
switch (frame.type) {
|
|
95
|
-
case "log": return "message" in frame && typeof frame.message === "string" && "level" in frame && (frame.level === 1 || frame.level === 2 || frame.level === 3);
|
|
96
|
-
case "eval": return "id" in frame && typeof frame.id === "string" && "code" in frame && typeof frame.code === "string";
|
|
97
|
-
case "eval-result": return "id" in frame && typeof frame.id === "string" && "ok" in frame && (frame.ok === true ? "value" in frame && typeof frame.value === "string" : frame.ok === false && hasError(frame));
|
|
98
|
-
case "plugin-push-result": return "id" in frame && typeof frame.id === "string" && "ok" in frame && (frame.ok === true || frame.ok === false && hasError(frame));
|
|
99
|
-
case "plugin-push": return "id" in frame && typeof frame.id === "string" && "addonId" in frame && typeof frame.addonId === "string" && (!("kind" in frame) || frame.kind === void 0 || frame.kind === "plugin" || frame.kind === "theme") && "bundle" in frame && typeof frame.bundle === "string" && "manifest" in frame && typeof frame.manifest === "object" && frame.manifest !== null && (!("bytecode" in frame) || frame.bytecode === void 0 || isStringRecord(frame.bytecode)) && (!("files" in frame) || frame.files === void 0 || isStringRecord(frame.files));
|
|
100
|
-
case "hello": return "device" in frame && isDeviceInfo(frame.device);
|
|
101
|
-
case "device-status": return "connected" in frame && (frame.connected === false || frame.connected === true && (!("device" in frame) || frame.device === void 0 || isDeviceInfo(frame.device)));
|
|
102
|
-
case "views-request":
|
|
103
|
-
case "views-result":
|
|
104
|
-
case "view-highlight": return isViewFrameMessage(frame);
|
|
105
|
-
case "react-devtools": return isReactDevtoolsFrame(frame);
|
|
106
|
-
default: return false;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
function hasError(frame) {
|
|
110
|
-
return typeof frame === "object" && frame !== null && "error" in frame && typeof frame.error === "string";
|
|
111
|
-
}
|
|
112
|
-
function isDeviceInfo(value) {
|
|
113
|
-
return typeof value === "object" && value !== null && "platform" in value && typeof value.platform === "string" && "discordVersion" in value && typeof value.discordVersion === "string" && "loaderVersion" in value && typeof value.loaderVersion === "string" && "clientVersion" in value && typeof value.clientVersion === "string";
|
|
114
|
-
}
|
|
115
|
-
function isStringRecord(value) {
|
|
116
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.values(value).every((entry) => typeof entry === "string");
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* @description Serialises a {@link BridgeMessage} into its wire form. Inverse of {@link parseMessage}.
|
|
120
|
-
* @param message The message to frame.
|
|
121
|
-
* @returns The JSON string to send over the socket.
|
|
122
|
-
*/
|
|
123
|
-
function serializeMessage(message) {
|
|
124
|
-
return JSON.stringify(message);
|
|
125
|
-
}
|
|
126
|
-
var src_default = {
|
|
127
|
-
DEFAULT_BRIDGE_PORT,
|
|
128
|
-
DEFAULT_EVAL_TIMEOUT_MS,
|
|
129
|
-
MAX_EVAL_TIMEOUT_MS,
|
|
130
|
-
PUSH_TIMEOUT_MS,
|
|
131
|
-
BRIDGE_REPLY_GRACE_MS,
|
|
132
|
-
CONTROLLER_ENDPOINT_MARKER: "mcp",
|
|
133
|
-
REACT_DEVTOOLS_SHUTDOWN_EVENT,
|
|
134
|
-
REACT_DEVTOOLS_STATUS_EVENT,
|
|
135
|
-
resolveEvalTimeout,
|
|
136
|
-
parseMessage,
|
|
137
|
-
serializeMessage
|
|
138
|
-
};
|
|
139
|
-
export { MAX_EVAL_TIMEOUT_MS as a, resolveEvalTimeout as c, REACT_DEVTOOLS_SHUTDOWN_EVENT as d, REACT_DEVTOOLS_STATUS_EVENT as f, DEFAULT_EVAL_TIMEOUT_MS as i, serializeMessage as l, CONTROLLER_ENDPOINT_MARKER as n, PUSH_TIMEOUT_MS as o, DEFAULT_BRIDGE_PORT as r, parseMessage as s, BRIDGE_REPLY_GRACE_MS as t, src_default as u };
|