@shwfed/nuxt 0.11.5 → 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 +8 -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/fields-instance.d.ts +3 -0
- package/dist/runtime/components/fields-instance.js +0 -0
- package/dist/runtime/components/fields.d.vue.ts +2 -1
- package/dist/runtime/components/fields.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/components/ui/fields/Fields.d.vue.ts +1 -3
- package/dist/runtime/components/ui/fields/Fields.vue.d.ts +1 -3
- package/dist/runtime/plugins/api/index.js +36 -0
- package/dist/types.d.mts +2 -0
- package/package.json +1 -1
package/dist/module.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
export { FieldsInstance } from '../dist/runtime/components/fields-instance.js';
|
|
2
3
|
|
|
3
4
|
type Wrap<T> = T extends object ? Readonly<{
|
|
4
5
|
[P in keyof T]?: Wrap<T[P]>;
|
|
@@ -11,6 +12,12 @@ type Config = Wrap<{
|
|
|
11
12
|
* @type DSL - Record<string, string>
|
|
12
13
|
*/
|
|
13
14
|
header: string;
|
|
15
|
+
/**
|
|
16
|
+
* 配置 API 响应是否表示 token 已过期
|
|
17
|
+
*
|
|
18
|
+
* @type DSL - bool
|
|
19
|
+
*/
|
|
20
|
+
expired: string;
|
|
14
21
|
};
|
|
15
22
|
}>;
|
|
16
23
|
interface Env {
|
|
@@ -45,6 +52,7 @@ declare global {
|
|
|
45
52
|
readonly NUXT_PUBLIC_TOKEN_HEADER_NAME?: string;
|
|
46
53
|
}
|
|
47
54
|
}
|
|
55
|
+
|
|
48
56
|
declare const _default: _nuxt_schema.NuxtModule<_nuxt_schema.ModuleOptions, _nuxt_schema.ModuleOptions, false>;
|
|
49
57
|
|
|
50
58
|
export { _default as default };
|
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 (): {
|
|
File without changes
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
2
|
import { type FieldsConfigInput } from './ui/fields/Fields.vue.js';
|
|
3
3
|
export { CalendarFieldC, EmptyFieldC, FieldC, FieldsBodyC, FieldsBodyInputC, FieldsConfigC, FieldsConfigInputC, NumberFieldC, SelectFieldC, SlotFieldC, StringFieldC, CURRENT_COMPATIBILITY_DATE, KIND, SUPPORTED_COMPATIBILITY_DATES, createFieldsConfig, } from './ui/fields/Fields.vue.js';
|
|
4
|
-
export type { EmptyField, Field,
|
|
4
|
+
export type { EmptyField, Field, FieldsBody, FieldsBodyInput, FieldsConfig, FieldsConfigInput, SlotField, } from './ui/fields/Fields.vue.js';
|
|
5
|
+
export type { FieldsInstance } from './fields-instance.js';
|
|
5
6
|
declare const _default: typeof __VLS_export;
|
|
6
7
|
export default _default;
|
|
7
8
|
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
2
|
import { type FieldsConfigInput } from './ui/fields/Fields.vue.js';
|
|
3
3
|
export { CalendarFieldC, EmptyFieldC, FieldC, FieldsBodyC, FieldsBodyInputC, FieldsConfigC, FieldsConfigInputC, NumberFieldC, SelectFieldC, SlotFieldC, StringFieldC, CURRENT_COMPATIBILITY_DATE, KIND, SUPPORTED_COMPATIBILITY_DATES, createFieldsConfig, } from './ui/fields/Fields.vue.js';
|
|
4
|
-
export type { EmptyField, Field,
|
|
4
|
+
export type { EmptyField, Field, FieldsBody, FieldsBodyInput, FieldsConfig, FieldsConfigInput, SlotField, } from './ui/fields/Fields.vue.js';
|
|
5
|
+
export type { FieldsInstance } from './fields-instance.js';
|
|
5
6
|
declare const _default: typeof __VLS_export;
|
|
6
7
|
export default _default;
|
|
7
8
|
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
@@ -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
|
+
};
|
|
@@ -2,9 +2,7 @@ import { Effect } from 'effect';
|
|
|
2
2
|
import type { CSSProperties } from 'vue';
|
|
3
3
|
export { CalendarFieldC, CURRENT_COMPATIBILITY_DATE, EmptyFieldC, FieldC, FieldsBodyC, FieldsBodyInputC, FieldsConfigC, FieldsConfigInputC, KIND, NumberFieldC, SelectFieldC, SlotFieldC, SUPPORTED_COMPATIBILITY_DATES, StringFieldC, ValidationRuleC, createFieldsConfig, validationC, } from './schema.js';
|
|
4
4
|
export type { EmptyField, Field, FieldsBody, FieldsBodyInput, FieldsConfig, FieldsConfigInput, SlotField, ValidationRule, } from './schema.js';
|
|
5
|
-
export type FieldsInstance
|
|
6
|
-
valid: import('effect').Effect.Effect<boolean, never>;
|
|
7
|
-
};
|
|
5
|
+
export type { FieldsInstance } from '../../fields-instance.js';
|
|
8
6
|
declare const _default: typeof __VLS_export;
|
|
9
7
|
export default _default;
|
|
10
8
|
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
@@ -2,9 +2,7 @@ import { Effect } from 'effect';
|
|
|
2
2
|
import type { CSSProperties } from 'vue';
|
|
3
3
|
export { CalendarFieldC, CURRENT_COMPATIBILITY_DATE, EmptyFieldC, FieldC, FieldsBodyC, FieldsBodyInputC, FieldsConfigC, FieldsConfigInputC, KIND, NumberFieldC, SelectFieldC, SlotFieldC, SUPPORTED_COMPATIBILITY_DATES, StringFieldC, ValidationRuleC, createFieldsConfig, validationC, } from './schema.js';
|
|
4
4
|
export type { EmptyField, Field, FieldsBody, FieldsBodyInput, FieldsConfig, FieldsConfigInput, SlotField, ValidationRule, } from './schema.js';
|
|
5
|
-
export type FieldsInstance
|
|
6
|
-
valid: import('effect').Effect.Effect<boolean, never>;
|
|
7
|
-
};
|
|
5
|
+
export type { FieldsInstance } from '../../fields-instance.js';
|
|
8
6
|
declare const _default: typeof __VLS_export;
|
|
9
7
|
export default _default;
|
|
10
8
|
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
@@ -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 {
|
package/dist/types.d.mts
CHANGED
|
@@ -4,6 +4,8 @@ import type { default as Module } from './module.mjs'
|
|
|
4
4
|
|
|
5
5
|
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
6
6
|
|
|
7
|
+
export { type FieldsInstance } from '../dist/runtime/components/fields-instance.js'
|
|
8
|
+
|
|
7
9
|
export { default } from './module.mjs'
|
|
8
10
|
|
|
9
11
|
export { type Env } from './module.mjs'
|