@intlayer/config 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/client.cjs +2 -10
- package/dist/cjs/client.cjs.map +1 -1
- package/dist/cjs/client.d.ts +2 -2
- package/dist/cjs/configFile/buildConfigurationFields.cjs +65 -5
- package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
- package/dist/cjs/defaultValues/editor.cjs +29 -0
- package/dist/cjs/defaultValues/editor.cjs.map +1 -0
- package/dist/cjs/defaultValues/editor.d.ts +3 -0
- package/dist/cjs/defaultValues/internationalization.cjs +5 -2
- package/dist/cjs/defaultValues/internationalization.cjs.map +1 -1
- package/dist/cjs/defaultValues/internationalization.d.ts +3 -1
- package/dist/cjs/defaultValues/server.cjs +15 -1
- package/dist/cjs/defaultValues/server.cjs.map +1 -1
- package/dist/cjs/defaultValues/server.d.ts +6 -1
- package/dist/cjs/envVariables/detectPlatform.cjs +7 -4
- package/dist/cjs/envVariables/detectPlatform.cjs.map +1 -1
- package/dist/cjs/envVariables/detectPlatform.d.ts +1 -4
- package/dist/cjs/envVariables/extractEnvVariable/index.cjs +44 -0
- package/dist/cjs/envVariables/extractEnvVariable/index.cjs.map +1 -0
- package/dist/cjs/envVariables/extractEnvVariable/index.d.ts +7 -0
- package/dist/cjs/envVariables/extractEnvVariable/next.cjs +75 -0
- package/dist/cjs/envVariables/extractEnvVariable/next.cjs.map +1 -0
- package/dist/cjs/envVariables/extractEnvVariable/next.d.ts +7 -0
- package/dist/cjs/envVariables/extractEnvVariable/react_app.cjs +75 -0
- package/dist/cjs/envVariables/extractEnvVariable/react_app.cjs.map +1 -0
- package/dist/cjs/envVariables/extractEnvVariable/react_app.d.ts +7 -0
- package/dist/cjs/envVariables/extractEnvVariable/types.cjs +17 -0
- package/dist/cjs/envVariables/extractEnvVariable/types.cjs.map +1 -0
- package/dist/cjs/envVariables/extractEnvVariable/types.d.ts +11 -0
- package/dist/cjs/envVariables/extractEnvVariable/undefined_platform.cjs +75 -0
- package/dist/cjs/envVariables/extractEnvVariable/undefined_platform.cjs.map +1 -0
- package/dist/cjs/envVariables/extractEnvVariable/undefined_platform.d.ts +7 -0
- package/dist/cjs/envVariables/extractEnvVariable/vite.cjs +83 -0
- package/dist/cjs/envVariables/extractEnvVariable/vite.cjs.map +1 -0
- package/dist/cjs/envVariables/extractEnvVariable/vite.d.ts +7 -0
- package/dist/cjs/envVariables/extractEnvVariable/vite_env.d.cjs +2 -0
- package/dist/cjs/envVariables/extractEnvVariable/vite_env.d.cjs.map +1 -0
- package/dist/cjs/envVariables/extractEnvVariable/vite_env.d.d.ts +2 -0
- package/dist/cjs/envVariables/formatEnvVariable.cjs +2 -1
- package/dist/cjs/envVariables/formatEnvVariable.cjs.map +1 -1
- package/dist/cjs/envVariables/getConfiguration.cjs +87 -115
- package/dist/cjs/envVariables/getConfiguration.cjs.map +1 -1
- package/dist/cjs/envVariables/getConfiguration.d.ts +2 -6
- package/dist/cjs/envVariables/index.cjs +2 -10
- package/dist/cjs/envVariables/index.cjs.map +1 -1
- package/dist/cjs/envVariables/index.d.ts +1 -1
- package/dist/cjs/index.cjs +2 -10
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/types/config.cjs.map +1 -1
- package/dist/cjs/types/config.d.ts +75 -4
- package/dist/esm/client.d.mts +2 -2
- package/dist/esm/client.mjs +2 -12
- package/dist/esm/client.mjs.map +1 -1
- package/dist/esm/configFile/buildConfigurationFields.mjs +73 -7
- package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
- package/dist/esm/defaultValues/editor.d.mts +3 -0
- package/dist/esm/defaultValues/editor.mjs +5 -0
- package/dist/esm/defaultValues/editor.mjs.map +1 -0
- package/dist/esm/defaultValues/internationalization.d.mts +3 -1
- package/dist/esm/defaultValues/internationalization.mjs +3 -1
- package/dist/esm/defaultValues/internationalization.mjs.map +1 -1
- package/dist/esm/defaultValues/server.d.mts +6 -1
- package/dist/esm/defaultValues/server.mjs +13 -1
- package/dist/esm/defaultValues/server.mjs.map +1 -1
- package/dist/esm/envVariables/detectPlatform.d.mts +1 -4
- package/dist/esm/envVariables/detectPlatform.mjs +7 -4
- package/dist/esm/envVariables/detectPlatform.mjs.map +1 -1
- package/dist/esm/envVariables/extractEnvVariable/index.d.mts +7 -0
- package/dist/esm/envVariables/extractEnvVariable/index.mjs +20 -0
- package/dist/esm/envVariables/extractEnvVariable/index.mjs.map +1 -0
- package/dist/esm/envVariables/extractEnvVariable/next.d.mts +7 -0
- package/dist/esm/envVariables/extractEnvVariable/next.mjs +51 -0
- package/dist/esm/envVariables/extractEnvVariable/next.mjs.map +1 -0
- package/dist/esm/envVariables/extractEnvVariable/react_app.d.mts +7 -0
- package/dist/esm/envVariables/extractEnvVariable/react_app.mjs +51 -0
- package/dist/esm/envVariables/extractEnvVariable/react_app.mjs.map +1 -0
- package/dist/esm/envVariables/extractEnvVariable/types.d.mts +11 -0
- package/dist/esm/envVariables/extractEnvVariable/types.mjs +1 -0
- package/dist/esm/envVariables/extractEnvVariable/types.mjs.map +1 -0
- package/dist/esm/envVariables/extractEnvVariable/undefined_platform.d.mts +7 -0
- package/dist/esm/envVariables/extractEnvVariable/undefined_platform.mjs +51 -0
- package/dist/esm/envVariables/extractEnvVariable/undefined_platform.mjs.map +1 -0
- package/dist/esm/envVariables/extractEnvVariable/vite.d.mts +7 -0
- package/dist/esm/envVariables/extractEnvVariable/vite.mjs +58 -0
- package/dist/esm/envVariables/extractEnvVariable/vite.mjs.map +1 -0
- package/dist/esm/envVariables/extractEnvVariable/vite_env.d.d.mts +2 -0
- package/dist/esm/envVariables/extractEnvVariable/vite_env.d.mjs +1 -0
- package/dist/esm/envVariables/extractEnvVariable/vite_env.d.mjs.map +1 -0
- package/dist/esm/envVariables/formatEnvVariable.mjs +2 -1
- package/dist/esm/envVariables/formatEnvVariable.mjs.map +1 -1
- package/dist/esm/envVariables/getConfiguration.d.mts +2 -6
- package/dist/esm/envVariables/getConfiguration.mjs +86 -110
- package/dist/esm/envVariables/getConfiguration.mjs.map +1 -1
- package/dist/esm/envVariables/index.d.mts +1 -1
- package/dist/esm/envVariables/index.mjs +2 -12
- package/dist/esm/envVariables/index.mjs.map +1 -1
- package/dist/esm/index.d.mts +2 -2
- package/dist/esm/index.mjs +1 -9
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/types/config.d.mts +75 -4
- package/package.json +2 -2
- package/src/client.ts +5 -11
- package/src/configFile/buildConfigurationFields.ts +82 -4
- package/src/defaultValues/editor.ts +1 -0
- package/src/defaultValues/internationalization.ts +3 -0
- package/src/defaultValues/server.ts +15 -1
- package/src/envVariables/detectPlatform.ts +12 -8
- package/src/envVariables/extractEnvVariable/index.ts +20 -0
- package/src/envVariables/extractEnvVariable/next.ts +64 -0
- package/src/envVariables/extractEnvVariable/react_app.ts +64 -0
- package/src/envVariables/extractEnvVariable/types.ts +10 -0
- package/src/envVariables/extractEnvVariable/undefined_platform.ts +59 -0
- package/src/envVariables/extractEnvVariable/vite.ts +72 -0
- package/src/envVariables/extractEnvVariable/vite_env.d.ts +9 -0
- package/src/envVariables/formatEnvVariable.ts +1 -0
- package/src/envVariables/getConfiguration.ts +94 -111
- package/src/envVariables/index.ts +1 -7
- package/src/index.ts +1 -4
- package/src/types/config.ts +82 -3
- package/dist/cjs/envVariables/extractEnvVariable.cjs +0 -211
- package/dist/cjs/envVariables/extractEnvVariable.cjs.map +0 -1
- package/dist/cjs/envVariables/extractEnvVariable.d.ts +0 -13
- package/dist/esm/envVariables/extractEnvVariable.d.mts +0 -13
- package/dist/esm/envVariables/extractEnvVariable.mjs +0 -186
- package/dist/esm/envVariables/extractEnvVariable.mjs.map +0 -1
- package/src/envVariables/extractEnvVariable.ts +0 -224
|
@@ -1,126 +1,109 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
ContentConfig,
|
|
3
|
+
DictionaryOutput,
|
|
3
4
|
InternationalizationConfig,
|
|
4
5
|
IntlayerConfig,
|
|
5
6
|
MiddlewareConfig,
|
|
6
7
|
ServerSetCookieRule,
|
|
8
|
+
StrictMode,
|
|
7
9
|
} from '../types/config';
|
|
8
10
|
import type { Locales } from '../types/locales';
|
|
9
|
-
import { extractEnvVariable } from './extractEnvVariable';
|
|
11
|
+
import { extractEnvVariable } from './extractEnvVariable/index';
|
|
10
12
|
import { getEnvValue } from './utils';
|
|
11
13
|
|
|
12
|
-
const env = extractEnvVariable();
|
|
13
|
-
|
|
14
|
-
export const intlayerIntlConfiguration: InternationalizationConfig = {
|
|
15
|
-
locales: getEnvValue<Locales>(
|
|
16
|
-
env.intlayerIntlConfiguration.locales,
|
|
17
|
-
'array'
|
|
18
|
-
)!,
|
|
19
|
-
defaultLocale: getEnvValue<Locales>(
|
|
20
|
-
env.intlayerIntlConfiguration.defaultLocale,
|
|
21
|
-
'string'
|
|
22
|
-
)!,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const intlayerMiddlewareConfiguration: MiddlewareConfig = {
|
|
26
|
-
headerName: getEnvValue(
|
|
27
|
-
env.intlayerMiddlewareConfiguration.headerName,
|
|
28
|
-
'string'
|
|
29
|
-
)!,
|
|
30
|
-
cookieName: getEnvValue(
|
|
31
|
-
env.intlayerMiddlewareConfiguration.cookieName,
|
|
32
|
-
'string'
|
|
33
|
-
)!,
|
|
34
|
-
prefixDefault: getEnvValue(
|
|
35
|
-
env.intlayerMiddlewareConfiguration.prefixDefault,
|
|
36
|
-
'boolean'
|
|
37
|
-
)!,
|
|
38
|
-
basePath: getEnvValue(
|
|
39
|
-
env.intlayerMiddlewareConfiguration.basePath,
|
|
40
|
-
'string'
|
|
41
|
-
)!,
|
|
42
|
-
serverSetCookie: getEnvValue<ServerSetCookieRule>(
|
|
43
|
-
env.intlayerMiddlewareConfiguration.serverSetCookie,
|
|
44
|
-
'string'
|
|
45
|
-
)!,
|
|
46
|
-
noPrefix: getEnvValue(
|
|
47
|
-
env.intlayerMiddlewareConfiguration.noPrefix,
|
|
48
|
-
'boolean'
|
|
49
|
-
)!,
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export const intlayerContentConfiguration: ContentConfig = {
|
|
53
|
-
fileExtensions: getEnvValue<string>(
|
|
54
|
-
env.intlayerContentConfiguration.fileExtensions,
|
|
55
|
-
'array'
|
|
56
|
-
)!,
|
|
57
|
-
baseDir: getEnvValue(env.intlayerContentConfiguration.baseDir, 'string')!,
|
|
58
|
-
contentDirName: getEnvValue(
|
|
59
|
-
env.intlayerContentConfiguration.contentDirName,
|
|
60
|
-
'string'
|
|
61
|
-
)!,
|
|
62
|
-
contentDir: getEnvValue(
|
|
63
|
-
env.intlayerContentConfiguration.contentDir,
|
|
64
|
-
'string'
|
|
65
|
-
)!,
|
|
66
|
-
excludedPath: getEnvValue<string>(
|
|
67
|
-
env.intlayerContentConfiguration.excludedPath,
|
|
68
|
-
'array'
|
|
69
|
-
)!,
|
|
70
|
-
resultDirName: getEnvValue(
|
|
71
|
-
env.intlayerContentConfiguration.resultDirName,
|
|
72
|
-
'string'
|
|
73
|
-
)!,
|
|
74
|
-
resultDir: getEnvValue(env.intlayerContentConfiguration.resultDir, 'string')!,
|
|
75
|
-
moduleAugmentationDirName: getEnvValue(
|
|
76
|
-
env.intlayerContentConfiguration.moduleAugmentationDirName,
|
|
77
|
-
'string'
|
|
78
|
-
)!,
|
|
79
|
-
moduleAugmentationDir: getEnvValue(
|
|
80
|
-
env.intlayerContentConfiguration.moduleAugmentationDir,
|
|
81
|
-
'string'
|
|
82
|
-
)!,
|
|
83
|
-
dictionariesDirName: getEnvValue(
|
|
84
|
-
env.intlayerContentConfiguration.dictionariesDirName,
|
|
85
|
-
'string'
|
|
86
|
-
)!,
|
|
87
|
-
dictionariesDir: getEnvValue(
|
|
88
|
-
env.intlayerContentConfiguration.dictionariesDir,
|
|
89
|
-
'string'
|
|
90
|
-
)!,
|
|
91
|
-
typeDirName: getEnvValue(
|
|
92
|
-
env.intlayerContentConfiguration.typeDirName,
|
|
93
|
-
'string'
|
|
94
|
-
)!,
|
|
95
|
-
typesDir: getEnvValue(env.intlayerContentConfiguration.typesDir, 'string')!,
|
|
96
|
-
mainDirName: getEnvValue(
|
|
97
|
-
env.intlayerContentConfiguration.mainDirName,
|
|
98
|
-
'string'
|
|
99
|
-
)!,
|
|
100
|
-
mainDir: getEnvValue(env.intlayerContentConfiguration.mainDir, 'string')!,
|
|
101
|
-
watchedFilesPattern: getEnvValue<string>(
|
|
102
|
-
env.intlayerContentConfiguration.watchedFilesPattern,
|
|
103
|
-
'array'
|
|
104
|
-
)!,
|
|
105
|
-
watchedFilesPatternWithPath: getEnvValue<string>(
|
|
106
|
-
env.intlayerContentConfiguration.watchedFilesPatternWithPath,
|
|
107
|
-
'array'
|
|
108
|
-
)!,
|
|
109
|
-
outputFilesPatternWithPath: getEnvValue(
|
|
110
|
-
env.intlayerContentConfiguration.outputFilesPatternWithPath,
|
|
111
|
-
'string'
|
|
112
|
-
)!,
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
export const intlayerConfiguration: IntlayerConfig = {
|
|
116
|
-
internationalization: intlayerIntlConfiguration,
|
|
117
|
-
middleware: intlayerMiddlewareConfiguration,
|
|
118
|
-
content: intlayerContentConfiguration,
|
|
119
|
-
};
|
|
120
|
-
|
|
121
14
|
/**
|
|
122
15
|
* Get all configuration values using environment variables
|
|
123
16
|
* Can be used in the client side as the server side
|
|
124
17
|
* To use it, be sure to have the environment variables set
|
|
125
18
|
*/
|
|
126
|
-
export const getConfiguration = (): IntlayerConfig =>
|
|
19
|
+
export const getConfiguration = (): IntlayerConfig => {
|
|
20
|
+
const env = extractEnvVariable();
|
|
21
|
+
|
|
22
|
+
const intlayerIntlConfiguration: InternationalizationConfig = {
|
|
23
|
+
locales: getEnvValue<Locales>(env.internationalization.locales, 'array')!,
|
|
24
|
+
strictMode: getEnvValue<StrictMode>(
|
|
25
|
+
env.internationalization.strictMode,
|
|
26
|
+
'string'
|
|
27
|
+
)!,
|
|
28
|
+
defaultLocale: getEnvValue<Locales>(
|
|
29
|
+
env?.internationalization.defaultLocale,
|
|
30
|
+
'string'
|
|
31
|
+
)!,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const intlayerMiddlewareConfiguration: MiddlewareConfig = {
|
|
35
|
+
headerName: getEnvValue(env.middleware.headerName, 'string')!,
|
|
36
|
+
cookieName: getEnvValue(env.middleware.cookieName, 'string')!,
|
|
37
|
+
prefixDefault: getEnvValue(env.middleware.prefixDefault, 'boolean')!,
|
|
38
|
+
basePath: getEnvValue(env.middleware.basePath, 'string')!,
|
|
39
|
+
serverSetCookie: getEnvValue<ServerSetCookieRule>(
|
|
40
|
+
env.middleware.serverSetCookie,
|
|
41
|
+
'string'
|
|
42
|
+
)!,
|
|
43
|
+
noPrefix: getEnvValue(env.middleware.noPrefix, 'boolean')!,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const intlayerContentConfiguration: ContentConfig = {
|
|
47
|
+
fileExtensions: getEnvValue<string>(env.content.fileExtensions, 'array')!,
|
|
48
|
+
baseDir: getEnvValue(env.content.baseDir, 'string')!,
|
|
49
|
+
contentDirName: getEnvValue(env.content.contentDirName, 'string')!,
|
|
50
|
+
contentDir: getEnvValue(env.content.contentDir, 'string')!,
|
|
51
|
+
excludedPath: getEnvValue<string>(env.content.excludedPath, 'array')!,
|
|
52
|
+
resultDirName: getEnvValue(env.content.resultDirName, 'string')!,
|
|
53
|
+
resultDir: getEnvValue(env.content.resultDir, 'string')!,
|
|
54
|
+
moduleAugmentationDirName: getEnvValue(
|
|
55
|
+
env.content.moduleAugmentationDirName,
|
|
56
|
+
'string'
|
|
57
|
+
)!,
|
|
58
|
+
moduleAugmentationDir: getEnvValue(
|
|
59
|
+
env.content.moduleAugmentationDir,
|
|
60
|
+
'string'
|
|
61
|
+
)!,
|
|
62
|
+
dictionaryOutput: getEnvValue<DictionaryOutput>(
|
|
63
|
+
env.content.dictionaryOutput,
|
|
64
|
+
'array'
|
|
65
|
+
)!,
|
|
66
|
+
dictionariesDirName: getEnvValue(
|
|
67
|
+
env.content.dictionariesDirName,
|
|
68
|
+
'string'
|
|
69
|
+
)!,
|
|
70
|
+
dictionariesDir: getEnvValue(env.content.dictionariesDir, 'string')!,
|
|
71
|
+
i18nDictionariesDirName: getEnvValue(
|
|
72
|
+
env.content.i18nDictionariesDirName,
|
|
73
|
+
'string'
|
|
74
|
+
)!,
|
|
75
|
+
i18nDictionariesDir: getEnvValue(
|
|
76
|
+
env.content.i18nDictionariesDir,
|
|
77
|
+
'string'
|
|
78
|
+
)!,
|
|
79
|
+
typeDirName: getEnvValue(env.content.typeDirName, 'string')!,
|
|
80
|
+
typesDir: getEnvValue(env.content.typesDir, 'string')!,
|
|
81
|
+
mainDirName: getEnvValue(env.content.mainDirName, 'string')!,
|
|
82
|
+
mainDir: getEnvValue(env.content.mainDir, 'string')!,
|
|
83
|
+
watchedFilesPattern: getEnvValue<string>(
|
|
84
|
+
env.content.watchedFilesPattern,
|
|
85
|
+
'array'
|
|
86
|
+
)!,
|
|
87
|
+
watchedFilesPatternWithPath: getEnvValue<string>(
|
|
88
|
+
env.content.watchedFilesPatternWithPath,
|
|
89
|
+
'array'
|
|
90
|
+
)!,
|
|
91
|
+
outputFilesPatternWithPath: getEnvValue(
|
|
92
|
+
env.content.outputFilesPatternWithPath,
|
|
93
|
+
'string'
|
|
94
|
+
)!,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const intlayerEditorConfiguration = {
|
|
98
|
+
port: getEnvValue(env.editor.port, 'number')!,
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const intlayerConfiguration: IntlayerConfig = {
|
|
102
|
+
internationalization: intlayerIntlConfiguration,
|
|
103
|
+
middleware: intlayerMiddlewareConfiguration,
|
|
104
|
+
content: intlayerContentConfiguration,
|
|
105
|
+
editor: intlayerEditorConfiguration,
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
return intlayerConfiguration;
|
|
109
|
+
};
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
intlayerIntlConfiguration,
|
|
3
|
-
intlayerMiddlewareConfiguration,
|
|
4
|
-
intlayerContentConfiguration,
|
|
5
|
-
intlayerConfiguration,
|
|
6
|
-
getConfiguration,
|
|
7
|
-
} from './getConfiguration';
|
|
1
|
+
export { getConfiguration } from './getConfiguration';
|
|
8
2
|
export { formatEnvVariable } from './formatEnvVariable';
|
package/src/index.ts
CHANGED
|
@@ -10,15 +10,12 @@ export type {
|
|
|
10
10
|
ResultDirDerivedConfig,
|
|
11
11
|
PatternsContentConfig,
|
|
12
12
|
ContentConfig,
|
|
13
|
+
StrictMode,
|
|
13
14
|
IntlayerConfig,
|
|
14
15
|
} from './types/config';
|
|
15
16
|
export type { LocalesValues } from './types/locales';
|
|
16
17
|
export { Locales } from './types/locales';
|
|
17
18
|
export {
|
|
18
19
|
formatEnvVariable,
|
|
19
|
-
intlayerIntlConfiguration,
|
|
20
|
-
intlayerMiddlewareConfiguration,
|
|
21
|
-
intlayerContentConfiguration,
|
|
22
|
-
intlayerConfiguration,
|
|
23
20
|
getConfiguration as getClientConfiguration,
|
|
24
21
|
} from './envVariables/index';
|
package/src/types/config.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Locales } from './locales';
|
|
2
2
|
|
|
3
|
+
export type StrictMode = 'strict' | 'required_only' | 'loose';
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Configuration for internationalization settings
|
|
5
7
|
*/
|
|
@@ -13,6 +15,15 @@ export type InternationalizationConfig = {
|
|
|
13
15
|
*/
|
|
14
16
|
locales: Locales[];
|
|
15
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Ensure strong implementations of internationalized content using typescript.
|
|
20
|
+
* - 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.
|
|
21
|
+
* - If set to "required_only", 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.
|
|
22
|
+
* - If set to "loose", the translation `t` function will accept any existing locale.
|
|
23
|
+
*
|
|
24
|
+
* Default: "required_only"
|
|
25
|
+
*/
|
|
26
|
+
strictMode: StrictMode;
|
|
16
27
|
/**
|
|
17
28
|
* Default locale of the application for fallback
|
|
18
29
|
*
|
|
@@ -84,6 +95,20 @@ export type MiddlewareConfig = {
|
|
|
84
95
|
noPrefix: boolean;
|
|
85
96
|
};
|
|
86
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Configuration for intlayer editor
|
|
100
|
+
*/
|
|
101
|
+
export type EditorConfig = {
|
|
102
|
+
/**
|
|
103
|
+
* Port number for the editor server
|
|
104
|
+
*
|
|
105
|
+
* Default: 4000
|
|
106
|
+
*
|
|
107
|
+
* The port number where the editor server runs.
|
|
108
|
+
*/
|
|
109
|
+
port: number;
|
|
110
|
+
};
|
|
111
|
+
|
|
87
112
|
/**
|
|
88
113
|
* Custom configuration that can be provided to override default settings
|
|
89
114
|
*/
|
|
@@ -102,6 +127,11 @@ export type CustomIntlayerConfig = {
|
|
|
102
127
|
* Custom content configuration
|
|
103
128
|
*/
|
|
104
129
|
content?: Partial<ContentConfig>;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Custom editor configuration
|
|
133
|
+
*/
|
|
134
|
+
editor?: Partial<EditorConfig>;
|
|
105
135
|
};
|
|
106
136
|
|
|
107
137
|
/**
|
|
@@ -122,6 +152,11 @@ export type IntlayerConfig = {
|
|
|
122
152
|
* Content configuration
|
|
123
153
|
*/
|
|
124
154
|
content: ContentConfig;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Intlayer editor configuration
|
|
158
|
+
*/
|
|
159
|
+
editor: EditorConfig;
|
|
125
160
|
};
|
|
126
161
|
|
|
127
162
|
/**
|
|
@@ -131,7 +166,7 @@ export type BaseContentConfig = {
|
|
|
131
166
|
/**
|
|
132
167
|
* File extensions of content to look for
|
|
133
168
|
*
|
|
134
|
-
* Default: ['.content.ts', '.content.js', '.content.json']
|
|
169
|
+
* Default: ['.content.ts', '.content.js', '.content.cjs', '.content.mjs', '.content.json', '.content.tsx', '.content.jsx']
|
|
135
170
|
*
|
|
136
171
|
* List of file extensions to scan for content.
|
|
137
172
|
*/
|
|
@@ -188,9 +223,24 @@ export type BaseContentConfig = {
|
|
|
188
223
|
* Default: 'dictionary'
|
|
189
224
|
*
|
|
190
225
|
* The directory for storing localization dictionaries.
|
|
226
|
+
*
|
|
227
|
+
* Note:
|
|
228
|
+
* - Ensure the dictionaries output includes intlayer to build the dictionaries for intlayer
|
|
191
229
|
*/
|
|
192
230
|
dictionariesDirName: string;
|
|
193
231
|
|
|
232
|
+
/**
|
|
233
|
+
* Name of the directory where dictionaries are stored
|
|
234
|
+
*
|
|
235
|
+
* Default: 'i18n_dictionary'
|
|
236
|
+
*
|
|
237
|
+
* The directory for storing localization dictionaries.
|
|
238
|
+
*
|
|
239
|
+
* Note:
|
|
240
|
+
* - Ensure the dictionaries output includes 'i18next' to build the dictionaries for i18next
|
|
241
|
+
*/
|
|
242
|
+
i18nDictionariesDirName: string;
|
|
243
|
+
|
|
194
244
|
/**
|
|
195
245
|
* Name of the directory where dictionary types are stored
|
|
196
246
|
*
|
|
@@ -210,6 +260,8 @@ export type BaseContentConfig = {
|
|
|
210
260
|
mainDirName: string;
|
|
211
261
|
};
|
|
212
262
|
|
|
263
|
+
export type DictionaryOutput = 'intlayer' | 'i18next';
|
|
264
|
+
|
|
213
265
|
/**
|
|
214
266
|
* Configuration derived based on the base content configuration
|
|
215
267
|
*/
|
|
@@ -240,6 +292,20 @@ export type BaseDerivedConfig = {
|
|
|
240
292
|
* Defines the derived path for module augmentation.
|
|
241
293
|
*/
|
|
242
294
|
moduleAugmentationDir: string;
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Type of dictionary to use as an output
|
|
298
|
+
*
|
|
299
|
+
* Default: ['intlayer']
|
|
300
|
+
*
|
|
301
|
+
* The type of dictionary to use as an output. It can be either 'intlayer' or 'i18next'.
|
|
302
|
+
*
|
|
303
|
+
* Note:
|
|
304
|
+
* - 'i18next' is not yet ensure a 1:1 mapping with the i18next library.
|
|
305
|
+
* - Removing 'intlayer' will break the compatibility with react-intlayer or next-intlayer
|
|
306
|
+
*
|
|
307
|
+
*/
|
|
308
|
+
dictionaryOutput: DictionaryOutput[];
|
|
243
309
|
};
|
|
244
310
|
|
|
245
311
|
/**
|
|
@@ -255,6 +321,19 @@ export type ResultDirDerivedConfig = {
|
|
|
255
321
|
*/
|
|
256
322
|
dictionariesDir: string;
|
|
257
323
|
|
|
324
|
+
/**
|
|
325
|
+
*
|
|
326
|
+
* Directory where dictionaries are stored, relative to the result directory
|
|
327
|
+
*
|
|
328
|
+
* Default: {{resultDir}} / {{i18nDictionariesDirName}}
|
|
329
|
+
*
|
|
330
|
+
* Specifies the derived path for dictionaries relative to the result directory.
|
|
331
|
+
*
|
|
332
|
+
* Note:
|
|
333
|
+
* - Ensure the i18n dictionaries output includes i18next to build the dictionaries for i18next
|
|
334
|
+
*/
|
|
335
|
+
i18nDictionariesDir: string;
|
|
336
|
+
|
|
258
337
|
/**
|
|
259
338
|
* Directory where dictionary types are stored, relative to the result directory
|
|
260
339
|
*
|
|
@@ -281,7 +360,7 @@ export type PatternsContentConfig = {
|
|
|
281
360
|
/**
|
|
282
361
|
* Patterns of files to watch for changes
|
|
283
362
|
*
|
|
284
|
-
* Default: ['/**\/*.content.ts', '/**\/*.content.js', '/**\/*.content.json']
|
|
363
|
+
* Default: ['/**\/*.content.ts', '/**\/*.content.js', '/**\/*.content.json', '/**\/*.content.cjs', '/**\/*.content.mjs', '/**\/*.content.tsx', '/**\/*.content.jsx']
|
|
285
364
|
*
|
|
286
365
|
* Defines file patterns for content to watch for changes.
|
|
287
366
|
*/
|
|
@@ -290,7 +369,7 @@ export type PatternsContentConfig = {
|
|
|
290
369
|
/**
|
|
291
370
|
* Patterns of files to watch for changes including the relative path
|
|
292
371
|
*
|
|
293
|
-
* Default: ['{{contentDir}}/**\/*.content.ts', '{{contentDir}}/**\/*.content.js', '{{contentDir}}/**\/*.content.json']
|
|
372
|
+
* Default: ['{{contentDir}}/**\/*.content.ts', '{{contentDir}}/**\/*.content.js', '{{contentDir}}/**\/*.content.json', '{{contentDir}}/**\/*.content.cjs', '{{contentDir}}/**\/*.content.mjs', '{{contentDir}}/**\/*.content.tsx', '{{contentDir}}/**\/*.content.jsx']
|
|
294
373
|
*
|
|
295
374
|
* Specifies the file patterns for content to watch, including relative paths.
|
|
296
375
|
*/
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var extractEnvVariable_exports = {};
|
|
20
|
-
__export(extractEnvVariable_exports, {
|
|
21
|
-
extractEnvVariable: () => extractEnvVariable
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(extractEnvVariable_exports);
|
|
24
|
-
var import_detectPlatform = require('./detectPlatform.cjs');
|
|
25
|
-
const import_meta = {};
|
|
26
|
-
const extractNextEnvVariable = () => {
|
|
27
|
-
if (typeof process === "undefined") {
|
|
28
|
-
return extractEmptyEnvVariable();
|
|
29
|
-
}
|
|
30
|
-
const env = process.env;
|
|
31
|
-
const intlayerIntlConfiguration = {
|
|
32
|
-
locales: env.NEXT_PUBLIC_INTLAYER_LOCALES,
|
|
33
|
-
defaultLocale: env.NEXT_PUBLIC_INTLAYER_DEFAULT_LOCALE
|
|
34
|
-
};
|
|
35
|
-
const intlayerMiddlewareConfiguration = {
|
|
36
|
-
headerName: env.NEXT_PUBLIC_INTLAYER_HEADER_NAME,
|
|
37
|
-
cookieName: env.NEXT_PUBLIC_INTLAYER_COOKIE_NAME,
|
|
38
|
-
prefixDefault: env.NEXT_PUBLIC_INTLAYER_PREFIX_DEFAULT,
|
|
39
|
-
basePath: env.NEXT_PUBLIC_INTLAYER_BASE_PATH,
|
|
40
|
-
serverSetCookie: env.NEXT_PUBLIC_INTLAYER_SERVER_SET_COOKIE,
|
|
41
|
-
noPrefix: env.NEXT_PUBLIC_INTLAYER_NO_PREFIX
|
|
42
|
-
};
|
|
43
|
-
const intlayerContentConfiguration = {
|
|
44
|
-
fileExtensions: env.NEXT_PUBLIC_INTLAYER_FILE_EXTENSIONS,
|
|
45
|
-
baseDir: env.NEXT_PUBLIC_INTLAYER_BASE_DIR,
|
|
46
|
-
contentDirName: env.NEXT_PUBLIC_INTLAYER_CONTENT_DIR_NAME,
|
|
47
|
-
contentDir: env.NEXT_PUBLIC_INTLAYER_CONTENT_DIR,
|
|
48
|
-
excludedPath: env.NEXT_PUBLIC_INTLAYER_EXCLUDED_PATH,
|
|
49
|
-
resultDirName: env.NEXT_PUBLIC_INTLAYER_RESULT_DIR_NAME,
|
|
50
|
-
moduleAugmentationDirName: env.NEXT_PUBLIC_INTLAYER_MODULE_AUGMENTATION_DIR_NAME,
|
|
51
|
-
dictionariesDirName: env.NEXT_PUBLIC_INTLAYER_DICTIONARIES_DIR_NAME,
|
|
52
|
-
typeDirName: env.NEXT_PUBLIC_INTLAYER_TYPE_DIR_NAME,
|
|
53
|
-
mainDirName: env.NEXT_PUBLIC_INTLAYER_MAIN_DIR_NAME,
|
|
54
|
-
resultDir: env.NEXT_PUBLIC_INTLAYER_RESULT_DIR,
|
|
55
|
-
moduleAugmentationDir: env.NEXT_PUBLIC_INTLAYER_MODULE_AUGMENTATION_DIR,
|
|
56
|
-
dictionariesDir: env.NEXT_PUBLIC_INTLAYER_DICTIONARIES_DIR,
|
|
57
|
-
typesDir: env.NEXT_PUBLIC_INTLAYER_TYPE_DIR,
|
|
58
|
-
mainDir: env.NEXT_PUBLIC_INTLAYER_MAIN_DIR,
|
|
59
|
-
watchedFilesPattern: env.NEXT_PUBLIC_INTLAYER_WATCHED_FILES_PATTERN,
|
|
60
|
-
watchedFilesPatternWithPath: env.NEXT_PUBLIC_INTLAYER_WATCHED_FILES_PATTERN_WITH_PATH,
|
|
61
|
-
outputFilesPatternWithPath: env.NEXT_PUBLIC_INTLAYER_OUTPUT_FILES_PATTERN_WITH_PATH
|
|
62
|
-
};
|
|
63
|
-
return {
|
|
64
|
-
intlayerIntlConfiguration,
|
|
65
|
-
intlayerMiddlewareConfiguration,
|
|
66
|
-
intlayerContentConfiguration
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
const extractReactAppEnvVariable = () => {
|
|
70
|
-
if (typeof process === "undefined") {
|
|
71
|
-
return extractEmptyEnvVariable();
|
|
72
|
-
}
|
|
73
|
-
const env = process.env;
|
|
74
|
-
const intlayerIntlConfiguration = {
|
|
75
|
-
locales: env.REACT_APP_INTLAYER_LOCALES,
|
|
76
|
-
defaultLocale: env.REACT_APP_INTLAYER_DEFAULT_LOCALE
|
|
77
|
-
};
|
|
78
|
-
const intlayerMiddlewareConfiguration = {
|
|
79
|
-
headerName: env.REACT_APP_INTLAYER_HEADER_NAME,
|
|
80
|
-
cookieName: env.REACT_APP_INTLAYER_COOKIE_NAME,
|
|
81
|
-
prefixDefault: env.REACT_APP_INTLAYER_PREFIX_DEFAULT,
|
|
82
|
-
basePath: env.REACT_APP_INTLAYER_BASE_PATH,
|
|
83
|
-
serverSetCookie: env.REACT_APP_INTLAYER_SERVER_SET_COOKIE,
|
|
84
|
-
noPrefix: env.REACT_APP_INTLAYER_NO_PREFIX
|
|
85
|
-
};
|
|
86
|
-
const intlayerContentConfiguration = {
|
|
87
|
-
fileExtensions: env.REACT_APP_INTLAYER_FILE_EXTENSIONS,
|
|
88
|
-
baseDir: env.REACT_APP_INTLAYER_BASE_DIR,
|
|
89
|
-
contentDirName: env.REACT_APP_INTLAYER_CONTENT_DIR_NAME,
|
|
90
|
-
contentDir: env.REACT_APP_INTLAYER_CONTENT_DIR,
|
|
91
|
-
excludedPath: env.REACT_APP_INTLAYER_EXCLUDED_PATH,
|
|
92
|
-
resultDirName: env.REACT_APP_INTLAYER_RESULT_DIR_NAME,
|
|
93
|
-
moduleAugmentationDirName: env.REACT_APP_INTLAYER_MODULE_AUGMENTATION_DIR_NAME,
|
|
94
|
-
dictionariesDirName: env.REACT_APP_INTLAYER_DICTIONARIES_DIR_NAME,
|
|
95
|
-
typeDirName: env.REACT_APP_INTLAYER_TYPE_DIR_NAME,
|
|
96
|
-
mainDirName: env.REACT_APP_INTLAYER_MAIN_DIR_NAME,
|
|
97
|
-
resultDir: env.REACT_APP_INTLAYER_RESULT_DIR,
|
|
98
|
-
moduleAugmentationDir: env.REACT_APP_INTLAYER_MODULE_AUGMENTATION_DIR,
|
|
99
|
-
dictionariesDir: env.REACT_APP_INTLAYER_DICTIONARIES_DIR,
|
|
100
|
-
typesDir: env.REACT_APP_INTLAYER_TYPE_DIR,
|
|
101
|
-
mainDir: env.REACT_APP_INTLAYER_MAIN_DIR,
|
|
102
|
-
watchedFilesPattern: env.REACT_APP_INTLAYER_WATCHED_FILES_PATTERN,
|
|
103
|
-
watchedFilesPatternWithPath: env.REACT_APP_INTLAYER_WATCHED_FILES_PATTERN_WITH_PATH,
|
|
104
|
-
outputFilesPatternWithPath: env.REACT_APP_INTLAYER_OUTPUT_FILES_PATTERN_WITH_PATH
|
|
105
|
-
};
|
|
106
|
-
return {
|
|
107
|
-
intlayerIntlConfiguration,
|
|
108
|
-
intlayerMiddlewareConfiguration,
|
|
109
|
-
intlayerContentConfiguration
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
const extractViteEnvVariable = () => {
|
|
113
|
-
const env = import_meta.env;
|
|
114
|
-
if (typeof env === "undefined") {
|
|
115
|
-
return extractEmptyEnvVariable();
|
|
116
|
-
}
|
|
117
|
-
const intlayerIntlConfiguration = {
|
|
118
|
-
locales: env.VITE_INTLAYER_LOCALES,
|
|
119
|
-
defaultLocale: env.VITE_INTLAYER_DEFAULT_LOCALE
|
|
120
|
-
};
|
|
121
|
-
const intlayerMiddlewareConfiguration = {
|
|
122
|
-
headerName: env.VITE_INTLAYER_HEADER_NAME,
|
|
123
|
-
cookieName: env.VITE_INTLAYER_COOKIE_NAME,
|
|
124
|
-
prefixDefault: env.VITE_INTLAYER_PREFIX_DEFAULT,
|
|
125
|
-
basePath: env.VITE_INTLAYER_BASE_PATH,
|
|
126
|
-
serverSetCookie: env.VITE_INTLAYER_SERVER_SET_COOKIE,
|
|
127
|
-
noPrefix: env.VITE_INTLAYER_NO_PREFIX
|
|
128
|
-
};
|
|
129
|
-
const intlayerContentConfiguration = {
|
|
130
|
-
fileExtensions: env.VITE_INTLAYER_FILE_EXTENSIONS,
|
|
131
|
-
baseDir: env.VITE_INTLAYER_BASE_DIR,
|
|
132
|
-
contentDirName: env.VITE_INTLAYER_CONTENT_DIR_NAME,
|
|
133
|
-
contentDir: env.VITE_INTLAYER_CONTENT_DIR,
|
|
134
|
-
excludedPath: env.VITE_INTLAYER_EXCLUDED_PATH,
|
|
135
|
-
resultDirName: env.VITE_INTLAYER_RESULT_DIR_NAME,
|
|
136
|
-
moduleAugmentationDirName: env.VITE_INTLAYER_MODULE_AUGMENTATION_DIR_NAME,
|
|
137
|
-
dictionariesDirName: env.VITE_INTLAYER_DICTIONARIES_DIR_NAME,
|
|
138
|
-
typeDirName: env.VITE_INTLAYER_TYPE_DIR_NAME,
|
|
139
|
-
mainDirName: env.VITE_INTLAYER_MAIN_DIR_NAME,
|
|
140
|
-
resultDir: env.VITE_INTLAYER_RESULT_DIR,
|
|
141
|
-
moduleAugmentationDir: env.VITE_INTLAYER_MODULE_AUGMENTATION_DIR,
|
|
142
|
-
dictionariesDir: env.VITE_INTLAYER_DICTIONARIES_DIR,
|
|
143
|
-
typesDir: env.VITE_INTLAYER_TYPE_DIR,
|
|
144
|
-
mainDir: env.VITE_INTLAYER_MAIN_DIR,
|
|
145
|
-
watchedFilesPattern: env.VITE_INTLAYER_WATCHED_FILES_PATTERN,
|
|
146
|
-
watchedFilesPatternWithPath: env.VITE_INTLAYER_WATCHED_FILES_PATTERN_WITH_PATH,
|
|
147
|
-
outputFilesPatternWithPath: env.VITE_INTLAYER_OUTPUT_FILES_PATTERN_WITH_PATH
|
|
148
|
-
};
|
|
149
|
-
return {
|
|
150
|
-
intlayerIntlConfiguration,
|
|
151
|
-
intlayerMiddlewareConfiguration,
|
|
152
|
-
intlayerContentConfiguration
|
|
153
|
-
};
|
|
154
|
-
};
|
|
155
|
-
const extractEmptyEnvVariable = () => {
|
|
156
|
-
const intlayerIntlConfiguration = {
|
|
157
|
-
locales: void 0,
|
|
158
|
-
defaultLocale: void 0
|
|
159
|
-
};
|
|
160
|
-
const intlayerMiddlewareConfiguration = {
|
|
161
|
-
headerName: void 0,
|
|
162
|
-
cookieName: void 0,
|
|
163
|
-
prefixDefault: void 0,
|
|
164
|
-
basePath: void 0,
|
|
165
|
-
serverSetCookie: void 0,
|
|
166
|
-
noPrefix: void 0
|
|
167
|
-
};
|
|
168
|
-
const intlayerContentConfiguration = {
|
|
169
|
-
fileExtensions: void 0,
|
|
170
|
-
baseDir: void 0,
|
|
171
|
-
contentDirName: void 0,
|
|
172
|
-
contentDir: void 0,
|
|
173
|
-
excludedPath: void 0,
|
|
174
|
-
resultDirName: void 0,
|
|
175
|
-
moduleAugmentationDirName: void 0,
|
|
176
|
-
dictionariesDirName: void 0,
|
|
177
|
-
typeDirName: void 0,
|
|
178
|
-
mainDirName: void 0,
|
|
179
|
-
resultDir: void 0,
|
|
180
|
-
moduleAugmentationDir: void 0,
|
|
181
|
-
dictionariesDir: void 0,
|
|
182
|
-
typesDir: void 0,
|
|
183
|
-
mainDir: void 0,
|
|
184
|
-
watchedFilesPattern: void 0,
|
|
185
|
-
watchedFilesPatternWithPath: void 0,
|
|
186
|
-
outputFilesPatternWithPath: void 0
|
|
187
|
-
};
|
|
188
|
-
return {
|
|
189
|
-
intlayerIntlConfiguration,
|
|
190
|
-
intlayerMiddlewareConfiguration,
|
|
191
|
-
intlayerContentConfiguration
|
|
192
|
-
};
|
|
193
|
-
};
|
|
194
|
-
const extractEnvVariable = () => {
|
|
195
|
-
const platform = (0, import_detectPlatform.getPlatform)();
|
|
196
|
-
switch (platform) {
|
|
197
|
-
case "next":
|
|
198
|
-
return extractNextEnvVariable();
|
|
199
|
-
case "vite":
|
|
200
|
-
return extractViteEnvVariable();
|
|
201
|
-
case "react_app":
|
|
202
|
-
return extractReactAppEnvVariable();
|
|
203
|
-
default:
|
|
204
|
-
return extractEmptyEnvVariable();
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
208
|
-
0 && (module.exports = {
|
|
209
|
-
extractEnvVariable
|
|
210
|
-
});
|
|
211
|
-
//# sourceMappingURL=extractEnvVariable.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/envVariables/extractEnvVariable.ts"],"sourcesContent":["import type {\n InternationalizationConfig,\n MiddlewareConfig,\n ContentConfig,\n} from '../types/config';\nimport { type ViteEnvVar, getPlatform } from './detectPlatform';\n\n// Utility type that replaces all values of a given type with another type\ntype ReplaceValue<T> = {\n [K in keyof T]: string | undefined;\n};\n\nconst extractNextEnvVariable = () => {\n if (typeof process === 'undefined') {\n return extractEmptyEnvVariable();\n }\n\n const env = process.env;\n\n const intlayerIntlConfiguration: ReplaceValue<InternationalizationConfig> = {\n locales: env.NEXT_PUBLIC_INTLAYER_LOCALES,\n defaultLocale: env.NEXT_PUBLIC_INTLAYER_DEFAULT_LOCALE,\n };\n\n const intlayerMiddlewareConfiguration: ReplaceValue<MiddlewareConfig> = {\n headerName: env.NEXT_PUBLIC_INTLAYER_HEADER_NAME,\n cookieName: env.NEXT_PUBLIC_INTLAYER_COOKIE_NAME,\n prefixDefault: env.NEXT_PUBLIC_INTLAYER_PREFIX_DEFAULT,\n basePath: env.NEXT_PUBLIC_INTLAYER_BASE_PATH,\n serverSetCookie: env.NEXT_PUBLIC_INTLAYER_SERVER_SET_COOKIE,\n noPrefix: env.NEXT_PUBLIC_INTLAYER_NO_PREFIX,\n };\n\n const intlayerContentConfiguration: ReplaceValue<ContentConfig> = {\n fileExtensions: env.NEXT_PUBLIC_INTLAYER_FILE_EXTENSIONS,\n baseDir: env.NEXT_PUBLIC_INTLAYER_BASE_DIR,\n contentDirName: env.NEXT_PUBLIC_INTLAYER_CONTENT_DIR_NAME,\n contentDir: env.NEXT_PUBLIC_INTLAYER_CONTENT_DIR,\n excludedPath: env.NEXT_PUBLIC_INTLAYER_EXCLUDED_PATH,\n resultDirName: env.NEXT_PUBLIC_INTLAYER_RESULT_DIR_NAME,\n moduleAugmentationDirName:\n env.NEXT_PUBLIC_INTLAYER_MODULE_AUGMENTATION_DIR_NAME,\n dictionariesDirName: env.NEXT_PUBLIC_INTLAYER_DICTIONARIES_DIR_NAME,\n typeDirName: env.NEXT_PUBLIC_INTLAYER_TYPE_DIR_NAME,\n mainDirName: env.NEXT_PUBLIC_INTLAYER_MAIN_DIR_NAME,\n resultDir: env.NEXT_PUBLIC_INTLAYER_RESULT_DIR,\n moduleAugmentationDir: env.NEXT_PUBLIC_INTLAYER_MODULE_AUGMENTATION_DIR,\n dictionariesDir: env.NEXT_PUBLIC_INTLAYER_DICTIONARIES_DIR,\n typesDir: env.NEXT_PUBLIC_INTLAYER_TYPE_DIR,\n mainDir: env.NEXT_PUBLIC_INTLAYER_MAIN_DIR,\n watchedFilesPattern: env.NEXT_PUBLIC_INTLAYER_WATCHED_FILES_PATTERN,\n watchedFilesPatternWithPath:\n env.NEXT_PUBLIC_INTLAYER_WATCHED_FILES_PATTERN_WITH_PATH,\n outputFilesPatternWithPath:\n env.NEXT_PUBLIC_INTLAYER_OUTPUT_FILES_PATTERN_WITH_PATH,\n };\n\n return {\n intlayerIntlConfiguration,\n intlayerMiddlewareConfiguration,\n intlayerContentConfiguration,\n };\n};\n\nconst extractReactAppEnvVariable = () => {\n if (typeof process === 'undefined') {\n return extractEmptyEnvVariable();\n }\n\n const env = process.env;\n\n const intlayerIntlConfiguration: ReplaceValue<InternationalizationConfig> = {\n locales: env.REACT_APP_INTLAYER_LOCALES,\n defaultLocale: env.REACT_APP_INTLAYER_DEFAULT_LOCALE,\n };\n\n const intlayerMiddlewareConfiguration: ReplaceValue<MiddlewareConfig> = {\n headerName: env.REACT_APP_INTLAYER_HEADER_NAME,\n cookieName: env.REACT_APP_INTLAYER_COOKIE_NAME,\n prefixDefault: env.REACT_APP_INTLAYER_PREFIX_DEFAULT,\n basePath: env.REACT_APP_INTLAYER_BASE_PATH,\n serverSetCookie: env.REACT_APP_INTLAYER_SERVER_SET_COOKIE,\n noPrefix: env.REACT_APP_INTLAYER_NO_PREFIX,\n };\n\n const intlayerContentConfiguration: ReplaceValue<ContentConfig> = {\n fileExtensions: env.REACT_APP_INTLAYER_FILE_EXTENSIONS,\n baseDir: env.REACT_APP_INTLAYER_BASE_DIR,\n contentDirName: env.REACT_APP_INTLAYER_CONTENT_DIR_NAME,\n contentDir: env.REACT_APP_INTLAYER_CONTENT_DIR,\n excludedPath: env.REACT_APP_INTLAYER_EXCLUDED_PATH,\n resultDirName: env.REACT_APP_INTLAYER_RESULT_DIR_NAME,\n moduleAugmentationDirName:\n env.REACT_APP_INTLAYER_MODULE_AUGMENTATION_DIR_NAME,\n dictionariesDirName: env.REACT_APP_INTLAYER_DICTIONARIES_DIR_NAME,\n typeDirName: env.REACT_APP_INTLAYER_TYPE_DIR_NAME,\n mainDirName: env.REACT_APP_INTLAYER_MAIN_DIR_NAME,\n resultDir: env.REACT_APP_INTLAYER_RESULT_DIR,\n moduleAugmentationDir: env.REACT_APP_INTLAYER_MODULE_AUGMENTATION_DIR,\n dictionariesDir: env.REACT_APP_INTLAYER_DICTIONARIES_DIR,\n typesDir: env.REACT_APP_INTLAYER_TYPE_DIR,\n mainDir: env.REACT_APP_INTLAYER_MAIN_DIR,\n watchedFilesPattern: env.REACT_APP_INTLAYER_WATCHED_FILES_PATTERN,\n watchedFilesPatternWithPath:\n env.REACT_APP_INTLAYER_WATCHED_FILES_PATTERN_WITH_PATH,\n outputFilesPatternWithPath:\n env.REACT_APP_INTLAYER_OUTPUT_FILES_PATTERN_WITH_PATH,\n };\n\n return {\n intlayerIntlConfiguration,\n intlayerMiddlewareConfiguration,\n intlayerContentConfiguration,\n };\n};\n\nconst extractViteEnvVariable = () => {\n const env = (import.meta as unknown as ViteEnvVar).env;\n\n if (typeof env === 'undefined') {\n return extractEmptyEnvVariable();\n }\n\n const intlayerIntlConfiguration: ReplaceValue<InternationalizationConfig> = {\n locales: env.VITE_INTLAYER_LOCALES,\n defaultLocale: env.VITE_INTLAYER_DEFAULT_LOCALE,\n };\n\n const intlayerMiddlewareConfiguration: ReplaceValue<MiddlewareConfig> = {\n headerName: env.VITE_INTLAYER_HEADER_NAME,\n cookieName: env.VITE_INTLAYER_COOKIE_NAME,\n prefixDefault: env.VITE_INTLAYER_PREFIX_DEFAULT,\n basePath: env.VITE_INTLAYER_BASE_PATH,\n serverSetCookie: env.VITE_INTLAYER_SERVER_SET_COOKIE,\n noPrefix: env.VITE_INTLAYER_NO_PREFIX,\n };\n\n const intlayerContentConfiguration: ReplaceValue<ContentConfig> = {\n fileExtensions: env.VITE_INTLAYER_FILE_EXTENSIONS,\n baseDir: env.VITE_INTLAYER_BASE_DIR,\n contentDirName: env.VITE_INTLAYER_CONTENT_DIR_NAME,\n contentDir: env.VITE_INTLAYER_CONTENT_DIR,\n excludedPath: env.VITE_INTLAYER_EXCLUDED_PATH,\n resultDirName: env.VITE_INTLAYER_RESULT_DIR_NAME,\n moduleAugmentationDirName: env.VITE_INTLAYER_MODULE_AUGMENTATION_DIR_NAME,\n dictionariesDirName: env.VITE_INTLAYER_DICTIONARIES_DIR_NAME,\n typeDirName: env.VITE_INTLAYER_TYPE_DIR_NAME,\n mainDirName: env.VITE_INTLAYER_MAIN_DIR_NAME,\n resultDir: env.VITE_INTLAYER_RESULT_DIR,\n moduleAugmentationDir: env.VITE_INTLAYER_MODULE_AUGMENTATION_DIR,\n dictionariesDir: env.VITE_INTLAYER_DICTIONARIES_DIR,\n typesDir: env.VITE_INTLAYER_TYPE_DIR,\n mainDir: env.VITE_INTLAYER_MAIN_DIR,\n watchedFilesPattern: env.VITE_INTLAYER_WATCHED_FILES_PATTERN,\n watchedFilesPatternWithPath:\n env.VITE_INTLAYER_WATCHED_FILES_PATTERN_WITH_PATH,\n outputFilesPatternWithPath:\n env.VITE_INTLAYER_OUTPUT_FILES_PATTERN_WITH_PATH,\n };\n\n return {\n intlayerIntlConfiguration,\n intlayerMiddlewareConfiguration,\n intlayerContentConfiguration,\n };\n};\n\nconst extractEmptyEnvVariable = () => {\n const intlayerIntlConfiguration: ReplaceValue<InternationalizationConfig> = {\n locales: undefined,\n defaultLocale: undefined,\n };\n\n const intlayerMiddlewareConfiguration: ReplaceValue<MiddlewareConfig> = {\n headerName: undefined,\n cookieName: undefined,\n prefixDefault: undefined,\n basePath: undefined,\n serverSetCookie: undefined,\n noPrefix: undefined,\n };\n\n const intlayerContentConfiguration: ReplaceValue<ContentConfig> = {\n fileExtensions: undefined,\n baseDir: undefined,\n contentDirName: undefined,\n contentDir: undefined,\n excludedPath: undefined,\n resultDirName: undefined,\n moduleAugmentationDirName: undefined,\n dictionariesDirName: undefined,\n typeDirName: undefined,\n mainDirName: undefined,\n resultDir: undefined,\n moduleAugmentationDir: undefined,\n dictionariesDir: undefined,\n typesDir: undefined,\n mainDir: undefined,\n watchedFilesPattern: undefined,\n watchedFilesPatternWithPath: undefined,\n outputFilesPatternWithPath: undefined,\n };\n\n return {\n intlayerIntlConfiguration,\n intlayerMiddlewareConfiguration,\n intlayerContentConfiguration,\n };\n};\n\nexport const extractEnvVariable = () => {\n const platform = getPlatform();\n\n switch (platform) {\n case 'next':\n return extractNextEnvVariable();\n case 'vite':\n return extractViteEnvVariable();\n case 'react_app':\n return extractReactAppEnvVariable();\n default:\n return extractEmptyEnvVariable();\n }\n};\n"],"mappings":"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","names":[]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { InternationalizationConfig, MiddlewareConfig, ContentConfig } from '../types/config.js';
|
|
2
|
-
import '../types/locales.js';
|
|
3
|
-
|
|
4
|
-
type ReplaceValue<T> = {
|
|
5
|
-
[K in keyof T]: string | undefined;
|
|
6
|
-
};
|
|
7
|
-
declare const extractEnvVariable: () => {
|
|
8
|
-
intlayerIntlConfiguration: ReplaceValue<InternationalizationConfig>;
|
|
9
|
-
intlayerMiddlewareConfiguration: ReplaceValue<MiddlewareConfig>;
|
|
10
|
-
intlayerContentConfiguration: ReplaceValue<ContentConfig>;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export { extractEnvVariable };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { InternationalizationConfig, MiddlewareConfig, ContentConfig } from '../types/config.mjs';
|
|
2
|
-
import '../types/locales.mjs';
|
|
3
|
-
|
|
4
|
-
type ReplaceValue<T> = {
|
|
5
|
-
[K in keyof T]: string | undefined;
|
|
6
|
-
};
|
|
7
|
-
declare const extractEnvVariable: () => {
|
|
8
|
-
intlayerIntlConfiguration: ReplaceValue<InternationalizationConfig>;
|
|
9
|
-
intlayerMiddlewareConfiguration: ReplaceValue<MiddlewareConfig>;
|
|
10
|
-
intlayerContentConfiguration: ReplaceValue<ContentConfig>;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export { extractEnvVariable };
|