New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

intl-schematic

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

intl-schematic - npm Package Compare versions

Comparing version 1.0.0-rc.5 to 1.0.0-rc.7

2

dist/metafile-cjs.json

@@ -1,1 +0,1 @@

{"inputs":{"packages/core/src/index.ts":{"bytes":5076,"imports":[],"format":"esm"},"packages/core/src/plugins.ts":{"bytes":8726,"imports":[],"format":"esm"}},"outputs":{"packages/core/dist/index.cjs":{"imports":[],"exports":[],"entryPoint":"packages/core/src/index.ts","inputs":{"packages/core/src/index.ts":{"bytesInOutput":2216}},"bytes":3046},"packages/core/dist/plugins.cjs":{"imports":[],"exports":[],"entryPoint":"packages/core/src/plugins.ts","inputs":{"packages/core/src/plugins.ts":{"bytesInOutput":273}},"bytes":1105}}}
{"inputs":{"packages/core/src/plugins.ts":{"bytes":8946,"imports":[],"format":"esm"},"packages/core/src/index.ts":{"bytes":5315,"imports":[{"path":"packages/core/src/plugins.ts","kind":"import-statement","original":"./plugins"}],"format":"esm"}},"outputs":{"packages/core/dist/index.cjs":{"imports":[],"exports":[],"entryPoint":"packages/core/src/index.ts","inputs":{"packages/core/src/index.ts":{"bytesInOutput":2216}},"bytes":3046},"packages/core/dist/plugins.cjs":{"imports":[],"exports":[],"entryPoint":"packages/core/src/plugins.ts","inputs":{"packages/core/src/plugins.ts":{"bytesInOutput":273}},"bytes":1105}}}

@@ -1,1 +0,1 @@

