@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
package/dist/index.d.cts CHANGED
@@ -1,54 +1,7 @@
1
- import { C as TranslationsByLanguage, S as TranslationsByKey, _ as TranslationKeys, a as LoadedTranslation, b as TranslationModule, c as ParsedFormatFnByKey, d as Tags, f as TranslationData, g as TranslationKey, h as TranslationFileMetadata, i as LanguageTarget, l as ParsedICUMessages, m as TranslationFileContents, n as GeneratedLanguageTarget, o as MessageGenerator, p as TranslationFile, r as LanguageName, s as ParsedFormatFn, t as FormatXMLElementFn, u as StringWithSuggestions, v as TranslationMessage, w as UserConfig, x as TranslationModuleByLanguage, y as TranslationMessagesByKey } from "./types-Bybu5Wvr.cjs";
1
+ import { t as __esmMin } from "./chunk-Bdo2O6aD.cjs";
2
+ import { C as TranslationsByLanguage, S as TranslationsByKey, T as init_types_d, _ as TranslationKeys, a as LoadedTranslation, b as TranslationModule, c as ParsedFormatFnByKey, d as Tags, f as TranslationData, g as TranslationKey, h as TranslationFileMetadata, i as LanguageTarget, l as ParsedICUMessages, m as TranslationFileContents, n as GeneratedLanguageTarget, o as MessageGenerator, p as TranslationFile, r as LanguageName, s as ParsedFormatFn, t as FormatXMLElementFn, u as StringWithSuggestions, v as TranslationMessage, w as UserConfig, x as TranslationModuleByLanguage, y as TranslationMessagesByKey } from "./types-Dhy3ksw5.cjs";
2
3
 
3
4
  //#region src/compile.d.ts
4
- declare function watch(config: UserConfig): () => Promise<void>;
5
- declare function compile({
6
- watch: shouldWatch
7
- }: {
8
- watch?: boolean | undefined;
9
- } | undefined, config: UserConfig): Promise<(() => Promise<void>) | undefined>;
10
- //#endregion
11
- //#region src/validate/index.d.ts
12
- declare function validate(config: UserConfig): Promise<boolean>;
13
- //#endregion
14
- //#region src/config.d.ts
15
- declare function validateConfig(c: UserConfig): boolean;
16
- declare function resolveConfig(customConfigFilePath?: string): Promise<UserConfig | null>;
17
- declare function resolveConfigSync(customConfigFilePath?: string): UserConfig | null;
18
- //#endregion
19
- //#region src/utils.d.ts
20
- type Fallback = 'none' | 'valid' | 'all';
21
- declare const compiledVocabFileFilter: RegExp;
22
- declare function getAltLanguages({
23
- devLanguage,
24
- languages
25
- }: {
26
- devLanguage: LanguageName;
27
- languages: LanguageTarget[];
28
- }): string[];
29
- declare function getDevLanguageFileFromTsFile(tsFilePath: string): string;
30
- declare function getAltLanguageFilePath(devLanguageFilePath: string, language: string): string;
31
- //#endregion
32
- //#region src/load-translations.d.ts
33
- declare function getUniqueKey(key: string, namespace: string): string;
34
- declare function loadTranslation({
35
- filePath,
36
- fallbacks,
37
- withTags
38
- }: {
39
- filePath: string;
40
- fallbacks: Fallback;
41
- withTags?: boolean;
42
- }, userConfig: UserConfig): LoadedTranslation;
43
- declare function loadAllTranslations({
44
- fallbacks,
45
- includeNodeModules,
46
- withTags
47
- }: {
48
- fallbacks: Fallback;
49
- includeNodeModules: boolean;
50
- withTags?: boolean;
51
- }, config: UserConfig): Promise<LoadedTranslation[]>;
52
- //#endregion
5
+
53
6
  export { FormatXMLElementFn, GeneratedLanguageTarget, LanguageName, LanguageTarget, LoadedTranslation, MessageGenerator, ParsedFormatFn, ParsedFormatFnByKey, ParsedICUMessages, StringWithSuggestions, Tags, TranslationData, TranslationFile, TranslationFileContents, TranslationFileMetadata, TranslationKey, TranslationKeys, TranslationMessage, TranslationMessagesByKey, TranslationModule, TranslationModuleByLanguage, TranslationsByKey, TranslationsByLanguage, UserConfig, compile, compiledVocabFileFilter, getAltLanguageFilePath, getAltLanguages, getDevLanguageFileFromTsFile, getUniqueKey, loadAllTranslations, loadTranslation, resolveConfig, resolveConfigSync, validate, validateConfig, watch };
