@rnzeus/heimdall-sdk 0.4.0 → 0.5.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/README.md +13 -3
- package/dist/core/connection/channel/generate.js +3 -1
- package/dist/core/connection/channel/parse.d.ts +5 -0
- package/dist/core/connection/channel/parse.js +15 -0
- package/dist/core/network/xhr-callbacks.js +15 -0
- package/dist/public/prompt/use-prompt.js +2 -7
- package/dist/public/prompt/views/manual-view.js +5 -1
- package/dist/public/prompt/views/styles.d.ts +7 -0
- package/dist/public/prompt/views/styles.js +7 -0
- package/dist/types/protocol.d.ts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -73,7 +73,7 @@ import { showSDKConnectPrompt } from "@rnzeus/heimdall-sdk";
|
|
|
73
73
|
showSDKConnectPrompt();
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
-
**4. Connect.**
|
|
76
|
+
**4. Connect.** The prompt shows a short code, such as `ab12cd`. Type it into the Channel field in Heimdall — or leave the field empty to accept any device on your network — start the server and connect.
|
|
77
77
|
|
|
78
78
|
Host to use:
|
|
79
79
|
|
|
@@ -117,6 +117,16 @@ Tokens, cookies and passwords can be masked on export, so the file is safe to pa
|
|
|
117
117
|
|
|
118
118
|
Recording and playback live in the desktop app — nothing extra is needed in your code.
|
|
119
119
|
|
|
120
|
+
## Bug reports
|
|
121
|
+
|
|
122
|
+
When something goes wrong, a tester presses **Report** in Heimdall. They don't need to know which request broke: Heimdall takes what happened around that moment, finds failed requests, console errors and socket failures on its own, and lists the last steps before it. The report goes to the clipboard as Markdown or straight to the team's tracker (ClickUp for now) with the `.edda` file — and a HAR, if wanted — attached. Sensitive data is masked first.
|
|
123
|
+
|
|
124
|
+

