@intlayer/types 8.4.3 → 8.4.5

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