react-native-divkit 0.1.0-alpha.1

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.
Files changed (322) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +340 -0
  3. package/dist/DivKit.d.ts +68 -0
  4. package/dist/DivKit.d.ts.map +1 -0
  5. package/dist/DivKit.js +400 -0
  6. package/dist/DivKit.js.map +1 -0
  7. package/dist/actions/array.d.ts +8 -0
  8. package/dist/actions/array.d.ts.map +1 -0
  9. package/dist/actions/array.js +139 -0
  10. package/dist/actions/array.js.map +1 -0
  11. package/dist/actions/copyToClipboard.d.ts +22 -0
  12. package/dist/actions/copyToClipboard.d.ts.map +1 -0
  13. package/dist/actions/copyToClipboard.js +63 -0
  14. package/dist/actions/copyToClipboard.js.map +1 -0
  15. package/dist/actions/dict.d.ts +6 -0
  16. package/dist/actions/dict.d.ts.map +1 -0
  17. package/dist/actions/dict.js +58 -0
  18. package/dist/actions/dict.js.map +1 -0
  19. package/dist/actions/index.d.ts +11 -0
  20. package/dist/actions/index.d.ts.map +1 -0
  21. package/dist/actions/index.js +11 -0
  22. package/dist/actions/index.js.map +1 -0
  23. package/dist/actions/updateStructure.d.ts +6 -0
  24. package/dist/actions/updateStructure.d.ts.map +1 -0
  25. package/dist/actions/updateStructure.js +116 -0
  26. package/dist/actions/updateStructure.js.map +1 -0
  27. package/dist/components/DivComponent.d.ts +29 -0
  28. package/dist/components/DivComponent.d.ts.map +1 -0
  29. package/dist/components/DivComponent.js +62 -0
  30. package/dist/components/DivComponent.js.map +1 -0
  31. package/dist/components/container/DivContainer.d.ts +26 -0
  32. package/dist/components/container/DivContainer.d.ts.map +1 -0
  33. package/dist/components/container/DivContainer.js +172 -0
  34. package/dist/components/container/DivContainer.js.map +1 -0
  35. package/dist/components/container/index.d.ts +3 -0
  36. package/dist/components/container/index.d.ts.map +1 -0
  37. package/dist/components/container/index.js +2 -0
  38. package/dist/components/container/index.js.map +1 -0
  39. package/dist/components/image/DivImage.d.ts +29 -0
  40. package/dist/components/image/DivImage.d.ts.map +1 -0
  41. package/dist/components/image/DivImage.js +122 -0
  42. package/dist/components/image/DivImage.js.map +1 -0
  43. package/dist/components/image/index.d.ts +3 -0
  44. package/dist/components/image/index.d.ts.map +1 -0
  45. package/dist/components/image/index.js +2 -0
  46. package/dist/components/image/index.js.map +1 -0
  47. package/dist/components/index.d.ts +14 -0
  48. package/dist/components/index.d.ts.map +1 -0
  49. package/dist/components/index.js +11 -0
  50. package/dist/components/index.js.map +1 -0
  51. package/dist/components/state/DivState.d.ts +26 -0
  52. package/dist/components/state/DivState.d.ts.map +1 -0
  53. package/dist/components/state/DivState.js +121 -0
  54. package/dist/components/state/DivState.js.map +1 -0
  55. package/dist/components/state/index.d.ts +3 -0
  56. package/dist/components/state/index.d.ts.map +1 -0
  57. package/dist/components/state/index.js +2 -0
  58. package/dist/components/state/index.js.map +1 -0
  59. package/dist/components/text/DivText.d.ts +28 -0
  60. package/dist/components/text/DivText.d.ts.map +1 -0
  61. package/dist/components/text/DivText.js +143 -0
  62. package/dist/components/text/DivText.js.map +1 -0
  63. package/dist/components/text/index.d.ts +3 -0
  64. package/dist/components/text/index.d.ts.map +1 -0
  65. package/dist/components/text/index.js +2 -0
  66. package/dist/components/text/index.js.map +1 -0
  67. package/dist/components/utilities/Outer.d.ts +17 -0
  68. package/dist/components/utilities/Outer.d.ts.map +1 -0
  69. package/dist/components/utilities/Outer.js +210 -0
  70. package/dist/components/utilities/Outer.js.map +1 -0
  71. package/dist/components/utilities/Unknown.d.ts +11 -0
  72. package/dist/components/utilities/Unknown.d.ts.map +1 -0
  73. package/dist/components/utilities/Unknown.js +50 -0
  74. package/dist/components/utilities/Unknown.js.map +1 -0
  75. package/dist/components/utilities/index.d.ts +5 -0
  76. package/dist/components/utilities/index.d.ts.map +1 -0
  77. package/dist/components/utilities/index.js +3 -0
  78. package/dist/components/utilities/index.js.map +1 -0
  79. package/dist/context/ActionContext.d.ts +25 -0
  80. package/dist/context/ActionContext.d.ts.map +1 -0
  81. package/dist/context/ActionContext.js +20 -0
  82. package/dist/context/ActionContext.js.map +1 -0
  83. package/dist/context/DivKitContext.d.ts +33 -0
  84. package/dist/context/DivKitContext.d.ts.map +1 -0
  85. package/dist/context/DivKitContext.js +14 -0
  86. package/dist/context/DivKitContext.js.map +1 -0
  87. package/dist/context/EnabledContext.d.ts +31 -0
  88. package/dist/context/EnabledContext.d.ts.map +1 -0
  89. package/dist/context/EnabledContext.js +31 -0
  90. package/dist/context/EnabledContext.js.map +1 -0
  91. package/dist/context/StateContext.d.ts +57 -0
  92. package/dist/context/StateContext.d.ts.map +1 -0
  93. package/dist/context/StateContext.js +20 -0
  94. package/dist/context/StateContext.js.map +1 -0
  95. package/dist/context/index.d.ts +9 -0
  96. package/dist/context/index.d.ts.map +1 -0
  97. package/dist/context/index.js +9 -0
  98. package/dist/context/index.js.map +1 -0
  99. package/dist/expressions/bigint.d.ts +8 -0
  100. package/dist/expressions/bigint.d.ts.map +1 -0
  101. package/dist/expressions/bigint.js +31 -0
  102. package/dist/expressions/bigint.js.map +1 -0
  103. package/dist/expressions/const.d.ts +15 -0
  104. package/dist/expressions/const.d.ts.map +1 -0
  105. package/dist/expressions/const.js +15 -0
  106. package/dist/expressions/const.js.map +1 -0
  107. package/dist/expressions/eval.d.ts +77 -0
  108. package/dist/expressions/eval.d.ts.map +1 -0
  109. package/dist/expressions/eval.js +459 -0
  110. package/dist/expressions/eval.js.map +1 -0
  111. package/dist/expressions/expressions.d.ts +7 -0
  112. package/dist/expressions/expressions.d.ts.map +1 -0
  113. package/dist/expressions/expressions.js +3191 -0
  114. package/dist/expressions/expressions.js.map +1 -0
  115. package/dist/expressions/funcs/array.d.ts +2 -0
  116. package/dist/expressions/funcs/array.d.ts.map +1 -0
  117. package/dist/expressions/funcs/array.js +381 -0
  118. package/dist/expressions/funcs/array.js.map +1 -0
  119. package/dist/expressions/funcs/colors.d.ts +2 -0
  120. package/dist/expressions/funcs/colors.d.ts.map +1 -0
  121. package/dist/expressions/funcs/colors.js +75 -0
  122. package/dist/expressions/funcs/colors.js.map +1 -0
  123. package/dist/expressions/funcs/customFuncs.d.ts +8 -0
  124. package/dist/expressions/funcs/customFuncs.d.ts.map +1 -0
  125. package/dist/expressions/funcs/customFuncs.js +114 -0
  126. package/dist/expressions/funcs/customFuncs.js.map +1 -0
  127. package/dist/expressions/funcs/datetime.d.ts +2 -0
  128. package/dist/expressions/funcs/datetime.d.ts.map +1 -0
  129. package/dist/expressions/funcs/datetime.js +182 -0
  130. package/dist/expressions/funcs/datetime.js.map +1 -0
  131. package/dist/expressions/funcs/dict.d.ts +2 -0
  132. package/dist/expressions/funcs/dict.d.ts.map +1 -0
  133. package/dist/expressions/funcs/dict.js +170 -0
  134. package/dist/expressions/funcs/dict.js.map +1 -0
  135. package/dist/expressions/funcs/funcs.d.ts +80 -0
  136. package/dist/expressions/funcs/funcs.d.ts.map +1 -0
  137. package/dist/expressions/funcs/funcs.js +146 -0
  138. package/dist/expressions/funcs/funcs.js.map +1 -0
  139. package/dist/expressions/funcs/index.d.ts +2 -0
  140. package/dist/expressions/funcs/index.d.ts.map +1 -0
  141. package/dist/expressions/funcs/index.js +23 -0
  142. package/dist/expressions/funcs/index.js.map +1 -0
  143. package/dist/expressions/funcs/interval.d.ts +2 -0
  144. package/dist/expressions/funcs/interval.d.ts.map +1 -0
  145. package/dist/expressions/funcs/interval.js +61 -0
  146. package/dist/expressions/funcs/interval.js.map +1 -0
  147. package/dist/expressions/funcs/math.d.ts +2 -0
  148. package/dist/expressions/funcs/math.d.ts.map +1 -0
  149. package/dist/expressions/funcs/math.js +324 -0
  150. package/dist/expressions/funcs/math.js.map +1 -0
  151. package/dist/expressions/funcs/std.d.ts +2 -0
  152. package/dist/expressions/funcs/std.d.ts.map +1 -0
  153. package/dist/expressions/funcs/std.js +293 -0
  154. package/dist/expressions/funcs/std.js.map +1 -0
  155. package/dist/expressions/funcs/stored.d.ts +4 -0
  156. package/dist/expressions/funcs/stored.d.ts.map +1 -0
  157. package/dist/expressions/funcs/stored.js +62 -0
  158. package/dist/expressions/funcs/stored.js.map +1 -0
  159. package/dist/expressions/funcs/strings.d.ts +2 -0
  160. package/dist/expressions/funcs/strings.d.ts.map +1 -0
  161. package/dist/expressions/funcs/strings.js +158 -0
  162. package/dist/expressions/funcs/strings.js.map +1 -0
  163. package/dist/expressions/funcs/trigonometry.d.ts +2 -0
  164. package/dist/expressions/funcs/trigonometry.d.ts.map +1 -0
  165. package/dist/expressions/funcs/trigonometry.js +92 -0
  166. package/dist/expressions/funcs/trigonometry.js.map +1 -0
  167. package/dist/expressions/json.d.ts +18 -0
  168. package/dist/expressions/json.d.ts.map +1 -0
  169. package/dist/expressions/json.js +271 -0
  170. package/dist/expressions/json.js.map +1 -0
  171. package/dist/expressions/parserCache.d.ts +4 -0
  172. package/dist/expressions/parserCache.d.ts.map +1 -0
  173. package/dist/expressions/parserCache.js +23 -0
  174. package/dist/expressions/parserCache.js.map +1 -0
  175. package/dist/expressions/simpleUnescapeString.d.ts +2 -0
  176. package/dist/expressions/simpleUnescapeString.d.ts.map +1 -0
  177. package/dist/expressions/simpleUnescapeString.js +61 -0
  178. package/dist/expressions/simpleUnescapeString.js.map +1 -0
  179. package/dist/expressions/utils.d.ts +29 -0
  180. package/dist/expressions/utils.d.ts.map +1 -0
  181. package/dist/expressions/utils.js +236 -0
  182. package/dist/expressions/utils.js.map +1 -0
  183. package/dist/expressions/variable.d.ts +82 -0
  184. package/dist/expressions/variable.d.ts.map +1 -0
  185. package/dist/expressions/variable.js +337 -0
  186. package/dist/expressions/variable.js.map +1 -0
  187. package/dist/expressions/walk.d.ts +7 -0
  188. package/dist/expressions/walk.d.ts.map +1 -0
  189. package/dist/expressions/walk.js +39 -0
  190. package/dist/expressions/walk.js.map +1 -0
  191. package/dist/hooks/index.d.ts +8 -0
  192. package/dist/hooks/index.d.ts.map +1 -0
  193. package/dist/hooks/index.js +11 -0
  194. package/dist/hooks/index.js.map +1 -0
  195. package/dist/hooks/useAction.d.ts +102 -0
  196. package/dist/hooks/useAction.d.ts.map +1 -0
  197. package/dist/hooks/useAction.js +116 -0
  198. package/dist/hooks/useAction.js.map +1 -0
  199. package/dist/hooks/useDerivedFromVars.d.ts +72 -0
  200. package/dist/hooks/useDerivedFromVars.d.ts.map +1 -0
  201. package/dist/hooks/useDerivedFromVars.js +100 -0
  202. package/dist/hooks/useDerivedFromVars.js.map +1 -0
  203. package/dist/hooks/useVariable.d.ts +86 -0
  204. package/dist/hooks/useVariable.d.ts.map +1 -0
  205. package/dist/hooks/useVariable.js +130 -0
  206. package/dist/hooks/useVariable.js.map +1 -0
  207. package/dist/index.d.ts +30 -0
  208. package/dist/index.d.ts.map +1 -0
  209. package/dist/index.js +28 -0
  210. package/dist/index.js.map +1 -0
  211. package/dist/stores/createObservable.d.ts +38 -0
  212. package/dist/stores/createObservable.d.ts.map +1 -0
  213. package/dist/stores/createObservable.js +49 -0
  214. package/dist/stores/createObservable.js.map +1 -0
  215. package/dist/utils/applyTemplate.d.ts +8 -0
  216. package/dist/utils/applyTemplate.d.ts.map +1 -0
  217. package/dist/utils/applyTemplate.js +94 -0
  218. package/dist/utils/applyTemplate.js.map +1 -0
  219. package/dist/utils/correctColor.d.ts +18 -0
  220. package/dist/utils/correctColor.d.ts.map +1 -0
  221. package/dist/utils/correctColor.js +79 -0
  222. package/dist/utils/correctColor.js.map +1 -0
  223. package/dist/utils/escapeRegExp.d.ts +2 -0
  224. package/dist/utils/escapeRegExp.d.ts.map +1 -0
  225. package/dist/utils/escapeRegExp.js +4 -0
  226. package/dist/utils/escapeRegExp.js.map +1 -0
  227. package/dist/utils/formatDate.d.ts +6 -0
  228. package/dist/utils/formatDate.d.ts.map +1 -0
  229. package/dist/utils/formatDate.js +325 -0
  230. package/dist/utils/formatDate.js.map +1 -0
  231. package/dist/utils/padLeft.d.ts +2 -0
  232. package/dist/utils/padLeft.d.ts.map +1 -0
  233. package/dist/utils/padLeft.js +7 -0
  234. package/dist/utils/padLeft.js.map +1 -0
  235. package/dist/utils/uniq.d.ts +2 -0
  236. package/dist/utils/uniq.d.ts.map +1 -0
  237. package/dist/utils/uniq.js +4 -0
  238. package/dist/utils/uniq.js.map +1 -0
  239. package/dist/utils/wrapError.d.ts +10 -0
  240. package/dist/utils/wrapError.d.ts.map +1 -0
  241. package/dist/utils/wrapError.js +9 -0
  242. package/dist/utils/wrapError.js.map +1 -0
  243. package/package.json +58 -0
  244. package/src/DivKit.tsx +542 -0
  245. package/src/actions/array.ts +170 -0
  246. package/src/actions/copyToClipboard.ts +82 -0
  247. package/src/actions/dict.ts +71 -0
  248. package/src/actions/index.ts +11 -0
  249. package/src/actions/updateStructure.ts +134 -0
  250. package/src/components/DivComponent.tsx +75 -0
  251. package/src/components/README.md +230 -0
  252. package/src/components/container/DivContainer.tsx +222 -0
  253. package/src/components/container/index.ts +2 -0
  254. package/src/components/image/DivImage.tsx +172 -0
  255. package/src/components/image/index.ts +2 -0
  256. package/src/components/index.ts +20 -0
  257. package/src/components/state/DivState.tsx +146 -0
  258. package/src/components/state/index.ts +2 -0
  259. package/src/components/text/DivText.tsx +186 -0
  260. package/src/components/text/index.ts +2 -0
  261. package/src/components/utilities/Outer.tsx +239 -0
  262. package/src/components/utilities/README.md +175 -0
  263. package/src/components/utilities/Unknown.tsx +60 -0
  264. package/src/components/utilities/index.ts +4 -0
  265. package/src/context/ActionContext.tsx +37 -0
  266. package/src/context/DivKitContext.tsx +54 -0
  267. package/src/context/EnabledContext.tsx +50 -0
  268. package/src/context/StateContext.tsx +75 -0
  269. package/src/context/index.ts +33 -0
  270. package/src/expressions/ast.d.ts +101 -0
  271. package/src/expressions/bigint.ts +38 -0
  272. package/src/expressions/const.ts +16 -0
  273. package/src/expressions/eval.ts +669 -0
  274. package/src/expressions/expressions.peggy +235 -0
  275. package/src/expressions/expressions.ts +2854 -0
  276. package/src/expressions/funcs/array.ts +412 -0
  277. package/src/expressions/funcs/colors.ts +100 -0
  278. package/src/expressions/funcs/customFuncs.ts +139 -0
  279. package/src/expressions/funcs/datetime.ts +232 -0
  280. package/src/expressions/funcs/dict.ts +207 -0
  281. package/src/expressions/funcs/funcs.ts +323 -0
  282. package/src/expressions/funcs/index.ts +23 -0
  283. package/src/expressions/funcs/interval.ts +76 -0
  284. package/src/expressions/funcs/math.ts +395 -0
  285. package/src/expressions/funcs/std.ts +392 -0
  286. package/src/expressions/funcs/stored.ts +62 -0
  287. package/src/expressions/funcs/strings.ts +200 -0
  288. package/src/expressions/funcs/trigonometry.ts +108 -0
  289. package/src/expressions/json.ts +367 -0
  290. package/src/expressions/parserCache.ts +32 -0
  291. package/src/expressions/simpleUnescapeString.ts +57 -0
  292. package/src/expressions/utils.ts +271 -0
  293. package/src/expressions/variable.ts +429 -0
  294. package/src/expressions/walk.ts +43 -0
  295. package/src/hooks/README.md +265 -0
  296. package/src/hooks/index.ts +28 -0
  297. package/src/hooks/useAction.ts +152 -0
  298. package/src/hooks/useDerivedFromVars.ts +187 -0
  299. package/src/hooks/useVariable.ts +157 -0
  300. package/src/index.ts +97 -0
  301. package/src/stores/createObservable.ts +64 -0
  302. package/src/types/alignment.d.ts +13 -0
  303. package/src/types/background.d.ts +71 -0
  304. package/src/types/base.d.ts +224 -0
  305. package/src/types/border.d.ts +46 -0
  306. package/src/types/componentContext.d.ts +98 -0
  307. package/src/types/container.d.ts +40 -0
  308. package/src/types/edgeInserts.d.ts +9 -0
  309. package/src/types/general.d.ts +3 -0
  310. package/src/types/image.d.ts +33 -0
  311. package/src/types/imageScale.d.ts +1 -0
  312. package/src/types/layoutParams.d.ts +27 -0
  313. package/src/types/sizes.d.ts +37 -0
  314. package/src/types/state.d.ts +19 -0
  315. package/src/types/text.d.ts +126 -0
  316. package/src/utils/applyTemplate.ts +145 -0
  317. package/src/utils/correctColor.ts +102 -0
  318. package/src/utils/escapeRegExp.ts +3 -0
  319. package/src/utils/formatDate.ts +385 -0
  320. package/src/utils/padLeft.ts +6 -0
  321. package/src/utils/uniq.ts +3 -0
  322. package/src/utils/wrapError.ts +21 -0
