Skip to content

Commit

Permalink
fix: allow explicit ESM import (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
williamhorning authored Jun 8, 2024
1 parent 929d1bc commit ced14f1
Show file tree
Hide file tree
Showing 53 changed files with 211 additions and 174 deletions.
3 changes: 3 additions & 0 deletions package-esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"author": "Paul Makles <insrt.uk>",
"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/",
Expand Down
21 changes: 14 additions & 7 deletions src/Client.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -16,23 +24,22 @@ 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,
HydratedMessage,
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;

Expand Down
2 changes: 1 addition & 1 deletion src/classes/Bot.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 7 additions & 4 deletions src/classes/Channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/classes/ChannelUnread.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChannelUnreadCollection } from "../collections";
import { ChannelUnreadCollection } from "../collections/index.js";

/**
* Channel Unread Class
Expand Down
4 changes: 2 additions & 2 deletions src/classes/ChannelWebhook.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/classes/Emoji.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { decodeTime } from "ulid";

import { EmojiCollection } from "../collections";
import { EmojiCollection } from "../collections/index.js";

/**
* Emoji Class
Expand Down
2 changes: 1 addition & 1 deletion src/classes/File.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Metadata } from "revolt-api";

import { API, Client } from "..";
import { API, Client } from "../index.js";

/**
* Uploaded File
Expand Down
2 changes: 1 addition & 1 deletion src/classes/Invite.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { API, Client } from "..";
import { API, Client } from "../index.js";

/**
* Channel Invite
Expand Down
2 changes: 1 addition & 1 deletion src/classes/MFA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
MFATicket as TicketType,
} from "revolt-api";

import { Client } from "..";
import { Client } from "../index.js";

/**
* Multi-Factor Authentication
Expand Down
4 changes: 2 additions & 2 deletions src/classes/Message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/classes/MessageEmbed.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { API, Client, File } from "..";
import { API, Client, File } from "../index.js";

/**
* Message Embed
Expand Down
2 changes: 1 addition & 1 deletion src/classes/PublicBot.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { API, Channel, Client, File, Server } from "..";
import { API, Channel, Client, File, Server } from "../index.js";

/**
* Public Bot Class
Expand Down
4 changes: 2 additions & 2 deletions src/classes/PublicInvite.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
21 changes: 12 additions & 9 deletions src/classes/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/classes/ServerBan.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MemberCompositeKey } from "revolt-api";

import { API, Client } from "..";
import { API, Client } from "../index.js";

/**
* Server Ban
Expand Down
15 changes: 9 additions & 6 deletions src/classes/ServerMember.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/classes/Session.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { decodeTime } from "ulid";

import { SessionCollection } from "../collections";
import { SessionCollection } from "../collections/index.js";

/**
* Session Class
Expand Down
2 changes: 1 addition & 1 deletion src/classes/SystemMessage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { API, Client } from "..";
import { API, Client } from "../index.js";

/**
* System Message
Expand Down
4 changes: 2 additions & 2 deletions src/classes/User.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
35 changes: 18 additions & 17 deletions src/classes/index.ts
Original file line number Diff line number Diff line change
@@ -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";

4 changes: 2 additions & 2 deletions src/collections/AccountCollection.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/collections/BotCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/collections/ChannelCollection.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/collections/ChannelUnreadCollection.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/collections/ChannelWebhookCollection.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/collections/Collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/collections/EmojiCollection.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/collections/MessageCollection.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/collections/ServerCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit ced14f1

Please sign in to comment.