Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vocab/types

Package Overview
Dependencies
Maintainers
5
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vocab/types - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

117

dist/declarations/src/index.d.ts

@@ -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; }
});

2

dist/vocab-types.esm.js

@@ -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"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc