@shwfed/nuxt 0.11.6 → 0.11.7
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 +6 -0
- package/dist/module.json +1 -1
- package/dist/runtime/components/button.d.vue.ts +2 -1
- package/dist/runtime/components/button.vue +2 -1
- package/dist/runtime/components/button.vue.d.ts +2 -1
- package/dist/runtime/components/ui/buttons/Buttons.d.vue.ts +10 -2
- package/dist/runtime/components/ui/buttons/Buttons.vue +6 -3
- package/dist/runtime/components/ui/buttons/Buttons.vue.d.ts +10 -2
- package/dist/runtime/plugins/api/index.js +36 -0
- package/package.json +1 -1
package/dist/module.d.mts
CHANGED
package/dist/module.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
|
+
import type { OverlayBodyRender } from '../composables/useOverlay.js';
|
|
2
3
|
import type { ButtonConfigInput } from './ui/buttons/schema.js';
|
|
3
4
|
export { ButtonActionC, ButtonBodyC, ButtonBodyInputC, ButtonConfigC, ButtonConfigInputC, ButtonDropdownC, ButtonGroupC, ButtonModalC, ButtonsStyleC, CURRENT_COMPATIBILITY_DATE, KIND, SUPPORTED_COMPATIBILITY_DATES, createButtonConfig, } from './ui/buttons/schema.js';
|
|
4
5
|
export type { ButtonAction, ButtonBody, ButtonBodyInput, ButtonConfig, ButtonConfigInput, ButtonDropdown, ButtonDropdownAction, ButtonGroup, ButtonGroupItem, ButtonModal, } from './ui/buttons/schema.js';
|
|
@@ -151,7 +152,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
|
151
152
|
style?: string | undefined;
|
|
152
153
|
}>) => any) | undefined;
|
|
153
154
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
154
|
-
[
|
|
155
|
+
[name: string]: OverlayBodyRender;
|
|
155
156
|
}>;
|
|
156
157
|
type __VLS_WithSlots<T, S> = T & {
|
|
157
158
|
new (): {
|
|
@@ -9,6 +9,7 @@ const props = defineProps({
|
|
|
9
9
|
config: { type: null, required: false }
|
|
10
10
|
});
|
|
11
11
|
const emit = defineEmits(["update:config"]);
|
|
12
|
+
const slots = defineSlots();
|
|
12
13
|
const defaultConfig = createButtonConfig({
|
|
13
14
|
gap: 12,
|
|
14
15
|
groups: []
|
|
@@ -53,7 +54,7 @@ export { ButtonActionService, currentButtonAction } from "../composables/useButt
|
|
|
53
54
|
@update:config="handleConfigUpdate"
|
|
54
55
|
>
|
|
55
56
|
<template
|
|
56
|
-
v-for="(_, slotName) in
|
|
57
|
+
v-for="(_, slotName) in slots"
|
|
57
58
|
#[slotName]="slotProps"
|
|
58
59
|
>
|
|
59
60
|
<slot
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
|
+
import type { OverlayBodyRender } from '../composables/useOverlay.js';
|
|
2
3
|
import type { ButtonConfigInput } from './ui/buttons/schema.js';
|
|
3
4
|
export { ButtonActionC, ButtonBodyC, ButtonBodyInputC, ButtonConfigC, ButtonConfigInputC, ButtonDropdownC, ButtonGroupC, ButtonModalC, ButtonsStyleC, CURRENT_COMPATIBILITY_DATE, KIND, SUPPORTED_COMPATIBILITY_DATES, createButtonConfig, } from './ui/buttons/schema.js';
|
|
4
5
|
export type { ButtonAction, ButtonBody, ButtonBodyInput, ButtonConfig, ButtonConfigInput, ButtonDropdown, ButtonDropdownAction, ButtonGroup, ButtonGroupItem, ButtonModal, } from './ui/buttons/schema.js';
|
|
@@ -151,7 +152,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
|
151
152
|
style?: string | undefined;
|
|
152
153
|
}>) => any) | undefined;
|
|
153
154
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
154
|
-
[
|
|
155
|
+
[name: string]: OverlayBodyRender;
|
|
155
156
|
}>;
|
|
156
157
|
type __VLS_WithSlots<T, S> = T & {
|
|
157
158
|
new (): {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
|
+
import { type OverlayBodyRender } from '../../../composables/useOverlay.js';
|
|
2
3
|
import { type ButtonConfigInput } from './schema.js';
|
|
3
4
|
export { ButtonActionC, ButtonConfigC, ButtonConfigInputC, ButtonDropdownC, ButtonGroupC, ButtonModalC, ButtonsStyleC } from './schema.js';
|
|
4
5
|
export { ButtonBodyC, ButtonBodyInputC, CURRENT_COMPATIBILITY_DATE, KIND, SUPPORTED_COMPATIBILITY_DATES, createButtonConfig, } from './schema.js';
|
|
@@ -7,7 +8,7 @@ export type { ButtonAction, ButtonBody, ButtonBodyInput, ButtonConfig, ButtonCon
|
|
|
7
8
|
export type { ButtonActionEffect, ButtonActionEffectFactory, ButtonActionRuntime } from '../../../composables/useButtonAction.js';
|
|
8
9
|
declare const _default: typeof __VLS_export;
|
|
9
10
|
export default _default;
|
|
10
|
-
declare const __VLS_export: import("vue").DefineComponent<{
|
|
11
|
+
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
11
12
|
config: Effect.Effect<ButtonConfigInput | undefined>;
|
|
12
13
|
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
13
14
|
"update:config": (args_0: Readonly<{
|
|
@@ -151,4 +152,11 @@ declare const __VLS_export: import("vue").DefineComponent<{
|
|
|
151
152
|
gap?: number | undefined;
|
|
152
153
|
style?: string | undefined;
|
|
153
154
|
}>) => any) | undefined;
|
|
154
|
-
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any
|
|
155
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
156
|
+
[name: string]: OverlayBodyRender;
|
|
157
|
+
}>;
|
|
158
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
159
|
+
new (): {
|
|
160
|
+
$slots: S;
|
|
161
|
+
};
|
|
162
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { useNuxtApp } from "#app";
|
|
3
|
-
import { useAttrs, computed, onBeforeUnmount, ref,
|
|
3
|
+
import { useAttrs, computed, onBeforeUnmount, ref, watch } from "vue";
|
|
4
4
|
import { computedAsync } from "@vueuse/core";
|
|
5
5
|
import { Icon } from "@iconify/vue";
|
|
6
6
|
import { Effect } from "effect";
|
|
@@ -9,7 +9,10 @@ import { useCheating } from "#imports";
|
|
|
9
9
|
import {
|
|
10
10
|
ButtonActionService
|
|
11
11
|
} from "../../../composables/useButtonAction";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
provideOverlay,
|
|
14
|
+
useOverlay
|
|
15
|
+
} from "../../../composables/useOverlay";
|
|
13
16
|
import { getLocalizedText, hasVisibleLocaleValue } from "../../../utils/coders";
|
|
14
17
|
import { cn } from "../../../utils/cn";
|
|
15
18
|
import ButtonConfiguratorDialog from "../button-configurator/ButtonConfiguratorDialog.vue";
|
|
@@ -35,7 +38,7 @@ const defaultConfig = createButtonConfig({
|
|
|
35
38
|
});
|
|
36
39
|
const uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;
|
|
37
40
|
const attrs = useAttrs();
|
|
38
|
-
const slots =
|
|
41
|
+
const slots = defineSlots();
|
|
39
42
|
const { locale, t } = useI18n();
|
|
40
43
|
const { $dsl } = useNuxtApp();
|
|
41
44
|
const overlay = useOverlay();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
|
+
import { type OverlayBodyRender } from '../../../composables/useOverlay.js';
|
|
2
3
|
import { type ButtonConfigInput } from './schema.js';
|
|
3
4
|
export { ButtonActionC, ButtonConfigC, ButtonConfigInputC, ButtonDropdownC, ButtonGroupC, ButtonModalC, ButtonsStyleC } from './schema.js';
|
|
4
5
|
export { ButtonBodyC, ButtonBodyInputC, CURRENT_COMPATIBILITY_DATE, KIND, SUPPORTED_COMPATIBILITY_DATES, createButtonConfig, } from './schema.js';
|
|
@@ -7,7 +8,7 @@ export type { ButtonAction, ButtonBody, ButtonBodyInput, ButtonConfig, ButtonCon
|
|
|
7
8
|
export type { ButtonActionEffect, ButtonActionEffectFactory, ButtonActionRuntime } from '../../../composables/useButtonAction.js';
|
|
8
9
|
declare const _default: typeof __VLS_export;
|
|
9
10
|
export default _default;
|
|
10
|
-
declare const __VLS_export: import("vue").DefineComponent<{
|
|
11
|
+
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
11
12
|
config: Effect.Effect<ButtonConfigInput | undefined>;
|
|
12
13
|
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
13
14
|
"update:config": (args_0: Readonly<{
|
|
@@ -151,4 +152,11 @@ declare const __VLS_export: import("vue").DefineComponent<{
|
|
|
151
152
|
gap?: number | undefined;
|
|
152
153
|
style?: string | undefined;
|
|
153
154
|
}>) => any) | undefined;
|
|
154
|
-
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any
|
|
155
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
156
|
+
[name: string]: OverlayBodyRender;
|
|
157
|
+
}>;
|
|
158
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
159
|
+
new (): {
|
|
160
|
+
$slots: S;
|
|
161
|
+
};
|
|
162
|
+
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { defineNuxtPlugin, useNuxtApp, useRuntimeConfig } from "#app";
|
|
2
2
|
import { useNavigatorLanguage } from "@vueuse/core";
|
|
3
3
|
import z from "zod";
|
|
4
|
+
let isRedirectingAfterTokenExpiry = false;
|
|
5
|
+
const processedResponses = /* @__PURE__ */ new WeakSet();
|
|
4
6
|
export default defineNuxtPlugin({
|
|
5
7
|
name: "shwfed-nuxt:api",
|
|
6
8
|
dependsOn: ["shwfed-nuxt:cel"],
|
|
@@ -8,6 +10,34 @@ export default defineNuxtPlugin({
|
|
|
8
10
|
const locale = useNavigatorLanguage();
|
|
9
11
|
const config = useRuntimeConfig().public.shwfed;
|
|
10
12
|
const { $dsl } = useNuxtApp();
|
|
13
|
+
function handleExpiredResponse(response) {
|
|
14
|
+
if (processedResponses.has(response)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
processedResponses.add(response);
|
|
18
|
+
if (typeof config.config?.api?.expired !== "string") {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
const isExpired = z.boolean().parse($dsl.evaluate`${config.config.api.expired}`({
|
|
23
|
+
status: BigInt(response.status),
|
|
24
|
+
ok: response.ok,
|
|
25
|
+
data: response._data ?? null
|
|
26
|
+
}));
|
|
27
|
+
if (!isExpired || isRedirectingAfterTokenExpiry) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
isRedirectingAfterTokenExpiry = true;
|
|
31
|
+
sessionStorage.removeItem("token");
|
|
32
|
+
if (config.api.logout) {
|
|
33
|
+
window.location.href = config.api.logout;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
console.warn("[shwfed-nuxt:api] token expired but no logout url configured");
|
|
37
|
+
} catch (e) {
|
|
38
|
+
console.error(e);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
11
41
|
const api = $fetch.create({
|
|
12
42
|
baseURL: config.api.host,
|
|
13
43
|
onRequest: ({
|
|
@@ -29,6 +59,12 @@ export default defineNuxtPlugin({
|
|
|
29
59
|
}
|
|
30
60
|
const name = config.headers.token || "Authorization";
|
|
31
61
|
options.headers.set(name, sessionStorage.getItem("token") ?? "");
|
|
62
|
+
},
|
|
63
|
+
onResponse: ({ response }) => {
|
|
64
|
+
handleExpiredResponse(response);
|
|
65
|
+
},
|
|
66
|
+
onResponseError: ({ response }) => {
|
|
67
|
+
handleExpiredResponse(response);
|
|
32
68
|
}
|
|
33
69
|
});
|
|
34
70
|
return {
|