@niibase/bottom-sheet-manager 1.4.0 → 1.4.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@niibase/bottom-sheet-manager",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "A bottom sheet manager for react-native based on @gorhom/bottom-sheet",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -47,6 +47,7 @@
47
47
  "files": [
48
48
  "src",
49
49
  "lib",
50
+ "scripts",
50
51
  "LICENSE"
51
52
  ],
52
53
  "peerDependencies": {
@@ -0,0 +1,36 @@
1
+ import { readFileSync, writeFileSync } from "node:fs";
2
+ import { dirname, join, resolve } from "node:path";
3
+ import { execSync } from "node:child_process";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = dirname(__filename);
8
+
9
+ // Get the package root (one level up from scripts/)
10
+ const packageRoot = dirname(__dirname);
11
+ const maybeNodeModules = resolve(packageRoot, "../");
12
+ const isInNodeModules =
13
+ maybeNodeModules.endsWith("node_modules") ||
14
+ maybeNodeModules.endsWith("node_modules/@niibase");
15
+
16
+ if (isInNodeModules) {
17
+ // Fix keyboard not closing issue: https://github.com/gorhom/react-native-bottom-sheet/pull/2511
18
+ const gorhamBottomSheet = join(
19
+ maybeNodeModules,
20
+ "@gorhom/bottom-sheet/src/components/bottomSheet/BottomSheet.tsx",
21
+ );
22
+
23
+ try {
24
+ const content = readFileSync(gorhamBottomSheet, "utf-8");
25
+ const updated = content.replace(
26
+ /index\s*=\s*highestDetentPosition\s*\?\?\s*DEFAULT_KEYBOARD_INDEX\s*;/g,
27
+ "index = detents?.indexOf(highestDetentPosition ?? 0) ?? DEFAULT_KEYBOARD_INDEX;",
28
+ );
29
+ writeFileSync(gorhamBottomSheet, updated, "utf-8");
30
+ console.log("Applied patch for @gorhom/bottom-sheet");
31
+ } catch (error) {
32
+ console.error("Error updating @gorhom/bottom-sheet:", error.message);
33
+ }
34
+ } else {
35
+ execSync("yarn run patch", { stdio: "inherit" });
36
+ }