@cyberskill/shared 3.2.0 → 3.3.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/config/commitlint/index.js +8 -9
- package/dist/config/commitlint/index.js.map +1 -1
- package/dist/config/config.type.js +8 -5
- package/dist/config/config.type.js.map +1 -1
- package/dist/config/config.util.js +33 -42
- package/dist/config/config.util.js.map +1 -1
- package/dist/config/env/env.constant.js +6 -5
- package/dist/config/env/env.constant.js.map +1 -1
- package/dist/config/env/env.util.js +26 -27
- package/dist/config/env/env.util.js.map +1 -1
- package/dist/config/env/index.js +2 -7
- package/dist/config/eslint/index.js +23 -19
- package/dist/config/eslint/index.js.map +1 -1
- package/dist/config/graphql-codegen/graphql-codegen.util.js +30 -38
- package/dist/config/graphql-codegen/graphql-codegen.util.js.map +1 -1
- package/dist/config/graphql-codegen/index.js +2 -5
- package/dist/config/index.js +3 -7
- package/dist/config/lint-staged/index.js +8 -7
- package/dist/config/lint-staged/index.js.map +1 -1
- package/dist/config/storybook/index.js +2 -6
- package/dist/config/storybook/storybook.main.js +19 -18
- package/dist/config/storybook/storybook.main.js.map +1 -1
- package/dist/config/storybook/storybook.preview.js +31 -37
- package/dist/config/storybook/storybook.preview.js.map +1 -1
- package/dist/config/vitest/index.js +3 -7
- package/dist/config/vitest/vitest.e2e.js +14 -17
- package/dist/config/vitest/vitest.e2e.js.map +1 -1
- package/dist/config/vitest/vitest.unit.js +31 -32
- package/dist/config/vitest/vitest.unit.js.map +1 -1
- package/dist/constant/common.js +6 -5
- package/dist/constant/common.js.map +1 -1
- package/dist/constant/index.js +3 -7
- package/dist/constant/response-status.d.ts +186 -186
- package/dist/constant/response-status.js +254 -253
- package/dist/constant/response-status.js.map +1 -1
- package/dist/node/apollo-server/apollo-server.util.js +27 -29
- package/dist/node/apollo-server/apollo-server.util.js.map +1 -1
- package/dist/node/apollo-server/index.js +2 -7
- package/dist/node/cli/index.js +112 -113
- package/dist/node/cli/index.js.map +1 -1
- package/dist/node/command/command.type.js +8 -5
- package/dist/node/command/command.type.js.map +1 -1
- package/dist/node/command/command.util.js +136 -149
- package/dist/node/command/command.util.js.map +1 -1
- package/dist/node/command/index.js +3 -12
- package/dist/node/express/express.type.d.ts +11 -0
- package/dist/node/express/express.type.js +2 -0
- package/dist/node/express/express.util.js +74 -65
- package/dist/node/express/express.util.js.map +1 -1
- package/dist/node/express/index.js +3 -14
- package/dist/node/fs/fs.util.js +27 -51
- package/dist/node/fs/fs.util.js.map +1 -1
- package/dist/node/fs/index.js +2 -19
- package/dist/node/log/index.js +2 -8
- package/dist/node/log/log.type.js +8 -5
- package/dist/node/log/log.type.js.map +1 -1
- package/dist/node/log/log.util.js +51 -68
- package/dist/node/log/log.util.js.map +1 -1
- package/dist/node/mongo/index.js +8 -26
- package/dist/node/mongo/mongo.constant.js +6 -6
- package/dist/node/mongo/mongo.constant.js.map +1 -1
- package/dist/node/mongo/mongo.controller.mongoose.d.ts +6 -1
- package/dist/node/mongo/mongo.controller.mongoose.js +333 -467
- package/dist/node/mongo/mongo.controller.mongoose.js.map +1 -1
- package/dist/node/mongo/mongo.controller.native.js +153 -212
- package/dist/node/mongo/mongo.controller.native.js.map +1 -1
- package/dist/node/mongo/mongo.dynamic-populate.js +164 -192
- package/dist/node/mongo/mongo.dynamic-populate.js.map +1 -1
- package/dist/node/mongo/mongo.populate.js +229 -262
- package/dist/node/mongo/mongo.populate.js.map +1 -1
- package/dist/node/mongo/mongo.type.js +8 -17
- package/dist/node/mongo/mongo.type.js.map +1 -1
- package/dist/node/mongo/mongo.util.js +134 -293
- package/dist/node/mongo/mongo.util.js.map +1 -1
- package/dist/node/package/index.js +3 -11
- package/dist/node/package/package.type.js +8 -5
- package/dist/node/package/package.type.js.map +1 -1
- package/dist/node/package/package.util.js +216 -225
- package/dist/node/package/package.util.js.map +1 -1
- package/dist/node/path/index.js +3 -58
- package/dist/node/path/path.constant.js +211 -298
- package/dist/node/path/path.constant.js.map +1 -1
- package/dist/node/path/path.util.js +13 -16
- package/dist/node/path/path.util.js.map +1 -1
- package/dist/node/storage/index.js +3 -10
- package/dist/node/storage/storage.constant.js +6 -8
- package/dist/node/storage/storage.constant.js.map +1 -1
- package/dist/node/storage/storage.util.js +127 -178
- package/dist/node/storage/storage.util.js.map +1 -1
- package/dist/node/upload/index.js +4 -16
- package/dist/node/upload/upload.constant.js +58 -32
- package/dist/node/upload/upload.constant.js.map +1 -1
- package/dist/node/upload/upload.type.js +8 -5
- package/dist/node/upload/upload.type.js.map +1 -1
- package/dist/node/upload/upload.util.js +125 -137
- package/dist/node/upload/upload.util.js.map +1 -1
- package/dist/node/ws/index.js +2 -6
- package/dist/node/ws/ws.type.d.ts +7 -8
- package/dist/node/ws/ws.util.js +46 -44
- package/dist/node/ws/ws.util.js.map +1 -1
- package/dist/node_modules/.pnpm/vitest@4.1.0_@types_node@25.5.0_jsdom@29.0.0_@noble_hashes@1.8.0__vite@8.0.0_@types_nod_53aa4254f295b3c40bb8f17b6ab226b5/node_modules/vitest/dist/config.js +8 -0
- package/dist/node_modules/.pnpm/vitest@4.1.0_@types_node@25.5.0_jsdom@29.0.0_@noble_hashes@1.8.0__vite@8.0.0_@types_nod_53aa4254f295b3c40bb8f17b6ab226b5/node_modules/vitest/dist/config.js.map +1 -0
- package/dist/react/apollo-client/apollo-client.component.js +16 -18
- package/dist/react/apollo-client/apollo-client.component.js.map +1 -1
- package/dist/react/apollo-client/apollo-client.constant.js +6 -5
- package/dist/react/apollo-client/apollo-client.constant.js.map +1 -1
- package/dist/react/apollo-client/apollo-client.context.js +10 -13
- package/dist/react/apollo-client/apollo-client.context.js.map +1 -1
- package/dist/react/apollo-client/apollo-client.module.scss.js +8 -7
- package/dist/react/apollo-client/apollo-client.module.scss.js.map +1 -1
- package/dist/react/apollo-client/apollo-client.util.js +57 -75
- package/dist/react/apollo-client/apollo-client.util.js.map +1 -1
- package/dist/react/apollo-client/index.js +7 -30
- package/dist/react/apollo-client/links/index.js +2 -5
- package/dist/react/apollo-client/links/upload.js +63 -107
- package/dist/react/apollo-client/links/upload.js.map +1 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.js +14 -16
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.component.js.map +1 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.js +8 -7
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.rsc.js.map +1 -1
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js +14 -14
- package/dist/react/apollo-client-nextjs/apollo-client-nextjs.util.js.map +1 -1
- package/dist/react/apollo-client-nextjs/index.js +3 -7
- package/dist/react/apollo-error/apollo-error.component.js +57 -69
- package/dist/react/apollo-error/apollo-error.component.js.map +1 -1
- package/dist/react/apollo-error/apollo-error.context.js +7 -6
- package/dist/react/apollo-error/apollo-error.context.js.map +1 -1
- package/dist/react/apollo-error/apollo-error.hook.js +10 -10
- package/dist/react/apollo-error/apollo-error.hook.js.map +1 -1
- package/dist/react/apollo-error/apollo-error.module.scss.js +15 -11
- package/dist/react/apollo-error/apollo-error.module.scss.js.map +1 -1
- package/dist/react/apollo-error/apollo-error.provider.js +31 -25
- package/dist/react/apollo-error/apollo-error.provider.js.map +1 -1
- package/dist/react/apollo-error/apollo-error.util.js +14 -16
- package/dist/react/apollo-error/apollo-error.util.js.map +1 -1
- package/dist/react/apollo-error/index.js +5 -15
- package/dist/react/i18next/i18next.hook.js +7 -6
- package/dist/react/i18next/i18next.hook.js.map +1 -1
- package/dist/react/i18next/i18next.util.js +9 -8
- package/dist/react/i18next/i18next.util.js.map +1 -1
- package/dist/react/i18next/index.js +3 -7
- package/dist/react/loading/index.js +3 -9
- package/dist/react/loading/loading.component.js +47 -48
- package/dist/react/loading/loading.component.js.map +1 -1
- package/dist/react/loading/loading.context.js +7 -6
- package/dist/react/loading/loading.context.js.map +1 -1
- package/dist/react/loading/loading.hook.js +11 -11
- package/dist/react/loading/loading.hook.js.map +1 -1
- package/dist/react/loading/loading.module.scss.js +18 -15
- package/dist/react/loading/loading.module.scss.js.map +1 -1
- package/dist/react/loading/loading.provider.js +26 -18
- package/dist/react/loading/loading.provider.js.map +1 -1
- package/dist/react/log/index.js +2 -6
- package/dist/react/log/log.util.d.ts +8 -0
- package/dist/react/log/log.util.js +33 -29
- package/dist/react/log/log.util.js.map +1 -1
- package/dist/react/next-intl/index.js +6 -14
- package/dist/react/next-intl/next-intl.constant.js +16 -15
- package/dist/react/next-intl/next-intl.constant.js.map +1 -1
- package/dist/react/next-intl/next-intl.context.js +7 -6
- package/dist/react/next-intl/next-intl.context.js.map +1 -1
- package/dist/react/next-intl/next-intl.hoc.js +20 -23
- package/dist/react/next-intl/next-intl.hoc.js.map +1 -1
- package/dist/react/next-intl/next-intl.hook.js +13 -14
- package/dist/react/next-intl/next-intl.hook.js.map +1 -1
- package/dist/react/next-intl/next-intl.provider.js +28 -23
- package/dist/react/next-intl/next-intl.provider.js.map +1 -1
- package/dist/react/storage/index.js +3 -7
- package/dist/react/storage/storage.hook.js +61 -58
- package/dist/react/storage/storage.hook.js.map +1 -1
- package/dist/react/storage/storage.util.js +36 -68
- package/dist/react/storage/storage.util.js.map +1 -1
- package/dist/react/toast/index.js +2 -6
- package/dist/react/userback/index.js +2 -5
- package/dist/react/userback/userback.component.js +27 -27
- package/dist/react/userback/userback.component.js.map +1 -1
- package/dist/style.css +2 -1
- package/dist/typescript/common.type.js +8 -5
- package/dist/typescript/common.type.js.map +1 -1
- package/dist/typescript/index.js +2 -5
- package/dist/util/common/common.util.js +119 -48
- package/dist/util/common/common.util.js.map +1 -1
- package/dist/util/common/index.js +2 -9
- package/dist/util/index.js +6 -27
- package/dist/util/object/index.d.ts +3 -0
- package/dist/util/object/index.js +2 -10
- package/dist/util/object/object.util.js +94 -128
- package/dist/util/object/object.util.js.map +1 -1
- package/dist/util/serializer/index.js +2 -5
- package/dist/util/serializer/serializer.util.js +73 -78
- package/dist/util/serializer/serializer.util.js.map +1 -1
- package/dist/util/string/index.d.ts +3 -0
- package/dist/util/string/index.js +2 -10
- package/dist/util/string/string.util.js +59 -71
- package/dist/util/string/string.util.js.map +1 -1
- package/dist/util/validate/index.d.ts +3 -0
- package/dist/util/validate/index.js +2 -5
- package/dist/util/validate/validate.util.js +13 -39
- package/dist/util/validate/validate.util.js.map +1 -1
- package/package.json +29 -27
- package/dist/config/env/index.js.map +0 -1
- package/dist/config/graphql-codegen/index.js.map +0 -1
- package/dist/config/index.js.map +0 -1
- package/dist/config/storybook/index.js.map +0 -1
- package/dist/config/vitest/index.js.map +0 -1
- package/dist/constant/index.js.map +0 -1
- package/dist/node/apollo-server/index.js.map +0 -1
- package/dist/node/command/index.js.map +0 -1
- package/dist/node/express/index.js.map +0 -1
- package/dist/node/fs/index.js.map +0 -1
- package/dist/node/log/index.js.map +0 -1
- package/dist/node/mongo/index.js.map +0 -1
- package/dist/node/package/index.js.map +0 -1
- package/dist/node/path/index.js.map +0 -1
- package/dist/node/storage/index.js.map +0 -1
- package/dist/node/upload/index.js.map +0 -1
- package/dist/node/ws/index.js.map +0 -1
- package/dist/node_modules/.pnpm/vitest@4.0.18_@types_node@25.3.5_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2/node_modules/vitest/dist/config.js +0 -7
- package/dist/node_modules/.pnpm/vitest@4.0.18_@types_node@25.3.5_jiti@2.6.1_jsdom@28.1.0_@noble_hashes@1.8.0__sass@1.97.3_tsx@4.21.0_yaml@2.8.2/node_modules/vitest/dist/config.js.map +0 -1
- package/dist/react/apollo-client/index.js.map +0 -1
- package/dist/react/apollo-client/links/index.js.map +0 -1
- package/dist/react/apollo-client-nextjs/index.js.map +0 -1
- package/dist/react/apollo-error/index.js.map +0 -1
- package/dist/react/i18next/index.js.map +0 -1
- package/dist/react/loading/index.js.map +0 -1
- package/dist/react/log/index.js.map +0 -1
- package/dist/react/next-intl/index.js.map +0 -1
- package/dist/react/storage/index.js.map +0 -1
- package/dist/react/toast/index.js.map +0 -1
- package/dist/react/userback/index.js.map +0 -1
- package/dist/typescript/index.js.map +0 -1
- package/dist/util/common/index.js.map +0 -1
- package/dist/util/index.js.map +0 -1
- package/dist/util/object/index.js.map +0 -1
- package/dist/util/serializer/index.js.map +0 -1
- package/dist/util/string/index.js.map +0 -1
- package/dist/util/validate/index.js.map +0 -1
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { use as
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { NextIntlContext as e } from "./next-intl.context.js";
|
|
2
|
+
import { use as t } from "react";
|
|
3
|
+
import { useTranslations as n } from "next-intl";
|
|
4
|
+
//#region src/react/next-intl/next-intl.hook.tsx
|
|
5
|
+
function r() {
|
|
6
|
+
let n = t(e);
|
|
7
|
+
if (!n) throw Error("useNextIntl must be used within a NextIntlProvider");
|
|
8
|
+
return n;
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
//# sourceMappingURL=next-intl.hook.js.map
|
|
10
|
+
var i = n;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { r as useNextIntl, i as useTranslateNextIntl };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=next-intl.hook.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-intl.hook.js","sources":["../../../src/react/next-intl/next-intl.hook.tsx"],"sourcesContent":["import { useTranslations } from 'next-intl';\nimport { use } from 'react';\n\nimport type { I_NextIntlContext } from './next-intl.type.js';\n\nimport { NextIntlContext } from './next-intl.context.js';\n\n/**\n * React hook that provides access to Next.js internationalization context.\n * This hook retrieves the Next.js internationalization context which contains\n * language information and language switching functionality. It provides a\n * convenient way to access internationalization features within components.\n *\n * The hook will throw an error if used outside of a NextIntlProvider,\n * ensuring proper context usage and providing clear error messages for debugging.\n *\n * @returns The Next.js internationalization context containing language state and control methods.\n * @throws {Error} When used outside of a NextIntlProvider context.\n */\nexport function useNextIntl(): I_NextIntlContext {\n const context = use(NextIntlContext);\n\n if (!context) {\n throw new Error('useNextIntl must be used within a NextIntlProvider');\n }\n\n return context;\n}\n\n/**\n * React hook that provides Next.js translation functionality.\n * This hook is a wrapper around next-intl's useTranslations hook,\n * providing access to translation functions and current locale information.\n * It enables internationalization features including text translation,\n * locale switching, and pluralization support for Next.js applications.\n *\n * @returns The useTranslations hook result with translation functions and locale information.\n */\nexport const useTranslateNextIntl: typeof useTranslations = useTranslations;\n"],"
|
|
1
|
+
{"version":3,"file":"next-intl.hook.js","names":[],"sources":["../../../src/react/next-intl/next-intl.hook.tsx"],"sourcesContent":["import { useTranslations } from 'next-intl';\nimport { use } from 'react';\n\nimport type { I_NextIntlContext } from './next-intl.type.js';\n\nimport { NextIntlContext } from './next-intl.context.js';\n\n/**\n * React hook that provides access to Next.js internationalization context.\n * This hook retrieves the Next.js internationalization context which contains\n * language information and language switching functionality. It provides a\n * convenient way to access internationalization features within components.\n *\n * The hook will throw an error if used outside of a NextIntlProvider,\n * ensuring proper context usage and providing clear error messages for debugging.\n *\n * @returns The Next.js internationalization context containing language state and control methods.\n * @throws {Error} When used outside of a NextIntlProvider context.\n */\nexport function useNextIntl(): I_NextIntlContext {\n const context = use(NextIntlContext);\n\n if (!context) {\n throw new Error('useNextIntl must be used within a NextIntlProvider');\n }\n\n return context;\n}\n\n/**\n * React hook that provides Next.js translation functionality.\n * This hook is a wrapper around next-intl's useTranslations hook,\n * providing access to translation functions and current locale information.\n * It enables internationalization features including text translation,\n * locale switching, and pluralization support for Next.js applications.\n *\n * @returns The useTranslations hook result with translation functions and locale information.\n */\nexport const useTranslateNextIntl: typeof useTranslations = useTranslations;\n"],"mappings":";;;;AAmBA,SAAgB,IAAiC;CAC7C,IAAM,IAAU,EAAI,EAAgB;AAEpC,KAAI,CAAC,EACD,OAAU,MAAM,qDAAqD;AAGzE,QAAO;;AAYX,IAAa,IAA+C"}
|
|
@@ -1,25 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { useStorage as e } from "../storage/storage.hook.js";
|
|
2
|
+
import { NEXT_INTL_DEFAULT_LANGUAGE as t } from "./next-intl.constant.js";
|
|
3
|
+
import { NextIntlContext as n } from "./next-intl.context.js";
|
|
4
|
+
import { withNextIntl as r } from "./next-intl.hoc.js";
|
|
5
|
+
import * as i from "react";
|
|
6
|
+
import { useMemo as a } from "react";
|
|
7
|
+
//#region src/react/next-intl/next-intl.provider.tsx
|
|
8
|
+
function o({ children: e }) {
|
|
9
|
+
return /* @__PURE__ */ i.createElement(i.Fragment, null, e);
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
var s = r(o);
|
|
12
|
+
function c({ children: r, languages: o, messages: c }) {
|
|
13
|
+
let { value: l, set: u } = e("lang", o[0]), d = a(() => ({
|
|
14
|
+
languages: o,
|
|
15
|
+
currentLanguage: l ?? t,
|
|
16
|
+
setCurrentLanguage: u
|
|
17
|
+
}), [
|
|
18
|
+
o,
|
|
19
|
+
u,
|
|
20
|
+
l
|
|
21
|
+
]);
|
|
22
|
+
return /* @__PURE__ */ i.createElement(n, { value: d }, /* @__PURE__ */ i.createElement(s, {
|
|
23
|
+
languages: o,
|
|
24
|
+
messages: c
|
|
25
|
+
}, r));
|
|
21
26
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
//# sourceMappingURL=next-intl.provider.js.map
|
|
27
|
+
//#endregion
|
|
28
|
+
export { c as NextIntlProvider };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=next-intl.provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-intl.provider.js","sources":["../../../src/react/next-intl/next-intl.provider.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useMemo } from 'react';\n\nimport type { I_Children } from '#typescript/index.js';\n\nimport type { I_NextIntlLanguage, I_NextIntlProviderProps } from './next-intl.type.js';\n\nimport { useStorage } from '../storage/index.js';\nimport { NEXT_INTL_DEFAULT_LANGUAGE } from './next-intl.constant.js';\nimport { NextIntlContext } from './next-intl.context.js';\nimport { withNextIntl } from './next-intl.hoc.js';\n\n/**\n * Base component that serves as a wrapper for the withNextIntl HOC.\n * This component is used internally by the NextIntlProvider to create\n * the language wrapper component with internationalization capabilities.\n *\n * @param props - Component props containing children.\n * @param props.children - React children to be wrapped with internationalization support.\n * @returns A React component that passes through its children.\n */\nfunction LanguageWrapperBase({ children }: I_Children) {\n return <>{children}</>;\n}\n\nconst LanguageWrapper = withNextIntl(LanguageWrapperBase);\n\n/**\n * Provider component that manages Next.js internationalization state and provides i18n context.\n * This component sets up a complete internationalization system for Next.js applications,\n * including language management, message loading, and persistent language preferences.\n * It integrates with the storage system to remember user language choices and provides\n * a comprehensive i18n context to all child components.\n *\n * Features:\n * - Language state management with persistence\n * - Automatic language detection and fallback\n * - Message loading and caching\n * - Timezone configuration per language\n * - Integration with Next.js internationalization\n * - Memoized context value for performance optimization\n *\n * @param props - Component props containing children, languages, and messages.\n * @param props.children - React children that will have access to the internationalization context.\n * @param props.languages - Array of supported languages with their configurations.\n * @param props.messages - Object containing translation messages for each supported language.\n * @returns A React component that provides internationalization context to its children.\n */\nexport function NextIntlProvider({\n children,\n languages,\n messages,\n}: I_NextIntlProviderProps) {\n const { value, set } = useStorage<I_NextIntlLanguage>('lang', languages[0]);\n\n const contextValue = useMemo(\n () => ({ languages, currentLanguage: value ?? NEXT_INTL_DEFAULT_LANGUAGE, setCurrentLanguage: set }),\n [languages, set, value],\n );\n\n return (\n <NextIntlContext value={contextValue}>\n <LanguageWrapper languages={languages} messages={messages}>\n {children}\n </LanguageWrapper>\n </NextIntlContext>\n );\n}\n"],"
|
|
1
|
+
{"version":3,"file":"next-intl.provider.js","names":[],"sources":["../../../src/react/next-intl/next-intl.provider.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useMemo } from 'react';\n\nimport type { I_Children } from '#typescript/index.js';\n\nimport type { I_NextIntlLanguage, I_NextIntlProviderProps } from './next-intl.type.js';\n\nimport { useStorage } from '../storage/index.js';\nimport { NEXT_INTL_DEFAULT_LANGUAGE } from './next-intl.constant.js';\nimport { NextIntlContext } from './next-intl.context.js';\nimport { withNextIntl } from './next-intl.hoc.js';\n\n/**\n * Base component that serves as a wrapper for the withNextIntl HOC.\n * This component is used internally by the NextIntlProvider to create\n * the language wrapper component with internationalization capabilities.\n *\n * @param props - Component props containing children.\n * @param props.children - React children to be wrapped with internationalization support.\n * @returns A React component that passes through its children.\n */\nfunction LanguageWrapperBase({ children }: I_Children) {\n return <>{children}</>;\n}\n\nconst LanguageWrapper = withNextIntl(LanguageWrapperBase);\n\n/**\n * Provider component that manages Next.js internationalization state and provides i18n context.\n * This component sets up a complete internationalization system for Next.js applications,\n * including language management, message loading, and persistent language preferences.\n * It integrates with the storage system to remember user language choices and provides\n * a comprehensive i18n context to all child components.\n *\n * Features:\n * - Language state management with persistence\n * - Automatic language detection and fallback\n * - Message loading and caching\n * - Timezone configuration per language\n * - Integration with Next.js internationalization\n * - Memoized context value for performance optimization\n *\n * @param props - Component props containing children, languages, and messages.\n * @param props.children - React children that will have access to the internationalization context.\n * @param props.languages - Array of supported languages with their configurations.\n * @param props.messages - Object containing translation messages for each supported language.\n * @returns A React component that provides internationalization context to its children.\n */\nexport function NextIntlProvider({\n children,\n languages,\n messages,\n}: I_NextIntlProviderProps) {\n const { value, set } = useStorage<I_NextIntlLanguage>('lang', languages[0]);\n\n const contextValue = useMemo(\n () => ({ languages, currentLanguage: value ?? NEXT_INTL_DEFAULT_LANGUAGE, setCurrentLanguage: set }),\n [languages, set, value],\n );\n\n return (\n <NextIntlContext value={contextValue}>\n <LanguageWrapper languages={languages} messages={messages}>\n {children}\n </LanguageWrapper>\n </NextIntlContext>\n );\n}\n"],"mappings":";;;;;;;AAqBA,SAAS,EAAoB,EAAE,eAAwB;AACnD,QAAO,kBAAA,cAAA,EAAA,UAAA,MAAG,EAAY;;AAG1B,IAAM,IAAkB,EAAa,EAAoB;AAuBzD,SAAgB,EAAiB,EAC7B,aACA,cACA,eACwB;CACxB,IAAM,EAAE,UAAO,WAAQ,EAA+B,QAAQ,EAAU,GAAG,EAErE,IAAe,SACV;EAAE;EAAW,iBAAiB,KAAS;EAA4B,oBAAoB;EAAK,GACnG;EAAC;EAAW;EAAK;EAAM,CAC1B;AAED,QACI,kBAAA,cAAC,GAAD,EAAiB,OAAO,GAIN,EAHd,kBAAA,cAAC,GAAD;EAA4B;EAAqB;EAE/B,EADb,EACa,CACJ"}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
4
|
-
a as storage,
|
|
5
|
-
e as useStorage
|
|
6
|
-
};
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { storage as e } from "./storage.util.js";
|
|
2
|
+
import { useStorage as t } from "./storage.hook.js";
|
|
3
|
+
export { e as storage, t as useStorage };
|
|
@@ -1,60 +1,63 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { serializer as e } from "../../util/serializer/serializer.util.js";
|
|
2
|
+
import { catchError as t } from "../log/log.util.js";
|
|
2
3
|
import { storage as n } from "./storage.util.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
4
|
+
import { useCallback as r, useEffect as i, useState as a } from "react";
|
|
5
|
+
//#region src/react/storage/storage.hook.tsx
|
|
6
|
+
function o(o, s, c = e) {
|
|
7
|
+
let [l, u] = a(s), [d, f] = a(!1);
|
|
8
|
+
return i(() => {
|
|
9
|
+
let e = !0;
|
|
10
|
+
return (async () => {
|
|
11
|
+
try {
|
|
12
|
+
let t = await n.get(o);
|
|
13
|
+
if (e) if (t !== null) u(c.deserialize(t));
|
|
14
|
+
else if (s !== void 0) {
|
|
15
|
+
let e = c.serialize(s);
|
|
16
|
+
await n.set(o, e), u(s);
|
|
17
|
+
} else u(void 0);
|
|
18
|
+
} catch (n) {
|
|
19
|
+
t(n), e && u(s);
|
|
20
|
+
} finally {
|
|
21
|
+
e && f(!0);
|
|
22
|
+
}
|
|
23
|
+
})(), () => {
|
|
24
|
+
e = !1, f(!1);
|
|
25
|
+
};
|
|
26
|
+
}, [
|
|
27
|
+
o,
|
|
28
|
+
s,
|
|
29
|
+
c
|
|
30
|
+
]), i(() => {
|
|
31
|
+
d && (async () => {
|
|
32
|
+
try {
|
|
33
|
+
if (l !== void 0) {
|
|
34
|
+
let e = c.serialize(l);
|
|
35
|
+
await n.set(o, e);
|
|
36
|
+
}
|
|
37
|
+
} catch (e) {
|
|
38
|
+
t(e);
|
|
39
|
+
}
|
|
40
|
+
})();
|
|
41
|
+
}, [
|
|
42
|
+
l,
|
|
43
|
+
o,
|
|
44
|
+
c,
|
|
45
|
+
d
|
|
46
|
+
]), {
|
|
47
|
+
value: l,
|
|
48
|
+
set: r((e) => {
|
|
49
|
+
u((t) => typeof e == "function" ? e(t) : e);
|
|
50
|
+
}, []),
|
|
51
|
+
remove: r(async () => {
|
|
52
|
+
try {
|
|
53
|
+
await n.remove(o), u(void 0);
|
|
54
|
+
} catch (e) {
|
|
55
|
+
t(e);
|
|
56
|
+
}
|
|
57
|
+
}, [o])
|
|
58
|
+
};
|
|
56
59
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
//# sourceMappingURL=storage.hook.js.map
|
|
60
|
+
//#endregion
|
|
61
|
+
export { o as useStorage };
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=storage.hook.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.hook.js","sources":["../../../src/react/storage/storage.hook.tsx"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react';\n\nimport type { I_Serializer } from '#util/serializer/index.js';\n\nimport { serializer as defaultSerializer } from '#util/serializer/index.js';\n\nimport { catchError } from '../log/index.js';\nimport { storage } from './storage.util.js';\n\n/**\n * React hook that provides persistent storage functionality with automatic serialization.\n * This hook manages state that persists across browser sessions using localForage,\n * with automatic serialization/deserialization of complex data types. It provides\n * a React-friendly interface for storage operations with proper error handling.\n *\n * Features:\n * - Automatic data serialization and deserialization\n * - Persistent storage across browser sessions\n * - Initial value handling and fallback\n * - Error handling with graceful degradation\n * - Automatic storage synchronization\n * - Support for complex data types via custom serializers\n *\n * @param key - The unique storage key for the data.\n * @param initialValue - Optional initial value to use if no stored value exists.\n * @param serializer - Optional custom serializer for complex data types (defaults to JSON serializer).\n * @returns An object containing the current value, set function, and remove function.\n */\nexport function useStorage<T>(\n key: string,\n initialValue?: T,\n serializer: I_Serializer<T> = defaultSerializer as I_Serializer<T>,\n) {\n const [value, setValue] = useState<T | undefined>(initialValue);\n const [isLoaded, setIsLoaded] = useState(false);\n\n useEffect(() => {\n let isMounted = true;\n\n const loadValue = async () => {\n try {\n const valueFound = await storage.get<string>(key);\n\n if (isMounted) {\n if (valueFound !== null) {\n const parsedValue = serializer.deserialize(valueFound);\n setValue(parsedValue);\n }\n else if (initialValue !== undefined) {\n const serialized = serializer.serialize(initialValue);\n await storage.set(key, serialized);\n setValue(initialValue);\n }\n else {\n setValue(undefined);\n }\n }\n }\n catch (error) {\n catchError(error);\n\n if (isMounted) {\n setValue(initialValue);\n }\n }\n finally {\n if (isMounted)\n setIsLoaded(true);\n }\n };\n\n loadValue();\n\n return () => {\n isMounted = false;\n setIsLoaded(false);\n };\n }, [key, initialValue, serializer]);\n\n useEffect(() => {\n if (!isLoaded)\n return;\n\n const saveValue = async () => {\n try {\n if (value !== undefined) {\n const serialized = serializer.serialize(value);\n await storage.set(key, serialized);\n }\n }\n catch (error) {\n catchError(error);\n }\n };\n\n saveValue();\n }, [value, key, serializer, isLoaded]);\n\n const set = useCallback(\n (newValue: T | ((val: T | undefined) => T)) => {\n setValue((prev) => {\n if (typeof newValue === 'function') {\n return (newValue as (val: T | undefined) => T)(prev);\n }\n return newValue;\n });\n },\n [],\n );\n\n const remove = useCallback(async () => {\n try {\n await storage.remove(key);\n setValue(undefined);\n }\n catch (error) {\n catchError(error);\n }\n }, [key]);\n\n return { value, set, remove };\n}\n"],"
|
|
1
|
+
{"version":3,"file":"storage.hook.js","names":[],"sources":["../../../src/react/storage/storage.hook.tsx"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react';\n\nimport type { I_Serializer } from '#util/serializer/index.js';\n\nimport { serializer as defaultSerializer } from '#util/serializer/index.js';\n\nimport { catchError } from '../log/index.js';\nimport { storage } from './storage.util.js';\n\n/**\n * React hook that provides persistent storage functionality with automatic serialization.\n * This hook manages state that persists across browser sessions using localForage,\n * with automatic serialization/deserialization of complex data types. It provides\n * a React-friendly interface for storage operations with proper error handling.\n *\n * Features:\n * - Automatic data serialization and deserialization\n * - Persistent storage across browser sessions\n * - Initial value handling and fallback\n * - Error handling with graceful degradation\n * - Automatic storage synchronization\n * - Support for complex data types via custom serializers\n *\n * @param key - The unique storage key for the data.\n * @param initialValue - Optional initial value to use if no stored value exists.\n * @param serializer - Optional custom serializer for complex data types (defaults to JSON serializer).\n * @returns An object containing the current value, set function, and remove function.\n */\nexport function useStorage<T>(\n key: string,\n initialValue?: T,\n serializer: I_Serializer<T> = defaultSerializer as I_Serializer<T>,\n) {\n const [value, setValue] = useState<T | undefined>(initialValue);\n const [isLoaded, setIsLoaded] = useState(false);\n\n useEffect(() => {\n let isMounted = true;\n\n const loadValue = async () => {\n try {\n const valueFound = await storage.get<string>(key);\n\n if (isMounted) {\n if (valueFound !== null) {\n const parsedValue = serializer.deserialize(valueFound);\n setValue(parsedValue);\n }\n else if (initialValue !== undefined) {\n const serialized = serializer.serialize(initialValue);\n await storage.set(key, serialized);\n setValue(initialValue);\n }\n else {\n setValue(undefined);\n }\n }\n }\n catch (error) {\n catchError(error);\n\n if (isMounted) {\n setValue(initialValue);\n }\n }\n finally {\n if (isMounted)\n setIsLoaded(true);\n }\n };\n\n loadValue();\n\n return () => {\n isMounted = false;\n setIsLoaded(false);\n };\n }, [key, initialValue, serializer]);\n\n useEffect(() => {\n if (!isLoaded)\n return;\n\n const saveValue = async () => {\n try {\n if (value !== undefined) {\n const serialized = serializer.serialize(value);\n await storage.set(key, serialized);\n }\n }\n catch (error) {\n catchError(error);\n }\n };\n\n saveValue();\n }, [value, key, serializer, isLoaded]);\n\n const set = useCallback(\n (newValue: T | ((val: T | undefined) => T)) => {\n setValue((prev) => {\n if (typeof newValue === 'function') {\n return (newValue as (val: T | undefined) => T)(prev);\n }\n return newValue;\n });\n },\n [],\n );\n\n const remove = useCallback(async () => {\n try {\n await storage.remove(key);\n setValue(undefined);\n }\n catch (error) {\n catchError(error);\n }\n }, [key]);\n\n return { value, set, remove };\n}\n"],"mappings":";;;;;AA4BA,SAAgB,EACZ,GACA,GACA,IAA8B,GAChC;CACE,IAAM,CAAC,GAAO,KAAY,EAAwB,EAAa,EACzD,CAAC,GAAU,KAAe,EAAS,GAAM;AAsF/C,QApFA,QAAgB;EACZ,IAAI,IAAY;AAoChB,UAlCkB,YAAY;AAC1B,OAAI;IACA,IAAM,IAAa,MAAM,EAAQ,IAAY,EAAI;AAEjD,QAAI,EACA,KAAI,MAAe,KAEf,GADoB,EAAW,YAAY,EAAW,CACjC;aAEhB,MAAiB,KAAA,GAAW;KACjC,IAAM,IAAa,EAAW,UAAU,EAAa;AAErD,KADA,MAAM,EAAQ,IAAI,GAAK,EAAW,EAClC,EAAS,EAAa;UAGtB,GAAS,KAAA,EAAU;YAIxB,GAAO;AAGV,IAFA,EAAW,EAAM,EAEb,KACA,EAAS,EAAa;aAGtB;AACJ,IAAI,KACA,EAAY,GAAK;;MAIlB,QAEE;AAET,GADA,IAAY,IACZ,EAAY,GAAM;;IAEvB;EAAC;EAAK;EAAc;EAAW,CAAC,EAEnC,QAAgB;AACP,QAGa,YAAY;AAC1B,OAAI;AACA,QAAI,MAAU,KAAA,GAAW;KACrB,IAAM,IAAa,EAAW,UAAU,EAAM;AAC9C,WAAM,EAAQ,IAAI,GAAK,EAAW;;YAGnC,GAAO;AACV,MAAW,EAAM;;MAId;IACZ;EAAC;EAAO;EAAK;EAAY;EAAS,CAAC,EAwB/B;EAAE;EAAO,KAtBJ,GACP,MAA8C;AAC3C,MAAU,MACF,OAAO,KAAa,aACZ,EAAuC,EAAK,GAEjD,EACT;KAEN,EAAE,CACL;EAYoB,QAVN,EAAY,YAAY;AACnC,OAAI;AAEA,IADA,MAAM,EAAQ,OAAO,EAAI,EACzB,EAAS,KAAA,EAAU;YAEhB,GAAO;AACV,MAAW,EAAM;;KAEtB,CAAC,EAAI,CAAC;EAEoB"}
|
|
@@ -1,69 +1,37 @@
|
|
|
1
|
-
import e from "
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
a(c);
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
/**
|
|
37
|
-
* Removes a value from browser storage by key.
|
|
38
|
-
* This method permanently deletes the stored data associated with the specified key.
|
|
39
|
-
* If the key doesn't exist, the operation completes successfully without error.
|
|
40
|
-
*
|
|
41
|
-
* @param key - The unique identifier of the value to remove.
|
|
42
|
-
* @returns A promise that resolves when the removal operation is complete.
|
|
43
|
-
*/
|
|
44
|
-
async remove(r) {
|
|
45
|
-
try {
|
|
46
|
-
await e.removeItem(r);
|
|
47
|
-
} catch (t) {
|
|
48
|
-
a(t);
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
/**
|
|
52
|
-
* Retrieves all storage keys.
|
|
53
|
-
* This method returns an array of all keys that currently have stored values.
|
|
54
|
-
* Returns an empty array if no keys exist or if an error occurs during retrieval.
|
|
55
|
-
*
|
|
56
|
-
* @returns A promise that resolves to an array of storage keys.
|
|
57
|
-
*/
|
|
58
|
-
async keys() {
|
|
59
|
-
try {
|
|
60
|
-
return await e.keys() ?? [];
|
|
61
|
-
} catch (r) {
|
|
62
|
-
return a(r, { returnValue: [] });
|
|
63
|
-
}
|
|
64
|
-
}
|
|
1
|
+
import { catchError as e } from "../log/log.util.js";
|
|
2
|
+
import t from "localforage";
|
|
3
|
+
//#region src/react/storage/storage.util.ts
|
|
4
|
+
var n = {
|
|
5
|
+
async get(n) {
|
|
6
|
+
try {
|
|
7
|
+
return await t.getItem(n);
|
|
8
|
+
} catch (t) {
|
|
9
|
+
return e(t, { returnValue: null });
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
async set(n, r) {
|
|
13
|
+
try {
|
|
14
|
+
await t.setItem(n, r);
|
|
15
|
+
} catch (t) {
|
|
16
|
+
e(t);
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
async remove(n) {
|
|
20
|
+
try {
|
|
21
|
+
await t.removeItem(n);
|
|
22
|
+
} catch (t) {
|
|
23
|
+
e(t);
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
async keys() {
|
|
27
|
+
try {
|
|
28
|
+
return await t.keys() ?? [];
|
|
29
|
+
} catch (t) {
|
|
30
|
+
return e(t, { returnValue: [] });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
65
33
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
//# sourceMappingURL=storage.util.js.map
|
|
34
|
+
//#endregion
|
|
35
|
+
export { n as storage };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=storage.util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.util.js","sources":["../../../src/react/storage/storage.util.ts"],"sourcesContent":["import localForage from 'localforage';\n\nimport { catchError } from '../log/index.js';\n\n/**\n * Browser storage utility object using localForage for cross-browser compatibility.\n * This object provides a unified interface for browser storage operations using localForage,\n * which automatically chooses the best available storage method (IndexedDB, WebSQL, or localStorage)\n * based on browser capabilities. It includes comprehensive error handling and type safety.\n */\nexport const storage = {\n /**\n * Retrieves a value from browser storage by key.\n * This method fetches data that was previously stored using the set method.\n * Returns null if the key doesn't exist or if an error occurs during retrieval.\n *\n * @param key - The unique identifier for the stored value.\n * @returns A promise that resolves to the stored value or null if not found.\n */\n async get<T = unknown>(key: string): Promise<T | null> {\n try {\n return await localForage.getItem<T>(key);\n }\n catch (error) {\n return catchError(error, { returnValue: null });\n }\n },\n /**\n * Stores a value in browser storage with a unique key.\n * This method saves data that can be retrieved later using the get method.\n * The data is automatically handled by localForage which chooses the optimal\n * storage method for the browser environment.\n *\n * @param key - The unique identifier for the value to store.\n * @param value - The data to store (will be automatically handled by localForage).\n * @returns A promise that resolves when the storage operation is complete.\n */\n async set<T = unknown>(key: string, value: T): Promise<void> {\n try {\n await localForage.setItem(key, value);\n }\n catch (error) {\n catchError(error);\n }\n },\n /**\n * Removes a value from browser storage by key.\n * This method permanently deletes the stored data associated with the specified key.\n * If the key doesn't exist, the operation completes successfully without error.\n *\n * @param key - The unique identifier of the value to remove.\n * @returns A promise that resolves when the removal operation is complete.\n */\n async remove(key: string): Promise<void> {\n try {\n await localForage.removeItem(key);\n }\n catch (error) {\n catchError(error);\n }\n },\n /**\n * Retrieves all storage keys.\n * This method returns an array of all keys that currently have stored values.\n * Returns an empty array if no keys exist or if an error occurs during retrieval.\n *\n * @returns A promise that resolves to an array of storage keys.\n */\n async keys(): Promise<string[]> {\n try {\n const keys = await localForage.keys();\n\n return keys ?? [];\n }\n catch (error) {\n return catchError(error, { returnValue: [] });\n }\n },\n};\n"],"
|
|
1
|
+
{"version":3,"file":"storage.util.js","names":[],"sources":["../../../src/react/storage/storage.util.ts"],"sourcesContent":["import localForage from 'localforage';\n\nimport { catchError } from '../log/index.js';\n\n/**\n * Browser storage utility object using localForage for cross-browser compatibility.\n * This object provides a unified interface for browser storage operations using localForage,\n * which automatically chooses the best available storage method (IndexedDB, WebSQL, or localStorage)\n * based on browser capabilities. It includes comprehensive error handling and type safety.\n */\nexport const storage = {\n /**\n * Retrieves a value from browser storage by key.\n * This method fetches data that was previously stored using the set method.\n * Returns null if the key doesn't exist or if an error occurs during retrieval.\n *\n * @param key - The unique identifier for the stored value.\n * @returns A promise that resolves to the stored value or null if not found.\n */\n async get<T = unknown>(key: string): Promise<T | null> {\n try {\n return await localForage.getItem<T>(key);\n }\n catch (error) {\n return catchError(error, { returnValue: null });\n }\n },\n /**\n * Stores a value in browser storage with a unique key.\n * This method saves data that can be retrieved later using the get method.\n * The data is automatically handled by localForage which chooses the optimal\n * storage method for the browser environment.\n *\n * @param key - The unique identifier for the value to store.\n * @param value - The data to store (will be automatically handled by localForage).\n * @returns A promise that resolves when the storage operation is complete.\n */\n async set<T = unknown>(key: string, value: T): Promise<void> {\n try {\n await localForage.setItem(key, value);\n }\n catch (error) {\n catchError(error);\n }\n },\n /**\n * Removes a value from browser storage by key.\n * This method permanently deletes the stored data associated with the specified key.\n * If the key doesn't exist, the operation completes successfully without error.\n *\n * @param key - The unique identifier of the value to remove.\n * @returns A promise that resolves when the removal operation is complete.\n */\n async remove(key: string): Promise<void> {\n try {\n await localForage.removeItem(key);\n }\n catch (error) {\n catchError(error);\n }\n },\n /**\n * Retrieves all storage keys.\n * This method returns an array of all keys that currently have stored values.\n * Returns an empty array if no keys exist or if an error occurs during retrieval.\n *\n * @returns A promise that resolves to an array of storage keys.\n */\n async keys(): Promise<string[]> {\n try {\n const keys = await localForage.keys();\n\n return keys ?? [];\n }\n catch (error) {\n return catchError(error, { returnValue: [] });\n }\n },\n};\n"],"mappings":";;;AAUA,IAAa,IAAU;CASnB,MAAM,IAAiB,GAAgC;AACnD,MAAI;AACA,UAAO,MAAM,EAAY,QAAW,EAAI;WAErC,GAAO;AACV,UAAO,EAAW,GAAO,EAAE,aAAa,MAAM,CAAC;;;CAavD,MAAM,IAAiB,GAAa,GAAyB;AACzD,MAAI;AACA,SAAM,EAAY,QAAQ,GAAK,EAAM;WAElC,GAAO;AACV,KAAW,EAAM;;;CAWzB,MAAM,OAAO,GAA4B;AACrC,MAAI;AACA,SAAM,EAAY,WAAW,EAAI;WAE9B,GAAO;AACV,KAAW,EAAM;;;CAUzB,MAAM,OAA0B;AAC5B,MAAI;AAGA,UAFa,MAAM,EAAY,MAAM,IAEtB,EAAE;WAEd,GAAO;AACV,UAAO,EAAW,GAAO,EAAE,aAAa,EAAE,EAAE,CAAC;;;CAGxD"}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useEffect as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import e from "@userback/widget";
|
|
2
|
+
import { useEffect as t } from "react";
|
|
3
|
+
//#region src/react/userback/userback.component.tsx
|
|
4
|
+
function n({ token: n, options: r }) {
|
|
5
|
+
return t(() => {
|
|
6
|
+
if (!n) return;
|
|
7
|
+
let t;
|
|
8
|
+
return (async () => {
|
|
9
|
+
let { hide: i, ...a } = r || {};
|
|
10
|
+
await e(n, a), i && i.length > 0 && i.forEach((e) => {
|
|
11
|
+
document.querySelectorAll(e).forEach((e) => e.remove());
|
|
12
|
+
}), t = new MutationObserver(() => {
|
|
13
|
+
i && i.length > 0 && i.forEach((e) => {
|
|
14
|
+
document.querySelectorAll(e).forEach((e) => e.remove());
|
|
15
|
+
});
|
|
16
|
+
}), t.observe(document.body, {
|
|
17
|
+
childList: !0,
|
|
18
|
+
subtree: !0
|
|
19
|
+
});
|
|
20
|
+
})(), () => {
|
|
21
|
+
t?.disconnect();
|
|
22
|
+
};
|
|
23
|
+
}, [n]), null;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
//# sourceMappingURL=userback.component.js.map
|
|
25
|
+
//#endregion
|
|
26
|
+
export { n as Userback };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=userback.component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userback.component.js","sources":["../../../src/react/userback/userback.component.tsx"],"sourcesContent":["import UserbackWidget from '@userback/widget';\nimport { useEffect } from 'react';\n\nimport type { I_UserBackProps } from './userback.type.js';\n\n/**\n * Userback feedback widget component for collecting user feedback.\n * This component integrates the Userback feedback widget into React applications,\n * providing a customizable feedback collection interface for users to submit\n * bug reports, feature requests, and general feedback.\n *\n * Features:\n * - Userback widget integration\n * - Customizable feedback collection\n * - Automatic widget initialization\n * - Token-based configuration\n * - Responsive design support\n *\n * @param props - Component props containing token and options.\n * @param props.token - The Userback token for widget authentication.\n * @param props.options - Optional configuration options for the Userback widget.\n * @returns A React component that renders the Userback feedback widget.\n */\nexport function Userback({ token, options }: I_UserBackProps) {\n useEffect(() => {\n if (!token) {\n return;\n }\n\n let observer: MutationObserver;\n\n const loadUserback = async () => {\n const { hide, ...rest } = options || {};\n\n await UserbackWidget(token, rest);\n\n if (hide && hide.length > 0) {\n hide.forEach((selector: string) => {\n document.querySelectorAll(selector).forEach(el => el.remove());\n });\n }\n\n observer = new MutationObserver(() => {\n if (hide && hide.length > 0) {\n hide.forEach((selector: string) => {\n document.querySelectorAll(selector).forEach(el => el.remove());\n });\n }\n });\n\n observer.observe(document.body, {\n childList: true,\n subtree: true,\n });\n };\n\n loadUserback();\n\n return () => {\n observer?.disconnect();\n };\n }, [token
|
|
1
|
+
{"version":3,"file":"userback.component.js","names":[],"sources":["../../../src/react/userback/userback.component.tsx"],"sourcesContent":["import UserbackWidget from '@userback/widget';\nimport { useEffect } from 'react';\n\nimport type { I_UserBackProps } from './userback.type.js';\n\n/**\n * Userback feedback widget component for collecting user feedback.\n * This component integrates the Userback feedback widget into React applications,\n * providing a customizable feedback collection interface for users to submit\n * bug reports, feature requests, and general feedback.\n *\n * Features:\n * - Userback widget integration\n * - Customizable feedback collection\n * - Automatic widget initialization\n * - Token-based configuration\n * - Responsive design support\n *\n * @param props - Component props containing token and options.\n * @param props.token - The Userback token for widget authentication.\n * @param props.options - Optional configuration options for the Userback widget.\n * @returns A React component that renders the Userback feedback widget.\n */\nexport function Userback({ token, options }: I_UserBackProps) {\n useEffect(() => {\n if (!token) {\n return;\n }\n\n let observer: MutationObserver;\n\n const loadUserback = async () => {\n const { hide, ...rest } = options || {};\n\n await UserbackWidget(token, rest);\n\n if (hide && hide.length > 0) {\n hide.forEach((selector: string) => {\n document.querySelectorAll(selector).forEach(el => el.remove());\n });\n }\n\n observer = new MutationObserver(() => {\n if (hide && hide.length > 0) {\n hide.forEach((selector: string) => {\n document.querySelectorAll(selector).forEach(el => el.remove());\n });\n }\n });\n\n observer.observe(document.body, {\n childList: true,\n subtree: true,\n });\n };\n\n loadUserback();\n\n return () => {\n observer?.disconnect();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- options is intentionally excluded to prevent infinite re-renders (object ref changes each render)\n }, [token]);\n\n return null;\n}\n"],"mappings":";;;AAuBA,SAAgB,EAAS,EAAE,UAAO,cAA4B;AAyC1D,QAxCA,QAAgB;AACZ,MAAI,CAAC,EACD;EAGJ,IAAI;AA6BJ,UA3BqB,YAAY;GAC7B,IAAM,EAAE,SAAM,GAAG,MAAS,KAAW,EAAE;AAkBvC,GAhBA,MAAM,EAAe,GAAO,EAAK,EAE7B,KAAQ,EAAK,SAAS,KACtB,EAAK,SAAS,MAAqB;AAC/B,aAAS,iBAAiB,EAAS,CAAC,SAAQ,MAAM,EAAG,QAAQ,CAAC;KAChE,EAGN,IAAW,IAAI,uBAAuB;AAClC,IAAI,KAAQ,EAAK,SAAS,KACtB,EAAK,SAAS,MAAqB;AAC/B,cAAS,iBAAiB,EAAS,CAAC,SAAQ,MAAM,EAAG,QAAQ,CAAC;MAChE;KAER,EAEF,EAAS,QAAQ,SAAS,MAAM;IAC5B,WAAW;IACX,SAAS;IACZ,CAAC;MAGQ,QAED;AACT,MAAU,YAAY;;IAG3B,CAAC,EAAM,CAAC,EAEJ"}
|
package/dist/style.css
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
.
|
|
1
|
+
._error-container_wq4ix_1{justify-content:center;align-items:center;gap:.5rem;display:flex}._error-details-button_wq4ix_8{color:#fff;cursor:pointer;background-color:#ef4444;border:2px solid #dc2626;border-radius:.5rem;justify-content:center;align-items:center;padding:.5rem 1rem;font-size:.875rem;font-weight:500;transition:all .2s ease-in-out;display:inline-flex}._error-details-button_wq4ix_8:hover{background-color:#dc2626;border-color:#b91c1c;transform:translateY(-1px);box-shadow:0 4px 6px -1px #0000001a,0 2px 4px -1px #0000000f}._error-details-button_wq4ix_8:active{transform:translateY(0);box-shadow:0 1px 3px #0000001a,0 1px 2px #0000000f}._error-details-button_wq4ix_8:focus-visible{outline-offset:2px;outline:2px solid #fca5a5}._modal-backdrop_199u4_1{z-index:9999999;background-color:#0009;justify-content:center;align-items:center;padding:1rem;display:flex;position:fixed;inset:0}._modal-backdrop_199u4_1 ._modal-content_199u4_11{color:#fff;background-color:#0f172a;border-radius:.75rem;width:100%;max-width:80vw;padding:2rem;position:relative;overflow:hidden;box-shadow:0 10px 20px #00000080}._modal-backdrop_199u4_1 ._modal-content_199u4_11 ._btn-close_199u4_22{color:#fff;cursor:pointer;background:0 0;border:none;font-size:1.25rem;transition:color .2s;position:absolute;top:.75rem;right:1rem}._modal-backdrop_199u4_1 ._modal-content_199u4_11 ._btn-close_199u4_22:hover{color:#f87171}._modal-backdrop_199u4_1 ._modal-content_199u4_11 ._btn-close_199u4_22:focus-visible{border-radius:.125rem;outline:none;box-shadow:0 0 0 2px #f87171}._modal-backdrop_199u4_1 ._modal-content_199u4_11 ._error-title_199u4_41{margin-bottom:1rem;font-weight:700}._modal-backdrop_199u4_1 ._modal-content_199u4_11 ._error-title_199u4_41 ._btn-retry_199u4_45{color:#fff;cursor:pointer;background:linear-gradient(90deg,#3b82f6,#06b6d4);border:none;border-radius:.75rem;padding:.5rem 1.5rem;font-weight:600;transition:background .3s}._modal-backdrop_199u4_1 ._modal-content_199u4_11 ._error-title_199u4_41 ._btn-retry_199u4_45:hover{background:linear-gradient(90deg,#2563eb,#0891b2)}._modal-backdrop_199u4_1 ._modal-content_199u4_11 ._error-title_199u4_41 ._btn-retry_199u4_45:focus-visible{outline-offset:2px;outline:2px solid #3b82f6}._modal-backdrop_199u4_1 ._modal-content_199u4_11 ._error-details_199u4_62{text-align:left;background-color:#1e293b;border:1px solid #334155;border-radius:.5rem;flex-direction:column;gap:.5rem;max-height:50vh;margin-bottom:1.5rem;padding:1rem;font-size:.875rem;display:flex;overflow-y:auto}._modal-backdrop_199u4_1 ._modal-content_199u4_11 ._error-details_199u4_62 pre{white-space:pre-wrap;word-break:break-word}._modal-backdrop_199u4_1 ._modal-content_199u4_11 ._error-details_199u4_62 pre._main_199u4_80{color:#fca5a5}._modal-backdrop_199u4_1 ._modal-content_199u4_11 ._error-details_199u4_62 pre._network_199u4_83{color:#fde68a}._modal-backdrop_199u4_1 ._modal-content_199u4_11 ._error-details_199u4_62 pre._extra_199u4_86{color:#67e8f9;white-space:pre;background-color:#0f172a;border-radius:.375rem;padding:.5rem;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;overflow-x:auto}._modal-backdrop_199u4_1 ._modal-content_199u4_11 ._error-details_199u4_62 ul{color:#fda4af;padding-left:1rem;list-style:outside}._overlay_b1d9o_1,._full_b1d9o_1,._block_b1d9o_2{z-index:999999;-webkit-backdrop-filter:blur(20px)saturate(200%);backdrop-filter:blur(20px)saturate(200%);background:linear-gradient(135deg,#ffffff59,#ffffffb3);border:1.5px solid #ffffff59;justify-content:center;align-items:center;width:100%;height:100%;animation:.5s ease-out _overlay-fade-in_b1d9o_1;display:flex;box-shadow:0 4px 32px #1f26872e,inset 0 1.5px 8px #ffffff40}._full_b1d9o_1,._block_b1d9o_2{pointer-events:none}._full_b1d9o_1{position:fixed;inset:0}._block_b1d9o_2{-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);background:#ffffff1a;width:100%;height:100%;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}._container_b1d9o_40{text-align:center;flex-direction:column;justify-content:center;align-items:center;gap:1.5rem;padding:1rem;display:flex;position:relative}._container_b1d9o_40 ._ring_b1d9o_50{border:2px solid #0000;border-radius:50%;width:clamp(60px,10vw,150px);height:clamp(60px,10vw,150px);transition:transform .3s;position:absolute}._container_b1d9o_40 ._ring_b1d9o_50:first-child{border-bottom:8px solid #f53dc7;animation:1s linear infinite _rotate1_b1d9o_1}._container_b1d9o_40 ._ring_b1d9o_50:nth-child(2){border-bottom:8px solid #f20d46;animation:1s linear infinite _rotate2_b1d9o_1}._container_b1d9o_40 ._ring_b1d9o_50:nth-child(3){border-bottom:8px solid #14b8b8;animation:1s linear infinite _rotate3_b1d9o_1}._container_b1d9o_40 ._ring_b1d9o_50:nth-child(4){border-bottom:8px solid #e69900;animation:1s linear infinite _rotate4_b1d9o_1}._container_b1d9o_40 ._message_b1d9o_74{color:#2f2f37;text-shadow:0 1px 2px #fffc;word-break:break-word;-webkit-hyphens:auto;hyphens:auto;font-weight:700;animation:2s ease-in-out infinite alternate _text-fade_b1d9o_1}@keyframes _rotate1_b1d9o_1{0%{transform:rotateX(50deg)rotate(110deg)}to{transform:rotateX(50deg)rotate(470deg)}}@keyframes _rotate2_b1d9o_1{0%{transform:rotateX(20deg)rotateY(50deg)rotate(20deg)}to{transform:rotateX(20deg)rotateY(50deg)rotate(380deg)}}@keyframes _rotate3_b1d9o_1{0%{transform:rotateX(40deg)rotateY(130deg)rotate(450deg)}to{transform:rotateX(40deg)rotateY(130deg)rotate(90deg)}}@keyframes _rotate4_b1d9o_1{0%{transform:rotateX(70deg)rotate(270deg)}to{transform:rotateX(70deg)rotate(630deg)}}@keyframes _text-fade_b1d9o_1{0%{opacity:.6}to{opacity:1}}@keyframes _overlay-fade-in_b1d9o_1{0%{opacity:0}to{opacity:1}}@media (prefers-reduced-motion:reduce){._ring_b1d9o_50,._message_b1d9o_74,._overlay_b1d9o_1,._full_b1d9o_1,._block_b1d9o_2{animation:none!important}}
|
|
2
|
+
/*$vite$:1*/
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
//#
|
|
1
|
+
//#region src/typescript/common.type.ts
|
|
2
|
+
var e = /* @__PURE__ */ function(e) {
|
|
3
|
+
return e.PRODUCTION = "production", e.STAGING = "staging", e.DEVELOPMENT = "development", e;
|
|
4
|
+
}({});
|
|
5
|
+
//#endregion
|
|
6
|
+
export { e as E_Environment };
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=common.type.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.type.js","sources":["../../src/typescript/common.type.ts"],"sourcesContent":["import type consola from 'consola';\n\n/**\n * Generic object type with string keys and values of type T (defaults to unknown).\n */\nexport type T_Object<T = unknown> = Record<string, T>;\n\n/**\n * Logging interface for browser and Node.js environments, compatible with consola.\n */\nexport interface I_Log {\n silent: typeof consola['silent'];\n level: typeof consola['level'];\n fatal: typeof consola['fatal'];\n error: typeof consola['error'];\n warn: typeof consola['warn'];\n log: typeof consola['log'];\n info: typeof consola['info'];\n success: typeof consola['success'];\n ready: typeof consola['ready'];\n start: typeof consola['start'];\n box: typeof consola['box'];\n debug: typeof consola['debug'];\n trace: typeof consola['trace'];\n verbose: typeof consola['verbose'];\n}\n\n/**\n * Base interface for return types with common properties.\n */\nexport interface I_ReturnBase {\n success: boolean;\n message?: string;\n code?: number | string;\n}\n\n/**\n * Success return type with result data.\n * @template T - The main result type\n * @template E - Additional properties to merge with the result (defaults to unknown)\n */\nexport interface I_ReturnSuccess<T, E = unknown> extends I_ReturnBase {\n success: true;\n result: T & E;\n}\n\n/**\n * Failure return type with error information.\n */\nexport interface I_ReturnFailure extends I_ReturnBase {\n success: false;\n message: string;\n code: number | string;\n}\n\n/**\n * Discriminated union type for function return values.\n * Provides type-safe handling of success and failure cases.\n *\n * @template T - The success result type (defaults to void)\n * @template E - Additional properties to merge with the result (defaults to unknown)\n *\n * @example\n * ```typescript\n * function fetchUser(id: string): I_Return<User> {\n * try {\n * const user = await getUser(id);\n * return { success: true, result: user };\n * } catch (error) {\n * return { success: false, message: error.message, code: 'USER_NOT_FOUND' };\n * }\n * }\n * ```\n */\nexport type I_Return<T = void, E = unknown> = I_ReturnSuccess<T, E> | I_ReturnFailure;\n\nexport enum E_Environment {\n PRODUCTION = 'production',\n STAGING = 'staging',\n DEVELOPMENT = 'development',\n}\n"],"
|
|
1
|
+
{"version":3,"file":"common.type.js","names":[],"sources":["../../src/typescript/common.type.ts"],"sourcesContent":["import type consola from 'consola';\n\n/**\n * Generic object type with string keys and values of type T (defaults to unknown).\n */\nexport type T_Object<T = unknown> = Record<string, T>;\n\n/**\n * Logging interface for browser and Node.js environments, compatible with consola.\n */\nexport interface I_Log {\n silent: typeof consola['silent'];\n level: typeof consola['level'];\n fatal: typeof consola['fatal'];\n error: typeof consola['error'];\n warn: typeof consola['warn'];\n log: typeof consola['log'];\n info: typeof consola['info'];\n success: typeof consola['success'];\n ready: typeof consola['ready'];\n start: typeof consola['start'];\n box: typeof consola['box'];\n debug: typeof consola['debug'];\n trace: typeof consola['trace'];\n verbose: typeof consola['verbose'];\n}\n\n/**\n * Base interface for return types with common properties.\n */\nexport interface I_ReturnBase {\n success: boolean;\n message?: string;\n code?: number | string;\n}\n\n/**\n * Success return type with result data.\n * @template T - The main result type\n * @template E - Additional properties to merge with the result (defaults to unknown)\n */\nexport interface I_ReturnSuccess<T, E = unknown> extends I_ReturnBase {\n success: true;\n result: T & E;\n}\n\n/**\n * Failure return type with error information.\n */\nexport interface I_ReturnFailure extends I_ReturnBase {\n success: false;\n message: string;\n code: number | string;\n}\n\n/**\n * Discriminated union type for function return values.\n * Provides type-safe handling of success and failure cases.\n *\n * @template T - The success result type (defaults to void)\n * @template E - Additional properties to merge with the result (defaults to unknown)\n *\n * @example\n * ```typescript\n * function fetchUser(id: string): I_Return<User> {\n * try {\n * const user = await getUser(id);\n * return { success: true, result: user };\n * } catch (error) {\n * return { success: false, message: error.message, code: 'USER_NOT_FOUND' };\n * }\n * }\n * ```\n */\nexport type I_Return<T = void, E = unknown> = I_ReturnSuccess<T, E> | I_ReturnFailure;\n\nexport enum E_Environment {\n PRODUCTION = 'production',\n STAGING = 'staging',\n DEVELOPMENT = 'development',\n}\n"],"mappings":";AA4EA,IAAY,IAAL,yBAAA,GAAA;QACH,EAAA,aAAA,cACA,EAAA,UAAA,WACA,EAAA,cAAA;KACH"}
|
package/dist/typescript/index.js
CHANGED