@vocab/core 1.7.0 → 1.7.1-isolate-rolldown-runtime-20251217033548

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 (44) hide show
  1. package/dist/chunk-BuD6V4w7.cjs +41 -0
  2. package/dist/chunk-YUyckAMm.mjs +8 -0
  3. package/dist/icu-handler-BALMAIaM.cjs +37 -0
  4. package/dist/{icu-handler-U7Z19ut9.cjs.map → icu-handler-BALMAIaM.cjs.map} +1 -1
  5. package/dist/icu-handler-CuYAM62Z.mjs +26 -0
  6. package/dist/{icu-handler-C6-jMNN0.mjs.map → icu-handler-CuYAM62Z.mjs.map} +1 -1
  7. package/dist/icu-handler.cjs +2 -1
  8. package/dist/icu-handler.cjs.map +1 -0
  9. package/dist/icu-handler.d.cts +3 -3
  10. package/dist/icu-handler.d.mts +3 -3
  11. package/dist/icu-handler.mjs +2 -1
  12. package/dist/index.cjs +132 -113
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +3 -50
  15. package/dist/index.d.mts +3 -50
  16. package/dist/index.mjs +124 -86
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/runtime.cjs +13 -6
  19. package/dist/runtime.cjs.map +1 -1
  20. package/dist/runtime.d.cts +4 -4
  21. package/dist/runtime.d.mts +4 -4
  22. package/dist/runtime.mjs +13 -6
  23. package/dist/runtime.mjs.map +1 -1
  24. package/dist/{translation-file-C6XiVDhV.mjs → translation-file-C23K0G2v.cjs} +16 -2
  25. package/dist/{translation-file-B46ZpuQo.cjs.map → translation-file-C23K0G2v.cjs.map} +1 -1
  26. package/dist/{translation-file-B46ZpuQo.cjs → translation-file-D18r2tf_.mjs} +4 -7
  27. package/dist/{translation-file-C6XiVDhV.mjs.map → translation-file-D18r2tf_.mjs.map} +1 -1
  28. package/dist/translation-file-DGrsUC73.d.cts +8 -0
  29. package/dist/translation-file-TvWb96IF.d.mts +8 -0
  30. package/dist/translation-file.cjs +2 -1
  31. package/dist/translation-file.cjs.map +1 -0
  32. package/dist/translation-file.d.cts +1 -2
  33. package/dist/translation-file.d.mts +1 -2
  34. package/dist/translation-file.mjs +2 -1
  35. package/dist/types-Dhy3ksw5.d.cts +8 -0
  36. package/dist/types-tajuHnML.d.mts +8 -0
  37. package/package.json +9 -9
  38. package/README.md +0 -827
  39. package/dist/icu-handler-C6-jMNN0.mjs +0 -22
  40. package/dist/icu-handler-U7Z19ut9.cjs +0 -28
  41. package/dist/translation-file-C4qAmnhr.d.mts +0 -7
  42. package/dist/translation-file-DXnLvsY4.d.cts +0 -7
  43. package/dist/types-Bybu5Wvr.d.cts +0 -146
  44. package/dist/types-rKEHSDgg.d.mts +0 -146
