nuxt-discord 0.2.0 → 0.2.1
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/module.d.mts +2 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +17 -5
- package/dist/runtime/client/components/CommandCard.d.ts +29 -0
- package/dist/runtime/client/components/CommandCard.js +75 -0
- package/dist/runtime/client/components/CommandPicker.d.vue.ts +2 -2
- package/dist/runtime/client/components/CommandPicker.vue.d.ts +2 -2
- package/dist/runtime/client/components/CommandReference.vue +1 -1
- package/dist/runtime/client/components/CommandsHeading.d.ts +24 -0
- package/dist/runtime/client/components/CommandsHeading.js +17 -0
- package/dist/runtime/client/components/DashboardHeader.d.ts +32 -0
- package/dist/runtime/client/components/DashboardHeader.js +32 -0
- package/dist/runtime/client/components/ProjectLogo.d.ts +4 -0
- package/dist/runtime/client/components/ProjectLogo.js +31 -0
- package/dist/runtime/client/components/ReferenceContent.d.ts +5 -9
- package/dist/runtime/client/components/ReferenceContent.js +29 -57
- package/dist/runtime/client/components/TheHeader.vue +33 -52
- package/dist/runtime/client/pages/slash-commands.vue +28 -110
- package/dist/runtime/client/reference.css +132 -45
- package/dist/runtime/dashboard/auth.js +8 -5
- package/dist/runtime/dashboard/origin.d.ts +0 -1
- package/dist/runtime/dashboard/origin.js +0 -7
- package/dist/runtime/dashboard/signin.d.ts +1 -1
- package/dist/runtime/dashboard/signin.js +4 -2
- package/dist/runtime/dashboard/urls.d.ts +2 -0
- package/dist/runtime/dashboard/urls.js +8 -0
- package/dist/runtime/reference/access.js +2 -1
- package/dist/runtime/reference/document.js +8 -5
- package/package.json +1 -1
- package/dist/runtime/client/components/ProjectLogo.d.vue.ts +0 -3
- package/dist/runtime/client/components/ProjectLogo.vue +0 -31
- package/dist/runtime/client/components/ProjectLogo.vue.d.ts +0 -3
package/dist/module.d.mts
CHANGED
|
@@ -241,6 +241,8 @@ interface ContextMenu {
|
|
|
241
241
|
}
|
|
242
242
|
type DiscordReferenceOptions = {
|
|
243
243
|
page?: boolean;
|
|
244
|
+
/** Origin of a separately hosted administrative dashboard, including an HTTP loopback tunnel. */
|
|
245
|
+
dashboardOrigin?: string;
|
|
244
246
|
} & ({
|
|
245
247
|
access: 'public' | 'private' | 'authenticated';
|
|
246
248
|
} | {
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -12,6 +12,7 @@ import chokidar from 'chokidar';
|
|
|
12
12
|
import { listen } from 'listhen';
|
|
13
13
|
import { rollup } from 'rollup';
|
|
14
14
|
import { WebSocketServer } from 'ws';
|
|
15
|
+
import { configuredOrigin, dashboardCommandsPath } from '../dist/runtime/dashboard/urls.js';
|
|
15
16
|
import { genSafeVariableName, genImport, genString, genArrayFromRaw } from 'knitwork';
|
|
16
17
|
|
|
17
18
|
function createContext(options, nuxt) {
|
|
@@ -822,18 +823,27 @@ function resolveReference(options) {
|
|
|
822
823
|
if (!options || !["public", "private", "authenticated", "members"].includes(options.access) || options.page !== void 0 && typeof options.page !== "boolean") {
|
|
823
824
|
throw new Error("discord.reference requires a valid access mode and an optional boolean page setting.");
|
|
824
825
|
}
|
|
825
|
-
if (Object.keys(options).some((key) => !["access", "page", "guilds"].includes(key)))
|
|
826
|
-
throw new Error("discord.reference accepts access, page and
|
|
826
|
+
if (Object.keys(options).some((key) => !["access", "page", "guilds", "dashboardOrigin"].includes(key)))
|
|
827
|
+
throw new Error("discord.reference accepts access, page, guilds and dashboardOrigin.");
|
|
828
|
+
const { dashboardOrigin } = options;
|
|
829
|
+
if (dashboardOrigin !== void 0 && (typeof dashboardOrigin !== "string" || !configuredOrigin(dashboardOrigin)))
|
|
830
|
+
throw new Error("discord.reference.dashboardOrigin must be an HTTPS origin or an HTTP loopback origin, with no path or trailing slash.");
|
|
831
|
+
const policy = { access: options.access, page: options.page ?? true, ...dashboardOrigin && { dashboardOrigin } };
|
|
827
832
|
if (options.access === "members") {
|
|
828
833
|
if (options.guilds === void 0)
|
|
829
|
-
return
|
|
834
|
+
return policy;
|
|
830
835
|
if (!Array.isArray(options.guilds) || !options.guilds.length || options.guilds.some((id) => typeof id !== "string" || !/^[1-9]\d{0,19}$/.test(id)))
|
|
831
836
|
throw new Error("discord.reference.guilds requires Discord server IDs for members access.");
|
|
832
|
-
return {
|
|
837
|
+
return { ...policy, guilds: [...new Set(options.guilds)] };
|
|
833
838
|
}
|
|
834
839
|
if ("guilds" in options)
|
|
835
840
|
throw new Error("discord.reference.guilds is used only with members access.");
|
|
836
|
-
return
|
|
841
|
+
return policy;
|
|
842
|
+
}
|
|
843
|
+
function referenceDashboardHref(options, hostedDashboard) {
|
|
844
|
+
if (options.dashboardOrigin)
|
|
845
|
+
return new URL(dashboardCommandsPath, options.dashboardOrigin).href;
|
|
846
|
+
return hostedDashboard ? dashboardCommandsPath : void 0;
|
|
837
847
|
}
|
|
838
848
|
function restricted(item) {
|
|
839
849
|
return Boolean(item.guilds || item.hasRuntimeMiddleware || item.middleware?.some((name) => name !== "cooldown" && name !== "guildOnly") || "nsfw" in item && item.nsfw || "defaultMemberPermissions" in item && item.defaultMemberPermissions != null);
|
|
@@ -954,6 +964,7 @@ function prepareTemplates(ctx) {
|
|
|
954
964
|
declare module 'discord/reference' {
|
|
955
965
|
export function getCatalog(): import('nuxt-discord').DiscordCommandReference | Promise<import('nuxt-discord').DiscordCommandReference>
|
|
956
966
|
export const policy: import('nuxt-discord').DiscordReferenceOptions
|
|
967
|
+
export const dashboardHref: string | undefined
|
|
957
968
|
export const styles: string
|
|
958
969
|
}
|
|
959
970
|
declare module 'discord/catalog' {
|
|
@@ -1442,6 +1453,7 @@ const module$1 = defineNuxtModule({
|
|
|
1442
1453
|
getContents: () => [
|
|
1443
1454
|
liveReferenceFile ? `import { readFile } from 'node:fs/promises'; export async function getCatalog() { return JSON.parse(await readFile(${JSON.stringify(liveReferenceFile)}, 'utf8')) }` : `const catalog = ${JSON.stringify(projectReference(ctx.slashCommands, ctx.contextMenus, reference.access))}; export const getCatalog = () => catalog`,
|
|
1444
1455
|
`export const policy = ${JSON.stringify(reference)}`,
|
|
1456
|
+
`export const dashboardHref = ${JSON.stringify(referenceDashboardHref(reference, hostedDashboard))}`,
|
|
1445
1457
|
`export const styles = ${JSON.stringify(readFileSync(ctx.resolve.module("runtime/client/reference.css"), "utf8"))}`
|
|
1446
1458
|
].join("\n")
|
|
1447
1459
|
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { PropType } from 'vue';
|
|
2
|
+
import type { DiscordReferenceOption } from '../../../types.js';
|
|
3
|
+
type Option = Omit<DiscordReferenceOption, 'type'> & {
|
|
4
|
+
type: number | DiscordReferenceOption['type'];
|
|
5
|
+
};
|
|
6
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
7
|
+
command: {
|
|
8
|
+
type: PropType<{
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
options: Option[];
|
|
12
|
+
}>;
|
|
13
|
+
required: true;
|
|
14
|
+
};
|
|
15
|
+
anchor: StringConstructor;
|
|
16
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
19
|
+
command: {
|
|
20
|
+
type: PropType<{
|
|
21
|
+
name: string;
|
|
22
|
+
description: string;
|
|
23
|
+
options: Option[];
|
|
24
|
+
}>;
|
|
25
|
+
required: true;
|
|
26
|
+
};
|
|
27
|
+
anchor: StringConstructor;
|
|
28
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
29
|
+
export default _default;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { defineComponent, h } from "vue";
|
|
2
|
+
const types = {
|
|
3
|
+
string: ["str", "primary"],
|
|
4
|
+
integer: ["int", "info"],
|
|
5
|
+
number: ["num", "info"],
|
|
6
|
+
boolean: ["bool", "success"],
|
|
7
|
+
user: ["user", "secondary"],
|
|
8
|
+
channel: ["chan", "warning"],
|
|
9
|
+
role: ["role", "secondary"],
|
|
10
|
+
mentionable: ["@", "secondary"],
|
|
11
|
+
attachment: ["file", "neutral"]
|
|
12
|
+
};
|
|
13
|
+
const discordTypes = {
|
|
14
|
+
3: "string",
|
|
15
|
+
4: "integer",
|
|
16
|
+
5: "boolean",
|
|
17
|
+
6: "user",
|
|
18
|
+
7: "channel",
|
|
19
|
+
8: "role",
|
|
20
|
+
9: "mentionable",
|
|
21
|
+
10: "number",
|
|
22
|
+
11: "attachment"
|
|
23
|
+
};
|
|
24
|
+
function optionChip(option) {
|
|
25
|
+
const type = typeof option.type === "number" ? discordTypes[option.type] : option.type;
|
|
26
|
+
const [label, color] = type ? types[type] : ["?", "neutral"];
|
|
27
|
+
const limits = [
|
|
28
|
+
[option.min, ">=", "Minimum"],
|
|
29
|
+
[option.max, "<=", "Maximum"],
|
|
30
|
+
[option.minLength, "len>=", "Minimum length"],
|
|
31
|
+
[option.maxLength, "len<=", "Maximum length"]
|
|
32
|
+
];
|
|
33
|
+
return h("details", { key: option.name, class: "nd-option" }, [
|
|
34
|
+
h("summary", [
|
|
35
|
+
h("span", { class: "nd-option-name" }, option.name),
|
|
36
|
+
!option.required && h("span", { "class": "nd-optional", "aria-hidden": "true" }, "?"),
|
|
37
|
+
h("span", { class: ["nd-badge", "nd-type", `nd-${color}`], title: type }, label),
|
|
38
|
+
...limits.filter(([value]) => value !== void 0).map(([value, prefix, title]) => h("span", { class: "nd-badge", title: `${title} ${value}` }, `${prefix}${value}`)),
|
|
39
|
+
option.choices?.length ? h("span", { class: "nd-badge" }, `${option.choices.length} ${option.choices.length === 1 ? "choice" : "choices"}`) : null,
|
|
40
|
+
option.hasAutocomplete && h("span", { class: "nd-badge nd-auto", title: "Autocomplete" }, "auto")
|
|
41
|
+
]),
|
|
42
|
+
h("div", { class: "nd-option-detail" }, [
|
|
43
|
+
h("p", option.description),
|
|
44
|
+
h("p", [type, option.required ? "Required" : "Optional", option.hasAutocomplete && "Autocomplete"].filter(Boolean).join(" \xB7 ")),
|
|
45
|
+
option.choices?.length ? h("p", `Choices \xB7 ${option.choices.map((choice) => choice.name).join(", ")}`) : null
|
|
46
|
+
])
|
|
47
|
+
]);
|
|
48
|
+
}
|
|
49
|
+
export default defineComponent({
|
|
50
|
+
name: "DiscordCommandCard",
|
|
51
|
+
props: {
|
|
52
|
+
command: { type: Object, required: true },
|
|
53
|
+
anchor: String
|
|
54
|
+
},
|
|
55
|
+
setup(props, { slots }) {
|
|
56
|
+
return () => {
|
|
57
|
+
const command = props.command;
|
|
58
|
+
const name = h("code", `/${command.name}`);
|
|
59
|
+
return h("article", { id: props.anchor, class: "nd-command-card" }, [
|
|
60
|
+
h("div", { class: "nd-card-header" }, [
|
|
61
|
+
h("div", { class: "nd-card-intro" }, [
|
|
62
|
+
h("div", { class: "nd-card-title" }, [
|
|
63
|
+
h("h2", props.anchor ? [h("a", { href: `#${encodeURIComponent(props.anchor)}` }, [name])] : [name]),
|
|
64
|
+
slots.badges?.()
|
|
65
|
+
]),
|
|
66
|
+
h("p", { class: "nd-description" }, command.description)
|
|
67
|
+
]),
|
|
68
|
+
slots.meta?.()
|
|
69
|
+
]),
|
|
70
|
+
command.options.length ? h("div", { class: "nd-card-options" }, command.options.map(optionChip)) : null,
|
|
71
|
+
slots.footer && h("div", { class: "nd-card-footer" }, slots.footer())
|
|
72
|
+
]);
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
});
|
|
@@ -14,11 +14,11 @@ type __VLS_Props = {
|
|
|
14
14
|
searching?: boolean;
|
|
15
15
|
};
|
|
16
16
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
17
|
-
choose: (item: PickerItem) => any;
|
|
18
17
|
highlight: (index: number) => any;
|
|
18
|
+
choose: (item: PickerItem) => any;
|
|
19
19
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
20
|
-
onChoose?: ((item: PickerItem) => any) | undefined;
|
|
21
20
|
onHighlight?: ((index: number) => any) | undefined;
|
|
21
|
+
onChoose?: ((item: PickerItem) => any) | undefined;
|
|
22
22
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
23
23
|
declare const _default: typeof __VLS_export;
|
|
24
24
|
export default _default;
|
|
@@ -14,11 +14,11 @@ type __VLS_Props = {
|
|
|
14
14
|
searching?: boolean;
|
|
15
15
|
};
|
|
16
16
|
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
17
|
-
choose: (item: PickerItem) => any;
|
|
18
17
|
highlight: (index: number) => any;
|
|
18
|
+
choose: (item: PickerItem) => any;
|
|
19
19
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
20
|
-
onChoose?: ((item: PickerItem) => any) | undefined;
|
|
21
20
|
onHighlight?: ((index: number) => any) | undefined;
|
|
21
|
+
onChoose?: ((item: PickerItem) => any) | undefined;
|
|
22
22
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
23
23
|
declare const _default: typeof __VLS_export;
|
|
24
24
|
export default _default;
|
|
@@ -10,7 +10,7 @@ defineSlots();
|
|
|
10
10
|
<template>
|
|
11
11
|
<ReferenceContent :catalog="catalog" :title="title">
|
|
12
12
|
<slot />
|
|
13
|
-
<template #command-footer="{ command }">
|
|
13
|
+
<template v-if="$slots['command-footer']" #command-footer="{ command }">
|
|
14
14
|
<slot name="command-footer" :command="command" />
|
|
15
15
|
</template>
|
|
16
16
|
</ReferenceContent>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
|
+
title: {
|
|
3
|
+
type: StringConstructor;
|
|
4
|
+
default: string;
|
|
5
|
+
};
|
|
6
|
+
count: {
|
|
7
|
+
type: NumberConstructor;
|
|
8
|
+
required: true;
|
|
9
|
+
};
|
|
10
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
13
|
+
title: {
|
|
14
|
+
type: StringConstructor;
|
|
15
|
+
default: string;
|
|
16
|
+
};
|
|
17
|
+
count: {
|
|
18
|
+
type: NumberConstructor;
|
|
19
|
+
required: true;
|
|
20
|
+
};
|
|
21
|
+
}>> & Readonly<{}>, {
|
|
22
|
+
title: string;
|
|
23
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
24
|
+
export default _default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineComponent, h } from "vue";
|
|
2
|
+
export default defineComponent({
|
|
3
|
+
name: "DiscordCommandsHeading",
|
|
4
|
+
props: {
|
|
5
|
+
title: { type: String, default: "Slash Commands" },
|
|
6
|
+
count: { type: Number, required: true }
|
|
7
|
+
},
|
|
8
|
+
setup(props, { slots }) {
|
|
9
|
+
return () => h("div", { class: "nd-commands-heading" }, [
|
|
10
|
+
h("div", [
|
|
11
|
+
h("h1", props.title),
|
|
12
|
+
h("p", `${props.count} ${props.count === 1 ? "command" : "commands"}`)
|
|
13
|
+
]),
|
|
14
|
+
slots.default?.()
|
|
15
|
+
]);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { PropType } from 'vue';
|
|
2
|
+
interface NavigationItem {
|
|
3
|
+
label: string;
|
|
4
|
+
href: string;
|
|
5
|
+
active?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
8
|
+
home: {
|
|
9
|
+
type: StringConstructor;
|
|
10
|
+
required: true;
|
|
11
|
+
};
|
|
12
|
+
items: {
|
|
13
|
+
type: PropType<NavigationItem[]>;
|
|
14
|
+
required: true;
|
|
15
|
+
};
|
|
16
|
+
hosted: BooleanConstructor;
|
|
17
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
20
|
+
home: {
|
|
21
|
+
type: StringConstructor;
|
|
22
|
+
required: true;
|
|
23
|
+
};
|
|
24
|
+
items: {
|
|
25
|
+
type: PropType<NavigationItem[]>;
|
|
26
|
+
required: true;
|
|
27
|
+
};
|
|
28
|
+
hosted: BooleanConstructor;
|
|
29
|
+
}>> & Readonly<{}>, {
|
|
30
|
+
hosted: boolean;
|
|
31
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
32
|
+
export default _default;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { defineComponent, h } from "vue";
|
|
2
|
+
import ProjectLogo from "./ProjectLogo.js";
|
|
3
|
+
export default defineComponent({
|
|
4
|
+
name: "DiscordDashboardHeader",
|
|
5
|
+
props: {
|
|
6
|
+
home: { type: String, required: true },
|
|
7
|
+
items: { type: Array, required: true },
|
|
8
|
+
hosted: Boolean
|
|
9
|
+
},
|
|
10
|
+
setup(props, { slots }) {
|
|
11
|
+
function navigation(mobile) {
|
|
12
|
+
return h("nav", { "class": mobile ? "nd-mobile-nav" : "nd-desktop-nav", "aria-label": "Dashboard" }, props.items.map((item) => {
|
|
13
|
+
const attrs = { "href": item.href, "aria-current": item.active ? "page" : void 0 };
|
|
14
|
+
return slots.link?.({ attrs, label: item.label }) ?? h("a", attrs, item.label);
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
return () => h("header", { class: ["nd-header", { "nd-header-hosted": props.hosted }] }, [
|
|
18
|
+
h("a", { class: "nd-skip", href: "#discord-main" }, "Skip to content"),
|
|
19
|
+
h("div", { class: "nd-header-row" }, [
|
|
20
|
+
h("div", { class: "nd-header-start" }, [
|
|
21
|
+
h("a", { class: "nd-brand", href: props.home }, [
|
|
22
|
+
h(ProjectLogo, { "width": 32, "height": 32, "aria-hidden": "true" }),
|
|
23
|
+
h("span", "nuxt-discord")
|
|
24
|
+
]),
|
|
25
|
+
navigation(false)
|
|
26
|
+
]),
|
|
27
|
+
h("div", { class: "nd-header-actions" }, slots.default?.())
|
|
28
|
+
]),
|
|
29
|
+
navigation(true)
|
|
30
|
+
]);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
4
|
+
export default _default;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineComponent, h, useId } from "vue";
|
|
2
|
+
export default defineComponent({
|
|
3
|
+
name: "ProjectLogo",
|
|
4
|
+
setup() {
|
|
5
|
+
const seamMask = useId();
|
|
6
|
+
return () => h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "8 5.5 84 84", width: "84", height: "84" }, [
|
|
7
|
+
h("title", "Nuxt Discord"),
|
|
8
|
+
h("defs", [
|
|
9
|
+
h("mask", { id: seamMask, maskUnits: "userSpaceOnUse", x: "8", y: "5.5", width: "84", height: "84" }, [
|
|
10
|
+
h("rect", { x: "8", y: "5.5", width: "84", height: "84", fill: "white" }),
|
|
11
|
+
h("g", { transform: "translate(1.3 -.65) scale(.97) translate(6.32 3.64) scale(.94155)", fill: "black" }, [
|
|
12
|
+
h("path", { d: "M10 45.4C25.8 37.9 39.4 36.4 47.7 39.7 52.1 41.5 55.5 45.1 57.8 48.1Q58.2 48.7 57.6 49 57.2 49.2 56.8 48.7C54.2 45.9 50.8 43 47 41.6 38.9 38.5 26 41.1 10 49.7Z" }),
|
|
13
|
+
h("path", { d: "M57 19C62 23.4 66.6 30.5 67.05 37Q67.1 37.7 66.55 37.7 66.1 37.7 65.95 37.2C65.1 32.4 63.84 28.44 60.2 25.5Q56.8 22.75 53.9 19Z" })
|
|
14
|
+
])
|
|
15
|
+
])
|
|
16
|
+
]),
|
|
17
|
+
h("g", { mask: `url(#${seamMask})` }, [
|
|
18
|
+
h("path", { fill: "#00dc82", style: "fill: light-dark(#00b574, #00dc82)", d: "M54.49 87.24C54.49 87.24 82.18 87.24 82.18 87.24 C83.06 87.24 83.91 86.93 84.67 86.49 C85.44 86.05 86.23 85.5 86.67 84.74 C87.11 83.98 87.42 83.12 87.42 82.25 C87.41 81.37 87.11 80.51 86.67 79.75 C86.67 79.75 67.96 47.58 67.96 47.58 C67.52 46.82 66.98 46.27 66.21 45.83 C65.45 45.39 64.35 45.08 63.47 45.08 C62.59 45.08 61.74 45.39 60.98 45.83 C60.21 46.27 59.67 46.82 59.23 47.58 C59.23 47.58 54.49 55.81 54.49 55.81 C54.49 55.81 45.01 39.84 45.01 39.84 C44.57 39.09 44.03 38.29 43.27 37.85 C42.5 37.41 41.65 37.35 40.77 37.35 C39.89 37.35 39.04 37.41 38.28 37.85 C37.51 38.29 36.72 39.09 36.28 39.84 C36.28 39.84 13.08 79.75 13.08 79.75 C12.64 80.51 12.59 81.37 12.58 82.25 C12.58 83.12 12.64 83.98 13.08 84.74 C13.53 85.5 14.31 86.05 15.08 86.49 C15.84 86.93 16.69 87.24 17.57 87.24 C17.57 87.24 35.03 87.24 35.03 87.24 C41.95 87.24 46.99 84.13 50.5 78.26 C50.5 78.26 58.98 63.54 58.98 63.54 C58.98 63.54 63.47 55.81 63.47 55.81 C63.47 55.81 77.19 79.26 77.19 79.26 C77.19 79.26 58.98 79.26 58.98 79.26 C58.98 79.26 54.49 87.24 54.49 87.24 C54.49 87.24 54.49 87.24 54.49 87.24 ZM34.78 79.26C34.78 79.26 22.56 79.26 22.56 79.26 C22.56 79.26 40.77 47.83 40.77 47.83 C40.77 47.83 50 63.54 50 63.54 C50 63.54 43.89 74.2 43.89 74.2 C41.56 78.01 38.9 79.26 34.78 79.26 C34.78 79.26 34.78 79.26 34.78 79.26 Z" }),
|
|
19
|
+
h("g", { transform: "translate(1.3 -.65) scale(.97)", fill: "#5865f2" }, [
|
|
20
|
+
h("g", { transform: "translate(6.32 3.64) scale(.94155)" }, [
|
|
21
|
+
h("path", { d: "M16.47 44.22C8 38.17 3.87 8.84 23.24 8.84 C40.6 8.84 53.4 20 60.2 25.5 C62.3 27.2 63.6 27.8 66.8 27.7 C74.1 27.7 79.7 28.4 81.5 32.4 C84.9 40 72.9 46.5 58.7 50C55.9 53.6 54.1 55.5 50.9 55.1 C40.6 53.1 30.4 46.2 12.4 54.1 Q10.2 55.1 10.9 52.9 Q12.3 48.3 16.47 44.22Z" })
|
|
22
|
+
]),
|
|
23
|
+
h("g", { fill: "#fff" }, [
|
|
24
|
+
h("path", { d: "M23.78 24.8C25.16 24.39 26.8 25.77 27.44 27.9 C28.09 30.02 27.49 32.08 26.12 32.5 C24.75 32.92 23.11 31.53 22.46 29.41 C21.82 27.29 22.41 25.22 23.78 24.8 Z" }),
|
|
25
|
+
h("path", { d: "M31.25 26.36C30.22 24.37 30.53 22.17 31.93 21.45 C33.33 20.73 35.3 21.76 36.32 23.74 C37.35 25.73 37.04 27.93 35.64 28.65 C34.24 29.38 32.27 28.35 31.25 26.36 Z" })
|
|
26
|
+
])
|
|
27
|
+
])
|
|
28
|
+
])
|
|
29
|
+
]);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
@@ -5,10 +5,8 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
5
5
|
type: PropType<DiscordCommandReference>;
|
|
6
6
|
required: true;
|
|
7
7
|
};
|
|
8
|
-
title:
|
|
9
|
-
|
|
10
|
-
default: string;
|
|
11
|
-
};
|
|
8
|
+
title: StringConstructor;
|
|
9
|
+
standalone: BooleanConstructor;
|
|
12
10
|
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
13
11
|
[key: string]: any;
|
|
14
12
|
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
@@ -16,11 +14,9 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
16
14
|
type: PropType<DiscordCommandReference>;
|
|
17
15
|
required: true;
|
|
18
16
|
};
|
|
19
|
-
title:
|
|
20
|
-
|
|
21
|
-
default: string;
|
|
22
|
-
};
|
|
17
|
+
title: StringConstructor;
|
|
18
|
+
standalone: BooleanConstructor;
|
|
23
19
|
}>> & Readonly<{}>, {
|
|
24
|
-
|
|
20
|
+
standalone: boolean;
|
|
25
21
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
26
22
|
export default _default;
|
|
@@ -1,73 +1,45 @@
|
|
|
1
1
|
import { defineComponent, h } from "vue";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function optionRow(option) {
|
|
6
|
-
const limits = [];
|
|
7
|
-
if (option.min !== void 0)
|
|
8
|
-
limits.push(`Minimum ${option.min}`);
|
|
9
|
-
if (option.max !== void 0)
|
|
10
|
-
limits.push(`Maximum ${option.max}`);
|
|
11
|
-
if (option.minLength !== void 0)
|
|
12
|
-
limits.push(`Minimum length ${option.minLength}`);
|
|
13
|
-
if (option.maxLength !== void 0)
|
|
14
|
-
limits.push(`Maximum length ${option.maxLength}`);
|
|
15
|
-
if (option.hasAutocomplete)
|
|
16
|
-
limits.push("Autocomplete");
|
|
17
|
-
return h("div", { key: option.name, class: "ref-option" }, [
|
|
18
|
-
h("dt", [
|
|
19
|
-
h("code", option.name),
|
|
20
|
-
" ",
|
|
21
|
-
h("small", `${option.type} \xB7 ${option.required ? "Required" : "Optional"}`)
|
|
22
|
-
]),
|
|
23
|
-
h("dd", [
|
|
24
|
-
option.description,
|
|
25
|
-
limits.length ? h("span", { class: "ref-meta" }, limits.join(" \xB7 ")) : null,
|
|
26
|
-
option.choices?.length ? h("span", { class: "ref-meta" }, `Choices \xB7 ${option.choices.map((choice) => choice.name).join(", ")}`) : null
|
|
27
|
-
])
|
|
28
|
-
]);
|
|
29
|
-
}
|
|
2
|
+
import CommandCard from "./CommandCard.js";
|
|
3
|
+
import CommandsHeading from "./CommandsHeading.js";
|
|
4
|
+
import DashboardHeader from "./DashboardHeader.js";
|
|
30
5
|
export default defineComponent({
|
|
31
6
|
name: "DiscordReferenceContent",
|
|
32
7
|
props: {
|
|
33
8
|
catalog: { type: Object, required: true },
|
|
34
|
-
title:
|
|
9
|
+
title: String,
|
|
10
|
+
standalone: Boolean
|
|
35
11
|
},
|
|
36
12
|
setup(props, { slots }) {
|
|
37
|
-
function
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
);
|
|
41
|
-
if (props.catalog.menus.length)
|
|
42
|
-
links.push(h("li", { key: "context-menus-link" }, [h("a", { href: "#context-menus" }, "Context menus")]));
|
|
43
|
-
return h("nav", { "class": "ref-nav", "aria-label": "On this page" }, [h("p", "On this page"), h("ul", links)]);
|
|
44
|
-
}
|
|
45
|
-
function commandSection(cmd) {
|
|
46
|
-
return h("section", { key: cmd.name, class: "ref-command" }, [
|
|
47
|
-
h("h3", { id: commandId(cmd.name) }, [h("code", `/${cmd.name}`)]),
|
|
48
|
-
h("p", cmd.description),
|
|
49
|
-
cmd.options.length ? h("dl", cmd.options.map(optionRow)) : null,
|
|
50
|
-
slots["command-footer"]?.({ command: cmd })
|
|
51
|
-
]);
|
|
13
|
+
function commandCard(command) {
|
|
14
|
+
const footer = slots["command-footer"];
|
|
15
|
+
return h(CommandCard, { key: command.name, command, anchor: `command-${command.name.replaceAll(" ", "/")}` }, footer && { footer: () => footer({ command }) });
|
|
52
16
|
}
|
|
53
17
|
function menuSection() {
|
|
54
|
-
return h("section", [
|
|
55
|
-
h("h2",
|
|
56
|
-
h("dl", props.catalog.menus.map((menu) => h("div", { key: `${menu.type}:${menu.name}`, class: "
|
|
18
|
+
return h("section", { class: "nd-menus", id: "context-menus" }, [
|
|
19
|
+
h("h2", "Context Menus"),
|
|
20
|
+
h("dl", props.catalog.menus.map((menu) => h("div", { key: `${menu.type}:${menu.name}`, class: "nd-command-card nd-menu" }, [
|
|
57
21
|
h("dt", menu.name),
|
|
58
22
|
h("dd", `Open the Apps menu on a ${menu.type}.`)
|
|
59
23
|
])))
|
|
60
24
|
]);
|
|
61
25
|
}
|
|
62
|
-
return () =>
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
26
|
+
return () => {
|
|
27
|
+
const { catalog, standalone } = props;
|
|
28
|
+
const items = [{ label: "Commands", href: "#discord-main", active: true }];
|
|
29
|
+
if (catalog.menus.length)
|
|
30
|
+
items.push({ label: "Context Menus", href: "#context-menus", active: false });
|
|
31
|
+
const content = [
|
|
32
|
+
h(CommandsHeading, { title: props.title ?? (standalone ? "Slash Commands" : "Command reference"), count: catalog.commands.length }),
|
|
33
|
+
!standalone && slots.default?.(),
|
|
34
|
+
h("hr", { class: "nd-divider" }),
|
|
35
|
+
...catalog.commands.map(commandCard),
|
|
36
|
+
!catalog.commands.length && h("p", { class: "nd-empty" }, "No commands yet"),
|
|
37
|
+
catalog.menus.length ? menuSection() : null
|
|
38
|
+
];
|
|
39
|
+
return standalone ? h("div", { class: "nd-reference-page" }, [
|
|
40
|
+
h(DashboardHeader, { home: "#discord-main", items }, { default: () => [slots["admin-entry"]?.(), slots.default?.()] }),
|
|
41
|
+
h("main", { id: "discord-main", class: "discord-reference", tabindex: -1 }, content)
|
|
42
|
+
]) : h("article", { class: "discord-reference" }, content);
|
|
43
|
+
};
|
|
72
44
|
}
|
|
73
45
|
});
|
|
@@ -1,62 +1,43 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
+
import { computed } from "vue";
|
|
2
3
|
import { useRoute } from "#imports";
|
|
3
4
|
import { appearanceSelect } from "./appearance-select";
|
|
4
|
-
import
|
|
5
|
+
import DashboardHeader from "./DashboardHeader";
|
|
5
6
|
const route = useRoute();
|
|
6
7
|
const hosted = !import.meta.dev;
|
|
7
|
-
const nav = [
|
|
8
|
-
{ label: "Overview",
|
|
9
|
-
{ label: "Commands",
|
|
10
|
-
{ label: "Context Menus",
|
|
11
|
-
{ label: "Listeners",
|
|
12
|
-
{ label: "Activity",
|
|
13
|
-
];
|
|
8
|
+
const nav = computed(() => [
|
|
9
|
+
{ label: "Overview", href: "/discord" },
|
|
10
|
+
{ label: "Commands", href: "/discord/slash-commands" },
|
|
11
|
+
{ label: "Context Menus", href: "/discord/context-menus" },
|
|
12
|
+
{ label: "Listeners", href: "/discord/listeners" },
|
|
13
|
+
{ label: "Activity", href: "/discord/activity" }
|
|
14
|
+
].map((item) => ({ ...item, active: route.path === item.href })));
|
|
14
15
|
</script>
|
|
15
16
|
|
|
16
17
|
<template>
|
|
17
|
-
<
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<NuxtLink to="/discord" class="flex items-center gap-2.5">
|
|
22
|
-
<ProjectLogo width="32" height="32" aria-hidden="true" class="shrink-0" />
|
|
23
|
-
<span class="text-sm font-semibold tracking-tight">nuxt-discord</span>
|
|
24
|
-
</NuxtLink>
|
|
25
|
-
|
|
26
|
-
<nav class="hidden items-center gap-1" :class="hosted ? 'md:flex' : 'sm:flex'">
|
|
27
|
-
<NuxtLink
|
|
28
|
-
v-for="item in nav"
|
|
29
|
-
:key="item.to"
|
|
30
|
-
:to="item.to"
|
|
31
|
-
class="px-2.5 py-1 text-xs font-medium rounded-md transition-colors"
|
|
32
|
-
:class="route.path === item.to ? 'text-highlighted bg-elevated' : 'text-muted hover:text-highlighted hover:bg-elevated/50'"
|
|
33
|
-
>
|
|
34
|
-
{{ item.label }}
|
|
35
|
-
</NuxtLink>
|
|
36
|
-
</nav>
|
|
37
|
-
</div>
|
|
38
|
-
|
|
39
|
-
<div class="flex items-center gap-1">
|
|
40
|
-
<UColorModeSelect v-bind="appearanceSelect" />
|
|
41
|
-
<a
|
|
42
|
-
href="https://github.com/zojize/nuxt-discord"
|
|
43
|
-
target="_blank"
|
|
44
|
-
title="View on GitHub"
|
|
45
|
-
class="flex size-8 cursor-pointer items-center justify-center rounded-md text-muted transition-colors hover:bg-elevated hover:text-highlighted"
|
|
46
|
-
>
|
|
47
|
-
<UIcon name="i-simple-icons-github" class="size-4" />
|
|
48
|
-
</a>
|
|
49
|
-
<form v-if="hosted" method="post" action="/__discord-auth/logout">
|
|
50
|
-
<button type="submit" class="min-h-11 cursor-pointer rounded-md px-2 text-sm font-medium text-muted hover:bg-elevated hover:text-highlighted focus-visible:outline-2 focus-visible:outline-primary">
|
|
51
|
-
Sign out
|
|
52
|
-
</button>
|
|
53
|
-
</form>
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
<nav aria-label="Dashboard" class="flex gap-3 overflow-x-auto border-t border-default px-4 py-2 text-sm" :class="hosted ? 'md:hidden' : 'sm:hidden'">
|
|
57
|
-
<NuxtLink v-for="item in nav" :key="item.to" :to="item.to" class="shrink-0" exact-active-class="font-bold">
|
|
58
|
-
{{ item.label }}
|
|
18
|
+
<DashboardHeader home="/discord" :items="nav" :hosted="hosted">
|
|
19
|
+
<template #link="{ attrs, label }">
|
|
20
|
+
<NuxtLink :to="attrs.href" :aria-current="attrs['aria-current']">
|
|
21
|
+
{{ label }}
|
|
59
22
|
</NuxtLink>
|
|
60
|
-
</
|
|
61
|
-
|
|
23
|
+
</template>
|
|
24
|
+
<UColorModeSelect v-bind="appearanceSelect" />
|
|
25
|
+
<a
|
|
26
|
+
href="https://github.com/zojize/nuxt-discord"
|
|
27
|
+
target="_blank"
|
|
28
|
+
title="View on GitHub"
|
|
29
|
+
class="flex size-8 cursor-pointer items-center justify-center rounded-md text-muted transition-colors hover:bg-elevated hover:text-highlighted"
|
|
30
|
+
>
|
|
31
|
+
<UIcon name="i-simple-icons-github" class="size-4" />
|
|
32
|
+
</a>
|
|
33
|
+
<form v-if="hosted" method="post" action="/__discord-auth/logout">
|
|
34
|
+
<button type="submit" class="min-h-11 cursor-pointer rounded-md px-2 text-sm font-medium text-muted hover:bg-elevated hover:text-highlighted focus-visible:outline-2 focus-visible:outline-primary">
|
|
35
|
+
Sign out
|
|
36
|
+
</button>
|
|
37
|
+
</form>
|
|
38
|
+
</DashboardHeader>
|
|
62
39
|
</template>
|
|
40
|
+
|
|
41
|
+
<style src="../reference.css">
|
|
42
|
+
|
|
43
|
+
</style>
|
|
@@ -1,33 +1,10 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed, ref, useFetch } from "#imports";
|
|
3
|
+
import CommandCard from "../components/CommandCard";
|
|
4
|
+
import CommandsHeading from "../components/CommandsHeading";
|
|
3
5
|
import CommandTestBar from "../components/CommandTestBar.vue";
|
|
4
6
|
import TheHeader from "../components/TheHeader.vue";
|
|
5
7
|
import { useCommandRegistry } from "../useCommandRegistry";
|
|
6
|
-
var ApplicationCommandOptionType = /* @__PURE__ */ ((ApplicationCommandOptionType2) => {
|
|
7
|
-
ApplicationCommandOptionType2[ApplicationCommandOptionType2["Subcommand"] = 1] = "Subcommand";
|
|
8
|
-
ApplicationCommandOptionType2[ApplicationCommandOptionType2["SubcommandGroup"] = 2] = "SubcommandGroup";
|
|
9
|
-
ApplicationCommandOptionType2[ApplicationCommandOptionType2["String"] = 3] = "String";
|
|
10
|
-
ApplicationCommandOptionType2[ApplicationCommandOptionType2["Integer"] = 4] = "Integer";
|
|
11
|
-
ApplicationCommandOptionType2[ApplicationCommandOptionType2["Boolean"] = 5] = "Boolean";
|
|
12
|
-
ApplicationCommandOptionType2[ApplicationCommandOptionType2["User"] = 6] = "User";
|
|
13
|
-
ApplicationCommandOptionType2[ApplicationCommandOptionType2["Channel"] = 7] = "Channel";
|
|
14
|
-
ApplicationCommandOptionType2[ApplicationCommandOptionType2["Role"] = 8] = "Role";
|
|
15
|
-
ApplicationCommandOptionType2[ApplicationCommandOptionType2["Mentionable"] = 9] = "Mentionable";
|
|
16
|
-
ApplicationCommandOptionType2[ApplicationCommandOptionType2["Number"] = 10] = "Number";
|
|
17
|
-
ApplicationCommandOptionType2[ApplicationCommandOptionType2["Attachment"] = 11] = "Attachment";
|
|
18
|
-
return ApplicationCommandOptionType2;
|
|
19
|
-
})(ApplicationCommandOptionType || {});
|
|
20
|
-
const typeConfig = {
|
|
21
|
-
[3 /* String */]: { label: "str", color: "primary" },
|
|
22
|
-
[4 /* Integer */]: { label: "int", color: "info" },
|
|
23
|
-
[10 /* Number */]: { label: "num", color: "info" },
|
|
24
|
-
[5 /* Boolean */]: { label: "bool", color: "success" },
|
|
25
|
-
[6 /* User */]: { label: "user", color: "secondary" },
|
|
26
|
-
[7 /* Channel */]: { label: "chan", color: "warning" },
|
|
27
|
-
[8 /* Role */]: { label: "role", color: "secondary" },
|
|
28
|
-
[9 /* Mentionable */]: { label: "@", color: "secondary" },
|
|
29
|
-
[11 /* Attachment */]: { label: "file", color: "neutral" }
|
|
30
|
-
};
|
|
31
8
|
function getRemoteId(command) {
|
|
32
9
|
if ("remote" in command && command.remote?.id)
|
|
33
10
|
return command.remote.id;
|
|
@@ -97,20 +74,6 @@ const statusMeta = {
|
|
|
97
74
|
removed: { color: "neutral", classes: "border-dashed border-neutral-400/40 opacity-60" },
|
|
98
75
|
conflict: { color: "error", classes: "border-dashed border-red-500/40" }
|
|
99
76
|
};
|
|
100
|
-
function constraintBadges(option) {
|
|
101
|
-
const badges = [];
|
|
102
|
-
if ("min" in option && option.min !== void 0)
|
|
103
|
-
badges.push(`>=${option.min}`);
|
|
104
|
-
if ("max" in option && option.max !== void 0)
|
|
105
|
-
badges.push(`<=${option.max}`);
|
|
106
|
-
if ("minLength" in option && option.minLength !== void 0)
|
|
107
|
-
badges.push(`len>=${option.minLength}`);
|
|
108
|
-
if ("maxLength" in option && option.maxLength !== void 0)
|
|
109
|
-
badges.push(`len<=${option.maxLength}`);
|
|
110
|
-
if ("choices" in option && option.choices?.length)
|
|
111
|
-
badges.push(`${option.choices.length} choices`);
|
|
112
|
-
return badges;
|
|
113
|
-
}
|
|
114
77
|
</script>
|
|
115
78
|
|
|
116
79
|
<template>
|
|
@@ -118,16 +81,7 @@ function constraintBadges(option) {
|
|
|
118
81
|
<TheHeader />
|
|
119
82
|
|
|
120
83
|
<main id="discord-main" tabindex="-1" class="mx-auto px-6 py-8 pb-24 max-w-6xl">
|
|
121
|
-
|
|
122
|
-
<div class="mb-8 flex items-start justify-between">
|
|
123
|
-
<div>
|
|
124
|
-
<h1 class="text-2xl tracking-tight font-bold">
|
|
125
|
-
Slash Commands
|
|
126
|
-
</h1>
|
|
127
|
-
<p class="text-muted text-sm mt-1">
|
|
128
|
-
{{ commandsWithStatus.length }} command{{ commandsWithStatus.length === 1 ? "" : "s" }}
|
|
129
|
-
</p>
|
|
130
|
-
</div>
|
|
84
|
+
<CommandsHeading :count="commandsWithStatus.length">
|
|
131
85
|
<UButton
|
|
132
86
|
v-if="canManage && !allSynced"
|
|
133
87
|
label="Sync to Discord"
|
|
@@ -139,7 +93,7 @@ function constraintBadges(option) {
|
|
|
139
93
|
:disabled="stats.conflict > 0"
|
|
140
94
|
@click="syncCommands"
|
|
141
95
|
/>
|
|
142
|
-
</
|
|
96
|
+
</CommandsHeading>
|
|
143
97
|
|
|
144
98
|
<div role="status" aria-atomic="true">
|
|
145
99
|
<p v-if="syncFeedback" class="mb-3 border-s-2 ps-3 text-sm" :class="syncFeedback.failed ? 'border-error' : 'border-success'">
|
|
@@ -169,75 +123,39 @@ function constraintBadges(option) {
|
|
|
169
123
|
|
|
170
124
|
<!-- Commands -->
|
|
171
125
|
<div v-if="sortedCommands.length > 0" class="space-y-3">
|
|
172
|
-
<
|
|
126
|
+
<CommandCard
|
|
173
127
|
v-for="command in sortedCommands"
|
|
174
128
|
:key="command.scope + command.name"
|
|
175
|
-
|
|
129
|
+
:command="command"
|
|
176
130
|
:class="statusMeta[command.status].classes"
|
|
177
|
-
:ui="command.options.length === 0 ? { body: 'hidden' } : {}"
|
|
178
131
|
>
|
|
179
|
-
<template #
|
|
180
|
-
<
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
<UBadge v-if="'nsfw' in command && command.nsfw" label="nsfw" color="error" variant="soft" size="xs" />
|
|
192
|
-
<UBadge v-if="'guilds' in command && command.guilds" :label="command.guilds === true ? 'guild' : `guild: ${Array.isArray(command.guilds) ? command.guilds.length : 1}`" color="warning" variant="soft" size="xs" />
|
|
193
|
-
<UBadge v-if="'contexts' in command && command.contexts?.length === 1" label="no DM" color="neutral" variant="outline" size="xs" />
|
|
194
|
-
<UBadge v-if="'defaultMemberPermissions' in command && command.defaultMemberPermissions" label="restricted" color="warning" variant="outline" size="xs" :title="`permissions: ${command.defaultMemberPermissions}`" />
|
|
195
|
-
</div>
|
|
196
|
-
<p class="text-muted text-sm mt-1">
|
|
197
|
-
{{ command.description }}
|
|
198
|
-
</p>
|
|
199
|
-
</div>
|
|
200
|
-
|
|
201
|
-
<div class="pt-0.5 flex shrink-0 flex-wrap gap-1.5 items-center">
|
|
202
|
-
<UBadge
|
|
203
|
-
v-if="'subcommands' in command && (command.subcommands?.length ?? 0) > 0"
|
|
204
|
-
:label="`${command.subcommands.length} sub`"
|
|
205
|
-
color="info" variant="soft" size="xs"
|
|
206
|
-
/>
|
|
207
|
-
<UBadge
|
|
208
|
-
v-if="getRemoteId(command)"
|
|
209
|
-
label="registered" color="success" variant="soft" size="xs"
|
|
210
|
-
:title="`ID: ${getRemoteId(command)}`"
|
|
211
|
-
/>
|
|
212
|
-
</div>
|
|
213
|
-
</div>
|
|
132
|
+
<template #badges>
|
|
133
|
+
<span v-if="command.scope" class="text-xs text-muted">{{ command.scope }}</span>
|
|
134
|
+
<UBadge
|
|
135
|
+
:color="statusMeta[command.status].color"
|
|
136
|
+
variant="subtle"
|
|
137
|
+
size="xs"
|
|
138
|
+
:label="command.status"
|
|
139
|
+
/>
|
|
140
|
+
<UBadge v-if="'nsfw' in command && command.nsfw" label="nsfw" color="error" variant="soft" size="xs" />
|
|
141
|
+
<UBadge v-if="'guilds' in command && command.guilds" :label="command.guilds === true ? 'guild' : `guild: ${Array.isArray(command.guilds) ? command.guilds.length : 1}`" color="warning" variant="soft" size="xs" />
|
|
142
|
+
<UBadge v-if="'contexts' in command && command.contexts?.length === 1" label="no DM" color="neutral" variant="outline" size="xs" />
|
|
143
|
+
<UBadge v-if="'defaultMemberPermissions' in command && command.defaultMemberPermissions" label="restricted" color="warning" variant="outline" size="xs" :title="`permissions: ${command.defaultMemberPermissions}`" />
|
|
214
144
|
</template>
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
<div v-if="command.options.length > 0" class="flex flex-wrap gap-2">
|
|
218
|
-
<div
|
|
219
|
-
v-for="option in command.options"
|
|
220
|
-
:key="option.name"
|
|
221
|
-
:title="option.description || option.name"
|
|
222
|
-
class="border-default bg-elevated text-xs px-2.5 py-1.5 border rounded-md flex gap-1.5 items-center cursor-default"
|
|
223
|
-
>
|
|
224
|
-
<span class="font-medium">{{ option.name }}</span>
|
|
225
|
-
<span v-if="!option.required" class="text-dimmed">?</span>
|
|
145
|
+
<template #meta>
|
|
146
|
+
<div class="pt-0.5 flex shrink-0 flex-wrap gap-1.5 items-center">
|
|
226
147
|
<UBadge
|
|
227
|
-
|
|
228
|
-
:
|
|
229
|
-
variant="
|
|
148
|
+
v-if="'subcommands' in command && (command.subcommands?.length ?? 0) > 0"
|
|
149
|
+
:label="`${command.subcommands.length} sub`"
|
|
150
|
+
color="info" variant="soft" size="xs"
|
|
230
151
|
/>
|
|
231
152
|
<UBadge
|
|
232
|
-
v-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
<UBadge
|
|
236
|
-
v-if="option.hasAutocomplete"
|
|
237
|
-
label="auto" color="info" variant="outline" size="xs"
|
|
153
|
+
v-if="getRemoteId(command)"
|
|
154
|
+
label="registered" color="success" variant="soft" size="xs"
|
|
155
|
+
:title="`ID: ${getRemoteId(command)}`"
|
|
238
156
|
/>
|
|
239
157
|
</div>
|
|
240
|
-
</
|
|
158
|
+
</template>
|
|
241
159
|
|
|
242
160
|
<template v-if="showEditorLinks && command.path || getRemoteId(command)" #footer>
|
|
243
161
|
<div class="text-dimmed text-xs flex items-center justify-between">
|
|
@@ -245,7 +163,7 @@ function constraintBadges(option) {
|
|
|
245
163
|
<span v-if="getRemoteId(command)" class="font-mono shrink-0">{{ getRemoteId(command) }}</span>
|
|
246
164
|
</div>
|
|
247
165
|
</template>
|
|
248
|
-
</
|
|
166
|
+
</CommandCard>
|
|
249
167
|
</div>
|
|
250
168
|
|
|
251
169
|
<!-- Empty state -->
|
|
@@ -1,46 +1,133 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
--
|
|
4
|
-
--
|
|
5
|
-
--
|
|
6
|
-
--
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
.
|
|
16
|
-
|
|
17
|
-
.
|
|
18
|
-
.discord-reference
|
|
19
|
-
.
|
|
20
|
-
.discord-reference
|
|
21
|
-
.discord-reference
|
|
22
|
-
.
|
|
23
|
-
.
|
|
24
|
-
.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
.
|
|
31
|
-
|
|
32
|
-
.
|
|
33
|
-
|
|
34
|
-
.
|
|
35
|
-
.
|
|
36
|
-
.
|
|
37
|
-
.
|
|
38
|
-
.
|
|
39
|
-
.
|
|
40
|
-
.
|
|
41
|
-
.
|
|
42
|
-
.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
1
|
+
/* Both the dashboard and the script-free reference use the same command view. */
|
|
2
|
+
:where(.nd-header, .discord-reference, .nd-command-card, .nd-commands-heading, .nd-reference-page) {
|
|
3
|
+
--nd-bg: var(--ui-bg, light-dark(#fff, #0f172b));
|
|
4
|
+
--nd-elevated: var(--ui-bg-elevated, light-dark(#f1f5f9, #1d293d));
|
|
5
|
+
--nd-border: var(--ui-border, light-dark(#e2e8f0, #1d293d));
|
|
6
|
+
--nd-text: var(--ui-text, light-dark(#314158, #e2e8f0));
|
|
7
|
+
--nd-strong: var(--ui-text-highlighted, light-dark(#0f172b, #fff));
|
|
8
|
+
--nd-muted: var(--ui-text-muted, light-dark(#45556c, #90a1b9));
|
|
9
|
+
}
|
|
10
|
+
html:has(.nd-reference-page) { color-scheme: light dark; background: light-dark(#fff, #0f172b); }
|
|
11
|
+
body:has(.nd-reference-page) { margin: 0; }
|
|
12
|
+
.nd-reference-page, .discord-reference {
|
|
13
|
+
color: var(--nd-text);
|
|
14
|
+
background: var(--nd-bg);
|
|
15
|
+
font: 1rem/1.5 ui-sans-serif, system-ui, sans-serif;
|
|
16
|
+
}
|
|
17
|
+
.nd-reference-page { min-height: 100vh; }
|
|
18
|
+
.discord-reference { overflow-wrap: anywhere; }
|
|
19
|
+
.nd-reference-page *, .discord-reference * { box-sizing: border-box; }
|
|
20
|
+
.discord-reference { box-sizing: border-box; max-width: 72rem; margin: auto; padding: 2rem 1.5rem 4rem; }
|
|
21
|
+
.discord-reference :where(p, h1, h2, dl, dd) { margin: 0; }
|
|
22
|
+
.nd-reference-page :where(a, button, summary):focus-visible, .discord-reference :where(a, summary):focus-visible,
|
|
23
|
+
.nd-command-card summary:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
|
|
24
|
+
.nd-header {
|
|
25
|
+
position: sticky; inset-block-start: 0; z-index: 50;
|
|
26
|
+
border-bottom: 1px solid var(--nd-border);
|
|
27
|
+
background: color-mix(in srgb, var(--nd-bg) 80%, transparent);
|
|
28
|
+
backdrop-filter: blur(24px);
|
|
29
|
+
}
|
|
30
|
+
.nd-header-row {
|
|
31
|
+
box-sizing: border-box; display: flex; align-items: center; justify-content: space-between;
|
|
32
|
+
height: 3.5rem; max-width: 72rem; padding-inline: 1.5rem; margin-inline: auto;
|
|
33
|
+
}
|
|
34
|
+
.nd-header-start, .nd-brand, .nd-header-actions, .nd-desktop-nav { display: flex; align-items: center; }
|
|
35
|
+
.nd-header-start { gap: 1.5rem; }
|
|
36
|
+
.nd-brand { gap: .625rem; font-size: .875rem; font-weight: 600; letter-spacing: -.025em; white-space: nowrap; }
|
|
37
|
+
.nd-header :where(.nd-brand, nav a, .ref-admin-entry) { color: inherit; text-decoration: none; }
|
|
38
|
+
.nd-brand svg { flex: none; }
|
|
39
|
+
.nd-header-actions, .nd-desktop-nav { gap: .25rem; }
|
|
40
|
+
.nd-skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
|
|
41
|
+
.nd-skip:focus { position: absolute; z-index: 1; padding: .5rem; background: var(--nd-bg); color: var(--nd-strong); }
|
|
42
|
+
.nd-desktop-nav a {
|
|
43
|
+
padding: .25rem .625rem; border-radius: .375rem; color: var(--nd-muted);
|
|
44
|
+
font-size: .75rem; line-height: 1rem; font-weight: 500;
|
|
45
|
+
}
|
|
46
|
+
.nd-desktop-nav a:is(:hover, [aria-current=page]), .nd-header-actions :is(.ref-admin-entry, form button):hover {
|
|
47
|
+
color: var(--nd-strong); background: var(--nd-elevated);
|
|
48
|
+
}
|
|
49
|
+
.nd-mobile-nav { display: none; }
|
|
50
|
+
.nd-mobile-nav a { flex: none; }
|
|
51
|
+
.nd-mobile-nav a[aria-current=page] { font-weight: 700; }
|
|
52
|
+
.nd-header-actions :where(.ref-admin-entry, form button) {
|
|
53
|
+
display: inline-flex; align-items: center; min-height: 2.75rem; padding: .25rem .5rem;
|
|
54
|
+
color: var(--nd-muted); background: none; border: 0; border-radius: .375rem; cursor: pointer;
|
|
55
|
+
font: inherit; font-size: .875rem; font-weight: 500; white-space: nowrap;
|
|
56
|
+
}
|
|
57
|
+
@media (max-width: 22.5rem) {
|
|
58
|
+
.nd-header-row { padding-inline: .75rem; }
|
|
59
|
+
.nd-header-actions :where(.ref-admin-entry, form button) { padding-inline: .25rem; }
|
|
60
|
+
}
|
|
61
|
+
@media (max-width: 39.999rem) {
|
|
62
|
+
.nd-header { --nd-desktop-display: none; --nd-mobile-display: flex; }
|
|
63
|
+
}
|
|
64
|
+
@media (max-width: 47.999rem) {
|
|
65
|
+
.nd-header-hosted { --nd-desktop-display: none; --nd-mobile-display: flex; }
|
|
66
|
+
}
|
|
67
|
+
.nd-desktop-nav { display: var(--nd-desktop-display, flex); }
|
|
68
|
+
.nd-mobile-nav {
|
|
69
|
+
display: var(--nd-mobile-display, none); gap: .75rem; overflow-x: auto; padding: .5rem 1rem;
|
|
70
|
+
border-top: 1px solid var(--nd-border); font-size: .875rem; line-height: 1.25rem;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.nd-commands-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 2rem; }
|
|
74
|
+
.nd-commands-heading h1 { margin: 0; font-size: 1.5rem; line-height: 2rem; font-weight: 700; letter-spacing: -.025em; }
|
|
75
|
+
.nd-commands-heading p, .nd-description, .nd-menu dd { margin: .25rem 0 0; color: var(--nd-muted); font-size: .875rem; line-height: 1.25rem; }
|
|
76
|
+
.nd-divider { border: 0; border-top: 1px solid var(--nd-border); margin: 0 0 2rem; }
|
|
77
|
+
:where(.nd-command-card) {
|
|
78
|
+
color: var(--nd-text); background: var(--nd-bg); border: 1px solid var(--nd-border); border-radius: .5rem;
|
|
79
|
+
}
|
|
80
|
+
.nd-command-card, .nd-menus, .nd-reference-page main { scroll-margin-top: 7rem; }
|
|
81
|
+
.discord-reference .nd-command-card + .nd-command-card { margin-top: .75rem; }
|
|
82
|
+
.nd-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
|
|
83
|
+
.nd-card-header, .nd-card-footer, .nd-menu { padding: 1rem; }
|
|
84
|
+
.nd-card-options, .nd-card-footer { border-top: 1px solid var(--nd-border); }
|
|
85
|
+
.nd-card-options { display: flex; align-items: flex-start; flex-wrap: wrap; gap: .5rem; padding: 1rem; }
|
|
86
|
+
.nd-card-intro { min-width: 0; flex: 1; overflow-wrap: anywhere; }
|
|
87
|
+
.nd-card-title { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
|
|
88
|
+
.nd-card-title h2 {
|
|
89
|
+
margin: 0; color: var(--nd-strong); font-size: 1rem; line-height: 1.5rem; font-weight: 600;
|
|
90
|
+
}
|
|
91
|
+
.nd-card-title code { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: inherit; }
|
|
92
|
+
.nd-card-title a { color: inherit; text-decoration: none; }
|
|
93
|
+
.nd-card-title a:hover { text-decoration: underline; text-underline-offset: .18em; }
|
|
94
|
+
.nd-option {
|
|
95
|
+
min-width: 0; max-width: 100%; font-size: .75rem; line-height: 1rem;
|
|
96
|
+
border: 1px solid var(--nd-border); border-radius: .375rem; background: var(--nd-elevated);
|
|
97
|
+
}
|
|
98
|
+
.nd-option > summary {
|
|
99
|
+
display: flex; align-items: center; flex-wrap: wrap; gap: .375rem; cursor: pointer;
|
|
100
|
+
padding: .375rem .625rem; border-radius: inherit; overflow-wrap: anywhere; list-style: none;
|
|
101
|
+
}
|
|
102
|
+
.nd-option > summary::-webkit-details-marker { display: none; }
|
|
103
|
+
.nd-option > summary::after {
|
|
104
|
+
content: ''; width: .3rem; height: .3rem; margin: 0 .125rem .15rem .125rem;
|
|
105
|
+
border: solid var(--nd-muted); border-width: 0 1px 1px 0; transform: rotate(45deg);
|
|
106
|
+
}
|
|
107
|
+
.nd-option[open] > summary::after { transform: rotate(225deg); margin-bottom: -.15rem; }
|
|
108
|
+
.nd-option-name { font-weight: 500; }
|
|
109
|
+
.nd-optional { color: var(--nd-muted); }
|
|
110
|
+
.nd-badge {
|
|
111
|
+
display: inline-flex; align-items: center; border-radius: .25rem; padding: .125rem .25rem;
|
|
112
|
+
color: var(--nd-text); font-size: .625rem; line-height: .75rem; font-weight: 500;
|
|
113
|
+
box-shadow: inset 0 0 0 1px var(--nd-border);
|
|
114
|
+
}
|
|
115
|
+
.nd-primary, .nd-success { --nd-tint: light-dark(#007a45, #7bf1a8); }
|
|
116
|
+
.nd-info, .nd-auto { --nd-tint: light-dark(#1447e6, #8ec5ff); }
|
|
117
|
+
.nd-secondary { --nd-tint: light-dark(#7008e7, #dab2ff); }
|
|
118
|
+
.nd-warning { --nd-tint: light-dark(#894b00, #ffd230); }
|
|
119
|
+
.nd-neutral { --nd-tint: var(--nd-text); }
|
|
120
|
+
.nd-type, .nd-auto { color: var(--nd-tint); box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 25%, transparent); }
|
|
121
|
+
.nd-type { background: color-mix(in srgb, currentColor 9%, transparent); }
|
|
122
|
+
.nd-option-detail { max-width: 30rem; padding: 0 .625rem .5rem; color: var(--nd-muted); overflow-wrap: anywhere; }
|
|
123
|
+
.nd-option-detail p { margin: .25rem 0 0; }
|
|
124
|
+
.nd-option-detail p:first-child { color: var(--nd-text); }
|
|
125
|
+
.nd-empty { padding: 4rem 1rem; text-align: center; }
|
|
126
|
+
.nd-menus { margin-top: 2.5rem; }
|
|
127
|
+
.nd-menus h2 { margin: 0 0 1rem; font-size: 1.25rem; line-height: 1.75rem; }
|
|
128
|
+
.nd-menu dt { font-weight: 600; }
|
|
129
|
+
@media (min-width: 40rem) {
|
|
130
|
+
.nd-card-header, .nd-card-footer, .nd-menu { padding-inline: 1.5rem; }
|
|
131
|
+
.nd-card-options { padding: 1.5rem; }
|
|
132
|
+
.nd-command-card, .nd-menus, .nd-reference-page main { scroll-margin-top: 4.5rem; }
|
|
46
133
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import process from "node:process";
|
|
2
|
-
import { defineEventHandler, getMethod, getRequestHeader, setResponseHeader, setResponseHeaders, setResponseStatus } from "h3";
|
|
2
|
+
import { defineEventHandler, getMethod, getQuery, getRequestHeader, setResponseHeader, setResponseHeaders, setResponseStatus } from "h3";
|
|
3
3
|
import { getDashboardUserId, handleDashboardOAuth } from "./oauth.js";
|
|
4
|
-
import { acceptsOrigin
|
|
4
|
+
import { acceptsOrigin } from "./origin.js";
|
|
5
5
|
import { dashboardAccessFor } from "./permissions.js";
|
|
6
6
|
import { renderAccessDeniedPage, renderSignInPage } from "./signin.js";
|
|
7
|
+
import { configuredOrigin, dashboardCommandsPath } from "./urls.js";
|
|
7
8
|
function rejectAccess(event, status, path) {
|
|
8
9
|
setResponseStatus(event, status);
|
|
9
10
|
if ((path === "/" || path === "/discord" || path.startsWith("/discord/")) && getMethod(event) === "GET" && getRequestHeader(event, "accept")?.includes("text/html")) {
|
|
10
11
|
setResponseHeader(event, "content-type", "text/html; charset=utf-8");
|
|
11
12
|
setResponseHeader(event, "content-security-policy", "default-src 'none'; style-src 'unsafe-inline'; form-action 'self'; base-uri 'none'; frame-ancestors 'none'");
|
|
12
|
-
return status === 401 ? renderSignInPage() : renderAccessDeniedPage();
|
|
13
|
+
return status === 401 ? renderSignInPage(path) : renderAccessDeniedPage();
|
|
13
14
|
}
|
|
14
15
|
return status === 401 ? "Sign in to the dashboard." : "Forbidden";
|
|
15
16
|
}
|
|
@@ -33,8 +34,10 @@ export default defineEventHandler(async (event) => {
|
|
|
33
34
|
setResponseStatus(event, 403);
|
|
34
35
|
return "Forbidden";
|
|
35
36
|
}
|
|
36
|
-
if (["/__discord-auth/login", "/__discord-auth/callback", "/__discord-auth/logout"].includes(path))
|
|
37
|
-
|
|
37
|
+
if (["/__discord-auth/login", "/__discord-auth/callback", "/__discord-auth/logout"].includes(path)) {
|
|
38
|
+
const landing = path === "/__discord-auth/login" && getQuery(event).view === "commands" ? dashboardCommandsPath : "/discord";
|
|
39
|
+
return handleDashboardOAuth(event, url, clientId, { audience: "dashboard", landing });
|
|
40
|
+
}
|
|
38
41
|
const userId = getDashboardUserId(event, url);
|
|
39
42
|
if (!userId)
|
|
40
43
|
return rejectAccess(event, 401, path);
|
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import { getMethod, getRequestHeader } from "h3";
|
|
2
|
-
export function configuredOrigin(origin) {
|
|
3
|
-
const url = origin && URL.canParse(origin) ? new URL(origin) : void 0;
|
|
4
|
-
if (!url || url.origin !== origin)
|
|
5
|
-
return;
|
|
6
|
-
if (url.protocol === "https:" || url.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname))
|
|
7
|
-
return url;
|
|
8
|
-
}
|
|
9
2
|
export function acceptsOrigin(event, url) {
|
|
10
3
|
const method = getMethod(event);
|
|
11
4
|
const requestOrigin = getRequestHeader(event, "origin");
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { dashboardCommandsPath } from "./urls.js";
|
|
1
2
|
function page(heading, action) {
|
|
2
3
|
return `<!doctype html>
|
|
3
4
|
<html lang="en">
|
|
@@ -31,8 +32,9 @@ function page(heading, action) {
|
|
|
31
32
|
</body>
|
|
32
33
|
</html>`;
|
|
33
34
|
}
|
|
34
|
-
export function renderSignInPage() {
|
|
35
|
-
|
|
35
|
+
export function renderSignInPage(path) {
|
|
36
|
+
const login = path === dashboardCommandsPath ? "/__discord-auth/login?view=commands" : "/__discord-auth/login";
|
|
37
|
+
return page("Sign in to the dashboard", `<a class="action" href="${login}">Sign in with Discord</a>`);
|
|
36
38
|
}
|
|
37
39
|
export function renderAccessDeniedPage() {
|
|
38
40
|
return page("This account doesn\u2019t have dashboard access", '<form method="post" action="/__discord-auth/logout"><button class="action" type="submit">Use another Discord account</button></form>');
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const dashboardCommandsPath = "/discord/slash-commands";
|
|
2
|
+
export function configuredOrigin(origin) {
|
|
3
|
+
const url = origin && URL.canParse(origin) ? new URL(origin) : void 0;
|
|
4
|
+
if (!url || url.origin !== origin)
|
|
5
|
+
return;
|
|
6
|
+
if (url.protocol === "https:" || url.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname))
|
|
7
|
+
return url;
|
|
8
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import process from "node:process";
|
|
2
2
|
import { createError, getMethod, getQuery, setResponseHeaders, setResponseStatus } from "h3";
|
|
3
3
|
import { getDiscordSession, handleDashboardOAuth } from "../dashboard/oauth.js";
|
|
4
|
-
import { acceptsOrigin
|
|
4
|
+
import { acceptsOrigin } from "../dashboard/origin.js";
|
|
5
5
|
import { dashboardAccessFor } from "../dashboard/permissions.js";
|
|
6
6
|
import { renderReferenceAccessPage } from "../dashboard/signin.js";
|
|
7
|
+
import { configuredOrigin } from "../dashboard/urls.js";
|
|
7
8
|
import { useDiscordClient } from "../server/utils/useDiscordClient.js";
|
|
8
9
|
const authPaths = ["/__discord-reference/login", "/__discord-reference/callback", "/__discord-reference/logout"];
|
|
9
10
|
export function referenceRequest(path, method, options) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getCatalog, policy, styles } from "discord/reference";
|
|
1
|
+
import { dashboardHref, getCatalog, policy, styles } from "discord/reference";
|
|
2
2
|
import { createError, defineEventHandler, setResponseHeaders } from "h3";
|
|
3
3
|
import { h } from "vue";
|
|
4
4
|
import { renderToString } from "vue/server-renderer";
|
|
@@ -14,9 +14,12 @@ export default defineEventHandler(async (event) => {
|
|
|
14
14
|
const denied = await authorizeReference(event, policy, true);
|
|
15
15
|
if (denied)
|
|
16
16
|
return denied;
|
|
17
|
-
const slots =
|
|
18
|
-
|
|
17
|
+
const slots = {
|
|
18
|
+
...dashboardHref && { "admin-entry": () => h("a", { href: dashboardHref, class: "ref-admin-entry", rel: "noreferrer" }, "Admin sign-in") },
|
|
19
|
+
...policy.access !== "public" && {
|
|
20
|
+
default: () => h("form", { method: "post", action: "/__discord-reference/logout" }, h("button", { type: "submit" }, "Sign out"))
|
|
21
|
+
}
|
|
19
22
|
};
|
|
20
|
-
const body = await renderToString(h(ReferenceContent, { catalog: await getCatalog() }, slots));
|
|
21
|
-
return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="color-scheme" content="light dark"><title>Command reference</title><style>${styles}</style></head><body
|
|
23
|
+
const body = await renderToString(h(ReferenceContent, { catalog: await getCatalog(), standalone: true }, slots));
|
|
24
|
+
return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="color-scheme" content="light dark"><title>Command reference</title><style>${styles}</style></head><body>${body}</body></html>`;
|
|
22
25
|
});
|
package/package.json
CHANGED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
-
declare const _default: typeof __VLS_export;
|
|
3
|
-
export default _default;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
<script setup>
|
|
2
|
-
import { useId } from "vue";
|
|
3
|
-
const seamMask = useId();
|
|
4
|
-
</script>
|
|
5
|
-
|
|
6
|
-
<template>
|
|
7
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="8 5.5 84 84" width="84" height="84">
|
|
8
|
-
<title>Nuxt Discord</title>
|
|
9
|
-
<defs>
|
|
10
|
-
<mask :id="seamMask" maskUnits="userSpaceOnUse" x="8" y="5.5" width="84" height="84">
|
|
11
|
-
<rect x="8" y="5.5" width="84" height="84" fill="white" />
|
|
12
|
-
<g transform="translate(1.3 -.65) scale(.97) translate(6.32 3.64) scale(.94155)" fill="black">
|
|
13
|
-
<path d="M10 45.4C25.8 37.9 39.4 36.4 47.7 39.7 52.1 41.5 55.5 45.1 57.8 48.1Q58.2 48.7 57.6 49 57.2 49.2 56.8 48.7C54.2 45.9 50.8 43 47 41.6 38.9 38.5 26 41.1 10 49.7Z" />
|
|
14
|
-
<path d="M57 19C62 23.4 66.6 30.5 67.05 37Q67.1 37.7 66.55 37.7 66.1 37.7 65.95 37.2C65.1 32.4 63.84 28.44 60.2 25.5Q56.8 22.75 53.9 19Z" />
|
|
15
|
-
</g>
|
|
16
|
-
</mask>
|
|
17
|
-
</defs>
|
|
18
|
-
<g :mask="`url(#${seamMask})`">
|
|
19
|
-
<path fill="#00dc82" style="fill: light-dark(#00b574, #00dc82)" d="M54.49 87.24C54.49 87.24 82.18 87.24 82.18 87.24 C83.06 87.24 83.91 86.93 84.67 86.49 C85.44 86.05 86.23 85.5 86.67 84.74 C87.11 83.98 87.42 83.12 87.42 82.25 C87.41 81.37 87.11 80.51 86.67 79.75 C86.67 79.75 67.96 47.58 67.96 47.58 C67.52 46.82 66.98 46.27 66.21 45.83 C65.45 45.39 64.35 45.08 63.47 45.08 C62.59 45.08 61.74 45.39 60.98 45.83 C60.21 46.27 59.67 46.82 59.23 47.58 C59.23 47.58 54.49 55.81 54.49 55.81 C54.49 55.81 45.01 39.84 45.01 39.84 C44.57 39.09 44.03 38.29 43.27 37.85 C42.5 37.41 41.65 37.35 40.77 37.35 C39.89 37.35 39.04 37.41 38.28 37.85 C37.51 38.29 36.72 39.09 36.28 39.84 C36.28 39.84 13.08 79.75 13.08 79.75 C12.64 80.51 12.59 81.37 12.58 82.25 C12.58 83.12 12.64 83.98 13.08 84.74 C13.53 85.5 14.31 86.05 15.08 86.49 C15.84 86.93 16.69 87.24 17.57 87.24 C17.57 87.24 35.03 87.24 35.03 87.24 C41.95 87.24 46.99 84.13 50.5 78.26 C50.5 78.26 58.98 63.54 58.98 63.54 C58.98 63.54 63.47 55.81 63.47 55.81 C63.47 55.81 77.19 79.26 77.19 79.26 C77.19 79.26 58.98 79.26 58.98 79.26 C58.98 79.26 54.49 87.24 54.49 87.24 C54.49 87.24 54.49 87.24 54.49 87.24 ZM34.78 79.26C34.78 79.26 22.56 79.26 22.56 79.26 C22.56 79.26 40.77 47.83 40.77 47.83 C40.77 47.83 50 63.54 50 63.54 C50 63.54 43.89 74.2 43.89 74.2 C41.56 78.01 38.9 79.26 34.78 79.26 C34.78 79.26 34.78 79.26 34.78 79.26 Z" />
|
|
20
|
-
<g transform="translate(1.3 -.65) scale(.97)" fill="#5865f2">
|
|
21
|
-
<g transform="translate(6.32 3.64) scale(.94155)">
|
|
22
|
-
<path d="M16.47 44.22C8 38.17 3.87 8.84 23.24 8.84 C40.6 8.84 53.4 20 60.2 25.5 C62.3 27.2 63.6 27.8 66.8 27.7 C74.1 27.7 79.7 28.4 81.5 32.4 C84.9 40 72.9 46.5 58.7 50C55.9 53.6 54.1 55.5 50.9 55.1 C40.6 53.1 30.4 46.2 12.4 54.1 Q10.2 55.1 10.9 52.9 Q12.3 48.3 16.47 44.22Z" />
|
|
23
|
-
</g>
|
|
24
|
-
<g fill="#fff">
|
|
25
|
-
<path d="M23.78 24.8C25.16 24.39 26.8 25.77 27.44 27.9 C28.09 30.02 27.49 32.08 26.12 32.5 C24.75 32.92 23.11 31.53 22.46 29.41 C21.82 27.29 22.41 25.22 23.78 24.8 Z" />
|
|
26
|
-
<path d="M31.25 26.36C30.22 24.37 30.53 22.17 31.93 21.45 C33.33 20.73 35.3 21.76 36.32 23.74 C37.35 25.73 37.04 27.93 35.64 28.65 C34.24 29.38 32.27 28.35 31.25 26.36 Z" />
|
|
27
|
-
</g>
|
|
28
|
-
</g>
|
|
29
|
-
</g>
|
|
30
|
-
</svg>
|
|
31
|
-
</template>
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
-
declare const _default: typeof __VLS_export;
|
|
3
|
-
export default _default;
|