@intlayer/config 6.1.6 → 7.0.0-canary.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/dist/cjs/_virtual/rolldown_runtime.cjs +34 -0
- package/dist/cjs/alias.cjs +27 -100
- package/dist/cjs/alias.cjs.map +1 -1
- package/dist/cjs/built.cjs +7 -25
- package/dist/cjs/built.cjs.map +1 -1
- package/dist/cjs/bundleJSFile.cjs +30 -51
- package/dist/cjs/bundleJSFile.cjs.map +1 -1
- package/dist/cjs/client.cjs +19 -52
- package/dist/cjs/configFile/buildConfigurationFields.cjs +100 -657
- package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
- package/dist/cjs/configFile/getConfiguration.cjs +60 -114
- package/dist/cjs/configFile/getConfiguration.cjs.map +1 -1
- package/dist/cjs/configFile/index.cjs +8 -25
- package/dist/cjs/configFile/loadConfigurationFile.cjs +22 -47
- package/dist/cjs/configFile/loadConfigurationFile.cjs.map +1 -1
- package/dist/cjs/configFile/searchConfigurationFile.cjs +49 -55
- package/dist/cjs/configFile/searchConfigurationFile.cjs.map +1 -1
- package/dist/cjs/defaultValues/build.cjs +23 -35
- package/dist/cjs/defaultValues/build.cjs.map +1 -1
- package/dist/cjs/defaultValues/content.cjs +68 -70
- package/dist/cjs/defaultValues/content.cjs.map +1 -1
- package/dist/cjs/defaultValues/editor.cjs +29 -41
- package/dist/cjs/defaultValues/editor.cjs.map +1 -1
- package/dist/cjs/defaultValues/index.cjs +62 -0
- package/dist/cjs/defaultValues/index.cjs.map +1 -0
- package/dist/cjs/defaultValues/internationalization.cjs +23 -34
- package/dist/cjs/defaultValues/internationalization.cjs.map +1 -1
- package/dist/cjs/defaultValues/log.cjs +17 -29
- package/dist/cjs/defaultValues/log.cjs.map +1 -1
- package/dist/cjs/defaultValues/routing.cjs +38 -0
- package/dist/cjs/defaultValues/routing.cjs.map +1 -0
- package/dist/cjs/extractErrorMessage.cjs +95 -0
- package/dist/cjs/extractErrorMessage.cjs.map +1 -0
- package/dist/cjs/index.cjs +67 -98
- package/dist/cjs/loadEnvFile.cjs +30 -51
- package/dist/cjs/loadEnvFile.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/bundleFile.cjs +74 -0
- package/dist/cjs/loadExternalFile/bundleFile.cjs.map +1 -0
- package/dist/cjs/loadExternalFile/loadExternalFile.cjs +86 -0
- package/dist/cjs/loadExternalFile/loadExternalFile.cjs.map +1 -0
- package/dist/cjs/loadExternalFile/parseFileContent.cjs +67 -0
- package/dist/cjs/loadExternalFile/parseFileContent.cjs.map +1 -0
- package/dist/cjs/loadExternalFile/transpileTSToMJS.cjs +60 -0
- package/dist/cjs/loadExternalFile/transpileTSToMJS.cjs.map +1 -0
- package/dist/cjs/logger.cjs +124 -152
- package/dist/cjs/logger.cjs.map +1 -1
- package/dist/cjs/package.cjs +12 -0
- package/dist/cjs/package.cjs.map +1 -0
- package/dist/cjs/retryManager.cjs +42 -49
- package/dist/cjs/retryManager.cjs.map +1 -1
- package/dist/cjs/utils/ESMxCJSHelpers.cjs +24 -33
- package/dist/cjs/utils/ESMxCJSHelpers.cjs.map +1 -1
- package/dist/cjs/utils/cache.cjs +426 -0
- package/dist/cjs/utils/cache.cjs.map +1 -0
- package/dist/cjs/utils/clearModuleCache.cjs +23 -46
- package/dist/cjs/utils/clearModuleCache.cjs.map +1 -1
- package/dist/cjs/utils/extractErrorMessage.cjs +95 -0
- package/dist/cjs/utils/extractErrorMessage.cjs.map +1 -0
- package/dist/cjs/utils/getExtension.cjs +12 -35
- package/dist/cjs/utils/getExtension.cjs.map +1 -1
- package/dist/cjs/utils/getPackageJsonPath.cjs +37 -0
- package/dist/cjs/utils/getPackageJsonPath.cjs.map +1 -0
- package/dist/cjs/utils/logStack.cjs +16 -0
- package/dist/cjs/utils/logStack.cjs.map +1 -0
- package/dist/cjs/utils/normalizePath.cjs +15 -27
- package/dist/cjs/utils/normalizePath.cjs.map +1 -1
- package/dist/esm/_virtual/rolldown_runtime.mjs +17 -0
- package/dist/esm/alias.mjs +23 -74
- package/dist/esm/alias.mjs.map +1 -1
- package/dist/esm/built.mjs +5 -3
- package/dist/esm/built.mjs.map +1 -1
- package/dist/esm/bundleJSFile.mjs +26 -25
- package/dist/esm/bundleJSFile.mjs.map +1 -1
- package/dist/esm/client.mjs +4 -31
- package/dist/esm/configFile/buildConfigurationFields.mjs +97 -674
- package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
- package/dist/esm/configFile/getConfiguration.mjs +52 -75
- package/dist/esm/configFile/getConfiguration.mjs.map +1 -1
- package/dist/esm/configFile/index.mjs +5 -3
- package/dist/esm/configFile/loadConfigurationFile.mjs +22 -23
- package/dist/esm/configFile/loadConfigurationFile.mjs.map +1 -1
- package/dist/esm/configFile/searchConfigurationFile.mjs +45 -30
- package/dist/esm/configFile/searchConfigurationFile.mjs.map +1 -1
- package/dist/esm/defaultValues/build.mjs +16 -11
- package/dist/esm/defaultValues/build.mjs.map +1 -1
- package/dist/esm/defaultValues/content.mjs +48 -34
- package/dist/esm/defaultValues/content.mjs.map +1 -1
- package/dist/esm/defaultValues/editor.mjs +17 -11
- package/dist/esm/defaultValues/editor.mjs.map +1 -1
- package/dist/esm/defaultValues/index.mjs +21 -0
- package/dist/esm/defaultValues/index.mjs.map +1 -0
- package/dist/esm/defaultValues/internationalization.mjs +13 -7
- package/dist/esm/defaultValues/internationalization.mjs.map +1 -1
- package/dist/esm/defaultValues/log.mjs +10 -4
- package/dist/esm/defaultValues/log.mjs.map +1 -1
- package/dist/esm/defaultValues/routing.mjs +25 -0
- package/dist/esm/defaultValues/routing.mjs.map +1 -0
- package/dist/esm/extractErrorMessage.mjs +94 -0
- package/dist/esm/extractErrorMessage.mjs.map +1 -0
- package/dist/esm/index.mjs +18 -61
- package/dist/esm/loadEnvFile.mjs +27 -17
- package/dist/esm/loadEnvFile.mjs.map +1 -1
- package/dist/esm/loadExternalFile/bundleFile.mjs +68 -0
- package/dist/esm/loadExternalFile/bundleFile.mjs.map +1 -0
- package/dist/esm/loadExternalFile/loadExternalFile.mjs +81 -0
- package/dist/esm/loadExternalFile/loadExternalFile.mjs.map +1 -0
- package/dist/esm/loadExternalFile/parseFileContent.mjs +63 -0
- package/dist/esm/loadExternalFile/parseFileContent.mjs.map +1 -0
- package/dist/esm/loadExternalFile/transpileTSToMJS.mjs +55 -0
- package/dist/esm/loadExternalFile/transpileTSToMJS.mjs.map +1 -0
- package/dist/esm/logger.mjs +110 -115
- package/dist/esm/logger.mjs.map +1 -1
- package/dist/esm/package.mjs +6 -0
- package/dist/esm/package.mjs.map +1 -0
- package/dist/esm/retryManager.mjs +40 -23
- package/dist/esm/retryManager.mjs.map +1 -1
- package/dist/esm/utils/ESMxCJSHelpers.mjs +20 -6
- package/dist/esm/utils/ESMxCJSHelpers.mjs.map +1 -1
- package/dist/esm/utils/cache.mjs +414 -0
- package/dist/esm/utils/cache.mjs.map +1 -0
- package/dist/esm/utils/clearModuleCache.mjs +22 -21
- package/dist/esm/utils/clearModuleCache.mjs.map +1 -1
- package/dist/esm/utils/extractErrorMessage.mjs +94 -0
- package/dist/esm/utils/extractErrorMessage.mjs.map +1 -0
- package/dist/esm/utils/getExtension.mjs +11 -11
- package/dist/esm/utils/getExtension.mjs.map +1 -1
- package/dist/esm/utils/getPackageJsonPath.mjs +33 -0
- package/dist/esm/utils/getPackageJsonPath.mjs.map +1 -0
- package/dist/esm/utils/logStack.mjs +16 -0
- package/dist/esm/utils/logStack.mjs.map +1 -0
- package/dist/esm/utils/normalizePath.mjs +14 -3
- package/dist/esm/utils/normalizePath.mjs.map +1 -1
- package/dist/types/alias.d.ts +20 -12
- package/dist/types/alias.d.ts.map +1 -1
- package/dist/types/built.d.ts +7 -6
- package/dist/types/built.d.ts.map +1 -1
- package/dist/types/bundleJSFile.d.ts +97 -93
- package/dist/types/bundleJSFile.d.ts.map +1 -1
- package/dist/types/client.d.ts +3 -5
- package/dist/types/configFile/buildConfigurationFields.d.ts +7 -2
- package/dist/types/configFile/buildConfigurationFields.d.ts.map +1 -1
- package/dist/types/configFile/getConfiguration.d.ts +19 -15
- package/dist/types/configFile/getConfiguration.d.ts.map +1 -1
- package/dist/types/configFile/index.d.ts +4 -3
- package/dist/types/configFile/loadConfigurationFile.d.ts +8 -3
- package/dist/types/configFile/loadConfigurationFile.d.ts.map +1 -1
- package/dist/types/configFile/searchConfigurationFile.d.ts +6 -4
- package/dist/types/configFile/searchConfigurationFile.d.ts.map +1 -1
- package/dist/types/defaultValues/build.d.ts +10 -4
- package/dist/types/defaultValues/build.d.ts.map +1 -1
- package/dist/types/defaultValues/content.d.ts +23 -16
- package/dist/types/defaultValues/content.d.ts.map +1 -1
- package/dist/types/defaultValues/editor.d.ts +14 -9
- package/dist/types/defaultValues/editor.d.ts.map +1 -1
- package/dist/types/defaultValues/index.d.ts +14 -0
- package/dist/types/defaultValues/index.d.ts.map +1 -0
- package/dist/types/defaultValues/internationalization.d.ts +12 -6
- package/dist/types/defaultValues/internationalization.d.ts.map +1 -1
- package/dist/types/defaultValues/log.d.ts +7 -2
- package/dist/types/defaultValues/log.d.ts.map +1 -1
- package/dist/types/defaultValues/routing.d.ts +14 -0
- package/dist/types/defaultValues/routing.d.ts.map +1 -0
- package/dist/types/extractErrorMessage.d.ts +5 -0
- package/dist/types/extractErrorMessage.d.ts.map +1 -0
- package/dist/types/index.d.ts +21 -17
- package/dist/types/loadEnvFile.d.ts +8 -5
- package/dist/types/loadEnvFile.d.ts.map +1 -1
- package/dist/types/loadExternalFile/bundleFile.d.ts +10 -0
- package/dist/types/loadExternalFile/bundleFile.d.ts.map +1 -0
- package/dist/types/loadExternalFile/loadExternalFile.d.ts +25 -0
- package/dist/types/loadExternalFile/loadExternalFile.d.ts.map +1 -0
- package/dist/types/loadExternalFile/parseFileContent.d.ts +29 -0
- package/dist/types/loadExternalFile/parseFileContent.d.ts.map +1 -0
- package/dist/types/loadExternalFile/transpileTSToMJS.d.ts +9 -0
- package/dist/types/loadExternalFile/transpileTSToMJS.d.ts.map +1 -0
- package/dist/types/logger.d.ts +41 -37
- package/dist/types/logger.d.ts.map +1 -1
- package/dist/types/retryManager.d.ts +26 -8
- package/dist/types/retryManager.d.ts.map +1 -1
- package/dist/types/utils/ESMxCJSHelpers.d.ts +16 -2
- package/dist/types/utils/ESMxCJSHelpers.d.ts.map +1 -1
- package/dist/types/utils/cache.d.ts +50 -0
- package/dist/types/utils/cache.d.ts.map +1 -0
- package/dist/types/utils/clearModuleCache.d.ts +4 -1
- package/dist/types/utils/clearModuleCache.d.ts.map +1 -1
- package/dist/types/utils/extractErrorMessage.d.ts +5 -0
- package/dist/types/utils/extractErrorMessage.d.ts.map +1 -0
- package/dist/types/utils/getExtension.d.ts +6 -2
- package/dist/types/utils/getExtension.d.ts.map +1 -1
- package/dist/types/utils/getPackageJsonPath.d.ts +10 -0
- package/dist/types/utils/getPackageJsonPath.d.ts.map +1 -0
- package/dist/types/utils/logStack.d.ts +7 -0
- package/dist/types/utils/logStack.d.ts.map +1 -0
- package/dist/types/utils/normalizePath.d.ts +4 -1
- package/dist/types/utils/normalizePath.d.ts.map +1 -1
- package/package.json +40 -35
- package/LICENSE +0 -202
- package/dist/cjs/client.cjs.map +0 -1
- package/dist/cjs/configFile/index.cjs.map +0 -1
- package/dist/cjs/defaultValues/middleware.cjs +0 -47
- package/dist/cjs/defaultValues/middleware.cjs.map +0 -1
- package/dist/cjs/getSandboxContext.cjs +0 -64
- package/dist/cjs/getSandboxContext.cjs.map +0 -1
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/loadExternalFile.cjs +0 -105
- package/dist/cjs/loadExternalFile.cjs.map +0 -1
- package/dist/cjs/types/config.cjs +0 -17
- package/dist/cjs/types/config.cjs.map +0 -1
- package/dist/cjs/types/locales.cjs +0 -310
- package/dist/cjs/types/locales.cjs.map +0 -1
- package/dist/esm/client.mjs.map +0 -1
- package/dist/esm/configFile/index.mjs.map +0 -1
- package/dist/esm/defaultValues/middleware.mjs +0 -17
- package/dist/esm/defaultValues/middleware.mjs.map +0 -1
- package/dist/esm/getSandboxContext.mjs +0 -40
- package/dist/esm/getSandboxContext.mjs.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/loadExternalFile.mjs +0 -81
- package/dist/esm/loadExternalFile.mjs.map +0 -1
- package/dist/esm/types/config.mjs +0 -1
- package/dist/esm/types/config.mjs.map +0 -1
- package/dist/esm/types/locales.mjs +0 -286
- package/dist/esm/types/locales.mjs.map +0 -1
- package/dist/types/client.d.ts.map +0 -1
- package/dist/types/configFile/index.d.ts.map +0 -1
- package/dist/types/defaultValues/middleware.d.ts +0 -8
- package/dist/types/defaultValues/middleware.d.ts.map +0 -1
- package/dist/types/getSandboxContext.d.ts +0 -4
- package/dist/types/getSandboxContext.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/loadExternalFile.d.ts +0 -8
- package/dist/types/loadExternalFile.d.ts.map +0 -1
- package/dist/types/types/config.d.ts +0 -659
- package/dist/types/types/config.d.ts.map +0 -1
- package/dist/types/types/locales.d.ts +0 -564
- package/dist/types/types/locales.d.ts.map +0 -1
|
@@ -1,692 +1,115 @@
|
|
|
1
|
-
import { join } from "path";
|
|
2
|
-
import {
|
|
3
|
-
IMPORT_MODE,
|
|
4
|
-
OPTIMIZE,
|
|
5
|
-
OUTPUT_FORMAT,
|
|
6
|
-
TRAVERSE_PATTERN
|
|
7
|
-
} from "../defaultValues/build.mjs";
|
|
8
|
-
import {
|
|
9
|
-
CONFIG_DIR,
|
|
10
|
-
CONTENT_DIR,
|
|
11
|
-
DICTIONARIES_DIR,
|
|
12
|
-
DYNAMIC_DICTIONARIES_DIR,
|
|
13
|
-
EXCLUDED_PATHS,
|
|
14
|
-
FETCH_DICTIONARIES_DIR,
|
|
15
|
-
FILE_EXTENSIONS,
|
|
16
|
-
MAIN_DIR,
|
|
17
|
-
MODULE_AUGMENTATION_DIR,
|
|
18
|
-
REMOTE_DICTIONARIES_DIR,
|
|
19
|
-
TYPES_DIR,
|
|
20
|
-
UNMERGED_DICTIONARIES_DIR,
|
|
21
|
-
WATCH
|
|
22
|
-
} from "../defaultValues/content.mjs";
|
|
23
|
-
import {
|
|
24
|
-
APPLICATION_URL,
|
|
25
|
-
BACKEND_URL,
|
|
26
|
-
CMS_URL,
|
|
27
|
-
DICTIONARY_PRIORITY_STRATEGY,
|
|
28
|
-
EDITOR_URL,
|
|
29
|
-
IS_ENABLED,
|
|
30
|
-
LIVE_SYNC,
|
|
31
|
-
LIVE_SYNC_PORT,
|
|
32
|
-
PORT
|
|
33
|
-
} from "../defaultValues/editor.mjs";
|
|
34
|
-
import {
|
|
35
|
-
DEFAULT_LOCALE,
|
|
36
|
-
LOCALES,
|
|
37
|
-
REQUIRED_LOCALES,
|
|
38
|
-
STRICT_MODE
|
|
39
|
-
} from "../defaultValues/internationalization.mjs";
|
|
40
|
-
import { MODE, PREFIX } from "../defaultValues/log.mjs";
|
|
41
|
-
import {
|
|
42
|
-
BASE_PATH,
|
|
43
|
-
COOKIE_NAME,
|
|
44
|
-
DETECT_LOCALE_ON_PREFETCH_NO_PREFIX,
|
|
45
|
-
HEADER_NAME,
|
|
46
|
-
NO_PREFIX,
|
|
47
|
-
PREFIX_DEFAULT,
|
|
48
|
-
SERVER_SET_COOKIE
|
|
49
|
-
} from "../defaultValues/middleware.mjs";
|
|
50
1
|
import { normalizePath } from "../utils/normalizePath.mjs";
|
|
2
|
+
import { CACHE, IMPORT_MODE, OPTIMIZE, OUTPUT_FORMAT, TRAVERSE_PATTERN } from "../defaultValues/build.mjs";
|
|
3
|
+
import { CACHE_DIR, CONFIG_DIR, CONTENT_DIR, DICTIONARIES_DIR, DYNAMIC_DICTIONARIES_DIR, EXCLUDED_PATHS, FETCH_DICTIONARIES_DIR, FILE_EXTENSIONS, FILL, MAIN_DIR, MODULE_AUGMENTATION_DIR, REMOTE_DICTIONARIES_DIR, TYPES_DIR, UNMERGED_DICTIONARIES_DIR, WATCH } from "../defaultValues/content.mjs";
|
|
4
|
+
import { APPLICATION_URL, BACKEND_URL, CMS_URL, DICTIONARY_PRIORITY_STRATEGY, EDITOR_URL, IS_ENABLED, LIVE_SYNC, LIVE_SYNC_PORT, PORT } from "../defaultValues/editor.mjs";
|
|
5
|
+
import { DEFAULT_LOCALE, LOCALES, REQUIRED_LOCALES, STRICT_MODE } from "../defaultValues/internationalization.mjs";
|
|
6
|
+
import { MODE, PREFIX } from "../defaultValues/log.mjs";
|
|
7
|
+
import { BASE_PATH, DETECT_LOCALE_ON_PREFETCH_NO_PREFIX, HEADER_NAME, ROUTING_MODE, STORAGE } from "../defaultValues/routing.mjs";
|
|
8
|
+
import { ESMxCJSRequire } from "../utils/ESMxCJSHelpers.mjs";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
|
|
11
|
+
//#region src/configFile/buildConfigurationFields.ts
|
|
51
12
|
let storedConfiguration;
|
|
52
13
|
const buildInternationalizationFields = (customConfiguration) => ({
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
*
|
|
58
|
-
*/
|
|
59
|
-
locales: customConfiguration?.locales ?? LOCALES,
|
|
60
|
-
/**
|
|
61
|
-
* Locales required by TypeScript to ensure strong implementations of internationalized content using typescript.
|
|
62
|
-
*
|
|
63
|
-
* Default: []
|
|
64
|
-
*
|
|
65
|
-
* If empty, all locales are required in `strict` mode.
|
|
66
|
-
*
|
|
67
|
-
* Ensure required locales are also defined in the `locales` field.
|
|
68
|
-
*/
|
|
69
|
-
requiredLocales: customConfiguration?.requiredLocales ?? customConfiguration?.locales ?? REQUIRED_LOCALES,
|
|
70
|
-
/**
|
|
71
|
-
* Ensure strong implementations of internationalized content using typescript.
|
|
72
|
-
* - If set to "strict", the translation `t` function will require each declared locales to be defined. If one locale is missing, or if a locale is not declared in your config, it will throw an error.
|
|
73
|
-
* - If set to "inclusive", the translation `t` function will require each declared locales to be defined. If one locale is missing, it will throw a warning. But will accept if a locale is not declared in your config, but exist.
|
|
74
|
-
* - If set to "loose", the translation `t` function will accept any existing locale.
|
|
75
|
-
*
|
|
76
|
-
* Default: "inclusive"
|
|
77
|
-
*/
|
|
78
|
-
strictMode: customConfiguration?.strictMode ?? STRICT_MODE,
|
|
79
|
-
/**
|
|
80
|
-
* Default locale of the application for fallback
|
|
81
|
-
*
|
|
82
|
-
* Default: 'en'
|
|
83
|
-
*/
|
|
84
|
-
defaultLocale: customConfiguration?.defaultLocale ?? DEFAULT_LOCALE
|
|
14
|
+
locales: customConfiguration?.locales ?? LOCALES,
|
|
15
|
+
requiredLocales: customConfiguration?.requiredLocales ?? customConfiguration?.locales ?? REQUIRED_LOCALES,
|
|
16
|
+
strictMode: customConfiguration?.strictMode ?? STRICT_MODE,
|
|
17
|
+
defaultLocale: customConfiguration?.defaultLocale ?? DEFAULT_LOCALE
|
|
85
18
|
});
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
headerName: customConfiguration?.headerName ?? HEADER_NAME,
|
|
93
|
-
/**
|
|
94
|
-
* Cookie name to get the locale
|
|
95
|
-
*
|
|
96
|
-
* Default: 'intlayer-locale'
|
|
97
|
-
*/
|
|
98
|
-
cookieName: customConfiguration?.cookieName ?? COOKIE_NAME,
|
|
99
|
-
/**
|
|
100
|
-
* Prefix default prefix the default locale to the path as other locales.
|
|
101
|
-
*
|
|
102
|
-
* Example with prefixDefault = true and defaultLocale = 'en':
|
|
103
|
-
* path = /en/dashboard or /fr/dashboard
|
|
104
|
-
*
|
|
105
|
-
* Example with prefixDefault = false and defaultLocale = 'en':
|
|
106
|
-
* path = /dashboard or /fr/dashboard
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
* Default: false
|
|
110
|
-
*/
|
|
111
|
-
prefixDefault: customConfiguration?.prefixDefault ?? PREFIX_DEFAULT,
|
|
112
|
-
/**
|
|
113
|
-
* Base path of the application URL
|
|
114
|
-
*
|
|
115
|
-
* Default: ''
|
|
116
|
-
*
|
|
117
|
-
* Example:
|
|
118
|
-
* - If the application is hosted at https://example.com/my-app
|
|
119
|
-
* - The base path is '/my-app'
|
|
120
|
-
* - The URL will be https://example.com/my-app/en
|
|
121
|
-
* - If the base path is not set, the URL will be https://example.com/en
|
|
122
|
-
*/
|
|
123
|
-
basePath: customConfiguration?.basePath ?? BASE_PATH,
|
|
124
|
-
/**
|
|
125
|
-
* Rule to set the cookie on the server
|
|
126
|
-
* - 'always': Set the cookie on every request
|
|
127
|
-
* - 'never': Never set the cookie
|
|
128
|
-
*/
|
|
129
|
-
serverSetCookie: customConfiguration?.serverSetCookie ?? SERVER_SET_COOKIE,
|
|
130
|
-
/**
|
|
131
|
-
* No prefix in the URL
|
|
132
|
-
* - true: No prefix in the URL
|
|
133
|
-
* - false: Prefix in the URL
|
|
134
|
-
*
|
|
135
|
-
* Example:
|
|
136
|
-
* - If the application is hosted at https://example.com/my-app
|
|
137
|
-
* - The base path is '/my-app'
|
|
138
|
-
* - The URL will be https://example.com/my-app/en
|
|
139
|
-
* - If the base path is not set, the URL will be https://example.com/en
|
|
140
|
-
* - If no prefix is set, the URL will be https://example.com/en
|
|
141
|
-
* - If the no prefix is set to true, the URL will be https://example.com
|
|
142
|
-
*
|
|
143
|
-
* Default: false
|
|
144
|
-
*/
|
|
145
|
-
noPrefix: customConfiguration?.noPrefix ?? NO_PREFIX,
|
|
146
|
-
/**
|
|
147
|
-
* Controls whether locale detection occurs during Next.js prefetch requests
|
|
148
|
-
* - true: Detect and apply locale during prefetch
|
|
149
|
-
* - false: Use default locale during prefetch (recommended)
|
|
150
|
-
*
|
|
151
|
-
* This setting affects how Next.js handles locale prefetching:
|
|
152
|
-
*
|
|
153
|
-
* Example scenario:
|
|
154
|
-
* - User's browser language is 'fr'
|
|
155
|
-
* - Current page is /fr/about
|
|
156
|
-
* - Link prefetches /about
|
|
157
|
-
*
|
|
158
|
-
* With `detectLocaleOnPrefetchNoPrefix:true`
|
|
159
|
-
* - Prefetch detects 'fr' locale from browser
|
|
160
|
-
* - Redirects prefetch to /fr/about
|
|
161
|
-
*
|
|
162
|
-
* With `detectLocaleOnPrefetchNoPrefix:false` (default)
|
|
163
|
-
* - Prefetch uses default locale
|
|
164
|
-
* - Redirects prefetch to /en/about (assuming 'en' is default)
|
|
165
|
-
*
|
|
166
|
-
* When to use true:
|
|
167
|
-
* - Your app uses non-localized internal links (e.g. <a href="/about">)
|
|
168
|
-
* - You want consistent locale detection behavior between regular and prefetch requests
|
|
169
|
-
*
|
|
170
|
-
* When to use false (default):
|
|
171
|
-
* - Your app uses locale-prefixed links (e.g. <a href="/fr/about">)
|
|
172
|
-
* - You want to optimize prefetching performance
|
|
173
|
-
* - You want to avoid potential redirect loops
|
|
174
|
-
*
|
|
175
|
-
* Default: false
|
|
176
|
-
*/
|
|
177
|
-
detectLocaleOnPrefetchNoPrefix: customConfiguration?.detectLocaleOnPrefetchNoPrefix ?? DETECT_LOCALE_ON_PREFETCH_NO_PREFIX
|
|
19
|
+
const buildRoutingFields = (customConfiguration) => ({
|
|
20
|
+
mode: customConfiguration?.mode ?? ROUTING_MODE,
|
|
21
|
+
storage: customConfiguration?.storage ?? STORAGE,
|
|
22
|
+
headerName: customConfiguration?.headerName ?? HEADER_NAME,
|
|
23
|
+
basePath: customConfiguration?.basePath ?? BASE_PATH,
|
|
24
|
+
detectLocaleOnPrefetchNoPrefix: customConfiguration?.detectLocaleOnPrefetchNoPrefix ?? DETECT_LOCALE_ON_PREFETCH_NO_PREFIX
|
|
178
25
|
});
|
|
179
26
|
const buildContentFields = (customConfiguration, baseDir) => {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
* Not used yet
|
|
211
|
-
* @TODO Implement the exclusion or remove it
|
|
212
|
-
*/
|
|
213
|
-
excludedPath: customConfiguration?.excludedPath ?? EXCLUDED_PATHS,
|
|
214
|
-
/**
|
|
215
|
-
* Indicates if Intlayer should watch for changes in the content declaration files in the app to rebuild the related dictionaries.
|
|
216
|
-
*
|
|
217
|
-
* Default: process.env.NODE_ENV === 'development'
|
|
218
|
-
*/
|
|
219
|
-
watch: customConfiguration?.watch ?? WATCH,
|
|
220
|
-
/**
|
|
221
|
-
* Indicate how the content should be automatically filled using AI.
|
|
222
|
-
*
|
|
223
|
-
* Default: undefined
|
|
224
|
-
*/
|
|
225
|
-
autoFill: customConfiguration?.autoFill ?? void 0
|
|
226
|
-
};
|
|
227
|
-
const baseDirDerivedConfiguration = {
|
|
228
|
-
/**
|
|
229
|
-
* Directory where the content is stored
|
|
230
|
-
*
|
|
231
|
-
* Relative to the base directory of the project
|
|
232
|
-
*
|
|
233
|
-
* Default: ./src
|
|
234
|
-
*
|
|
235
|
-
* Example: 'src'
|
|
236
|
-
*
|
|
237
|
-
* Note:
|
|
238
|
-
* - Can be changed to a custom directory to externalize the content used in the project
|
|
239
|
-
* - If the content is not at the base directory level, update the contentDirName field instead
|
|
240
|
-
*/
|
|
241
|
-
contentDir: (customConfiguration?.contentDir ?? CONTENT_DIR).map(
|
|
242
|
-
(contentDir) => join(notDerivedContentConfig.baseDir, contentDir)
|
|
243
|
-
),
|
|
244
|
-
/**
|
|
245
|
-
* Directory where the result will be stored
|
|
246
|
-
*
|
|
247
|
-
* Relative to the base directory of the project
|
|
248
|
-
*
|
|
249
|
-
* Default: .intlayer/dictionary
|
|
250
|
-
*
|
|
251
|
-
* Example: '.intlayer'
|
|
252
|
-
*
|
|
253
|
-
* Note:
|
|
254
|
-
* - Can be changed to a custom directory to externalize the intlayer application from the project
|
|
255
|
-
* - If the result is not at the base directory level, update the dictionariesDirName field instead
|
|
256
|
-
*/
|
|
257
|
-
dictionariesDir: join(
|
|
258
|
-
notDerivedContentConfig.baseDir,
|
|
259
|
-
customConfiguration?.dictionariesDir ?? DICTIONARIES_DIR
|
|
260
|
-
),
|
|
261
|
-
/**
|
|
262
|
-
* Directory where the module augmentation will be stored
|
|
263
|
-
*
|
|
264
|
-
* Module augmentation allow better IDE suggestions and type checking
|
|
265
|
-
*
|
|
266
|
-
* Relative to the base directory of the project
|
|
267
|
-
*
|
|
268
|
-
* Default: .intlayer/types
|
|
269
|
-
*
|
|
270
|
-
* Example: 'types'
|
|
271
|
-
*
|
|
272
|
-
* Note:
|
|
273
|
-
* - If this path changed, be sure to include it from the tsconfig.json file
|
|
274
|
-
* - If the module augmentation is not at the base directory level, update the moduleAugmentationDirName field instead
|
|
275
|
-
*
|
|
276
|
-
*/
|
|
277
|
-
moduleAugmentationDir: join(
|
|
278
|
-
notDerivedContentConfig.baseDir,
|
|
279
|
-
customConfiguration?.moduleAugmentationDir ?? MODULE_AUGMENTATION_DIR
|
|
280
|
-
)
|
|
281
|
-
};
|
|
282
|
-
const dictionariesDirDerivedConfiguration = {
|
|
283
|
-
/**
|
|
284
|
-
* Directory where the unmerged dictionaries will be stored
|
|
285
|
-
*
|
|
286
|
-
* Relative to the result directory
|
|
287
|
-
*
|
|
288
|
-
* Default: '.intlayer/unmerged_dictionary'
|
|
289
|
-
*
|
|
290
|
-
*/
|
|
291
|
-
unmergedDictionariesDir: join(
|
|
292
|
-
notDerivedContentConfig.baseDir,
|
|
293
|
-
customConfiguration?.unmergedDictionariesDir ?? UNMERGED_DICTIONARIES_DIR
|
|
294
|
-
),
|
|
295
|
-
/**
|
|
296
|
-
* Directory where the remote dictionaries will be stored
|
|
297
|
-
*
|
|
298
|
-
* Relative to the result directory
|
|
299
|
-
*
|
|
300
|
-
* Default: '.intlayer/remote_dictionary'
|
|
301
|
-
*/
|
|
302
|
-
remoteDictionariesDir: join(
|
|
303
|
-
notDerivedContentConfig.baseDir,
|
|
304
|
-
customConfiguration?.remoteDictionariesDir ?? REMOTE_DICTIONARIES_DIR
|
|
305
|
-
),
|
|
306
|
-
/**
|
|
307
|
-
* Directory where the final dictionaries will be stored
|
|
308
|
-
*
|
|
309
|
-
* Relative to the result directory
|
|
310
|
-
*
|
|
311
|
-
* Default: .intlayer/dictionary
|
|
312
|
-
*
|
|
313
|
-
* Example: '.intlayer/dictionary'
|
|
314
|
-
*
|
|
315
|
-
* Note:
|
|
316
|
-
* - If the types are not at the result directory level, update the dictionariesDirName field instead
|
|
317
|
-
* - The dictionaries are stored in JSON format
|
|
318
|
-
* - The dictionaries are used to translate the content
|
|
319
|
-
* - The dictionaries are built from the content files
|
|
320
|
-
*/
|
|
321
|
-
dictionariesDir: join(
|
|
322
|
-
notDerivedContentConfig.baseDir,
|
|
323
|
-
customConfiguration?.dictionariesDir ?? DICTIONARIES_DIR
|
|
324
|
-
),
|
|
325
|
-
/**
|
|
326
|
-
* Directory where the dynamic dictionaries will be stored
|
|
327
|
-
*
|
|
328
|
-
* Relative to the result directory
|
|
329
|
-
*
|
|
330
|
-
* Default: .intlayer/dynamic_dictionary
|
|
331
|
-
*/
|
|
332
|
-
dynamicDictionariesDir: join(
|
|
333
|
-
notDerivedContentConfig.baseDir,
|
|
334
|
-
customConfiguration?.dynamicDictionariesDir ?? DYNAMIC_DICTIONARIES_DIR
|
|
335
|
-
),
|
|
336
|
-
/**
|
|
337
|
-
* Directory where the fetch dictionaries will be stored
|
|
338
|
-
*
|
|
339
|
-
* Relative to the result directory
|
|
340
|
-
*
|
|
341
|
-
* Default: .intlayer/fetch_dictionary
|
|
342
|
-
*/
|
|
343
|
-
fetchDictionariesDir: join(
|
|
344
|
-
notDerivedContentConfig.baseDir,
|
|
345
|
-
customConfiguration?.fetchDictionariesDir ?? FETCH_DICTIONARIES_DIR
|
|
346
|
-
),
|
|
347
|
-
/**
|
|
348
|
-
* Directory where the dictionaries types will be stored
|
|
349
|
-
*
|
|
350
|
-
* Relative to the result directory
|
|
351
|
-
*
|
|
352
|
-
* Default: .intlayer/types
|
|
353
|
-
*
|
|
354
|
-
* Example: 'types'
|
|
355
|
-
*
|
|
356
|
-
* Note:
|
|
357
|
-
* - If the types are not at the result directory level, update the typesDirName field instead
|
|
358
|
-
*/
|
|
359
|
-
typesDir: join(
|
|
360
|
-
notDerivedContentConfig.baseDir,
|
|
361
|
-
customConfiguration?.typesDir ?? TYPES_DIR
|
|
362
|
-
),
|
|
363
|
-
/**
|
|
364
|
-
* Directory where the main files will be stored
|
|
365
|
-
*
|
|
366
|
-
* Relative to the result directory
|
|
367
|
-
*
|
|
368
|
-
* Default: .intlayer/main
|
|
369
|
-
*
|
|
370
|
-
* Example: '.intlayer/main'
|
|
371
|
-
*
|
|
372
|
-
* Note:
|
|
373
|
-
*
|
|
374
|
-
* - If the main files are not at the result directory level, update the mainDirName field instead
|
|
375
|
-
*/
|
|
376
|
-
mainDir: join(
|
|
377
|
-
notDerivedContentConfig.baseDir,
|
|
378
|
-
customConfiguration?.mainDir ?? MAIN_DIR
|
|
379
|
-
),
|
|
380
|
-
/**
|
|
381
|
-
* Directory where the configuration files are stored
|
|
382
|
-
*
|
|
383
|
-
* Relative to the result directory
|
|
384
|
-
*
|
|
385
|
-
* Default: .intlayer/config
|
|
386
|
-
*
|
|
387
|
-
* Example: '.intlayer/config'
|
|
388
|
-
*
|
|
389
|
-
* Note:
|
|
390
|
-
*
|
|
391
|
-
* - If the configuration files are not at the result directory level, update the configDirName field instead
|
|
392
|
-
*/
|
|
393
|
-
configDir: join(
|
|
394
|
-
notDerivedContentConfig.baseDir,
|
|
395
|
-
customConfiguration?.configDir ?? CONFIG_DIR
|
|
396
|
-
)
|
|
397
|
-
};
|
|
398
|
-
const patternsConfiguration = {
|
|
399
|
-
/**
|
|
400
|
-
* Pattern of files to watch
|
|
401
|
-
*
|
|
402
|
-
* Default: ['/**\/*.content.ts', '/**\/*.content.js', '/**\/*.content.json', '/**\/*.content.cjs', '/**\/*.content.mjs', '/**\/*.content.tsx', '/**\/*.content.jsx']
|
|
403
|
-
*/
|
|
404
|
-
watchedFilesPattern: notDerivedContentConfig.fileExtensions.map(
|
|
405
|
-
(ext) => `/**/*${ext}`
|
|
406
|
-
),
|
|
407
|
-
/**
|
|
408
|
-
* Pattern of files to watch including the relative path
|
|
409
|
-
*
|
|
410
|
-
* Default: ['src/**\/*.content.ts', 'src/**\/*.content.js', 'src/**\/*.content.json', 'src/**\/*.content.cjs', 'src/**\/*.content.mjs', 'src/**\/*.content.tsx', 'src/**\/*.content.jsx']
|
|
411
|
-
*/
|
|
412
|
-
watchedFilesPatternWithPath: notDerivedContentConfig.fileExtensions.flatMap(
|
|
413
|
-
(ext) => baseDirDerivedConfiguration.contentDir.map(
|
|
414
|
-
(contentDir) => `${normalizePath(contentDir)}/**/*${ext}`
|
|
415
|
-
)
|
|
416
|
-
),
|
|
417
|
-
/**
|
|
418
|
-
* Pattern of dictionary to interpret
|
|
419
|
-
*
|
|
420
|
-
* Default: '.intlayer/dictionary/**\/*.json'
|
|
421
|
-
*/
|
|
422
|
-
outputFilesPatternWithPath: `${normalizePath(
|
|
423
|
-
dictionariesDirDerivedConfiguration.dictionariesDir
|
|
424
|
-
)}/**/*.json`
|
|
425
|
-
};
|
|
426
|
-
return {
|
|
427
|
-
...notDerivedContentConfig,
|
|
428
|
-
...baseDirDerivedConfiguration,
|
|
429
|
-
...dictionariesDirDerivedConfiguration,
|
|
430
|
-
...patternsConfiguration
|
|
431
|
-
};
|
|
27
|
+
const notDerivedContentConfig = {
|
|
28
|
+
fileExtensions: customConfiguration?.fileExtensions ?? FILE_EXTENSIONS,
|
|
29
|
+
baseDir: customConfiguration?.baseDir ?? baseDir ?? process.cwd(),
|
|
30
|
+
excludedPath: customConfiguration?.excludedPath ?? EXCLUDED_PATHS,
|
|
31
|
+
watch: customConfiguration?.watch ?? WATCH,
|
|
32
|
+
fill: customConfiguration?.fill ?? FILL
|
|
33
|
+
};
|
|
34
|
+
const baseDirDerivedConfiguration = {
|
|
35
|
+
contentDir: (customConfiguration?.contentDir ?? CONTENT_DIR).map((contentDir) => join(notDerivedContentConfig.baseDir, contentDir)),
|
|
36
|
+
moduleAugmentationDir: join(notDerivedContentConfig.baseDir, customConfiguration?.moduleAugmentationDir ?? MODULE_AUGMENTATION_DIR),
|
|
37
|
+
unmergedDictionariesDir: join(notDerivedContentConfig.baseDir, customConfiguration?.unmergedDictionariesDir ?? UNMERGED_DICTIONARIES_DIR),
|
|
38
|
+
remoteDictionariesDir: join(notDerivedContentConfig.baseDir, customConfiguration?.remoteDictionariesDir ?? REMOTE_DICTIONARIES_DIR),
|
|
39
|
+
dictionariesDir: join(notDerivedContentConfig.baseDir, customConfiguration?.dictionariesDir ?? DICTIONARIES_DIR),
|
|
40
|
+
dynamicDictionariesDir: join(notDerivedContentConfig.baseDir, customConfiguration?.dynamicDictionariesDir ?? DYNAMIC_DICTIONARIES_DIR),
|
|
41
|
+
fetchDictionariesDir: join(notDerivedContentConfig.baseDir, customConfiguration?.fetchDictionariesDir ?? FETCH_DICTIONARIES_DIR),
|
|
42
|
+
typesDir: join(notDerivedContentConfig.baseDir, customConfiguration?.typesDir ?? TYPES_DIR),
|
|
43
|
+
mainDir: join(notDerivedContentConfig.baseDir, customConfiguration?.mainDir ?? MAIN_DIR),
|
|
44
|
+
configDir: join(notDerivedContentConfig.baseDir, customConfiguration?.configDir ?? CONFIG_DIR),
|
|
45
|
+
cacheDir: join(notDerivedContentConfig.baseDir, customConfiguration?.cacheDir ?? CACHE_DIR)
|
|
46
|
+
};
|
|
47
|
+
const patternsConfiguration = {
|
|
48
|
+
watchedFilesPattern: notDerivedContentConfig.fileExtensions.map((ext) => `/**/*${ext}`),
|
|
49
|
+
watchedFilesPatternWithPath: notDerivedContentConfig.fileExtensions.flatMap((ext) => baseDirDerivedConfiguration.contentDir.map((contentDir) => `${normalizePath(contentDir)}/**/*${ext}`)),
|
|
50
|
+
outputFilesPatternWithPath: `${normalizePath(baseDirDerivedConfiguration.dictionariesDir)}/**/*.json`
|
|
51
|
+
};
|
|
52
|
+
return {
|
|
53
|
+
...notDerivedContentConfig,
|
|
54
|
+
...baseDirDerivedConfiguration,
|
|
55
|
+
...patternsConfiguration
|
|
56
|
+
};
|
|
432
57
|
};
|
|
433
58
|
const buildEditorFields = (customConfiguration) => ({
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
* Default: '*'
|
|
448
|
-
*/
|
|
449
|
-
editorURL: customConfiguration?.editorURL ?? EDITOR_URL,
|
|
450
|
-
/**
|
|
451
|
-
* URL of the CMS server. Used to restrict the origin of the editor for security reasons.
|
|
452
|
-
*/
|
|
453
|
-
cmsURL: customConfiguration?.cmsURL ?? CMS_URL,
|
|
454
|
-
/**
|
|
455
|
-
* URL of the editor server
|
|
456
|
-
*
|
|
457
|
-
* Default: 'https://back.intlayer.org'
|
|
458
|
-
*/
|
|
459
|
-
backendURL: customConfiguration?.backendURL ?? BACKEND_URL,
|
|
460
|
-
/** Port of the editor server
|
|
461
|
-
*
|
|
462
|
-
* Default: 8000
|
|
463
|
-
*/
|
|
464
|
-
port: customConfiguration?.port ?? PORT,
|
|
465
|
-
/**
|
|
466
|
-
* Indicates if the application interact with the visual editor
|
|
467
|
-
*
|
|
468
|
-
* Default: true;
|
|
469
|
-
*
|
|
470
|
-
* If true, the editor will be able to interact with the application.
|
|
471
|
-
* If false, the editor will not be able to interact with the application.
|
|
472
|
-
* In any case, the editor can only be enabled by the visual editor.
|
|
473
|
-
* Disabling the editor for specific environments is a way to enforce the security.
|
|
474
|
-
*
|
|
475
|
-
* Usage:
|
|
476
|
-
* ```js
|
|
477
|
-
* {
|
|
478
|
-
* // Other configurations
|
|
479
|
-
* editor: {
|
|
480
|
-
* enabled: process.env.NODE_ENV !== 'production',
|
|
481
|
-
* }
|
|
482
|
-
* };
|
|
483
|
-
* ```
|
|
484
|
-
*/
|
|
485
|
-
enabled: customConfiguration?.enabled ?? IS_ENABLED,
|
|
486
|
-
/**
|
|
487
|
-
* clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.
|
|
488
|
-
* An access token is use to authenticate the user related to the project.
|
|
489
|
-
* To get an access token, go to https://intlayer.org/dashboard/project and create an account.
|
|
490
|
-
*
|
|
491
|
-
* Default: undefined
|
|
492
|
-
*
|
|
493
|
-
* > Important: The clientId and clientSecret should be kept secret and not shared publicly. Please ensure to keep them in a secure location, such as environment variables.
|
|
494
|
-
*/
|
|
495
|
-
clientId: customConfiguration?.clientId ?? void 0,
|
|
496
|
-
/**
|
|
497
|
-
* clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.
|
|
498
|
-
* An access token is use to authenticate the user related to the project.
|
|
499
|
-
* To get an access token, go to https://intlayer.org/dashboard/project and create an account.
|
|
500
|
-
*
|
|
501
|
-
* Default: undefined
|
|
502
|
-
*
|
|
503
|
-
* > Important: The clientId and clientSecret should be kept secret and not shared publicly. Please ensure to keep them in a secure location, such as environment variables.
|
|
504
|
-
*/
|
|
505
|
-
clientSecret: customConfiguration?.clientSecret ?? void 0,
|
|
506
|
-
/**
|
|
507
|
-
* Strategy for prioritizing dictionaries. If a dictionary is both present online and locally, the content will be merge.
|
|
508
|
-
* However, is a field is defined in both dictionary, this setting determines which fields takes the priority over the other.
|
|
509
|
-
*
|
|
510
|
-
* Default: 'local_first'
|
|
511
|
-
*
|
|
512
|
-
* The strategy for prioritizing dictionaries. It can be either 'local_first' or 'distant_first'.
|
|
513
|
-
* - 'local_first': The first dictionary found in the locale is used.
|
|
514
|
-
* - 'distant_first': The first dictionary found in the distant locales is used.
|
|
515
|
-
*/
|
|
516
|
-
dictionaryPriorityStrategy: customConfiguration?.dictionaryPriorityStrategy ?? DICTIONARY_PRIORITY_STRATEGY,
|
|
517
|
-
/**
|
|
518
|
-
* Indicates if the application should hot reload the locale configurations when a change is detected.
|
|
519
|
-
* For example, when a new dictionary is added or updated, the application will update the content tu display in the page.
|
|
520
|
-
*
|
|
521
|
-
* The hot reload is only available for clients of the `enterprise` plan.
|
|
522
|
-
*
|
|
523
|
-
* Default: false
|
|
524
|
-
*/
|
|
525
|
-
liveSync: customConfiguration?.liveSync ?? LIVE_SYNC,
|
|
526
|
-
/**
|
|
527
|
-
* Port of the live sync server
|
|
528
|
-
*
|
|
529
|
-
* Default: 4000
|
|
530
|
-
*/
|
|
531
|
-
liveSyncPort: customConfiguration?.liveSyncPort ?? LIVE_SYNC_PORT,
|
|
532
|
-
/**
|
|
533
|
-
* URL of the live sync server in case of remote live sync server
|
|
534
|
-
*
|
|
535
|
-
* Default: `http://localhost:${LIVE_SYNC_PORT}`
|
|
536
|
-
*/
|
|
537
|
-
liveSyncURL: customConfiguration?.liveSyncURL ?? `http://localhost:${customConfiguration?.liveSyncPort ?? LIVE_SYNC_PORT}`
|
|
59
|
+
applicationURL: customConfiguration?.applicationURL ?? APPLICATION_URL,
|
|
60
|
+
editorURL: customConfiguration?.editorURL ?? EDITOR_URL,
|
|
61
|
+
cmsURL: customConfiguration?.cmsURL ?? CMS_URL,
|
|
62
|
+
backendURL: customConfiguration?.backendURL ?? BACKEND_URL,
|
|
63
|
+
port: customConfiguration?.port ?? PORT,
|
|
64
|
+
enabled: customConfiguration?.enabled ?? IS_ENABLED,
|
|
65
|
+
clientId: customConfiguration?.clientId ?? void 0,
|
|
66
|
+
clientSecret: customConfiguration?.clientSecret ?? void 0,
|
|
67
|
+
dictionaryPriorityStrategy: customConfiguration?.dictionaryPriorityStrategy ?? DICTIONARY_PRIORITY_STRATEGY,
|
|
68
|
+
liveSync: customConfiguration?.liveSync ?? LIVE_SYNC,
|
|
69
|
+
liveSyncPort: customConfiguration?.liveSyncPort ?? LIVE_SYNC_PORT,
|
|
70
|
+
liveSyncURL: customConfiguration?.liveSyncURL ?? `http://localhost:${customConfiguration?.liveSyncPort ?? LIVE_SYNC_PORT}`,
|
|
71
|
+
formatCommand: customConfiguration?.formatCommand
|
|
538
72
|
});
|
|
539
73
|
const buildLogFields = (customConfiguration, logFunctions) => ({
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
* If 'verbose', the logger will be enabled and can be used, but will log more information.
|
|
547
|
-
* If 'disabled', the logger is disabled and cannot be used.
|
|
548
|
-
*/
|
|
549
|
-
mode: customConfiguration?.mode ?? MODE,
|
|
550
|
-
/**
|
|
551
|
-
* Prefix of the logger
|
|
552
|
-
*
|
|
553
|
-
* Default: '[intlayer]'
|
|
554
|
-
*
|
|
555
|
-
* The prefix of the logger.
|
|
556
|
-
*/
|
|
557
|
-
prefix: customConfiguration?.prefix ?? PREFIX,
|
|
558
|
-
/**
|
|
559
|
-
* Functions to log
|
|
560
|
-
*/
|
|
561
|
-
error: logFunctions?.error,
|
|
562
|
-
log: logFunctions?.log,
|
|
563
|
-
info: logFunctions?.info,
|
|
564
|
-
warn: logFunctions?.warn
|
|
74
|
+
mode: customConfiguration?.mode ?? MODE,
|
|
75
|
+
prefix: customConfiguration?.prefix ?? PREFIX,
|
|
76
|
+
error: logFunctions?.error,
|
|
77
|
+
log: logFunctions?.log,
|
|
78
|
+
info: logFunctions?.info,
|
|
79
|
+
warn: logFunctions?.warn
|
|
565
80
|
});
|
|
566
81
|
const buildAiFields = (customConfiguration) => ({
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
* API key
|
|
573
|
-
*/
|
|
574
|
-
apiKey: customConfiguration?.apiKey,
|
|
575
|
-
/**
|
|
576
|
-
* API model
|
|
577
|
-
*/
|
|
578
|
-
model: customConfiguration?.model,
|
|
579
|
-
/**
|
|
580
|
-
* Temperature
|
|
581
|
-
*/
|
|
582
|
-
temperature: customConfiguration?.temperature,
|
|
583
|
-
/**
|
|
584
|
-
* Application context
|
|
585
|
-
*/
|
|
586
|
-
applicationContext: customConfiguration?.applicationContext
|
|
82
|
+
provider: customConfiguration?.provider,
|
|
83
|
+
apiKey: customConfiguration?.apiKey,
|
|
84
|
+
model: customConfiguration?.model,
|
|
85
|
+
temperature: customConfiguration?.temperature,
|
|
86
|
+
applicationContext: customConfiguration?.applicationContext
|
|
587
87
|
});
|
|
588
88
|
const buildBuildFields = (customConfiguration) => ({
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
* If false, the build will not be optimized.
|
|
596
|
-
*
|
|
597
|
-
* Intlayer will replace all calls of dictionaries to optimize chunking. That way the final bundle will import only the dictionaries that are used.
|
|
598
|
-
* All imports will stay as static import to avoid async processing when loading the dictionaries.
|
|
599
|
-
*
|
|
600
|
-
* Note:
|
|
601
|
-
* - Intlayer will replace all call of `useIntlayer` with the defined mode by the `importMode` option.
|
|
602
|
-
* - Intlayer will replace all call of `getIntlayer` with `getDictionary`.
|
|
603
|
-
* - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.
|
|
604
|
-
* - In most cases, "dynamic" will be used for React applications, "async" for Vue.js applications.
|
|
605
|
-
* - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.
|
|
606
|
-
*/
|
|
607
|
-
optimize: customConfiguration?.optimize ?? OPTIMIZE,
|
|
608
|
-
/**
|
|
609
|
-
* Indicates the mode of import to use for the dictionaries.
|
|
610
|
-
*
|
|
611
|
-
* Available modes:
|
|
612
|
-
* - "static": The dictionaries are imported statically.
|
|
613
|
-
* In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionary`.
|
|
614
|
-
* - "dynamic": The dictionaries are imported dynamically in a synchronous component using the suspense API.
|
|
615
|
-
* In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.
|
|
616
|
-
* - "live": The dictionaries are imported dynamically using the live sync API.
|
|
617
|
-
* In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.
|
|
618
|
-
* Live mode will use the live sync API to fetch the dictionaries. If the API call fails, the dictionaries will be imported dynamically as "dynamic" mode.
|
|
619
|
-
*
|
|
620
|
-
* Default: "static"
|
|
621
|
-
*
|
|
622
|
-
* By default, when a dictionary is loaded, it imports content for all locales as it's imported statically.
|
|
623
|
-
*
|
|
624
|
-
* Note:
|
|
625
|
-
* - Dynamic imports rely on Suspense and may slightly impact rendering performance.
|
|
626
|
-
* - If desabled all locales will be loaded at once, even if they are not used.
|
|
627
|
-
* - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.
|
|
628
|
-
* - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.
|
|
629
|
-
* - This option will be ignored if `optimize` is disabled.
|
|
630
|
-
* - This option will not impact the `getIntlayer`, `getDictionary`, `useDictionary`, `useDictionaryAsync` and `useDictionaryDynamic` functions. You can still use them to refine you code on manual optimization.
|
|
631
|
-
* - The "live" allows to sync the dictionaries to the live sync server.
|
|
632
|
-
*/
|
|
633
|
-
importMode: customConfiguration?.importMode ?? IMPORT_MODE,
|
|
634
|
-
/**
|
|
635
|
-
* Pattern to traverse the code to optimize.
|
|
636
|
-
*
|
|
637
|
-
* Allows to avoid to traverse the code that is not relevant to the optimization.
|
|
638
|
-
* Improve build performance.
|
|
639
|
-
*
|
|
640
|
-
* Default: ['**\/*.{js,ts,mjs,cjs,jsx,tsx,mjx,cjx}', '!**\/node_modules/**']
|
|
641
|
-
*
|
|
642
|
-
* Example: `['src/**\/*.{ts,tsx}', '../ui-library/**\/*.{ts,tsx}']`
|
|
643
|
-
*
|
|
644
|
-
* Note:
|
|
645
|
-
* - This option will be ignored if `optimize` is disabled.
|
|
646
|
-
* - Use glob pattern.
|
|
647
|
-
*/
|
|
648
|
-
traversePattern: customConfiguration?.traversePattern ?? TRAVERSE_PATTERN,
|
|
649
|
-
/**
|
|
650
|
-
* Output format of the dictionaries
|
|
651
|
-
*
|
|
652
|
-
* Can be set on large projects to improve build performance.
|
|
653
|
-
*
|
|
654
|
-
* Default: ['cjs', 'esm']
|
|
655
|
-
*
|
|
656
|
-
* The output format of the dictionaries. It can be either 'cjs' or 'esm'.
|
|
657
|
-
* - 'cjs': The dictionaries are outputted as CommonJS modules.
|
|
658
|
-
* - 'esm': The dictionaries are outputted as ES modules.
|
|
659
|
-
*/
|
|
660
|
-
outputFormat: customConfiguration?.outputFormat ?? OUTPUT_FORMAT
|
|
89
|
+
optimize: customConfiguration?.optimize ?? OPTIMIZE,
|
|
90
|
+
importMode: customConfiguration?.importMode ?? IMPORT_MODE,
|
|
91
|
+
traversePattern: customConfiguration?.traversePattern ?? TRAVERSE_PATTERN,
|
|
92
|
+
outputFormat: customConfiguration?.outputFormat ?? OUTPUT_FORMAT,
|
|
93
|
+
cache: customConfiguration?.cache ?? CACHE,
|
|
94
|
+
require: customConfiguration?.require ?? ESMxCJSRequire
|
|
661
95
|
});
|
|
96
|
+
/**
|
|
97
|
+
* Build the configuration fields by merging the default values with the custom configuration
|
|
98
|
+
*/
|
|
662
99
|
const buildConfigurationFields = (customConfiguration, baseDir, logFunctions) => {
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
const logConfig = buildLogFields(customConfiguration?.log, logFunctions);
|
|
675
|
-
const aiConfig = buildAiFields(customConfiguration?.ai);
|
|
676
|
-
const buildConfig = buildBuildFields(customConfiguration?.build);
|
|
677
|
-
storedConfiguration = {
|
|
678
|
-
internationalization: internationalizationConfig,
|
|
679
|
-
middleware: middlewareConfig,
|
|
680
|
-
content: contentConfig,
|
|
681
|
-
editor: editorConfig,
|
|
682
|
-
log: logConfig,
|
|
683
|
-
ai: aiConfig,
|
|
684
|
-
build: buildConfig,
|
|
685
|
-
plugins: customConfiguration?.plugins
|
|
686
|
-
};
|
|
687
|
-
return storedConfiguration;
|
|
688
|
-
};
|
|
689
|
-
export {
|
|
690
|
-
buildConfigurationFields
|
|
100
|
+
storedConfiguration = {
|
|
101
|
+
internationalization: buildInternationalizationFields(customConfiguration?.internationalization),
|
|
102
|
+
routing: buildRoutingFields(customConfiguration?.routing),
|
|
103
|
+
content: buildContentFields(customConfiguration?.content, baseDir),
|
|
104
|
+
editor: buildEditorFields(customConfiguration?.editor),
|
|
105
|
+
log: buildLogFields(customConfiguration?.log, logFunctions),
|
|
106
|
+
ai: buildAiFields(customConfiguration?.ai),
|
|
107
|
+
build: buildBuildFields(customConfiguration?.build),
|
|
108
|
+
plugins: customConfiguration?.plugins
|
|
109
|
+
};
|
|
110
|
+
return storedConfiguration;
|
|
691
111
|
};
|
|
112
|
+
|
|
113
|
+
//#endregion
|
|
114
|
+
export { buildConfigurationFields };
|
|
692
115
|
//# sourceMappingURL=buildConfigurationFields.mjs.map
|