Skip to content

Commit

Permalink
feat: add voice connection functionalities
Browse files Browse the repository at this point in the history
  • Loading branch information
twlite committed Jul 8, 2024
1 parent f776993 commit 875f16a
Show file tree
Hide file tree
Showing 92 changed files with 1,187 additions and 494 deletions.
7 changes: 4 additions & 3 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"printWidth": 200,
"trailingComma": "none",
"printWidth": 120,
"trailingComma": "all",
"singleQuote": true,
"tabWidth": 4,
"semi": true
"semi": true,
"endOfLine": "lf"
}
16 changes: 8 additions & 8 deletions apps/website/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@ const withMDX = nextMDX({
showCopyButton: true,
theme: 'github-dark-dimmed',
autoImport: true,
autoLink: true
}
autoLink: true,
},
],
remarkGfm
remarkGfm,
],
providerImportSource: '@mdx-js/react'
}
providerImportSource: '@mdx-js/react',
},
});

/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: false,
pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'],
typescript: {
ignoreBuildErrors: true
ignoreBuildErrors: true,
},
eslint: {
ignoreDuringBuilds: true
ignoreDuringBuilds: true,
},
swcMinify: true
swcMinify: true,
// experimental: {
// mdxRs: true
// }
Expand Down
4 changes: 2 additions & 2 deletions apps/website/postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {}
}
autoprefixer: {},
},
};
10 changes: 9 additions & 1 deletion apps/website/src/components/assets/TextMark.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@ import { cn } from '@edge-ui/react';

