@wervt/nuxt 0.3.8 → 0.3.9
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/brand.d.ts
CHANGED
|
@@ -18,4 +18,11 @@ export interface BrandOptions {
|
|
|
18
18
|
* why the address bar shows wervt and that the account works in other apps too.
|
|
19
19
|
*/
|
|
20
20
|
securedByWervt?: boolean;
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* The sign-in options the login offers for this app, in wervt's order (`['twitch']`). All of
|
|
23
|
+
* them by default. Providers the server has no keys for stay hidden either way.
|
|
24
|
+
*/
|
|
25
|
+
signIn?: SignInMethod[];
|
|
26
|
+
}
|
|
27
|
+
export declare const SIGN_IN_METHODS: readonly ['google', 'github', 'discord', 'twitch', 'spotify', 'passkey', 'email'];
|
|
28
|
+
export type SignInMethod = (typeof SIGN_IN_METHODS)[number];
|
package/dist/brand.js
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import { headIcon, headMeta } from "./preview.js";
|
|
2
2
|
// src/brand.ts
|
|
3
|
+
const SIGN_IN_METHODS = [
|
|
4
|
+
"google",
|
|
5
|
+
"github",
|
|
6
|
+
"discord",
|
|
7
|
+
"twitch",
|
|
8
|
+
"spotify",
|
|
9
|
+
"passkey",
|
|
10
|
+
"email"
|
|
11
|
+
];
|
|
12
|
+
/** The known methods of a list, without duplicates; undefined when none is left. */
|
|
13
|
+
function signInMethods(value) {
|
|
14
|
+
if (!Array.isArray(value)) return void 0;
|
|
15
|
+
const methods = SIGN_IN_METHODS.filter((m) => value.includes(m));
|
|
16
|
+
return methods.length ? methods : void 0;
|
|
17
|
+
}
|
|
3
18
|
const HEX_COLOR = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
|
|
4
19
|
/** The login's branding for the app, or undefined while the app keeps wervt's. */
|
|
5
20
|
function brandManifest(option, head, app, favicon) {
|
|
@@ -8,12 +23,14 @@ function brandManifest(option, head, app, favicon) {
|
|
|
8
23
|
const pick = (value, fallback) => value?.trim() || fallback;
|
|
9
24
|
const title = typeof head.title === "string" && head.title.trim() ? head.title.trim() : app;
|
|
10
25
|
const color = pick(custom.color, headMeta(head, "theme-color"));
|
|
26
|
+
const signIn = signInMethods(custom.signIn);
|
|
11
27
|
return {
|
|
12
28
|
name: pick(custom.name, title).slice(0, 60),
|
|
13
29
|
logo: pick(custom.logo, void 0),
|
|
14
30
|
icon: pick(custom.icon, headIcon(head) ?? favicon),
|
|
15
31
|
color: color && HEX_COLOR.test(color) ? color : void 0,
|
|
16
|
-
...custom.securedByWervt === false && { securedByWervt: false }
|
|
32
|
+
...custom.securedByWervt === false && { securedByWervt: false },
|
|
33
|
+
...signIn && { signIn }
|
|
17
34
|
};
|
|
18
35
|
}
|
|
19
|
-
export { HEX_COLOR, brandManifest };
|
|
36
|
+
export { HEX_COLOR, SIGN_IN_METHODS, brandManifest, signInMethods };
|
package/dist/module.js
CHANGED
|
@@ -7,7 +7,7 @@ import { iconDefaults, iconSources, iconWarning } from "./icons.js";
|
|
|
7
7
|
import { stripJsdocImports } from "./jsdoc-imports.js";
|
|
8
8
|
import { findRouteTools } from "./route-tools.js";
|
|
9
9
|
import { localFiles, previewManifest } from "./preview.js";
|
|
10
|
-
import { brandManifest } from "./brand.js";
|
|
10
|
+
import { SIGN_IN_METHODS, brandManifest } from "./brand.js";
|
|
11
11
|
import { findShapeRoutes, shapeRoutesTypes, shapesManifest } from "./shapes.js";
|
|
12
12
|
import { addImports, addPlugin, addServerHandler, addServerPlugin, addServerTemplate, addTypeTemplate, createResolver, defineNuxtModule, getNuxtVersion, hasNuxtModule, installModule, updateTemplates, useLogger } from "nuxt/kit";
|
|
13
13
|
import { existsSync } from "node:fs";
|
|
@@ -398,6 +398,11 @@ var module_default = defineNuxtModule({
|
|
|
398
398
|
image: brand.logo
|
|
399
399
|
} : false)) if (!existsSync(join(publicDir, file))) logger.warn(`The login branding names \`${file}\`, which isn't in public/.`);
|
|
400
400
|
if (typeof options.brand === "object" && options.brand.color && !brand?.color) logger.warn("`wervt.brand.color` must be a hex color like `#ff5a1f`; it is ignored.");
|
|
401
|
+
if (typeof options.brand === "object" && options.brand.signIn) {
|
|
402
|
+
const unknown = options.brand.signIn.filter((m) => !SIGN_IN_METHODS.includes(m));
|
|
403
|
+
if (unknown.length) logger.warn(`\`wervt.brand.signIn\` ignores ${unknown.map((m) => `\`${m}\``).join(", ")}; it knows ${SIGN_IN_METHODS.join(", ")}.`);
|
|
404
|
+
if (!brand?.signIn) logger.warn("`wervt.brand.signIn` names no sign-in option; the login offers all.");
|
|
405
|
+
}
|
|
401
406
|
nuxt.hook("nitro:init", (instance) => {
|
|
402
407
|
const { serverDir } = instance.options.output;
|
|
403
408
|
instance.hooks.hook("compiled", async () => {
|
|
@@ -11,8 +11,8 @@ type Registry = Record<string, {
|
|
|
11
11
|
}>;
|
|
12
12
|
/** `POST /_wervt/tasks/:name`: runs a task when the control plane asks. */
|
|
13
13
|
export declare function taskRunHandler(runTask: RunTask): import("nuxt/server").EventHandler<Promise<{
|
|
14
|
-
error: string;
|
|
15
14
|
result?: undefined;
|
|
15
|
+
error: string;
|
|
16
16
|
} | {
|
|
17
17
|
error?: undefined;
|
|
18
18
|
result: {} | null;
|