@intlayer/types 8.4.4 → 8.4.6

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