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