diff --git a/package-esm.json b/package-esm.json new file mode 100644 index 00000000..3dbc1ca5 --- /dev/null +++ b/package-esm.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/package.json b/package.json index 4a22f2f1..a93b7fe0 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,8 @@ "author": "Paul Makles ", "license": "MIT", "scripts": { - "build": "tsc && tsc -p tsconfig.cjs.json", - "build:esm": "tsc", + "build": "pnpm run build:esm && pnpm run build:cjs", + "build:esm": "tsc && cp package-esm.json lib/esm/package.json", "build:cjs": "tsc -p tsconfig.cjs.json", "build:watch": "tsc-watch --onSuccess \"node .\"", "lint": "eslint --ext .ts,.tsx src/", diff --git a/src/Client.ts b/src/Client.ts index 96033ce5..65d8fbe1 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -1,10 +1,18 @@ import { Accessor, Setter, batch, createSignal } from "solid-js"; import EventEmitter from "eventemitter3"; -import { API, Role } from "revolt-api"; import type { DataLogin, RevoltConfig } from "revolt-api"; +import { API, Role } from "revolt-api"; -import { Channel, Emoji, Message, Server, ServerMember, User } from "./classes"; +import { + Channel, + Emoji, + Message, + Server, + ServerMember, + User, +} from "./classes/index.js"; +import { AccountCollection } from "./collections/AccountCollection.js"; import { BotCollection, ChannelCollection, @@ -16,14 +24,13 @@ import { ServerMemberCollection, SessionCollection, UserCollection, -} from "./collections"; -import { AccountCollection } from "./collections/AccountCollection"; +} from "./collections/index.js"; import { ConnectionState, EventClient, EventClientOptions, handleEventV1, -} from "./events"; +} from "./events/index.js"; import { HydratedChannel, HydratedEmoji, @@ -31,8 +38,8 @@ import { HydratedServer, HydratedServerMember, HydratedUser, -} from "./hydration"; -import { RE_CHANNELS, RE_MENTIONS, RE_SPOILER } from "./lib/regex"; +} from "./hydration/index.js"; +import { RE_CHANNELS, RE_MENTIONS, RE_SPOILER } from "./lib/regex.js"; export type Session = { _id: string; token: string; user_id: string } | string; diff --git a/src/classes/Bot.ts b/src/classes/Bot.ts index f266ee8c..4527c773 100644 --- a/src/classes/Bot.ts +++ b/src/classes/Bot.ts @@ -1,7 +1,7 @@ import { DataEditBot } from "revolt-api"; import { decodeTime } from "ulid"; -import { BotCollection } from "../collections"; +import { BotCollection } from "../collections/index.js"; /** * Bot Class diff --git a/src/classes/Channel.ts b/src/classes/Channel.ts index 7a49e0ea..d1ec4ed7 100644 --- a/src/classes/Channel.ts +++ b/src/classes/Channel.ts @@ -12,10 +12,13 @@ import type { import { APIRoutes } from "revolt-api/dist/routes"; import { decodeTime, ulid } from "ulid"; -import { Message } from ".."; -import { ChannelCollection } from "../collections"; -import { bitwiseAndEq, calculatePermission } from "../permissions/calculator"; -import { Permission } from "../permissions/definitions"; +import { ChannelCollection } from "../collections/index.js"; +import { Message } from "../index.js"; +import { + bitwiseAndEq, + calculatePermission, +} from "../permissions/calculator.js"; +import { Permission } from "../permissions/definitions.js"; /** * Channel Class diff --git a/src/classes/ChannelUnread.ts b/src/classes/ChannelUnread.ts index 6f6dabf9..738174be 100644 --- a/src/classes/ChannelUnread.ts +++ b/src/classes/ChannelUnread.ts @@ -1,4 +1,4 @@ -import { ChannelUnreadCollection } from "../collections"; +import { ChannelUnreadCollection } from "../collections/index.js"; /** * Channel Unread Class diff --git a/src/classes/ChannelWebhook.ts b/src/classes/ChannelWebhook.ts index 860bb5d7..4082b380 100644 --- a/src/classes/ChannelWebhook.ts +++ b/src/classes/ChannelWebhook.ts @@ -1,7 +1,7 @@ import { DataEditWebhook } from "revolt-api"; -import { ChannelWebhookCollection } from "../collections"; -import { hydrate } from "../hydration"; +import { ChannelWebhookCollection } from "../collections/index.js"; +import { hydrate } from "../hydration/index.js"; /** * Channel Webhook Class diff --git a/src/classes/Emoji.ts b/src/classes/Emoji.ts index 9c02950d..2bf03aed 100644 --- a/src/classes/Emoji.ts +++ b/src/classes/Emoji.ts @@ -1,6 +1,6 @@ import { decodeTime } from "ulid"; -import { EmojiCollection } from "../collections"; +import { EmojiCollection } from "../collections/index.js"; /** * Emoji Class diff --git a/src/classes/File.ts b/src/classes/File.ts index 2ad83947..10568597 100644 --- a/src/classes/File.ts +++ b/src/classes/File.ts @@ -1,6 +1,6 @@ import { Metadata } from "revolt-api"; -import { API, Client } from ".."; +import { API, Client } from "../index.js"; /** * Uploaded File diff --git a/src/classes/Invite.ts b/src/classes/Invite.ts index 786c6e61..3b9b3a71 100644 --- a/src/classes/Invite.ts +++ b/src/classes/Invite.ts @@ -1,4 +1,4 @@ -import { API, Client } from ".."; +import { API, Client } from "../index.js"; /** * Channel Invite diff --git a/src/classes/MFA.ts b/src/classes/MFA.ts index e4d7b96a..739c1e86 100644 --- a/src/classes/MFA.ts +++ b/src/classes/MFA.ts @@ -7,7 +7,7 @@ import { MFATicket as TicketType, } from "revolt-api"; -import { Client } from ".."; +import { Client } from "../index.js"; /** * Multi-Factor Authentication diff --git a/src/classes/Message.ts b/src/classes/Message.ts index be88bddf..e212e761 100644 --- a/src/classes/Message.ts +++ b/src/classes/Message.ts @@ -5,8 +5,8 @@ import { } from "revolt-api"; import { decodeTime } from "ulid"; -import { Client, File } from ".."; -import { MessageCollection } from "../collections"; +import { MessageCollection } from "../collections/index.js"; +import { Client, File } from "../index.js"; /** * Message Class diff --git a/src/classes/MessageEmbed.ts b/src/classes/MessageEmbed.ts index 0be64a50..f0ae016d 100644 --- a/src/classes/MessageEmbed.ts +++ b/src/classes/MessageEmbed.ts @@ -1,4 +1,4 @@ -import { API, Client, File } from ".."; +import { API, Client, File } from "../index.js"; /** * Message Embed diff --git a/src/classes/PublicBot.ts b/src/classes/PublicBot.ts index 039a378a..fa07542b 100644 --- a/src/classes/PublicBot.ts +++ b/src/classes/PublicBot.ts @@ -1,4 +1,4 @@ -import { API, Channel, Client, File, Server } from ".."; +import { API, Channel, Client, File, Server } from "../index.js"; /** * Public Bot Class diff --git a/src/classes/PublicInvite.ts b/src/classes/PublicInvite.ts index 4ab1b43c..d446dc79 100644 --- a/src/classes/PublicInvite.ts +++ b/src/classes/PublicInvite.ts @@ -1,7 +1,7 @@ import { batch } from "solid-js"; -import { API, Client, File } from ".."; -import { ServerFlags } from "../hydration/server"; +import { ServerFlags } from "../hydration/server.js"; +import { API, Client, File } from "../index.js"; /** * Public Channel Invite diff --git a/src/classes/Server.ts b/src/classes/Server.ts index f49fb829..807c3bbd 100644 --- a/src/classes/Server.ts +++ b/src/classes/Server.ts @@ -12,15 +12,18 @@ import type { } from "revolt-api"; import { decodeTime } from "ulid"; -import { ServerMember, User } from ".."; -import { ServerCollection } from "../collections"; -import { hydrate } from "../hydration"; -import { bitwiseAndEq, calculatePermission } from "../permissions/calculator"; -import { Permission } from "../permissions/definitions"; - -import { Channel } from "./Channel"; -import { ChannelInvite } from "./Invite"; -import { ServerBan } from "./ServerBan"; +import { ServerCollection } from "../collections/index.js"; +import { hydrate } from "../hydration/index.js"; +import { ServerMember, User } from "../index.js"; +import { + bitwiseAndEq, + calculatePermission, +} from "../permissions/calculator.js"; +import { Permission } from "../permissions/definitions.js"; + +import { Channel } from "./Channel.js"; +import { ChannelInvite } from "./Invite.js"; +import { ServerBan } from "./ServerBan.js"; /** * Server Class diff --git a/src/classes/ServerBan.ts b/src/classes/ServerBan.ts index 8cd31733..f3a6697f 100644 --- a/src/classes/ServerBan.ts +++ b/src/classes/ServerBan.ts @@ -1,6 +1,6 @@ import { MemberCompositeKey } from "revolt-api"; -import { API, Client } from ".."; +import { API, Client } from "../index.js"; /** * Server Ban diff --git a/src/classes/ServerMember.ts b/src/classes/ServerMember.ts index 9f0d13d4..002fa7f5 100644 --- a/src/classes/ServerMember.ts +++ b/src/classes/ServerMember.ts @@ -4,12 +4,15 @@ import type { MemberCompositeKey, } from "revolt-api"; -import { ServerMemberCollection } from "../collections"; -import { bitwiseAndEq, calculatePermission } from "../permissions/calculator"; -import { Permission } from "../permissions/definitions"; - -import { Channel } from "./Channel"; -import { Server } from "./Server"; +import { ServerMemberCollection } from "../collections/index.js"; +import { + bitwiseAndEq, + calculatePermission, +} from "../permissions/calculator.js"; +import { Permission } from "../permissions/definitions.js"; + +import { Channel } from "./Channel.js"; +import { Server } from "./Server.js"; /** * Deterministic conversion of member composite key to string ID diff --git a/src/classes/Session.ts b/src/classes/Session.ts index c9e00b72..d0952ba1 100644 --- a/src/classes/Session.ts +++ b/src/classes/Session.ts @@ -1,6 +1,6 @@ import { decodeTime } from "ulid"; -import { SessionCollection } from "../collections"; +import { SessionCollection } from "../collections/index.js"; /** * Session Class diff --git a/src/classes/SystemMessage.ts b/src/classes/SystemMessage.ts index 00cce6fa..7e8b04e0 100644 --- a/src/classes/SystemMessage.ts +++ b/src/classes/SystemMessage.ts @@ -1,4 +1,4 @@ -import { API, Client } from ".."; +import { API, Client } from "../index.js"; /** * System Message diff --git a/src/classes/User.ts b/src/classes/User.ts index 7a71e72f..c066c599 100644 --- a/src/classes/User.ts +++ b/src/classes/User.ts @@ -1,8 +1,8 @@ import { DataEditUser, Presence } from "revolt-api"; import { decodeTime } from "ulid"; -import { UserCollection } from "../collections"; -import { U32_MAX, UserPermission } from "../permissions/definitions"; +import { UserCollection } from "../collections/index.js"; +import { U32_MAX, UserPermission } from "../permissions/definitions.js"; /** * User Class diff --git a/src/classes/index.ts b/src/classes/index.ts index 75ea597e..ed8ac5fe 100644 --- a/src/classes/index.ts +++ b/src/classes/index.ts @@ -1,17 +1,18 @@ -export * from "./Bot"; -export * from "./Channel"; -export * from "./ChannelUnread"; -export * from "./ChannelWebhook"; -export * from "./Emoji"; -export * from "./File"; -export * from "./Invite"; -export * from "./Message"; -export * from "./MessageEmbed"; -export * from "./PublicBot"; -export * from "./PublicInvite"; -export * from "./Server"; -export * from "./ServerBan"; -export * from "./ServerMember"; -export * from "./SystemMessage"; -export * from "./Session"; -export * from "./User"; +export * from "./Bot.js"; +export * from "./Channel.js"; +export * from "./ChannelUnread.js"; +export * from "./ChannelWebhook.js"; +export * from "./Emoji.js"; +export * from "./File.js"; +export * from "./Invite.js"; +export * from "./Message.js"; +export * from "./MessageEmbed.js"; +export * from "./PublicBot.js"; +export * from "./PublicInvite.js"; +export * from "./Server.js"; +export * from "./ServerBan.js"; +export * from "./ServerMember.js"; +export * from "./Session.js"; +export * from "./SystemMessage.js"; +export * from "./User.js"; + diff --git a/src/collections/AccountCollection.ts b/src/collections/AccountCollection.ts index a869a2d2..bcdcd8f2 100644 --- a/src/collections/AccountCollection.ts +++ b/src/collections/AccountCollection.ts @@ -1,7 +1,7 @@ import { DataCreateAccount, WebPushSubscription } from "revolt-api"; -import { Client } from ".."; -import { MFA } from "../classes/MFA"; +import { MFA } from "../classes/MFA.js"; +import { Client } from "../index.js"; /** * Utility functions for working with accounts diff --git a/src/collections/BotCollection.ts b/src/collections/BotCollection.ts index e9087bf5..03296b18 100644 --- a/src/collections/BotCollection.ts +++ b/src/collections/BotCollection.ts @@ -2,10 +2,10 @@ import { batch } from "solid-js"; import { OwnedBotsResponse } from "revolt-api"; -import { API, Bot, PublicBot } from ".."; -import { HydratedBot } from "../hydration/bot"; +import { HydratedBot } from "../hydration/bot.js"; +import { API, Bot, PublicBot } from "../index.js"; -import { ClassCollection } from "."; +import { ClassCollection } from "./index.js"; /** * Collection of Bots diff --git a/src/collections/ChannelCollection.ts b/src/collections/ChannelCollection.ts index 753ac087..117d1544 100644 --- a/src/collections/ChannelCollection.ts +++ b/src/collections/ChannelCollection.ts @@ -1,7 +1,7 @@ -import { API, Channel, User } from ".."; -import { HydratedChannel } from "../hydration"; +import { HydratedChannel } from "../hydration/index.js"; +import { API, Channel, User } from "../index.js"; -import { ClassCollection } from "."; +import { ClassCollection } from "./index.js"; /** * Collection of Channels diff --git a/src/collections/ChannelUnreadCollection.ts b/src/collections/ChannelUnreadCollection.ts index d36e629b..a930d7d8 100644 --- a/src/collections/ChannelUnreadCollection.ts +++ b/src/collections/ChannelUnreadCollection.ts @@ -1,8 +1,8 @@ -import { API } from ".."; -import { ChannelUnread } from "../classes/ChannelUnread"; -import { HydratedChannelUnread } from "../hydration"; +import { ChannelUnread } from "../classes/ChannelUnread.js"; +import { HydratedChannelUnread } from "../hydration/index.js"; +import { API } from "../index.js"; -import { ClassCollection } from "."; +import { ClassCollection } from "./index.js"; /** * Collection of Channel Unreads diff --git a/src/collections/ChannelWebhookCollection.ts b/src/collections/ChannelWebhookCollection.ts index c2b72be5..466af1cf 100644 --- a/src/collections/ChannelWebhookCollection.ts +++ b/src/collections/ChannelWebhookCollection.ts @@ -1,8 +1,8 @@ -import { API } from ".."; -import { ChannelWebhook } from "../classes/ChannelWebhook"; -import { HydratedChannelWebhook } from "../hydration/channelWebhook"; +import { ChannelWebhook } from "../classes/ChannelWebhook.js"; +import { HydratedChannelWebhook } from "../hydration/channelWebhook.js"; +import { API } from "../index.js"; -import { ClassCollection } from "."; +import { ClassCollection } from "./index.js"; /** * Collection of Channel Webhooks diff --git a/src/collections/Collection.ts b/src/collections/Collection.ts index 21d5c9ed..83808f4e 100644 --- a/src/collections/Collection.ts +++ b/src/collections/Collection.ts @@ -2,9 +2,9 @@ import { SetStoreFunction } from "solid-js/store"; import { ReactiveMap } from "@solid-primitives/map"; -import { Client } from ".."; -import { Hydrators } from "../hydration"; -import { ObjectStorage } from "../storage/ObjectStorage"; +import { Hydrators } from "../hydration/index.js"; +import { Client } from "../index.js"; +import { ObjectStorage } from "../storage/ObjectStorage.js"; /** * Abstract Collection type diff --git a/src/collections/EmojiCollection.ts b/src/collections/EmojiCollection.ts index f9ca975a..4c41a9a8 100644 --- a/src/collections/EmojiCollection.ts +++ b/src/collections/EmojiCollection.ts @@ -1,7 +1,7 @@ -import { API, Emoji } from ".."; -import { HydratedEmoji } from "../hydration"; +import { HydratedEmoji } from "../hydration/index.js"; +import { API, Emoji } from "../index.js"; -import { ClassCollection } from "."; +import { ClassCollection } from "./index.js"; /** * Collection of Emoji diff --git a/src/collections/MessageCollection.ts b/src/collections/MessageCollection.ts index b46d8c0b..726860de 100644 --- a/src/collections/MessageCollection.ts +++ b/src/collections/MessageCollection.ts @@ -1,7 +1,7 @@ -import { API, Message } from ".."; import { HydratedMessage } from "../hydration"; +import { API, Message } from "../index.js"; -import { ClassCollection } from "."; +import { ClassCollection } from "./index.js"; /** * Collection of Messages diff --git a/src/collections/ServerCollection.ts b/src/collections/ServerCollection.ts index 701c5292..5044daa7 100644 --- a/src/collections/ServerCollection.ts +++ b/src/collections/ServerCollection.ts @@ -2,10 +2,10 @@ import { batch } from "solid-js"; import { DataCreateServer } from "revolt-api"; -import { API, Server } from ".."; -import { HydratedServer } from "../hydration"; +import { HydratedServer } from "../hydration/index.js"; +import { API, Server } from "../index.js"; -import { ClassCollection } from "."; +import { ClassCollection } from "./index.js"; /** * Collection of Servers diff --git a/src/collections/ServerMemberCollection.ts b/src/collections/ServerMemberCollection.ts index 958e45e8..e6b73746 100644 --- a/src/collections/ServerMemberCollection.ts +++ b/src/collections/ServerMemberCollection.ts @@ -1,7 +1,7 @@ -import { API, ServerMember } from ".."; -import { HydratedServerMember } from "../hydration"; +import { HydratedServerMember } from "../hydration/index.js"; +import { API, ServerMember } from "../index.js"; -import { ClassCollection } from "."; +import { ClassCollection } from "./index.js"; /** * Collection of Server Members diff --git a/src/collections/SessionCollection.ts b/src/collections/SessionCollection.ts index 27090a27..60e04b91 100644 --- a/src/collections/SessionCollection.ts +++ b/src/collections/SessionCollection.ts @@ -1,10 +1,10 @@ import { batch } from "solid-js"; -import { API } from ".."; -import { Session } from "../classes"; -import { HydratedSession } from "../hydration/session"; +import { Session } from "../classes/index.js"; +import { HydratedSession } from "../hydration/session.js"; +import { API } from "../index.js"; -import { ClassCollection } from "."; +import { ClassCollection } from "./index.js"; /** * Collection of Sessions diff --git a/src/collections/UserCollection.ts b/src/collections/UserCollection.ts index 879e89e7..59022a62 100644 --- a/src/collections/UserCollection.ts +++ b/src/collections/UserCollection.ts @@ -1,7 +1,7 @@ -import { API, Client, User } from ".."; -import { HydratedUser } from "../hydration"; +import { HydratedUser } from "../hydration/index.js"; +import { API, Client, User } from "../index.js"; -import { ClassCollection } from "."; +import { ClassCollection } from "./index.js"; /** * Collection of Users diff --git a/src/collections/index.ts b/src/collections/index.ts index fca9681c..d192286a 100644 --- a/src/collections/index.ts +++ b/src/collections/index.ts @@ -1,12 +1,12 @@ -export * from "./Collection"; +export * from "./Collection.js"; -export { BotCollection } from "./BotCollection"; -export { ChannelCollection } from "./ChannelCollection"; -export { ChannelUnreadCollection } from "./ChannelUnreadCollection"; -export { ChannelWebhookCollection } from "./ChannelWebhookCollection"; -export { EmojiCollection } from "./EmojiCollection"; -export { MessageCollection } from "./MessageCollection"; -export { ServerCollection } from "./ServerCollection"; -export { ServerMemberCollection } from "./ServerMemberCollection"; -export { SessionCollection } from "./SessionCollection"; -export { UserCollection } from "./UserCollection"; +export { BotCollection } from "./BotCollection.js"; +export { ChannelCollection } from "./ChannelCollection.js"; +export { ChannelUnreadCollection } from "./ChannelUnreadCollection.js"; +export { ChannelWebhookCollection } from "./ChannelWebhookCollection.js"; +export { EmojiCollection } from "./EmojiCollection.js"; +export { MessageCollection } from "./MessageCollection.js"; +export { ServerCollection } from "./ServerCollection.js"; +export { ServerMemberCollection } from "./ServerMemberCollection.js"; +export { SessionCollection } from "./SessionCollection.js"; +export { UserCollection } from "./UserCollection.js"; diff --git a/src/events/EventClient.ts b/src/events/EventClient.ts index e025d4c3..440d6375 100644 --- a/src/events/EventClient.ts +++ b/src/events/EventClient.ts @@ -3,7 +3,7 @@ import { Accessor, Setter, createSignal } from "solid-js"; import EventEmitter from "eventemitter3"; import WebSocket from "isomorphic-ws"; -import type { AvailableProtocols, EventProtocol } from "."; +import type { AvailableProtocols, EventProtocol } from "./index.js"; /** * All possible event client states. diff --git a/src/events/index.ts b/src/events/index.ts index 69b111d6..33a26217 100644 --- a/src/events/index.ts +++ b/src/events/index.ts @@ -1,8 +1,8 @@ -import type { ProtocolV1 } from "./v1"; +import type { ProtocolV1 } from "./v1.js"; -export { handleEvent as handleEventV1 } from "./v1"; +export { handleEvent as handleEventV1 } from "./v1.js"; -export * from "./EventClient"; +export * from "./EventClient.js"; /** * Available protocols to connect with diff --git a/src/events/v1.ts b/src/events/v1.ts index c9226482..6c92a358 100644 --- a/src/events/v1.ts +++ b/src/events/v1.ts @@ -18,8 +18,8 @@ import type { User, } from "revolt-api"; -import { Client } from ".."; -import { hydrate } from "../hydration"; +import { Client } from "../index.js"; +import { hydrate } from "../hydration/index.js"; /** * Version 1 of the events protocol diff --git a/src/hydration/bot.ts b/src/hydration/bot.ts index 12809253..666b6af3 100644 --- a/src/hydration/bot.ts +++ b/src/hydration/bot.ts @@ -1,6 +1,6 @@ import { Bot as ApiBot } from "revolt-api"; -import { Hydrate } from "."; +import { Hydrate } from "./index.js"; export type HydratedBot = { id: string; diff --git a/src/hydration/channel.ts b/src/hydration/channel.ts index 64578bc9..aef59c30 100644 --- a/src/hydration/channel.ts +++ b/src/hydration/channel.ts @@ -1,10 +1,10 @@ import { ReactiveSet } from "@solid-primitives/set"; import { Channel as ApiChannel, OverrideField } from "revolt-api"; -import { Client, File } from ".."; -import type { Merge } from "../lib/merge"; +import { Client, File } from "../index.js"; +import type { Merge } from "../lib/merge.js"; -import { Hydrate } from "."; +import { Hydrate } from "./index.js"; export type HydratedChannel = { id: string; diff --git a/src/hydration/channelUnread.ts b/src/hydration/channelUnread.ts index a8de27bb..f293327e 100644 --- a/src/hydration/channelUnread.ts +++ b/src/hydration/channelUnread.ts @@ -1,9 +1,9 @@ import { ReactiveSet } from "@solid-primitives/set"; -import { API } from ".."; -import type { Merge } from "../lib/merge"; +import { API } from "../index.js"; +import type { Merge } from "../lib/merge.js"; -import { Hydrate } from "."; +import { Hydrate } from "./index.js"; export type HydratedChannelUnread = { id: string; diff --git a/src/hydration/channelWebhook.ts b/src/hydration/channelWebhook.ts index 3d2b5726..3a2dd564 100644 --- a/src/hydration/channelWebhook.ts +++ b/src/hydration/channelWebhook.ts @@ -1,7 +1,7 @@ -import { API, Client, File } from ".."; -import type { Merge } from "../lib/merge"; +import { API, Client, File } from "../index.js"; +import type { Merge } from "../lib/merge.js"; -import { Hydrate } from "."; +import { Hydrate } from "./index.js"; export type HydratedChannelWebhook = { id: string; diff --git a/src/hydration/emoji.ts b/src/hydration/emoji.ts index 115473ec..c86aa70f 100644 --- a/src/hydration/emoji.ts +++ b/src/hydration/emoji.ts @@ -1,8 +1,8 @@ import { Emoji as ApiEmoji, EmojiParent } from "revolt-api"; -import type { Merge } from "../lib/merge"; +import type { Merge } from "../lib/merge.js"; -import { Hydrate } from "."; +import { Hydrate } from "./index.js"; export type HydratedEmoji = { id: string; diff --git a/src/hydration/index.ts b/src/hydration/index.ts index a2003594..6bda0a3f 100644 --- a/src/hydration/index.ts +++ b/src/hydration/index.ts @@ -1,28 +1,28 @@ -import { botHydration } from "./bot"; -import { channelHydration } from "./channel"; -import { channelUnreadHydration } from "./channelUnread"; -import { channelWebhookHydration } from "./channelWebhook"; -import { emojiHydration } from "./emoji"; -import { messageHydration } from "./message"; -import { serverHydration } from "./server"; -import { serverMemberHydration } from "./serverMember"; -import { sessionHydration } from "./session"; -import { userHydration } from "./user"; +import { botHydration } from "./bot.js"; +import { channelHydration } from "./channel.js"; +import { channelUnreadHydration } from "./channelUnread.js"; +import { channelWebhookHydration } from "./channelWebhook.js"; +import { emojiHydration } from "./emoji.js"; +import { messageHydration } from "./message.js"; +import { serverHydration } from "./server.js"; +import { serverMemberHydration } from "./serverMember.js"; +import { sessionHydration } from "./session.js"; +import { userHydration } from "./user.js"; -export { BotFlags } from "./bot"; -export { ServerFlags } from "./server"; -export { UserBadges, UserFlags } from "./user"; +export { BotFlags } from "./bot.js"; +export { ServerFlags } from "./server.js"; +export { UserBadges, UserFlags } from "./user.js"; -export type { HydratedBot } from "./bot"; -export type { HydratedChannel } from "./channel"; -export type { HydratedChannelUnread } from "./channelUnread"; -export type { HydratedChannelWebhook } from "./channelWebhook"; -export type { HydratedEmoji } from "./emoji"; -export type { HydratedMessage } from "./message"; -export type { HydratedServer } from "./server"; -export type { HydratedServerMember } from "./serverMember"; -export type { HydratedUser } from "./user"; -export type { HydratedSession } from "./session"; +export type { HydratedBot } from "./bot.js"; +export type { HydratedChannel } from "./channel.js"; +export type { HydratedChannelUnread } from "./channelUnread.js"; +export type { HydratedChannelWebhook } from "./channelWebhook.js"; +export type { HydratedEmoji } from "./emoji.js"; +export type { HydratedMessage } from "./message.js"; +export type { HydratedServer } from "./server.js"; +export type { HydratedServerMember } from "./serverMember.js"; +export type { HydratedSession } from "./session.js"; +export type { HydratedUser } from "./user.js"; /** * Functions to map from one object to another diff --git a/src/hydration/message.ts b/src/hydration/message.ts index 4a3a41f7..ea2ac380 100644 --- a/src/hydration/message.ts +++ b/src/hydration/message.ts @@ -8,10 +8,10 @@ import { MessageEmbed, MessageWebhook, SystemMessage, -} from ".."; -import type { Merge } from "../lib/merge"; +} from "../index.js"; +import type { Merge } from "../lib/merge.js"; -import { Hydrate } from "."; +import { Hydrate } from "./index.js"; export type HydratedMessage = { id: string; diff --git a/src/hydration/server.ts b/src/hydration/server.ts index 420076c0..f47e0be9 100644 --- a/src/hydration/server.ts +++ b/src/hydration/server.ts @@ -7,9 +7,9 @@ import { SystemMessageChannels, } from "revolt-api"; -import { Client, File } from ".."; +import { Client, File } from "../index.js"; -import { Hydrate } from "."; +import { Hydrate } from "./index.js"; export type HydratedServer = { id: string; diff --git a/src/hydration/serverMember.ts b/src/hydration/serverMember.ts index b80febb1..1d2c6ce2 100644 --- a/src/hydration/serverMember.ts +++ b/src/hydration/serverMember.ts @@ -1,9 +1,9 @@ import { Member as ApiMember, MemberCompositeKey } from "revolt-api"; -import { Client, File } from ".."; -import type { Merge } from "../lib/merge"; +import { Client, File } from "../index.js"; +import type { Merge } from "../lib/merge.js"; -import { Hydrate } from "."; +import { Hydrate } from "./index.js"; export type HydratedServerMember = { id: MemberCompositeKey; diff --git a/src/hydration/session.ts b/src/hydration/session.ts index 15938ea0..11b0c31b 100644 --- a/src/hydration/session.ts +++ b/src/hydration/session.ts @@ -1,6 +1,6 @@ import { SessionInfo as ApiSession } from "revolt-api"; -import { Hydrate } from "."; +import { Hydrate } from "./index.js"; export type HydratedSession = { id: string; diff --git a/src/hydration/user.ts b/src/hydration/user.ts index 38f1d06c..7b83868c 100644 --- a/src/hydration/user.ts +++ b/src/hydration/user.ts @@ -5,9 +5,9 @@ import { UserStatus, } from "revolt-api"; -import { Client, File } from ".."; +import { Client, File } from "../index.js"; -import { Hydrate } from "."; +import { Hydrate } from "./index.js"; export type HydratedUser = { id: string; diff --git a/src/index.ts b/src/index.ts index 89dd790e..f32105c5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,13 @@ -export * from "./classes"; -export * from "./lib/regex"; -export * from "./collections"; export * as API from "revolt-api"; -export { Client } from "./Client"; -export type { Session as PrivateSession, ClientOptions } from "./Client"; -export { EventClient, ConnectionState } from "./events"; -export { ServerFlags, UserBadges, UserFlags, BotFlags } from "./hydration"; +export { Client } from "./Client.js"; +export type { ClientOptions, Session as PrivateSession } from "./Client.js"; +export * from "./classes/index.js"; +export * from "./collections/index.js"; +export { ConnectionState, EventClient } from "./events/index.js"; +export { + BotFlags, + ServerFlags, + UserBadges, + UserFlags, +} from "./hydration/index.js"; +export * from "./lib/regex.js"; diff --git a/src/permissions/calculator.ts b/src/permissions/calculator.ts index 1973ed9e..816fa249 100644 --- a/src/permissions/calculator.ts +++ b/src/permissions/calculator.ts @@ -1,6 +1,6 @@ import Long from "long"; -import { Channel, Client, Server, ServerMember } from ".."; +import { Channel, Client, Server, ServerMember } from "../index.js"; import { ALLOW_IN_TIMEOUT, @@ -8,7 +8,7 @@ import { DEFAULT_PERMISSION_VIEW_ONLY, Permission, UserPermission, -} from "./definitions"; +} from "./definitions.js"; /** * Check whether `b` is present in `a` diff --git a/src/storage/ObjectStorage.ts b/src/storage/ObjectStorage.ts index c0fd8977..d2f6104b 100644 --- a/src/storage/ObjectStorage.ts +++ b/src/storage/ObjectStorage.ts @@ -1,6 +1,6 @@ import { SetStoreFunction, createStore } from "solid-js/store"; -import { Hydrators, hydrate } from "../hydration"; +import { Hydrators, hydrate } from "../hydration/index.js"; /** * Wrapper around Solid.js store diff --git a/test.mjs b/test.mjs new file mode 100644 index 00000000..c514b316 --- /dev/null +++ b/test.mjs @@ -0,0 +1,12 @@ +import "dotenv/config"; + +import { Client } from "./lib/esm/index.js"; + +const client = new Client({ debug: true }); + +client.on("ready", () => console.info(`Logged in as ${client.user.username}!`)); +client.on("disconnected", () => console.info("Disconnected.")); + +client.on("messageCreate", (message) => console.info(message.content)); + +client.loginBot(process.env.TOKEN);