@whetware/react-native-stroke-text 0.0.13 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @whetware/react-native-stroke-text
2
2
 
3
+ ## 0.0.15
4
+
5
+ ### Patch Changes
6
+
7
+ - [`57b743f`](https://github.com/whetware/react-native-stroke-text/commit/57b743f53c5ef6777be9564d38d2d95c5facb13b) Thanks [@evelant](https://github.com/evelant)! - Keep the native `textTransform` prop concrete during Android measured-line updates so Fabric never sends Nitro a null enum value.
8
+
3
9
  ## 0.0.13
4
10
 
5
11
  ### Patch Changes
package/lib/StrokeText.js CHANGED
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { Platform, StyleSheet, Text, View } from 'react-native';
3
3
  import { callback, getHostComponent } from 'react-native-nitro-modules';
4
4
  import StrokeTextViewConfig from '../nitrogen/generated/shared/json/StrokeTextViewConfig.json';
5
+ import { resolveNativeTextTransform } from './resolveNativeTextTransform';
5
6
  const NativeStrokeTextView = getHostComponent('StrokeTextView', () => StrokeTextViewConfig);
6
7
  function resolveText(text, children) {
7
8
  if (typeof text === 'string')
@@ -113,7 +114,7 @@ export function StrokeText({ text, children, style, hybridRef, ...rest }) {
113
114
  const shouldSyncMeasuredLineBreaks = Platform.OS === 'android' && effectiveNumberOfLines == null;
114
115
  const [measuredNativeText, setMeasuredNativeText] = React.useState(undefined);
115
116
  const nativeText = measuredNativeText ?? resolvedText;
116
- const nativeTextTransform = measuredNativeText == null ? effectiveTextTransform : 'none';
117
+ const nativeTextTransform = resolveNativeTextTransform(effectiveTextTransform, measuredNativeText != null);
117
118
  // RN's hidden Text owns measurement, but Android TextView gets its own layout pass.
118
119
  // Compensate for the native stroke inset on every edge, then give that native
119
120
  // pass extra right-side room so one-pixel/font-metric drift cannot turn an RN
@@ -0,0 +1,7 @@
1
+ import type { StrokeTextTransform } from './specs/StrokeTextView.nitro';
2
+ /**
3
+ * Keep the Fabric host prop concrete across text-measurement state changes.
4
+ * React Native represents a removed prop as null during native updates, while
5
+ * Nitro's optional enum converter accepts undefined but rejects null.
6
+ */
7
+ export declare function resolveNativeTextTransform(effectiveTextTransform: StrokeTextTransform | undefined, hasMeasuredNativeText: boolean): StrokeTextTransform;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Keep the Fabric host prop concrete across text-measurement state changes.
3
+ * React Native represents a removed prop as null during native updates, while
4
+ * Nitro's optional enum converter accepts undefined but rejects null.
5
+ */
6
+ export function resolveNativeTextTransform(effectiveTextTransform, hasMeasuredNativeText) {
7
+ return hasMeasuredNativeText ? 'none' : (effectiveTextTransform ?? 'none');
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whetware/react-native-stroke-text",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "Stroke/outline text for React Native (New Architecture) on iOS, Android, and Web.",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -33,6 +33,7 @@
33
33
  "clean": "rm -rf android/build node_modules/**/android/build lib",
34
34
  "lint": "eslint \"**/*.{js,ts,tsx}\" --fix",
35
35
  "lint-ci": "eslint \"**/*.{js,ts,tsx}\"",
36
+ "test": "tsc && node --test test/*.test.mjs",
36
37
  "typescript": "tsc",
37
38
  "prepare": "npm run prepack",
38
39
  "prepack": "tsc",
@@ -121,4 +122,4 @@
121
122
  "useTabs": false,
122
123
  "semi": false
123
124
  }
124
- }
125
+ }