@@ -1,22 +0,0 @@
1
- import { IntlMessageFormat } from "intl-messageformat";
2
-
3
- //#region src/icu-handler.ts
4
- const moduleCache = /* @__PURE__ */ new WeakMap();
5
- const getParsedICUMessages = (m, locale) => {
6
- const moduleCachedResult = moduleCache.get(m);
7
- if (moduleCachedResult && moduleCachedResult[locale]) return moduleCachedResult[locale];
8
- const parsedICUMessages = {};
9
- for (const translation of Object.keys(m)) {
10
- const intlMessageFormat = new IntlMessageFormat(m[translation], locale);
11
- parsedICUMessages[translation] = { format: (params) => intlMessageFormat.format(params) };
12
- }
13
- moduleCache.set(m, {
14
- ...moduleCachedResult,
15
- [locale]: parsedICUMessages
16
- });
17
- return parsedICUMessages;
18
- };
19
-
20
- //#endregion
21
- export { getParsedICUMessages as t };
22
- //# sourceMappingURL=icu-handler-C6-jMNN0.mjs.map
@@ -1,28 +0,0 @@
1
- const require_index = require('./index.cjs');
2
- let intl_messageformat = require("intl-messageformat");
3
-
4
- //#region src/icu-handler.ts
5
- const moduleCache = /* @__PURE__ */ new WeakMap();
6
- const getParsedICUMessages = (m, locale) => {
7
- const moduleCachedResult = moduleCache.get(m);
8
- if (moduleCachedResult && moduleCachedResult[locale]) return moduleCachedResult[locale];
9
- const parsedICUMessages = {};
10
- for (const translation of Object.keys(m)) {
11
- const intlMessageFormat = new intl_messageformat.IntlMessageFormat(m[translation], locale);
12
- parsedICUMessages[translation] = { format: (params) => intlMessageFormat.format(params) };
13
- }
14
- moduleCache.set(m, {
15
- ...moduleCachedResult,
16
- [locale]: parsedICUMessages
17
- });
18
- return parsedICUMessages;
19
- };
20
-
21
- //#endregion
22
- Object.defineProperty(exports, 'getParsedICUMessages', {
23
- enumerable: true,
24
- get: function () {
25
- return getParsedICUMessages;
26
- }
27
- });
28
- //# sourceMappingURL=icu-handler-U7Z19ut9.cjs.map
@@ -1,7 +0,0 @@
1
- import { c as ParsedFormatFnByKey, p as TranslationFile, r as LanguageName, x as TranslationModuleByLanguage } from "./types-rKEHSDgg.mjs";
2
-
3
- //#region src/translation-file.d.ts
4
- declare function createTranslationFile<Language extends LanguageName, FormatFnByKey extends ParsedFormatFnByKey>(translationsByLanguage: TranslationModuleByLanguage<Language, FormatFnByKey>): TranslationFile<Language, FormatFnByKey>;
5
- //#endregion
6
- export { createTranslationFile as t };
7
- //# sourceMappingURL=translation-file-C4qAmnhr.d.mts.map
@@ -1,7 +0,0 @@
1
- import { c as ParsedFormatFnByKey, p as TranslationFile, r as LanguageName, x as TranslationModuleByLanguage } from "./types-Bybu5Wvr.cjs";
2
-
3
- //#region src/translation-file.d.ts
4
- declare function createTranslationFile<Language extends LanguageName, FormatFnByKey extends ParsedFormatFnByKey>(translationsByLanguage: TranslationModuleByLanguage<Language, FormatFnByKey>): TranslationFile<Language, FormatFnByKey>;
5
- //#endregion
6
- export { createTranslationFile as t };
7
- //# sourceMappingURL=translation-file-DXnLvsY4.d.cts.map
@@ -1,146 +0,0 @@
1
- import { FormatXMLElementFn } from "intl-messageformat";
2
-
3
- //#region src/types.d.ts
4
- type LanguageName = string;
5
- type TranslationKey = string;
6
- type TranslationMessage = string;
7
- type ParsedFormatFn = (parts: any) => any;
8
- type ParsedFormatFnByKey = Record<string, ParsedFormatFn>;
9
- /**
10
- * Equivalent to the `string` type, but tricks TypeScript into prodiving
11
- * suggestions for string literals passed into the `Suggestions` generic parameter
12
- *
13
- * @example
14
- * type AnyAnimal = StringWithSuggestions<"cat" | "dog">;
15
- * // Suggests cat and dog, but accepts any string
16
- * const animal: AnyAnimal = "";
17
- */
18
- type StringWithSuggestions<Suggestions extends string> = Suggestions | Omit<string, Suggestions>;
19
- /**
20
- * ParsedICUMessage A strictly typed formatter from intl-messageformat
21
- */
22
- interface ParsedICUMessage<FormatFn extends ParsedFormatFn> {
23
- format: FormatFn;
24
- }
25
- type ParsedICUMessages<FormatFnByKey extends ParsedFormatFnByKey> = { [key in keyof FormatFnByKey]: ParsedICUMessage<FormatFnByKey[key]> };
26
- /**
27
- * TranslationModule is a wrapper around a potentially asynchronously loaded set of ParsedICUMessages
28
- */
29
- type TranslationModule<FormatFnByKey extends ParsedFormatFnByKey> = {
30
- getValue: (locale: string) => ParsedICUMessages<FormatFnByKey> | undefined;
31
- load: () => Promise<void>;
32
- };
33
- type TranslationModuleByLanguage<Language extends LanguageName, FormatFnByKey extends ParsedFormatFnByKey> = Record<Language, TranslationModule<FormatFnByKey>>;
34
- /**
35
- * TranslationFile contains a record of TranslationModules per language, exposing a set of methods to load and return the module by language
36
- */
37
- type TranslationFile<Language extends LanguageName, FormatFnByKey extends ParsedFormatFnByKey> = {
38
- /**
39
- * Retrieve messages. If not loaded, will attempt to load messages and resolve once complete.
40
- */
41
- getMessages: (language: Language, locale?: string) => Promise<ParsedICUMessages<FormatFnByKey>>;
42
- /**
43
- * Retrieve already loaded messages. Will return null if no messages have been loaded.
44
- */
45
- getLoadedMessages: (language: Language, locale?: string) => ParsedICUMessages<FormatFnByKey> | null;
46
- /**
47
- * Load messages for the given language. Resolving once complete.
48
- */
49
- load: (language: Language) => Promise<void>;
50
- };
51
- /**
52
- * A utility type to get the union of all translation keys from a translation file
53
- *
54
- * @example
55
- * // translations.json
56
- * {
57
- * "Hello": {
58
- * "message": "Hello",
59
- * },
60
- * "Goodbye": {
61
- * "message": "Goodbye",
62
- * },
63
- * }
64
- *
65
- * // myFile.ts
66
- * import { TranslationKeys } from '@vocab/core';
67
- * import translations from './.vocab';
68
- *
69
- * // 'Hello' | 'Goodbye'
70
- * type TheTranslationKeys = TranslationKeys<typeof translations>;
71
- *
72
- * @example
73
- * import { TranslationKeys } from '@vocab/core';
74
- * import fooTranslations from './foo.vocab';
75
- * import barTranslations from './bar.vocab';
76
- *
77
- * // It even works with multiple translation files
78
- * type FooBarTranslationKeys = TranslationKeys<typeof fooTranslations | typeof barTranslations>;
79
- */
80
- type TranslationKeys<Translations extends TranslationFile<any, ParsedFormatFnByKey>> = Translations extends unknown ? keyof Awaited<ReturnType<Translations['getMessages']>> : never;
81
- interface LanguageTarget {
82
- name: LanguageName;
83
- extends?: LanguageName;
84
- }
85
- interface MessageGenerator {
86
- transformElement?: (element: string) => string;
87
- transformMessage?: (message: string) => string;
88
- }
89
- interface GeneratedLanguageTarget {
90
- name: LanguageName;
91
- extends?: LanguageName;
92
- generator: MessageGenerator;
93
- }
94
- interface UserConfig {
95
- /**
96
- * The root directory to compile and validate translations
97
- */
98
- projectRoot?: string;
99
- /**
100
- * The language used in translations.json
101
- */
102
- devLanguage: LanguageName;
103
- /**
104
- * An array of languages to build for
105
- */
106
- languages: LanguageTarget[];
107
- /**
108
- * An array of languages to generate from existing translations
109
- */
110
- generatedLanguages?: GeneratedLanguageTarget[];
111
- /**
112
- * A custom suffix to name vocab translation directories
113
- */
114
- translationsDirectorySuffix?: string;
115
- /**
116
- * An array of glob paths to ignore from compilation and validation
117
- */
118
- ignore?: string[];
119
- }
120
- type Tags = string[];
121
- interface TranslationFileMetadata {
122
- tags?: Tags;
123
- }
124
- interface TranslationData {
125
- message: TranslationMessage;
126
- description?: string;
127
- tags?: Tags;
128
- globalKey?: string;
129
- }
130
- type TranslationsByKey<Key extends TranslationKey = string> = Record<Key, TranslationData>;
131
- type TranslationFileContents = TranslationsByKey & {
132
- _meta?: TranslationFileMetadata;
133
- };
134
- type TranslationMessagesByKey<Key extends TranslationKey = string> = Record<Key, TranslationMessage>;
135
- type TranslationsByLanguage<Key extends TranslationKey = string> = Record<LanguageName, TranslationsByKey<Key>>;
136
- type LoadedTranslation<Key extends TranslationKey = string> = {
137
- namespace: string;
138
- keys: Key[];
139
- filePath: string;
140
- relativePath: string;
141
- languages: TranslationsByLanguage<Key>;
142
- metadata: TranslationFileMetadata;
143
- };
144
- //#endregion
145
- export { TranslationsByLanguage as C, TranslationsByKey as S, TranslationKeys as _, LoadedTranslation as a, TranslationModule as b, ParsedFormatFnByKey as c, Tags as d, TranslationData as f, TranslationKey as g, TranslationFileMetadata as h, LanguageTarget as i, ParsedICUMessages as l, TranslationFileContents as m, GeneratedLanguageTarget as n, MessageGenerator as o, TranslationFile as p, LanguageName as r, ParsedFormatFn as s, FormatXMLElementFn as t, StringWithSuggestions as u, TranslationMessage as v, UserConfig as w, TranslationModuleByLanguage as x, TranslationMessagesByKey as y };
146
- //# sourceMappingURL=types-Bybu5Wvr.d.cts.map
@@ -1,146 +0,0 @@
1
- import { FormatXMLElementFn } from "intl-messageformat";
2
-
3
- //#region src/types.d.ts
4
- type LanguageName = string;
5
- type TranslationKey = string;
6
- type TranslationMessage = string;
7
- type ParsedFormatFn = (parts: any) => any;
8
- type ParsedFormatFnByKey = Record<string, ParsedFormatFn>;
9
- /**
10
- * Equivalent to the `string` type, but tricks TypeScript into prodiving
11
- * suggestions for string literals passed into the `Suggestions` generic parameter
12
- *
13
- * @example
14
- * type AnyAnimal = StringWithSuggestions<"cat" | "dog">;
15
- * // Suggests cat and dog, but accepts any string
16
- * const animal: AnyAnimal = "";
17
- */
18
- type StringWithSuggestions<Suggestions extends string> = Suggestions | Omit<string, Suggestions>;
19
- /**
20
- * ParsedICUMessage A strictly typed formatter from intl-messageformat
21
- */
22
- interface ParsedICUMessage<FormatFn extends ParsedFormatFn> {
23
- format: FormatFn;
24
- }
25
- type ParsedICUMessages<FormatFnByKey extends ParsedFormatFnByKey> = { [key in keyof FormatFnByKey]: ParsedICUMessage<FormatFnByKey[key]> };
26
- /**
27
- * TranslationModule is a wrapper around a potentially asynchronously loaded set of ParsedICUMessages
28
- */
29
- type TranslationModule<FormatFnByKey extends ParsedFormatFnByKey> = {
30
- getValue: (locale: string) => ParsedICUMessages<FormatFnByKey> | undefined;
31
- load: () => Promise<void>;
32
- };
33
- type TranslationModuleByLanguage<Language extends LanguageName, FormatFnByKey extends ParsedFormatFnByKey> = Record<Language, TranslationModule<FormatFnByKey>>;
34
- /**
35
- * TranslationFile contains a record of TranslationModules per language, exposing a set of methods to load and return the module by language
36
- */
37
- type TranslationFile<Language extends LanguageName, FormatFnByKey extends ParsedFormatFnByKey> = {
38
- /**
39
- * Retrieve messages. If not loaded, will attempt to load messages and resolve once complete.
40
- */
41
- getMessages: (language: Language, locale?: string) => Promise<ParsedICUMessages<FormatFnByKey>>;
42
- /**
43
- * Retrieve already loaded messages. Will return null if no messages have been loaded.
44
- */
45
- getLoadedMessages: (language: Language, locale?: string) => ParsedICUMessages<FormatFnByKey> | null;
46
- /**
47
- * Load messages for the given language. Resolving once complete.
48
- */
49
- load: (language: Language) => Promise<void>;
50
- };
51
- /**
52
- * A utility type to get the union of all translation keys from a translation file
53
- *
54
- * @example
55
- * // translations.json
56
- * {
57
- * "Hello": {
58
- * "message": "Hello",
59
- * },
60
- * "Goodbye": {
61
- * "message": "Goodbye",
62
- * },
63
- * }
64
- *
65
- * // myFile.ts
66
- * import { TranslationKeys } from '@vocab/core';
67
- * import translations from './.vocab';
68
- *
69
- * // 'Hello' | 'Goodbye'
70
- * type TheTranslationKeys = TranslationKeys<typeof translations>;
71
- *
72
- * @example
73
- * import { TranslationKeys } from '@vocab/core';
74
- * import fooTranslations from './foo.vocab';
75
- * import barTranslations from './bar.vocab';
76
- *
77
- * // It even works with multiple translation files
78
- * type FooBarTranslationKeys = TranslationKeys<typeof fooTranslations | typeof barTranslations>;
79
- */
80
- type TranslationKeys<Translations extends TranslationFile<any, ParsedFormatFnByKey>> = Translations extends unknown ? keyof Awaited<ReturnType<Translations['getMessages']>> : never;
81
- interface LanguageTarget {
82
- name: LanguageName;
83
- extends?: LanguageName;
84
- }
85
- interface MessageGenerator {
86
- transformElement?: (element: string) => string;
87
- transformMessage?: (message: string) => string;
88
- }
89
- interface GeneratedLanguageTarget {
90
- name: LanguageName;
91
- extends?: LanguageName;
92
- generator: MessageGenerator;
93
- }
94
- interface UserConfig {
95
- /**
96
- * The root directory to compile and validate translations
97
- */
98
- projectRoot?: string;
99
- /**
100
- * The language used in translations.json
101
- */
102
- devLanguage: LanguageName;
103
- /**
104
- * An array of languages to build for
105
- */
106
- languages: LanguageTarget[];
107
- /**
108
- * An array of languages to generate from existing translations
109
- */
110
- generatedLanguages?: GeneratedLanguageTarget[];
111
- /**
112
- * A custom suffix to name vocab translation directories
113
- */
114
- translationsDirectorySuffix?: string;
115
- /**
116
- * An array of glob paths to ignore from compilation and validation
117
- */
118
- ignore?: string[];
119
- }
120
- type Tags = string[];
121
- interface TranslationFileMetadata {
122
- tags?: Tags;
123
- }
124
- interface TranslationData {
125
- message: TranslationMessage;
126
- description?: string;
127
- tags?: Tags;
128
- globalKey?: string;
129
- }
130
- type TranslationsByKey<Key extends TranslationKey = string> = Record<Key, TranslationData>;
131
- type TranslationFileContents = TranslationsByKey & {
132
- _meta?: TranslationFileMetadata;
133
- };
134
- type TranslationMessagesByKey<Key extends TranslationKey = string> = Record<Key, TranslationMessage>;
135
- type TranslationsByLanguage<Key extends TranslationKey = string> = Record<LanguageName, TranslationsByKey<Key>>;
136
- type LoadedTranslation<Key extends TranslationKey = string> = {
137
- namespace: string;
138
- keys: Key[];
139
- filePath: string;
140
- relativePath: string;
141
- languages: TranslationsByLanguage<Key>;
142
- metadata: TranslationFileMetadata;
143
- };
144
- //#endregion
145
- export { TranslationsByLanguage as C, TranslationsByKey as S, TranslationKeys as _, LoadedTranslation as a, TranslationModule as b, ParsedFormatFnByKey as c, Tags as d, TranslationData as f, TranslationKey as g, TranslationFileMetadata as h, LanguageTarget as i, ParsedICUMessages as l, TranslationFileContents as m, GeneratedLanguageTarget as n, MessageGenerator as o, TranslationFile as p, LanguageName as r, ParsedFormatFn as s, FormatXMLElementFn as t, StringWithSuggestions as u, TranslationMessage as v, UserConfig as w, TranslationModuleByLanguage as x, TranslationMessagesByKey as y };
146
- //# sourceMappingURL=types-rKEHSDgg.d.mts.map