From 67b1f45a8f4f35cff4b352cb54b25e6f90b96ca8 Mon Sep 17 00:00:00 2001 From: itsMapleLeaf <19603573+itsMapleLeaf@users.noreply.github.com> Date: Mon, 25 Jul 2022 11:03:55 -0500 Subject: [PATCH] move things to folders --- .../{library.new => helpers}/async-queue.ts | 0 .../{library.new => helpers}/container.ts | 0 .../{ => core}/button-shared-props.ts | 0 .../reacord/library.new/{ => core}/button.tsx | 0 .../library.new/{ => core}/component-event.ts | 0 .../{ => core}/make-message-payload.ts | 0 .../reacord/library.new/{ => core}/node.ts | 2 +- .../library.new/{ => core}/reacord-element.ts | 0 .../{ => core}/reacord-instance-pool.ts | 2 +- .../library.new/{ => core}/reconciler.ts | 2 +- .../channel-message-renderer.ts} | 44 +++---------------- .../library.new/djs/reacord-discord-js.ts | 22 ++++++++++ packages/reacord/library.new/main.ts | 8 ++-- 13 files changed, 34 insertions(+), 46 deletions(-) rename packages/reacord/{library.new => helpers}/async-queue.ts (100%) rename packages/reacord/{library.new => helpers}/container.ts (100%) rename packages/reacord/library.new/{ => core}/button-shared-props.ts (100%) rename packages/reacord/library.new/{ => core}/button.tsx (100%) rename packages/reacord/library.new/{ => core}/component-event.ts (100%) rename packages/reacord/library.new/{ => core}/make-message-payload.ts (100%) rename packages/reacord/library.new/{ => core}/node.ts (95%) rename packages/reacord/library.new/{ => core}/reacord-element.ts (100%) rename packages/reacord/library.new/{ => core}/reacord-instance-pool.ts (98%) rename packages/reacord/library.new/{ => core}/reconciler.ts (97%) rename packages/reacord/library.new/{reacord-discord-js.ts => djs/channel-message-renderer.ts} (50%) create mode 100644 packages/reacord/library.new/djs/reacord-discord-js.ts diff --git a/packages/reacord/library.new/async-queue.ts b/packages/reacord/helpers/async-queue.ts similarity index 100% rename from packages/reacord/library.new/async-queue.ts rename to packages/reacord/helpers/async-queue.ts diff --git a/packages/reacord/library.new/container.ts b/packages/reacord/helpers/container.ts similarity index 100% rename from packages/reacord/library.new/container.ts rename to packages/reacord/helpers/container.ts diff --git a/packages/reacord/library.new/button-shared-props.ts b/packages/reacord/library.new/core/button-shared-props.ts similarity index 100% rename from packages/reacord/library.new/button-shared-props.ts rename to packages/reacord/library.new/core/button-shared-props.ts diff --git a/packages/reacord/library.new/button.tsx b/packages/reacord/library.new/core/button.tsx similarity index 100% rename from packages/reacord/library.new/button.tsx rename to packages/reacord/library.new/core/button.tsx diff --git a/packages/reacord/library.new/component-event.ts b/packages/reacord/library.new/core/component-event.ts similarity index 100% rename from packages/reacord/library.new/component-event.ts rename to packages/reacord/library.new/core/component-event.ts diff --git a/packages/reacord/library.new/make-message-payload.ts b/packages/reacord/library.new/core/make-message-payload.ts similarity index 100% rename from packages/reacord/library.new/make-message-payload.ts rename to packages/reacord/library.new/core/make-message-payload.ts diff --git a/packages/reacord/library.new/node.ts b/packages/reacord/library.new/core/node.ts similarity index 95% rename from packages/reacord/library.new/node.ts rename to packages/reacord/library.new/core/node.ts index 47c5b1e..5d73e45 100644 --- a/packages/reacord/library.new/node.ts +++ b/packages/reacord/library.new/core/node.ts @@ -1,5 +1,5 @@ import type { ButtonNode } from "./button" -import { Container } from "./container" +import { Container } from "../../helpers/container" export type NodeBase = { type: Type diff --git a/packages/reacord/library.new/reacord-element.ts b/packages/reacord/library.new/core/reacord-element.ts similarity index 100% rename from packages/reacord/library.new/reacord-element.ts rename to packages/reacord/library.new/core/reacord-element.ts diff --git a/packages/reacord/library.new/reacord-instance-pool.ts b/packages/reacord/library.new/core/reacord-instance-pool.ts similarity index 98% rename from packages/reacord/library.new/reacord-instance-pool.ts rename to packages/reacord/library.new/core/reacord-instance-pool.ts index 4cffe77..ca2009b 100644 --- a/packages/reacord/library.new/reacord-instance-pool.ts +++ b/packages/reacord/library.new/core/reacord-instance-pool.ts @@ -1,5 +1,5 @@ import type { ReactNode } from "react" -import { Container } from "./container" +import { Container } from "../../helpers/container" import type { MessagePayload } from "./make-message-payload" import { makeMessagePayload } from "./make-message-payload" import type { Node } from "./node" diff --git a/packages/reacord/library.new/reconciler.ts b/packages/reacord/library.new/core/reconciler.ts similarity index 97% rename from packages/reacord/library.new/reconciler.ts rename to packages/reacord/library.new/core/reconciler.ts index 597fa81..7bb8bd9 100644 --- a/packages/reacord/library.new/reconciler.ts +++ b/packages/reacord/library.new/core/reconciler.ts @@ -1,6 +1,6 @@ import ReactReconciler from "react-reconciler" import { DefaultEventPriority } from "react-reconciler/constants" -import type { Container } from "./container" +import type { Container } from "../../helpers/container" import type { Node, TextNode } from "./node" import { makeNode, NodeRef } from "./node" diff --git a/packages/reacord/library.new/reacord-discord-js.ts b/packages/reacord/library.new/djs/channel-message-renderer.ts similarity index 50% rename from packages/reacord/library.new/reacord-discord-js.ts rename to packages/reacord/library.new/djs/channel-message-renderer.ts index ea62364..73fc20f 100644 --- a/packages/reacord/library.new/reacord-discord-js.ts +++ b/packages/reacord/library.new/djs/channel-message-renderer.ts @@ -1,33 +1,9 @@ -import type { Client, Interaction, Message, TextBasedChannel } from "discord.js" -import { ButtonStyle } from "discord.js" -import type { ReactNode } from "react" -import { AsyncQueue } from "./async-queue" -import type { ButtonProps } from "./button" -import type { MessagePayload as MessagePayloadType } from "./make-message-payload" -import type { - ReacordMessageRenderer, - ReacordOptions, -} from "./reacord-instance-pool" -import { ReacordInstancePool } from "./reacord-instance-pool" +import type { Client, Message, TextBasedChannel } from "discord.js" +import { AsyncQueue } from "../../helpers/async-queue" +import type { MessagePayload as MessagePayloadType } from "../core/make-message-payload" +import type { ReacordMessageRenderer } from "../core/reacord-instance-pool" -export class ReacordDiscordJs { - private instances - - constructor(private readonly client: Client, options: ReacordOptions = {}) { - this.instances = new ReacordInstancePool(options) - } - - send(channelId: string, initialContent?: ReactNode) { - const renderer = new ChannelMessageRenderer(this.client, channelId) - return this.instances.create({ initialContent, renderer }) - } - - reply(interaction: Interaction, initialContent?: ReactNode) {} - - ephemeralReply(interaction: Interaction, initialContent?: ReactNode) {} -} - -class ChannelMessageRenderer implements ReacordMessageRenderer { +export class ChannelMessageRenderer implements ReacordMessageRenderer { private message: Message | undefined private channel: TextBasedChannel | undefined private active = true @@ -86,13 +62,3 @@ class ChannelMessageRenderer implements ReacordMessageRenderer { return (this.channel = channel) } } - -function getButtonStyle(style: NonNullable) { - const styleMap = { - primary: ButtonStyle.Primary, - secondary: ButtonStyle.Secondary, - danger: ButtonStyle.Danger, - success: ButtonStyle.Success, - } as const - return styleMap[style] -} diff --git a/packages/reacord/library.new/djs/reacord-discord-js.ts b/packages/reacord/library.new/djs/reacord-discord-js.ts new file mode 100644 index 0000000..f6be369 --- /dev/null +++ b/packages/reacord/library.new/djs/reacord-discord-js.ts @@ -0,0 +1,22 @@ +import type { Client, Interaction } from "discord.js" +import type { ReactNode } from "react" +import type { ReacordOptions } from "../core/reacord-instance-pool" +import { ReacordInstancePool } from "../core/reacord-instance-pool" +import { ChannelMessageRenderer } from "./channel-message-renderer" + +export class ReacordDiscordJs { + private instances + + constructor(private readonly client: Client, options: ReacordOptions = {}) { + this.instances = new ReacordInstancePool(options) + } + + send(channelId: string, initialContent?: ReactNode) { + const renderer = new ChannelMessageRenderer(this.client, channelId) + return this.instances.create({ initialContent, renderer }) + } + + reply(interaction: Interaction, initialContent?: ReactNode) {} + + ephemeralReply(interaction: Interaction, initialContent?: ReactNode) {} +} diff --git a/packages/reacord/library.new/main.ts b/packages/reacord/library.new/main.ts index c9f7da3..1cc401f 100644 --- a/packages/reacord/library.new/main.ts +++ b/packages/reacord/library.new/main.ts @@ -1,7 +1,7 @@ -export { Button, type ButtonProps } from "./button" -export { type ButtonSharedProps } from "./button-shared-props" -export { ReacordDiscordJs } from "./reacord-discord-js" +export { Button, type ButtonProps } from "./core/button" +export { type ButtonSharedProps } from "./core/button-shared-props" export { type ReacordInstance, type ReacordOptions, -} from "./reacord-instance-pool" +} from "./core/reacord-instance-pool" +export { ReacordDiscordJs } from "./djs/reacord-discord-js"