export function TextMark({ onClick, className }: { onClick?: () => void; className?: string }) {
return (
<svg width="497" height="390" className={cn('h-12 w-12', className)} viewBox="0 0 497 390" fill="none" xmlns="http://www.w3.org/2000/svg" onClick={onClick}>
<svg
width="497"
height="390"
className={cn('h-12 w-12', className)}
viewBox="0 0 497 390"
fill="none"
xmlns="http://www.w3.org/2000/svg"
onClick={onClick}
>
<path
d="M304.471 297.502C304.471 308.822 303.035 319.043 300.163 328.166C297.291 337.12 293.489 345.061 288.759 351.987C284.028 358.745 278.538 364.574 272.287 369.473C266.036 374.204 259.447 378.089 252.52 381.13C245.762 384.171 238.835 386.452 231.74 387.973C224.813 389.324 218.224 390 211.973 390H93.1201C81.8008 390 71.6641 388.564 62.71 385.692C53.7559 382.82 45.8154 379.019 38.8887 374.288C32.1309 369.389 26.3022 363.813 21.4028 357.562C16.6724 351.312 12.7866 344.807 9.74561 338.049C6.70459 331.123 4.42383 324.196 2.90332 317.269C1.55176 310.173 0.875977 303.584 0.875977 297.502V208.299C0.875977 191.405 3.91699 177.129 9.99902 165.472C16.25 153.646 23.937 144.1 33.0601 136.835C42.3521 129.402 52.4043 124.08 63.2168 120.87C74.0293 117.66 83.9971 116.055 93.1201 116.055H211.973V181.944H93.627C84.8418 181.944 78.1685 184.225 73.6069 188.786C69.0454 193.179 66.7646 199.683 66.7646 208.299V296.996C66.7646 305.95 68.9609 312.708 73.3535 317.269C77.915 321.831 84.5039 324.111 93.1201 324.111H211.973C220.927 324.111 227.601 321.831 231.993 317.269C236.386 312.708 238.582 306.119 238.582 297.502V0.243164H304.471V297.502ZM496.663 125.77H354.039V90.1896H496.663V125.77Z"
className="fill-primary"
Expand Down
73 changes: 58 additions & 15 deletions apps/website/src/components/cmdk/CommandDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,18 @@ import { Search } from 'lucide-react';
import { cn } from '@edge-ui/react';
import { Dialog, DialogContent } from '@edge-ui/react';

const Command = React.forwardRef<React.ElementRef<typeof CommandPrimitive>, React.ComponentPropsWithoutRef<typeof CommandPrimitive>>(({ className, ...props }, ref) => (
<CommandPrimitive ref={ref} className={cn('flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground', className)} {...props} />
const Command = React.forwardRef<
React.ElementRef<typeof CommandPrimitive>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive>
>(({ className, ...props }, ref) => (
<CommandPrimitive
ref={ref}
className={cn(
'flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground',
className,
)}
{...props}
/>
));
Command.displayName = CommandPrimitive.displayName;

Expand All @@ -29,55 +39,78 @@ const CommandDialog = ({ children, shouldFilter, ...props }: CommandDialogProps)
);
};

const CommandInput = React.forwardRef<React.ElementRef<typeof CommandPrimitive.Input>, React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>>(({ className, ...props }, ref) => (
const CommandInput = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.Input>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
>(({ className, ...props }, ref) => (
<div className="flex items-center border-b px-3" cmdk-input-wrapper="">
<Search className="mr-2 h-4 w-4 shrink-0 opacity-50" />
<CommandPrimitive.Input
ref={ref}
className={cn('placeholder:text-foreground-muted flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none disabled:cursor-not-allowed disabled:opacity-50', className)}
className={cn(
'placeholder:text-foreground-muted flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none disabled:cursor-not-allowed disabled:opacity-50',
className,
)}
{...props}
/>
</div>
));

CommandInput.displayName = CommandPrimitive.Input.displayName;

const CommandList = React.forwardRef<React.ElementRef<typeof CommandPrimitive.List>, React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>>(({ className, ...props }, ref) => (
<CommandPrimitive.List ref={ref} className={cn('max-h-[300px] overflow-y-auto overflow-x-hidden', className)} {...props} />
const CommandList = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.List>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
>(({ className, ...props }, ref) => (
<CommandPrimitive.List
ref={ref}
className={cn('max-h-[300px] overflow-y-auto overflow-x-hidden', className)}
{...props}
/>
));

CommandList.displayName = CommandPrimitive.List.displayName;

const CommandEmpty = React.forwardRef<React.ElementRef<typeof CommandPrimitive.Empty>, React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>>((props, ref) => (
<CommandPrimitive.Empty ref={ref} className="py-6 text-center text-sm" {...props} />
));
const CommandEmpty = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.Empty>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
>((props, ref) => <CommandPrimitive.Empty ref={ref} className="py-6 text-center text-sm" {...props} />);

CommandEmpty.displayName = CommandPrimitive.Empty.displayName;

const CommandGroup = React.forwardRef<React.ElementRef<typeof CommandPrimitive.Group>, React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>>(({ className, ...props }, ref) => (
const CommandGroup = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.Group>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
>(({ className, ...props }, ref) => (
<CommandPrimitive.Group
ref={ref}
className={cn(
'overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground',
className
className,
)}
{...props}
/>
));

CommandGroup.displayName = CommandPrimitive.Group.displayName;

const CommandSeparator = React.forwardRef<React.ElementRef<typeof CommandPrimitive.Separator>, React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>>(({ className, ...props }, ref) => (
const CommandSeparator = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.Separator>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
>(({ className, ...props }, ref) => (
<CommandPrimitive.Separator ref={ref} className={cn('-mx-1 h-px bg-border', className)} {...props} />
));
CommandSeparator.displayName = CommandPrimitive.Separator.displayName;

const CommandItem = React.forwardRef<React.ElementRef<typeof CommandPrimitive.Item>, React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>>(({ className, ...props }, ref) => (
const CommandItem = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
>(({ className, ...props }, ref) => (
<CommandPrimitive.Item
ref={ref}
className={cn(
'relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
className
className,
)}
{...props}
/>
Expand All @@ -90,4 +123,14 @@ const CommandShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanE
};
CommandShortcut.displayName = 'CommandShortcut';

export { Command, CommandDialog, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandShortcut, CommandSeparator };
export {
Command,
CommandDialog,
CommandInput,
CommandList,
CommandEmpty,
CommandGroup,
CommandItem,
CommandShortcut,
CommandSeparator,
};
13 changes: 12 additions & 1 deletion apps/website/src/components/combobox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@

import * as React from 'react';
import { Check, ChevronsUpDown } from 'lucide-react';
import { cn, Button, Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, Popover, PopoverContent, PopoverTrigger } from '@edge-ui/react';
import {
cn,
Button,
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
Popover,
PopoverContent,
PopoverTrigger,
} from '@edge-ui/react';

interface IProps {
onSelect: (value: string) => void;
Expand Down
31 changes: 20 additions & 11 deletions apps/website/src/components/docs/ContentArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ interface IProps {
export function ContentArea({ data }: IProps) {
const router = useRouter();
const { package: packageName, type, target, scrollTo } = router.query;
const [currentItem, setCurrentItem] = useState<DocumentedClass | DocumentedTypes | DocumentedFunction | null>(() => {
const t = type === 'class' ? 'classes' : type === 'function' ? 'functions' : 'types';
const res = data[t as Exclude<keyof typeof data, 'name'>] as unknown as { data: DocumentedClass | DocumentedTypes | DocumentedFunction }[];
const entity = res.find((e) => e.data.name === target)?.data || null;
const [currentItem, setCurrentItem] = useState<DocumentedClass | DocumentedTypes | DocumentedFunction | null>(
() => {
const t = type === 'class' ? 'classes' : type === 'function' ? 'functions' : 'types';
const res = data[t as Exclude<keyof typeof data, 'name'>] as unknown as {
data: DocumentedClass | DocumentedTypes | DocumentedFunction;
}[];
const entity = res.find((e) => e.data.name === target)?.data || null;

return entity;
});
return entity;
},
);

useEffect(() => {
const elm = document.getElementById(scrollTo as string);
Expand All @@ -35,15 +39,17 @@ export function ContentArea({ data }: IProps) {
const t = data.classes.length ? 'classes' : data.functions.length ? 'functions' : 'types';
const resolvedType = t === 'classes' ? 'class' : t === 'functions' ? 'function' : 'type';
if (!type) {
const dest = `/docs/${encodeURIComponent(packageName as string)}?type=${resolvedType}&target=${data[t as Exclude<keyof typeof data, 'name'>][0].data.name}${
router.query.scrollTo ? `&scrollTo=${router.query.scrollTo}` : ''
}`;
const dest = `/docs/${encodeURIComponent(packageName as string)}?type=${resolvedType}&target=${
data[t as Exclude<keyof typeof data, 'name'>][0].data.name
}${router.query.scrollTo ? `&scrollTo=${router.query.scrollTo}` : ''}`;
return void router.replace(dest);
}
}
} else {
const t = type === 'class' ? 'classes' : type === 'function' ? 'functions' : 'types';
const res = data[t as Exclude<keyof typeof data, 'name'>] as unknown as { data: DocumentedClass | DocumentedTypes | DocumentedFunction }[];
const res = data[t as Exclude<keyof typeof data, 'name'>] as unknown as {
data: DocumentedClass | DocumentedTypes | DocumentedFunction;
}[];
const entity = res.find((e) => e.data.name === target)?.data || null;
setCurrentItem(entity);
}
Expand All @@ -54,7 +60,10 @@ export function ContentArea({ data }: IProps) {

return (
<>
<HeadingMeta title={`${currentItem.name} | Discord Player`} description={`Documentation for ${currentItem.name}.`} />
<HeadingMeta
title={`${currentItem.name} | Discord Player`}
description={`Documentation for ${currentItem.name}.`}
/>
<div className="mb-16">
{type === 'type' ? (
<TypeRenderer entity={currentItem as DocumentedTypes} />
Expand Down
6 changes: 5 additions & 1 deletion apps/website/src/components/docs/DocsItemList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ export function DocsItemList({ data, name, link, icon }: IProps) {
<h1
className={cn(
'text-base font-normal text-muted-foreground cursor-pointer',
item.lib === router.query.package && item.name === router.query.target && item.type === router.query.type ? 'font-medium text-secondary' : ''
item.lib === router.query.package &&
item.name === router.query.target &&
item.type === router.query.type
? 'font-medium text-secondary'
: '',
)}
>
{item.name}
Expand Down
8 changes: 6 additions & 2 deletions apps/website/src/components/docs/entities/EntitySymbol.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ export function EntitySymbol({ type, children, id, link, source }: EntityProps)
let c: React.ReactNode;

const href = useMemo(() => {
const entries = Object.entries(router.query).filter((f) => !['scrollTo', 'target', 'package', 'type'].includes(f[0]));
const href = `${router.asPath.split('?')[0]}${entries.map((m, i) => `${i === 0 ? '?' : ''}${m[0]}=${m[1]}`).join('&')}${entries.length ? '&' : '?'}scrollTo=${id}`;
const entries = Object.entries(router.query).filter(
(f) => !['scrollTo', 'target', 'package', 'type'].includes(f[0]),
);
const href = `${router.asPath.split('?')[0]}${entries
.map((m, i) => `${i === 0 ? '?' : ''}${m[0]}=${m[1]}`)
.join('&')}${entries.length ? '&' : '?'}scrollTo=${id}`;

return href;
}, []);
Expand Down
8 changes: 7 additions & 1 deletion apps/website/src/components/docs/entities/ParameterTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ export function ParameterTable({ parameters }: { parameters: DocumentedParameter
</Paragraph>
</TableCell>
) : null}
<TableCell>{param.optional ? <CheckCircle className="text-green-500" /> : <XCircle className="text-destructive" />}</TableCell>
<TableCell>
{param.optional ? (
<CheckCircle className="text-green-500" />
) : (
<XCircle className="text-destructive" />
)}
</TableCell>
</TableRow>
))}
</TableBody>
Expand Down
5 changes: 4 additions & 1 deletion apps/website/src/components/docs/entities/Properties.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ export function Properties({ entity }: { entity: DocumentedClassProperty }) {
</Paragraph>
) : null}
<div className="my-2">
<Type types={entity.rawType || entity.type ? makeTypeParams(entity.type!) : ['any']} prefix="Type:" />
<Type
types={entity.rawType || entity.type ? makeTypeParams(entity.type!) : ['any']}
prefix="Type:"
/>
</div>
</div>
</div>
Expand Down
24 changes: 19 additions & 5 deletions apps/website/src/components/docs/entities/Type.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,16 @@ export function Type({ types, prefix }: { types: string[]; prefix?: string }) {
if (!mod) {
if (!(type in docsLink.external)) {
resolved.push(
<span key={`${i}-${type}-unresolved`} className={cn('font-semibold', ['keyof', 'typeof', ';', '{', ':'].includes(type) ? 'mr-2' : type === '|' ? 'mx-1' : '', 'text-sm')}>
<span
key={`${i}-${type}-unresolved`}
className={cn(
'font-semibold',
['keyof', 'typeof', ';', '{', ':'].includes(type) ? 'mr-2' : type === '|' ? 'mx-1' : '',
'text-sm',
)}
>
{type}
</span>
</span>,
);
continue;
}
Expand All @@ -32,17 +39,24 @@ export function Type({ types, prefix }: { types: string[]; prefix?: string }) {
target="_blank"
>
<span>{type}</span>
</Link>
</Link>,
);
} else {
resolved.push(
<Link
href={mod.href}
key={`${i}-${type}-${mod}`}
className={cn('font-semibold text-sm', mod.type === 'class' ? 'text-yellow-600' : mod.type === 'function' ? 'text-purple-600' : 'text-sky-600')}
className={cn(
'font-semibold text-sm',
mod.type === 'class'
? 'text-yellow-600'
: mod.type === 'function'
? 'text-purple-600'
: 'text-sky-600',
)}
>
<span>{mod.target}</span>
</Link>
</Link>,
);
}
}
Expand Down
5 changes: 4 additions & 1 deletion apps/website/src/components/guide/GuideItemList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ export function GuideItemList({ data, name, id, link, icon }: IProps) {
<h1
className={cn(
'text-base font-normal text-muted-foreground cursor-pointer',
item.id === decodeURIComponent(router.query.page as string) && id === decodeURIComponent(router.query.topic as string) ? 'font-medium text-secondary' : ''
item.id === decodeURIComponent(router.query.page as string) &&
id === decodeURIComponent(router.query.topic as string)
? 'font-medium text-secondary'
: '',
)}
>
{item.name}
Expand Down
Loading

0 comments on commit 875f16a

Please sign in to comment.