@lipsjs/lips 0.0.2 → 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.
@@ -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 __translations;
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,3 @@
1
+ import type { I18nFormat } from '..';
2
+ declare const _default: (type: string, reference: string, value: I18nFormat["value"], params: Record<string, any>, variant?: string) => string | undefined;
3
+ export default _default;
@@ -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
+ }
@@ -18,7 +18,12 @@ export type Variable = {
18
18
  }
19
19
  export type VariableSet = Record<string, Variable>
20
20
 
21
- export type LanguageDictionary = Record<string, Record<string, string> | string>
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
@@ -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
- language(lang: string): void;
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
  }
@@ -13,6 +13,8 @@ export interface MetricStats {
13
13
  domInsertsCount: number;
14
14
  domUpdatesCount: number;
15
15
  domRemovalsCount: number;
16
+ i18nTrackCount: number;
17
+ i18nUpdateCount: number;
16
18
  dependencyTrackCount: number;
17
19
  dependencyUpdateCount: number;
18
20
  batchSize: number;
@@ -9,7 +9,7 @@ export interface State {
9
9
  argvlist: Record<string, any>[] | null;
10
10
  }
11
11
  export interface Static {
12
- lastInput: any;
12
+ lastIn: any;
13
13
  processingBatch: boolean;
14
14
  }
15
15
  export declare const declaration: Declaration;
@@ -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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lipsjs/lips",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "Fast, Lightweight Reactive UI Framework",
5
5
  "main": "./dist/lips.min.js",
6
6
  "files": [