stream-chat-react-native-core 9.0.0-beta.28 → 9.0.0-beta.29

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 (73) hide show
  1. package/lib/commonjs/components/Attachment/Gallery.js +29 -9
  2. package/lib/commonjs/components/Attachment/Gallery.js.map +1 -1
  3. package/lib/commonjs/components/Attachment/Giphy/GiphyImage.js +4 -4
  4. package/lib/commonjs/components/Attachment/Giphy/GiphyImage.js.map +1 -1
  5. package/lib/commonjs/components/Attachment/ImageLoadingFailedIndicator.js +3 -3
  6. package/lib/commonjs/components/Attachment/ImageLoadingFailedIndicator.js.map +1 -1
  7. package/lib/commonjs/components/Attachment/ImageLoadingIndicator.js +1 -1
  8. package/lib/commonjs/components/Attachment/ImageLoadingIndicator.js.map +1 -1
  9. package/lib/commonjs/components/AttachmentPicker/components/AttachmentMediaPicker/AttachmentPickerItem.js +2 -2
  10. package/lib/commonjs/components/AttachmentPicker/components/AttachmentMediaPicker/AttachmentPickerItem.js.map +1 -1
  11. package/lib/commonjs/components/ChannelList/Skeleton.js +1 -1
  12. package/lib/commonjs/components/ChannelList/Skeleton.js.map +1 -1
  13. package/lib/commonjs/components/ImageGallery/ImageGallery.js +3 -3
  14. package/lib/commonjs/components/ImageGallery/ImageGallery.js.map +1 -1
  15. package/lib/commonjs/components/MessageInput/components/AttachmentPreview/ImageAttachmentUploadPreview.js +1 -1
  16. package/lib/commonjs/components/MessageInput/components/AttachmentPreview/ImageAttachmentUploadPreview.js.map +1 -1
  17. package/lib/commonjs/components/Reply/Reply.js +2 -2
  18. package/lib/commonjs/components/Reply/Reply.js.map +1 -1
  19. package/lib/commonjs/components/ThreadList/ThreadListItemSkeleton.js +1 -1
  20. package/lib/commonjs/components/ThreadList/ThreadListItemSkeleton.js.map +1 -1
  21. package/lib/commonjs/components/UIComponents/BottomSheetModal.js +4 -4
  22. package/lib/commonjs/components/UIComponents/BottomSheetModal.js.map +1 -1
  23. package/lib/commonjs/contexts/overlayContext/ClosingPortalHostsLayer.js +10 -1
  24. package/lib/commonjs/contexts/overlayContext/ClosingPortalHostsLayer.js.map +1 -1
  25. package/lib/commonjs/contexts/overlayContext/MessageOverlayHostLayer.js +16 -7
  26. package/lib/commonjs/contexts/overlayContext/MessageOverlayHostLayer.js.map +1 -1
  27. package/lib/commonjs/version.json +1 -1
  28. package/lib/module/components/Attachment/Gallery.js +29 -9
  29. package/lib/module/components/Attachment/Gallery.js.map +1 -1
  30. package/lib/module/components/Attachment/Giphy/GiphyImage.js +4 -4
  31. package/lib/module/components/Attachment/Giphy/GiphyImage.js.map +1 -1
  32. package/lib/module/components/Attachment/ImageLoadingFailedIndicator.js +3 -3
  33. package/lib/module/components/Attachment/ImageLoadingFailedIndicator.js.map +1 -1
  34. package/lib/module/components/Attachment/ImageLoadingIndicator.js +1 -1
  35. package/lib/module/components/Attachment/ImageLoadingIndicator.js.map +1 -1
  36. package/lib/module/components/AttachmentPicker/components/AttachmentMediaPicker/AttachmentPickerItem.js +2 -2
  37. package/lib/module/components/AttachmentPicker/components/AttachmentMediaPicker/AttachmentPickerItem.js.map +1 -1
  38. package/lib/module/components/ChannelList/Skeleton.js +1 -1
  39. package/lib/module/components/ChannelList/Skeleton.js.map +1 -1
  40. package/lib/module/components/ImageGallery/ImageGallery.js +3 -3
  41. package/lib/module/components/ImageGallery/ImageGallery.js.map +1 -1
  42. package/lib/module/components/MessageInput/components/AttachmentPreview/ImageAttachmentUploadPreview.js +1 -1
  43. package/lib/module/components/MessageInput/components/AttachmentPreview/ImageAttachmentUploadPreview.js.map +1 -1
  44. package/lib/module/components/Reply/Reply.js +2 -2
  45. package/lib/module/components/Reply/Reply.js.map +1 -1
  46. package/lib/module/components/ThreadList/ThreadListItemSkeleton.js +1 -1
  47. package/lib/module/components/ThreadList/ThreadListItemSkeleton.js.map +1 -1
  48. package/lib/module/components/UIComponents/BottomSheetModal.js +4 -4
  49. package/lib/module/components/UIComponents/BottomSheetModal.js.map +1 -1
  50. package/lib/module/contexts/overlayContext/ClosingPortalHostsLayer.js +10 -1
  51. package/lib/module/contexts/overlayContext/ClosingPortalHostsLayer.js.map +1 -1
  52. package/lib/module/contexts/overlayContext/MessageOverlayHostLayer.js +16 -7
  53. package/lib/module/contexts/overlayContext/MessageOverlayHostLayer.js.map +1 -1
  54. package/lib/module/version.json +1 -1
  55. package/lib/typescript/components/Attachment/Giphy/GiphyImage.d.ts.map +1 -1
  56. package/lib/typescript/components/UIComponents/BottomSheetModal.d.ts.map +1 -1
  57. package/lib/typescript/contexts/overlayContext/MessageOverlayHostLayer.d.ts.map +1 -1
  58. package/package.json +2 -4
  59. package/src/components/Attachment/Gallery.tsx +21 -5
  60. package/src/components/Attachment/Giphy/GiphyImage.tsx +6 -3
  61. package/src/components/Attachment/ImageLoadingFailedIndicator.tsx +1 -2
  62. package/src/components/Attachment/ImageLoadingIndicator.tsx +1 -1
  63. package/src/components/AttachmentPicker/components/AttachmentMediaPicker/AttachmentPickerItem.tsx +2 -2
  64. package/src/components/ChannelList/Skeleton.tsx +1 -1
  65. package/src/components/ImageGallery/ImageGallery.tsx +3 -3
  66. package/src/components/MessageInput/components/AttachmentPreview/ImageAttachmentUploadPreview.tsx +1 -1
  67. package/src/components/Reply/Reply.tsx +2 -2
  68. package/src/components/ThreadList/ThreadListItemSkeleton.tsx +1 -1
  69. package/src/components/UIComponents/BottomSheetModal.tsx +5 -3
  70. package/src/contexts/overlayContext/ClosingPortalHostsLayer.tsx +11 -1
  71. package/src/contexts/overlayContext/MessageOverlayHostLayer.tsx +17 -10
  72. package/src/version.json +1 -1
  73. package/bin/patch-bottom-sheet-5.1.8-pr-2561.js +0 -246
