Initial Commit

This commit is contained in:
JB
2025-10-06 23:31:31 -04:00
commit 0c8630b8ba
243 changed files with 166945 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
import { createActionRow } from '@components';
export function ActionRow(props: { children: any | any[] }) {
return createActionRow(...(Array.isArray(props.children) ? props.children : [props.children]));
}

View File

@@ -0,0 +1,6 @@
import { createButton, type ButtonStyle } from '@components';
import type { PartialEmoji } from '@projectdysnomia/dysnomia';
export function Button(props: { label: string; customId: string; style?: ButtonStyle; emoji?: PartialEmoji; disabled?: boolean }) {
return createButton(props.label, props.customId, { style: props.style, emoji: props.emoji, disabled: props.disabled });
}

View File

@@ -0,0 +1,8 @@
import { createContainer } from '@components';
export function Container(props: { accent?: number; spoiler?: boolean; children: any | any[] }) {
return createContainer(
{ accent_color: props.accent, spoiler: props.spoiler },
...(Array.isArray(props.children) ? props.children : [props.children]),
);
}

View File

@@ -0,0 +1,4 @@
export * from './action-row';
export * from './button';
export * from './container';
export * from './text-display';

View File

@@ -0,0 +1,5 @@
import { createTextDisplay } from '@components/builders';
export function TextDisplay(props: { content: string }) {
return createTextDisplay(props.content);
}

View File

@@ -0,0 +1,3 @@
export * from './runtime';
export * from './components';
export * as JSX from './jsx';

View File

@@ -0,0 +1,69 @@
import {
type ActionRow,
type Button,
type ChannelSelectMenu,
type MentionableSelectMenu,
type PartialEmoji,
type RoleSelectMenu,
type StringSelectMenu,
type TextInput,
type UserSelectMenu,
type LabelComponent,
type ContainerComponent,
type TextDisplayComponent,
type SectionComponent,
type MediaGalleryComponent,
type SeparatorComponent,
type FileComponent,
type InteractionButton,
type URLButton,
type PremiumButton,
type ThumbnailComponent,
} from '@projectdysnomia/dysnomia';
export type Component =
| ActionRow
| Button
| StringSelectMenu
| UserSelectMenu
| RoleSelectMenu
| MentionableSelectMenu
| ChannelSelectMenu
| TextInput
| LabelComponent
| ContainerComponent
| TextDisplayComponent
| SectionComponent
| MediaGalleryComponent
| SeparatorComponent
| FileComponent
| InteractionButton
| URLButton
| PremiumButton
| ThumbnailComponent;
export type Element = Component | Promise<Component>;
export interface ElementClass {
render: any;
}
export interface ElementAttributesProperty {
props: {};
}
export interface IntrinsicElements {
// Allow any element, but prefer known elements
[elemName: string]: any;
// Known elements
ActionRow: { children: any | any[] };
Button: {
label: string;
customId: string;
style?: number;
emoji?: PartialEmoji;
disabled?: boolean;
};
Container: { color?: string; accent?: number; spoiler?: boolean; children: any | any[] };
TextDisplay: { content: string };
}

View File

@@ -0,0 +1,30 @@
export function jsx(type: any, props: Record<string, any>) {
console.log('JSX', type, props);
if (typeof type === 'function') {
return type(props);
}
return {
type,
props,
};
}
export function jsxDEV(
type: any,
props: Record<string, any>,
key: string | number | symbol,
isStaticChildren: boolean,
source: any,
self: any,
) {
console.log('JSX DEV', type, props);
if (typeof type === 'function') {
return type(props);
}
return {
type,
props: { ...props, key },
_source: source,
_self: self,
};
}

8
packages/discord/src/jsx/types.d.ts vendored Normal file
View File

@@ -0,0 +1,8 @@
import type { Component, IntrinsicElements as StarKittenIntrinsicElements } from './jsx';
declare global {
namespace JSX {
type Element = Component;
interface IntrinsicElements extends StarKittenIntrinsicElements {}
}
}