|
|
125
|
+
|
|
126
|
+
A report can also start from one event — a request, a log line, a socket frame or a state change — or from a stopped recording. Pins and notes on events mark what matters and go into the report too.
|
|
127
|
+
|
|
128
|
+
Trackers are connected in the desktop app (Settings → Integrations); nothing extra is needed in your code. Adapters are open source: [`@rnzeus/heimdall-trackers`](https://github.com/rnzeus/heimdall-trackers).
|
|
129
|
+
|
|
120
130
|
## Without the prompt
|
|
121
131
|
|
|
122
132
|
```ts
|
|
@@ -135,7 +145,7 @@ disconnect();
|
|
|
135
145
|
|---|---|---|---|
|
|
136
146
|
| `host` | `string` | — | where Heimdall is running |
|
|
137
147
|
| `port` | `number` | — | Heimdall listens on `35678` by default |
|
|
138
|
-
| `channel` | `string` | — | `heimdall
|
|
148
|
+
| `channel` | `string` | — | `heimdall://<name>-<code>`; Heimdall accepts the device by the code |
|
|
139
149
|
| `enabled` | `boolean` | `__DEV__` | set `true` explicitly to use the SDK in a stage build |
|
|
140
150
|
| `platform` | `"ios" \| "android" \| "macos" \| "windows" \| "other"` | — | |
|
|
141
151
|
| `deviceName` | `string` | — | name shown in Heimdall |
|
|
@@ -153,7 +163,7 @@ disconnect();
|
|
|
153
163
|
|
|
154
164
|
## Connecting without typing an address
|
|
155
165
|
|
|
156
|
-
By default you
|
|
166
|
+
By default you type the host into the prompt and the code into Heimdall by hand. Heimdall Cloud removes that step for testers: a device is linked to an account once, and after that the app finds the desktop on its own.
|
|
157
167
|
|
|
158
168
|
```ts
|
|
159
169
|
configureConnectPrompt({
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { CHANNEL_SCHEME } from "./types.js";
|
|
2
2
|
import { sanitizeChannelSlug } from "./sanitize.js";
|
|
3
3
|
import { generateRandomId } from "../../../utils/index.js";
|
|
4
|
+
/** Letters and digits that are not mistaken for one another when typed by hand: no 0/o, 1/i. */
|
|
5
|
+
const SHORT_ID_ALPHABET = "abcdefghjklmnpqrstuvwxyz23456789";
|
|
4
6
|
/**
|
|
5
7
|
* Generate a random short ID (default length = 6).
|
|
6
8
|
*/
|
|
7
9
|
function generateShortId(length = 6) {
|
|
8
|
-
return generateRandomId(length,
|
|
10
|
+
return generateRandomId(length, SHORT_ID_ALPHABET);
|
|
9
11
|
}
|
|
10
12
|
/**
|
|
11
13
|
* Generate a full Channel identifier:
|
|
@@ -7,3 +7,8 @@ export declare function isChannel(value: string): value is Channel;
|
|
|
7
7
|
* Parse Heimdall Channel into {scheme, slug, shortId}
|
|
8
8
|
*/
|
|
9
9
|
export declare function parseChannel(value: string): ChannelParts | null;
|
|
10
|
+
/**
|
|
11
|
+
* Channel from what was typed in the prompt: a full `heimdall://…` channel as is, `slug-code` with the scheme
|
|
12
|
+
* added, anything else as the slug of a new channel.
|
|
13
|
+
*/
|
|
14
|
+
export declare function channelFromInput(input: string): Channel;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { generateChannelId } from "./generate.js";
|
|
2
|
+
import { sanitizeChannelSlug } from "./sanitize.js";
|
|
1
3
|
import { CHANNEL_SCHEME } from "./types.js";
|
|
2
4
|
/**
|
|
3
5
|
* Check if value looks like a Heimdall Channel
|
|
@@ -25,3 +27,16 @@ export function parseChannel(value) {
|
|
|
25
27
|
shortId,
|
|
26
28
|
};
|
|
27
29
|
}
|
|
30
|
+
const SLUG_AND_CODE = /^[a-z0-9-]+-[a-z0-9]{6}$/;
|
|
31
|
+
/**
|
|
32
|
+
* Channel from what was typed in the prompt: a full `heimdall://…` channel as is, `slug-code` with the scheme
|
|
33
|
+
* added, anything else as the slug of a new channel.
|
|
34
|
+
*/
|
|
35
|
+
export function channelFromInput(input) {
|
|
36
|
+
const typed = input.trim().toLowerCase();
|
|
37
|
+
if (isChannel(typed))
|
|
38
|
+
return typed;
|
|
39
|
+
if (SLUG_AND_CODE.test(typed))
|
|
40
|
+
return `${CHANNEL_SCHEME}${typed}`;
|
|
41
|
+
return generateChannelId(sanitizeChannelSlug(typed || "session"));
|
|
42
|
+
}
|
|
@@ -52,6 +52,21 @@ export function createXhrCallbacks(deps) {
|
|
|
52
52
|
const tsStart = Date.now();
|
|
53
53
|
meta.tsStart = tsStart;
|
|
54
54
|
meta.requestId = `${tsStart}-${Math.random().toString(16).slice(2)}`;
|
|
55
|
+
// Lets the host show a request that is still waiting; the completion follows with the same requestId.
|
|
56
|
+
const start = {
|
|
57
|
+
id: generateRandomId(),
|
|
58
|
+
type: "networkStart",
|
|
59
|
+
transport: "xhr",
|
|
60
|
+
requestId: meta.requestId,
|
|
61
|
+
tsStart,
|
|
62
|
+
method: meta.method,
|
|
63
|
+
url: meta.url,
|
|
64
|
+
host: meta.host,
|
|
65
|
+
path: meta.path,
|
|
66
|
+
requestHeaders: { ...meta.requestHeaders },
|
|
67
|
+
requestContentType: meta.requestHeaders["content-type"],
|
|
68
|
+
};
|
|
69
|
+
sendEvent(start);
|
|
55
70
|
const requestContentType = meta.requestHeaders["content-type"];
|
|
56
71
|
const reqBody = buildBodySnippet(data, { contentType: requestContentType });
|
|
57
72
|
meta.requestBodySnippet = reqBody.snippet;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
-
import { connect, disconnect, getPromptState, hidePrompt,
|
|
3
|
-
import { generateChannelId } from "../../core/connection/index.js";
|
|
2
|
+
import { channelFromInput, connect, disconnect, getPromptState, hidePrompt, } from "../../core/connection/index.js";
|
|
4
3
|
const usePrompt = (props) => {
|
|
5
4
|
const onCancel = () => {
|
|
6
5
|
hidePrompt();
|
|
@@ -15,11 +14,7 @@ const usePrompt = (props) => {
|
|
|
15
14
|
const host = props.host.trim() || defaults.host;
|
|
16
15
|
const portNum = Number(props.port);
|
|
17
16
|
const port = Number.isFinite(portNum) && portNum > 0 ? portNum : defaults.port;
|
|
18
|
-
|
|
19
|
-
if (!isChannel(channel)) {
|
|
20
|
-
const slug = sanitizeChannelSlug(channel || "session");
|
|
21
|
-
channel = generateChannelId(slug);
|
|
22
|
-
}
|
|
17
|
+
const channel = channelFromInput(props.channel);
|
|
23
18
|
props.startConnecting(() => connect({ ...defaults, channel, host, port }));
|
|
24
19
|
};
|
|
25
20
|
const onConfirmDisconnect = () => {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Text, TextInput, View } from "react-native";
|
|
3
|
+
import { parseChannel } from "../../../core/connection/index.js";
|
|
3
4
|
import { CopyButton } from "../../copy-button/index.js";
|
|
4
5
|
import ActionButton from "../ui/action-button.js";
|
|
5
6
|
import Footer from "../ui/footer.js";
|
|
6
7
|
import Header from "../ui/header.js";
|
|
7
8
|
import styles from "./styles.js";
|
|
8
9
|
const ManualView = ({ ui, setUi, theme, isDark, canCopy, onCopyChannel, onConnect, onBack, isConnecting, }) => {
|
|
10
|
+
var _a, _b;
|
|
9
11
|
const error = isConnecting ? null : ui.errorMessage;
|
|
10
12
|
const inputStyle = [
|
|
11
13
|
styles.input,
|
|
@@ -16,6 +18,8 @@ const ManualView = ({ ui, setUi, theme, isDark, canCopy, onCopyChannel, onConnec
|
|
|
16
18
|
},
|
|
17
19
|
];
|
|
18
20
|
const labelStyle = [styles.label, { color: theme.muted }];
|
|
19
|
-
|
|
21
|
+
// The host matches by this code alone, so it is what people read out and type.
|
|
22
|
+
const code = (_b = (_a = parseChannel(ui.channel.trim().toLowerCase())) === null || _a === void 0 ? void 0 : _a.shortId) !== null && _b !== void 0 ? _b : null;
|
|
23
|
+
return (_jsxs(_Fragment, { children: [_jsx(Header, { title: "Heimdall", status: isConnecting ? "busy" : error ? "error" : "idle", theme: theme }), _jsx(Text, { style: labelStyle, children: "Host" }), _jsx(TextInput, { value: ui.host, onChangeText: (text) => setUi((prev) => ({ ...prev, host: text })), style: inputStyle, autoCapitalize: "none", autoCorrect: false, editable: !isConnecting, placeholder: "127.0.0.1", placeholderTextColor: theme.idle }), _jsx(Text, { style: labelStyle, children: "Port" }), _jsx(TextInput, { value: ui.port, onChangeText: (text) => setUi((prev) => ({ ...prev, port: text })), style: inputStyle, keyboardType: "number-pad", editable: !isConnecting, placeholder: "35678", placeholderTextColor: theme.idle }), _jsx(Text, { style: labelStyle, children: "Channel" }), _jsxs(View, { style: styles.inputRow, children: [_jsx(TextInput, { value: ui.channel, onChangeText: (text) => setUi((prev) => ({ ...prev, channel: text })), style: [inputStyle, styles.inputFlex], autoCapitalize: "none", autoCorrect: false, editable: !isConnecting, placeholder: "heimdall://session-xxxxxx", placeholderTextColor: theme.idle }), _jsx(CopyButton, { tone: isDark ? "dark" : "light", disabled: !canCopy, onPress: onCopyChannel })] }), code ? (_jsxs(_Fragment, { children: [_jsx(Text, { style: labelStyle, children: "Code for Heimdall" }), _jsx(Text, { style: [styles.code, { color: theme.text }], selectable: true, children: code })] })) : null, error ? (_jsx(Text, { style: [styles.error, { color: theme.danger }], children: error })) : null, _jsx(Footer, { secondary: onBack ? (_jsx(ActionButton, { title: "Back", variant: "link", theme: theme, disabled: isConnecting, onPress: onBack })) : null, primary: _jsx(ActionButton, { title: isConnecting ? "Connecting…" : "Connect", theme: theme, disabled: isConnecting, onPress: onConnect }) })] }));
|
|
20
24
|
};
|
|
21
25
|
export default ManualView;
|
|
@@ -20,4 +20,11 @@ export default StyleSheet.create({
|
|
|
20
20
|
marginTop: 4,
|
|
21
21
|
},
|
|
22
22
|
channel: { flexShrink: 1, fontSize: 12 },
|
|
23
|
+
code: {
|
|
24
|
+
fontFamily: Platform.select({ ios: "Menlo", default: "monospace" }),
|
|
25
|
+
fontSize: 22,
|
|
26
|
+
fontWeight: "600",
|
|
27
|
+
letterSpacing: 2,
|
|
28
|
+
marginTop: 2,
|
|
29
|
+
},
|
|
23
30
|
});
|
package/dist/types/protocol.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { HelloWireMessageV1, EventWireMessageV1, EventWirePayload, NetworkFilters, NetworkEventPayload, ZustandEventPayload, WsEventPayload, ConsoleEventPayload, HelloAppInfo, HelloDeviceInfo, } from "@rnzeus/heimdall-protocol";
|
|
1
|
+
export type { HelloWireMessageV1, EventWireMessageV1, EventWirePayload, NetworkFilters, NetworkEventPayload, NetworkStartEventPayload, ZustandEventPayload, WsEventPayload, ConsoleEventPayload, HelloAppInfo, HelloDeviceInfo, } from "@rnzeus/heimdall-protocol";
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.5.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.
|
|
1
|
+
export const SDK_VERSION = "0.5.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rnzeus/heimdall-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "React Native client for Heimdall — a desktop debug inspector for network, WebSocket, Zustand and console",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Volodymyr Dudkevych",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
94
|
"dependencies": {
|
|
95
|
-
"@rnzeus/heimdall-protocol": "^0.
|
|
95
|
+
"@rnzeus/heimdall-protocol": "^0.4.0"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
98
|
"@types/node": "^25.0.3",
|