Skip to content

Commit cb72d1b

Browse files
committed
Update dist
1 parent 1fe60d0 commit cb72d1b

File tree

14 files changed

+72
-34
lines changed

14 files changed

+72
-34
lines changed

packages/intl-schematic/dist/es/index.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/intl-schematic/dist/es/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ export const createTranslator = (getLocaleDocument, currentLocaleId, options = {
1212
const { processors = {}, plugins = [], } = options;
1313
const translate = function (key, input, parameter) {
1414
const doc = getLocaleDocument();
15-
const callHook = (hook, value, processor, _input = input) => callPluginsHook(hook, value, _input, parameter, currentLocaleId, key, doc, processor) ?? key;
15+
const callHook = (hook, value, _input = input) => callPluginsHook(hook, value, _input, parameter, currentLocaleId, key, doc) ?? key;
1616
if (!doc) {
1717
return callHook('docNotFound');
1818
}
1919
const currentKey = doc[key];
20-
if (typeof currentKey === 'undefined') {
21-
return callHook('keyNotFound');
20+
if (currentKey == null) {
21+
return callHook('keyNotFound', key);
2222
}
2323
// Process a plain-string
24-
if (typeof currentKey !== 'object' && typeof currentKey !== 'function') {
25-
return currentKey ? callHook('keyProcessed', currentKey) : callHook('keyNotFound');
24+
if (typeof currentKey === 'string') {
25+
return callHook('keyProcessed', currentKey);
2626
}
2727
// Process a function record
2828
// TODO: move into a plugin

packages/intl-schematic/dist/es/plugins/array-record.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ export declare const ArrayRecordPlugin: {
33
keyFound(this: {
44
translate: import("..").TranslationProxy<any, any>;
55
callHook: (hook: "initPlugin" | "docNotFound" | "keyNotFound" | "keyFound" | "processorFound" | "processorNotFound" | "keyProcessed" | "keyNotProcessed", value?: unknown) => string | undefined;
6-
}, key: unknown, input: import("..").LocaleInputParameter<any, string, any> | undefined, parameter: import("..").LocaleOptionsParameter<any, string, any> | undefined): string | undefined;
6+
}, key: unknown, input: import("..").LocaleInputParameter<any, string, any> | undefined, parameter: import("..").LocaleOptionsParameter<any, string, any> | undefined, _: () => Intl.Locale | undefined, recKey: string): string | undefined;
77
};
88
//# sourceMappingURL=array-record.d.ts.map

packages/intl-schematic/dist/es/plugins/array-record.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createPlugin } from './core';
22
export const ArrayRecordPlugin = createPlugin({
33
name: 'ArrayRecord',
4-
keyFound(key, input, parameter) {
4+
keyFound(key, input, parameter, _, recKey) {
55
// Process an array record (["Some text", "translation-key"])
66
if (Array.isArray(key)) {
77
const result = key.reduce((arr, refK) => {

packages/intl-schematic/dist/es/plugins/core.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Translation, LocaleInputParameter, LocaleKey, TranslationProxy, LocaleO
22
export type PluginHook<Locale extends Translation, Processors> = (this: {
33
translate: TranslationProxy<Locale, Processors>;
44
callHook: (hook: PluginHooks, value?: unknown) => string | undefined;
5-
}, value: unknown | undefined, input: LocaleInputParameter<Locale, LocaleKey<Locale>, Processors> | undefined, parameter: LocaleOptionsParameter<Locale, LocaleKey<Locale>, Processors> | undefined, currentLocaleId: () => Intl.Locale | undefined, key: string, translationDocument: Locale | undefined, initiatorPlugin: string | undefined) => string | undefined;
5+
}, value: unknown | undefined, input: LocaleInputParameter<Locale, LocaleKey<Locale>, Processors> | undefined, parameter: LocaleOptionsParameter<Locale, LocaleKey<Locale>, Processors> | undefined, currentLocaleId: () => Intl.Locale | undefined, key: string, translationDocument: Locale | undefined, initiatorPlugin?: string | undefined) => string | undefined;
66
export interface Plugin<Locale extends Translation, Processors> {
77
name: string;
88
initPlugin?: PluginHook<Locale, Processors>;
@@ -15,7 +15,7 @@ export interface Plugin<Locale extends Translation, Processors> {
1515
keyNotProcessed?: PluginHook<Locale, Processors>;
1616
}
1717
type PluginHooks = keyof Omit<Plugin<any, any>, 'name'>;
18-
export declare const callPlugins: <Locale extends import("../ts.schema").TranslationModule, Processors>(translate: TranslationProxy<Locale, Processors>, plugins?: Plugin<Locale, Processors>[]) => (hook: PluginHooks, value: unknown, input: LocaleInputParameter<Locale, Extract<Exclude<keyof Locale, "$schema">, string>, Processors> | undefined, parameter: LocaleOptionsParameter<Locale, Extract<Exclude<keyof Locale, "$schema">, string>, Processors> | undefined, currentLocaleId: () => Intl.Locale | undefined, key: string, translationDocument: Locale | undefined, initiatorPlugin: string | undefined) => string | undefined;
18+
export declare const callPlugins: <Locale extends import("../ts.schema").TranslationModule, Processors>(translate: TranslationProxy<Locale, Processors>, plugins?: Plugin<Locale, Processors>[]) => (hook: PluginHooks, value: unknown, input: LocaleInputParameter<Locale, Extract<Exclude<keyof Locale, "$schema">, string>, Processors> | undefined, parameter: LocaleOptionsParameter<Locale, Extract<Exclude<keyof Locale, "$schema">, string>, Processors> | undefined, currentLocaleId: () => Intl.Locale | undefined, key: string, translationDocument: Locale | undefined, initiatorPlugin?: string | undefined) => string | undefined;
1919
export declare const createPlugin: <T extends Plugin<any, any>>(plugin: T) => T;
2020
export {};
2121
//# sourceMappingURL=core.d.ts.map

packages/intl-schematic/dist/es/plugins/core.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/intl-schematic/dist/es/plugins/core.js

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,31 @@ export const callPlugins = (translate, plugins = []) => {
1313
}
1414
return obj;
1515
}, {});
16-
const callPluginsForHook = (hook, ...[value, input, parameter, key, currentLocaleId, doc, initiatorPlugin]) => String(pluginsPerHook[hook]?.reduce((val, pluginHook) => (pluginHook?.call({
17-
callHook(hook, value) {
18-
return callPluginsForHook(hook, value, input, parameter, key, currentLocaleId, doc, pluginHook.name);
19-
},
20-
translate
21-
}, val, input, parameter, key, currentLocaleId, doc, initiatorPlugin) ?? val), value) ?? value);
16+
const callPluginsForHook = (hook, ...[value, input, parameter, currentLocaleId, key, doc, initiatorPlugin]) => {
17+
if (!pluginsPerHook[hook]) {
18+
return !value ? undefined : String(value);
19+
}
20+
let val = value;
21+
for (const pluginHook of pluginsPerHook[hook]) {
22+
const pluginResult = pluginHook.call({
23+
callHook(_hook, value) {
24+
if (hook === _hook) {
25+
// Prevent recursion
26+
return;
27+
}
28+
return callPluginsForHook(_hook, value, input, parameter, currentLocaleId, key, doc, pluginHook.name);
29+
},
30+
translate
31+
}, val, input, parameter, currentLocaleId, key, doc, initiatorPlugin);
32+
if (typeof pluginResult === 'string') {
33+
return pluginResult;
34+
}
35+
if (pluginResult != null) {
36+
val = pluginResult;
37+
}
38+
}
39+
return !val ? undefined : String(val);
40+
};
2241
return callPluginsForHook;
2342
};
2443
export const createPlugin = (plugin) => plugin;

packages/intl-schematic/dist/esnext/index.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/intl-schematic/dist/esnext/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ export const createTranslator = (getLocaleDocument, currentLocaleId, options = {
1212
const { processors = {}, plugins = [], } = options;
1313
const translate = function (key, input, parameter) {
1414
const doc = getLocaleDocument();
15-
const callHook = (hook, value, processor, _input = input) => callPluginsHook(hook, value, _input, parameter, currentLocaleId, key, doc, processor) ?? key;
15+
const callHook = (hook, value, _input = input) => callPluginsHook(hook, value, _input, parameter, currentLocaleId, key, doc) ?? key;
1616
if (!doc) {
1717
return callHook('docNotFound');
1818
}
1919
const currentKey = doc[key];
20-
if (typeof currentKey === 'undefined') {
21-
return callHook('keyNotFound');
20+
if (currentKey == null) {
21+
return callHook('keyNotFound', key);
2222
}
2323
// Process a plain-string
24-
if (typeof currentKey !== 'object' && typeof currentKey !== 'function') {
25-
return currentKey ? callHook('keyProcessed', currentKey) : callHook('keyNotFound');
24+
if (typeof currentKey === 'string') {
25+
return callHook('keyProcessed', currentKey);
2626
}
2727
// Process a function record
2828
// TODO: move into a plugin

packages/intl-schematic/dist/esnext/plugins/array-record.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ export declare const ArrayRecordPlugin: {
33
keyFound(this: {
44
translate: import("..").TranslationProxy<any, any>;
55
callHook: (hook: "initPlugin" | "docNotFound" | "keyNotFound" | "keyFound" | "processorFound" | "processorNotFound" | "keyProcessed" | "keyNotProcessed", value?: unknown) => string | undefined;
6-
}, key: unknown, input: import("..").LocaleInputParameter<any, string, any> | undefined, parameter: import("..").LocaleOptionsParameter<any, string, any> | undefined): string | undefined;
6+
}, key: unknown, input: import("..").LocaleInputParameter<any, string, any> | undefined, parameter: import("..").LocaleOptionsParameter<any, string, any> | undefined, _: () => Intl.Locale | undefined, recKey: string): string | undefined;
77
};
88
//# sourceMappingURL=array-record.d.ts.map

packages/intl-schematic/dist/esnext/plugins/array-record.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createPlugin } from './core';
22
export const ArrayRecordPlugin = createPlugin({
33
name: 'ArrayRecord',
4-
keyFound(key, input, parameter) {
4+
keyFound(key, input, parameter, _, recKey) {
55
// Process an array record (["Some text", "translation-key"])
66
if (Array.isArray(key)) {
77
const result = key.reduce((arr, refK) => {

packages/intl-schematic/dist/esnext/plugins/core.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Translation, LocaleInputParameter, LocaleKey, TranslationProxy, LocaleO
22
export type PluginHook<Locale extends Translation, Processors> = (this: {
33
translate: TranslationProxy<Locale, Processors>;
44
callHook: (hook: PluginHooks, value?: unknown) => string | undefined;
5-
}, value: unknown | undefined, input: LocaleInputParameter<Locale, LocaleKey<Locale>, Processors> | undefined, parameter: LocaleOptionsParameter<Locale, LocaleKey<Locale>, Processors> | undefined, currentLocaleId: () => Intl.Locale | undefined, key: string, translationDocument: Locale | undefined, initiatorPlugin: string | undefined) => string | undefined;
5+
}, value: unknown | undefined, input: LocaleInputParameter<Locale, LocaleKey<Locale>, Processors> | undefined, parameter: LocaleOptionsParameter<Locale, LocaleKey<Locale>, Processors> | undefined, currentLocaleId: () => Intl.Locale | undefined, key: string, translationDocument: Locale | undefined, initiatorPlugin?: string | undefined) => string | undefined;
66
export interface Plugin<Locale extends Translation, Processors> {
77
name: string;
88
initPlugin?: PluginHook<Locale, Processors>;
@@ -15,7 +15,7 @@ export interface Plugin<Locale extends Translation, Processors> {
1515
keyNotProcessed?: PluginHook<Locale, Processors>;
1616
}
1717
type PluginHooks = keyof Omit<Plugin<any, any>, 'name'>;
18-
export declare const callPlugins: <Locale extends import("../ts.schema").TranslationModule, Processors>(translate: TranslationProxy<Locale, Processors>, plugins?: Plugin<Locale, Processors>[]) => (hook: PluginHooks, value: unknown, input: LocaleInputParameter<Locale, Extract<Exclude<keyof Locale, "$schema">, string>, Processors> | undefined, parameter: LocaleOptionsParameter<Locale, Extract<Exclude<keyof Locale, "$schema">, string>, Processors> | undefined, currentLocaleId: () => Intl.Locale | undefined, key: string, translationDocument: Locale | undefined, initiatorPlugin: string | undefined) => string | undefined;
18+
export declare const callPlugins: <Locale extends import("../ts.schema").TranslationModule, Processors>(translate: TranslationProxy<Locale, Processors>, plugins?: Plugin<Locale, Processors>[]) => (hook: PluginHooks, value: unknown, input: LocaleInputParameter<Locale, Extract<Exclude<keyof Locale, "$schema">, string>, Processors> | undefined, parameter: LocaleOptionsParameter<Locale, Extract<Exclude<keyof Locale, "$schema">, string>, Processors> | undefined, currentLocaleId: () => Intl.Locale | undefined, key: string, translationDocument: Locale | undefined, initiatorPlugin?: string | undefined) => string | undefined;
1919
export declare const createPlugin: <T extends Plugin<any, any>>(plugin: T) => T;
2020
export {};
2121
//# sourceMappingURL=core.d.ts.map

0 commit comments

Comments
 (0)