@anweb/nuxt-ancore 1.8.6 → 1.9.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/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "AnCore",
3
3
  "configKey": "ancore",
4
- "version": "1.8.6",
4
+ "version": "1.9.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.1",
7
7
  "unbuild": "3.5.0"
@@ -1,5 +1,6 @@
1
1
  import type { NitroFetchOptions, NitroFetchRequest } from 'nitropack';
2
2
  import { type Ref, type ComputedRef } from 'vue';
3
+ import type { KeysOf, PickFrom } from '#app/composables/asyncData';
3
4
  import { useAsyncData } from '#app';
4
5
  interface TConfig {
5
6
  request: NitroFetchRequest;
@@ -10,7 +11,7 @@ interface TUseAnData<TData, TError> {
10
11
  set: (data: TData) => void;
11
12
  loading: ComputedRef<boolean>;
12
13
  request: Ref<NitroFetchRequest>;
13
- data: ComputedRef<TData>;
14
+ data: Ref<PickFrom<TData, KeysOf<TData>> | undefined, PickFrom<TData, KeysOf<TData>> | undefined>;
14
15
  error: ComputedRef<TError>;
15
16
  status: ReturnType<typeof useAsyncData>['status'];
16
17
  }
@@ -1,4 +1,4 @@
1
- declare const _default: (resources?: Record<string, any>, ns?: string) => {
1
+ declare const _default: (resources?: Record<string, any>) => {
2
2
  t: import("i18next").TFunction<["translation", ...string[]], undefined>;
3
3
  } | {
4
4
  t: (key: string, options?: {}) => string;
@@ -1,6 +1,8 @@
1
1
  import i18next from "i18next";
2
- export default (resources, ns) => {
3
- if (!ns) return { t: i18next.t };
2
+ import { getJSONHash } from "../utils/index.js";
3
+ export default (resources) => {
4
+ if (!resources) return { t: i18next.t };
5
+ const ns = getJSONHash(resources);
4
6
  for (const lang in resources) {
5
7
  if (!i18next.hasResourceBundle(lang, ns)) {
6
8
  i18next.addResourceBundle(lang, ns, resources[lang]);
@@ -0,0 +1 @@
1
+ export declare const getJSONHash: (obj: object) => string;
@@ -0,0 +1,4 @@
1
+ import SHA256 from "crypto-js/sha256";
2
+ export const getJSONHash = (obj) => {
3
+ return SHA256(JSON.stringify(obj)).toString();
4
+ };
@@ -1,4 +1,5 @@
1
1
  export * from './asyncInit.js';
2
2
  export * from './coreApi.js';
3
- export * from './userApi.js';
3
+ export * from './getJSONHash.js';
4
4
  export * from './toQuery.js';
5
+ export * from './userApi.js';
@@ -1,4 +1,5 @@
1
1
  export * from "./asyncInit.js";
2
2
  export * from "./coreApi.js";
3
- export * from "./userApi.js";
3
+ export * from "./getJSONHash.js";
4
4
  export * from "./toQuery.js";
5
+ export * from "./userApi.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anweb/nuxt-ancore",
3
- "version": "1.8.6",
3
+ "version": "1.9.0",
4
4
  "description": "AnCore Nuxt module",
5
5
  "repository": "https://github.com/ANLTD/ancore",
6
6
  "license": "MIT",
@@ -36,12 +36,14 @@
36
36
  "@vueuse/core": "^13.5.0",
37
37
  "@vueuse/integrations": "^13.5.0",
38
38
  "async-validator": "^4.2.5",
39
+ "crypto-js": "^4.2.0",
39
40
  "i18next": "^25.3.2"
40
41
  },
41
42
  "devDependencies": {
42
43
  "@nuxt/devtools": "^2.6.2",
43
44
  "@nuxt/module-builder": "^1.0.1",
44
45
  "@nuxt/schema": "^4.0.1",
46
+ "@types/crypto-js": "^4.2.2",
45
47
  "@types/node": "latest",
46
48
  "changelogen": "^0.6.2",
47
49
  "nuxt": "^4.0.1",