54
7
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.mts CHANGED
@@ -1,54 +1,7 @@
1
- import { C as TranslationsByLanguage, S as TranslationsByKey, _ as TranslationKeys, a as LoadedTranslation, b as TranslationModule, c as ParsedFormatFnByKey, d as Tags, f as TranslationData, g as TranslationKey, h as TranslationFileMetadata, i as LanguageTarget, l as ParsedICUMessages, m as TranslationFileContents, n as GeneratedLanguageTarget, o as MessageGenerator, p as TranslationFile, r as LanguageName, s as ParsedFormatFn, t as FormatXMLElementFn, u as StringWithSuggestions, v as TranslationMessage, w as UserConfig, x as TranslationModuleByLanguage, y as TranslationMessagesByKey } from "./types-rKEHSDgg.mjs";
1
+ import { t as __esmMin } from "./chunk-YUyckAMm.mjs";
2
+ import { C as TranslationsByLanguage, S as TranslationsByKey, T as init_types_d, _ as TranslationKeys, a as LoadedTranslation, b as TranslationModule, c as ParsedFormatFnByKey, d as Tags, f as TranslationData, g as TranslationKey, h as TranslationFileMetadata, i as LanguageTarget, l as ParsedICUMessages, m as TranslationFileContents, n as GeneratedLanguageTarget, o as MessageGenerator, p as TranslationFile, r as LanguageName, s as ParsedFormatFn, t as FormatXMLElementFn, u as StringWithSuggestions, v as TranslationMessage, w as UserConfig, x as TranslationModuleByLanguage, y as TranslationMessagesByKey } from "./types-tajuHnML.mjs";
2
3
 
3
4
  //#region src/compile.d.ts
4
- declare function watch(config: UserConfig): () => Promise<void>;
5
- declare function compile({
6
- watch: shouldWatch
7
- }: {
8
- watch?: boolean | undefined;
9
- } | undefined, config: UserConfig): Promise<(() => Promise<void>) | undefined>;
10
- //#endregion
11
- //#region src/validate/index.d.ts
12
- declare function validate(config: UserConfig): Promise<boolean>;
13
- //#endregion
14
- //#region src/config.d.ts
15
- declare function validateConfig(c: UserConfig): boolean;
16
- declare function resolveConfig(customConfigFilePath?: string): Promise<UserConfig | null>;
17
- declare function resolveConfigSync(customConfigFilePath?: string): UserConfig | null;
18
- //#endregion
19
- //#region src/utils.d.ts
20
- type Fallback = 'none' | 'valid' | 'all';
21
- declare const compiledVocabFileFilter: RegExp;
22
- declare function getAltLanguages({
23
- devLanguage,
24
- languages
25
- }: {
26
- devLanguage: LanguageName;
27
- languages: LanguageTarget[];
28
- }): string[];
29
- declare function getDevLanguageFileFromTsFile(tsFilePath: string): string;
30
- declare function getAltLanguageFilePath(devLanguageFilePath: string, language: string): string;
31
- //#endregion
32
- //#region src/load-translations.d.ts
33
- declare function getUniqueKey(key: string, namespace: string): string;
34
- declare function loadTranslation({
35
- filePath,
36
- fallbacks,
37
- withTags
38
- }: {
39
- filePath: string;
40
- fallbacks: Fallback;
41
- withTags?: boolean;
42
- }, userConfig: UserConfig): LoadedTranslation;
43
- declare function loadAllTranslations({
44
- fallbacks,
45
- includeNodeModules,
46
- withTags
47
- }: {
48
- fallbacks: Fallback;
49
- includeNodeModules: boolean;
50
- withTags?: boolean;
51
- }, config: UserConfig): Promise<LoadedTranslation[]>;
52
- //#endregion
5
+
53
6
  export { FormatXMLElementFn, GeneratedLanguageTarget, LanguageName, LanguageTarget, LoadedTranslation, MessageGenerator, ParsedFormatFn, ParsedFormatFnByKey, ParsedICUMessages, StringWithSuggestions, Tags, TranslationData, TranslationFile, TranslationFileContents, TranslationFileMetadata, TranslationKey, TranslationKeys, TranslationMessage, TranslationMessagesByKey, TranslationModule, TranslationModuleByLanguage, TranslationsByKey, TranslationsByLanguage, UserConfig, compile, compiledVocabFileFilter, getAltLanguageFilePath, getAltLanguages, getDevLanguageFileFromTsFile, getUniqueKey, loadAllTranslations, loadTranslation, resolveConfig, resolveConfigSync, validate, validateConfig, watch };
