@cyberskill/shared 1.46.0 → 1.48.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/README.md +12 -18
- package/dist/_tsup-dts-rollup.d.cts +413 -31
- package/dist/_tsup-dts-rollup.d.ts +413 -31
- package/dist/cli.cjs +2136 -1
- package/dist/cli.d.cts +2 -1
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +2056 -1
- package/dist/configs/commitlint/base.cjs +64 -1
- package/dist/configs/commitlint/base.js +7 -1
- package/dist/configs/eslint/base.cjs +121 -1
- package/dist/configs/eslint/base.js +52 -1
- package/dist/configs/eslint/nestjs.cjs +155 -1
- package/dist/configs/eslint/nestjs.js +85 -1
- package/dist/configs/eslint/nextjs.cjs +155 -1
- package/dist/configs/eslint/nextjs.js +85 -1
- package/dist/configs/eslint/nodejs.cjs +156 -1
- package/dist/configs/eslint/nodejs.js +86 -1
- package/dist/configs/eslint/vite-react.cjs +159 -1
- package/dist/configs/eslint/vite-react.js +89 -1
- package/dist/configs/graphql/graphql-codegen.cjs +125 -1
- package/dist/configs/graphql/graphql-codegen.js +64 -1
- package/dist/configs/graphql/index.cjs +126 -1
- package/dist/configs/graphql/index.js +64 -1
- package/dist/configs/i18n/react/i18next.cjs +80 -1
- package/dist/configs/i18n/react/i18next.js +7 -1
- package/dist/configs/i18n/react/index.cjs +81 -1
- package/dist/configs/i18n/react/index.js +7 -1
- package/dist/configs/index.cjs +232 -1
- package/dist/configs/index.js +166 -1
- package/dist/configs/lint-staged/base.cjs +64 -1
- package/dist/configs/lint-staged/base.js +7 -1
- package/dist/configs/vitest/react/e2e.cjs +128 -1
- package/dist/configs/vitest/react/e2e.js +59 -1
- package/dist/configs/vitest/react/unit.cjs +305 -1
- package/dist/configs/vitest/react/unit.js +228 -1
- package/dist/configs/vitest/react/unit.setup.cjs +60 -1
- package/dist/configs/vitest/react/unit.setup.js +8 -1
- package/dist/constants/index.cjs +678 -1
- package/dist/constants/index.d.cts +31 -1
- package/dist/constants/index.d.ts +31 -1
- package/dist/constants/index.js +469 -1
- package/dist/constants/path.cjs +423 -1
- package/dist/constants/path.d.cts +31 -1
- package/dist/constants/path.d.ts +31 -1
- package/dist/constants/path.js +218 -1
- package/dist/constants/response-status.cjs +313 -1
- package/dist/constants/response-status.js +252 -1
- package/dist/index.cjs +4546 -1
- package/dist/index.d.cts +51 -6
- package/dist/index.d.ts +51 -6
- package/dist/index.js +4133 -1
- package/dist/nodejs/index.cjs +2138 -1
- package/dist/nodejs/index.js +2054 -1
- package/dist/nodejs/mongo.cjs +2137 -1
- package/dist/nodejs/mongo.js +2054 -1
- package/dist/react/apollo-client.cjs +177 -1
- package/dist/react/apollo-client.js +116 -1
- package/dist/react/index.cjs +990 -1
- package/dist/react/index.js +876 -1
- package/dist/react/loading.cjs +301 -1
- package/dist/react/loading.js +216 -1
- package/dist/react/next-intl.cjs +744 -1
- package/dist/react/next-intl.js +655 -1
- package/dist/react/storage.cjs +631 -1
- package/dist/react/storage.js +558 -1
- package/dist/typescript/api-response.cjs +48 -1
- package/dist/typescript/apollo.cjs +48 -1
- package/dist/typescript/command.cjs +68 -1
- package/dist/typescript/command.d.cts +4 -0
- package/dist/typescript/command.d.ts +4 -0
- package/dist/typescript/command.js +7 -1
- package/dist/typescript/config.cjs +48 -1
- package/dist/typescript/fs.cjs +48 -0
- package/dist/typescript/fs.d.cts +1 -0
- package/dist/typescript/fs.d.ts +1 -0
- package/dist/typescript/fs.js +0 -0
- package/dist/typescript/graphql-codegen.cjs +48 -1
- package/dist/typescript/index.cjs +175 -1
- package/dist/typescript/index.d.cts +5 -0
- package/dist/typescript/index.d.ts +5 -0
- package/dist/typescript/index.js +151 -1
- package/dist/typescript/loading.cjs +48 -1
- package/dist/typescript/log.cjs +48 -1
- package/dist/typescript/mongo.cjs +164 -1
- package/dist/typescript/mongo.js +145 -1
- package/dist/typescript/next-intl.cjs +48 -1
- package/dist/typescript/react.cjs +48 -1
- package/dist/typescript/serializer.cjs +48 -1
- package/dist/typescript/string.cjs +48 -1
- package/dist/utils/command.cjs +1387 -1
- package/dist/utils/command.d.cts +2 -0
- package/dist/utils/command.d.ts +2 -0
- package/dist/utils/command.js +1287 -1
- package/dist/utils/common.cjs +300 -1
- package/dist/utils/common.js +219 -1
- package/dist/utils/config.cjs +146 -1
- package/dist/utils/config.js +89 -1
- package/dist/utils/fs.cjs +118 -1
- package/dist/utils/fs.d.cts +4 -1
- package/dist/utils/fs.d.ts +4 -1
- package/dist/utils/fs.js +37 -1
- package/dist/utils/index-nodejs.cjs +1738 -1
- package/dist/utils/index-nodejs.d.cts +15 -5
- package/dist/utils/index-nodejs.d.ts +15 -5
- package/dist/utils/index-nodejs.js +1571 -1
- package/dist/utils/index.cjs +727 -1
- package/dist/utils/index.js +625 -1
- package/dist/utils/log.cjs +330 -1
- package/dist/utils/log.js +269 -1
- package/dist/utils/package.cjs +941 -0
- package/dist/utils/package.d.cts +3 -0
- package/dist/utils/package.d.ts +3 -0
- package/dist/utils/package.js +857 -0
- package/dist/utils/path.cjs +291 -0
- package/dist/utils/path.d.cts +6 -0
- package/dist/utils/path.d.ts +6 -0
- package/dist/utils/path.js +191 -0
- package/dist/utils/serializer.cjs +91 -1
- package/dist/utils/serializer.js +30 -1
- package/dist/utils/storage-client.cjs +349 -1
- package/dist/utils/storage-client.js +276 -1
- package/dist/utils/storage-server.cjs +636 -1
- package/dist/utils/storage-server.d.cts +1 -1
- package/dist/utils/storage-server.d.ts +1 -1
- package/dist/utils/storage-server.js +550 -1
- package/dist/utils/string.cjs +152 -1
- package/dist/utils/string.js +75 -1
- package/dist/utils/validate.cjs +90 -1
- package/dist/utils/validate.js +33 -1
- package/package.json +19 -16
- package/dist/utils/npm-package.cjs +0 -1
- package/dist/utils/npm-package.d.cts +0 -4
- package/dist/utils/npm-package.d.ts +0 -4
- package/dist/utils/npm-package.js +0 -1
package/dist/react/index.js
CHANGED
|
@@ -1 +1,876 @@
|
|
|
1
|
-
function e(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n<r;n++)t[n]=e[n];return t}function r(e){if(Array.isArray(e))return e}function n(e,r,n,t,o,a,i){try{var s=e[a](i);var u=s.value}catch(e){n(e);return}if(s.done){r(u)}else{Promise.resolve(u).then(t,o)}}function t(e){return function(){var r=this,t=arguments;return new Promise(function(o,a){var i=e.apply(r,t);function s(e){n(i,o,a,s,u,"next",e)}function u(e){n(i,o,a,s,u,"throw",e)}s(undefined)})}}function o(e,r,n){if(r in e){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true})}else{e[r]=n}return e}function a(e,r){if(r!=null&&typeof Symbol!=="undefined"&&r[Symbol.hasInstance]){return!!r[Symbol.hasInstance](e)}else{return e instanceof r}}function i(e,r){var n=e==null?null:typeof Symbol!=="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(n==null)return;var t=[];var o=true;var a=false;var i,s;try{for(n=n.call(e);!(o=(i=n.next()).done);o=true){t.push(i.value);if(r&&t.length===r)break}}catch(e){a=true;s=e}finally{try{if(!o&&n["return"]!=null)n["return"]()}finally{if(a)throw s}}return t}function s(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};var t=Object.keys(n);if(typeof Object.getOwnPropertySymbols==="function"){t=t.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))}t.forEach(function(r){o(e,r,n[r])})}return e}function l(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);if(r){t=t.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})}n.push.apply(n,t)}return n}function c(e,r){r=r!=null?r:{};if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(r))}else{l(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function f(e,r){if(e==null)return{};var n=v(e,r);var t,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++){t=a[o];if(r.indexOf(t)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}function v(e,r){if(e==null)return{};var n={};var t=Object.keys(e);var o,a;for(a=0;a<t.length;a++){o=t[a];if(r.indexOf(o)>=0)continue;n[o]=e[o]}return n}function d(e,n){return r(e)||i(e,n)||p(e,n)||s()}function p(r,n){if(!r)return;if(typeof r==="string")return e(r,n);var t=Object.prototype.toString.call(r).slice(8,-1);if(t==="Object"&&r.constructor)t=r.constructor.name;if(t==="Map"||t==="Set")return Array.from(t);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return e(r,n)}function m(e,r){var n,t,o,a,i={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]};return a={next:s(0),"throw":s(1),"return":s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(e){return function(r){return u([e,r])}}function u(a){if(n)throw new TypeError("Generator is already executing.");while(i)try{if(n=1,t&&(o=a[0]&2?t["return"]:a[0]?t["throw"]||((o=t["return"])&&o.call(t),0):t.next)&&!(o=o.call(t,a[1])).done)return o;if(t=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:i.label++;return{value:a[1],done:false};case 5:i.label++;t=a[1];a=[0];continue;case 7:a=i.ops.pop();i.trys.pop();continue;default:if(!(o=i.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){i=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(a[0]===6&&i.label<o[1]){i.label=o[1];o=a;break}if(o&&i.label<o[2]){i.label=o[2];i.ops.push(a);break}if(o[2])i.ops.pop();i.trys.pop();continue}a=r.call(e,i)}catch(e){a=[6,e];t=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}}import{ApolloClient as g,ApolloLink as h,ApolloProvider as y,HttpLink as b,InMemoryCache as w,split as O}from"@apollo/client";import{onError as k}from"@apollo/client/link/error";import{GraphQLWsLink as x}from"@apollo/client/link/subscriptions";import{getMainDefinition as S}from"@apollo/client/utilities";import{createClient as j}from"graphql-ws";import{jsx as N}from"react/jsx-runtime";function L(e){var r=k(function(e){var r=e.graphQLErrors,n=e.networkError;r===null||r===void 0?void 0:r.forEach(function(e){var r=e.message,n=e.locations,t=e.path;return console.error("[GraphQL error]: Message: ".concat(r,", Location: ").concat(n,", Path: ").concat(t))}),n&&console.error("[Network error]: ".concat(n))}),n=new b({uri:e===null||e===void 0?void 0:e.uri,credentials:"include"}),t=(e===null||e===void 0?void 0:e.wsUrl)?new x(j({url:e.wsUrl})):null,o=t?O(function(e){var r=e.query;var n=S(r);if(n.kind==="OperationDefinition"){var t=n.operation;return t==="subscription"}return!1},t,n):n,a=new h(function(e,r){return e.variables&&(e.variables=JSON.parse(JSON.stringify(e.variables),function(e,r){return e==="__typename"?void 0:r})),r(e)});return{errorLink:r,httpLink:n,wsLink:t,splitLink:o,cleanTypeName:a}}function P(e){var r=e.isNextJS,n=e.options,t=e.children,o=e.client,i=e.provider,s=e.cache;var l=o!==null&&o!==void 0?o:g;if(typeof l!="function")throw new TypeError("Invalid ApolloClient provided. Ensure CustomClient is a class.");var c=i||y,f=s||w,v=L(n),d=v.cleanTypeName,p=v.errorLink,m=v.splitLink,b=new l(u({cache:a(f,w)?f:new w,link:h.from([d,p,m].filter(Boolean))},n));return r?N(c,{makeClient:function(){return b},children:t}):N(c,{client:b,children:t})}import E from"classnames";import{createContext as I,use as C,useCallback as A,useMemo as D,useState as _}from"react";import M from"./loading.module.scss";import{jsx as T,jsxs as z}from"react/jsx-runtime";var J=I(void 0);function U(){var e=C(J);if(!e)throw new Error("useLoading must be used within a LoadingProvider");return e}function G(e){var r=e.full,n=r===void 0?!1:r,t=e.block,o=t===void 0?!1:t,a=e.className,i=a===void 0?"":a,s=e.message,l=s===void 0?"Loading":s,v=f(e,["full","block","className","message"]);function d(){return z("div",c(u({className:M.container},v),{children:[T("div",{className:M.ring}),T("div",{className:M.ring}),T("div",{className:M.ring}),T("div",{className:M.ring}),l&&T("div",{className:M.message,children:l})]}))}return n?T("div",{className:E(M.fullscreen,i),children:d()}):o?T("div",{className:E(M.block,i),children:d()}):d()}function Q(e){var r=e.children;var n=d(_(!1),2),t=n[0],o=n[1],a=d(_(!1),2),i=a[0],s=a[1],u=A(function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;o(!0),s(e)},[]),l=A(function(){o(!1),s(!1)},[]),c=D(function(){return{isLoading:t,isGlobalLoading:i,showLoading:u,hideLoading:l}},[t,i,u,l]);return T(J,{value:c,children:t?T(G,{full:i}):r})}import{NextIntlClientProvider as q,useTranslations as $}from"next-intl";import{createContext as B,use as F,useMemo as H}from"react";import{useCallback as R,useEffect as W,useState as X}from"react";var Y={serialize:function(e){return JSON.stringify(e,function(e,r){return a(r,Date)?{__type:"Date",value:r.toISOString()}:r})},deserialize:function(e){return JSON.parse(e,function(e,r){return(r===null||r===void 0?void 0:r.__type)==="Date"?new Date(r.value):r})}};import Z from"localforage";var K={get:function e(e){return t(function(){var r;return m(this,function(n){switch(n.label){case 0:n.trys.push([0,2,,3]);return[4,Z.getItem(e)];case 1:return[2,n.sent()];case 2:r=n.sent();return[2,(console.error('❌ [Storage:get] Error getting key "'.concat(e,'":'),r),null)];case 3:return[2]}})})()},set:function e(e,r){return t(function(){var n;return m(this,function(t){switch(t.label){case 0:t.trys.push([0,2,,3]);return[4,Z.setItem(e,r)];case 1:t.sent();return[3,3];case 2:n=t.sent();console.error('❌ [Storage:set] Error setting key "'.concat(e,'":'),n);return[3,3];case 3:return[2]}})})()},remove:function e(e){return t(function(){var r;return m(this,function(n){switch(n.label){case 0:n.trys.push([0,2,,3]);return[4,Z.removeItem(e)];case 1:n.sent();return[3,3];case 2:r=n.sent();console.error('❌ [Storage:remove] Error removing key "'.concat(e,'":'),r);return[3,3];case 3:return[2]}})})()},keys:function e(){return t(function(){var e,r;return m(this,function(n){switch(n.label){case 0:n.trys.push([0,2,,3]);return[4,Z.keys()];case 1:return[2,(e=n.sent())!==null&&e!==void 0?e:[]];case 2:r=n.sent();return[2,(console.error("❌ [Storage:keys] Error getting keys:",r),[])];case 3:return[2]}})})()}};function V(e,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Y;var o=d(X(r),2),a=o[0],i=o[1],s=d(X(!1),2),u=s[0],l=s[1];W(function(){var o=!0;return t(function(){var t,a,s,u;return m(this,function(c){switch(c.label){case 0:c.trys.push([0,6,7,8]);return[4,K.get(e)];case 1:t=c.sent();if(!o)return[3,5];if(!(t!==null))return[3,2];a=n.deserialize(t);i(a);return[3,5];case 2:if(!(r!==void 0))return[3,4];s=n.serialize(r);return[4,K.set(e,s)];case 3:c.sent(),i(r);return[3,5];case 4:i(void 0);c.label=5;case 5:return[3,8];case 6:u=c.sent();console.error('Error loading value for key "'.concat(e,'":'),u),o&&i(r);return[3,8];case 7:o&&l(!0);return[7];case 8:return[2]}})})(),function(){o=!1,l(!1)}},[e,r,n]),W(function(){if(!u)return;t(function(){var r,t;return m(this,function(o){switch(o.label){case 0:o.trys.push([0,3,,4]);if(!(a!==void 0))return[3,2];r=n.serialize(a);return[4,K.set(e,r)];case 1:o.sent();o.label=2;case 2:return[3,4];case 3:t=o.sent();console.error('Error saving value for key "'.concat(e,'":'),t);return[3,4];case 4:return[2]}})})()},[a,e,n,u]);var c=R(function(e){i(function(r){return typeof e=="function"?e(r):e})},[]),f=R(/*#__PURE__*/t(function(){var r;return m(this,function(n){switch(n.label){case 0:n.trys.push([0,2,,3]);return[4,K.remove(e)];case 1:n.sent(),i(void 0);return[3,3];case 2:r=n.sent();console.error('Error removing key "'.concat(e,'":'),r);return[3,3];case 3:return[2]}})}),[e]);return{value:a,set:c,remove:f}}import{Fragment as ee,jsx as er}from"react/jsx-runtime";var en=B(void 0);function et(){var e=F(en);if(!e)throw new Error("useNextIntl must be used within a NextIntlProvider");return e}var eo=$;function ea(e){var r=function(r){var n;var t=et(),o=t.currentLanguage,a=r.messages,i=r.languages,s="en",l=a[(o===null||o===void 0?void 0:o.value)||s],c=(n=i.find(function(e){return e.value===(o===null||o===void 0?void 0:o.value)}))===null||n===void 0?void 0:n.timezone;return a?er(q,{locale:(o===null||o===void 0?void 0:o.value)||s,messages:l,timeZone:c,children:er(e,u({},r))}):(console.warn("Missing messages for language: ".concat((o===null||o===void 0?void 0:o.value)||s)),null)};return r.displayName="withNextIntl(".concat(e.displayName||e.name||"Component",")"),r}function ei(e){var r=e.children;return er(ee,{children:r})}var es=ea(ei);function eu(e){var r=e.children,n=e.languages,t=e.messages;var o;var a=V("lang",(o=n===null||n===void 0?void 0:n[0])!==null&&o!==void 0?o:{}),i=a.value,s=a.set,u=H(function(){return{languages:n,currentLanguage:i,setCurrentLanguage:s}},[n,s,i]);return er(en,{value:u,children:er(es,{languages:n,messages:t,children:r})})}export{P as ApolloProvider,G as Loading,J as LoadingContext,Q as LoadingProvider,en as NextIntlContext,eu as NextIntlProvider,U as useLoading,et as useNextIntl,V as useStorage,eo as useTranslateNextIntl,ea as withNextIntl};
|
|
1
|
+
// src/react/apollo-client.tsx
|
|
2
|
+
function _array_like_to_array(arr, len) {
|
|
3
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
4
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5
|
+
return arr2;
|
|
6
|
+
}
|
|
7
|
+
function _array_with_holes(arr) {
|
|
8
|
+
if (Array.isArray(arr)) return arr;
|
|
9
|
+
}
|
|
10
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
11
|
+
try {
|
|
12
|
+
var info = gen[key](arg);
|
|
13
|
+
var value = info.value;
|
|
14
|
+
} catch (error) {
|
|
15
|
+
reject(error);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (info.done) {
|
|
19
|
+
resolve(value);
|
|
20
|
+
} else {
|
|
21
|
+
Promise.resolve(value).then(_next, _throw);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function _async_to_generator(fn) {
|
|
25
|
+
return function() {
|
|
26
|
+
var self = this, args = arguments;
|
|
27
|
+
return new Promise(function(resolve, reject) {
|
|
28
|
+
var gen = fn.apply(self, args);
|
|
29
|
+
function _next(value) {
|
|
30
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
31
|
+
}
|
|
32
|
+
function _throw(err) {
|
|
33
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
34
|
+
}
|
|
35
|
+
_next(undefined);
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function _define_property(obj, key, value) {
|
|
40
|
+
if (key in obj) {
|
|
41
|
+
Object.defineProperty(obj, key, {
|
|
42
|
+
value: value,
|
|
43
|
+
enumerable: true,
|
|
44
|
+
configurable: true,
|
|
45
|
+
writable: true
|
|
46
|
+
});
|
|
47
|
+
} else {
|
|
48
|
+
obj[key] = value;
|
|
49
|
+
}
|
|
50
|
+
return obj;
|
|
51
|
+
}
|
|
52
|
+
function _instanceof(left, right) {
|
|
53
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
54
|
+
return !!right[Symbol.hasInstance](left);
|
|
55
|
+
} else {
|
|
56
|
+
return left instanceof right;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function _iterable_to_array_limit(arr, i) {
|
|
60
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
61
|
+
if (_i == null) return;
|
|
62
|
+
var _arr = [];
|
|
63
|
+
var _n = true;
|
|
64
|
+
var _d = false;
|
|
65
|
+
var _s, _e;
|
|
66
|
+
try {
|
|
67
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
68
|
+
_arr.push(_s.value);
|
|
69
|
+
if (i && _arr.length === i) break;
|
|
70
|
+
}
|
|
71
|
+
} catch (err) {
|
|
72
|
+
_d = true;
|
|
73
|
+
_e = err;
|
|
74
|
+
} finally{
|
|
75
|
+
try {
|
|
76
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
77
|
+
} finally{
|
|
78
|
+
if (_d) throw _e;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return _arr;
|
|
82
|
+
}
|
|
83
|
+
function _non_iterable_rest() {
|
|
84
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
85
|
+
}
|
|
86
|
+
function _object_spread(target) {
|
|
87
|
+
for(var i = 1; i < arguments.length; i++){
|
|
88
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
89
|
+
var ownKeys = Object.keys(source);
|
|
90
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
91
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
92
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
93
|
+
}));
|
|
94
|
+
}
|
|
95
|
+
ownKeys.forEach(function(key) {
|
|
96
|
+
_define_property(target, key, source[key]);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return target;
|
|
100
|
+
}
|
|
101
|
+
function ownKeys(object, enumerableOnly) {
|
|
102
|
+
var keys = Object.keys(object);
|
|
103
|
+
if (Object.getOwnPropertySymbols) {
|
|
104
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
105
|
+
if (enumerableOnly) {
|
|
106
|
+
symbols = symbols.filter(function(sym) {
|
|
107
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
keys.push.apply(keys, symbols);
|
|
111
|
+
}
|
|
112
|
+
return keys;
|
|
113
|
+
}
|
|
114
|
+
function _object_spread_props(target, source) {
|
|
115
|
+
source = source != null ? source : {};
|
|
116
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
117
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
118
|
+
} else {
|
|
119
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
120
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return target;
|
|
124
|
+
}
|
|
125
|
+
function _object_without_properties(source, excluded) {
|
|
126
|
+
if (source == null) return {};
|
|
127
|
+
var target = _object_without_properties_loose(source, excluded);
|
|
128
|
+
var key, i;
|
|
129
|
+
if (Object.getOwnPropertySymbols) {
|
|
130
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
131
|
+
for(i = 0; i < sourceSymbolKeys.length; i++){
|
|
132
|
+
key = sourceSymbolKeys[i];
|
|
133
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
134
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
135
|
+
target[key] = source[key];
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return target;
|
|
139
|
+
}
|
|
140
|
+
function _object_without_properties_loose(source, excluded) {
|
|
141
|
+
if (source == null) return {};
|
|
142
|
+
var target = {};
|
|
143
|
+
var sourceKeys = Object.keys(source);
|
|
144
|
+
var key, i;
|
|
145
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
146
|
+
key = sourceKeys[i];
|
|
147
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
148
|
+
target[key] = source[key];
|
|
149
|
+
}
|
|
150
|
+
return target;
|
|
151
|
+
}
|
|
152
|
+
function _sliced_to_array(arr, i) {
|
|
153
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
154
|
+
}
|
|
155
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
156
|
+
if (!o) return;
|
|
157
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
158
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
159
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
160
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
161
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
162
|
+
}
|
|
163
|
+
function _ts_generator(thisArg, body) {
|
|
164
|
+
var f, y, t, g, _ = {
|
|
165
|
+
label: 0,
|
|
166
|
+
sent: function() {
|
|
167
|
+
if (t[0] & 1) throw t[1];
|
|
168
|
+
return t[1];
|
|
169
|
+
},
|
|
170
|
+
trys: [],
|
|
171
|
+
ops: []
|
|
172
|
+
};
|
|
173
|
+
return g = {
|
|
174
|
+
next: verb(0),
|
|
175
|
+
"throw": verb(1),
|
|
176
|
+
"return": verb(2)
|
|
177
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
178
|
+
return this;
|
|
179
|
+
}), g;
|
|
180
|
+
function verb(n) {
|
|
181
|
+
return function(v) {
|
|
182
|
+
return step([
|
|
183
|
+
n,
|
|
184
|
+
v
|
|
185
|
+
]);
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
function step(op) {
|
|
189
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
190
|
+
while(_)try {
|
|
191
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
192
|
+
if (y = 0, t) op = [
|
|
193
|
+
op[0] & 2,
|
|
194
|
+
t.value
|
|
195
|
+
];
|
|
196
|
+
switch(op[0]){
|
|
197
|
+
case 0:
|
|
198
|
+
case 1:
|
|
199
|
+
t = op;
|
|
200
|
+
break;
|
|
201
|
+
case 4:
|
|
202
|
+
_.label++;
|
|
203
|
+
return {
|
|
204
|
+
value: op[1],
|
|
205
|
+
done: false
|
|
206
|
+
};
|
|
207
|
+
case 5:
|
|
208
|
+
_.label++;
|
|
209
|
+
y = op[1];
|
|
210
|
+
op = [
|
|
211
|
+
0
|
|
212
|
+
];
|
|
213
|
+
continue;
|
|
214
|
+
case 7:
|
|
215
|
+
op = _.ops.pop();
|
|
216
|
+
_.trys.pop();
|
|
217
|
+
continue;
|
|
218
|
+
default:
|
|
219
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
220
|
+
_ = 0;
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
224
|
+
_.label = op[1];
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
228
|
+
_.label = t[1];
|
|
229
|
+
t = op;
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
if (t && _.label < t[2]) {
|
|
233
|
+
_.label = t[2];
|
|
234
|
+
_.ops.push(op);
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
if (t[2]) _.ops.pop();
|
|
238
|
+
_.trys.pop();
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
op = body.call(thisArg, _);
|
|
242
|
+
} catch (e) {
|
|
243
|
+
op = [
|
|
244
|
+
6,
|
|
245
|
+
e
|
|
246
|
+
];
|
|
247
|
+
y = 0;
|
|
248
|
+
} finally{
|
|
249
|
+
f = t = 0;
|
|
250
|
+
}
|
|
251
|
+
if (op[0] & 5) throw op[1];
|
|
252
|
+
return {
|
|
253
|
+
value: op[0] ? op[1] : void 0,
|
|
254
|
+
done: true
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
import { ApolloClient, ApolloLink, ApolloProvider as ApolloProviderDefault, HttpLink, InMemoryCache, split } from "@apollo/client";
|
|
259
|
+
import { onError } from "@apollo/client/link/error";
|
|
260
|
+
import { GraphQLWsLink } from "@apollo/client/link/subscriptions";
|
|
261
|
+
import { getMainDefinition } from "@apollo/client/utilities";
|
|
262
|
+
import { createClient as createGraphqlWebSocketClient } from "graphql-ws";
|
|
263
|
+
import { jsx } from "react/jsx-runtime";
|
|
264
|
+
function createLinks(options) {
|
|
265
|
+
var errorLink = onError(function(param) {
|
|
266
|
+
var graphQLErrors = param.graphQLErrors, networkError = param.networkError;
|
|
267
|
+
graphQLErrors === null || graphQLErrors === void 0 ? void 0 : graphQLErrors.forEach(function(param) {
|
|
268
|
+
var message = param.message, locations = param.locations, path = param.path;
|
|
269
|
+
return console.error("[GraphQL error]: Message: ".concat(message, ", Location: ").concat(locations, ", Path: ").concat(path));
|
|
270
|
+
});
|
|
271
|
+
if (networkError) {
|
|
272
|
+
console.error("[Network error]: ".concat(networkError));
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
var httpLink = new HttpLink({
|
|
276
|
+
uri: options === null || options === void 0 ? void 0 : options.uri,
|
|
277
|
+
credentials: "include"
|
|
278
|
+
});
|
|
279
|
+
var wsLink = (options === null || options === void 0 ? void 0 : options.wsUrl) ? new GraphQLWsLink(createGraphqlWebSocketClient({
|
|
280
|
+
url: options.wsUrl
|
|
281
|
+
})) : null;
|
|
282
|
+
var splitLink = wsLink ? split(function(param) {
|
|
283
|
+
var query = param.query;
|
|
284
|
+
var mainDefinition = getMainDefinition(query);
|
|
285
|
+
if (mainDefinition.kind === "OperationDefinition") {
|
|
286
|
+
var operation = mainDefinition.operation;
|
|
287
|
+
return operation === "subscription";
|
|
288
|
+
}
|
|
289
|
+
return false;
|
|
290
|
+
}, wsLink, httpLink) : httpLink;
|
|
291
|
+
var cleanTypeName = new ApolloLink(function(operation, forward) {
|
|
292
|
+
if (operation.variables) {
|
|
293
|
+
operation.variables = JSON.parse(JSON.stringify(operation.variables), function(key, value) {
|
|
294
|
+
return key === "__typename" ? void 0 : value;
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
return forward(operation);
|
|
298
|
+
});
|
|
299
|
+
return {
|
|
300
|
+
errorLink: errorLink,
|
|
301
|
+
httpLink: httpLink,
|
|
302
|
+
wsLink: wsLink,
|
|
303
|
+
splitLink: splitLink,
|
|
304
|
+
cleanTypeName: cleanTypeName
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
function ApolloProvider(param) {
|
|
308
|
+
var isNextJS = param.isNextJS, options = param.options, children = param.children, CustomClient = param.client, CustomProvider = param.provider, CustomCache = param.cache;
|
|
309
|
+
var Client = CustomClient !== null && CustomClient !== void 0 ? CustomClient : ApolloClient;
|
|
310
|
+
if (typeof Client !== "function") {
|
|
311
|
+
throw new TypeError("Invalid ApolloClient provided. Ensure CustomClient is a class.");
|
|
312
|
+
}
|
|
313
|
+
var Provider = CustomProvider || ApolloProviderDefault;
|
|
314
|
+
var Cache = CustomCache || InMemoryCache;
|
|
315
|
+
var _createLinks = createLinks(options), cleanTypeName = _createLinks.cleanTypeName, errorLink = _createLinks.errorLink, splitLink = _createLinks.splitLink;
|
|
316
|
+
var client = new Client(_object_spread({
|
|
317
|
+
cache: _instanceof(Cache, InMemoryCache) ? Cache : new InMemoryCache(),
|
|
318
|
+
link: ApolloLink.from([
|
|
319
|
+
cleanTypeName,
|
|
320
|
+
errorLink,
|
|
321
|
+
splitLink
|
|
322
|
+
].filter(Boolean))
|
|
323
|
+
}, options));
|
|
324
|
+
if (isNextJS) {
|
|
325
|
+
return /* @__PURE__ */ jsx(Provider, {
|
|
326
|
+
makeClient: function() {
|
|
327
|
+
return client;
|
|
328
|
+
},
|
|
329
|
+
children: children
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
return /* @__PURE__ */ jsx(Provider, {
|
|
333
|
+
client: client,
|
|
334
|
+
children: children
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
// src/react/loading.tsx
|
|
338
|
+
import cn from "classnames";
|
|
339
|
+
import { createContext, use, useCallback, useMemo, useState } from "react";
|
|
340
|
+
import styles from "./loading.module.scss";
|
|
341
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
342
|
+
var LoadingContext = createContext(void 0);
|
|
343
|
+
function useLoading() {
|
|
344
|
+
var context = use(LoadingContext);
|
|
345
|
+
if (!context) {
|
|
346
|
+
throw new Error("useLoading must be used within a LoadingProvider");
|
|
347
|
+
}
|
|
348
|
+
return context;
|
|
349
|
+
}
|
|
350
|
+
function Loading(_param) {
|
|
351
|
+
var _param_full = _param.full, full = _param_full === void 0 ? false : _param_full, _param_block = _param.block, block = _param_block === void 0 ? false : _param_block, _param_className = _param.className, className = _param_className === void 0 ? "" : _param_className, _param_message = _param.message, message = _param_message === void 0 ? "Loading" : _param_message, rest = _object_without_properties(_param, [
|
|
352
|
+
"full",
|
|
353
|
+
"block",
|
|
354
|
+
"className",
|
|
355
|
+
"message"
|
|
356
|
+
]);
|
|
357
|
+
function _renderLoading() {
|
|
358
|
+
return /* @__PURE__ */ jsxs("div", _object_spread_props(_object_spread({
|
|
359
|
+
className: styles.container
|
|
360
|
+
}, rest), {
|
|
361
|
+
children: [
|
|
362
|
+
/* @__PURE__ */ jsx2("div", {
|
|
363
|
+
className: styles.ring
|
|
364
|
+
}),
|
|
365
|
+
/* @__PURE__ */ jsx2("div", {
|
|
366
|
+
className: styles.ring
|
|
367
|
+
}),
|
|
368
|
+
/* @__PURE__ */ jsx2("div", {
|
|
369
|
+
className: styles.ring
|
|
370
|
+
}),
|
|
371
|
+
/* @__PURE__ */ jsx2("div", {
|
|
372
|
+
className: styles.ring
|
|
373
|
+
}),
|
|
374
|
+
message && /* @__PURE__ */ jsx2("div", {
|
|
375
|
+
className: styles.message,
|
|
376
|
+
children: message
|
|
377
|
+
})
|
|
378
|
+
]
|
|
379
|
+
}));
|
|
380
|
+
}
|
|
381
|
+
if (full) {
|
|
382
|
+
return /* @__PURE__ */ jsx2("div", {
|
|
383
|
+
className: cn(styles.fullscreen, className),
|
|
384
|
+
children: _renderLoading()
|
|
385
|
+
});
|
|
386
|
+
} else if (block) {
|
|
387
|
+
return /* @__PURE__ */ jsx2("div", {
|
|
388
|
+
className: cn(styles.block, className),
|
|
389
|
+
children: _renderLoading()
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
return _renderLoading();
|
|
393
|
+
}
|
|
394
|
+
function LoadingProvider(param) {
|
|
395
|
+
var children = param.children;
|
|
396
|
+
var _useState = _sliced_to_array(useState(false), 2), isLoading = _useState[0], setIsLoading = _useState[1];
|
|
397
|
+
var _useState1 = _sliced_to_array(useState(false), 2), isGlobalLoading = _useState1[0], setIsGlobalLoading = _useState1[1];
|
|
398
|
+
var showLoading = useCallback(function() {
|
|
399
|
+
var global = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
|
|
400
|
+
setIsLoading(true);
|
|
401
|
+
setIsGlobalLoading(global);
|
|
402
|
+
}, []);
|
|
403
|
+
var hideLoading = useCallback(function() {
|
|
404
|
+
setIsLoading(false);
|
|
405
|
+
setIsGlobalLoading(false);
|
|
406
|
+
}, []);
|
|
407
|
+
var contextValue = useMemo(function() {
|
|
408
|
+
return {
|
|
409
|
+
isLoading: isLoading,
|
|
410
|
+
isGlobalLoading: isGlobalLoading,
|
|
411
|
+
showLoading: showLoading,
|
|
412
|
+
hideLoading: hideLoading
|
|
413
|
+
};
|
|
414
|
+
}, [
|
|
415
|
+
isLoading,
|
|
416
|
+
isGlobalLoading,
|
|
417
|
+
showLoading,
|
|
418
|
+
hideLoading
|
|
419
|
+
]);
|
|
420
|
+
return /* @__PURE__ */ jsx2(LoadingContext, {
|
|
421
|
+
value: contextValue,
|
|
422
|
+
children: isLoading ? /* @__PURE__ */ jsx2(Loading, {
|
|
423
|
+
full: isGlobalLoading
|
|
424
|
+
}) : children
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
// src/react/next-intl.tsx
|
|
428
|
+
import { NextIntlClientProvider, useTranslations } from "next-intl";
|
|
429
|
+
import { createContext as createContext2, use as use2, useMemo as useMemo2 } from "react";
|
|
430
|
+
// src/react/storage.tsx
|
|
431
|
+
import { useCallback as useCallback2, useEffect, useState as useState2 } from "react";
|
|
432
|
+
// src/utils/serializer.ts
|
|
433
|
+
var serializer = {
|
|
434
|
+
serialize: function(value) {
|
|
435
|
+
return JSON.stringify(value, function(_, v) {
|
|
436
|
+
if (_instanceof(v, Date)) {
|
|
437
|
+
return {
|
|
438
|
+
__type: "Date",
|
|
439
|
+
value: v.toISOString()
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
return v;
|
|
443
|
+
});
|
|
444
|
+
},
|
|
445
|
+
deserialize: function(value) {
|
|
446
|
+
return JSON.parse(value, function(_, v) {
|
|
447
|
+
if ((v === null || v === void 0 ? void 0 : v.__type) === "Date") {
|
|
448
|
+
return new Date(v.value);
|
|
449
|
+
}
|
|
450
|
+
return v;
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
// src/utils/storage-client.ts
|
|
455
|
+
import localForage from "localforage";
|
|
456
|
+
var storageClient = {
|
|
457
|
+
get: function get(key) {
|
|
458
|
+
return _async_to_generator(function() {
|
|
459
|
+
var error;
|
|
460
|
+
return _ts_generator(this, function(_state) {
|
|
461
|
+
switch(_state.label){
|
|
462
|
+
case 0:
|
|
463
|
+
_state.trys.push([
|
|
464
|
+
0,
|
|
465
|
+
2,
|
|
466
|
+
,
|
|
467
|
+
3
|
|
468
|
+
]);
|
|
469
|
+
return [
|
|
470
|
+
4,
|
|
471
|
+
localForage.getItem(key)
|
|
472
|
+
];
|
|
473
|
+
case 1:
|
|
474
|
+
return [
|
|
475
|
+
2,
|
|
476
|
+
_state.sent()
|
|
477
|
+
];
|
|
478
|
+
case 2:
|
|
479
|
+
error = _state.sent();
|
|
480
|
+
console.error('❌ [Storage:get] Error getting key "'.concat(key, '":'), error);
|
|
481
|
+
return [
|
|
482
|
+
2,
|
|
483
|
+
null
|
|
484
|
+
];
|
|
485
|
+
case 3:
|
|
486
|
+
return [
|
|
487
|
+
2
|
|
488
|
+
];
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
})();
|
|
492
|
+
},
|
|
493
|
+
set: function set(key, value) {
|
|
494
|
+
return _async_to_generator(function() {
|
|
495
|
+
var error;
|
|
496
|
+
return _ts_generator(this, function(_state) {
|
|
497
|
+
switch(_state.label){
|
|
498
|
+
case 0:
|
|
499
|
+
_state.trys.push([
|
|
500
|
+
0,
|
|
501
|
+
2,
|
|
502
|
+
,
|
|
503
|
+
3
|
|
504
|
+
]);
|
|
505
|
+
return [
|
|
506
|
+
4,
|
|
507
|
+
localForage.setItem(key, value)
|
|
508
|
+
];
|
|
509
|
+
case 1:
|
|
510
|
+
_state.sent();
|
|
511
|
+
return [
|
|
512
|
+
3,
|
|
513
|
+
3
|
|
514
|
+
];
|
|
515
|
+
case 2:
|
|
516
|
+
error = _state.sent();
|
|
517
|
+
console.error('❌ [Storage:set] Error setting key "'.concat(key, '":'), error);
|
|
518
|
+
return [
|
|
519
|
+
3,
|
|
520
|
+
3
|
|
521
|
+
];
|
|
522
|
+
case 3:
|
|
523
|
+
return [
|
|
524
|
+
2
|
|
525
|
+
];
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
})();
|
|
529
|
+
},
|
|
530
|
+
remove: function remove(key) {
|
|
531
|
+
return _async_to_generator(function() {
|
|
532
|
+
var error;
|
|
533
|
+
return _ts_generator(this, function(_state) {
|
|
534
|
+
switch(_state.label){
|
|
535
|
+
case 0:
|
|
536
|
+
_state.trys.push([
|
|
537
|
+
0,
|
|
538
|
+
2,
|
|
539
|
+
,
|
|
540
|
+
3
|
|
541
|
+
]);
|
|
542
|
+
return [
|
|
543
|
+
4,
|
|
544
|
+
localForage.removeItem(key)
|
|
545
|
+
];
|
|
546
|
+
case 1:
|
|
547
|
+
_state.sent();
|
|
548
|
+
return [
|
|
549
|
+
3,
|
|
550
|
+
3
|
|
551
|
+
];
|
|
552
|
+
case 2:
|
|
553
|
+
error = _state.sent();
|
|
554
|
+
console.error('❌ [Storage:remove] Error removing key "'.concat(key, '":'), error);
|
|
555
|
+
return [
|
|
556
|
+
3,
|
|
557
|
+
3
|
|
558
|
+
];
|
|
559
|
+
case 3:
|
|
560
|
+
return [
|
|
561
|
+
2
|
|
562
|
+
];
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
})();
|
|
566
|
+
},
|
|
567
|
+
keys: function keys() {
|
|
568
|
+
return _async_to_generator(function() {
|
|
569
|
+
var keys, error;
|
|
570
|
+
return _ts_generator(this, function(_state) {
|
|
571
|
+
switch(_state.label){
|
|
572
|
+
case 0:
|
|
573
|
+
_state.trys.push([
|
|
574
|
+
0,
|
|
575
|
+
2,
|
|
576
|
+
,
|
|
577
|
+
3
|
|
578
|
+
]);
|
|
579
|
+
return [
|
|
580
|
+
4,
|
|
581
|
+
localForage.keys()
|
|
582
|
+
];
|
|
583
|
+
case 1:
|
|
584
|
+
keys = _state.sent();
|
|
585
|
+
return [
|
|
586
|
+
2,
|
|
587
|
+
keys !== null && keys !== void 0 ? keys : []
|
|
588
|
+
];
|
|
589
|
+
case 2:
|
|
590
|
+
error = _state.sent();
|
|
591
|
+
console.error("❌ [Storage:keys] Error getting keys:", error);
|
|
592
|
+
return [
|
|
593
|
+
2,
|
|
594
|
+
[]
|
|
595
|
+
];
|
|
596
|
+
case 3:
|
|
597
|
+
return [
|
|
598
|
+
2
|
|
599
|
+
];
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
})();
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
// src/react/storage.tsx
|
|
606
|
+
function useStorage(key, initialValue) {
|
|
607
|
+
var serializer2 = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : serializer;
|
|
608
|
+
var _useState2 = _sliced_to_array(useState2(initialValue), 2), value = _useState2[0], setValue = _useState2[1];
|
|
609
|
+
var _useState21 = _sliced_to_array(useState2(false), 2), isLoaded = _useState21[0], setIsLoaded = _useState21[1];
|
|
610
|
+
useEffect(function() {
|
|
611
|
+
var isMounted = true;
|
|
612
|
+
var loadValue = /*#__PURE__*/ function() {
|
|
613
|
+
var _ref = _async_to_generator(function() {
|
|
614
|
+
var valueFound, parsedValue, serialized, error;
|
|
615
|
+
return _ts_generator(this, function(_state) {
|
|
616
|
+
switch(_state.label){
|
|
617
|
+
case 0:
|
|
618
|
+
_state.trys.push([
|
|
619
|
+
0,
|
|
620
|
+
6,
|
|
621
|
+
7,
|
|
622
|
+
8
|
|
623
|
+
]);
|
|
624
|
+
return [
|
|
625
|
+
4,
|
|
626
|
+
storageClient.get(key)
|
|
627
|
+
];
|
|
628
|
+
case 1:
|
|
629
|
+
valueFound = _state.sent();
|
|
630
|
+
if (!isMounted) return [
|
|
631
|
+
3,
|
|
632
|
+
5
|
|
633
|
+
];
|
|
634
|
+
if (!(valueFound !== null)) return [
|
|
635
|
+
3,
|
|
636
|
+
2
|
|
637
|
+
];
|
|
638
|
+
parsedValue = serializer2.deserialize(valueFound);
|
|
639
|
+
setValue(parsedValue);
|
|
640
|
+
return [
|
|
641
|
+
3,
|
|
642
|
+
5
|
|
643
|
+
];
|
|
644
|
+
case 2:
|
|
645
|
+
if (!(initialValue !== void 0)) return [
|
|
646
|
+
3,
|
|
647
|
+
4
|
|
648
|
+
];
|
|
649
|
+
serialized = serializer2.serialize(initialValue);
|
|
650
|
+
return [
|
|
651
|
+
4,
|
|
652
|
+
storageClient.set(key, serialized)
|
|
653
|
+
];
|
|
654
|
+
case 3:
|
|
655
|
+
_state.sent();
|
|
656
|
+
setValue(initialValue);
|
|
657
|
+
return [
|
|
658
|
+
3,
|
|
659
|
+
5
|
|
660
|
+
];
|
|
661
|
+
case 4:
|
|
662
|
+
setValue(void 0);
|
|
663
|
+
_state.label = 5;
|
|
664
|
+
case 5:
|
|
665
|
+
return [
|
|
666
|
+
3,
|
|
667
|
+
8
|
|
668
|
+
];
|
|
669
|
+
case 6:
|
|
670
|
+
error = _state.sent();
|
|
671
|
+
console.error('Error loading value for key "'.concat(key, '":'), error);
|
|
672
|
+
if (isMounted) {
|
|
673
|
+
setValue(initialValue);
|
|
674
|
+
}
|
|
675
|
+
return [
|
|
676
|
+
3,
|
|
677
|
+
8
|
|
678
|
+
];
|
|
679
|
+
case 7:
|
|
680
|
+
if (isMounted) setIsLoaded(true);
|
|
681
|
+
return [
|
|
682
|
+
7
|
|
683
|
+
];
|
|
684
|
+
case 8:
|
|
685
|
+
return [
|
|
686
|
+
2
|
|
687
|
+
];
|
|
688
|
+
}
|
|
689
|
+
});
|
|
690
|
+
});
|
|
691
|
+
return function loadValue() {
|
|
692
|
+
return _ref.apply(this, arguments);
|
|
693
|
+
};
|
|
694
|
+
}();
|
|
695
|
+
loadValue();
|
|
696
|
+
return function() {
|
|
697
|
+
isMounted = false;
|
|
698
|
+
setIsLoaded(false);
|
|
699
|
+
};
|
|
700
|
+
}, [
|
|
701
|
+
key,
|
|
702
|
+
initialValue,
|
|
703
|
+
serializer2
|
|
704
|
+
]);
|
|
705
|
+
useEffect(function() {
|
|
706
|
+
if (!isLoaded) return;
|
|
707
|
+
var saveValue = /*#__PURE__*/ function() {
|
|
708
|
+
var _ref = _async_to_generator(function() {
|
|
709
|
+
var serialized, error;
|
|
710
|
+
return _ts_generator(this, function(_state) {
|
|
711
|
+
switch(_state.label){
|
|
712
|
+
case 0:
|
|
713
|
+
_state.trys.push([
|
|
714
|
+
0,
|
|
715
|
+
3,
|
|
716
|
+
,
|
|
717
|
+
4
|
|
718
|
+
]);
|
|
719
|
+
if (!(value !== void 0)) return [
|
|
720
|
+
3,
|
|
721
|
+
2
|
|
722
|
+
];
|
|
723
|
+
serialized = serializer2.serialize(value);
|
|
724
|
+
return [
|
|
725
|
+
4,
|
|
726
|
+
storageClient.set(key, serialized)
|
|
727
|
+
];
|
|
728
|
+
case 1:
|
|
729
|
+
_state.sent();
|
|
730
|
+
_state.label = 2;
|
|
731
|
+
case 2:
|
|
732
|
+
return [
|
|
733
|
+
3,
|
|
734
|
+
4
|
|
735
|
+
];
|
|
736
|
+
case 3:
|
|
737
|
+
error = _state.sent();
|
|
738
|
+
console.error('Error saving value for key "'.concat(key, '":'), error);
|
|
739
|
+
return [
|
|
740
|
+
3,
|
|
741
|
+
4
|
|
742
|
+
];
|
|
743
|
+
case 4:
|
|
744
|
+
return [
|
|
745
|
+
2
|
|
746
|
+
];
|
|
747
|
+
}
|
|
748
|
+
});
|
|
749
|
+
});
|
|
750
|
+
return function saveValue() {
|
|
751
|
+
return _ref.apply(this, arguments);
|
|
752
|
+
};
|
|
753
|
+
}();
|
|
754
|
+
saveValue();
|
|
755
|
+
}, [
|
|
756
|
+
value,
|
|
757
|
+
key,
|
|
758
|
+
serializer2,
|
|
759
|
+
isLoaded
|
|
760
|
+
]);
|
|
761
|
+
var set = useCallback2(function(newValue) {
|
|
762
|
+
setValue(function(prev) {
|
|
763
|
+
return typeof newValue === "function" ? newValue(prev) : newValue;
|
|
764
|
+
});
|
|
765
|
+
}, []);
|
|
766
|
+
var remove = useCallback2(/*#__PURE__*/ _async_to_generator(function() {
|
|
767
|
+
var error;
|
|
768
|
+
return _ts_generator(this, function(_state) {
|
|
769
|
+
switch(_state.label){
|
|
770
|
+
case 0:
|
|
771
|
+
_state.trys.push([
|
|
772
|
+
0,
|
|
773
|
+
2,
|
|
774
|
+
,
|
|
775
|
+
3
|
|
776
|
+
]);
|
|
777
|
+
return [
|
|
778
|
+
4,
|
|
779
|
+
storageClient.remove(key)
|
|
780
|
+
];
|
|
781
|
+
case 1:
|
|
782
|
+
_state.sent();
|
|
783
|
+
setValue(void 0);
|
|
784
|
+
return [
|
|
785
|
+
3,
|
|
786
|
+
3
|
|
787
|
+
];
|
|
788
|
+
case 2:
|
|
789
|
+
error = _state.sent();
|
|
790
|
+
console.error('Error removing key "'.concat(key, '":'), error);
|
|
791
|
+
return [
|
|
792
|
+
3,
|
|
793
|
+
3
|
|
794
|
+
];
|
|
795
|
+
case 3:
|
|
796
|
+
return [
|
|
797
|
+
2
|
|
798
|
+
];
|
|
799
|
+
}
|
|
800
|
+
});
|
|
801
|
+
}), [
|
|
802
|
+
key
|
|
803
|
+
]);
|
|
804
|
+
return {
|
|
805
|
+
value: value,
|
|
806
|
+
set: set,
|
|
807
|
+
remove: remove
|
|
808
|
+
};
|
|
809
|
+
}
|
|
810
|
+
// src/react/next-intl.tsx
|
|
811
|
+
import { Fragment, jsx as jsx3 } from "react/jsx-runtime";
|
|
812
|
+
var NextIntlContext = createContext2(void 0);
|
|
813
|
+
function useNextIntl() {
|
|
814
|
+
var context = use2(NextIntlContext);
|
|
815
|
+
if (!context) {
|
|
816
|
+
throw new Error("useNextIntl must be used within a NextIntlProvider");
|
|
817
|
+
}
|
|
818
|
+
return context;
|
|
819
|
+
}
|
|
820
|
+
var useTranslateNextIntl = useTranslations;
|
|
821
|
+
function withNextIntl(Component) {
|
|
822
|
+
var PageWithI18n = function(props) {
|
|
823
|
+
var _languages_find;
|
|
824
|
+
var currentLanguage = useNextIntl().currentLanguage;
|
|
825
|
+
var messages = props.messages, languages = props.languages;
|
|
826
|
+
var defaultLang = "en";
|
|
827
|
+
var defaultMessages = messages[(currentLanguage === null || currentLanguage === void 0 ? void 0 : currentLanguage.value) || defaultLang];
|
|
828
|
+
var timeZone = (_languages_find = languages.find(function(lang) {
|
|
829
|
+
return lang.value === (currentLanguage === null || currentLanguage === void 0 ? void 0 : currentLanguage.value);
|
|
830
|
+
})) === null || _languages_find === void 0 ? void 0 : _languages_find.timezone;
|
|
831
|
+
if (!messages) {
|
|
832
|
+
console.warn("Missing messages for language: ".concat((currentLanguage === null || currentLanguage === void 0 ? void 0 : currentLanguage.value) || defaultLang));
|
|
833
|
+
return null;
|
|
834
|
+
}
|
|
835
|
+
return /* @__PURE__ */ jsx3(NextIntlClientProvider, {
|
|
836
|
+
locale: (currentLanguage === null || currentLanguage === void 0 ? void 0 : currentLanguage.value) || defaultLang,
|
|
837
|
+
messages: defaultMessages,
|
|
838
|
+
timeZone: timeZone,
|
|
839
|
+
children: /* @__PURE__ */ jsx3(Component, _object_spread({}, props))
|
|
840
|
+
});
|
|
841
|
+
};
|
|
842
|
+
PageWithI18n.displayName = "withNextIntl(".concat(Component.displayName || Component.name || "Component", ")");
|
|
843
|
+
return PageWithI18n;
|
|
844
|
+
}
|
|
845
|
+
function LanguageWrapperBase(param) {
|
|
846
|
+
var children = param.children;
|
|
847
|
+
return /* @__PURE__ */ jsx3(Fragment, {
|
|
848
|
+
children: children
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
var LanguageWrapper = withNextIntl(LanguageWrapperBase);
|
|
852
|
+
function NextIntlProvider(param) {
|
|
853
|
+
var children = param.children, languages = param.languages, messages = param.messages;
|
|
854
|
+
var _languages_;
|
|
855
|
+
var _useStorage = useStorage("lang", (_languages_ = languages === null || languages === void 0 ? void 0 : languages[0]) !== null && _languages_ !== void 0 ? _languages_ : {}), value = _useStorage.value, set = _useStorage.set;
|
|
856
|
+
var contextValue = useMemo2(function() {
|
|
857
|
+
return {
|
|
858
|
+
languages: languages,
|
|
859
|
+
currentLanguage: value,
|
|
860
|
+
setCurrentLanguage: set
|
|
861
|
+
};
|
|
862
|
+
}, [
|
|
863
|
+
languages,
|
|
864
|
+
set,
|
|
865
|
+
value
|
|
866
|
+
]);
|
|
867
|
+
return /* @__PURE__ */ jsx3(NextIntlContext, {
|
|
868
|
+
value: contextValue,
|
|
869
|
+
children: /* @__PURE__ */ jsx3(LanguageWrapper, {
|
|
870
|
+
languages: languages,
|
|
871
|
+
messages: messages,
|
|
872
|
+
children: children
|
|
873
|
+
})
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
export { ApolloProvider, Loading, LoadingContext, LoadingProvider, NextIntlContext, NextIntlProvider, useLoading, useNextIntl, useStorage, useTranslateNextIntl, withNextIntl };
|