@dressed/react 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/action-row.js +2 -2
- package/dist/components/action-row.js.map +1 -1
- package/dist/components/container.d.ts +2 -2
- package/dist/components/container.js +2 -2
- package/dist/components/container.js.map +1 -1
- package/dist/components/file.d.ts +2 -2
- package/dist/components/label.d.ts +2 -2
- package/dist/components/label.js +2 -2
- package/dist/components/label.js.map +1 -1
- package/dist/components/media-gallery.d.ts +5 -5
- package/dist/components/media-gallery.js.map +1 -1
- package/dist/components/section.d.ts +2 -2
- package/dist/components/section.js +2 -2
- package/dist/components/section.js.map +1 -1
- package/dist/components/select-menu.d.ts +3 -9
- package/dist/components/select-menu.js.map +1 -1
- package/dist/components/separator.d.ts +3 -3
- package/dist/components/separator.js +2 -2
- package/dist/components/separator.js.map +1 -1
- package/dist/components/text-display.d.ts +2 -2
- package/dist/components/text-input.d.ts +3 -3
- package/dist/components/text-input.js +2 -2
- package/dist/components/text-input.js.map +1 -1
- package/dist/components/thumbnail.d.ts +2 -2
- package/dist/react/node.d.ts +3 -1
- package/dist/react/node.js +15 -7
- package/dist/react/node.js.map +1 -1
- package/dist/react/reconciler.d.ts +1 -1
- package/dist/react/reconciler.js +23 -11
- package/dist/react/reconciler.js.map +1 -1
- package/dist/react/renderer.d.ts +3 -2
- package/dist/react/renderer.js +18 -11
- package/dist/react/renderer.js.map +1 -1
- package/dist/react/text-node.d.ts +1 -1
- package/dist/react/text-node.js +4 -5
- package/dist/react/text-node.js.map +1 -1
- package/dist/rendering/index.d.ts +2 -1
- package/dist/rendering/index.js +5 -5
- package/dist/rendering/index.js.map +1 -1
- package/dist/rendering/interaction.js +13 -5
- package/dist/rendering/interaction.js.map +1 -1
- package/dist/rendering/message.d.ts +4 -14
- package/dist/rendering/message.js +21 -13
- package/dist/rendering/message.js.map +1 -1
- package/package.json +6 -6
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ActionRow as DressedComponent } from "dressed";
|
|
2
2
|
import { createElement } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { parseNode } from "../react/renderer.js";
|
|
4
4
|
export function ActionRow({ children, }) {
|
|
5
5
|
const props = DressedComponent();
|
|
6
6
|
return createElement("dressed-node", props, children);
|
|
7
7
|
}
|
|
8
8
|
export async function parseActionRow(props, children) {
|
|
9
|
-
return { ...props, components: await Promise.all(children.map(
|
|
9
|
+
return { ...props, components: await Promise.all(children.map(parseNode)) };
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=action-row.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-row.js","sourceRoot":"","sources":["../../src/components/action-row.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,aAAa,EAAqC,MAAM,OAAO,CAAC;AACzE,OAAO,EAAsB,
|
|
1
|
+
{"version":3,"file":"action-row.js","sourceRoot":"","sources":["../../src/components/action-row.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,aAAa,EAAqC,MAAM,OAAO,CAAC;AACzE,OAAO,EAAsB,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAErE,MAAM,UAAU,SAAS,CAAC,EACxB,QAAQ,GAGT;IACC,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC;IACjC,OAAO,aAAa,CAAC,cAAc,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,KAAQ,EACR,QAAyB;IAEzB,OAAO,EAAE,GAAG,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC;AAC9E,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { APIContainerComponent } from "discord-api-types/v10";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
3
|
import { type ComponentNode } from "../react/renderer.ts";
|
|
4
|
-
|
|
4
|
+
interface ContainerProps extends Omit<APIContainerComponent, "components" | "type"> {
|
|
5
5
|
children: ReactNode;
|
|
6
|
-
}
|
|
6
|
+
}
|
|
7
7
|
export declare function Container({ children, ...rest }: ContainerProps): import("react").ReactElement<APIContainerComponent, string | import("react").JSXElementConstructor<any>>;
|
|
8
8
|
export declare function parseContainer<T extends APIContainerComponent>(props: T, children: ComponentNode[]): Promise<T>;
|
|
9
9
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Container as DressedComponent } from "dressed";
|
|
2
2
|
import { createElement } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { parseNode } from "../react/renderer.js";
|
|
4
4
|
export function Container({ children, ...rest }) {
|
|
5
5
|
const props = DressedComponent([], rest);
|
|
6
6
|
return createElement("dressed-node", props, children);
|
|
7
7
|
}
|
|
8
8
|
export async function parseContainer(props, children) {
|
|
9
|
-
return { ...props, components: await Promise.all(children.map(
|
|
9
|
+
return { ...props, components: await Promise.all(children.map(parseNode)) };
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=container.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../src/components/container.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,aAAa,EAAkB,MAAM,OAAO,CAAC;AACtD,OAAO,EAAsB,
|
|
1
|
+
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../src/components/container.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,aAAa,EAAkB,MAAM,OAAO,CAAC;AACtD,OAAO,EAAsB,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAMrE,MAAM,UAAU,SAAS,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAkB;IAC7D,MAAM,KAAK,GAAG,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IACzC,OAAO,aAAa,CAAC,cAAc,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAAkC,KAAQ,EAAE,QAAyB;IACvG,OAAO,EAAE,GAAG,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC;AAC9E,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { APIFileComponent } from "discord-api-types/v10";
|
|
2
|
-
|
|
2
|
+
interface FileProps extends Omit<APIFileComponent, "file" | "type"> {
|
|
3
3
|
file: APIFileComponent["file"] | string;
|
|
4
|
-
}
|
|
4
|
+
}
|
|
5
5
|
export declare function File({ file, ...rest }: FileProps): import("react").ReactElement<APIFileComponent, string | import("react").JSXElementConstructor<any>>;
|
|
6
6
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { APILabelComponent } from "discord-api-types/v10";
|
|
2
2
|
import { type ReactElement, type ReactNode } from "react";
|
|
3
3
|
import { type ComponentNode } from "../react/renderer.ts";
|
|
4
|
-
|
|
4
|
+
interface LabelProps extends Omit<APILabelComponent, "component" | "type"> {
|
|
5
5
|
children: ReactNode;
|
|
6
|
-
}
|
|
6
|
+
}
|
|
7
7
|
export declare function Label({ label, description, children, ...rest }: LabelProps): ReactElement<APILabelComponent>;
|
|
8
8
|
export declare function parseLabel<T extends APILabelComponent>(props: T, children: ComponentNode[]): Promise<T>;
|
|
9
9
|
export {};
|
package/dist/components/label.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Label as DressedComponent } from "dressed";
|
|
2
2
|
import { createElement } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { parseNode } from "../react/renderer.js";
|
|
4
4
|
export function Label({ label, description, children, ...rest }) {
|
|
5
5
|
const props = DressedComponent(label, null, description, rest);
|
|
6
6
|
return createElement("dressed-node", props, children);
|
|
@@ -8,7 +8,7 @@ export function Label({ label, description, children, ...rest }) {
|
|
|
8
8
|
export async function parseLabel(props, children) {
|
|
9
9
|
return {
|
|
10
10
|
...props,
|
|
11
|
-
component: (await Promise.all(children.map(
|
|
11
|
+
component: (await Promise.all(children.map(parseNode)))[0],
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=label.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label.js","sourceRoot":"","sources":["../../src/components/label.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,IAAI,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,aAAa,EAAqC,MAAM,OAAO,CAAC;AACzE,OAAO,EAAsB,
|
|
1
|
+
{"version":3,"file":"label.js","sourceRoot":"","sources":["../../src/components/label.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,IAAI,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,aAAa,EAAqC,MAAM,OAAO,CAAC;AACzE,OAAO,EAAsB,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAMrE,MAAM,UAAU,KAAK,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAc;IACzE,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,EAAE,IAAa,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;IACxE,OAAO,aAAa,CAAC,cAAc,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAA8B,KAAQ,EAAE,QAAyB;IAC/F,OAAO;QACL,GAAG,KAAK;QACR,SAAS,EAAE,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAC3D,CAAC;AACJ,CAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { APIMediaGalleryComponent, APIMediaGalleryItem } from "discord-api-types/v10";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
3
|
import type { Node } from "../react/node.ts";
|
|
4
|
-
|
|
4
|
+
interface MediaGalleryProps extends Omit<APIMediaGalleryComponent, "items" | "type"> {
|
|
5
5
|
children: ReactNode;
|
|
6
|
-
}
|
|
7
|
-
type ItemProps = Omit<APIMediaGalleryItem, "media" | "type"> & {
|
|
8
|
-
media: APIMediaGalleryItem["media"] | string;
|
|
9
|
-
};
|
|
6
|
+
}
|
|
10
7
|
export declare function MediaGallery({ children, ...rest }: MediaGalleryProps): import("react").ReactElement<APIMediaGalleryComponent, string | import("react").JSXElementConstructor<any>>;
|
|
8
|
+
interface ItemProps extends Omit<APIMediaGalleryItem, "media" | "type"> {
|
|
9
|
+
media: APIMediaGalleryItem["media"] | string;
|
|
10
|
+
}
|
|
11
11
|
export declare function MediaGalleryItem({ media, ...rest }: ItemProps): import("react").ReactElement<APIMediaGalleryItem, string | import("react").JSXElementConstructor<any>>;
|
|
12
12
|
export declare function parseMediaGallery<T extends APIMediaGalleryComponent>(props: T, children: Node<APIMediaGalleryItem>[]): T;
|
|
13
13
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media-gallery.js","sourceRoot":"","sources":["../../src/components/media-gallery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAE,gBAAgB,IAAI,WAAW,EAAE,MAAM,SAAS,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAkB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"media-gallery.js","sourceRoot":"","sources":["../../src/components/media-gallery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAE,gBAAgB,IAAI,WAAW,EAAE,MAAM,SAAS,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAkB,MAAM,OAAO,CAAC;AAOtD,MAAM,UAAU,YAAY,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAqB;IACnE,MAAM,KAAK,GAAG,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IACzC,OAAO,aAAa,CAAC,cAAc,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;AACxD,CAAC;AAMD,MAAM,UAAU,gBAAgB,CAAC,EAAE,KAAK,EAAE,GAAG,IAAI,EAAa;IAC5D,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACvC,OAAO,aAAa,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,KAAQ,EACR,QAAqC;IAErC,OAAO,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;AAC3D,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { APISectionComponent } from "discord-api-types/v10";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
3
|
import { type ComponentNode } from "../react/renderer.ts";
|
|
4
|
-
|
|
4
|
+
interface SectionProps extends Omit<APISectionComponent, "accessory" | "components" | "type"> {
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
accessory: ReactNode;
|
|
7
|
-
}
|
|
7
|
+
}
|
|
8
8
|
export declare function Section({ children, accessory, ...rest }: SectionProps): import("react").ReactElement<APISectionComponent, string | import("react").JSXElementConstructor<any>>;
|
|
9
9
|
export declare function parseSection<T extends APISectionComponent>(props: T, children: ComponentNode[]): Promise<T>;
|
|
10
10
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Section as DressedComponent } from "dressed";
|
|
2
2
|
import { createElement, isValidElement } from "react";
|
|
3
3
|
import { render } from "../index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { parseNode } from "../react/renderer.js";
|
|
5
5
|
export function Section({ children, accessory, ...rest }) {
|
|
6
6
|
const props = DressedComponent([], accessory, rest);
|
|
7
7
|
return createElement("dressed-node", props, children);
|
|
@@ -14,7 +14,7 @@ export async function parseSection(props, children) {
|
|
|
14
14
|
return {
|
|
15
15
|
...props,
|
|
16
16
|
accessory,
|
|
17
|
-
components: await Promise.all(children.map(
|
|
17
|
+
components: await Promise.all(children.map(parseNode)),
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
//# sourceMappingURL=section.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"section.js","sourceRoot":"","sources":["../../src/components/section.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAkB,MAAM,OAAO,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAsB,
|
|
1
|
+
{"version":3,"file":"section.js","sourceRoot":"","sources":["../../src/components/section.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAkB,MAAM,OAAO,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAsB,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAOrE,MAAM,UAAU,OAAO,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI,EAAgB;IACpE,MAAM,KAAK,GAAG,gBAAgB,CAAC,EAAE,EAAE,SAAkB,EAAE,IAAI,CAAC,CAAC;IAC7D,OAAO,aAAa,CAAC,cAAc,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAgC,KAAQ,EAAE,QAAyB;IACnG,IAAI,SAAS,GAAuC,KAAK,CAAC,SAAkB,CAAC;IAE7E,IAAI,cAAc,CAAC,SAAS,CAAC,EAAE,CAAC;QAC9B,SAAS,GAAG,CAAC,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAU,CAAC;IAC/D,CAAC;IAED,OAAO;QACL,GAAG,KAAK;QACR,SAAS;QACT,UAAU,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;KACvD,CAAC;AACJ,CAAC"}
|
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
import { type APISelectMenuComponent, type APISelectMenuOption, ComponentType } from "discord-api-types/v10";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
3
|
import type { Node } from "../react/node.ts";
|
|
4
|
-
type SelectType =
|
|
5
|
-
Channel: 8;
|
|
6
|
-
Mentionable: 7;
|
|
7
|
-
Role: 6;
|
|
8
|
-
String: 3;
|
|
9
|
-
User: 5;
|
|
10
|
-
};
|
|
4
|
+
type SelectType = "Channel" | "Mentionable" | "Role" | "String" | "User";
|
|
11
5
|
type SelectMap = {
|
|
12
6
|
[Key in keyof typeof ComponentType]: Extract<APISelectMenuComponent, {
|
|
13
7
|
type: (typeof ComponentType)[Key];
|
|
14
8
|
}>;
|
|
15
9
|
};
|
|
16
|
-
type MenuProps<K extends
|
|
10
|
+
type MenuProps<K extends SelectType> = Omit<SelectMap[`${K}Select`], "type" | "options"> & ({
|
|
17
11
|
children: ReactNode;
|
|
18
12
|
type: "String";
|
|
19
13
|
} | {
|
|
20
14
|
type: Exclude<K, "String">;
|
|
21
15
|
});
|
|
22
|
-
export declare function SelectMenu<K extends
|
|
16
|
+
export declare function SelectMenu<K extends SelectType>(props: MenuProps<K>): import("react").DOMElement<never, Element>;
|
|
23
17
|
export declare function SelectMenuOption(props: APISelectMenuOption): import("react").ReactElement<APISelectMenuOption, string | import("react").JSXElementConstructor<any>>;
|
|
24
18
|
export declare function parseSelectMenu<T extends APISelectMenuComponent>(props: T, children: Node<APISelectMenuOption>[]): T;
|
|
25
19
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-menu.js","sourceRoot":"","sources":["../../src/components/select-menu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyD,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC7G,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,gBAAgB,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAkB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"select-menu.js","sourceRoot":"","sources":["../../src/components/select-menu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyD,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC7G,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,gBAAgB,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAkB,MAAM,OAAO,CAAC;AAYtD,MAAM,UAAU,UAAU,CAAuB,KAAmB;IAClE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,KAAgC,CAAC;IAC/D,MAAM,SAAS,GAAG,gBAAgB,CAAC,IAAa,CAAC,CAAC;IAClD,OAAO,aAAa,CAAC,cAAc,EAAE,SAAkB,EAAE,QAAqB,CAAC,CAAC;AAClF,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAA0B;IACzD,MAAM,SAAS,GAAG,aAAa,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACjE,OAAO,aAAa,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,eAAe,CAAmC,KAAQ,EAAE,QAAqC;IAC/G,IAAI,KAAK,CAAC,IAAI,KAAK,aAAa,CAAC,YAAY,EAAE,CAAC;QAC9C,KAAK,CAAC,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { APISeparatorComponent, SeparatorSpacingSize } from "discord-api-types/v10";
|
|
2
|
-
|
|
2
|
+
interface SeparatorProps extends Omit<APISeparatorComponent, "type" | "spacing"> {
|
|
3
3
|
spacing?: keyof typeof SeparatorSpacingSize;
|
|
4
|
-
}
|
|
5
|
-
export declare function Separator(props: SeparatorProps): import("react").ReactElement<APISeparatorComponent, string | import("react").JSXElementConstructor<any>>;
|
|
4
|
+
}
|
|
5
|
+
export declare function Separator({ spacing, ...props }: SeparatorProps): import("react").ReactElement<APISeparatorComponent, string | import("react").JSXElementConstructor<any>>;
|
|
6
6
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Separator as DressedComponent } from "dressed";
|
|
2
2
|
import { createElement } from "react";
|
|
3
|
-
export function Separator(props) {
|
|
4
|
-
const component = DressedComponent(props);
|
|
3
|
+
export function Separator({ spacing, ...props }) {
|
|
4
|
+
const component = DressedComponent({ spacing, ...props });
|
|
5
5
|
return createElement("dressed-node", component);
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=separator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"separator.js","sourceRoot":"","sources":["../../src/components/separator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAMtC,MAAM,UAAU,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"separator.js","sourceRoot":"","sources":["../../src/components/separator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAMtC,MAAM,UAAU,SAAS,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,EAAkB;IAC7D,MAAM,SAAS,GAAG,gBAAgB,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;IAC1D,OAAO,aAAa,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { APITextDisplayComponent } from "discord-api-types/v10";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
|
-
|
|
3
|
+
interface TextDisplayProps extends Omit<APITextDisplayComponent, "content" | "type"> {
|
|
4
4
|
children: ReactNode;
|
|
5
|
-
}
|
|
5
|
+
}
|
|
6
6
|
export declare function TextDisplay({ children, ...rest }: TextDisplayProps): import("react").ReactElement<APITextDisplayComponent, string | import("react").JSXElementConstructor<any>>;
|
|
7
7
|
export declare function parseTextDisplay<T extends APITextDisplayComponent>(props: T, children: string): T;
|
|
8
8
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { APITextInputComponent, TextInputStyle } from "discord-api-types/v10";
|
|
2
|
-
|
|
2
|
+
interface TextInputProps extends Omit<APITextInputComponent, "type" | "style"> {
|
|
3
3
|
style?: keyof typeof TextInputStyle;
|
|
4
|
-
}
|
|
5
|
-
export declare function TextInput(props: TextInputProps): import("react").ReactElement<APITextInputComponent, string | import("react").JSXElementConstructor<any>>;
|
|
4
|
+
}
|
|
5
|
+
export declare function TextInput({ style, ...props }: TextInputProps): import("react").ReactElement<APITextInputComponent, string | import("react").JSXElementConstructor<any>>;
|
|
6
6
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TextInput as DressedComponent } from "dressed";
|
|
2
2
|
import { createElement } from "react";
|
|
3
|
-
export function TextInput(props) {
|
|
4
|
-
const component = DressedComponent(props);
|
|
3
|
+
export function TextInput({ style, ...props }) {
|
|
4
|
+
const component = DressedComponent({ style, ...props });
|
|
5
5
|
return createElement("dressed-node", component);
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=text-input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-input.js","sourceRoot":"","sources":["../../src/components/text-input.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAMtC,MAAM,UAAU,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"text-input.js","sourceRoot":"","sources":["../../src/components/text-input.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAMtC,MAAM,UAAU,SAAS,CAAC,EAAE,KAAK,EAAE,GAAG,KAAK,EAAkB;IAC3D,MAAM,SAAS,GAAG,gBAAgB,CAAC,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;IACxD,OAAO,aAAa,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { APIThumbnailComponent } from "discord-api-types/v10";
|
|
2
|
-
|
|
2
|
+
interface ThumbnailProps extends Omit<APIThumbnailComponent, "media" | "type"> {
|
|
3
3
|
media: APIThumbnailComponent["media"] | string;
|
|
4
|
-
}
|
|
4
|
+
}
|
|
5
5
|
export declare function Thumbnail({ media, ...rest }: ThumbnailProps): import("react").ReactElement<APIThumbnailComponent, string | import("react").JSXElementConstructor<any>>;
|
|
6
6
|
export {};
|
package/dist/react/node.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ export interface Node<Props, Children = unknown> {
|
|
|
2
2
|
props: Props;
|
|
3
3
|
children: Node<Children>[];
|
|
4
4
|
text: () => string;
|
|
5
|
+
hidden: boolean;
|
|
5
6
|
}
|
|
6
|
-
export declare function createNode<Props>(props: Props): Node<Props>;
|
|
7
|
+
export declare function createNode<Props>(props: Props): Node<Props, unknown>;
|
|
7
8
|
export declare function isNode(obj: unknown): obj is Node<unknown>;
|
|
9
|
+
export declare function removeChild<T>(array: T[], item: T): void;
|
package/dist/react/node.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
export function createNode(props) {
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
return children.map((c) => c.text()).join("");
|
|
5
|
-
}
|
|
6
|
-
return {
|
|
2
|
+
const node = {
|
|
3
|
+
hidden: false,
|
|
7
4
|
props,
|
|
8
|
-
children,
|
|
9
|
-
text
|
|
5
|
+
children: [],
|
|
6
|
+
text() {
|
|
7
|
+
if (node.hidden)
|
|
8
|
+
return "";
|
|
9
|
+
return node.children.map((c) => c.text()).join("");
|
|
10
|
+
},
|
|
10
11
|
};
|
|
12
|
+
return node;
|
|
11
13
|
}
|
|
12
14
|
export function isNode(obj) {
|
|
13
15
|
return (obj !== null &&
|
|
@@ -17,4 +19,10 @@ export function isNode(obj) {
|
|
|
17
19
|
"text" in obj &&
|
|
18
20
|
typeof obj.text === "function");
|
|
19
21
|
}
|
|
22
|
+
export function removeChild(array, item) {
|
|
23
|
+
const index = array.indexOf(item);
|
|
24
|
+
if (index !== -1) {
|
|
25
|
+
array.splice(index, 1);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
20
28
|
//# sourceMappingURL=node.js.map
|
package/dist/react/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/react/node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/react/node.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,UAAU,CAAQ,KAAY;IAC5C,MAAM,IAAI,GAAgB;QACxB,MAAM,EAAE,KAAK;QACb,KAAK;QACL,QAAQ,EAAE,EAAE;QACZ,IAAI;YACF,IAAI,IAAI,CAAC,MAAM;gBAAE,OAAO,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACrD,CAAC;KACF,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,GAAY;IACjC,OAAO,CACL,GAAG,KAAK,IAAI;QACZ,OAAO,GAAG,KAAK,QAAQ;QACvB,OAAO,IAAI,GAAG;QACd,UAAU,IAAI,GAAG;QACjB,MAAM,IAAI,GAAG;QACb,OAAO,GAAG,CAAC,IAAI,KAAK,UAAU,CAC/B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,WAAW,CAAI,KAAU,EAAE,IAAO;IAChD,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;QACjB,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACzB,CAAC;AACH,CAAC"}
|
|
@@ -2,4 +2,4 @@ import ReactReconciler from "react-reconciler";
|
|
|
2
2
|
import { type Node } from "./node.ts";
|
|
3
3
|
import type { Renderer } from "./renderer.ts";
|
|
4
4
|
import { type TextNode } from "./text-node.ts";
|
|
5
|
-
export declare const reconciler: ReactReconciler.Reconciler<Renderer, Node<unknown, unknown>, TextNode, never, never, never
|
|
5
|
+
export declare const reconciler: ReactReconciler.Reconciler<Renderer, Node<unknown, unknown>, TextNode, never, never, Record<string, never>>;
|
package/dist/react/reconciler.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import ReactReconciler from "react-reconciler";
|
|
2
2
|
import { DefaultEventPriority, NoEventPriority } from "react-reconciler/constants.js";
|
|
3
|
-
import { createNode, isNode } from "./node.js";
|
|
3
|
+
import { createNode, isNode, removeChild } from "./node.js";
|
|
4
4
|
import { createTextNode } from "./text-node.js";
|
|
5
5
|
let currentUpdatePriority = NoEventPriority;
|
|
6
|
-
const
|
|
6
|
+
export const reconciler = ReactReconciler({
|
|
7
7
|
supportsMutation: true,
|
|
8
8
|
supportsPersistence: false,
|
|
9
9
|
supportsHydration: false,
|
|
10
10
|
isPrimaryRenderer: true,
|
|
11
|
+
supportsMicrotasks: true,
|
|
12
|
+
scheduleMicrotask: queueMicrotask,
|
|
11
13
|
scheduleTimeout: globalThis.setTimeout,
|
|
12
14
|
cancelTimeout: globalThis.clearTimeout,
|
|
13
15
|
noTimeout: -1,
|
|
@@ -17,7 +19,6 @@ const config = {
|
|
|
17
19
|
if (type !== "dressed-node") {
|
|
18
20
|
throw new Error(`Unknown node type: ${type}`);
|
|
19
21
|
}
|
|
20
|
-
// biome-ignore lint/correctness/noUnusedVariables: Children are being filtered out
|
|
21
22
|
const { children, ...rest } = props;
|
|
22
23
|
const node = createNode(rest);
|
|
23
24
|
if (!isNode(node)) {
|
|
@@ -33,10 +34,10 @@ const config = {
|
|
|
33
34
|
getInstanceFromNode: () => null,
|
|
34
35
|
getInstanceFromScope: () => null,
|
|
35
36
|
clearContainer: (renderer) => {
|
|
36
|
-
renderer.nodes
|
|
37
|
+
renderer.nodes = [];
|
|
37
38
|
},
|
|
38
39
|
appendChildToContainer: (renderer, child) => renderer.nodes.push(child),
|
|
39
|
-
removeChildFromContainer: (renderer, child) => renderer.nodes
|
|
40
|
+
removeChildFromContainer: (renderer, child) => removeChild(renderer.nodes, child),
|
|
40
41
|
insertInContainerBefore: (renderer, child, before) => {
|
|
41
42
|
let index = renderer.nodes.indexOf(before);
|
|
42
43
|
if (index === -1) {
|
|
@@ -46,7 +47,7 @@ const config = {
|
|
|
46
47
|
},
|
|
47
48
|
appendInitialChild: (parent, child) => parent.children.push(child),
|
|
48
49
|
appendChild: (parent, child) => parent.children.push(child),
|
|
49
|
-
removeChild: (parent, child) => parent.children
|
|
50
|
+
removeChild: (parent, child) => removeChild(parent.children, child),
|
|
50
51
|
insertBefore: (parent, child, before) => {
|
|
51
52
|
let index = parent.children.indexOf(before);
|
|
52
53
|
if (index === -1) {
|
|
@@ -55,7 +56,7 @@ const config = {
|
|
|
55
56
|
parent.children.splice(index, 0, child);
|
|
56
57
|
},
|
|
57
58
|
prepareForCommit: () => null,
|
|
58
|
-
resetAfterCommit: () =>
|
|
59
|
+
resetAfterCommit: (renderer) => queueMicrotask(renderer.render),
|
|
59
60
|
prepareScopeUpdate() { },
|
|
60
61
|
preparePortalMount: () => {
|
|
61
62
|
throw new Error("Portals are not supported");
|
|
@@ -68,8 +69,8 @@ const config = {
|
|
|
68
69
|
currentUpdatePriority = newPriority;
|
|
69
70
|
},
|
|
70
71
|
getCurrentUpdatePriority: () => currentUpdatePriority,
|
|
71
|
-
resolveUpdatePriority: () => currentUpdatePriority
|
|
72
|
-
maySuspendCommit: () =>
|
|
72
|
+
resolveUpdatePriority: () => currentUpdatePriority || DefaultEventPriority,
|
|
73
|
+
maySuspendCommit: () => true,
|
|
73
74
|
NotPendingTransition: null,
|
|
74
75
|
HostTransitionContext: {
|
|
75
76
|
$$typeof: Symbol.for("react.context"),
|
|
@@ -89,6 +90,17 @@ const config = {
|
|
|
89
90
|
startSuspendingCommit() { },
|
|
90
91
|
suspendInstance() { },
|
|
91
92
|
waitForCommitToBeReady: () => null,
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
hideInstance: (instance) => {
|
|
94
|
+
instance.hidden = true;
|
|
95
|
+
},
|
|
96
|
+
unhideInstance: (instance) => {
|
|
97
|
+
instance.hidden = false;
|
|
98
|
+
},
|
|
99
|
+
hideTextInstance: (textInstance) => {
|
|
100
|
+
textInstance.hidden = true;
|
|
101
|
+
},
|
|
102
|
+
unhideTextInstance: (textInstance) => {
|
|
103
|
+
textInstance.hidden = false;
|
|
104
|
+
},
|
|
105
|
+
});
|
|
94
106
|
//# sourceMappingURL=reconciler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reconciler.js","sourceRoot":"","sources":["../../src/react/reconciler.ts"],"names":[],"mappings":"AACA,OAAO,eAAe,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,EAAa,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"reconciler.js","sourceRoot":"","sources":["../../src/react/reconciler.ts"],"names":[],"mappings":"AACA,OAAO,eAAe,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,EAAa,WAAW,EAAE,MAAM,WAAW,CAAC;AAEvE,OAAO,EAAE,cAAc,EAAiB,MAAM,gBAAgB,CAAC;AAE/D,IAAI,qBAAqB,GAAW,eAAe,CAAC;AAEpD,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAevC;IACA,gBAAgB,EAAE,IAAI;IACtB,mBAAmB,EAAE,KAAK;IAC1B,iBAAiB,EAAE,KAAK;IACxB,iBAAiB,EAAE,IAAI;IACvB,kBAAkB,EAAE,IAAI;IACxB,iBAAiB,EAAE,cAAc;IACjC,eAAe,EAAE,UAAU,CAAC,UAAU;IACtC,aAAa,EAAE,UAAU,CAAC,YAAY;IACtC,SAAS,EAAE,CAAC,CAAC;IACb,kBAAkB,EAAE,GAAG,EAAE,CAAC,IAAI;IAC9B,mBAAmB,EAAE,GAAG,EAAE,CAAC,IA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,YAAY,CAAC,MAAM,GAAG,KAAK,CAAC;IAC9B,CAAC;CACF,CAAC,CAAC"}
|
package/dist/react/renderer.d.ts
CHANGED
|
@@ -6,5 +6,6 @@ export interface Renderer {
|
|
|
6
6
|
components: (APIMessageComponent | APIModalComponent)[];
|
|
7
7
|
}
|
|
8
8
|
export type ComponentNode = Node<APIMessageComponent | APIModalComponent, APIMessageComponent | APIModalComponent>;
|
|
9
|
-
export
|
|
10
|
-
export declare function
|
|
9
|
+
export type RendererCallback = (components: (APIMessageComponent | APIModalComponent)[]) => void;
|
|
10
|
+
export declare function createRenderer(callback?: RendererCallback): Renderer;
|
|
11
|
+
export declare function parseNode(node: ComponentNode): Promise<APIMessageComponent | APIModalComponent>;
|
package/dist/react/renderer.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
1
2
|
import { ComponentType, } from "discord-api-types/v10";
|
|
2
3
|
import { TextDisplay } from "dressed";
|
|
3
4
|
import { parseActionRow } from "../components/action-row.js";
|
|
@@ -23,27 +24,33 @@ function mergeTextNodes(nodes) {
|
|
|
23
24
|
}
|
|
24
25
|
else {
|
|
25
26
|
pushText();
|
|
26
|
-
node
|
|
27
|
-
merged.push(node);
|
|
27
|
+
merged.push({ ...node, children: mergeTextNodes(node.children) });
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
pushText();
|
|
31
31
|
return merged;
|
|
32
32
|
}
|
|
33
|
-
export function createRenderer() {
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
export function createRenderer(callback) {
|
|
34
|
+
let prevHash = "";
|
|
35
|
+
const renderer = {
|
|
36
|
+
nodes: [],
|
|
37
|
+
components: [],
|
|
38
38
|
async render() {
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
const components = [];
|
|
40
|
+
for (const node of mergeTextNodes(renderer.nodes)) {
|
|
41
|
+
components.push(await parseNode(node));
|
|
41
42
|
}
|
|
43
|
+
const hash = createHash("sha256").update(JSON.stringify(components)).digest("hex");
|
|
44
|
+
if (hash === prevHash)
|
|
45
|
+
return;
|
|
46
|
+
prevHash = hash;
|
|
47
|
+
callback === null || callback === void 0 ? void 0 : callback(components);
|
|
48
|
+
renderer.components = components;
|
|
42
49
|
},
|
|
43
|
-
components,
|
|
44
50
|
};
|
|
51
|
+
return renderer;
|
|
45
52
|
}
|
|
46
|
-
export async function
|
|
53
|
+
export async function parseNode(node) {
|
|
47
54
|
switch (node.props.type) {
|
|
48
55
|
case ComponentType.ActionRow: {
|
|
49
56
|
return parseActionRow(node.props, node.children);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../../src/react/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,aAAa,GACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAUhD,SAAS,cAAc,CAAI,KAAgB;IACzC,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,IAAI,OAAO,GAAG,EAAE,CAAC;IAEjB,SAAS,QAAQ;QACf,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;YACrC,OAA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,CAAC,CAAC;QACnD,CAAC;QACD,KAAK,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;YACzB,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,CAAC,CAAC,CAAC;YACR,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACnC,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YAClC,CAAC;YAED,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/react/text-node.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { createNode } from "./node.js";
|
|
2
2
|
export function createTextNode(props) {
|
|
3
3
|
const node = createNode(props);
|
|
4
|
-
|
|
4
|
+
node.text = () => {
|
|
5
|
+
if (node.hidden)
|
|
6
|
+
return "";
|
|
5
7
|
return node.props;
|
|
6
|
-
}
|
|
7
|
-
return {
|
|
8
|
-
...node,
|
|
9
|
-
text,
|
|
10
8
|
};
|
|
9
|
+
return node;
|
|
11
10
|
}
|
|
12
11
|
//# sourceMappingURL=text-node.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-node.js","sourceRoot":"","sources":["../../src/react/text-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,WAAW,CAAC;AAIlD,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,MAAM,IAAI,GAAG,UAAU,CAAS,KAAK,CAAC,CAAC;IAEvC,
|
|
1
|
+
{"version":3,"file":"text-node.js","sourceRoot":"","sources":["../../src/react/text-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,WAAW,CAAC;AAIlD,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,MAAM,IAAI,GAAG,UAAU,CAAS,KAAK,CAAC,CAAC;IAEvC,IAAI,CAAC,IAAI,GAAG,GAAG,EAAE;QACf,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
|
|
2
|
+
import { type RendererCallback } from "../react/renderer.ts";
|
|
3
|
+
export declare function render(children: ReactNode, callback?: RendererCallback): Promise<import("../react/renderer.ts").Renderer>;
|
package/dist/rendering/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { reconciler } from "../react/reconciler.js";
|
|
2
2
|
import { createRenderer } from "../react/renderer.js";
|
|
3
|
-
export async function render(children) {
|
|
4
|
-
const
|
|
5
|
-
const root = reconciler.createContainer(
|
|
3
|
+
export async function render(children, callback) {
|
|
4
|
+
const renderer = createRenderer(callback);
|
|
5
|
+
const root = reconciler.createContainer(renderer, 0, null, false, null, "dressed", (error) => console.error(error), () => { }, () => { }, () => { }, null);
|
|
6
6
|
if (root !== null) {
|
|
7
7
|
await new Promise((r) => reconciler.updateContainer(children, root, null, r));
|
|
8
|
-
await
|
|
8
|
+
await renderer.render();
|
|
9
9
|
}
|
|
10
|
-
return
|
|
10
|
+
return renderer;
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rendering/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rendering/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAyB,MAAM,sBAAsB,CAAC;AAE7E,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,QAAmB,EAAE,QAA2B;IAC3E,MAAM,QAAQ,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,UAAU,CAAC,eAAe,CACrC,QAAQ,EACR,CAAC,EACD,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,SAAS,EACT,CAAC,KAAY,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EACtC,GAAG,EAAE,GAAE,CAAC,EACR,GAAG,EAAE,GAAE,CAAC,EACR,GAAG,EAAE,GAAE,CAAC,EACR,IAAI,CACL,CAAC;IAEF,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,MAAM,IAAI,OAAO,CAAO,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACpF,MAAM,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC1B,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -5,16 +5,24 @@ export function patchInteraction(interaction) {
|
|
|
5
5
|
throw new Error("No interaction");
|
|
6
6
|
// biome-ignore lint/suspicious/noExplicitAny: We're overriding the types
|
|
7
7
|
const newInteraction = interaction;
|
|
8
|
+
// @ts-expect-error
|
|
9
|
+
const editReply = interaction.editReply;
|
|
8
10
|
for (const method of ["reply", "editReply", "update", "followUp", "showModal"]) {
|
|
9
11
|
if (!(method in interaction))
|
|
10
12
|
continue;
|
|
11
13
|
const original = interaction[method];
|
|
12
|
-
newInteraction[method] =
|
|
14
|
+
newInteraction[method] = (components, data = {}) => {
|
|
13
15
|
var _a;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
data.flags = ((_a = data.flags) !== null && _a !== void 0 ? _a : 0) | MessageFlags.IsComponentsV2;
|
|
17
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
18
|
+
render(components, (c) => {
|
|
19
|
+
data.components = c;
|
|
20
|
+
if (interaction.history.some((h) => ["reply", "deferReply", "update", "deferUpdate"].includes(h))) {
|
|
21
|
+
return editReply(data);
|
|
22
|
+
}
|
|
23
|
+
resolve(original(data));
|
|
24
|
+
});
|
|
25
|
+
return promise;
|
|
18
26
|
};
|
|
19
27
|
}
|
|
20
28
|
return newInteraction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interaction.js","sourceRoot":"","sources":["../../src/rendering/interaction.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"interaction.js","sourceRoot":"","sources":["../../src/rendering/interaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,YAAY,GACb,MAAM,uBAAuB,CAAC;AAS/B,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAkEpC,MAAM,UAAU,gBAAgB,CAC9B,WAAc;IAEd,IAAI,CAAC,WAAW;QAAE,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACpD,yEAAyE;IACzE,MAAM,cAAc,GAAG,WAAkB,CAAC;IAC1C,mBAAmB;IACnB,MAAM,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC;IACxC,KAAK,MAAM,MAAM,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,CAAgB,EAAE,CAAC;QAC9F,IAAI,CAAC,CAAC,MAAM,IAAI,WAAW,CAAC;YAAE,SAAS;QAEvC,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAA4B,CAAC;QAEhE,cAAc,CAAC,MAAM,CAAC,GAAG,CAAC,UAAyB,EAAE,OAAsB,EAAE,EAAE,EAAE;;YAC/E,IAAI,CAAC,KAAK,GAAG,CAAC,MAAA,IAAI,CAAC,KAAK,mCAAI,CAAC,CAAC,GAAG,YAAY,CAAC,cAAc,CAAC;YAE7D,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;YAErD,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,EAAE;gBACvB,IAAI,CAAC,UAAU,GAAG,CAAkC,CAAC;gBACrD,IAAI,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;oBAClG,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;gBACzB,CAAC;gBACD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;YAC1B,CAAC,CAAC,CAAC;YAEH,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC;IACJ,CAAC;IACD,OAAO,cAAc,CAAC;AACxB,CAAC"}
|
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import
|
|
1
|
+
import { type Snowflake } from "discord-api-types/v10";
|
|
2
|
+
import { createMessage as dressedCreateMessage, editMessage as dressedEditMessage } from "dressed";
|
|
3
3
|
import type { ReactNode } from "react";
|
|
4
4
|
/**
|
|
5
5
|
* Renders the provided children and posts a message to a guild text or DM channel with the `IsComponentsV2` flag.
|
|
6
6
|
* @example createMessage(channelId, <Button label="Foo" />)
|
|
7
|
-
* @param channel The channel to post the message to
|
|
8
|
-
* @param components The contents of the message
|
|
9
|
-
* @param data The message data
|
|
10
7
|
*/
|
|
11
|
-
export declare function createMessage(
|
|
12
|
-
files?: RawFile[];
|
|
13
|
-
}): Promise<import("discord-api-types/v10").APIMessage>;
|
|
8
|
+
export declare function createMessage(channelId: Snowflake, components: ReactNode, data?: Exclude<Parameters<typeof dressedCreateMessage>[1], string>): Promise<unknown>;
|
|
14
9
|
/**
|
|
15
10
|
* Renders the provided children and edits a previously sent message.
|
|
16
11
|
* @example editMessage(channelId, messageId, <Button label="Bar" />)
|
|
17
|
-
* @param channel The channel to edit the message in
|
|
18
|
-
* @param components The contents of the message
|
|
19
|
-
* @param data The new message data
|
|
20
12
|
*/
|
|
21
|
-
export declare function editMessage(
|
|
22
|
-
files?: RawFile[];
|
|
23
|
-
}): Promise<import("discord-api-types/v10").APIMessage>;
|
|
13
|
+
export declare function editMessage(channelId: Snowflake, messageId: Snowflake, components: ReactNode, data?: Exclude<Parameters<typeof dressedEditMessage>[2], string>): Promise<unknown>;
|
|
@@ -1,30 +1,38 @@
|
|
|
1
|
-
import { MessageFlags
|
|
1
|
+
import { MessageFlags } from "discord-api-types/v10";
|
|
2
2
|
import { createMessage as dressedCreateMessage, editMessage as dressedEditMessage } from "dressed";
|
|
3
3
|
import { render } from "./index.js";
|
|
4
4
|
/**
|
|
5
5
|
* Renders the provided children and posts a message to a guild text or DM channel with the `IsComponentsV2` flag.
|
|
6
6
|
* @example createMessage(channelId, <Button label="Foo" />)
|
|
7
|
-
* @param channel The channel to post the message to
|
|
8
|
-
* @param components The contents of the message
|
|
9
|
-
* @param data The message data
|
|
10
7
|
*/
|
|
11
|
-
export async function createMessage(
|
|
8
|
+
export async function createMessage(channelId, components, data = {}) {
|
|
12
9
|
var _a;
|
|
13
10
|
data.flags = ((_a = data.flags) !== null && _a !== void 0 ? _a : 0) | MessageFlags.IsComponentsV2;
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
12
|
+
let messageId;
|
|
13
|
+
render(components, async (c) => {
|
|
14
|
+
data.components = c;
|
|
15
|
+
if (messageId) {
|
|
16
|
+
return dressedEditMessage(channelId, messageId, data);
|
|
17
|
+
}
|
|
18
|
+
const message = await dressedCreateMessage(channelId, data);
|
|
19
|
+
messageId = message.id;
|
|
20
|
+
resolve(message);
|
|
21
|
+
});
|
|
22
|
+
return promise;
|
|
16
23
|
}
|
|
17
24
|
/**
|
|
18
25
|
* Renders the provided children and edits a previously sent message.
|
|
19
26
|
* @example editMessage(channelId, messageId, <Button label="Bar" />)
|
|
20
|
-
* @param channel The channel to edit the message in
|
|
21
|
-
* @param components The contents of the message
|
|
22
|
-
* @param data The new message data
|
|
23
27
|
*/
|
|
24
|
-
export async function editMessage(
|
|
28
|
+
export async function editMessage(channelId, messageId, components, data = {}) {
|
|
25
29
|
var _a;
|
|
26
30
|
data.flags = ((_a = data.flags) !== null && _a !== void 0 ? _a : 0) | MessageFlags.IsComponentsV2;
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
32
|
+
render(components, async (c) => {
|
|
33
|
+
data.components = c;
|
|
34
|
+
resolve(dressedEditMessage(channelId, messageId, data));
|
|
35
|
+
});
|
|
36
|
+
return promise;
|
|
29
37
|
}
|
|
30
38
|
//# sourceMappingURL=message.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../src/rendering/message.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../src/rendering/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,YAAY,EAAkB,MAAM,uBAAuB,CAAC;AACvG,OAAO,EAAE,aAAa,IAAI,oBAAoB,EAAE,WAAW,IAAI,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAEnG,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,SAAoB,EACpB,UAAqB,EACrB,OAAoE,EAAE;;IAEtE,IAAI,CAAC,KAAK,GAAG,CAAC,MAAA,IAAI,CAAC,KAAK,mCAAI,CAAC,CAAC,GAAG,YAAY,CAAC,cAAc,CAAC;IAE7D,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IACrD,IAAI,SAAiB,CAAC;IAEtB,MAAM,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;QAC7B,IAAI,CAAC,UAAU,GAAG,CAAkC,CAAC;QACrD,IAAI,SAAS,EAAE,CAAC;YACd,OAAO,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;QACxD,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,oBAAoB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAC5D,SAAS,GAAG,OAAO,CAAC,EAAE,CAAC;QACvB,OAAO,CAAC,OAAO,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,SAAoB,EACpB,SAAoB,EACpB,UAAqB,EACrB,OAAkE,EAAE;;IAEpE,IAAI,CAAC,KAAK,GAAG,CAAC,MAAA,IAAI,CAAC,KAAK,mCAAI,CAAC,CAAC,GAAG,YAAY,CAAC,cAAc,CAAC;IAE7D,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAErD,MAAM,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;QAC7B,IAAI,CAAC,UAAU,GAAG,CAAkC,CAAC;QACrD,OAAO,CAAC,kBAAkB,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dressed/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/Inbestigator/dressed.git",
|
|
7
7
|
"directory": "packages/dressed-react"
|
|
8
8
|
},
|
|
9
9
|
"peerDependencies": {
|
|
10
|
-
"dressed": "^1.10.
|
|
11
|
-
"react": "^19.
|
|
10
|
+
"dressed": "^1.10.1",
|
|
11
|
+
"react": "^19.2.3"
|
|
12
12
|
},
|
|
13
13
|
"exports": "./dist/index.js",
|
|
14
14
|
"description": "Render Dressed's components using React",
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
"type": "module",
|
|
32
32
|
"types": "./dist/index.d.ts",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"discord-api-types": "^0.38.
|
|
34
|
+
"discord-api-types": "^0.38.37",
|
|
35
35
|
"react-reconciler": "npm:@dressed/react-reconciler"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@types/react": "^19.
|
|
39
|
-
"@types/react-reconciler": "^0.32.
|
|
38
|
+
"@types/react": "^19.2.7",
|
|
39
|
+
"@types/react-reconciler": "^0.32.3"
|
|
40
40
|
}
|
|
41
41
|
}
|