54
7
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -1,5 +1,4 @@
1
- import { createRequire } from "node:module";
2
- import { IntlMessageFormat } from "intl-messageformat";
1
+ import { n as __require, t as __esmMin } from "./chunk-YUyckAMm.mjs";
3
2
  import { existsSync, promises } from "fs";
4
3
  import path from "path";
5
4
  import { TYPE, isArgumentElement, isDateElement, isNumberElement, isPluralElement, isSelectElement, isTagElement, isTimeElement, parse } from "@formatjs/icu-messageformat-parser";
@@ -8,23 +7,19 @@ import chokidar from "chokidar";
8
7
  import pc from "picocolors";
9
8
  import debug from "debug";
10
9
  import glob from "fast-glob";
10
+ import { IntlMessageFormat } from "intl-messageformat";
11
11
  import { printAST } from "@formatjs/icu-messageformat-parser/printer.js";
12
12
  import findUp from "find-up";
13
13
  import Validator from "fastest-validator";
14
14
 
15
- //#region rolldown:runtime
16
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
17
-
18
- //#endregion
19
15
  //#region src/logger.ts
20
- const trace = debug(`vocab:core`);
16
+ var trace;
17
+ var init_logger = __esmMin((() => {
18
+ trace = debug(`vocab:core`);
19
+ }));
21
20
 
22
21
  //#endregion
23
22
  //#region src/utils.ts
24
- const defaultTranslationDirSuffix = ".vocab";
25
- const devTranslationFileName = "translations.json";
26
- const globAnyPathWithOptionalPrefix = "**/?(*)";
27
- const compiledVocabFileFilter = /\.vocab[\\/]index\.(?:ts|js|cjs|mjs)$/;
28
23
  function isDevLanguageFile(filePath) {
29
24
  return filePath.endsWith(`/${devTranslationFileName}`) || filePath === devTranslationFileName;
30
25
  }
@@ -88,6 +83,14 @@ function mapValues(obj, func) {
88
83
  function getTranslationMessages(translations) {
89
84
  return mapValues(translations, (v) => v.message);
90
85
  }
86
+ var defaultTranslationDirSuffix, devTranslationFileName, globAnyPathWithOptionalPrefix, compiledVocabFileFilter;
87
+ var init_utils = __esmMin((() => {
88
+ init_logger();
89
+ defaultTranslationDirSuffix = ".vocab";
90
+ devTranslationFileName = "translations.json";
91
+ globAnyPathWithOptionalPrefix = "**/?(*)";
92
+ compiledVocabFileFilter = /\.vocab[\\/]index\.(?:ts|js|cjs|mjs)$/;
93
+ }));
91
94
 
92
95
  //#endregion
93
96
  //#region src/generate-language.ts
@@ -124,6 +127,7 @@ function transformMessageFormatElement(transformElement) {
124
127
  return transformedMessageFormatElement;
125
128
  };
126
129
  }
130
+ var init_generate_language = __esmMin((() => {}));
127
131
 
128
132
  //#endregion
129
133
  //#region src/load-translations.ts
@@ -178,13 +182,13 @@ function printValidationError(...params) {
178
182
  }
