react-native-nitro-input 0.3.8 → 0.4.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 (107) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/README.md +5 -1
  3. package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroInputMeasure.kt +52 -0
  4. package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroInputView.kt +74 -80
  5. package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroNumberView.kt +18 -18
  6. package/android/src/main/java/com/margelo/nitro/nitroinput/HybridNitroTextView.kt +14 -14
  7. package/android/src/main/java/com/margelo/nitro/nitroinput/InputFonts.kt +199 -0
  8. package/android/src/main/java/com/margelo/nitro/nitroinput/InputSizing.kt +398 -0
  9. package/android/src/main/java/com/margelo/nitro/nitroinput/NitroInputView.kt +112 -333
  10. package/android/src/main/java/com/margelo/nitro/nitroinput/NitroNumberView.kt +178 -30
  11. package/ios/HybridNitroInputView.swift +69 -75
  12. package/ios/HybridNitroNumberView.swift +18 -18
  13. package/ios/HybridNitroTextView.swift +14 -14
  14. package/ios/InputSizing.swift +534 -0
  15. package/ios/NitroInputView.swift +102 -198
  16. package/ios/NitroNumberView.swift +98 -23
  17. package/lib/commonjs/nitrogen/generated/shared/json/NitroInputViewConfig.json +12 -8
  18. package/lib/commonjs/nitrogen/generated/shared/json/NitroNumberViewConfig.json +6 -6
  19. package/lib/commonjs/nitrogen/generated/shared/json/NitroTextViewConfig.json +6 -6
  20. package/lib/commonjs/src/NitroInput.js +164 -23
  21. package/lib/commonjs/src/NitroNumber.js +1 -1
  22. package/lib/commonjs/src/NitroText.js +6 -6
  23. package/lib/commonjs/src/specs/NitroInputMeasure.nitro.js +2 -0
  24. package/lib/module/nitrogen/generated/shared/json/NitroInputViewConfig.json +12 -8
  25. package/lib/module/nitrogen/generated/shared/json/NitroNumberViewConfig.json +6 -6
  26. package/lib/module/nitrogen/generated/shared/json/NitroTextViewConfig.json +6 -6
  27. package/lib/module/src/NitroInput.js +165 -24
  28. package/lib/module/src/NitroNumber.js +1 -1
  29. package/lib/module/src/NitroText.js +6 -6
  30. package/lib/module/src/specs/NitroInputMeasure.nitro.js +1 -0
  31. package/lib/typescript/src/NitroInput.d.ts +9 -16
  32. package/lib/typescript/src/specs/NitroInput.nitro.d.ts +17 -8
  33. package/lib/typescript/src/specs/NitroInputMeasure.nitro.d.ts +67 -0
  34. package/lib/typescript/src/specs/NitroNumber.nitro.d.ts +6 -6
  35. package/lib/typescript/src/specs/NitroText.nitro.d.ts +6 -6
  36. package/nitro.json +10 -0
  37. package/nitrogen/generated/android/NitroInput+autolinking.cmake +2 -0
  38. package/nitrogen/generated/android/NitroInputOnLoad.cpp +16 -0
  39. package/nitrogen/generated/android/c++/JHybridNitroInputMeasureSpec.cpp +93 -0
  40. package/nitrogen/generated/android/c++/JHybridNitroInputMeasureSpec.hpp +63 -0
  41. package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.cpp +76 -40
  42. package/nitrogen/generated/android/c++/JHybridNitroInputViewSpec.hpp +24 -16
  43. package/nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.cpp +30 -30
  44. package/nitrogen/generated/android/c++/JHybridNitroNumberViewSpec.hpp +12 -12
  45. package/nitrogen/generated/android/c++/JHybridNitroTextViewSpec.cpp +30 -30
  46. package/nitrogen/generated/android/c++/JHybridNitroTextViewSpec.hpp +12 -12
  47. package/nitrogen/generated/android/c++/JNitroInputSize.hpp +61 -0
  48. package/nitrogen/generated/android/c++/JNitroInputSizing.hpp +284 -0
  49. package/nitrogen/generated/android/c++/views/JHybridNitroInputViewStateUpdater.cpp +44 -24
  50. package/nitrogen/generated/android/c++/views/JHybridNitroNumberViewStateUpdater.cpp +18 -18
  51. package/nitrogen/generated/android/c++/views/JHybridNitroTextViewStateUpdater.cpp +18 -18
  52. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroInputMeasureSpec.kt +56 -0
  53. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroInputViewSpec.kt +32 -8
  54. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroNumberViewSpec.kt +6 -6
  55. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/HybridNitroTextViewSpec.kt +6 -6
  56. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputSize.kt +56 -0
  57. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroinput/NitroInputSizing.kt +246 -0
  58. package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.cpp +17 -0
  59. package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Bridge.hpp +29 -0
  60. package/nitrogen/generated/ios/NitroInput-Swift-Cxx-Umbrella.hpp +11 -0
  61. package/nitrogen/generated/ios/NitroInputAutolinking.mm +8 -0
  62. package/nitrogen/generated/ios/NitroInputAutolinking.swift +12 -0
  63. package/nitrogen/generated/ios/c++/HybridNitroInputMeasureSpecSwift.cpp +11 -0
  64. package/nitrogen/generated/ios/c++/HybridNitroInputMeasureSpecSwift.hpp +112 -0
  65. package/nitrogen/generated/ios/c++/HybridNitroInputViewSpecSwift.hpp +56 -32
  66. package/nitrogen/generated/ios/c++/HybridNitroNumberViewSpecSwift.hpp +24 -24
  67. package/nitrogen/generated/ios/c++/HybridNitroTextViewSpecSwift.hpp +24 -24
  68. package/nitrogen/generated/ios/c++/views/HybridNitroInputViewComponent.mm +56 -32
  69. package/nitrogen/generated/ios/c++/views/HybridNitroNumberViewComponent.mm +24 -24
  70. package/nitrogen/generated/ios/c++/views/HybridNitroTextViewComponent.mm +24 -24
  71. package/nitrogen/generated/ios/swift/HybridNitroInputMeasureSpec.swift +55 -0
  72. package/nitrogen/generated/ios/swift/HybridNitroInputMeasureSpec_cxx.swift +138 -0
  73. package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec.swift +12 -8
  74. package/nitrogen/generated/ios/swift/HybridNitroInputViewSpec_cxx.swift +68 -24
  75. package/nitrogen/generated/ios/swift/HybridNitroNumberViewSpec.swift +6 -6
  76. package/nitrogen/generated/ios/swift/HybridNitroNumberViewSpec_cxx.swift +18 -18
  77. package/nitrogen/generated/ios/swift/HybridNitroTextViewSpec.swift +6 -6
  78. package/nitrogen/generated/ios/swift/HybridNitroTextViewSpec_cxx.swift +18 -18
  79. package/nitrogen/generated/ios/swift/NitroInputSize.swift +34 -0
  80. package/nitrogen/generated/ios/swift/NitroInputSizing.swift +242 -0
  81. package/nitrogen/generated/shared/c++/HybridNitroInputMeasureSpec.cpp +21 -0
  82. package/nitrogen/generated/shared/c++/HybridNitroInputMeasureSpec.hpp +66 -0
  83. package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.cpp +24 -16
  84. package/nitrogen/generated/shared/c++/HybridNitroInputViewSpec.hpp +24 -16
  85. package/nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.cpp +12 -12
  86. package/nitrogen/generated/shared/c++/HybridNitroNumberViewSpec.hpp +12 -12
  87. package/nitrogen/generated/shared/c++/HybridNitroTextViewSpec.cpp +12 -12
  88. package/nitrogen/generated/shared/c++/HybridNitroTextViewSpec.hpp +12 -12
  89. package/nitrogen/generated/shared/c++/NitroInputSize.hpp +87 -0
  90. package/nitrogen/generated/shared/c++/NitroInputSizing.hpp +263 -0
  91. package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.cpp +24 -16
  92. package/nitrogen/generated/shared/c++/views/HybridNitroInputViewComponent.hpp +36 -24
  93. package/nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.cpp +12 -12
  94. package/nitrogen/generated/shared/c++/views/HybridNitroNumberViewComponent.hpp +18 -18
  95. package/nitrogen/generated/shared/c++/views/HybridNitroTextViewComponent.cpp +12 -12
  96. package/nitrogen/generated/shared/c++/views/HybridNitroTextViewComponent.hpp +18 -18
  97. package/nitrogen/generated/shared/json/NitroInputViewConfig.json +12 -8
  98. package/nitrogen/generated/shared/json/NitroNumberViewConfig.json +6 -6
  99. package/nitrogen/generated/shared/json/NitroTextViewConfig.json +6 -6
  100. package/package.json +4 -2
  101. package/src/NitroInput.tsx +201 -64
  102. package/src/NitroNumber.tsx +6 -6
  103. package/src/NitroText.tsx +6 -6
  104. package/src/specs/NitroInput.nitro.ts +17 -8
  105. package/src/specs/NitroInputMeasure.nitro.ts +76 -0
  106. package/src/specs/NitroNumber.nitro.ts +6 -6
  107. package/src/specs/NitroText.nitro.ts +6 -6
