@divkitframework/divkit 24.2.0 → 24.3.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": "24.2.0",
3
+ "version": "24.3.0",
4
4
  "description": "DivKit for the web",
5
5
  "keywords": [
6
6
  "server-driven-ui",
@@ -112,6 +112,7 @@
112
112
  "jest": "28.1.3",
113
113
  "jest-environment-jsdom": "28.0.0",
114
114
  "jest-html-reporter": "3.6.0",
115
+ "lottie-web": "5.11.0",
115
116
  "mini-css-extract-plugin": "2.6.1",
116
117
  "peggy": "2.0.1",
117
118
  "postcss": "8.4.14",
@@ -7,7 +7,8 @@ import type {
7
7
  ComponentCallback,
8
8
  CustomActionCallback,
9
9
  Theme,
10
- Customization
10
+ Customization,
11
+ DivExtensionClass
11
12
  } from './common';
12
13
  import type { GlobalVariablesController, Variable } from './variables';
13
14
  import type { WrappedError } from './common';
@@ -30,12 +31,18 @@ export function render(opts: {
30
31
  platform?: Platform;
31
32
  customization?: Customization;
32
33
  builtinProtocols?: string[];
34
+ extensions?: Map<string, DivExtensionClass>;
33
35
  /** EXPERIMENTAL SUPPORT */
34
36
  theme?: Theme;
35
37
  }): DivkitDebugInstance;
36
38
 
37
39
  export { createVariable, createGlobalVariablesController } from './variables';
38
40
 
41
+ export {
42
+ SizeProvider,
43
+ lottieExtensionBuilder
44
+ } from './extensions';
45
+
39
46
  export interface EvalValueBase {
40
47
  type: string;
41
48
  value: unknown;
@@ -6,7 +6,8 @@ import type {
6
6
  Platform,
7
7
  CustomActionCallback,
8
8
  Theme,
9
- Customization
9
+ Customization,
10
+ DivExtensionClass
10
11
  } from './common';
11
12
  import type { GlobalVariablesController } from './variables';
12
13
 
@@ -23,8 +24,14 @@ export function render(opts: {
23
24
  platform?: Platform;
24
25
  customization?: Customization;
25
26
  builtinProtocols?: string[];
27
+ extensions?: Map<string, DivExtensionClass>;
26
28
  /** EXPERIMENTAL SUPPORT */
27
29
  theme?: Theme;
28
30
  }): DivkitInstance;
29
31
 
30
32
  export { createVariable, createGlobalVariablesController } from './variables';
33
+
34
+ export {
35
+ SizeProvider,
36
+ lottieExtensionBuilder
37
+ } from './extensions';
@@ -6,7 +6,8 @@ import type {
6
6
  Platform,
7
7
  CustomActionCallback,
8
8
  Theme,
9
- Customization
9
+ Customization,
10
+ DivExtensionClass
10
11
  } from './common';
11
12
  import type { GlobalVariablesController } from './variables';
12
13
 
@@ -22,8 +23,14 @@ export function render(opts: {
22
23
  platform?: Platform;
23
24
  customization?: Customization;
24
25
  builtinProtocols?: string[];
26
+ extensions?: Map<string, DivExtensionClass>;
25
27
  /** EXPERIMENTAL SUPPORT */
26
28
  theme?: Theme;
27
29
  }): DivkitInstance;
28
30
 
29
31
  export { createVariable, createGlobalVariablesController } from './variables';
32
+
33
+ export {
34
+ SizeProvider,
35
+ lottieExtensionBuilder
36
+ } from './extensions';
@@ -1,3 +1,5 @@
1
+ import type { Variable } from './variables';
2
+
1
3
  export type BooleanInt = 0 | 1 | false | true;
2
4
 
3
5
  export type TemplateContext = Record<string, unknown>;
@@ -151,3 +153,19 @@ export interface Customization {
151
153
  galleryLeftClass?: string;
152
154
  galleryRightClass?: string;
153
155
  }
156
+
157
+ export interface DivExtensionContext {
158
+ variables: Map<string, Variable>;
159
+ logError(error: WrappedError): void;
160
+ }
161
+
162
+ export interface DivExtensionClass {
163
+ new(params: object): DivExtension;
164
+ prototype: DivExtension;
165
+ }
166
+
167
+ export interface DivExtension {
168
+ mountView?(node: HTMLElement, context: DivExtensionContext): void;
169
+
170
+ unmountView?(node: HTMLElement, context: DivExtensionContext): void;
171
+ }
@@ -0,0 +1,40 @@
1
+ import type { DivExtension } from './common';
2
+
3
+ export class SizeProvider implements DivExtension {}
4
+
5
+ declare class Lottie implements DivExtension {}
6
+
7
+ interface Params {
8
+ lottie_url?: string;
9
+ lottie_json?: object;
10
+ repeat_count?: number;
11
+ repeat_mode?: 'restart' | 'reverse';
12
+ }
13
+
14
+ interface AnimationItem {
15
+ totalFrames: number;
16
+
17
+ addEventListener(type: string, cb: () => void): void;
18
+ destroy(): void;
19
+ stop(): void;
20
+ setDirection(direction: number): void;
21
+ goToAndPlay(value: number, isFrame?: boolean): void;
22
+ }
23
+
24
+ interface LoadAnimationParamsWidthPath {
25
+ container: HTMLElement;
26
+ path: string;
27
+ renderer: 'svg' | 'html' | 'canvas';
28
+ loop: boolean | number | undefined;
29
+ }
30
+
31
+ interface LoadAnimationParamsWidthData {
32
+ container: HTMLElement;
33
+ animationData: any;
34
+ renderer: 'svg' | 'html' | 'canvas';
35
+ loop: boolean | number | undefined;
36
+ }
37
+
38
+ type LoadAnimation = (opts: LoadAnimationParamsWidthPath | LoadAnimationParamsWidthData) => AnimationItem;
39
+
40
+ export function lottieExtensionBuilder(loadAnimation: LoadAnimation): typeof Lottie;