@divkitframework/divkit 3.0.0 → 4.0.0-patched-b90e1be4804b31ad27014160a0600d42cf9887d6

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 CHANGED
@@ -1,9 +1,11 @@
1
1
  ## DivKit for the Web
2
2
 
3
+ ![client code size](https://img.shields.io/badge/client%20lib%20minified&brotli-47.7%20KB-brightgreen)
4
+
3
5
  ### Installation
4
6
 
5
7
  ```
6
- npm i @divkit/divkit --save
8
+ npm i @divkitframework/divkit --save
7
9
  ```
8
10
 
9
11
  ### Usage
@@ -21,7 +23,7 @@ JS code can be bundled with various strategies. Basically you need to answer a f
21
23
  On the server side there is `/server` module:
22
24
 
23
25
  ```js
24
- import {render} from '@divkit/divkit/server';
26
+ import {render} from '@divkitframework/divkit/server';
25
27
 
26
28
  const html = render({
27
29
  id: 'smth',
@@ -38,7 +40,7 @@ const html = render({
38
40
  Then use `/client-hydratable` on client to hydrate server-side html::
39
41
 
40
42
  ```js
41
- import {render} from '@divkit/divkit/client-hydratable';
43
+ import {render} from '@divkitframework/divkit/client-hydratable';
42
44
 
43
45
  render({
44
46
  id: 'smth',
@@ -59,7 +61,7 @@ render({
59
61
  For the client-only usage there is `/client` module. The size of this module is slightly smaller than `/client-hydratable`.
60
62
 
61
63
  ```js
62
- import {render} from '@divkit/divkit/client';
64
+ import {render} from '@divkitframework/divkit/client';
63
65
 
64
66
  render({
65
67
  id: 'smth',
@@ -102,7 +104,7 @@ ES modules can be used in the browser directly without any build:
102
104
 
103
105
  ```html
104
106
  <script type="module">
105
- import {render} from './node_modules/@divkit/divkit/dist/esm/client.mjs';
107
+ import {render} from './node_modules/@divkitframework/divkit/dist/esm/client.mjs';
106
108
 
107
109
  render({
108
110
  id: 'smth',
@@ -121,7 +123,7 @@ ES modules can be used in the browser directly without any build:
121
123
  ### Use in the browser via global variables without build:
122
124
 
123
125
  ```html
124
- <script src="./node_modules/@divkit/divkit/dist/browser/client.js"></script>
126
+ <script src="./node_modules/@divkitframework/divkit/dist/browser/client.js"></script>
125
127
  <script>
126
128
  window.Ya.Divkit.render({
127
129
  id: 'smth',
@@ -137,6 +139,12 @@ ES modules can be used in the browser directly without any build:
137
139
  </script>
138
140
  ```
139
141
 
142
+ ### Usage with React
143
+
144
+ There is a separate package for that.
145
+
146
+ [React component package](../divkit-react)
147
+
140
148
  ### TypeScript and types
141
149
 
142
150
  All modules have typescript definitions (client, client-hydratable and server), so typescript will load them at any use.
@@ -155,7 +163,7 @@ Node.js
155
163
  Node.js >= 8
156
164
  ```
157
165
 
158
- ### API
166
+ ### API: render
159
167
 
160
168
  All 3 exported modules have an exported function `render`. This function works in a similar way on client and server.
161
169
 
@@ -163,8 +171,6 @@ All 3 exported modules have an exported function `render`. This function works i
163
171
 
164
172
  Instead, `/server` module will return an HTML string.
165
173
 
166
- ### Options
167
-
168
174
  #### id
169
175
 
170
176
  String, required.
@@ -280,3 +286,38 @@ Divjson along with the `card` and `templates` can contain a `palette` property w
280
286
  }
281
287
  }
282
288
  ```
289
+
290
+ ### API: other
291
+
292
+ #### Variables
293
+
294
+ ```js
295
+ import {createVariable, createGlobalVariablesController, render} from '@divkit/divkit';
296
+
297
+ // Custom variable outside of DivJson
298
+ const variable = createVariable('name', 'string', 'val');
299
+
300
+ variable.subscribe(newVal => {
301
+ console.log(newVal);
302
+ });
303
+
304
+ // Custom scope for variables
305
+ const controller = createGlobalVariablesController();
306
+
307
+ controller.setVariable(variable);
308
+
309
+ render(({
310
+ id: 'smth',
311
+ target: document.querySelector('#root'),
312
+ json: {},
313
+ globalVariablesController: controller
314
+ });
315
+ ```
316
+
317
+ ---
318
+
319
+ [Documentation](https://divkit.tech/doc). [Medium tutorial](https://medium.com/p/cad519252f0f). [Habr tutorial](https://habr.com/ru/company/yandex/blog/683886/).
320
+
321
+ Telegram: [News](https://t.me/divkit_news) | [English-speaking chat](https://t.me/divkit_community_en) | [Чат на русском](https://t.me/divkit_community_ru).
322
+
323
+ [Twitter](https://twitter.com/DivKitFramework)