179
183
  function getTranslationsFromFile(translationFileContents, { isAltLanguage, filePath, withTags }) {
180
184
  if (!translationFileContents || typeof translationFileContents !== "object") throw new Error(`Unable to read translation file ${filePath}. Translations must be an object.`);
181
- const { $namespace, _meta,...keys } = translationFileContents;
185
+ const { $namespace, _meta, ...keys } = translationFileContents;
182
186
  if (isAltLanguage && $namespace) printValidationError(`Found $namespace in alt language file in ${filePath}. $namespace is only used in the dev language and will be ignored.`);
183
187
  if (!isAltLanguage && $namespace && typeof $namespace !== "string") printValidationError(`Found non-string $namespace in language file in ${filePath}. $namespace must be a string.`);
184
188
  if (isAltLanguage && _meta?.tags) printValidationError(`Found _meta.tags in alt language file in ${filePath}. _meta.tags is only used in the dev language and will be ignored.`);
185
189
  const includeTags = !isAltLanguage && withTags;
186
190
  const validKeys = {};
187
- for (const [translationKey, { tags,...translation }] of Object.entries(keys)) {
191
+ for (const [translationKey, { tags, ...translation }] of Object.entries(keys)) {
188
192
  if (typeof translation === "string") {
189
193
  printValidationError(`Found string for a translation "${translationKey}" in ${filePath}. Translation must be an object of the format {message: string}.`);
190
194
  continue;
@@ -236,7 +240,7 @@ function loadAltLanguageFile({ filePath, languageName, devTranslation, fallbacks
236
240
  return altLanguageTranslation;
237
241
  }
238
242
  function stripTagsFromTranslations(translations) {
239
- return Object.fromEntries(Object.entries(translations).map(([key, { tags,...rest }]) => [key, rest]));
243
+ return Object.fromEntries(Object.entries(translations).map(([key, { tags, ...rest }]) => [key, rest]));
240
244
  }
241
245
  function loadTranslation({ filePath, fallbacks, withTags }, userConfig) {
242
246
  trace(`Loading translation file in "${fallbacks}" fallback mode: "${filePath}"`);
@@ -310,6 +314,11 @@ async function loadAllTranslations({ fallbacks, includeNodeModules, withTags },
310
314
  }
311
315
  return loadedTranslations;
312
316
  }
317
+ var init_load_translations = __esmMin((() => {
318
+ init_logger();
319
+ init_utils();
320
+ init_generate_language();
321
+ }));
313
322
 
314
323
  //#endregion
315
324
  //#region src/compile.ts
@@ -358,10 +367,6 @@ function serialiseObjectToType(v) {
358
367
  for (const [key, value] of Object.entries(v)) result += `${JSON.stringify(key)}: ${value && typeof value === "object" ? serialiseObjectToType(value) : value},`;
359
368
  return `{ ${result} }`;
360
369
  }
361
- const serializeTypeImports = (imports, moduleName) => {
362
- if (imports.size === 0) return "";
363
- return `import type { ${Array.from(imports).join(", ")} } from '${moduleName}';`;
364
- };
365
370
  function serialiseTranslationRuntime(value, imports, loadedTranslation) {
366
371
  trace("Serialising translations:", loadedTranslation);
367
372
  const translationsType = {};
@@ -488,6 +493,16 @@ async function writeIfChanged(filepath, contents) {
488
493
  } catch {}
489
494
  if (hasChanged) await promises.writeFile(filepath, contents, { encoding: "utf-8" });
490
495
  }
496
+ var serializeTypeImports;
497
+ var init_compile = __esmMin((() => {
498
+ init_utils();
499
+ init_logger();
500
+ init_load_translations();
501
+ serializeTypeImports = (imports, moduleName) => {
502
+ if (imports.size === 0) return "";
503
+ return `import type { ${Array.from(imports).join(", ")} } from '${moduleName}';`;
504
+ };
505
+ }));
491
506
 
492
507
  //#endregion
493
508
  //#region src/validate/index.ts
@@ -526,80 +541,28 @@ async function validate(config) {
526
541
  }
527
542
  return valid;
528
543
  }
544
+ var init_validate = __esmMin((() => {
545
+ init_load_translations();
546
+ init_utils();
547
+ }));
529
548
 
530
549
  //#endregion
531
550
  //#region src/ValidationError.ts
532
- var ValidationError = class extends Error {
533
- code;
534
- rawMessage;
535
- constructor(code, message) {
536
- super(`Invalid vocab.config.js: ${code} - ${message}`);
537
- this.code = code;
538
- this.rawMessage = message;
539
- }
540
- };
551
+ var ValidationError;
552
+ var init_ValidationError = __esmMin((() => {
553
+ ValidationError = class extends Error {
554
+ code;
555
+ rawMessage;
556
+ constructor(code, message) {
557
+ super(`Invalid vocab.config.js: ${code} - ${message}`);
558
+ this.code = code;
559
+ this.rawMessage = message;
560
+ }
561
+ };
562
+ }));
541
563
 
542
564
  //#endregion
543
565
  //#region src/config.ts
544
- const boldCyan = (s) => pc.bold(pc.cyan(s));
545
- const checkConfigFile = new Validator().compile({
546
- $$strict: true,
547
- devLanguage: { type: "string" },
548
- languages: {
549
- type: "array",
550
- items: {
551
- type: "object",
552
- props: {
553
- name: { type: "string" },
554
- extends: {
555
- type: "string",
556
- optional: true
557
- }
558
- }
559
- }
560
- },
561
- generatedLanguages: {
562
- type: "array",
563
- items: {
564
- type: "object",
565
- props: {
566
- name: { type: "string" },
567
- extends: {
568
- type: "string",
569
- optional: true
570
- },
571
- generator: {
572
- type: "object",
573
- props: {
574
- transformElement: {
575
- type: "function",
576
- optional: true
577
- },
578
- transformMessage: {
579
- type: "function",
580
- optional: true
581
- }
582
- }
583
- }
584
- }
585
- },
586
- optional: true
587
- },
588
- translationsDirectorySuffix: {
589
- type: "string",
590
- optional: true
591
- },
592
- projectRoot: {
593
- type: "string",
594
- optional: true
595
- },
596
- ignore: {
597
- type: "array",
598
- items: "string",
599
- optional: true
600
- }
601
- });
602
- const splitMap = (message, callback) => message.split(" ,").map((v) => callback(v)).join(" ,");
603
566
  function validateConfig(c) {
604
567
  trace("Validating configuration file");
605
568
  const isValid = checkConfigFile(c);
@@ -650,7 +613,82 @@ function resolveConfigSync(customConfigFilePath) {
650
613
  trace("No configuration file found");
651
614
  return null;
652
615
  }
616
+ var boldCyan, checkConfigFile, splitMap;
617
+ var init_config = __esmMin((() => {
618
+ init_ValidationError();
619
+ init_logger();
620
+ boldCyan = (s) => pc.bold(pc.cyan(s));
621
+ checkConfigFile = new Validator().compile({
622
+ $$strict: true,
623
+ devLanguage: { type: "string" },
624
+ languages: {
625
+ type: "array",
626
+ items: {
627
+ type: "object",
628
+ props: {
629
+ name: { type: "string" },
630
+ extends: {
631
+ type: "string",
632
+ optional: true
633
+ }
634
+ }
635
+ }
636
+ },
637
+ generatedLanguages: {
638
+ type: "array",
639
+ items: {
640
+ type: "object",
641
+ props: {
642
+ name: { type: "string" },
643
+ extends: {
644
+ type: "string",
645
+ optional: true
646
+ },
647
+ generator: {
648
+ type: "object",
649
+ props: {
650
+ transformElement: {
651
+ type: "function",
652
+ optional: true
653
+ },
654
+ transformMessage: {
655
+ type: "function",
656
+ optional: true
657
+ }
658
+ }
659
+ }
660
+ }
661
+ },
662
+ optional: true
663
+ },
664
+ translationsDirectorySuffix: {
665
+ type: "string",
666
+ optional: true
667
+ },
668
+ projectRoot: {
669
+ type: "string",
670
+ optional: true
671
+ },
672
+ ignore: {
673
+ type: "array",
674
+ items: "string",
675
+ optional: true
676
+ }
677
+ });
678
+ splitMap = (message, callback) => message.split(" ,").map((v) => callback(v)).join(" ,");
679
+ }));
680
+
681
+ //#endregion
682
+ //#region src/index.ts
683
+ var init_src = __esmMin((() => {
684
+ init_compile();
685
+ init_validate();
686
+ init_config();
687
+ init_utils();
688
+ init_load_translations();
689
+ }));
653
690
 
654
691
  //#endregion
692
+ init_src();
655
693
  export { compile, compiledVocabFileFilter, getAltLanguageFilePath, getAltLanguages, getDevLanguageFileFromTsFile, getUniqueKey, loadAllTranslations, loadTranslation, resolveConfig, resolveConfigSync, validate, validateConfig, watch };
656
694
  //# sourceMappingURL=index.mjs.map