zustic 1.1.3 → 1.1.5
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/i18n/index.d.mts +13 -5
- package/dist/i18n/index.d.ts +13 -5
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/index.mjs +1 -1
- package/package.json +1 -1
package/dist/i18n/index.d.mts
CHANGED
|
@@ -13,12 +13,20 @@ type NestedKeys<T, D extends number = 9> = D extends never ? never : T extends o
|
|
|
13
13
|
}[keyof T & string] : never;
|
|
14
14
|
type TranslationKey<T> = NestedKeys<T> & string;
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
t
|
|
16
|
+
interface I18nInstance<T = any, L = any> {
|
|
17
|
+
t(key: TranslationKey<T>): string;
|
|
18
18
|
lan: L;
|
|
19
|
-
updateTranslation
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
updateTranslation(lang: L): void;
|
|
20
|
+
}
|
|
21
|
+
declare function createI18n<T = any, L = any>(params: I18nParams<T, L>): {
|
|
22
|
+
useTranslation: () => {
|
|
23
|
+
t: (key: TranslationKey<T>) => string;
|
|
24
|
+
lan: L;
|
|
25
|
+
updateTranslation: (lang: L) => void;
|
|
26
|
+
isUpdating: boolean;
|
|
27
|
+
isInitialLoading: boolean;
|
|
28
|
+
};
|
|
29
|
+
i18n: I18nInstance<T, L>;
|
|
22
30
|
};
|
|
23
31
|
|
|
24
32
|
export { createI18n };
|
package/dist/i18n/index.d.ts
CHANGED
|
@@ -13,12 +13,20 @@ type NestedKeys<T, D extends number = 9> = D extends never ? never : T extends o
|
|
|
13
13
|
}[keyof T & string] : never;
|
|
14
14
|
type TranslationKey<T> = NestedKeys<T> & string;
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
t
|
|
16
|
+
interface I18nInstance<T = any, L = any> {
|
|
17
|
+
t(key: TranslationKey<T>): string;
|
|
18
18
|
lan: L;
|
|
19
|
-
updateTranslation
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
updateTranslation(lang: L): void;
|
|
20
|
+
}
|
|
21
|
+
declare function createI18n<T = any, L = any>(params: I18nParams<T, L>): {
|
|
22
|
+
useTranslation: () => {
|
|
23
|
+
t: (key: TranslationKey<T>) => string;
|
|
24
|
+
lan: L;
|
|
25
|
+
updateTranslation: (lang: L) => void;
|
|
26
|
+
isUpdating: boolean;
|
|
27
|
+
isInitialLoading: boolean;
|
|
28
|
+
};
|
|
29
|
+
i18n: I18nInstance<T, L>;
|
|
22
30
|
};
|
|
23
31
|
|
|
24
32
|
export { createI18n };
|
package/dist/i18n/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var y=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var v=(a,e)=>{for(var t in e)y(a,t,{get:e[t],enumerable:!0})},x=(a,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of w(e))!M.call(a,i)&&i!==t&&y(a,i,{get:()=>e[i],enumerable:!(n=h(e,i))||n.enumerable});return a};var b=a=>x(y({},"__esModule",{value:!0}),a);var C={};v(C,{createI18n:()=>K});module.exports=b(C);var g=require("react");function I(a,e=[]){let t,n=[],i=r=>{let s=typeof r=="function"?r(t):r;t={...t,...s},n.forEach(l=>l())},d=()=>t,p=E(i,d,e);t=a(p,d);let o=r=>(n.push(r),()=>{n=n.filter(s=>s!==r)});return(r=s=>s)=>(0,g.useSyncExternalStore)(o,()=>r(t))}var E=(a,e,t)=>!t||t.length===0?a:t.reduceRight((n,i)=>i(a,e)(n),a);var P=require("react");function K(a){let{resource:e,initialLan:t}=a,n={t:()=>"",updateTranslation:()=>{},lan:""},i=0,d=I((o,r)=>({lan:t,data:null,isUpdating:!1,isInitialLoading:!0,async load(s){let l=++i,u=r().data===null;o({isUpdating:!u,isInitialLoading:u});let c=await Promise.resolve(e(s));l===i&&o({data:c,isUpdating:!1,isInitialLoading:!1})},update(s){o({lan:s})}}));function p(){let{lan:o,data:r,update:s,isUpdating:l,isInitialLoading:u,load:c}=d();(0,P.useEffect)(()=>{c(o)},[o]);function L(T){var S;return!r||u?"":(S=T.split(".").reduce((f,U)=>f==null?void 0:f[U],r))!=null?S:T}function m(T){s(T)}return n.t=L,n.lan=o,n.updateTranslation=m,{t:L,lan:o,updateTranslation:m,isUpdating:l,isInitialLoading:u}}return{useTranslation:p,i18n:n}}0&&(module.exports={createI18n});
|
package/dist/i18n/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{a as
|
|
1
|
+
"use client";import{a as L}from"../chunk-RXPCG2VZ.mjs";import{useEffect as U}from"react";function S(c){let{resource:f,initialLan:I}=c,i={t:()=>"",updateTranslation:()=>{},lan:""},u=0,y=L((n,e)=>({lan:I,data:null,isUpdating:!1,isInitialLoading:!0,async load(a){let r=++u,t=e().data===null;n({isUpdating:!t,isInitialLoading:t});let o=await Promise.resolve(f(a));r===u&&n({data:o,isUpdating:!1,isInitialLoading:!1})},update(a){n({lan:a})}}));function g(){let{lan:n,data:e,update:a,isUpdating:r,isInitialLoading:t,load:o}=y();U(()=>{o(n)},[n]);function d(s){var T;return!e||t?"":(T=s.split(".").reduce((l,m)=>l==null?void 0:l[m],e))!=null?T:s}function p(s){a(s)}return i.t=d,i.lan=n,i.updateTranslation=p,{t:d,lan:n,updateTranslation:p,isUpdating:r,isInitialLoading:t}}return{useTranslation:g,i18n:i}}export{S as createI18n};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zustic",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "A fast, minimal state management solution for React ecosystems. Works seamlessly with React, Next.js, and React Native, offering predictable state updates with a tiny footprint.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsup",
|