react-native-laminar 1.4.2 → 1.4.3

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 (35) hide show
  1. package/lib/commonjs/hooks/use-inline-auto-width.js +105 -18
  2. package/lib/commonjs/hooks/use-inline-auto-width.js.map +1 -1
  3. package/lib/commonjs/index.js +5 -1
  4. package/lib/commonjs/index.js.map +1 -1
  5. package/lib/commonjs/view/morph-viewport.js +2 -0
  6. package/lib/commonjs/view/morph-viewport.js.map +1 -1
  7. package/lib/commonjs/view/text-run.js +30 -12
  8. package/lib/commonjs/view/text-run.js.map +1 -1
  9. package/lib/module/hooks/use-inline-auto-width.js +106 -19
  10. package/lib/module/hooks/use-inline-auto-width.js.map +1 -1
  11. package/lib/module/index.js +5 -1
  12. package/lib/module/index.js.map +1 -1
  13. package/lib/module/view/morph-viewport.js +2 -0
  14. package/lib/module/view/morph-viewport.js.map +1 -1
  15. package/lib/module/view/text-run.js +30 -12
  16. package/lib/module/view/text-run.js.map +1 -1
  17. package/lib/typescript/commonjs/hooks/use-inline-auto-width.d.ts +2 -0
  18. package/lib/typescript/commonjs/hooks/use-inline-auto-width.d.ts.map +1 -1
  19. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  20. package/lib/typescript/commonjs/view/morph-viewport.d.ts +3 -2
  21. package/lib/typescript/commonjs/view/morph-viewport.d.ts.map +1 -1
  22. package/lib/typescript/commonjs/view/text-run.d.ts +2 -1
  23. package/lib/typescript/commonjs/view/text-run.d.ts.map +1 -1
  24. package/lib/typescript/module/hooks/use-inline-auto-width.d.ts +2 -0
  25. package/lib/typescript/module/hooks/use-inline-auto-width.d.ts.map +1 -1
  26. package/lib/typescript/module/index.d.ts.map +1 -1
  27. package/lib/typescript/module/view/morph-viewport.d.ts +3 -2
  28. package/lib/typescript/module/view/morph-viewport.d.ts.map +1 -1
  29. package/lib/typescript/module/view/text-run.d.ts +2 -1
  30. package/lib/typescript/module/view/text-run.d.ts.map +1 -1
  31. package/package.json +1 -1
  32. package/src/hooks/use-inline-auto-width.ts +160 -18
  33. package/src/index.tsx +10 -1
  34. package/src/view/morph-viewport.tsx +7 -2
  35. package/src/view/text-run.tsx +49 -15
