diff --git a/package.json b/package.json index 638dedd6..3da5ed12 100644 --- a/package.json +++ b/package.json @@ -147,8 +147,7 @@ "react-scroll": "^1.8.2", "react-virtualized-auto-sizer": "^1.0.5", "react-virtuoso": "^1.10.4", - "revolt-api": "0.5.3-alpha.12", - "revolt.js": "5.2.8", + "revolt.js": "6.0.0-rc.3", "rimraf": "^3.0.2", "sass": "^1.35.1", "shade-blend-color": "^1.0.0", diff --git a/src/components/common/AgeGate.tsx b/src/components/common/AgeGate.tsx index ee25d947..6641877b 100644 --- a/src/components/common/AgeGate.tsx +++ b/src/components/common/AgeGate.tsx @@ -1,6 +1,6 @@ import { observer } from "mobx-react-lite"; import { useHistory } from "react-router-dom"; -import { Channel } from "revolt.js/dist/maps/Channels"; +import { Channel } from "revolt.js"; import styled from "styled-components/macro"; import { Text } from "preact-i18n"; diff --git a/src/components/common/AutoComplete.tsx b/src/components/common/AutoComplete.tsx index cb03c6cb..3d038537 100644 --- a/src/components/common/AutoComplete.tsx +++ b/src/components/common/AutoComplete.tsx @@ -1,5 +1,4 @@ -import { Channel } from "revolt.js/dist/maps/Channels"; -import { User } from "revolt.js/dist/maps/Users"; +import { Channel, User } from "revolt.js"; import styled, { css } from "styled-components/macro"; import { StateUpdater, useState } from "preact/hooks"; diff --git a/src/components/common/ChannelIcon.tsx b/src/components/common/ChannelIcon.tsx index a7828338..92fafcaa 100644 --- a/src/components/common/ChannelIcon.tsx +++ b/src/components/common/ChannelIcon.tsx @@ -1,14 +1,15 @@ import { Hash, VolumeFull } from "@styled-icons/boxicons-regular"; import { observer } from "mobx-react-lite"; -import { Channel } from "revolt.js/dist/maps/Channels"; +import { Channel } from "revolt.js"; import { useContext } from "preact/hooks"; import { AppContext } from "../../context/revoltjs/RevoltClient"; -import { ImageIconBase, IconBaseProps } from "./IconBase"; import fallback from "./assets/group.png"; +import { ImageIconBase, IconBaseProps } from "./IconBase"; + interface Props extends IconBaseProps { isServerChannel?: boolean; } @@ -32,7 +33,7 @@ export default observer( ...imgProps } = props; const iconURL = client.generateFileURL( - target?.icon ?? attachment, + target?.icon ?? attachment ?? undefined, { max_side: 256 }, animate, ); diff --git a/src/components/common/IconBase.tsx b/src/components/common/IconBase.tsx index 2bbfb8b9..66e85a8a 100644 --- a/src/components/common/IconBase.tsx +++ b/src/components/common/IconBase.tsx @@ -1,10 +1,11 @@ -import { Attachment } from "revolt-api/types/Autumn"; +import { API } from "revolt.js"; +import { Nullable } from "revolt.js/dist/util/null"; import styled, { css } from "styled-components/macro"; export interface IconBaseProps { target?: T; url?: string; - attachment?: Attachment; + attachment?: Nullable; size: number; hover?: boolean; diff --git a/src/components/common/ServerHeader.tsx b/src/components/common/ServerHeader.tsx index 5bdc8cd2..db72bbad 100644 --- a/src/components/common/ServerHeader.tsx +++ b/src/components/common/ServerHeader.tsx @@ -2,8 +2,7 @@ import { Check } from "@styled-icons/boxicons-regular"; import { Cog } from "@styled-icons/boxicons-solid"; import { observer } from "mobx-react-lite"; import { Link } from "react-router-dom"; -import { Permission } from "revolt.js/dist/api/permissions"; -import { Server } from "revolt.js/dist/maps/Servers"; +import { Server } from "revolt.js"; import styled, { css } from "styled-components/macro"; import { Text } from "preact-i18n"; diff --git a/src/components/common/ServerIcon.tsx b/src/components/common/ServerIcon.tsx index ae0bec93..282e9d73 100644 --- a/src/components/common/ServerIcon.tsx +++ b/src/components/common/ServerIcon.tsx @@ -1,5 +1,5 @@ import { observer } from "mobx-react-lite"; -import { Server } from "revolt.js/dist/maps/Servers"; +import { Server } from "revolt.js"; import styled from "styled-components/macro"; import { useContext } from "preact/hooks"; @@ -39,7 +39,7 @@ export default observer( const { target, attachment, size, animate, server_name, ...imgProps } = props; const iconURL = client.generateFileURL( - target?.icon ?? attachment, + target?.icon ?? attachment ?? undefined, { max_side: 256 }, animate, ); diff --git a/src/components/common/messaging/Message.tsx b/src/components/common/messaging/Message.tsx index 7f64f65c..dc4bfafd 100644 --- a/src/components/common/messaging/Message.tsx +++ b/src/components/common/messaging/Message.tsx @@ -1,5 +1,5 @@ import { observer } from "mobx-react-lite"; -import { Message as MessageObject } from "revolt.js/dist/maps/Messages"; +import { Message as MessageObject } from "revolt.js"; import { attachContextMenu } from "preact-context-menu"; import { memo } from "preact/compat"; diff --git a/src/components/common/messaging/MessageBase.tsx b/src/components/common/messaging/MessageBase.tsx index c6b2bf5e..863ba567 100644 --- a/src/components/common/messaging/MessageBase.tsx +++ b/src/components/common/messaging/MessageBase.tsx @@ -1,5 +1,5 @@ import { observer } from "mobx-react-lite"; -import { Message } from "revolt.js/dist/maps/Messages"; +import { Message } from "revolt.js"; import styled, { css, keyframes } from "styled-components/macro"; import { decodeTime } from "ulid"; diff --git a/src/components/common/messaging/MessageBox.tsx b/src/components/common/messaging/MessageBox.tsx index cce10c94..4a64f4c7 100644 --- a/src/components/common/messaging/MessageBox.tsx +++ b/src/components/common/messaging/MessageBox.tsx @@ -1,8 +1,7 @@ -import { Send, ShieldX, HappyBeaming, Box } from "@styled-icons/boxicons-solid"; +import { Send, ShieldX } from "@styled-icons/boxicons-solid"; import Axios, { CancelTokenSource } from "axios"; import { observer } from "mobx-react-lite"; -import { Permission } from "revolt.js/dist/api/permissions"; -import { Channel } from "revolt.js/dist/maps/Channels"; +import { Channel, Permission } from "revolt.js"; import styled, { css } from "styled-components/macro"; import { ulid } from "ulid"; diff --git a/src/components/common/messaging/SystemMessage.tsx b/src/components/common/messaging/SystemMessage.tsx index 66a84685..e96fdd74 100644 --- a/src/components/common/messaging/SystemMessage.tsx +++ b/src/components/common/messaging/SystemMessage.tsx @@ -11,8 +11,7 @@ import { MessageSquareEdit, } from "@styled-icons/boxicons-solid"; import { observer } from "mobx-react-lite"; -import { SystemMessage as SystemMessageI } from "revolt-api/types/Channels"; -import { Message } from "revolt.js/dist/maps/Messages"; +import { Message, API } from "revolt.js"; import styled from "styled-components/macro"; import { attachContextMenu } from "preact-context-menu"; @@ -75,7 +74,8 @@ export const SystemMessage = observer( ({ attachContext, message, highlight, hideInfo }: Props) => { const data = message.asSystemMessage; const SystemMessageIcon = - iconDictionary[data.type as SystemMessageI["type"]] ?? InfoCircle; + iconDictionary[data.type as API.SystemMessage["type"]] ?? + InfoCircle; let children; switch (data.type) { diff --git a/src/components/common/messaging/attachments/Attachment.tsx b/src/components/common/messaging/attachments/Attachment.tsx index 4ac53214..a4e30497 100644 --- a/src/components/common/messaging/attachments/Attachment.tsx +++ b/src/components/common/messaging/attachments/Attachment.tsx @@ -1,4 +1,4 @@ -import { Attachment as AttachmentI } from "revolt-api/types/Autumn"; +import { API } from "revolt.js"; import styles from "./Attachment.module.scss"; import classNames from "classnames"; @@ -14,7 +14,7 @@ import Spoiler from "./Spoiler"; import TextFile from "./TextFile"; interface Props { - attachment: AttachmentI; + attachment: API.File; hasContent?: boolean; } diff --git a/src/components/common/messaging/attachments/AttachmentActions.tsx b/src/components/common/messaging/attachments/AttachmentActions.tsx index 6122d2a3..9db29ac6 100644 --- a/src/components/common/messaging/attachments/AttachmentActions.tsx +++ b/src/components/common/messaging/attachments/AttachmentActions.tsx @@ -4,7 +4,7 @@ import { Download, } from "@styled-icons/boxicons-regular"; import { File, Video } from "@styled-icons/boxicons-solid"; -import { Attachment } from "revolt-api/types/Autumn"; +import { API } from "revolt.js"; import styles from "./AttachmentActions.module.scss"; import classNames from "classnames"; @@ -17,7 +17,7 @@ import { AppContext } from "../../../../context/revoltjs/RevoltClient"; import IconButton from "../../../ui/IconButton"; interface Props { - attachment: Attachment; + attachment: API.File; } export default function AttachmentActions({ attachment }: Props) { diff --git a/src/components/common/messaging/attachments/ImageFile.tsx b/src/components/common/messaging/attachments/ImageFile.tsx index 3108ff00..252387b2 100644 --- a/src/components/common/messaging/attachments/ImageFile.tsx +++ b/src/components/common/messaging/attachments/ImageFile.tsx @@ -1,4 +1,4 @@ -import { Attachment } from "revolt-api/types/Autumn"; +import { API } from "revolt.js"; import styles from "./Attachment.module.scss"; import classNames from "classnames"; @@ -10,12 +10,12 @@ import { AppContext } from "../../../../context/revoltjs/RevoltClient"; enum ImageLoadingState { Loading, Loaded, - Error + Error, } type Props = JSX.HTMLAttributes & { - attachment: Attachment; -} + attachment: API.File; +}; export default function ImageFile({ attachment, ...props }: Props) { const [loading, setLoading] = useState(ImageLoadingState.Loading); @@ -23,25 +23,19 @@ export default function ImageFile({ attachment, ...props }: Props) { const { openScreen } = useIntermediate(); const url = client.generateFileURL(attachment)!; - return {attachment.filename} - openScreen({ id: "image_viewer", attachment }) - } - onMouseDown={(ev) => - ev.button === 1 && window.open(url, "_blank") - } - onLoad={() => - setLoading(ImageLoadingState.Loaded) - } - onError={() => - setLoading(ImageLoadingState.Error) - } - /> + return ( + {attachment.filename} openScreen({ id: "image_viewer", attachment })} + onMouseDown={(ev) => ev.button === 1 && window.open(url, "_blank")} + onLoad={() => setLoading(ImageLoadingState.Loaded)} + onError={() => setLoading(ImageLoadingState.Error)} + /> + ); } diff --git a/src/components/common/messaging/attachments/MessageReply.tsx b/src/components/common/messaging/attachments/MessageReply.tsx index a82678a6..82ec7077 100644 --- a/src/components/common/messaging/attachments/MessageReply.tsx +++ b/src/components/common/messaging/attachments/MessageReply.tsx @@ -2,9 +2,7 @@ import { Reply } from "@styled-icons/boxicons-regular"; import { File } from "@styled-icons/boxicons-solid"; import { observer } from "mobx-react-lite"; import { useHistory } from "react-router-dom"; -import { RelationshipStatus } from "revolt-api/types/Users"; -import { Channel } from "revolt.js/dist/maps/Channels"; -import { Message } from "revolt.js/dist/maps/Messages"; +import { Channel, Message, API } from "revolt.js"; import styled, { css } from "styled-components/macro"; import { Text } from "preact-i18n"; @@ -174,7 +172,7 @@ export const MessageReply = observer( {/**/} - {message.author?.relationship === RelationshipStatus.Blocked ? ( + {message.author?.relationship === "Blocked" ? ( ) : ( <> diff --git a/src/components/common/messaging/attachments/TextFile.tsx b/src/components/common/messaging/attachments/TextFile.tsx index 1b78cd38..6b2d32fb 100644 --- a/src/components/common/messaging/attachments/TextFile.tsx +++ b/src/components/common/messaging/attachments/TextFile.tsx @@ -1,5 +1,5 @@ import axios from "axios"; -import { Attachment } from "revolt-api/types/Autumn"; +import { API } from "revolt.js"; import styles from "./Attachment.module.scss"; import { useContext, useEffect, useState } from "preact/hooks"; @@ -13,7 +13,7 @@ import { import Preloader from "../../../ui/Preloader"; interface Props { - attachment: Attachment; + attachment: API.File; } const fileCache: { [key: string]: string } = {}; diff --git a/src/components/common/messaging/bars/JumpToBottom.tsx b/src/components/common/messaging/bars/JumpToBottom.tsx index 62a91496..b403c2ea 100644 --- a/src/components/common/messaging/bars/JumpToBottom.tsx +++ b/src/components/common/messaging/bars/JumpToBottom.tsx @@ -1,6 +1,6 @@ import { DownArrowAlt } from "@styled-icons/boxicons-regular"; import { observer } from "mobx-react-lite"; -import { Channel } from "revolt.js/dist/maps/Channels"; +import { Channel } from "revolt.js"; import styled, { css } from "styled-components/macro"; import { Text } from "preact-i18n"; diff --git a/src/components/common/messaging/bars/MessageOverlayBar.tsx b/src/components/common/messaging/bars/MessageOverlayBar.tsx index 922c5c39..6c17bb94 100644 --- a/src/components/common/messaging/bars/MessageOverlayBar.tsx +++ b/src/components/common/messaging/bars/MessageOverlayBar.tsx @@ -8,7 +8,7 @@ import { } from "@styled-icons/boxicons-solid"; import { observer } from "mobx-react-lite"; import { Permission } from "revolt.js"; -import { Message as MessageObject } from "revolt.js/dist/maps/Messages"; +import { Message as MessageObject } from "revolt.js"; import styled from "styled-components"; import { openContextMenu } from "preact-context-menu"; diff --git a/src/components/common/messaging/bars/NewMessages.tsx b/src/components/common/messaging/bars/NewMessages.tsx index 46c6989a..d62eb971 100644 --- a/src/components/common/messaging/bars/NewMessages.tsx +++ b/src/components/common/messaging/bars/NewMessages.tsx @@ -1,7 +1,7 @@ import { UpArrowAlt } from "@styled-icons/boxicons-regular"; import { observer } from "mobx-react-lite"; import { useHistory } from "react-router-dom"; -import { Channel } from "revolt.js/dist/maps/Channels"; +import { Channel } from "revolt.js"; import { decodeTime } from "ulid"; import { Text } from "preact-i18n"; diff --git a/src/components/common/messaging/bars/ReplyBar.tsx b/src/components/common/messaging/bars/ReplyBar.tsx index 7fe55e20..4b3b3fec 100644 --- a/src/components/common/messaging/bars/ReplyBar.tsx +++ b/src/components/common/messaging/bars/ReplyBar.tsx @@ -1,8 +1,7 @@ -import { At, Reply as ReplyIcon } from "@styled-icons/boxicons-regular"; +import { At } from "@styled-icons/boxicons-regular"; import { File, XCircle } from "@styled-icons/boxicons-solid"; import { observer } from "mobx-react-lite"; -import { Channel } from "revolt.js/dist/maps/Channels"; -import { Message } from "revolt.js/dist/maps/Messages"; +import { Channel, Message } from "revolt.js"; import styled from "styled-components/macro"; import { Text } from "preact-i18n"; diff --git a/src/components/common/messaging/bars/TypingIndicator.tsx b/src/components/common/messaging/bars/TypingIndicator.tsx index e704a7ee..b7d2d75c 100644 --- a/src/components/common/messaging/bars/TypingIndicator.tsx +++ b/src/components/common/messaging/bars/TypingIndicator.tsx @@ -1,6 +1,5 @@ import { observer } from "mobx-react-lite"; -import { RelationshipStatus } from "revolt-api/types/Users"; -import { Channel } from "revolt.js/dist/maps/Channels"; +import { Channel } from "revolt.js"; import styled from "styled-components/macro"; import { Text } from "preact-i18n"; @@ -65,7 +64,7 @@ export default observer(({ channel }: Props) => { (x) => typeof x !== "undefined" && x._id !== x.client.user!._id && - x.relationship !== RelationshipStatus.Blocked, + x.relationship !== "Blocked", ); if (users.length > 0) { diff --git a/src/components/common/messaging/embed/Embed.tsx b/src/components/common/messaging/embed/Embed.tsx index 1591a669..8cc7540f 100644 --- a/src/components/common/messaging/embed/Embed.tsx +++ b/src/components/common/messaging/embed/Embed.tsx @@ -1,4 +1,4 @@ -import { Embed as EmbedI } from "revolt-api/types/Channels"; +import { API } from "revolt.js"; import styles from "./Embed.module.scss"; import classNames from "classnames"; @@ -13,7 +13,7 @@ import Attachment from "../attachments/Attachment"; import EmbedMedia from "./EmbedMedia"; interface Props { - embed: EmbedI; + embed: API.Embed; } const MAX_EMBED_WIDTH = 480; @@ -128,7 +128,7 @@ export default function Embed({ embed }: Props) { (ev.button === 0 || ev.button === 1) && - openLink(embed.url) + openLink(embed.url!) } className={styles.title}> {embed.title} diff --git a/src/components/common/messaging/embed/EmbedInvite.tsx b/src/components/common/messaging/embed/EmbedInvite.tsx index dddb2d2a..368ac7df 100644 --- a/src/components/common/messaging/embed/EmbedInvite.tsx +++ b/src/components/common/messaging/embed/EmbedInvite.tsx @@ -1,14 +1,12 @@ import { Group } from "@styled-icons/boxicons-solid"; -import { autorun, reaction } from "mobx"; +import { reaction } from "mobx"; import { observer } from "mobx-react-lite"; import { useHistory } from "react-router-dom"; -import { RetrievedInvite } from "revolt-api/types/Invites"; -import { Message } from "revolt.js/dist/maps/Messages"; +import { Message, API } from "revolt.js"; import styled, { css } from "styled-components/macro"; import { useContext, useEffect, useState } from "preact/hooks"; -import { defer } from "../../../../lib/defer"; import { isTouchscreenDevice } from "../../../../lib/isTouchscreenDevice"; import { @@ -85,9 +83,9 @@ export function EmbedInvite({ code }: Props) { const [processing, setProcessing] = useState(false); const [error, setError] = useState(undefined); const [joinError, setJoinError] = useState(undefined); - const [invite, setInvite] = useState( - undefined, - ); + const [invite, setInvite] = useState< + (API.InviteResponse & { type: "Server" }) | undefined + >(undefined); useEffect(() => { if ( @@ -96,7 +94,9 @@ export function EmbedInvite({ code }: Props) { ) { client .fetchInvite(code) - .then((data) => setInvite(data)) + .then((data) => + setInvite(data as API.InviteResponse & { type: "Server" }), + ) .catch((err) => setError(takeError(err))); } }, [client, code, invite, status]); diff --git a/src/components/common/messaging/embed/EmbedMedia.tsx b/src/components/common/messaging/embed/EmbedMedia.tsx index cf8c948f..a9cb05f8 100644 --- a/src/components/common/messaging/embed/EmbedMedia.tsx +++ b/src/components/common/messaging/embed/EmbedMedia.tsx @@ -1,5 +1,5 @@ /* eslint-disable react-hooks/rules-of-hooks */ -import { JanuaryEmbed } from "revolt-api/types/January"; +import { API } from "revolt.js"; import styles from "./Embed.module.scss"; @@ -7,7 +7,7 @@ import { useIntermediate } from "../../../../context/intermediate/Intermediate"; import { useClient } from "../../../../context/revoltjs/RevoltClient"; interface Props { - embed: JanuaryEmbed; + embed: API.Embed; width?: number; height: number; } @@ -94,7 +94,7 @@ export default function EmbedMedia({ embed, width, height }: Props) { onClick={() => openScreen({ id: "image_viewer", - embed: embed.image, + embed: embed.image!, }) } onMouseDown={(ev) => diff --git a/src/components/common/messaging/embed/EmbedMediaActions.tsx b/src/components/common/messaging/embed/EmbedMediaActions.tsx index fe9f6cd0..27f82c75 100644 --- a/src/components/common/messaging/embed/EmbedMediaActions.tsx +++ b/src/components/common/messaging/embed/EmbedMediaActions.tsx @@ -1,12 +1,12 @@ import { LinkExternal } from "@styled-icons/boxicons-regular"; -import { EmbedImage } from "revolt-api/types/January"; +import { API } from "revolt.js"; import styles from "./Embed.module.scss"; import IconButton from "../../../ui/IconButton"; interface Props { - embed: EmbedImage; + embed: API.Image; } export default function EmbedMediaActions({ embed }: Props) { diff --git a/src/components/common/user/UserBadges.tsx b/src/components/common/user/UserBadges.tsx index 962a659a..b8c36e44 100644 --- a/src/components/common/user/UserBadges.tsx +++ b/src/components/common/user/UserBadges.tsx @@ -1,11 +1,23 @@ import { Shield } from "@styled-icons/boxicons-regular"; -import { Badges } from "revolt-api/types/Users"; import styled from "styled-components/macro"; import { Localizer, Text } from "preact-i18n"; import Tooltip from "../Tooltip"; +enum Badges { + Developer = 1, + Translator = 2, + Supporter = 4, + ResponsibleDisclosure = 8, + Founder = 16, + PlatformModeration = 32, + ActiveSupporter = 64, + Paw = 128, + EarlyAdopter = 256, + ReservedRelevantJokeBadge1 = 512, +} + const BadgesBase = styled.div` gap: 8px; display: flex; diff --git a/src/components/common/user/UserCheckbox.tsx b/src/components/common/user/UserCheckbox.tsx index bbde2a09..f810bc43 100644 --- a/src/components/common/user/UserCheckbox.tsx +++ b/src/components/common/user/UserCheckbox.tsx @@ -1,4 +1,4 @@ -import { User } from "revolt.js/dist/maps/Users"; +import { User } from "revolt.js"; import Checkbox, { CheckboxProps } from "../../ui/Checkbox"; diff --git a/src/components/common/user/UserHeader.tsx b/src/components/common/user/UserHeader.tsx index 2808d254..e3d207c6 100644 --- a/src/components/common/user/UserHeader.tsx +++ b/src/components/common/user/UserHeader.tsx @@ -1,7 +1,7 @@ import { Cog } from "@styled-icons/boxicons-solid"; import { observer } from "mobx-react-lite"; import { Link } from "react-router-dom"; -import { User } from "revolt.js/dist/maps/Users"; +import { User } from "revolt.js"; import styled from "styled-components/macro"; import { openContextMenu } from "preact-context-menu"; diff --git a/src/components/common/user/UserHover.tsx b/src/components/common/user/UserHover.tsx index 0f42e09c..d04536a3 100644 --- a/src/components/common/user/UserHover.tsx +++ b/src/components/common/user/UserHover.tsx @@ -1,4 +1,4 @@ -import { User } from "revolt.js/dist/maps/Users"; +import { User } from "revolt.js"; import styled from "styled-components/macro"; import { Children } from "../../../types/Preact"; diff --git a/src/components/common/user/UserIcon.tsx b/src/components/common/user/UserIcon.tsx index 6ddb74c8..d95463f0 100644 --- a/src/components/common/user/UserIcon.tsx +++ b/src/components/common/user/UserIcon.tsx @@ -1,9 +1,7 @@ import { VolumeMute, MicrophoneOff } from "@styled-icons/boxicons-solid"; import { observer } from "mobx-react-lite"; import { useParams } from "react-router-dom"; -import { Masquerade } from "revolt-api/types/Channels"; -import { Presence } from "revolt-api/types/Users"; -import { User } from "revolt.js/dist/maps/Users"; +import { User, API } from "revolt.js"; import styled, { css } from "styled-components/macro"; import { useApplicationState } from "../../../mobx/State"; @@ -18,17 +16,17 @@ type VoiceStatus = "muted" | "deaf"; interface Props extends IconBaseProps { status?: boolean; voice?: VoiceStatus; - masquerade?: Masquerade; + masquerade?: API.Masquerade; showServerIdentity?: boolean; } export function useStatusColour(user?: User) { const theme = useApplicationState().settings.theme; - return user?.online && user?.status?.presence !== Presence.Invisible - ? user?.status?.presence === Presence.Idle + return user?.online && user?.status?.presence !== "Invisible" + ? user?.status?.presence === "Idle" ? theme.getVariable("status-away") - : user?.status?.presence === Presence.Busy + : user?.status?.presence === "Busy" ? theme.getVariable("status-busy") : theme.getVariable("status-online") : theme.getVariable("status-invisible"); @@ -94,7 +92,7 @@ export default observer( url = client.generateFileURL( - override ?? target?.avatar ?? attachment, + override ?? target?.avatar ?? attachment ?? undefined, { max_side: 256 }, animate, ) ?? (target ? target.defaultAvatarURL : fallback); diff --git a/src/components/common/user/UserShort.tsx b/src/components/common/user/UserShort.tsx index 0ef5ccf8..03f0cee5 100644 --- a/src/components/common/user/UserShort.tsx +++ b/src/components/common/user/UserShort.tsx @@ -1,8 +1,6 @@ import { observer } from "mobx-react-lite"; import { useParams } from "react-router-dom"; -import { Masquerade } from "revolt-api/types/Channels"; -import { User } from "revolt.js/dist/maps/Users"; -import { Nullable } from "revolt.js/dist/util/null"; +import { User, API } from "revolt.js"; import styled from "styled-components/macro"; import { Text } from "preact-i18n"; @@ -31,7 +29,7 @@ const BotBadge = styled.div` type UsernameProps = JSX.HTMLAttributes & { user?: User; prefixAt?: boolean; - masquerade?: Masquerade; + masquerade?: API.Masquerade; showServerIdentity?: boolean | "both"; }; @@ -116,7 +114,7 @@ export default function UserShort({ user?: User; size?: number; prefixAt?: boolean; - masquerade?: Masquerade; + masquerade?: API.Masquerade; showServerIdentity?: boolean; }) { const { openScreen } = useIntermediate(); diff --git a/src/components/common/user/UserStatus.tsx b/src/components/common/user/UserStatus.tsx index ff8a354d..36e866c4 100644 --- a/src/components/common/user/UserStatus.tsx +++ b/src/components/common/user/UserStatus.tsx @@ -1,6 +1,5 @@ import { observer } from "mobx-react-lite"; -import { Presence } from "revolt-api/types/Users"; -import { User } from "revolt.js/dist/maps/Users"; +import { User, API } from "revolt.js"; import { Text } from "preact-i18n"; @@ -25,15 +24,15 @@ export default observer(({ user, tooltip }: Props) => { return <>{user.status.text}; } - if (user.status?.presence === Presence.Busy) { + if (user.status?.presence === "Busy") { return ; } - if (user.status?.presence === Presence.Idle) { + if (user.status?.presence === "Idle") { return ; } - if (user.status?.presence === Presence.Invisible) { + if (user.status?.presence === "Invisible") { return ; } diff --git a/src/components/markdown/Markdown.tsx b/src/components/markdown/Markdown.tsx index 0f1e0887..986fbd2d 100644 --- a/src/components/markdown/Markdown.tsx +++ b/src/components/markdown/Markdown.tsx @@ -3,7 +3,7 @@ import { Suspense, lazy } from "preact/compat"; const Renderer = lazy(() => import("./Renderer")); export interface MarkdownProps { - content?: string; + content?: string | null; disallowBigEmoji?: boolean; } diff --git a/src/components/markdown/Renderer.tsx b/src/components/markdown/Renderer.tsx index 374fed67..3d4323c1 100644 --- a/src/components/markdown/Renderer.tsx +++ b/src/components/markdown/Renderer.tsx @@ -129,7 +129,7 @@ export default function Renderer({ content, disallowBigEmoji }: MarkdownProps) { const { openLink } = useIntermediate(); if (typeof content === "undefined") return null; - if (content.length === 0) return null; + if (!content || content.length === 0) return null; // We replace the message with the mention at the time of render. // We don't care if the mention changes. diff --git a/src/components/navigation/items/ButtonItem.tsx b/src/components/navigation/items/ButtonItem.tsx index a9a7a895..36f902be 100644 --- a/src/components/navigation/items/ButtonItem.tsx +++ b/src/components/navigation/items/ButtonItem.tsx @@ -1,9 +1,7 @@ import { X } from "@styled-icons/boxicons-regular"; import { Crown } from "@styled-icons/boxicons-solid"; import { observer } from "mobx-react-lite"; -import { Presence } from "revolt-api/types/Users"; -import { Channel } from "revolt.js/dist/maps/Channels"; -import { User } from "revolt.js/dist/maps/Users"; +import { User, Channel } from "revolt.js"; import styles from "./Item.module.scss"; import classNames from "classnames"; @@ -64,7 +62,7 @@ export const UserButton = observer((props: UserProps) => { data-alert={typeof alert === "string"} data-online={ typeof channel !== "undefined" || - (user.online && user.status?.presence !== Presence.Invisible) + (user.online && user.status?.presence !== "Invisible") } onContextMenu={attachContextMenu("Menu", { user: user._id, diff --git a/src/components/navigation/left/HomeSidebar.tsx b/src/components/navigation/left/HomeSidebar.tsx index c391079d..bb471340 100644 --- a/src/components/navigation/left/HomeSidebar.tsx +++ b/src/components/navigation/left/HomeSidebar.tsx @@ -5,8 +5,7 @@ import { Notepad, } from "@styled-icons/boxicons-solid"; import { observer } from "mobx-react-lite"; -import { Link, Redirect, useLocation, useParams } from "react-router-dom"; -import { RelationshipStatus } from "revolt-api/types/Users"; +import { Link, useLocation, useParams } from "react-router-dom"; import styled, { css } from "styled-components/macro"; import { Text } from "preact-i18n"; @@ -68,7 +67,7 @@ export default observer(() => { // ! FIXME: must be a better way const incoming = [...client.users.values()].filter( - (user) => user?.relationship === RelationshipStatus.Incoming, + (user) => user?.relationship === "Incoming", ); return ( diff --git a/src/components/navigation/left/ServerListSidebar.tsx b/src/components/navigation/left/ServerListSidebar.tsx index ad742e0e..68177e89 100644 --- a/src/components/navigation/left/ServerListSidebar.tsx +++ b/src/components/navigation/left/ServerListSidebar.tsx @@ -2,11 +2,9 @@ import { Plus } from "@styled-icons/boxicons-regular"; import { Cog, Compass } from "@styled-icons/boxicons-solid"; import { observer } from "mobx-react-lite"; import { Link, useHistory, useLocation, useParams } from "react-router-dom"; -import { RelationshipStatus } from "revolt-api/types/Users"; import styled, { css } from "styled-components/macro"; import { attachContextMenu } from "preact-context-menu"; -import { Text } from "preact-i18n"; import ConditionalLink from "../../../lib/ConditionalLink"; import PaintCounter from "../../../lib/PaintCounter"; @@ -248,7 +246,7 @@ export default observer(() => { const { openScreen } = useIntermediate(); let alertCount = [...client.users.values()].filter( - (x) => x.relationship === RelationshipStatus.Incoming, + (x) => x.relationship === "Incoming", ).length; const homeActive = diff --git a/src/components/navigation/left/ServerSidebar.tsx b/src/components/navigation/left/ServerSidebar.tsx index 06d3979b..fe199fff 100644 --- a/src/components/navigation/left/ServerSidebar.tsx +++ b/src/components/navigation/left/ServerSidebar.tsx @@ -1,6 +1,6 @@ import { observer } from "mobx-react-lite"; import { Redirect, useParams } from "react-router"; -import { Server } from "revolt.js/dist/maps/Servers"; +import { Server } from "revolt.js"; import styled, { css } from "styled-components/macro"; import { attachContextMenu } from "preact-context-menu"; diff --git a/src/components/navigation/right/ChannelDebugInfo.tsx b/src/components/navigation/right/ChannelDebugInfo.tsx index fc78a79e..5465041a 100644 --- a/src/components/navigation/right/ChannelDebugInfo.tsx +++ b/src/components/navigation/right/ChannelDebugInfo.tsx @@ -1,6 +1,6 @@ /* eslint-disable react-hooks/rules-of-hooks */ import { observer } from "mobx-react-lite"; -import { Channel } from "revolt.js/dist/maps/Channels"; +import { Channel } from "revolt.js"; import { getRenderer } from "../../../lib/renderer/Singleton"; diff --git a/src/components/navigation/right/MemberList.tsx b/src/components/navigation/right/MemberList.tsx index 11e6d524..45aef23b 100644 --- a/src/components/navigation/right/MemberList.tsx +++ b/src/components/navigation/right/MemberList.tsx @@ -1,7 +1,6 @@ import { Link } from "react-router-dom"; import { GroupedVirtuoso } from "react-virtuoso"; -import { Channel } from "revolt.js/dist/maps/Channels"; -import { User } from "revolt.js/dist/maps/Users"; +import { Channel, User } from "revolt.js"; import styled, { css } from "styled-components/macro"; import { Text } from "preact-i18n"; diff --git a/src/components/navigation/right/MemberSidebar.tsx b/src/components/navigation/right/MemberSidebar.tsx index b97d003a..6996a8be 100644 --- a/src/components/navigation/right/MemberSidebar.tsx +++ b/src/components/navigation/right/MemberSidebar.tsx @@ -2,11 +2,7 @@ import { autorun } from "mobx"; import { observer } from "mobx-react-lite"; import { useParams } from "react-router-dom"; -import { Role } from "revolt-api/types/Servers"; -import { Presence } from "revolt-api/types/Users"; -import { Channel } from "revolt.js/dist/maps/Channels"; -import { Server } from "revolt.js/dist/maps/Servers"; -import { User } from "revolt.js/dist/maps/Users"; +import { Channel, Server, User, API } from "revolt.js"; import { useContext, useEffect, useState } from "preact/hooks"; @@ -62,7 +58,7 @@ function useEntries( .map((id) => { return [id, roles![id], roles![id].rank ?? 0] as [ string, - Role, + API.Role, number, ]; }) @@ -96,7 +92,7 @@ function useEntries( const sort = member?.nickname ?? u.username; const entry = [u, sort] as [User, string]; - if (!u.online || u.status?.presence === Presence.Invisible) { + if (!u.online || u.status?.presence === "Invisible") { categories.offline.push(entry); } else { if (isServer) { diff --git a/src/components/navigation/right/Search.tsx b/src/components/navigation/right/Search.tsx index 35475009..97891c30 100644 --- a/src/components/navigation/right/Search.tsx +++ b/src/components/navigation/right/Search.tsx @@ -1,5 +1,5 @@ import { Link, useParams } from "react-router-dom"; -import { Message as MessageI } from "revolt.js/dist/maps/Messages"; +import { Message as MessageI } from "revolt.js"; import styled from "styled-components/macro"; import { Text } from "preact-i18n"; diff --git a/src/components/settings/roles/PermissionList.tsx b/src/components/settings/roles/PermissionList.tsx index fd96caa1..03c1f8f2 100644 --- a/src/components/settings/roles/PermissionList.tsx +++ b/src/components/settings/roles/PermissionList.tsx @@ -1,11 +1,11 @@ -import { OverrideField } from "revolt-api/types/_common"; +import { API } from "revolt.js"; import { Permission } from "revolt.js"; import { PermissionSelect } from "./PermissionSelect"; interface Props { - value: OverrideField | number; - onChange: (v: OverrideField | number) => void; + value: API.OverrideField | number; + onChange: (v: API.OverrideField | number) => void; filter?: (keyof typeof Permission)[]; } diff --git a/src/components/settings/roles/PermissionSelect.tsx b/src/components/settings/roles/PermissionSelect.tsx index e049507f..8592e765 100644 --- a/src/components/settings/roles/PermissionSelect.tsx +++ b/src/components/settings/roles/PermissionSelect.tsx @@ -1,5 +1,5 @@ import Long from "long"; -import { OverrideField } from "revolt-api/types/_common"; +import { API } from "revolt.js"; import { Permission } from "revolt.js"; import styled from "styled-components"; @@ -13,8 +13,8 @@ import { OverrideSwitch } from "./OverrideSwitch"; interface PermissionSelectProps { id: keyof typeof Permission; permission: number; - value: OverrideField | number; - onChange: (value: OverrideField | number) => void; + value: API.OverrideField | number; + onChange: (value: API.OverrideField | number) => void; } type State = "Allow" | "Neutral" | "Deny"; diff --git a/src/components/settings/roles/RoleSelection.tsx b/src/components/settings/roles/RoleSelection.tsx index 8ffa4e1e..4ce36b77 100644 --- a/src/components/settings/roles/RoleSelection.tsx +++ b/src/components/settings/roles/RoleSelection.tsx @@ -1,9 +1,9 @@ -import { Role } from "revolt-api/types/Servers"; +import { API } from "revolt.js"; import Checkbox from "../../ui/Checkbox"; export type RoleOrDefault = ( - | Role + | API.Role | { name: string; permissions: number; diff --git a/src/context/intermediate/Intermediate.tsx b/src/context/intermediate/Intermediate.tsx index 3e001a09..9be2fe29 100644 --- a/src/context/intermediate/Intermediate.tsx +++ b/src/context/intermediate/Intermediate.tsx @@ -1,13 +1,6 @@ import { Prompt } from "react-router"; import { useHistory } from "react-router-dom"; -import type { Attachment } from "revolt-api/types/Autumn"; -import { Bot } from "revolt-api/types/Bots"; -import { TextChannel, VoiceChannel } from "revolt-api/types/Channels"; -import type { EmbedImage } from "revolt-api/types/January"; -import { Channel } from "revolt.js/dist/maps/Channels"; -import { Message } from "revolt.js/dist/maps/Messages"; -import { Server } from "revolt.js/dist/maps/Servers"; -import { User } from "revolt.js/dist/maps/Users"; +import { API, Channel, Message, Server, User } from "revolt.js"; import { createContext } from "preact"; import { useContext, useEffect, useMemo, useState } from "preact/hooks"; @@ -61,7 +54,11 @@ export type Screen = | { type: "create_channel"; target: Server; - cb?: (channel: TextChannel | VoiceChannel) => void; + cb?: ( + channel: Channel & { + channel_type: "TextChannel" | "VoiceChannel"; + }, + ) => void; } | { type: "create_category"; target: Server } )) @@ -101,11 +98,11 @@ export type Screen = omit?: string[]; callback: (users: string[]) => Promise; } - | { id: "image_viewer"; attachment?: Attachment; embed?: EmbedImage } + | { id: "image_viewer"; attachment?: API.File; embed?: API.Image } | { id: "channel_info"; channel: Channel } | { id: "pending_requests"; users: User[] } | { id: "modify_account"; field: "username" | "email" | "password" } - | { id: "create_bot"; onCreate: (bot: Bot) => void } + | { id: "create_bot"; onCreate: (bot: API.Bot) => void } | { id: "server_identity"; server: Server; diff --git a/src/context/intermediate/modals/Input.tsx b/src/context/intermediate/modals/Input.tsx index f8853d92..cd6dd09f 100644 --- a/src/context/intermediate/modals/Input.tsx +++ b/src/context/intermediate/modals/Input.tsx @@ -1,5 +1,5 @@ import { useHistory } from "react-router"; -import { Server } from "revolt.js/dist/maps/Servers"; +import { Server } from "revolt.js"; import { ulid } from "ulid"; import { Text } from "preact-i18n"; @@ -99,7 +99,6 @@ export function SpecialInputModal(props: SpecialProps) { callback={async (name) => { const group = await client.channels.createGroup({ name, - nonce: ulid(), users: [], }); @@ -117,7 +116,6 @@ export function SpecialInputModal(props: SpecialProps) { callback={async (name) => { const server = await client.servers.createServer({ name, - nonce: ulid(), }); history.push(`/server/${server._id}`); @@ -146,7 +144,7 @@ export function SpecialInputModal(props: SpecialProps) { onClose={onClose} question={} field={} - defaultValue={client.user?.status?.text} + defaultValue={client.user?.status?.text ?? undefined} callback={(text) => client.users.edit({ status: { @@ -164,11 +162,8 @@ export function SpecialInputModal(props: SpecialProps) { onClose={onClose} question={"Add Friend"} callback={(username) => - client - .req( - "PUT", - `/users/${username}/friend` as "/users/id/friend", - ) + client.api + .put(`/users/${username as ""}/friend`) .then(undefined) } /> diff --git a/src/context/intermediate/modals/Onboarding.module.scss b/src/context/intermediate/modals/Onboarding.module.scss index ea1a13ce..887b4224 100644 --- a/src/context/intermediate/modals/Onboarding.module.scss +++ b/src/context/intermediate/modals/Onboarding.module.scss @@ -16,6 +16,10 @@ h1 { margin: 0; } + + img { + max-height: 80px; + } } &.form { diff --git a/src/context/intermediate/modals/Prompt.tsx b/src/context/intermediate/modals/Prompt.tsx index 4da5a07d..b41c5da3 100644 --- a/src/context/intermediate/modals/Prompt.tsx +++ b/src/context/intermediate/modals/Prompt.tsx @@ -1,10 +1,6 @@ import { observer } from "mobx-react-lite"; import { useHistory } from "react-router-dom"; -import { TextChannel, VoiceChannel } from "revolt-api/types/Channels"; -import { Channel } from "revolt.js/dist/maps/Channels"; -import { Message as MessageI } from "revolt.js/dist/maps/Messages"; -import { Server } from "revolt.js/dist/maps/Servers"; -import { User } from "revolt.js/dist/maps/Users"; +import { Channel, Message as MessageI, Server, User } from "revolt.js"; import { ulid } from "ulid"; import styles from "./Prompt.module.scss"; @@ -74,7 +70,11 @@ type SpecialProps = { onClose: () => void } & ( | { type: "create_channel"; target: Server; - cb?: (channel: TextChannel | VoiceChannel) => void; + cb?: ( + channel: Channel & { + channel_type: "TextChannel" | "VoiceChannel"; + }, + ) => void; } | { type: "create_category"; target: Server } ); @@ -429,11 +429,10 @@ export const SpecialPromptModal = observer((props: SpecialProps) => { await props.target.createChannel({ type, name, - nonce: ulid(), }); if (props.cb) { - props.cb(channel); + props.cb(channel as any); } else { history.push( `/server/${props.target._id}/channel/${channel._id}`, diff --git a/src/context/intermediate/popovers/ChannelInfo.tsx b/src/context/intermediate/popovers/ChannelInfo.tsx index a2f41f87..bf9f928c 100644 --- a/src/context/intermediate/popovers/ChannelInfo.tsx +++ b/src/context/intermediate/popovers/ChannelInfo.tsx @@ -1,6 +1,6 @@ import { X } from "@styled-icons/boxicons-regular"; import { observer } from "mobx-react-lite"; -import { Channel } from "revolt.js/dist/maps/Channels"; +import { Channel } from "revolt.js"; import styles from "./ChannelInfo.module.scss"; diff --git a/src/context/intermediate/popovers/CreateBot.tsx b/src/context/intermediate/popovers/CreateBot.tsx index 1ff082c7..d089d529 100644 --- a/src/context/intermediate/popovers/CreateBot.tsx +++ b/src/context/intermediate/popovers/CreateBot.tsx @@ -1,5 +1,5 @@ import { SubmitHandler, useForm } from "react-hook-form"; -import { Bot } from "revolt-api/types/Bots"; +import { API } from "revolt.js"; import { Text } from "preact-i18n"; import { useContext, useState } from "preact/hooks"; @@ -13,7 +13,7 @@ import { takeError } from "../../revoltjs/util"; interface Props { onClose: () => void; - onCreate: (bot: Bot) => void; + onCreate: (bot: API.Bot) => void; } interface FormInputs { diff --git a/src/context/intermediate/popovers/ImageViewer.tsx b/src/context/intermediate/popovers/ImageViewer.tsx index c65dca8e..3d51ff3e 100644 --- a/src/context/intermediate/popovers/ImageViewer.tsx +++ b/src/context/intermediate/popovers/ImageViewer.tsx @@ -1,6 +1,5 @@ /* eslint-disable react-hooks/rules-of-hooks */ -import { Attachment, AttachmentMetadata } from "revolt-api/types/Autumn"; -import { EmbedImage } from "revolt-api/types/January"; +import { API } from "revolt.js"; import styles from "./ImageViewer.module.scss"; @@ -12,11 +11,11 @@ import { useClient } from "../../revoltjs/RevoltClient"; interface Props { onClose: () => void; - embed?: EmbedImage; - attachment?: Attachment; + embed?: API.Image; + attachment?: API.File; } -type ImageMetadata = AttachmentMetadata & { type: "Image" }; +type ImageMetadata = API.Metadata & { type: "Image" }; export function ImageViewer({ attachment, embed, onClose }: Props) { if (attachment && attachment.metadata.type !== "Image") { diff --git a/src/context/intermediate/popovers/ModifyAccount.tsx b/src/context/intermediate/popovers/ModifyAccount.tsx index 2c2145c4..20ec4dcc 100644 --- a/src/context/intermediate/popovers/ModifyAccount.tsx +++ b/src/context/intermediate/popovers/ModifyAccount.tsx @@ -43,19 +43,19 @@ export function ModifyAccountModal({ onClose, field }: Props) { try { if (field === "email") { - await client.req("PATCH", "/auth/account/change/email", { + await client.api.patch("/auth/account/change/email", { current_password: password, email: new_email, }); onClose(); } else if (field === "password") { - await client.req("PATCH", "/auth/account/change/password", { + await client.api.patch("/auth/account/change/password", { current_password: password, password: new_password, }); onClose(); } else if (field === "username") { - await client.req("PATCH", "/users/id/username", { + await client.api.patch("/users/@me/username", { username: new_username, password, }); diff --git a/src/context/intermediate/popovers/PendingRequests.tsx b/src/context/intermediate/popovers/PendingRequests.tsx index df7d66bd..1c068d97 100644 --- a/src/context/intermediate/popovers/PendingRequests.tsx +++ b/src/context/intermediate/popovers/PendingRequests.tsx @@ -1,5 +1,5 @@ import { observer } from "mobx-react-lite"; -import { User } from "revolt.js/dist/maps/Users"; +import { User } from "revolt.js"; import styles from "./UserPicker.module.scss"; import { Text } from "preact-i18n"; diff --git a/src/context/intermediate/popovers/ServerIdentityModal.tsx b/src/context/intermediate/popovers/ServerIdentityModal.tsx index 4f1a10c1..1632f389 100644 --- a/src/context/intermediate/popovers/ServerIdentityModal.tsx +++ b/src/context/intermediate/popovers/ServerIdentityModal.tsx @@ -1,11 +1,12 @@ import { observer } from "mobx-react-lite"; -import { Server } from "revolt.js/dist/maps/Servers"; -import styled, { css } from "styled-components/macro"; +import { Server } from "revolt.js"; import styles from "./ServerIdentityModal.module.scss"; import { Text } from "preact-i18n"; import { useEffect, useState } from "preact/hooks"; +import { noop } from "../../../lib/js"; + import Button from "../../../components/ui/Button"; import InputBox from "../../../components/ui/InputBox"; import Modal from "../../../components/ui/Modal"; @@ -57,8 +58,12 @@ export const ServerIdentityModal = observer(({ server, onClose }: Props) => { fileType="avatars" behaviour="upload" maxFileSize={4_000_000} - onUpload={(avatar) => member.edit({ avatar })} - remove={() => member.edit({ remove: "Avatar" })} + onUpload={(avatar) => + member.edit({ avatar }).then(noop) + } + remove={() => + member.edit({ remove: ["Avatar"] }).then(noop) + } defaultPreview={client.user?.generateAvatarURL( { max_side: 256, @@ -92,7 +97,7 @@ export const ServerIdentityModal = observer(({ server, onClose }: Props) => { diff --git a/src/context/intermediate/popovers/UserPicker.tsx b/src/context/intermediate/popovers/UserPicker.tsx index 68b5d61c..c9be5fab 100644 --- a/src/context/intermediate/popovers/UserPicker.tsx +++ b/src/context/intermediate/popovers/UserPicker.tsx @@ -1,5 +1,3 @@ -import { RelationshipStatus } from "revolt-api/types/Users"; - import styles from "./UserPicker.module.scss"; import { Text } from "preact-i18n"; import { useState } from "preact/hooks"; @@ -37,7 +35,7 @@ export function UserPicker(props: Props) { .filter( (x) => x && - x.relationship === RelationshipStatus.Friend && + x.relationship === "Friend" && !omit.includes(x._id), ) .map((x) => ( diff --git a/src/context/intermediate/popovers/UserProfile.tsx b/src/context/intermediate/popovers/UserProfile.tsx index 37c78f5b..3d8b1e4f 100644 --- a/src/context/intermediate/popovers/UserProfile.tsx +++ b/src/context/intermediate/popovers/UserProfile.tsx @@ -9,9 +9,7 @@ import { } from "@styled-icons/boxicons-solid"; import { observer } from "mobx-react-lite"; import { Link, useHistory } from "react-router-dom"; -import { Profile, RelationshipStatus } from "revolt-api/types/Users"; -import { UserPermission } from "revolt.js/dist/api/permissions"; -import { Route } from "revolt.js/dist/api/routes"; +import { UserPermission, API } from "revolt.js"; import styles from "./UserProfile.module.scss"; import { Localizer, Text } from "preact-i18n"; @@ -44,18 +42,18 @@ interface Props { user_id: string; dummy?: boolean; onClose?: () => void; - dummyProfile?: Profile; + dummyProfile?: API.UserProfile; } export const UserProfile = observer( ({ user_id, onClose, dummy, dummyProfile }: Props) => { const { openScreen, writeClipboard } = useIntermediate(); - const [profile, setProfile] = useState( - undefined, - ); + const [profile, setProfile] = useState< + undefined | null | API.UserProfile + >(undefined); const [mutual, setMutual] = useState< - undefined | null | Route<"GET", "/users/id/mutual">["response"] + undefined | null | API.MutualResponse >(undefined); const [isPublicBot, setIsPublicBot] = useState< undefined | null | boolean @@ -139,7 +137,11 @@ export const UserProfile = observer( const backgroundURL = profile && - client.generateFileURL(profile.background, { width: 1000 }, true); + client.generateFileURL( + profile.background as any, + { width: 1000 }, + true, + ); const badges = user.badges ?? 0; const flags = user.flags ?? 0; @@ -198,7 +200,7 @@ export const UserProfile = observer( )} - {user.relationship === RelationshipStatus.Friend && ( + {user.relationship === "Friend" && ( )} - {user.relationship === RelationshipStatus.User && - !dummy && ( - { - onClose?.(); - history.push(`/settings/profile`); - }}> - - - )} + {user.relationship === "User" && !dummy && ( + { + onClose?.(); + history.push(`/settings/profile`); + }}> + + + )} {!user.bot && flags != 2 && flags != 4 && - (user.relationship === - RelationshipStatus.Incoming || - user.relationship === - RelationshipStatus.None) && ( + (user.relationship === "Incoming" || + user.relationship === "None") && ( user.addFriend()}> )} - {user.relationship === RelationshipStatus.Outgoing && ( + {user.relationship === "Outgoing" && ( user.removeFriend()}> @@ -247,7 +246,7 @@ export const UserProfile = observer( onClick={() => setTab("profile")}> - {user.relationship !== RelationshipStatus.User && ( + {user.relationship !== "User" && ( <>
{ - if (client.user?.status?.presence === Presence.Busy) return; + if (client.user?.status?.presence === "Busy") return; if (!showNotification) return; let event; switch (user.relationship) { - case RelationshipStatus.Incoming: + case "Incoming": event = translate("notifications.sent_request", { person: user.username, }); break; - case RelationshipStatus.Friend: + case "Friend": event = translate("notifications.now_friends", { person: user.username, }); diff --git a/src/context/revoltjs/RevoltClient.tsx b/src/context/revoltjs/RevoltClient.tsx index 1676d56e..b4fefcce 100644 --- a/src/context/revoltjs/RevoltClient.tsx +++ b/src/context/revoltjs/RevoltClient.tsx @@ -50,7 +50,7 @@ export default observer(({ children }: Props) => { useEffect(() => { if (navigator.onLine) { - state.config.createClient().req("GET", "/").then(state.config.set); + state.config.createClient().api.get("/").then(state.config.set); } }, []); @@ -79,7 +79,7 @@ export default observer(({ children }: Props) => { } }, [state.auth.getSession()]); - useEffect(() => registerEvents(state.auth, setStatus, client), [client]); + useEffect(() => registerEvents(state, setStatus, client), [client]); if (!loaded || status === ClientStatus.LOADING) { return ; diff --git a/src/context/revoltjs/StateMonitor.tsx b/src/context/revoltjs/StateMonitor.tsx index 061a7168..34400f0b 100644 --- a/src/context/revoltjs/StateMonitor.tsx +++ b/src/context/revoltjs/StateMonitor.tsx @@ -1,7 +1,7 @@ /** * This file monitors the message cache to delete any queued messages that have already sent. */ -import { Message } from "revolt.js/dist/maps/Messages"; +import { Message } from "revolt.js"; import { useContext, useEffect } from "preact/hooks"; diff --git a/src/context/revoltjs/events.ts b/src/context/revoltjs/events.ts index 7c18dae2..a4121bc9 100644 --- a/src/context/revoltjs/events.ts +++ b/src/context/revoltjs/events.ts @@ -1,17 +1,16 @@ -import { Client } from "revolt.js/dist"; -import { Server } from "revolt.js/dist/maps/Servers"; +import { Client, Server } from "revolt.js"; import { StateUpdater } from "preact/hooks"; import { deleteRenderer } from "../../lib/renderer/Singleton"; -import Auth from "../../mobx/stores/Auth"; +import State from "../../mobx/State"; import { resetMemberSidebarFetched } from "../../components/navigation/right/MemberSidebar"; import { ClientStatus } from "./RevoltClient"; export function registerEvents( - auth: Auth, + state: State, setStatus: StateUpdater, client: Client, ) { @@ -28,7 +27,8 @@ export function registerEvents( }, logout: () => { - auth.logout(); + state.auth.logout(); + state.reset(); setStatus(ClientStatus.READY); }, diff --git a/src/context/revoltjs/util.tsx b/src/context/revoltjs/util.tsx index 4d7522fb..c99924cb 100644 --- a/src/context/revoltjs/util.tsx +++ b/src/context/revoltjs/util.tsx @@ -1,4 +1,4 @@ -import { Channel } from "revolt.js/dist/maps/Channels"; +import { Channel } from "revolt.js"; import { Text } from "preact-i18n"; diff --git a/src/lib/ContextMenus.tsx b/src/lib/ContextMenus.tsx index 55f3ff0a..66e6520e 100644 --- a/src/lib/ContextMenus.tsx +++ b/src/lib/ContextMenus.tsx @@ -12,13 +12,8 @@ import { } from "@styled-icons/boxicons-regular"; import { Cog, UserVoice } from "@styled-icons/boxicons-solid"; import { useHistory } from "react-router-dom"; -import { Attachment } from "revolt-api/types/Autumn"; -import { Presence, RelationshipStatus } from "revolt-api/types/Users"; +import { Channel, Message, Server, User, API } from "revolt.js"; import { Permission, UserPermission } from "revolt.js/dist/api/permissions"; -import { Channel } from "revolt.js/dist/maps/Channels"; -import { Message } from "revolt.js/dist/maps/Messages"; -import { Server } from "revolt.js/dist/maps/Servers"; -import { User } from "revolt.js/dist/maps/Users"; import { ContextMenuWithData, @@ -56,7 +51,7 @@ interface ContextMenuData { server_list?: string; channel?: string; message?: Message; - attachment?: Attachment; + attachment?: API.File; unread?: boolean; queued?: QueuedMessage; @@ -78,9 +73,9 @@ type Action = | { action: "quote_message"; content: string } | { action: "edit_message"; id: string } | { action: "delete_message"; target: Message } - | { action: "open_file"; attachment: Attachment } - | { action: "save_file"; attachment: Attachment } - | { action: "copy_file_link"; attachment: Attachment } + | { action: "open_file"; attachment: API.File } + | { action: "save_file"; attachment: API.File } + | { action: "copy_file_link"; attachment: API.File } | { action: "open_link"; link: string } | { action: "copy_link"; link: string } | { action: "remove_member"; channel: Channel; user: User } @@ -93,7 +88,7 @@ type Action = | { action: "add_friend"; user: User } | { action: "remove_friend"; user: User } | { action: "cancel_friend"; user: User } - | { action: "set_presence"; presence: Presence } + | { action: "set_presence"; presence: API.Presence } | { action: "set_status" } | { action: "clear_status" } | { action: "create_channel"; target: Server } @@ -588,29 +583,29 @@ export default function ContextMenus() { if (!user.bot) { let actions: Action["action"][]; switch (user.relationship) { - case RelationshipStatus.User: + case "User": actions = []; break; - case RelationshipStatus.Friend: + case "Friend": actions = ["remove_friend", "block_user"]; break; - case RelationshipStatus.Incoming: + case "Incoming": actions = [ "add_friend", "cancel_friend", "block_user", ]; break; - case RelationshipStatus.Outgoing: + case "Outgoing": actions = ["cancel_friend", "block_user"]; break; - case RelationshipStatus.Blocked: + case "Blocked": actions = ["unblock_user"]; break; - case RelationshipStatus.BlockedOther: + case "BlockedOther": actions = ["block_user"]; break; - case RelationshipStatus.None: + case "None": default: if ( (user.flags && 2) || @@ -1047,7 +1042,7 @@ export default function ContextMenus() {
@@ -1056,7 +1051,7 @@ export default function ContextMenus() {
@@ -1065,7 +1060,7 @@ export default function ContextMenus() {
@@ -1074,7 +1069,7 @@ export default function ContextMenus() {
diff --git a/src/mobx/State.ts b/src/mobx/State.ts index 94f2315f..bc83cfbc 100644 --- a/src/mobx/State.ts +++ b/src/mobx/State.ts @@ -1,7 +1,7 @@ // @ts-expect-error No typings. import stringify from "json-stringify-deterministic"; import localforage from "localforage"; -import { makeAutoObservable, reaction } from "mobx"; +import { makeAutoObservable, reaction, runInAction } from "mobx"; import { Client } from "revolt.js"; import { reportError } from "../lib/ErrorBoundary"; @@ -59,6 +59,7 @@ export default class State { this.sync = new Sync(this); makeAutoObservable(this); + this.register(); this.setDisabled = this.setDisabled.bind(this); } @@ -159,10 +160,12 @@ export default class State { } if (Object.keys(obj).length > 0) { - client.syncSetSettings( - obj as any, - revision, - ); + if (client.websocket.connected) { + client.syncSetSettings( + obj as any, + revision, + ); + } } break; } @@ -173,12 +176,14 @@ export default class State { } this.sync.setRevision(id, revision); - client.syncSetSettings( - ( - store as unknown as Syncable - ).toSyncable(), - revision, - ); + if (client.websocket.connected) { + client.syncSetSettings( + ( + store as unknown as Syncable + ).toSyncable(), + revision, + ); + } } } } @@ -229,6 +234,24 @@ export default class State { // Dump stores back to disk. await this.save(); } + + /** + * Reset known state values. + */ + reset() { + runInAction(() => { + this.draft = new Draft(); + this.experiments = new Experiments(); + this.layout = new Layout(); + this.notifications = new NotificationOptions(); + this.queue = new MessageQueue(); + this.settings = new Settings(); + this.sync = new Sync(this); + + this.persistent = []; + this.register(); + }); + } } var state: State; diff --git a/src/mobx/legacy/redux.ts b/src/mobx/legacy/redux.ts index 1069494e..bea67b84 100644 --- a/src/mobx/legacy/redux.ts +++ b/src/mobx/legacy/redux.ts @@ -1,5 +1,5 @@ import { runInAction } from "mobx"; -import { Session } from "revolt-api/types/Auth"; +import { API } from "revolt.js"; import { Language } from "../../context/Locale"; import { @@ -63,7 +63,7 @@ export interface LegacySyncOptions { export interface LegacyAuthState { accounts: { [key: string]: { - session: Session; + session: API.Session; }; }; active?: string; diff --git a/src/mobx/stores/Auth.ts b/src/mobx/stores/Auth.ts index baee76b8..9e375158 100644 --- a/src/mobx/stores/Auth.ts +++ b/src/mobx/stores/Auth.ts @@ -1,5 +1,5 @@ import { action, computed, makeAutoObservable, ObservableMap } from "mobx"; -import { Session } from "revolt-api/types/Auth"; +import { API } from "revolt.js"; import { Nullable } from "revolt.js/dist/util/null"; import { mapToRecord } from "../../lib/conversion"; @@ -8,7 +8,7 @@ import Persistent from "../interfaces/Persistent"; import Store from "../interfaces/Store"; interface Account { - session: Session; + session: API.Session; } export interface Data { @@ -82,7 +82,7 @@ export default class Auth implements Store, Persistent { * Add a new session to the auth manager. * @param session Session */ - @action setSession(session: Session) { + @action setSession(session: API.Session) { this.sessions.set(session.user_id, { session }); this.current = session.user_id; } diff --git a/src/mobx/stores/NotificationOptions.ts b/src/mobx/stores/NotificationOptions.ts index 18836afb..a615fbf9 100644 --- a/src/mobx/stores/NotificationOptions.ts +++ b/src/mobx/stores/NotificationOptions.ts @@ -1,5 +1,4 @@ import { action, computed, makeAutoObservable, ObservableMap } from "mobx"; -import { Presence, RelationshipStatus } from "revolt-api/types/Users"; import { Channel } from "revolt.js/dist/maps/Channels"; import { Message } from "revolt.js/dist/maps/Messages"; import { Server } from "revolt.js/dist/maps/Servers"; @@ -113,7 +112,7 @@ export default class NotificationOptions */ shouldNotify(message: Message) { // Make sure the author is not blocked. - if (message.author?.relationship === RelationshipStatus.Blocked) { + if (message.author?.relationship === "Blocked") { return false; } @@ -124,7 +123,7 @@ export default class NotificationOptions } // Check whether we are busy. - if (user.status?.presence === Presence.Busy) { + if (user.status?.presence === "Busy") { return false; } diff --git a/src/mobx/stores/ServerConfig.ts b/src/mobx/stores/ServerConfig.ts index d8bd811f..cc520adf 100644 --- a/src/mobx/stores/ServerConfig.ts +++ b/src/mobx/stores/ServerConfig.ts @@ -1,5 +1,5 @@ import { action, computed, makeAutoObservable } from "mobx"; -import { RevoltConfiguration } from "revolt-api/types/Core"; +import { API } from "revolt.js"; import { Client } from "revolt.js"; import { Nullable } from "revolt.js/dist/util/null"; @@ -11,9 +11,9 @@ import Store from "../interfaces/Store"; * Stores server configuration data. */ export default class ServerConfig - implements Store, Persistent + implements Store, Persistent { - private config: Nullable; + private config: Nullable; /** * Construct new ServerConfig store. @@ -32,7 +32,7 @@ export default class ServerConfig return JSON.parse(JSON.stringify(this.config)); } - @action hydrate(data: RevoltConfiguration) { + @action hydrate(data: API.RevoltConfig) { this.config = data ?? null; } @@ -68,7 +68,7 @@ export default class ServerConfig * Set server configuration. * @param config Server configuration */ - @action set(config: RevoltConfiguration) { + @action set(config: API.RevoltConfig) { this.config = config; } } diff --git a/src/mobx/stores/Sync.ts b/src/mobx/stores/Sync.ts index 4a50de23..01acf8f4 100644 --- a/src/mobx/stores/Sync.ts +++ b/src/mobx/stores/Sync.ts @@ -7,7 +7,6 @@ import { runInAction, } from "mobx"; import { Client } from "revolt.js"; -import { UserSettings } from "revolt-api/types/Sync"; import { mapToRecord } from "../../lib/conversion"; @@ -104,7 +103,7 @@ export default class Sync implements Store, Persistent { return this.revision.get(key); } - @action apply(data: UserSettings) { + @action apply(data: Record) { const tryRead = (key: string) => { if (key in data) { const revision = data[key][0]; diff --git a/src/pages/channels/Channel.tsx b/src/pages/channels/Channel.tsx index bba4d824..14bf5f65 100644 --- a/src/pages/channels/Channel.tsx +++ b/src/pages/channels/Channel.tsx @@ -149,9 +149,9 @@ const TextChannel = observer(({ channel }: { channel: ChannelI }) => { // Mark channel as read. useEffect(() => { setLastId( - channel.unread + (channel.unread ? channel.client.unreads?.getUnread(channel._id)?.last_id - : undefined ?? undefined, + : undefined) ?? undefined, ); const checkUnread = () => diff --git a/src/pages/channels/messaging/MessageRenderer.tsx b/src/pages/channels/messaging/MessageRenderer.tsx index 422f0127..0b510b44 100644 --- a/src/pages/channels/messaging/MessageRenderer.tsx +++ b/src/pages/channels/messaging/MessageRenderer.tsx @@ -2,8 +2,7 @@ import { X } from "@styled-icons/boxicons-regular"; import isEqual from "lodash.isequal"; import { observer } from "mobx-react-lite"; -import { Masquerade } from "revolt-api/types/Channels"; -import { RelationshipStatus } from "revolt-api/types/Users"; +import { API } from "revolt.js"; import { Message as MessageI } from "revolt.js/dist/maps/Messages"; import { Nullable } from "revolt.js/dist/util/null"; import styled from "styled-components/macro"; @@ -99,10 +98,10 @@ export default observer(({ last_id, renderer, highlight }: Props) => { function compare( current: string, curAuthor: string, - currentMasq: Nullable, + currentMasq: Nullable, previous: string, prevAuthor: string, - previousMasq: Nullable, + previousMasq: Nullable, ) { head = false; const atime = decodeTime(current), @@ -172,9 +171,7 @@ export default observer(({ last_id, renderer, highlight }: Props) => { highlight={highlight === message._id} />, ); - } else if ( - message.author?.relationship === RelationshipStatus.Blocked - ) { + } else if (message.author?.relationship === "Blocked") { blocked++; } else { if (blocked > 0) pushBlocked(); diff --git a/src/pages/friends/Friend.tsx b/src/pages/friends/Friend.tsx index c52b10d4..cb507b2b 100644 --- a/src/pages/friends/Friend.tsx +++ b/src/pages/friends/Friend.tsx @@ -2,7 +2,6 @@ import { X, Plus } from "@styled-icons/boxicons-regular"; import { PhoneCall, Envelope, UserX } from "@styled-icons/boxicons-solid"; import { observer } from "mobx-react-lite"; import { useHistory } from "react-router-dom"; -import { RelationshipStatus } from "revolt-api/types/Users"; import { User } from "revolt.js/dist/maps/Users"; import styles from "./Friend.module.scss"; @@ -33,7 +32,7 @@ export const Friend = observer(({ user }: Props) => { const actions: Children[] = []; let subtext: Children = null; - if (user.relationship === RelationshipStatus.Friend) { + if (user.relationship === "Friend") { subtext = ; actions.push( <> @@ -70,7 +69,7 @@ export const Friend = observer(({ user }: Props) => { ); } - if (user.relationship === RelationshipStatus.Incoming) { + if (user.relationship === "Incoming") { actions.push( { subtext = ; } - if (user.relationship === RelationshipStatus.Outgoing) { + if (user.relationship === "Outgoing") { subtext = ; } if ( - user.relationship === RelationshipStatus.Friend || - user.relationship === RelationshipStatus.Outgoing || - user.relationship === RelationshipStatus.Incoming + user.relationship === "Friend" || + user.relationship === "Outgoing" || + user.relationship === "Incoming" ) { actions.push( { onClick={(ev) => stopPropagation( ev, - user.relationship === RelationshipStatus.Friend + user.relationship === "Friend" ? openScreen({ id: "special_prompt", type: "unfriend_user", @@ -117,7 +116,7 @@ export const Friend = observer(({ user }: Props) => { ); } - if (user.relationship === RelationshipStatus.Blocked) { + if (user.relationship === "Blocked") { actions.push( { const users = [...client.users.values()]; users.sort((a, b) => a.username.localeCompare(b.username)); - const friends = users.filter( - (x) => x.relationship === RelationshipStatus.Friend, - ); + const friends = users.filter((x) => x.relationship === "Friend"); const lists = [ - [ - "", - users.filter((x) => x.relationship === RelationshipStatus.Incoming), - ], + ["", users.filter((x) => x.relationship === "Incoming")], [ "app.special.friends.sent", - users.filter((x) => x.relationship === RelationshipStatus.Outgoing), + users.filter((x) => x.relationship === "Outgoing"), "outgoing", ], [ "app.status.online", friends.filter( - (x) => x.online && x.status?.presence !== Presence.Invisible, + (x) => x.online && x.status?.presence !== "Invisible", ), "online", ], [ "app.status.offline", friends.filter( - (x) => !x.online || x.status?.presence === Presence.Invisible, + (x) => !x.online || x.status?.presence === "Invisible", ), "offline", ], [ "app.special.friends.blocked", - users.filter((x) => x.relationship === RelationshipStatus.Blocked), + users.filter((x) => x.relationship === "Blocked"), "blocked", ], ] as [string, User[], string][]; diff --git a/src/pages/invite/Invite.tsx b/src/pages/invite/Invite.tsx index b55dce37..bb492319 100644 --- a/src/pages/invite/Invite.tsx +++ b/src/pages/invite/Invite.tsx @@ -1,7 +1,7 @@ import { ArrowBack } from "@styled-icons/boxicons-regular"; import { autorun } from "mobx"; import { Redirect, useHistory, useParams } from "react-router-dom"; -import { RetrievedInvite } from "revolt-api/types/Invites"; +import { API } from "revolt.js"; import styles from "./Invite.module.scss"; import { Text } from "preact-i18n"; @@ -36,7 +36,7 @@ export default function Invite() { const { code } = useParams<{ code: string }>(); const [processing, setProcessing] = useState(false); const [error, setError] = useState(undefined); - const [invite, setInvite] = useState( + const [invite, setInvite] = useState( undefined, ); @@ -92,6 +92,8 @@ export default function Invite() { ); } + if (invite.type === "Group") return

unimplemented

; + return (
(); const client = useClient(); - const [data, setData] = - useState["response"]>(); + const [data, setData] = useState(); useEffect(() => { client.bots.fetchPublic(id).then(setData); diff --git a/src/pages/login/forms/FormLogin.tsx b/src/pages/login/forms/FormLogin.tsx index 44c5a59a..e827b197 100644 --- a/src/pages/login/forms/FormLogin.tsx +++ b/src/pages/login/forms/FormLogin.tsx @@ -1,6 +1,5 @@ import { detect } from "detect-browser"; -import { Session } from "revolt-api/types/Auth"; -import { Client } from "revolt.js"; +import { API } from "revolt.js"; import { useApplicationState } from "../../../mobx/State"; @@ -44,25 +43,26 @@ export function FormLogin() { // This should be replaced in the future. const client = state.config.createClient(); await client.fetchConfiguration(); - const session = (await client.req( - "POST", - "/auth/session/login", - { ...data, friendly_name }, - )) as unknown as Session; + const session = await client.api.post("/auth/session/login", { + ...data, + friendly_name, + }); - client.session = session; - (client as any).Axios.defaults.headers = { - "x-session-token": session?.token, - }; - - async function login() { - state.auth.setSession(session); + if (session.result !== "Success") { + alert("unsupported!"); + return; } - const { onboarding } = await client.req( - "GET", - "/onboard/hello", - ); + const s = session; + + client.session = session; + (client as any).$updateHeaders(); + + async function login() { + state.auth.setSession(s); + } + + const { onboarding } = await client.api.get("/onboard/hello"); if (onboarding) { openScreen({ diff --git a/src/pages/login/forms/FormReset.tsx b/src/pages/login/forms/FormReset.tsx index 89dc1093..f71fec44 100644 --- a/src/pages/login/forms/FormReset.tsx +++ b/src/pages/login/forms/FormReset.tsx @@ -16,7 +16,7 @@ export function FormSendReset() {
{ - await client.req("POST", "/auth/account/reset_password", data); + await client.api.post("/auth/account/reset_password", data); }} /> ); @@ -32,7 +32,7 @@ export function FormReset() { { - await client.req("PATCH", "/auth/account/reset_password", { + await client.api.patch("/auth/account/reset_password", { token, ...data, }); diff --git a/src/pages/login/forms/FormVerify.tsx b/src/pages/login/forms/FormVerify.tsx index 2a46ff39..f7ecd1b9 100644 --- a/src/pages/login/forms/FormVerify.tsx +++ b/src/pages/login/forms/FormVerify.tsx @@ -20,7 +20,7 @@ export function FormResend() { { - await client.req("POST", "/auth/account/reverify", data); + await client.api.post("/auth/account/reverify", data); }} /> ); @@ -34,11 +34,8 @@ export function FormVerify() { const history = useHistory(); useEffect(() => { - client - .req( - "POST", - `/auth/account/verify/${token}` as "/auth/account/verify/:code", - ) + client.api + .post(`/auth/account/verify/${token as ""}`) .then(() => history.push("/login")) .catch((err) => setError(takeError(err))); // eslint-disable-next-line diff --git a/src/pages/settings/Settings.tsx b/src/pages/settings/Settings.tsx index e8743a02..eb642503 100644 --- a/src/pages/settings/Settings.tsx +++ b/src/pages/settings/Settings.tsx @@ -337,7 +337,9 @@ export default observer(() => { - client.users.edit({ remove: "StatusText" }) + client.users.edit({ + remove: ["StatusText"], + }) } /> )} diff --git a/src/pages/settings/channel/Overview.tsx b/src/pages/settings/channel/Overview.tsx index 31bf7be2..2ac42c1a 100644 --- a/src/pages/settings/channel/Overview.tsx +++ b/src/pages/settings/channel/Overview.tsx @@ -69,7 +69,7 @@ export default observer(({ channel }: Props) => { { max_side: 256 }, true, )} - remove={() => channel.edit({ remove: "Icon" })} + remove={() => channel.edit({ remove: ["Icon"] })} defaultPreview={ channel.channel_type === "Group" ? "/assets/group.png" diff --git a/src/pages/settings/channel/Permissions.tsx b/src/pages/settings/channel/Permissions.tsx index 506ee6ed..900592e9 100644 --- a/src/pages/settings/channel/Permissions.tsx +++ b/src/pages/settings/channel/Permissions.tsx @@ -1,7 +1,6 @@ import isEqual from "lodash.isequal"; import { observer } from "mobx-react-lite"; -import { OverrideField } from "revolt-api/types/_common"; -import { Channel } from "revolt.js/dist/maps/Channels"; +import { Channel, API } from "revolt.js"; import { useLayoutEffect, useState } from "preact/hooks"; @@ -42,7 +41,7 @@ export default observer(({ channel }: Props) => { // Keep track of whatever role we're editing right now. const [selected, setSelected] = useState("default"); - const [value, setValue] = useState( + const [value, setValue] = useState( undefined, ); const currentPermission = currentRoles.find( @@ -64,10 +63,10 @@ export default observer(({ channel }: Props) => { selected, typeof currentValue === "number" ? currentValue - : { + : ({ allow: currentValue.a, deny: currentValue.d, - }, + } as any), ); } diff --git a/src/pages/settings/panes/Account.tsx b/src/pages/settings/panes/Account.tsx index 6d58d4aa..08d4722c 100644 --- a/src/pages/settings/panes/Account.tsx +++ b/src/pages/settings/panes/Account.tsx @@ -1,4 +1,4 @@ -import { At, Key, Block, ListOl } from "@styled-icons/boxicons-regular"; +import { At, Key, Block } from "@styled-icons/boxicons-regular"; import { Envelope, HelpCircle, @@ -8,7 +8,7 @@ import { } from "@styled-icons/boxicons-solid"; import { observer } from "mobx-react-lite"; import { useHistory } from "react-router-dom"; -import { Profile } from "revolt-api/types/Users"; +import { API } from "revolt.js"; import styles from "./Panes.module.scss"; import { Text } from "preact-i18n"; @@ -37,7 +37,9 @@ export const Account = observer(() => { const [email, setEmail] = useState("..."); const [revealEmail, setRevealEmail] = useState(false); - const [profile, setProfile] = useState(undefined); + const [profile, setProfile] = useState( + undefined, + ); const history = useHistory(); function switchPage(to: string) { @@ -46,8 +48,8 @@ export const Account = observer(() => { useEffect(() => { if (email === "..." && status === ClientStatus.ONLINE) { - client - .req("GET", "/auth/account") + client.api + .get("/auth/account/") .then((account) => setEmail(account.email)); } diff --git a/src/pages/settings/panes/MyBots.tsx b/src/pages/settings/panes/MyBots.tsx index 36331377..ca30a290 100644 --- a/src/pages/settings/panes/MyBots.tsx +++ b/src/pages/settings/panes/MyBots.tsx @@ -1,9 +1,9 @@ +// ! FIXME: this code is garbage, need to replace import { Key, Clipboard, Globe, Plus } from "@styled-icons/boxicons-regular"; import { LockAlt, HelpCircle } from "@styled-icons/boxicons-solid"; import type { AxiosError } from "axios"; import { observer } from "mobx-react-lite"; -import { Bot } from "revolt-api/types/Bots"; -import { Profile as ProfileI } from "revolt-api/types/Users"; +import { API } from "revolt.js"; import { User } from "revolt.js/dist/maps/Users"; import styled from "styled-components/macro"; @@ -43,7 +43,7 @@ interface Changes { name?: string; public?: boolean; interactions_url?: string; - remove?: "InteractionsURL"; + remove?: "InteractionsURL"[]; } const BotBadge = styled.div` @@ -62,7 +62,7 @@ const BotBadge = styled.div` `; interface Props { - bot: Bot; + bot: API.Bot; onDelete(): void; onUpdate(changes: Changes): void; } @@ -75,7 +75,7 @@ function BotCard({ bot, onDelete, onUpdate }: Props) { _id: bot._id, username: user.username, public: bot.public, - interactions_url: bot.interactions_url, + interactions_url: bot.interactions_url as any, }); const [error, setError] = useState(""); const [saving, setSaving] = useState(false); @@ -87,23 +87,21 @@ function BotCard({ bot, onDelete, onUpdate }: Props) { useState(null); const { writeClipboard, openScreen } = useIntermediate(); - const [profile, setProfile] = useState(undefined); + const [profile, setProfile] = useState( + undefined, + ); const refreshProfile = useCallback(() => { - client - .request( - "GET", - `/users/${bot._id}/profile` as "/users/id/profile", - { - headers: { "x-bot-token": bot.token }, - transformRequest: (data, headers) => { - // Remove user headers for this request - delete headers["x-user-id"]; - delete headers["x-session-token"]; - return data; - }, + client.api + .get(`/users/${bot._id as ""}/profile`, undefined, { + headers: { "x-bot-token": bot.token }, + transformRequest: (data, headers) => { + // Remove user headers for this request + delete headers?.["x-user-id"]; + delete headers?.["x-session-token"]; + return data; }, - ) + }) .then((profile) => setProfile(profile ?? {})); // eslint-disable-next-line react-hooks/exhaustive-deps }, [user, setProfile]); @@ -122,14 +120,14 @@ function BotCard({ bot, onDelete, onUpdate }: Props) { const changes: Changes = {}; if (data.username !== user!.username) changes.name = data.username; if (data.public !== bot.public) changes.public = data.public; - if (data.interactions_url === "") changes.remove = "InteractionsURL"; + if (data.interactions_url === "") changes.remove = ["InteractionsURL"]; else if (data.interactions_url !== bot.interactions_url) changes.interactions_url = data.interactions_url; setSaving(true); setError(""); try { await client.bots.edit(bot._id, changes); - if (changed) await editBotContent(profile?.content); + if (changed) await editBotContent(profile?.content ?? undefined); onUpdate(changes); setChanged(false); setEditMode(false); @@ -152,19 +150,22 @@ function BotCard({ bot, onDelete, onUpdate }: Props) { async function editBotAvatar(avatar?: string) { setSaving(true); setError(""); - await client.request("PATCH", "/users/id", { - headers: { "x-bot-token": bot.token }, - transformRequest: (data, headers) => { - // Remove user headers for this request - delete headers["x-user-id"]; - delete headers["x-session-token"]; - return data; + await client.api.patch( + "/users/@me", + avatar ? { avatar } : { remove: ["Avatar"] }, + { + headers: { "x-bot-token": bot.token }, + transformRequest: (data, headers) => { + // Remove user headers for this request + delete headers?.["x-user-id"]; + delete headers?.["x-session-token"]; + return data; + }, }, - data: JSON.stringify(avatar ? { avatar } : { remove: "Avatar" }), - }); + ); const res = await client.bots.fetch(bot._id); - if (!avatar) res.user.update({}, "Avatar"); + if (!avatar) res.user.update({}, ["Avatar"]); setUser(res.user); setSaving(false); } @@ -172,20 +173,21 @@ function BotCard({ bot, onDelete, onUpdate }: Props) { async function editBotBackground(background?: string) { setSaving(true); setError(""); - await client.request("PATCH", "/users/id", { - headers: { "x-bot-token": bot.token }, - transformRequest: (data, headers) => { - // Remove user headers for this request - delete headers["x-user-id"]; - delete headers["x-session-token"]; - return data; + await client.api.patch( + "/users/@me", + background + ? { profile: { background } } + : { remove: ["ProfileBackground"] }, + { + headers: { "x-bot-token": bot.token }, + transformRequest: (data, headers) => { + // Remove user headers for this request + delete headers?.["x-user-id"]; + delete headers?.["x-session-token"]; + return data; + }, }, - data: JSON.stringify( - background - ? { profile: { background } } - : { remove: "ProfileBackground" }, - ), - }); + ); if (!background) setProfile({ ...profile, background: undefined }); else refreshProfile(); @@ -195,20 +197,19 @@ function BotCard({ bot, onDelete, onUpdate }: Props) { async function editBotContent(content?: string) { setSaving(true); setError(""); - await client.request("PATCH", "/users/id", { - headers: { "x-bot-token": bot.token }, - transformRequest: (data, headers) => { - // Remove user headers for this request - delete headers["x-user-id"]; - delete headers["x-session-token"]; - return data; + await client.api.patch( + "/users/@me", + content ? { profile: { content } } : { remove: ["ProfileContent"] }, + { + headers: { "x-bot-token": bot.token }, + transformRequest: (data, headers) => { + // Remove user headers for this request + delete headers?.["x-user-id"]; + delete headers?.["x-session-token"]; + return data; + }, }, - data: JSON.stringify( - content - ? { profile: { content } } - : { remove: "ProfileContent" }, - ), - }); + ); if (!content) setProfile({ ...profile, content: undefined }); else refreshProfile(); @@ -333,7 +334,7 @@ function BotCard({ bot, onDelete, onUpdate }: Props) { _id: bot._id, username: user!.username, public: bot.public, - interactions_url: bot.interactions_url, + interactions_url: bot.interactions_url as any, }); usernameRef!.value = user!.username; interactionsRef!.value = bot.interactions_url || ""; @@ -521,7 +522,7 @@ function BotCard({ bot, onDelete, onUpdate }: Props) { export const MyBots = observer(() => { const client = useClient(); - const [bots, setBots] = useState(undefined); + const [bots, setBots] = useState(undefined); useEffect(() => { client.bots.fetchOwned().then(({ bots }) => setBots(bots)); @@ -582,7 +583,7 @@ export const MyBots = observer(() => { changes.interactions_url; if ( changes.remove === - "InteractionsURL" + ["InteractionsURL"] ) x.interactions_url = undefined; } diff --git a/src/pages/settings/panes/Notifications.tsx b/src/pages/settings/panes/Notifications.tsx index 6c692c44..4d6e24e1 100644 --- a/src/pages/settings/panes/Notifications.tsx +++ b/src/pages/settings/panes/Notifications.tsx @@ -81,7 +81,7 @@ export const Notifications = observer(() => { // tell the server we just subscribed const json = sub.toJSON(); if (json.keys) { - client.req("POST", "/push/subscribe", { + client.api.post("/push/subscribe", { endpoint: sub.endpoint, ...(json.keys as { p256dh: string; @@ -96,7 +96,7 @@ export const Notifications = observer(() => { sub?.unsubscribe(); setPushEnabled(false); - client.req("POST", "/push/unsubscribe"); + client.api.post("/push/unsubscribe"); } } } catch (err) { diff --git a/src/pages/settings/panes/Profile.tsx b/src/pages/settings/panes/Profile.tsx index 02f5dfe8..cb717dd6 100644 --- a/src/pages/settings/panes/Profile.tsx +++ b/src/pages/settings/panes/Profile.tsx @@ -1,7 +1,7 @@ import { Markdown } from "@styled-icons/boxicons-logos"; import { observer } from "mobx-react-lite"; import { useHistory } from "react-router-dom"; -import { Profile as ProfileI } from "revolt-api/types/Users"; +import { API } from "revolt.js"; import styles from "./Panes.module.scss"; import { Text } from "preact-i18n"; @@ -30,7 +30,9 @@ export const Profile = observer(() => { const client = useClient(); const history = useHistory(); - const [profile, setProfile] = useState(undefined); + const [profile, setProfile] = useState( + undefined, + ); // ! FIXME: temporary solution // ! we should just announce profile changes through WS @@ -103,7 +105,7 @@ export const Profile = observer(() => { behaviour="upload" maxFileSize={4_000_000} onUpload={(avatar) => client.users.edit({ avatar })} - remove={() => client.users.edit({ remove: "Avatar" })} + remove={() => client.users.edit({ remove: ["Avatar"] })} defaultPreview={client.user!.generateAvatarURL( { max_side: 256 }, true, @@ -132,7 +134,7 @@ export const Profile = observer(() => { }} remove={async () => { await client.users.edit({ - remove: "ProfileBackground", + remove: ["ProfileBackground"], }); setProfile({ ...profile, background: undefined }); }} diff --git a/src/pages/settings/panes/Sessions.tsx b/src/pages/settings/panes/Sessions.tsx index 44215426..2c5744f6 100644 --- a/src/pages/settings/panes/Sessions.tsx +++ b/src/pages/settings/panes/Sessions.tsx @@ -11,7 +11,7 @@ import { } from "@styled-icons/simple-icons"; import relativeTime from "dayjs/plugin/relativeTime"; import { useHistory } from "react-router-dom"; -import { SessionInfo } from "revolt-api/types/Auth"; +import { API } from "revolt.js"; import { decodeTime } from "ulid"; import styles from "./Panes.module.scss"; @@ -33,7 +33,7 @@ export function Sessions() { const deviceId = typeof client.session === "object" ? client.session._id : undefined; - const [sessions, setSessions] = useState( + const [sessions, setSessions] = useState( undefined, ); const [attemptingDelete, setDelete] = useState([]); @@ -44,7 +44,7 @@ export function Sessions() { } useEffect(() => { - client.req("GET", "/auth/session/all").then((data) => { + client.api.get("/auth/session/all").then((data) => { data.sort( (a, b) => (b._id === deviceId ? 1 : 0) - (a._id === deviceId ? 1 : 0), @@ -61,7 +61,7 @@ export function Sessions() { ); } - function getIcon(session: SessionInfo) { + function getIcon(session: API.SessionInfo) { const name = session.name; switch (true) { case /firefox/i.test(name): @@ -83,7 +83,7 @@ export function Sessions() { } } - function getSystemIcon(session: SessionInfo) { + function getSystemIcon(session: API.SessionInfo) { const name = session.name; switch (true) { case /linux/i.test(name): @@ -187,9 +187,10 @@ export function Sessions() { ...attemptingDelete, session._id, ]); - await client.req( - "DELETE", - `/auth/session/${session._id}` as "/auth/session/id", + await client.api.delete( + `/auth/session/${ + session._id as "" + }`, ); setSessions( sessions?.filter( @@ -222,10 +223,7 @@ export function Sessions() { setDelete(del); for (const id of del) { - await client.req( - "DELETE", - `/auth/session/${id}` as "/auth/session/id", - ); + await client.api.delete(`/auth/session/${id as ""}`); } setSessions(sessions.filter((x) => x._id === deviceId)); diff --git a/src/pages/settings/server/Bans.tsx b/src/pages/settings/server/Bans.tsx index 29af2fe7..f7c14fcd 100644 --- a/src/pages/settings/server/Bans.tsx +++ b/src/pages/settings/server/Bans.tsx @@ -1,9 +1,7 @@ import { XCircle } from "@styled-icons/boxicons-regular"; import { observer } from "mobx-react-lite"; import { Virtuoso } from "react-virtuoso"; -import { Ban } from "revolt-api/types/Servers"; -import { User } from "revolt-api/types/Users"; -import { Route } from "revolt.js/dist/api/routes"; +import { API } from "revolt.js"; import { Server } from "revolt.js/dist/maps/Servers"; import styles from "./Panes.module.scss"; @@ -15,8 +13,8 @@ import IconButton from "../../../components/ui/IconButton"; import Preloader from "../../../components/ui/Preloader"; interface InnerProps { - ban: Ban; - users: Pick[]; + ban: API.ServerBan; + users: Pick[]; server: Server; removeSelf: () => void; } @@ -53,9 +51,7 @@ interface Props { } export const Bans = observer(({ server }: Props) => { - const [data, setData] = useState< - Route<"GET", "/servers/id/bans">["response"] | undefined - >(undefined); + const [data, setData] = useState(undefined); useEffect(() => { server.fetchBans().then(setData); diff --git a/src/pages/settings/server/Categories.tsx b/src/pages/settings/server/Categories.tsx index a797eb36..5dd9e74c 100644 --- a/src/pages/settings/server/Categories.tsx +++ b/src/pages/settings/server/Categories.tsx @@ -1,9 +1,7 @@ import { Plus, X } from "@styled-icons/boxicons-regular"; import { observer } from "mobx-react-lite"; import { DragDropContext } from "react-beautiful-dnd"; -import { TextChannel, VoiceChannel } from "revolt-api/types/Channels"; -import { Category } from "revolt-api/types/Servers"; -import { Server } from "revolt.js/dist/maps/Servers"; +import { Channel, Server, API } from "revolt.js"; import styled, { css } from "styled-components/macro"; import { ulid } from "ulid"; @@ -135,7 +133,7 @@ interface Props { export const Categories = observer(({ server }: Props) => { const [status, setStatus] = useState("saved"); - const [categories, setCategories] = useState( + const [categories, setCategories] = useState( server.categories ?? [], ); @@ -327,12 +325,14 @@ function ListElement({ addChannel, draggable, }: { - category: Category; + category: API.Category; server: Server; index: number; setTitle?: (title: string) => void; deleteSelf?: () => void; - addChannel: (channel: TextChannel | VoiceChannel) => void; + addChannel: ( + channel: Channel & { channel_type: "TextChannel" | "VoiceChannel" }, + ) => void; draggable?: boolean; }) { const { openScreen } = useIntermediate(); diff --git a/src/pages/settings/server/Invites.tsx b/src/pages/settings/server/Invites.tsx index 4823e3bf..f4f64d1f 100644 --- a/src/pages/settings/server/Invites.tsx +++ b/src/pages/settings/server/Invites.tsx @@ -1,8 +1,7 @@ import { XCircle } from "@styled-icons/boxicons-regular"; import { observer } from "mobx-react-lite"; import { Virtuoso } from "react-virtuoso"; -import { Invite, ServerInvite } from "revolt-api/types/Invites"; -import { Server } from "revolt.js/dist/maps/Servers"; +import { API, Server } from "revolt.js"; import styles from "./Panes.module.scss"; import { Text } from "preact-i18n"; @@ -16,7 +15,7 @@ import IconButton from "../../../components/ui/IconButton"; import Preloader from "../../../components/ui/Preloader"; interface InnerProps { - invite: Invite; + invite: API.Invite; server: Server; removeSelf: () => void; } @@ -52,12 +51,10 @@ interface Props { } export const Invites = ({ server }: Props) => { - const [invites, setInvites] = useState( - undefined, - ); + const [invites, setInvites] = useState(undefined); useEffect(() => { - server.fetchInvites().then(setInvites); + server.fetchInvites().then((v) => setInvites(v)); }, [server, setInvites]); return ( diff --git a/src/pages/settings/server/Overview.tsx b/src/pages/settings/server/Overview.tsx index 24f241f1..4589e35a 100644 --- a/src/pages/settings/server/Overview.tsx +++ b/src/pages/settings/server/Overview.tsx @@ -8,6 +8,7 @@ import { Text } from "preact-i18n"; import { useEffect, useState } from "preact/hooks"; import TextAreaAutoSize from "../../../lib/TextAreaAutoSize"; +import { noop } from "../../../lib/js"; import { FileUploader } from "../../../context/revoltjs/FileUploads"; import { getChannelName } from "../../../context/revoltjs/util"; @@ -60,9 +61,9 @@ export const Overview = observer(({ server }: Props) => { fileType="icons" behaviour="upload" maxFileSize={2_500_000} - onUpload={(icon) => server.edit({ icon })} + onUpload={(icon) => server.edit({ icon }).then(noop)} previewURL={server.generateIconURL({ max_side: 256 }, true)} - remove={() => server.edit({ remove: "Icon" })} + remove={() => server.edit({ remove: ["Icon"] }).then(noop)} />

@@ -117,9 +118,9 @@ export const Overview = observer(({ server }: Props) => { fileType="banners" behaviour="upload" maxFileSize={6_000_000} - onUpload={(banner) => server.edit({ banner })} + onUpload={(banner) => server.edit({ banner }).then(noop)} previewURL={server.generateBannerURL({ width: 1000 }, true)} - remove={() => server.edit({ remove: "Banner" })} + remove={() => server.edit({ remove: ["Banner"] }).then(noop)} />

diff --git a/yarn.lock b/yarn.lock index 8f0957b4..f9aa2894 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1375,6 +1375,16 @@ resolved "https://registry.yarnpkg.com/@insertish/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz#5bcd6f73b93efa9ccdb6abf887ae808d40827169" integrity sha512-kFD/p8T4Hkqr992QrdkbW/cQ/W/q2d9MPCobwzBv2PwTKLkCD9RaYDy6m17qRnSLQQ5PU0kHCG8kaOwAqzj1vQ== +"@insertish/oapi@0.1.13": + version "0.1.13" + resolved "https://registry.yarnpkg.com/@insertish/oapi/-/oapi-0.1.13.tgz#92579172bd6896152e9b68ef5bafcf8cc2048492" + integrity sha512-yj1Jk3VlNCjp0hNOsknevyR7PwVzSzc5pbUTuyhtyPlbuHRTv1b9DWs8Ki7xbF/mrIy2DzkHoUu4Ik/Q4oS93w== + dependencies: + typescript "^4.6.2" + optionalDependencies: + axios "^0.26.1" + openapi-typescript "^5.2.0" + "@insertish/vite-plugin-babel-macros@^1.0.5": version "1.0.5" resolved "https://registry.yarnpkg.com/@insertish/vite-plugin-babel-macros/-/vite-plugin-babel-macros-1.0.5.tgz#399c79f22d08bf5ba8830dd4500bd6b4e5f14f92" @@ -2083,6 +2093,13 @@ axios@^0.21.4: dependencies: follow-redirects "^1.14.0" +axios@^0.26.1: + version "0.26.1" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.26.1.tgz#1ede41c51fcf51bbbd6fd43669caaa4f0495aaa9" + integrity sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA== + dependencies: + follow-redirects "^1.14.8" + babel-eslint@^10.0.1: version "10.1.0" resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-10.1.0.tgz#6968e568a910b78fb3779cdd8b6ac2f479943232" @@ -3027,6 +3044,11 @@ follow-redirects@^1.14.0: resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.4.tgz#838fdf48a8bbdd79e52ee51fb1c94e3ed98b9379" integrity sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g== +follow-redirects@^1.14.8: + version "1.14.9" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.9.tgz#dd4ea157de7bfaf9ea9b3fbd85aa16951f78d8d7" + integrity sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w== + fs-extra@^10.0.0: version "10.0.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.0.0.tgz#9ff61b655dde53fb34a82df84bb214ce802e17c1" @@ -3129,6 +3151,11 @@ globals@^13.6.0, globals@^13.9.0: dependencies: type-fest "^0.20.2" +globalyzer@0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/globalyzer/-/globalyzer-0.1.0.tgz#cb76da79555669a1519d5a8edf093afaa0bf1465" + integrity sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q== + globby@^11.0.3: version "11.0.4" resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.4.tgz#2cbaff77c2f2a62e71e9b2813a67b97a3a3001a5" @@ -3141,6 +3168,11 @@ globby@^11.0.3: merge2 "^1.3.0" slash "^3.0.0" +globrex@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/globrex/-/globrex-0.1.2.tgz#dd5d9ec826232730cd6793a5e33a9302985e6098" + integrity sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg== + graceful-fs@^4.1.6, graceful-fs@^4.1.9, graceful-fs@^4.2.0: version "4.2.8" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.8.tgz#e412b8d33f5e006593cbd3cee6df9f2cebbe802a" @@ -3457,6 +3489,13 @@ js-yaml@^3.13.1: argparse "^1.0.7" esprima "^4.0.0" +js-yaml@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" + integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== + dependencies: + argparse "^2.0.1" + jsesc@^2.5.1: version "2.5.2" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4" @@ -3757,6 +3796,11 @@ mime@^2.3.1: resolved "https://registry.yarnpkg.com/mime/-/mime-2.5.2.tgz#6e3dc6cc2b9510643830e5f19d5cb753da5eeabe" integrity sha512-tqkh47FzKeCPD2PUiPB6pkbMzsCasjxAfC62/Wap5qrUWcb+sFasXUC5I3gYM5iBM8v/Qpn4UK0x+j0iHyFPDg== +mime@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/mime/-/mime-3.0.0.tgz#b374550dca3a0c18443b0c950a6a58f1931cf7a7" + integrity sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A== + mini-create-react-context@^0.4.0: version "0.4.1" resolved "https://registry.yarnpkg.com/mini-create-react-context/-/mini-create-react-context-0.4.1.tgz#072171561bfdc922da08a60c2197a497cc2d1d5e" @@ -3889,6 +3933,18 @@ once@^1.3.0: dependencies: wrappy "1" +openapi-typescript@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/openapi-typescript/-/openapi-typescript-5.2.0.tgz#c0712d7a17e4502ac083162c42f946c0e966a505" + integrity sha512-EGoPTmxrpiN40R6An5Wqol2l74sRb773pv/KXWYCQaMCXNtMGN7Jv+y/jY4B1Bd4hsIW2j9GFmQXxqfGmOXaxA== + dependencies: + js-yaml "^4.1.0" + mime "^3.0.0" + prettier "^2.5.1" + tiny-glob "^0.2.9" + undici "^4.14.1" + yargs-parser "^21.0.0" + optionator@^0.9.1: version "0.9.1" resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.1.tgz#4f236a6373dae0566a6d43e1326674f50c291499" @@ -4023,6 +4079,11 @@ prettier@^2.3.1: resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.3.2.tgz#ef280a05ec253712e486233db5c6f23441e7342d" integrity sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ== +prettier@^2.5.1: + version "2.6.0" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.6.0.tgz#12f8f504c4d8ddb76475f441337542fa799207d4" + integrity sha512-m2FgJibYrBGGgQXNzfd0PuDGShJgRavjUoRCw1mZERIWVSXF0iLzLm+aOqTAbLnC3n6JzUhAA8uZnFVghHJ86A== + pretty-bytes@^5.3.0, pretty-bytes@^5.6.0: version "5.6.0" resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-5.6.0.tgz#356256f643804773c82f64723fe78c92c62beaeb" @@ -4303,15 +4364,19 @@ reusify@^1.0.4: resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== -revolt-api@0.5.3-alpha.12: - version "0.5.3-alpha.12" - resolved "https://registry.yarnpkg.com/revolt-api/-/revolt-api-0.5.3-alpha.12.tgz#78f25b567b840c1fd072595526592a422cb01f25" - integrity sha512-MM42oI5+5JJMnAs3JiOwSQOy/SUYzYs3M8YRC5QI4G6HU7CfyB2HNWh5jFsyRlcLdSi13dGazHm31FUPHsxOzw== +revolt-api@0.5.3-rc.7: + version "0.5.3-rc.7" + resolved "https://registry.yarnpkg.com/revolt-api/-/revolt-api-0.5.3-rc.7.tgz#eed82fcd014a25a4d080c4502c0ae4aa283adddb" + integrity sha512-72SJ+P19nRRD+xE8bXAV8mFZNBgtKkXogQACDvNSIdATUmszYl91YRPqX+UQ1Oz4ePgKFwyWPxrnmfede7Q83g== + dependencies: + "@insertish/oapi" "0.1.13" + axios "^0.26.1" + lodash.defaultsdeep "^4.6.1" -revolt.js@5.2.8: - version "5.2.8" - resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-5.2.8.tgz#5c9b3b10d3ea488e74b3208a9309e2106fb8c2c2" - integrity sha512-J3n2Rwbqen9UTqfgl/N2RJx/9QaXhuZWdp/Pce0wrw9pP/xCTk87FlHHG0ZWuJvX4fltg9lbCHGMcUIT6UA2wA== +revolt.js@6.0.0-rc.3: + version "6.0.0-rc.3" + resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-6.0.0-rc.3.tgz#0bf791eebf49b70c0baa2d2bd645c500c40ba737" + integrity sha512-b3jh/U80cWHJgjZxhyufCEspsWUOgKHPV+h3/1gWpt3fvpUWC2BPxDtJSVNXKe9AjQOpofpYaNQ8l9wlEfxA4A== dependencies: "@insertish/exponential-backoff" "3.1.0-patch.0" "@insertish/isomorphic-ws" "^4.0.1" @@ -4320,8 +4385,9 @@ revolt.js@5.2.8: lodash.defaultsdeep "^4.6.1" lodash.flatten "^4.4.0" lodash.isequal "^4.5.0" + long "^5.2.0" mobx "^6.3.2" - revolt-api "0.5.3-alpha.12" + revolt-api "0.5.3-rc.7" ulid "^2.3.0" ws "^8.2.2" @@ -4737,6 +4803,14 @@ text-table@^0.2.0: resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= +tiny-glob@^0.2.9: + version "0.2.9" + resolved "https://registry.yarnpkg.com/tiny-glob/-/tiny-glob-0.2.9.tgz#2212d441ac17928033b110f8b3640683129d31e2" + integrity sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg== + dependencies: + globalyzer "0.1.0" + globrex "^0.1.2" + tiny-invariant@^1.0.2, tiny-invariant@^1.0.6: version "1.1.0" resolved "https://registry.yarnpkg.com/tiny-invariant/-/tiny-invariant-1.1.0.tgz#634c5f8efdc27714b7f386c35e6760991d230875" @@ -4822,6 +4896,11 @@ typescript@^4.4.2: resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.2.tgz#6d618640d430e3569a1dfb44f7d7e600ced3ee86" integrity sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ== +typescript@^4.6.2: + version "4.6.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.2.tgz#fe12d2727b708f4eef40f51598b3398baa9611d4" + integrity sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg== + ua-parser-js@^0.7.24: version "0.7.28" resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.28.tgz#8ba04e653f35ce210239c64661685bf9121dec31" @@ -4847,6 +4926,11 @@ unbox-primitive@^1.0.1: has-symbols "^1.0.2" which-boxed-primitive "^1.0.2" +undici@^4.14.1: + version "4.16.0" + resolved "https://registry.yarnpkg.com/undici/-/undici-4.16.0.tgz#469bb87b3b918818d3d7843d91a1d08da357d5ff" + integrity sha512-tkZSECUYi+/T1i4u+4+lwZmQgLXd4BLGlrc7KZPcLIW7Jpq99+Xpc30ONv7nS6F5UNOxp/HBZSSL9MafUrvJbw== + unicode-canonical-property-names-ecmascript@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz#2619800c4c825800efdd8343af7dd9933cbe2818" @@ -5189,6 +5273,11 @@ yaml@^1.10.0: resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b" integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg== +yargs-parser@^21.0.0: + version "21.0.1" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.0.1.tgz#0267f286c877a4f0f728fceb6f8a3e4cb95c6e35" + integrity sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg== + yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"