@@ -14,7 +14,7 @@ export const ImageLoadingIndicator = () => {
14
14
  accessible
15
15
  enabled
16
16
  gradientColor={semantics.skeletonLoadingHighlight}
17
- style={StyleSheet.absoluteFillObject}
17
+ style={StyleSheet.absoluteFill}
18
18
  >
19
19
  <View pointerEvents='none' style={styles.centered}>
20
20
  <ActivityIndicator />
@@ -79,7 +79,7 @@ const AttachmentVideo = (props: AttachmentPickerItemType) => {
79
79
  image,
80
80
  ]}
81
81
  >
82
- <Image source={{ uri: thumb_url }} style={StyleSheet.absoluteFillObject} />
82
+ <Image source={{ uri: thumb_url }} style={StyleSheet.absoluteFill} />
83
83
  <View style={[styles.overlay, imageOverlay]}>
84
84
  <ImageOverlaySelectedComponent index={selectedIndex} />
85
85
  </View>
@@ -138,7 +138,7 @@ const AttachmentImage = (props: AttachmentPickerItemType) => {
138
138
  image,
139
139
  ]}
140
140
  >
141
- <Image source={{ uri }} style={StyleSheet.absoluteFillObject} />
141
+ <Image source={{ uri }} style={StyleSheet.absoluteFill} />
142
142
  <View style={[styles.overlay, imageOverlay]}>
