@lipsjs/lips 0.0.3 → 0.0.4
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/README.md +4 -2
- package/dist/lips.min.js +2 -2
- package/dist/lips.min.js.map +13 -12
- package/dist/test.component.min.js +23 -25
- package/dist/test.component.min.js.map +17 -16
- package/dist/test.stress.min.js +6 -6
- package/dist/test.stress.min.js.map +13 -12
- package/dist/types/component.d.ts +3 -1
- package/dist/types/i18n/formatters.d.ts +3 -0
- package/dist/types/i18n/index.d.ts +19 -0
- package/dist/types/index.d.ts +11 -4
- package/dist/types/lips.d.ts +5 -1
- package/dist/types/metrics.d.ts +2 -0
- package/dist/types/syntax/for.d.ts +1 -1
- package/dist/types/utils.d.ts +2 -0
- package/package.json +1 -1
|
@@ -16,10 +16,11 @@ export default class Component<MT extends Metavars> extends Events {
|
|
|
16
16
|
context: MT['Context'];
|
|
17
17
|
__name__: string;
|
|
18
18
|
__path__: string;
|
|
19
|
+
private __lang__;
|
|
19
20
|
private __template__;
|
|
20
21
|
private __previous;
|
|
21
22
|
private __macros;
|
|
22
|
-
private
|
|
23
|
+
private __i18nDeps;
|
|
23
24
|
private __renderCache;
|
|
24
25
|
FGUD: FGUDependencies;
|
|
25
26
|
private PCC;
|
|
@@ -73,6 +74,7 @@ export default class Component<MT extends Metavars> extends Events {
|
|
|
73
74
|
private __shouldUpdate__;
|
|
74
75
|
private __updateDepNodes__;
|
|
75
76
|
private __updateVarDepNodes__;
|
|
77
|
+
private __updateI18nDepNodes__;
|
|
76
78
|
appendTo(arg: Cash | string): this;
|
|
77
79
|
prependTo(arg: Cash | string): this;
|
|
78
80
|
replaceWith(arg: Cash | string): this;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Dictionary } from '..';
|
|
2
|
+
export default class I18N {
|
|
3
|
+
private currentLang;
|
|
4
|
+
private DICTIONARIES;
|
|
5
|
+
set lang(value: string);
|
|
6
|
+
get lang(): string;
|
|
7
|
+
setDictionary(id: string, dico: Dictionary): void;
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
translate(text: string, lang?: string): {
|
|
12
|
+
text: string;
|
|
13
|
+
lang: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
format(reference: string, params: Record<string, any>, local?: string): string | undefined;
|
|
19
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -18,7 +18,12 @@ export type Variable = {
|
|
|
18
18
|
}
|
|
19
19
|
export type VariableSet = Record<string, Variable>
|
|
20
20
|
|
|
21
|
-
export type
|
|
21
|
+
export type I18nVariant = Record<string, string>
|
|
22
|
+
export type I18nFormat = {
|
|
23
|
+
type: string
|
|
24
|
+
value: string | I18nVariant | Record<string, string | I18nVariant>
|
|
25
|
+
}
|
|
26
|
+
export type Dictionary = Record<string, string | I18nFormat | I18nVariant>
|
|
22
27
|
|
|
23
28
|
export type DeclarationTagType = 'nexted' | 'child'
|
|
24
29
|
export type DeclarationTag = {
|
|
@@ -74,8 +79,6 @@ export type ComponentOptions = {
|
|
|
74
79
|
lips: Lips
|
|
75
80
|
debug?: boolean
|
|
76
81
|
prepath?: string
|
|
77
|
-
enableTemplateCache?: boolean
|
|
78
|
-
enableSmartDiff?: boolean
|
|
79
82
|
}
|
|
80
83
|
export type LipsConfig<Context extends Object> = {
|
|
81
84
|
debug?: boolean
|
|
@@ -123,6 +126,11 @@ export interface FGUSync {
|
|
|
123
126
|
memo?: VariableSet
|
|
124
127
|
cleanup?: () => void
|
|
125
128
|
}
|
|
129
|
+
export interface I18nDependency {
|
|
130
|
+
$fragment: Cash
|
|
131
|
+
memo: VariableSet
|
|
132
|
+
update: ( memo: VariableSet, by?: string ) => FGUSync | void
|
|
133
|
+
}
|
|
126
134
|
export interface FGUDependency {
|
|
127
135
|
path: string
|
|
128
136
|
$fragment: Cash | null
|
|
@@ -130,7 +138,6 @@ export interface FGUDependency {
|
|
|
130
138
|
haslet?: boolean
|
|
131
139
|
batch?: boolean
|
|
132
140
|
syntax?: boolean
|
|
133
|
-
translate?: boolean
|
|
134
141
|
partial?: string[]
|
|
135
142
|
memo: VariableSet
|
|
136
143
|
update: ( memo: VariableSet, by?: string ) => FGUSync | void
|
package/dist/types/lips.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export default class Lips<Context extends Object = {}> {
|
|
|
13
13
|
i18n: I18N;
|
|
14
14
|
watcher: DWS<any>;
|
|
15
15
|
IUC: IUC;
|
|
16
|
+
private __setLang;
|
|
17
|
+
private __getLang;
|
|
16
18
|
private __setContext;
|
|
17
19
|
private __getContext;
|
|
18
20
|
constructor(config?: LipsConfig<Context>);
|
|
@@ -22,9 +24,11 @@ export default class Lips<Context extends Object = {}> {
|
|
|
22
24
|
import<MT extends Metavars>(pathname: string): Template<MT>;
|
|
23
25
|
render<MT extends Metavars>(name: string, template: Template<MT>, input?: MT['Input']): Component<MT>;
|
|
24
26
|
root<MT extends Metavars>(template: Template<MT>, selector: string): Component<any>;
|
|
25
|
-
|
|
27
|
+
setLanguage(lang: string): void;
|
|
28
|
+
getLanguage(): string;
|
|
26
29
|
setContext(arg: Context | string, value?: any): void;
|
|
27
30
|
getContext(): Context;
|
|
28
31
|
useContext<P extends Context>(fields: (keyof P)[], fn: (context: P) => void): void;
|
|
32
|
+
useTranslator(support: string | string[], fn: (lang: string) => void): void;
|
|
29
33
|
dispose(): void;
|
|
30
34
|
}
|
package/dist/types/metrics.d.ts
CHANGED
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export declare const ROOT_PATH = "#0";
|
|
2
|
+
export declare const I18N_ATTR_FLAG = "i18n";
|
|
2
3
|
export declare const SYNCTAX_VAR_FLAG = "syn:";
|
|
3
4
|
export declare const FUNCTION_ATTR_FLAG = "fn:";
|
|
4
5
|
export declare const EVENT_LISTENER_FLAG = "on-";
|
|
5
6
|
export declare const SPREAD_VAR_PATTERN: RegExp;
|
|
6
7
|
export declare const ARGUMENT_VAR_PATTERN: RegExp;
|
|
8
|
+
export declare const INTERPOLATE_PATTERN: RegExp;
|
|
7
9
|
export declare const META_ATTRIBUTES: string[];
|
|
8
10
|
/**
|
|
9
11
|
* Deep difference checker with support for Map, Set,
|