deploy: v0.12 fix 存档key名

This commit is contained in:
2026-06-24 03:09:02 +00:00
parent 7a08d49fe3
commit e0a5281119
58743 changed files with 7297269 additions and 39505 deletions
@@ -0,0 +1,32 @@
/**
* Allows to import `next-intl/server` in non-RSC environments.
*
* This is mostly relevant for testing, since e.g. a `generateMetadata`
* export from a page might use `next-intl/server`, but the test
* only uses the default export for a page.
*/
function notSupported(message) {
return () => {
throw new Error(`\`${message}\` is not supported in Client Components.`);
};
}
function getRequestConfig(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
...args) {
return notSupported('getRequestConfig');
}
const getFormatter = notSupported('getFormatter');
const getNow = notSupported('getNow');
const getTimeZone = notSupported('getTimeZone');
const getMessages = notSupported('getMessages');
const getLocale = notSupported('getLocale');
const getExtracted = notSupported('getExtracted');
// The type of `getTranslations` is not assigned here because it
// causes a type error. The types use the `react-server` entry
// anyway, therefore this is irrelevant.
const getTranslations = notSupported('getTranslations');
const setRequestLocale = notSupported('setRequestLocale');
export { getExtracted, getFormatter, getLocale, getMessages, getNow, getRequestConfig, getTimeZone, getTranslations, setRequestLocale };
@@ -0,0 +1,36 @@
import { headers } from 'next/headers';
import { cache } from 'react';
import { HEADER_LOCALE_NAME } from '../../shared/constants.js';
import { isPromise } from '../../shared/utils.js';
import { getCachedRequestLocale } from './RequestLocaleCache.js';
async function getHeadersImpl() {
const promiseOrValue = headers();
// Compatibility with Next.js <15
return isPromise(promiseOrValue) ? await promiseOrValue : promiseOrValue;
}
const getHeaders = cache(getHeadersImpl);
async function getLocaleFromHeaderImpl() {
let locale;
try {
locale = (await getHeaders()).get(HEADER_LOCALE_NAME) || undefined;
} catch (error) {
if (error instanceof Error && error.digest === 'DYNAMIC_SERVER_USAGE') {
const wrappedError = new Error('Usage of next-intl APIs in Server Components currently opts into dynamic rendering. This limitation will eventually be lifted, but as a stopgap solution, you can use the `setRequestLocale` API to enable static rendering, see https://next-intl.dev/docs/routing/setup#static-rendering', {
cause: error
});
wrappedError.digest = error.digest;
throw wrappedError;
} else {
throw error;
}
}
return locale;
}
const getLocaleFromHeader = cache(getLocaleFromHeaderImpl);
async function getRequestLocale() {
return getCachedRequestLocale() || (await getLocaleFromHeader());
}
export { getRequestLocale };
@@ -0,0 +1,18 @@
import { cache } from 'react';
// See https://github.com/vercel/next.js/discussions/58862
function getCacheImpl() {
const value = {
locale: undefined
};
return value;
}
const getCache = cache(getCacheImpl);
function getCachedRequestLocale() {
return getCache().locale;
}
function setCachedRequestLocale(locale) {
getCache().locale = locale;
}
export { getCachedRequestLocale, setCachedRequestLocale };
@@ -0,0 +1,2 @@
import getRuntimeConfig from 'next-intl/config';
export { default } from 'next-intl/config';
@@ -0,0 +1,59 @@
import { cache } from 'react';
import { initializeConfig, _createIntlFormatters, _createCache } from 'use-intl/core';
import { isPromise } from '../../shared/utils.js';
import { getRequestLocale } from './RequestLocale.js';
import getRuntimeConfig from 'next-intl/config';
import validateLocale from './validateLocale.js';
// This is automatically inherited by `NextIntlClientProvider` if
// the component is rendered from a Server Component
function getDefaultTimeZoneImpl() {
return Intl.DateTimeFormat().resolvedOptions().timeZone;
}
const getDefaultTimeZone = cache(getDefaultTimeZoneImpl);
async function receiveRuntimeConfigImpl(getConfig, localeOverride) {
if (typeof getConfig !== 'function') {
throw new Error(`Invalid i18n request configuration detected.
Please verify that:
1. In case you've specified a custom location in your Next.js config, make sure that the path is correct.
2. You have a default export in your i18n request configuration file.
See also: https://next-intl.dev/docs/usage/configuration#i18n-request
`);
}
const params = {
locale: localeOverride,
// In case the consumer doesn't read `params.locale` and instead provides the
// `locale` (either in a single-language workflow or because the locale is
// read from the user settings), don't attempt to read the request locale.
get requestLocale() {
return localeOverride ? Promise.resolve(localeOverride) : getRequestLocale();
}
};
let result = getConfig(params);
if (isPromise(result)) {
result = await result;
}
if (!result.locale) {
throw new Error('No locale was returned from `getRequestConfig`.\n\nSee https://next-intl.dev/docs/usage/configuration#i18n-request');
}
{
validateLocale(result.locale);
}
return result;
}
const receiveRuntimeConfig = cache(receiveRuntimeConfigImpl);
const getFormatters = cache(_createIntlFormatters);
const getCache = cache(_createCache);
async function getConfigImpl(localeOverride) {
const runtimeConfig = await receiveRuntimeConfig(getRuntimeConfig, localeOverride);
return {
...initializeConfig(runtimeConfig),
_formatters: getFormatters(getCache()),
timeZone: runtimeConfig.timeZone || getDefaultTimeZone()
};
}
const getConfig = cache(getConfigImpl);
export { getConfig as default };
@@ -0,0 +1,10 @@
import { cache } from 'react';
import getConfig from './getConfig.js';
async function getConfigNowImpl(locale) {
const config = await getConfig(locale);
return config.now;
}
const getConfigNow = cache(getConfigNowImpl);
export { getConfigNow as default };
@@ -0,0 +1,9 @@
import { cache } from 'react';
function defaultNow() {
// See https://next-intl.dev/docs/usage/dates-times#relative-times-server
return new Date();
}
const getDefaultNow = cache(defaultNow);
export { getDefaultNow as default };
@@ -0,0 +1,24 @@
import { cache } from 'react';
import getConfig from './getConfig.js';
import getServerExtractor from './getServerExtractor.js';
// Call signature 1: `getExtracted(namespace)`
// Call signature 2: `getExtracted({locale, namespace})`
// Implementation
async function getExtractedImpl(namespaceOrOpts) {
let namespace;
let locale;
if (typeof namespaceOrOpts === 'string') {
namespace = namespaceOrOpts;
} else if (namespaceOrOpts) {
locale = namespaceOrOpts.locale;
namespace = namespaceOrOpts.namespace;
}
const config = await getConfig(locale);
return getServerExtractor(config, namespace);
}
const getExtracted = cache(getExtractedImpl);
export { getExtracted as default };
@@ -0,0 +1,10 @@
import { cache } from 'react';
import getConfig from './getConfig.js';
async function getFormatsCachedImpl() {
const config = await getConfig();
return config.formats;
}
const getFormats = cache(getFormatsCachedImpl);
export { getFormats as default };
@@ -0,0 +1,21 @@
import { cache } from 'react';
import getConfig from './getConfig.js';
import getFormatterCached$1 from './getServerFormatter.js';
async function getFormatterCachedImpl(locale) {
const config = await getConfig(locale);
return getFormatterCached$1(config);
}
const getFormatterCached = cache(getFormatterCachedImpl);
/**
* Returns a formatter based on the given locale.
*
* The formatter automatically receives the request config, but
* you can override it by passing in additional options.
*/
async function getFormatter(opts) {
return getFormatterCached(opts?.locale);
}
export { getFormatter as default };
@@ -0,0 +1,10 @@
import { cache } from 'react';
import getConfig from './getConfig.js';
async function getLocaleCachedImpl() {
const config = await getConfig();
return config.locale;
}
const getLocaleCached = cache(getLocaleCachedImpl);
export { getLocaleCached as default };
@@ -0,0 +1,19 @@
import { cache } from 'react';
import getConfig from './getConfig.js';
function getMessagesFromConfig(config) {
if (!config.messages) {
throw new Error('No messages found. Have you configured them correctly? See https://next-intl.dev/docs/configuration#messages');
}
return config.messages;
}
async function getMessagesCachedImpl(locale) {
const config = await getConfig(locale);
return getMessagesFromConfig(config);
}
const getMessagesCached = cache(getMessagesCachedImpl);
async function getMessages(opts) {
return getMessagesCached(opts?.locale);
}
export { getMessages as default, getMessagesFromConfig };
@@ -0,0 +1,8 @@
import getConfigNow from './getConfigNow.js';
import getDefaultNow from './getDefaultNow.js';
async function getNow(opts) {
return (await getConfigNow(opts?.locale)) ?? getDefaultNow();
}
export { getNow as default };
@@ -0,0 +1,8 @@
/**
* Should be called in `i18n/request.ts` to create the configuration for the current request.
*/
function getRequestConfig(createRequestConfig) {
return createRequestConfig;
}
export { getRequestConfig as default };
@@ -0,0 +1,38 @@
import { cache } from 'react';
import getServerTranslator from './getServerTranslator.js';
// Note: This API is usually compiled into `useTranslations`,
// but there is some fallback handling which allows this hook
// to still work when not being compiled.
//
// This is relevant for:
// - Isolated environments like tests, Storybook, etc.
// - Fallbacks in case an extracted message is not yet available
function getServerExtractorImpl(config, namespace) {
const t = getServerTranslator(config, namespace);
function translateFn(...[message, values, formats]) {
return t(undefined, values, formats,
// @ts-expect-error -- Secret fallback parameter
message );
}
translateFn.rich = function translateRichFn(...[message, values, formats]) {
return t.rich(undefined, values, formats,
// @ts-expect-error -- Secret fallback parameter
message );
};
translateFn.markup = function translateMarkupFn(...[message, values, formats]) {
return t.markup(undefined, values, formats,
// @ts-expect-error -- Secret fallback parameter
message );
};
translateFn.has = function translateHasFn(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
...[message]) {
// Not really something better we can do here
return true;
};
return translateFn;
}
var getServerExtractor = cache(getServerExtractorImpl);
export { getServerExtractor as default };
@@ -0,0 +1,17 @@
import { cache } from 'react';
import { createFormatter } from 'use-intl/core';
import getDefaultNow from './getDefaultNow.js';
function getFormatterCachedImpl(config) {
return createFormatter({
...config,
// Only init when necessary to avoid triggering a `dynamicIO` error
// unnecessarily (`now` is only needed for `format.relativeTime`)
get now() {
return config.now ?? getDefaultNow();
}
});
}
const getFormatterCached = cache(getFormatterCachedImpl);
export { getFormatterCached as default };
@@ -0,0 +1,12 @@
import { cache } from 'react';
import { createTranslator } from 'use-intl/core';
function getServerTranslatorImpl(config, namespace) {
return createTranslator({
...config,
namespace
});
}
var getServerTranslator = cache(getServerTranslatorImpl);
export { getServerTranslator as default };
@@ -0,0 +1,13 @@
import { cache } from 'react';
import getConfig from './getConfig.js';
async function getTimeZoneCachedImpl(locale) {
const config = await getConfig(locale);
return config.timeZone;
}
const getTimeZoneCached = cache(getTimeZoneCachedImpl);
async function getTimeZone(opts) {
return getTimeZoneCached(opts?.locale);
}
export { getTimeZone as default };
@@ -0,0 +1,28 @@
import { cache } from 'react';
import getConfig from './getConfig.js';
import getServerTranslator from './getServerTranslator.js';
// Maintainer note: `getTranslations` has two different call signatures.
// We need to define these with function overloads, otherwise TypeScript
// messes up the return type.
// Call signature 1: `getTranslations(namespace)`
// Call signature 2: `getTranslations({locale, namespace})`
// Implementation
async function getTranslations(namespaceOrOpts) {
let namespace;
let locale;
if (typeof namespaceOrOpts === 'string') {
namespace = namespaceOrOpts;
} else if (namespaceOrOpts) {
locale = namespaceOrOpts.locale;
namespace = namespaceOrOpts.namespace;
}
const config = await getConfig(locale);
return getServerTranslator(config, namespace);
}
var getTranslations$1 = cache(getTranslations);
export { getTranslations$1 as default };
@@ -0,0 +1,12 @@
function validateLocale(locale) {
try {
const constructed = new Intl.Locale(locale);
if (!constructed.language) {
throw new Error('Language is required');
}
} catch {
console.error(`An invalid locale was provided: "${locale}"\nPlease ensure you're using a valid Unicode locale identifier (e.g. "en-US").`);
}
}
export { validateLocale as default };