{"inputs":{"packages/core/src/index.ts":{"bytes":5076,"imports":[],"format":"esm"},"packages/core/src/plugins.ts":{"bytes":8726,"imports":[],"format":"esm"}},"outputs":{"packages/core/dist/index.js":{"imports":[],"exports":["createTranslator"],"entryPoint":"packages/core/src/index.ts","inputs":{"packages/core/src/index.ts":{"bytesInOutput":2079}},"bytes":2140},"packages/core/dist/plugins.js":{"imports":[],"exports":["createPlugin"],"entryPoint":"packages/core/src/plugins.ts","inputs":{"packages/core/src/plugins.ts":{"bytesInOutput":132}},"bytes":191}}}
{"inputs":{"packages/core/src/plugins.ts":{"bytes":8946,"imports":[],"format":"esm"},"packages/core/src/index.ts":{"bytes":5315,"imports":[{"path":"packages/core/src/plugins.ts","kind":"import-statement","original":"./plugins"}],"format":"esm"}},"outputs":{"packages/core/dist/index.js":{"imports":[],"exports":["LocaleKey","TranslationDocument","createTranslator"],"entryPoint":"packages/core/src/index.ts","inputs":{"packages/core/src/index.ts":{"bytesInOutput":2079}},"bytes":2140},"packages/core/dist/plugins.js":{"imports":[],"exports":["createPlugin"],"entryPoint":"packages/core/src/plugins.ts","inputs":{"packages/core/src/plugins.ts":{"bytesInOutput":132}},"bytes":191}}}
{
"name": "intl-schematic",
"version": "1.0.0-rc.5",
"version": "1.0.0-rc.7",
"license": "MIT",

@@ -5,0 +5,0 @@ "repository": {

@@ -11,3 +11,5 @@ <h1 align="center">

A tiny framework-agnostic i18n library (1kb gzip, zero-dependency)
Bravely modern, incredibly tiny, blazingly fast.
THis is a tiny framework-agnostic i18n library (1kb gzip, zero-dependency)
that allows to localize and format strings with infinitely expandable functionality.

@@ -19,2 +21,3 @@

- 🎄 **Tree-shakable**: only take what you need;
- 🌌 **Truly universal**: one-size-fits-all solution - able to suit any project setup;
- 🎈 **Incredibly lightweight**: less than 1kb for the core package, less than 5kb for [every feature imaginable](#list).

@@ -38,2 +41,4 @@ - 🧩 **Easily integrates with UI-frameworks**: we don't play favorites here - [every framework can use this](#using-with-reactive-frameworks);

- [Using with JSON-schema](#using-with-json-schema)
- [Plugins that define a `property.schema.json`](#plugins-that-define-a-propertyschemajson)
- [No-goals](#no-goals)

@@ -138,3 +143,6 @@

that is then passed in a closure to `intl-schematic` and user-defined plugins
- [`@intl-schematic/vue`](/pacakges/vue/) - Work in progress
- [`@intl-schematic/vue`](/pacakges/vue/) - reactive adapter for [`vue`](https://vuejs.org)
- Utilizes a watcher to reactively fetch the needed document based on user locale
- [`@intl-schematic/react`](/pacakges/react/) - reactive adapter for [`react`](https://react.com)
- Utilizes a `useEffect` hook to reactively fetch the needed document based on user locale

@@ -217,22 +225,13 @@ If you want an integration for your favorite framework, feel free to contibute or [create an issue](https://github.com/Raiondesu/intl-schematic/issues/new)!

To define a JSON-schema for your translation documents, simply create a `.schema.json` file with this template:
```json
// translation.schema.json
{
"$ref": "./node_modules/intl-schematic/translation.schema.json",
"additionalProperties": {
"anyOf": [
// Definition for the default string key-value pair
{
"$ref": "./node_modules/intl-schematic/property.schema.json",
}
// Add references to more allowed types for your schema
/* for example, @intl-schematic/plugin-processors definition:
{
"$ref": "./node_modules/@intl-schematic/plugin-processors/property.schema.json"
}
*/
]
}
}
### Using the CLI
> Broken right now, see [manual definition](/packages/core/README.md#manual-definition).
To quickly define the `translation.schema.json` for your translation documents,
you can run the official [CLI](/packages/cli/) in your project's root:
```bash
npx intl-schematic init
# or provide an optional custom file name
npx intl-schematic init ./locales/my-translation.schema.json
```

@@ -247,3 +246,3 @@

"$schema": "./translation.schema.json",
"key": "Translation"
"key": "Translation of my key"
}

@@ -263,2 +262,26 @@ ```

### Manual definition
To define a JSON-schema for your translation documents, simply create a `.schema.json` file with this template:
```json
// translation.schema.json
{
"$ref": "https://unpkg.com/intl-schematic/translation.schema.json",
"additionalProperties": {
"anyOf": [
// Definition for the default string key-value pair
{
"$ref": "https://unpkg.com/intl-schematic/property.schema.json",
}
// Add references to more allowed types for your schema
/* for example, @intl-schematic/plugin-processors definition:
{
"$ref": "https://unpkg.com/@intl-schematic/plugin-processors/property.schema.json"
}
*/
]
}
}
```
### Plugins that define a `property.schema.json`

@@ -272,1 +295,11 @@

- apply custom and default processors to format the user inputs
- [`@intl-schematic/plugin-nested`](/packages/plugins/nested/)
- access nested keys in deep multi-level objects
## No-goals
Even though custom plugins can do literally anything with keys, values, and translation documents,\
the core library will **not** support:
- **Translation key nesting using dot-notation**: needlessly complicates key lookup and maintenance;
- Instead use namespaced keys or the [`nested` plugin](/packages/plugins/nested) (which supports dot-notation!);
- **String interpolation**: the library by-itself does not and will not do any processing on the strings.

@@ -8,3 +8,6 @@ import type {

PMatch,
GetPluginFromArray
InfoPerPlugin,
PluginPerPlugin,
MatchPerPlugin,
LocaleKey
} from './plugins';

@@ -17,2 +20,4 @@

export { LocaleKey, TranslationDocument } from './plugins';
/**

@@ -146,3 +151,6 @@ * Creates a translation function (commonly known as `t()` or `$t()`)

LocaleDoc extends Record<string, any>,
P extends readonly Plugin[]
P extends readonly Plugin[],
PluginsInfo extends Record<keyof PluginRegistry, any> = InfoPerPlugin<P>,
MatchInfo extends Record<keyof PluginRegistry, any> = MatchPerPlugin<P>,
PluginPerP extends Record<keyof PluginRegistry, any> = PluginPerPlugin<P>
> = {

@@ -157,16 +165,10 @@ /**

K extends LocaleKey<LocaleDoc>,
PluginKey extends keyof PluginRegistry = GetPluginNameFromArray<LocaleDoc, K, P>,
_Signature = GetPluginFromArray<LocaleDoc, K, P, PluginKey>['signature']
PluginName extends keyof PluginRegistry = GetPluginNameFromArray<LocaleDoc, K, MatchInfo>,
_Signature = PluginRegistry<LocaleDoc, K, PluginsInfo[PluginName], PluginPerP>[PluginName]['signature'],
>(
key: K,
...args: GetPluginFromArray<LocaleDoc, K, P, PluginKey>['args']
...args: PluginRegistry<LocaleDoc, K, PluginsInfo[PluginName], PluginPerP>[PluginName]['args']
): string;
}
export interface TranslationDocument {
[key: string]: unknown;
}
export type LocaleKey<LocaleDoc extends TranslationDocument> = Exclude<keyof LocaleDoc, '$schema'>;
export type ExtraPartial<I> = {

@@ -173,0 +175,0 @@ [P in keyof I]?: I[P] | null | undefined;

@@ -1,3 +0,1 @@

import type { LocaleKey } from './';
export interface PluginRecord<

@@ -162,3 +160,8 @@ Args extends unknown[] = unknown[],

export interface TranslationDocument {
[key: string]: unknown;
}
export type LocaleKey<LocaleDoc extends TranslationDocument> = Exclude<keyof LocaleDoc, '$schema'>;
export type PMatch<P extends readonly Plugin[]> = (

@@ -172,3 +175,3 @@ [] extends P ? never : P extends readonly Plugin<infer Match, any>[] ? Match : never

type MatchPerPlugin<P extends readonly Plugin[], Names extends Record<number, keyof PluginRegistry> = NamePerPlugin<P>> = {
export type MatchPerPlugin<P extends readonly Plugin[], Names extends Record<number, keyof PluginRegistry> = NamePerPlugin<P>> = {
[key in keyof Names & keyof P & `${number}` as Names[key]]: P[key] extends Plugin<infer Match, any> ? Match : never;

@@ -181,7 +184,7 @@ };

type InfoPerPlugin<P extends readonly Plugin[], Names extends Record<number, keyof PluginRegistry> = NamePerPlugin<P>> = {
export type InfoPerPlugin<P extends readonly Plugin[], Names extends Record<number, keyof PluginRegistry> = NamePerPlugin<P>> = {
[key in keyof Names & keyof P & `${number}` as Names[key]]: P[key] extends Plugin<any, any, any, infer Info> ? Info : never;
};
type PluginPerPlugin<P extends readonly Plugin[], Names extends Record<number, keyof PluginRegistry> = NamePerPlugin<P>> = {
export type PluginPerPlugin<P extends readonly Plugin[], Names extends Record<number, keyof PluginRegistry> = NamePerPlugin<P>> = {
[key in Extract<keyof Names & keyof P & `${number}`, keyof PluginRegistry> as Names[key]]: P[key] extends Plugin ? P[key] : never;

@@ -205,4 +208,4 @@ };

K extends LocaleKey<LocaleDoc>,
P extends readonly Plugin[]
> = KeysOfType<MatchPerPlugin<P>, LocaleDoc[K]>;
MatchPerP extends Record<keyof PluginRegistry, any>
> = KeysOfType<MatchPerP, LocaleDoc[K]> & string;

@@ -216,6 +219,6 @@ /**

K extends LocaleKey<LocaleDoc>,
P extends readonly Plugin[],
PluginKey extends keyof PluginRegistry,
PluginsInfo extends Record<keyof PluginRegistry, any> = InfoPerPlugin<P>,
> = PluginRegistry<LocaleDoc, K, PluginsInfo[PluginKey], PluginPerPlugin<P>>[PluginKey];
PluginsInfo extends Record<keyof PluginRegistry, any>,
Plugins extends Record<keyof PluginRegistry, any>,
> = PluginRegistry<LocaleDoc, K, PluginsInfo[PluginKey], Plugins>[PluginKey] extends infer R extends PluginRecord ? R : never;

@@ -222,0 +225,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