@intlayer/core 7.0.0-canary.3 → 7.0.1

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 (62) hide show
  1. package/dist/cjs/getStorageAttributes.cjs +24 -5
  2. package/dist/cjs/getStorageAttributes.cjs.map +1 -1
  3. package/dist/cjs/localization/getMultilingualUrls.cjs +3 -1
  4. package/dist/cjs/localization/getMultilingualUrls.cjs.map +1 -1
  5. package/dist/cjs/transpiler/file/file.cjs +2 -2
  6. package/dist/cjs/utils/localeStorage.cjs +18 -5
  7. package/dist/cjs/utils/localeStorage.cjs.map +1 -1
  8. package/dist/esm/getStorageAttributes.mjs +24 -5
  9. package/dist/esm/getStorageAttributes.mjs.map +1 -1
  10. package/dist/esm/localization/getMultilingualUrls.mjs +2 -1
  11. package/dist/esm/localization/getMultilingualUrls.mjs.map +1 -1
  12. package/dist/esm/transpiler/file/file.mjs +1 -1
  13. package/dist/esm/utils/localeStorage.mjs +18 -5
  14. package/dist/esm/utils/localeStorage.mjs.map +1 -1
  15. package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts +4 -4
  16. package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts +4 -4
  17. package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts +4 -4
  18. package/dist/types/deepTransformPlugins/index.d.ts.map +1 -0
  19. package/dist/types/dictionaryManipulator/getUnmergedDictionaryByKeyPath.d.ts +2 -2
  20. package/dist/types/dictionaryManipulator/index.d.ts.map +1 -0
  21. package/dist/types/dictionaryManipulator/orderDictionaries.d.ts +2 -2
  22. package/dist/types/formatters/index.d.ts.map +1 -0
  23. package/dist/types/getStorageAttributes.d.ts +7 -3
  24. package/dist/types/getStorageAttributes.d.ts.map +1 -1
  25. package/dist/types/index.d.ts +2 -2
  26. package/dist/types/index.d.ts.map +1 -0
  27. package/dist/types/interpreter/getContent/index.d.ts.map +1 -0
  28. package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
  29. package/dist/types/interpreter/getIntlayerAsync.d.ts +13 -0
  30. package/dist/types/interpreter/getIntlayerAsync.d.ts.map +1 -0
  31. package/dist/types/interpreter/index.d.ts.map +1 -0
  32. package/dist/types/localization/getMultilingualUrls.d.ts.map +1 -1
  33. package/dist/types/localization/index.d.ts.map +1 -0
  34. package/dist/types/localization/localeList.d.ts +3 -0
  35. package/dist/types/localization/localeList.d.ts.map +1 -0
  36. package/dist/types/transpiler/condition/index.d.ts.map +1 -0
  37. package/dist/types/transpiler/enumeration/enumeration.d.ts.map +1 -1
  38. package/dist/types/transpiler/enumeration/index.d.ts.map +1 -0
  39. package/dist/types/transpiler/file/index.d.ts.map +1 -0
  40. package/dist/types/transpiler/gender/index.d.ts.map +1 -0
  41. package/dist/types/transpiler/index.d.ts.map +1 -0
  42. package/dist/types/transpiler/insertion/index.d.ts.map +1 -0
  43. package/dist/types/transpiler/markdown/index.d.ts.map +1 -0
  44. package/dist/types/transpiler/nesting/index.d.ts.map +1 -0
  45. package/dist/types/transpiler/translation/index.d.ts.map +1 -0
  46. package/dist/types/transpiler/translation/translation.d.ts +1 -1
  47. package/dist/types/transpiler/translation/translation.d.ts.map +1 -1
  48. package/dist/types/types/dictionary.d.ts +307 -0
  49. package/dist/types/types/dictionary.d.ts.map +1 -0
  50. package/dist/types/types/index.d.ts +5 -0
  51. package/dist/types/types/index.d.ts.map +1 -0
  52. package/dist/types/types/intlayer.d.ts +5 -0
  53. package/dist/types/types/intlayer.d.ts.map +1 -0
  54. package/dist/types/types/keyPath.d.ts +47 -0
  55. package/dist/types/types/keyPath.d.ts.map +1 -0
  56. package/dist/types/types/nodeType.d.ts +30 -0
  57. package/dist/types/types/nodeType.d.ts.map +1 -0
  58. package/dist/types/types/translation.d.ts +25 -0
  59. package/dist/types/types/translation.d.ts.map +1 -0
  60. package/dist/types/utils/localeStorage.d.ts +8 -6
  61. package/dist/types/utils/localeStorage.d.ts.map +1 -1
  62. package/package.json +14 -14
