@intlayer/types 9.0.0-canary.9 → 9.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/allLocales.cjs.map +1 -1
- package/dist/cjs/config.cjs.map +1 -1
- package/dist/cjs/nodeType.cjs.map +1 -1
- package/dist/esm/allLocales.mjs.map +1 -1
- package/dist/esm/config.mjs.map +1 -1
- package/dist/esm/nodeType.mjs.map +1 -1
- package/dist/types/allLocales.d.ts +0 -1
- package/dist/types/allLocales.d.ts.map +1 -1
- package/dist/types/config.d.ts +989 -941
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/dictionary.d.ts +449 -427
- package/dist/types/dictionary.d.ts.map +1 -1
- package/dist/types/filePathPattern.d.ts +6 -7
- package/dist/types/filePathPattern.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/keyPath.d.ts +0 -1
- package/dist/types/keyPath.d.ts.map +1 -1
- package/dist/types/locales.d.ts.map +1 -1
- package/dist/types/module_augmentation.d.ts +47 -48
- package/dist/types/module_augmentation.d.ts.map +1 -1
- package/dist/types/nodeType.d.ts +4 -4
- package/dist/types/nodeType.d.ts.map +1 -1
- package/dist/types/plugin.d.ts +24 -25
- package/dist/types/plugin.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/types/config.d.ts
CHANGED
|
@@ -2,12 +2,11 @@ import { Locale } from "./allLocales.js";
|
|
|
2
2
|
import { LocalesValues, StrictModeLocaleMap } from "./module_augmentation.js";
|
|
3
3
|
import { ContentAutoTransformation, DictionaryFormat, DictionaryLocation, Fill } from "./dictionary.js";
|
|
4
4
|
import { Plugin } from "./plugin.js";
|
|
5
|
-
|
|
6
5
|
//#region src/config.d.ts
|
|
7
6
|
/**
|
|
8
|
-
* Structural type for schema validation, compatible with Zod and other
|
|
9
|
-
* schema libraries that implement safeParse. Avoids a hard dependency on Zod.
|
|
10
|
-
*/
|
|
7
|
+
* Structural type for schema validation, compatible with Zod and other
|
|
8
|
+
* schema libraries that implement safeParse. Avoids a hard dependency on Zod.
|
|
9
|
+
*/
|
|
11
10
|
type ConfigSchema = {
|
|
12
11
|
safeParse(data: unknown): {
|
|
13
12
|
success: boolean;
|
|
@@ -24,155 +23,155 @@ type IPUrl = `${Protocol}://${number}.${string}${OptionalURLPath}` | `${Protocol
|
|
|
24
23
|
type DomainURL = `${Protocol}://${string}.${string}${OptionalURLPath}`;
|
|
25
24
|
type URLType = LocalhostURL | IPUrl | DomainURL | (string & {});
|
|
26
25
|
/**
|
|
27
|
-
* Configuration for internationalization settings
|
|
28
|
-
*/
|
|
26
|
+
* Configuration for internationalization settings
|
|
27
|
+
*/
|
|
29
28
|
type InternationalizationConfig = {
|
|
30
29
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
* Locales available in the application
|
|
31
|
+
*
|
|
32
|
+
* Default: [Locales.ENGLISH]
|
|
33
|
+
*
|
|
34
|
+
* You can define a list of available locales to support in the application.
|
|
35
|
+
*/
|
|
37
36
|
locales: Locale[];
|
|
38
37
|
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
* Locales required by TypeScript to ensure strong implementations of internationalized content using typescript.
|
|
39
|
+
*
|
|
40
|
+
* Default: []
|
|
41
|
+
*
|
|
42
|
+
* If empty, all locales are required in `strict` mode.
|
|
43
|
+
*
|
|
44
|
+
* Ensure required locales are also defined in the `locales` field.
|
|
45
|
+
*/
|
|
47
46
|
requiredLocales: Locale[];
|
|
48
47
|
/**
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
* Ensure strong implementations of internationalized content using typescript.
|
|
49
|
+
* - 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.
|
|
50
|
+
* - 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.
|
|
51
|
+
* - If set to "loose", the translation `t` function will accept any existing locale.
|
|
52
|
+
*
|
|
53
|
+
* Default: "inclusive"
|
|
54
|
+
*/
|
|
56
55
|
strictMode: StrictMode;
|
|
57
56
|
/**
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
* Default locale of the application for fallback
|
|
58
|
+
*
|
|
59
|
+
* Default: Locales.ENGLISH
|
|
60
|
+
*
|
|
61
|
+
* Used to specify a fallback locale in case no other locale is set.
|
|
62
|
+
*/
|
|
64
63
|
defaultLocale: Locale;
|
|
65
64
|
};
|
|
66
65
|
type CookiesAttributes = {
|
|
67
66
|
/**
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
* Type of the storage
|
|
68
|
+
*
|
|
69
|
+
* The type of the storage. It can be 'cookie'.
|
|
70
|
+
*/
|
|
72
71
|
type: "cookie";
|
|
73
72
|
/**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
* Cookie name to store the locale information
|
|
74
|
+
*
|
|
75
|
+
* Default: 'INTLAYER_LOCALE'
|
|
76
|
+
*
|
|
77
|
+
* The cookie key where the locale information is stored.
|
|
78
|
+
*/
|
|
80
79
|
name?: string;
|
|
81
80
|
/**
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
81
|
+
* Cookie domain to store the locale information
|
|
82
|
+
*
|
|
83
|
+
* Default: undefined
|
|
84
|
+
*
|
|
85
|
+
* Define the domain where the cookie is available. Defaults to
|
|
86
|
+
* the domain of the page where the cookie was created.
|
|
87
|
+
*/
|
|
89
88
|
domain?: string;
|
|
90
89
|
/**
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
90
|
+
* Cookie path to store the locale information
|
|
91
|
+
*
|
|
92
|
+
* Default: undefined
|
|
93
|
+
*
|
|
94
|
+
* Define the path where the cookie is available. Defaults to '/'
|
|
95
|
+
*/
|
|
97
96
|
path?: string;
|
|
98
97
|
/**
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
98
|
+
* Cookie secure to store the locale information
|
|
99
|
+
*
|
|
100
|
+
* Default: undefined
|
|
101
|
+
*
|
|
102
|
+
* A Boolean indicating if the cookie transmission requires a
|
|
103
|
+
* secure protocol (https). Defaults to false.
|
|
104
|
+
*/
|
|
106
105
|
secure?: boolean;
|
|
107
106
|
/**
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
107
|
+
* Cookie httpOnly to store the locale information
|
|
108
|
+
*
|
|
109
|
+
* Default: undefined
|
|
110
|
+
*
|
|
111
|
+
* The cookie httpOnly where the locale information is stored.
|
|
112
|
+
*/
|
|
114
113
|
httpOnly?: boolean;
|
|
115
114
|
/**
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
115
|
+
* Cookie sameSite to store the locale information
|
|
116
|
+
*
|
|
117
|
+
* Default: undefined
|
|
118
|
+
*
|
|
119
|
+
* Asserts that a cookie must not be sent with cross-origin requests,
|
|
120
|
+
* providing some protection against cross-site request forgery
|
|
121
|
+
* attacks (CSRF)
|
|
122
|
+
*/
|
|
124
123
|
sameSite?: "strict" | "lax" | "none";
|
|
125
124
|
/**
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
125
|
+
* Cookie expires to store the locale information
|
|
126
|
+
*
|
|
127
|
+
* Default: undefined
|
|
128
|
+
*
|
|
129
|
+
* Define when the cookie will be removed:
|
|
130
|
+
* - a `number` is interpreted as **days from the time of creation**;
|
|
131
|
+
* - a `Date` instance (or an ISO date string, e.g. produced when the
|
|
132
|
+
* configuration is serialized) is interpreted as an **absolute moment**.
|
|
133
|
+
*
|
|
134
|
+
* If omitted, the cookie becomes a session cookie. When `maxAge` is set it
|
|
135
|
+
* takes precedence over `expires`.
|
|
136
|
+
*/
|
|
138
137
|
expires?: Date | number | string | undefined;
|
|
139
138
|
/**
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
139
|
+
* Cookie max-age to store the locale information
|
|
140
|
+
*
|
|
141
|
+
* Default: undefined
|
|
142
|
+
*
|
|
143
|
+
* Define the cookie lifetime in seconds from the time of creation
|
|
144
|
+
* (e.g. `60 * 60 * 24 * 365` for one year). Takes precedence over
|
|
145
|
+
* `expires` when both are set.
|
|
146
|
+
*/
|
|
148
147
|
maxAge?: number;
|
|
149
148
|
};
|
|
150
149
|
type StorageAttributes = {
|
|
151
150
|
/**
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
151
|
+
* Storage type where the locale is stored
|
|
152
|
+
*
|
|
153
|
+
* Determines whether the locale is persisted in `localStorage` (across sessions)
|
|
154
|
+
* or `sessionStorage` (cleared when the browser session ends) or `header` (from the request header).
|
|
155
|
+
*/
|
|
157
156
|
type: "localStorage" | "sessionStorage" | "header";
|
|
158
157
|
/**
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
158
|
+
* Storage key to store the locale information
|
|
159
|
+
*
|
|
160
|
+
* Default: 'INTLAYER_LOCALE'
|
|
161
|
+
*
|
|
162
|
+
* The key name used in the client storage to save the locale.
|
|
163
|
+
*/
|
|
165
164
|
name?: string;
|
|
166
165
|
};
|
|
167
166
|
/**
|
|
168
|
-
* Cookie attributes after the config-build normalization step.
|
|
169
|
-
*
|
|
170
|
-
* The user-facing `expires` (days / `Date` / ISO string) and `maxAge` (seconds)
|
|
171
|
-
* are merged into a single, serialization-safe `expires` field so the client
|
|
172
|
-
* runtime stays minimal:
|
|
173
|
-
* - `number` → seconds from cookie creation (relative);
|
|
174
|
-
* - `string` → an absolute expiry as an ISO date string.
|
|
175
|
-
*/
|
|
167
|
+
* Cookie attributes after the config-build normalization step.
|
|
168
|
+
*
|
|
169
|
+
* The user-facing `expires` (days / `Date` / ISO string) and `maxAge` (seconds)
|
|
170
|
+
* are merged into a single, serialization-safe `expires` field so the client
|
|
171
|
+
* runtime stays minimal:
|
|
172
|
+
* - `number` → seconds from cookie creation (relative);
|
|
173
|
+
* - `string` → an absolute expiry as an ISO date string.
|
|
174
|
+
*/
|
|
176
175
|
type ProcessedCookieAttributes = {
|
|
177
176
|
domain?: string;
|
|
178
177
|
path?: string;
|
|
@@ -182,9 +181,9 @@ type ProcessedCookieAttributes = {
|
|
|
182
181
|
expires?: number | string;
|
|
183
182
|
};
|
|
184
183
|
/**
|
|
185
|
-
* Pre-computed storage attributes derived from `RoutingConfig.storage`.
|
|
186
|
-
* Computed at config-build time to avoid repeated processing at runtime.
|
|
187
|
-
*/
|
|
184
|
+
* Pre-computed storage attributes derived from `RoutingConfig.storage`.
|
|
185
|
+
* Computed at config-build time to avoid repeated processing at runtime.
|
|
186
|
+
*/
|
|
188
187
|
type ProcessedStorageAttributes = {
|
|
189
188
|
cookies?: {
|
|
190
189
|
name: string;
|
|
@@ -209,232 +208,273 @@ type RewriteRules = {
|
|
|
209
208
|
};
|
|
210
209
|
type RewriteObject = {
|
|
211
210
|
/**
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
211
|
+
* Used for client-side URL generation (e.g., getLocalizedUrl).
|
|
212
|
+
* Patterns are usually stripped of locale prefixes as the core logic handles prefixing.
|
|
213
|
+
*/
|
|
215
214
|
url: RewriteRules;
|
|
216
215
|
/**
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
216
|
+
* Used for Next.js middleware / proxy.
|
|
217
|
+
* Patterns usually include [locale] or :locale to match incoming full URLs.
|
|
218
|
+
*/
|
|
220
219
|
nextjs?: RewriteRules;
|
|
221
220
|
/**
|
|
222
|
-
|
|
223
|
-
|
|
221
|
+
* Used for Vite proxy middleware.
|
|
222
|
+
*/
|
|
224
223
|
vite?: RewriteRules;
|
|
225
224
|
};
|
|
226
225
|
/**
|
|
227
|
-
* Configuration for routing behaviors
|
|
228
|
-
*/
|
|
226
|
+
* Configuration for routing behaviors
|
|
227
|
+
*/
|
|
229
228
|
type RoutingConfig = {
|
|
230
229
|
/**
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
230
|
+
* Rewrite the URLs to a localized path
|
|
231
|
+
*
|
|
232
|
+
* Example:
|
|
233
|
+
* ```ts
|
|
234
|
+
* // ...
|
|
235
|
+
* routing: {
|
|
236
|
+
* rewrite: nextjsRewrite({
|
|
237
|
+
* '[locale]/about': {
|
|
238
|
+
* fr: '[locale]/a-propos'
|
|
239
|
+
* }
|
|
240
|
+
* })
|
|
241
|
+
* }
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
245
244
|
rewrite?: Record<URLPath, StrictModeLocaleMap<URLPath>> | RewriteObject;
|
|
246
245
|
/**
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
246
|
+
* URL routing mode for locale handling
|
|
247
|
+
*
|
|
248
|
+
* Controls how locales are represented in application URLs:
|
|
249
|
+
* - 'prefix-no-default': Prefix all locales except the default locale
|
|
250
|
+
* - 'prefix-all': Prefix all locales including the default locale
|
|
251
|
+
* - 'no-prefix': No locale prefixing in URLs
|
|
252
|
+
* - 'search-params': Use search parameters for locale handling
|
|
253
|
+
*
|
|
254
|
+
* Examples with defaultLocale = 'en':
|
|
255
|
+
* - 'prefix-no-default': /dashboard (en) or /fr/dashboard (fr)
|
|
256
|
+
* - 'prefix-all': /en/dashboard (en) or /fr/dashboard (fr)
|
|
257
|
+
* - 'no-prefix': /dashboard (locale handled via other means)
|
|
258
|
+
* - 'search-params': /dashboard?locale=fr
|
|
259
|
+
*
|
|
260
|
+
* Note: This setting do not impact the cookie, or locale storage management.
|
|
261
|
+
*
|
|
262
|
+
* Default: 'prefix-no-default'
|
|
263
|
+
*/
|
|
265
264
|
mode: "prefix-no-default" | "prefix-all" | "no-prefix" | "search-params";
|
|
266
265
|
/**
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
266
|
+
* Enables the Intlayer locale-routing proxy (middleware).
|
|
267
|
+
*
|
|
268
|
+
* When enabled, the build-tool integration (e.g. the `intlayer()` Vite plugin)
|
|
269
|
+
* automatically wires the locale-detection / redirect / rewrite middleware in
|
|
270
|
+
* development, preview, and production SSR. Disable it when you want to handle
|
|
271
|
+
* locale routing yourself, or when your routing mode does not require a proxy.
|
|
272
|
+
*
|
|
273
|
+
* Default: true
|
|
274
|
+
*/
|
|
276
275
|
enableProxy: boolean;
|
|
277
276
|
/**
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
277
|
+
* Pre-computed storage attributes derived from the raw `storage` input.
|
|
278
|
+
* Populated at config-build time by `getStorageAttributes(rawStorage)`.
|
|
279
|
+
* Use this at runtime instead of re-processing the raw storage config.
|
|
280
|
+
*/
|
|
282
281
|
storage: ProcessedStorageAttributes;
|
|
283
282
|
/**
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
283
|
+
* Base path for application URLs
|
|
284
|
+
*
|
|
285
|
+
* Default: ''
|
|
286
|
+
*
|
|
287
|
+
* Defines the base path where the application is accessible from.
|
|
288
|
+
*/
|
|
290
289
|
basePath?: string;
|
|
291
290
|
/**
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
291
|
+
* Maps locales to specific domain hostnames for domain-based routing.
|
|
292
|
+
* When a locale is mapped to a domain, URLs generated for that locale
|
|
293
|
+
* will use that domain as the base URL (absolute URL), and no locale
|
|
294
|
+
* prefix will be added to the path (the domain itself implies the locale).
|
|
295
|
+
*
|
|
296
|
+
* Default: undefined
|
|
297
|
+
*
|
|
298
|
+
* Example:
|
|
299
|
+
* ```ts
|
|
300
|
+
* domains: {
|
|
301
|
+
* en: 'intlayer.org',
|
|
302
|
+
* zh: 'intlayer.cn',
|
|
303
|
+
* }
|
|
304
|
+
* ```
|
|
305
|
+
*/
|
|
307
306
|
domains?: Partial<Record<LocalesValues, string>>;
|
|
308
307
|
};
|
|
309
308
|
/**
|
|
310
|
-
* Raw storage input accepted in the user-facing config (`intlayer.config.ts`).
|
|
311
|
-
* Converted to {@link ProcessedStorageAttributes} during config build.
|
|
312
|
-
*
|
|
313
|
-
* Configuration for storing the locale in the client (localStorage or sessionStorage)
|
|
314
|
-
*
|
|
315
|
-
* If false, the locale will not be stored by the middleware.
|
|
316
|
-
* If true, the locale storage will consider all default values.
|
|
317
|
-
*
|
|
318
|
-
* Default: ['cookie', 'header]
|
|
319
|
-
*
|
|
320
|
-
* Note: Check out GDPR compliance for cookies. See https://gdpr.eu/cookies/
|
|
321
|
-
* Note: useLocale hook includes a prop to disable the cookie storage.
|
|
322
|
-
* Note: Even if storage is disabled, the middleware will still detect the locale from the request header (1- check for `x-intlayer-locale`, 2- fallback to the `accept-language`).
|
|
323
|
-
*
|
|
324
|
-
* Recommendation:
|
|
325
|
-
* - Config both localStorage and cookies for the storage of the locale if you want to support GDPR compliance.
|
|
326
|
-
* - Disable the cookie storage by default on the useLocale hook by waiting for the user to consent to the cookie storage.
|
|
327
|
-
*/
|
|
309
|
+
* Raw storage input accepted in the user-facing config (`intlayer.config.ts`).
|
|
310
|
+
* Converted to {@link ProcessedStorageAttributes} during config build.
|
|
311
|
+
*
|
|
312
|
+
* Configuration for storing the locale in the client (localStorage or sessionStorage)
|
|
313
|
+
*
|
|
314
|
+
* If false, the locale will not be stored by the middleware.
|
|
315
|
+
* If true, the locale storage will consider all default values.
|
|
316
|
+
*
|
|
317
|
+
* Default: ['cookie', 'header]
|
|
318
|
+
*
|
|
319
|
+
* Note: Check out GDPR compliance for cookies. See https://gdpr.eu/cookies/
|
|
320
|
+
* Note: useLocale hook includes a prop to disable the cookie storage.
|
|
321
|
+
* Note: Even if storage is disabled, the middleware will still detect the locale from the request header (1- check for `x-intlayer-locale`, 2- fallback to the `accept-language`).
|
|
322
|
+
*
|
|
323
|
+
* Recommendation:
|
|
324
|
+
* - Config both localStorage and cookies for the storage of the locale if you want to support GDPR compliance.
|
|
325
|
+
* - Disable the cookie storage by default on the useLocale hook by waiting for the user to consent to the cookie storage.
|
|
326
|
+
*/
|
|
328
327
|
type RoutingStorageInput = false | "cookie" | "localStorage" | "sessionStorage" | "header" | CookiesAttributes | StorageAttributes | ("cookie" | "localStorage" | "sessionStorage" | "header" | CookiesAttributes | StorageAttributes)[];
|
|
329
328
|
/**
|
|
330
|
-
* User-facing routing configuration (accepted in `intlayer.config.ts`).
|
|
331
|
-
*/
|
|
329
|
+
* User-facing routing configuration (accepted in `intlayer.config.ts`).
|
|
330
|
+
*/
|
|
332
331
|
type CustomRoutingConfig = Omit<RoutingConfig, "storage"> & {
|
|
333
332
|
storage?: RoutingStorageInput;
|
|
334
333
|
};
|
|
335
334
|
/**
|
|
336
|
-
* Configuration for intlayer editor
|
|
337
|
-
*/
|
|
335
|
+
* Configuration for intlayer editor
|
|
336
|
+
*/
|
|
338
337
|
type EditorConfig = {
|
|
339
338
|
/**
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
339
|
+
* URL of the application. Used to restrict the origin of the editor for security reasons.
|
|
340
|
+
*
|
|
341
|
+
* Default: ''
|
|
342
|
+
*/
|
|
344
343
|
applicationURL?: URLType;
|
|
345
344
|
/**
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
345
|
+
* Public URL for the editor.
|
|
346
|
+
* Default: "http://localhost:8000"
|
|
347
|
+
*/
|
|
349
348
|
editorURL?: URLType;
|
|
350
349
|
/**
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
350
|
+
* Intlayer CMS URL.
|
|
351
|
+
* Default: "https://app.intlayer.org"
|
|
352
|
+
*/
|
|
354
353
|
cmsURL?: URLType;
|
|
355
354
|
/**
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
355
|
+
* Backend API URL.
|
|
356
|
+
* Default: "https://back.intlayer.org"
|
|
357
|
+
*/
|
|
359
358
|
backendURL?: URLType;
|
|
360
359
|
/**
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
360
|
+
* Indicates if the application interact with the visual editor
|
|
361
|
+
*
|
|
362
|
+
* Default: false;
|
|
363
|
+
*
|
|
364
|
+
* If true, the editor will be able to interact with the application.
|
|
365
|
+
* If false, the editor will not be able to interact with the application.
|
|
366
|
+
* In any case, the editor can only be enabled by the visual editor.
|
|
367
|
+
* Disabling the editor for specific environments is a way to enforce the security.
|
|
368
|
+
*
|
|
369
|
+
* Usage:
|
|
370
|
+
* ```js
|
|
371
|
+
* {
|
|
372
|
+
* // Other configurations
|
|
373
|
+
* editor: {
|
|
374
|
+
* enabled: process.env.NODE_ENV !== 'production',
|
|
375
|
+
* }
|
|
376
|
+
* };
|
|
377
|
+
* ```
|
|
378
|
+
*
|
|
379
|
+
*/
|
|
381
380
|
enabled: boolean;
|
|
382
381
|
/** Port of the editor server
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
382
|
+
*
|
|
383
|
+
* Default: 8000
|
|
384
|
+
*/
|
|
386
385
|
port: number;
|
|
387
386
|
/**
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
387
|
+
* clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.
|
|
388
|
+
* An access token is use to authenticate the user related to the project.
|
|
389
|
+
* To get an access token, go to https://app.intlayer.org/project and create an account.
|
|
390
|
+
*
|
|
391
|
+
* Default: undefined
|
|
392
|
+
*
|
|
393
|
+
* > 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.
|
|
394
|
+
*/
|
|
396
395
|
clientId?: string;
|
|
397
396
|
/**
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
397
|
+
* clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.
|
|
398
|
+
* An access token is use to authenticate the user related to the project.
|
|
399
|
+
* To get an access token, go to https://app.intlayer.org/project and create an account.
|
|
400
|
+
*
|
|
401
|
+
* Default: undefined
|
|
402
|
+
*
|
|
403
|
+
* > 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.
|
|
404
|
+
*/
|
|
406
405
|
clientSecret?: string;
|
|
407
406
|
/**
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
407
|
+
* Strategy for prioritizing dictionaries. If a dictionary is both present online and locally, the content will be merge.
|
|
408
|
+
* However, is a field is defined in both dictionary, this setting determines which fields takes the priority over the other.
|
|
409
|
+
*
|
|
410
|
+
* Default: 'local_first'
|
|
411
|
+
*
|
|
412
|
+
* The strategy for prioritizing dictionaries. It can be either 'local_first' or 'distant_first'.
|
|
413
|
+
* - 'local_first': The first dictionary found in the locale is used.
|
|
414
|
+
* - 'distant_first': The first dictionary found in the distant locales is used.
|
|
415
|
+
*/
|
|
417
416
|
dictionaryPriorityStrategy: "local_first" | "distant_first";
|
|
418
417
|
/**
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
418
|
+
* Indicates if the application should hot reload the locale configurations when a change is detected.
|
|
419
|
+
* For example, when a new dictionary is added or updated, the application will update the content tu display in the page.
|
|
420
|
+
*
|
|
421
|
+
* Default: true
|
|
422
|
+
*/
|
|
424
423
|
liveSync: boolean;
|
|
425
424
|
/**
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
425
|
+
* Port of the live sync server
|
|
426
|
+
*
|
|
427
|
+
* Default: 4000
|
|
428
|
+
*/
|
|
430
429
|
liveSyncPort: number;
|
|
431
430
|
/**
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
431
|
+
* URL of the live sync server in case of remote live sync server
|
|
432
|
+
*
|
|
433
|
+
* Default: `http://localhost:${liveSyncPort}`
|
|
434
|
+
*/
|
|
436
435
|
liveSyncURL: URLType;
|
|
437
436
|
};
|
|
437
|
+
/**
|
|
438
|
+
* Configuration for Intlayer analytics (`@intlayer/analytics`).
|
|
439
|
+
*
|
|
440
|
+
* Analytics is strictly **opt-in**: nothing is collected unless `enabled` is
|
|
441
|
+
* explicitly set to `true` AND a project key (`editor.clientId`) is configured
|
|
442
|
+
* for attribution.
|
|
443
|
+
*/
|
|
444
|
+
type AnalyticsConfig = {
|
|
445
|
+
/**
|
|
446
|
+
* Enables analytics collection (page views, content exposures, A/B events).
|
|
447
|
+
*
|
|
448
|
+
* Default: false
|
|
449
|
+
*
|
|
450
|
+
* When `false` (the default), the whole `@intlayer/analytics` integration is
|
|
451
|
+
* dead-code-eliminated from the application bundle.
|
|
452
|
+
*
|
|
453
|
+
* Usage:
|
|
454
|
+
* ```js
|
|
455
|
+
* {
|
|
456
|
+
* // Other configurations
|
|
457
|
+
* analytics: {
|
|
458
|
+
* enabled: process.env.NODE_ENV === 'production',
|
|
459
|
+
* }
|
|
460
|
+
* };
|
|
461
|
+
* ```
|
|
462
|
+
*/
|
|
463
|
+
enabled: boolean;
|
|
464
|
+
/**
|
|
465
|
+
* Milliseconds between automatic batched flushes to the backend.
|
|
466
|
+
*
|
|
467
|
+
* Default: 20000
|
|
468
|
+
*/
|
|
469
|
+
flushInterval: number;
|
|
470
|
+
/**
|
|
471
|
+
* Fraction of sessions to record, from 0 (none) to 1 (all). Sampling is
|
|
472
|
+
* deterministic per session so recorded sessions report all of their events.
|
|
473
|
+
*
|
|
474
|
+
* Default: 1
|
|
475
|
+
*/
|
|
476
|
+
sampleRate: number;
|
|
477
|
+
};
|
|
438
478
|
declare enum AiProviders {
|
|
439
479
|
OPENAI = "openai",
|
|
440
480
|
ANTHROPIC = "anthropic",
|
|
@@ -455,810 +495,818 @@ declare enum AiProviders {
|
|
|
455
495
|
}
|
|
456
496
|
type CommonAiConfig = {
|
|
457
497
|
/**
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
498
|
+
* API model
|
|
499
|
+
*
|
|
500
|
+
* The model to use for the AI features of Intlayer.
|
|
501
|
+
*
|
|
502
|
+
* Example: 'gpt-4o-2024-11-20'
|
|
503
|
+
*
|
|
504
|
+
*/
|
|
465
505
|
model?: string;
|
|
466
506
|
/**
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
507
|
+
* temperature
|
|
508
|
+
*
|
|
509
|
+
* The temperature to use for the AI features of Intlayer.
|
|
510
|
+
* The temperature controls the randomness of the AI's responses.
|
|
511
|
+
* A higher temperature will make the AI more creative and less predictable.
|
|
512
|
+
*
|
|
513
|
+
* Example: 0.1
|
|
514
|
+
*/
|
|
475
515
|
temperature?: number;
|
|
476
516
|
/**
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
517
|
+
* API key
|
|
518
|
+
*
|
|
519
|
+
* Use your own OpenAI API key to use the AI features of Intlayer.
|
|
520
|
+
* If you don't have an OpenAI API key, you can get one for free at https://openai.com/api/.
|
|
521
|
+
*
|
|
522
|
+
*/
|
|
483
523
|
apiKey?: string;
|
|
484
524
|
/**
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
525
|
+
* Application context
|
|
526
|
+
*
|
|
527
|
+
* The context of the application to use for the AI features of Intlayer.
|
|
528
|
+
*
|
|
529
|
+
* Example: 'This is a website for a company that sells products online.'
|
|
530
|
+
*/
|
|
491
531
|
applicationContext?: string;
|
|
492
532
|
/**
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
533
|
+
* Base URL
|
|
534
|
+
*
|
|
535
|
+
* The base URL to use for the AI features of Intlayer.
|
|
536
|
+
*
|
|
537
|
+
* Example: 'https://api.openai.com/v1'
|
|
538
|
+
*/
|
|
499
539
|
baseURL?: string;
|
|
500
540
|
/**
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
541
|
+
* Data serialization
|
|
542
|
+
*
|
|
543
|
+
* The data serialization format to use for the AI features of Intlayer.
|
|
544
|
+
*
|
|
545
|
+
* Default: 'json'
|
|
546
|
+
*/
|
|
507
547
|
dataSerialization?: "json" | "toon";
|
|
508
548
|
};
|
|
509
549
|
type AiProviderConfigMap = {};
|
|
510
550
|
type AiConfigUnion = { [P in keyof AiProviderConfigMap]: {
|
|
511
551
|
provider: P | `${P}`;
|
|
512
|
-
} & AiProviderConfigMap[P] }[keyof AiProviderConfigMap];
|
|
552
|
+
} & AiProviderConfigMap[P]; }[keyof AiProviderConfigMap];
|
|
513
553
|
type AiConfig = CommonAiConfig & (AiConfigUnion | {
|
|
514
554
|
provider?: AiProviders | `${AiProviders}`;
|
|
515
555
|
});
|
|
516
556
|
type BuildConfig = {
|
|
517
557
|
/**
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
558
|
+
* Indicates the mode of the build
|
|
559
|
+
*
|
|
560
|
+
* Default: 'auto'
|
|
561
|
+
*
|
|
562
|
+
* If 'auto', the build will be enabled automatically when the application is built.
|
|
563
|
+
* If 'manual', the build will be set only when the build command is executed.
|
|
564
|
+
*
|
|
565
|
+
* Can be used to disable dictionaries build, for instance when execution on Node.js environment should be avoided.
|
|
566
|
+
*/
|
|
527
567
|
mode: "auto" | "manual";
|
|
528
568
|
/**
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
569
|
+
* Indicates if the build should be optimized
|
|
570
|
+
*
|
|
571
|
+
* Default: undefined
|
|
572
|
+
*
|
|
573
|
+
* If true, the build will be optimized.
|
|
574
|
+
* If false, the build will not be optimized.
|
|
575
|
+
*
|
|
576
|
+
* Intlayer will replace all calls of dictionaries to optimize chunking. That way the final bundle will import only the dictionaries that are used.
|
|
577
|
+
* All imports will stay as static import to avoid async processing when loading the dictionaries.
|
|
578
|
+
*
|
|
579
|
+
* Note:
|
|
580
|
+
* - Intlayer will replace all call of `useIntlayer` with the defined mode by the `importMode` option.
|
|
581
|
+
* - Intlayer will replace all call of `getIntlayer` with `getDictionary`.
|
|
582
|
+
* - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.
|
|
583
|
+
* - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.
|
|
584
|
+
*/
|
|
545
585
|
optimize?: boolean;
|
|
546
586
|
/**
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
587
|
+
* Indicates the mode of import to use for the dictionaries.
|
|
588
|
+
*
|
|
589
|
+
* Available modes:
|
|
590
|
+
* - "static": The dictionaries are imported statically.
|
|
591
|
+
* In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionary`.
|
|
592
|
+
* - "dynamic": The dictionaries are imported dynamically in a synchronous component using the suspense API.
|
|
593
|
+
* In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.
|
|
594
|
+
* - "fetch": The dictionaries are imported dynamically using the live sync API.
|
|
595
|
+
* In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.
|
|
596
|
+
* Fetch 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.
|
|
597
|
+
*
|
|
598
|
+
* Default: "static"
|
|
599
|
+
*
|
|
600
|
+
* By default, when a dictionary is loaded, it imports content for all locales as it's imported statically.
|
|
601
|
+
*
|
|
602
|
+
* Note:
|
|
603
|
+
* - Dynamic imports rely on Suspense and may slightly impact rendering performance.
|
|
604
|
+
* - If desabled all locales will be loaded at once, even if they are not used.
|
|
605
|
+
* - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.
|
|
606
|
+
* - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.
|
|
607
|
+
* - This option will be ignored if `optimize` is disabled.
|
|
608
|
+
* - 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.
|
|
609
|
+
* - The "fetch" allows to sync the dictionaries to the live sync server.
|
|
610
|
+
* - Require static key to work. Example of invalid code: `const navbarKey = "my-key"; useIntlayer(navbarKey)`.
|
|
611
|
+
*
|
|
612
|
+
* @deprecated Use `dictionary.importMode` instead.
|
|
613
|
+
*/
|
|
574
614
|
importMode?: "static" | "dynamic" | "fetch";
|
|
575
615
|
/**
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
616
|
+
* Minify the dictionaries to reduce the bundle size.
|
|
617
|
+
*
|
|
618
|
+
* Default: false
|
|
619
|
+
*
|
|
620
|
+
* Note:
|
|
621
|
+
* - This option will be ignored if `optimize` is disabled.
|
|
622
|
+
* - This option will be ignore if `editor.enabled` is true.
|
|
623
|
+
* - If there is edge cases where the minification is not working properly, the dictionary will be not minified.
|
|
624
|
+
*/
|
|
585
625
|
minify: boolean;
|
|
586
626
|
/**
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
627
|
+
* Purge the unused keys in a dictionaries
|
|
628
|
+
*
|
|
629
|
+
* Default: false
|
|
630
|
+
*
|
|
631
|
+
* Note:
|
|
632
|
+
* - This option will be ignored if `optimize` is disabled.
|
|
633
|
+
*/
|
|
594
634
|
purge: boolean;
|
|
595
635
|
/**
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
636
|
+
* Pattern to traverse the code to optimize.
|
|
637
|
+
*
|
|
638
|
+
* Allows to avoid to traverse the code that is not relevant to the optimization.
|
|
639
|
+
* Improve build performance.
|
|
640
|
+
*
|
|
641
|
+
* Default: ['**\/*.{js,ts,mjs,cjs,jsx,tsx}', '!**\/node_modules/**']
|
|
642
|
+
*
|
|
643
|
+
* Example: `['src/**\/*.{ts,tsx}', '../ui-library/**\/*.{ts,tsx}', '!**\/node_modules/**']`
|
|
644
|
+
*
|
|
645
|
+
* Note:
|
|
646
|
+
* - This option will be ignored if `optimize` is disabled.
|
|
647
|
+
* - Use glob pattern.
|
|
648
|
+
*/
|
|
609
649
|
traversePattern: string[];
|
|
610
650
|
/**
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
651
|
+
* Output format of the dictionaries
|
|
652
|
+
*
|
|
653
|
+
* Default: ['cjs', 'esm']
|
|
654
|
+
*
|
|
655
|
+
* The output format of the dictionaries. It can be either 'cjs' or 'esm'. Even if dictionaries are written in JSON, entry point to access the dictionaries are generated.
|
|
656
|
+
* This function will use the output format defined using this option.
|
|
657
|
+
* The default format is 'cjs' as it allows better interoperability with other libraries, scripts, and applications. But some build tools, such as Vite, require ES modules.
|
|
658
|
+
*/
|
|
619
659
|
outputFormat: ("cjs" | "esm")[];
|
|
620
660
|
/**
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
661
|
+
* Indicates if the cache should be enabled
|
|
662
|
+
*
|
|
663
|
+
* Default: true
|
|
664
|
+
*
|
|
665
|
+
* If true, the cache will be enabled.
|
|
666
|
+
* If false, the cache will not be enabled.
|
|
667
|
+
*/
|
|
628
668
|
cache: boolean;
|
|
629
669
|
/**
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
670
|
+
* Require function
|
|
671
|
+
*
|
|
672
|
+
* In some environments, as VSCode extension, the require function should be set relatively to the project root to work properly.
|
|
673
|
+
*
|
|
674
|
+
* Default: undefined
|
|
675
|
+
*
|
|
676
|
+
* If undefined, the require function will be set to the default require function.
|
|
677
|
+
* If defined, the require function will be set to the defined require function.
|
|
678
|
+
*
|
|
679
|
+
* Example:
|
|
680
|
+
* ```js
|
|
681
|
+
* {
|
|
682
|
+
* require: require
|
|
683
|
+
* }
|
|
684
|
+
* ```
|
|
685
|
+
*/
|
|
646
686
|
require?: NodeJS.Require;
|
|
647
687
|
/**
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
688
|
+
* Indicates if the build should check TypeScript types
|
|
689
|
+
*
|
|
690
|
+
* Default: false
|
|
691
|
+
*
|
|
692
|
+
* If true, the build will check TypeScript types and log errors.
|
|
693
|
+
* Note: This can slow down the build.
|
|
694
|
+
*/
|
|
655
695
|
checkTypes: boolean;
|
|
656
696
|
};
|
|
657
697
|
type CompilerConfig = {
|
|
658
698
|
/**
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
699
|
+
* Indicates if the compiler should be enabled.
|
|
700
|
+
* If 'build-only', the compiler will be skipped during development mode to speed up start times.
|
|
701
|
+
*/
|
|
662
702
|
enabled: boolean | "build-only";
|
|
663
703
|
/**
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
704
|
+
* Prefix for the extracted dictionary keys.
|
|
705
|
+
* Default: ''
|
|
706
|
+
*/
|
|
667
707
|
dictionaryKeyPrefix?: string;
|
|
668
708
|
/**
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
709
|
+
* Pattern to traverse the code to optimize.
|
|
710
|
+
*
|
|
711
|
+
* Allows to avoid to traverse the code that is not relevant to the optimization.
|
|
712
|
+
* Improve build performance.
|
|
713
|
+
*
|
|
714
|
+
* Default: ['**\/*.{ts,tsx,jsx,js,cjs,mjs,svelte,vue}', '!**\/node_modules/**']
|
|
715
|
+
*
|
|
716
|
+
* Example: `['src/**\/*.{ts,tsx}', '../ui-library/**\/*.{ts,tsx}', '!**\/node_modules/**']`
|
|
717
|
+
*
|
|
718
|
+
* Note:
|
|
719
|
+
* - This option will be ignored if `optimize` is disabled.
|
|
720
|
+
* - Use glob pattern.
|
|
721
|
+
*
|
|
722
|
+
* @deprecated use build.traversePattern instead
|
|
723
|
+
*/
|
|
684
724
|
transformPattern?: string | string[];
|
|
685
725
|
/**
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
726
|
+
* Pattern to exclude from the optimization.
|
|
727
|
+
*
|
|
728
|
+
* Allows to exclude files from the optimization.
|
|
729
|
+
*
|
|
730
|
+
* Default: ['**\/node_modules/**']
|
|
731
|
+
*
|
|
732
|
+
* Example: `['**\/node_modules/**', '!**\/node_modules/react/**']`
|
|
733
|
+
*
|
|
734
|
+
* @deprecated use build.traversePattern instead
|
|
735
|
+
*/
|
|
696
736
|
excludePattern?: string | string[];
|
|
697
737
|
/**
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
738
|
+
* Defines the output files path. Replaces `outputDir`.
|
|
739
|
+
*
|
|
740
|
+
* - `./` paths are resolved relative to the component directory.
|
|
741
|
+
* - `/` paths are resolved relative to the project root (`baseDir`).
|
|
742
|
+
*
|
|
743
|
+
* - Including the `{{locale}}` variable in the path will trigger the generation of separate dictionaries per locale.
|
|
744
|
+
*
|
|
745
|
+
* Example:
|
|
746
|
+
* ```ts
|
|
747
|
+
* {
|
|
748
|
+
* // Create Multilingual .content.ts files close to the component
|
|
749
|
+
* output: ({ fileName, extension }) => `./${fileName}${extension}`,
|
|
750
|
+
*
|
|
751
|
+
* // output: './{{fileName}}{{extension}}', // Equivalent using template string
|
|
752
|
+
* }
|
|
753
|
+
* ```
|
|
754
|
+
*
|
|
755
|
+
* ```ts
|
|
756
|
+
* {
|
|
757
|
+
* // Create centralize per-locale JSON at the root of the project
|
|
758
|
+
* output: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,
|
|
759
|
+
*
|
|
760
|
+
* // output: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using template string
|
|
761
|
+
* }
|
|
762
|
+
* ```
|
|
763
|
+
*
|
|
764
|
+
* ```ts
|
|
765
|
+
* {
|
|
766
|
+
* // Create per-locale JSON files with locale-specific output paths
|
|
767
|
+
* output: {
|
|
768
|
+
* en: ({ fileName, locale }) => `${fileName}.${locale}.content.json`,
|
|
769
|
+
* fr: '{{fileName}}.{{locale}}.content.json',
|
|
770
|
+
* es: false, // skip this locale
|
|
771
|
+
* },
|
|
772
|
+
* }
|
|
773
|
+
* ```
|
|
774
|
+
*
|
|
775
|
+
* Variable list:
|
|
776
|
+
* - `fileName`: The name of the file.
|
|
777
|
+
* - `key`: The key of the content.
|
|
778
|
+
* - `locale`: The locale of the content.
|
|
779
|
+
* - `extension`: The extension of the file.
|
|
780
|
+
* - `componentFileName`: The name of the component file.
|
|
781
|
+
* - `componentExtension`: The extension of the component file.
|
|
782
|
+
* - `format`: The format of the dictionary.
|
|
783
|
+
* - `componentFormat`: The format of the component dictionary.
|
|
784
|
+
* - `componentDirPath`: The directory path of the component.
|
|
785
|
+
*/
|
|
746
786
|
output?: Fill;
|
|
747
787
|
/**
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
788
|
+
* Indicates if the metadata should be saved in the file.
|
|
789
|
+
*
|
|
790
|
+
* If true, the compiler will not save the metadata of the dictionaries.
|
|
791
|
+
*
|
|
792
|
+
* If true:
|
|
793
|
+
*
|
|
794
|
+
* ```json
|
|
795
|
+
* {
|
|
796
|
+
* "key": "value"
|
|
797
|
+
* }
|
|
798
|
+
* ```
|
|
799
|
+
*
|
|
800
|
+
* If false:
|
|
801
|
+
*
|
|
802
|
+
* ```json
|
|
803
|
+
* {
|
|
804
|
+
* "key": "value",
|
|
805
|
+
* "content": {
|
|
806
|
+
* "key": "value"
|
|
807
|
+
* }
|
|
808
|
+
* }
|
|
809
|
+
* ```
|
|
810
|
+
*
|
|
811
|
+
* Default: false
|
|
812
|
+
*
|
|
813
|
+
* Note: Useful if used with loadJSON plugin
|
|
814
|
+
*
|
|
815
|
+
*/
|
|
776
816
|
noMetadata?: boolean;
|
|
777
817
|
/**
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
818
|
+
* Indicates if the components should be saved after being transformed.
|
|
819
|
+
*
|
|
820
|
+
* If true, the compiler will replace the original files with the transformed files.
|
|
821
|
+
* That way, the compiler can be run only once to transform the app, and then it can be removed.
|
|
822
|
+
*
|
|
823
|
+
* Default: false
|
|
824
|
+
*/
|
|
785
825
|
saveComponents: boolean;
|
|
786
826
|
};
|
|
787
827
|
/**
|
|
788
|
-
* Custom configuration that can be provided to override default settings
|
|
789
|
-
*/
|
|
828
|
+
* Custom configuration that can be provided to override default settings
|
|
829
|
+
*/
|
|
790
830
|
type CustomIntlayerConfig = {
|
|
791
831
|
/**
|
|
792
|
-
|
|
793
|
-
|
|
832
|
+
* Custom internationalization configuration
|
|
833
|
+
*/
|
|
794
834
|
internationalization?: Partial<InternationalizationConfig>;
|
|
795
835
|
/**
|
|
796
|
-
|
|
797
|
-
|
|
836
|
+
* Custom dictionary configuration
|
|
837
|
+
*/
|
|
798
838
|
dictionary?: Partial<DictionaryConfig>;
|
|
799
839
|
/**
|
|
800
|
-
|
|
801
|
-
|
|
840
|
+
* Custom routing configuration
|
|
841
|
+
*/
|
|
802
842
|
routing?: Partial<CustomRoutingConfig>;
|
|
803
843
|
/**
|
|
804
|
-
|
|
805
|
-
|
|
844
|
+
* Custom content configuration
|
|
845
|
+
*/
|
|
806
846
|
content?: Partial<ContentConfig>;
|
|
807
847
|
/**
|
|
808
|
-
|
|
809
|
-
|
|
848
|
+
* Custom editor configuration
|
|
849
|
+
*/
|
|
810
850
|
editor?: Partial<EditorConfig>;
|
|
811
851
|
/**
|
|
812
|
-
|
|
813
|
-
|
|
852
|
+
* Custom analytics configuration
|
|
853
|
+
*/
|
|
854
|
+
analytics?: Partial<AnalyticsConfig>;
|
|
855
|
+
/**
|
|
856
|
+
* Custom log configuration
|
|
857
|
+
*/
|
|
814
858
|
log?: Partial<LogConfig>;
|
|
815
859
|
/**
|
|
816
|
-
|
|
817
|
-
|
|
860
|
+
* Custom AI configuration
|
|
861
|
+
*/
|
|
818
862
|
ai?: Partial<AiConfig>;
|
|
819
863
|
/**
|
|
820
|
-
|
|
821
|
-
|
|
864
|
+
* Custom build configuration
|
|
865
|
+
*/
|
|
822
866
|
build?: Partial<BuildConfig>;
|
|
823
867
|
/**
|
|
824
|
-
|
|
825
|
-
|
|
868
|
+
* Custom compiler configuration
|
|
869
|
+
*/
|
|
826
870
|
compiler?: Partial<CompilerConfig>;
|
|
827
871
|
/**
|
|
828
|
-
|
|
829
|
-
|
|
872
|
+
* Custom system configuration
|
|
873
|
+
*/
|
|
830
874
|
system?: Partial<SystemConfig>;
|
|
831
875
|
/**
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
876
|
+
* Custom schemas to validate the dictionaries content.
|
|
877
|
+
*
|
|
878
|
+
* Example:
|
|
879
|
+
* ```ts
|
|
880
|
+
* {
|
|
881
|
+
* schemas: {
|
|
882
|
+
* 'my-schema': z.object({
|
|
883
|
+
* title: z.string(),
|
|
884
|
+
* description: z.string(),
|
|
885
|
+
* }),
|
|
886
|
+
* }
|
|
887
|
+
* }
|
|
888
|
+
* ```
|
|
889
|
+
*/
|
|
846
890
|
schemas?: Record<string, ConfigSchema>;
|
|
847
891
|
/**
|
|
848
|
-
|
|
849
|
-
|
|
892
|
+
* Custom plugins configuration
|
|
893
|
+
*/
|
|
850
894
|
plugins?: (Plugin | Promise<Plugin>)[];
|
|
851
895
|
};
|
|
852
896
|
type DictionaryConfig = {
|
|
853
897
|
/**
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
898
|
+
* Indicate how the dictionary should be filled using AI.
|
|
899
|
+
*
|
|
900
|
+
* Default: `true`
|
|
901
|
+
*
|
|
902
|
+
* - If `true`, will consider the `compiler.output` field.
|
|
903
|
+
* - If `false`, will skip the fill process.
|
|
904
|
+
*
|
|
905
|
+
* - `./` paths are resolved relative to the component directory.
|
|
906
|
+
* - `/` paths are resolved relative to the project root (`baseDir`).
|
|
907
|
+
*
|
|
908
|
+
* - If includes `{{locale}}` variable in the path, will trigger the generation of separate dictionaries per locale.
|
|
909
|
+
*
|
|
910
|
+
* Example:
|
|
911
|
+
* ```ts
|
|
912
|
+
* {
|
|
913
|
+
* // Create Multilingual .content.ts files close to the component
|
|
914
|
+
* fill: ({ fileName, extension }) => `./${fileName}${extension}`,
|
|
915
|
+
*
|
|
916
|
+
* // fill: './{{fileName}}{{extension}}', // Equivalent using template string
|
|
917
|
+
* }
|
|
918
|
+
* ```
|
|
919
|
+
*
|
|
920
|
+
* ```ts
|
|
921
|
+
* {
|
|
922
|
+
* // Create centralize per-locale JSON at the root of the project
|
|
923
|
+
* fill: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,
|
|
924
|
+
*
|
|
925
|
+
* // fill: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using template string
|
|
926
|
+
* }
|
|
927
|
+
* ```
|
|
928
|
+
*
|
|
929
|
+
* ```ts
|
|
930
|
+
* {
|
|
931
|
+
* // Create custom output based on the locale
|
|
932
|
+
* fill: {
|
|
933
|
+
* en: ({ key }) => `/locales/en/${key}.content.json`,
|
|
934
|
+
* fr: '/locales/fr/{{key}}.content.json',
|
|
935
|
+
* es: false,
|
|
936
|
+
* de: true,
|
|
937
|
+
* },
|
|
938
|
+
* }
|
|
939
|
+
* ```
|
|
940
|
+
*
|
|
941
|
+
*
|
|
942
|
+
* Variable list:
|
|
943
|
+
* - `fileName`: The name of the file.
|
|
944
|
+
* - `key`: The key of the content.
|
|
945
|
+
* - `locale`: The locale of the content.
|
|
946
|
+
* - `extension`: The extension of the file.
|
|
947
|
+
* - `componentFileName`: The name of the component file.
|
|
948
|
+
* - `componentExtension`: The extension of the component file.
|
|
949
|
+
* - `format`: The format of the dictionary.
|
|
950
|
+
* - `componentFormat`: The format of the component dictionary.
|
|
951
|
+
* - `componentDirPath`: The directory path of the component.
|
|
952
|
+
*/
|
|
909
953
|
fill?: Fill;
|
|
910
954
|
/**
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
955
|
+
* The description of the dictionary. Helps to understand the purpose of the dictionary in the editor, and the CMS.
|
|
956
|
+
* The description is also used as context for translations generation.
|
|
957
|
+
*
|
|
958
|
+
* Example:
|
|
959
|
+
* ```ts
|
|
960
|
+
* {
|
|
961
|
+
* "key": "about-page-meta",
|
|
962
|
+
* "description":[
|
|
963
|
+
* "This dictionary is manage the metadata of the About Page",
|
|
964
|
+
* "Consider good practices for SEO:",
|
|
965
|
+
* "- The title should be between 50 and 60 characters",
|
|
966
|
+
* "- The description should be between 150 and 160 characters",
|
|
967
|
+
* ].join('\n'),
|
|
968
|
+
* "content": { ... }
|
|
969
|
+
* }
|
|
970
|
+
* ```
|
|
971
|
+
*/
|
|
928
972
|
description?: string;
|
|
929
973
|
/**
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
974
|
+
* Transform the dictionary in a per-locale dictionary.
|
|
975
|
+
* Each field declared in a per-locale dictionary will be transformed in a translation node.
|
|
976
|
+
* If missing, the dictionary will be treated as a multilingual dictionary.
|
|
977
|
+
* If declared, do not use translation nodes in the content.
|
|
978
|
+
*
|
|
979
|
+
* Example:
|
|
980
|
+
* ```json
|
|
981
|
+
* {
|
|
982
|
+
* "key": "about-page",
|
|
983
|
+
* "locale": "en",
|
|
984
|
+
* "content": {
|
|
985
|
+
* "multilingualContent": "English content"
|
|
986
|
+
* }
|
|
987
|
+
* }
|
|
988
|
+
* ```
|
|
989
|
+
*/
|
|
946
990
|
locale?: LocalesValues;
|
|
947
991
|
/**
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
992
|
+
* Indicators if the content of the dictionary should be automatically transformed.
|
|
993
|
+
* If true, the content will be transformed to the corresponding node type.
|
|
994
|
+
* - Markdown: `### Title` -> `md('### Title')`
|
|
995
|
+
* - HTML: `<div>Title</div>` -> `html('<div>Title</div>')`
|
|
996
|
+
* - Insertion: `Hello {{name}}` -> `insert('Hello {{name}}')`
|
|
997
|
+
*
|
|
998
|
+
* If an object is provided, you can specify which transformations should be enabled.
|
|
999
|
+
*
|
|
1000
|
+
* Default: false
|
|
1001
|
+
*/
|
|
958
1002
|
contentAutoTransformation?: ContentAutoTransformation;
|
|
959
1003
|
/**
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
1004
|
+
* Indicates the priority of the dictionary.
|
|
1005
|
+
* In the case of conflicts, the dictionary with the highest priority will override the other dictionaries.
|
|
1006
|
+
*/
|
|
963
1007
|
priority?: number;
|
|
964
1008
|
/**
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
1009
|
+
* Indicates the mode of import to use for the dictionaries.
|
|
1010
|
+
*
|
|
1011
|
+
* Available modes:
|
|
1012
|
+
* - "static": The dictionaries are imported statically.
|
|
1013
|
+
* In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionary`.
|
|
1014
|
+
* - "dynamic": The dictionaries are imported dynamically in a synchronous component using the suspense API.
|
|
1015
|
+
* In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.
|
|
1016
|
+
* - "fetch": The dictionaries are imported dynamically using the live sync API.
|
|
1017
|
+
* In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.
|
|
1018
|
+
* Fetch 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.
|
|
1019
|
+
*
|
|
1020
|
+
* Default: "static"
|
|
1021
|
+
*
|
|
1022
|
+
* By default, when a dictionary is loaded, it imports content for all locales as it's imported statically.
|
|
1023
|
+
*
|
|
1024
|
+
* Note:
|
|
1025
|
+
* - Dynamic imports rely on Suspense and may slightly impact rendering performance.
|
|
1026
|
+
* - If disabled all locales will be loaded at once, even if they are not used.
|
|
1027
|
+
* - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.
|
|
1028
|
+
* - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.
|
|
1029
|
+
* - This option will be ignored if `optimize` is disabled.
|
|
1030
|
+
* - 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.
|
|
1031
|
+
* - The "fetch" allows to sync the dictionaries to the live sync server.
|
|
1032
|
+
* - Require static key to work. Example of invalid code: `const navbarKey = "my-key"; useIntlayer(navbarKey)`.
|
|
1033
|
+
*/
|
|
990
1034
|
importMode?: "static" | "dynamic" | "fetch";
|
|
991
1035
|
/**
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1036
|
+
* The title of the dictionary. Helps to identify the dictionary in the editor, and the CMS.
|
|
1037
|
+
*
|
|
1038
|
+
* Example:
|
|
1039
|
+
* ```json
|
|
1040
|
+
* {
|
|
1041
|
+
* "key": "about-page-meta",
|
|
1042
|
+
* "title": "About Page",
|
|
1043
|
+
* "content": { ... }
|
|
1044
|
+
* }
|
|
1045
|
+
* ```
|
|
1046
|
+
*/
|
|
1003
1047
|
title?: string;
|
|
1004
1048
|
/**
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1049
|
+
* Helps to categorize the dictionaries. The tags can provide more context and instructions for the dictionary.
|
|
1050
|
+
*
|
|
1051
|
+
* Example:
|
|
1052
|
+
* ```json
|
|
1053
|
+
* {
|
|
1054
|
+
* "key": "about-page-meta",
|
|
1055
|
+
* "tags": ["metadata","about-page"]
|
|
1056
|
+
* }
|
|
1057
|
+
* ```
|
|
1058
|
+
*/
|
|
1015
1059
|
tags?: string[];
|
|
1016
1060
|
/**
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1061
|
+
* Indicates the location of the dictionary and controls how it synchronizes with the CMS.
|
|
1062
|
+
*
|
|
1063
|
+
* - 'hybrid': The dictionary is managed locally and remotely. Once pushed on the CMS, it will be synchronized from the local one. The local dictionary will be pulled from the CMS.
|
|
1064
|
+
* - 'remote': The dictionary is managed remotely only. Once pushed on the CMS, it will be detached from the local one. At content load time, the remote dictionary will be pulled from the CMS. A '.content' file with remote location will be ignored.
|
|
1065
|
+
* - 'local': The dictionary is managed locally. It will not be pushed to the remote CMS.
|
|
1066
|
+
* - 'plugin' (or any custom string): The dictionary is managed by a plugin, or a custom source. When you will try to push it, the system will ask an action to the user.
|
|
1067
|
+
*/
|
|
1024
1068
|
location?: DictionaryLocation;
|
|
1025
1069
|
/**
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1070
|
+
* The default message format for all dictionaries in the project.
|
|
1071
|
+
*
|
|
1072
|
+
* Controls how dictionary content strings are interpreted at runtime.
|
|
1073
|
+
*
|
|
1074
|
+
* - 'intlayer': Native intlayer format (default).
|
|
1075
|
+
* - 'icu': ICU message format (used by next-intl, react-intl, etc.).
|
|
1076
|
+
* - 'i18next': i18next interpolation format (used by i18next, react-i18next, next-i18next).
|
|
1077
|
+
* - 'vue-i18n': Vue I18n format (used by vue-i18n).
|
|
1078
|
+
* - 'po': GNU Gettext PO format.
|
|
1079
|
+
*
|
|
1080
|
+
* Default: 'intlayer'
|
|
1081
|
+
*/
|
|
1038
1082
|
format?: DictionaryFormat;
|
|
1039
1083
|
};
|
|
1040
1084
|
/**
|
|
1041
|
-
* Combined configuration for internationalization, middleware, and content
|
|
1042
|
-
*/
|
|
1085
|
+
* Combined configuration for internationalization, middleware, and content
|
|
1086
|
+
*/
|
|
1043
1087
|
type IntlayerConfig = {
|
|
1044
1088
|
/**
|
|
1045
|
-
|
|
1046
|
-
|
|
1089
|
+
* Internationalization configuration
|
|
1090
|
+
*/
|
|
1047
1091
|
internationalization: InternationalizationConfig;
|
|
1048
1092
|
/**
|
|
1049
|
-
|
|
1050
|
-
|
|
1093
|
+
* Default dictionary configuration
|
|
1094
|
+
*/
|
|
1051
1095
|
dictionary?: Partial<DictionaryConfig>;
|
|
1052
1096
|
/**
|
|
1053
|
-
|
|
1054
|
-
|
|
1097
|
+
* Routing configuration
|
|
1098
|
+
*/
|
|
1055
1099
|
routing: RoutingConfig;
|
|
1056
1100
|
/**
|
|
1057
|
-
|
|
1058
|
-
|
|
1101
|
+
* Content configuration
|
|
1102
|
+
*/
|
|
1059
1103
|
content: ContentConfig;
|
|
1060
1104
|
/**
|
|
1061
|
-
|
|
1062
|
-
|
|
1105
|
+
* System configuration
|
|
1106
|
+
*/
|
|
1063
1107
|
system: SystemConfig;
|
|
1064
1108
|
/**
|
|
1065
|
-
|
|
1066
|
-
|
|
1109
|
+
* Intlayer editor configuration
|
|
1110
|
+
*/
|
|
1067
1111
|
editor: EditorConfig;
|
|
1068
1112
|
/**
|
|
1069
|
-
|
|
1070
|
-
|
|
1113
|
+
* Intlayer analytics configuration
|
|
1114
|
+
*/
|
|
1115
|
+
analytics?: AnalyticsConfig;
|
|
1116
|
+
/**
|
|
1117
|
+
* Logger configuration
|
|
1118
|
+
*/
|
|
1071
1119
|
log: LogConfig;
|
|
1072
1120
|
/**
|
|
1073
|
-
|
|
1074
|
-
|
|
1121
|
+
* AI configuration
|
|
1122
|
+
*/
|
|
1075
1123
|
ai?: Partial<AiConfig>;
|
|
1076
1124
|
/**
|
|
1077
|
-
|
|
1078
|
-
|
|
1125
|
+
* Build configuration
|
|
1126
|
+
*/
|
|
1079
1127
|
build: BuildConfig;
|
|
1080
1128
|
/**
|
|
1081
|
-
|
|
1082
|
-
|
|
1129
|
+
* Compiler configuration
|
|
1130
|
+
*/
|
|
1083
1131
|
compiler: CompilerConfig;
|
|
1084
1132
|
/**
|
|
1085
|
-
|
|
1086
|
-
|
|
1133
|
+
* Custom schemas to validate the dictionaries content.
|
|
1134
|
+
*/
|
|
1087
1135
|
schemas?: Record<string, ConfigSchema>;
|
|
1088
1136
|
/**
|
|
1089
|
-
|
|
1090
|
-
|
|
1137
|
+
* Plugins configuration
|
|
1138
|
+
*/
|
|
1091
1139
|
plugins?: Plugin[];
|
|
1092
1140
|
};
|
|
1093
1141
|
/**
|
|
1094
|
-
* Configuration for content handling
|
|
1095
|
-
*/
|
|
1142
|
+
* Configuration for content handling
|
|
1143
|
+
*/
|
|
1096
1144
|
type ContentConfig = {
|
|
1097
1145
|
/**
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1146
|
+
* File extensions of content to look for
|
|
1147
|
+
*
|
|
1148
|
+
* Default: ['.content.ts', '.content.js', '.content.cjs', '.content.mjs', '.content.json', '.content.tsx', '.content.jsx']
|
|
1149
|
+
*
|
|
1150
|
+
* List of file extensions to scan for content.
|
|
1151
|
+
*/
|
|
1104
1152
|
fileExtensions: string[];
|
|
1105
1153
|
/**
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1154
|
+
* Directory where the content is stored, relative to the base directory
|
|
1155
|
+
*
|
|
1156
|
+
* Default: ['.']
|
|
1157
|
+
*
|
|
1158
|
+
* Derived content directory based on the base configuration.
|
|
1159
|
+
*
|
|
1160
|
+
* Note: This is used to watch for content files.
|
|
1161
|
+
*/
|
|
1114
1162
|
contentDir: string[];
|
|
1115
1163
|
/**
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1164
|
+
* Directory where the code is stored, relative to the base directory
|
|
1165
|
+
*
|
|
1166
|
+
* Default: ['.']
|
|
1167
|
+
*
|
|
1168
|
+
* Derived code directory based on the base configuration.
|
|
1169
|
+
*
|
|
1170
|
+
* Note: This is used to watch for code files to transform.
|
|
1171
|
+
*/
|
|
1124
1172
|
codeDir: string[];
|
|
1125
1173
|
/**
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1174
|
+
* Directories to be excluded from content processing
|
|
1175
|
+
*
|
|
1176
|
+
* Default: ['node_modules', '.intlayer']
|
|
1177
|
+
*
|
|
1178
|
+
* A list of directories to exclude from content processing.
|
|
1179
|
+
*/
|
|
1132
1180
|
excludedPath: string[];
|
|
1133
1181
|
/**
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1182
|
+
* Indicates if Intlayer should watch for changes in the content declaration files in the app to rebuild the related dictionaries.
|
|
1183
|
+
*
|
|
1184
|
+
* Default: process.env.NODE_ENV === 'development'
|
|
1185
|
+
*/
|
|
1138
1186
|
watch: boolean;
|
|
1139
1187
|
/**
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1188
|
+
* Command to format the content. When intlayer write your .content files locally, this command will be used to format the content.
|
|
1189
|
+
*
|
|
1190
|
+
* Example:
|
|
1191
|
+
*
|
|
1192
|
+
* ```bash
|
|
1193
|
+
* npx prettier --write {{file}}
|
|
1194
|
+
* ```
|
|
1195
|
+
*
|
|
1196
|
+
* ```bash
|
|
1197
|
+
* bunx biome format {{file}}
|
|
1198
|
+
* ```
|
|
1199
|
+
*
|
|
1200
|
+
* ```bash
|
|
1201
|
+
* bun format {{file}}
|
|
1202
|
+
* ```
|
|
1203
|
+
*
|
|
1204
|
+
* ```bash
|
|
1205
|
+
* npx eslint --fix {{file}}
|
|
1206
|
+
* ```
|
|
1207
|
+
*
|
|
1208
|
+
* Intlayer will replace the {{file}} with the path of the file to format.
|
|
1209
|
+
*
|
|
1210
|
+
* Default: undefined
|
|
1211
|
+
*/
|
|
1164
1212
|
formatCommand: string | undefined;
|
|
1165
1213
|
};
|
|
1166
1214
|
type SystemConfig = {
|
|
1167
1215
|
/**
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1216
|
+
* Absolute path of the project's base directory
|
|
1217
|
+
*
|
|
1218
|
+
* Default: process.cwd()
|
|
1219
|
+
*
|
|
1220
|
+
* The root directory of the project, typically used for resolving other paths.
|
|
1221
|
+
*/
|
|
1174
1222
|
baseDir: string;
|
|
1175
1223
|
/**
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1224
|
+
* Directory for module augmentation, relative to the base directory
|
|
1225
|
+
*
|
|
1226
|
+
* Default: .intlayer/types
|
|
1227
|
+
*
|
|
1228
|
+
* Defines the derived path for module augmentation.
|
|
1229
|
+
*/
|
|
1182
1230
|
moduleAugmentationDir: string;
|
|
1183
1231
|
/**
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1232
|
+
* Directory where unmerged dictionaries are stored, relative to the result directory
|
|
1233
|
+
*
|
|
1234
|
+
* Default: .intlayer/unmerged_dictionary
|
|
1235
|
+
*
|
|
1236
|
+
* Specifies the derived path for unmerged dictionaries relative to the result directory.
|
|
1237
|
+
*/
|
|
1190
1238
|
unmergedDictionariesDir: string;
|
|
1191
1239
|
/**
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1240
|
+
* Directory where remote dictionaries are stored, relative to the result directory
|
|
1241
|
+
*
|
|
1242
|
+
* Default: .intlayer/remote_dictionary
|
|
1243
|
+
*
|
|
1244
|
+
* Specifies the derived path for remote dictionaries relative to the result directory.
|
|
1245
|
+
*/
|
|
1198
1246
|
remoteDictionariesDir: string;
|
|
1199
1247
|
/**
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1248
|
+
* Directory where final dictionaries are stored, relative to the result directory
|
|
1249
|
+
*
|
|
1250
|
+
* Default: .intlayer/dictionary
|
|
1251
|
+
*
|
|
1252
|
+
* Specifies the derived path for dictionaries relative to the result directory.
|
|
1253
|
+
*/
|
|
1206
1254
|
dictionariesDir: string;
|
|
1207
1255
|
/**
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1256
|
+
* Directory where dynamic dictionaries are stored, relative to the result directory
|
|
1257
|
+
*
|
|
1258
|
+
* Default: .intlayer/dynamic_dictionary
|
|
1259
|
+
*
|
|
1260
|
+
* Specifies the derived path for dynamic dictionaries relative to the result directory.
|
|
1261
|
+
*/
|
|
1214
1262
|
dynamicDictionariesDir: string;
|
|
1215
1263
|
/**
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1264
|
+
* Directory where fetch dictionaries are stored, relative to the result directory
|
|
1265
|
+
*
|
|
1266
|
+
* Default: .intlayer/fetch_dictionary
|
|
1267
|
+
*
|
|
1268
|
+
* Specifies the derived path for fetch dictionaries relative to the result directory.
|
|
1269
|
+
*/
|
|
1222
1270
|
fetchDictionariesDir: string;
|
|
1223
1271
|
/**
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1272
|
+
* Directory where dictionary types are stored, relative to the result directory
|
|
1273
|
+
*
|
|
1274
|
+
* Default: .intlayer/types
|
|
1275
|
+
*
|
|
1276
|
+
* Specifies the derived path for dictionary types relative to the result directory.
|
|
1277
|
+
*/
|
|
1230
1278
|
typesDir: string;
|
|
1231
1279
|
/**
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1280
|
+
* Directory where the main files are stored, relative to the result directory
|
|
1281
|
+
*
|
|
1282
|
+
* Default: .intlayer/main
|
|
1283
|
+
*
|
|
1284
|
+
* Specifies the derived path for the main files relative to the result directory.
|
|
1285
|
+
*/
|
|
1238
1286
|
mainDir: string;
|
|
1239
1287
|
/**
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1288
|
+
* Directory where the configuration files are stored, relative to the result directory
|
|
1289
|
+
*
|
|
1290
|
+
* Default: .intlayer/config
|
|
1291
|
+
*
|
|
1292
|
+
* Specifies the derived path for the configuration files relative to the result directory.
|
|
1293
|
+
*/
|
|
1246
1294
|
configDir: string;
|
|
1247
1295
|
/**
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1296
|
+
* Directory where the cache files are stored, relative to the result directory
|
|
1297
|
+
*
|
|
1298
|
+
* Default: .intlayer/cache
|
|
1299
|
+
*
|
|
1300
|
+
* Specifies the derived path for the cache files relative to the result directory.
|
|
1301
|
+
*/
|
|
1254
1302
|
cacheDir: string;
|
|
1255
1303
|
/**
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1304
|
+
* Directory where the temp files are stored, relative to the result directory
|
|
1305
|
+
*
|
|
1306
|
+
* Default: .intlayer/tmp
|
|
1307
|
+
*
|
|
1308
|
+
* Specifies the derived path for the tmp files relative to the result directory.
|
|
1309
|
+
*/
|
|
1262
1310
|
tempDir: string;
|
|
1263
1311
|
};
|
|
1264
1312
|
type LogFunctions = {
|
|
@@ -1269,26 +1317,26 @@ type LogFunctions = {
|
|
|
1269
1317
|
};
|
|
1270
1318
|
type LogConfig = {
|
|
1271
1319
|
/**
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1320
|
+
* Indicates if the logger is enabled
|
|
1321
|
+
*
|
|
1322
|
+
* Default: true
|
|
1323
|
+
*
|
|
1324
|
+
* If 'default', the logger is enabled and can be used.
|
|
1325
|
+
* If 'verbose', the logger will be enabled and can be used, but will log more information.
|
|
1326
|
+
* If 'disabled', the logger is disabled and cannot be used.
|
|
1327
|
+
*/
|
|
1280
1328
|
mode: "default" | "verbose" | "disabled";
|
|
1281
1329
|
/**
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1330
|
+
* Prefix of the logger
|
|
1331
|
+
*
|
|
1332
|
+
* Default: '[intlayer]'
|
|
1333
|
+
*
|
|
1334
|
+
* The prefix of the logger.
|
|
1335
|
+
*/
|
|
1288
1336
|
prefix: string;
|
|
1289
1337
|
/**
|
|
1290
|
-
|
|
1291
|
-
|
|
1338
|
+
* Functions to log
|
|
1339
|
+
*/
|
|
1292
1340
|
error?: typeof console.error;
|
|
1293
1341
|
log?: typeof console.log;
|
|
1294
1342
|
info?: typeof console.info;
|
|
@@ -1296,5 +1344,5 @@ type LogConfig = {
|
|
|
1296
1344
|
debug?: typeof console.debug;
|
|
1297
1345
|
};
|
|
1298
1346
|
//#endregion
|
|
1299
|
-
export { AiConfig, AiProviderConfigMap, AiProviders, BuildConfig, CommonAiConfig, CompilerConfig, ConfigSchema, ContentConfig, CookiesAttributes, CustomIntlayerConfig, CustomRoutingConfig, DictionaryConfig, EditorConfig, InternationalizationConfig, IntlayerConfig, LogConfig, LogFunctions, ProcessedCookieAttributes, ProcessedStorageAttributes, RewriteObject, RewriteRule, RewriteRules, RoutingConfig, RoutingStorageInput, StorageAttributes, StrictMode, SystemConfig, URLType };
|
|
1347
|
+
export { AiConfig, AiProviderConfigMap, AiProviders, AnalyticsConfig, BuildConfig, CommonAiConfig, CompilerConfig, ConfigSchema, ContentConfig, CookiesAttributes, CustomIntlayerConfig, CustomRoutingConfig, DictionaryConfig, EditorConfig, InternationalizationConfig, IntlayerConfig, LogConfig, LogFunctions, ProcessedCookieAttributes, ProcessedStorageAttributes, RewriteObject, RewriteRule, RewriteRules, RoutingConfig, RoutingStorageInput, StorageAttributes, StrictMode, SystemConfig, URLType };
|
|
1300
1348
|
//# sourceMappingURL=config.d.ts.map
|