react-intlayer 9.5.9-canary.0 → 9.5.10
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/cjs/IntlayerNode.cjs +18 -18
- package/dist/cjs/IntlayerNode.cjs.map +1 -1
- package/dist/cjs/analytics/useAnalytics.cjs +2 -2
- package/dist/cjs/analytics/useConversion.cjs +1 -1
- package/dist/cjs/analytics/useExperiment.cjs +1 -1
- package/dist/cjs/client/IntlayerProvider.cjs +30 -16
- package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
- package/dist/cjs/client/format/index.cjs +4 -4
- package/dist/cjs/client/index.cjs +2 -2
- package/dist/cjs/client/t.cjs +1 -1
- package/dist/cjs/client/useDictionary.cjs +2 -2
- package/dist/cjs/client/useDictionary.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryAsync.cjs +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +2 -2
- package/dist/cjs/client/useI18n.cjs +1 -1
- package/dist/cjs/client/useIntlayer.cjs +2 -2
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useLocale.cjs +1 -1
- package/dist/cjs/client/useLocaleBase.cjs +1 -1
- package/dist/cjs/client/useLocaleStorage.cjs +10 -2
- package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
- package/dist/cjs/client/useRewriteURL.cjs +1 -1
- package/dist/cjs/client/useTraduction.cjs +1 -1
- package/dist/cjs/html/HTMLRenderer.cjs +1 -1
- package/dist/cjs/index.cjs +5 -3
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/plugins.cjs +32 -47
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/cjs/server/format/index.cjs +4 -4
- package/dist/cjs/server/index.cjs +3 -3
- package/dist/cjs/server/useDictionaryDynamic.cjs +1 -1
- package/dist/esm/IntlayerNode.mjs +18 -18
- package/dist/esm/IntlayerNode.mjs.map +1 -1
- package/dist/esm/analytics/useAnalytics.mjs +2 -2
- package/dist/esm/analytics/useConversion.mjs +1 -1
- package/dist/esm/analytics/useExperiment.mjs +1 -1
- package/dist/esm/client/IntlayerProvider.mjs +31 -17
- package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
- package/dist/esm/client/format/index.mjs +4 -4
- package/dist/esm/client/index.mjs +2 -2
- package/dist/esm/client/t.mjs +1 -1
- package/dist/esm/client/useDictionary.mjs +2 -2
- package/dist/esm/client/useDictionary.mjs.map +1 -1
- package/dist/esm/client/useDictionaryAsync.mjs +1 -1
- package/dist/esm/client/useDictionaryDynamic.mjs +2 -2
- package/dist/esm/client/useI18n.mjs +1 -1
- package/dist/esm/client/useIntlayer.mjs +2 -2
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/client/useLocale.mjs +1 -1
- package/dist/esm/client/useLocaleBase.mjs +1 -1
- package/dist/esm/client/useLocaleStorage.mjs +11 -4
- package/dist/esm/client/useLocaleStorage.mjs.map +1 -1
- package/dist/esm/client/useRewriteURL.mjs +1 -1
- package/dist/esm/client/useTraduction.mjs +1 -1
- package/dist/esm/html/HTMLRenderer.mjs +1 -1
- package/dist/esm/index.mjs +5 -4
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/plugins.mjs +32 -47
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/esm/server/format/index.mjs +4 -4
- package/dist/esm/server/index.mjs +3 -3
- package/dist/esm/server/useDictionaryDynamic.mjs +1 -1
- package/dist/types/IntlayerNode.d.ts +12 -0
- package/dist/types/IntlayerNode.d.ts.map +1 -1
- package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
- package/dist/types/client/useLocaleStorage.d.ts +8 -1
- package/dist/types/client/useLocaleStorage.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/markdown/index.d.ts +2 -2
- package/dist/types/plugins.d.ts.map +1 -1
- package/package.json +9 -9
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
let react = require("react");
|
|
3
|
+
let _intlayer_core_utils = require("@intlayer/core/utils");
|
|
3
4
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
4
5
|
|
|
5
6
|
//#region src/IntlayerNode.tsx
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
};
|
|
7
|
+
/**
|
|
8
|
+
* Renders content as a React element that also behaves like its value
|
|
9
|
+
* (`node.value`, `${node}`, `node.toUpperCase()`).
|
|
10
|
+
*
|
|
11
|
+
* The node is a copy of the element built on a shared prototype serving the
|
|
12
|
+
* value's members, rather than a Proxy: React reads an element's fields many
|
|
13
|
+
* times while reconciling, and a Proxy trap makes each read several times
|
|
14
|
+
* slower.
|
|
15
|
+
*
|
|
16
|
+
* @param props - The value, the rendered children and extra node members.
|
|
17
|
+
* @returns The renderable node.
|
|
18
|
+
*/
|
|
19
|
+
const renderIntlayerNode = ({ children, value, additionalProps }) => Object.setPrototypeOf({
|
|
20
|
+
...(0, react.isValidElement)(children) ? children : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children }),
|
|
21
|
+
value,
|
|
22
|
+
...additionalProps
|
|
23
|
+
}, (0, _intlayer_core_utils.getIntlayerNodePrototype)(value));
|
|
24
24
|
|
|
25
25
|
//#endregion
|
|
26
26
|
exports.renderIntlayerNode = renderIntlayerNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerNode.cjs","names":["isValidElement"],"sources":["../../src/IntlayerNode.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core/interpreter';\nimport type { ResolvedEditor } from '@intlayer/types/module_augmentation';\nimport {
|
|
1
|
+
{"version":3,"file":"IntlayerNode.cjs","names":["isValidElement","getIntlayerNodePrototype"],"sources":["../../src/IntlayerNode.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core/interpreter';\nimport { getIntlayerNodePrototype } from '@intlayer/core/utils';\nimport type { ResolvedEditor } from '@intlayer/types/module_augmentation';\nimport { isValidElement, type PropsWithChildren, type ReactNode } from 'react';\n\nexport type IntlayerNode<\n T = NodeProps['children'],\n AdditionalProps = Record<string, never>,\n> = ResolvedEditor<T, ReactNode> & {\n value: T;\n} & AdditionalProps &\n T;\n\ntype RenderIntlayerNodeProps<T> = PropsWithChildren<{\n value: T;\n children: ReactNode;\n additionalProps?: { [key: string]: any };\n}>;\n\n/**\n * Renders content as a React element that also behaves like its value\n * (`node.value`, `${node}`, `node.toUpperCase()`).\n *\n * The node is a copy of the element built on a shared prototype serving the\n * value's members, rather than a Proxy: React reads an element's fields many\n * times while reconciling, and a Proxy trap makes each read several times\n * slower.\n *\n * @param props - The value, the rendered children and extra node members.\n * @returns The renderable node.\n */\nexport const renderIntlayerNode = <\n T, // Broadened to support arrays, numbers, objects, etc.\n>({\n children,\n value,\n additionalProps,\n}: RenderIntlayerNodeProps<T>): IntlayerNode<T> =>\n // Fields first, prototype last: set the other way round, each field would\n // first look for a setter along the prototype chain, through its Proxy\n Object.setPrototypeOf(\n {\n ...(isValidElement(children) ? children : <>{children}</>),\n value,\n ...additionalProps,\n },\n getIntlayerNodePrototype(value)\n );\n"],"mappings":";;;;;;;;;;;;;;;;;;AA+BA,MAAa,sBAEX,EACA,UACA,OACA,sBAIA,OAAO,eACL;CACE,OAAIA,sBAAe,QAAQ,IAAI,WAAW,yEAAG,SAAW;CACxD;CACA,GAAG;AACL,OACAC,+CAAyB,KAAK,CAChC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
const require_client_IntlayerProvider = require('../client/IntlayerProvider.cjs');
|
|
5
4
|
const require_analytics_exposureSink = require('./exposureSink.cjs');
|
|
6
|
-
|
|
5
|
+
const require_client_IntlayerProvider = require('../client/IntlayerProvider.cjs');
|
|
7
6
|
let react = require("react");
|
|
7
|
+
let _intlayer_analytics_isEnabled = require("@intlayer/analytics/isEnabled");
|
|
8
8
|
|
|
9
9
|
//#region src/analytics/useAnalytics.tsx
|
|
10
10
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
let _intlayer_analytics_isEnabled = require("@intlayer/analytics/isEnabled");
|
|
5
4
|
let react = require("react");
|
|
5
|
+
let _intlayer_analytics_isEnabled = require("@intlayer/analytics/isEnabled");
|
|
6
6
|
|
|
7
7
|
//#region src/analytics/useConversion.tsx
|
|
8
8
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
let _intlayer_analytics_isEnabled = require("@intlayer/analytics/isEnabled");
|
|
5
4
|
let react = require("react");
|
|
5
|
+
let _intlayer_analytics_isEnabled = require("@intlayer/analytics/isEnabled");
|
|
6
6
|
|
|
7
7
|
//#region src/analytics/useExperiment.tsx
|
|
8
8
|
/**
|
|
@@ -4,18 +4,20 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
4
4
|
const require_editor_EditorProvider = require('../editor/EditorProvider.cjs');
|
|
5
5
|
const require_client_useLocaleStorage = require('./useLocaleStorage.cjs');
|
|
6
6
|
const require_analytics_AnalyticsProvider = require('../analytics/AnalyticsProvider.cjs');
|
|
7
|
-
let react = require("react");
|
|
8
7
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
8
|
+
let react = require("react");
|
|
9
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
10
|
let _intlayer_config_client = require("@intlayer/config/client");
|
|
10
11
|
let _intlayer_core_localization = require("@intlayer/core/localization");
|
|
11
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
12
|
|
|
13
13
|
//#region src/client/IntlayerProvider.tsx
|
|
14
14
|
/**
|
|
15
15
|
* Context that stores the current locale on the client side.
|
|
16
16
|
*/
|
|
17
17
|
const IntlayerClientContext = (0, react.createContext)({
|
|
18
|
-
locale
|
|
18
|
+
get locale() {
|
|
19
|
+
return require_client_useLocaleStorage.getLocaleInStorage() ?? _intlayer_config_built.internationalization?.defaultLocale;
|
|
20
|
+
},
|
|
19
21
|
setLocale: () => null,
|
|
20
22
|
isCookieEnabled: true
|
|
21
23
|
});
|
|
@@ -35,14 +37,16 @@ const useIntlayerContext = () => (0, react.useContext)(IntlayerClientContext) ??
|
|
|
35
37
|
*/
|
|
36
38
|
const IntlayerProviderContent = ({ locale: localeProp, defaultLocale: defaultLocaleProp, variant, children, setLocale: setLocaleProp, disableEditor, isCookieEnabled }) => {
|
|
37
39
|
const { locales: availableLocales, defaultLocale: defaultLocaleConfig } = _intlayer_config_built.internationalization ?? {};
|
|
38
|
-
const [currentLocale, setCurrentLocale] = (0, react.useState)(localeProp ?? require_client_useLocaleStorage.
|
|
39
|
-
(0, react.
|
|
40
|
+
const [currentLocale, setCurrentLocale] = (0, react.useState)(() => localeProp ?? require_client_useLocaleStorage.getLocaleInStorage() ?? defaultLocaleProp ?? defaultLocaleConfig);
|
|
41
|
+
const [adoptedLocaleProp, setAdoptedLocaleProp] = (0, react.useState)(localeProp);
|
|
42
|
+
if (localeProp !== adoptedLocaleProp) {
|
|
43
|
+
setAdoptedLocaleProp(localeProp);
|
|
40
44
|
if (localeProp && localeProp !== currentLocale) setCurrentLocale(localeProp);
|
|
41
|
-
}
|
|
45
|
+
}
|
|
42
46
|
(0, react.useEffect)(() => {
|
|
43
47
|
(0, _intlayer_config_client.setIntlayerIdentifier)();
|
|
44
48
|
}, []);
|
|
45
|
-
const setLocaleBase = (newLocale) => {
|
|
49
|
+
const setLocaleBase = (0, react.useCallback)((newLocale) => {
|
|
46
50
|
if (currentLocale.toString() === newLocale.toString()) return;
|
|
47
51
|
if (!availableLocales?.map(String).includes(newLocale)) {
|
|
48
52
|
console.error(`Locale ${newLocale} is not available`);
|
|
@@ -50,16 +54,26 @@ const IntlayerProviderContent = ({ locale: localeProp, defaultLocale: defaultLoc
|
|
|
50
54
|
}
|
|
51
55
|
setCurrentLocale(newLocale);
|
|
52
56
|
require_client_useLocaleStorage.setLocaleInStorage(newLocale, isCookieEnabled);
|
|
53
|
-
}
|
|
57
|
+
}, [
|
|
58
|
+
currentLocale,
|
|
59
|
+
availableLocales,
|
|
60
|
+
isCookieEnabled
|
|
61
|
+
]);
|
|
54
62
|
const setLocale = setLocaleProp ?? setLocaleBase;
|
|
55
63
|
const resolvedLocale = (0, _intlayer_core_localization.localeResolver)(currentLocale);
|
|
64
|
+
const contextValue = (0, react.useMemo)(() => ({
|
|
65
|
+
locale: resolvedLocale,
|
|
66
|
+
setLocale,
|
|
67
|
+
variant,
|
|
68
|
+
disableEditor
|
|
69
|
+
}), [
|
|
70
|
+
resolvedLocale,
|
|
71
|
+
setLocale,
|
|
72
|
+
variant,
|
|
73
|
+
disableEditor
|
|
74
|
+
]);
|
|
56
75
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IntlayerClientContext.Provider, {
|
|
57
|
-
value:
|
|
58
|
-
locale: resolvedLocale,
|
|
59
|
-
setLocale,
|
|
60
|
-
variant,
|
|
61
|
-
disableEditor
|
|
62
|
-
},
|
|
76
|
+
value: contextValue,
|
|
63
77
|
children
|
|
64
78
|
});
|
|
65
79
|
};
|
|
@@ -86,8 +100,8 @@ const IntlayerProviderContent = ({ locale: localeProp, defaultLocale: defaultLoc
|
|
|
86
100
|
const IntlayerProvider = ({ children, ...props }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(IntlayerProviderContent, {
|
|
87
101
|
...props,
|
|
88
102
|
children: [
|
|
89
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_editor_EditorProvider.EditorProvider, {}),
|
|
90
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_analytics_AnalyticsProvider.AnalyticsProvider, {}),
|
|
103
|
+
process.env.INTLAYER_EDITOR_ENABLED !== "false" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_editor_EditorProvider.EditorProvider, {}),
|
|
104
|
+
process.env.INTLAYER_ANALYTICS_ENABLED !== "false" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_analytics_AnalyticsProvider.AnalyticsProvider, {}),
|
|
91
105
|
children
|
|
92
106
|
]
|
|
93
107
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerProvider.cjs","names":["createContext","
|
|
1
|
+
{"version":3,"file":"IntlayerProvider.cjs","names":["createContext","getLocaleInStorage","internationalization","useContext","useState","useCallback","localeResolver","useMemo","EditorProvider","AnalyticsProvider"],"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport { internationalization } from '@intlayer/config/built';\nimport { setIntlayerIdentifier } from '@intlayer/config/client';\nimport { localeResolver } from '@intlayer/core/localization';\nimport type {\n LocalesValues,\n ProviderVariant,\n} from '@intlayer/types/module_augmentation';\nimport {\n createContext,\n type FC,\n type PropsWithChildren,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport { AnalyticsProvider } from '../analytics/AnalyticsProvider';\nimport { EditorProvider } from '../editor/EditorProvider';\nimport { getLocaleInStorage, setLocaleInStorage } from './useLocaleStorage';\n\ntype IntlayerValue = {\n locale: LocalesValues;\n setLocale: (newLocale: LocalesValues) => void;\n /**\n * Ambient variant applied to every dictionary read below the provider, the\n * same way `locale` is. Overridden per call by an explicit selector.\n */\n variant?: ProviderVariant;\n disableEditor?: boolean;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Context that stores the current locale on the client side.\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n // Read on demand: only a tree rendered without a provider needs it\n get locale() {\n return getLocaleInStorage() ?? internationalization?.defaultLocale;\n },\n setLocale: () => null,\n isCookieEnabled: true,\n});\n\n/**\n * Hook that provides the current Intlayer client context.\n *\n * @returns The current Intlayer context values.\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext) ?? {};\n\n/**\n * Props for the IntlayerProvider component.\n */\nexport type IntlayerProviderProps = PropsWithChildren<{\n /**\n * The locale to use. If not provided, it will be detected from storage or configuration.\n */\n locale?: LocalesValues;\n /**\n * Ambient variant applied to every dictionary read below this provider — for\n * a dimension that is fixed for the whole session (tenant, school type, plan\n * tier…) and that therefore no component should have to pass by hand.\n *\n * Accepts three forms:\n * - `variant=\"school1\"` — one named variant for every key\n * - `variant={['school1', 'default']}` — an ordered preference chain: the\n * first variant the key actually declares wins\n * - `variant={{ key1: 'school1', key2: ['school1', 'default'], default: 'base' }}`\n * — per dictionary key, with `default` covering every key not listed\n *\n * A plain object is always read as the per-key map. To pin a structured\n * variant globally, nest it: `variant={{ default: { id: 'prod_abc' } }}`.\n *\n * A call-site selector always wins: `useIntlayer('key', { variant: 'x' })`\n * replaces this default rather than extending it.\n */\n variant?: ProviderVariant;\n /**\n * The default locale to use as a fallback.\n */\n defaultLocale?: LocalesValues;\n /**\n * Function to set the locale.\n */\n setLocale?: (locale: LocalesValues) => void;\n /**\n * Whether to disable the editor.\n */\n disableEditor?: boolean;\n /**\n * Whether to enable cookies for storing the locale.\n */\n isCookieEnabled?: boolean;\n}>;\n\n/**\n * Provider that stores the current locale on the client side.\n *\n * This component is focused on content delivery without the editor features.\n *\n * @param props - The provider props.\n * @returns The provider component.\n */\nexport const IntlayerProviderContent: FC<IntlayerProviderProps> = ({\n locale: localeProp,\n defaultLocale: defaultLocaleProp,\n variant,\n children,\n setLocale: setLocaleProp,\n disableEditor,\n isCookieEnabled,\n}) => {\n const { locales: availableLocales, defaultLocale: defaultLocaleConfig } =\n internationalization ?? {};\n\n // Storage is only read when no locale is passed, and only on mount\n const [currentLocale, setCurrentLocale] = useState<LocalesValues>(\n () =>\n localeProp ??\n getLocaleInStorage() ??\n defaultLocaleProp ??\n defaultLocaleConfig\n );\n const [adoptedLocaleProp, setAdoptedLocaleProp] = useState(localeProp);\n\n // Adopt a new `locale` prop during render rather than in an effect: an\n // effect commits the whole subtree once with the stale locale, then renders\n // it again with the new one.\n if (localeProp !== adoptedLocaleProp) {\n setAdoptedLocaleProp(localeProp);\n\n if (localeProp && localeProp !== currentLocale) {\n setCurrentLocale(localeProp);\n }\n }\n\n useEffect(() => {\n setIntlayerIdentifier();\n }, []);\n\n const setLocaleBase = useCallback(\n (newLocale: LocalesValues) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale);\n setLocaleInStorage(newLocale, isCookieEnabled);\n },\n [currentLocale, availableLocales, isCookieEnabled]\n );\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n // Resolve based on currentLocale (the state), not the prop directly\n const resolvedLocale = localeResolver(currentLocale);\n\n // Stable value so a parent re-render does not re-render every consumer\n const contextValue = useMemo<IntlayerValue>(\n () => ({\n locale: resolvedLocale,\n setLocale,\n variant,\n disableEditor,\n }),\n [resolvedLocale, setLocale, variant, disableEditor]\n );\n\n return (\n <IntlayerClientContext.Provider value={contextValue}>\n {children}\n </IntlayerClientContext.Provider>\n );\n};\n\n/**\n * Main provider for Intlayer in React applications.\n *\n * It includes the editor provider by default, allowing for live content editing\n * if configured.\n *\n * @param props - The provider props.\n * @returns The provider component with editor support.\n *\n * @example\n * ```tsx\n * import { IntlayerProvider } from 'react-intlayer';\n *\n * const App = () => (\n * <IntlayerProvider>\n * <MyComponent />\n * </IntlayerProvider>\n * );\n * ```\n */\nexport const IntlayerProvider: FC<IntlayerProviderProps> = ({\n children,\n ...props\n}) => (\n <IntlayerProviderContent {...props}>\n {/* Build flags drop these, and their modules, when the feature is off */}\n {process.env.INTLAYER_EDITOR_ENABLED !== 'false' && <EditorProvider />}\n {process.env.INTLAYER_ANALYTICS_ENABLED !== 'false' && (\n <AnalyticsProvider />\n )}\n {children}\n </IntlayerProviderContent>\n);\n"],"mappings":";;;;;;;;;;;;;;;;AAsCA,MAAa,4BAAwBA,qBAA6B;CAEhE,IAAI,SAAS;EACX,OAAOC,mDAAmB,KAAKC,6CAAsB;CACvD;CACA,iBAAiB;CACjB,iBAAiB;AACnB,CAAC;;;;;;AAOD,MAAa,+BAA2BC,kBAAW,qBAAqB,KAAK,CAAC;;;;;;;;;AAuD9E,MAAa,2BAAsD,EACjE,QAAQ,YACR,eAAe,mBACf,SACA,UACA,WAAW,eACX,eACA,sBACI;CACJ,MAAM,EAAE,SAAS,kBAAkB,eAAe,wBAChDD,+CAAwB,CAAC;CAG3B,MAAM,CAAC,eAAe,wBAAoBE,sBAEtC,cACAH,mDAAmB,KACnB,qBACA,mBACJ;CACA,MAAM,CAAC,mBAAmB,4BAAwBG,gBAAS,UAAU;CAKrE,IAAI,eAAe,mBAAmB;EACpC,qBAAqB,UAAU;EAE/B,IAAI,cAAc,eAAe,eAC/B,iBAAiB,UAAU;CAE/B;CAEA,2BAAgB;EACd,mDAAsB;CACxB,GAAG,CAAC,CAAC;CAEL,MAAM,oBAAgBC,oBACnB,cAA6B;EAC5B,IAAI,cAAc,SAAS,MAAM,UAAU,SAAS,GAAG;EAEvD,IAAI,CAAC,kBAAkB,IAAI,MAAM,CAAC,CAAC,SAAS,SAAS,GAAG;GACtD,QAAQ,MAAM,UAAU,UAAU,kBAAkB;GACpD;EACF;EAEA,iBAAiB,SAAS;EAC1B,mDAAmB,WAAW,eAAe;CAC/C,GACA;EAAC;EAAe;EAAkB;CAAe,CACnD;CAEA,MAAM,YAAY,iBAAiB;CAGnC,MAAM,qBAAiBC,4CAAe,aAAa;CAGnD,MAAM,mBAAeC,sBACZ;EACL,QAAQ;EACR;EACA;EACA;CACF,IACA;EAAC;EAAgB;EAAW;EAAS;CAAa,CACpD;CAEA,OACE,2CAAC,sBAAsB,UAAvB;EAAgC,OAAO;EACpC;CAC6B;AAEpC;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,oBAA+C,EAC1D,UACA,GAAG,YAEH,4CAAC,yBAAD;CAAyB,GAAI;WAA7B;EAEG,QAAQ,IAAI,4BAA4B,WAAW,2CAACC,8CAAD,CAAiB;EACpE,QAAQ,IAAI,+BAA+B,WAC1C,2CAACC,uDAAD,CAAoB;EAErB;CACsB"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_client_format_useIntl = require('./useIntl.cjs');
|
|
3
|
-
const
|
|
3
|
+
const require_client_format_usePercentage = require('./usePercentage.cjs');
|
|
4
4
|
const require_client_format_useUnit = require('./useUnit.cjs');
|
|
5
|
-
const require_client_format_useDate = require('./useDate.cjs');
|
|
6
5
|
const require_client_format_useCompact = require('./useCompact.cjs');
|
|
7
|
-
const require_client_format_useList = require('./useList.cjs');
|
|
8
6
|
const require_client_format_useNumber = require('./useNumber.cjs');
|
|
9
|
-
const
|
|
7
|
+
const require_client_format_useList = require('./useList.cjs');
|
|
8
|
+
const require_client_format_useCurrency = require('./useCurrency.cjs');
|
|
9
|
+
const require_client_format_useDate = require('./useDate.cjs');
|
|
10
10
|
const require_client_format_useRelativeTime = require('./useRelativeTime.cjs');
|
|
11
11
|
|
|
12
12
|
exports.useCompact = require_client_format_useCompact.useCompact;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_client_useLoadDynamic = require('./useLoadDynamic.cjs');
|
|
2
3
|
const require_client_useLocaleStorage = require('./useLocaleStorage.cjs');
|
|
3
4
|
const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
4
5
|
const require_client_t = require('./t.cjs');
|
|
5
|
-
const require_client_useLoadDynamic = require('./useLoadDynamic.cjs');
|
|
6
6
|
const require_client_useDictionary = require('./useDictionary.cjs');
|
|
7
7
|
const require_client_useDictionaryAsync = require('./useDictionaryAsync.cjs');
|
|
8
8
|
const require_client_useDictionaryDynamic = require('./useDictionaryDynamic.cjs');
|
|
@@ -10,8 +10,8 @@ const require_client_useI18n = require('./useI18n.cjs');
|
|
|
10
10
|
const require_client_useIntlayer = require('./useIntlayer.cjs');
|
|
11
11
|
const require_client_useLocale = require('./useLocale.cjs');
|
|
12
12
|
const require_client_useLocaleBase = require('./useLocaleBase.cjs');
|
|
13
|
-
const require_client_useRewriteURL = require('./useRewriteURL.cjs');
|
|
14
13
|
const require_client_usePathname = require('./usePathname.cjs');
|
|
14
|
+
const require_client_useRewriteURL = require('./useRewriteURL.cjs');
|
|
15
15
|
|
|
16
16
|
exports.IntlayerClientContext = require_client_IntlayerProvider.IntlayerClientContext;
|
|
17
17
|
exports.IntlayerProvider = require_client_IntlayerProvider.IntlayerProvider;
|
package/dist/cjs/client/t.cjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
5
|
-
let react = require("react");
|
|
6
5
|
let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
|
|
6
|
+
let react = require("react");
|
|
7
7
|
|
|
8
8
|
//#region src/client/t.ts
|
|
9
9
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
5
4
|
const require_getDictionary = require('../getDictionary.cjs');
|
|
5
|
+
const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
6
6
|
let react = require("react");
|
|
7
7
|
let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
|
|
8
8
|
|
|
@@ -23,7 +23,7 @@ const useDictionary = (dictionary, localeOrSelector) => {
|
|
|
23
23
|
contextVariant,
|
|
24
24
|
dictionaryKey: dictionary.key
|
|
25
25
|
}) : localeOrSelector ?? currentLocale;
|
|
26
|
-
const argumentIdentity = typeof argument === "object" && argument !== null ? `${argument.locale ?? ""}|${(0, _intlayer_core_dictionaryManipulator.getDictionarySelectorCacheKey)(argument)}` : argument;
|
|
26
|
+
const argumentIdentity = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && typeof argument === "object" && argument !== null ? `${argument.locale ?? ""}|${(0, _intlayer_core_dictionaryManipulator.getDictionarySelectorCacheKey)(argument)}` : argument;
|
|
27
27
|
return (0, react.useMemo)(() => require_getDictionary.getDictionary(dictionary, argument), [dictionary.key, argumentIdentity]);
|
|
28
28
|
};
|
|
29
29
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.cjs","names":["useContext","IntlayerClientContext","resolveDictionaryArgument","getDictionarySelectorCacheKey","useMemo","getDictionary"],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport {\n getDictionarySelectorCacheKey,\n resolveDictionaryArgument,\n} from '@intlayer/core/dictionaryManipulator';\nimport type {\n Dictionary,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Client-side hook that transforms a dictionary (or qualified dictionary\n * group) and returns the content.\n *\n * If the locale is not provided (directly or through the selector), it will\n * use the locale from the client context. The same applies to the variant,\n * which falls back to the provider's ambient `variant`.\n */\nexport const useDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends\n | LocalesValues\n | DictionarySelectorForGroup<T> = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A\n) => {\n const { locale: currentLocale, variant: contextVariant } =\n useContext(IntlayerClientContext) ?? {};\n\n // Layers the provider's locale and variant under the call-site argument.\n // This is the seam the build-time optimize transform lands on: it rewrites\n // `useIntlayer('key', selector)` into `useDictionary(dict, selector)`, so an\n // ambient variant has to be applied here to survive the rewrite.\n const argument =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: currentLocale,\n contextVariant,\n dictionaryKey: dictionary.key,\n })\n : (localeOrSelector ?? currentLocale);\n\n // Stable identity of the resolved argument for memoization — a provider\n // variant is often a fresh object literal on every render, so the dependency\n // has to be its serialization, never its reference.\n const argumentIdentity =\n typeof argument === 'object'
|
|
1
|
+
{"version":3,"file":"useDictionary.cjs","names":["useContext","IntlayerClientContext","resolveDictionaryArgument","getDictionarySelectorCacheKey","useMemo","getDictionary"],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["'use client';\n\nimport {\n getDictionarySelectorCacheKey,\n resolveDictionaryArgument,\n} from '@intlayer/core/dictionaryManipulator';\nimport type {\n Dictionary,\n DictionarySelectorForGroup,\n QualifiedDictionaryGroup,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Client-side hook that transforms a dictionary (or qualified dictionary\n * group) and returns the content.\n *\n * If the locale is not provided (directly or through the selector), it will\n * use the locale from the client context. The same applies to the variant,\n * which falls back to the provider's ambient `variant`.\n */\nexport const useDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends\n | LocalesValues\n | DictionarySelectorForGroup<T> = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A\n) => {\n const { locale: currentLocale, variant: contextVariant } =\n useContext(IntlayerClientContext) ?? {};\n\n // Layers the provider's locale and variant under the call-site argument.\n // This is the seam the build-time optimize transform lands on: it rewrites\n // `useIntlayer('key', selector)` into `useDictionary(dict, selector)`, so an\n // ambient variant has to be applied here to survive the rewrite.\n const argument =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: currentLocale,\n contextVariant,\n dictionaryKey: dictionary.key,\n })\n : (localeOrSelector ?? currentLocale);\n\n // Stable identity of the resolved argument for memoization — a provider\n // variant is often a fresh object literal on every render, so the dependency\n // has to be its serialization, never its reference.\n const argumentIdentity =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof argument === 'object' &&\n argument !== null\n ? `${argument.locale ?? ''}|${getDictionarySelectorCacheKey(argument)}`\n : argument;\n\n return useMemo(\n () => getDictionary<T, A>(dictionary, argument as A),\n [dictionary.key, argumentIdentity]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AA2BA,MAAa,iBAMX,YACA,qBACG;CACH,MAAM,EAAE,QAAQ,eAAe,SAAS,uBACtCA,kBAAWC,qDAAqB,KAAK,CAAC;CAMxC,MAAM,WACJ,QAAQ,IAAI,iCAAiC,cACzCC,gEAA0B;EACxB;EACA,eAAe;EACf;EACA,eAAe,WAAW;CAC5B,CAAC,IACA,oBAAoB;CAK3B,MAAM,mBACJ,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,aAAa,YACpB,aAAa,OACT,GAAG,SAAS,UAAU,GAAG,OAAGC,oEAA8B,QAAQ,MAClE;CAEN,WAAOC,qBACCC,oCAAoB,YAAY,QAAa,GACnD,CAAC,WAAW,KAAK,gBAAgB,CACnC;AACF"}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
5
5
|
const require_client_useDictionary = require('./useDictionary.cjs');
|
|
6
|
-
let react = require("react");
|
|
7
6
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
7
|
+
let react = require("react");
|
|
8
8
|
|
|
9
9
|
//#region src/client/useDictionaryAsync.ts
|
|
10
10
|
/**
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
5
4
|
const require_client_useLoadDynamic = require('./useLoadDynamic.cjs');
|
|
6
5
|
const require_getDictionary = require('../getDictionary.cjs');
|
|
7
|
-
|
|
6
|
+
const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
8
7
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
8
|
+
let react = require("react");
|
|
9
9
|
let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
|
|
10
10
|
|
|
11
11
|
//#region src/client/useDictionaryDynamic.ts
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
5
|
-
let react = require("react");
|
|
6
5
|
let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
|
|
6
|
+
let react = require("react");
|
|
7
7
|
|
|
8
8
|
//#region src/client/useI18n.ts
|
|
9
9
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
5
4
|
const require_getIntlayer = require('../getIntlayer.cjs');
|
|
5
|
+
const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
6
6
|
let react = require("react");
|
|
7
7
|
let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
|
|
8
8
|
|
|
@@ -43,7 +43,7 @@ const useIntlayer = (key, localeOrSelector) => {
|
|
|
43
43
|
contextVariant,
|
|
44
44
|
dictionaryKey: key
|
|
45
45
|
}) : localeOrSelector ?? currentLocale;
|
|
46
|
-
const argumentIdentity = typeof argument === "object" && argument !== null ? `${argument.locale ?? ""}|${(0, _intlayer_core_dictionaryManipulator.getDictionarySelectorCacheKey)(argument)}` : argument;
|
|
46
|
+
const argumentIdentity = process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && typeof argument === "object" && argument !== null ? `${argument.locale ?? ""}|${(0, _intlayer_core_dictionaryManipulator.getDictionarySelectorCacheKey)(argument)}` : argument;
|
|
47
47
|
return (0, react.useMemo)(() => require_getIntlayer.getIntlayer(key, argument), [key, argumentIdentity]);
|
|
48
48
|
};
|
|
49
49
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.cjs","names":["useContext","IntlayerClientContext","resolveDictionaryArgument","getDictionarySelectorCacheKey","useMemo","getIntlayer"],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport {\n getDictionarySelectorCacheKey,\n resolveDictionaryArgument,\n} from '@intlayer/core/dictionaryManipulator';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { getIntlayer } from '../getIntlayer';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Client-side hook that picks one dictionary by its key and returns its content.\n *\n * The second argument is either a locale or a selector object:\n * - `{ item: 2 }` — collection item (omit `item` to get every item as array)\n * - `{ variant: 'black-friday' }` — named variant (omit for the `default` one)\n * - `{ variant: ['black-friday', 'promo'] }` — ordered preference chain\n * - `locale` composes with any selector and overrides the context locale\n *\n * `locale` and `variant` both fall back to the surrounding `IntlayerProvider`\n * when the call does not pin them.\n *\n * @param key - The unique key of the dictionary to retrieve.\n * @param localeOrSelector - Optional locale or selector.\n * @returns The dictionary content for the resolved entry and locale.\n *\n * @example\n * ```tsx\n * import { useIntlayer } from 'react-intlayer';\n *\n * const MyComponent = () => {\n * const content = useIntlayer('my-dictionary-key');\n * const faq2 = useIntlayer('faq', { item: 2 });\n *\n * return <div>{content.myField.value}</div>;\n * };\n * ```\n */\nexport const useIntlayer = <\n const T extends DictionaryKeys,\n const A extends LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A\n) => {\n const { locale: currentLocale, variant: contextVariant } =\n useContext(IntlayerClientContext) ?? {};\n\n // Layers the provider's locale and variant under the call-site argument.\n // Selectors disabled project-wide (build-time flag) ⇒ the argument can only\n // be a locale, so the merge is dead code and is dropped by the bundler.\n const argument =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: currentLocale,\n contextVariant,\n dictionaryKey: key as string,\n })\n : (localeOrSelector ?? currentLocale);\n\n // Stable identity of the resolved argument for memoization — a provider\n // variant is often a fresh object literal on every render, so the dependency\n // has to be its serialization, never its reference.\n const argumentIdentity =\n typeof argument === 'object'
|
|
1
|
+
{"version":3,"file":"useIntlayer.cjs","names":["useContext","IntlayerClientContext","resolveDictionaryArgument","getDictionarySelectorCacheKey","useMemo","getIntlayer"],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["'use client';\n\nimport {\n getDictionarySelectorCacheKey,\n resolveDictionaryArgument,\n} from '@intlayer/core/dictionaryManipulator';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'react';\nimport { getIntlayer } from '../getIntlayer';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Client-side hook that picks one dictionary by its key and returns its content.\n *\n * The second argument is either a locale or a selector object:\n * - `{ item: 2 }` — collection item (omit `item` to get every item as array)\n * - `{ variant: 'black-friday' }` — named variant (omit for the `default` one)\n * - `{ variant: ['black-friday', 'promo'] }` — ordered preference chain\n * - `locale` composes with any selector and overrides the context locale\n *\n * `locale` and `variant` both fall back to the surrounding `IntlayerProvider`\n * when the call does not pin them.\n *\n * @param key - The unique key of the dictionary to retrieve.\n * @param localeOrSelector - Optional locale or selector.\n * @returns The dictionary content for the resolved entry and locale.\n *\n * @example\n * ```tsx\n * import { useIntlayer } from 'react-intlayer';\n *\n * const MyComponent = () => {\n * const content = useIntlayer('my-dictionary-key');\n * const faq2 = useIntlayer('faq', { item: 2 });\n *\n * return <div>{content.myField.value}</div>;\n * };\n * ```\n */\nexport const useIntlayer = <\n const T extends DictionaryKeys,\n const A extends LocalesValues | DictionarySelectorForKey<T> = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A\n) => {\n const { locale: currentLocale, variant: contextVariant } =\n useContext(IntlayerClientContext) ?? {};\n\n // Layers the provider's locale and variant under the call-site argument.\n // Selectors disabled project-wide (build-time flag) ⇒ the argument can only\n // be a locale, so the merge is dead code and is dropped by the bundler.\n const argument =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false'\n ? resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: currentLocale,\n contextVariant,\n dictionaryKey: key as string,\n })\n : (localeOrSelector ?? currentLocale);\n\n // Stable identity of the resolved argument for memoization — a provider\n // variant is often a fresh object literal on every render, so the dependency\n // has to be its serialization, never its reference.\n const argumentIdentity =\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n typeof argument === 'object' &&\n argument !== null\n ? `${argument.locale ?? ''}|${getDictionarySelectorCacheKey(argument)}`\n : argument;\n\n return useMemo(\n () => getIntlayer<T, A>(key, argument as A),\n [key, argumentIdentity]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAa,eAIX,KACA,qBACG;CACH,MAAM,EAAE,QAAQ,eAAe,SAAS,uBACtCA,kBAAWC,qDAAqB,KAAK,CAAC;CAKxC,MAAM,WACJ,QAAQ,IAAI,iCAAiC,cACzCC,gEAA0B;EACxB;EACA,eAAe;EACf;EACA,eAAe;CACjB,CAAC,IACA,oBAAoB;CAK3B,MAAM,mBACJ,QAAQ,IAAI,iCAAiC,WAC7C,OAAO,aAAa,YACpB,aAAa,OACT,GAAG,SAAS,UAAU,GAAG,OAAGC,oEAA8B,QAAQ,MAClE;CAEN,WAAOC,qBACCC,gCAAkB,KAAK,QAAa,GAC1C,CAAC,KAAK,gBAAgB,CACxB;AACF"}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
const require_client_useLocaleStorage = require('./useLocaleStorage.cjs');
|
|
5
5
|
const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
6
|
-
let react = require("react");
|
|
7
6
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
7
|
+
let react = require("react");
|
|
8
8
|
|
|
9
9
|
//#region src/client/useLocale.ts
|
|
10
10
|
const { defaultLocale, locales: availableLocales } = _intlayer_config_built.internationalization ?? {};
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
5
|
-
let react = require("react");
|
|
6
5
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
6
|
+
let react = require("react");
|
|
7
7
|
|
|
8
8
|
//#region src/client/useLocaleBase.ts
|
|
9
9
|
const { defaultLocale, locales: availableLocales } = _intlayer_config_built.internationalization;
|
|
@@ -4,12 +4,19 @@ let _intlayer_core_utils = require("@intlayer/core/utils");
|
|
|
4
4
|
|
|
5
5
|
//#region src/client/useLocaleStorage.ts
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Reads the locale persisted in the browser storage (cookie, localStorage…).
|
|
8
|
+
*
|
|
9
|
+
* Unlike `localeInStorage`, read on first call rather than at import, then
|
|
10
|
+
* cached until the next `setLocaleInStorage`. Never cached on the server.
|
|
8
11
|
*/
|
|
12
|
+
const getLocaleInStorage = _intlayer_core_utils.getCachedLocaleFromStorageClient;
|
|
9
13
|
/**
|
|
10
14
|
* Get the locale cookie
|
|
15
|
+
*
|
|
16
|
+
* Read once at import time; marked pure so bundlers drop the read when nothing
|
|
17
|
+
* imports it.
|
|
11
18
|
*/
|
|
12
|
-
const localeInStorage = (0, _intlayer_core_utils.getLocaleFromStorageClient)(_intlayer_core_utils.localeStorageOptions);
|
|
19
|
+
const localeInStorage = /* @__PURE__ */ (0, _intlayer_core_utils.getLocaleFromStorageClient)(_intlayer_core_utils.localeStorageOptions);
|
|
13
20
|
/**
|
|
14
21
|
* @deprecated Use localeInStorage instead
|
|
15
22
|
*
|
|
@@ -46,6 +53,7 @@ const useLocaleStorage = (isCookieEnabled) => (0, react.useMemo)(() => (0, _intl
|
|
|
46
53
|
const useLocaleCookie = useLocaleStorage;
|
|
47
54
|
|
|
48
55
|
//#endregion
|
|
56
|
+
exports.getLocaleInStorage = getLocaleInStorage;
|
|
49
57
|
exports.localeCookie = localeCookie;
|
|
50
58
|
exports.localeInStorage = localeInStorage;
|
|
51
59
|
exports.setLocaleCookie = setLocaleCookie;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocaleStorage.cjs","names":["
|
|
1
|
+
{"version":3,"file":"useLocaleStorage.cjs","names":["getCachedLocaleFromStorageClient","localeStorageOptions","setLocaleInStorageCore","useMemo","LocaleStorageClient"],"sources":["../../../src/client/useLocaleStorage.ts"],"sourcesContent":["import {\n getCachedLocaleFromStorageClient,\n getLocaleFromStorageClient,\n LocaleStorageClient,\n localeStorageOptions,\n setLocaleInStorageClient as setLocaleInStorageCore,\n} from '@intlayer/core/utils';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useMemo } from 'react';\n\n/**\n * Reads the locale persisted in the browser storage (cookie, localStorage…).\n *\n * Unlike `localeInStorage`, read on first call rather than at import, then\n * cached until the next `setLocaleInStorage`. Never cached on the server.\n */\nexport const getLocaleInStorage = getCachedLocaleFromStorageClient;\n\n/**\n * Get the locale cookie\n *\n * Read once at import time; marked pure so bundlers drop the read when nothing\n * imports it.\n */\nexport const localeInStorage =\n /* @__PURE__ */ getLocaleFromStorageClient(localeStorageOptions);\n/**\n * @deprecated Use localeInStorage instead\n *\n * Get the locale cookie\n */\nexport const localeCookie = localeInStorage;\n\n/**\n * Set the locale cookie\n */\nexport const setLocaleInStorage = (\n locale: LocalesValues,\n isCookieEnabled?: boolean\n) =>\n setLocaleInStorageCore(locale, {\n ...localeStorageOptions,\n isCookieEnabled,\n });\n\n/**\n * @deprecated Use setLocaleInStorage instead\n *\n * Set the locale cookie\n */\nexport const setLocaleCookie = setLocaleInStorage;\n\n/**\n * Hook that provides the locale cookie and a function to set it\n */\nexport const useLocaleStorage = (isCookieEnabled?: boolean) =>\n useMemo(\n () =>\n LocaleStorageClient({\n ...localeStorageOptions,\n isCookieEnabled,\n }),\n [isCookieEnabled]\n );\n\n/**\n * @deprecated Use useLocaleStorage instead\n *\n * For GDPR compliance, use useLocaleStorage instead\n *\n * Hook that provides the locale cookie and a function to set it\n */\nexport const useLocaleCookie = useLocaleStorage;\n"],"mappings":";;;;;;;;;;;AAgBA,MAAa,qBAAqBA;;;;;;;AAQlC,MAAa,kBACK,qEAA2BC,yCAAoB;;;;;;AAMjE,MAAa,eAAe;;;;AAK5B,MAAa,sBACX,QACA,wBAEAC,+CAAuB,QAAQ;CAC7B,GAAGD;CACH;AACF,CAAC;;;;;;AAOH,MAAa,kBAAkB;;;;AAK/B,MAAa,oBAAoB,wBAC/BE,yBAEIC,0CAAoB;CAClB,GAAGH;CACH;AACF,CAAC,GACH,CAAC,eAAe,CAClB;;;;;;;;AASF,MAAa,kBAAkB"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
const require_client_useLocale = require('./useLocale.cjs');
|
|
5
|
-
let react = require("react");
|
|
6
5
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
6
|
+
let react = require("react");
|
|
7
7
|
let _intlayer_core_localization = require("@intlayer/core/localization");
|
|
8
8
|
|
|
9
9
|
//#region src/client/useRewriteURL.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
3
|
-
let react = require("react");
|
|
4
3
|
let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
|
|
4
|
+
let react = require("react");
|
|
5
5
|
|
|
6
6
|
//#region src/client/useTraduction.ts
|
|
7
7
|
/**
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
const require_html_HTMLProvider = require('./HTMLProvider.cjs');
|
|
5
|
+
let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
|
|
5
6
|
let react = require("react");
|
|
6
7
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
-
let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
|
|
8
8
|
let _intlayer_core_transpiler = require("@intlayer/core/transpiler");
|
|
9
9
|
|
|
10
10
|
//#region src/html/HTMLRenderer.tsx
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_client_useLoadDynamic = require('./client/useLoadDynamic.cjs');
|
|
3
|
+
const require_getDictionary = require('./getDictionary.cjs');
|
|
4
|
+
const require_getIntlayer = require('./getIntlayer.cjs');
|
|
2
5
|
const require_client_useLocaleStorage = require('./client/useLocaleStorage.cjs');
|
|
3
6
|
const require_client_IntlayerProvider = require('./client/IntlayerProvider.cjs');
|
|
4
7
|
const require_analytics_useAnalytics = require('./analytics/useAnalytics.cjs');
|
|
@@ -7,16 +10,14 @@ const require_analytics_useConversion = require('./analytics/useConversion.cjs')
|
|
|
7
10
|
const require_analytics_useExperiment = require('./analytics/useExperiment.cjs');
|
|
8
11
|
const require_client_format_useIntl = require('./client/format/useIntl.cjs');
|
|
9
12
|
const require_client_t = require('./client/t.cjs');
|
|
10
|
-
const require_client_useLoadDynamic = require('./client/useLoadDynamic.cjs');
|
|
11
|
-
const require_getDictionary = require('./getDictionary.cjs');
|
|
12
13
|
const require_client_useDictionary = require('./client/useDictionary.cjs');
|
|
13
14
|
const require_client_useDictionaryAsync = require('./client/useDictionaryAsync.cjs');
|
|
14
15
|
const require_client_useDictionaryDynamic = require('./client/useDictionaryDynamic.cjs');
|
|
15
16
|
const require_client_useI18n = require('./client/useI18n.cjs');
|
|
16
|
-
const require_getIntlayer = require('./getIntlayer.cjs');
|
|
17
17
|
const require_client_useIntlayer = require('./client/useIntlayer.cjs');
|
|
18
18
|
const require_client_useLocale = require('./client/useLocale.cjs');
|
|
19
19
|
const require_client_useLocaleBase = require('./client/useLocaleBase.cjs');
|
|
20
|
+
const require_client_usePathname = require('./client/usePathname.cjs');
|
|
20
21
|
const require_client_useRewriteURL = require('./client/useRewriteURL.cjs');
|
|
21
22
|
const require_markdown_MarkdownProvider = require('./markdown/MarkdownProvider.cjs');
|
|
22
23
|
const require_markdown_MarkdownRenderer = require('./markdown/MarkdownRenderer.cjs');
|
|
@@ -75,5 +76,6 @@ exports.useLocaleCookie = require_client_useLocaleStorage.useLocaleCookie;
|
|
|
75
76
|
exports.useLocaleStorage = require_client_useLocaleStorage.useLocaleStorage;
|
|
76
77
|
exports.useMarkdownContext = useMarkdownContext;
|
|
77
78
|
exports.useMarkdownRenderer = useMarkdownRenderer;
|
|
79
|
+
exports.usePathname = require_client_usePathname.usePathname;
|
|
78
80
|
exports.useRewriteURL = require_client_useRewriteURL.useRewriteURL;
|
|
79
81
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["_MarkdownProvider","_useMarkdownContext","_renderMarkdown","_useMarkdownRenderer","_MarkdownRenderer"],"sources":["../../src/index.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { IInterpreterPluginReact } from './plugins';\n\ndeclare module '@intlayer/core/interpreter' {\n interface IInterpreterPlugin<T, S, L extends LocalesValues>\n extends IInterpreterPluginReact<T, S, L> {}\n}\n\nexport { AnalyticsProvider } from './analytics/AnalyticsProvider';\nexport { useAnalytics } from './analytics/useAnalytics';\nexport type { ConversionParams } from './analytics/useConversion';\nexport { useConversion } from './analytics/useConversion';\nexport type { ExperimentState } from './analytics/useExperiment';\nexport { useExperiment } from './analytics/useExperiment';\n/**\n * @deprecated import from react-intlayer/format instead\n */\nexport { useIntl } from './client/format/useIntl';\n// Import directly from individual files to avoid circular dependency issues\nexport type { IntlayerProviderProps } from './client/IntlayerProvider';\nexport {\n IntlayerClientContext,\n IntlayerProvider,\n IntlayerProviderContent,\n useIntlayerContext,\n} from './client/IntlayerProvider';\nexport { t } from './client/t';\nexport { useDictionary } from './client/useDictionary';\nexport { useDictionaryAsync } from './client/useDictionaryAsync';\nexport { useDictionaryDynamic } from './client/useDictionaryDynamic';\nexport { useI18n } from './client/useI18n';\nexport { useIntlayer } from './client/useIntlayer';\nexport { useLoadDynamic } from './client/useLoadDynamic';\nexport type { UseLocaleProps, UseLocaleResult } from './client/useLocale';\nexport { useLocale } from './client/useLocale';\nexport { useLocaleBase } from './client/useLocaleBase';\nexport {\n localeCookie,\n localeInStorage,\n setLocaleCookie,\n setLocaleInStorage,\n useLocaleCookie,\n useLocaleStorage,\n} from './client/useLocaleStorage';\nexport { useRewriteURL } from './client/useRewriteURL';\nexport { getDictionary } from './getDictionary';\nexport { getIntlayer } from './getIntlayer';\nexport type { IntlayerNode } from './IntlayerNode';\n\nimport type {\n MarkdownProviderOptions as _MarkdownProviderOptions,\n MarkdownRendererProps as _MarkdownRendererProps,\n RenderMarkdownProps as _RenderMarkdownProps,\n} from './markdown';\nimport {\n MarkdownProvider as _MarkdownProvider,\n MarkdownRenderer as _MarkdownRenderer,\n renderMarkdown as _renderMarkdown,\n useMarkdownContext as _useMarkdownContext,\n useMarkdownRenderer as _useMarkdownRenderer,\n} from './markdown';\n/**\n * @deprecated import from react-intlayer/markdown instead\n */\nexport const MarkdownProvider = _MarkdownProvider;\n/**\n * @deprecated import from react-intlayer/markdown instead\n */\nexport const useMarkdownContext = _useMarkdownContext;\n/**\n * @deprecated import from react-intlayer/markdown instead\n */\nexport type MarkdownProviderOptions = _MarkdownProviderOptions;\n/**\n * @deprecated import from react-intlayer/markdown instead\n */\nexport const renderMarkdown = _renderMarkdown;\n/**\n * @deprecated import from react-intlayer/markdown instead\n */\nexport const useMarkdownRenderer = _useMarkdownRenderer;\n/**\n * @deprecated import from react-intlayer/markdown instead\n */\nexport const MarkdownRenderer = _MarkdownRenderer;\n/**\n * @deprecated import from react-intlayer/markdown instead\n */\nexport type RenderMarkdownProps = _RenderMarkdownProps;\n/**\n * @deprecated import from react-intlayer/markdown instead\n */\nexport type MarkdownRendererProps = _MarkdownRendererProps;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["_MarkdownProvider","_useMarkdownContext","_renderMarkdown","_useMarkdownRenderer","_MarkdownRenderer"],"sources":["../../src/index.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { IInterpreterPluginReact } from './plugins';\n\ndeclare module '@intlayer/core/interpreter' {\n interface IInterpreterPlugin<T, S, L extends LocalesValues>\n extends IInterpreterPluginReact<T, S, L> {}\n}\n\nexport { AnalyticsProvider } from './analytics/AnalyticsProvider';\nexport { useAnalytics } from './analytics/useAnalytics';\nexport type { ConversionParams } from './analytics/useConversion';\nexport { useConversion } from './analytics/useConversion';\nexport type { ExperimentState } from './analytics/useExperiment';\nexport { useExperiment } from './analytics/useExperiment';\n/**\n * @deprecated import from react-intlayer/format instead\n */\nexport { useIntl } from './client/format/useIntl';\n// Import directly from individual files to avoid circular dependency issues\nexport type { IntlayerProviderProps } from './client/IntlayerProvider';\nexport {\n IntlayerClientContext,\n IntlayerProvider,\n IntlayerProviderContent,\n useIntlayerContext,\n} from './client/IntlayerProvider';\nexport { t } from './client/t';\nexport { useDictionary } from './client/useDictionary';\nexport { useDictionaryAsync } from './client/useDictionaryAsync';\nexport { useDictionaryDynamic } from './client/useDictionaryDynamic';\nexport { useI18n } from './client/useI18n';\nexport { useIntlayer } from './client/useIntlayer';\nexport { useLoadDynamic } from './client/useLoadDynamic';\nexport type { UseLocaleProps, UseLocaleResult } from './client/useLocale';\nexport { useLocale } from './client/useLocale';\nexport { useLocaleBase } from './client/useLocaleBase';\nexport {\n localeCookie,\n localeInStorage,\n setLocaleCookie,\n setLocaleInStorage,\n useLocaleCookie,\n useLocaleStorage,\n} from './client/useLocaleStorage';\nexport { usePathname } from './client/usePathname';\nexport { useRewriteURL } from './client/useRewriteURL';\nexport { getDictionary } from './getDictionary';\nexport { getIntlayer } from './getIntlayer';\nexport type { IntlayerNode } from './IntlayerNode';\n\nimport type {\n MarkdownProviderOptions as _MarkdownProviderOptions,\n MarkdownRendererProps as _MarkdownRendererProps,\n RenderMarkdownProps as _RenderMarkdownProps,\n} from './markdown';\nimport {\n MarkdownProvider as _MarkdownProvider,\n MarkdownRenderer as _MarkdownRenderer,\n renderMarkdown as _renderMarkdown,\n useMarkdownContext as _useMarkdownContext,\n useMarkdownRenderer as _useMarkdownRenderer,\n} from './markdown';\n/**\n * @deprecated import from react-intlayer/markdown instead\n */\nexport const MarkdownProvider = _MarkdownProvider;\n/**\n * @deprecated import from react-intlayer/markdown instead\n */\nexport const useMarkdownContext = _useMarkdownContext;\n/**\n * @deprecated import from react-intlayer/markdown instead\n */\nexport type MarkdownProviderOptions = _MarkdownProviderOptions;\n/**\n * @deprecated import from react-intlayer/markdown instead\n */\nexport const renderMarkdown = _renderMarkdown;\n/**\n * @deprecated import from react-intlayer/markdown instead\n */\nexport const useMarkdownRenderer = _useMarkdownRenderer;\n/**\n * @deprecated import from react-intlayer/markdown instead\n */\nexport const MarkdownRenderer = _MarkdownRenderer;\n/**\n * @deprecated import from react-intlayer/markdown instead\n */\nexport type RenderMarkdownProps = _RenderMarkdownProps;\n/**\n * @deprecated import from react-intlayer/markdown instead\n */\nexport type MarkdownRendererProps = _MarkdownRendererProps;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,MAAa,mBAAmBA;;;;AAIhC,MAAa,qBAAqBC;;;;AAQlC,MAAa,iBAAiBC;;;;AAI9B,MAAa,sBAAsBC;;;;AAInC,MAAa,mBAAmBC"}
|