@react-native-motion-kit/text-motion 0.0.0-stage → 0.1.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.
Files changed (252) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/LICENSE +20 -0
  3. package/README.ko.md +698 -0
  4. package/README.md +696 -2
  5. package/lib/module/accessibility/index.js +4 -0
  6. package/lib/module/accessibility/index.js.map +1 -0
  7. package/lib/module/accessibility/policies.js +39 -0
  8. package/lib/module/accessibility/policies.js.map +1 -0
  9. package/lib/module/controls/brand.js +4 -0
  10. package/lib/module/controls/brand.js.map +1 -0
  11. package/lib/module/controls/controls.js +28 -0
  12. package/lib/module/controls/controls.js.map +1 -0
  13. package/lib/module/controls/descriptors.js +55 -0
  14. package/lib/module/controls/descriptors.js.map +1 -0
  15. package/lib/module/controls/index.js +4 -0
  16. package/lib/module/controls/index.js.map +1 -0
  17. package/lib/module/effects/compose.js +48 -0
  18. package/lib/module/effects/compose.js.map +1 -0
  19. package/lib/module/effects/fade.js +15 -0
  20. package/lib/module/effects/fade.js.map +1 -0
  21. package/lib/module/effects/index.js +12 -0
  22. package/lib/module/effects/index.js.map +1 -0
  23. package/lib/module/effects/lineReveal.js +17 -0
  24. package/lib/module/effects/lineReveal.js.map +1 -0
  25. package/lib/module/effects/pulse.js +14 -0
  26. package/lib/module/effects/pulse.js.map +1 -0
  27. package/lib/module/effects/rise.js +14 -0
  28. package/lib/module/effects/rise.js.map +1 -0
  29. package/lib/module/effects/scale.js +15 -0
  30. package/lib/module/effects/scale.js.map +1 -0
  31. package/lib/module/effects/shake.js +14 -0
  32. package/lib/module/effects/shake.js.map +1 -0
  33. package/lib/module/effects/slide.js +15 -0
  34. package/lib/module/effects/slide.js.map +1 -0
  35. package/lib/module/effects/typewriter.js +19 -0
  36. package/lib/module/effects/typewriter.js.map +1 -0
  37. package/lib/module/effects/validation.js +10 -0
  38. package/lib/module/effects/validation.js.map +1 -0
  39. package/lib/module/index.js +10 -0
  40. package/lib/module/index.js.map +1 -0
  41. package/lib/module/package.json +1 -0
  42. package/lib/module/presets/index.js +35 -0
  43. package/lib/module/presets/index.js.map +1 -0
  44. package/lib/module/recipe/component.js +60 -0
  45. package/lib/module/recipe/component.js.map +1 -0
  46. package/lib/module/recipe/defineTextMotion.js +9 -0
  47. package/lib/module/recipe/defineTextMotion.js.map +1 -0
  48. package/lib/module/recipe/descriptors.js +60 -0
  49. package/lib/module/recipe/descriptors.js.map +1 -0
  50. package/lib/module/recipe/index.js +5 -0
  51. package/lib/module/recipe/index.js.map +1 -0
  52. package/lib/module/recipe/recipe.js +163 -0
  53. package/lib/module/recipe/recipe.js.map +1 -0
  54. package/lib/module/renderers/index.js +5 -0
  55. package/lib/module/renderers/index.js.map +1 -0
  56. package/lib/module/renderers/nativeText.js +494 -0
  57. package/lib/module/renderers/nativeText.js.map +1 -0
  58. package/lib/module/renderers/nativeTextControls.js +96 -0
  59. package/lib/module/renderers/nativeTextControls.js.map +1 -0
  60. package/lib/module/renderers/nativeTextLineLayout.js +290 -0
  61. package/lib/module/renderers/nativeTextLineLayout.js.map +1 -0
  62. package/lib/module/renderers/nativeTextPlayback.js +91 -0
  63. package/lib/module/renderers/nativeTextPlayback.js.map +1 -0
  64. package/lib/module/renderers/overlayText.js +543 -0
  65. package/lib/module/renderers/overlayText.js.map +1 -0
  66. package/lib/module/renderers/overlayTextLayout.js +182 -0
  67. package/lib/module/renderers/overlayTextLayout.js.map +1 -0
  68. package/lib/module/renderers/rendererMotion.js +264 -0
  69. package/lib/module/renderers/rendererMotion.js.map +1 -0
  70. package/lib/module/split/createToken.js +19 -0
  71. package/lib/module/split/createToken.js.map +1 -0
  72. package/lib/module/split/custom.js +57 -0
  73. package/lib/module/split/custom.js.map +1 -0
  74. package/lib/module/split/graphemes.js +25 -0
  75. package/lib/module/split/graphemes.js.map +1 -0
  76. package/lib/module/split/index.js +7 -0
  77. package/lib/module/split/index.js.map +1 -0
  78. package/lib/module/split/lines.js +43 -0
  79. package/lib/module/split/lines.js.map +1 -0
  80. package/lib/module/split/segmenter.js +74 -0
  81. package/lib/module/split/segmenter.js.map +1 -0
  82. package/lib/module/split/words.js +28 -0
  83. package/lib/module/split/words.js.map +1 -0
  84. package/lib/module/timeline/index.js +7 -0
  85. package/lib/module/timeline/index.js.map +1 -0
  86. package/lib/module/timeline/parallel.js +21 -0
  87. package/lib/module/timeline/parallel.js.map +1 -0
  88. package/lib/module/timeline/sequence.js +18 -0
  89. package/lib/module/timeline/sequence.js.map +1 -0
  90. package/lib/module/timeline/stagger.js +43 -0
  91. package/lib/module/timeline/stagger.js.map +1 -0
  92. package/lib/module/timeline/validation.js +24 -0
  93. package/lib/module/timeline/validation.js.map +1 -0
  94. package/lib/module/timeline/wave.js +25 -0
  95. package/lib/module/timeline/wave.js.map +1 -0
  96. package/lib/module/types/index.js +4 -0
  97. package/lib/module/types/index.js.map +1 -0
  98. package/lib/module/types/recipe.js +4 -0
  99. package/lib/module/types/recipe.js.map +1 -0
  100. package/lib/module/types/renderer.js +27 -0
  101. package/lib/module/types/renderer.js.map +1 -0
  102. package/lib/module/types/token.js +2 -0
  103. package/lib/module/types/token.js.map +1 -0
  104. package/lib/typescript/package.json +1 -0
  105. package/lib/typescript/src/accessibility/index.d.ts +2 -0
  106. package/lib/typescript/src/accessibility/index.d.ts.map +1 -0
  107. package/lib/typescript/src/accessibility/policies.d.ts +13 -0
  108. package/lib/typescript/src/accessibility/policies.d.ts.map +1 -0
  109. package/lib/typescript/src/controls/brand.d.ts +2 -0
  110. package/lib/typescript/src/controls/brand.d.ts.map +1 -0
  111. package/lib/typescript/src/controls/controls.d.ts +28 -0
  112. package/lib/typescript/src/controls/controls.d.ts.map +1 -0
  113. package/lib/typescript/src/controls/descriptors.d.ts +14 -0
  114. package/lib/typescript/src/controls/descriptors.d.ts.map +1 -0
  115. package/lib/typescript/src/controls/index.d.ts +3 -0
  116. package/lib/typescript/src/controls/index.d.ts.map +1 -0
  117. package/lib/typescript/src/effects/compose.d.ts +11 -0
  118. package/lib/typescript/src/effects/compose.d.ts.map +1 -0
  119. package/lib/typescript/src/effects/fade.d.ts +10 -0
  120. package/lib/typescript/src/effects/fade.d.ts.map +1 -0
  121. package/lib/typescript/src/effects/index.d.ts +10 -0
  122. package/lib/typescript/src/effects/index.d.ts.map +1 -0
  123. package/lib/typescript/src/effects/lineReveal.d.ts +11 -0
  124. package/lib/typescript/src/effects/lineReveal.d.ts.map +1 -0
  125. package/lib/typescript/src/effects/pulse.d.ts +8 -0
  126. package/lib/typescript/src/effects/pulse.d.ts.map +1 -0
  127. package/lib/typescript/src/effects/rise.d.ts +8 -0
  128. package/lib/typescript/src/effects/rise.d.ts.map +1 -0
  129. package/lib/typescript/src/effects/scale.d.ts +10 -0
  130. package/lib/typescript/src/effects/scale.d.ts.map +1 -0
  131. package/lib/typescript/src/effects/shake.d.ts +8 -0
  132. package/lib/typescript/src/effects/shake.d.ts.map +1 -0
  133. package/lib/typescript/src/effects/slide.d.ts +10 -0
  134. package/lib/typescript/src/effects/slide.d.ts.map +1 -0
  135. package/lib/typescript/src/effects/typewriter.d.ts +13 -0
  136. package/lib/typescript/src/effects/typewriter.d.ts.map +1 -0
  137. package/lib/typescript/src/effects/validation.d.ts +2 -0
  138. package/lib/typescript/src/effects/validation.d.ts.map +1 -0
  139. package/lib/typescript/src/index.d.ts +15 -0
  140. package/lib/typescript/src/index.d.ts.map +1 -0
  141. package/lib/typescript/src/presets/index.d.ts +10 -0
  142. package/lib/typescript/src/presets/index.d.ts.map +1 -0
  143. package/lib/typescript/src/recipe/component.d.ts +3 -0
  144. package/lib/typescript/src/recipe/component.d.ts.map +1 -0
  145. package/lib/typescript/src/recipe/defineTextMotion.d.ts +4 -0
  146. package/lib/typescript/src/recipe/defineTextMotion.d.ts.map +1 -0
  147. package/lib/typescript/src/recipe/descriptors.d.ts +15 -0
  148. package/lib/typescript/src/recipe/descriptors.d.ts.map +1 -0
  149. package/lib/typescript/src/recipe/index.d.ts +4 -0
  150. package/lib/typescript/src/recipe/index.d.ts.map +1 -0
  151. package/lib/typescript/src/recipe/recipe.d.ts +67 -0
  152. package/lib/typescript/src/recipe/recipe.d.ts.map +1 -0
  153. package/lib/typescript/src/renderers/index.d.ts +3 -0
  154. package/lib/typescript/src/renderers/index.d.ts.map +1 -0
  155. package/lib/typescript/src/renderers/nativeText.d.ts +13 -0
  156. package/lib/typescript/src/renderers/nativeText.d.ts.map +1 -0
  157. package/lib/typescript/src/renderers/nativeTextControls.d.ts +16 -0
  158. package/lib/typescript/src/renderers/nativeTextControls.d.ts.map +1 -0
  159. package/lib/typescript/src/renderers/nativeTextLineLayout.d.ts +84 -0
  160. package/lib/typescript/src/renderers/nativeTextLineLayout.d.ts.map +1 -0
  161. package/lib/typescript/src/renderers/nativeTextPlayback.d.ts +21 -0
  162. package/lib/typescript/src/renderers/nativeTextPlayback.d.ts.map +1 -0
  163. package/lib/typescript/src/renderers/overlayText.d.ts +13 -0
  164. package/lib/typescript/src/renderers/overlayText.d.ts.map +1 -0
  165. package/lib/typescript/src/renderers/overlayTextLayout.d.ts +36 -0
  166. package/lib/typescript/src/renderers/overlayTextLayout.d.ts.map +1 -0
  167. package/lib/typescript/src/renderers/rendererMotion.d.ts +53 -0
  168. package/lib/typescript/src/renderers/rendererMotion.d.ts.map +1 -0
  169. package/lib/typescript/src/split/createToken.d.ts +11 -0
  170. package/lib/typescript/src/split/createToken.d.ts.map +1 -0
  171. package/lib/typescript/src/split/custom.d.ts +17 -0
  172. package/lib/typescript/src/split/custom.d.ts.map +1 -0
  173. package/lib/typescript/src/split/graphemes.d.ts +4 -0
  174. package/lib/typescript/src/split/graphemes.d.ts.map +1 -0
  175. package/lib/typescript/src/split/index.d.ts +5 -0
  176. package/lib/typescript/src/split/index.d.ts.map +1 -0
  177. package/lib/typescript/src/split/lines.d.ts +4 -0
  178. package/lib/typescript/src/split/lines.d.ts.map +1 -0
  179. package/lib/typescript/src/split/segmenter.d.ts +18 -0
  180. package/lib/typescript/src/split/segmenter.d.ts.map +1 -0
  181. package/lib/typescript/src/split/words.d.ts +4 -0
  182. package/lib/typescript/src/split/words.d.ts.map +1 -0
  183. package/lib/typescript/src/timeline/index.d.ts +5 -0
  184. package/lib/typescript/src/timeline/index.d.ts.map +1 -0
  185. package/lib/typescript/src/timeline/parallel.d.ts +4 -0
  186. package/lib/typescript/src/timeline/parallel.d.ts.map +1 -0
  187. package/lib/typescript/src/timeline/sequence.d.ts +4 -0
  188. package/lib/typescript/src/timeline/sequence.d.ts.map +1 -0
  189. package/lib/typescript/src/timeline/stagger.d.ts +11 -0
  190. package/lib/typescript/src/timeline/stagger.d.ts.map +1 -0
  191. package/lib/typescript/src/timeline/validation.d.ts +4 -0
  192. package/lib/typescript/src/timeline/validation.d.ts.map +1 -0
  193. package/lib/typescript/src/timeline/wave.d.ts +11 -0
  194. package/lib/typescript/src/timeline/wave.d.ts.map +1 -0
  195. package/lib/typescript/src/types/index.d.ts +6 -0
  196. package/lib/typescript/src/types/index.d.ts.map +1 -0
  197. package/lib/typescript/src/types/recipe.d.ts +123 -0
  198. package/lib/typescript/src/types/recipe.d.ts.map +1 -0
  199. package/lib/typescript/src/types/renderer.d.ts +51 -0
  200. package/lib/typescript/src/types/renderer.d.ts.map +1 -0
  201. package/lib/typescript/src/types/token.d.ts +35 -0
  202. package/lib/typescript/src/types/token.d.ts.map +1 -0
  203. package/package.json +116 -3
  204. package/src/accessibility/index.ts +7 -0
  205. package/src/accessibility/policies.ts +60 -0
  206. package/src/controls/brand.ts +3 -0
  207. package/src/controls/controls.ts +41 -0
  208. package/src/controls/descriptors.ts +83 -0
  209. package/src/controls/index.ts +2 -0
  210. package/src/effects/compose.ts +98 -0
  211. package/src/effects/fade.ts +22 -0
  212. package/src/effects/index.ts +9 -0
  213. package/src/effects/lineReveal.ts +28 -0
  214. package/src/effects/pulse.ts +19 -0
  215. package/src/effects/rise.ts +19 -0
  216. package/src/effects/scale.ts +22 -0
  217. package/src/effects/shake.ts +19 -0
  218. package/src/effects/slide.ts +22 -0
  219. package/src/effects/typewriter.ts +16 -0
  220. package/src/effects/validation.ts +9 -0
  221. package/src/index.tsx +46 -0
  222. package/src/presets/index.ts +42 -0
  223. package/src/recipe/component.tsx +88 -0
  224. package/src/recipe/defineTextMotion.ts +6 -0
  225. package/src/recipe/descriptors.ts +158 -0
  226. package/src/recipe/index.ts +3 -0
  227. package/src/recipe/recipe.ts +359 -0
  228. package/src/renderers/index.ts +2 -0
  229. package/src/renderers/nativeText.tsx +813 -0
  230. package/src/renderers/nativeTextControls.ts +131 -0
  231. package/src/renderers/nativeTextLineLayout.ts +495 -0
  232. package/src/renderers/nativeTextPlayback.ts +204 -0
  233. package/src/renderers/overlayText.tsx +945 -0
  234. package/src/renderers/overlayTextLayout.ts +312 -0
  235. package/src/renderers/rendererMotion.ts +483 -0
  236. package/src/split/createToken.ts +26 -0
  237. package/src/split/custom.ts +92 -0
  238. package/src/split/graphemes.ts +27 -0
  239. package/src/split/index.ts +9 -0
  240. package/src/split/lines.ts +35 -0
  241. package/src/split/segmenter.ts +111 -0
  242. package/src/split/words.ts +28 -0
  243. package/src/timeline/index.ts +4 -0
  244. package/src/timeline/parallel.ts +30 -0
  245. package/src/timeline/sequence.ts +29 -0
  246. package/src/timeline/stagger.ts +60 -0
  247. package/src/timeline/validation.ts +29 -0
  248. package/src/timeline/wave.ts +34 -0
  249. package/src/types/index.ts +34 -0
  250. package/src/types/recipe.ts +195 -0
  251. package/src/types/renderer.ts +91 -0
  252. package/src/types/token.ts +39 -0
