@vesperjs/vue 0.1.9 → 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 CHANGED
@@ -1,5 +1,5 @@
1
- import * as _$_vue_reactivity0 from "@vue/reactivity";
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
4
  import * as _$vue_i18n0 from "vue-i18n";
5
5
  import * as _$_nanostores_router0 from "@nanostores/router";
@@ -7,7 +7,7 @@ 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: _$_vue_reactivity0.WritableComputedRef<string, string>;
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>;
@@ -138,40 +100,6 @@ declare const useElement: <EL extends Element, P extends string>(el: EL | undefi
138
100
  property: P;
139
101
  }) => Record<P, Ref<string, string | null | undefined>>;
140
102
  //#endregion
141
- //#region src/composables/util/use-date.d.ts
142
- declare const useDate: () => {
143
- isValidDate: (str: string) => boolean;
144
- };
145
- //#endregion
146
- //#region src/composables/use-entity.d.ts
147
- declare const useEntity: <M extends object, R extends object = M>() => {
148
- create: ({
149
- from
150
- }: {
151
- from: R | M;
152
- }) => M;
153
- copy: ({
154
- from,
155
- to
156
- }: {
157
- from: R | M;
158
- to: M;
159
- }) => void;
160
- };
161
- //#endregion
162
- //#region src/composables/use-flash.d.ts
163
- declare const useFlash: () => {
164
- flash: _$_vue_reactivity0.Ref<{
165
- notice?: string | undefined;
166
- alert?: string | undefined;
167
- }, Flash | {
168
- notice?: string | undefined;
169
- alert?: string | undefined;
170
- }>;
171
- clearFlash: () => void;
172
- };
173
- type UseFlashType = ReturnType<typeof useFlash>;
174
- //#endregion
175
103
  //#region node_modules/.pnpm/@vue+shared@3.5.30/node_modules/@vue/shared/dist/shared.d.ts
176
104
  type Prettify<T> = { [K in keyof T]: T[K] } & {};
177
105
  type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
@@ -21624,7 +21552,7 @@ declare module '@vue/runtime-core' {
21624
21552
  //#endregion
21625
21553
  //#region src/composables/use-locale.d.ts
21626
21554
  declare const useLocale: () => {
21627
- locale: WritableComputedRef<"en" | "ja", "en" | "ja">;
21555
+ locale: WritableComputedRef$1<"en" | "ja", "en" | "ja">;
21628
21556
  autodetect: () => void;
21629
21557
  };
21630
21558
  //#endregion
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();
@@ -235,7 +194,8 @@ const useAlert = function({ flash, caller }) {
235
194
  //#endregion
236
195
  //#region src/composables/ui/dom/use-element.ts
237
196
  const useElement = function(el, { property }) {
238
- const propertyRef = computed({
197
+ const obj = {};
198
+ obj[property] = computed({
239
199
  get() {
240
200
  return el && property in el ? el[property] : "";
241
201
  },
@@ -243,47 +203,9 @@ const useElement = function(el, { property }) {
243
203
  if (el && property in el) el[property] = value ?? "";
244
204
  }
245
205
  });
246
- const obj = {};
247
- obj[property] = propertyRef;
248
206
  return obj;
249
207
  };
250
208
  //#endregion
251
- //#region src/composables/util/use-date.ts
252
- const useDate = function() {
253
- const isValidDate = (str) => {
254
- return !!str && !!str.match(/\d{4}\/\d{2}\/\d{2}/) && !isNaN(Date.parse(str));
255
- };
256
- return { isValidDate };
257
- };
258
- //#endregion
259
- //#region src/composables/use-entity.ts
260
- const useEntity = function() {
261
- const create = ({ from }) => {
262
- const model = {};
263
- Object.assign(model, from);
264
- return model;
265
- };
266
- const copy = ({ from, to }) => {
267
- Object.assign(to, from);
268
- };
269
- return {
270
- create,
271
- copy
272
- };
273
- };
274
- //#endregion
275
- //#region src/composables/use-flash.ts
276
- const useFlash = function() {
277
- const flash = ref({});
278
- const clearFlash = () => {
279
- flash.value = {};
280
- };
281
- return {
282
- flash,
283
- clearFlash
284
- };
285
- };
286
- //#endregion
287
209
  //#region src/composables/use-nano-route.ts
288
210
  const useNanoRoute = function(router) {
289
211
  const page = router.get();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vesperjs/vue",
3
- "version": "0.1.9",
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": "^7.24.6",
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.57.2",
34
- "@typescript-eslint/parser": "^8.57.2",
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.42.0",
39
- "tsdown": "^0.21.6",
39
+ "oxfmt": "^0.43.0",
40
+ "tsdown": "^0.21.7",
40
41
  "typescript": "^5.9.3"
41
42
  },
42
43
  "scripts": {