@rnzeus/heimdall-sdk 0.0.0-stage → 0.2.2
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/LICENSE +21 -0
- package/README.md +210 -2
- package/dist/core/cloud/client.d.ts +44 -0
- package/dist/core/cloud/client.js +65 -0
- package/dist/core/cloud/index.d.ts +4 -0
- package/dist/core/cloud/index.js +4 -0
- package/dist/core/cloud/link-device.d.ts +14 -0
- package/dist/core/cloud/link-device.js +28 -0
- package/dist/core/cloud/state.d.ts +10 -0
- package/dist/core/cloud/state.js +21 -0
- package/dist/core/cloud/storage.d.ts +7 -0
- package/dist/core/cloud/storage.js +31 -0
- package/dist/core/connection/channel/generate.d.ts +10 -0
- package/dist/core/connection/channel/generate.js +22 -0
- package/dist/core/connection/channel/index.d.ts +4 -0
- package/dist/core/connection/channel/index.js +4 -0
- package/dist/core/connection/channel/parse.d.ts +9 -0
- package/dist/core/connection/channel/parse.js +27 -0
- package/dist/core/connection/channel/sanitize.d.ts +9 -0
- package/dist/core/connection/channel/sanitize.js +15 -0
- package/dist/core/connection/channel/types.d.ts +9 -0
- package/dist/core/connection/channel/types.js +1 -0
- package/dist/core/connection/index.d.ts +7 -0
- package/dist/core/connection/index.js +7 -0
- package/dist/core/connection/lifecycle/connect.d.ts +2 -0
- package/dist/core/connection/lifecycle/connect.js +46 -0
- package/dist/core/connection/lifecycle/destroy.d.ts +1 -0
- package/dist/core/connection/lifecycle/destroy.js +12 -0
- package/dist/core/connection/lifecycle/disconnect.d.ts +1 -0
- package/dist/core/connection/lifecycle/disconnect.js +10 -0
- package/dist/core/connection/lifecycle/early-events.d.ts +2 -0
- package/dist/core/connection/lifecycle/early-events.js +18 -0
- package/dist/core/connection/lifecycle/index.d.ts +5 -0
- package/dist/core/connection/lifecycle/index.js +5 -0
- package/dist/core/connection/lifecycle/keep-alive.d.ts +5 -0
- package/dist/core/connection/lifecycle/keep-alive.js +40 -0
- package/dist/core/connection/prompt/index.d.ts +1 -0
- package/dist/core/connection/prompt/index.js +1 -0
- package/dist/core/connection/prompt/prompt-state.d.ts +12 -0
- package/dist/core/connection/prompt/prompt-state.js +30 -0
- package/dist/core/connection/resolver/cloud.d.ts +4 -0
- package/dist/core/connection/resolver/cloud.js +29 -0
- package/dist/core/connection/resolver/index.d.ts +3 -0
- package/dist/core/connection/resolver/index.js +3 -0
- package/dist/core/connection/resolver/manual.d.ts +2 -0
- package/dist/core/connection/resolver/manual.js +3 -0
- package/dist/core/connection/resolver/types.d.ts +9 -0
- package/dist/core/connection/resolver/types.js +1 -0
- package/dist/core/connection/sdk-enabled.d.ts +3 -0
- package/dist/core/connection/sdk-enabled.js +10 -0
- package/dist/core/connection/session/clear-last-connection.d.ts +1 -0
- package/dist/core/connection/session/clear-last-connection.js +11 -0
- package/dist/core/connection/session/client-id.d.ts +3 -0
- package/dist/core/connection/session/client-id.js +25 -0
- package/dist/core/connection/session/constants.d.ts +14 -0
- package/dist/core/connection/session/constants.js +21 -0
- package/dist/core/connection/session/create-session.d.ts +3 -0
- package/dist/core/connection/session/create-session.js +21 -0
- package/dist/core/connection/session/index.d.ts +6 -0
- package/dist/core/connection/session/index.js +6 -0
- package/dist/core/connection/session/load-last-connection.d.ts +2 -0
- package/dist/core/connection/session/load-last-connection.js +16 -0
- package/dist/core/connection/session/state.d.ts +7 -0
- package/dist/core/connection/session/state.js +23 -0
- package/dist/core/connection/session/types.d.ts +12 -0
- package/dist/core/connection/session/types.js +1 -0
- package/dist/core/connection/socket/connect-socket.d.ts +3 -0
- package/dist/core/connection/socket/connect-socket.js +110 -0
- package/dist/core/connection/socket/constants.d.ts +4 -0
- package/dist/core/connection/socket/constants.js +4 -0
- package/dist/core/connection/socket/destroy-socket.d.ts +1 -0
- package/dist/core/connection/socket/destroy-socket.js +4 -0
- package/dist/core/connection/socket/disconnect-socket.d.ts +1 -0
- package/dist/core/connection/socket/disconnect-socket.js +26 -0
- package/dist/core/connection/socket/early-buffer.d.ts +7 -0
- package/dist/core/connection/socket/early-buffer.js +26 -0
- package/dist/core/connection/socket/flush-early-events.d.ts +1 -0
- package/dist/core/connection/socket/flush-early-events.js +18 -0
- package/dist/core/connection/socket/handle-socket-lost.d.ts +1 -0
- package/dist/core/connection/socket/handle-socket-lost.js +24 -0
- package/dist/core/connection/socket/index.d.ts +6 -0
- package/dist/core/connection/socket/index.js +6 -0
- package/dist/core/connection/socket/normalize-socket-error.d.ts +1 -0
- package/dist/core/connection/socket/normalize-socket-error.js +13 -0
- package/dist/core/connection/socket/send-event.d.ts +3 -0
- package/dist/core/connection/socket/send-event.js +45 -0
- package/dist/core/connection/socket/state.d.ts +8 -0
- package/dist/core/connection/socket/state.js +35 -0
- package/dist/core/console/index.d.ts +2 -0
- package/dist/core/console/index.js +2 -0
- package/dist/core/console/patch-console.d.ts +1 -0
- package/dist/core/console/patch-console.js +64 -0
- package/dist/core/console/restore-console.d.ts +1 -0
- package/dist/core/console/restore-console.js +28 -0
- package/dist/core/console/send-console-event.d.ts +8 -0
- package/dist/core/console/send-console-event.js +95 -0
- package/dist/core/console/state.d.ts +19 -0
- package/dist/core/console/state.js +25 -0
- package/dist/core/mmkv/index.d.ts +0 -0
- package/dist/core/mmkv/index.js +2 -0
- package/dist/core/network/get-interceptor.d.ts +11 -0
- package/dist/core/network/get-interceptor.js +19 -0
- package/dist/core/network/headers.d.ts +6 -0
- package/dist/core/network/headers.js +46 -0
- package/dist/core/network/index.d.ts +2 -0
- package/dist/core/network/index.js +2 -0
- package/dist/core/network/patch-xhr.d.ts +2 -0
- package/dist/core/network/patch-xhr.js +40 -0
- package/dist/core/network/restore-xhr.d.ts +1 -0
- package/dist/core/network/restore-xhr.js +40 -0
- package/dist/core/network/rn-blob.d.ts +1 -0
- package/dist/core/network/rn-blob.js +15 -0
- package/dist/core/network/should-skip.d.ts +2 -0
- package/dist/core/network/should-skip.js +30 -0
- package/dist/core/network/state.d.ts +5 -0
- package/dist/core/network/state.js +14 -0
- package/dist/core/network/xhr-callbacks.d.ts +12 -0
- package/dist/core/network/xhr-callbacks.js +169 -0
- package/dist/core/network/xhr-runtime-state.d.ts +4 -0
- package/dist/core/network/xhr-runtime-state.js +15 -0
- package/dist/core/network/xhr-types.d.ts +33 -0
- package/dist/core/network/xhr-types.js +1 -0
- package/dist/core/public.d.ts +2 -0
- package/dist/core/public.js +1 -0
- package/dist/core/react-query/index.d.ts +0 -0
- package/dist/core/react-query/index.js +2 -0
- package/dist/core/system/dev-server.d.ts +6 -0
- package/dist/core/system/dev-server.js +37 -0
- package/dist/core/system/device-info.d.ts +3 -0
- package/dist/core/system/device-info.js +46 -0
- package/dist/core/system/index.d.ts +2 -0
- package/dist/core/system/index.js +2 -0
- package/dist/core/websocket/index.d.ts +2 -0
- package/dist/core/websocket/index.js +2 -0
- package/dist/core/websocket/patch-websocket.d.ts +2 -0
- package/dist/core/websocket/patch-websocket.js +247 -0
- package/dist/core/websocket/restore-websocket.d.ts +1 -0
- package/dist/core/websocket/restore-websocket.js +16 -0
- package/dist/core/websocket/should-skip.d.ts +2 -0
- package/dist/core/websocket/should-skip.js +22 -0
- package/dist/core/websocket/state.d.ts +9 -0
- package/dist/core/websocket/state.js +21 -0
- package/dist/core/zustand/index.d.ts +1 -0
- package/dist/core/zustand/index.js +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/public/copy-button/component.d.ts +9 -0
- package/dist/public/copy-button/component.js +13 -0
- package/dist/public/copy-button/index.d.ts +1 -0
- package/dist/public/copy-button/index.js +1 -0
- package/dist/public/copy-button/styles.d.ts +64 -0
- package/dist/public/copy-button/styles.js +52 -0
- package/dist/public/index.d.ts +1 -0
- package/dist/public/index.js +1 -0
- package/dist/public/prompt/component.d.ts +7 -0
- package/dist/public/prompt/component.js +56 -0
- package/dist/public/prompt/index.d.ts +1 -0
- package/dist/public/prompt/index.js +1 -0
- package/dist/public/prompt/prompt-mode.d.ts +3 -0
- package/dist/public/prompt/prompt-mode.js +19 -0
- package/dist/public/prompt/styles.d.ts +23 -0
- package/dist/public/prompt/styles.js +23 -0
- package/dist/public/prompt/theme.d.ts +16 -0
- package/dist/public/prompt/theme.js +32 -0
- package/dist/public/prompt/types.d.ts +12 -0
- package/dist/public/prompt/types.js +1 -0
- package/dist/public/prompt/ui/action-button.d.ts +11 -0
- package/dist/public/prompt/ui/action-button.js +23 -0
- package/dist/public/prompt/ui/footer.d.ts +7 -0
- package/dist/public/prompt/ui/footer.js +13 -0
- package/dist/public/prompt/ui/header.d.ts +10 -0
- package/dist/public/prompt/ui/header.js +17 -0
- package/dist/public/prompt/ui/report-link.d.ts +8 -0
- package/dist/public/prompt/ui/report-link.js +19 -0
- package/dist/public/prompt/use-connect-awaiter.d.ts +11 -0
- package/dist/public/prompt/use-connect-awaiter.js +45 -0
- package/dist/public/prompt/use-prompt-animation.d.ts +17 -0
- package/dist/public/prompt/use-prompt-animation.js +53 -0
- package/dist/public/prompt/use-prompt-ui.d.ts +3 -0
- package/dist/public/prompt/use-prompt-ui.js +99 -0
- package/dist/public/prompt/use-prompt.d.ts +11 -0
- package/dist/public/prompt/use-prompt.js +43 -0
- package/dist/public/prompt/views/cloud-view.d.ts +13 -0
- package/dist/public/prompt/views/cloud-view.js +19 -0
- package/dist/public/prompt/views/connected-view.d.ts +14 -0
- package/dist/public/prompt/views/connected-view.js +9 -0
- package/dist/public/prompt/views/manual-view.d.ts +16 -0
- package/dist/public/prompt/views/manual-view.js +21 -0
- package/dist/public/prompt/views/styles.d.ts +44 -0
- package/dist/public/prompt/views/styles.js +23 -0
- package/dist/public/prompt/views/use-cloud-view.d.ts +15 -0
- package/dist/public/prompt/views/use-cloud-view.js +103 -0
- package/dist/public/public.d.ts +1 -0
- package/dist/public/public.js +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/types/options.d.ts +30 -0
- package/dist/types/options.js +1 -0
- package/dist/types/protocol.d.ts +1 -0
- package/dist/types/protocol.js +1 -0
- package/dist/types/public.d.ts +1 -0
- package/dist/types/public.js +1 -0
- package/dist/utils/body-snippet.d.ts +19 -0
- package/dist/utils/body-snippet.js +186 -0
- package/dist/utils/debug-log.d.ts +26 -0
- package/dist/utils/debug-log.js +44 -0
- package/dist/utils/generate-random-id.d.ts +1 -0
- package/dist/utils/generate-random-id.js +8 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/parse-url.d.ts +5 -0
- package/dist/utils/parse-url.js +32 -0
- package/dist/utils/safe-serialize.d.ts +6 -0
- package/dist/utils/safe-serialize.js +77 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/dist/zustand/index.d.ts +1 -0
- package/dist/zustand/index.js +1 -0
- package/dist/zustand/middleware.d.ts +18 -0
- package/dist/zustand/middleware.js +77 -0
- package/package.json +88 -4
- package/zustand/index.d.ts +1 -0
- package/zustand/index.js +1 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useColorScheme } from "react-native";
|
|
2
|
+
const LIGHT = {
|
|
3
|
+
backdrop: "rgba(0,0,0,0.38)",
|
|
4
|
+
card: "#FFFFFF",
|
|
5
|
+
text: "#111827",
|
|
6
|
+
muted: "#6B7280",
|
|
7
|
+
border: "#E5E7EB",
|
|
8
|
+
inputBackground: "#FFFFFF",
|
|
9
|
+
inputDisabledBackground: "#F3F4F6",
|
|
10
|
+
primary: "#2563EB",
|
|
11
|
+
onPrimary: "#FFFFFF",
|
|
12
|
+
danger: "#DC2626",
|
|
13
|
+
success: "#16A34A",
|
|
14
|
+
warning: "#D97706",
|
|
15
|
+
idle: "#9CA3AF",
|
|
16
|
+
};
|
|
17
|
+
const DARK = {
|
|
18
|
+
backdrop: "rgba(0,0,0,0.55)",
|
|
19
|
+
card: "#1C1F26",
|
|
20
|
+
text: "#F3F4F6",
|
|
21
|
+
muted: "#9CA3AF",
|
|
22
|
+
border: "#2D323C",
|
|
23
|
+
inputBackground: "#14171C",
|
|
24
|
+
inputDisabledBackground: "#23272F",
|
|
25
|
+
primary: "#3B82F6",
|
|
26
|
+
onPrimary: "#FFFFFF",
|
|
27
|
+
danger: "#F87171",
|
|
28
|
+
success: "#4ADE80",
|
|
29
|
+
warning: "#FBBF24",
|
|
30
|
+
idle: "#6B7280",
|
|
31
|
+
};
|
|
32
|
+
export const usePromptTheme = () => useColorScheme() === "dark" ? DARK : LIGHT;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type Props = {
|
|
2
|
+
onCopyToClipboard?: (text: string) => void;
|
|
3
|
+
};
|
|
4
|
+
export type PromptUiState = {
|
|
5
|
+
visible: boolean;
|
|
6
|
+
host: string;
|
|
7
|
+
port: string;
|
|
8
|
+
channel: string;
|
|
9
|
+
isConnected: boolean;
|
|
10
|
+
errorMessage: string | null;
|
|
11
|
+
};
|
|
12
|
+
export type UsePromptProps = Pick<PromptUiState, "host" | "port" | "channel" | "visible" | "isConnected"> & Props;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { JSX } from "react";
|
|
2
|
+
import type { PromptTheme } from "../theme";
|
|
3
|
+
type Props = {
|
|
4
|
+
title: string;
|
|
5
|
+
onPress: () => void;
|
|
6
|
+
theme: PromptTheme;
|
|
7
|
+
variant?: "primary" | "danger" | "link";
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
};
|
|
10
|
+
declare const ActionButton: ({ title, onPress, theme, variant, disabled, }: Props) => JSX.Element;
|
|
11
|
+
export default ActionButton;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Pressable, StyleSheet, Text } from "react-native";
|
|
3
|
+
const ActionButton = ({ title, onPress, theme, variant = "primary", disabled = false, }) => {
|
|
4
|
+
const isLink = variant === "link";
|
|
5
|
+
const background = isLink
|
|
6
|
+
? "transparent"
|
|
7
|
+
: variant === "danger"
|
|
8
|
+
? theme.danger
|
|
9
|
+
: theme.primary;
|
|
10
|
+
const color = isLink ? theme.primary : theme.onPrimary;
|
|
11
|
+
return (_jsx(Pressable, { onPress: onPress, disabled: disabled, hitSlop: 8, style: ({ pressed }) => [
|
|
12
|
+
isLink ? styles.link : styles.button,
|
|
13
|
+
{ backgroundColor: background },
|
|
14
|
+
(pressed || disabled) && styles.dimmed,
|
|
15
|
+
], children: _jsx(Text, { style: [styles.title, { color }], children: title }) }));
|
|
16
|
+
};
|
|
17
|
+
const styles = StyleSheet.create({
|
|
18
|
+
button: { borderRadius: 8, paddingHorizontal: 14, paddingVertical: 9 },
|
|
19
|
+
link: { paddingVertical: 9 },
|
|
20
|
+
title: { fontSize: 14, fontWeight: "600" },
|
|
21
|
+
dimmed: { opacity: 0.5 },
|
|
22
|
+
});
|
|
23
|
+
export default ActionButton;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { StyleSheet, View } from "react-native";
|
|
3
|
+
const Footer = ({ secondary, primary }) => (_jsxs(View, { style: styles.row, children: [_jsx(View, { style: styles.secondary, children: secondary }), primary] }));
|
|
4
|
+
const styles = StyleSheet.create({
|
|
5
|
+
row: {
|
|
6
|
+
alignItems: "center",
|
|
7
|
+
flexDirection: "row",
|
|
8
|
+
justifyContent: "space-between",
|
|
9
|
+
marginTop: 16,
|
|
10
|
+
},
|
|
11
|
+
secondary: { alignItems: "center", flexDirection: "row", gap: 16 },
|
|
12
|
+
});
|
|
13
|
+
export default Footer;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { JSX } from "react";
|
|
2
|
+
import type { PromptTheme } from "../theme";
|
|
3
|
+
export type HeaderStatus = "idle" | "busy" | "connected" | "error";
|
|
4
|
+
type Props = {
|
|
5
|
+
title: string;
|
|
6
|
+
status: HeaderStatus;
|
|
7
|
+
theme: PromptTheme;
|
|
8
|
+
};
|
|
9
|
+
declare const Header: ({ title, status, theme }: Props) => JSX.Element;
|
|
10
|
+
export default Header;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { StyleSheet, Text, View } from "react-native";
|
|
3
|
+
const Header = ({ title, status, theme }) => {
|
|
4
|
+
const dot = {
|
|
5
|
+
idle: theme.idle,
|
|
6
|
+
busy: theme.warning,
|
|
7
|
+
connected: theme.success,
|
|
8
|
+
error: theme.danger,
|
|
9
|
+
}[status];
|
|
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 })] }));
|
|
11
|
+
};
|
|
12
|
+
const styles = StyleSheet.create({
|
|
13
|
+
row: { alignItems: "center", flexDirection: "row", marginBottom: 8 },
|
|
14
|
+
dot: { borderRadius: 4, height: 8, marginRight: 8, width: 8 },
|
|
15
|
+
title: { flexShrink: 1, fontSize: 16, fontWeight: "600" },
|
|
16
|
+
});
|
|
17
|
+
export default Header;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Linking, Platform, Pressable, StyleSheet, Text } from "react-native";
|
|
3
|
+
import { SDK_VERSION } from "../../../version.js";
|
|
4
|
+
const feedbackUrl = (baseUrl) => {
|
|
5
|
+
const device = `${Platform.OS} ${String(Platform.Version)}`;
|
|
6
|
+
const params = [
|
|
7
|
+
"type=bug",
|
|
8
|
+
"product=sdk",
|
|
9
|
+
`sdkVersion=${encodeURIComponent(SDK_VERSION)}`,
|
|
10
|
+
`device=${encodeURIComponent(device)}`,
|
|
11
|
+
];
|
|
12
|
+
return `${baseUrl.replace(/\/+$/, "")}/feedback/new?${params.join("&")}`;
|
|
13
|
+
};
|
|
14
|
+
const ReportLink = ({ baseUrl, theme }) => (_jsx(Pressable, { hitSlop: 8, style: styles.container, onPress: () => void Linking.openURL(feedbackUrl(baseUrl)), children: _jsx(Text, { style: [styles.text, { color: theme.muted }], children: "Report a problem" }) }));
|
|
15
|
+
const styles = StyleSheet.create({
|
|
16
|
+
container: { alignSelf: "center", marginTop: 14 },
|
|
17
|
+
text: { fontSize: 12, textDecorationLine: "underline" },
|
|
18
|
+
});
|
|
19
|
+
export default ReportLink;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeps the prompt open while connecting: closes it only on success,
|
|
3
|
+
* leaves it open with the error otherwise.
|
|
4
|
+
*/
|
|
5
|
+
declare const useConnectAwaiter: ({ visible }: {
|
|
6
|
+
visible: boolean;
|
|
7
|
+
}) => {
|
|
8
|
+
isConnecting: boolean;
|
|
9
|
+
startConnecting: (connectFn: () => void) => void;
|
|
10
|
+
};
|
|
11
|
+
export default useConnectAwaiter;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { getLastError, getSocket, hidePrompt, isConnected, setLastError, subscribeSocketState, } from "../../core/connection/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Keeps the prompt open while connecting: closes it only on success,
|
|
5
|
+
* leaves it open with the error otherwise.
|
|
6
|
+
*/
|
|
7
|
+
const useConnectAwaiter = ({ visible }) => {
|
|
8
|
+
const [isConnecting, setConnecting] = useState(false);
|
|
9
|
+
const awaitingRef = useRef(false);
|
|
10
|
+
const finish = useCallback(() => {
|
|
11
|
+
awaitingRef.current = false;
|
|
12
|
+
setConnecting(false);
|
|
13
|
+
}, []);
|
|
14
|
+
useEffect(() => subscribeSocketState(() => {
|
|
15
|
+
if (!awaitingRef.current)
|
|
16
|
+
return;
|
|
17
|
+
if (isConnected()) {
|
|
18
|
+
finish();
|
|
19
|
+
hidePrompt();
|
|
20
|
+
}
|
|
21
|
+
else if (getLastError()) {
|
|
22
|
+
finish();
|
|
23
|
+
}
|
|
24
|
+
}), [finish]);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (!visible)
|
|
27
|
+
finish();
|
|
28
|
+
}, [visible, finish]);
|
|
29
|
+
const startConnecting = useCallback((connectFn) => {
|
|
30
|
+
awaitingRef.current = true;
|
|
31
|
+
setConnecting(true);
|
|
32
|
+
connectFn();
|
|
33
|
+
if (!awaitingRef.current)
|
|
34
|
+
return;
|
|
35
|
+
if (isConnected()) {
|
|
36
|
+
finish();
|
|
37
|
+
hidePrompt();
|
|
38
|
+
}
|
|
39
|
+
else if (!getSocket()) {
|
|
40
|
+
setLastError("Heimdall SDK is disabled in this build.");
|
|
41
|
+
}
|
|
42
|
+
}, [finish]);
|
|
43
|
+
return { isConnecting, startConnecting };
|
|
44
|
+
};
|
|
45
|
+
export default useConnectAwaiter;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Animated } from "react-native";
|
|
2
|
+
type UsePromptAnimationParams = {
|
|
3
|
+
visible: boolean;
|
|
4
|
+
inDurationMs?: number;
|
|
5
|
+
outDurationMs?: number;
|
|
6
|
+
fromScale?: number;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Keeps the component mounted during fade-out so the animation can complete.
|
|
10
|
+
* Returns Animated.Values for opacity/scale and a `mounted` flag for render gating.
|
|
11
|
+
*/
|
|
12
|
+
declare const usePromptAnimation: ({ visible, inDurationMs, outDurationMs, fromScale, }: UsePromptAnimationParams) => {
|
|
13
|
+
readonly mounted: boolean;
|
|
14
|
+
readonly opacity: Animated.Value;
|
|
15
|
+
readonly scale: Animated.Value;
|
|
16
|
+
};
|
|
17
|
+
export default usePromptAnimation;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { Animated } from "react-native";
|
|
3
|
+
/**
|
|
4
|
+
* Keeps the component mounted during fade-out so the animation can complete.
|
|
5
|
+
* Returns Animated.Values for opacity/scale and a `mounted` flag for render gating.
|
|
6
|
+
*/
|
|
7
|
+
const usePromptAnimation = ({ visible, inDurationMs = 160, outDurationMs = 140, fromScale = 0.98, }) => {
|
|
8
|
+
const [mounted, setMounted] = useState(visible);
|
|
9
|
+
const opacity = useRef(new Animated.Value(visible ? 1 : 0)).current;
|
|
10
|
+
const scale = useRef(new Animated.Value(visible ? 1 : fromScale)).current;
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
let cancelled = false;
|
|
13
|
+
if (visible) {
|
|
14
|
+
setMounted(true);
|
|
15
|
+
Animated.parallel([
|
|
16
|
+
Animated.timing(opacity, {
|
|
17
|
+
toValue: 1,
|
|
18
|
+
duration: inDurationMs,
|
|
19
|
+
useNativeDriver: true,
|
|
20
|
+
}),
|
|
21
|
+
Animated.timing(scale, {
|
|
22
|
+
toValue: 1,
|
|
23
|
+
duration: inDurationMs,
|
|
24
|
+
useNativeDriver: true,
|
|
25
|
+
}),
|
|
26
|
+
]).start();
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
Animated.parallel([
|
|
30
|
+
Animated.timing(opacity, {
|
|
31
|
+
toValue: 0,
|
|
32
|
+
duration: outDurationMs,
|
|
33
|
+
useNativeDriver: true,
|
|
34
|
+
}),
|
|
35
|
+
Animated.timing(scale, {
|
|
36
|
+
toValue: fromScale,
|
|
37
|
+
duration: outDurationMs,
|
|
38
|
+
useNativeDriver: true,
|
|
39
|
+
}),
|
|
40
|
+
]).start(({ finished }) => {
|
|
41
|
+
if (cancelled)
|
|
42
|
+
return;
|
|
43
|
+
if (finished)
|
|
44
|
+
setMounted(false);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return () => {
|
|
48
|
+
cancelled = true;
|
|
49
|
+
};
|
|
50
|
+
}, [visible, inDurationMs, outDurationMs, fromScale, opacity, scale]);
|
|
51
|
+
return { mounted, opacity, scale };
|
|
52
|
+
};
|
|
53
|
+
export default usePromptAnimation;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { generateChannelId, getCurrentChannel, getCurrentHost, getCurrentPort, getLastError, getPromptState, isConnected, loadLastConnection, subscribePrompt, subscribeSocketState, } from "../../core/connection/index.js";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
const usePromptUi = () => {
|
|
4
|
+
const initialPrompt = getPromptState();
|
|
5
|
+
const initiallyConnected = isConnected();
|
|
6
|
+
const currentHost = getCurrentHost();
|
|
7
|
+
const currentPort = getCurrentPort();
|
|
8
|
+
const currentChannel = getCurrentChannel();
|
|
9
|
+
const initialError = getLastError();
|
|
10
|
+
const [ui, setUi] = useState(() => {
|
|
11
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
12
|
+
const last = loadLastConnection();
|
|
13
|
+
const defaultHost = (_c = (_a = last === null || last === void 0 ? void 0 : last.host) !== null && _a !== void 0 ? _a : (_b = initialPrompt.defaults) === null || _b === void 0 ? void 0 : _b.host) !== null && _c !== void 0 ? _c : "127.0.0.1";
|
|
14
|
+
const defaultPort = String((_f = (_d = last === null || last === void 0 ? void 0 : last.port) !== null && _d !== void 0 ? _d : (_e = initialPrompt.defaults) === null || _e === void 0 ? void 0 : _e.port) !== null && _f !== void 0 ? _f : 35678);
|
|
15
|
+
const defaultChannel = (_g = last === null || last === void 0 ? void 0 : last.channel) !== null && _g !== void 0 ? _g : generateChannelId("session");
|
|
16
|
+
return {
|
|
17
|
+
visible: initialPrompt.visible,
|
|
18
|
+
host: initiallyConnected && currentHost ? currentHost : defaultHost,
|
|
19
|
+
port: initiallyConnected && currentPort != null
|
|
20
|
+
? String(currentPort)
|
|
21
|
+
: defaultPort,
|
|
22
|
+
channel: initiallyConnected && currentChannel ? currentChannel : defaultChannel,
|
|
23
|
+
isConnected: initiallyConnected,
|
|
24
|
+
errorMessage: initialError !== null && initialError !== void 0 ? initialError : null,
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const unsubscribe = subscribePrompt(() => {
|
|
29
|
+
const s = getPromptState();
|
|
30
|
+
const connectedNow = isConnected();
|
|
31
|
+
const chHost = getCurrentHost();
|
|
32
|
+
const chPort = getCurrentPort();
|
|
33
|
+
const chChannel = getCurrentChannel();
|
|
34
|
+
const lastError = getLastError();
|
|
35
|
+
setUi((prev) => {
|
|
36
|
+
var _a, _b, _c, _d, _e, _f;
|
|
37
|
+
// modal just opened
|
|
38
|
+
if (s.visible && !prev.visible) {
|
|
39
|
+
if (connectedNow && chHost && chPort != null && chChannel) {
|
|
40
|
+
return {
|
|
41
|
+
visible: true,
|
|
42
|
+
host: chHost,
|
|
43
|
+
port: String(chPort),
|
|
44
|
+
channel: chChannel,
|
|
45
|
+
isConnected: true,
|
|
46
|
+
errorMessage: null,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const defaults = s.defaults;
|
|
50
|
+
const last = loadLastConnection();
|
|
51
|
+
const host = (_c = (_b = (_a = last === null || last === void 0 ? void 0 : last.host) !== null && _a !== void 0 ? _a : defaults === null || defaults === void 0 ? void 0 : defaults.host) !== null && _b !== void 0 ? _b : prev.host) !== null && _c !== void 0 ? _c : "127.0.0.1";
|
|
52
|
+
const port = String((_e = (_d = last === null || last === void 0 ? void 0 : last.port) !== null && _d !== void 0 ? _d : defaults === null || defaults === void 0 ? void 0 : defaults.port) !== null && _e !== void 0 ? _e : (Number(prev.port) || 35678));
|
|
53
|
+
const channel = (_f = last === null || last === void 0 ? void 0 : last.channel) !== null && _f !== void 0 ? _f : (prev.channel && !prev.isConnected
|
|
54
|
+
? prev.channel
|
|
55
|
+
: generateChannelId("session"));
|
|
56
|
+
return {
|
|
57
|
+
visible: true,
|
|
58
|
+
host,
|
|
59
|
+
port,
|
|
60
|
+
channel,
|
|
61
|
+
isConnected: false,
|
|
62
|
+
errorMessage: lastError !== null && lastError !== void 0 ? lastError : null,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
// just synchronize visible and error
|
|
66
|
+
return {
|
|
67
|
+
...prev,
|
|
68
|
+
visible: s.visible,
|
|
69
|
+
isConnected: connectedNow,
|
|
70
|
+
errorMessage: lastError !== null && lastError !== void 0 ? lastError : null,
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
return unsubscribe;
|
|
75
|
+
}, []);
|
|
76
|
+
useEffect(() => subscribeSocketState(() => {
|
|
77
|
+
const connectedNow = isConnected();
|
|
78
|
+
const lastError = getLastError();
|
|
79
|
+
setUi((prev) => {
|
|
80
|
+
var _a, _b;
|
|
81
|
+
return ({
|
|
82
|
+
...prev,
|
|
83
|
+
isConnected: connectedNow,
|
|
84
|
+
errorMessage: lastError !== null && lastError !== void 0 ? lastError : null,
|
|
85
|
+
...(connectedNow
|
|
86
|
+
? {
|
|
87
|
+
host: (_a = getCurrentHost()) !== null && _a !== void 0 ? _a : prev.host,
|
|
88
|
+
port: getCurrentPort() != null
|
|
89
|
+
? String(getCurrentPort())
|
|
90
|
+
: prev.port,
|
|
91
|
+
channel: (_b = getCurrentChannel()) !== null && _b !== void 0 ? _b : prev.channel,
|
|
92
|
+
}
|
|
93
|
+
: {}),
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
}), []);
|
|
97
|
+
return [ui, setUi];
|
|
98
|
+
};
|
|
99
|
+
export default usePromptUi;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { UsePromptProps } from "./types";
|
|
2
|
+
declare const usePrompt: (props: UsePromptProps & {
|
|
3
|
+
startConnecting: (connectFn: () => void) => void;
|
|
4
|
+
}) => {
|
|
5
|
+
onCancel: () => void;
|
|
6
|
+
onConfirmConnect: () => void;
|
|
7
|
+
onConfirmDisconnect: () => void;
|
|
8
|
+
isInputDisabled: boolean;
|
|
9
|
+
handleCopyChannel: () => void;
|
|
10
|
+
};
|
|
11
|
+
export default usePrompt;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { connect, disconnect, getPromptState, hidePrompt, isChannel, sanitizeChannelSlug, } from "../../core/connection/index.js";
|
|
3
|
+
import { generateChannelId } from "../../core/connection/index.js";
|
|
4
|
+
const usePrompt = (props) => {
|
|
5
|
+
const onCancel = () => {
|
|
6
|
+
hidePrompt();
|
|
7
|
+
};
|
|
8
|
+
const onConfirmConnect = () => {
|
|
9
|
+
const state = getPromptState();
|
|
10
|
+
const defaults = state.defaults;
|
|
11
|
+
if (!defaults) {
|
|
12
|
+
hidePrompt();
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const host = props.host.trim() || defaults.host;
|
|
16
|
+
const portNum = Number(props.port);
|
|
17
|
+
const port = Number.isFinite(portNum) && portNum > 0 ? portNum : defaults.port;
|
|
18
|
+
let channel = props.channel.trim();
|
|
19
|
+
if (!isChannel(channel)) {
|
|
20
|
+
const slug = sanitizeChannelSlug(channel || "session");
|
|
21
|
+
channel = generateChannelId(slug);
|
|
22
|
+
}
|
|
23
|
+
props.startConnecting(() => connect({ ...defaults, channel, host, port }));
|
|
24
|
+
};
|
|
25
|
+
const onConfirmDisconnect = () => {
|
|
26
|
+
disconnect();
|
|
27
|
+
hidePrompt();
|
|
28
|
+
};
|
|
29
|
+
const isInputDisabled = useMemo(() => props.isConnected, [props.isConnected]);
|
|
30
|
+
const handleCopyChannel = () => {
|
|
31
|
+
if (!props.channel || !props.onCopyToClipboard)
|
|
32
|
+
return;
|
|
33
|
+
props.onCopyToClipboard(props.channel);
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
onCancel,
|
|
37
|
+
onConfirmConnect,
|
|
38
|
+
onConfirmDisconnect,
|
|
39
|
+
isInputDisabled,
|
|
40
|
+
handleCopyChannel,
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export default usePrompt;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { JSX } from "react";
|
|
2
|
+
import type { PromptTheme } from "../theme";
|
|
3
|
+
type Props = {
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
visible: boolean;
|
|
6
|
+
socketError: string | null;
|
|
7
|
+
theme: PromptTheme;
|
|
8
|
+
isConnecting: boolean;
|
|
9
|
+
startConnecting: (connectFn: () => void) => void;
|
|
10
|
+
onManual: () => void;
|
|
11
|
+
};
|
|
12
|
+
declare const CloudView: ({ baseUrl, visible, socketError, theme, isConnecting, startConnecting, onManual, }: Props) => JSX.Element;
|
|
13
|
+
export default CloudView;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Text } from "react-native";
|
|
3
|
+
import ActionButton from "../ui/action-button.js";
|
|
4
|
+
import Footer from "../ui/footer.js";
|
|
5
|
+
import Header from "../ui/header.js";
|
|
6
|
+
import useCloudView from "./use-cloud-view.js";
|
|
7
|
+
import styles from "./styles.js";
|
|
8
|
+
const CloudView = ({ baseUrl, visible, socketError, theme, isConnecting, startConnecting, onManual, }) => {
|
|
9
|
+
const { deviceName, phase, message, onFindMe, onCancelLinking, onConnect, onUnlink, } = useCloudView({ baseUrl, visible, startConnecting });
|
|
10
|
+
const error = isConnecting ? null : (message !== null && message !== void 0 ? message : socketError);
|
|
11
|
+
const isBusy = phase !== "idle" || isConnecting;
|
|
12
|
+
if (phase === "linking") {
|
|
13
|
+
return (_jsxs(_Fragment, { children: [_jsx(Header, { title: "Heimdall", status: "busy", theme: theme }), _jsx(Text, { style: [styles.text, { color: theme.muted }], children: "Sign in and pick this device in the browser, then come back." }), _jsx(Footer, { primary: _jsx(ActionButton, { title: "Cancel", variant: "link", theme: theme, onPress: onCancelLinking }) })] }));
|
|
14
|
+
}
|
|
15
|
+
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
|
|
16
|
+
? "Start Heimdall for this device on your Mac."
|
|
17
|
+
: "Link this device with your Heimdall account." }), error ? (_jsx(Text, { style: [styles.error, { color: theme.danger }], children: error })) : null, _jsx(Footer, { secondary: _jsxs(_Fragment, { children: [deviceName ? (_jsx(ActionButton, { title: "Unlink", variant: "link", theme: theme, disabled: isBusy, onPress: onUnlink })) : null, _jsx(ActionButton, { title: "Enter manually", variant: "link", theme: theme, disabled: isBusy, onPress: onManual })] }), primary: _jsx(ActionButton, { title: isConnecting ? "Connecting…" : deviceName ? "Connect" : "Find me", theme: theme, disabled: isBusy, onPress: deviceName ? onConnect : onFindMe }) })] }));
|
|
18
|
+
};
|
|
19
|
+
export default CloudView;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { JSX } from "react";
|
|
2
|
+
import type { PromptTheme } from "../theme";
|
|
3
|
+
type Props = {
|
|
4
|
+
hostLabel: string;
|
|
5
|
+
channel: string;
|
|
6
|
+
theme: PromptTheme;
|
|
7
|
+
isDark: boolean;
|
|
8
|
+
canCopy: boolean;
|
|
9
|
+
onCopyChannel: () => void;
|
|
10
|
+
onClose: () => void;
|
|
11
|
+
onDisconnect: () => void;
|
|
12
|
+
};
|
|
13
|
+
declare const ConnectedView: ({ hostLabel, channel, theme, isDark, canCopy, onCopyChannel, onClose, onDisconnect, }: Props) => JSX.Element;
|
|
14
|
+
export default ConnectedView;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Text, View } from "react-native";
|
|
3
|
+
import { CopyButton } from "../../copy-button/index.js";
|
|
4
|
+
import ActionButton from "../ui/action-button.js";
|
|
5
|
+
import Footer from "../ui/footer.js";
|
|
6
|
+
import Header from "../ui/header.js";
|
|
7
|
+
import styles from "./styles.js";
|
|
8
|
+
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(Footer, { secondary: _jsx(ActionButton, { title: "Close", variant: "link", theme: theme, onPress: onClose }), primary: _jsx(ActionButton, { title: "Disconnect", variant: "danger", theme: theme, onPress: onDisconnect }) })] }));
|
|
9
|
+
export default ConnectedView;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Dispatch, JSX, SetStateAction } from "react";
|
|
2
|
+
import type { PromptTheme } from "../theme";
|
|
3
|
+
import type { PromptUiState } from "../types";
|
|
4
|
+
type Props = {
|
|
5
|
+
ui: PromptUiState;
|
|
6
|
+
setUi: Dispatch<SetStateAction<PromptUiState>>;
|
|
7
|
+
theme: PromptTheme;
|
|
8
|
+
isDark: boolean;
|
|
9
|
+
canCopy: boolean;
|
|
10
|
+
onCopyChannel: () => void;
|
|
11
|
+
onConnect: () => void;
|
|
12
|
+
onBack?: () => void;
|
|
13
|
+
isConnecting: boolean;
|
|
14
|
+
};
|
|
15
|
+
declare const ManualView: ({ ui, setUi, theme, isDark, canCopy, onCopyChannel, onConnect, onBack, isConnecting, }: Props) => JSX.Element;
|
|
16
|
+
export default ManualView;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Text, TextInput, View } from "react-native";
|
|
3
|
+
import { CopyButton } from "../../copy-button/index.js";
|
|
4
|
+
import ActionButton from "../ui/action-button.js";
|
|
5
|
+
import Footer from "../ui/footer.js";
|
|
6
|
+
import Header from "../ui/header.js";
|
|
7
|
+
import styles from "./styles.js";
|
|
8
|
+
const ManualView = ({ ui, setUi, theme, isDark, canCopy, onCopyChannel, onConnect, onBack, isConnecting, }) => {
|
|
9
|
+
const error = isConnecting ? null : ui.errorMessage;
|
|
10
|
+
const inputStyle = [
|
|
11
|
+
styles.input,
|
|
12
|
+
{
|
|
13
|
+
backgroundColor: theme.inputBackground,
|
|
14
|
+
borderColor: theme.border,
|
|
15
|
+
color: theme.text,
|
|
16
|
+
},
|
|
17
|
+
];
|
|
18
|
+
const labelStyle = [styles.label, { color: theme.muted }];
|
|
19
|
+
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 })] }), 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
|
+
};
|
|
21
|
+
export default ManualView;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
text: {
|
|
3
|
+
fontSize: number;
|
|
4
|
+
lineHeight: number;
|
|
5
|
+
};
|
|
6
|
+
error: {
|
|
7
|
+
fontSize: number;
|
|
8
|
+
marginTop: number;
|
|
9
|
+
};
|
|
10
|
+
label: {
|
|
11
|
+
fontSize: number;
|
|
12
|
+
marginBottom: number;
|
|
13
|
+
marginTop: number;
|
|
14
|
+
};
|
|
15
|
+
input: {
|
|
16
|
+
borderRadius: number;
|
|
17
|
+
borderWidth: number;
|
|
18
|
+
fontSize: number;
|
|
19
|
+
paddingHorizontal: number;
|
|
20
|
+
paddingVertical: number;
|
|
21
|
+
};
|
|
22
|
+
inputRow: {
|
|
23
|
+
alignItems: "center";
|
|
24
|
+
flexDirection: "row";
|
|
25
|
+
gap: number;
|
|
26
|
+
};
|
|
27
|
+
inputFlex: {
|
|
28
|
+
flex: number;
|
|
29
|
+
};
|
|
30
|
+
value: {
|
|
31
|
+
fontSize: number;
|
|
32
|
+
};
|
|
33
|
+
channelRow: {
|
|
34
|
+
alignItems: "center";
|
|
35
|
+
flexDirection: "row";
|
|
36
|
+
gap: number;
|
|
37
|
+
marginTop: number;
|
|
38
|
+
};
|
|
39
|
+
channel: {
|
|
40
|
+
flexShrink: number;
|
|
41
|
+
fontSize: number;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export default _default;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Platform, StyleSheet } from "react-native";
|
|
2
|
+
export default StyleSheet.create({
|
|
3
|
+
text: { fontSize: 13, lineHeight: 18 },
|
|
4
|
+
error: { fontSize: 12, marginTop: 8 },
|
|
5
|
+
label: { fontSize: 11, marginBottom: 4, marginTop: 8 },
|
|
6
|
+
input: {
|
|
7
|
+
borderRadius: 8,
|
|
8
|
+
borderWidth: 1,
|
|
9
|
+
fontSize: 13,
|
|
10
|
+
paddingHorizontal: 10,
|
|
11
|
+
paddingVertical: Platform.OS === "ios" ? 9 : 5,
|
|
12
|
+
},
|
|
13
|
+
inputRow: { alignItems: "center", flexDirection: "row", gap: 8 },
|
|
14
|
+
inputFlex: { flex: 1 },
|
|
15
|
+
value: { fontSize: 13 },
|
|
16
|
+
channelRow: {
|
|
17
|
+
alignItems: "center",
|
|
18
|
+
flexDirection: "row",
|
|
19
|
+
gap: 8,
|
|
20
|
+
marginTop: 4,
|
|
21
|
+
},
|
|
22
|
+
channel: { flexShrink: 1, fontSize: 12 },
|
|
23
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type Phase = "idle" | "linking" | "connecting";
|
|
2
|
+
declare const useCloudView: ({ baseUrl, visible, startConnecting, }: {
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
visible: boolean;
|
|
5
|
+
startConnecting: (connectFn: () => void) => void;
|
|
6
|
+
}) => {
|
|
7
|
+
deviceName: string | null;
|
|
8
|
+
phase: Phase;
|
|
9
|
+
message: string | null;
|
|
10
|
+
onFindMe: () => Promise<void>;
|
|
11
|
+
onCancelLinking: () => void;
|
|
12
|
+
onConnect: () => Promise<void>;
|
|
13
|
+
onUnlink: () => Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
export default useCloudView;
|