package/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
package/README.md ADDED
@@ -0,0 +1,340 @@
1
+ # react-native-divkit
2
+
3
+ DivKit renderer for React Native - Server-driven UI framework.
4
+
5
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
6
+ [![npm version](https://img.shields.io/npm/v/react-native-divkit.svg)](https://www.npmjs.com/package/react-native-divkit)
7
+
8
+ ## Overview
9
+
10
+ DivKit is a server-driven UI framework that allows you to define UI layouts in JSON and render them natively. This React Native implementation is based on the [DivKit Web](../web/divkit/) implementation, reusing the expression engine and adapting components for React Native.
11
+
12
+ ## Status
13
+
14
+ **MVP Version 0.1.0-alpha**
15
+
16
+ | Feature | Status |
17
+ |---------|--------|
18
+ | Text component | ✅ Complete |
19
+ | Container component | ✅ Complete |
20
+ | Image component | ✅ Complete |
21
+ | State component | ✅ Complete |
22
+ | Variable system | ✅ Complete |
23
+ | Expression engine | ✅ Complete |
24
+ | Action handlers | ✅ Complete |
25
+ | Template resolution | ✅ Complete |
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ npm install react-native-divkit
31
+ ```
32
+
33
+ ### Optional Dependencies
34
+
35
+ For enhanced functionality, install these optional packages:
36
+
37
+ ```bash
38
+ # Optimized image loading with caching
39
+ npm install react-native-fast-image
40
+
41
+ # Gradient support (backgrounds)
42
+ npm install react-native-linear-gradient
43
+
44
+ # Clipboard support
45
+ npm install @react-native-clipboard/clipboard
46
+ ```
47
+
48
+ ## Quick Start
49
+
50
+ ```tsx
51
+ import { DivKit } from 'react-native-divkit';
52
+
53
+ const divKitJson = {
54
+ card: {
55
+ log_id: 'hello_world',
56
+ states: [{
57
+ state_id: 0,
58
+ div: {
59
+ type: 'text',
60
+ text: 'Hello, @{name}!',
61
+ font_size: 24,
62
+ text_color: '#000000',
63
+ text_alignment_horizontal: 'center'
64
+ }
65
+ }],
66
+ variables: [{
67
+ type: 'string',
68
+ name: 'name',
69
+ value: 'World'
70
+ }]
71
+ }
72
+ };
73
+
74
+ export default function App() {
75
+ return (
76
+ <DivKit
77
+ data={divKitJson}
78
+ onStat={(stat) => console.log('Stat:', stat.type, stat.action.log_id)}
79
+ onCustomAction={(action) => console.log('Custom action:', action.url)}
80
+ onError={(error) => console.error('Error:', error.message)}
81
+ />
82
+ );
83
+ }
84
+ ```
85
+
86
+ ## Components
87
+
88
+ ### Text
89
+
90
+ ```json
91
+ {
92
+ "type": "text",
93
+ "text": "Hello World",
94
+ "font_size": 16,
95
+ "font_weight": "bold",
96
+ "text_color": "#000000",
97
+ "text_alignment_horizontal": "center",
98
+ "max_lines": 2
99
+ }
100
+ ```
101
+
102
+ ### Container
103
+
104
+ ```json
105
+ {
106
+ "type": "container",
107
+ "orientation": "vertical",
108
+ "items": [
109
+ { "type": "text", "text": "Item 1" },
110
+ { "type": "text", "text": "Item 2" }
111
+ ],
112
+ "content_alignment_horizontal": "center"
113
+ }
114
+ ```
115
+
116
+ ### Image
117
+
118
+ ```json
119
+ {
120
+ "type": "image",
121
+ "image_url": "https://example.com/image.png",
122
+ "scale": "fill",
123
+ "width": { "type": "fixed", "value": 200 },
124
+ "height": { "type": "fixed", "value": 150 }
125
+ }
126
+ ```
127
+
128
+ ### State
129
+
130
+ ```json
131
+ {
132
+ "type": "state",
133
+ "id": "my_state",
134
+ "default_state_id": "state1",
135
+ "states": [
136
+ {
137
+ "state_id": "state1",
138
+ "div": { "type": "text", "text": "State 1" }
139
+ },
140
+ {
141
+ "state_id": "state2",
142
+ "div": { "type": "text", "text": "State 2" }
143
+ }
144
+ ]
145
+ }
146
+ ```
147
+
148
+ ## Variables
149
+
150
+ Define variables in your JSON:
151
+
152
+ ```json
153
+ {
154
+ "card": {
155
+ "variables": [
156
+ { "type": "string", "name": "userName", "value": "World" },
157
+ { "type": "integer", "name": "counter", "value": 0 },
158
+ { "type": "color", "name": "textColor", "value": "#FF0000" },
159
+ { "type": "boolean", "name": "isActive", "value": true }
160
+ ]
161
+ }
162
+ }
163
+ ```
164
+
165
+ Use variables in expressions:
166
+
167
+ ```json
168
+ {
169
+ "type": "text",
170
+ "text": "Hello, @{userName}!",
171
+ "text_color": "@{textColor}"
172
+ }
173
+ ```
174
+
175
+ ### Variable Types
176
+
177
+ | Type | Description | Example |
178
+ |------|-------------|---------|
179
+ | `string` | Text value | `"Hello"` |
180
+ | `integer` | Whole number | `42` |
181
+ | `number` | Decimal number | `3.14` |
182
+ | `boolean` | True/false | `true` |
183
+ | `color` | Color value | `"#FF5500"` |
184
+ | `url` | URL string | `"https://..."` |
185
+ | `dict` | Key-value object | `{"key": "value"}` |
186
+ | `array` | List of values | `[1, 2, 3]` |
187
+
188
+ ## Actions
189
+
190
+ Actions are triggered by user interaction:
191
+
192
+ ```json
193
+ {
194
+ "type": "text",
195
+ "text": "Tap me",
196
+ "actions": [{
197
+ "log_id": "button_tap",
198
+ "url": "divkit://custom_action"
199
+ }]
200
+ }
201
+ ```
202
+
203
+ ### Typed Actions
204
+
205
+ #### set_variable
206
+
207
+ ```json
208
+ {
209
+ "typed": {
210
+ "type": "set_variable",
211
+ "variable_name": "counter",
212
+ "value": { "type": "integer", "value": 10 }
213
+ }
214
+ }
215
+ ```
216
+
217
+ #### set_state
218
+
219
+ ```json
220
+ {
221
+ "typed": {
222
+ "type": "set_state",
223
+ "state_id": "my_state",
224
+ "temporary_state_id": "state2"
225
+ }
226
+ }
227
+ ```
228
+
229
+ ## Props
230
+
231
+ | Prop | Type | Required | Description |
232
+ |------|------|----------|-------------|
233
+ | `data` | `DivJson` | Yes | DivKit JSON data |
234
+ | `onStat` | `(stat) => void` | No | Statistics callback |
235
+ | `onCustomAction` | `(action) => void` | No | Custom action handler |
236
+ | `onError` | `(error) => void` | No | Error handler |
237
+ | `direction` | `'ltr' \| 'rtl'` | No | Text direction (default: `'ltr'`) |
238
+ | `platform` | `'desktop' \| 'touch'` | No | Platform type (default: `'touch'`) |
239
+ | `style` | `ViewStyle` | No | Container style |
240
+
241
+ ## Hooks
242
+
243
+ For advanced usage, you can use hooks directly:
244
+
245
+ ```tsx
246
+ import {
247
+ useDivKitContext,
248
+ useVariable,
249
+ useVariableState,
250
+ useAction
251
+ } from 'react-native-divkit';
252
+
253
+ function MyComponent() {
254
+ const { setVariable } = useDivKitContext();
255
+ const counter = useVariable('counter');
256
+
257
+ return (
258
+ <View>
259
+ <Text>Count: {counter}</Text>
260
+ <Button
261
+ onPress={() => setVariable('counter', counter + 1)}
262
+ title="Increment"
263
+ />
264
+ </View>
265
+ );
266
+ }
267
+ ```
268
+
269
+ ## Examples
270
+
271
+ See the [examples/BasicExample](examples/BasicExample/) directory for a complete React Native app demonstrating all features.
272
+
273
+ ```bash
274
+ cd examples/BasicExample
275
+ npm install
276
+ npm run ios # or npm run android
277
+ ```
278
+
279
+ ## Documentation
280
+
281
+ - [API Reference](docs/API.md) - Complete API documentation
282
+ - [Migration Guide](docs/MIGRATION.md) - Migrating from Web version
283
+ - [Architecture](docs/ARCHITECTURE.md) - Internal architecture
284
+
285
+ ## Not Included in MVP
286
+
287
+ The following features are planned for future versions:
288
+
289
+ - Gallery, Pager, Slider, Tabs
290
+ - Input, Select, Switch
291
+ - Video, Lottie animations
292
+ - Text ranges, complex gradients
293
+ - Advanced transitions and animations
294
+ - Custom components API
295
+
296
+ ## Architecture
297
+
298
+ This library is based on DivKit Web (TypeScript + Svelte):
299
+
300
+ | Component | Reuse |
301
+ |-----------|-------|
302
+ | Expression engine | 100% copied |
303
+ | Type definitions | 100% copied |
304
+ | Utilities | ~90% adapted |
305
+ | Components | ~20% (rewritten for RN) |
306
+ | Context system | New (React-specific) |
307
+
308
+ ## Development
309
+
310
+ ```bash
311
+ # Install dependencies
312
+ npm install
313
+
314
+ # Build PEG parser
315
+ npm run build:peggy
316
+
317
+ # Type check
318
+ npm run typecheck
319
+
320
+ # Lint
321
+ npm run lint
322
+
323
+ # Build
324
+ npm run build
325
+
326
+ # Test
327
+ npm test
328
+ ```
329
+
330
+ ## Contributing
331
+
332
+ 1. Fork the repository
333
+ 2. Create a feature branch
334
+ 3. Make your changes
335
+ 4. Add tests
336
+ 5. Submit a pull request
337
+
338
+ ## License
339
+
340
+ Apache 2.0
@@ -0,0 +1,68 @@
1
+ /**
2
+ * DivKit - Main entry point component for React Native
3
+ *
4
+ * Based on Root.svelte from Web implementation
5
+ * Provides context setup, variable management, and component rendering
6
+ *
7
+ * MVP Scope:
8
+ * - 4 basic components (Text, Container, Image, State)
9
+ * - Variable system with reactive updates
10
+ * - Action execution
11
+ * - Template resolution
12
+ *
13
+ * Deferred for post-MVP:
14
+ * - Timers
15
+ * - Variable triggers
16
+ * - Complex animations
17
+ * - Custom components
18
+ * - Extensions
19
+ */
20
+ import React from 'react';
21
+ import { type ViewStyle } from 'react-native';
22
+ import type { Action, DivJson, Direction } from '../typings/common';
23
+ import { type WrappedError } from './utils/wrapError';
24
+ /**
25
+ * Callback for logging statistics
26
+ */
27
+ export type StatCallback = (stat: {
28
+ type: string;
29
+ action: Action;
30
+ }) => void;
31
+ /**
32
+ * Callback for custom actions (actions with URLs)
33
+ */
34
+ export type CustomActionCallback = (action: Action & {
35
+ url: string;
36
+ }) => void;
37
+ /**
38
+ * Callback for errors
39
+ */
40
+ export type ErrorCallback = (error: WrappedError) => void;
41
+ /**
42
+ * Props for DivKit component
43
+ */
44
+ export interface DivKitProps {
45
+ /** DivKit JSON data */
46
+ data: Partial<DivJson>;
47
+ /** Callback for statistics/logging */
48
+ onStat?: StatCallback;
49
+ /** Callback for custom actions */
50
+ onCustomAction?: CustomActionCallback;
51
+ /** Callback for errors */
52
+ onError?: ErrorCallback;
53
+ /** Text direction (default: 'ltr') */
54
+ direction?: Direction;
55
+ /** Platform type (default: 'touch' for mobile) */
56
+ platform?: 'desktop' | 'touch';
57
+ /** Custom style for the root container */
58
+ style?: ViewStyle;
59
+ /** Component ID (for debugging) */
60
+ id?: string;
61
+ }
62
+ /**
63
+ * DivKit - Main component
64
+ *
65
+ * Renders DivKit JSON as React Native components
66
+ */
67
+ export declare function DivKit({ data, onStat, onCustomAction, onError, direction, platform, style, id }: DivKitProps): React.JSX.Element;
68
+ //# sourceMappingURL=DivKit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DivKit.d.ts","sourceRoot":"","sources":["../src/DivKit.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAuC,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAoB,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAe,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAUjF,OAAO,EAAa,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAOjE;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAClB,KAAK,IAAI,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,KAAK,IAAI,CAAC;AAE9E;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,uBAAuB;IACvB,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAEvB,sCAAsC;IACtC,MAAM,CAAC,EAAE,YAAY,CAAC;IAEtB,kCAAkC;IAClC,cAAc,CAAC,EAAE,oBAAoB,CAAC;IAEtC,0BAA0B;IAC1B,OAAO,CAAC,EAAE,aAAa,CAAC;IAExB,sCAAsC;IACtC,SAAS,CAAC,EAAE,SAAS,CAAC;IAEtB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAE/B,0CAA0C;IAC1C,KAAK,CAAC,EAAE,SAAS,CAAC;IAElB,mCAAmC;IACnC,EAAE,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,EACnB,IAAI,EACJ,MAAM,EACN,cAAc,EACd,OAAO,EACP,SAAiB,EACjB,QAAkB,EAClB,KAAK,EACL,EAAW,EACd,EAAE,WAAW,qBAmbb"}