@@ -54,6 +54,8 @@ private const val NUMERIC_BLUR = 0.08f
54
54
  /** Blurred copies per digit, from a touch of blur to the full one. */
55
55
  private const val NUMERIC_BLUR_LEVELS = 6
56
56
 
57
+ private fun isMainThread(): Boolean = Looper.myLooper() === Looper.getMainLooper()
58
+
57
59
  /** `RollingEngine::TextSlot`. */
58
60
  private const val TEXT_PREFIX = 0
59
61
  private const val TEXT_SUFFIX = 1
@@ -449,7 +451,20 @@ class NitroNumberView(context: Context) : View(context) {
449
451
  digitIndex * (NUMERIC_BLUR_LEVELS + 1) + level.coerceIn(0, NUMERIC_BLUR_LEVELS)
450
452
  digitMasks.get(slot)?.let { return it }
451
453
  val radius = if (level <= 0 || numericBlur <= 0f) 0 else Math.round(lineHeight * numericBlur * level / NUMERIC_BLUR_LEVELS).coerceAtLeast(1)
452
- val mask = BlurredGlyphCache.get("${key(role)}|$digitIndex|$radius|$blurPad") {
454
+ val cacheKey = "${key(role)}|$digitIndex|$radius|$blurPad"
455
+ if (radius > 0 && isMainThread()) {
456
+ // Not warmed yet (a font or size that just changed): blur it on the
457
+ // warm thread and draw the sharp mask this frame. A blur in onDraw was
458
+ // ANRing low-end phones, see [BlurredGlyphCache].
459
+ val ready = BlurredGlyphCache.peek(cacheKey)
460
+ if (ready == null) {
461
+ WarmExecutor.request(cacheKey) { blurred(role, digitIndex, level) }
462
+ return blurred(role, digitIndex, 0)
463
+ }
464
+ digitMasks.set(slot, ready)
465
+ return ready
466
+ }
467
+ val mask = BlurredGlyphCache.get(cacheKey) {
453
468
  val text = glyphs[digitIndex]
454
469
  val pad = blurPad
455
470
  val w = ceil(cell).toInt() + 2 * pad
@@ -463,7 +478,7 @@ class NitroNumberView(context: Context) : View(context) {
463
478
  val canvas = Canvas(mask)
464
479
  // A paint of its own: the masks are warmed off the main thread, where
465
480
  // the digit paint's alpha is being changed by the draws.
466
- val paint = TextPaint(paint(role)).apply { alpha = 255 }
481
+ val paint = TextPaint(threadPaint(role)).apply { alpha = 255 }
467
482
  canvas.drawText(text, pad + (cell - width(text, role)) / 2f, pad + digitBaseline(role), paint)
468
483
  if (radius > 0) boxBlurMask(mask, radius)
469
484
  // Immutable and uploaded ahead of its first draw: HWUI re-pins a mutable
@@ -471,7 +486,6 @@ class NitroNumberView(context: Context) : View(context) {
471
486
  // for its texture upload.
472
487
  val done = mask.copy(Bitmap.Config.ALPHA_8, false) ?: mask
473
488
  if (done !== mask) mask.recycle()
474
- done.prepareToDraw()
475
489
  done
476
490
  }
477
491
  digitMasks.set(slot, mask)
@@ -487,18 +501,25 @@ class NitroNumberView(context: Context) : View(context) {
487
501
  fun blurredText(text: String, role: GlyphRole, level: Int): Bitmap? {
488
502
  if (text.isEmpty() || lineHeight <= 0f) return null
489
503
  val radius = if (level <= 0 || numericBlur <= 0f) 0 else Math.round(lineHeight * numericBlur * level / NUMERIC_BLUR_LEVELS).coerceAtLeast(1)
490
- return BlurredGlyphCache.get("${key(role)}|t|$text|$radius|$blurPad") {
504
+ val cacheKey = "${key(role)}|t|$text|$radius|$blurPad"
505
+ if (radius > 0 && isMainThread()) {
506
+ // Never warmed ahead (any text can change into any other): blurred on
507
+ // the warm thread, sharp until it lands, as [blurred] does.
508
+ BlurredGlyphCache.peek(cacheKey)?.let { return it }
509
+ WarmExecutor.request(cacheKey) { blurredText(text, role, level) }
510
+ return blurredText(text, role, 0)
511
+ }
512
+ return BlurredGlyphCache.get(cacheKey) {
491
513
  val pad = blurPad
492
514
  val w = ceil(width(text, role)).toInt() + 2 * pad
493
515
  val h = ceil(lineHeight).toInt() + 2 * pad
494
516
  val mask = Bitmap.createBitmap(w.coerceAtLeast(1), h, Bitmap.Config.ALPHA_8)
495
517
  val canvas = Canvas(mask)
496
- val paint = TextPaint(paint(role)).apply { alpha = 255 }
518
+ val paint = TextPaint(threadPaint(role)).apply { alpha = 255 }
497
519
  canvas.drawText(text, pad.toFloat(), pad + baseline(role, text, 0f), paint)
498
520
  if (radius > 0) boxBlurMask(mask, radius)
499
521
  val done = mask.copy(Bitmap.Config.ALPHA_8, false) ?: mask
500
522
  if (done !== mask) mask.recycle()
501
- done.prepareToDraw()
502
523
  done
503
524
  }
504
525
  }
@@ -547,8 +568,10 @@ class NitroNumberView(context: Context) : View(context) {
547
568
  if (strip !== drawn) drawn.recycle()
548
569
  return strip
549
570
  }
550
- private val capHeightCache = HashMap<GlyphRole, Float>()
551
- private val inkDescentCache = HashMap<String, Float>()
571
+ // Concurrent: a prefix or suffix blurred on the warm thread ([blurredText])
572
+ // aligns itself through these while the UI thread draws through them.
573
+ private val capHeightCache = java.util.concurrent.ConcurrentHashMap<GlyphRole, Float>()
574
+ private val inkDescentCache = java.util.concurrent.ConcurrentHashMap<String, Float>()
552
575
 
553
576
  /** A fraction digit's baseline in the line box, at its alignment. */
554
577
  private val fractionBaseline: Float
@@ -560,6 +583,15 @@ class NitroNumberView(context: Context) : View(context) {
560
583
  * strips and masks are keyed by it.
561
584
  */
562
585
  private val roleKeys: Array<String>
586
+ /**
587
+ * Each role's paint as the font set was made, never changed after: what
588
+ * the warm thread measures and draws masks with. The UI thread changes the
589
+ * role paints' alpha as it draws, and a Paint promises no thread safety.
590
+ */
591
+ private val maskPaints: Array<TextPaint>
592
+
593
+ /** The paint to measure or draw [role] with on this thread: the UI thread's own, the warm thread's unchanging copy. */
594
+ private fun threadPaint(role: GlyphRole): TextPaint = if (isMainThread()) paint(role) else maskPaints[role.ordinal]
563
595
 
564
596
  init {
565
597
  for (d in 0..9) digitWidths[d] = width(glyphs[d], GlyphRole.DIGIT)
@@ -575,6 +607,7 @@ class NitroNumberView(context: Context) : View(context) {
575
607
  "${t.fontFamily}|${t.fontWeight}|${digit.textSize}|${p.textSize}|${p.color}|${p.typeface?.hashCode()}|${p.fontFeatureSettings}|" +
576
608
  "${role.name}|${alignment(role)}|${if (role == GlyphRole.PREFIX) prefixOffset else if (role == GlyphRole.SUFFIX) suffixOffset else 0f}|$glyphsKey"
577
609
  }
610
+ maskPaints = Array(GlyphRole.entries.size) { TextPaint(paint(GlyphRole.entries[it])).apply { alpha = 255 } }
578
611
  }
579
612
 
580
613
  private fun key(role: GlyphRole): String = roleKeys[role.ordinal]
@@ -600,7 +633,7 @@ class NitroNumberView(context: Context) : View(context) {
600
633
  // One map per role: a joined "role|text" key allocated a string on every
601
634
  // lookup, and the layout looks widths up for every glyph on every frame.
602
635
  fun width(text: String, role: GlyphRole): Float =
603
- widthCache[role.ordinal].getOrPut(text) { paint(role).measureText(text) }
636
+ widthCache[role.ordinal].getOrPut(text) { threadPaint(role).measureText(text) }
604
637
 
605
638
  private val shapedCache = Array(GlyphRole.entries.size) { java.util.concurrent.ConcurrentHashMap<String, ShapedText>() }
606
639
 
@@ -656,13 +689,13 @@ class NitroNumberView(context: Context) : View(context) {
656
689
  /** How far `text`'s ink hangs below the baseline (0 for digits and capitals). */
657
690
  private fun inkDescent(text: String, role: GlyphRole): Float = inkDescentCache.getOrPut(role.name + "|" + text) {
658
691
  val bounds = Rect()
659
- paint(role).getTextBounds(text, 0, text.length, bounds)
692
+ threadPaint(role).getTextBounds(text, 0, text.length, bounds)
660
693
  max(0, bounds.bottom).toFloat()
661
694
  }
662
695
 
663
696
  private fun capHeight(role: GlyphRole): Float = capHeightCache.getOrPut(role) {
664
697
  val bounds = Rect()
665
- paint(role).getTextBounds("0", 0, 1, bounds)
698
+ threadPaint(role).getTextBounds("0", 0, 1, bounds)
666
699
  -bounds.top.toFloat()
667
700
  }
668
701
  }
@@ -680,10 +713,16 @@ class NitroNumberView(context: Context) : View(context) {
680
713
  val w = mask.width
681
714
  val h = mask.height
682
715
  val stride = mask.rowBytes
683
- val bytes = java.nio.ByteBuffer.allocate(stride * h)
716
+ // Reused, not allocated per mask: two float copies of a large glyph went
717
+ // to the large-object heap, and a screenful of masks collected mid-frame.
718
+ val buffers = BlurBuffers.get(stride * h, w * h)
719
+ val bytes = buffers.bytes
720
+ bytes.clear()
721
+ bytes.limit(stride * h)
684
722
  mask.copyPixelsToBuffer(bytes)
685
- val alpha = FloatArray(w * h) { (bytes.get((it / w) * stride + it % w).toInt() and 0xff).toFloat() }
686
- val scratch = FloatArray(w * h)
723
+ val alpha = buffers.alpha
724
+ val scratch = buffers.scratch
725
+ for (i in 0 until w * h) alpha[i] = (bytes.get((i / w) * stride + i % w).toInt() and 0xff).toFloat()
687
726
  val window = (2 * radius + 1).toFloat()
688
727
  repeat(3) {
689
728
  // horizontal
@@ -706,7 +745,7 @@ class NitroNumberView(context: Context) : View(context) {
706
745
  }
707
746
  }
708
747
  }
709
- for (i in alpha.indices) bytes.put((i / w) * stride + i % w, Math.round(alpha[i]).coerceIn(0, 255).toByte())
748
+ for (i in 0 until w * h) bytes.put((i / w) * stride + i % w, Math.round(alpha[i]).coerceIn(0, 255).toByte())
710
749
  bytes.rewind()
711
750
  mask.copyPixelsFromBuffer(bytes)
712
751
  }
@@ -1142,16 +1181,105 @@ class NitroNumberView(context: Context) : View(context) {
1142
1181
  if (timing.transition != Transition.NUMERIC) return
1143
1182
  val set = fonts
1144
1183
  val fraction = format.fractionDigits > 0
1145
- WarmExecutor.execute {
1146
- for (digit in 0..9) for (level in 0..NUMERIC_BLUR_LEVELS) set.blurred(GlyphRole.DIGIT, digit, level)
1147
- if (fraction) for (digit in 0..9) for (level in 0..NUMERIC_BLUR_LEVELS) set.blurred(GlyphRole.FRACTION, digit, level)
1184
+ // One task a mask, so a mask the UI thread asks for meanwhile is made
1185
+ // next rather than after the whole set (70 to 140 blurs).
1186
+ val roles = if (fraction) listOf(GlyphRole.DIGIT, GlyphRole.FRACTION) else listOf(GlyphRole.DIGIT)
1187
+ for (role in roles) for (digit in 0..9) for (level in 0..NUMERIC_BLUR_LEVELS) {
1188
+ WarmExecutor.execute { set.blurred(role, digit, level) }
1148
1189
  }
1149
1190
  }
1150
1191
 
1151
- /** One background thread for warming glyph masks, shared by every view. */
1192
+ /**
1193
+ * One background thread for glyph masks, shared by every view. A mask the UI
1194
+ * thread is waiting on ([request]) goes to the front of the queue, ahead of
1195
+ * the ten-digits-at-every-level warm-ups ([execute]): behind a font change's
1196
+ * warm-up, the glyph on screen stayed sharp for its whole swap.
1197
+ *
1198
+ * At background priority plus one step (Glide's choice): below the UI
1199
+ * thread, not starved under load (Thread.MIN_PRIORITY is the lowest nice
1200
+ * level there is). A mask that cannot be made (out of memory, say) is
1201
+ * skipped, the glyph stays sharp, and it is not asked for again for a
1202
+ * while: an exception escaping a thread of its own takes the whole app down
1203
+ * on Android, and a failure retried every frame logged every frame. Any
1204
+ * other Error is a bug and is not swallowed.
1205
+ */
1152
1206
  private object WarmExecutor : java.util.concurrent.Executor {
1153
- private val pool = java.util.concurrent.Executors.newSingleThreadExecutor { r -> Thread(r, "NitroNumberWarm").apply { isDaemon = true; priority = Thread.MIN_PRIORITY } }
1154
- override fun execute(command: Runnable) = pool.execute(command)
1207
+ private val queue = java.util.concurrent.LinkedBlockingDeque<Runnable>()
1208
+ /** Masks the UI thread has asked for and the warm thread has not made yet. */
1209
+ private val pending = java.util.concurrent.ConcurrentHashMap.newKeySet<String>()
1210
+ /** When a mask last failed, by key: not asked for again until [RETRY_MS] later. */
1211
+ private val failed = java.util.concurrent.ConcurrentHashMap<String, Long>()
1212
+ private const val RETRY_MS = 2000L
1213
+
1214
+ init {
1215
+ Thread({
1216
+ android.os.Process.setThreadPriority(
1217
+ android.os.Process.THREAD_PRIORITY_BACKGROUND + android.os.Process.THREAD_PRIORITY_MORE_FAVORABLE
1218
+ )
1219
+ while (true) {
1220
+ val task = try {
1221
+ queue.take()
1222
+ } catch (_: InterruptedException) {
1223
+ continue
1224
+ }
1225
+ try {
1226
+ task.run()
1227
+ } catch (e: Exception) {
1228
+ android.util.Log.w("NitroNumber", "A glyph mask could not be made; the glyph is drawn sharp", e)
1229
+ } catch (e: OutOfMemoryError) {
1230
+ android.util.Log.w("NitroNumber", "Out of memory making a glyph mask; the glyph is drawn sharp", e)
1231
+ }
1232
+ }
1233
+ }, "NitroNumberWarm").apply {
1234
+ isDaemon = true
1235
+ start()
1236
+ }
1237
+ }
1238
+
1239
+ override fun execute(command: Runnable) {
1240
+ queue.offerLast(command)
1241
+ }
1242
+
1243
+ /** Makes [key]'s mask on the warm thread next, once however many frames ask for it while it is queued. */
1244
+ fun request(key: String, make: () -> Unit) {
1245
+ failed[key]?.let { if (SystemClock.uptimeMillis() - it < RETRY_MS) return }
1246
+ if (!pending.add(key)) return
1247
+ queue.offerFirst(
1248
+ Runnable {
1249
+ try {
1250
+ make()
1251
+ failed.remove(key)
1252
+ } catch (e: Exception) {
1253
+ failed[key] = SystemClock.uptimeMillis()
1254
+ throw e
1255
+ } catch (e: OutOfMemoryError) {
1256
+ failed[key] = SystemClock.uptimeMillis()
1257
+ throw e
1258
+ } finally {
1259
+ pending.remove(key)
1260
+ }
1261
+ }
1262
+ )
1263
+ }
1264
+ }
1265
+
1266
+ /** Per-thread buffers for [boxBlurMask], grown to the largest mask that thread has blurred. */
1267
+ private object BlurBuffers {
1268
+ class Buffers {
1269
+ var bytes: java.nio.ByteBuffer = java.nio.ByteBuffer.allocate(0)
1270
+ var alpha = FloatArray(0)
1271
+ var scratch = FloatArray(0)
1272
+ }
1273
+
1274
+ private val local = ThreadLocal.withInitial { Buffers() }
1275
+
1276
+ fun get(byteCount: Int, pixelCount: Int): Buffers = local.get()!!.apply {
1277
+ if (bytes.capacity() < byteCount) bytes = java.nio.ByteBuffer.allocate(byteCount)
1278
+ if (alpha.size < pixelCount) {
1279
+ alpha = FloatArray(pixelCount)
1280
+ scratch = FloatArray(pixelCount)
1281
+ }
1282
+ }
1155
1283
  }
1156
1284
 
1157
1285
  /**
@@ -2028,18 +2156,38 @@ class NitroNumberView(context: Context) : View(context) {
2028
2156
  private var bytes = 0L
2029
2157
 
2030
2158
  @Synchronized
2159
+ fun peek(key: String): Bitmap? = entries[key]
2160
+
2161
+ /**
2162
+ * [make] runs OUTSIDE the lock. Run inside it, the warm thread (then at
2163
+ * Thread.MIN_PRIORITY) held the lock through each blur, and the UI thread's
2164
+ * lookup in onDraw waited on it: ANRs with the main thread `Blocked` in
2165
+ * `get`. Two threads making the same key both make it; the second keeps
2166
+ * the first's bitmap and recycles its own, which nobody has seen.
2167
+ */
2031
2168
  fun get(key: String, make: () -> Bitmap): Bitmap {
2032
- entries[key]?.let { return it }
2169
+ peek(key)?.let { return it }
2033
2170
  val bitmap = make()
2034
- entries[key] = bitmap
2035
- bytes += bitmap.allocationByteCount
2036
- val eldest = entries.entries.iterator()
2037
- while (bytes > BUDGET && eldest.hasNext()) {
2038
- val entry = eldest.next()
2039
- if (entry.value === bitmap) break
2040
- bytes -= entry.value.allocationByteCount
2041
- eldest.remove()
2171
+ synchronized(this) {
2172
+ entries[key]?.let { existing ->
2173
+ bitmap.recycle()
2174
+ return existing
2175
+ }
2176
+ entries[key] = bitmap
2177
+ bytes += bitmap.allocationByteCount
2178
+ val eldest = entries.entries.iterator()
2179
+ while (bytes > BUDGET && eldest.hasNext()) {
2180
+ val entry = eldest.next()
2181
+ if (entry.value === bitmap) break
2182
+ bytes -= entry.value.allocationByteCount
2183
+ eldest.remove()
2184
+ }
2042
2185
  }
2186
+ // Immutable and uploaded ahead of its first draw: HWUI re-pins a mutable
2187
+ // bitmap at every sync, and the first frame that drew a fresh mask paid
2188
+ // for its texture upload. Only the one that is kept: a race's loser is
2189
+ // recycled above, unseen.
2190
+ bitmap.prepareToDraw()
2043
2191
  return bitmap
2044
2192
  }
2045
2193
  }
@@ -70,7 +70,12 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
70
70
  self?.onKeyPress?(key)
71
71
  }
72
72
  inputView.onIntrinsicSizeChange = { [weak self] size in
73
- self?.onSizeChange?(Double(size.width), Double(size.height))
73
+ guard let self else { return }
74
+ if !self.configured || self.committing {
75
+ self.sizeHeld = true
76
+ } else {
77
+ self.onSizeChange?(Double(size.width), Double(size.height))
78
+ }
74
79
  }
75
80
  }
76
81
 
@@ -112,7 +117,7 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
112
117
  var signPlacement: NitroInputSignPlacement = .beforeaffix { didSet { markConfigDirty() } }
113
118
  var prefixAlign: NitroInputAffixAlign = .baseline { didSet { markConfigDirty() } }
114
119
  var suffixAlign: NitroInputAffixAlign = .baseline { didSet { markConfigDirty() } }
115
- var letterSpacing: Double = 0 { didSet { markConfigDirty() } }
120
+ var textLetterSpacing: Double = 0 { didSet { markConfigDirty() } }
116
121
  var prefixSpacing: Double = .infinity { didSet { markConfigDirty() } }
117
122
  var suffixSpacing: Double = .infinity { didSet { markConfigDirty() } }
118
123
  var prefixOffset: Double = 0 { didSet { markConfigDirty() } }
@@ -123,12 +128,12 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
123
128
  var easing: NitroInputEasing = .expo { didSet { markConfigDirty() } }
124
129
  var bounce: Double = 0.15 { didSet { markConfigDirty() } }
125
130
  var effect: NitroInputEffect = .auto { didSet { markConfigDirty() } }
126
- var fontSize: Double = 32 { didSet { markConfigDirty() } }
127
- var lineHeight: Double = 0 { didSet { markConfigDirty() } }
128
- var fontWeight: Double = 400 { didSet { markConfigDirty() } }
129
- var fontFamily: String = "" { didSet { markConfigDirty() } }
130
- var color: Double = .nan { didSet { markConfigDirty() } }
131
- var textAlign: NitroInputTextAlign = .auto { didSet { markConfigDirty() } }
131
+ var textSize: Double = 32 { didSet { markConfigDirty() } }
132
+ var textLineHeight: Double = 0 { didSet { markConfigDirty() } }
133
+ var textWeight: Double = 400 { didSet { markConfigDirty() } }
134
+ var textFamily: String = "" { didSet { markConfigDirty() } }
135
+ var textColor: Double = .nan { didSet { markConfigDirty() } }
136
+ var textAlignment: NitroInputTextAlign = .auto { didSet { markConfigDirty() } }
132
137
  var rightToLeft: Bool = false { didSet { markConfigDirty() } }
133
138
  var caretColor: Double = .nan { didSet { markConfigDirty() } }
134
139
  var selectionColor: Double = .nan { didSet { markConfigDirty() } }
@@ -144,7 +149,13 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
144
149
  var editable: Bool = true { didSet { markConfigDirty() } }
145
150
  var multiline: Bool = false { didSet { markConfigDirty() } }
146
151
  var numberOfLines: Double = 0 { didSet { markConfigDirty() } }
147
- var textAlignVertical: NitroInputTextAlignVertical = .auto { didSet { markConfigDirty() } }
152
+ var textVerticalAlignment: NitroInputTextAlignVertical = .auto { didSet { markConfigDirty() } }
153
+ /// The style's padding and border. Android insets its content by them; on
154
+ /// iOS React Native already lays the view's content out inside them.
155
+ var textInsetLeft: Double = 0
156
+ var textInsetTop: Double = 0
157
+ var textInsetRight: Double = 0
158
+ var textInsetBottom: Double = 0
148
159
  var scrollEnabled: Bool = true { didSet { markConfigDirty() } }
149
160
  var autoFocus: Bool = false { didSet { markConfigDirty() } }
150
161
  var fieldTestID: String = "" { didSet { markConfigDirty() } }
@@ -181,7 +192,7 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
181
192
  var onSelectionChange: ((Double, Double) -> Void)?
182
193
  var onKeyPress: ((String) -> Void)?
183
194
  var onSizeChange: ((Double, Double) -> Void)? {
184
- didSet { onMain { self.inputView.resendIntrinsicSize() } }
195
+ didSet { onMain { if self.configured { self.inputView.resendIntrinsicSize() } } }
185
196
  }
186
197
 
187
198
  // MARK: - Methods
@@ -325,7 +336,7 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
325
336
  signPlacement = .beforeaffix
326
337
  prefixAlign = .baseline
327
338
  suffixAlign = .baseline
328
- letterSpacing = 0
339
+ textLetterSpacing = 0
329
340
  prefixSpacing = .infinity
330
341
  suffixSpacing = .infinity
331
342
  prefixOffset = 0
@@ -336,12 +347,12 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
336
347
  easing = .expo
337
348
  bounce = 0.15
338
349
  effect = .auto
339
- fontSize = 32
340
- lineHeight = 0
341
- fontWeight = 400
342
- fontFamily = ""
343
- color = .nan
344
- textAlign = .auto
350
+ textSize = 32
351
+ textLineHeight = 0
352
+ textWeight = 400
353
+ textFamily = ""
354
+ textColor = .nan
355
+ textAlignment = .auto
345
356
  rightToLeft = false
346
357
  caretColor = .nan
347
358
  selectionColor = .nan
@@ -357,7 +368,11 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
357
368
  editable = true
358
369
  multiline = false
359
370
  numberOfLines = 0
360
- textAlignVertical = .auto
371
+ textVerticalAlignment = .auto
372
+ textInsetLeft = 0
373
+ textInsetTop = 0
374
+ textInsetRight = 0
375
+ textInsetBottom = 0
361
376
  scrollEnabled = true
362
377
  autoFocus = false
363
378
  fieldTestID = ""
@@ -401,7 +416,10 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
401
416
  snapshotLock.lock()
402
417
  snapshot = Snapshot()
403
418
  snapshotLock.unlock()
404
- onMain { self.inputView.resetForRecycle() }
419
+ onMain {
420
+ self.configured = false
421
+ self.inputView.resetForRecycle()
422
+ }
405
423
  }
406
424
 
407
425
  // MARK: - Batching
@@ -425,11 +443,32 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
425
443
  if !isBatching { commit() }
426
444
  }
427
445
 
446
+ /// Whether the props have been applied since the view was made or recycled.
447
+ /// Until then its size is the defaults' (or the last element's), and JS,
448
+ /// which lays the field out at its measured size from the first commit, must
449
+ /// not see it: a stray report made the field jump to it and back.
450
+ private var configured = false
451
+ /// Inside `commit`, where a size is of half-applied props (the config
452
+ /// applied, the text not yet).
453
+ private var committing = false
454
+ /// A size was held back by the two above, so the settled one is sent after.
455
+ private var sizeHeld = false
456
+
428
457
  private func commit() {
429
458
  onMain {
430
- self.flushConfigIfNeeded()
431
- self.applyTextIfNeeded()
432
- self.applySelectionIfNeeded()
459
+ self.committing = true
460
+ self.inputView.batch {
461
+ self.flushConfigIfNeeded()
462
+ self.applyTextIfNeeded()
463
+ self.applySelectionIfNeeded()
464
+ }
465
+ self.committing = false
466
+ // Once after the first commit, so JS always hears the view's size.
467
+ if !self.configured || self.sizeHeld {
468
+ self.configured = true
469
+ self.sizeHeld = false
470
+ self.inputView.resendIntrinsicSize()
471
+ }
433
472
  }
434
473
  }
435
474
 
@@ -519,54 +558,18 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
519
558
  guard configDirty else { return }
520
559
  configDirty = false
521
560
 
522
- var format = NitroInputView.Format()
523
- switch mode {
524
- case .number: format.mode = .number
525
- case .mask: format.mode = .mask
526
- case .text: format.mode = .text
527
- }
528
- format.mask = mask
529
- format.maskNotations = maskNotations.map {
530
- NitroInputView.MaskNotation(character: $0.character, characterSet: $0.characterSet, isOptional: $0.isOptional)
531
- }
532
- format.maskAutocomplete = maskAutocomplete
533
- format.maskAutoSkip = maskAutoSkip
534
- format.maskAffinityFormats = maskAffinityFormats
535
- format.maskAffinityStrategy = Int(maskAffinityStrategy.rawValue)
536
- format.maskTextCase = Int(maskTextCase.rawValue)
537
- format.maskCharacterMap = maskCharacterMap.map { NitroInputView.MaskMapping(from: $0.from, to: $0.to) }
538
- format.maskSlotPlaceholder = maskSlotPlaceholder
539
- format.keepPlaceholder = keepPlaceholder
540
- format.fractionDigits = Self.clampInt(fractionDigits, 0, 9, fallback: 2)
541
- format.maxIntegerDigits = Self.clampInt(maxIntegerDigits, 1, 30, fallback: 15)
542
- format.groupingSeparator = groupingSeparator
543
- format.decimalSeparator = decimalSeparator.isEmpty ? "." : decimalSeparator
544
- format.prefix = prefix
545
- format.suffix = suffix
546
- format.signPlacement = signPlacement == .afteraffix ? .afterAffix : .beforeAffix
547
- format.placeholder = placeholder
548
- format.maxLength = Self.clampInt(maxLength, 0, 1_000_000, fallback: 0)
549
-
550
- var typography = NitroInputView.Typography()
551
- typography.fontSize = CGFloat(fontSize.isFinite && fontSize > 0 ? fontSize : 32)
552
- typography.lineHeight = CGFloat(lineHeight.isFinite && lineHeight > 0 ? lineHeight : 0)
553
- typography.prefixFontSize = prefixFontSize.isFinite && prefixFontSize > 0 ? CGFloat(prefixFontSize) : nil
554
- typography.suffixFontSize = suffixFontSize.isFinite && suffixFontSize > 0 ? CGFloat(suffixFontSize) : nil
555
- typography.fontWeight = CGFloat(fontWeight.isFinite ? fontWeight : 400)
556
- typography.fontFamily = fontFamily.isEmpty ? nil : fontFamily
557
- typography.color = Self.color(fromARGB: color) ?? .label
561
+ // The sizing half of the mapping is shared with HybridNitroInputMeasure,
562
+ // which sizes the field before this view exists (InputSizing.swift).
563
+ let format = InputMapping.format(self)
564
+ var typography = InputMapping.sizingTypography(self)
565
+ typography.color = Self.color(fromARGB: textColor) ?? .label
558
566
  typography.placeholderColor = Self.color(fromARGB: placeholderColor) ?? .placeholderText
559
567
  typography.prefixAlign = Self.mapAffixAlign(prefixAlign)
560
568
  typography.suffixAlign = Self.mapAffixAlign(suffixAlign)
561
- typography.letterSpacing = CGFloat(letterSpacing.isFinite ? letterSpacing : 0)
562
- typography.prefixSpacing = prefixSpacing.isFinite ? CGFloat(prefixSpacing) : nil
563
- typography.suffixSpacing = suffixSpacing.isFinite ? CGFloat(suffixSpacing) : nil
564
569
  typography.prefixOffset = CGFloat(prefixOffset.isFinite ? prefixOffset : 0)
565
570
  typography.suffixOffset = CGFloat(suffixOffset.isFinite ? suffixOffset : 0)
566
571
  typography.adjustsFontSizeToFit = adjustsFontSizeToFit
567
572
  typography.minimumFontScale = CGFloat(min(1, max(0.05, minimumFontScale.isFinite ? minimumFontScale : 0.5)))
568
- typography.allowFontScaling = allowFontScaling
569
- typography.maxFontSizeMultiplier = CGFloat(max(0, maxFontSizeMultiplier.isFinite ? maxFontSizeMultiplier : 0))
570
573
 
571
574
  var timing = NitroInputView.Timing()
572
575
  timing.duration = max(0, (duration.isFinite ? duration : 400) / 1000)
@@ -582,7 +585,7 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
582
585
  traits.editable = editable
583
586
  traits.multiline = multiline
584
587
  traits.numberOfLines = numberOfLines.isFinite ? max(0, Int(numberOfLines)) : 0
585
- traits.textAlignVertical = switch textAlignVertical {
588
+ traits.textAlignVertical = switch textVerticalAlignment {
586
589
  case .top: .top
587
590
  case .center: .center
588
591
  case .bottom: .bottom
@@ -620,28 +623,19 @@ final class HybridNitroInputView: HybridNitroInputViewSpec, RecyclableView {
620
623
  worklets.onKeyPress = Self.clampInt(onKeyPressWorklet, 0, Int(Int32.max), fallback: 0)
621
624
 
622
625
  inputView.typography = typography
623
- var inputFrame = NitroInputView.Frame()
624
- switch variant {
625
- case .outlined: inputFrame.variant = .outlined
626
- case .filled: inputFrame.variant = .filled
627
- case .none: inputFrame.variant = .none
628
- }
629
- inputFrame.label = label
630
- inputFrame.labelBehavior = labelBehavior == .always ? .always : .float
626
+ var inputFrame = InputMapping.sizingFrame(self)
631
627
  inputFrame.labelColor = Self.color(fromARGB: labelColor)
632
628
  inputFrame.labelFocusedColor = Self.color(fromARGB: labelFocusedColor)
633
- inputFrame.labelFontSize = labelFontSize.isFinite ? max(0, CGFloat(labelFontSize)) : 0
634
629
  inputFrame.strokeColor = Self.color(fromARGB: strokeColor)
635
630
  inputFrame.focusedStrokeColor = Self.color(fromARGB: focusedStrokeColor)
636
631
  inputFrame.strokeWidth = strokeWidth.isFinite ? max(0, CGFloat(strokeWidth)) : 1
637
- inputFrame.cornerRadius = cornerRadius.isFinite ? max(0, CGFloat(cornerRadius)) : 8
638
632
  inputFrame.fillColor = Self.color(fromARGB: fillColor)
639
633
  inputView.inputFrame = inputFrame
640
634
  inputView.format = format
641
635
  inputView.timing = timing
642
636
  inputView.traits = traits
643
637
  inputView.worklets = worklets
644
- inputView.alignment = Self.mapAlignment(textAlign)
638
+ inputView.alignment = Self.mapAlignment(textAlignment)
645
639
  // Fabric does not hand a Hybrid View its layout direction, so JS resolves
646
640
  // it and the view is told outright; `effectiveUserInterfaceLayoutDirection`
647
641
  // then reads it back for everything that has an edge.
@@ -90,13 +90,13 @@ final class HybridNitroNumberView: HybridNitroNumberViewSpec, RecyclableView {
90
90
  var shimmerBaseColor: Double? { didSet { markConfigDirty() } }
91
91
  var shimmerDirection: NitroNumberShimmerDirection? { didSet { markConfigDirty() } }
92
92
  var shimmerDelay: Double? { didSet { markConfigDirty() } }
93
- var fontSize: Double? { didSet { markConfigDirty() } }
93
+ var textSize: Double? { didSet { markConfigDirty() } }
94
94
  var prefixFontSize: Double? { didSet { markConfigDirty() } }
95
95
  var suffixFontSize: Double? { didSet { markConfigDirty() } }
96
96
  var affixAlign: NitroNumberAffixAlign? { didSet { markConfigDirty() } }
97
97
  var prefixAlign: NitroNumberAffixAlign? { didSet { markConfigDirty() } }
98
98
  var suffixAlign: NitroNumberAffixAlign? { didSet { markConfigDirty() } }
99
- var letterSpacing: Double? { didSet { markConfigDirty() } }
99
+ var textLetterSpacing: Double? { didSet { markConfigDirty() } }
100
100
  var prefixSpacing: Double? { didSet { markConfigDirty() } }
101
101
  var suffixSpacing: Double? { didSet { markConfigDirty() } }
102
102
  var prefixOffset: Double? { didSet { markConfigDirty() } }
@@ -121,10 +121,10 @@ final class HybridNitroNumberView: HybridNitroNumberViewSpec, RecyclableView {
121
121
  var minimumFontScale: Double? { didSet { markConfigDirty() } }
122
122
  var allowFontScaling: Bool? { didSet { markConfigDirty() } }
123
123
  var maxFontSizeMultiplier: Double? { didSet { markConfigDirty() } }
124
- var fontWeight: Double? { didSet { markConfigDirty() } }
125
- var fontFamily: String? { didSet { markConfigDirty() } }
126
- var color: Double? { didSet { markConfigDirty() } }
127
- var textAlign: NitroNumberTextAlign? { didSet { markConfigDirty() } }
124
+ var textWeight: Double? { didSet { markConfigDirty() } }
125
+ var textFamily: String? { didSet { markConfigDirty() } }
126
+ var textColor: Double? { didSet { markConfigDirty() } }
127
+ var textAlignment: NitroNumberTextAlign? { didSet { markConfigDirty() } }
128
128
  var rightToLeft: Bool? { didSet { markConfigDirty() } }
129
129
  var onSizeChange: ((Double, Double) -> Void)? {
130
130
  didSet { onMain { self.rollingView.resendIntrinsicSize() } }
@@ -256,13 +256,13 @@ final class HybridNitroNumberView: HybridNitroNumberViewSpec, RecyclableView {
256
256
  shimmerBaseColor = nil
257
257
  shimmerDirection = nil
258
258
  shimmerDelay = nil
259
- fontSize = nil
259
+ textSize = nil
260
260
  prefixFontSize = nil
261
261
  suffixFontSize = nil
262
262
  affixAlign = nil
263
263
  prefixAlign = nil
264
264
  suffixAlign = nil
265
- letterSpacing = nil
265
+ textLetterSpacing = nil
266
266
  prefixSpacing = nil
267
267
  suffixSpacing = nil
268
268
  prefixOffset = nil
@@ -287,10 +287,10 @@ final class HybridNitroNumberView: HybridNitroNumberViewSpec, RecyclableView {
287
287
  minimumFontScale = nil
288
288
  allowFontScaling = nil
289
289
  maxFontSizeMultiplier = nil
290
- fontWeight = nil
291
- fontFamily = nil
292
- color = nil
293
- textAlign = nil
290
+ textWeight = nil
291
+ textFamily = nil
292
+ textColor = nil
293
+ textAlignment = nil
294
294
  rightToLeft = nil
295
295
  onSizeChange = nil
296
296
  configDirty = true
@@ -359,16 +359,16 @@ final class HybridNitroNumberView: HybridNitroNumberViewSpec, RecyclableView {
359
359
  format.digitMax = (digitMax ?? []).map { $0.isFinite ? Int($0.rounded()) : 9 }
360
360
 
361
361
  var typography = NitroNumberView.Typography()
362
- typography.fontSize = CGFloat(fontSize ?? 32)
362
+ typography.fontSize = CGFloat(textSize ?? 32)
363
363
  typography.prefixFontSize = prefixFontSize.map { CGFloat($0) }
364
364
  typography.suffixFontSize = suffixFontSize.map { CGFloat($0) }
365
- typography.fontWeight = CGFloat(fontWeight ?? 400)
366
- typography.fontFamily = fontFamily
367
- typography.color = color.map(Self.color(fromARGB:)) ?? .label
365
+ typography.fontWeight = CGFloat(textWeight ?? 400)
366
+ typography.fontFamily = textFamily
367
+ typography.color = textColor.map(Self.color(fromARGB:)) ?? .label
368
368
  let sharedAlign = Self.mapAffixAlign(affixAlign)
369
369
  typography.prefixAlign = prefixAlign.map { Self.mapAffixAlign($0) } ?? sharedAlign
370
370
  typography.suffixAlign = suffixAlign.map { Self.mapAffixAlign($0) } ?? sharedAlign
371
- typography.letterSpacing = CGFloat((letterSpacing ?? 0).isFinite ? letterSpacing ?? 0 : 0)
371
+ typography.letterSpacing = CGFloat((textLetterSpacing ?? 0).isFinite ? textLetterSpacing ?? 0 : 0)
372
372
  typography.prefixSpacing = prefixSpacing.flatMap { $0.isFinite ? CGFloat($0) : nil }
373
373
  typography.suffixSpacing = suffixSpacing.flatMap { $0.isFinite ? CGFloat($0) : nil }
374
374
  typography.prefixOffset = CGFloat((prefixOffset ?? 0).isFinite ? prefixOffset ?? 0 : 0)
@@ -426,7 +426,7 @@ final class HybridNitroNumberView: HybridNitroNumberViewSpec, RecyclableView {
426
426
  rollingView.timing = timing
427
427
  rollingView.revealMilestones = revealMilestones ?? []
428
428
  rollingView.shimmer = shimmer
429
- rollingView.alignment = Self.mapAlignment(textAlign)
429
+ rollingView.alignment = Self.mapAlignment(textAlignment)
430
430
  // Fabric does not hand a Hybrid View its layout direction, so JS resolves
431
431
  // it and the view is told outright; `effectiveUserInterfaceLayoutDirection`
432
432
  // then reads it back for the alignment and the affixes.