@@ -15,10 +15,19 @@ const useInlineAutoWidth = ({
15
15
  measurementKey
16
16
  }) => {
17
17
  const widthValue = (0, _reactNativeReanimated.useSharedValue)(0);
18
+ const hasBootstrappedWidth = (0, _reactNativeReanimated.useSharedValue)(false);
18
19
  const measuredWidthRef = (0, _react.useRef)(null);
19
20
  const bootstrappedRef = (0, _react.useRef)(false);
20
21
  const widthCacheRef = (0, _react.useRef)(new Map());
21
- const [hasBootstrappedWidth, setHasBootstrappedWidth] = (0, _react.useState)(false);
22
+ const hasCapturedVisibleLayoutRef = (0, _react.useRef)(false);
23
+ const initialMeasurementKeyRef = (0, _react.useRef)(null);
24
+ const firstProbeRef = (0, _react.useRef)(null);
25
+ const latestProbeRef = (0, _react.useRef)(null);
26
+ const bootstrapTimerRef = (0, _react.useRef)(null);
27
+ const [readyMeasurementKey, setReadyMeasurementKey] = (0, _react.useState)(null);
28
+ const markMeasurementReady = (0, _react.useCallback)(key => {
29
+ setReadyMeasurementKey(currentKey => currentKey === key ? currentKey : key);
30
+ }, []);
22
31
 
23
32
  // the first measurement establishes the shell without animating from zero
24
33
  const applyWidth = (0, _react.useCallback)(nextWidth => {
@@ -29,11 +38,62 @@ const useInlineAutoWidth = ({
29
38
  if (!bootstrappedRef.current) {
30
39
  bootstrappedRef.current = true;
31
40
  widthValue.value = nextWidth;
32
- setHasBootstrappedWidth(true);
41
+ hasBootstrappedWidth.value = true;
33
42
  return;
34
43
  }
35
44
  widthValue.value = driveToWidth(nextWidth);
36
45
  }, [driveToWidth, widthValue]);
46
+ const bootstrapFromProbe = (0, _react.useCallback)(() => {
47
+ bootstrapTimerRef.current = null;
48
+ if (hasCapturedVisibleLayoutRef.current) {
49
+ return;
50
+ }
51
+ const firstProbe = firstProbeRef.current;
52
+ if (!firstProbe) {
53
+ return;
54
+ }
55
+
56
+ // The visible layout did not arrive in time, so use the first probe as a
57
+ // safe fallback. A later probe can still animate from this baseline.
58
+ hasCapturedVisibleLayoutRef.current = true;
59
+ initialMeasurementKeyRef.current = firstProbe.key;
60
+ applyWidth(firstProbe.width);
61
+ const latestProbe = latestProbeRef.current;
62
+ if (latestProbe && latestProbe.key !== firstProbe.key) {
63
+ // The target width is already cached. Defer its animation until the
64
+ // ready render so the shell and the new glyph row start together.
65
+ markMeasurementReady(latestProbe.key);
66
+ } else {
67
+ markMeasurementReady(firstProbe.key);
68
+ }
69
+ }, [applyWidth, markMeasurementReady]);
70
+ const captureVisibleLayout = (0, _react.useCallback)(event => {
71
+ if (!enabled || hasCapturedVisibleLayoutRef.current) {
72
+ return;
73
+ }
74
+ if (bootstrapTimerRef.current !== null) {
75
+ clearTimeout(bootstrapTimerRef.current);
76
+ bootstrapTimerRef.current = null;
77
+ }
78
+ hasCapturedVisibleLayoutRef.current = true;
79
+ // bootstrap from the visible tree so the first explicit width matches
80
+ // the geometry that was already painted to the user
81
+ const nextWidth = Math.max(0, event.nativeEvent.layout.width);
82
+ // retain the visible width for the initial key so a later cache hit does
83
+ // not reintroduce the probe-to-visible mismatch
84
+ widthCacheRef.current.delete(measurementKey);
85
+ widthCacheRef.current.set(measurementKey, nextWidth);
86
+ const firstProbe = firstProbeRef.current;
87
+ if (firstProbe && firstProbe.key !== measurementKey) {
88
+ initialMeasurementKeyRef.current = firstProbe.key;
89
+ applyWidth(firstProbe.width);
90
+ markMeasurementReady(measurementKey);
91
+ return;
92
+ }
93
+ initialMeasurementKeyRef.current = measurementKey;
94
+ applyWidth(nextWidth);
95
+ markMeasurementReady(measurementKey);
96
+ }, [applyWidth, enabled, markMeasurementReady, measurementKey]);
37
97
  const captureLayout = (0, _react.useCallback)(event => {
38
98
  if (!enabled) {
39
99
  return;
@@ -41,36 +101,63 @@ const useInlineAutoWidth = ({
41
101
 
42
102
  // round up so fractional native measurements cannot clip the final glyph
43
103
  const nextWidth = Math.max(0, Math.ceil(event.nativeEvent.layout.width));
44
-
45
- // delete before setting so a repeated key moves to the most recent position
46
- widthCacheRef.current.delete(measurementKey);
47
- if (widthCacheRef.current.size >= WIDTH_CACHE_LIMIT) {
48
- // map insertion order gives the lru entry at the front
49
- const oldestKey = widthCacheRef.current.keys().next().value;
50
- if (oldestKey !== undefined) {
51
- widthCacheRef.current.delete(oldestKey);
104
+ const isInitialMeasurement = initialMeasurementKeyRef.current === measurementKey;
105
+ if (!isInitialMeasurement) {
106
+ // delete before setting so a repeated key moves to the most recent position
107
+ widthCacheRef.current.delete(measurementKey);
108
+ if (widthCacheRef.current.size >= WIDTH_CACHE_LIMIT) {
109
+ // map insertion order gives the lru entry at the front
110
+ const oldestKey = widthCacheRef.current.keys().next().value;
111
+ if (oldestKey !== undefined) {
112
+ widthCacheRef.current.delete(oldestKey);
113
+ }
52
114
  }
115
+ widthCacheRef.current.set(measurementKey, nextWidth);
53
116
  }
54
- widthCacheRef.current.set(measurementKey, nextWidth);
55
- applyWidth(nextWidth);
56
- }, [applyWidth, enabled, measurementKey]);
117
+ const probe = {
118
+ key: measurementKey,
119
+ width: nextWidth
120
+ };
121
+ if (!firstProbeRef.current) {
122
+ firstProbeRef.current = probe;
123
+ }
124
+ latestProbeRef.current = probe;
125
+ if (!hasCapturedVisibleLayoutRef.current && bootstrapTimerRef.current === null) {
126
+ bootstrapTimerRef.current = setTimeout(bootstrapFromProbe, 0);
127
+ }
128
+
129
+ // Do not let the initial probe override the visible first frame.
130
+ if (hasCapturedVisibleLayoutRef.current && !isInitialMeasurement) {
131
+ // captureLayout only records the target. The cache effect applies the
132
+ // animation during the render that releases the new glyph row.
133
+ markMeasurementReady(measurementKey);
134
+ }
135
+ }, [applyWidth, bootstrapFromProbe, enabled, markMeasurementReady, measurementKey]);
57
136
  const cachedWidth = widthCacheRef.current.get(measurementKey);
58
137
 
59
138
  // a cached width can restore the shell before the hidden probe renders again
60
- (0, _react.useEffect)(() => {
61
- if (enabled && cachedWidth !== undefined) {
139
+ (0, _react.useLayoutEffect)(() => {
140
+ if (enabled && cachedWidth !== undefined && hasCapturedVisibleLayoutRef.current) {
62
141
  // promote cache hits so active states stay available longer
63
142
  widthCacheRef.current.delete(measurementKey);
64
143
  widthCacheRef.current.set(measurementKey, cachedWidth);
65
144
  applyWidth(cachedWidth);
145
+ markMeasurementReady(measurementKey);
146
+ }
147
+ }, [applyWidth, cachedWidth, enabled, markMeasurementReady, measurementKey]);
148
+ (0, _react.useEffect)(() => () => {
149
+ if (bootstrapTimerRef.current !== null) {
150
+ clearTimeout(bootstrapTimerRef.current);
66
151
  }
67
- }, [applyWidth, cachedWidth, enabled, measurementKey]);
68
- const animatedWidthStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => enabled && hasBootstrappedWidth ? {
152
+ }, []);
153
+ const animatedWidthStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => enabled && hasBootstrappedWidth.value ? {
69
154
  width: widthValue.value
70
- } : {}, [enabled, hasBootstrappedWidth]);
155
+ } : {}, [enabled]);
71
156
  return {
72
157
  captureLayout,
158
+ captureVisibleLayout,
73
159
  animatedWidthStyle,
160
+ isReady: !enabled || cachedWidth !== undefined || readyMeasurementKey === measurementKey,
74
161
  shouldMeasure: enabled && cachedWidth === undefined
75
162
  };
76
163
  };
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_reactNativeReanimated","WIDTH_CACHE_LIMIT","useInlineAutoWidth","enabled","driveToWidth","measurementKey","widthValue","useSharedValue","measuredWidthRef","useRef","bootstrappedRef","widthCacheRef","Map","hasBootstrappedWidth","setHasBootstrappedWidth","useState","applyWidth","useCallback","nextWidth","current","value","captureLayout","event","Math","max","ceil","nativeEvent","layout","width","delete","size","oldestKey","keys","next","undefined","set","cachedWidth","get","useEffect","animatedWidthStyle","useAnimatedStyle","shouldMeasure","exports"],"sourceRoot":"../../../src","sources":["hooks/use-inline-auto-width.ts"],"mappings":";;;;;;AAAA,IAAA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,KAAKF;EAC5C,CAAC;AACH,CAAC;AAACQ,OAAA,CAAAxC,kBAAA,GAAAA,kBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","_reactNativeReanimated","WIDTH_CACHE_LIMIT","useInlineAutoWidth","enabled","driveToWidth","measurementKey","widthValue","useSharedValue","hasBootstrappedWidth","measuredWidthRef","useRef","bootstrappedRef","widthCacheRef","Map","hasCapturedVisibleLayoutRef","initialMeasurementKeyRef","firstProbeRef","latestProbeRef","bootstrapTimerRef","readyMeasurementKey","setReadyMeasurementKey","useState","markMeasurementReady","useCallback","key","currentKey","applyWidth","nextWidth","current","value","bootstrapFromProbe","firstProbe","width","latestProbe","captureVisibleLayout","event","clearTimeout","Math","max","nativeEvent","layout","delete","set","captureLayout","ceil","isInitialMeasurement","size","oldestKey","keys","next","undefined","probe","setTimeout","cachedWidth","get","useLayoutEffect","useEffect","animatedWidthStyle","useAnimatedStyle","isReady","shouldMeasure","exports"],"sourceRoot":"../../../src","sources":["hooks/use-inline-auto-width.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAQA,IAAAC,sBAAA,GAAAD,OAAA;AAaA,MAAME,iBAAiB,GAAG,EAAE;;AAE5B;AACO,MAAMC,kBAAkB,GAAGA,CAAC;EACjCC,OAAO;EACPC,YAAY;EACZC;AACM,CAAC,KAAK;EACZ,MAAMC,UAAU,GAAG,IAAAC,qCAAc,EAAC,CAAC,CAAC;EACpC,MAAMC,oBAAoB,GAAG,IAAAD,qCAAc,EAAC,KAAK,CAAC;EAClD,MAAME,gBAAgB,GAAG,IAAAC,aAAM,EAAgB,IAAI,CAAC;EACpD,MAAMC,eAAe,GAAG,IAAAD,aAAM,EAAC,KAAK,CAAC;EACrC,MAAME,aAAa,GAAG,IAAAF,aAAM,EAAC,IAAIG,GAAG,CAAiB,CAAC,CAAC;EACvD,MAAMC,2BAA2B,GAAG,IAAAJ,aAAM,EAAC,KAAK,CAAC;EACjD,MAAMK,wBAAwB,GA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AC1B,OAAO,CACV,CAAC;EAED,OAAO;IACLwC,aAAa;IACbT,oBAAoB;IACpBuB,kBAAkB;IAClBE,OAAO,EACL,CAACxD,OAAO,IACRkD,WAAW,KAAKH,SAAS,IACzB/B,mBAAmB,KAAKd,cAAc;IACxCuD,aAAa,EAAEzD,OAAO,IAAIkD,WAAW,KAAKH;EAC5C,CAAC;AACH,CAAC;AAACW,OAAA,CAAA3D,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -66,7 +66,9 @@ const Laminar = exports.Laminar = /*#__PURE__*/_react.default.memo(function Lami
66
66
  }, [leadingGap, resolvedLeading, resolvedLeadingKey, resolvedValue, textStyle, variant]);
67
67
  const {
68
68
  captureLayout,
69
+ captureVisibleLayout,
69
70
  animatedWidthStyle,
71
+ isReady: isAutoSizeReady,
70
72
  shouldMeasure
71
73
  } = (0, _useInlineAutoWidth.useInlineAutoWidth)({
72
74
  enabled: autoSize,
@@ -86,6 +88,7 @@ const Laminar = exports.Laminar = /*#__PURE__*/_react.default.memo(function Lami
86
88
  align: align,
87
89
  containerStyle: containerStyle,
88
90
  animatedWidthStyle: animatedWidthStyle,
91
+ onVisibleLayout: autoSize ? captureVisibleLayout : undefined,
89
92
  measurement: shouldMeasure ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
90
93
  onLayout: captureLayout,
91
94
  style: {
@@ -103,7 +106,7 @@ const Laminar = exports.Laminar = /*#__PURE__*/_react.default.memo(function Lami
103
106
  style: textStyle,
104
107
  children: (0, _displayUnits.normalizeDisplayUnit)(unit)
105
108
  }, `${unit}-${index}`))]
106
- }) : undefined,
109
+ }, measurementKey) : undefined,
107
110
  children: variant === "slots" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_slotsRun.SlotsRun, {
108
111
  value: resolvedValue,
109
112
  motionRecipe: motionRecipe,
@@ -127,6 +130,7 @@ const Laminar = exports.Laminar = /*#__PURE__*/_react.default.memo(function Lami
127
130
  leading: resolvedLeading,
128
131
  leadingKey: resolvedLeadingKey,
129
132
  leadingGap: leadingGap,
133
+ ready: !autoSize || isAutoSizeReady,
130
134
  textStyle: textStyle,
131
135
  className: className
132
136
  })
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_useInlineAutoWidth","_useMorphMotion","_useMorphTextStyle","_displayUnits","_morphViewport","_numberRun","_slotsRun","_textRun","_jsxRuntime","e","__esModule","default","Laminar","exports","React","memo","text","variant","fontSize","color","align","className","leading","leadingKey","leadingGap","style","containerStyle","fontStyle","animationDuration","animationPreset","stagger","autoSize","clipToBounds","resolvedValue","String","leadingMap","isLeadingMap","undefined","resolvedLeading","resolvedLeadingKey","motionRecipe","staggerMs","useMorphMotion","textStyle","useMorphTextStyle","measurementKey","useMemo","flattenedStyle","StyleSheet","flatten","JSON","stringify","fontFamily","fontWeight","fontVariant","letterSpacing","lineHeight","textTransform","Boolean","captureLayout","animatedWidthStyle","shouldMeasure","useInlineAutoWidth","enabled","driveToWidth","driveNumber","measuredValue","splitDisplayUnits","map","normalizeDisplayUnit","join","jsx","MorphViewport","measurement","jsxs","View","onLayout","flexDirection","alignSelf","children","alignItems","justifyContent","marginRight","unit","index","Text","SlotsRun","value","NumberRun","TextRun","isValidElement","Array","isArray"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AACA,IAAAI,kBAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AAKA,IAAAM,cAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAT,OAAA;AAA0C,IAAAU,WAAA,GAAAV,OAAA;AAAA,SAAAD,uBAAAY,CAAA,WAAAA,CAAA,I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A,SAAU;MACrBF,SAAS,EAAEA,SAAU;MACrBpB,SAAS,EAAEA;IAAU,CACtB,CAAC,gBAEF,IAAAb,WAAA,CAAA+D,GAAA,EAAChE,QAAA,CAAAkF,OAAO;MACNF,KAAK,EAAEtD,aAAc;MACrBO,YAAY,EAAEA,YAAa;MAC3BpB,KAAK,EAAEA,KAAM;MACbE,OAAO,EAAEgB,eAAgB;MACzBf,UAAU,EAAEgB,kBAAmB;MAC/Bf,UAAU,EAAEA,UAAW;MACvBmB,SAAS,EAAEA,SAAU;MACrBtB,SAAS,EAAEA;IAAU,CACtB;EACJ,CACY,CAAC;AAElB,CAAC,CAAC;AAEJ,SAASe,YAAYA,CACnBmD,KAAmC,EACP;EAC5B;EACA,OACE,OAAOA,KAAK,KAAK,QAAQ,IACzBA,KAAK,KAAK,IAAI,IACd,eAACzE,cAAK,CAAC4E,cAAc,CAACH,KAAK,CAAC,IAC5B,CAACI,KAAK,CAACC,OAAO,CAACL,KAAK,CAAC;AAEzB","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_useInlineAutoWidth","_useMorphMotion","_useMorphTextStyle","_displayUnits","_morphViewport","_numberRun","_slotsRun","_textRun","_jsxRuntime","e","__esModule","default","Laminar","exports","React","memo","text","variant","fontSize","color","align","className","leading","leadingKey","leadingGap","style","containerStyle","fontStyle","animationDuration","animationPreset","stagger","autoSize","clipToBounds","resolvedValue","String","leadingMap","isLeadingMap","undefined","resolvedLeading","resolvedLeadingKey","motionRecipe","staggerMs","useMorphMotion","textStyle","useMorphTextStyle","measurementKey","useMemo","flattenedStyle","StyleSheet","flatten","JSON","stringify","fontFamily","fontWeight","fontVariant","letterSpacing","lineHeight","textTransform","Boolean","captureLayout","captureVisibleLayout","animatedWidthStyle","isReady","isAutoSizeReady","shouldMeasure","useInlineAutoWidth","enabled","driveToWidth","driveNumber","measuredValue","splitDisplayUnits","map","normalizeDisplayUnit","join","jsx","MorphViewport","onVisibleLayout","measurement","jsxs","View","onLayout","flexDirection","alignSelf","children","alignItems","justifyContent","marginRight","unit","index","Text","SlotsRun","value","NumberRun","TextRun","ready","isValidElement","Array","isArray"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AACA,IAAAI,kBAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AAKA,IAAAM,cAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAT,OAAA;AAA0C,IAAAU,WAAA,GAAAV,OAAA;AAAA,SAAAD,uBAAAY,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE1C;AACO,MAAMG,OAAO,GAAAC,OAAA,CAAAD,OAAA,gBAAGE,cAAK,CAACC,IAAI,CAAC,SAASH,OAAOA,CAAC;EAC/CI,IAAI;EACJC,OAAO,GAAG,MAAM;EAChBC,QAAQ;EACRC,KAAK;EACLC,KAAK,GAAG,MAAM;EACdC,SAAS;EACTC,OAAO;EACPC,UAAU;EACVC,UAAU,GAAG,CAAC;EACdC,KAAK;EACLC,cAAc;EACdC,SAAS;EACTC,iBAAiB;EACjBC,eAAe;EACfC,OAAO,GAAG,IAAI;EACdC,QAAQ,GAAG,IAAI;EACfC,YAAY,GAAG;AACY,CAAC,EAAE;EAC9B,MAAMC,aAAa,GAAGC,MAAM,CAAClB,IAAI,IAAI,EAAE,CAAC;EACxC;EACA,MAAMmB,UAAU,GAAGC,YAAY,CAACd,OAAO,CAAC,GAAGA,OAAO,GAAGe,SAAS;EAC9D,MAAMC,eAAgC,GAAGH,UAAU,GAC/CA,UAAU,CAACF,aAAa,CAAC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I,IACd,eAAC7E,cAAK,CAACiF,cAAc,CAACJ,KAAK,CAAC,IAC5B,CAACK,KAAK,CAACC,OAAO,CAACN,KAAK,CAAC;AAEzB","ignoreList":[]}
@@ -63,6 +63,7 @@ const MorphViewport = exports.MorphViewport = /*#__PURE__*/_react.default.memo((
63
63
  align,
64
64
  containerStyle,
65
65
  animatedWidthStyle,
66
+ onVisibleLayout,
66
67
  measurement,
67
68
  children
68
69
  }) => {
@@ -81,6 +82,7 @@ const MorphViewport = exports.MorphViewport = /*#__PURE__*/_react.default.memo((
81
82
  style: measuredContentStyle,
82
83
  children: measurement
83
84
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
85
+ onLayout: onVisibleLayout,
84
86
  style: [resolvedViewportStyle, animatedWidthStyle],
85
87
  children: children
86
88
  })]
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_interopRequireDefault","_jsxRuntime","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","shellStyle","position","alignSelf","viewportStyle","measuredContentStyle","left","top","opacity","flexShrink","clippedViewportStyle","overflow","unclippedViewportStyle","fullWidthViewportStyle","width","shellAlignStyles","center","right","viewportAlignStyles","alignItems","MorphViewport","exports","React","memo","autoSize","clipToBounds","align","containerStyle","animatedWidthStyle","measurement","children","resolvedViewportStyle","useMemo","jsx","View","style","jsxs","Fragment","accessibilityElementsHidden","collapsable","importantForAccessibility","pointerEvents","displayName"],"sourceRoot":"../../../src","sources":["view/morph-viewport.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAC,sBAAA,CAAAH,OAAA;AAA+C,IAAAI,WAAA,GAAAJ,OAAA;AAAA,SAAAG,uBAAAE,CAAA,WAAAA,CAAA,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AAA3C,WAAA,CAAAuD,IAAA,EAAAvD,WAAA,CAAAwD,QAAA;MAAAP,QAAA,gBACE,IAAAjD,WAAA,CAAAoD,GAAA,EAACvD,YAAA,CAAAwD,IAAI;QACHI,2BAA2B;QAC3BC,WAAW,EAAE,KAAM;QACnBC,yBAAyB,EAAC,qBAAqB;QAC/CC,aAAa,EAAC,MAAM;QACpBN,KAAK,EAAE9B,oBAAqB;QAAAyB,QAAA,EAE3BD;MAAW,CACR,CAAC,eACP,IAAAhD,WAAA,CAAAoD,GAAA,EAACtD,sBAAA,CAAAK,OAAQ,CAACkD,IAAI;QAACC,KAAK,EAAE,CAACJ,qBAAqB,EAAEH,kBAAkB,CAAE;QAAAE,QAAA,EAC/DA;MAAQ,CACI,CAAC;IAAA,CAChB,CAAC,gBAEH,IAAAjD,WAAA,CAAAoD,GAAA,EAACvD,YAAA,CAAAwD,IAAI;MAACC,KAAK,EAAE,CAACJ,qBAAqB,EAAElB,sBAAsB,CAAE;MAAAiB,QAAA,EAC1DA;IAAQ,CACL;EACP,CACG,CAAC;AAEX,CACF,CAAC;AAEDV,aAAa,CAACsB,WAAW,GAAG,eAAe","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_interopRequireDefault","_jsxRuntime","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","shellStyle","position","alignSelf","viewportStyle","measuredContentStyle","left","top","opacity","flexShrink","clippedViewportStyle","overflow","unclippedViewportStyle","fullWidthViewportStyle","width","shellAlignStyles","center","right","viewportAlignStyles","alignItems","MorphViewport","exports","React","memo","autoSize","clipToBounds","align","containerStyle","animatedWidthStyle","onVisibleLayout","measurement","children","resolvedViewportStyle","useMemo","jsx","View","style","jsxs","Fragment","accessibilityElementsHidden","collapsable","importantForAccessibility","pointerEvents","onLayout","displayName"],"sourceRoot":"../../../src","sources":["view/morph-viewport.tsx"],"mapp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,KAAK,EAAED,YAAY,CACtB,CAAC;;EAED;EACA,oBACE,IAAA5C,WAAA,CAAAqD,GAAA,EAACxD,YAAA,CAAAyD,IAAI;IAACC,KAAK,EAAE,CAACnC,UAAU,EAAEc,gBAAgB,CAACW,KAAK,CAAC,EAAEC,cAAc,CAAE;IAAAI,QAAA,EAChEP,QAAQ,gBACP,IAAA3C,WAAA,CAAAwD,IAAA,EAAAxD,WAAA,CAAAyD,QAAA;MAAAP,QAAA,gBACE,IAAAlD,WAAA,CAAAqD,GAAA,EAACxD,YAAA,CAAAyD,IAAI;QACHI,2BAA2B;QAC3BC,WAAW,EAAE,KAAM;QACnBC,yBAAyB,EAAC,qBAAqB;QAC/CC,aAAa,EAAC,MAAM;QACpBN,KAAK,EAAE/B,oBAAqB;QAAA0B,QAAA,EAE3BD;MAAW,CACR,CAAC,eACP,IAAAjD,WAAA,CAAAqD,GAAA,EAACvD,sBAAA,CAAAK,OAAQ,CAACmD,IAAI;QACZQ,QAAQ,EAAEd,eAAgB;QAC1BO,KAAK,EAAE,CAACJ,qBAAqB,EAAEJ,kBAAkB,CAAE;QAAAG,QAAA,EAElDA;MAAQ,CACI,CAAC;IAAA,CAChB,CAAC,gBAEH,IAAAlD,WAAA,CAAAqD,GAAA,EAACxD,YAAA,CAAAyD,IAAI;MAACC,KAAK,EAAE,CAACJ,qBAAqB,EAAEnB,sBAAsB,CAAE;MAAAkB,QAAA,EAC1DA;IAAQ,CACL;EACP,CACG,CAAC;AAEX,CACF,CAAC;AAEDX,aAAa,CAACwB,WAAW,GAAG,eAAe","ignoreList":[]}
@@ -19,22 +19,40 @@ const TextRun = exports.TextRun = /*#__PURE__*/_react.default.memo(({
19
19
  leading,
20
20
  leadingKey,
21
21
  leadingGap = 0,
22
+ ready = true,
22
23
  textStyle,
23
24
  className
24
25
  }) => {
25
26
  // namespace ids per instance so repeated strings do not collide
26
27
  const scopeId = (0, _react.useId)();
27
- const lastValueRef = (0, _react.useRef)(value);
28
- const lastLeadingPresenceRef = (0, _react.useRef)(Boolean(leading));
29
- const lastLeadingKeyRef = (0, _react.useRef)(leadingKey);
28
+ const hasDisplayedRef = (0, _react.useRef)(false);
29
+ const displayedValueRef = (0, _react.useRef)(value);
30
+ const displayedLeadingRef = (0, _react.useRef)(leading);
31
+ const displayedLeadingKeyRef = (0, _react.useRef)(leadingKey);
32
+ const displayedLeadingGapRef = (0, _react.useRef)(leadingGap);
33
+ const shouldDisplayTarget = ready || !hasDisplayedRef.current;
34
+ const visibleValue = shouldDisplayTarget ? value : displayedValueRef.current;
35
+ const visibleLeading = shouldDisplayTarget ? leading : displayedLeadingRef.current;
36
+ const visibleLeadingKey = shouldDisplayTarget ? leadingKey : displayedLeadingKeyRef.current;
37
+ const visibleLeadingGap = shouldDisplayTarget ? leadingGap : displayedLeadingGapRef.current;
38
+ if (shouldDisplayTarget) {
39
+ hasDisplayedRef.current = true;
40
+ displayedValueRef.current = value;
41
+ displayedLeadingRef.current = leading;
42
+ displayedLeadingKeyRef.current = leadingKey;
43
+ displayedLeadingGapRef.current = leadingGap;
44
+ }
45
+ const lastValueRef = (0, _react.useRef)(visibleValue);
46
+ const lastLeadingPresenceRef = (0, _react.useRef)(Boolean(visibleLeading));
47
+ const lastLeadingKeyRef = (0, _react.useRef)(visibleLeadingKey);
30
48
  const hasAnimatedRef = (0, _react.useRef)(false);
31
- const isLeadingSwap = Boolean(leading) && lastLeadingPresenceRef.current && leadingKey !== lastLeadingKeyRef.current;
49
+ const isLeadingSwap = Boolean(visibleLeading) && lastLeadingPresenceRef.current && visibleLeadingKey !== lastLeadingKeyRef.current;
32
50
  // update the worklet flag after commit so render never writes a shared value
33
51
  const leadingSwapProgress = (0, _reactNativeReanimated.useSharedValue)(0);
34
52
  (0, _react.useLayoutEffect)(() => {
35
53
  leadingSwapProgress.value = isLeadingSwap ? 1 : 0;
36
54
  }, [isLeadingSwap, leadingSwapProgress]);
37
- const glyphs = (0, _useTextGlyphs.useTextGlyphs)(value, scopeId, leading, leadingKey);
55
+ const glyphs = (0, _useTextGlyphs.useTextGlyphs)(visibleValue, scopeId, visibleLeading, visibleLeadingKey);
38
56
  const elementEnterTransition = (0, _react.useMemo)(() => (0, _entryExitBuilders.createLeadingEnterTransition)({
39
57
  durationMs: motionRecipe.durationMs,
40
58
  easing: motionRecipe.easing
@@ -42,16 +60,16 @@ const TextRun = exports.TextRun = /*#__PURE__*/_react.default.memo(({
42
60
  const elementExitTransition = (0, _react.useMemo)(() => (0, _entryExitBuilders.createLeadingExitTransition)({
43
61
  durationMs: motionRecipe.durationMs,
44
62
  easing: motionRecipe.easing,
45
- leadingGap,
63
+ leadingGap: visibleLeadingGap,
46
64
  scale: leadingSwapProgress
47
- }), [leadingGap, leadingSwapProgress, motionRecipe.durationMs, motionRecipe.easing]);
65
+ }), [visibleLeadingGap, leadingSwapProgress, motionRecipe.durationMs, motionRecipe.easing]);
48
66
 
49
67
  // mark the first value as settled and later changes as eligible for motion
50
- if (value !== lastValueRef.current || Boolean(leading) !== lastLeadingPresenceRef.current || leadingKey !== lastLeadingKeyRef.current) {
68
+ if (visibleValue !== lastValueRef.current || Boolean(visibleLeading) !== lastLeadingPresenceRef.current || visibleLeadingKey !== lastLeadingKeyRef.current) {
51
69
  hasAnimatedRef.current = true;
52
- lastValueRef.current = value;
53
- lastLeadingPresenceRef.current = Boolean(leading);
54
- lastLeadingKeyRef.current = leadingKey;
70
+ lastValueRef.current = visibleValue;
71
+ lastLeadingPresenceRef.current = Boolean(visibleLeading);
72
+ lastLeadingKeyRef.current = visibleLeadingKey;
55
73
  }
56
74
  const hasAnimated = hasAnimatedRef.current;
57
75
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_glyphRun.GlyphRun, {
@@ -61,7 +79,7 @@ const TextRun = exports.TextRun = /*#__PURE__*/_react.default.memo(({
61
79
  elementEnterTransition: isLeadingSwap ? elementEnterTransition : undefined,
62
80
  exitTransition: motionRecipe.exitTransition,
63
81
  elementExitTransition: elementExitTransition,
64
- leadingGap: leadingGap,
82
+ leadingGap: visibleLeadingGap,
65
83
  align: align,
66
84
  textStyle: textStyle,
67
85
  className: className
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNativeReanimated","_useTextGlyphs","_entryExitBuilders","_glyphRun","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","TextRun","exports","React","memo","value","motionRecipe","align","leading","leadingKey","leadingGap","textStyle","className","scopeId","useId","lastValueRef","useRef","lastLeadingPresenceRef","Boolean","lastLeadingKeyRef","hasAnimatedRef","isLeadingSwap","current","leadingSwapProgress","useSharedValue","useLayoutEffect","glyphs","useTextGlyphs","elementEnterTransition","useMemo","createLeadingEnterTransition","durationMs","easing","elementExitTransition","createLeadingExitTransition","scale","hasAnimated","jsx","GlyphRun","layoutTransition","undefined","enterTransition","exitTransition","displayName"],"sourceRoot":"../../../src","sources":["view/text-run.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAGA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAH,OAAA;AAKA,IAAAI,SAAA,GAAAJ,OAAA;AAAuC,IAAAK,WAAA,GAAAL,OAAA;AAAA,SAAAD,wBAAAO,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAT,uBAAA,YAAAA,CAAAO,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CA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AO;EAE1C,oBACE,IAAAzC,WAAA,CAAAwD,GAAA,EAACzD,SAAA,CAAA0D,QAAQ;IACPZ,MAAM,EAAEA,MAAO;IACfa,gBAAgB,EACdH,WAAW,GAAG9B,YAAY,CAACiC,gBAAgB,GAAGC,SAC/C;IACDC,eAAe,EACbrB,cAAc,CAACE,OAAO,GAClBhB,YAAY,CAACmC,eAAe,GAC5BD,SACL;IACDZ,sBAAsB,EACpBP,aAAa,GAAGO,sBAAsB,GAAGY,SAC1C;IACDE,cAAc,EAAEpC,YAAY,CAACoC,cAAe;IAC5CT,qBAAqB,EAAEA,qBAAsB;IAC7CvB,UAAU,EAAEA,UAAW;IACvBH,KAAK,EAAEA,KAAM;IACbI,SAAS,EAAEA,SAAU;IACrBC,SAAS,EAAEA;EAAU,CACtB,CAAC;AAEN,CACF,CAAC;AAEDX,OAAO,CAAC0C,WAAW,GAAG,SAAS","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNativeReanimated","_useTextGlyphs","_entryExitBuilders","_glyphRun","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","TextRun","exports","React","memo","value","motionRecipe","align","leading","leadingKey","leadingGap","ready","textStyle","className","scopeId","useId","hasDisplayedRef","useRef","displayedValueRef","displayedLeadingRef","displayedLeadingKeyRef","displayedLeadingGapRef","shouldDisplayTarget","current","visibleValue","visibleLeading","visibleLeadingKey","visibleLeadingGap","lastValueRef","lastLeadingPresenceRef","Boolean","lastLeadingKeyRef","hasAnimatedRef","isLeadingSwap","leadingSwapProgress","useSharedValue","useLayoutEffect","glyphs","useTextGlyphs","elementEnterTransition","useMemo","createLeadingEnterTransition","durationMs","easing","elementExitTransition","createLeadingExitTransition","scale","hasAnimated","jsx","GlyphRun","layoutTransition","undefined","enterTransition","exitTransition","displayName"],"sourceRoot":"../../../src","sources":["view/text-run.tsx"],"mappings":";;;;;;AAAA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L,cAAc,CAAC,KAAKI,sBAAsB,CAACN,OAAO,IAC1DG,iBAAiB,KAAKK,iBAAiB,CAACR,OAAO,EAC/C;IACAS,cAAc,CAACT,OAAO,GAAG,IAAI;IAC7BK,YAAY,CAACL,OAAO,GAAGC,YAAY;IACnCK,sBAAsB,CAACN,OAAO,GAAGO,OAAO,CAACL,cAAc,CAAC;IACxDM,iBAAiB,CAACR,OAAO,GAAGG,iBAAiB;EAC/C;EAEA,MAAMqB,WAAW,GAAGf,cAAc,CAACT,OAAO;EAE1C,oBACE,IAAA1C,WAAA,CAAAmE,GAAA,EAACpE,SAAA,CAAAqE,QAAQ;IACPZ,MAAM,EAAEA,MAAO;IACfa,gBAAgB,EACdH,WAAW,GAAGzC,YAAY,CAAC4C,gBAAgB,GAAGC,SAC/C;IACDC,eAAe,EACbpB,cAAc,CAACT,OAAO,GAClBjB,YAAY,CAAC8C,eAAe,GAC5BD,SACL;IACDZ,sBAAsB,EACpBN,aAAa,GAAGM,sBAAsB,GAAGY,SAC1C;IACDE,cAAc,EAAE/C,YAAY,CAAC+C,cAAe;IAC5CT,qBAAqB,EAAEA,qBAAsB;IAC7ClC,UAAU,EAAEiB,iBAAkB;IAC9BpB,KAAK,EAAEA,KAAM;IACbK,SAAS,EAAEA,SAAU;IACrBC,SAAS,EAAEA;EAAU,CACtB,CAAC;AAEN,CACF,CAAC;AAEDZ,OAAO,CAACqD,WAAW,GAAG,SAAS","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- import { useCallback, useEffect, useRef, useState } from "react";
3
+ import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
4
4
  import { useAnimatedStyle, useSharedValue } from "react-native-reanimated";
5
5
  const WIDTH_CACHE_LIMIT = 64;
6
6
 
@@ -11,10 +11,19 @@ export const useInlineAutoWidth = ({
11
11
  measurementKey
12
12
  }) => {
13
13
  const widthValue = useSharedValue(0);
14
+ const hasBootstrappedWidth = useSharedValue(false);
14
15
  const measuredWidthRef = useRef(null);
15
16
  const bootstrappedRef = useRef(false);
16
17
  const widthCacheRef = useRef(new Map());
17
- const [hasBootstrappedWidth, setHasBootstrappedWidth] = useState(false);
18
+ const hasCapturedVisibleLayoutRef = useRef(false);
19
+ const initialMeasurementKeyRef = useRef(null);
20
+ const firstProbeRef = useRef(null);
21
+ const latestProbeRef = useRef(null);
22
+ const bootstrapTimerRef = useRef(null);
23
+ const [readyMeasurementKey, setReadyMeasurementKey] = useState(null);
24
+ const markMeasurementReady = useCallback(key => {
25
+ setReadyMeasurementKey(currentKey => currentKey === key ? currentKey : key);
26
+ }, []);
18
27
 
19
28
  // the first measurement establishes the shell without animating from zero
20
29
  const applyWidth = useCallback(nextWidth => {
@@ -25,11 +34,62 @@ export const useInlineAutoWidth = ({
25
34
  if (!bootstrappedRef.current) {
26
35
  bootstrappedRef.current = true;
27
36
  widthValue.value = nextWidth;
28
- setHasBootstrappedWidth(true);
37
+ hasBootstrappedWidth.value = true;
29
38
  return;
30
39
  }
31
40
  widthValue.value = driveToWidth(nextWidth);
32
41
  }, [driveToWidth, widthValue]);
42
+ const bootstrapFromProbe = useCallback(() => {
43
+ bootstrapTimerRef.current = null;
44
+ if (hasCapturedVisibleLayoutRef.current) {
45
+ return;
46
+ }
47
+ const firstProbe = firstProbeRef.current;
48
+ if (!firstProbe) {
49
+ return;
50
+ }
51
+
52
+ // The visible layout did not arrive in time, so use the first probe as a
53
+ // safe fallback. A later probe can still animate from this baseline.
54
+ hasCapturedVisibleLayoutRef.current = true;
55
+ initialMeasurementKeyRef.current = firstProbe.key;
56
+ applyWidth(firstProbe.width);
57
+ const latestProbe = latestProbeRef.current;
58
+ if (latestProbe && latestProbe.key !== firstProbe.key) {
59
+ // The target width is already cached. Defer its animation until the
60
+ // ready render so the shell and the new glyph row start together.
61
+ markMeasurementReady(latestProbe.key);
62
+ } else {
63
+ markMeasurementReady(firstProbe.key);
64
+ }
65
+ }, [applyWidth, markMeasurementReady]);
66
+ const captureVisibleLayout = useCallback(event => {
67
+ if (!enabled || hasCapturedVisibleLayoutRef.current) {
68
+ return;
69
+ }
70
+ if (bootstrapTimerRef.current !== null) {
71
+ clearTimeout(bootstrapTimerRef.current);
72
+ bootstrapTimerRef.current = null;
73
+ }
74
+ hasCapturedVisibleLayoutRef.current = true;
75
+ // bootstrap from the visible tree so the first explicit width matches
76
+ // the geometry that was already painted to the user
77
+ const nextWidth = Math.max(0, event.nativeEvent.layout.width);
78
+ // retain the visible width for the initial key so a later cache hit does
79
+ // not reintroduce the probe-to-visible mismatch
80
+ widthCacheRef.current.delete(measurementKey);
81
+ widthCacheRef.current.set(measurementKey, nextWidth);
82
+ const firstProbe = firstProbeRef.current;
83
+ if (firstProbe && firstProbe.key !== measurementKey) {
84
+ initialMeasurementKeyRef.current = firstProbe.key;
85
+ applyWidth(firstProbe.width);
86
+ markMeasurementReady(measurementKey);
87
+ return;
88
+ }
89
+ initialMeasurementKeyRef.current = measurementKey;
90
+ applyWidth(nextWidth);
91
+ markMeasurementReady(measurementKey);
92
+ }, [applyWidth, enabled, markMeasurementReady, measurementKey]);
33
93
  const captureLayout = useCallback(event => {
34
94
  if (!enabled) {
35
95
  return;
@@ -37,36 +97,63 @@ export const useInlineAutoWidth = ({
37
97
 
38
98
  // round up so fractional native measurements cannot clip the final glyph
39
99
  const nextWidth = Math.max(0, Math.ceil(event.nativeEvent.layout.width));
40
-
41
- // delete before setting so a repeated key moves to the most recent position
42
- widthCacheRef.current.delete(measurementKey);
43
- if (widthCacheRef.current.size >= WIDTH_CACHE_LIMIT) {
44
- // map insertion order gives the lru entry at the front
45
- const oldestKey = widthCacheRef.current.keys().next().value;
46
- if (oldestKey !== undefined) {
47
- widthCacheRef.current.delete(oldestKey);
100
+ const isInitialMeasurement = initialMeasurementKeyRef.current === measurementKey;
101
+ if (!isInitialMeasurement) {
102
+ // delete before setting so a repeated key moves to the most recent position
103
+ widthCacheRef.current.delete(measurementKey);
104
+ if (widthCacheRef.current.size >= WIDTH_CACHE_LIMIT) {
105
+ // map insertion order gives the lru entry at the front
106
+ const oldestKey = widthCacheRef.current.keys().next().value;
107
+ if (oldestKey !== undefined) {
108
+ widthCacheRef.current.delete(oldestKey);
109
+ }
48
110
  }
111
+ widthCacheRef.current.set(measurementKey, nextWidth);
49
112
  }
50
- widthCacheRef.current.set(measurementKey, nextWidth);
51
- applyWidth(nextWidth);
52
- }, [applyWidth, enabled, measurementKey]);
113
+ const probe = {
114
+ key: measurementKey,
115
+ width: nextWidth
116
+ };
117
+ if (!firstProbeRef.current) {
118
+ firstProbeRef.current = probe;
119
+ }
120
+ latestProbeRef.current = probe;
121
+ if (!hasCapturedVisibleLayoutRef.current && bootstrapTimerRef.current === null) {
122
+ bootstrapTimerRef.current = setTimeout(bootstrapFromProbe, 0);
123
+ }
124
+
125
+ // Do not let the initial probe override the visible first frame.
126
+ if (hasCapturedVisibleLayoutRef.current && !isInitialMeasurement) {
127
+ // captureLayout only records the target. The cache effect applies the
128
+ // animation during the render that releases the new glyph row.
129
+ markMeasurementReady(measurementKey);
130
+ }
131
+ }, [applyWidth, bootstrapFromProbe, enabled, markMeasurementReady, measurementKey]);
53
132
  const cachedWidth = widthCacheRef.current.get(measurementKey);
54
133
 
55
134
  // a cached width can restore the shell before the hidden probe renders again
56
- useEffect(() => {
57
- if (enabled && cachedWidth !== undefined) {
135
+ useLayoutEffect(() => {
136
+ if (enabled && cachedWidth !== undefined && hasCapturedVisibleLayoutRef.current) {
58
137
  // promote cache hits so active states stay available longer
59
138
  widthCacheRef.current.delete(measurementKey);
60
139
  widthCacheRef.current.set(measurementKey, cachedWidth);
61
140
  applyWidth(cachedWidth);
141
+ markMeasurementReady(measurementKey);
142
+ }
143
+ }, [applyWidth, cachedWidth, enabled, markMeasurementReady, measurementKey]);
144
+ useEffect(() => () => {
145
+ if (bootstrapTimerRef.current !== null) {
146
+ clearTimeout(bootstrapTimerRef.current);
62
147
  }
63
- }, [applyWidth, cachedWidth, enabled, measurementKey]);
64
- const animatedWidthStyle = useAnimatedStyle(() => enabled && hasBootstrappedWidth ? {
148
+ }, []);
149
+ const animatedWidthStyle = useAnimatedStyle(() => enabled && hasBootstrappedWidth.value ? {
65
150
  width: widthValue.value
66
- } : {}, [enabled, hasBootstrappedWidth]);
151
+ } : {}, [enabled]);
67
152
  return {
68
153
  captureLayout,
154
+ captureVisibleLayout,
69
155
  animatedWidthStyle,
156
+ isReady: !enabled || cachedWidth !== undefined || readyMeasurementKey === measurementKey,
70
157
  shouldMeasure: enabled && cachedWidth === undefined
71
158
  };
72
159
  };
@@ -1 +1 @@
1
- {"version":3,"names":["useCallback","useEffect","useRef","useState","useAnimatedStyle","useSharedValue","WIDTH_CACHE_LIMIT","useInlineAutoWidth","enabled","driveToWidth","measurementKey","widthValue","measuredWidthRef","bootstrappedRef","widthCacheRef","Map","hasBootstrappedWidth","setHasBootstrappedWidth","applyWidth","nextWidth","current","value","captureLayout","event","Math","max","ceil","nativeEvent","layout","width","delete","size","oldestKey","keys","next","undefined","set","cachedWidth","get","animatedWidthStyle","shouldMeasure"],"sourceRoot":"../../../src","sources":["hooks/use-inline-auto-width.ts"],"mappings":";;AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAEhE,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,yBAAyB;AAQ1E,MAAMC,iBAAiB,GAAG,EAAE;;AAE5B;AACA,OAAO,MAAMC,kBAAkB,GAAGA,CAAC;EACjCC,OAAO;EACPC,YAAY;EACZC;AACM,CAAC,KAAK;EACZ,MAAMC,UAAU,GAAGN,cAAc,CAAC,CAAC,CAAC;EACpC,MAAMO,gBAAgB,GAAGV,MAAM,CAAgB,IAAI,CAAC;EACpD,MAAMW,eAAe,GAAGX,MAAM,CAAC,KAAK,CAAC;EACrC,MAAMY,aAAa,GAAGZ,MAAM,CAAC,IAAIa,GAAG,CAAiB,CAAC,CAAC;EACvD,MAAM,CAACC,oBAAoB,EAAEC,uBAAuB,CAAC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E,cAAc,CACtC,CAAC;EAED,MAAM2B,WAAW,GAAGvB,aAAa,CAACM,OAAO,CAACkB,GAAG,CAAC5B,cAAc,CAAC;;EAE7D;EACAT,SAAS,CAAC,MAAM;IACd,IAAIO,OAAO,IAAI6B,WAAW,KAAKF,SAAS,EAAE;MACxC;MACArB,aAAa,CAACM,OAAO,CAACU,MAAM,CAACpB,cAAc,CAAC;MAC5CI,aAAa,CAACM,OAAO,CAACgB,GAAG,CAAC1B,cAAc,EAAE2B,WAAW,CAAC;MACtDnB,UAAU,CAACmB,WAAW,CAAC;IACzB;EACF,CAAC,EAAE,CAACnB,UAAU,EAAEmB,WAAW,EAAE7B,OAAO,EAAEE,cAAc,CAAC,CAAC;EAEtD,MAAM6B,kBAAkB,GAAGnC,gBAAgB,CACzC,MACEI,OAAO,IAAIQ,oBAAoB,GAC3B;IACEa,KAAK,EAAElB,UAAU,CAACU;EACpB,CAAC,GACD,CAAC,CAAC,EACR,CAACb,OAAO,EAAEQ,oBAAoB,CAChC,CAAC;EAED,OAAO;IACLM,aAAa;IACbiB,kBAAkB;IAClBC,aAAa,EAAEhC,OAAO,IAAI6B,WAAW,KAAKF;EAC5C,CAAC;AACH,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["useCallback","useEffect","useLayoutEffect","useRef","useState","useAnimatedStyle","useSharedValue","WIDTH_CACHE_LIMIT","useInlineAutoWidth","enabled","driveToWidth","measurementKey","widthValue","hasBootstrappedWidth","measuredWidthRef","bootstrappedRef","widthCacheRef","Map","hasCapturedVisibleLayoutRef","initialMeasurementKeyRef","firstProbeRef","latestProbeRef","bootstrapTimerRef","readyMeasurementKey","setReadyMeasurementKey","markMeasurementReady","key","currentKey","applyWidth","nextWidth","current","value","bootstrapFromProbe","firstProbe","width","latestProbe","captureVisibleLayout","event","clearTimeout","Math","max","nativeEvent","layout","delete","set","captureLayout","ceil","isInitialMeasurement","size","oldestKey","keys","next","undefined","probe","setTimeout","cachedWidth","get","animatedWidthStyle","isReady","should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