@@ -0,0 +1,307 @@
1
+ import type { ConditionContent } from '../transpiler/condition';
2
+ import type { EnumerationContent } from '../transpiler/enumeration';
3
+ import type { FileContent } from '../transpiler/file';
4
+ import type { GenderContent } from '../transpiler/gender';
5
+ import type { InsertionContent } from '../transpiler/insertion';
6
+ import type { MarkdownContent } from '../transpiler/markdown';
7
+ import type { NestedContent } from '../transpiler/nesting';
8
+ import type { TranslationContent } from '../transpiler/translation';
9
+ import type { IntlayerDictionaryTypesConnector, LanguageContent, LocalesValues } from './intlayer';
10
+ /**
11
+ * Provides a fallback to string type if the generic type T is undefined,
12
+ * otherwise returns T. This is useful for handling cases where no keys are found.
13
+ * Example: StringFallback<undefined> -> string; StringFallback<'key'> -> 'key'
14
+ */
15
+ export type StringFallback<T> = T extends undefined ? string : T;
16
+ /**
17
+ * Represents the keys of the IntlayerDictionaryTypesConnector,
18
+ * ensuring they are valid dictionary keys or fallback to string if none exist.
19
+ *
20
+ * Example:
21
+ * ```ts
22
+ * DictionaryKeys -> 'key1' | 'key2'
23
+ * // or if IntlayerDictionaryTypesConnector is not defined,
24
+ * DictionaryKeys -> string
25
+ * ```
26
+ */
27
+ export type DictionaryKeys = StringFallback<keyof IntlayerDictionaryTypesConnector>;
28
+ type BaseNode = number | string | boolean | null | undefined;
29
+ export type TypedNode<NodeType = undefined> = TranslationContent<NodeType> | EnumerationContent<NodeType> | ConditionContent<NodeType> | InsertionContent<NodeType> | MarkdownContent<NodeType> | NestedContent<DictionaryKeys> | GenderContent<NodeType> | FileContent;
30
+ type FetchableContentNode<NodeType> = (args?: any) => ContentNode<NodeType> | Promise<ContentNode<NodeType>>;
31
+ export type ContentNode<T = undefined, FetchableNode = false, NodeType = T extends undefined ? BaseNode : T> = NodeType | TypedNode<NodeType> | ((args?: any) => ContentNode<NodeType>) | (FetchableNode extends true ? FetchableContentNode<NodeType> : undefined);
32
+ type IsArray<T> = T extends any[] ? true : false;
33
+ type ReplaceContentValueArray<T, FetchableNode> = T extends (infer U)[] ? // Allow either a *single* typed node returning the entire array
34
+ ContentNode<T, FetchableNode> | ReplaceContentValue<U, FetchableNode>[] : never;
35
+ type ReplaceContentValueObject<T, FetchableNode> = {
36
+ [K in keyof T]: ReplaceContentValue<T[K], FetchableNode>;
37
+ };
38
+ type ReplaceContentValue<NodeType, FetchableNode = true> = NodeType extends object ? IsArray<NodeType> extends true ? ReplaceContentValueArray<NodeType, FetchableNode> : ContentNode<NodeType, FetchableNode> | ReplaceContentValueObject<NodeType, FetchableNode> : ContentNode<NodeType, FetchableNode>;
39
+ export type AutoFill = true | string | Partial<LanguageContent<string>>;
40
+ export type LocalDictionaryId = string;
41
+ export type Dictionary<ContentType = undefined, FetchableNode = false> = {
42
+ /**
43
+ * _Auto generated by the intlayer, do not modify it_
44
+ *
45
+ * The schema of the dictionary, used for JSON validation
46
+ */
47
+ $schema?: string;
48
+ /**
49
+ * _Auto generated by the intlayer, do not modify it_
50
+ *
51
+ * For remote dictionaries, the id is the id of the dictionary in the remote server
52
+ */
53
+ id?: string;
54
+ /**
55
+ * _Auto generated by the intlayer, do not modify it_
56
+ *
57
+ * Unique Identifier for the dictionaries. Auto generated by the intlayer, it helps to identify the dictionary and know if it is a local or remote dictionary, and his location.
58
+ */
59
+ localId?: LocalDictionaryId;
60
+ /**
61
+ * _Auto generated by the intlayer, do not modify it_
62
+ *
63
+ * For merged dictionaries, the localIds is the ids of the dictionaries that are merged
64
+ */
65
+ localIds?: LocalDictionaryId[];
66
+ /**
67
+ * The key of the dictionary. If multiple dictionaries have the same key, intlayer will merge them.
68
+ *
69
+ * As convention, use '-' to separate the words in the key.
70
+ *
71
+ * Example:
72
+ * ```json
73
+ * {
74
+ * "key": "about-page-meta",
75
+ * "content": { ... }
76
+ * }
77
+ * ```
78
+ */
79
+ key: string;
80
+ /**
81
+ * The title of the dictionary. Helps to identify the dictionary in the editor, and the CMS.
82
+ *
83
+ * Example:
84
+ * ```json
85
+ * {
86
+ * "key": "about-page-meta",
87
+ * "title": "About Page",
88
+ * "content": { ... }
89
+ * }
90
+ * ```
91
+ */
92
+ title?: string;
93
+ /**
94
+ * The description of the dictionary. Helps to understand the purpose of the dictionary in the editor, and the CMS.
95
+ * The descrtion is also used as context for translations generation.
96
+ *
97
+ * Example:
98
+ * ```ts
99
+ * {
100
+ * "key": "about-page-meta",
101
+ * "description":[
102
+ * "This dictionary is manage the metadata of the About Page",
103
+ * "Consider good practices for SEO:",
104
+ * "- The title should be between 50 and 60 characters",
105
+ * "- The description should be between 150 and 160 characters",
106
+ * ].join('\n'),
107
+ * "content": { ... }
108
+ * }
109
+ * ```
110
+ */
111
+ description?: string;
112
+ /**
113
+ * _Auto generated by the intlayer, do not modify it_
114
+ *
115
+ * The available versions of the remote dictionary. Helps to know the versions of the dictionary that are available.
116
+ */
117
+ versions?: string[];
118
+ /**
119
+ * _Managable on the CMS, do not modify it locally_
120
+ *
121
+ * The version of the remote dictionary. Helps to know the version of the dictionary that is currently used.
122
+ */
123
+ version?: string;
124
+ /**
125
+ * _Auto generated by the intlayer, do not modify it_
126
+ *
127
+ * The file path of the local dictionary. Helps to know from what .content file the dictionary has been generated.
128
+ */
129
+ filePath?: string;
130
+ /**
131
+ * Helps to categorize the dictionaries. The tags can provide more context and instructions for the dictionary.
132
+ *
133
+ * Example:
134
+ * ```json
135
+ * {
136
+ * "key": "about-page-meta",
137
+ * "tags": ["metadata","about-page"]
138
+ * }
139
+ * ```
140
+ */
141
+ tags?: string[];
142
+ /**
143
+ * Transform the dictionary in a per-locale dictionary.
144
+ * Each field declared in a per-locale dictionary will be transformed in a translation node.
145
+ * If missing, the dictionary will be treated as a multilingual dictionary.
146
+ * If declared, do not use translation nodes in the content.
147
+ *
148
+ * Example:
149
+ * ```json
150
+ * {
151
+ * "key": "about-page",
152
+ * "locale": "en",
153
+ * "content": {
154
+ * "multilingualContent": "English content"
155
+ * }
156
+ * }
157
+ * ```
158
+ */
159
+ locale?: LocalesValues;
160
+ /**
161
+ * Instruction to auto fill the dictionary.
162
+ * Can also be declared globally in the `intlayer.config.ts` file.
163
+ *
164
+ * Example:
165
+ * ```json
166
+ * {
167
+ * "key": "about-page",
168
+ * "autoFill": true
169
+ * }
170
+ * ```
171
+ * ```json
172
+ * {
173
+ * "key": "about-page",
174
+ * "autoFill": "./aboutPage.content.json"
175
+ * }
176
+ * ```
177
+ * ```json
178
+ * {
179
+ * "key": "about-page",
180
+ * "autoFill": "/messages/{{locale}}/{{key}}/{{fileName}}.content.json"
181
+ * }
182
+ * ```
183
+ * ```json
184
+ * {
185
+ * "key": "about-page",
186
+ * "autoFill": {
187
+ * "fr": "./aboutPage.fr.content.json",
188
+ * "es": "./aboutPage.es.content.json"
189
+ * }
190
+ * }
191
+ * ```
192
+ *
193
+ */
194
+ autoFill?: AutoFill;
195
+ /**
196
+ * _Auto generated by the intlayer, do not modify it_
197
+ *
198
+ * Indicates if the dictionary has been auto filled.
199
+ * In the case of conflicts, base dictionaryed will override auto filled dictionary.
200
+ */
201
+ autoFilled?: true;
202
+ /**
203
+ * Indicates the priority of the dictionary.
204
+ * In the case of conflicts, the dictionary with the highest priority will override the other dictionaries.
205
+ */
206
+ priority?: number;
207
+ /**
208
+ * _Managable on the CMS, do not modify it locally_
209
+ *
210
+ * For remote dictionaries, indicates if the dictionary is live.
211
+ *
212
+ * Will need the `importMode` to be "live" to be effective in the `intlayer.config.ts` file. Will also need the live server to be running.
213
+ *
214
+ * A live dictionary will be fetched at runtime using the live sync API.
215
+ *
216
+ * If live, the dictionary will by transformed to include fetch functions.
217
+ * If not live, the dictionary will be transformed at build time using "dynamic" mode to optimize the number of fetch queries, and load performance.
218
+ *
219
+ * If live but the fetch request fails, the dictionary will return the dynamic value of the dictionary as fallback.
220
+ *
221
+ */
222
+ live?: boolean;
223
+ /**
224
+ * _Auto generated by the intlayer, do not modify it_
225
+ *
226
+ * Indicates the location of the dictionary.
227
+ */
228
+ location?: 'distant' | 'locale' | 'plugin';
229
+ /**
230
+ * The content of the dictionary.
231
+ *
232
+ * Example:
233
+ * ```tsx
234
+ * import { t, enu, cond, nest, md, insert, file } from "intlayer";
235
+ *
236
+ * export default {
237
+ * key: "about-page-meta",
238
+ * content: {
239
+ * stringContent: "About Page Meta",
240
+ * numberContent: 123,
241
+ * booleanContent: true,
242
+ * multilingualContent: t({
243
+ * en: "About Page Meta",
244
+ * fr: "Meta de la page About",
245
+ * es: "Meta de la página About",
246
+ * }),
247
+ * conditionalContent: cond({
248
+ * true: "About Page Meta",
249
+ * false: "About Page Meta",
250
+ * }),
251
+ * insertionContent: insert("About Page Meta"),
252
+ * nestedContent: nest("about-page"),
253
+ * markdownContent: md("# About Page Meta"),
254
+ * fileContent: file("./path/to/file.txt"),
255
+ * jsxContent: <h1>About Page Meta</h1>,
256
+ * },
257
+ *
258
+ * } satisfies Dictionary<Content>;
259
+ * ```
260
+ *
261
+ * ```json
262
+ * {
263
+ * "key": "about-page-meta",
264
+ * "content": {
265
+ * "stringContent": "About Page Meta",
266
+ * "numberContent": 123,
267
+ * "booleanContent": true,
268
+ * "multilingualContent": {
269
+ * "nodeType": "translation",
270
+ * "translation": {
271
+ * "en": "About Page Meta",
272
+ * "fr": "Meta de la page About",
273
+ * "es": "Meta de la página About",
274
+ * },
275
+ * },
276
+ * "conditionalContent": {
277
+ * "nodeType": "condition",
278
+ * "condition": {
279
+ * "true": "About Page Meta",
280
+ * "false": "About Page Meta",
281
+ * },
282
+ * },
283
+ * "insertionContent": {
284
+ * "nodeType": "insertion",
285
+ * "insertion": "About Page Meta",
286
+ * },
287
+ * "nestedContent": {
288
+ * "nodeType": "nested",
289
+ * "nested": { "dictionaryKey": "about-page" },
290
+ * },
291
+ * "markdownContent": {
292
+ * "nodeType": "markdown",
293
+ * "markdown": "# About Page Meta",
294
+ * },
295
+ * "fileContent": {
296
+ * "nodeType": "file",
297
+ * "file": "./path/to/file.txt",
298
+ * },
299
+ * }
300
+ * }
301
+ * ```
302
+ */
303
+ content: ContentType extends undefined ? any : ReplaceContentValue<ContentType, FetchableNode> | ContentType;
304
+ };
305
+ export type GetSubPath<T, P> = P extends `${infer K}.${infer Rest}` ? K extends keyof T ? GetSubPath<T[K], Rest> : never : P extends keyof T ? T[P] : T;
306
+ export {};
307
+ //# sourceMappingURL=dictionary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dictionary.d.ts","sourceRoot":"","sources":["../../../src/types/dictionary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EACV,gCAAgC,EAChC,eAAe,EACf,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB;;;;GAIG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,MAAM,GAAG,CAAC,CAAC;AAEjE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,cAAc,GAAG,cAAc,CACzC,MAAM,gCAAgC,CACvC,CAAC;AAEF,KAAK,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;AAE7D,MAAM,MAAM,SAAS,CAAC,QAAQ,GAAG,SAAS,IACtC,kBAAkB,CAAC,QAAQ,CAAC,GAC5B,kBAAkB,CAAC,QAAQ,CAAC,GAC5B,gBAAgB,CAAC,QAAQ,CAAC,GAC1B,gBAA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AE,IAAI,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;;;;;;;;;OAcG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;OAIG;IACH,QAAQ,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyEG;IACH,OAAO,EAAE,WAAW,SAAS,SAAS,GAClC,GAAG,GACH,mBAAmB,CAAC,WAAW,EAAE,aAAa,CAAC,GAAG,WAAW,CAAC;CACnE,CAAC;AAEF,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,IAAI,MAAM,IAAI,EAAE,GAC/D,CAAC,SAAS,MAAM,CAAC,GACf,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GACtB,KAAK,GACP,CAAC,SAAS,MAAM,CAAC,GACf,CAAC,CAAC,CAAC,CAAC,GACJ,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './dictionary';
2
+ export * from './keyPath';
3
+ export * from './nodeType';
4
+ export * from './translation';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Reexport the intlayer module with the module augmentation because of typescript error
3
+ */
4
+ export type { IConfigLocales, IntlayerDictionaryTypesConnector, LanguageContent, LocalesValues, } from 'intlayer';
5
+ //# sourceMappingURL=intlayer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intlayer.d.ts","sourceRoot":"","sources":["../../../src/types/intlayer.ts"],"names":[],"mappings":"AACA;;GAEG;AAEH,YAAY,EACV,cAAc,EACd,gCAAgC,EAChC,eAAe,EACf,aAAa,GACd,MAAM,UAAU,CAAC"}
@@ -0,0 +1,47 @@
1
+ import type { NodeType } from './nodeType';
2
+ export type ObjectNode = {
3
+ type: NodeType.Object;
4
+ key: string;
5
+ };
6
+ export type ArrayNode = {
7
+ type: NodeType.Array;
8
+ key: number;
9
+ };
10
+ export type EnumerationNode = {
11
+ type: NodeType.Enumeration;
12
+ key: string;
13
+ };
14
+ export type TranslationNode = {
15
+ type: NodeType.Translation;
16
+ key: string;
17
+ };
18
+ export type ConditionNode = {
19
+ type: NodeType.Condition;
20
+ key: string;
21
+ };
22
+ export type GenderNode = {
23
+ type: NodeType.Gender;
24
+ key: string;
25
+ };
26
+ export type InsertionNode = {
27
+ type: NodeType.Insertion;
28
+ key?: undefined;
29
+ };
30
+ export type MarkdownNode = {
31
+ type: NodeType.Markdown;
32
+ key?: undefined;
33
+ };
34
+ export type ReactNode = {
35
+ type: NodeType.ReactNode;
36
+ key?: undefined;
37
+ };
38
+ export type NestedNode = {
39
+ type: NodeType.Nested;
40
+ key?: undefined;
41
+ };
42
+ export type FileNode = {
43
+ type: NodeType.File;
44
+ key?: undefined;
45
+ };
46
+ export type KeyPath = ObjectNode | ArrayNode | TranslationNode | EnumerationNode | InsertionNode | GenderNode | MarkdownNode | ReactNode | ConditionNode | NestedNode | FileNode;
47
+ //# sourceMappingURL=keyPath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyPath.d.ts","sourceRoot":"","sources":["../../../src/types/keyPath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAA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f,eAAe,GACf,aAAa,GACb,UAAU,GACV,YAAY,GACZ,SAAS,GACT,aAAa,GACb,UAAU,GACV,QAAQ,CAAC"}
@@ -0,0 +1,30 @@
1
+ export declare enum NodeType {
2
+ Translation = "translation",
3
+ Enumeration = "enumeration",
4
+ Condition = "condition",
5
+ Insertion = "insertion",
6
+ File = "file",
7
+ Object = "object",
8
+ Array = "array",
9
+ Nested = "nested",
10
+ ReactNode = "reactNode",
11
+ Markdown = "markdown",
12
+ Text = "text",
13
+ Number = "number",
14
+ Boolean = "boolean",
15
+ Gender = "gender",
16
+ Unknown = "unknown"
17
+ }
18
+ type AdditionalAttributesType = {
19
+ [key: string]: any;
20
+ };
21
+ export type TypedNodeModel<T extends NodeType, Content, AdditionalAttributes extends AdditionalAttributesType = {}> = {
22
+ nodeType: T | `${T}`;
23
+ } & {
24
+ [K in T]: Content;
25
+ } & AdditionalAttributes;
26
+ export declare const formatNodeType: <T extends NodeType, Content = any, AdditionalAttributes extends AdditionalAttributesType = {}>(nodeType: T | `${T}`, content: Content, additionalAttributes?: {
27
+ [key: string]: any;
28
+ }) => TypedNodeModel<T, Content, AdditionalAttributes>;
29
+ export {};
30
+ //# sourceMappingURL=nodeType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodeType.d.ts","sourceRoot":"","sources":["../../../src/types/nodeType.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ;IAClB,WAAW,gBAAgB;IAC3B,WAAW,gBAAgB;IAC3B,SAAS,cAAc;IACvB,SAAS,cAAc;IACvB,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,OAAO,YAAY;CACpB;AAED,KAAK,wBAAwB,GAAG;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,cAAc,CACxB,CAAC,SAAS,QAAQ,EAClB,OAAO,EACP,oBAAoB,SAAS,wBAAwB,GAAG,EAAE,IACxD;IACF,QAAQ,EAAE,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC;CACtB,GAAG;KACD,CAAC,IAAI,CAAC,GAAG,OAAO;CAClB,GAAG,oBAAoB,CAAC;AAEzB,eAAO,MAAM,cAAc,GACzB,CAAC,SAAS,QAAQ,EAClB,OAAO,GAAG,GAAG,EACb,oBAAoB,SAAS,wBAAwB,GAAG,EAAE,EAE1D,UAAU,CAAC,GAAG,GAAG,CAAC,EAAE,EACpB,SAAS,OAAO,EAChB,uBAAuB;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,KAMvC,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,oBAAoB,CAAC,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { LocalesValues } from '@intlayer/config/client';
2
+ import type { IConfigLocales } from './intlayer';
3
+ /**
4
+ * If module augmented, it will return the configured locales such as Locales.ENGLISH | Locales.FRENCH | Locales.SPANISH | ...
5
+ * If not, it will return never
6
+ */
7
+ export type ConfigLocales = keyof IConfigLocales<unknown>;
8
+ /**
9
+ * Record of locales and content
10
+ *
11
+ * const myVar1: TranslationContentState<string> = {
12
+ * "en": "",
13
+ * "fr": ""
14
+ * }
15
+ *
16
+ * const myVar2: TranslationContentState<{age: number, name: string}> = {
17
+ * "en": {age: 1, name: "test"},
18
+ * "fr": {age: 1, name: "test"}
19
+ * }
20
+ */
21
+ export type TranslationContentState<Content = unknown> = {
22
+ [locale in LocalesValues]?: Content;
23
+ };
24
+ export type LanguageContent<Content = unknown> = keyof IConfigLocales<unknown> extends never ? TranslationContentState<Content> : IConfigLocales<Content>;
25
+ //# sourceMappingURL=translation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translation.d.ts","sourceRoot":"","sources":["../../../src/types/translation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC;AAE1D;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,uBAAuB,CAAC,OAAO,GAAG,OAAO,IAAI;KACtD,MAAM,IAAI,aAAa,CAAC,CAAC,EAAE,OAAO;CACpC,CAAC;AAEF,MAAM,MAAM,eAAe,CAAC,OAAO,GAAG,OAAO,IAC3C,MAAM,cAAc,CAAC,OAAO,CAAC,SAAS,KAAK,GACvC,uBAAuB,CAAC,OAAO,CAAC,GAChC,cAAc,CAAC,OAAO,CAAC,CAAC"}
@@ -67,16 +67,18 @@ type LocaleStorageOptions = {
67
67
  getSessionStorage?: (name: string) => string | undefined | null;
68
68
  setLocaleStorage?: (name: string, value: string) => void;
69
69
  getLocaleStorage?: (name: string) => string | undefined | null;
70
+ getHeader?: (name: string) => string | undefined | null;
71
+ setHeader?: (name: string, value: string) => void;
70
72
  };
