@anweb/nuxt-ancore 1.9.1 → 1.9.2
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,6 +1,6 @@
|
|
|
1
|
-
declare const _default: (resources?: Record<string, any>) => {
|
|
1
|
+
declare const _default: (resources?: Record<string, any>) => Promise<{
|
|
2
2
|
t: import("i18next").TFunction<["translation", ...string[]], undefined>;
|
|
3
3
|
} | {
|
|
4
4
|
t: (key: string, options?: {}) => string;
|
|
5
|
-
}
|
|
5
|
+
}>;
|
|
6
6
|
export default _default;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import i18next from "i18next";
|
|
2
2
|
import { getJSONHash } from "../utils/index.js";
|
|
3
|
-
export default (resources) => {
|
|
3
|
+
export default async (resources) => {
|
|
4
4
|
if (!resources) return { t: i18next.t };
|
|
5
|
-
const ns = getJSONHash(resources);
|
|
5
|
+
const ns = await getJSONHash(resources);
|
|
6
6
|
for (const lang in resources) {
|
|
7
7
|
if (!i18next.hasResourceBundle(lang, ns)) {
|
|
8
8
|
i18next.addResourceBundle(lang, ns, resources[lang]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const getJSONHash: (obj: object) => string
|
|
1
|
+
export declare const getJSONHash: (obj: object) => Promise<string>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export const getJSONHash = async (obj) => {
|
|
2
|
+
const str = JSON.stringify(obj);
|
|
3
|
+
const bytes = new TextEncoder().encode(str);
|
|
4
|
+
const digest = await crypto.subtle.digest("SHA-256", bytes);
|
|
5
|
+
return Array.from(new Uint8Array(digest)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
4
6
|
};
|