gt-react 9.0.10-alpha.3 → 9.1.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/client.cjs.min.cjs +3 -3
- package/dist/client.d.ts +9 -12
- package/dist/client.esm.min.mjs +3 -3
- package/dist/index.cjs.min.cjs +3 -3
- package/dist/index.esm.min.mjs +3 -3
- package/dist/inline/T.d.ts.map +1 -1
- package/dist/internal.cjs.min.cjs +1 -1
- package/dist/internal.d.ts +2 -3
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.esm.min.mjs +1 -1
- package/dist/provider/ClientProvider.d.ts +1 -1
- package/dist/provider/ClientProvider.d.ts.map +1 -1
- package/dist/provider/GTProvider.d.ts +1 -2
- package/dist/provider/GTProvider.d.ts.map +1 -1
- package/dist/provider/helpers/{extractEntryMetadata.d.ts → getEntryAndMetadata.d.ts} +2 -2
- package/dist/provider/helpers/getEntryAndMetadata.d.ts.map +1 -0
- package/dist/provider/rendering/defaultRenderSettings.d.ts +1 -1
- package/dist/provider/rendering/defaultRenderSettings.d.ts.map +1 -1
- package/dist/provider/runtime/useRuntimeTranslation.d.ts +3 -3
- package/dist/provider/runtime/useRuntimeTranslation.d.ts.map +1 -1
- package/dist/types/types.d.ts +4 -6
- package/dist/types/types.d.ts.map +1 -1
- package/dist/utils/fetchTranslations.d.ts +6 -1
- package/dist/utils/fetchTranslations.d.ts.map +1 -1
- package/dist/utils/utils.d.ts +1 -3
- package/dist/utils/utils.d.ts.map +1 -1
- package/package.json +6 -6
- package/dist/provider/helpers/extractEntryMetadata.d.ts.map +0 -1
- package/dist/utils/getKey.d.ts +0 -2
- package/dist/utils/getKey.d.ts.map +0 -1
package/dist/internal.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,8BAA8B,CAAC;AAC7D,OAAO,eA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ChB,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,kBAAkB,EAClB,WAAW,EACX,qBAAqB,EACrB,gBAAgB,EAChB,QAAQ,EACR,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EACxB,cAAc,EACd,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,QAAQ,EACR,KAAK,EACL,MAAM,EACN,KAAK,EACL,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,mBAAmB,GACpB,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
import e,{isValidElement as r}from"react";import{jsx as n}from"react/jsx-runtime";import"generaltranslation";const t=e=>`Duplicate key found in dictionary: "${e}"`;function a(r,n=""){const i={};for(const o in r)if(r.hasOwnProperty(o)){const l=n?`${n}.${o}`:o;if("object"!=typeof r[o]||null===r[o]||Array.isArray(r[o])||e.isValidElement(r[o])){if(i.hasOwnProperty(l))throw new Error(t(l));i[l]=r[o]}else{const e=a(r[o],l);for(const r in e){if(i.hasOwnProperty(r))throw new Error(t(r));i[r]=e[r]}}}return i}function i(e,r){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&r.indexOf(t)<0&&(n[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(t=Object.getOwnPropertySymbols(e);a<t.length;a++)r.indexOf(t[a])<0&&Object.prototype.propertyIsEnumerable.call(e,t[a])&&(n[t[a]]=e[t[a]])}return n}"function"==typeof SuppressedError&&SuppressedError;var o="en-US",l=["singular","plural","dual","zero","one","two","few","many","other"];const s=e=>`gt-react: No dictionary entry found for id: "${e}"`;function c(t,a=0){let o=a;const s=e=>{const{type:r,props:n}=e;o+=1;let t,a={id:o};try{t="function"==typeof r&&r.gtTransformation||""}catch(e){t=""}if(t){const r=t.split("-");if("translate"===r[0])throw new Error((e=>{var r;return`General Translation: Nested <T> components. The inner <T> has the id: "${null===(r=null==e?void 0:e.props)||void 0===r?void 0:r.id}".`})(e));if("variable"===r[0]&&(a.variableType=(null==r?void 0:r[1])||"variable"),"plural"===r[0]){const e=Object.entries(n).reduce(((e,[r,n])=>{var t;return t=r,l.includes(t)&&(e[r]=c(n,o)),e}),{});Object.keys(e).length&&(a.branches=e)}if("branch"===r[0]){const e=i(n,["children","branch"]),r=Object.entries(e).reduce(((e,[r,n])=>(e[r]=c(n,o),e)),{});Object.keys(r).length&&(a.branches=r)}a.transformation=r[0]}return a};function u(t){return r(t)?function(r){const{props:t}=r;if(t["data-_gt"])throw new Error((e=>`General Translation already in use on child with props: ${e.props}. This usually occurs when you nest <T> components within the same file. Remove one of the <T> components to continue.`)(r));let a=s(r),i=Object.assign(Object.assign({},t),{"data-_gt":a});if(t.children&&!a.variableType&&(i.children=d(t.children)),r.type===e.Fragment)return n("span",Object.assign({style:{all:"unset",display:"contents"}},i));return e.cloneElement(r,i)}(t):t}function d(r){return Array.isArray(r)?e.Children.map(r,u):u(r)}return d(t)}const u={variable:"value",number:"n",datetime:"date",currency:"cost"};function d(e="variable"){return u[e]||"variable"}const p="_gt_";function b(e={},r){var n;if(e.name)return e.name;if(e["data-_gt-variable-name"])return e["data-_gt-variable-name"];return`${p}${u[r]||"value"}_${null===(n=e["data-_gt"])||void 0===n?void 0:n.id}`}function f(r){if(e.isValidElement(r)&&r.type===e.Fragment){const n=r.props;return!n.children||0===e.Children.count(n.children)}return!1}const v=e=>{var r;if(!e)return"";const{type:n,props:t}=e;if(n&&"function"==typeof n){if("displayName"in n&&"string"==typeof n.displayName&&n.displayName)return n.displayName;if("name"in n&&"string"==typeof n.name&&n.name)return n.name}return n&&"string"==typeof n?n:t.href?"a":(null===(r=t["data-_gt"])||void 0===r?void 0:r.id)?`C${t["data-_gt"].id}`:"function"},y=r=>{return n=r,e.isValidElement(n)?(e=>{const{type:r,props:n}=e;let t={type:v(e),props:{}};if(n["data-_gt"]){const e=n["data-_gt"];let r=Object.assign({},e);const a=e.transformation;if("variable"===a){const r=e.variableType||"variable";return{variable:r,key:b(n,r),id:e.id}}if("plural"===a&&e.branches){t.type="Plural";let n={};Object.entries(e.branches).forEach((([e,r])=>{n[e]=h(r)})),r=Object.assign(Object.assign({},r),{branches:n})}if("branch"===a&&e.branches){t.type="Branch";let n={};Object.entries(e.branches).forEach((([e,r])=>{n[e]=h(r)})),r=Object.assign(Object.assign({},r),{branches:n})}t.props["data-_gt"]=r}return n.children&&(t.props.children=h(n.children)),t})(r):"number"==typeof r?r.toString():r;var n};function h(e){return Array.isArray(e)?e.map(y):y(e)}function g(e,r,n){let t="",a=null;return"number"==typeof e&&!a&&n&&(t=function(e,r,n){void 0===r&&(r=l),void 0===n&&(n=[o]);var t=new Intl.PluralRules(n).select(e),a=Math.abs(e);if(0===a&&r.includes("zero"))return"zero";if(1===a){if(r.includes("singular"))return"singular";if(r.includes("one"))return"one"}if("one"===t&&r.includes("singular"))return"singular";if(2===a){if(r.includes("dual"))return"dual";if(r.includes("two"))return"two"}return"two"===t&&r.includes("dual")?"dual":r.includes(t)?t:"two"===t&&r.includes("dual")?"dual":"two"===t&&r.includes("plural")?"plural":"two"===t&&r.includes("other")?"other":"few"===t&&r.includes("plural")?"plural":"few"===t&&r.includes("other")?"other":"many"===t&&r.includes("plural")?"plural":"many"===t&&r.includes("other")?"other":"other"===t&&r.includes("plural")?"plural":""}(e,Object.keys(n),r)),t&&!a&&(a=n[t]),a}function m(r,n){let t=r,a=n.split(".");for(const r of a){if("object"!=typeof t||Array.isArray(t)||e.isValidElement(t))return void console.error(s(n));t=t[r]}return t}function O(e){if(Array.isArray(e)){if(1===e.length)return{entry:e[0]};if(2===e.length)return{entry:e[0],metadata:e[1]}}return{entry:e}}function j(e){var r;const n=(null===(r=e["data-_gt"])||void 0===r?void 0:r.variableType)||"variable";return{variableType:n,variableName:b(e,n),variableValue:void 0!==e.value?e.value:void 0!==e["data-_gt-unformatted-value"]?e["data-_gt-unformatted-value"]:void 0!==e.children?e.children:void 0,variableOptions:(()=>{const r=Object.assign(Object.assign({},e.currency&&{currency:e.currency}),e.options&&Object.assign({},e.options));return Object.keys(r).length?r:"string"==typeof e["data-_gt-variable-options"]?JSON.parse(e["data-_gt-variable-options"]):e["data-_gt-variable-options"]||void 0})()}}function _(e){const r=e;if(r&&"object"==typeof r&&"string"==typeof r.key){const e=Object.keys(r);if(1===e.length)return!0;if(2===e.length){if("number"==typeof r.id)return!0;if("string"==typeof r.variable)return!0}if(3===e.length&&"string"==typeof r.variable&&"number"==typeof r.id)return!0}return!1}function E(e){return e&&e.props&&e.props["data-_gt"]?e.props["data-_gt"]:null}function w({children:r,variables:n={},variablesOptions:t={},defaultLocale:a=o,renderVariable:l}){const s=r=>e.isValidElement(r)?(r=>{const o=E(r);if("variable"===(null==o?void 0:o.transformation)){let{variableName:e,variableType:i,variableValue:o,variableOptions:s}=j(r.props);return o=(()=>{if(void 0!==n[e])return n[e];if(void 0!==o)return o;if(e.startsWith(p)){const e=d(i);if(void 0!==n[e])return n[e]}})(),s=Object.assign(Object.assign({},t[e]),s),l({variableName:e,variableType:i,variableValue:o,variableOptions:s,locales:[a]})}if("plural"===(null==o?void 0:o.transformation)){const e="number"==typeof n.n?n.n:"number"==typeof r.props.n?r.props.n:r.props["data-_gt-n"];"number"==typeof e&&void 0===n.n&&(n.n=e);const t=o.branches||{};return c(g(e,[a],t)||r.props.children)}if("branch"===(null==o?void 0:o.transformation)){let e=r.props,{children:t,name:a,branch:l,"data-_gt":s}=e,u=i(e,["children","name","branch","data-_gt"]);return a=a||r.props["data-_gt-name"]||"branch",l=n[a]||l||r.props["data-_gt-branch-name"],u=o.branches||{},c(void 0!==u[l]?u[l]:t)}return r.props.children?e.cloneElement(r,Object.assign(Object.assign({},r.props),{"data-_gt":void 0,children:c(r.props.children)})):e.cloneElement(r,Object.assign(Object.assign({},r.props),{"data-_gt":void 0}))})(r):r,c=r=>Array.isArray(r)?e.Children.map(r,s):s(r);return c(r)}function V({sourceElement:r,targetElement:n,variables:t={},variablesOptions:a={},locales:i=[o],renderVariable:l}){var s;const{props:c}=r,u=c["data-_gt"],d=null==u?void 0:u.transformation;if("plural"===d){const e="number"==typeof t.n?t.n:"number"==typeof r.props.n?r.props.n:r.props["data-_gt-n"],o=g(e,i,u.branches||{})||r.props.children,s=g(e,i,n.props["data-_gt"].branches||{})||n.props.children;return"number"==typeof e&&void 0===t.n&&(t.n=e),A({source:o,target:s,variables:t,variablesOptions:a,locales:i,renderVariable:l})}if("branch"===d){let{name:e,branch:o,children:s}=c;e=e||r.props["data-_gt-name"]||"branch",o=t[e]||o||r.props["data-_gt-branch-name"];return A({source:(u.branches||{})[o]||s,target:(n.props["data-_gt"].branches||{})[o]||n.props.children,variables:t,variablesOptions:a,locales:i,renderVariable:l})}return(null==c?void 0:c.children)&&(null===(s=n.props)||void 0===s?void 0:s.children)?e.cloneElement(r,Object.assign(Object.assign({},c),{"data-_gt":void 0,children:A({source:c.children,target:n.props.children,variables:t,variablesOptions:a,locales:i,renderVariable:l})})):w({children:r,variables:t,variablesOptions:a,defaultLocale:i[0],renderVariable:l})}function A({source:r,target:t,variables:a={},variablesOptions:i={},locales:l=[o],renderVariable:s}){if(null==t&&r)return w({children:r,variables:a,variablesOptions:i,defaultLocale:l[0],renderVariable:s});if("string"==typeof t)return t;if(Array.isArray(t)&&!Array.isArray(r)&&r&&(r=[r]),Array.isArray(r)&&Array.isArray(t)){const o=r.filter((r=>{if(e.isValidElement(r)){const e=E(r);if(j(r.props),"variable"!==(null==e?void 0:e.transformation))return!0;{let{variableName:e,variableValue:n,variableOptions:t,variableType:o}=j(r.props);void 0===a[e]&&(a[e]=n);const l=d(o);void 0===a[l]&&(a[l]=n),i[e]=Object.assign(Object.assign({},i[e]),t)}}})),c=e=>o.find((r=>{var n,t;const a=E(r);if(void 0!==(null==a?void 0:a.id)){return a.id===(null===(t=null===(n=null==e?void 0:e.props)||void 0===n?void 0:n["data-_gt"])||void 0===t?void 0:t.id)}return!1}));return t.map(((r,t)=>{if("string"==typeof r)return n(e.Fragment,{children:r},`string_${t}`);if(_(r)){const o=r.key,c=r.variable||"variable",u=(()=>{if(void 0!==a[r.key])return a[r.key];if(o.startsWith(p)){const e=d(c);if(void 0!==a[e])return a[e]}})();return n(e.Fragment,{children:s({variableType:c,variableName:o,variableValue:u,variableOptions:i[r.key],locales:l})},`var_${t}`)}const o=c(r);return o?n(e.Fragment,{children:V({sourceElement:o,targetElement:r,variables:a,variablesOptions:i,locales:l,renderVariable:s})},`element_${t}`):void 0}))}if(t&&"object"==typeof t&&!Array.isArray(t)){const n=_(t)?"variable":"element";if(e.isValidElement(r)){if("element"===n)return V({sourceElement:r,targetElement:t,variables:a,variablesOptions:i,locales:l,renderVariable:s});const e=E(r);if("variable"===(null==e?void 0:e.transformation)){let{variableName:e,variableValue:n,variableOptions:t}=j(r.props);void 0===a[e]&&(a[e]=n),i[e]=Object.assign(Object.assign({},i[e]),t)}}if("variable"===n){const e=t,r=e.key,n=e.variable||"variable",o=(()=>{if(void 0!==a[e.key])return a[e.key];if(r.startsWith(p)){const e=d(n);if(void 0!==a[e])return a[e]}})();return s({variableType:n,variableName:r,variableValue:o,variableOptions:i[e.key]||{},locales:l})}}return w({children:r,variables:a,variablesOptions:i,defaultLocale:l[0],renderVariable:s})}const T=Object.assign({method:"default"},"undefined"!=typeof process&&"development"!==process.env.NODE_ENV?{timeout:8e3}:{});function k(){return""}class N extends Error{constructor(e,r){super(e),this.error=e,this.code=r,this.code=r}toTranslationError(){return{state:"error",error:this.error,code:this.code}}}export{N as GTTranslationError,c as addGTIdentifier,T as defaultRenderSettings,O as extractEntryMetadata,a as flattenDictionary,m as getDictionaryEntry,d as getFallbackVariableName,g as getPluralBranch,b as getVariableName,j as getVariableProps,f as isEmptyReactFragment,_ as isVariableObject,w as renderDefaultChildren,k as renderSkeleton,A as renderTranslatedChildren,h as writeChildrenAsObjects};
|
1
|
+
import e,{isValidElement as r}from"react";import{jsx as n}from"react/jsx-runtime";import"generaltranslation";const t=e=>`Duplicate key found in dictionary: "${e}"`;function a(r,n=""){const i={};for(const o in r)if(r.hasOwnProperty(o)){const l=n?`${n}.${o}`:o;if("object"!=typeof r[o]||null===r[o]||Array.isArray(r[o])||e.isValidElement(r[o])){if(i.hasOwnProperty(l))throw new Error(t(l));i[l]=r[o]}else{const e=a(r[o],l);for(const r in e){if(i.hasOwnProperty(r))throw new Error(t(r));i[r]=e[r]}}}return i}function i(e,r){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&r.indexOf(t)<0&&(n[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(t=Object.getOwnPropertySymbols(e);a<t.length;a++)r.indexOf(t[a])<0&&Object.prototype.propertyIsEnumerable.call(e,t[a])&&(n[t[a]]=e[t[a]])}return n}"function"==typeof SuppressedError&&SuppressedError;var o="en-US",l=["singular","plural","dual","zero","one","two","few","many","other"];const s=e=>`gt-react: No dictionary entry found for id: "${e}"`;function c(t,a=0){let o=a;const s=e=>{const{type:r,props:n}=e;o+=1;let t,a={id:o};try{t="function"==typeof r&&r.gtTransformation||""}catch(e){t=""}if(t){const r=t.split("-");if("translate"===r[0])throw new Error((e=>{var r;return`General Translation: Nested <T> components. The inner <T> has the id: "${null===(r=null==e?void 0:e.props)||void 0===r?void 0:r.id}".`})(e));if("variable"===r[0]&&(a.variableType=(null==r?void 0:r[1])||"variable"),"plural"===r[0]){const e=Object.entries(n).reduce(((e,[r,n])=>{var t;return t=r,l.includes(t)&&(e[r]=c(n,o)),e}),{});Object.keys(e).length&&(a.branches=e)}if("branch"===r[0]){const e=i(n,["children","branch"]),r=Object.entries(e).reduce(((e,[r,n])=>(e[r]=c(n,o),e)),{});Object.keys(r).length&&(a.branches=r)}a.transformation=r[0]}return a};function u(t){return r(t)?function(r){const{props:t}=r;if(t["data-_gt"])throw new Error((e=>`General Translation already in use on child with props: ${e.props}. This usually occurs when you nest <T> components within the same file. Remove one of the <T> components to continue.`)(r));let a=s(r),i=Object.assign(Object.assign({},t),{"data-_gt":a});if(t.children&&!a.variableType&&(i.children=d(t.children)),r.type===e.Fragment)return n("span",Object.assign({style:{all:"unset",display:"contents"}},i));return e.cloneElement(r,i)}(t):t}function d(r){return Array.isArray(r)?e.Children.map(r,u):u(r)}return d(t)}const u={variable:"value",number:"n",datetime:"date",currency:"cost"};function d(e="variable"){return u[e]||"variable"}const p="_gt_";function b(e={},r){var n;if(e.name)return e.name;if(e["data-_gt-variable-name"])return e["data-_gt-variable-name"];return`${p}${u[r]||"value"}_${null===(n=e["data-_gt"])||void 0===n?void 0:n.id}`}const f=e=>{var r;if(!e)return"";const{type:n,props:t}=e;if(n&&"function"==typeof n){if("displayName"in n&&"string"==typeof n.displayName&&n.displayName)return n.displayName;if("name"in n&&"string"==typeof n.name&&n.name)return n.name}return n&&"string"==typeof n?n:t.href?"a":(null===(r=t["data-_gt"])||void 0===r?void 0:r.id)?`C${t["data-_gt"].id}`:"function"},v=r=>{return n=r,e.isValidElement(n)?(e=>{const{type:r,props:n}=e;let t={type:f(e),props:{}};if(n["data-_gt"]){const e=n["data-_gt"];let r=Object.assign({},e);const a=e.transformation;if("variable"===a){const r=e.variableType||"variable";return{variable:r,key:b(n,r),id:e.id}}if("plural"===a&&e.branches){t.type="Plural";let n={};Object.entries(e.branches).forEach((([e,r])=>{n[e]=y(r)})),r=Object.assign(Object.assign({},r),{branches:n})}if("branch"===a&&e.branches){t.type="Branch";let n={};Object.entries(e.branches).forEach((([e,r])=>{n[e]=y(r)})),r=Object.assign(Object.assign({},r),{branches:n})}t.props["data-_gt"]=r}return n.children&&(t.props.children=y(n.children)),t})(r):"number"==typeof r?r.toString():r;var n};function y(e){return Array.isArray(e)?e.map(v):v(e)}function h(e,r,n){let t="",a=null;return"number"==typeof e&&!a&&n&&(t=function(e,r,n){void 0===r&&(r=l),void 0===n&&(n=[o]);var t=new Intl.PluralRules(n).select(e),a=Math.abs(e);if(0===a&&r.includes("zero"))return"zero";if(1===a){if(r.includes("singular"))return"singular";if(r.includes("one"))return"one"}if("one"===t&&r.includes("singular"))return"singular";if(2===a){if(r.includes("dual"))return"dual";if(r.includes("two"))return"two"}return"two"===t&&r.includes("dual")?"dual":r.includes(t)?t:"two"===t&&r.includes("dual")?"dual":"two"===t&&r.includes("plural")?"plural":"two"===t&&r.includes("other")?"other":"few"===t&&r.includes("plural")?"plural":"few"===t&&r.includes("other")?"other":"many"===t&&r.includes("plural")?"plural":"many"===t&&r.includes("other")?"other":"other"===t&&r.includes("plural")?"plural":""}(e,Object.keys(n),r)),t&&!a&&(a=n[t]),a}function g(r,n){let t=r,a=n.split(".");for(const r of a){if("object"!=typeof t||Array.isArray(t)||e.isValidElement(t))return void console.error(s(n));t=t[r]}return t}function m(e){if(Array.isArray(e)){if(1===e.length)return{entry:e[0]};if(2===e.length)return{entry:e[0],metadata:e[1]}}return{entry:e}}function O(e){var r;const n=(null===(r=e["data-_gt"])||void 0===r?void 0:r.variableType)||"variable";return{variableType:n,variableName:b(e,n),variableValue:void 0!==e.value?e.value:void 0!==e["data-_gt-unformatted-value"]?e["data-_gt-unformatted-value"]:void 0!==e.children?e.children:void 0,variableOptions:(()=>{const r=Object.assign(Object.assign({},e.currency&&{currency:e.currency}),e.options&&Object.assign({},e.options));return Object.keys(r).length?r:"string"==typeof e["data-_gt-variable-options"]?JSON.parse(e["data-_gt-variable-options"]):e["data-_gt-variable-options"]||void 0})()}}function j(e){const r=e;if(r&&"object"==typeof r&&"string"==typeof r.key){const e=Object.keys(r);if(1===e.length)return!0;if(2===e.length){if("number"==typeof r.id)return!0;if("string"==typeof r.variable)return!0}if(3===e.length&&"string"==typeof r.variable&&"number"==typeof r.id)return!0}return!1}function _(e){return e&&e.props&&e.props["data-_gt"]?e.props["data-_gt"]:null}function E({children:r,variables:n={},variablesOptions:t={},defaultLocale:a=o,renderVariable:l}){const s=r=>e.isValidElement(r)?(r=>{const o=_(r);if("variable"===(null==o?void 0:o.transformation)){let{variableName:e,variableType:i,variableValue:o,variableOptions:s}=O(r.props);return o=(()=>{if(void 0!==n[e])return n[e];if(void 0!==o)return o;if(e.startsWith(p)){const e=d(i);if(void 0!==n[e])return n[e]}})(),s=Object.assign(Object.assign({},t[e]),s),l({variableName:e,variableType:i,variableValue:o,variableOptions:s,locales:[a]})}if("plural"===(null==o?void 0:o.transformation)){const e="number"==typeof n.n?n.n:"number"==typeof r.props.n?r.props.n:r.props["data-_gt-n"];"number"==typeof e&&void 0===n.n&&(n.n=e);const t=o.branches||{};return c(h(e,[a],t)||r.props.children)}if("branch"===(null==o?void 0:o.transformation)){let e=r.props,{children:t,name:a,branch:l,"data-_gt":s}=e,u=i(e,["children","name","branch","data-_gt"]);return a=a||r.props["data-_gt-name"]||"branch",l=n[a]||l||r.props["data-_gt-branch-name"],u=o.branches||{},c(void 0!==u[l]?u[l]:t)}return r.props.children?e.cloneElement(r,Object.assign(Object.assign({},r.props),{"data-_gt":void 0,children:c(r.props.children)})):e.cloneElement(r,Object.assign(Object.assign({},r.props),{"data-_gt":void 0}))})(r):r,c=r=>Array.isArray(r)?e.Children.map(r,s):s(r);return c(r)}function w({sourceElement:r,targetElement:n,variables:t={},variablesOptions:a={},locales:i=[o],renderVariable:l}){var s;const{props:c}=r,u=c["data-_gt"],d=null==u?void 0:u.transformation;if("plural"===d){const e="number"==typeof t.n?t.n:"number"==typeof r.props.n?r.props.n:r.props["data-_gt-n"],o=h(e,i,u.branches||{})||r.props.children,s=h(e,i,n.props["data-_gt"].branches||{})||n.props.children;return"number"==typeof e&&void 0===t.n&&(t.n=e),V({source:o,target:s,variables:t,variablesOptions:a,locales:i,renderVariable:l})}if("branch"===d){let{name:e,branch:o,children:s}=c;e=e||r.props["data-_gt-name"]||"branch",o=t[e]||o||r.props["data-_gt-branch-name"];return V({source:(u.branches||{})[o]||s,target:(n.props["data-_gt"].branches||{})[o]||n.props.children,variables:t,variablesOptions:a,locales:i,renderVariable:l})}return(null==c?void 0:c.children)&&(null===(s=n.props)||void 0===s?void 0:s.children)?e.cloneElement(r,Object.assign(Object.assign({},c),{"data-_gt":void 0,children:V({source:c.children,target:n.props.children,variables:t,variablesOptions:a,locales:i,renderVariable:l})})):E({children:r,variables:t,variablesOptions:a,defaultLocale:i[0],renderVariable:l})}function V({source:r,target:t,variables:a={},variablesOptions:i={},locales:l=[o],renderVariable:s}){if(null==t&&r)return E({children:r,variables:a,variablesOptions:i,defaultLocale:l[0],renderVariable:s});if("string"==typeof t)return t;if(Array.isArray(t)&&!Array.isArray(r)&&r&&(r=[r]),Array.isArray(r)&&Array.isArray(t)){const o=r.filter((r=>{if(e.isValidElement(r)){const e=_(r);if(O(r.props),"variable"!==(null==e?void 0:e.transformation))return!0;{let{variableName:e,variableValue:n,variableOptions:t,variableType:o}=O(r.props);void 0===a[e]&&(a[e]=n);const l=d(o);void 0===a[l]&&(a[l]=n),i[e]=Object.assign(Object.assign({},i[e]),t)}}})),c=e=>o.find((r=>{var n,t;const a=_(r);if(void 0!==(null==a?void 0:a.id)){return a.id===(null===(t=null===(n=null==e?void 0:e.props)||void 0===n?void 0:n["data-_gt"])||void 0===t?void 0:t.id)}return!1}));return t.map(((r,t)=>{if("string"==typeof r)return n(e.Fragment,{children:r},`string_${t}`);if(j(r)){const o=r.key,c=r.variable||"variable",u=(()=>{if(void 0!==a[r.key])return a[r.key];if(o.startsWith(p)){const e=d(c);if(void 0!==a[e])return a[e]}})();return n(e.Fragment,{children:s({variableType:c,variableName:o,variableValue:u,variableOptions:i[r.key],locales:l})},`var_${t}`)}const o=c(r);return o?n(e.Fragment,{children:w({sourceElement:o,targetElement:r,variables:a,variablesOptions:i,locales:l,renderVariable:s})},`element_${t}`):void 0}))}if(t&&"object"==typeof t&&!Array.isArray(t)){const n=j(t)?"variable":"element";if(e.isValidElement(r)){if("element"===n)return w({sourceElement:r,targetElement:t,variables:a,variablesOptions:i,locales:l,renderVariable:s});const e=_(r);if("variable"===(null==e?void 0:e.transformation)){let{variableName:e,variableValue:n,variableOptions:t}=O(r.props);void 0===a[e]&&(a[e]=n),i[e]=Object.assign(Object.assign({},i[e]),t)}}if("variable"===n){const e=t,r=e.key,n=e.variable||"variable",o=(()=>{if(void 0!==a[e.key])return a[e.key];if(r.startsWith(p)){const e=d(n);if(void 0!==a[e])return a[e]}})();return s({variableType:n,variableName:r,variableValue:o,variableOptions:i[e.key]||{},locales:l})}}return E({children:r,variables:a,variablesOptions:i,defaultLocale:l[0],renderVariable:s})}const A={method:"default",timeout:"undefined"!=typeof process&&"development"!==process.env.NODE_ENV?8e3:12e3};function T(){return""}class k extends Error{constructor(e,r){super(e),this.error=e,this.code=r,this.code=r}toTranslationError(){return{state:"error",error:this.error,code:this.code}}}export{k as GTTranslationError,c as addGTIdentifier,A as defaultRenderSettings,a as flattenDictionary,g as getDictionaryEntry,m as getEntryAndMetadata,d as getFallbackVariableName,h as getPluralBranch,b as getVariableName,O as getVariableProps,j as isVariableObject,E as renderDefaultChildren,T as renderSkeleton,V as renderTranslatedChildren,y as writeChildrenAsObjects};
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { ClientProviderProps } from '../types/types';
|
3
|
-
export default function ClientProvider({ children, dictionary, initialTranslations, translationPromises, locale: _locale, _versionId,
|
3
|
+
export default function ClientProvider({ children, dictionary, initialTranslations, translationPromises, locale: _locale, _versionId, defaultLocale, translationRequired, dialectTranslationRequired, locales, requiredPrefix, renderSettings, projectId, devApiKey, runtimeUrl, developmentTranslationEnabled, onLocaleChange, cookieName, }: ClientProviderProps): React.JSX.Element;
|
4
4
|
//# sourceMappingURL=ClientProvider.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ClientProvider.d.ts","sourceRoot":"","sources":["../../src/provider/ClientProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAOhF,OAAO,EACL,mBAAmB,EASpB,MAAM,gBAAgB,CAAC;
|
1
|
+
{"version":3,"file":"ClientProvider.d.ts","sourceRoot":"","sources":["../../src/provider/ClientProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAOhF,OAAO,EACL,mBAAmB,EASpB,MAAM,gBAAgB,CAAC;AAWxB,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,mBAAmB,EACnB,MAAM,EAAE,OAAO,EACf,UAAU,EACV,aAAa,EACb,mBAAmB,EACnB,0BAA0B,EAC1B,OAAY,EACZ,cAAc,EACd,cAAc,EACd,SAAS,EACT,SAAS,EACT,UAAU,EACV,6BAA6B,EAC7B,cAAyB,EACzB,UAA6B,GAC9B,EAAE,mBAAmB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA6QzC"}
|
@@ -9,7 +9,7 @@ import React from 'react';
|
|
9
9
|
* @param {string[]} [locales] - The list of approved locales for the project.
|
10
10
|
* @param {string} [defaultLocale=libraryDefaultLocale] - The default locale to use if no other locale is found.
|
11
11
|
* @param {string} [locale] - The current locale, if already set.
|
12
|
-
* @param {string} [cacheUrl='https://
|
12
|
+
* @param {string} [cacheUrl='https://cdn.gtx.dev'] - The URL of the cache service for fetching translations.
|
13
13
|
* @param {string} [runtimeUrl='https://runtime.gtx.dev'] - The URL of the runtime service for fetching translations.
|
14
14
|
* @param {RenderSettings} [renderSettings=defaultRenderSettings] - The settings for rendering translations.
|
15
15
|
* @param {string} [_versionId] - The version ID for fetching translations.
|
@@ -32,7 +32,6 @@ export default function GTProvider({ children, projectId: _projectId, devApiKey:
|
|
32
32
|
method: RenderMethod;
|
33
33
|
timeout?: number;
|
34
34
|
};
|
35
|
-
enableCache?: boolean;
|
36
35
|
loadTranslation?: (locale: string) => Promise<any>;
|
37
36
|
_versionId?: string;
|
38
37
|
[key: string]: any;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"GTProvider.d.ts","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings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AAC,OAAO,CA4YpB"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { DictionaryEntry, Entry, Metadata, TaggedDictionaryEntry, TaggedEntry } from '../../types/types';
|
2
|
-
export default function
|
2
|
+
export default function getEntryAndMetadata(value: DictionaryEntry | TaggedDictionaryEntry): {
|
3
3
|
entry: Entry | TaggedEntry;
|
4
4
|
metadata?: Metadata;
|
5
5
|
};
|
6
|
-
//# sourceMappingURL=
|
6
|
+
//# sourceMappingURL=getEntryAndMetadata.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getEntryAndMetadata.d.ts","sourceRoot":"","sources":["../../../src/provider/helpers/getEntryAndMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,KAAK,EACL,QAAQ,EACR,qBAAqB,EACrB,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAE3B,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,KAAK,EAAE,eAAe,GAAG,qBAAqB,GAC7C;IACD,KAAK,EAAE,KAAK,GAAG,WAAW,CAAC;IAC3B,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,CAUA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"defaultRenderSettings.d.ts","sourceRoot":"","sources":["../../../src/provider/rendering/defaultRenderSettings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AASjD,eAAO,MAAM,qBAAqB,EAAE;IAClC,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,
|
1
|
+
{"version":3,"file":"defaultRenderSettings.d.ts","sourceRoot":"","sources":["../../../src/provider/rendering/defaultRenderSettings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AASjD,eAAO,MAAM,qBAAqB,EAAE;IAClC,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CAIR,CAAC"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { RenderMethod, TranslateChildrenCallback, TranslateContentCallback } from '../../types/types';
|
2
|
-
export default function useRuntimeTranslation({ projectId, devApiKey, locale, versionId, defaultLocale, runtimeUrl, renderSettings, setTranslations, runtimeTranslationEnabled, ...
|
2
|
+
export default function useRuntimeTranslation({ projectId, devApiKey, locale, versionId, defaultLocale, runtimeUrl, renderSettings, setTranslations, runtimeTranslationEnabled, ...globalMetadata }: {
|
3
3
|
projectId?: string;
|
4
4
|
devApiKey?: string;
|
5
5
|
locale: string;
|
@@ -14,7 +14,7 @@ export default function useRuntimeTranslation({ projectId, devApiKey, locale, ve
|
|
14
14
|
setTranslations: React.Dispatch<React.SetStateAction<any>>;
|
15
15
|
[key: string]: any;
|
16
16
|
}): {
|
17
|
-
|
18
|
-
|
17
|
+
registerContentForTranslation: TranslateContentCallback;
|
18
|
+
registerJsxForTranslation: TranslateChildrenCallback;
|
19
19
|
};
|
20
20
|
//# sourceMappingURL=useRuntimeTranslation.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useRuntimeTranslation.d.ts","sourceRoot":"","sources":["../../../src/provider/runtime/useRuntimeTranslation.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"useRuntimeTranslation.d.ts","sourceRoot":"","sources":["../../../src/provider/runtime/useRuntimeTranslation.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,YAAY,EACZ,yBAAyB,EACzB,wBAAwB,EAEzB,MAAM,mBAAmB,CAAC;AA6B3B,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,EAC5C,SAAS,EACT,SAAS,EACT,MAAM,EACN,SAAS,EACT,aAAa,EACb,UAAU,EACV,cAAc,EACd,eAAe,EACf,yBAAyB,EACzB,GAAG,cAAc,EAClB,EAAE;IACD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,yBAAyB,EAAE,OAAO,CAAC;IACnC,cAAc,EAAE;QACd,MAAM,EAAE,YAAY,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,eAAe,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3D,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,GAAG;IACF,6BAA6B,EAAE,wBAAwB,CAAC;IACxD,yBAAyB,EAAE,yBAAyB,CAAC;CACtD,CAmTA"}
|
package/dist/types/types.d.ts
CHANGED
@@ -97,8 +97,9 @@ export type TranslateChildrenCallback = (params: {
|
|
97
97
|
}) => Promise<void>;
|
98
98
|
export type GTContextType = {
|
99
99
|
translateDictionaryEntry: (id: string, options?: Record<string, any>) => React.ReactNode;
|
100
|
-
|
101
|
-
|
100
|
+
registerContentForTranslation: TranslateContentCallback;
|
101
|
+
registerJsxForTranslation: TranslateChildrenCallback;
|
102
|
+
developmentTranslationEnabled: boolean;
|
102
103
|
locale: string;
|
103
104
|
locales: string[];
|
104
105
|
setLocale: (locale: string) => void;
|
@@ -111,8 +112,6 @@ export type GTContextType = {
|
|
111
112
|
timeout?: number;
|
112
113
|
};
|
113
114
|
projectId?: string;
|
114
|
-
translationEnabled: boolean;
|
115
|
-
runtimeTranslationEnabled: boolean;
|
116
115
|
};
|
117
116
|
export declare class GTTranslationError extends Error {
|
118
117
|
error: string;
|
@@ -137,8 +136,7 @@ export type ClientProviderProps = {
|
|
137
136
|
method: RenderMethod;
|
138
137
|
timeout?: number;
|
139
138
|
};
|
140
|
-
|
141
|
-
runtimeTranslationEnabled: boolean;
|
139
|
+
developmentTranslationEnabled: boolean;
|
142
140
|
projectId?: string;
|
143
141
|
devApiKey?: string;
|
144
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;CACpB,CAAC;AAEF,qBAAa,kBAAmB,SAAQ,KAAK;IAElC,KAAK,EAAE,MAAM;IACb,IAAI,EAAE,MAAM;gBADZ,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM;IAMrB,kBAAkB,IAAI,gBAAgB;CAOvC;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,GAAG,CAAC;IACd,UAAU,EAAE,yBAAyB,CAAC;IACtC,mBAAmB,EAAE,kBAAkB,CAAC;IACxC,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC;IACjE,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,0BAA0B,EAAE,OAAO,CAAC;IACpC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,cAAc,EAAE;QACd,MAAM,EAAE,YAAY,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,6BAA6B,EAAE,OAAO,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC"}
|
@@ -1,2 +1,7 @@
|
|
1
|
-
export default function fetchTranslations(cacheUrl
|
1
|
+
export default function fetchTranslations({ cacheUrl, projectId, locale, versionId, }: {
|
2
|
+
cacheUrl: string;
|
3
|
+
projectId: string;
|
4
|
+
locale: string;
|
5
|
+
versionId?: string;
|
6
|
+
}): Promise<any>;
|
2
7
|
//# sourceMappingURL=fetchTranslations.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fetchTranslations.d.ts","sourceRoot":"","sources":["../../src/utils/fetchTranslations.ts"],"names":[],"mappings":"AAAA,wBAA8B,iBAAiB,
|
1
|
+
{"version":3,"file":"fetchTranslations.d.ts","sourceRoot":"","sources":["../../src/utils/fetchTranslations.ts"],"names":[],"mappings":"AAAA,wBAA8B,iBAAiB,CAAC,EAC9C,QAAQ,EACR,SAAS,EACT,MAAM,EACN,SAAS,GACV,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,gBASA"}
|
package/dist/utils/utils.d.ts
CHANGED
@@ -1,9 +1,7 @@
|
|
1
|
-
import React from 'react';
|
2
1
|
import { TaggedElement, TranslatedContent } from '../types/types';
|
3
2
|
export declare function isTranslatedContent(target: unknown): target is TranslatedContent;
|
4
3
|
export declare function isValidTaggedElement(target: unknown): target is TaggedElement;
|
5
|
-
export declare function
|
6
|
-
export declare function getAuth(projectId?: string, devApiKey?: string): {
|
4
|
+
export declare function readAuthFromEnv(projectId?: string, devApiKey?: string): {
|
7
5
|
projectId: string;
|
8
6
|
devApiKey?: string;
|
9
7
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils/utils.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils/utils.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EAEb,iBAAiB,EAClB,MAAM,gBAAgB,CAAC;AAExB,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,OAAO,GACd,MAAM,IAAI,iBAAiB,CAuB7B;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,aAAa,CAE7E;AAED,wBAAgB,eAAe,CAC7B,SAAS,CAAC,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM,GACjB;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CA6BA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "gt-react",
|
3
|
-
"version": "9.0
|
3
|
+
"version": "9.1.0",
|
4
4
|
"description": "A React library for automatic internationalization.",
|
5
5
|
"main": "./dist/index.cjs.min.cjs",
|
6
6
|
"module": "./dist/index.esm.min.mjs",
|
@@ -9,6 +9,10 @@
|
|
9
9
|
"react": ">=16.8.0 <20.0.0",
|
10
10
|
"react-dom": ">=16.8.0 <20.0.0"
|
11
11
|
},
|
12
|
+
"dependencies": {
|
13
|
+
"@generaltranslation/supported-locales": "^2.0.2",
|
14
|
+
"generaltranslation": "^6.2.0"
|
15
|
+
},
|
12
16
|
"scripts": {
|
13
17
|
"patch": "npm version patch",
|
14
18
|
"transpile": "tsc",
|
@@ -90,9 +94,5 @@
|
|
90
94
|
"internationalization",
|
91
95
|
"localization",
|
92
96
|
"i18n"
|
93
|
-
]
|
94
|
-
"dependencies": {
|
95
|
-
"@generaltranslation/supported-locales": "^2.0.2",
|
96
|
-
"generaltranslation": "^6.1.11-alpha.1"
|
97
|
-
}
|
97
|
+
]
|
98
98
|
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"extractEntryMetadata.d.ts","sourceRoot":"","sources":["../../../src/provider/helpers/extractEntryMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,KAAK,EACL,QAAQ,EACR,qBAAqB,EACrB,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAE3B,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAC1C,KAAK,EAAE,eAAe,GAAG,qBAAqB,GAC7C;IACD,KAAK,EAAE,KAAK,GAAG,WAAW,CAAC;IAC3B,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,CAUA"}
|
package/dist/utils/getKey.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"getKey.d.ts","sourceRoot":"","sources":["../../src/utils/getKey.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,UAEvD"}
|