@vocab/types
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -1,116 +0,1 @@ | ||
export { FormatXMLElementFn } from 'intl-messageformat'; | ||
export type LanguageName = string; | ||
export type TranslationKey = string; | ||
export type TranslationMessage = string; | ||
export type ParsedFormatFn = (parts: any) => any; | ||
export type ParsedFormatFnByKey = Record<string, ParsedFormatFn>; | ||
export type ICUFormatResult<T = unknown> = string | T | (string | T); | ||
/** | ||
* Equivalent to the `string` type, but tricks the language server into prodiving | ||
* suggestions for string literals passed into the `Suggestions` generic parameter | ||
* | ||
* @example | ||
* Accept any string, but suggest specific animals | ||
* ``` | ||
* type AnyAnimal = StringWithSuggestions<"cat" | "dog">; | ||
* // Suggests cat and dog, but accepts any string | ||
* const animal: AnyAnimal = ""; | ||
* ``` | ||
*/ | ||
export type StringWithSuggestions<Suggestions extends string> = Suggestions | Omit<string, Suggestions>; | ||
/** | ||
* ParsedICUMessage A strictly typed formatter from intl-messageformat | ||
*/ | ||
interface ParsedICUMessage<FormatFn extends ParsedFormatFn> { | ||
format: FormatFn; | ||
} | ||
export type ParsedICUMessages<FormatFnByKey extends ParsedFormatFnByKey> = { | ||
[key in keyof FormatFnByKey]: ParsedICUMessage<FormatFnByKey[key]>; | ||
}; | ||
/** | ||
* TranslationModule is a wrapper around a potentially asynchronously loaded set of ParsedICUMessages | ||
*/ | ||
export type TranslationModule<FormatFnByKey extends ParsedFormatFnByKey> = { | ||
getValue: (locale: string) => ParsedICUMessages<FormatFnByKey> | undefined; | ||
load: () => Promise<void>; | ||
}; | ||
export type TranslationModuleByLanguage<Language extends LanguageName, FormatFnByKey extends ParsedFormatFnByKey> = Record<Language, TranslationModule<FormatFnByKey>>; | ||
/** | ||
* TranslationFile contains a record of TranslationModules per language, exposing a set of methods to load and return the module by language | ||
*/ | ||
export type TranslationFile<Language extends LanguageName, FormatFnByKey extends ParsedFormatFnByKey> = { | ||
/** | ||
* Retrieve messages. If not loaded, will attempt to load messages and resolve once complete. | ||
*/ | ||
getMessages: (language: Language, locale?: string) => Promise<ParsedICUMessages<FormatFnByKey>>; | ||
/** | ||
* Retrieve already loaded messages. Will return null if no messages have been loaded. | ||
*/ | ||
getLoadedMessages: (language: Language, locale?: string) => ParsedICUMessages<FormatFnByKey> | null; | ||
/** | ||
* Load messages for the given language. Resolving once complete. | ||
*/ | ||
load: (language: Language) => Promise<void>; | ||
}; | ||
export interface LanguageTarget { | ||
name: LanguageName; | ||
extends?: LanguageName; | ||
} | ||
export interface MessageGenerator { | ||
transformElement?: (element: string) => string; | ||
transformMessage?: (message: string) => string; | ||
} | ||
export interface GeneratedLanguageTarget { | ||
name: LanguageName; | ||
extends?: LanguageName; | ||
generator: MessageGenerator; | ||
} | ||
export interface UserConfig { | ||
/** | ||
* The root directory to compile and validate translations | ||
*/ | ||
projectRoot?: string; | ||
/** | ||
* The language used in translations.json | ||
*/ | ||
devLanguage: LanguageName; | ||
/** | ||
* An array of languages to build for | ||
*/ | ||
languages: Array<LanguageTarget>; | ||
/** | ||
* An array of languages to generate from existing translations | ||
*/ | ||
generatedLanguages?: Array<GeneratedLanguageTarget>; | ||
/** | ||
* A custom suffix to name vocab translation directories | ||
*/ | ||
translationsDirectorySuffix?: string; | ||
/** | ||
* An array of glob paths to ignore from compilation and validation | ||
*/ | ||
ignore?: Array<string>; | ||
} | ||
export type Tags = Array<string>; | ||
export interface TranslationFileMetadata { | ||
tags?: Tags; | ||
} | ||
export interface TranslationData { | ||
message: TranslationMessage; | ||
description?: string; | ||
tags?: Tags; | ||
} | ||
export type TranslationsByKey<Key extends TranslationKey = string> = Record<Key, TranslationData>; | ||
export type TranslationFileContents = TranslationsByKey & { | ||
_meta?: TranslationFileMetadata; | ||
}; | ||
export type TranslationMessagesByKey<Key extends TranslationKey = string> = Record<Key, TranslationMessage>; | ||
export type TranslationsByLanguage<Key extends TranslationKey = string> = Record<LanguageName, TranslationsByKey<Key>>; | ||
export type LoadedTranslation<Key extends TranslationKey = string> = { | ||
namespace: string; | ||
keys: Array<Key>; | ||
filePath: string; | ||
relativePath: string; | ||
languages: TranslationsByLanguage<Key>; | ||
metadata: TranslationFileMetadata; | ||
}; | ||
export type { FormatXMLElementFn, LanguageName, TranslationKey, TranslationMessage, ParsedFormatFn, ParsedFormatFnByKey, StringWithSuggestions, ParsedICUMessages, TranslationModule, TranslationModuleByLanguage, TranslationFile, Tags, TranslationsByKey, TranslationFileContents, TranslationMessagesByKey, TranslationsByLanguage, LoadedTranslation, } from '@vocab/core'; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var intlMessageformat = require('intl-messageformat'); | ||
Object.defineProperty(exports, 'FormatXMLElementFn', { | ||
enumerable: true, | ||
get: function () { return intlMessageformat.FormatXMLElementFn; } | ||
}); |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var intlMessageformat = require('intl-messageformat'); | ||
Object.defineProperty(exports, 'FormatXMLElementFn', { | ||
enumerable: true, | ||
get: function () { return intlMessageformat.FormatXMLElementFn; } | ||
}); |
@@ -1,1 +0,1 @@ | ||
export { FormatXMLElementFn } from 'intl-messageformat'; | ||
{ | ||
"name": "@vocab/types", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"main": "dist/vocab-types.cjs.js", | ||
@@ -12,4 +12,4 @@ "module": "dist/vocab-types.esm.js", | ||
"dependencies": { | ||
"intl-messageformat": "^10.0.0" | ||
"@vocab/core": "^1.3.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18378
11
+ Added@vocab/core@^1.3.0
+ Added@nodelib/fs.scandir@2.1.5(transitive)
+ Added@nodelib/fs.stat@2.0.5(transitive)
+ Added@nodelib/fs.walk@1.2.8(transitive)
+ Added@vocab/core@1.6.3(transitive)
+ Addedanymatch@3.1.3(transitive)
+ Addedbinary-extensions@2.3.0(transitive)
+ Addedbraces@3.0.3(transitive)
+ Addedchokidar@3.6.0(transitive)
+ Addeddebug@4.3.7(transitive)
+ Addedfast-glob@3.3.2(transitive)
+ Addedfastest-validator@1.19.0(transitive)
+ Addedfastq@1.17.1(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedfind-up@5.0.0(transitive)
+ Addedfsevents@2.3.3(transitive)
+ Addedglob-parent@5.1.2(transitive)
+ Addedis-binary-path@2.1.0(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-glob@4.0.3(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addedlocate-path@6.0.0(transitive)
+ Addedmerge2@1.4.1(transitive)
+ Addedmicromatch@4.0.8(transitive)
+ Addedms@2.1.3(transitive)
+ Addednormalize-path@3.0.0(transitive)
+ Addedp-limit@3.1.0(transitive)
+ Addedp-locate@5.0.0(transitive)
+ Addedpath-exists@4.0.0(transitive)
+ Addedpicocolors@1.1.1(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedprettier@2.8.8(transitive)
+ Addedqueue-microtask@1.2.3(transitive)
+ Addedreaddirp@3.6.0(transitive)
+ Addedreusify@1.0.4(transitive)
+ Addedrun-parallel@1.2.0(transitive)
+ Addedto-regex-range@5.0.1(transitive)
+ Addedyocto-queue@0.1.0(transitive)
- Removedintl-messageformat@^10.0.0