vona-core 5.0.114 → 5.0.115
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/dist/index.js
CHANGED
|
@@ -1691,6 +1691,53 @@ const errorsInternal = {
|
|
|
1691
1691
|
|
|
1692
1692
|
const LocaleModuleNameSeparator = '::';
|
|
1693
1693
|
|
|
1694
|
+
function $localeScope(moduleName, key, ...args) {
|
|
1695
|
+
return $makeLocaleMagic(`${moduleName}::${String(key)}`, ...args);
|
|
1696
|
+
}
|
|
1697
|
+
function $makeLocaleMagic(str, ...args) {
|
|
1698
|
+
return {
|
|
1699
|
+
toString() {
|
|
1700
|
+
return str;
|
|
1701
|
+
},
|
|
1702
|
+
toJSON() {
|
|
1703
|
+
if (!str || !str.includes(LocaleModuleNameSeparator)) return str;
|
|
1704
|
+
const app = useApp();
|
|
1705
|
+
return app.meta.text(str, ...args);
|
|
1706
|
+
}
|
|
1707
|
+
};
|
|
1708
|
+
}
|
|
1709
|
+
function text(strings, ...expressions) {
|
|
1710
|
+
return {
|
|
1711
|
+
toString() {
|
|
1712
|
+
let result = '';
|
|
1713
|
+
for (let i = 0; i < expressions.length; i++) {
|
|
1714
|
+
result += strings[i];
|
|
1715
|
+
result += expressions[i];
|
|
1716
|
+
}
|
|
1717
|
+
return result;
|
|
1718
|
+
},
|
|
1719
|
+
toJSON() {
|
|
1720
|
+
const app = useApp();
|
|
1721
|
+
let result = '';
|
|
1722
|
+
for (let i = 0; i < strings.length; i++) {
|
|
1723
|
+
result += strings[i];
|
|
1724
|
+
if (i < expressions.length) {
|
|
1725
|
+
const expression = app.meta.text(expressions[i]);
|
|
1726
|
+
if (typeof expression === 'string' || isLocaleMagic(expression)) {
|
|
1727
|
+
result += app.meta.text(expression);
|
|
1728
|
+
} else {
|
|
1729
|
+
result += expression;
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
return result;
|
|
1734
|
+
}
|
|
1735
|
+
};
|
|
1736
|
+
}
|
|
1737
|
+
function isLocaleMagic(str) {
|
|
1738
|
+
return typeof str === 'object' && cast(str).toJSON;
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1694
1741
|
class AppLocale extends BeanSimple {
|
|
1695
1742
|
get current() {
|
|
1696
1743
|
return this.ctx.locale;
|
|
@@ -1730,7 +1777,9 @@ class AppLocale extends BeanSimple {
|
|
|
1730
1777
|
}
|
|
1731
1778
|
getText(supportCustomMessage, moduleScope, locale, key, ...args) {
|
|
1732
1779
|
if (!key) return key;
|
|
1733
|
-
if (
|
|
1780
|
+
if (isLocaleMagic(key)) {
|
|
1781
|
+
return cast(key).toJSON();
|
|
1782
|
+
}
|
|
1734
1783
|
if (typeof key !== 'string') throw new Error(`${key} should be string`);
|
|
1735
1784
|
const pos = key.indexOf(LocaleModuleNameSeparator);
|
|
1736
1785
|
if (pos > -1) {
|
|
@@ -1757,22 +1806,6 @@ class BeanScopeLocale extends BeanSimple {
|
|
|
1757
1806
|
}
|
|
1758
1807
|
}
|
|
1759
1808
|
|
|
1760
|
-
function $localeScope(moduleName, key) {
|
|
1761
|
-
return $makeLocaleMagic(`${moduleName}::${String(key)}`);
|
|
1762
|
-
}
|
|
1763
|
-
function $makeLocaleMagic(str) {
|
|
1764
|
-
return {
|
|
1765
|
-
toString() {
|
|
1766
|
-
return str;
|
|
1767
|
-
},
|
|
1768
|
-
toJSON() {
|
|
1769
|
-
if (!str || !str.includes(LocaleModuleNameSeparator)) return str;
|
|
1770
|
-
const app = useApp();
|
|
1771
|
-
return app.meta.text(str);
|
|
1772
|
-
}
|
|
1773
|
-
};
|
|
1774
|
-
}
|
|
1775
|
-
|
|
1776
1809
|
const BeanModuleScope$1 = Symbol('BeanScopeScene#ModuleScope');
|
|
1777
1810
|
const BeanModuleScene = Symbol('BeanScopeScene#BeanModuleScene');
|
|
1778
1811
|
class BeanScopeScene extends BeanSimple {
|
|
@@ -3238,4 +3271,4 @@ function prepareNativeBinding(nativeBinding) {
|
|
|
3238
3271
|
|
|
3239
3272
|
zodExtendOpenApi();
|
|
3240
3273
|
|
|
3241
|
-
export { $Class, $customKey, $localeScope, $makeLocaleMagic, AppHmr, AppHmrDeps, AppLocale, AppLogger, AppMeta, AppMetadata, AppResource, AppUtil, BeanAopBase, BeanAopMethodBase, BeanBase, BeanBaseSimple, BeanContainer, BeanInfo, BeanScopeBase, BeanScopeContainer, BeanScopeError, BeanScopeErrorImpl, BeanScopeLocale, BeanScopeScene, BeanScopeUtil, BeanSimple, EnumAppEvent, ErrorClass, LocaleModuleNameSeparator, PickClassInner, ProxyDisable, SymbolBeanContainerInstances, SymbolBeanFullName, SymbolBeanInstanceKey, SymbolBeanInstancePropsLazy, SymbolCacheAopChains, SymbolCacheAopChainsKey, SymbolDecoratorBeanFullName, SymbolDecoratorBeanInfo, SymbolDecoratorProxyDisable, SymbolDecoratorUse, SymbolDecoratorVirtual, SymbolHmrStateLoad, SymbolHmrStateSave, SymbolMappedClassMetadataKeys, SymbolModuleBelong, SymbolModuleName, Use, Virtual, VonaApplication, __prepareInjectSelectorInfo, appHmrDeps, appMetadata, appResource, beanFullNameFromOnionName, bootstrap, cast, closeApp, combineConfigDefault, combineFilePathSafe, compose, copyMetadataOfClasses, copyProperties, copyPropertiesOfClasses, copySqlite3NativeBinding, createApp, createAppMaster, createBeanDecorator, createGeneralApp, createHash, deepExtend, disposeInstance, errorsInternal, filterHeaders, formatLoggerAxiosError, formatLoggerConsole, formatLoggerCtx, formatLoggerDummy, formatLoggerFilter, functionNoop, getLoggerPathPhysicalRoot, getMappedClassMetadataKeys, getPublicPathPhysicalRoot, getRuntimePathPhysicalRoot, getSqlite3DatabaseNameDefault, getSqlite3NativeBinding, instanceDesp, loadJSONFile, localeDefault, onionNameFromBeanFullName, pathToHref, polyfillDispose, prepareEnv, registerMappedClassMetadataKey, requireDynamic, retry, saveJSONFile, setMappedClassMetadataKeys, useApp, usePrepareArg, usePrepareArgs, uuidv4 };
|
|
3274
|
+
export { $Class, $customKey, $localeScope, $makeLocaleMagic, AppHmr, AppHmrDeps, AppLocale, AppLogger, AppMeta, AppMetadata, AppResource, AppUtil, BeanAopBase, BeanAopMethodBase, BeanBase, BeanBaseSimple, BeanContainer, BeanInfo, BeanScopeBase, BeanScopeContainer, BeanScopeError, BeanScopeErrorImpl, BeanScopeLocale, BeanScopeScene, BeanScopeUtil, BeanSimple, EnumAppEvent, ErrorClass, LocaleModuleNameSeparator, PickClassInner, ProxyDisable, SymbolBeanContainerInstances, SymbolBeanFullName, SymbolBeanInstanceKey, SymbolBeanInstancePropsLazy, SymbolCacheAopChains, SymbolCacheAopChainsKey, SymbolDecoratorBeanFullName, SymbolDecoratorBeanInfo, SymbolDecoratorProxyDisable, SymbolDecoratorUse, SymbolDecoratorVirtual, SymbolHmrStateLoad, SymbolHmrStateSave, SymbolMappedClassMetadataKeys, SymbolModuleBelong, SymbolModuleName, Use, Virtual, VonaApplication, __prepareInjectSelectorInfo, appHmrDeps, appMetadata, appResource, beanFullNameFromOnionName, bootstrap, cast, closeApp, combineConfigDefault, combineFilePathSafe, compose, copyMetadataOfClasses, copyProperties, copyPropertiesOfClasses, copySqlite3NativeBinding, createApp, createAppMaster, createBeanDecorator, createGeneralApp, createHash, deepExtend, disposeInstance, errorsInternal, filterHeaders, formatLoggerAxiosError, formatLoggerConsole, formatLoggerCtx, formatLoggerDummy, formatLoggerFilter, functionNoop, getLoggerPathPhysicalRoot, getMappedClassMetadataKeys, getPublicPathPhysicalRoot, getRuntimePathPhysicalRoot, getSqlite3DatabaseNameDefault, getSqlite3NativeBinding, instanceDesp, isLocaleMagic, loadJSONFile, localeDefault, onionNameFromBeanFullName, pathToHref, polyfillDispose, prepareEnv, registerMappedClassMetadataKey, requireDynamic, retry, saveJSONFile, setMappedClassMetadataKeys, text, useApp, usePrepareArg, usePrepareArgs, uuidv4 };
|
|
@@ -5,5 +5,5 @@ export declare class AppLocale extends BeanSimple {
|
|
|
5
5
|
set current(value: keyof ILocaleRecord);
|
|
6
6
|
get tz(): string | undefined;
|
|
7
7
|
set tz(value: string | undefined);
|
|
8
|
-
getText<T extends keyof ILocaleRecord>(supportCustomMessage: boolean, moduleScope: string | undefined, locale: T | undefined, key: string, ...args: any[]): string;
|
|
8
|
+
getText<T extends keyof ILocaleRecord>(supportCustomMessage: boolean, moduleScope: string | undefined, locale: T | undefined, key: string | object, ...args: any[]): string;
|
|
9
9
|
}
|
|
@@ -4,8 +4,8 @@ export interface IModuleLocale {
|
|
|
4
4
|
locale: <T extends keyof ILocaleRecord>(locale: T, ...args: any[]) => string;
|
|
5
5
|
}
|
|
6
6
|
export interface IModuleLocaleText {
|
|
7
|
-
(text: string, ...args: any[]): string;
|
|
8
|
-
locale: <T extends keyof ILocaleRecord>(locale: T, text: string, ...args: any[]) => string;
|
|
7
|
+
(text: string | object, ...args: any[]): string;
|
|
8
|
+
locale: <T extends keyof ILocaleRecord>(locale: T, text: string | object, ...args: any[]) => string;
|
|
9
9
|
}
|
|
10
10
|
export type TypeModuleLocales<T> = {
|
|
11
11
|
[prop in keyof T]: IModuleLocale;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { IBeanScopeLocale } from '../../type.ts';
|
|
2
2
|
import type { ILocaleMagic } from './type.ts';
|
|
3
|
-
export declare function $localeScope<M extends keyof IBeanScopeLocale, K extends keyof IBeanScopeLocale[M]>(moduleName: M, key: K): ILocaleMagic<`${M}::${K extends string ? K : never}`>;
|
|
4
|
-
export declare function $makeLocaleMagic<T extends string>(str: T): ILocaleMagic<T>;
|
|
3
|
+
export declare function $localeScope<M extends keyof IBeanScopeLocale, K extends keyof IBeanScopeLocale[M]>(moduleName: M, key: K, ...args: any[]): ILocaleMagic<`${M}::${K extends string ? K : never}`>;
|
|
4
|
+
export declare function $makeLocaleMagic<T extends string>(str: T, ...args: any[]): ILocaleMagic<T>;
|
|
5
|
+
export declare function text(strings: any, ...expressions: any): ILocaleMagic;
|
|
6
|
+
export declare function isLocaleMagic(str: string | object): any;
|