71
73
  /**
72
- * Retrieves the locale from various storage mechanisms (cookies, localStorage, sessionStorage).
74
+ * Retrieves the locale from various storage mechanisms (cookies, localStorage, sessionStorage, headers).
73
75
  * The function checks storage locations in order of priority as defined in the configuration.
74
76
  *
75
77
  * @returns The locale if found in any storage, or undefined if not found
76
78
  */
77
- declare const getLocaleFromStorage: (options: Pick<LocaleStorageOptions, "getCookie" | "getSessionStorage" | "getLocaleStorage" | "isCookieEnabled">) => Locale | undefined;
79
+ declare const getLocaleFromStorage: (options: Pick<LocaleStorageOptions, "getCookie" | "getSessionStorage" | "getLocaleStorage" | "getHeader" | "isCookieEnabled">) => Locale | undefined;
78
80
  /**
79
- * Stores the locale in various storage mechanisms (cookies, localStorage, sessionStorage).
81
+ * Stores the locale in various storage mechanisms (cookies, localStorage, sessionStorage, headers).
80
82
  * The function writes to all configured storage locations according to their attributes.
81
83
  * Respects overwrite flags for localStorage and sessionStorage.
82
84
  *
@@ -86,11 +88,11 @@ declare const setLocaleInStorage: (locale: LocalesValues, options?: LocaleStorag
86
88
  /**
87
89
  * Utility object to get and set the locale in the storage by considering the configuration
88
90
  *
89
- * @property getLocale - Retrieves the locale from various storage mechanisms (cookies, localStorage, sessionStorage).
90
- * Retrieves the locale from various storage mechanisms (cookies, localStorage, sessionStorage).
91
+ * @property getLocale - Retrieves the locale from various storage mechanisms (cookies, localStorage, sessionStorage, headers).
92
+ * Retrieves the locale from various storage mechanisms (cookies, localStorage, sessionStorage, headers).
91
93
  * The function checks storage locations in order of priority as defined in the configuration.
92
94
  *
93
- * @property setLocale - Stores the locale in various storage mechanisms (cookies, localStorage, sessionStorage).
95
+ * @property setLocale - Stores the locale in various storage mechanisms (cookies, localStorage, sessionStorage, headers).
94
96
  * The function writes to all configured storage locations according to their attributes.
95
97
  * Respects overwrite flags for localStorage and sessionStorage.
96
98
  *
@@ -1 +1 @@
1
- {"version":3,"file":"localeStorage.d.ts","names":[],"sources":["../../../src/utils/localeStorage.ts"],"sourcesContent":[],"mappings":";;;KAIK,qBAAA;;AAH2E;AA+EhF;AAsBA;;;;;EAkGa,MAAA,CAAA,EAAA,MAAA;EAuFA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA/MD,oBAAA;;;yDAMA;;;;;;;;;;;;;;cAgBC,gCACF,KACP,sGAGD;;;;;;;;cA6FU,6BACH,yBACE;;;;;;;;;;;;;;cAqFC,yBAA0B;;sBAEjB"}
1
+ {"version":3,"file":"localeStorage.d.ts","names":[],"sources":["../../../src/utils/localeStorage.ts"],"sourcesContent":[],"mappings":";;;KAIK,qBAAA;;AAH2E;AA+EhF;AAwBA;;;;;EAiHa,MAAA,CAAA,EAAA,MAAA;EAkGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA3OD,oBAAA;;;yDAMA;;;;;;;;;;;;;;;;cAkBC,gCACF,KACP,oHAOD;;;;;;;;cAwGU,6BACH,yBACE;;;;;;;;;;;;;;cAgGC,yBAA0B;;sBAEjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/core",
3
- "version": "7.0.0-canary.3",
3
+ "version": "7.0.1",
4
4
  "private": false,
5
5
  "description": "Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.",
6
6
  "keywords": [
@@ -98,29 +98,29 @@
98
98
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
99
99
  },
100
100
  "dependencies": {
101
- "@intlayer/api": "7.0.0-canary.3",
102
- "@intlayer/config": "7.0.0-canary.3",
103
- "@intlayer/dictionaries-entry": "7.0.0-canary.3",
104
- "@intlayer/types": "7.0.0-canary.3",
105
- "@intlayer/unmerged-dictionaries-entry": "7.0.0-canary.3",
101
+ "@intlayer/api": "7.0.1",
102
+ "@intlayer/config": "7.0.1",
103
+ "@intlayer/dictionaries-entry": "7.0.1",
104
+ "@intlayer/types": "7.0.1",
105
+ "@intlayer/unmerged-dictionaries-entry": "7.0.1",
106
106
  "deepmerge": "4.3.1"
107
107
  },
108
108
  "devDependencies": {
109
109
  "@types/node": "24.9.1",
110
- "@utils/ts-config": "7.0.0-canary.3",
111
- "@utils/ts-config-types": "7.0.0-canary.3",
112
- "@utils/tsdown-config": "7.0.0-canary.3",
110
+ "@utils/ts-config": "7.0.1",
111
+ "@utils/ts-config-types": "7.0.1",
112
+ "@utils/tsdown-config": "7.0.1",
113
113
  "rimraf": "6.0.1",
114
114
  "tsdown": "0.15.9",
115
115
  "typescript": "5.9.3",
116
116
  "vitest": "4.0.3"
117
117
  },
118
118
  "peerDependencies": {
119
- "@intlayer/api": "7.0.0-canary.3",
120
- "@intlayer/config": "7.0.0-canary.3",
121
- "@intlayer/dictionaries-entry": "7.0.0-canary.3",
122
- "@intlayer/types": "7.0.0-canary.3",
123
- "@intlayer/unmerged-dictionaries-entry": "7.0.0-canary.3"
119
+ "@intlayer/api": "7.0.1",
120
+ "@intlayer/config": "7.0.1",
121
+ "@intlayer/dictionaries-entry": "7.0.1",
122
+ "@intlayer/types": "7.0.1",
123
+ "@intlayer/unmerged-dictionaries-entry": "7.0.1"
124
124
  },
125
125
  "engines": {
126
126
  "node": ">=14.18"