@@ -0,0 +1 @@
1
+ {"version":3,"names":["effectDescriptors","WeakMap","timelineDescriptors","splitterDescriptors","rendererDescriptors","attachTextMotionEffectDescriptor","effect","descriptor","set","readTextMotionEffectDescriptor","get","Error","flattenTextMotionEffectDescriptors","effects","flatMap","createTextMotionTimelineHandle","timeline","readTextMotionTimelineDescriptor","createTextMotionSplitterHandle","splitter","readTextMotionSplitterDescriptor","createTextMotionRendererHandle","renderer","readTextMotionR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T,UAAU,EAAE;IACd,OAAOA,UAAU;EACnB;EAEA,MAAM,IAAII,KAAK,CAAC,2EAA2E,CAAC;AAC9F;AAEA,OAAO,SAASO,8BAA8BA,CAC5CX,UAA8C,EACpB;EAC1B,MAAMY,QAAQ,GAAG,CAAC,CAA6B;EAC/ChB,mBAAmB,CAACK,GAAG,CAACW,QAAQ,EAAEZ,UAAU,CAAC;EAE7C,OAAOY,QAAQ;AACjB;AAEA,OAAO,SAASC,gCAAgCA,CAC9CD,QAAkC,EACE;EACpC,MAAMZ,UAAU,GAAGJ,mBAAmB,CAACO,GAAG,CAACS,QAAQ,CAAC;EAEpD,IAAIZ,UAAU,EAAE;IACd,OAAOA,UAAU;EACnB;EAEA,MAAM,IAAII,KAAK,CAAC,2EAA2E,CAAC;AAC9F;AAEA,OAAO,SAASU,8BAA8BA,CAK5Cd,UAA0E,EACd;EAC5D,MAAMe,QAAQ,GAAG,CAAC,CAA+D;EACjFlB,mBAAmB,CAACI,GAAG,CACrBc,QAAQ,EACRf,UACF,CAAC;EAED,OAAOe,QAAQ;AACjB;AAEA,OAAO,SAASC,gCAAgCA,CAI9CD,QAAkD,EACE;EACpD,MAAMf,UAAU,GAAGH,mBAAmB,CAACM,GAAG,CAACY,QAAQ,CAAC;EAEpD,IAAIf,UAAU,EAAE;IACd,OAAOA,UAAU;EACnB;EAEA,MAAM,IAAII,KAAK,CAAC,2EAA2E,CAAC;AAC9F","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ export { createTextMotionComponent } from "./component.js";
4
+ export { defineTextMotion } from "./defineTextMotion.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createTextMotionComponent","defineTextMotion"],"sourceRoot":"../../../src","sources":["recipe/index.ts"],"mappings":";;AAAA,SAASA,yBAAyB,QAAQ,gBAAa;AACvD,SAASC,gBAAgB,QAAQ,uBAAoB","ignoreList":[]}
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+
3
+ import { createTextMotionComponent } from "./component.js";
4
+
5
+ /** Builder state before a renderer has been selected. */
6
+
7
+ /** Builder state after a splitter has been selected before renderer layout. */
8
+
9
+ /** Builder state after a renderer has been selected. */
10
+
11
+ /** Builder state after a splittable renderer and splitter have been selected. */
12
+
13
+ /** Builder state after a rendered-line renderer has been selected. */
14
+
15
+ function cloneTimingOptions(options) {
16
+ return options ? {
17
+ ...options
18
+ } : undefined;
19
+ }
20
+ function cloneSpringOptions(options) {
21
+ if (!options) {
22
+ return undefined;
23
+ }
24
+ if (options.clamp) {
25
+ return {
26
+ ...options,
27
+ clamp: {
28
+ ...options.clamp
29
+ }
30
+ };
31
+ }
32
+ return {
33
+ ...options
34
+ };
35
+ }
36
+ function cloneAccessibilityPolicy(accessibility) {
37
+ return accessibility ? {
38
+ ...accessibility
39
+ } : undefined;
40
+ }
41
+ function validateMotionOptionValue(kind, path, value) {
42
+ if (typeof value === 'number' && Number.isFinite(value)) {
43
+ return;
44
+ }
45
+ if (typeof value === 'number') {
46
+ throw new Error(`@react-native-motion-kit/text-motion ${kind} motion option "${path}" must be a finite number.`);
47
+ }
48
+ if (Array.isArray(value)) {
49
+ value.forEach((item, index) => validateMotionOptionValue(kind, `${path}[${index}]`, item));
50
+ return;
51
+ }
52
+ if (value && typeof value === 'object') {
53
+ Object.entries(value).forEach(([key, nestedValue]) => validateMotionOptionValue(kind, `${path}.${key}`, nestedValue));
54
+ }
55
+ }
56
+ function validateMotionConfig(motion) {
57
+ if (motion.kind === 'spring') {
58
+ if (motion.options) {
59
+ validateMotionOptionValue(motion.kind, 'options', motion.options);
60
+ }
61
+ return {
62
+ kind: 'spring',
63
+ options: cloneSpringOptions(motion.options)
64
+ };
65
+ }
66
+ if (motion.kind === 'timing') {
67
+ if (motion.options) {
68
+ validateMotionOptionValue(motion.kind, 'options', motion.options);
69
+ }
70
+ return {
71
+ kind: 'timing',
72
+ options: cloneTimingOptions(motion.options)
73
+ };
74
+ }
75
+ throw new Error('@react-native-motion-kit/text-motion motion kind must be "timing" or "spring".');
76
+ }
77
+ function cloneMotionConfig(motion) {
78
+ return motion ? validateMotionConfig(motion) : undefined;
79
+ }
80
+ function cloneDraft(draft) {
81
+ return {
82
+ ...draft,
83
+ accessibility: cloneAccessibilityPolicy(draft.accessibility),
84
+ effects: [...draft.effects],
85
+ motion: cloneMotionConfig(draft.motion)
86
+ };
87
+ }
88
+ class TextMotionRecipeBuilderImpl {
89
+ constructor(draft = {}) {
90
+ this.draft = {
91
+ effects: draft.effects ? [...draft.effects] : [],
92
+ splitter: draft.splitter,
93
+ renderer: draft.renderer,
94
+ timeline: draft.timeline,
95
+ motion: draft.motion,
96
+ accessibility: draft.accessibility
97
+ };
98
+ }
99
+
100
+ /** Choose how the input string is split into tokens. */
101
+ split(splitter) {
102
+ return new TextMotionRecipeBuilderImpl({
103
+ ...cloneDraft(this.draft),
104
+ splitter
105
+ });
106
+ }
107
+
108
+ /** Choose the renderer responsible for measuring and drawing tokens. */
109
+ layout(renderer) {
110
+ return new TextMotionRecipeBuilderImpl({
111
+ ...cloneDraft(this.draft),
112
+ renderer
113
+ });
114
+ }
115
+
116
+ /** Choose the timing strategy for token delays. */
117
+ timeline(timeline) {
118
+ return new TextMotionRecipeBuilderImpl({
119
+ ...cloneDraft(this.draft),
120
+ timeline
121
+ });
122
+ }
123
+
124
+ /** Add an effect that is compatible with the selected renderer. */
125
+ effect(effect) {
126
+ return new TextMotionRecipeBuilderImpl({
127
+ ...cloneDraft(this.draft),
128
+ effects: [...this.draft.effects, effect]
129
+ });
130
+ }
131
+
132
+ /** Configure the Reanimated motion primitive used by the renderer. */
133
+ motion(motion) {
134
+ return new TextMotionRecipeBuilderImpl({
135
+ ...cloneDraft(this.draft),
136
+ motion: validateMotionConfig(motion)
137
+ });
138
+ }
139
+
140
+ /** Configure accessibility behavior such as reduced motion and token hiding. */
141
+ accessibility(accessibility) {
142
+ return new TextMotionRecipeBuilderImpl({
143
+ ...cloneDraft(this.draft),
144
+ accessibility
145
+ });
146
+ }
147
+
148
+ /** Return the immutable recipe config. */
149
+ recipe() {
150
+ return cloneDraft(this.draft);
151
+ }
152
+
153
+ /** Create a React component from the current recipe. */
154
+ component() {
155
+ return createTextMotionComponent(cloneDraft(this.draft));
156
+ }
157
+ }
158
+
159
+ /** @internal */
160
+ export function createTextMotionRecipeBuilder() {
161
+ return new TextMotionRecipeBuilderImpl();
162
+ }
163
+ //# sourceMappingURL=recipe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createTextMotionComponent","cloneTimingOptions","options","undefined","cloneSpringOptions","clamp","cloneAccessibilityPolicy","accessibility","validateMotionOptionValue","kind","path","value","Number","isFinite","Error","Array","isArray","forEach","item","index","Object","entries","key","nestedValue","validateMotionConfig","motion","cloneMotionConfig","cloneDraft","draft","effects","TextMotionRecipeBuilderImpl","constructor","splitter","renderer","timeline","split","layout","effect","recipe","component","createTextMotionRecipeBuilder"],"sourceRoot":"../../../src","sources":["recipe/recipe.ts"],"mappings":";;AAkBA,SAASA,yBAAyB,QAAQ,gBAAa;;AAoDvD;;AAqBA;;AAgBA;;AAwBA;;AAmBA;;AAqBA,SAASC,kBAAkBA,CACzBC,OAAuE,EACvE;EACA,OAAOA,OAAO,GAAG;IAAE,GAAGA;EAAQ,CAAC,GAAGC,SAAS;AAC7C;AAEA,SAASC,kBAAkBA,CACzBF,OAAuE,EACvE;EACA,IAAI,CAACA,OAAO,EAAE;IACZ,OAAOC,SAAS;EAClB;EAEA,IAAID,OAAO,CAACG,KAAK,EAAE;IACjB,OAAO;MACL,GAAGH,OAAO;MACVG,KAAK,EAAE;QAAE,GAAGH,OAAO,CAACG;MAAM;IAC5B,CAAC;EACH;EAEA,OAAO;IAAE,GAAGH;EAAQ,CAAC;AACvB;AAEA,SAASI,wBAAwBA,CAC/BC,aAAwD,EACb;EAC3C,OAAOA,aAAa,GAAG;IAAE,GAAGA;EAAc,CAAC,GAAGJ,SAAS;AACzD;AAEA,SAASK,yBAAyBA,CAChC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UAAU,CAAC,IAAI,CAACC,KAAK,CAAC;MACzBK;IACF,CAAC,CAAC;EACJ;;EAEA;EACAC,QAAQA,CAACA,QAA+B,EAAqD;IAC3F,OAAO,IAAIJ,2BAA2B,CAAuB;MAC3D,GAAGH,UAAU,CAAC,IAAI,CAACC,KAAK,CAAC;MACzBM;IACF,CAAC,CAAC;EACJ;;EAEA;EACAG,MAAMA,CACJA,MAIC,EACkD;IACnD,OAAO,IAAIP,2BAA2B,CAAuB;MAC3D,GAAGH,UAAU,CAAC,IAAI,CAACC,KAAK,CAAC;MACzBC,OAAO,EAAE,CAAC,GAAG,IAAI,CAACD,KAAK,CAACC,OAAO,EAAEQ,MAAM;IACzC,CAAC,CAAC;EACJ;;EAEA;EACAZ,MAAMA,CAACA,MAA8B,EAAqD;IACxF,OAAO,IAAIK,2BAA2B,CAAuB;MAC3D,GAAGH,UAAU,CAAC,IAAI,CAACC,KAAK,CAAC;MACzBH,MAAM,EAAED,oBAAoB,CAACC,MAAM;IACrC,CAAC,CAAC;EACJ;;EAEA;EACAlB,aAAaA,CACXA,aAA4C,EACO;IACnD,OAAO,IAAIuB,2BAA2B,CAAuB;MAC3D,GAAGH,UAAU,CAAC,IAAI,CAACC,KAAK,CAAC;MACzBrB;IACF,CAAC,CAAC;EACJ;;EAEA;EACA+B,MAAMA,CAAA,EAAiD;IACrD,OAAOX,UAAU,CAAC,IAAI,CAACC,KAAK,CAAC;EAC/B;;EAEA;EACAW,SAASA,CAAA,EAAwB;IAC/B,OAAOvC,yBAAyB,CAAC2B,UAAU,CAAC,IAAI,CAACC,KAAK,CAAC,CAAC;EAC1D;AACF;;AAEA;AACA,OAAO,SAASY,6BAA6BA,CAAA,EAA4B;EACvE,OAAO,IAAIV,2BAA2B,CAAC,CAAC;AAC1C","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ export { nativeText } from "./nativeText.js";
4
+ export { overlayText } from "./overlayText.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["nativeText","overlayText"],"sourceRoot":"../../../src","sources":["renderers/index.ts"],"mappings":";;AAAA,SAASA,UAAU,QAAwC,iBAAc;AACzE,SAASC,WAAW,QAAyC,kBAAe","ignoreList":[]}
@@ -0,0 +1,494 @@
1
+ "use strict";
2
+
3
+ import { useLayoutEffect, useRef, createElement as _createElement } from 'react';
4
+ import { StyleSheet, Text, View } from 'react-native';
5
+ import { createAnimatedComponent, useAnimatedStyle, useReducedMotion, useSharedValue } from 'react-native-reanimated';
6
+ import { createHiddenTokenAccessibilityProps, createParentAccessibilityProps, parentLabelPolicy, resolveAccessibleText } from "../accessibility/index.js";
7
+ import { createTextMotionRendererHandle } from "../recipe/descriptors.js";
8
+ import { useNativeTextControlsPlayback } from "./nativeTextControls.js";
9
+ import { areNativeTextPlaybackRunsEqual, createNativeTextPlaybackRun } from "./nativeTextPlayback.js";
10
+ import { clampTextMotionProgress, createTextMotionControlledProgressPlan, createTextMotionControlledTimelineSpan, createTextMotionDelaySecondsByItemIndex, createTextMotionItemMotion, createTextMotionProgressAnimation, createTextMotionStyleTransformStatePair, readTextMotionProgressForAnimatedStyle, shouldRenderTextMotionFinalState } from "./rendererMotion.js";
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ const AnimatedView = createAnimatedComponent(View);
13
+ const TEXT_ALIGN_TO_JUSTIFY_CONTENT = {
14
+ auto: 'flex-start',
15
+ center: 'center',
16
+ justify: 'flex-start',
17
+ left: 'flex-start',
18
+ right: 'flex-end'
19
+ };
20
+ const NATIVE_TEXT_LINE_BREAK_PATTERN = /\r\n|\n/g;
21
+ const NATIVE_TEXT_LINE_BREAK_MARKER_STYLE = {
22
+ flexBasis: '100%',
23
+ height: 0,
24
+ width: '100%'
25
+ };
26
+ const NATIVE_TEXT_BLANK_LINE_SPACER_STYLE = {
27
+ flexBasis: '100%',
28
+ opacity: 0,
29
+ width: '100%'
30
+ };
31
+ const NATIVE_TEXT_BLANK_LINE_SPACER_TEXT = ' ';
32
+ const NATIVE_TEXT_ANIMATED_TOKEN_CONTAINER_STYLE = {
33
+ overflow: 'visible'
34
+ };
35
+ function shouldAnimateToken(token) {
36
+ return token.text.trim().length > 0;
37
+ }
38
+ function createMotionIndexByTokenId(tokens) {
39
+ const motionTokens = tokens.filter(shouldAnimateToken);
40
+ const motionIndexByTokenId = new Map(motionTokens.map((token, motionIndex) => [token.id, motionIndex]));
41
+ return {
42
+ motionCount: motionTokens.length,
43
+ motionIndexByTokenId
44
+ };
45
+ }
46
+ function createTokenDelaySecondsByMotionIndex(recipe, count) {
47
+ return createTextMotionDelaySecondsByItemIndex(recipe, count);
48
+ }
49
+ function createTokenMotion(recipe, motionIndex, styleState, delaySecondsByMotionIndex) {
50
+ return createTextMotionItemMotion(recipe, styleState, delaySecondsByMotionIndex[motionIndex] ?? 0);
51
+ }
52
+ function createControlledProgressPlan(motionIndex, delaySecondsByMotionIndex, totalTimelineSpan) {
53
+ return createTextMotionControlledProgressPlan(motionIndex, delaySecondsByMotionIndex, totalTimelineSpan);
54
+ }
55
+ function createNativeTextTextFragment(token, text, textFragmentIndex) {
56
+ return {
57
+ kind: 'text',
58
+ key: textFragmentIndex === 0 ? token.id : `${token.id}:text:${textFragmentIndex}`,
59
+ text,
60
+ textFragmentIndex,
61
+ token
62
+ };
63
+ }
64
+ function createNativeTextLineBreakFragment(token, lineBreakIndex, preservesLineHeight) {
65
+ return {
66
+ kind: 'line-break',
67
+ key: `${token.id}:line-break:${lineBreakIndex}`,
68
+ preservesLineHeight
69
+ };
70
+ }
71
+ function hasNativeTextLineContent(text) {
72
+ return text.replace(NATIVE_TEXT_LINE_BREAK_PATTERN, '').length > 0;
73
+ }
74
+ function hasNativeTextLineContentAfter(sourceText, sourceIndex) {
75
+ return hasNativeTextLineContent(sourceText.slice(sourceIndex));
76
+ }
77
+ function createNativeTextTokenRenderFragments(token, sourceText, currentLineHasText) {
78
+ if (!token.text.includes('\n')) {
79
+ return {
80
+ currentLineHasText: currentLineHasText || token.text.length > 0,
81
+ fragments: [createNativeTextTextFragment(token, token.text, 0)]
82
+ };
83
+ }
84
+ const lineBreaks = Array.from(token.text.matchAll(NATIVE_TEXT_LINE_BREAK_PATTERN));
85
+ const initialAccumulator = {
86
+ cursor: 0,
87
+ currentLineHasText,
88
+ fragments: [],
89
+ textFragmentIndex: 0
90
+ };
91
+ const result = lineBreaks.reduce((accumulator, lineBreak, lineBreakIndex) => {
92
+ const start = lineBreak.index ?? accumulator.cursor;
93
+ const lineBreakEnd = start + lineBreak[0].length;
94
+ const textBeforeLineBreak = token.text.slice(accumulator.cursor, start);
95
+ const textFragment = textBeforeLineBreak.length > 0 ? [createNativeTextTextFragment(token, textBeforeLineBreak, accumulator.textFragmentIndex)] : [];
96
+ const lineHasText = accumulator.currentLineHasText || textBeforeLineBreak.length > 0;
97
+ const hasTextAfterLineBreak = hasNativeTextLineContentAfter(sourceText, token.sourceRange.start + lineBreakEnd);
98
+ return {
99
+ cursor: lineBreakEnd,
100
+ currentLineHasText: false,
101
+ fragments: [...accumulator.fragments, ...textFragment, createNativeTextLineBreakFragment(token, lineBreakIndex, !lineHasText || !hasTextAfterLineBreak)],
102
+ textFragmentIndex: accumulator.textFragmentIndex + textFragment.length
103
+ };
104
+ }, initialAccumulator);
105
+ const trailingText = token.text.slice(result.cursor);
106
+ if (trailingText.length === 0) {
107
+ return {
108
+ currentLineHasText: result.currentLineHasText,
109
+ fragments: result.fragments
110
+ };
111
+ }
112
+ return {
113
+ currentLineHasText: true,
114
+ fragments: [...result.fragments, createNativeTextTextFragment(token, trailingText, result.textFragmentIndex)]
115
+ };
116
+ }
117
+ function createNativeTextRenderFragments(tokens, sourceText) {
118
+ const result = tokens.reduce((accumulator, token) => {
119
+ const tokenResult = createNativeTextTokenRenderFragments(token, sourceText, accumulator.currentLineHasText);
120
+ return {
121
+ currentLineHasText: tokenResult.currentLineHasText,
122
+ fragments: [...accumulator.fragments, ...tokenResult.fragments]
123
+ };
124
+ }, {
125
+ currentLineHasText: false,
126
+ fragments: []
127
+ });
128
+ return result.fragments.map((fragment, renderIndex) => ({
129
+ ...fragment,
130
+ renderIndex
131
+ }));
132
+ }
133
+ function createNativeTextFragmentTestID(prefix, fragment) {
134
+ if (!prefix) {
135
+ return undefined;
136
+ }
137
+ if (fragment.textFragmentIndex === 0) {
138
+ return `${prefix}-${fragment.token.index}`;
139
+ }
140
+ return `${prefix}-${fragment.token.index}-${fragment.textFragmentIndex}`;
141
+ }
142
+ function createNativeTextLineBreakTestID(prefix, fragment) {
143
+ return prefix ? `${prefix}-line-break-${fragment.renderIndex}` : undefined;
144
+ }
145
+ function StaticNativeTextToken({
146
+ children,
147
+ style,
148
+ ...tokenProps
149
+ }) {
150
+ return /*#__PURE__*/_jsx(Text, {
151
+ ...tokenProps,
152
+ style: style,
153
+ children: children
154
+ });
155
+ }
156
+ function splitAnimatedTokenProps({
157
+ accessibilityElementsHidden,
158
+ accessible,
159
+ importantForAccessibility,
160
+ testID,
161
+ ...textProps
162
+ }) {
163
+ return {
164
+ containerProps: {
165
+ accessibilityElementsHidden,
166
+ accessible,
167
+ importantForAccessibility,
168
+ testID
169
+ },
170
+ textProps
171
+ };
172
+ }
173
+ function AnimatedNativeTextTokenContent({
174
+ children,
175
+ style,
176
+ ...tokenProps
177
+ }) {
178
+ return /*#__PURE__*/_jsx(Text, {
179
+ ...tokenProps,
180
+ style: style,
181
+ children: children
182
+ });
183
+ }
184
+ function useNativeTextAnimatedStyle(options) {
185
+ const {
186
+ controlled,
187
+ progress,
188
+ renderFinalState,
189
+ tokenMotion
190
+ } = options;
191
+ const initialOpacity = tokenMotion.initial.opacity;
192
+ const initialScale = tokenMotion.initial.scale;
193
+ const initialTranslateX = tokenMotion.initial.translateX;
194
+ const initialTranslateY = tokenMotion.initial.translateY;
195
+ const targetOpacity = tokenMotion.target.opacity;
196
+ const targetScale = tokenMotion.target.scale;
197
+ const targetTranslateX = tokenMotion.target.translateX;
198
+ const targetTranslateY = tokenMotion.target.translateY;
199
+ const pulseScale = tokenMotion.pulseScale;
200
+ const revealOnStart = tokenMotion.revealOnStart === true;
201
+ const itemDelaySeconds = controlled ? options.controlledProgressPlan.itemDelaySeconds : 0;
202
+ const totalTimelineSpan = controlled ? options.controlledProgressPlan.totalTimelineSpan : 1;
203
+ return useAnimatedStyle(() => {
204
+ const current = readTextMotionProgressForAnimatedStyle({
205
+ controlledProgressPlan: controlled ? {
206
+ itemDelaySeconds,
207
+ totalTimelineSpan
208
+ } : undefined,
209
+ progress,
210
+ renderFinalState
211
+ });
212
+ const clampedCurrent = clampTextMotionProgress(current);
213
+ const baseScale = initialScale + (targetScale - initialScale) * current;
214
+ const pulseProgress = 1 - Math.abs(clampedCurrent * 2 - 1);
215
+ const pulseMultiplier = 1 + (pulseScale - 1) * pulseProgress;
216
+ return {
217
+ opacity: revealOnStart && current <= 0 ? 0 : initialOpacity + (targetOpacity - initialOpacity) * current,
218
+ transform: [{
219
+ translateX: initialTranslateX + (targetTranslateX - initialTranslateX) * current
220
+ }, {
221
+ translateY: initialTranslateY + (targetTranslateY - initialTranslateY) * current
222
+ }, {
223
+ scale: baseScale * pulseMultiplier
224
+ }]
225
+ };
226
+ }, [initialOpacity, initialScale, initialTranslateX, initialTranslateY, controlled, progress, pulseScale, renderFinalState, revealOnStart, targetOpacity, targetScale, targetTranslateX, targetTranslateY, itemDelaySeconds, totalTimelineSpan]);
227
+ }
228
+ function ControlledAnimatedNativeTextToken({
229
+ children,
230
+ controlledProgress,
231
+ controlledProgressPlan,
232
+ style,
233
+ tokenMotion,
234
+ ...tokenProps
235
+ }) {
236
+ const reducedMotion = tokenMotion.reducedMotion;
237
+ const reducedMotionEnabled = useReducedMotion();
238
+ const renderFinalState = shouldRenderTextMotionFinalState(reducedMotionEnabled, reducedMotion);
239
+ const {
240
+ containerProps,
241
+ textProps
242
+ } = splitAnimatedTokenProps(tokenProps);
243
+ const animatedStyle = useNativeTextAnimatedStyle({
244
+ controlled: true,
245
+ controlledProgressPlan,
246
+ progress: controlledProgress,
247
+ renderFinalState,
248
+ tokenMotion
249
+ });
250
+ return /*#__PURE__*/_jsx(AnimatedView, {
251
+ ...containerProps,
252
+ style: [NATIVE_TEXT_ANIMATED_TOKEN_CONTAINER_STYLE, animatedStyle],
253
+ children: /*#__PURE__*/_jsx(AnimatedNativeTextTokenContent, {
254
+ ...textProps,
255
+ style: style,
256
+ children: children
257
+ })
258
+ });
259
+ }
260
+ function UncontrolledAnimatedNativeTextToken({
261
+ children,
262
+ controls,
263
+ playbackText,
264
+ style,
265
+ tokenMotion,
266
+ ...tokenProps
267
+ }) {
268
+ const reducedMotion = tokenMotion.reducedMotion;
269
+ const reducedMotionEnabled = useReducedMotion();
270
+ const renderFinalState = shouldRenderTextMotionFinalState(reducedMotionEnabled, reducedMotion);
271
+ const progress = useSharedValue(renderFinalState ? 1 : 0);
272
+ const playbackRun = createNativeTextPlaybackRun(tokenMotion, renderFinalState, playbackText);
273
+ const previousPlaybackRun = useRef(undefined);
274
+ const {
275
+ containerProps,
276
+ textProps
277
+ } = splitAnimatedTokenProps(tokenProps);
278
+ const animatedStyle = useNativeTextAnimatedStyle({
279
+ controlled: false,
280
+ progress,
281
+ renderFinalState,
282
+ tokenMotion
283
+ });
284
+ useLayoutEffect(() => {
285
+ if (areNativeTextPlaybackRunsEqual(previousPlaybackRun.current, playbackRun)) {
286
+ return;
287
+ }
288
+ previousPlaybackRun.current = playbackRun;
289
+ if (playbackRun.renderFinalState) {
290
+ progress.value = 1;
291
+ return;
292
+ }
293
+ progress.value = 0;
294
+ progress.value = createTextMotionProgressAnimation(playbackRun);
295
+ });
296
+ useNativeTextControlsPlayback({
297
+ controls,
298
+ createProgressAnimation: createTextMotionProgressAnimation,
299
+ progress,
300
+ renderFinalState,
301
+ tokenMotion
302
+ });
303
+ return /*#__PURE__*/_jsx(AnimatedView, {
304
+ ...containerProps,
305
+ style: [NATIVE_TEXT_ANIMATED_TOKEN_CONTAINER_STYLE, animatedStyle],
306
+ children: /*#__PURE__*/_jsx(AnimatedNativeTextTokenContent, {
307
+ ...textProps,
308
+ style: style,
309
+ children: children
310
+ })
311
+ });
312
+ }
313
+ function NativeTextToken(props) {
314
+ if (!props.tokenMotion) {
315
+ const {
316
+ tokenMotion: _tokenMotion,
317
+ ...tokenProps
318
+ } = props;
319
+ return /*#__PURE__*/_jsx(StaticNativeTextToken, {
320
+ ...tokenProps
321
+ });
322
+ }
323
+ if ('controlledProgress' in props) {
324
+ const {
325
+ controlledProgress,
326
+ controlledProgressPlan,
327
+ tokenMotion,
328
+ ...tokenProps
329
+ } = props;
330
+ return /*#__PURE__*/_jsx(ControlledAnimatedNativeTextToken, {
331
+ ...tokenProps,
332
+ controlledProgress: controlledProgress,
333
+ controlledProgressPlan: controlledProgressPlan,
334
+ tokenMotion: tokenMotion
335
+ });
336
+ }
337
+ const {
338
+ controls,
339
+ playbackText,
340
+ tokenMotion,
341
+ ...tokenProps
342
+ } = props;
343
+ return /*#__PURE__*/_jsx(UncontrolledAnimatedNativeTextToken, {
344
+ ...tokenProps,
345
+ controls: controls,
346
+ playbackText: playbackText,
347
+ tokenMotion: tokenMotion
348
+ });
349
+ }
350
+ function NativeTextLineBreak({
351
+ preservesLineHeight,
352
+ testID,
353
+ textStyle,
354
+ tokenTextProps
355
+ }) {
356
+ if (preservesLineHeight) {
357
+ return /*#__PURE__*/_jsx(Text, {
358
+ ...tokenTextProps,
359
+ accessibilityElementsHidden: true,
360
+ accessible: false,
361
+ importantForAccessibility: "no-hide-descendants",
362
+ style: [textStyle, NATIVE_TEXT_BLANK_LINE_SPACER_STYLE],
363
+ testID: testID,
364
+ children: NATIVE_TEXT_BLANK_LINE_SPACER_TEXT
365
+ });
366
+ }
367
+ return /*#__PURE__*/_jsx(View, {
368
+ accessibilityElementsHidden: true,
369
+ accessible: false,
370
+ importantForAccessibility: "no-hide-descendants",
371
+ style: NATIVE_TEXT_LINE_BREAK_MARKER_STYLE,
372
+ testID: testID
373
+ });
374
+ }
375
+ function resolveJustifyContent(style) {
376
+ const textAlign = StyleSheet.flatten(style)?.textAlign;
377
+ return textAlign ? TEXT_ALIGN_TO_JUSTIFY_CONTENT[textAlign] : 'flex-start';
378
+ }
379
+ function createContainerStyle(style) {
380
+ return {
381
+ flexDirection: 'row',
382
+ flexWrap: 'wrap',
383
+ justifyContent: resolveJustifyContent(style)
384
+ };
385
+ }
386
+ function createContainerProps(textProps, parentAccessibilityProps) {
387
+ return {
388
+ accessibilityActions: textProps?.accessibilityActions,
389
+ accessibilityHint: textProps?.accessibilityHint,
390
+ accessibilityLabel: textProps?.accessibilityLabel ?? parentAccessibilityProps.accessibilityLabel,
391
+ accessibilityLanguage: textProps?.accessibilityLanguage,
392
+ accessibilityRole: textProps?.accessibilityRole,
393
+ accessibilityState: textProps?.accessibilityState,
394
+ accessibilityValue: textProps?.accessibilityValue,
395
+ accessible: parentAccessibilityProps.accessible,
396
+ nativeID: textProps?.nativeID,
397
+ onAccessibilityAction: textProps?.onAccessibilityAction,
398
+ testID: textProps?.testID
399
+ };
400
+ }
401
+ function createTokenTextProps(textProps) {
402
+ return {
403
+ allowFontScaling: textProps?.allowFontScaling,
404
+ maxFontSizeMultiplier: textProps?.maxFontSizeMultiplier
405
+ };
406
+ }
407
+ function createNativeTextRendererComponent(options) {
408
+ function NativeTextRenderer({
409
+ children,
410
+ recipe,
411
+ textProps,
412
+ tokens
413
+ }) {
414
+ const text = typeof children === 'string' ? children : '';
415
+ const textStyle = textProps?.style;
416
+ const policy = recipe.accessibility ?? parentLabelPolicy();
417
+ const accessibilityLabel = resolveAccessibleText(text, tokens);
418
+ const parentAccessibilityProps = createParentAccessibilityProps(policy, accessibilityLabel);
419
+ const tokenAccessibilityProps = createHiddenTokenAccessibilityProps(policy);
420
+ const containerProps = createContainerProps(textProps, parentAccessibilityProps);
421
+ const tokenTextProps = createTokenTextProps(textProps);
422
+ const styleState = createTextMotionStyleTransformStatePair(recipe.effects, 'nativeText()');
423
+ const {
424
+ motionCount,
425
+ motionIndexByTokenId
426
+ } = createMotionIndexByTokenId(tokens);
427
+ const delaySecondsByMotionIndex = createTokenDelaySecondsByMotionIndex(recipe, motionCount);
428
+ const totalTimelineSpan = createTextMotionControlledTimelineSpan(delaySecondsByMotionIndex);
429
+ const externalProgress = textProps?.progress;
430
+ const controls = textProps?.controls;
431
+ const fragments = createNativeTextRenderFragments(tokens, text);
432
+ if (externalProgress && controls) {
433
+ throw new Error('@react-native-motion-kit/text-motion cannot receive both progress and controls. Use progress for raw app-owned values, or controls for event-driven playback.');
434
+ }
435
+ return /*#__PURE__*/_jsx(View, {
436
+ ...containerProps,
437
+ style: createContainerStyle(textStyle),
438
+ children: fragments.map(fragment => {
439
+ if (fragment.kind === 'line-break') {
440
+ return /*#__PURE__*/_jsx(NativeTextLineBreak, {
441
+ preservesLineHeight: fragment.preservesLineHeight,
442
+ testID: createNativeTextLineBreakTestID(options.testIDPrefix, fragment),
443
+ textStyle: textStyle,
444
+ tokenTextProps: tokenTextProps
445
+ }, fragment.key);
446
+ }
447
+ const token = fragment.token;
448
+ const motionIndex = motionIndexByTokenId.get(token.id);
449
+ const commonTokenProps = {
450
+ ...tokenAccessibilityProps,
451
+ ...tokenTextProps,
452
+ style: textStyle,
453
+ testID: createNativeTextFragmentTestID(options.testIDPrefix, fragment)
454
+ };
455
+ if (typeof motionIndex !== 'number') {
456
+ return /*#__PURE__*/_createElement(NativeTextToken, {
457
+ ...commonTokenProps,
458
+ key: fragment.key
459
+ }, fragment.text);
460
+ }
461
+ const tokenMotion = createTokenMotion(recipe, motionIndex, styleState, delaySecondsByMotionIndex);
462
+ if (!externalProgress) {
463
+ return /*#__PURE__*/_createElement(NativeTextToken, {
464
+ ...commonTokenProps,
465
+ controls: controls,
466
+ key: fragment.key,
467
+ playbackText: fragment.text,
468
+ tokenMotion: tokenMotion
469
+ }, fragment.text);
470
+ }
471
+ return /*#__PURE__*/_createElement(NativeTextToken, {
472
+ ...commonTokenProps,
473
+ controlledProgress: externalProgress,
474
+ controlledProgressPlan: createControlledProgressPlan(motionIndex, delaySecondsByMotionIndex, totalTimelineSpan),
475
+ key: fragment.key,
476
+ tokenMotion: tokenMotion
477
+ }, fragment.text);
478
+ })
479
+ });
480
+ }
481
+ NativeTextRenderer.displayName = 'NativeTextRenderer';
482
+ return NativeTextRenderer;
483
+ }
484
+
485
+ /** Render text as wrapping React Native Text tokens animated by Reanimated. */
486
+ export function nativeText(options = {}) {
487
+ return createTextMotionRendererHandle({
488
+ kind: 'nativeText',
489
+ capabilities: ['native-text', 'style-transform'],
490
+ motionUnit: 'source-token',
491
+ Component: createNativeTextRendererComponent(options)
492
+ });
493
+ }
494
+ //# sourceMappingURL=nativeText.js.map