@vocab/core 1.5.0 → 1.6.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.
package/README.md CHANGED
@@ -29,7 +29,7 @@ $ npm i --save @vocab/core @vocab/react
29
29
 
30
30
  ### Step 2: Configure Vocab
31
31
 
32
- You can configure Vocab directly when calling the API or via a `vocab.config.js` file.
32
+ You can configure Vocab directly when calling the API or via a `vocab.config.js` or `vocab.config.cjs` file.
33
33
 
34
34
  In this example we've configured two languages, English and French, where our initial `translation.json` files will use English.
35
35
 
@@ -184,7 +184,7 @@ t('my key with component', {
184
184
 
185
185
  ## Configuration
186
186
 
187
- Configuration can either be passed into the Node API directly or be gathered from the nearest _vocab.config.js_ file.
187
+ Configuration can either be passed into the Node API directly or be gathered from the nearest _vocab.config.js_ or _vocab.config.cjs_ file.
188
188
 
189
189
  **vocab.config.js**
190
190
 
@@ -341,7 +341,7 @@ functionality.
341
341
 
342
342
  ### Generating a pseudo-localized language using Vocab
343
343
 
344
- Vocab can generate a pseudo-localized language via the [`generatedLanguages` config][generated languages config], either via the webpack plugin or your `vocab.config.js` file.
344
+ Vocab can generate a pseudo-localized language via the [`generatedLanguages` config][generated languages config], either via the webpack plugin or your `vocab.config.js` or `vocab.config.cjs` file.
345
345
  `@vocab/pseudo-localize` exports a `generator` that can be used directly in your config.
346
346
 
347
347
  **vocab.config.js**
@@ -1,4 +1,4 @@
1
- import type { LoadedTranslation, UserConfig } from './types';
1
+ import type { LoadedTranslation, UserConfig } from "./types.js";
2
2
  export declare function generateRuntime(loadedTranslation: LoadedTranslation): Promise<void>;
3
3
  export declare function watch(config: UserConfig): () => Promise<void>;
4
4
  export declare function compile({ watch: shouldWatch }: {
@@ -1,4 +1,4 @@
1
- import type { UserConfig } from './types';
1
+ import type { UserConfig } from "./types.js";
2
2
  export declare function validateConfig(c: UserConfig): boolean;
3
3
  export declare function resolveConfig(customConfigFilePath?: string): Promise<UserConfig | null>;
4
4
  export declare function resolveConfigSync(customConfigFilePath?: string): UserConfig | null;
@@ -1,2 +1,2 @@
1
- import type { ParsedICUMessages, TranslationMessagesByKey } from './types';
1
+ import type { ParsedICUMessages, TranslationMessagesByKey } from "./types.js";
2
2
  export declare const getParsedICUMessages: (m: TranslationMessagesByKey, locale: string) => ParsedICUMessages<any>;
@@ -1,6 +1,6 @@
1
- export { compile, watch } from './compile';
2
- export { validate } from './validate';
3
- export { resolveConfig, resolveConfigSync, validateConfig } from './config';
4
- export { getAltLanguages, getAltLanguageFilePath, getDevLanguageFileFromTsFile, } from './utils';
5
- export { getUniqueKey, loadAllTranslations, loadTranslation, } from './load-translations';
6
- export * from './types';
1
+ export { compile, watch } from "./compile.js";
2
+ export { validate } from "./validate/index.js";
3
+ export { resolveConfig, resolveConfigSync, validateConfig } from "./config.js";
4
+ export { getAltLanguages, getAltLanguageFilePath, getDevLanguageFileFromTsFile, } from "./utils.js";
5
+ export { getUniqueKey, loadAllTranslations, loadTranslation, } from "./load-translations.js";
6
+ export * from "./types.js";
@@ -1,5 +1,5 @@
1
- import type { TranslationsByKey, UserConfig, LoadedTranslation, LanguageTarget } from './types';
2
- import { type Fallback } from './utils';
1
+ import type { TranslationsByKey, UserConfig, LoadedTranslation, LanguageTarget } from "./types.js";
2
+ import { type Fallback } from "./utils.js";
3
3
  export declare function getUniqueKey(key: string, namespace: string): string;
4
4
  export declare function mergeWithDevLanguageTranslation({ translation, devTranslation, }: {
5
5
  translation: TranslationsByKey;
@@ -1,3 +1,3 @@
1
- import type { TranslationModule, TranslationMessagesByKey } from './types';
2
- export { createTranslationFile } from './translation-file';
1
+ import type { TranslationModule, TranslationMessagesByKey } from "./types.js";
2
+ export { createTranslationFile } from "./translation-file.js";
3
3
  export declare const createLanguage: (module: TranslationMessagesByKey) => TranslationModule<any>;
@@ -1,2 +1,2 @@
1
- import type { TranslationModuleByLanguage, LanguageName, ParsedFormatFnByKey, TranslationFile } from './types';
1
+ import type { TranslationModuleByLanguage, LanguageName, ParsedFormatFnByKey, TranslationFile } from "./types.js";
2
2
  export declare function createTranslationFile<Language extends LanguageName, FormatFnByKey extends ParsedFormatFnByKey>(translationsByLanguage: TranslationModuleByLanguage<Language, FormatFnByKey>): TranslationFile<Language, FormatFnByKey>;
@@ -1,4 +1,4 @@
1
- import type { LanguageName, LanguageTarget, TranslationsByKey, TranslationMessagesByKey, UserConfig } from './types';
1
+ import type { LanguageName, LanguageTarget, TranslationsByKey, TranslationMessagesByKey, UserConfig } from "./types.js";
2
2
  export declare const defaultTranslationDirSuffix = ".vocab";
3
3
  export declare const devTranslationFileName = "translations.json";
4
4
  export type Fallback = 'none' | 'valid' | 'all';
@@ -1,3 +1,3 @@
1
- import type { UserConfig, LoadedTranslation, LanguageName } from '../types';
1
+ import type { UserConfig, LoadedTranslation, LanguageName } from "../types.js";
2
2
  export declare function findMissingKeys(loadedTranslation: LoadedTranslation, devLanguageName: LanguageName, altLanguages: Array<LanguageName>): readonly [boolean, Record<string, string[]>];
3
3
  export declare function validate(config: UserConfig): Promise<boolean>;
@@ -1 +1,2 @@
1
1
  export * from "./declarations/src/index";
2
+ //# sourceMappingURL=vocab-core.cjs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vocab-core.cjs.d.ts","sourceRoot":"","sources":["./declarations/src/index.d.ts"],"names":[],"mappings":"AAAA"}
@@ -855,7 +855,7 @@ function createConfig(configFilePath) {
855
855
  };
856
856
  }
857
857
  async function resolveConfig(customConfigFilePath) {
858
- const configFilePath = customConfigFilePath ? path__default["default"].resolve(customConfigFilePath) : await findUp__default["default"]('vocab.config.js');
858
+ const configFilePath = customConfigFilePath ? path__default["default"].resolve(customConfigFilePath) : await findUp__default["default"](['vocab.config.js', 'vocab.config.cjs']);
859
859
  if (configFilePath) {
860
860
  trace(`Resolved configuration file to ${configFilePath}`);
861
861
  return createConfig(configFilePath);
@@ -864,7 +864,7 @@ async function resolveConfig(customConfigFilePath) {
864
864
  return null;
865
865
  }
866
866
  function resolveConfigSync(customConfigFilePath) {
867
- const configFilePath = customConfigFilePath ? path__default["default"].resolve(customConfigFilePath) : findUp__default["default"].sync('vocab.config.js');
867
+ const configFilePath = customConfigFilePath ? path__default["default"].resolve(customConfigFilePath) : findUp__default["default"].sync(['vocab.config.js', 'vocab.config.cjs']);
868
868
  if (configFilePath) {
869
869
  trace(`Resolved configuration file to ${configFilePath}`);
870
870
  return createConfig(configFilePath);
@@ -855,7 +855,7 @@ function createConfig(configFilePath) {
855
855
  };
856
856
  }
857
857
  async function resolveConfig(customConfigFilePath) {
858
- const configFilePath = customConfigFilePath ? path__default["default"].resolve(customConfigFilePath) : await findUp__default["default"]('vocab.config.js');
858
+ const configFilePath = customConfigFilePath ? path__default["default"].resolve(customConfigFilePath) : await findUp__default["default"](['vocab.config.js', 'vocab.config.cjs']);
859
859
  if (configFilePath) {
860
860
  trace(`Resolved configuration file to ${configFilePath}`);
861
861
  return createConfig(configFilePath);
@@ -864,7 +864,7 @@ async function resolveConfig(customConfigFilePath) {
864
864
  return null;
865
865
  }
866
866
  function resolveConfigSync(customConfigFilePath) {
867
- const configFilePath = customConfigFilePath ? path__default["default"].resolve(customConfigFilePath) : findUp__default["default"].sync('vocab.config.js');
867
+ const configFilePath = customConfigFilePath ? path__default["default"].resolve(customConfigFilePath) : findUp__default["default"].sync(['vocab.config.js', 'vocab.config.cjs']);
868
868
  if (configFilePath) {
869
869
  trace(`Resolved configuration file to ${configFilePath}`);
870
870
  return createConfig(configFilePath);
@@ -839,7 +839,7 @@ function createConfig(configFilePath) {
839
839
  };
840
840
  }
841
841
  async function resolveConfig(customConfigFilePath) {
842
- const configFilePath = customConfigFilePath ? path.resolve(customConfigFilePath) : await findUp('vocab.config.js');
842
+ const configFilePath = customConfigFilePath ? path.resolve(customConfigFilePath) : await findUp(['vocab.config.js', 'vocab.config.cjs']);
843
843
  if (configFilePath) {
844
844
  trace(`Resolved configuration file to ${configFilePath}`);
845
845
  return createConfig(configFilePath);
@@ -848,7 +848,7 @@ async function resolveConfig(customConfigFilePath) {
848
848
  return null;
849
849
  }
850
850
  function resolveConfigSync(customConfigFilePath) {
851
- const configFilePath = customConfigFilePath ? path.resolve(customConfigFilePath) : findUp.sync('vocab.config.js');
851
+ const configFilePath = customConfigFilePath ? path.resolve(customConfigFilePath) : findUp.sync(['vocab.config.js', 'vocab.config.cjs']);
852
852
  if (configFilePath) {
853
853
  trace(`Resolved configuration file to ${configFilePath}`);
854
854
  return createConfig(configFilePath);
@@ -1 +1,2 @@
1
1
  export * from "../../dist/declarations/src/icu-handler";
2
+ //# sourceMappingURL=vocab-core-icu-handler.cjs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vocab-core-icu-handler.cjs.d.ts","sourceRoot":"","sources":["../../dist/declarations/src/icu-handler.d.ts"],"names":[],"mappings":"AAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vocab/core",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "main": "dist/vocab-core.cjs.js",
5
5
  "module": "dist/vocab-core.esm.js",
6
6
  "exports": {
@@ -1 +1,2 @@
1
1
  export * from "../../dist/declarations/src/runtime";
2
+ //# sourceMappingURL=vocab-core-runtime.cjs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vocab-core-runtime.cjs.d.ts","sourceRoot":"","sources":["../../dist/declarations/src/runtime.d.ts"],"names":[],"mappings":"AAAA"}
@@ -1 +1,2 @@
1
1
  export * from "../../dist/declarations/src/translation-file";
2
+ //# sourceMappingURL=vocab-core-translation-file.cjs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vocab-core-translation-file.cjs.d.ts","sourceRoot":"","sources":["../../dist/declarations/src/translation-file.d.ts"],"names":[],"mappings":"AAAA"}
@@ -1,5 +0,0 @@
1
- export declare class ValidationError extends Error {
2
- code: string;
3
- rawMessage: string;
4
- constructor(code: string, message: string);
5
- }
@@ -1,5 +0,0 @@
1
- import type { MessageGenerator, TranslationsByKey } from './types';
2
- export declare function generateLanguageFromTranslations({ baseTranslations, generator, }: {
3
- baseTranslations: TranslationsByKey<string>;
4
- generator: MessageGenerator;
5
- }): TranslationsByKey<string>;
@@ -1,3 +0,0 @@
1
- import debug from 'debug';
2
- export declare const trace: debug.Debugger;
3
- export declare const log: (...params: unknown[]) => void;