next-intlayer 9.5.9 → 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/rsc/index.cjs +4 -4
- package/dist/cjs/server/ambientLocale.cjs +25 -4
- package/dist/cjs/server/ambientLocale.cjs.map +1 -1
- package/dist/cjs/server/index.cjs +7 -7
- package/dist/cjs/server/withIntlayer.cjs +1 -1
- package/dist/esm/server/ambientLocale.mjs +25 -4
- package/dist/esm/server/ambientLocale.mjs.map +1 -1
- package/dist/types/generateStaticParams.d.ts +1 -2
- package/dist/types/generateStaticParams.d.ts.map +1 -1
- package/dist/types/server/ambientLocale.d.ts +4 -2
- package/dist/types/server/ambientLocale.d.ts.map +1 -1
- package/dist/types/server/prepareSwcOptimization.d.ts +1 -1
- package/dist/types/server/useDictionary.d.ts +1 -1
- package/dist/types/server/useDictionaryAsync.d.ts +1 -1
- package/dist/types/server/useDictionaryDynamic.d.ts +1 -1
- package/package.json +8 -8
- package/dist/types/intlayer/dist/types/index.d.ts +0 -14
package/dist/cjs/rsc/index.cjs
CHANGED
|
@@ -3,15 +3,15 @@ const require_generateStaticParams = require('../generateStaticParams.cjs');
|
|
|
3
3
|
const require_client_IntlayerClientProvider = require('../client/IntlayerClientProvider.cjs');
|
|
4
4
|
const require_client_usePathname = require('../client/usePathname.cjs');
|
|
5
5
|
const require_client_useLocalePageRouter = require('../client/useLocalePageRouter.cjs');
|
|
6
|
-
const require_server_useIntlayer = require('../server/useIntlayer.cjs');
|
|
7
|
-
const require_server_useIntl = require('../server/useIntl.cjs');
|
|
8
|
-
const require_server_useDictionaryDynamic = require('../server/useDictionaryDynamic.cjs');
|
|
9
|
-
const require_server_useLocale = require('../server/useLocale.cjs');
|
|
10
6
|
const require_server_IntlayerProvider = require('../server/IntlayerProvider.cjs');
|
|
11
7
|
const require_server_t = require('../server/t.cjs');
|
|
12
8
|
const require_server_useDictionary = require('../server/useDictionary.cjs');
|
|
13
9
|
const require_server_useDictionaryAsync = require('../server/useDictionaryAsync.cjs');
|
|
10
|
+
const require_server_useDictionaryDynamic = require('../server/useDictionaryDynamic.cjs');
|
|
14
11
|
const require_server_useI18n = require('../server/useI18n.cjs');
|
|
12
|
+
const require_server_useIntl = require('../server/useIntl.cjs');
|
|
13
|
+
const require_server_useIntlayer = require('../server/useIntlayer.cjs');
|
|
14
|
+
const require_server_useLocale = require('../server/useLocale.cjs');
|
|
15
15
|
let react_intlayer = require("react-intlayer");
|
|
16
16
|
let react_intlayer_server = require("react-intlayer/server");
|
|
17
17
|
|
|
@@ -29,6 +29,17 @@ const needsRequestLocale = (localeOrSelector) => !hasExplicitLocale(localeOrSele
|
|
|
29
29
|
*/
|
|
30
30
|
const readStoredLocale = require_server_suspendingReader.createSuspendingReader(require_server_getLocale.getLocale);
|
|
31
31
|
/**
|
|
32
|
+
* Resolves after one macrotask.
|
|
33
|
+
*
|
|
34
|
+
* Next.js renders a page concurrently with its layout, and the layout usually
|
|
35
|
+
* awaits `params` before `IntlayerProvider` renders and seeds the server
|
|
36
|
+
* context. A synchronous page therefore reads the context before it is seeded.
|
|
37
|
+
* Yielding once lets the provider run first, so a full render (including the
|
|
38
|
+
* build-time prerender) never reaches request storage and stays static.
|
|
39
|
+
*/
|
|
40
|
+
const yieldToProvider = () => new Promise((resolve) => setTimeout(() => resolve(true), 0));
|
|
41
|
+
const waitForProvider = require_server_suspendingReader.createSuspendingReader(yieldToProvider);
|
|
42
|
+
/**
|
|
32
43
|
* Fallback locale for the synchronous server hooks, so a page does not need a
|
|
33
44
|
* provider of its own. Not a React hook despite suspending — it holds no
|
|
34
45
|
* positional state, which is what lets it run conditionally (see
|
|
@@ -36,15 +47,25 @@ const readStoredLocale = require_server_suspendingReader.createSuspendingReader(
|
|
|
36
47
|
* page segment, the layout — and with it `IntlayerProvider` — does not re-run,
|
|
37
48
|
* and the locale carried by the request takes over.
|
|
38
49
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
50
|
+
* On a context miss, first suspends once so a concurrently rendering provider
|
|
51
|
+
* can seed the context, then suspends until the request storage resolves.
|
|
52
|
+
* Returns `undefined` when the call site or the server context already carries
|
|
53
|
+
* the locale.
|
|
41
54
|
*/
|
|
42
|
-
const resolveFallbackLocale = (localeOrSelector) =>
|
|
55
|
+
const resolveFallbackLocale = (localeOrSelector) => {
|
|
56
|
+
if (!needsRequestLocale(localeOrSelector)) return void 0;
|
|
57
|
+
waitForProvider();
|
|
58
|
+
return needsRequestLocale(localeOrSelector) ? readStoredLocale() : void 0;
|
|
59
|
+
};
|
|
43
60
|
/**
|
|
44
61
|
* Asynchronous twin of {@link resolveFallbackLocale}, for the hooks that are
|
|
45
62
|
* already async and can await the request storage instead of suspending on it.
|
|
46
63
|
*/
|
|
47
|
-
const getFallbackLocale = async (localeOrSelector) =>
|
|
64
|
+
const getFallbackLocale = async (localeOrSelector) => {
|
|
65
|
+
if (!needsRequestLocale(localeOrSelector)) return void 0;
|
|
66
|
+
await yieldToProvider();
|
|
67
|
+
return needsRequestLocale(localeOrSelector) ? await require_server_getLocale.getLocale() : void 0;
|
|
68
|
+
};
|
|
48
69
|
/**
|
|
49
70
|
* Full ambient locale for the server APIs that take a plain locale argument
|
|
50
71
|
* (or none at all): call site → server context → locale carried by the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ambientLocale.cjs","names":["getServerContext","IntlayerServer","createSuspendingReader","getLocale"],"sources":["../../../src/server/ambientLocale.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getServerContext, IntlayerServer } from 'react-intlayer/server';\nimport { getLocale } from './getLocale';\nimport { createSuspendingReader } from './suspendingReader';\n\n/**\n * Whether the call site already carries a locale — either a plain locale\n * argument or a selector object with an explicit `locale` field.\n */\nconst hasExplicitLocale = (localeOrSelector?: unknown): boolean =>\n typeof localeOrSelector === 'string' ||\n (typeof localeOrSelector === 'object' &&\n localeOrSelector !== null &&\n Boolean((localeOrSelector as { locale?: unknown }).locale));\n\n/**\n * Whether the request-derived locale is worth reading at all.\n *\n * The base hooks in `react-intlayer/server` already prefer, in order, the\n * locale passed at the call site and the request-scoped server context seeded\n * by `IntlayerProvider`; they only fall back to the third argument these\n * helpers produce. Reading request storage means calling `headers()` /\n * `cookies()`, which opts the route into dynamic rendering — so it must stay\n * behind both of those, and never run when either already answers.\n */\nconst needsRequestLocale = (localeOrSelector?: unknown): boolean =>\n !hasExplicitLocale(localeOrSelector) && !getServerContext(IntlayerServer);\n\n/**\n * Reads the locale carried by the request: the `x-intlayer-locale` header set\n * by the intlayer proxy, then the locale cookie, then `accept-language`.\n *\n * Errors are not swallowed — during prerendering Next.js relies on the throw\n * from `headers()` to mark the route dynamic.\n */\nconst readStoredLocale = createSuspendingReader<Locale>(getLocale);\n\n/**\n * Fallback locale for the synchronous server hooks, so a page does not need a\n * provider of its own. Not a React hook despite suspending — it holds no\n * positional state, which is what lets it run conditionally (see\n * {@link createSuspendingReader}): on a client-side navigation that re-renders only the\n * page segment, the layout — and with it `IntlayerProvider` — does not re-run,\n * and the locale carried by the request takes over.\n *\n *
|
|
1
|
+
{"version":3,"file":"ambientLocale.cjs","names":["getServerContext","IntlayerServer","createSuspendingReader","getLocale"],"sources":["../../../src/server/ambientLocale.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getServerContext, IntlayerServer } from 'react-intlayer/server';\nimport { getLocale } from './getLocale';\nimport { createSuspendingReader } from './suspendingReader';\n\n/**\n * Whether the call site already carries a locale — either a plain locale\n * argument or a selector object with an explicit `locale` field.\n */\nconst hasExplicitLocale = (localeOrSelector?: unknown): boolean =>\n typeof localeOrSelector === 'string' ||\n (typeof localeOrSelector === 'object' &&\n localeOrSelector !== null &&\n Boolean((localeOrSelector as { locale?: unknown }).locale));\n\n/**\n * Whether the request-derived locale is worth reading at all.\n *\n * The base hooks in `react-intlayer/server` already prefer, in order, the\n * locale passed at the call site and the request-scoped server context seeded\n * by `IntlayerProvider`; they only fall back to the third argument these\n * helpers produce. Reading request storage means calling `headers()` /\n * `cookies()`, which opts the route into dynamic rendering — so it must stay\n * behind both of those, and never run when either already answers.\n */\nconst needsRequestLocale = (localeOrSelector?: unknown): boolean =>\n !hasExplicitLocale(localeOrSelector) && !getServerContext(IntlayerServer);\n\n/**\n * Reads the locale carried by the request: the `x-intlayer-locale` header set\n * by the intlayer proxy, then the locale cookie, then `accept-language`.\n *\n * Errors are not swallowed — during prerendering Next.js relies on the throw\n * from `headers()` to mark the route dynamic.\n */\nconst readStoredLocale = createSuspendingReader<Locale>(getLocale);\n\n/**\n * Resolves after one macrotask.\n *\n * Next.js renders a page concurrently with its layout, and the layout usually\n * awaits `params` before `IntlayerProvider` renders and seeds the server\n * context. A synchronous page therefore reads the context before it is seeded.\n * Yielding once lets the provider run first, so a full render (including the\n * build-time prerender) never reaches request storage and stays static.\n */\nconst yieldToProvider = (): Promise<true> =>\n new Promise((resolve) => setTimeout(() => resolve(true), 0));\n\nconst waitForProvider = createSuspendingReader<true>(yieldToProvider);\n\n/**\n * Fallback locale for the synchronous server hooks, so a page does not need a\n * provider of its own. Not a React hook despite suspending — it holds no\n * positional state, which is what lets it run conditionally (see\n * {@link createSuspendingReader}): on a client-side navigation that re-renders only the\n * page segment, the layout — and with it `IntlayerProvider` — does not re-run,\n * and the locale carried by the request takes over.\n *\n * On a context miss, first suspends once so a concurrently rendering provider\n * can seed the context, then suspends until the request storage resolves.\n * Returns `undefined` when the call site or the server context already carries\n * the locale.\n */\nexport const resolveFallbackLocale = (\n localeOrSelector?: unknown\n): Locale | undefined => {\n if (!needsRequestLocale(localeOrSelector)) return undefined;\n\n waitForProvider();\n\n return needsRequestLocale(localeOrSelector) ? readStoredLocale() : undefined;\n};\n\n/**\n * Asynchronous twin of {@link resolveFallbackLocale}, for the hooks that are\n * already async and can await the request storage instead of suspending on it.\n */\nexport const getFallbackLocale = async (\n localeOrSelector?: unknown\n): Promise<Locale | undefined> => {\n if (!needsRequestLocale(localeOrSelector)) return undefined;\n\n await yieldToProvider();\n\n return needsRequestLocale(localeOrSelector) ? await getLocale() : undefined;\n};\n\n/**\n * Full ambient locale for the server APIs that take a plain locale argument\n * (or none at all): call site → server context → locale carried by the\n * request.\n *\n * {@link resolveFallbackLocale} only yields the last rung, because the base hooks\n * in `react-intlayer/server` consult the first two themselves. The APIs\n * reimplemented here have no such fallback slot, so they need the resolved\n * value.\n */\nexport const resolveAmbientLocale = (\n locale?: LocalesValues\n): LocalesValues | undefined =>\n locale ??\n getServerContext<LocalesValues>(IntlayerServer) ??\n resolveFallbackLocale(locale);\n"],"mappings":";;;;;;;;;;AAUA,MAAM,qBAAqB,qBACzB,OAAO,qBAAqB,YAC3B,OAAO,qBAAqB,YAC3B,qBAAqB,QACrB,QAAS,iBAA0C,MAAM;;;;;;;;;;;AAY7D,MAAM,sBAAsB,qBAC1B,CAAC,kBAAkB,gBAAgB,KAAK,KAACA,wCAAiBC,oCAAc;;;;;;;;AAS1E,MAAM,mBAAmBC,uDAA+BC,kCAAS;;;;;;;;;;AAWjE,MAAM,wBACJ,IAAI,SAAS,YAAY,iBAAiB,QAAQ,IAAI,GAAG,CAAC,CAAC;AAE7D,MAAM,kBAAkBD,uDAA6B,eAAe;;;;;;;;;;;;;;AAepE,MAAa,yBACX,qBACuB;CACvB,IAAI,CAAC,mBAAmB,gBAAgB,GAAG,OAAO;CAElD,gBAAgB;CAEhB,OAAO,mBAAmB,gBAAgB,IAAI,iBAAiB,IAAI;AACrE;;;;;AAMA,MAAa,oBAAoB,OAC/B,qBACgC;CAChC,IAAI,CAAC,mBAAmB,gBAAgB,GAAG,OAAO;CAElD,MAAM,gBAAgB;CAEtB,OAAO,mBAAmB,gBAAgB,IAAI,MAAMC,mCAAU,IAAI;AACpE;;;;;;;;;;;AAYA,MAAa,wBACX,WAEA,cACAH,wCAAgCC,oCAAc,KAC9C,sBAAsB,MAAM"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_server_withIntlayer = require('./withIntlayer.cjs');
|
|
3
|
-
const require_server_getLocale = require('./getLocale.cjs');
|
|
4
|
-
const require_server_useIntlayer = require('./useIntlayer.cjs');
|
|
5
|
-
const require_server_useIntl = require('./useIntl.cjs');
|
|
6
|
-
const require_server_useDictionaryDynamic = require('./useDictionaryDynamic.cjs');
|
|
7
|
-
const require_server_useLocale = require('./useLocale.cjs');
|
|
8
2
|
const require_server_IntlayerProvider = require('./IntlayerProvider.cjs');
|
|
9
|
-
const
|
|
3
|
+
const require_server_getLocale = require('./getLocale.cjs');
|
|
10
4
|
const require_server_t = require('./t.cjs');
|
|
11
5
|
const require_server_useDictionary = require('./useDictionary.cjs');
|
|
12
6
|
const require_server_useDictionaryAsync = require('./useDictionaryAsync.cjs');
|
|
7
|
+
const require_server_useDictionaryDynamic = require('./useDictionaryDynamic.cjs');
|
|
13
8
|
const require_server_useI18n = require('./useI18n.cjs');
|
|
9
|
+
const require_server_useIntl = require('./useIntl.cjs');
|
|
10
|
+
const require_server_useIntlayer = require('./useIntlayer.cjs');
|
|
11
|
+
const require_server_useLocale = require('./useLocale.cjs');
|
|
12
|
+
const require_server_withIntlayer = require('./withIntlayer.cjs');
|
|
13
|
+
const require_server_IntlayerServerProvider = require('./IntlayerServerProvider.cjs');
|
|
14
14
|
let react_intlayer_server = require("react-intlayer/server");
|
|
15
15
|
|
|
16
16
|
exports.IntlayerProvider = require_server_IntlayerProvider.IntlayerProvider;
|
|
@@ -10,8 +10,8 @@ let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
|
10
10
|
let _intlayer_config_node = require("@intlayer/config/node");
|
|
11
11
|
let _intlayer_config_utils = require("@intlayer/config/utils");
|
|
12
12
|
let _intlayer_engine_utils = require("@intlayer/engine/utils");
|
|
13
|
-
let _intlayer_config_callers = require("@intlayer/config/callers");
|
|
14
13
|
let _intlayer_config_defaultValues = require("@intlayer/config/defaultValues");
|
|
14
|
+
let _intlayer_config_callers = require("@intlayer/config/callers");
|
|
15
15
|
let _intlayer_config_envVars = require("@intlayer/config/envVars");
|
|
16
16
|
let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
|
|
17
17
|
let _intlayer_dictionaries_entry = require("@intlayer/dictionaries-entry");
|
|
@@ -28,6 +28,17 @@ const needsRequestLocale = (localeOrSelector) => !hasExplicitLocale(localeOrSele
|
|
|
28
28
|
*/
|
|
29
29
|
const readStoredLocale = createSuspendingReader(getLocale);
|
|
30
30
|
/**
|
|
31
|
+
* Resolves after one macrotask.
|
|
32
|
+
*
|
|
33
|
+
* Next.js renders a page concurrently with its layout, and the layout usually
|
|
34
|
+
* awaits `params` before `IntlayerProvider` renders and seeds the server
|
|
35
|
+
* context. A synchronous page therefore reads the context before it is seeded.
|
|
36
|
+
* Yielding once lets the provider run first, so a full render (including the
|
|
37
|
+
* build-time prerender) never reaches request storage and stays static.
|
|
38
|
+
*/
|
|
39
|
+
const yieldToProvider = () => new Promise((resolve) => setTimeout(() => resolve(true), 0));
|
|
40
|
+
const waitForProvider = createSuspendingReader(yieldToProvider);
|
|
41
|
+
/**
|
|
31
42
|
* Fallback locale for the synchronous server hooks, so a page does not need a
|
|
32
43
|
* provider of its own. Not a React hook despite suspending — it holds no
|
|
33
44
|
* positional state, which is what lets it run conditionally (see
|
|
@@ -35,15 +46,25 @@ const readStoredLocale = createSuspendingReader(getLocale);
|
|
|
35
46
|
* page segment, the layout — and with it `IntlayerProvider` — does not re-run,
|
|
36
47
|
* and the locale carried by the request takes over.
|
|
37
48
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
49
|
+
* On a context miss, first suspends once so a concurrently rendering provider
|
|
50
|
+
* can seed the context, then suspends until the request storage resolves.
|
|
51
|
+
* Returns `undefined` when the call site or the server context already carries
|
|
52
|
+
* the locale.
|
|
40
53
|
*/
|
|
41
|
-
const resolveFallbackLocale = (localeOrSelector) =>
|
|
54
|
+
const resolveFallbackLocale = (localeOrSelector) => {
|
|
55
|
+
if (!needsRequestLocale(localeOrSelector)) return void 0;
|
|
56
|
+
waitForProvider();
|
|
57
|
+
return needsRequestLocale(localeOrSelector) ? readStoredLocale() : void 0;
|
|
58
|
+
};
|
|
42
59
|
/**
|
|
43
60
|
* Asynchronous twin of {@link resolveFallbackLocale}, for the hooks that are
|
|
44
61
|
* already async and can await the request storage instead of suspending on it.
|
|
45
62
|
*/
|
|
46
|
-
const getFallbackLocale = async (localeOrSelector) =>
|
|
63
|
+
const getFallbackLocale = async (localeOrSelector) => {
|
|
64
|
+
if (!needsRequestLocale(localeOrSelector)) return void 0;
|
|
65
|
+
await yieldToProvider();
|
|
66
|
+
return needsRequestLocale(localeOrSelector) ? await getLocale() : void 0;
|
|
67
|
+
};
|
|
47
68
|
/**
|
|
48
69
|
* Full ambient locale for the server APIs that take a plain locale argument
|
|
49
70
|
* (or none at all): call site → server context → locale carried by the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ambientLocale.mjs","names":[],"sources":["../../../src/server/ambientLocale.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getServerContext, IntlayerServer } from 'react-intlayer/server';\nimport { getLocale } from './getLocale';\nimport { createSuspendingReader } from './suspendingReader';\n\n/**\n * Whether the call site already carries a locale — either a plain locale\n * argument or a selector object with an explicit `locale` field.\n */\nconst hasExplicitLocale = (localeOrSelector?: unknown): boolean =>\n typeof localeOrSelector === 'string' ||\n (typeof localeOrSelector === 'object' &&\n localeOrSelector !== null &&\n Boolean((localeOrSelector as { locale?: unknown }).locale));\n\n/**\n * Whether the request-derived locale is worth reading at all.\n *\n * The base hooks in `react-intlayer/server` already prefer, in order, the\n * locale passed at the call site and the request-scoped server context seeded\n * by `IntlayerProvider`; they only fall back to the third argument these\n * helpers produce. Reading request storage means calling `headers()` /\n * `cookies()`, which opts the route into dynamic rendering — so it must stay\n * behind both of those, and never run when either already answers.\n */\nconst needsRequestLocale = (localeOrSelector?: unknown): boolean =>\n !hasExplicitLocale(localeOrSelector) && !getServerContext(IntlayerServer);\n\n/**\n * Reads the locale carried by the request: the `x-intlayer-locale` header set\n * by the intlayer proxy, then the locale cookie, then `accept-language`.\n *\n * Errors are not swallowed — during prerendering Next.js relies on the throw\n * from `headers()` to mark the route dynamic.\n */\nconst readStoredLocale = createSuspendingReader<Locale>(getLocale);\n\n/**\n * Fallback locale for the synchronous server hooks, so a page does not need a\n * provider of its own. Not a React hook despite suspending — it holds no\n * positional state, which is what lets it run conditionally (see\n * {@link createSuspendingReader}): on a client-side navigation that re-renders only the\n * page segment, the layout — and with it `IntlayerProvider` — does not re-run,\n * and the locale carried by the request takes over.\n *\n *
|
|
1
|
+
{"version":3,"file":"ambientLocale.mjs","names":[],"sources":["../../../src/server/ambientLocale.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getServerContext, IntlayerServer } from 'react-intlayer/server';\nimport { getLocale } from './getLocale';\nimport { createSuspendingReader } from './suspendingReader';\n\n/**\n * Whether the call site already carries a locale — either a plain locale\n * argument or a selector object with an explicit `locale` field.\n */\nconst hasExplicitLocale = (localeOrSelector?: unknown): boolean =>\n typeof localeOrSelector === 'string' ||\n (typeof localeOrSelector === 'object' &&\n localeOrSelector !== null &&\n Boolean((localeOrSelector as { locale?: unknown }).locale));\n\n/**\n * Whether the request-derived locale is worth reading at all.\n *\n * The base hooks in `react-intlayer/server` already prefer, in order, the\n * locale passed at the call site and the request-scoped server context seeded\n * by `IntlayerProvider`; they only fall back to the third argument these\n * helpers produce. Reading request storage means calling `headers()` /\n * `cookies()`, which opts the route into dynamic rendering — so it must stay\n * behind both of those, and never run when either already answers.\n */\nconst needsRequestLocale = (localeOrSelector?: unknown): boolean =>\n !hasExplicitLocale(localeOrSelector) && !getServerContext(IntlayerServer);\n\n/**\n * Reads the locale carried by the request: the `x-intlayer-locale` header set\n * by the intlayer proxy, then the locale cookie, then `accept-language`.\n *\n * Errors are not swallowed — during prerendering Next.js relies on the throw\n * from `headers()` to mark the route dynamic.\n */\nconst readStoredLocale = createSuspendingReader<Locale>(getLocale);\n\n/**\n * Resolves after one macrotask.\n *\n * Next.js renders a page concurrently with its layout, and the layout usually\n * awaits `params` before `IntlayerProvider` renders and seeds the server\n * context. A synchronous page therefore reads the context before it is seeded.\n * Yielding once lets the provider run first, so a full render (including the\n * build-time prerender) never reaches request storage and stays static.\n */\nconst yieldToProvider = (): Promise<true> =>\n new Promise((resolve) => setTimeout(() => resolve(true), 0));\n\nconst waitForProvider = createSuspendingReader<true>(yieldToProvider);\n\n/**\n * Fallback locale for the synchronous server hooks, so a page does not need a\n * provider of its own. Not a React hook despite suspending — it holds no\n * positional state, which is what lets it run conditionally (see\n * {@link createSuspendingReader}): on a client-side navigation that re-renders only the\n * page segment, the layout — and with it `IntlayerProvider` — does not re-run,\n * and the locale carried by the request takes over.\n *\n * On a context miss, first suspends once so a concurrently rendering provider\n * can seed the context, then suspends until the request storage resolves.\n * Returns `undefined` when the call site or the server context already carries\n * the locale.\n */\nexport const resolveFallbackLocale = (\n localeOrSelector?: unknown\n): Locale | undefined => {\n if (!needsRequestLocale(localeOrSelector)) return undefined;\n\n waitForProvider();\n\n return needsRequestLocale(localeOrSelector) ? readStoredLocale() : undefined;\n};\n\n/**\n * Asynchronous twin of {@link resolveFallbackLocale}, for the hooks that are\n * already async and can await the request storage instead of suspending on it.\n */\nexport const getFallbackLocale = async (\n localeOrSelector?: unknown\n): Promise<Locale | undefined> => {\n if (!needsRequestLocale(localeOrSelector)) return undefined;\n\n await yieldToProvider();\n\n return needsRequestLocale(localeOrSelector) ? await getLocale() : undefined;\n};\n\n/**\n * Full ambient locale for the server APIs that take a plain locale argument\n * (or none at all): call site → server context → locale carried by the\n * request.\n *\n * {@link resolveFallbackLocale} only yields the last rung, because the base hooks\n * in `react-intlayer/server` consult the first two themselves. The APIs\n * reimplemented here have no such fallback slot, so they need the resolved\n * value.\n */\nexport const resolveAmbientLocale = (\n locale?: LocalesValues\n): LocalesValues | undefined =>\n locale ??\n getServerContext<LocalesValues>(IntlayerServer) ??\n resolveFallbackLocale(locale);\n"],"mappings":";;;;;;;;;AAUA,MAAM,qBAAqB,qBACzB,OAAO,qBAAqB,YAC3B,OAAO,qBAAqB,YAC3B,qBAAqB,QACrB,QAAS,iBAA0C,MAAM;;;;;;;;;;;AAY7D,MAAM,sBAAsB,qBAC1B,CAAC,kBAAkB,gBAAgB,KAAK,CAAC,iBAAiB,cAAc;;;;;;;;AAS1E,MAAM,mBAAmB,uBAA+B,SAAS;;;;;;;;;;AAWjE,MAAM,wBACJ,IAAI,SAAS,YAAY,iBAAiB,QAAQ,IAAI,GAAG,CAAC,CAAC;AAE7D,MAAM,kBAAkB,uBAA6B,eAAe;;;;;;;;;;;;;;AAepE,MAAa,yBACX,qBACuB;CACvB,IAAI,CAAC,mBAAmB,gBAAgB,GAAG,OAAO;CAElD,gBAAgB;CAEhB,OAAO,mBAAmB,gBAAgB,IAAI,iBAAiB,IAAI;AACrE;;;;;AAMA,MAAa,oBAAoB,OAC/B,qBACgC;CAChC,IAAI,CAAC,mBAAmB,gBAAgB,GAAG,OAAO;CAElD,MAAM,gBAAgB;CAEtB,OAAO,mBAAmB,gBAAgB,IAAI,MAAM,UAAU,IAAI;AACpE;;;;;;;;;;;AAYA,MAAa,wBACX,WAEA,UACA,iBAAgC,cAAc,KAC9C,sBAAsB,MAAM"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Locale } from "./intlayer/dist/types/index.js";
|
|
2
1
|
//#region src/generateStaticParams.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Generates static parameters for Next.js's dynamic routes based on the configured locales.
|
|
@@ -19,7 +18,7 @@ import { Locale } from "./intlayer/dist/types/index.js";
|
|
|
19
18
|
* ```
|
|
20
19
|
*/
|
|
21
20
|
export declare const generateStaticParams: () => {
|
|
22
|
-
locale: Locale;
|
|
21
|
+
locale: import("@intlayer/types").Locale;
|
|
23
22
|
}[];
|
|
24
23
|
//#endregion
|
|
25
24
|
//# sourceMappingURL=generateStaticParams.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateStaticParams.d.ts","names":[],"sources":["../../src/generateStaticParams.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"generateStaticParams.d.ts","names":[],"sources":["../../src/generateStaticParams.ts"],"mappings":";;;;;;;;;;;;;;;;;;;qBAsBa;EAAA,kCAAA"}
|
|
@@ -9,8 +9,10 @@ import { Locale } from "@intlayer/types/allLocales";
|
|
|
9
9
|
* page segment, the layout — and with it `IntlayerProvider` — does not re-run,
|
|
10
10
|
* and the locale carried by the request takes over.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* On a context miss, first suspends once so a concurrently rendering provider
|
|
13
|
+
* can seed the context, then suspends until the request storage resolves.
|
|
14
|
+
* Returns `undefined` when the call site or the server context already carries
|
|
15
|
+
* the locale.
|
|
14
16
|
*/
|
|
15
17
|
export declare const resolveFallbackLocale: (localeOrSelector?: unknown) => Locale | undefined;
|
|
16
18
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ambientLocale.d.ts","names":[],"sources":["../../../src/server/ambientLocale.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ambientLocale.d.ts","names":[],"sources":["../../../src/server/ambientLocale.ts"],"mappings":";;;;;;;;;;;;;;;;qBAiEa,wBAAqB,+BAE/B;;;;;qBAYU,oBAAiB,+BAE3B,QAAQ;;;;;;;;;;;qBAkBE,uBAAoB,SACtB,kBACR"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { IntlayerConfig } from "@intlayer/types/config";
|
|
2
1
|
import { Dictionary } from "@intlayer/types/dictionary";
|
|
3
2
|
import { CallerDescriptor } from "@intlayer/config/callers";
|
|
4
3
|
import { GetConfigurationOptions } from "@intlayer/config/node";
|
|
5
4
|
import { SerializedFieldRenameMap } from "@intlayer/babel";
|
|
5
|
+
import { IntlayerConfig } from "@intlayer/types/config";
|
|
6
6
|
//#region src/server/prepareSwcOptimization.d.ts
|
|
7
7
|
/**
|
|
8
8
|
* Field-rename tables keyed by dictionary key, forwarded to the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DeclaredLocales, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
2
|
-
import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup } from "@intlayer/types/dictionary";
|
|
3
2
|
import { useDictionary as useDictionary$1 } from "react-intlayer/server";
|
|
3
|
+
import { Dictionary, DictionarySelectorForGroup, QualifiedDictionaryGroup } from "@intlayer/types/dictionary";
|
|
4
4
|
//#region src/server/useDictionary.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* On the server side, hook that transforms a dictionary (or qualified
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DeclaredLocales, LocalesValues, StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
|
|
2
|
-
import { Dictionary } from "@intlayer/types/dictionary";
|
|
3
2
|
import { useDictionaryAsync as useDictionaryAsync$1 } from "react-intlayer/server";
|
|
3
|
+
import { Dictionary } from "@intlayer/types/dictionary";
|
|
4
4
|
//#region src/server/useDictionaryAsync.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* On the server side, hook that transforms a dictionary and returns the content
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DeclaredLocales, LocalesValues, StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
|
|
2
|
-
import { Dictionary, DictionarySelector } from "@intlayer/types/dictionary";
|
|
3
2
|
import { useDictionaryDynamic as useDictionaryDynamic$1 } from "react-intlayer/server";
|
|
3
|
+
import { Dictionary, DictionarySelector } from "@intlayer/types/dictionary";
|
|
4
4
|
import { QualifiedDynamicLoaderMap } from "@intlayer/core/dictionaryManipulator";
|
|
5
5
|
//#region src/server/useDictionaryDynamic.d.ts
|
|
6
6
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intlayer",
|
|
3
|
-
"version": "9.5.
|
|
3
|
+
"version": "9.5.10",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Simplify internationalization i18n in Next.js with context providers, hooks, locale detection, and multilingual content integration.",
|
|
6
6
|
"keywords": [
|
|
@@ -147,14 +147,14 @@
|
|
|
147
147
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
148
148
|
},
|
|
149
149
|
"dependencies": {
|
|
150
|
-
"@intlayer/config": "9.5.
|
|
151
|
-
"@intlayer/core": "9.5.
|
|
152
|
-
"@intlayer/dictionaries-entry": "9.5.
|
|
153
|
-
"@intlayer/engine": "9.5.
|
|
154
|
-
"@intlayer/types": "9.5.
|
|
150
|
+
"@intlayer/config": "9.5.10",
|
|
151
|
+
"@intlayer/core": "9.5.10",
|
|
152
|
+
"@intlayer/dictionaries-entry": "9.5.10",
|
|
153
|
+
"@intlayer/engine": "9.5.10",
|
|
154
|
+
"@intlayer/types": "9.5.10",
|
|
155
155
|
"defu": "6.1.7",
|
|
156
156
|
"node-loader": "2.1.0",
|
|
157
|
-
"react-intlayer": "9.5.
|
|
157
|
+
"react-intlayer": "9.5.10"
|
|
158
158
|
},
|
|
159
159
|
"devDependencies": {
|
|
160
160
|
"@types/node": "^22",
|
|
@@ -166,7 +166,7 @@
|
|
|
166
166
|
"rimraf": "6.1.3",
|
|
167
167
|
"tsdown": "0.23.0",
|
|
168
168
|
"typescript": "7.0.2",
|
|
169
|
-
"vitest": "5.0.
|
|
169
|
+
"vitest": "5.0.2"
|
|
170
170
|
},
|
|
171
171
|
"peerDependencies": {
|
|
172
172
|
"next": ">=14.0.0",
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { DeclaredLocales } from "@intlayer/types/module_augmentation";
|
|
2
|
-
import { IntlayerConfig } from "@intlayer/types/config";
|
|
3
|
-
import { Dictionary } from "@intlayer/types/dictionary";
|
|
4
|
-
import { Locale as Locale$1 } from "@intlayer/types/allLocales";
|
|
5
|
-
import "@intlayer/types/locales";
|
|
6
|
-
import "@intlayer/config/built";
|
|
7
|
-
import "@intlayer/core/file";
|
|
8
|
-
import "@intlayer/core/formatters";
|
|
9
|
-
import "@intlayer/core/interpreter";
|
|
10
|
-
import "@intlayer/core/localization";
|
|
11
|
-
import "@intlayer/core/markdown";
|
|
12
|
-
import "@intlayer/core/transpiler";
|
|
13
|
-
import "@intlayer/core/utils";
|
|
14
|
-
export type { Locale$1 as Locale };
|