@rnzeus/heimdall-sdk 0.7.0 → 0.7.1
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/public/prompt/component.js +3 -3
- package/dist/public/prompt/local-network.d.ts +31 -0
- package/dist/public/prompt/local-network.js +34 -0
- package/dist/public/prompt/theme.d.ts +6 -1
- package/dist/public/prompt/theme.js +23 -21
- package/dist/public/prompt/ui/action-button.d.ts +2 -1
- package/dist/public/prompt/ui/action-button.js +14 -3
- package/dist/public/prompt/ui/footer.d.ts +5 -2
- package/dist/public/prompt/ui/footer.js +3 -4
- package/dist/public/prompt/ui/header.js +2 -2
- package/dist/public/prompt/ui/status-line.d.ts +11 -0
- package/dist/public/prompt/ui/status-line.js +12 -0
- package/dist/public/prompt/use-connect-awaiter.d.ts +3 -2
- package/dist/public/prompt/use-connect-awaiter.js +55 -9
- package/dist/public/prompt/views/cloud-view.d.ts +3 -1
- package/dist/public/prompt/views/cloud-view.js +3 -2
- package/dist/public/prompt/views/connected-view.js +1 -1
- package/dist/public/prompt/views/manual-view.d.ts +5 -2
- package/dist/public/prompt/views/manual-view.js +3 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -17,7 +17,7 @@ import styles from "./styles.js";
|
|
|
17
17
|
const HeimdallConnectPrompt = ({ onCopyToClipboard, }) => {
|
|
18
18
|
var _a, _b;
|
|
19
19
|
const [ui, setUi] = usePromptUi();
|
|
20
|
-
const { isConnecting, startConnecting } = useConnectAwaiter({
|
|
20
|
+
const { isConnecting, notice, startConnecting } = useConnectAwaiter({
|
|
21
21
|
visible: ui.visible,
|
|
22
22
|
});
|
|
23
23
|
const { onCancel, onConfirmConnect, onConfirmDisconnect, handleCopyChannel } = usePrompt({ ...ui, onCopyToClipboard, startConnecting });
|
|
@@ -43,9 +43,9 @@ const HeimdallConnectPrompt = ({ onCopyToClipboard, }) => {
|
|
|
43
43
|
return (_jsx(ConnectedView, { hostLabel: (_a = getCloudHostName(ui.channel)) !== null && _a !== void 0 ? _a : `${ui.host}:${ui.port}`, channel: ui.channel, theme: theme, isDark: isDark, canCopy: canCopy, onCopyChannel: handleCopyChannel, onClose: onCancel, onDisconnect: onConfirmDisconnect }));
|
|
44
44
|
}
|
|
45
45
|
if (cloudUrl && mode === "cloud") {
|
|
46
|
-
return (_jsx(CloudView, { baseUrl: cloudUrl, visible: ui.visible, socketError: ui.errorMessage, theme: theme, isConnecting: isConnecting, startConnecting: startConnecting, onManual: () => switchMode("manual") }));
|
|
46
|
+
return (_jsx(CloudView, { baseUrl: cloudUrl, visible: ui.visible, socketError: ui.errorMessage, theme: theme, isConnecting: isConnecting, notice: notice, startConnecting: startConnecting, onManual: () => switchMode("manual") }));
|
|
47
47
|
}
|
|
48
|
-
return (_jsx(ManualView, { ui: ui, setUi: setUi, theme: theme, isDark: isDark, canCopy: canCopy, onCopyChannel: handleCopyChannel, onConnect: onConfirmConnect,
|
|
48
|
+
return (_jsx(ManualView, { ui: ui, setUi: setUi, theme: theme, isDark: isDark, canCopy: canCopy, onCopyChannel: handleCopyChannel, onConnect: onConfirmConnect, onAuto: cloudUrl ? () => switchMode("cloud") : undefined, isConnecting: isConnecting, notice: notice }));
|
|
49
49
|
};
|
|
50
50
|
return (_jsxs(Animated.View, { style: [styles.backdrop, { backgroundColor: theme.backdrop, opacity }], pointerEvents: backdropPointerEvents, children: [_jsx(Pressable, { style: StyleSheet.absoluteFill, onPress: onCancel }), _jsx(KeyboardAvoidingView, { style: styles.keyboard, behavior: Platform.OS === "ios" ? "padding" : undefined, pointerEvents: "box-none", children: _jsxs(Animated.View, { style: [
|
|
51
51
|
styles.card,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* iOS asks “Find devices on local networks” on the first connection to a LAN address and fails that very
|
|
3
|
+
* connection with “No route to host”. While the question may still be open, the prompt keeps trying instead.
|
|
4
|
+
*/
|
|
5
|
+
export declare const LOCAL_NETWORK: {
|
|
6
|
+
/** how long the user may take to answer iOS */
|
|
7
|
+
waitMs: number;
|
|
8
|
+
retryMs: number;
|
|
9
|
+
/** after this the user has most likely answered: say where to turn it on, and keep trying */
|
|
10
|
+
hintAfterMs: number;
|
|
11
|
+
hint: string;
|
|
12
|
+
notice: string;
|
|
13
|
+
denied: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function shouldWaitForLocalNetwork({ platform, error, startedAt, now, }: {
|
|
16
|
+
platform: string;
|
|
17
|
+
error: string | null;
|
|
18
|
+
/** when the user pressed Connect */
|
|
19
|
+
startedAt: number;
|
|
20
|
+
now: number;
|
|
21
|
+
}): boolean;
|
|
22
|
+
/** What the prompt says while it keeps trying: first the iOS question, then where to turn access on. */
|
|
23
|
+
export declare function localNetworkNotice({ startedAt, now, }: {
|
|
24
|
+
startedAt: number;
|
|
25
|
+
now: number;
|
|
26
|
+
}): string;
|
|
27
|
+
/** after the wait: a “no route” on iOS most likely means the permission is off */
|
|
28
|
+
export declare function localNetworkError({ platform, error, }: {
|
|
29
|
+
platform: string;
|
|
30
|
+
error: string;
|
|
31
|
+
}): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* iOS asks “Find devices on local networks” on the first connection to a LAN address and fails that very
|
|
3
|
+
* connection with “No route to host”. While the question may still be open, the prompt keeps trying instead.
|
|
4
|
+
*/
|
|
5
|
+
export const LOCAL_NETWORK = {
|
|
6
|
+
/** how long the user may take to answer iOS */
|
|
7
|
+
waitMs: 30000,
|
|
8
|
+
retryMs: 1500,
|
|
9
|
+
/** after this the user has most likely answered: say where to turn it on, and keep trying */
|
|
10
|
+
hintAfterMs: 8000,
|
|
11
|
+
hint: "No access yet. If you tapped Don't Allow, turn it on in Settings → Privacy & Security → Local Network.",
|
|
12
|
+
notice: "Allow “Local Network” in the iOS prompt: Heimdall connects right after.",
|
|
13
|
+
denied: "Local Network access is off for this app: Settings → Privacy & Security → Local Network.",
|
|
14
|
+
};
|
|
15
|
+
/** POSIX texts of EHOSTUNREACH / ENETUNREACH, as iOS reports a connection the Local Network permission held back */
|
|
16
|
+
const NO_ROUTE = /no route to host|host is unreachable|network is unreachable|EHOSTUNREACH|ENETUNREACH/i;
|
|
17
|
+
export function shouldWaitForLocalNetwork({ platform, error, startedAt, now, }) {
|
|
18
|
+
return (platform === "ios" &&
|
|
19
|
+
error !== null &&
|
|
20
|
+
NO_ROUTE.test(error) &&
|
|
21
|
+
now - startedAt < LOCAL_NETWORK.waitMs);
|
|
22
|
+
}
|
|
23
|
+
/** What the prompt says while it keeps trying: first the iOS question, then where to turn access on. */
|
|
24
|
+
export function localNetworkNotice({ startedAt, now, }) {
|
|
25
|
+
return now - startedAt < LOCAL_NETWORK.hintAfterMs
|
|
26
|
+
? LOCAL_NETWORK.notice
|
|
27
|
+
: LOCAL_NETWORK.hint;
|
|
28
|
+
}
|
|
29
|
+
/** after the wait: a “no route” on iOS most likely means the permission is off */
|
|
30
|
+
export function localNetworkError({ platform, error, }) {
|
|
31
|
+
return platform === "ios" && NO_ROUTE.test(error)
|
|
32
|
+
? LOCAL_NETWORK.denied
|
|
33
|
+
: error;
|
|
34
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** Heimdall's own colours, as in the desktop app: the brand orange for the main action, the soft orange for links. */
|
|
1
2
|
export type PromptTheme = {
|
|
2
3
|
backdrop: string;
|
|
3
4
|
card: string;
|
|
@@ -6,10 +7,14 @@ export type PromptTheme = {
|
|
|
6
7
|
border: string;
|
|
7
8
|
inputBackground: string;
|
|
8
9
|
inputDisabledBackground: string;
|
|
10
|
+
/** the main button: the brand orange */
|
|
9
11
|
primary: string;
|
|
10
12
|
onPrimary: string;
|
|
13
|
+
/** links and the “connecting” dot */
|
|
14
|
+
link: string;
|
|
11
15
|
danger: string;
|
|
12
|
-
|
|
16
|
+
/** connected, as the session blue in the desktop app */
|
|
17
|
+
session: string;
|
|
13
18
|
warning: string;
|
|
14
19
|
idle: string;
|
|
15
20
|
};
|
|
@@ -2,31 +2,33 @@ import { useColorScheme } from "react-native";
|
|
|
2
2
|
const LIGHT = {
|
|
3
3
|
backdrop: "rgba(0,0,0,0.38)",
|
|
4
4
|
card: "#FFFFFF",
|
|
5
|
-
text: "#
|
|
6
|
-
muted: "#
|
|
7
|
-
border: "#
|
|
8
|
-
inputBackground: "#
|
|
9
|
-
inputDisabledBackground: "#
|
|
10
|
-
primary: "#
|
|
11
|
-
onPrimary: "#
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
text: "#161B22",
|
|
6
|
+
muted: "#5F6672",
|
|
7
|
+
border: "#DDE1E7",
|
|
8
|
+
inputBackground: "#F7F8FA",
|
|
9
|
+
inputDisabledBackground: "#EEF0F3",
|
|
10
|
+
primary: "#FC7F1C",
|
|
11
|
+
onPrimary: "#1C0D00",
|
|
12
|
+
link: "#B85407",
|
|
13
|
+
danger: "#C62828",
|
|
14
|
+
session: "#0A78BF",
|
|
15
|
+
warning: "#B85407",
|
|
15
16
|
idle: "#9CA3AF",
|
|
16
17
|
};
|
|
17
18
|
const DARK = {
|
|
18
19
|
backdrop: "rgba(0,0,0,0.55)",
|
|
19
|
-
card: "#
|
|
20
|
-
text: "#
|
|
21
|
-
muted: "#
|
|
22
|
-
border: "#
|
|
23
|
-
inputBackground: "#
|
|
24
|
-
inputDisabledBackground: "#
|
|
25
|
-
primary: "#
|
|
26
|
-
onPrimary: "#
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
card: "#171C23",
|
|
21
|
+
text: "#DEE2ED",
|
|
22
|
+
muted: "#9E9E9E",
|
|
23
|
+
border: "#30353E",
|
|
24
|
+
inputBackground: "#0F141B",
|
|
25
|
+
inputDisabledBackground: "#1D232B",
|
|
26
|
+
primary: "#FC7F1C",
|
|
27
|
+
onPrimary: "#1C0D00",
|
|
28
|
+
link: "#FFAD66",
|
|
29
|
+
danger: "#FF6B6B",
|
|
30
|
+
session: "#42BAFD",
|
|
31
|
+
warning: "#FFAD66",
|
|
30
32
|
idle: "#6B7280",
|
|
31
33
|
};
|
|
32
34
|
export const usePromptTheme = () => useColorScheme() === "dark" ? DARK : LIGHT;
|
|
@@ -4,7 +4,8 @@ type Props = {
|
|
|
4
4
|
title: string;
|
|
5
5
|
onPress: () => void;
|
|
6
6
|
theme: PromptTheme;
|
|
7
|
-
|
|
7
|
+
/** quiet: a link for a rarer action, in the muted colour */
|
|
8
|
+
variant?: "primary" | "danger" | "link" | "quiet";
|
|
8
9
|
disabled?: boolean;
|
|
9
10
|
};
|
|
10
11
|
declare const ActionButton: ({ title, onPress, theme, variant, disabled, }: Props) => JSX.Element;
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Pressable, StyleSheet, Text } from "react-native";
|
|
3
3
|
const ActionButton = ({ title, onPress, theme, variant = "primary", disabled = false, }) => {
|
|
4
|
-
const isLink = variant === "link";
|
|
4
|
+
const isLink = variant === "link" || variant === "quiet";
|
|
5
5
|
const background = isLink
|
|
6
6
|
? "transparent"
|
|
7
7
|
: variant === "danger"
|
|
8
8
|
? theme.danger
|
|
9
9
|
: theme.primary;
|
|
10
|
-
const color =
|
|
10
|
+
const color = variant === "link"
|
|
11
|
+
? theme.link
|
|
12
|
+
: variant === "quiet"
|
|
13
|
+
? theme.muted
|
|
14
|
+
: variant === "danger"
|
|
15
|
+
? theme.card
|
|
16
|
+
: theme.onPrimary;
|
|
11
17
|
return (_jsx(Pressable, { onPress: onPress, disabled: disabled, hitSlop: 8, style: ({ pressed }) => [
|
|
12
18
|
isLink ? styles.link : styles.button,
|
|
13
19
|
{ backgroundColor: background },
|
|
@@ -15,7 +21,12 @@ const ActionButton = ({ title, onPress, theme, variant = "primary", disabled = f
|
|
|
15
21
|
], children: _jsx(Text, { style: [styles.title, { color }], children: title }) }));
|
|
16
22
|
};
|
|
17
23
|
const styles = StyleSheet.create({
|
|
18
|
-
button: {
|
|
24
|
+
button: {
|
|
25
|
+
alignItems: "center",
|
|
26
|
+
borderRadius: 10,
|
|
27
|
+
paddingHorizontal: 14,
|
|
28
|
+
paddingVertical: 11,
|
|
29
|
+
},
|
|
19
30
|
link: { paddingVertical: 9 },
|
|
20
31
|
title: { fontSize: 14, fontWeight: "600" },
|
|
21
32
|
dimmed: { opacity: 0.5 },
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { JSX, ReactNode } from "react";
|
|
2
2
|
type Props = {
|
|
3
|
-
|
|
3
|
+
/** the main action, across the whole card */
|
|
4
4
|
primary?: ReactNode;
|
|
5
|
+
/** links under it: the other way to connect on the left, a rarer action on the right */
|
|
6
|
+
start?: ReactNode;
|
|
7
|
+
end?: ReactNode;
|
|
5
8
|
};
|
|
6
|
-
declare const Footer: ({
|
|
9
|
+
declare const Footer: ({ primary, start, end }: Props) => JSX.Element;
|
|
7
10
|
export default Footer;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { StyleSheet, View } from "react-native";
|
|
3
|
-
const Footer = ({
|
|
3
|
+
const Footer = ({ primary, start, end }) => (_jsxs(View, { style: styles.column, children: [primary, start || end ? (_jsxs(View, { style: styles.links, children: [_jsx(View, { children: start }), _jsx(View, { children: end })] })) : null] }));
|
|
4
4
|
const styles = StyleSheet.create({
|
|
5
|
-
|
|
5
|
+
column: { gap: 6, marginTop: 16 },
|
|
6
|
+
links: {
|
|
6
7
|
alignItems: "center",
|
|
7
8
|
flexDirection: "row",
|
|
8
9
|
justifyContent: "space-between",
|
|
9
|
-
marginTop: 16,
|
|
10
10
|
},
|
|
11
|
-
secondary: { alignItems: "center", flexDirection: "row", gap: 16 },
|
|
12
11
|
});
|
|
13
12
|
export default Footer;
|
|
@@ -3,8 +3,8 @@ import { StyleSheet, Text, View } from "react-native";
|
|
|
3
3
|
const Header = ({ title, status, theme }) => {
|
|
4
4
|
const dot = {
|
|
5
5
|
idle: theme.idle,
|
|
6
|
-
busy: theme.
|
|
7
|
-
connected: theme.
|
|
6
|
+
busy: theme.link,
|
|
7
|
+
connected: theme.session,
|
|
8
8
|
error: theme.danger,
|
|
9
9
|
}[status];
|
|
10
10
|
return (_jsxs(View, { style: styles.row, children: [_jsx(View, { style: [styles.dot, { backgroundColor: dot }] }), _jsx(Text, { style: [styles.title, { color: theme.text }], numberOfLines: 1, children: title })] }));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { JSX } from "react";
|
|
2
|
+
import type { PromptTheme } from "../theme";
|
|
3
|
+
type Props = {
|
|
4
|
+
error: string | null;
|
|
5
|
+
/** a step the user takes while it connects, e.g. the iOS Local Network question */
|
|
6
|
+
notice: string | null;
|
|
7
|
+
theme: PromptTheme;
|
|
8
|
+
};
|
|
9
|
+
/** What went wrong, or what the user has to do for the connection to go on. */
|
|
10
|
+
declare const StatusLine: ({ error, notice, theme }: Props) => JSX.Element | null;
|
|
11
|
+
export default StatusLine;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Text } from "react-native";
|
|
3
|
+
import styles from "../views/styles.js";
|
|
4
|
+
/** What went wrong, or what the user has to do for the connection to go on. */
|
|
5
|
+
const StatusLine = ({ error, notice, theme }) => {
|
|
6
|
+
if (error)
|
|
7
|
+
return _jsx(Text, { style: [styles.error, { color: theme.danger }], children: error });
|
|
8
|
+
if (notice)
|
|
9
|
+
return _jsx(Text, { style: [styles.error, { color: theme.muted }], children: notice });
|
|
10
|
+
return null;
|
|
11
|
+
};
|
|
12
|
+
export default StatusLine;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Keeps the prompt open while connecting: closes it only on success,
|
|
3
|
-
*
|
|
2
|
+
* Keeps the prompt open while connecting: closes it only on success, leaves it open with the error otherwise.
|
|
3
|
+
* On iOS a first connection that the Local Network question holds back is tried again until the user answers.
|
|
4
4
|
*/
|
|
5
5
|
declare const useConnectAwaiter: ({ visible }: {
|
|
6
6
|
visible: boolean;
|
|
7
7
|
}) => {
|
|
8
8
|
isConnecting: boolean;
|
|
9
|
+
notice: string | null;
|
|
9
10
|
startConnecting: (connectFn: () => void) => void;
|
|
10
11
|
};
|
|
11
12
|
export default useConnectAwaiter;
|
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { Platform } from "react-native";
|
|
2
3
|
import { getLastError, getSocket, hidePrompt, isConnected, setLastError, subscribeSocketState, } from "../../core/connection/index.js";
|
|
4
|
+
import { LOCAL_NETWORK, localNetworkError, localNetworkNotice, shouldWaitForLocalNetwork, } from "./local-network.js";
|
|
5
|
+
const IDLE = { isConnecting: false, notice: null };
|
|
3
6
|
/**
|
|
4
|
-
* Keeps the prompt open while connecting: closes it only on success,
|
|
5
|
-
*
|
|
7
|
+
* Keeps the prompt open while connecting: closes it only on success, leaves it open with the error otherwise.
|
|
8
|
+
* On iOS a first connection that the Local Network question holds back is tried again until the user answers.
|
|
6
9
|
*/
|
|
7
10
|
const useConnectAwaiter = ({ visible }) => {
|
|
8
|
-
const [
|
|
11
|
+
const [state, setState] = useState(IDLE);
|
|
9
12
|
const awaitingRef = useRef(false);
|
|
13
|
+
const attemptRef = useRef(null);
|
|
14
|
+
const retryRef = useRef(null);
|
|
10
15
|
const finish = useCallback(() => {
|
|
11
16
|
awaitingRef.current = false;
|
|
12
|
-
|
|
17
|
+
attemptRef.current = null;
|
|
18
|
+
if (retryRef.current)
|
|
19
|
+
clearTimeout(retryRef.current);
|
|
20
|
+
retryRef.current = null;
|
|
21
|
+
setState(IDLE);
|
|
13
22
|
}, []);
|
|
14
23
|
useEffect(() => subscribeSocketState(() => {
|
|
15
24
|
if (!awaitingRef.current)
|
|
@@ -17,18 +26,51 @@ const useConnectAwaiter = ({ visible }) => {
|
|
|
17
26
|
if (isConnected()) {
|
|
18
27
|
finish();
|
|
19
28
|
hidePrompt();
|
|
29
|
+
return;
|
|
20
30
|
}
|
|
21
|
-
|
|
22
|
-
|
|
31
|
+
const error = getLastError();
|
|
32
|
+
const attempt = attemptRef.current;
|
|
33
|
+
if (!error)
|
|
34
|
+
return;
|
|
35
|
+
if (attempt &&
|
|
36
|
+
shouldWaitForLocalNetwork({
|
|
37
|
+
platform: Platform.OS,
|
|
38
|
+
error,
|
|
39
|
+
startedAt: attempt.startedAt,
|
|
40
|
+
now: Date.now(),
|
|
41
|
+
})) {
|
|
42
|
+
if (retryRef.current)
|
|
43
|
+
return;
|
|
44
|
+
setState({
|
|
45
|
+
isConnecting: true,
|
|
46
|
+
notice: localNetworkNotice({
|
|
47
|
+
startedAt: attempt.startedAt,
|
|
48
|
+
now: Date.now(),
|
|
49
|
+
}),
|
|
50
|
+
});
|
|
51
|
+
retryRef.current = setTimeout(() => {
|
|
52
|
+
retryRef.current = null;
|
|
53
|
+
if (!awaitingRef.current)
|
|
54
|
+
return;
|
|
55
|
+
setLastError(null);
|
|
56
|
+
attempt.connectFn();
|
|
57
|
+
}, LOCAL_NETWORK.retryMs);
|
|
58
|
+
return;
|
|
23
59
|
}
|
|
60
|
+
const message = localNetworkError({ platform: Platform.OS, error });
|
|
61
|
+
if (message !== error)
|
|
62
|
+
setLastError(message);
|
|
63
|
+
finish();
|
|
24
64
|
}), [finish]);
|
|
25
65
|
useEffect(() => {
|
|
26
66
|
if (!visible)
|
|
27
67
|
finish();
|
|
28
68
|
}, [visible, finish]);
|
|
69
|
+
useEffect(() => finish, [finish]);
|
|
29
70
|
const startConnecting = useCallback((connectFn) => {
|
|
30
71
|
awaitingRef.current = true;
|
|
31
|
-
|
|
72
|
+
attemptRef.current = { connectFn, startedAt: Date.now() };
|
|
73
|
+
setState({ isConnecting: true, notice: null });
|
|
32
74
|
connectFn();
|
|
33
75
|
if (!awaitingRef.current)
|
|
34
76
|
return;
|
|
@@ -36,10 +78,14 @@ const useConnectAwaiter = ({ visible }) => {
|
|
|
36
78
|
finish();
|
|
37
79
|
hidePrompt();
|
|
38
80
|
}
|
|
39
|
-
else if (!getSocket()) {
|
|
81
|
+
else if (!getSocket() && !getLastError()) {
|
|
40
82
|
setLastError("Heimdall SDK is disabled in this build.");
|
|
41
83
|
}
|
|
42
84
|
}, [finish]);
|
|
43
|
-
return {
|
|
85
|
+
return {
|
|
86
|
+
isConnecting: state.isConnecting,
|
|
87
|
+
notice: state.notice,
|
|
88
|
+
startConnecting,
|
|
89
|
+
};
|
|
44
90
|
};
|
|
45
91
|
export default useConnectAwaiter;
|
|
@@ -6,8 +6,10 @@ type Props = {
|
|
|
6
6
|
socketError: string | null;
|
|
7
7
|
theme: PromptTheme;
|
|
8
8
|
isConnecting: boolean;
|
|
9
|
+
/** a step the user takes while it connects, e.g. the iOS Local Network question */
|
|
10
|
+
notice: string | null;
|
|
9
11
|
startConnecting: (connectFn: () => void) => void;
|
|
10
12
|
onManual: () => void;
|
|
11
13
|
};
|
|
12
|
-
declare const CloudView: ({ baseUrl, visible, socketError, theme, isConnecting, startConnecting, onManual, }: Props) => JSX.Element;
|
|
14
|
+
declare const CloudView: ({ baseUrl, visible, socketError, theme, isConnecting, notice, startConnecting, onManual, }: Props) => JSX.Element;
|
|
13
15
|
export default CloudView;
|
|
@@ -3,10 +3,11 @@ import { Text } from "react-native";
|
|
|
3
3
|
import ActionButton from "../ui/action-button.js";
|
|
4
4
|
import Footer from "../ui/footer.js";
|
|
5
5
|
import ScreenRecording from "../ui/screen-recording.js";
|
|
6
|
+
import StatusLine from "../ui/status-line.js";
|
|
6
7
|
import Header from "../ui/header.js";
|
|
7
8
|
import useCloudView from "./use-cloud-view.js";
|
|
8
9
|
import styles from "./styles.js";
|
|
9
|
-
const CloudView = ({ baseUrl, visible, socketError, theme, isConnecting, startConnecting, onManual, }) => {
|
|
10
|
+
const CloudView = ({ baseUrl, visible, socketError, theme, isConnecting, notice, startConnecting, onManual, }) => {
|
|
10
11
|
const { deviceName, phase, message, onFindMe, onCancelLinking, onConnect, onUnlink, } = useCloudView({ baseUrl, visible, startConnecting });
|
|
11
12
|
const error = isConnecting ? null : (message !== null && message !== void 0 ? message : socketError);
|
|
12
13
|
const isBusy = phase !== "idle" || isConnecting;
|
|
@@ -15,6 +16,6 @@ const CloudView = ({ baseUrl, visible, socketError, theme, isConnecting, startCo
|
|
|
15
16
|
}
|
|
16
17
|
return (_jsxs(_Fragment, { children: [_jsx(Header, { title: deviceName !== null && deviceName !== void 0 ? deviceName : "Heimdall", status: error ? "error" : isBusy ? "busy" : "idle", theme: theme }), _jsx(Text, { style: [styles.text, { color: theme.muted }], children: deviceName
|
|
17
18
|
? "Start Heimdall for this device on your Mac."
|
|
18
|
-
: "Link this device with your Heimdall account." }),
|
|
19
|
+
: "Link this device with your Heimdall account." }), _jsx(StatusLine, { error: error, notice: notice, theme: theme }), _jsx(ScreenRecording, { theme: theme }), _jsx(Footer, { start: _jsx(ActionButton, { title: "Enter manually", variant: "link", theme: theme, disabled: isBusy, onPress: onManual }), end: deviceName ? (_jsx(ActionButton, { title: "Unlink", variant: "quiet", theme: theme, disabled: isBusy, onPress: onUnlink })) : null, primary: _jsx(ActionButton, { title: isConnecting ? "Connecting…" : deviceName ? "Connect" : "Find me", theme: theme, disabled: isBusy, onPress: deviceName ? onConnect : onFindMe }) })] }));
|
|
19
20
|
};
|
|
20
21
|
export default CloudView;
|
|
@@ -6,5 +6,5 @@ import Footer from "../ui/footer.js";
|
|
|
6
6
|
import Header from "../ui/header.js";
|
|
7
7
|
import ScreenRecording from "../ui/screen-recording.js";
|
|
8
8
|
import styles from "./styles.js";
|
|
9
|
-
const ConnectedView = ({ hostLabel, channel, theme, isDark, canCopy, onCopyChannel, onClose, onDisconnect, }) => (_jsxs(_Fragment, { children: [_jsx(Header, { title: "Connected", status: "connected", theme: theme }), _jsx(Text, { style: [styles.value, { color: theme.text }], children: hostLabel }), _jsxs(View, { style: styles.channelRow, children: [_jsx(Text, { style: [styles.channel, { color: theme.muted }], numberOfLines: 1, selectable: true, children: channel }), _jsx(CopyButton, { tone: isDark ? "dark" : "light", disabled: !canCopy, onPress: onCopyChannel })] }), _jsx(ScreenRecording, { theme: theme }), _jsx(Footer, {
|
|
9
|
+
const ConnectedView = ({ hostLabel, channel, theme, isDark, canCopy, onCopyChannel, onClose, onDisconnect, }) => (_jsxs(_Fragment, { children: [_jsx(Header, { title: "Connected", status: "connected", theme: theme }), _jsx(Text, { style: [styles.value, { color: theme.text }], children: hostLabel }), _jsxs(View, { style: styles.channelRow, children: [_jsx(Text, { style: [styles.channel, { color: theme.muted }], numberOfLines: 1, selectable: true, children: channel }), _jsx(CopyButton, { tone: isDark ? "dark" : "light", disabled: !canCopy, onPress: onCopyChannel })] }), _jsx(ScreenRecording, { theme: theme }), _jsx(Footer, { start: _jsx(ActionButton, { title: "Close", variant: "link", theme: theme, onPress: onClose }), primary: _jsx(ActionButton, { title: "Disconnect", variant: "danger", theme: theme, onPress: onDisconnect }) })] }));
|
|
10
10
|
export default ConnectedView;
|
|
@@ -9,8 +9,11 @@ type Props = {
|
|
|
9
9
|
canCopy: boolean;
|
|
10
10
|
onCopyChannel: () => void;
|
|
11
11
|
onConnect: () => void;
|
|
12
|
-
|
|
12
|
+
/** back to finding the Mac through Heimdall cloud: the counterpart of “Enter manually” */
|
|
13
|
+
onAuto?: () => void;
|
|
13
14
|
isConnecting: boolean;
|
|
15
|
+
/** a step the user takes while it connects, e.g. the iOS Local Network question */
|
|
16
|
+
notice: string | null;
|
|
14
17
|
};
|
|
15
|
-
declare const ManualView: ({ ui, setUi, theme, isDark, canCopy, onCopyChannel, onConnect,
|
|
18
|
+
declare const ManualView: ({ ui, setUi, theme, isDark, canCopy, onCopyChannel, onConnect, onAuto, isConnecting, notice, }: Props) => JSX.Element;
|
|
16
19
|
export default ManualView;
|
|
@@ -5,9 +5,10 @@ import { CopyButton } from "../../copy-button/index.js";
|
|
|
5
5
|
import ActionButton from "../ui/action-button.js";
|
|
6
6
|
import Footer from "../ui/footer.js";
|
|
7
7
|
import ScreenRecording from "../ui/screen-recording.js";
|
|
8
|
+
import StatusLine from "../ui/status-line.js";
|
|
8
9
|
import Header from "../ui/header.js";
|
|
9
10
|
import styles from "./styles.js";
|
|
10
|
-
const ManualView = ({ ui, setUi, theme, isDark, canCopy, onCopyChannel, onConnect,
|
|
11
|
+
const ManualView = ({ ui, setUi, theme, isDark, canCopy, onCopyChannel, onConnect, onAuto, isConnecting, notice, }) => {
|
|
11
12
|
var _a, _b;
|
|
12
13
|
const error = isConnecting ? null : ui.errorMessage;
|
|
13
14
|
const inputStyle = [
|
|
@@ -21,6 +22,6 @@ const ManualView = ({ ui, setUi, theme, isDark, canCopy, onCopyChannel, onConnec
|
|
|
21
22
|
const labelStyle = [styles.label, { color: theme.muted }];
|
|
22
23
|
// The host matches by this code alone, so it is what people read out and type.
|
|
23
24
|
const code = (_b = (_a = parseChannel(ui.channel.trim().toLowerCase())) === null || _a === void 0 ? void 0 : _a.shortId) !== null && _b !== void 0 ? _b : null;
|
|
24
|
-
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,
|
|
25
|
+
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, _jsx(StatusLine, { error: error, notice: notice, theme: theme }), _jsx(ScreenRecording, { theme: theme }), _jsx(Footer, { start: onAuto ? (_jsx(ActionButton, { title: "Find automatically", variant: "link", theme: theme, disabled: isConnecting, onPress: onAuto })) : null, primary: _jsx(ActionButton, { title: isConnecting ? "Connecting…" : "Connect", theme: theme, disabled: isConnecting, onPress: onConnect }) })] }));
|
|
25
26
|
};
|
|
26
27
|
export default ManualView;
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.7.
|
|
1
|
+
export declare const SDK_VERSION = "0.7.1";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.7.
|
|
1
|
+
export const SDK_VERSION = "0.7.1";
|
package/package.json
CHANGED