@shwfed/nuxt 0.1.31 → 0.1.33
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
CHANGED
|
@@ -1,14 +1,37 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
|
|
3
3
|
interface ModuleOptions {
|
|
4
|
-
|
|
4
|
+
apis: Readonly<{
|
|
5
|
+
/**
|
|
6
|
+
* DSL
|
|
7
|
+
*/
|
|
8
|
+
headers?: string;
|
|
9
|
+
/**
|
|
10
|
+
* DSL
|
|
11
|
+
*/
|
|
12
|
+
baseURL: string;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
15
|
+
interface Env {
|
|
16
|
+
ci: boolean;
|
|
17
|
+
git: Readonly<{
|
|
18
|
+
commit: string;
|
|
19
|
+
branch: string;
|
|
20
|
+
}>;
|
|
5
21
|
}
|
|
6
22
|
declare module 'nuxt/schema' {
|
|
7
23
|
interface PublicRuntimeConfig {
|
|
8
|
-
shwfed: ModuleOptions;
|
|
24
|
+
shwfed: ModuleOptions & Env;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
declare global {
|
|
28
|
+
interface ImportMetaEnv {
|
|
29
|
+
readonly CI?: 'true';
|
|
30
|
+
readonly GIT_COMMIT?: string;
|
|
31
|
+
readonly GIT_LOCAL_BRANCH?: string;
|
|
9
32
|
}
|
|
10
33
|
}
|
|
11
34
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
12
35
|
|
|
13
36
|
export { _default as default };
|
|
14
|
-
export type { ModuleOptions };
|
|
37
|
+
export type { Env, ModuleOptions };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineNuxtModule, createResolver, addVitePlugin, addPlugin, addImportsDir, addComponentsDir } from '@nuxt/kit';
|
|
2
2
|
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
|
|
3
|
+
import defu from 'defu';
|
|
3
4
|
|
|
4
5
|
const module$1 = defineNuxtModule({
|
|
5
6
|
meta: {
|
|
@@ -9,7 +10,13 @@ const module$1 = defineNuxtModule({
|
|
|
9
10
|
defaults: {},
|
|
10
11
|
setup(options, nuxt) {
|
|
11
12
|
const resolver = createResolver(import.meta.url);
|
|
12
|
-
nuxt.options.runtimeConfig.public.shwfed = options
|
|
13
|
+
nuxt.options.runtimeConfig.public.shwfed = defu(options, {
|
|
14
|
+
ci: import.meta.env.CI === "true",
|
|
15
|
+
git: {
|
|
16
|
+
commit: import.meta.env.GIT_COMMIT ?? "",
|
|
17
|
+
branch: import.meta.env.GIT_LOCAL_BRANCH ?? ""
|
|
18
|
+
}
|
|
19
|
+
});
|
|
13
20
|
nuxt.options.css ||= [];
|
|
14
21
|
nuxt.options.css.push("vue-sonner/style.css");
|
|
15
22
|
addVitePlugin(VueI18nPlugin({
|
|
@@ -18,6 +25,7 @@ const module$1 = defineNuxtModule({
|
|
|
18
25
|
addPlugin(resolver.resolve("runtime/plugins/i18n/index"));
|
|
19
26
|
addPlugin(resolver.resolve("runtime/plugins/cel/index"));
|
|
20
27
|
addPlugin(resolver.resolve("runtime/plugins/markdown/index"));
|
|
28
|
+
addPlugin(resolver.resolve("runtime/plugins/api/index"));
|
|
21
29
|
addPlugin({
|
|
22
30
|
src: resolver.resolve("runtime/plugins/toast/index"),
|
|
23
31
|
mode: "client"
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const _default: import("#app").Plugin<{
|
|
2
|
+
api: import("nitropack").$Fetch<unknown, import("nitropack").NitroFetchRequest>;
|
|
3
|
+
}> & import("#app").ObjectPlugin<{
|
|
4
|
+
api: import("nitropack").$Fetch<unknown, import("nitropack").NitroFetchRequest>;
|
|
5
|
+
}>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { defineNuxtPlugin, useNuxtApp } from "#app";
|
|
2
|
+
import z from "zod";
|
|
3
|
+
export default defineNuxtPlugin({
|
|
4
|
+
name: "shwfed-nuxt:api",
|
|
5
|
+
dependsOn: ["shwfed-nuxt:cel"],
|
|
6
|
+
setup: (nuxt) => {
|
|
7
|
+
const { $dsl } = useNuxtApp();
|
|
8
|
+
const api = $fetch.create({
|
|
9
|
+
onRequest: ({
|
|
10
|
+
options
|
|
11
|
+
}) => {
|
|
12
|
+
if (options.baseURL === "/") {
|
|
13
|
+
try {
|
|
14
|
+
const baseURL = $dsl.evaluate`${nuxt.$config.public.shwfed.apis.baseURL}`();
|
|
15
|
+
if (typeof baseURL === "string") {
|
|
16
|
+
options.baseURL = baseURL;
|
|
17
|
+
}
|
|
18
|
+
} catch {
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (nuxt.$config.public.shwfed.apis.headers) {
|
|
22
|
+
try {
|
|
23
|
+
const headers = $dsl.evaluate`${nuxt.$config.public.shwfed.apis.headers}`();
|
|
24
|
+
for (const [key, value] of Object.entries(z.record(z.string(), z.string()).parse(headers))) {
|
|
25
|
+
options.headers.set(key, value);
|
|
26
|
+
}
|
|
27
|
+
} catch {
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
provide: {
|
|
34
|
+
api
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Environment, EvaluationError } from "@marcbachmann/cel-js";
|
|
1
|
+
import { Environment, EvaluationError, Optional } from "@marcbachmann/cel-js";
|
|
2
2
|
import { startOfDay, startOfWeek, startOfYear, startOfMonth, endOfDay, endOfWeek, endOfYear, endOfMonth, addYears, addMonths, addDays, addWeeks, setDate, setMonth, setYear, formatDate, isBefore, isAfter, isEqual } from "date-fns";
|
|
3
3
|
import { TZDate } from "@date-fns/tz";
|
|
4
4
|
import { BigNumber } from "bignumber.js";
|
|
@@ -86,6 +86,17 @@ export function createEnvironment(_) {
|
|
|
86
86
|
return number.toLocaleString(navigator.language, options);
|
|
87
87
|
}).registerFunction("int.toLocaleString(dyn): string", (number, options) => {
|
|
88
88
|
return number.toLocaleString(navigator.language, options);
|
|
89
|
+
}).registerFunction("parseJSON(string): dyn", (string) => {
|
|
90
|
+
return JSON.parse(string);
|
|
91
|
+
}).registerFunction("session(string): optional<string>", (key) => {
|
|
92
|
+
if (typeof window === "undefined") return Optional.none();
|
|
93
|
+
try {
|
|
94
|
+
const value = window.sessionStorage.getItem(key);
|
|
95
|
+
if (value === null) return Optional.none();
|
|
96
|
+
return Optional.of(value);
|
|
97
|
+
} catch {
|
|
98
|
+
return Optional.none();
|
|
99
|
+
}
|
|
89
100
|
});
|
|
90
101
|
return env;
|
|
91
102
|
}
|
package/dist/types.d.mts
CHANGED