@vesperjs/vue 0.1.8 → 0.2.0
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/index.d.mts +15 -80
- package/dist/index.mjs +14 -77
- package/package.json +7 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ComputedGetter, DebuggerEvent, DebuggerOptions, OnCleanup, ReactiveEffect, Ref, ShallowUnwrapRef, UnwrapNestedRefs, WatchCallback, WatchStopHandle, WritableComputedOptions, WritableComputedRef, computed } from "@vue/reactivity";
|
|
1
|
+
import { BackendErrorInfo, BackendErrorResource, ErrorMessages, ErrorsResource, Flash, UseFlashType, useDate, useEntity, useExternalErrors, useFlash } from "@vesperjs/shared";
|
|
2
|
+
import { ComputedGetter, DebuggerEvent, DebuggerOptions, OnCleanup, ReactiveEffect, Ref, ShallowUnwrapRef, UnwrapNestedRefs, WatchCallback, WatchStopHandle, WritableComputedOptions, WritableComputedRef, WritableComputedRef as WritableComputedRef$1, computed } from "@vue/reactivity";
|
|
3
3
|
import { FetchError, FetchOptions, FetchResponse } from "ofetch";
|
|
4
|
-
import * as vue_i18n0 from "vue-i18n";
|
|
5
|
-
import * as _nanostores_router0 from "@nanostores/router";
|
|
4
|
+
import * as _$vue_i18n0 from "vue-i18n";
|
|
5
|
+
import * as _$_nanostores_router0 from "@nanostores/router";
|
|
6
6
|
import { Router, RouterConfig } from "@nanostores/router";
|
|
7
7
|
|
|
8
8
|
//#region src/composables/backend/api/use-api-constants.d.ts
|
|
9
9
|
declare const useApiConstants: () => {
|
|
10
|
-
baseURL:
|
|
10
|
+
baseURL: WritableComputedRef<string, string>;
|
|
11
11
|
};
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/composables/backend/api/use-ofetch.d.ts
|
|
@@ -72,44 +72,6 @@ declare const useMutationApi: <T = unknown, E = any>(url: string, {
|
|
|
72
72
|
pending: boolean;
|
|
73
73
|
}>;
|
|
74
74
|
//#endregion
|
|
75
|
-
//#region src/interfaces/error/backend-error-info.d.ts
|
|
76
|
-
interface BackendErrorInfo<BER> {
|
|
77
|
-
error?: BER;
|
|
78
|
-
status?: number;
|
|
79
|
-
}
|
|
80
|
-
//#endregion
|
|
81
|
-
//#region src/interfaces/resource/backend-error-resource.d.ts
|
|
82
|
-
interface BackendErrorResource {
|
|
83
|
-
source?: string;
|
|
84
|
-
title: string;
|
|
85
|
-
errors: string[];
|
|
86
|
-
}
|
|
87
|
-
//#endregion
|
|
88
|
-
//#region src/interfaces/resource/errors-resource.d.ts
|
|
89
|
-
interface ErrorsResource<T> {
|
|
90
|
-
errors: T;
|
|
91
|
-
}
|
|
92
|
-
//#endregion
|
|
93
|
-
//#region src/interfaces/flash.d.ts
|
|
94
|
-
interface Flash {
|
|
95
|
-
notice?: string;
|
|
96
|
-
alert?: string;
|
|
97
|
-
}
|
|
98
|
-
//#endregion
|
|
99
|
-
//#region src/composables/backend/error/use-external-errors.d.ts
|
|
100
|
-
declare const useExternalErrors: <P extends string>({
|
|
101
|
-
flash
|
|
102
|
-
}: {
|
|
103
|
-
flash: Ref<Flash>;
|
|
104
|
-
}) => {
|
|
105
|
-
externalErrors: _vue_reactivity0.WritableComputedRef<Partial<Record<P, string[]>>, Partial<Record<P, string[]>>>;
|
|
106
|
-
clearExternalErrors: () => void;
|
|
107
|
-
isSuccess: () => boolean;
|
|
108
|
-
};
|
|
109
|
-
//#endregion
|
|
110
|
-
//#region src/types/error-messages.d.ts
|
|
111
|
-
type ErrorMessages<T extends string> = Partial<Record<T, string[]>>;
|
|
112
|
-
//#endregion
|
|
113
75
|
//#region src/composables/backend/use-alert.d.ts
|
|
114
76
|
interface UseAlertOptions {
|
|
115
77
|
flash: Ref<Flash>;
|
|
@@ -131,39 +93,12 @@ declare const useAlert: <BER extends object = BackendErrorResource>({
|
|
|
131
93
|
};
|
|
132
94
|
type UseAlertType = ReturnType<typeof useAlert>;
|
|
133
95
|
//#endregion
|
|
134
|
-
//#region src/composables/
|
|
135
|
-
declare const
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
declare const useEntity: <M extends object, R extends object = M>() => {
|
|
141
|
-
create: ({
|
|
142
|
-
from
|
|
143
|
-
}: {
|
|
144
|
-
from: R | M;
|
|
145
|
-
}) => M;
|
|
146
|
-
copy: ({
|
|
147
|
-
from,
|
|
148
|
-
to
|
|
149
|
-
}: {
|
|
150
|
-
from: R | M;
|
|
151
|
-
to: M;
|
|
152
|
-
}) => void;
|
|
153
|
-
};
|
|
154
|
-
//#endregion
|
|
155
|
-
//#region src/composables/use-flash.d.ts
|
|
156
|
-
declare const useFlash: () => {
|
|
157
|
-
flash: _vue_reactivity0.Ref<{
|
|
158
|
-
notice?: string | undefined;
|
|
159
|
-
alert?: string | undefined;
|
|
160
|
-
}, Flash | {
|
|
161
|
-
notice?: string | undefined;
|
|
162
|
-
alert?: string | undefined;
|
|
163
|
-
}>;
|
|
164
|
-
clearFlash: () => void;
|
|
165
|
-
};
|
|
166
|
-
type UseFlashType = ReturnType<typeof useFlash>;
|
|
96
|
+
//#region src/composables/ui/dom/use-element.d.ts
|
|
97
|
+
declare const useElement: <EL extends Element, P extends string>(el: EL | undefined | null, {
|
|
98
|
+
property
|
|
99
|
+
}: {
|
|
100
|
+
property: P;
|
|
101
|
+
}) => Record<P, Ref<string, string | null | undefined>>;
|
|
167
102
|
//#endregion
|
|
168
103
|
//#region node_modules/.pnpm/@vue+shared@3.5.30/node_modules/@vue/shared/dist/shared.d.ts
|
|
169
104
|
type Prettify<T> = { [K in keyof T]: T[K] } & {};
|
|
@@ -21617,20 +21552,20 @@ declare module '@vue/runtime-core' {
|
|
|
21617
21552
|
//#endregion
|
|
21618
21553
|
//#region src/composables/use-locale.d.ts
|
|
21619
21554
|
declare const useLocale: () => {
|
|
21620
|
-
locale: WritableComputedRef<"en" | "ja", "en" | "ja">;
|
|
21555
|
+
locale: WritableComputedRef$1<"en" | "ja", "en" | "ja">;
|
|
21621
21556
|
autodetect: () => void;
|
|
21622
21557
|
};
|
|
21623
21558
|
//#endregion
|
|
21624
21559
|
//#region src/composables/use-nano-route.d.ts
|
|
21625
21560
|
declare const useNanoRoute: <T extends RouterConfig>(router: Router<T>) => {
|
|
21626
|
-
params: _nanostores_router0.ParamsFromConfig<T>[string] | _nanostores_router0.ParamsFromConfig<T>[number] | _nanostores_router0.ParamsFromConfig<T>[symbol] | undefined;
|
|
21561
|
+
params: _$_nanostores_router0.ParamsFromConfig<T>[string] | _$_nanostores_router0.ParamsFromConfig<T>[number] | _$_nanostores_router0.ParamsFromConfig<T>[symbol] | undefined;
|
|
21627
21562
|
query: Record<string, string> | undefined;
|
|
21628
21563
|
path: string | undefined;
|
|
21629
21564
|
};
|
|
21630
21565
|
type UseNanoRouteType = ReturnType<typeof useNanoRoute>;
|
|
21631
21566
|
//#endregion
|
|
21632
21567
|
//#region src/i18n/i18n.d.ts
|
|
21633
|
-
declare const i18n: vue_i18n0.I18n<{
|
|
21568
|
+
declare const i18n: _$vue_i18n0.I18n<{
|
|
21634
21569
|
en: {
|
|
21635
21570
|
backend: {
|
|
21636
21571
|
error: {
|
|
@@ -21651,4 +21586,4 @@ declare const i18n: vue_i18n0.I18n<{
|
|
|
21651
21586
|
};
|
|
21652
21587
|
}, {}, {}, string, false>;
|
|
21653
21588
|
//#endregion
|
|
21654
|
-
export { type BackendErrorInfo, type BackendErrorResource, type ErrorMessages, type ErrorsResource, type Flash, type UseAlertType, type UseFlashType, type UseNanoRouteType, i18n, useAlert, useApiConstants, useDate, useEntity, useExternalErrors, useFlash, useLocale, useMutationApi, useNanoRoute, useOFetch, useQueryApi };
|
|
21589
|
+
export { type BackendErrorInfo, type BackendErrorResource, type ErrorMessages, type ErrorsResource, type Flash, type UseAlertType, type UseFlashType, type UseNanoRouteType, i18n, useAlert, useApiConstants, useDate, useElement, useEntity, useExternalErrors, useFlash, useLocale, useMutationApi, useNanoRoute, useOFetch, useQueryApi };
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useBackendErrorInfo, useDate, useEntity, useExternalErrors, useFlash } from "@vesperjs/shared";
|
|
1
2
|
import { computed, ref } from "@vue/reactivity";
|
|
2
3
|
import { persistentAtom } from "@nanostores/persistent";
|
|
3
4
|
import { ofetch } from "ofetch";
|
|
@@ -147,48 +148,6 @@ const useMutationApi = async function(url, { method, body = {}, token = null, on
|
|
|
147
148
|
};
|
|
148
149
|
};
|
|
149
150
|
//#endregion
|
|
150
|
-
//#region src/composables/backend/error/use-external-errors.ts
|
|
151
|
-
const useExternalErrors = function({ flash }) {
|
|
152
|
-
const errors = ref({});
|
|
153
|
-
const externalErrors = computed({
|
|
154
|
-
get() {
|
|
155
|
-
return errors.value;
|
|
156
|
-
},
|
|
157
|
-
set(value) {
|
|
158
|
-
if (errors.value) for (const key in value) errors.value[key] = value[key] ?? [];
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
const clearExternalErrors = () => {
|
|
162
|
-
externalErrors.value = {};
|
|
163
|
-
};
|
|
164
|
-
const isSuccess = () => {
|
|
165
|
-
let result = true;
|
|
166
|
-
for (const key in errors.value) if (errors.value[key].length > 0) result = false;
|
|
167
|
-
if (flash.value.alert) result = false;
|
|
168
|
-
return result;
|
|
169
|
-
};
|
|
170
|
-
return {
|
|
171
|
-
externalErrors,
|
|
172
|
-
clearExternalErrors,
|
|
173
|
-
isSuccess
|
|
174
|
-
};
|
|
175
|
-
};
|
|
176
|
-
//#endregion
|
|
177
|
-
//#region src/composables/backend/error/use-backend-error-info.ts
|
|
178
|
-
const useBackendErrorInfo = function() {
|
|
179
|
-
const info = ref({});
|
|
180
|
-
const backendErrorInfo = computed(() => {
|
|
181
|
-
return info.value;
|
|
182
|
-
});
|
|
183
|
-
const clearBackendErrorInfo = () => {
|
|
184
|
-
info.value = {};
|
|
185
|
-
};
|
|
186
|
-
return {
|
|
187
|
-
backendErrorInfo,
|
|
188
|
-
clearBackendErrorInfo
|
|
189
|
-
};
|
|
190
|
-
};
|
|
191
|
-
//#endregion
|
|
192
151
|
//#region src/composables/backend/use-alert.ts
|
|
193
152
|
const useAlert = function({ flash, caller }) {
|
|
194
153
|
const { backendErrorInfo, clearBackendErrorInfo } = useBackendErrorInfo();
|
|
@@ -233,40 +192,18 @@ const useAlert = function({ flash, caller }) {
|
|
|
233
192
|
};
|
|
234
193
|
};
|
|
235
194
|
//#endregion
|
|
236
|
-
//#region src/composables/
|
|
237
|
-
const
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
Object.assign(model, from);
|
|
249
|
-
return model;
|
|
250
|
-
};
|
|
251
|
-
const copy = ({ from, to }) => {
|
|
252
|
-
Object.assign(to, from);
|
|
253
|
-
};
|
|
254
|
-
return {
|
|
255
|
-
create,
|
|
256
|
-
copy
|
|
257
|
-
};
|
|
258
|
-
};
|
|
259
|
-
//#endregion
|
|
260
|
-
//#region src/composables/use-flash.ts
|
|
261
|
-
const useFlash = function() {
|
|
262
|
-
const flash = ref({});
|
|
263
|
-
const clearFlash = () => {
|
|
264
|
-
flash.value = {};
|
|
265
|
-
};
|
|
266
|
-
return {
|
|
267
|
-
flash,
|
|
268
|
-
clearFlash
|
|
269
|
-
};
|
|
195
|
+
//#region src/composables/ui/dom/use-element.ts
|
|
196
|
+
const useElement = function(el, { property }) {
|
|
197
|
+
const obj = {};
|
|
198
|
+
obj[property] = computed({
|
|
199
|
+
get() {
|
|
200
|
+
return el && property in el ? el[property] : "";
|
|
201
|
+
},
|
|
202
|
+
set(value) {
|
|
203
|
+
if (el && property in el) el[property] = value ?? "";
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
return obj;
|
|
270
207
|
};
|
|
271
208
|
//#endregion
|
|
272
209
|
//#region src/composables/use-nano-route.ts
|
|
@@ -279,4 +216,4 @@ const useNanoRoute = function(router) {
|
|
|
279
216
|
};
|
|
280
217
|
};
|
|
281
218
|
//#endregion
|
|
282
|
-
export { i18n, useAlert, useApiConstants, useDate, useEntity, useExternalErrors, useFlash, useLocale, useMutationApi, useNanoRoute, useOFetch, useQueryApi };
|
|
219
|
+
export { i18n, useAlert, useApiConstants, useDate, useElement, useEntity, useExternalErrors, useFlash, useLocale, useMutationApi, useNanoRoute, useOFetch, useQueryApi };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesperjs/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"vue.js"
|
|
6
6
|
],
|
|
@@ -22,21 +22,22 @@
|
|
|
22
22
|
"@formkit/tempo": "^1.0.0",
|
|
23
23
|
"@nanostores/persistent": "^1.3.3",
|
|
24
24
|
"@nanostores/router": "^1.0.0",
|
|
25
|
+
"@vesperjs/shared": "0.2.0",
|
|
25
26
|
"@vue/reactivity": "^3.6.0-beta.9",
|
|
26
27
|
"nanostores": "^1.2.0",
|
|
27
28
|
"ofetch": "^1.5.1",
|
|
28
|
-
"undici": "^
|
|
29
|
+
"undici": "^8.0.1",
|
|
29
30
|
"vue-i18n": "^11.3.0"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@eslint/js": "^9.39.4",
|
|
33
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
34
|
-
"@typescript-eslint/parser": "^8.
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "^8.58.0",
|
|
35
|
+
"@typescript-eslint/parser": "^8.58.0",
|
|
35
36
|
"@vue/eslint-config-typescript": "^14.7.0",
|
|
36
37
|
"eslint": "^9.39.4",
|
|
37
38
|
"eslint-plugin-vue": "^10.8.0",
|
|
38
|
-
"oxfmt": "^0.
|
|
39
|
-
"tsdown": "^0.21.
|
|
39
|
+
"oxfmt": "^0.43.0",
|
|
40
|
+
"tsdown": "^0.21.7",
|
|
40
41
|
"typescript": "^5.9.3"
|
|
41
42
|
},
|
|
42
43
|
"scripts": {
|