143
143
  <ImageOverlaySelectedComponent index={selectedIndex} />
144
144
  </View>
@@ -19,7 +19,7 @@ const SkeletonBlock = ({ style }: { style: React.ComponentProps<typeof View>['st
19
19
  baseColor={semantics.backgroundCoreSurfaceDefault}
20
20
  duration={animationTime}
21
21
  gradientColor={semantics.skeletonLoadingHighlight}
22
- style={StyleSheet.absoluteFillObject}
22
+ style={StyleSheet.absoluteFill}
23
23
  />
24
24
  </View>
25
25
  );
@@ -279,11 +279,11 @@ export const ImageGalleryWithContext = (props: ImageGalleryWithContextProps) =>
279
279
  <Animated.View
280
280
  accessibilityLabel='Image Gallery'
281
281
  pointerEvents={'auto'}
282
- style={[StyleSheet.absoluteFillObject, showScreenStyle]}
282
+ style={[StyleSheet.absoluteFill, showScreenStyle]}
283
283
  >
284
- <Animated.View style={[StyleSheet.absoluteFillObject, containerBackground]} />
284
+ <Animated.View style={[StyleSheet.absoluteFill, containerBackground]} />
285
285
  <GestureDetector gesture={Gesture.Simultaneous(singleTap, doubleTap, pinch, pan)}>
286
- <Animated.View style={StyleSheet.absoluteFillObject}>
286
+ <Animated.View style={StyleSheet.absoluteFill}>
287
287
  <Animated.View
288
288
  testID='image-gallery-pager'
289
289
  style={[styles.animatedContainer, pagerStyle, pager]}
@@ -66,7 +66,7 @@ export const ImageAttachmentUploadPreview = ({
66
66
  onError={onErrorHandler}
67
67
  onLoadEnd={onLoadEndHandler}
68
68
  source={{ uri: attachment.localMetadata.previewUri ?? attachment.image_url }}
69
- style={StyleSheet.absoluteFillObject}
69
+ style={StyleSheet.absoluteFill}
70
70
  testID={'image-attachment-upload-preview-image'}
71
71
  />
72
72
  {indicatorType === ProgressIndicatorTypes.IN_PROGRESS && <ImageUploadInProgressIndicator />}
@@ -51,7 +51,7 @@ const RightContent = React.memo(
51
51
  ) {
52
52
  return (
53
53
  <View style={[styles.contentWrapper, styles.contentBorder]}>
54
- <ImageComponent source={{ uri }} style={StyleSheet.absoluteFillObject} />
54
+ <ImageComponent source={{ uri }} style={StyleSheet.absoluteFill} />
55
55
  </View>
56
56
  );
57
57
  }
@@ -59,7 +59,7 @@ const RightContent = React.memo(
59
59
  return (
60
60
  <View style={[styles.contentWrapper, styles.contentBorder]}>
61
61
  <View style={styles.attachmentContainer}>
62
- <Image source={{ uri: attachment.thumb_url }} style={StyleSheet.absoluteFillObject} />
62
+ <Image source={{ uri: attachment.thumb_url }} style={StyleSheet.absoluteFill} />
63
63
  <VideoPlayIndicator size='sm' />
64
64
  </View>
65
65
  </View>
@@ -19,7 +19,7 @@ const SkeletonBlock = ({ style }: { style: React.ComponentProps<typeof View>['st
19
19
  baseColor={semantics.backgroundCoreSurfaceDefault}
20
20
  duration={animationTime}
21
21
  gradientColor={semantics.skeletonLoadingHighlight}
22
- style={StyleSheet.absoluteFillObject}
22
+ style={StyleSheet.absoluteFill}
23
23
  />
24
24
  </View>
25
25
  );
@@ -514,8 +514,11 @@ const BottomSheetModalInner = (props: PropsWithChildren<BottomSheetModalProps>)
514
514
  <Modal onRequestClose={onClose} transparent visible={visible}>
515
515
  <GestureHandlerRootView style={styles.sheetContentContainer}>
516
516
  <View style={[styles.overlay, overlayTheme]}>
517
- <Animated.View pointerEvents='none' style={[styles.backdrop, overlayAnimatedStyle]} />
518
- <Pressable onPress={onBackdropPress} style={StyleSheet.absoluteFillObject} />
517
+ <Animated.View
518
+ pointerEvents='none'
519
+ style={[StyleSheet.absoluteFill, styles.backdrop, overlayAnimatedStyle]}
520
+ />
521
+ <Pressable onPress={onBackdropPress} style={StyleSheet.absoluteFill} />
519
522
 
520
523
  <Animated.View
521
524
  pointerEvents='box-none'
@@ -590,7 +593,6 @@ const useStyles = () => {
590
593
  justifyContent: 'flex-end',
591
594
  },
592
595
  backdrop: {
593
- ...StyleSheet.absoluteFillObject,
594
596
  backgroundColor: semantics.backgroundCoreScrim,
595
597
  },
596
598
  sheetContentContainer: {
@@ -36,7 +36,7 @@ const ClosingPortalHostSlot = ({
36
36
  style={style}
37
37
  testID={`closing-portal-host-slot-${hostName}`}
38
38
  >
39
- <PortalHost name={hostName} style={StyleSheet.absoluteFillObject} />
39
+ <PortalHost name={hostName} style={styles.absoluteFill} />
40
40
  </Animated.View>
41
41
  );
42
42
  };
@@ -76,3 +76,13 @@ export const ClosingPortalHostsLayer = ({ closeCoverOpacity }: ClosingPortalHost
76
76
  </>
77
77
  );
78
78
  };
79
+
80
+ const styles = StyleSheet.create({
81
+ absoluteFill: {
82
+ bottom: 0,
83
+ left: 0,
84
+ position: 'absolute',
85
+ right: 0,
86
+ top: 0,
87
+ },
88
+ });
@@ -39,11 +39,11 @@ const DefaultMessageOverlayBackground = () => {
39
39
  } = useTheme();
40
40
 
41
41
  return (
42
- <View pointerEvents='none' style={StyleSheet.absoluteFillObject}>
42
+ <View pointerEvents='none' style={StyleSheet.absoluteFill}>
43
43
  <View
44
44
  pointerEvents='none'
45
45
  style={[
46
- StyleSheet.absoluteFillObject,
46
+ StyleSheet.absoluteFill,
47
47
  {
48
48
  backgroundColor: semantics.badgeBgOverlay,
49
49
  },
@@ -320,10 +320,7 @@ export const MessageOverlayHostLayer = ({ BackgroundComponent }: MessageOverlayH
320
320
  <GestureDetector gesture={tap}>
321
321
  <View pointerEvents='box-none' style={StyleSheet.absoluteFill}>
322
322
  {isActive ? (
323
- <Animated.View
324
- pointerEvents='none'
325
- style={[StyleSheet.absoluteFillObject, backdropStyle]}
326
- >
323
+ <Animated.View pointerEvents='none' style={[StyleSheet.absoluteFill, backdropStyle]}>
327
324
  <OverlayBackground />
328
325
  </Animated.View>
329
326
  ) : null}
@@ -332,13 +329,13 @@ export const MessageOverlayHostLayer = ({ BackgroundComponent }: MessageOverlayH
332
329
  {isActive ? (
333
330
  <Pressable
334
331
  onPress={closeOverlay}
335
- style={StyleSheet.absoluteFillObject}
332
+ style={StyleSheet.absoluteFill}
336
333
  testID='message-overlay-backdrop'
337
334
  />
338
335
  ) : null}
339
336
 
340
337
  <Animated.View style={[topItemStyle, topItemTranslateStyle]} testID='message-overlay-top'>
341
- <PortalHost name='top-item' style={StyleSheet.absoluteFillObject} />
338
+ <PortalHost name='top-item' style={styles.absoluteFill} />
342
339
  </Animated.View>
343
340
 
344
341
  <Animated.View
@@ -346,14 +343,14 @@ export const MessageOverlayHostLayer = ({ BackgroundComponent }: MessageOverlayH
346
343
  style={hostStyle}
347
344
  testID='message-overlay-message'
348
345
  >
349
- <PortalHost name='message-overlay' style={StyleSheet.absoluteFillObject} />
346
+ <PortalHost name='message-overlay' style={styles.absoluteFill} />
350
347
  </Animated.View>
351
348
 
352
349
  <Animated.View
353
350
  style={[bottomItemStyle, bottomItemTranslateStyle]}
354
351
  testID='message-overlay-bottom'
355
352
  >
356
- <PortalHost name='bottom-item' style={StyleSheet.absoluteFillObject} />
353
+ <PortalHost name='bottom-item' style={styles.absoluteFill} />
357
354
  </Animated.View>
358
355
  </View>
359
356
 
@@ -362,3 +359,13 @@ export const MessageOverlayHostLayer = ({ BackgroundComponent }: MessageOverlayH
362
359
  </GestureDetector>
363
360
  );
364
361
  };
362
+
363
+ const styles = StyleSheet.create({
364
+ absoluteFill: {
365
+ bottom: 0,
366
+ left: 0,
367
+ position: 'absolute',
368
+ right: 0,
369
+ top: 0,
370
+ },
371
+ });
package/src/version.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "9.0.0-beta.28"
2
+ "version": "9.0.0-beta.29"
3
3
  }
@@ -1,246 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const fs = require('fs');
4
- const path = require('path');
5
-
6
- const TARGET_VERSION_RANGE = {
7
- maxExclusive: '5.2.7',
8
- minInclusive: '5.1.8',
9
- };
10
-
11
- const FILE_PATCHES = {
12
- 'src/hooks/useBoundingClientRect.ts': {
13
- from: ` // @ts-ignore 👉 https://github.com/facebook/react/commit/53b1f69ba
14
- if (ref.current.unstable_getBoundingClientRect !== null) {
15
- // @ts-ignore https://github.com/facebook/react/commit/53b1f69ba
16
- const layout = ref.current.unstable_getBoundingClientRect();
17
- handler(layout);
18
- return;
19
- }
20
-
21
- // @ts-ignore once it \`unstable_getBoundingClientRect\` gets stable 🤞.
22
- if (ref.current.getBoundingClientRect !== null) {
23
- // @ts-ignore once it \`unstable_getBoundingClientRect\` gets stable.
24
- const layout = ref.current.getBoundingClientRect();
25
- handler(layout);
26
- }`,
27
- to: ` if (
28
- // @ts-ignore 👉 https://github.com/facebook/react/commit/53b1f69ba
29
- ref.current.unstable_getBoundingClientRect !== null &&
30
- // @ts-ignore 👉 https://github.com/facebook/react/commit/53b1f69ba
31
- typeof ref.current.unstable_getBoundingClientRect === 'function'
32
- ) {
33
- // @ts-ignore https://github.com/facebook/react/commit/53b1f69ba
34
- const layout = ref.current.unstable_getBoundingClientRect();
35
- handler(layout);
36
- return;
37
- }
38
-
39
- if (
40
- // @ts-ignore once it \`unstable_getBoundingClientRect\` gets stable.
41
- ref.current.getBoundingClientRect !== null &&
42
- // @ts-ignore once it \`unstable_getBoundingClientRect\` gets stable.
43
- typeof ref.current.getBoundingClientRect === 'function'
44
- ) {
45
- // @ts-ignore once it \`unstable_getBoundingClientRect\` gets stable.
46
- const layout = ref.current.getBoundingClientRect();
47
- handler(layout);
48
- }`,
49
- },
50
- 'lib/module/hooks/useBoundingClientRect.js': {
51
- from: ` // @ts-ignore 👉 https://github.com/facebook/react/commit/53b1f69ba
52
- if (ref.current.unstable_getBoundingClientRect !== null) {
53
- // @ts-ignore https://github.com/facebook/react/commit/53b1f69ba
54
- const layout = ref.current.unstable_getBoundingClientRect();
55
- handler(layout);
56
- return;
57
- }
58
-
59
- // @ts-ignore once it \`unstable_getBoundingClientRect\` gets stable 🤞.
60
- if (ref.current.getBoundingClientRect !== null) {
61
- // @ts-ignore once it \`unstable_getBoundingClientRect\` gets stable.
62
- const layout = ref.current.getBoundingClientRect();
63
- handler(layout);
64
- }`,
65
- to: ` if (
66
- // @ts-ignore 👉 https://github.com/facebook/react/commit/53b1f69ba
67
- ref.current.unstable_getBoundingClientRect !== null &&
68
- // @ts-ignore 👉 https://github.com/facebook/react/commit/53b1f69ba
69
- typeof ref.current.unstable_getBoundingClientRect === 'function') {
70
- // @ts-ignore https://github.com/facebook/react/commit/53b1f69ba
71
- const layout = ref.current.unstable_getBoundingClientRect();
72
- handler(layout);
73
- return;
74
- }
75
-
76
- if (
77
- // @ts-ignore once it \`unstable_getBoundingClientRect\` gets stable 🤞.
78
- ref.current.getBoundingClientRect !== null &&
79
- // @ts-ignore once it \`unstable_getBoundingClientRect\` gets stable.
80
- typeof ref.current.getBoundingClientRect === 'function') {
81
- // @ts-ignore once it \`unstable_getBoundingClientRect\` gets stable.
82
- const layout = ref.current.getBoundingClientRect();
83
- handler(layout);
84
- }`,
85
- },
86
- 'lib/commonjs/hooks/useBoundingClientRect.js': {
87
- from: ` // @ts-ignore 👉 https://github.com/facebook/react/commit/53b1f69ba
88
- if (ref.current.unstable_getBoundingClientRect !== null) {
89
- // @ts-ignore https://github.com/facebook/react/commit/53b1f69ba
90
- const layout = ref.current.unstable_getBoundingClientRect();
91
- handler(layout);
92
- return;
93
- }
94
-
95
- // @ts-ignore once it \`unstable_getBoundingClientRect\` gets stable 🤞.
96
- if (ref.current.getBoundingClientRect !== null) {
97
- // @ts-ignore once it \`unstable_getBoundingClientRect\` gets stable.
98
- const layout = ref.current.getBoundingClientRect();
99
- handler(layout);
100
- }`,
101
- to: ` if (
102
- // @ts-ignore 👉 https://github.com/facebook/react/commit/53b1f69ba
103
- ref.current.unstable_getBoundingClientRect !== null &&
104
- // @ts-ignore 👉 https://github.com/facebook/react/commit/53b1f69ba
105
- typeof ref.current.unstable_getBoundingClientRect === 'function') {
106
- // @ts-ignore https://github.com/facebook/react/commit/53b1f69ba
107
- var layout = ref.current.unstable_getBoundingClientRect();
108
- handler(layout);
109
- return;
110
- }
111
-
112
- if (
113
- // @ts-ignore once it \`unstable_getBoundingClientRect\` gets stable 🤞.
114
- ref.current.getBoundingClientRect !== null &&
115
- // @ts-ignore once it \`unstable_getBoundingClientRect\` gets stable.
116
- typeof ref.current.getBoundingClientRect === 'function') {
117
- // @ts-ignore once it \`unstable_getBoundingClientRect\` gets stable.
118
- var _layout = ref.current.getBoundingClientRect();
119
- handler(_layout);
120
- }`,
121
- },
122
- };
123
-
124
- function resolveBottomSheetPackageDirectory() {
125
- try {
126
- return path.dirname(require.resolve('@gorhom/bottom-sheet/package.json'));
127
- } catch {
128
- return undefined;
129
- }
130
- }
131
-
132
- function readInstalledVersion(bottomSheetPackageDirectory) {
133
- const packageJsonPath = path.join(bottomSheetPackageDirectory, 'package.json');
134
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
135
-
136
- return packageJson.version;
137
- }
138
-
139
- function parseVersion(version) {
140
- const [major = '0', minor = '0', patchWithSuffix = '0'] = version.split('.');
141
- const patch = patchWithSuffix.split('-')[0];
142
-
143
- return [major, minor, patch].map((part) => Number.parseInt(part, 10));
144
- }
145
-
146
- function compareVersions(left, right) {
147
- const leftParts = parseVersion(left);
148
- const rightParts = parseVersion(right);
149
-
150
- for (let index = 0; index < 3; index += 1) {
151
- if (leftParts[index] > rightParts[index]) {
152
- return 1;
153
- }
154
-
155
- if (leftParts[index] < rightParts[index]) {
156
- return -1;
157
- }
158
- }
159
-
160
- return 0;
161
- }
162
-
163
- function shouldPatchVersion(version) {
164
- return (
165
- compareVersions(version, TARGET_VERSION_RANGE.minInclusive) >= 0 &&
166
- compareVersions(version, TARGET_VERSION_RANGE.maxExclusive) < 0
167
- );
168
- }
169
-
170
- function patchFile(relativeFilePath, originalContents) {
171
- const patch = FILE_PATCHES[relativeFilePath];
172
-
173
- if (!patch) {
174
- return {
175
- changed: false,
176
- contents: originalContents,
177
- };
178
- }
179
-
180
- const nextContents = originalContents.replace(patch.from, patch.to);
181
-
182
- return {
183
- changed: nextContents !== originalContents,
184
- contents: nextContents,
185
- };
186
- }
187
-
188
- function patchBottomSheet(bottomSheetPackageDirectory) {
189
- const installedVersion = readInstalledVersion(bottomSheetPackageDirectory);
190
-
191
- if (!shouldPatchVersion(installedVersion)) {
192
- return { changedFilesCount: 0, installedVersion, skipped: true };
193
- }
194
-
195
- let changedFilesCount = 0;
196
-
197
- for (const relativeFilePath of Object.keys(FILE_PATCHES)) {
198
- const absoluteFilePath = path.join(bottomSheetPackageDirectory, relativeFilePath);
199
-
200
- if (!fs.existsSync(absoluteFilePath)) {
201
- continue;
202
- }
203
-
204
- const originalContents = fs.readFileSync(absoluteFilePath, 'utf8');
205
- const { changed, contents } = patchFile(relativeFilePath, originalContents);
206
-
207
- if (!changed) {
208
- continue;
209
- }
210
-
211
- fs.writeFileSync(absoluteFilePath, contents);
212
- changedFilesCount += 1;
213
- }
214
-
215
- return { changedFilesCount, installedVersion, skipped: false };
216
- }
217
-
218
- function run() {
219
- const bottomSheetPackageDirectory = resolveBottomSheetPackageDirectory();
220
-
221
- if (!bottomSheetPackageDirectory) {
222
- return;
223
- }
224
-
225
- const result = patchBottomSheet(bottomSheetPackageDirectory);
226
-
227
- if (result.skipped || result.changedFilesCount === 0) {
228
- return;
229
- }
230
-
231
- console.log(
232
- `[stream-chat-react-native-core] Applied gorhom/react-native-bottom-sheet PR #2561 patch to @gorhom/bottom-sheet@${result.installedVersion}.`,
233
- );
234
- }
235
-
236
- if (require.main === module) {
237
- run();
238
- }
239
-
240
- module.exports = {
241
- FILE_PATCHES,
242
- patchFile,
243
- run,
244
- shouldPatchVersion,
245
- TARGET_VERSION_RANGE,
246
- };