react-intlayer 9.3.3 → 9.4.0-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cjs/analytics/useAnalytics.cjs +4 -4
- package/dist/cjs/analytics/useAnalytics.cjs.map +1 -1
- package/dist/cjs/server/IntlayerServerProvider.cjs +28 -0
- package/dist/cjs/server/IntlayerServerProvider.cjs.map +1 -1
- package/dist/cjs/server/index.cjs +5 -0
- package/dist/cjs/server/serverContext.cjs.map +1 -1
- package/dist/esm/analytics/useAnalytics.mjs +4 -4
- package/dist/esm/analytics/useAnalytics.mjs.map +1 -1
- package/dist/esm/server/IntlayerServerProvider.mjs +27 -1
- package/dist/esm/server/IntlayerServerProvider.mjs.map +1 -1
- package/dist/esm/server/index.mjs +3 -2
- package/dist/esm/server/serverContext.mjs.map +1 -1
- package/dist/types/analytics/useAnalytics.d.ts +4 -4
- package/dist/types/client/format/useCompact.d.ts +1 -2
- package/dist/types/client/format/useCompact.d.ts.map +1 -1
- package/dist/types/client/format/useCurrency.d.ts +1 -2
- package/dist/types/client/format/useCurrency.d.ts.map +1 -1
- package/dist/types/client/format/useList.d.ts +1 -2
- package/dist/types/client/format/useList.d.ts.map +1 -1
- package/dist/types/client/format/useNumber.d.ts +1 -2
- package/dist/types/client/format/useNumber.d.ts.map +1 -1
- package/dist/types/client/format/usePercentage.d.ts +1 -2
- package/dist/types/client/format/usePercentage.d.ts.map +1 -1
- package/dist/types/client/format/useRelativeTime.d.ts +1 -2
- package/dist/types/client/format/useRelativeTime.d.ts.map +1 -1
- package/dist/types/client/format/useUnit.d.ts +1 -2
- package/dist/types/client/format/useUnit.d.ts.map +1 -1
- package/dist/types/client/useI18n.d.ts +1 -1
- package/dist/types/client/useLocaleBase.d.ts +2 -3
- package/dist/types/client/useLocaleBase.d.ts.map +1 -1
- package/dist/types/client/useLocaleStorage.d.ts +3 -4
- package/dist/types/client/useLocaleStorage.d.ts.map +1 -1
- package/dist/types/server/IntlayerServerProvider.d.ts +26 -29
- package/dist/types/server/IntlayerServerProvider.d.ts.map +1 -1
- package/dist/types/server/index.d.ts +3 -2
- package/dist/types/server/serverContext.d.ts +1 -1
- package/dist/types/server/serverContext.d.ts.map +1 -1
- package/dist/types/server/useI18n.d.ts +1 -1
- package/package.json +8 -8
- package/dist/types/intlayer/dist/types/index.d.ts +0 -14
package/README.md
CHANGED
|
@@ -327,4 +327,4 @@ Contribute on [GitHub](https://github.com/aymericzip/intlayer), [GitLab](https:/
|
|
|
327
327
|
|
|
328
328
|
If you like Intlayer, give us a ⭐ on GitHub. It helps others discover the project! [See why GitHub Stars matter](https://github.com/aymericzip/intlayer/blob/main/CONTRIBUTING.md#why-github-stars-matter-).
|
|
329
329
|
|
|
330
|
-
[](https://star-history.dera.page/#aymericzip/intlayer&Date)
|
|
@@ -12,10 +12,10 @@ let _intlayer_analytics_isEnabled = require("@intlayer/analytics/isEnabled");
|
|
|
12
12
|
* and keeps it aware of the current locale.
|
|
13
13
|
*
|
|
14
14
|
* Mirrors {@link useEditor}: the module is loaded via a dynamic `import()` so it
|
|
15
|
-
* ships as its own async chunk, off the critical rendering path. Apps that
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* time.
|
|
15
|
+
* ships as its own async chunk, off the critical rendering path. Apps that opt
|
|
16
|
+
* out (`analytics.enabled !== true`), or that never install
|
|
17
|
+
* `@intlayer/analytics`, pay nothing — the whole body is guarded by
|
|
18
|
+
* `INTLAYER_ANALYTICS_ENABLED` and dead-code-eliminated at build time.
|
|
19
19
|
*/
|
|
20
20
|
const useAnalytics = () => {
|
|
21
21
|
const { locale } = (0, react.useContext)(require_client_IntlayerProvider.IntlayerClientContext) ?? {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAnalytics.cjs","names":["useContext","IntlayerClientContext","useRef","isEnabled"],"sources":["../../../src/analytics/useAnalytics.tsx"],"sourcesContent":["'use client';\n\nimport type { AnalyticsClient } from '@intlayer/analytics';\nimport { isEnabled } from '@intlayer/analytics/isEnabled';\nimport { useContext, useEffect, useRef } from 'react';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\nimport { setExposureSink } from './exposureSink';\n\n/**\n * Initializes the Intlayer analytics client singleton when analytics is enabled\n * and keeps it aware of the current locale.\n *\n * Mirrors {@link useEditor}: the module is loaded via a dynamic `import()` so it\n * ships as its own async chunk, off the critical rendering path. Apps that\n *
|
|
1
|
+
{"version":3,"file":"useAnalytics.cjs","names":["useContext","IntlayerClientContext","useRef","isEnabled"],"sources":["../../../src/analytics/useAnalytics.tsx"],"sourcesContent":["'use client';\n\nimport type { AnalyticsClient } from '@intlayer/analytics';\nimport { isEnabled } from '@intlayer/analytics/isEnabled';\nimport { useContext, useEffect, useRef } from 'react';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\nimport { setExposureSink } from './exposureSink';\n\n/**\n * Initializes the Intlayer analytics client singleton when analytics is enabled\n * and keeps it aware of the current locale.\n *\n * Mirrors {@link useEditor}: the module is loaded via a dynamic `import()` so it\n * ships as its own async chunk, off the critical rendering path. Apps that opt\n * out (`analytics.enabled !== true`), or that never install\n * `@intlayer/analytics`, pay nothing — the whole body is guarded by\n * `INTLAYER_ANALYTICS_ENABLED` and dead-code-eliminated at build time.\n */\nexport const useAnalytics = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n const clientRef = useRef<AnalyticsClient | null>(null);\n\n useEffect(() => {\n if (process.env.INTLAYER_ANALYTICS_ENABLED === 'false' || !isEnabled) {\n return;\n }\n\n let cancelled = false;\n // Tracks whether initAnalyticsClient actually ran, so cleanup never calls\n // stopAnalyticsClient for an init that was cancelled — that would decrement\n // the shared reference count once too many and could stop a client another\n // provider still uses.\n let initialized = false;\n\n import('@intlayer/analytics')\n .then(({ initAnalyticsClient, buildContentExposure }) => {\n if (cancelled) return;\n\n const client = initAnalyticsClient();\n initialized = true;\n clientRef.current = client;\n\n if (locale) client.setLocale(locale);\n client.trackPageView({ reason: 'initial' });\n\n // Route node-level exposures (from the interpreter plugins) into the\n // client. Serialization happens here, off the hot render path.\n setExposureSink((input) =>\n client.trackContentExposure(buildContentExposure(input))\n );\n })\n .catch(() => {\n /* chunk failed to load — analytics stays a no-op */\n });\n\n return () => {\n cancelled = true;\n clientRef.current = null;\n setExposureSink(null);\n import('@intlayer/analytics')\n .then(({ stopAnalyticsClient }) => {\n if (initialized) stopAnalyticsClient();\n })\n .catch(() => {});\n };\n // Run once on mount; locale updates are handled by the effect below.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n if (!locale || !clientRef.current) return;\n\n clientRef.current.setLocale(locale);\n clientRef.current.trackPageView({ reason: 'locale_change' });\n }, [locale]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,MAAa,qBAAqB;CAChC,MAAM,EAAE,eAAWA,kBAAWC,qDAAqB,KAAK,CAAC;CACzD,MAAM,gBAAYC,cAA+B,IAAI;CAErD,2BAAgB;EACd,IAAI,QAAQ,IAAI,+BAA+B,WAAW,CAACC,yCACzD;EAGF,IAAI,YAAY;EAKhB,IAAI,cAAc;EAElB,OAAO,sBAAsB,CAC1B,MAAM,EAAE,qBAAqB,2BAA2B;GACvD,IAAI,WAAW;GAEf,MAAM,SAAS,oBAAoB;GACnC,cAAc;GACd,UAAU,UAAU;GAEpB,IAAI,QAAQ,OAAO,UAAU,MAAM;GACnC,OAAO,cAAc,EAAE,QAAQ,UAAU,CAAC;GAI1C,gDAAiB,UACf,OAAO,qBAAqB,qBAAqB,KAAK,CAAC,CACzD;EACF,CAAC,CAAC,CACD,YAAY,CAEb,CAAC;EAEH,aAAa;GACX,YAAY;GACZ,UAAU,UAAU;GACpB,+CAAgB,IAAI;GACpB,OAAO,sBAAsB,CAC1B,MAAM,EAAE,0BAA0B;IACjC,IAAI,aAAa,oBAAoB;GACvC,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;EACnB;CAGF,GAAG,CAAC,CAAC;CAEL,2BAAgB;EACd,IAAI,CAAC,UAAU,CAAC,UAAU,SAAS;EAEnC,UAAU,QAAQ,UAAU,MAAM;EAClC,UAAU,QAAQ,cAAc,EAAE,QAAQ,gBAAgB,CAAC;CAC7D,GAAG,CAAC,MAAM,CAAC;AACb"}
|
|
@@ -25,6 +25,32 @@ const useIntlayer = () => require_server_serverContext.getServerContext(Intlayer
|
|
|
25
25
|
*/
|
|
26
26
|
const locale = require_server_serverContext.getServerContext(IntlayerServerContext);
|
|
27
27
|
/**
|
|
28
|
+
* Seeds the request-scoped server context locale imperatively — the equivalent
|
|
29
|
+
* of mounting {@link IntlayerServerProvider} without wrapping the tree.
|
|
30
|
+
*
|
|
31
|
+
* Useful in pages that must stay statically rendered while no ambient
|
|
32
|
+
* request-derived locale source is static-safe (Next.js < 16):
|
|
33
|
+
*
|
|
34
|
+
* ```tsx
|
|
35
|
+
* const Page = async ({ params }) => {
|
|
36
|
+
* const { locale } = await params;
|
|
37
|
+
* setLocale(locale);
|
|
38
|
+
* return <PageContent />;
|
|
39
|
+
* };
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
const setLocale = (locale) => {
|
|
43
|
+
IntlayerServerContext._storage().value = locale;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Seeds the request-scoped ambient variant imperatively — the equivalent of
|
|
47
|
+
* the `variant` prop of {@link IntlayerServerProvider} without wrapping the
|
|
48
|
+
* tree. See that prop for the accepted shapes.
|
|
49
|
+
*/
|
|
50
|
+
const setVariant = (variant) => {
|
|
51
|
+
IntlayerServerVariantContext._storage().value = variant;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
28
54
|
* Provider that store the current locale on the server side
|
|
29
55
|
*/
|
|
30
56
|
const IntlayerServerProvider = ({ children, locale = defaultLocale, variant }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IntlayerServerContext.Provider, {
|
|
@@ -40,5 +66,7 @@ exports.IntlayerServerContext = IntlayerServerContext;
|
|
|
40
66
|
exports.IntlayerServerProvider = IntlayerServerProvider;
|
|
41
67
|
exports.IntlayerServerVariantContext = IntlayerServerVariantContext;
|
|
42
68
|
exports.locale = locale;
|
|
69
|
+
exports.setLocale = setLocale;
|
|
70
|
+
exports.setVariant = setVariant;
|
|
43
71
|
exports.useIntlayer = useIntlayer;
|
|
44
72
|
//# sourceMappingURL=IntlayerServerProvider.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerServerProvider.cjs","names":["internationalization","createServerContext","getServerContext"],"sources":["../../../src/server/IntlayerServerProvider.tsx"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type {\n LocalesValues,\n ProviderVariant,\n} from '@intlayer/types/module_augmentation';\n\nimport type { FC, PropsWithChildren } from 'react';\nimport { createServerContext, getServerContext } from './serverContext';\n\nconst { defaultLocale } = internationalization ?? {};\n\n/**\n * Context that store the current locale on the server side\n */\nexport const IntlayerServerContext =\n createServerContext<LocalesValues>(defaultLocale);\n\n/**\n * Context that stores the ambient variant on the server side.\n *\n * Kept separate from {@link IntlayerServerContext} so the locale context keeps\n * its plain `LocalesValues` shape for the packages already reading it.\n */\nexport const IntlayerServerVariantContext =\n createServerContext<ProviderVariant>(undefined);\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayer = () => getServerContext(IntlayerServerContext);\n\n/**\n * Get the current locale\n */\nexport const locale = getServerContext(IntlayerServerContext);\n\nexport type IntlayerServerProviderProps = PropsWithChildren & {\n locale?: LocalesValues;\n /**\n * Ambient variant applied to every dictionary read below this provider — for\n * a dimension resolved once per request (tenant, school type, plan tier…).\n *\n * Accepts a name (`'school1'`), an ordered preference chain\n * (`['school1', 'default']`), or a per-key map\n * (`{ key1: 'school1', default: 'base' }`). A call-site selector wins.\n */\n variant?: ProviderVariant;\n};\n\n/**\n * Provider that store the current locale on the server side\n */\nexport const IntlayerServerProvider: FC<IntlayerServerProviderProps> = ({\n children,\n locale = defaultLocale,\n variant,\n}) => (\n <IntlayerServerContext.Provider value={locale}>\n <IntlayerServerVariantContext.Provider value={variant}>\n {children}\n </IntlayerServerVariantContext.Provider>\n </IntlayerServerContext.Provider>\n);\n"],"mappings":";;;;;;AASA,MAAM,EAAE,kBAAkBA,+CAAwB,CAAC;;;;AAKnD,MAAa,wBACXC,iDAAmC,aAAa;;;;;;;AAQlD,MAAa,+BACXA,iDAAqC,MAAS;;;;AAKhD,MAAa,oBAAoBC,8CAAiB,qBAAqB;;;;AAKvE,MAAa,SAASA,8CAAiB,qBAAqB;;;;
|
|
1
|
+
{"version":3,"file":"IntlayerServerProvider.cjs","names":["internationalization","createServerContext","getServerContext"],"sources":["../../../src/server/IntlayerServerProvider.tsx"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type {\n LocalesValues,\n ProviderVariant,\n} from '@intlayer/types/module_augmentation';\n\nimport type { FC, PropsWithChildren } from 'react';\nimport { createServerContext, getServerContext } from './serverContext';\n\nconst { defaultLocale } = internationalization ?? {};\n\n/**\n * Context that store the current locale on the server side\n */\nexport const IntlayerServerContext =\n createServerContext<LocalesValues>(defaultLocale);\n\n/**\n * Context that stores the ambient variant on the server side.\n *\n * Kept separate from {@link IntlayerServerContext} so the locale context keeps\n * its plain `LocalesValues` shape for the packages already reading it.\n */\nexport const IntlayerServerVariantContext =\n createServerContext<ProviderVariant>(undefined);\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayer = () => getServerContext(IntlayerServerContext);\n\n/**\n * Get the current locale\n */\nexport const locale = getServerContext(IntlayerServerContext);\n\n/**\n * Seeds the request-scoped server context locale imperatively — the equivalent\n * of mounting {@link IntlayerServerProvider} without wrapping the tree.\n *\n * Useful in pages that must stay statically rendered while no ambient\n * request-derived locale source is static-safe (Next.js < 16):\n *\n * ```tsx\n * const Page = async ({ params }) => {\n * const { locale } = await params;\n * setLocale(locale);\n * return <PageContent />;\n * };\n * ```\n */\nexport const setLocale = (locale: LocalesValues): void => {\n IntlayerServerContext._storage().value = locale;\n};\n\n/**\n * Seeds the request-scoped ambient variant imperatively — the equivalent of\n * the `variant` prop of {@link IntlayerServerProvider} without wrapping the\n * tree. See that prop for the accepted shapes.\n */\nexport const setVariant = (variant: ProviderVariant): void => {\n IntlayerServerVariantContext._storage().value = variant;\n};\n\nexport type IntlayerServerProviderProps = PropsWithChildren & {\n locale?: LocalesValues;\n /**\n * Ambient variant applied to every dictionary read below this provider — for\n * a dimension resolved once per request (tenant, school type, plan tier…).\n *\n * Accepts a name (`'school1'`), an ordered preference chain\n * (`['school1', 'default']`), or a per-key map\n * (`{ key1: 'school1', default: 'base' }`). A call-site selector wins.\n */\n variant?: ProviderVariant;\n};\n\n/**\n * Provider that store the current locale on the server side\n */\nexport const IntlayerServerProvider: FC<IntlayerServerProviderProps> = ({\n children,\n locale = defaultLocale,\n variant,\n}) => (\n <IntlayerServerContext.Provider value={locale}>\n <IntlayerServerVariantContext.Provider value={variant}>\n {children}\n </IntlayerServerVariantContext.Provider>\n </IntlayerServerContext.Provider>\n);\n"],"mappings":";;;;;;AASA,MAAM,EAAE,kBAAkBA,+CAAwB,CAAC;;;;AAKnD,MAAa,wBACXC,iDAAmC,aAAa;;;;;;;AAQlD,MAAa,+BACXA,iDAAqC,MAAS;;;;AAKhD,MAAa,oBAAoBC,8CAAiB,qBAAqB;;;;AAKvE,MAAa,SAASA,8CAAiB,qBAAqB;;;;;;;;;;;;;;;;AAiB5D,MAAa,aAAa,WAAgC;CACxD,sBAAsB,SAAS,CAAC,CAAC,QAAQ;AAC3C;;;;;;AAOA,MAAa,cAAc,YAAmC;CAC5D,6BAA6B,SAAS,CAAC,CAAC,QAAQ;AAClD;;;;AAkBA,MAAa,0BAA2D,EACtE,UACA,SAAS,eACT,cAEA,2CAAC,sBAAsB,UAAvB;CAAgC,OAAO;WACrC,2CAAC,6BAA6B,UAA9B;EAAuC,OAAO;EAC3C;CACoC;AACT"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_server_serverContext = require('./serverContext.cjs');
|
|
2
3
|
const require_server_IntlayerServerProvider = require('./IntlayerServerProvider.cjs');
|
|
3
4
|
const require_server_t = require('./t.cjs');
|
|
4
5
|
const require_server_useI18n = require('./useI18n.cjs');
|
|
@@ -12,7 +13,11 @@ const require_server_format_useIntl = require('./format/useIntl.cjs');
|
|
|
12
13
|
|
|
13
14
|
exports.IntlayerServer = require_server_IntlayerServerProvider.IntlayerServerContext;
|
|
14
15
|
exports.IntlayerServerProvider = require_server_IntlayerServerProvider.IntlayerServerProvider;
|
|
16
|
+
exports.IntlayerServerVariantContext = require_server_IntlayerServerProvider.IntlayerServerVariantContext;
|
|
17
|
+
exports.getServerContext = require_server_serverContext.getServerContext;
|
|
15
18
|
exports.locale = require_server_IntlayerServerProvider.locale;
|
|
19
|
+
exports.setLocale = require_server_IntlayerServerProvider.setLocale;
|
|
20
|
+
exports.setVariant = require_server_IntlayerServerProvider.setVariant;
|
|
16
21
|
exports.t = require_server_t.t;
|
|
17
22
|
exports.useDictionary = require_server_useDictionary.useDictionary;
|
|
18
23
|
exports.useDictionaryAsync = require_server_useDictionaryAsync.useDictionaryAsync;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverContext.cjs","names":[],"sources":["../../../src/server/serverContext.tsx"],"sourcesContent":["/**\n * Creates a new datastore for a given server context.\n * Attempts to closely mimic the `createContext` API.\n *\n * @example\n * const IntlayerServer = createServerContext<string | null>(null);\n *\n * <IntlayerServer value={locale}>\n * {children}\n * </IntlayerServer>\n */\nimport react, { type FC, type PropsWithChildren, type ReactNode } from 'react';\n\ntype CacheType<T> = () => { value: T | undefined };\n\nconst cacheFallback = () => () => ({ value: undefined });\n\nexport const createServerContext = <T,>(defaultValue?: T): ServerContext<T> => {\n throwInClient();\n\n /** @ts-ignore remove error Property 'cache' does not exist on type 'typeof React'. */\n const cache = react.cache<CacheType<T>> ?? cacheFallback;\n\n const getCache = cache(() => ({\n value: undefined,\n }));\n\n const Provider: FC<PropsWithChildren<{ value?: T }>> = ({\n children,\n value,\n }) => {\n getCache().value = value;\n return children;\n };\n\n const ServerContext = Provider as ServerContext<T>;\n ServerContext.Provider = Provider;\n ServerContext.Consumer = (props) => {\n const store = getCache();\n return props.children(store ? store.value : defaultValue);\n };\n ServerContext._storage = getCache;\n ServerContext._defaultValue = defaultValue;\n\n return ServerContext;\n};\n\n/**\n * Fetches a value present in a given server context.\n * Attempts to closely mimic the `useContext` API.\n *\n * @example\n * getServerContext(IntlayerServer);\n */\nexport const getServerContext = <T,>({\n _storage,\n _defaultValue,\n}: ServerContext<T>) => {\n // throwInClient();\n const store = _storage();\n if (!store) return _defaultValue;\n return store.value;\n};\n\
|
|
1
|
+
{"version":3,"file":"serverContext.cjs","names":[],"sources":["../../../src/server/serverContext.tsx"],"sourcesContent":["/**\n * Creates a new datastore for a given server context.\n * Attempts to closely mimic the `createContext` API.\n *\n * @example\n * const IntlayerServer = createServerContext<string | null>(null);\n *\n * <IntlayerServer value={locale}>\n * {children}\n * </IntlayerServer>\n */\nimport react, { type FC, type PropsWithChildren, type ReactNode } from 'react';\n\ntype CacheType<T> = () => { value: T | undefined };\n\nconst cacheFallback = () => () => ({ value: undefined });\n\nexport const createServerContext = <T,>(defaultValue?: T): ServerContext<T> => {\n throwInClient();\n\n /** @ts-ignore remove error Property 'cache' does not exist on type 'typeof React'. */\n const cache = react.cache<CacheType<T>> ?? cacheFallback;\n\n const getCache = cache(() => ({\n value: undefined,\n }));\n\n const Provider: FC<PropsWithChildren<{ value?: T }>> = ({\n children,\n value,\n }) => {\n getCache().value = value;\n return children;\n };\n\n const ServerContext = Provider as ServerContext<T>;\n ServerContext.Provider = Provider;\n ServerContext.Consumer = (props) => {\n const store = getCache();\n return props.children(store ? store.value : defaultValue);\n };\n ServerContext._storage = getCache;\n ServerContext._defaultValue = defaultValue;\n\n return ServerContext;\n};\n\n/**\n * Fetches a value present in a given server context.\n * Attempts to closely mimic the `useContext` API.\n *\n * @example\n * getServerContext(IntlayerServer);\n */\nexport const getServerContext = <T,>({\n _storage,\n _defaultValue,\n}: ServerContext<T>) => {\n // throwInClient();\n const store = _storage();\n if (!store) return _defaultValue;\n return store.value;\n};\n\nexport type ServerContext<T> = FC<PropsWithChildren<{ value?: T }>> & {\n Provider: FC<PropsWithChildren<{ value?: T }>>;\n Consumer: FC<\n PropsWithChildren<{ children: (context: T | undefined) => ReactNode }>\n >;\n _storage: () => { value: T | undefined };\n _defaultValue: T | undefined;\n};\n\n/**\n * Throws if called within a client component environment.\n * Useful to help prevent mistakes.\n */\nconst throwInClient = (): undefined | never => {\n // If window.document is defined we're in a client component\n if (typeof window !== 'undefined') {\n throw new Error(`createServerContext only works in Server Components`);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAeA,MAAM,6BAA6B,EAAE,OAAO,OAAU;AAEtD,MAAa,uBAA2B,iBAAuC;CAC7E,cAAc;CAKd,MAAM,YAFQ,cAAM,SAAuB,cAErB,QAAQ,EAC5B,OAAO,OACT,EAAE;CAEF,MAAM,YAAkD,EACtD,UACA,YACI;EACJ,SAAS,CAAC,CAAC,QAAQ;EACnB,OAAO;CACT;CAEA,MAAM,gBAAgB;CACtB,cAAc,WAAW;CACzB,cAAc,YAAY,UAAU;EAClC,MAAM,QAAQ,SAAS;EACvB,OAAO,MAAM,SAAS,QAAQ,MAAM,QAAQ,YAAY;CAC1D;CACA,cAAc,WAAW;CACzB,cAAc,gBAAgB;CAE9B,OAAO;AACT;;;;;;;;AASA,MAAa,oBAAwB,EACnC,UACA,oBACsB;CAEtB,MAAM,QAAQ,SAAS;CACvB,IAAI,CAAC,OAAO,OAAO;CACnB,OAAO,MAAM;AACf;;;;;AAeA,MAAM,sBAAyC;CAE7C,IAAI,OAAO,WAAW,aACpB,MAAM,IAAI,MAAM,qDAAqD;AAEzE"}
|
|
@@ -11,10 +11,10 @@ import { isEnabled } from "@intlayer/analytics/isEnabled";
|
|
|
11
11
|
* and keeps it aware of the current locale.
|
|
12
12
|
*
|
|
13
13
|
* Mirrors {@link useEditor}: the module is loaded via a dynamic `import()` so it
|
|
14
|
-
* ships as its own async chunk, off the critical rendering path. Apps that
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* time.
|
|
14
|
+
* ships as its own async chunk, off the critical rendering path. Apps that opt
|
|
15
|
+
* out (`analytics.enabled !== true`), or that never install
|
|
16
|
+
* `@intlayer/analytics`, pay nothing — the whole body is guarded by
|
|
17
|
+
* `INTLAYER_ANALYTICS_ENABLED` and dead-code-eliminated at build time.
|
|
18
18
|
*/
|
|
19
19
|
const useAnalytics = () => {
|
|
20
20
|
const { locale } = useContext(IntlayerClientContext) ?? {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAnalytics.mjs","names":[],"sources":["../../../src/analytics/useAnalytics.tsx"],"sourcesContent":["'use client';\n\nimport type { AnalyticsClient } from '@intlayer/analytics';\nimport { isEnabled } from '@intlayer/analytics/isEnabled';\nimport { useContext, useEffect, useRef } from 'react';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\nimport { setExposureSink } from './exposureSink';\n\n/**\n * Initializes the Intlayer analytics client singleton when analytics is enabled\n * and keeps it aware of the current locale.\n *\n * Mirrors {@link useEditor}: the module is loaded via a dynamic `import()` so it\n * ships as its own async chunk, off the critical rendering path. Apps that\n *
|
|
1
|
+
{"version":3,"file":"useAnalytics.mjs","names":[],"sources":["../../../src/analytics/useAnalytics.tsx"],"sourcesContent":["'use client';\n\nimport type { AnalyticsClient } from '@intlayer/analytics';\nimport { isEnabled } from '@intlayer/analytics/isEnabled';\nimport { useContext, useEffect, useRef } from 'react';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\nimport { setExposureSink } from './exposureSink';\n\n/**\n * Initializes the Intlayer analytics client singleton when analytics is enabled\n * and keeps it aware of the current locale.\n *\n * Mirrors {@link useEditor}: the module is loaded via a dynamic `import()` so it\n * ships as its own async chunk, off the critical rendering path. Apps that opt\n * out (`analytics.enabled !== true`), or that never install\n * `@intlayer/analytics`, pay nothing — the whole body is guarded by\n * `INTLAYER_ANALYTICS_ENABLED` and dead-code-eliminated at build time.\n */\nexport const useAnalytics = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n const clientRef = useRef<AnalyticsClient | null>(null);\n\n useEffect(() => {\n if (process.env.INTLAYER_ANALYTICS_ENABLED === 'false' || !isEnabled) {\n return;\n }\n\n let cancelled = false;\n // Tracks whether initAnalyticsClient actually ran, so cleanup never calls\n // stopAnalyticsClient for an init that was cancelled — that would decrement\n // the shared reference count once too many and could stop a client another\n // provider still uses.\n let initialized = false;\n\n import('@intlayer/analytics')\n .then(({ initAnalyticsClient, buildContentExposure }) => {\n if (cancelled) return;\n\n const client = initAnalyticsClient();\n initialized = true;\n clientRef.current = client;\n\n if (locale) client.setLocale(locale);\n client.trackPageView({ reason: 'initial' });\n\n // Route node-level exposures (from the interpreter plugins) into the\n // client. Serialization happens here, off the hot render path.\n setExposureSink((input) =>\n client.trackContentExposure(buildContentExposure(input))\n );\n })\n .catch(() => {\n /* chunk failed to load — analytics stays a no-op */\n });\n\n return () => {\n cancelled = true;\n clientRef.current = null;\n setExposureSink(null);\n import('@intlayer/analytics')\n .then(({ stopAnalyticsClient }) => {\n if (initialized) stopAnalyticsClient();\n })\n .catch(() => {});\n };\n // Run once on mount; locale updates are handled by the effect below.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n if (!locale || !clientRef.current) return;\n\n clientRef.current.setLocale(locale);\n clientRef.current.trackPageView({ reason: 'locale_change' });\n }, [locale]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,MAAa,qBAAqB;CAChC,MAAM,EAAE,WAAW,WAAW,qBAAqB,KAAK,CAAC;CACzD,MAAM,YAAY,OAA+B,IAAI;CAErD,gBAAgB;EACd,IAAI,QAAQ,IAAI,+BAA+B,WAAW,CAAC,WACzD;EAGF,IAAI,YAAY;EAKhB,IAAI,cAAc;EAElB,OAAO,sBAAsB,CAC1B,MAAM,EAAE,qBAAqB,2BAA2B;GACvD,IAAI,WAAW;GAEf,MAAM,SAAS,oBAAoB;GACnC,cAAc;GACd,UAAU,UAAU;GAEpB,IAAI,QAAQ,OAAO,UAAU,MAAM;GACnC,OAAO,cAAc,EAAE,QAAQ,UAAU,CAAC;GAI1C,iBAAiB,UACf,OAAO,qBAAqB,qBAAqB,KAAK,CAAC,CACzD;EACF,CAAC,CAAC,CACD,YAAY,CAEb,CAAC;EAEH,aAAa;GACX,YAAY;GACZ,UAAU,UAAU;GACpB,gBAAgB,IAAI;GACpB,OAAO,sBAAsB,CAC1B,MAAM,EAAE,0BAA0B;IACjC,IAAI,aAAa,oBAAoB;GACvC,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;EACnB;CAGF,GAAG,CAAC,CAAC;CAEL,gBAAgB;EACd,IAAI,CAAC,UAAU,CAAC,UAAU,SAAS;EAEnC,UAAU,QAAQ,UAAU,MAAM;EAClC,UAAU,QAAQ,cAAc,EAAE,QAAQ,gBAAgB,CAAC;CAC7D,GAAG,CAAC,MAAM,CAAC;AACb"}
|
|
@@ -24,6 +24,32 @@ const useIntlayer = () => getServerContext(IntlayerServerContext);
|
|
|
24
24
|
*/
|
|
25
25
|
const locale = getServerContext(IntlayerServerContext);
|
|
26
26
|
/**
|
|
27
|
+
* Seeds the request-scoped server context locale imperatively — the equivalent
|
|
28
|
+
* of mounting {@link IntlayerServerProvider} without wrapping the tree.
|
|
29
|
+
*
|
|
30
|
+
* Useful in pages that must stay statically rendered while no ambient
|
|
31
|
+
* request-derived locale source is static-safe (Next.js < 16):
|
|
32
|
+
*
|
|
33
|
+
* ```tsx
|
|
34
|
+
* const Page = async ({ params }) => {
|
|
35
|
+
* const { locale } = await params;
|
|
36
|
+
* setLocale(locale);
|
|
37
|
+
* return <PageContent />;
|
|
38
|
+
* };
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
const setLocale = (locale) => {
|
|
42
|
+
IntlayerServerContext._storage().value = locale;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Seeds the request-scoped ambient variant imperatively — the equivalent of
|
|
46
|
+
* the `variant` prop of {@link IntlayerServerProvider} without wrapping the
|
|
47
|
+
* tree. See that prop for the accepted shapes.
|
|
48
|
+
*/
|
|
49
|
+
const setVariant = (variant) => {
|
|
50
|
+
IntlayerServerVariantContext._storage().value = variant;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
27
53
|
* Provider that store the current locale on the server side
|
|
28
54
|
*/
|
|
29
55
|
const IntlayerServerProvider = ({ children, locale = defaultLocale, variant }) => /* @__PURE__ */ jsx(IntlayerServerContext.Provider, {
|
|
@@ -35,5 +61,5 @@ const IntlayerServerProvider = ({ children, locale = defaultLocale, variant }) =
|
|
|
35
61
|
});
|
|
36
62
|
|
|
37
63
|
//#endregion
|
|
38
|
-
export { IntlayerServerContext, IntlayerServerProvider, IntlayerServerVariantContext, locale, useIntlayer };
|
|
64
|
+
export { IntlayerServerContext, IntlayerServerProvider, IntlayerServerVariantContext, locale, setLocale, setVariant, useIntlayer };
|
|
39
65
|
//# sourceMappingURL=IntlayerServerProvider.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerServerProvider.mjs","names":[],"sources":["../../../src/server/IntlayerServerProvider.tsx"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type {\n LocalesValues,\n ProviderVariant,\n} from '@intlayer/types/module_augmentation';\n\nimport type { FC, PropsWithChildren } from 'react';\nimport { createServerContext, getServerContext } from './serverContext';\n\nconst { defaultLocale } = internationalization ?? {};\n\n/**\n * Context that store the current locale on the server side\n */\nexport const IntlayerServerContext =\n createServerContext<LocalesValues>(defaultLocale);\n\n/**\n * Context that stores the ambient variant on the server side.\n *\n * Kept separate from {@link IntlayerServerContext} so the locale context keeps\n * its plain `LocalesValues` shape for the packages already reading it.\n */\nexport const IntlayerServerVariantContext =\n createServerContext<ProviderVariant>(undefined);\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayer = () => getServerContext(IntlayerServerContext);\n\n/**\n * Get the current locale\n */\nexport const locale = getServerContext(IntlayerServerContext);\n\nexport type IntlayerServerProviderProps = PropsWithChildren & {\n locale?: LocalesValues;\n /**\n * Ambient variant applied to every dictionary read below this provider — for\n * a dimension resolved once per request (tenant, school type, plan tier…).\n *\n * Accepts a name (`'school1'`), an ordered preference chain\n * (`['school1', 'default']`), or a per-key map\n * (`{ key1: 'school1', default: 'base' }`). A call-site selector wins.\n */\n variant?: ProviderVariant;\n};\n\n/**\n * Provider that store the current locale on the server side\n */\nexport const IntlayerServerProvider: FC<IntlayerServerProviderProps> = ({\n children,\n locale = defaultLocale,\n variant,\n}) => (\n <IntlayerServerContext.Provider value={locale}>\n <IntlayerServerVariantContext.Provider value={variant}>\n {children}\n </IntlayerServerVariantContext.Provider>\n </IntlayerServerContext.Provider>\n);\n"],"mappings":";;;;;AASA,MAAM,EAAE,kBAAkB,wBAAwB,CAAC;;;;AAKnD,MAAa,wBACX,oBAAmC,aAAa;;;;;;;AAQlD,MAAa,+BACX,oBAAqC,MAAS;;;;AAKhD,MAAa,oBAAoB,iBAAiB,qBAAqB;;;;AAKvE,MAAa,SAAS,iBAAiB,qBAAqB;;;;
|
|
1
|
+
{"version":3,"file":"IntlayerServerProvider.mjs","names":[],"sources":["../../../src/server/IntlayerServerProvider.tsx"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type {\n LocalesValues,\n ProviderVariant,\n} from '@intlayer/types/module_augmentation';\n\nimport type { FC, PropsWithChildren } from 'react';\nimport { createServerContext, getServerContext } from './serverContext';\n\nconst { defaultLocale } = internationalization ?? {};\n\n/**\n * Context that store the current locale on the server side\n */\nexport const IntlayerServerContext =\n createServerContext<LocalesValues>(defaultLocale);\n\n/**\n * Context that stores the ambient variant on the server side.\n *\n * Kept separate from {@link IntlayerServerContext} so the locale context keeps\n * its plain `LocalesValues` shape for the packages already reading it.\n */\nexport const IntlayerServerVariantContext =\n createServerContext<ProviderVariant>(undefined);\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayer = () => getServerContext(IntlayerServerContext);\n\n/**\n * Get the current locale\n */\nexport const locale = getServerContext(IntlayerServerContext);\n\n/**\n * Seeds the request-scoped server context locale imperatively — the equivalent\n * of mounting {@link IntlayerServerProvider} without wrapping the tree.\n *\n * Useful in pages that must stay statically rendered while no ambient\n * request-derived locale source is static-safe (Next.js < 16):\n *\n * ```tsx\n * const Page = async ({ params }) => {\n * const { locale } = await params;\n * setLocale(locale);\n * return <PageContent />;\n * };\n * ```\n */\nexport const setLocale = (locale: LocalesValues): void => {\n IntlayerServerContext._storage().value = locale;\n};\n\n/**\n * Seeds the request-scoped ambient variant imperatively — the equivalent of\n * the `variant` prop of {@link IntlayerServerProvider} without wrapping the\n * tree. See that prop for the accepted shapes.\n */\nexport const setVariant = (variant: ProviderVariant): void => {\n IntlayerServerVariantContext._storage().value = variant;\n};\n\nexport type IntlayerServerProviderProps = PropsWithChildren & {\n locale?: LocalesValues;\n /**\n * Ambient variant applied to every dictionary read below this provider — for\n * a dimension resolved once per request (tenant, school type, plan tier…).\n *\n * Accepts a name (`'school1'`), an ordered preference chain\n * (`['school1', 'default']`), or a per-key map\n * (`{ key1: 'school1', default: 'base' }`). A call-site selector wins.\n */\n variant?: ProviderVariant;\n};\n\n/**\n * Provider that store the current locale on the server side\n */\nexport const IntlayerServerProvider: FC<IntlayerServerProviderProps> = ({\n children,\n locale = defaultLocale,\n variant,\n}) => (\n <IntlayerServerContext.Provider value={locale}>\n <IntlayerServerVariantContext.Provider value={variant}>\n {children}\n </IntlayerServerVariantContext.Provider>\n </IntlayerServerContext.Provider>\n);\n"],"mappings":";;;;;AASA,MAAM,EAAE,kBAAkB,wBAAwB,CAAC;;;;AAKnD,MAAa,wBACX,oBAAmC,aAAa;;;;;;;AAQlD,MAAa,+BACX,oBAAqC,MAAS;;;;AAKhD,MAAa,oBAAoB,iBAAiB,qBAAqB;;;;AAKvE,MAAa,SAAS,iBAAiB,qBAAqB;;;;;;;;;;;;;;;;AAiB5D,MAAa,aAAa,WAAgC;CACxD,sBAAsB,SAAS,CAAC,CAAC,QAAQ;AAC3C;;;;;;AAOA,MAAa,cAAc,YAAmC;CAC5D,6BAA6B,SAAS,CAAC,CAAC,QAAQ;AAClD;;;;AAkBA,MAAa,0BAA2D,EACtE,UACA,SAAS,eACT,cAEA,oBAAC,sBAAsB,UAAvB;CAAgC,OAAO;WACrC,oBAAC,6BAA6B,UAA9B;EAAuC,OAAO;EAC3C;CACoC;AACT"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getServerContext } from "./serverContext.mjs";
|
|
2
|
+
import { IntlayerServerContext, IntlayerServerProvider, IntlayerServerVariantContext, locale, setLocale, setVariant } from "./IntlayerServerProvider.mjs";
|
|
2
3
|
import { t } from "./t.mjs";
|
|
3
4
|
import { useI18n } from "./useI18n.mjs";
|
|
4
5
|
import { useIntlayer } from "./useIntlayer.mjs";
|
|
@@ -9,4 +10,4 @@ import { useLoadDynamic } from "./useLoadDynamic.mjs";
|
|
|
9
10
|
import { useDictionaryDynamic } from "./useDictionaryDynamic.mjs";
|
|
10
11
|
import { useIntl } from "./format/useIntl.mjs";
|
|
11
12
|
|
|
12
|
-
export { IntlayerServerContext as IntlayerServer, IntlayerServerProvider, locale, t, useDictionary, useDictionaryAsync, useDictionaryDynamic, useI18n, useIntl, useIntlayer, useLoadDynamic, useLocale };
|
|
13
|
+
export { IntlayerServerContext as IntlayerServer, IntlayerServerProvider, IntlayerServerVariantContext, getServerContext, locale, setLocale, setVariant, t, useDictionary, useDictionaryAsync, useDictionaryDynamic, useI18n, useIntl, useIntlayer, useLoadDynamic, useLocale };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverContext.mjs","names":[],"sources":["../../../src/server/serverContext.tsx"],"sourcesContent":["/**\n * Creates a new datastore for a given server context.\n * Attempts to closely mimic the `createContext` API.\n *\n * @example\n * const IntlayerServer = createServerContext<string | null>(null);\n *\n * <IntlayerServer value={locale}>\n * {children}\n * </IntlayerServer>\n */\nimport react, { type FC, type PropsWithChildren, type ReactNode } from 'react';\n\ntype CacheType<T> = () => { value: T | undefined };\n\nconst cacheFallback = () => () => ({ value: undefined });\n\nexport const createServerContext = <T,>(defaultValue?: T): ServerContext<T> => {\n throwInClient();\n\n /** @ts-ignore remove error Property 'cache' does not exist on type 'typeof React'. */\n const cache = react.cache<CacheType<T>> ?? cacheFallback;\n\n const getCache = cache(() => ({\n value: undefined,\n }));\n\n const Provider: FC<PropsWithChildren<{ value?: T }>> = ({\n children,\n value,\n }) => {\n getCache().value = value;\n return children;\n };\n\n const ServerContext = Provider as ServerContext<T>;\n ServerContext.Provider = Provider;\n ServerContext.Consumer = (props) => {\n const store = getCache();\n return props.children(store ? store.value : defaultValue);\n };\n ServerContext._storage = getCache;\n ServerContext._defaultValue = defaultValue;\n\n return ServerContext;\n};\n\n/**\n * Fetches a value present in a given server context.\n * Attempts to closely mimic the `useContext` API.\n *\n * @example\n * getServerContext(IntlayerServer);\n */\nexport const getServerContext = <T,>({\n _storage,\n _defaultValue,\n}: ServerContext<T>) => {\n // throwInClient();\n const store = _storage();\n if (!store) return _defaultValue;\n return store.value;\n};\n\
|
|
1
|
+
{"version":3,"file":"serverContext.mjs","names":[],"sources":["../../../src/server/serverContext.tsx"],"sourcesContent":["/**\n * Creates a new datastore for a given server context.\n * Attempts to closely mimic the `createContext` API.\n *\n * @example\n * const IntlayerServer = createServerContext<string | null>(null);\n *\n * <IntlayerServer value={locale}>\n * {children}\n * </IntlayerServer>\n */\nimport react, { type FC, type PropsWithChildren, type ReactNode } from 'react';\n\ntype CacheType<T> = () => { value: T | undefined };\n\nconst cacheFallback = () => () => ({ value: undefined });\n\nexport const createServerContext = <T,>(defaultValue?: T): ServerContext<T> => {\n throwInClient();\n\n /** @ts-ignore remove error Property 'cache' does not exist on type 'typeof React'. */\n const cache = react.cache<CacheType<T>> ?? cacheFallback;\n\n const getCache = cache(() => ({\n value: undefined,\n }));\n\n const Provider: FC<PropsWithChildren<{ value?: T }>> = ({\n children,\n value,\n }) => {\n getCache().value = value;\n return children;\n };\n\n const ServerContext = Provider as ServerContext<T>;\n ServerContext.Provider = Provider;\n ServerContext.Consumer = (props) => {\n const store = getCache();\n return props.children(store ? store.value : defaultValue);\n };\n ServerContext._storage = getCache;\n ServerContext._defaultValue = defaultValue;\n\n return ServerContext;\n};\n\n/**\n * Fetches a value present in a given server context.\n * Attempts to closely mimic the `useContext` API.\n *\n * @example\n * getServerContext(IntlayerServer);\n */\nexport const getServerContext = <T,>({\n _storage,\n _defaultValue,\n}: ServerContext<T>) => {\n // throwInClient();\n const store = _storage();\n if (!store) return _defaultValue;\n return store.value;\n};\n\nexport type ServerContext<T> = FC<PropsWithChildren<{ value?: T }>> & {\n Provider: FC<PropsWithChildren<{ value?: T }>>;\n Consumer: FC<\n PropsWithChildren<{ children: (context: T | undefined) => ReactNode }>\n >;\n _storage: () => { value: T | undefined };\n _defaultValue: T | undefined;\n};\n\n/**\n * Throws if called within a client component environment.\n * Useful to help prevent mistakes.\n */\nconst throwInClient = (): undefined | never => {\n // If window.document is defined we're in a client component\n if (typeof window !== 'undefined') {\n throw new Error(`createServerContext only works in Server Components`);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAM,6BAA6B,EAAE,OAAO,OAAU;AAEtD,MAAa,uBAA2B,iBAAuC;CAC7E,cAAc;CAKd,MAAM,YAFQ,MAAM,SAAuB,cAErB,QAAQ,EAC5B,OAAO,OACT,EAAE;CAEF,MAAM,YAAkD,EACtD,UACA,YACI;EACJ,SAAS,CAAC,CAAC,QAAQ;EACnB,OAAO;CACT;CAEA,MAAM,gBAAgB;CACtB,cAAc,WAAW;CACzB,cAAc,YAAY,UAAU;EAClC,MAAM,QAAQ,SAAS;EACvB,OAAO,MAAM,SAAS,QAAQ,MAAM,QAAQ,YAAY;CAC1D;CACA,cAAc,WAAW;CACzB,cAAc,gBAAgB;CAE9B,OAAO;AACT;;;;;;;;AASA,MAAa,oBAAwB,EACnC,UACA,oBACsB;CAEtB,MAAM,QAAQ,SAAS;CACvB,IAAI,CAAC,OAAO,OAAO;CACnB,OAAO,MAAM;AACf;;;;;AAeA,MAAM,sBAAyC;CAE7C,IAAI,OAAO,WAAW,aACpB,MAAM,IAAI,MAAM,qDAAqD;AAEzE"}
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* and keeps it aware of the current locale.
|
|
5
5
|
*
|
|
6
6
|
* Mirrors {@link useEditor}: the module is loaded via a dynamic `import()` so it
|
|
7
|
-
* ships as its own async chunk, off the critical rendering path. Apps that
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* time.
|
|
7
|
+
* ships as its own async chunk, off the critical rendering path. Apps that opt
|
|
8
|
+
* out (`analytics.enabled !== true`), or that never install
|
|
9
|
+
* `@intlayer/analytics`, pay nothing — the whole body is guarded by
|
|
10
|
+
* `INTLAYER_ANALYTICS_ENABLED` and dead-code-eliminated at build time.
|
|
11
11
|
*/
|
|
12
12
|
declare const useAnalytics: () => void;
|
|
13
13
|
//#endregion
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LocalesValues } from "../../intlayer/dist/types/index.js";
|
|
2
1
|
//#region src/client/format/useCompact.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* React client hook that provides a compact number formatter
|
|
@@ -11,7 +10,7 @@ import { LocalesValues } from "../../intlayer/dist/types/index.js";
|
|
|
11
10
|
* ```
|
|
12
11
|
*/
|
|
13
12
|
declare const useCompact: () => (value: string | number, options?: Intl.NumberFormatOptions & {
|
|
14
|
-
locale?: LocalesValues;
|
|
13
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
15
14
|
}) => string;
|
|
16
15
|
//#endregion
|
|
17
16
|
export { useCompact };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCompact.d.ts","names":[],"sources":["../../../../src/client/format/useCompact.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCompact.d.ts","names":[],"sources":["../../../../src/client/format/useCompact.ts"],"mappings":";;;;;;;;;;;cAgBa,mBAAU,wBAAA,UAAA,KAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LocalesValues } from "../../intlayer/dist/types/index.js";
|
|
2
1
|
//#region src/client/format/useCurrency.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* React client hook that provides a currency formatter
|
|
@@ -25,7 +24,7 @@ import { LocalesValues } from "../../intlayer/dist/types/index.js";
|
|
|
25
24
|
* ```
|
|
26
25
|
*/
|
|
27
26
|
declare const useCurrency: () => (value: string | number, options?: Intl.NumberFormatOptions & {
|
|
28
|
-
locale?: LocalesValues;
|
|
27
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
29
28
|
}) => string;
|
|
30
29
|
//#endregion
|
|
31
30
|
export { useCurrency };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrency.d.ts","names":[],"sources":["../../../../src/client/format/useCurrency.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCurrency.d.ts","names":[],"sources":["../../../../src/client/format/useCurrency.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;cA8Ba,oBAAW,wBAAA,UAAA,KAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LocalesValues } from "../../intlayer/dist/types/index.js";
|
|
2
1
|
//#region src/client/format/useList.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* React client hook that provides a list formatter
|
|
@@ -26,7 +25,7 @@ declare const useList: () => (values: (string | number)[], options?: {
|
|
|
26
25
|
type?: 'conjunction' | 'disjunction' | 'unit';
|
|
27
26
|
style?: 'long' | 'short' | 'narrow';
|
|
28
27
|
} & {
|
|
29
|
-
locale?: LocalesValues;
|
|
28
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
30
29
|
}) => string;
|
|
31
30
|
//#endregion
|
|
32
31
|
export { useList };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useList.d.ts","names":[],"sources":["../../../../src/client/format/useList.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useList.d.ts","names":[],"sources":["../../../../src/client/format/useList.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;cA2Ba,gBAAO,6BAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LocalesValues } from "../../intlayer/dist/types/index.js";
|
|
2
1
|
//#region src/client/format/useNumber.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* React client hook that provides a localized number formatter.
|
|
@@ -23,7 +22,7 @@ import { LocalesValues } from "../../intlayer/dist/types/index.js";
|
|
|
23
22
|
* A number formatting function bound to the active locale.
|
|
24
23
|
*/
|
|
25
24
|
declare const useNumber: () => (value: string | number, args_1?: Intl.NumberFormatOptions & {
|
|
26
|
-
locale?: LocalesValues;
|
|
25
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
27
26
|
}) => string;
|
|
28
27
|
//#endregion
|
|
29
28
|
export { useNumber };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNumber.d.ts","names":[],"sources":["../../../../src/client/format/useNumber.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useNumber.d.ts","names":[],"sources":["../../../../src/client/format/useNumber.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;cA4Ba,kBAAS,wBAAA,SAAA,KAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LocalesValues } from "../../intlayer/dist/types/index.js";
|
|
2
1
|
//#region src/client/format/usePercentage.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* React hook to provide a percentage formatter function
|
|
@@ -19,7 +18,7 @@ import { LocalesValues } from "../../intlayer/dist/types/index.js";
|
|
|
19
18
|
* A function that formats numbers or numeric strings into localized percentages.
|
|
20
19
|
*/
|
|
21
20
|
declare const usePercentage: () => (value: string | number, args_1?: Intl.NumberFormatOptions & {
|
|
22
|
-
locale?: LocalesValues;
|
|
21
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
23
22
|
}) => string;
|
|
24
23
|
//#endregion
|
|
25
24
|
export { usePercentage };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePercentage.d.ts","names":[],"sources":["../../../../src/client/format/usePercentage.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePercentage.d.ts","names":[],"sources":["../../../../src/client/format/usePercentage.ts"],"mappings":";;;;;;;;;;;;;;;;;;;cAwBa,sBAAa,wBAAA,SAAA,KAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LocalesValues } from "../../intlayer/dist/types/index.js";
|
|
2
1
|
//#region src/client/format/useRelativeTime.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Client-side React hook for accessing a localized relative time formatter.
|
|
@@ -19,7 +18,7 @@ import { LocalesValues } from "../../intlayer/dist/types/index.js";
|
|
|
19
18
|
* bound to the current client locale.
|
|
20
19
|
*/
|
|
21
20
|
declare const useRelativeTime: () => (from: string | number | Date, to?: string | number | Date, options?: Intl.RelativeTimeFormatOptions & {
|
|
22
|
-
locale?: LocalesValues;
|
|
21
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
23
22
|
unit?: Intl.RelativeTimeFormatUnit;
|
|
24
23
|
}) => string;
|
|
25
24
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRelativeTime.d.ts","names":[],"sources":["../../../../src/client/format/useRelativeTime.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useRelativeTime.d.ts","names":[],"sources":["../../../../src/client/format/useRelativeTime.ts"],"mappings":";;;;;;;;;;;;;;;;;;;cAwBa,wBAAe,wBAAA,MAAA,uBAAA,MAAA,UAAA,KAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LocalesValues } from "../../intlayer/dist/types/index.js";
|
|
2
1
|
//#region src/client/format/useUnit.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* React hook that provides a unit formatting function
|
|
@@ -18,7 +17,7 @@ import { LocalesValues } from "../../intlayer/dist/types/index.js";
|
|
|
18
17
|
* @returns {Function} A unit formatting function that accepts a value and optional formatting options.
|
|
19
18
|
*/
|
|
20
19
|
declare const useUnit: () => (value: string | number, options?: Intl.NumberFormatOptions & {
|
|
21
|
-
locale?: LocalesValues;
|
|
20
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
22
21
|
}) => string;
|
|
23
22
|
//#endregion
|
|
24
23
|
export { useUnit };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUnit.d.ts","names":[],"sources":["../../../../src/client/format/useUnit.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useUnit.d.ts","names":[],"sources":["../../../../src/client/format/useUnit.ts"],"mappings":";;;;;;;;;;;;;;;;;;cAuBa,gBAAO,wBAAA,UAAA,KAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DeepTransformContent } from "../plugins.js";
|
|
2
2
|
import { DeclaredLocales, DictionaryKeys, DictionaryRegistryContent } from "@intlayer/types/module_augmentation";
|
|
3
|
-
import { GetSubPath } from "@intlayer/types/dictionary";
|
|
4
3
|
import { ValidDotPathsFor } from "@intlayer/core/transpiler";
|
|
4
|
+
import { GetSubPath } from "@intlayer/types/dictionary";
|
|
5
5
|
//#region src/client/useI18n.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* Hook that provides a translation function `t()` for accessing nested content by key.
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { LocalesValues } from "../intlayer/dist/types/index.js";
|
|
2
1
|
//#region src/client/useLocaleBase.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* On the client side, hook to get the current locale and all related fields
|
|
5
4
|
*/
|
|
6
5
|
declare const useLocaleBase: () => {
|
|
7
|
-
locale: LocalesValues;
|
|
6
|
+
locale: import("@intlayer/types").LocalesValues;
|
|
8
7
|
defaultLocale: any;
|
|
9
8
|
availableLocales: any;
|
|
10
|
-
setLocale: (newLocale: LocalesValues) => void;
|
|
9
|
+
setLocale: (newLocale: import("@intlayer/types").LocalesValues) => void;
|
|
11
10
|
};
|
|
12
11
|
//#endregion
|
|
13
12
|
export { useLocaleBase };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocaleBase.d.ts","names":[],"sources":["../../../src/client/useLocaleBase.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLocaleBase.d.ts","names":[],"sources":["../../../src/client/useLocaleBase.ts"],"mappings":";;;;cAWa"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Locale } from "../intlayer/dist/types/index.js";
|
|
2
1
|
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
3
2
|
//#region src/client/useLocaleStorage.d.ts
|
|
4
3
|
/**
|
|
@@ -7,13 +6,13 @@ import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
|
7
6
|
/**
|
|
8
7
|
* Get the locale cookie
|
|
9
8
|
*/
|
|
10
|
-
declare const localeInStorage: Locale;
|
|
9
|
+
declare const localeInStorage: import("@intlayer/types").Locale;
|
|
11
10
|
/**
|
|
12
11
|
* @deprecated Use localeInStorage instead
|
|
13
12
|
*
|
|
14
13
|
* Get the locale cookie
|
|
15
14
|
*/
|
|
16
|
-
declare const localeCookie: Locale;
|
|
15
|
+
declare const localeCookie: import("@intlayer/types").Locale;
|
|
17
16
|
/**
|
|
18
17
|
* Set the locale cookie
|
|
19
18
|
*/
|
|
@@ -28,7 +27,7 @@ declare const setLocaleCookie: typeof setLocaleInStorage;
|
|
|
28
27
|
* Hook that provides the locale cookie and a function to set it
|
|
29
28
|
*/
|
|
30
29
|
declare const useLocaleStorage: (isCookieEnabled?: boolean) => {
|
|
31
|
-
getLocale: () => Locale;
|
|
30
|
+
getLocale: () => import("@intlayer/types").Locale;
|
|
32
31
|
setLocale: (locale: LocalesValues) => void;
|
|
33
32
|
};
|
|
34
33
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocaleStorage.d.ts","names":[],"sources":["../../../src/client/useLocaleStorage.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLocaleStorage.d.ts","names":[],"sources":["../../../src/client/useLocaleStorage.ts"],"mappings":";;;;;;;;cAea,2CAAe;;;;;;cAMf,wCAAY;;;;cAKZ,qBAAkB,QACrB,eAAa;;;;;;cAaV,wBAAe;;;;cAKf,mBAAgB;;sBAAhB;;;;;;;;;cAiBA,wBAAe"}
|
|
@@ -1,43 +1,18 @@
|
|
|
1
|
+
import { ServerContext } from "./serverContext.js";
|
|
1
2
|
import { LocalesValues, ProviderVariant } from "@intlayer/types/module_augmentation";
|
|
2
3
|
import { FC, PropsWithChildren } from "react";
|
|
3
4
|
//#region src/server/IntlayerServerProvider.d.ts
|
|
4
5
|
/**
|
|
5
6
|
* Context that store the current locale on the server side
|
|
6
7
|
*/
|
|
7
|
-
declare const IntlayerServerContext:
|
|
8
|
-
value?: LocalesValues;
|
|
9
|
-
}>> & {
|
|
10
|
-
Provider: FC<PropsWithChildren<{
|
|
11
|
-
value?: LocalesValues;
|
|
12
|
-
}>>;
|
|
13
|
-
Consumer: FC<PropsWithChildren<{
|
|
14
|
-
children: (context: LocalesValues) => import("react").ReactNode;
|
|
15
|
-
}>>;
|
|
16
|
-
_storage: () => {
|
|
17
|
-
value: LocalesValues;
|
|
18
|
-
};
|
|
19
|
-
_defaultValue: LocalesValues;
|
|
20
|
-
};
|
|
8
|
+
declare const IntlayerServerContext: ServerContext<LocalesValues>;
|
|
21
9
|
/**
|
|
22
10
|
* Context that stores the ambient variant on the server side.
|
|
23
11
|
*
|
|
24
12
|
* Kept separate from {@link IntlayerServerContext} so the locale context keeps
|
|
25
13
|
* its plain `LocalesValues` shape for the packages already reading it.
|
|
26
14
|
*/
|
|
27
|
-
declare const IntlayerServerVariantContext:
|
|
28
|
-
value?: ProviderVariant;
|
|
29
|
-
}>> & {
|
|
30
|
-
Provider: FC<PropsWithChildren<{
|
|
31
|
-
value?: ProviderVariant;
|
|
32
|
-
}>>;
|
|
33
|
-
Consumer: FC<PropsWithChildren<{
|
|
34
|
-
children: (context: ProviderVariant) => import("react").ReactNode;
|
|
35
|
-
}>>;
|
|
36
|
-
_storage: () => {
|
|
37
|
-
value: ProviderVariant;
|
|
38
|
-
};
|
|
39
|
-
_defaultValue: ProviderVariant;
|
|
40
|
-
};
|
|
15
|
+
declare const IntlayerServerVariantContext: ServerContext<ProviderVariant>;
|
|
41
16
|
/**
|
|
42
17
|
* Hook that provides the current locale
|
|
43
18
|
*/
|
|
@@ -46,6 +21,28 @@ declare const useIntlayer: () => LocalesValues;
|
|
|
46
21
|
* Get the current locale
|
|
47
22
|
*/
|
|
48
23
|
declare const locale: LocalesValues;
|
|
24
|
+
/**
|
|
25
|
+
* Seeds the request-scoped server context locale imperatively — the equivalent
|
|
26
|
+
* of mounting {@link IntlayerServerProvider} without wrapping the tree.
|
|
27
|
+
*
|
|
28
|
+
* Useful in pages that must stay statically rendered while no ambient
|
|
29
|
+
* request-derived locale source is static-safe (Next.js < 16):
|
|
30
|
+
*
|
|
31
|
+
* ```tsx
|
|
32
|
+
* const Page = async ({ params }) => {
|
|
33
|
+
* const { locale } = await params;
|
|
34
|
+
* setLocale(locale);
|
|
35
|
+
* return <PageContent />;
|
|
36
|
+
* };
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
declare const setLocale: (locale: LocalesValues) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Seeds the request-scoped ambient variant imperatively — the equivalent of
|
|
42
|
+
* the `variant` prop of {@link IntlayerServerProvider} without wrapping the
|
|
43
|
+
* tree. See that prop for the accepted shapes.
|
|
44
|
+
*/
|
|
45
|
+
declare const setVariant: (variant: ProviderVariant) => void;
|
|
49
46
|
type IntlayerServerProviderProps = PropsWithChildren & {
|
|
50
47
|
locale?: LocalesValues;
|
|
51
48
|
/**
|
|
@@ -63,5 +60,5 @@ type IntlayerServerProviderProps = PropsWithChildren & {
|
|
|
63
60
|
*/
|
|
64
61
|
declare const IntlayerServerProvider: FC<IntlayerServerProviderProps>;
|
|
65
62
|
//#endregion
|
|
66
|
-
export { IntlayerServerContext, IntlayerServerProvider, IntlayerServerProviderProps, IntlayerServerVariantContext, locale, useIntlayer };
|
|
63
|
+
export { IntlayerServerContext, IntlayerServerProvider, IntlayerServerProviderProps, IntlayerServerVariantContext, locale, setLocale, setVariant, useIntlayer };
|
|
67
64
|
//# sourceMappingURL=IntlayerServerProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerServerProvider.d.ts","names":[],"sources":["../../../src/server/IntlayerServerProvider.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"IntlayerServerProvider.d.ts","names":[],"sources":["../../../src/server/IntlayerServerProvider.tsx"],"mappings":";;;;;;;cAca,uBAAqB,cAAA;;;;;;;cASrB,8BAA4B,cAAA;;;;cAM5B,mBAAW;;;;cAKX,QAAM;;;;;;;;;;;;;;;;cAiBN,YAAS,QAAY;;;;;;cASrB,aAAU,SAAa;KAIxB,8BAA8B;EACxC,SAAS;;;;;;;;;EAST,UAAU;;;;;cAMC,wBAAwB,GAAG"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ServerContext, getServerContext } from "./serverContext.js";
|
|
2
|
+
import { IntlayerServerContext, IntlayerServerProvider, IntlayerServerProviderProps, IntlayerServerVariantContext, locale, setLocale, setVariant } from "./IntlayerServerProvider.js";
|
|
2
3
|
import { useIntl } from "./format/useIntl.js";
|
|
3
4
|
import { t } from "./t.js";
|
|
4
5
|
import { useDictionary } from "./useDictionary.js";
|
|
@@ -8,4 +9,4 @@ import { useI18n } from "./useI18n.js";
|
|
|
8
9
|
import { useIntlayer } from "./useIntlayer.js";
|
|
9
10
|
import { useLoadDynamic } from "./useLoadDynamic.js";
|
|
10
11
|
import { useLocale } from "./useLocale.js";
|
|
11
|
-
export { IntlayerServerContext as IntlayerServer, IntlayerServerProvider, type IntlayerServerProviderProps, locale, t, useDictionary, useDictionaryAsync, useDictionaryDynamic, useI18n, useIntl, useIntlayer, useLoadDynamic, useLocale };
|
|
12
|
+
export { IntlayerServerContext as IntlayerServer, IntlayerServerProvider, type IntlayerServerProviderProps, IntlayerServerVariantContext, type ServerContext, getServerContext, locale, setLocale, setVariant, t, useDictionary, useDictionaryAsync, useDictionaryDynamic, useI18n, useIntl, useIntlayer, useLoadDynamic, useLocale };
|
|
@@ -24,5 +24,5 @@ type ServerContext<T> = FC<PropsWithChildren<{
|
|
|
24
24
|
_defaultValue: T | undefined;
|
|
25
25
|
};
|
|
26
26
|
//#endregion
|
|
27
|
-
export { createServerContext, getServerContext };
|
|
27
|
+
export { ServerContext, createServerContext, getServerContext };
|
|
28
28
|
//# sourceMappingURL=serverContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverContext.d.ts","names":[],"sources":["../../../src/server/serverContext.tsx"],"mappings":";;cAiBa,sBAAuB,GAAC,eAAkB,MAAI,cAAc;;;;;;;;cAqC5D,mBAAoB,KAAC,UAAA,iBAG/B,cAAc,OAAE;
|
|
1
|
+
{"version":3,"file":"serverContext.d.ts","names":[],"sources":["../../../src/server/serverContext.tsx"],"mappings":";;cAiBa,sBAAuB,GAAC,eAAkB,MAAI,cAAc;;;;;;;;cAqC5D,mBAAoB,KAAC,UAAA,iBAG/B,cAAc,OAAE;KAOP,cAAc,KAAK,GAAG;EAAoB,QAAQ;;EAC5D,UAAU,GAAG;IAAoB,QAAQ;;EACzC,UAAU,GACR;IAAoB,WAAW,SAAS,kBAAkB;;EAE5D;IAAkB,OAAO;;EACzB,eAAe"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DeepTransformContent } from "../plugins.js";
|
|
2
2
|
import { DictionaryKeys, DictionaryRegistryContent, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
3
|
-
import { GetSubPath } from "@intlayer/types/dictionary";
|
|
4
3
|
import { ValidDotPathsFor } from "@intlayer/core/transpiler";
|
|
4
|
+
import { GetSubPath } from "@intlayer/types/dictionary";
|
|
5
5
|
//#region src/server/useI18n.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* Hook that provides a translation function `t()` for accessing nested content by key.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-intlayer",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.4.0-canary.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your React applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -132,12 +132,12 @@
|
|
|
132
132
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
133
133
|
},
|
|
134
134
|
"dependencies": {
|
|
135
|
-
"@intlayer/api": "9.
|
|
136
|
-
"@intlayer/config": "9.
|
|
137
|
-
"@intlayer/core": "9.
|
|
138
|
-
"@intlayer/dictionaries-entry": "9.
|
|
139
|
-
"@intlayer/editor": "9.
|
|
140
|
-
"@intlayer/types": "9.
|
|
135
|
+
"@intlayer/api": "9.4.0-canary.0",
|
|
136
|
+
"@intlayer/config": "9.4.0-canary.0",
|
|
137
|
+
"@intlayer/core": "9.4.0-canary.0",
|
|
138
|
+
"@intlayer/dictionaries-entry": "9.4.0-canary.0",
|
|
139
|
+
"@intlayer/editor": "9.4.0-canary.0",
|
|
140
|
+
"@intlayer/types": "9.4.0-canary.0"
|
|
141
141
|
},
|
|
142
142
|
"devDependencies": {
|
|
143
143
|
"@craco/types": "7.1.0",
|
|
@@ -158,7 +158,7 @@
|
|
|
158
158
|
"react-dom": ">=16.0.0"
|
|
159
159
|
},
|
|
160
160
|
"optionalDependencies": {
|
|
161
|
-
"@intlayer/analytics": "9.
|
|
161
|
+
"@intlayer/analytics": "9.4.0-canary.0"
|
|
162
162
|
},
|
|
163
163
|
"engines": {
|
|
164
164
|
"node": ">=14.18"
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import "@intlayer/core/interpreter";
|
|
2
|
-
import { LocalesValues as LocalesValues$1 } from "@intlayer/types/module_augmentation";
|
|
3
|
-
import "@intlayer/types/config";
|
|
4
|
-
import { Dictionary } from "@intlayer/types/dictionary";
|
|
5
|
-
import { Locale } from "@intlayer/types/allLocales";
|
|
6
|
-
import "@intlayer/types/locales";
|
|
7
|
-
import "@intlayer/config/built";
|
|
8
|
-
import "@intlayer/core/file";
|
|
9
|
-
import "@intlayer/core/formatters";
|
|
10
|
-
import "@intlayer/core/localization";
|
|
11
|
-
import "@intlayer/core/markdown";
|
|
12
|
-
import "@intlayer/core/transpiler";
|
|
13
|
-
import "@intlayer/core/utils";
|
|
14
|
-
export type { Locale, LocalesValues$1 as LocalesValues };
|