@common.js/next-intl 4.13.1
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/LICENSE +21 -0
- package/README.md +5 -0
- package/config.d.ts +4 -0
- package/dist/cjs/development/ExtractorCodec-D9Tw618d.cjs +7 -0
- package/dist/cjs/development/JSONCodec-CzA8ubPy.cjs +55 -0
- package/dist/cjs/development/POCodec-CWGHK-Gp.cjs +111 -0
- package/dist/cjs/development/plugin-DlFYUFWh.cjs +1613 -0
- package/dist/cjs/development/plugin.cjs +13 -0
- package/dist/esm/development/config.js +13 -0
- package/dist/esm/development/extractor/ExtractionCompiler.js +284 -0
- package/dist/esm/development/extractor/catalog/CatalogLocales.js +398 -0
- package/dist/esm/development/extractor/catalog/CatalogManager.js +1515 -0
- package/dist/esm/development/extractor/catalog/CatalogPersister.js +341 -0
- package/dist/esm/development/extractor/catalog/SaveScheduler.js +314 -0
- package/dist/esm/development/extractor/catalogLoader.js +288 -0
- package/dist/esm/development/extractor/extractMessages.js +180 -0
- package/dist/esm/development/extractor/extractionLoader.js +37 -0
- package/dist/esm/development/extractor/extractor/LRUCache.js +68 -0
- package/dist/esm/development/extractor/extractor/MessageExtractor.js +273 -0
- package/dist/esm/development/extractor/format/ExtractorCodec.js +13 -0
- package/dist/esm/development/extractor/format/codecs/JSONCodec.js +91 -0
- package/dist/esm/development/extractor/format/codecs/POCodec.js +227 -0
- package/dist/esm/development/extractor/format/index.js +289 -0
- package/dist/esm/development/extractor/normalizeExtractorConfig.js +91 -0
- package/dist/esm/development/extractor/source/SourceFileFilter.js +104 -0
- package/dist/esm/development/extractor/source/SourceFileScanner.js +297 -0
- package/dist/esm/development/extractor/source/SourceFileWatcher.js +610 -0
- package/dist/esm/development/extractor/utils.js +133 -0
- package/dist/esm/development/extractor.js +25 -0
- package/dist/esm/development/index.react-client.js +59 -0
- package/dist/esm/development/index.react-server.js +61 -0
- package/dist/esm/development/middleware/getAlternateLinksHeaderValue.js +142 -0
- package/dist/esm/development/middleware/middleware.js +231 -0
- package/dist/esm/development/middleware/resolveLocale.js +150 -0
- package/dist/esm/development/middleware/syncCookie.js +87 -0
- package/dist/esm/development/middleware/utils.js +403 -0
- package/dist/esm/development/middleware.js +16 -0
- package/dist/esm/development/navigation/react-client/createNavigation.js +195 -0
- package/dist/esm/development/navigation/react-client/useBasePathname.js +46 -0
- package/dist/esm/development/navigation/react-server/createNavigation.js +111 -0
- package/dist/esm/development/navigation/react-server/getServerLocale.js +167 -0
- package/dist/esm/development/navigation/shared/BaseLink.js +115 -0
- package/dist/esm/development/navigation/shared/createSharedNavigationFns.js +214 -0
- package/dist/esm/development/navigation/shared/syncLocaleCookie.js +139 -0
- package/dist/esm/development/navigation/shared/utils.js +352 -0
- package/dist/esm/development/navigation.react-client.js +16 -0
- package/dist/esm/development/navigation.react-server.js +16 -0
- package/dist/esm/development/plugin/config.js +28 -0
- package/dist/esm/development/plugin/createNextIntlPlugin.js +66 -0
- package/dist/esm/development/plugin/declaration/createMessagesDeclaration.js +91 -0
- package/dist/esm/development/plugin/extractor/initExtractionCompiler.js +64 -0
- package/dist/esm/development/plugin/getNextConfig.js +355 -0
- package/dist/esm/development/plugin/nextFlags.js +47 -0
- package/dist/esm/development/plugin/utils.js +43 -0
- package/dist/esm/development/plugin/watchFile.js +32 -0
- package/dist/esm/development/plugin.js +16 -0
- package/dist/esm/development/react-client/index.js +67 -0
- package/dist/esm/development/react-server/NextIntlClientProviderServer.js +327 -0
- package/dist/esm/development/react-server/useConfig.js +40 -0
- package/dist/esm/development/react-server/useExtracted.js +21 -0
- package/dist/esm/development/react-server/useFormatter.js +21 -0
- package/dist/esm/development/react-server/useLocale.js +20 -0
- package/dist/esm/development/react-server/useMessages.js +21 -0
- package/dist/esm/development/react-server/useNow.js +25 -0
- package/dist/esm/development/react-server/useTimeZone.js +20 -0
- package/dist/esm/development/react-server/useTranslations.js +71 -0
- package/dist/esm/development/routing/config.js +82 -0
- package/dist/esm/development/routing/defineRouting.js +116 -0
- package/dist/esm/development/routing.js +16 -0
- package/dist/esm/development/server/react-client/index.js +68 -0
- package/dist/esm/development/server/react-server/RequestLocale.js +267 -0
- package/dist/esm/development/server/react-server/RequestLocaleCache.js +33 -0
- package/dist/esm/development/server/react-server/createRequestConfig.js +16 -0
- package/dist/esm/development/server/react-server/getConfig.js +283 -0
- package/dist/esm/development/server/react-server/getConfigNow.js +166 -0
- package/dist/esm/development/server/react-server/getDefaultNow.js +16 -0
- package/dist/esm/development/server/react-server/getExtracted.js +176 -0
- package/dist/esm/development/server/react-server/getFormats.js +166 -0
- package/dist/esm/development/server/react-server/getFormatter.js +186 -0
- package/dist/esm/development/server/react-server/getLocale.js +166 -0
- package/dist/esm/development/server/react-server/getMessages.js +194 -0
- package/dist/esm/development/server/react-server/getNow.js +164 -0
- package/dist/esm/development/server/react-server/getRequestConfig.js +15 -0
- package/dist/esm/development/server/react-server/getServerExtractor.js +108 -0
- package/dist/esm/development/server/react-server/getServerFormatter.js +81 -0
- package/dist/esm/development/server/react-server/getServerTranslator.js +70 -0
- package/dist/esm/development/server/react-server/getTimeZone.js +180 -0
- package/dist/esm/development/server/react-server/getTranslations.js +179 -0
- package/dist/esm/development/server/react-server/validateLocale.js +20 -0
- package/dist/esm/development/server.react-client.js +40 -0
- package/dist/esm/development/server.react-server.js +53 -0
- package/dist/esm/development/shared/NextIntlClientProvider.js +79 -0
- package/dist/esm/development/shared/constants.js +12 -0
- package/dist/esm/development/shared/use.js +59 -0
- package/dist/esm/development/shared/utils.js +201 -0
- package/dist/esm/production/config.js +13 -0
- package/dist/esm/production/extractor/ExtractionCompiler.js +275 -0
- package/dist/esm/production/extractor/catalog/CatalogLocales.js +384 -0
- package/dist/esm/production/extractor/catalog/CatalogManager.js +1401 -0
- package/dist/esm/production/extractor/catalog/CatalogPersister.js +334 -0
- package/dist/esm/production/extractor/catalog/SaveScheduler.js +278 -0
- package/dist/esm/production/extractor/catalogLoader.js +251 -0
- package/dist/esm/production/extractor/extractMessages.js +178 -0
- package/dist/esm/production/extractor/extractionLoader.js +27 -0
- package/dist/esm/production/extractor/extractor/LRUCache.js +59 -0
- package/dist/esm/production/extractor/extractor/MessageExtractor.js +259 -0
- package/dist/esm/production/extractor/format/ExtractorCodec.js +13 -0
- package/dist/esm/production/extractor/format/codecs/JSONCodec.js +83 -0
- package/dist/esm/production/extractor/format/codecs/POCodec.js +210 -0
- package/dist/esm/production/extractor/format/index.js +278 -0
- package/dist/esm/production/extractor/normalizeExtractorConfig.js +54 -0
- package/dist/esm/production/extractor/source/SourceFileFilter.js +99 -0
- package/dist/esm/production/extractor/source/SourceFileScanner.js +293 -0
- package/dist/esm/production/extractor/source/SourceFileWatcher.js +579 -0
- package/dist/esm/production/extractor/utils.js +108 -0
- package/dist/esm/production/extractor.js +25 -0
- package/dist/esm/production/index.react-client.js +59 -0
- package/dist/esm/production/index.react-server.js +61 -0
- package/dist/esm/production/middleware/getAlternateLinksHeaderValue.js +104 -0
- package/dist/esm/production/middleware/middleware.js +155 -0
- package/dist/esm/production/middleware/resolveLocale.js +99 -0
- package/dist/esm/production/middleware/syncCookie.js +81 -0
- package/dist/esm/production/middleware/utils.js +315 -0
- package/dist/esm/production/middleware.js +16 -0
- package/dist/esm/production/navigation/react-client/createNavigation.js +174 -0
- package/dist/esm/production/navigation/react-client/useBasePathname.js +32 -0
- package/dist/esm/production/navigation/react-server/createNavigation.js +110 -0
- package/dist/esm/production/navigation/react-server/getServerLocale.js +162 -0
- package/dist/esm/production/navigation/shared/BaseLink.js +98 -0
- package/dist/esm/production/navigation/shared/createSharedNavigationFns.js +182 -0
- package/dist/esm/production/navigation/shared/syncLocaleCookie.js +113 -0
- package/dist/esm/production/navigation/shared/utils.js +264 -0
- package/dist/esm/production/navigation.react-client.js +16 -0
- package/dist/esm/production/navigation.react-server.js +16 -0
- package/dist/esm/production/plugin/config.js +22 -0
- package/dist/esm/production/plugin/createNextIntlPlugin.js +48 -0
- package/dist/esm/production/plugin/declaration/createMessagesDeclaration.js +72 -0
- package/dist/esm/production/plugin/extractor/initExtractionCompiler.js +33 -0
- package/dist/esm/production/plugin/getNextConfig.js +242 -0
- package/dist/esm/production/plugin/nextFlags.js +44 -0
- package/dist/esm/production/plugin/utils.js +35 -0
- package/dist/esm/production/plugin/watchFile.js +26 -0
- package/dist/esm/production/plugin.js +16 -0
- package/dist/esm/production/react-client/index.js +57 -0
- package/dist/esm/production/react-server/NextIntlClientProviderServer.js +327 -0
- package/dist/esm/production/react-server/useConfig.js +35 -0
- package/dist/esm/production/react-server/useExtracted.js +21 -0
- package/dist/esm/production/react-server/useFormatter.js +21 -0
- package/dist/esm/production/react-server/useLocale.js +19 -0
- package/dist/esm/production/react-server/useMessages.js +21 -0
- package/dist/esm/production/react-server/useNow.js +22 -0
- package/dist/esm/production/react-server/useTimeZone.js +19 -0
- package/dist/esm/production/react-server/useTranslations.js +71 -0
- package/dist/esm/production/routing/config.js +77 -0
- package/dist/esm/production/routing/defineRouting.js +13 -0
- package/dist/esm/production/routing.js +16 -0
- package/dist/esm/production/server/react-client/index.js +51 -0
- package/dist/esm/production/server/react-server/RequestLocale.js +246 -0
- package/dist/esm/production/server/react-server/RequestLocaleCache.js +30 -0
- package/dist/esm/production/server/react-server/createRequestConfig.js +16 -0
- package/dist/esm/production/server/react-server/getConfig.js +262 -0
- package/dist/esm/production/server/react-server/getConfigNow.js +162 -0
- package/dist/esm/production/server/react-server/getDefaultNow.js +14 -0
- package/dist/esm/production/server/react-server/getExtracted.js +166 -0
- package/dist/esm/production/server/react-server/getFormats.js +157 -0
- package/dist/esm/production/server/react-server/getFormatter.js +179 -0
- package/dist/esm/production/server/react-server/getLocale.js +157 -0
- package/dist/esm/production/server/react-server/getMessages.js +190 -0
- package/dist/esm/production/server/react-server/getNow.js +164 -0
- package/dist/esm/production/server/react-server/getRequestConfig.js +13 -0
- package/dist/esm/production/server/react-server/getServerExtractor.js +20 -0
- package/dist/esm/production/server/react-server/getServerFormatter.js +78 -0
- package/dist/esm/production/server/react-server/getServerTranslator.js +69 -0
- package/dist/esm/production/server/react-server/getTimeZone.js +176 -0
- package/dist/esm/production/server/react-server/getTranslations.js +166 -0
- package/dist/esm/production/server.react-client.js +40 -0
- package/dist/esm/production/server.react-server.js +53 -0
- package/dist/esm/production/shared/NextIntlClientProvider.js +77 -0
- package/dist/esm/production/shared/constants.js +11 -0
- package/dist/esm/production/shared/use.js +51 -0
- package/dist/esm/production/shared/utils.js +156 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/types/extractor/ExtractionCompiler.d.ts +16 -0
- package/dist/types/extractor/catalog/CatalogLocales.d.ts +29 -0
- package/dist/types/extractor/catalog/CatalogManager.d.ts +76 -0
- package/dist/types/extractor/catalog/CatalogPersister.d.ts +20 -0
- package/dist/types/extractor/catalog/SaveScheduler.d.ts +18 -0
- package/dist/types/extractor/extractMessages.d.ts +2 -0
- package/dist/types/extractor/extractor/LRUCache.d.ts +7 -0
- package/dist/types/extractor/extractor/MessageExtractor.bench.d.ts +1 -0
- package/dist/types/extractor/extractor/MessageExtractor.d.ts +17 -0
- package/dist/types/extractor/format/ExtractorCodec.d.ts +33 -0
- package/dist/types/extractor/format/codecs/JSONCodec.d.ts +2 -0
- package/dist/types/extractor/format/codecs/POCodec.d.ts +2 -0
- package/dist/types/extractor/format/codecs/fixtures/JSONCodecStructured.d.ts +2 -0
- package/dist/types/extractor/format/codecs/fixtures/POCodecSourceMessageKey.d.ts +2 -0
- package/dist/types/extractor/format/index.d.ts +15 -0
- package/dist/types/extractor/format/types.d.ts +8 -0
- package/dist/types/extractor/index.d.ts +2 -0
- package/dist/types/extractor/normalizeExtractorConfig.d.ts +5 -0
- package/dist/types/extractor/source/SourceFileFilter.d.ts +8 -0
- package/dist/types/extractor/source/SourceFileScanner.d.ts +4 -0
- package/dist/types/extractor/source/SourceFileWatcher.d.ts +15 -0
- package/dist/types/extractor/types.d.ts +79 -0
- package/dist/types/extractor/utils.d.ts +9 -0
- package/dist/types/extractor.d.ts +1 -0
- package/dist/types/index.react-client.d.ts +8 -0
- package/dist/types/index.react-server.d.ts +1 -0
- package/dist/types/middleware/getAlternateLinksHeaderValue.d.ts +13 -0
- package/dist/types/middleware/index.d.ts +4 -0
- package/dist/types/middleware/middleware.d.ts +4 -0
- package/dist/types/middleware/resolveLocale.d.ts +9 -0
- package/dist/types/middleware/syncCookie.d.ts +7 -0
- package/dist/types/middleware/utils.d.ts +26 -0
- package/dist/types/middleware.d.ts +1 -0
- package/dist/types/navigation/react-client/createNavigation.d.ts +465 -0
- package/dist/types/navigation/react-client/index.d.ts +2 -0
- package/dist/types/navigation/react-client/useBasePathname.d.ts +5 -0
- package/dist/types/navigation/react-server/createNavigation.d.ts +384 -0
- package/dist/types/navigation/react-server/getServerLocale.d.ts +5 -0
- package/dist/types/navigation/react-server/index.d.ts +2 -0
- package/dist/types/navigation/shared/BaseLink.d.ts +11 -0
- package/dist/types/navigation/shared/StrictParams.d.ts +8 -0
- package/dist/types/navigation/shared/createSharedNavigationFns.d.ts +370 -0
- package/dist/types/navigation/shared/syncLocaleCookie.d.ts +8 -0
- package/dist/types/navigation/shared/utils.d.ts +53 -0
- package/dist/types/navigation.react-client.d.ts +1 -0
- package/dist/types/navigation.react-server.d.ts +1 -0
- package/dist/types/plugin/catalog/catalogLoader.d.ts +10 -0
- package/dist/types/plugin/config.d.ts +3 -0
- package/dist/types/plugin/createNextIntlPlugin.d.ts +3 -0
- package/dist/types/plugin/declaration/createMessagesDeclaration.d.ts +1 -0
- package/dist/types/plugin/declaration/index.d.ts +1 -0
- package/dist/types/plugin/extractor/extractionLoader.d.ts +3 -0
- package/dist/types/plugin/extractor/initExtractionCompiler.d.ts +2 -0
- package/dist/types/plugin/getNextConfig.d.ts +4 -0
- package/dist/types/plugin/index.d.ts +1 -0
- package/dist/types/plugin/nextFlags.d.ts +2 -0
- package/dist/types/plugin/types.d.ts +25 -0
- package/dist/types/plugin/utils.d.ts +8 -0
- package/dist/types/plugin/watchFile.d.ts +6 -0
- package/dist/types/plugin.d.ts +1 -0
- package/dist/types/react-client/index.d.ts +16 -0
- package/dist/types/react-server/NextIntlClientProviderServer.d.ts +5 -0
- package/dist/types/react-server/index.d.ts +16 -0
- package/dist/types/react-server/testUtils.d.ts +2 -0
- package/dist/types/react-server/useConfig.d.ts +2 -0
- package/dist/types/react-server/useExtracted.d.ts +2 -0
- package/dist/types/react-server/useFormatter.d.ts +2 -0
- package/dist/types/react-server/useLocale.d.ts +2 -0
- package/dist/types/react-server/useMessages.d.ts +2 -0
- package/dist/types/react-server/useNow.d.ts +2 -0
- package/dist/types/react-server/useTimeZone.d.ts +2 -0
- package/dist/types/react-server/useTranslations.d.ts +2 -0
- package/dist/types/routing/config.d.ts +73 -0
- package/dist/types/routing/defineRouting.d.ts +3 -0
- package/dist/types/routing/index.d.ts +3 -0
- package/dist/types/routing/types.d.ts +25 -0
- package/dist/types/routing.d.ts +1 -0
- package/dist/types/server/react-client/index.d.ts +10 -0
- package/dist/types/server/react-server/RequestLocale.d.ts +1 -0
- package/dist/types/server/react-server/RequestLocaleCache.d.ts +3 -0
- package/dist/types/server/react-server/createRequestConfig.d.ts +3 -0
- package/dist/types/server/react-server/getConfig.d.ts +13 -0
- package/dist/types/server/react-server/getConfigNow.d.ts +4 -0
- package/dist/types/server/react-server/getDefaultNow.d.ts +3 -0
- package/dist/types/server/react-server/getExtracted.d.ts +10 -0
- package/dist/types/server/react-server/getFormats.d.ts +3 -0
- package/dist/types/server/react-server/getFormatter.d.ts +10 -0
- package/dist/types/server/react-server/getLocale.d.ts +4 -0
- package/dist/types/server/react-server/getMessages.d.ts +6 -0
- package/dist/types/server/react-server/getNow.d.ts +4 -0
- package/dist/types/server/react-server/getRequestConfig.d.ts +35 -0
- package/dist/types/server/react-server/getServerExtractor.d.ts +5 -0
- package/dist/types/server/react-server/getServerFormatter.d.ts +29 -0
- package/dist/types/server/react-server/getServerTranslator.d.ts +4 -0
- package/dist/types/server/react-server/getTimeZone.d.ts +4 -0
- package/dist/types/server/react-server/getTranslations.d.ts +8 -0
- package/dist/types/server/react-server/index.d.ts +12 -0
- package/dist/types/server/react-server/validateLocale.d.ts +1 -0
- package/dist/types/server.react-client.d.ts +1 -0
- package/dist/types/server.react-server.d.ts +1 -0
- package/dist/types/shared/NextIntlClientProvider.d.ts +9 -0
- package/dist/types/shared/constants.d.ts +1 -0
- package/dist/types/shared/types.d.ts +5 -0
- package/dist/types/shared/use.d.ts +3 -0
- package/dist/types/shared/utils.d.ts +20 -0
- package/extractor/catalogLoader.d.ts +4 -0
- package/extractor/extractionLoader.d.ts +4 -0
- package/extractor.d.ts +2 -0
- package/middleware.d.ts +4 -0
- package/navigation.d.ts +2 -0
- package/package.json +60 -0
- package/plugin.d.cts +3 -0
- package/plugin.d.ts +4 -0
- package/routing.d.ts +2 -0
- package/server.d.ts +2 -0
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
applyPathnamePrefix: function() {
|
|
13
|
+
return applyPathnamePrefix;
|
|
14
|
+
},
|
|
15
|
+
compileLocalizedPathname: function() {
|
|
16
|
+
return compileLocalizedPathname;
|
|
17
|
+
},
|
|
18
|
+
getBasePath: function() {
|
|
19
|
+
return getBasePath;
|
|
20
|
+
},
|
|
21
|
+
getRoute: function() {
|
|
22
|
+
return getRoute;
|
|
23
|
+
},
|
|
24
|
+
normalizeNameOrNameWithParams: function() {
|
|
25
|
+
return normalizeNameOrNameWithParams;
|
|
26
|
+
},
|
|
27
|
+
serializeSearchParams: function() {
|
|
28
|
+
return serializeSearchParams;
|
|
29
|
+
},
|
|
30
|
+
validateReceivedConfig: function() {
|
|
31
|
+
return validateReceivedConfig;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
var _utilsJs = require("../../shared/utils.js");
|
|
35
|
+
function _arrayLikeToArray(arr, len) {
|
|
36
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
37
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
38
|
+
return arr2;
|
|
39
|
+
}
|
|
40
|
+
function _arrayWithHoles(arr) {
|
|
41
|
+
if (Array.isArray(arr)) return arr;
|
|
42
|
+
}
|
|
43
|
+
function _defineProperty(obj, key, value) {
|
|
44
|
+
if (key in obj) {
|
|
45
|
+
Object.defineProperty(obj, key, {
|
|
46
|
+
value: value,
|
|
47
|
+
enumerable: true,
|
|
48
|
+
configurable: true,
|
|
49
|
+
writable: true
|
|
50
|
+
});
|
|
51
|
+
} else {
|
|
52
|
+
obj[key] = value;
|
|
53
|
+
}
|
|
54
|
+
return obj;
|
|
55
|
+
}
|
|
56
|
+
function _iterableToArrayLimit(arr, i) {
|
|
57
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
58
|
+
if (_i == null) return;
|
|
59
|
+
var _arr = [];
|
|
60
|
+
var _n = true;
|
|
61
|
+
var _d = false;
|
|
62
|
+
var _s, _e;
|
|
63
|
+
try {
|
|
64
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
65
|
+
_arr.push(_s.value);
|
|
66
|
+
if (i && _arr.length === i) break;
|
|
67
|
+
}
|
|
68
|
+
} catch (err) {
|
|
69
|
+
_d = true;
|
|
70
|
+
_e = err;
|
|
71
|
+
} finally{
|
|
72
|
+
try {
|
|
73
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
74
|
+
} finally{
|
|
75
|
+
if (_d) throw _e;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return _arr;
|
|
79
|
+
}
|
|
80
|
+
function _nonIterableRest() {
|
|
81
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
82
|
+
}
|
|
83
|
+
function _objectSpread(target) {
|
|
84
|
+
for(var i = 1; i < arguments.length; i++){
|
|
85
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
86
|
+
var ownKeys = Object.keys(source);
|
|
87
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
88
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
89
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
ownKeys.forEach(function(key) {
|
|
93
|
+
_defineProperty(target, key, source[key]);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return target;
|
|
97
|
+
}
|
|
98
|
+
function ownKeys(object, enumerableOnly) {
|
|
99
|
+
var keys = Object.keys(object);
|
|
100
|
+
if (Object.getOwnPropertySymbols) {
|
|
101
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
102
|
+
if (enumerableOnly) {
|
|
103
|
+
symbols = symbols.filter(function(sym) {
|
|
104
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
keys.push.apply(keys, symbols);
|
|
108
|
+
}
|
|
109
|
+
return keys;
|
|
110
|
+
}
|
|
111
|
+
function _objectSpreadProps(target, source) {
|
|
112
|
+
source = source != null ? source : {};
|
|
113
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
114
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
115
|
+
} else {
|
|
116
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
117
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return target;
|
|
121
|
+
}
|
|
122
|
+
function _objectWithoutProperties(source, excluded) {
|
|
123
|
+
if (source == null) return {};
|
|
124
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
125
|
+
var key, i;
|
|
126
|
+
if (Object.getOwnPropertySymbols) {
|
|
127
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
128
|
+
for(i = 0; i < sourceSymbolKeys.length; i++){
|
|
129
|
+
key = sourceSymbolKeys[i];
|
|
130
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
131
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
132
|
+
target[key] = source[key];
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return target;
|
|
136
|
+
}
|
|
137
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
138
|
+
if (source == null) return {};
|
|
139
|
+
var target = {};
|
|
140
|
+
var sourceKeys = Object.keys(source);
|
|
141
|
+
var key, i;
|
|
142
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
143
|
+
key = sourceKeys[i];
|
|
144
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
145
|
+
target[key] = source[key];
|
|
146
|
+
}
|
|
147
|
+
return target;
|
|
148
|
+
}
|
|
149
|
+
function _slicedToArray(arr, i) {
|
|
150
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
151
|
+
}
|
|
152
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
153
|
+
if (!o) return;
|
|
154
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
155
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
156
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
157
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
158
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
159
|
+
}
|
|
160
|
+
// Minor false positive: A route that has both optional and
|
|
161
|
+
// required params will allow optional params.
|
|
162
|
+
// For `Link`
|
|
163
|
+
// For `getPathname` (hence also its consumers: `redirect`, `useRouter`, …)
|
|
164
|
+
function normalizeNameOrNameWithParams(href) {
|
|
165
|
+
return typeof href === "string" ? {
|
|
166
|
+
pathname: href
|
|
167
|
+
} : href;
|
|
168
|
+
}
|
|
169
|
+
function serializeSearchParams(searchParams) {
|
|
170
|
+
var serializeValue = function serializeValue(value) {
|
|
171
|
+
return String(value);
|
|
172
|
+
};
|
|
173
|
+
var urlSearchParams = new URLSearchParams();
|
|
174
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
175
|
+
try {
|
|
176
|
+
var _loop = function() {
|
|
177
|
+
var _value = _slicedToArray(_step.value, 2), key = _value[0], value = _value[1];
|
|
178
|
+
if (Array.isArray(value)) {
|
|
179
|
+
value.forEach(function(cur) {
|
|
180
|
+
urlSearchParams.append(key, serializeValue(cur));
|
|
181
|
+
});
|
|
182
|
+
} else {
|
|
183
|
+
urlSearchParams.set(key, serializeValue(value));
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
for(var _iterator = Object.entries(searchParams)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
187
|
+
} catch (err) {
|
|
188
|
+
_didIteratorError = true;
|
|
189
|
+
_iteratorError = err;
|
|
190
|
+
} finally{
|
|
191
|
+
try {
|
|
192
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
193
|
+
_iterator.return();
|
|
194
|
+
}
|
|
195
|
+
} finally{
|
|
196
|
+
if (_didIteratorError) {
|
|
197
|
+
throw _iteratorError;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return "?" + urlSearchParams.toString();
|
|
202
|
+
}
|
|
203
|
+
function compileLocalizedPathname(param) {
|
|
204
|
+
var pathname = param.pathname, locale = param.locale, params = param.params, pathnames = param.pathnames, query = param.query;
|
|
205
|
+
var compilePath = function compilePath(value) {
|
|
206
|
+
var pathnameConfig = pathnames[value];
|
|
207
|
+
var compiled;
|
|
208
|
+
if (pathnameConfig) {
|
|
209
|
+
var template = (0, _utilsJs.getLocalizedTemplate)(pathnameConfig, locale, value);
|
|
210
|
+
compiled = template;
|
|
211
|
+
if (params) {
|
|
212
|
+
Object.entries(params).forEach(function(param) {
|
|
213
|
+
var _param = _slicedToArray(param, 2), key = _param[0], paramValue = _param[1];
|
|
214
|
+
var regexp, replacer;
|
|
215
|
+
if (Array.isArray(paramValue)) {
|
|
216
|
+
regexp = "(\\[)?\\[...".concat(key, "\\](\\])?");
|
|
217
|
+
replacer = paramValue.map(function(v) {
|
|
218
|
+
return String(v);
|
|
219
|
+
}).join("/");
|
|
220
|
+
} else {
|
|
221
|
+
regexp = "\\[".concat(key, "\\]");
|
|
222
|
+
replacer = String(paramValue);
|
|
223
|
+
}
|
|
224
|
+
compiled = compiled.replace(new RegExp(regexp, "g"), replacer);
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
// Clean up optional catch-all segments that were not replaced
|
|
228
|
+
compiled = compiled.replace(/\[\[\.\.\..+\]\]/g, "");
|
|
229
|
+
if (compiled.includes("[")) {
|
|
230
|
+
// Next.js throws anyway, therefore better provide a more helpful error message
|
|
231
|
+
throw new Error("Insufficient params provided for localized pathname.\nTemplate: ".concat(template, "\nParams: ").concat(JSON.stringify(params)));
|
|
232
|
+
}
|
|
233
|
+
compiled = encodePathname(compiled);
|
|
234
|
+
} else {
|
|
235
|
+
// Unknown pathnames
|
|
236
|
+
compiled = value;
|
|
237
|
+
}
|
|
238
|
+
compiled = (0, _utilsJs.normalizeTrailingSlash)(compiled);
|
|
239
|
+
if (query) {
|
|
240
|
+
// This also encodes non-ASCII characters by
|
|
241
|
+
// using `new URLSearchParams()` internally
|
|
242
|
+
compiled += serializeSearchParams(query);
|
|
243
|
+
}
|
|
244
|
+
return compiled;
|
|
245
|
+
};
|
|
246
|
+
if (typeof pathname === "string") {
|
|
247
|
+
return compilePath(pathname);
|
|
248
|
+
} else {
|
|
249
|
+
var internalPathname = pathname.pathname, rest = _objectWithoutProperties(pathname, [
|
|
250
|
+
"pathname"
|
|
251
|
+
]);
|
|
252
|
+
var compiled = compilePath(internalPathname);
|
|
253
|
+
var result = _objectSpreadProps(_objectSpread({}, rest), {
|
|
254
|
+
pathname: compiled
|
|
255
|
+
});
|
|
256
|
+
return result;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
function encodePathname(pathname) {
|
|
260
|
+
// Generally, to comply with RFC 3986 and Google's best practices for URL structures
|
|
261
|
+
// (https://developers.google.com/search/docs/crawling-indexing/url-structure),
|
|
262
|
+
// we should always encode non-ASCII characters.
|
|
263
|
+
//
|
|
264
|
+
// There are two places where next-intl interacts with potentially non-ASCII URLs:
|
|
265
|
+
// 1. Middleware: When mapping a localized pathname to a non-localized pathname internally
|
|
266
|
+
// 2. Navigation APIs: When generating a URLs to be used for <Link /> & friends
|
|
267
|
+
//
|
|
268
|
+
// Next.js normalizes incoming pathnames to always be encoded, therefore we can safely
|
|
269
|
+
// decode them there (see middleware.tsx). On the other hand, Next.js doesn't consistently
|
|
270
|
+
// encode non-ASCII characters that are passed to navigation APIs:
|
|
271
|
+
// 1. <Link /> doesn't encode non-ASCII characters
|
|
272
|
+
// 2. useRouter() uses `new URL()` internally, which will encode—but only if necessary
|
|
273
|
+
// 3. redirect() uses useRouter() on the client, but on the server side only
|
|
274
|
+
// assigns the location header without encoding.
|
|
275
|
+
//
|
|
276
|
+
// In addition to this, for getPathname() we need to encode non-ASCII characters.
|
|
277
|
+
//
|
|
278
|
+
// Therefore, the bottom line is that next-intl should take care of encoding non-ASCII
|
|
279
|
+
// characters in all cases, but can rely on `new URL()` to not double-encode characters.
|
|
280
|
+
return new URL(pathname, "http://l").pathname;
|
|
281
|
+
}
|
|
282
|
+
function getRoute(locale, pathname, pathnames) {
|
|
283
|
+
var sortedPathnames = (0, _utilsJs.getSortedPathnames)(Object.keys(pathnames));
|
|
284
|
+
var decoded = decodeURI(pathname);
|
|
285
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
286
|
+
try {
|
|
287
|
+
for(var _iterator = sortedPathnames[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
288
|
+
var internalPathname = _step.value;
|
|
289
|
+
var localizedPathnamesOrPathname = pathnames[internalPathname];
|
|
290
|
+
if (typeof localizedPathnamesOrPathname === "string") {
|
|
291
|
+
var localizedPathname = localizedPathnamesOrPathname;
|
|
292
|
+
if ((0, _utilsJs.matchesPathname)(localizedPathname, decoded)) {
|
|
293
|
+
return internalPathname;
|
|
294
|
+
}
|
|
295
|
+
} else {
|
|
296
|
+
if ((0, _utilsJs.matchesPathname)((0, _utilsJs.getLocalizedTemplate)(localizedPathnamesOrPathname, locale, internalPathname), decoded)) {
|
|
297
|
+
return internalPathname;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
} catch (err) {
|
|
302
|
+
_didIteratorError = true;
|
|
303
|
+
_iteratorError = err;
|
|
304
|
+
} finally{
|
|
305
|
+
try {
|
|
306
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
307
|
+
_iterator.return();
|
|
308
|
+
}
|
|
309
|
+
} finally{
|
|
310
|
+
if (_didIteratorError) {
|
|
311
|
+
throw _iteratorError;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return pathname;
|
|
316
|
+
}
|
|
317
|
+
function getBasePath(pathname) {
|
|
318
|
+
var windowPathname = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : window.location.pathname;
|
|
319
|
+
if (pathname === "/") {
|
|
320
|
+
return windowPathname;
|
|
321
|
+
} else {
|
|
322
|
+
return windowPathname.replace(pathname, "");
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
function applyPathnamePrefix(pathname, locale, routing, force) {
|
|
326
|
+
var _localePrefix = routing.localePrefix, routingMode = _localePrefix.mode;
|
|
327
|
+
var shouldPrefix;
|
|
328
|
+
if (force !== undefined) {
|
|
329
|
+
shouldPrefix = force;
|
|
330
|
+
} else if ((0, _utilsJs.isLocalizableHref)(pathname)) {
|
|
331
|
+
var ref;
|
|
332
|
+
// Since locales are unique per domain, there should be
|
|
333
|
+
// only one domain that contains the locale
|
|
334
|
+
var domain = (ref = routing.domains) === null || ref === void 0 ? void 0 : ref.find(function(cur) {
|
|
335
|
+
return cur.locales.includes(locale);
|
|
336
|
+
});
|
|
337
|
+
// Domains can override the mode
|
|
338
|
+
var mode = (domain === null || domain === void 0 ? void 0 : domain.localePrefix) || routingMode;
|
|
339
|
+
if (mode === "always") {
|
|
340
|
+
shouldPrefix = true;
|
|
341
|
+
} else if (mode === "as-needed") {
|
|
342
|
+
shouldPrefix = domain ? locale !== domain.defaultLocale : locale !== routing.defaultLocale;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return shouldPrefix ? (0, _utilsJs.prefixPathname)((0, _utilsJs.getLocalePrefix)(locale, routing.localePrefix), pathname) : pathname;
|
|
346
|
+
}
|
|
347
|
+
function validateReceivedConfig(config) {
|
|
348
|
+
var ref;
|
|
349
|
+
if (((ref = config.localePrefix) === null || ref === void 0 ? void 0 : ref.mode) === "as-needed" && !("defaultLocale" in config)) {
|
|
350
|
+
throw new Error("`localePrefix: 'as-needed' requires a `defaultLocale`.");
|
|
351
|
+
}
|
|
352
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "createNavigation", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _createNavigationJs.default;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _createNavigationJs = /*#__PURE__*/ _interopRequireDefault(require("./navigation/react-client/createNavigation.js"));
|
|
12
|
+
function _interopRequireDefault(obj) {
|
|
13
|
+
return obj && obj.__esModule ? obj : {
|
|
14
|
+
default: obj
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "createNavigation", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _createNavigationJs.default;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _createNavigationJs = /*#__PURE__*/ _interopRequireDefault(require("./navigation/react-server/createNavigation.js"));
|
|
12
|
+
function _interopRequireDefault(obj) {
|
|
13
|
+
return obj && obj.__esModule ? obj : {
|
|
14
|
+
default: obj
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Avoid rollup's `replace` plugin to compile this away
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
function _export(target, all) {
|
|
7
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
isDevelopment: function() {
|
|
14
|
+
return isDevelopment;
|
|
15
|
+
},
|
|
16
|
+
isDevelopmentOrNextBuild: function() {
|
|
17
|
+
return isDevelopmentOrNextBuild;
|
|
18
|
+
},
|
|
19
|
+
isNextBuild: function() {
|
|
20
|
+
return isNextBuild;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
var nodeEnvKey = "NODE_ENV".trim();
|
|
24
|
+
// We avoid reading `argv.includes('dev')` related to
|
|
25
|
+
// https://github.com/amannn/next-intl/issues/2006
|
|
26
|
+
var isDevelopment = process.env[nodeEnvKey] === "development";
|
|
27
|
+
var isNextBuild = process.argv.includes("build");
|
|
28
|
+
var isDevelopmentOrNextBuild = isDevelopment || isNextBuild;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return createNextIntlPlugin;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _normalizeExtractorConfigJs = /*#__PURE__*/ _interopRequireDefault(require("../extractor/normalizeExtractorConfig.js"));
|
|
12
|
+
var _initExtractionCompilerJs = /*#__PURE__*/ _interopRequireDefault(require("./extractor/initExtractionCompiler.js"));
|
|
13
|
+
var _getNextConfigJs = /*#__PURE__*/ _interopRequireDefault(require("./getNextConfig.js"));
|
|
14
|
+
var _utilsJs = require("./utils.js");
|
|
15
|
+
var _createMessagesDeclarationJs = /*#__PURE__*/ _interopRequireDefault(require("./declaration/createMessagesDeclaration.js"));
|
|
16
|
+
function _interopRequireDefault(obj) {
|
|
17
|
+
return obj && obj.__esModule ? obj : {
|
|
18
|
+
default: obj
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function initPlugin(pluginConfig, nextConfig) {
|
|
22
|
+
var ref;
|
|
23
|
+
if ((nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.i18n) != null) {
|
|
24
|
+
(0, _utilsJs.warn)("An `i18n` property was found in your Next.js config. This likely causes conflicts and should therefore be removed if you use the App Router.\n\nIf you're in progress of migrating from the Pages Router, you can refer to this example: https://next-intl.dev/examples#app-router-migration\n");
|
|
25
|
+
}
|
|
26
|
+
var skipWatchers = isNextTelemetryDetachedFlushProcess();
|
|
27
|
+
var messagesPathOrPaths = (ref = pluginConfig.experimental) === null || ref === void 0 ? void 0 : ref.createMessagesDeclaration;
|
|
28
|
+
if (messagesPathOrPaths && !skipWatchers) {
|
|
29
|
+
(0, _createMessagesDeclarationJs.default)(typeof messagesPathOrPaths === "string" ? [
|
|
30
|
+
messagesPathOrPaths
|
|
31
|
+
] : messagesPathOrPaths);
|
|
32
|
+
}
|
|
33
|
+
var extractorConfig;
|
|
34
|
+
var experimental = pluginConfig.experimental;
|
|
35
|
+
var extract = experimental === null || experimental === void 0 ? void 0 : experimental.extract;
|
|
36
|
+
if (extract) {
|
|
37
|
+
extractorConfig = (0, _normalizeExtractorConfigJs.default)({
|
|
38
|
+
extract: extract,
|
|
39
|
+
messages: experimental.messages,
|
|
40
|
+
srcPath: experimental.srcPath
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (!skipWatchers) {
|
|
44
|
+
(0, _initExtractionCompilerJs.default)(extractorConfig);
|
|
45
|
+
}
|
|
46
|
+
return (0, _getNextConfigJs.default)(pluginConfig, nextConfig, extractorConfig);
|
|
47
|
+
}
|
|
48
|
+
function createNextIntlPlugin() {
|
|
49
|
+
var i18nPathOrConfig = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
50
|
+
var config = typeof i18nPathOrConfig === "string" ? {
|
|
51
|
+
requestConfig: i18nPathOrConfig
|
|
52
|
+
} : i18nPathOrConfig;
|
|
53
|
+
return function withNextIntl(nextConfig) {
|
|
54
|
+
return initPlugin(config, nextConfig);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Next runs `telemetry/detached-flush.js` in a detached process to flush telemetry
|
|
59
|
+
* (often when `next dev` exits). That loads dev `next.config` with inherited
|
|
60
|
+
* `NODE_ENV=development`, which would otherwise start orphan plugin watchers.
|
|
61
|
+
*/ function isNextTelemetryDetachedFlushProcess() {
|
|
62
|
+
var scriptPath = process.argv[1];
|
|
63
|
+
if (!scriptPath) return false;
|
|
64
|
+
var normalized = scriptPath.replace(/\\/g, "/");
|
|
65
|
+
return normalized.includes("/telemetry/detached-flush");
|
|
66
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return createMessagesDeclaration;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
12
|
+
var _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
13
|
+
var _utilsJs = require("../utils.js");
|
|
14
|
+
var _watchFileJs = /*#__PURE__*/ _interopRequireDefault(require("../watchFile.js"));
|
|
15
|
+
function _interopRequireDefault(obj) {
|
|
16
|
+
return obj && obj.__esModule ? obj : {
|
|
17
|
+
default: obj
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
var runOnce = (0, _utilsJs.once)("_NEXT_INTL_COMPILE_MESSAGES");
|
|
21
|
+
function createMessagesDeclaration(messagesPaths) {
|
|
22
|
+
// Instead of running _only_ in certain cases, it's
|
|
23
|
+
// safer to _avoid_ running for certain known cases.
|
|
24
|
+
// https://github.com/amannn/next-intl/issues/2006
|
|
25
|
+
var shouldBailOut = [
|
|
26
|
+
"info",
|
|
27
|
+
"start"
|
|
28
|
+
].some(function(arg) {
|
|
29
|
+
return process.argv.includes(arg);
|
|
30
|
+
});
|
|
31
|
+
if (shouldBailOut) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
runOnce(function() {
|
|
35
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
36
|
+
try {
|
|
37
|
+
for(var _iterator = messagesPaths[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
38
|
+
var messagesPath = _step.value;
|
|
39
|
+
var fullPath = _path.default.resolve(messagesPath);
|
|
40
|
+
if (!_fs.default.existsSync(fullPath)) {
|
|
41
|
+
(0, _utilsJs.throwError)("`createMessagesDeclaration` points to a non-existent file: ".concat(fullPath));
|
|
42
|
+
}
|
|
43
|
+
if (!fullPath.endsWith(".json")) {
|
|
44
|
+
(0, _utilsJs.throwError)("`createMessagesDeclaration` needs to point to a JSON file. Received: ".concat(fullPath));
|
|
45
|
+
}
|
|
46
|
+
// Keep this as a runtime check and don't replace
|
|
47
|
+
// this with a constant during the build process
|
|
48
|
+
var env = process.env["NODE_ENV".trim()];
|
|
49
|
+
compileDeclaration(messagesPath);
|
|
50
|
+
if (env === "development") {
|
|
51
|
+
startWatching(messagesPath);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
} catch (err) {
|
|
55
|
+
_didIteratorError = true;
|
|
56
|
+
_iteratorError = err;
|
|
57
|
+
} finally{
|
|
58
|
+
try {
|
|
59
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
60
|
+
_iterator.return();
|
|
61
|
+
}
|
|
62
|
+
} finally{
|
|
63
|
+
if (_didIteratorError) {
|
|
64
|
+
throw _iteratorError;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function startWatching(messagesPath) {
|
|
71
|
+
var watcher = (0, _watchFileJs.default)(messagesPath, function() {
|
|
72
|
+
compileDeclaration(messagesPath, true);
|
|
73
|
+
});
|
|
74
|
+
process.on("exit", function() {
|
|
75
|
+
watcher.close();
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function compileDeclaration(messagesPath) {
|
|
79
|
+
var async = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
80
|
+
var createDeclaration = function createDeclaration(content) {
|
|
81
|
+
return "// This file is auto-generated by next-intl, do not edit directly.\n// See: https://next-intl.dev/docs/workflows/typescript#messages-arguments\n\ndeclare const messages: ".concat(content.trim(), ";\nexport default messages;");
|
|
82
|
+
};
|
|
83
|
+
var declarationPath = messagesPath.replace(/\.json$/, ".d.json.ts");
|
|
84
|
+
if (async) {
|
|
85
|
+
return _fs.default.promises.readFile(messagesPath, "utf-8").then(function(content) {
|
|
86
|
+
return _fs.default.promises.writeFile(declarationPath, createDeclaration(content));
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
var content = _fs.default.readFileSync(messagesPath, "utf-8");
|
|
90
|
+
_fs.default.writeFileSync(declarationPath, createDeclaration(content));
|
|
91
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return initExtractionCompiler;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _extractionCompilerJs = /*#__PURE__*/ _interopRequireDefault(require("../../extractor/ExtractionCompiler.js"));
|
|
12
|
+
var _utilsJs = require("../../extractor/utils.js");
|
|
13
|
+
var _configJs = require("../config.js");
|
|
14
|
+
var _utilsJs1 = require("../utils.js");
|
|
15
|
+
function _interopRequireDefault(obj) {
|
|
16
|
+
return obj && obj.__esModule ? obj : {
|
|
17
|
+
default: obj
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
// Single compiler instance, initialized once per process
|
|
21
|
+
var compiler;
|
|
22
|
+
var runOnce = (0, _utilsJs1.once)("_NEXT_INTL_EXTRACT");
|
|
23
|
+
function initExtractionCompiler(extractorConfig) {
|
|
24
|
+
if (!extractorConfig || !(0, _utilsJs.hasLocalesToExtract)(extractorConfig)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
// Avoid running for:
|
|
28
|
+
// - info
|
|
29
|
+
// - start
|
|
30
|
+
// - typegen
|
|
31
|
+
//
|
|
32
|
+
// Doesn't consult Next.js config anyway:
|
|
33
|
+
// - lint
|
|
34
|
+
// - telemetry (however, the `detached-flush` DOES - see `createNextIntlPlugin`)
|
|
35
|
+
//
|
|
36
|
+
// What remains are:
|
|
37
|
+
// - dev (NODE_ENV=development)
|
|
38
|
+
// - build (NODE_ENV=production)
|
|
39
|
+
var shouldRun = _configJs.isDevelopment || _configJs.isNextBuild;
|
|
40
|
+
if (!shouldRun) return;
|
|
41
|
+
runOnce(function() {
|
|
42
|
+
var cleanup = function cleanup() {
|
|
43
|
+
if (compiler) {
|
|
44
|
+
compiler[Symbol.dispose]();
|
|
45
|
+
compiler = undefined;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
compiler = new _extractionCompilerJs.default(extractorConfig, {
|
|
49
|
+
isDevelopment: _configJs.isDevelopment,
|
|
50
|
+
projectRoot: process.cwd()
|
|
51
|
+
});
|
|
52
|
+
// Fire-and-forget: Start extraction, don't block config return.
|
|
53
|
+
// In dev mode, this also starts the file watcher.
|
|
54
|
+
// In prod, ideally we would wait until the extraction is complete,
|
|
55
|
+
// but we can't `await` anywhere (at least for Turbopack).
|
|
56
|
+
// The result is ok though, as if we encounter untranslated messages,
|
|
57
|
+
// we'll simply add empty messages to the catalog. So for actually
|
|
58
|
+
// running the app, there is no difference.
|
|
59
|
+
compiler.extractAll();
|
|
60
|
+
process.on("exit", cleanup);
|
|
61
|
+
process.on("SIGINT", cleanup);
|
|
62
|
+
process.on("SIGTERM", cleanup);
|
|
63
|
+
});
|
|
64
|
+
}
|