@divkitframework/divkit 28.13.0 → 29.0.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@divkitframework/divkit",
3
- "version": "28.13.0",
3
+ "version": "29.0.0",
4
4
  "description": "DivKit for the web",
5
5
  "keywords": [
6
6
  "server-driven-ui",
@@ -18,6 +18,7 @@ import type { CustomComponentDescription } from './custom';
18
18
 
19
19
  export interface DivkitDebugInstance extends DivkitInstance {
20
20
  getDebugVariables(): Map<string, Variable>;
21
+ getDebugAllVariables(): Map<string, Variable>;
21
22
  }
22
23
 
23
24
  export function render(opts: {
@@ -228,14 +228,11 @@ export type StatCallback = (details: {
228
228
  export type CustomActionCallback = (action: Action & { url: string }) => void;
229
229
 
230
230
  export type ComponentCallback = (details: {
231
- type: 'mount';
231
+ type: 'mount' | 'update' | 'destroy';
232
232
  node: HTMLElement;
233
233
  json: DivBase;
234
234
  origJson: DivBase | undefined;
235
235
  templateContext: TemplateContext;
236
- } | {
237
- type: 'destroy';
238
- node: HTMLElement;
239
236
  }) => void;
240
237
 
241
238
  export interface WrappedError extends Error {
@@ -256,7 +253,10 @@ export type FetchInit = RequestInit | ((url: string) => RequestInit);
256
253
  export interface DivkitInstance {
257
254
  $destroy(): void;
258
255
  execAction(action: Action | VisibilityAction): void;
256
+ /** @deprecated */
259
257
  setTheme(theme: Theme): void;
258
+ /** Experimental */
259
+ setData(json: DivJson): void;
260
260
  }
261
261
 
262
262
  export type Platform = 'desktop' | 'touch' | 'auto';
@@ -266,6 +266,8 @@ export type Theme = 'system' | 'light' | 'dark';
266
266
  export interface Customization {
267
267
  galleryLeftClass?: string;
268
268
  galleryRightClass?: string;
269
+ pagerLeftClass?: string;
270
+ pagerRightClass?: string;
269
271
  }
270
272
 
271
273
  export interface DivExtensionContext {
@@ -1,35 +1,51 @@
1
1
  /* eslint-disable @typescript-eslint/no-empty-interface */
2
2
 
3
- import type { Subscriber, Unsubscriber } from 'svelte/store';
3
+ type Subscriber<T> = (value: T) => void;
4
+ type Unsubscriber = () => void;
4
5
 
5
- export interface Variable<T = any> {
6
+ export type VariableType = 'string' | 'number' | 'integer' | 'boolean' | 'color' | 'url' | 'dict' | 'array';
7
+ export type VariableValue = string | number | bigint | boolean | null | undefined | object | unknown[];
8
+
9
+ export declare class Variable<ValueType = any, TypeName = VariableType> {
10
+ constructor(name: string, value: ValueType);
6
11
  getName(): string;
7
- subscribe(cb: Subscriber<T>): Unsubscriber;
12
+ subscribe(cb: Subscriber<ValueType>): Unsubscriber;
8
13
  set(val: string): void;
9
- setValue(value: T): void;
10
- getValue(): T;
11
- getType(): string;
14
+ setValue(val: ValueType): void;
15
+ getValue(): ValueType;
16
+ getType(): TypeName;
12
17
  }
13
18
 
14
- export interface StringVariable extends Variable<string> {}
15
- export interface NumberVariable extends Variable<number> {}
16
- export interface IntegerVariable extends Variable<number> {}
17
- export interface BooleanVariable extends Variable<number> {}
18
- export interface ColorVariable extends Variable<string> {}
19
- export interface UrlVariable extends Variable<string> {}
20
- export interface DictVariable extends Variable<object> {}
21
- export interface ArrayVariable extends Variable<unknown[]> {}
19
+ export declare class StringVariable extends Variable<string, 'string'> {}
20
+ export declare class IntegerVariable extends Variable<number | bigint, 'integer'> {}
21
+ export declare class NumberVariable extends Variable<number, 'number'> {}
22
+ export declare class BooleanVariable extends Variable<number, 'boolean'> {}
23
+ export declare class ColorVariable extends Variable<string, 'color'> {}
24
+ export declare class UrlVariable extends Variable<string, 'url'> {}
25
+ export declare class DictVariable extends Variable<object, 'dict'> {}
26
+ export declare class ArrayVariable extends Variable<unknown[], 'array'> {}
27
+
28
+ declare const TYPE_TO_CLASS: {
29
+ string: typeof StringVariable;
30
+ number: typeof NumberVariable;
31
+ integer: typeof IntegerVariable;
32
+ boolean: typeof BooleanVariable;
33
+ color: typeof ColorVariable;
34
+ url: typeof UrlVariable;
35
+ dict: typeof DictVariable;
36
+ array: typeof ArrayVariable;
37
+ };
22
38
 
23
39
  export type AnyVariable = StringVariable | NumberVariable | IntegerVariable |
24
40
  BooleanVariable | ColorVariable | UrlVariable | DictVariable | ArrayVariable;
25
41
 
26
- export type VariableType = 'string' | 'number' | 'integer' | 'boolean' | 'color' | 'url' | 'dict' | 'array';
27
-
28
42
  export interface GlobalVariablesController {
29
43
  setVariable(variable: AnyVariable): void;
30
44
  getVariable(variableName: string): AnyVariable | undefined;
45
+ list(): IterableIterator<Variable>;
31
46
  }
32
47
 
33
- export function createVariable(variableName: string, type: VariableType, value: unknown): AnyVariable;
48
+ export function createVariable<T extends VariableType>(variableName: string, type: T, value: unknown):
49
+ InstanceType<typeof TYPE_TO_CLASS[T]>;
34
50
 
35
51
  export function createGlobalVariablesController(): GlobalVariablesController;