@anweb/nuxt-ancore 1.10.6 → 1.10.8

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.10.6",
4
+ "version": "1.10.8",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -4,11 +4,7 @@ interface TStructureItem<TData> {
4
4
  default: TData;
5
5
  rules?: RuleItem[];
6
6
  }
7
- interface TFormParams<TForm> {
8
- structure: Record<keyof TForm, TStructureItem<TForm[keyof TForm]>>;
9
- data?: Partial<TForm> | null;
10
- }
11
- export declare const useAnForm: <TForm extends object>(params: TFormParams<TForm>) => {
7
+ export declare const useAnForm: <TForm extends object>(params: Record<keyof TForm, TStructureItem<TForm[keyof TForm]>>, data?: Partial<TForm> | null) => {
12
8
  state: [TForm] extends [import("vue").Ref<any, any>] ? import("@vue/shared").IfAny<TForm, import("vue").Ref<TForm, TForm>, TForm> : import("vue").Ref<import("vue").UnwrapRef<TForm>, TForm | import("vue").UnwrapRef<TForm>>;
13
9
  merge: (data: TForm) => void;
14
10
  validator: {
@@ -3,12 +3,12 @@ import { useRefHistory } from "@vueuse/core";
3
3
  import {
4
4
  useAsyncValidator
5
5
  } from "@vueuse/integrations/useAsyncValidator";
6
- export const useAnForm = (params) => {
6
+ export const useAnForm = (params, data) => {
7
7
  const state = ref(
8
8
  Object.fromEntries(
9
- Object.entries(params.structure).map(([k, v]) => {
9
+ Object.entries(params).map(([k, v]) => {
10
10
  const key = k;
11
- return [key, params.data?.[key] ?? v.default];
11
+ return [key, data?.[key] ?? v.default];
12
12
  })
13
13
  )
14
14
  );
@@ -17,20 +17,20 @@ export const useAnForm = (params) => {
17
17
  const History = useRefHistory(state, { deep: true });
18
18
  const errors = ref({});
19
19
  const init = () => {
20
- if (params.data) merge(params.data);
20
+ if (data) merge(data);
21
21
  initValidate();
22
22
  void nextTick(History.clear);
23
23
  };
24
- const merge = (data) => {
24
+ const merge = (data2) => {
25
25
  for (const key of keys) {
26
- state.value[key] = data[key];
26
+ state.value[key] = data2[key];
27
27
  }
28
28
  };
29
29
  const initValidate = () => {
30
30
  const rules = {};
31
31
  for (const key of keys) {
32
- if (!params.structure[key].rules) continue;
33
- rules[key] = params.structure[key].rules;
32
+ if (!params[key].rules) continue;
33
+ rules[key] = params[key].rules;
34
34
  }
35
35
  const validator = useAsyncValidator(
36
36
  state,
@@ -63,8 +63,8 @@ export const useAnForm = (params) => {
63
63
  init();
64
64
  return {
65
65
  state,
66
- merge: (data) => {
67
- merge(data);
66
+ merge: (data2) => {
67
+ merge(data2);
68
68
  },
69
69
  validator: {
70
70
  check: () => {
@@ -1,8 +1,5 @@
1
- import { sha256 } from "@noble/hashes/sha2";
2
- import { utf8ToBytes, bytesToHex } from "@noble/hashes/utils";
1
+ import { sha256 } from "js-sha256";
3
2
  export const getJSONHash = (obj) => {
4
- const s = JSON.stringify(obj);
5
- const bytes = utf8ToBytes(s);
6
- const digest = sha256(bytes);
7
- return bytesToHex(digest);
3
+ const json = JSON.stringify(obj);
4
+ return sha256(json);
8
5
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anweb/nuxt-ancore",
3
- "version": "1.10.6",
3
+ "version": "1.10.8",
4
4
  "description": "AnCore Nuxt module",
5
5
  "repository": "https://github.com/ANLTD/ancore",
6
6
  "license": "MIT",
@@ -32,12 +32,12 @@
32
32
  "release:major": "npm run prepack && changelogen --major --release && npm publish --access public && git push --follow-tags && changelogen gh release"
33
33
  },
34
34
  "dependencies": {
35
- "@noble/hashes": "^2.0.0",
36
35
  "@nuxt/kit": "^4.1.2",
37
36
  "@vueuse/core": "^13.9.0",
38
37
  "@vueuse/integrations": "^13.9.0",
39
38
  "async-validator": "^4.2.5",
40
- "i18next": "^25.5.2"
39
+ "i18next": "^25.5.2",
40
+ "js-sha256": "^0.11.1"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@nuxt/devtools": "^2.6.3",
@@ -48,4 +48,4 @@
48
48
  "nuxt": "^4.1.2",
49
49
  "typescript": "~5.9.2"
50
50
  }
51
- }
51
+ }