Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ class RNGoogleMapsPlusView(
override val view =
GoogleMapsViewImpl(context, locationHandler, playServiceHandler, markerBuilder, mapErrorHandler)

override fun dispose() {
view.destroyInternal()
super.dispose()
}

override var initialProps: RNInitialProps? = null
set(value) {
if (field == value) return
Expand Down
38 changes: 19 additions & 19 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ PODS:
- glog (0.3.5)
- Google-Maps-iOS-Utils (7.0.0):
- GoogleMaps (~> 10.0)
- GoogleMaps (10.7.0):
- GoogleMaps/Maps (= 10.7.0)
- GoogleMaps/Maps (10.7.0)
- GoogleMaps (10.8.0):
- GoogleMaps/Maps (= 10.8.0)
- GoogleMaps/Maps (10.8.0)
- hermes-engine (0.14.0):
- hermes-engine/Pre-built (= 0.14.0)
- hermes-engine/Pre-built (0.14.0)
- NitroModules (0.32.0):
- NitroModules (0.33.8):
- boost
- DoubleConversion
- fast_float
Expand Down Expand Up @@ -2632,14 +2632,14 @@ PODS:
- ReactCommon/turbomodule/core
- SocketRocket
- Yoga
- RNGoogleMapsPlus (1.10.2):
- RNGoogleMapsPlus (1.11.0):
- boost
- DoubleConversion
- fast_float
- fmt
- glog
- Google-Maps-iOS-Utils (= 7.0.0)
- GoogleMaps (= 10.7.0)
- GoogleMaps (= 10.8.0)
- hermes-engine
- NitroModules
- RCT-Folly
Expand Down Expand Up @@ -2757,7 +2757,7 @@ PODS:
- RNWorklets
- SocketRocket
- Yoga
- RNScreens (4.19.0):
- RNScreens (4.23.0):
- boost
- DoubleConversion
- fast_float
Expand All @@ -2784,10 +2784,10 @@ PODS:
- ReactCodegen
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- RNScreens/common (= 4.19.0)
- RNScreens/common (= 4.23.0)
- SocketRocket
- Yoga
- RNScreens/common (4.19.0):
- RNScreens/common (4.23.0):
- boost
- DoubleConversion
- fast_float
Expand Down Expand Up @@ -2816,7 +2816,7 @@ PODS:
- ReactCommon/turbomodule/core
- SocketRocket
- Yoga
- RNWorklets (0.7.1):
- RNWorklets (0.7.3):
- boost
- DoubleConversion
- fast_float
Expand All @@ -2843,10 +2843,10 @@ PODS:
- ReactCodegen
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- RNWorklets/worklets (= 0.7.1)
- RNWorklets/worklets (= 0.7.3)
- SocketRocket
- Yoga
- RNWorklets/worklets (0.7.1):
- RNWorklets/worklets (0.7.3):
- boost
- DoubleConversion
- fast_float
Expand All @@ -2873,10 +2873,10 @@ PODS:
- ReactCodegen
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- RNWorklets/worklets/apple (= 0.7.1)
- RNWorklets/worklets/apple (= 0.7.3)
- SocketRocket
- Yoga
- RNWorklets/worklets/apple (0.7.1):
- RNWorklets/worklets/apple (0.7.3):
- boost
- DoubleConversion
- fast_float
Expand Down Expand Up @@ -3190,9 +3190,9 @@ SPEC CHECKSUMS:
fmt: a40bb5bd0294ea969aaaba240a927bd33d878cdd
glog: 5683914934d5b6e4240e497e0f4a3b42d1854183
Google-Maps-iOS-Utils: cbaa0660586302c8d4149b43910a4973494ed64c
GoogleMaps: 5db81729b4f6defd40820d46b49a350273ec1d28
GoogleMaps: fe4035acb768ed14ce732811363f232550ba55af
hermes-engine: ff3a9fe253825c0e37c52df65dd0c483ded41ece
NitroModules: 5ab248c0c4bc0a440414c0a8509dbad55cc7da6c
NitroModules: ceb81cc842944a13b5f7d451f92008e8cf38e12c
RCT-Folly: 846fda9475e61ec7bcbf8a3fe81edfcaeb090669
RCTDeprecation: a41bbdd9af30bf2e5715796b313e44ec43eefff1
RCTRequired: 7be34aabb0b77c3cefe644528df0fa0afad4e4d0
Expand Down Expand Up @@ -3264,10 +3264,10 @@ SPEC CHECKSUMS:
ReactCodegen: d663254bf59e57e5ed7c65638bd45f358a373bba
ReactCommon: 15e1e727fa34f760beb7dd52928687fda8edf8dc
RNGestureHandler: c6327cf6e2bd384dc90351ccfff0da8142d62f54
RNGoogleMapsPlus: b871e689be34a1a2ae40178bc1a4e67dcf54cd6f
RNGoogleMapsPlus: 66b395c9122ca8c818b82861ad7dd892f83640f8
RNReanimated: fbcb7fd8da5b0b088401542c58fb5d266388f1cf
RNScreens: d6413aeb1878cdafd3c721e2c5218faf5d5d3b13
RNWorklets: 69f7239afaf3a156f7f9549eeb0ae8d02adc095f
RNScreens: 199799bdab32fa1e17ebf938b06fec52033e81e5
RNWorklets: 944dddd0eef13006b658e653abbb3ee8365c3809
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
SVGKit: 1ad7513f8c74d9652f94ed64ddecda1a23864dea
Yoga: 33b53536a0500d039f2cd78caf1d5d68712d3af7
Expand Down
24 changes: 12 additions & 12 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,36 @@
"build:ios": "react-native build-ios --mode Debug --extra-params 'CODE_SIGNING_ALLOWED=NO CODE_SIGNING_REQUIRED=NO'"
},
"dependencies": {
"@react-navigation/native": "7.1.26",
"@react-navigation/native-stack": "7.9.0",
"@react-navigation/stack": "7.6.13",
"@react-navigation/native": "7.1.28",
"@react-navigation/native-stack": "7.12.0",
"@react-navigation/stack": "7.7.1",
"react": "19.2.3",
"react-hook-form": "7.71.0",
"react-hook-form": "7.71.1",
"react-native": "0.83.1",
"react-native-clusterer": "5.0.2",
"react-native-gesture-handler": "2.30.0",
"react-native-google-maps-plus": "workspace:*",
"react-native-nitro-modules": "0.32.0",
"react-native-nitro-modules": "0.33.8",
"react-native-reanimated": "4.2.1",
"react-native-safe-area-context": "5.6.2",
"react-native-screens": "4.19.0",
"react-native-worklets": "0.7.1",
"react-native-screens": "4.23.0",
"react-native-worklets": "0.7.3",
"superstruct": "2.0.2"
},
"devDependencies": {
"@babel/core": "7.28.5",
"@babel/preset-env": "7.28.5",
"@babel/runtime": "7.28.4",
"@react-native-community/cli": "20.1.0",
"@react-native-community/cli-platform-android": "20.1.0",
"@react-native-community/cli-platform-ios": "20.1.0",
"@react-native-community/cli": "20.1.1",
"@react-native-community/cli-platform-android": "20.1.1",
"@react-native-community/cli-platform-ios": "20.1.1",
"@react-native/babel-preset": "0.83.1",
"@react-native/metro-config": "0.83.1",
"@react-native/typescript-config": "0.83.1",
"@types/react": "19.2.8",
"babel-plugin-module-resolver": "5.0.2",
"react-native-builder-bob": "0.40.17",
"react-native-monorepo-config": "0.3.2"
"react-native-builder-bob": "0.40.18",
"react-native-monorepo-config": "0.3.3"
},
"engines": {
"node": ">=20"
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@
"eslint-plugin-unused-imports": "4.3.0",
"jest": "30.2.0",
"lefthook": "2.0.13",
"nitrogen": "0.32.0",
"nitrogen": "0.33.8",
"prettier": "3.7.4",
"react": "19.2.3",
"react-native": "0.83.1",
"react-native-builder-bob": "0.40.17",
"react-native-nitro-modules": "0.32.0",
"react-native-nitro-modules": "0.33.8",
"semantic-release": "25.0.2",
"typedoc": "0.28.16",
"typescript": "5.9.3"
Expand Down
66 changes: 28 additions & 38 deletions scripts/nitrogen-patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
* - Replaces 'com.margelo.nitro.rngooglemapsplus' -> 'com.rngooglemapsplus'
* - Replaces 'com/margelo/nitro/rngooglemapsplus' -> 'com/rngooglemapsplus'
* - Removes 'margelo/nitro/' in RNGoogleMapsPlusOnLoad.cpp
* - Inserts `prepareToRecycleView()`
* - Inserts `onDropViewInstance()`
* nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/views/HybridRNGoogleMapsPlusViewManager.kt
*
* iOS
* - Inserts `+ (BOOL)shouldBeRecycled`
* - Inserts `+ (void)dealloc`
* nitrogen/generated/ios/c++/views/HybridRNGoogleMapsPlusViewComponent.mm
*/
import { readFile, readdir, writeFile } from 'node:fs/promises';
Expand Down Expand Up @@ -70,33 +70,19 @@ const REPLACEMENTS = [
const __filename = fileURLToPath(import.meta.url);
const filename = basename(__filename);

const ANDROID_VIEW_MANAGER_METHODS =
/override fun onDropViewInstance\(view: View\)\s*\{\s*super\.onDropViewInstance\(view\)\s*views\.remove\(view\)\s*\}/m;
const PATCH_MARKER = ` // added by ${filename}`;

const ANDROID_VIEW_MANAGER_METHODS_NEW = `
const ON_DROP_VIEW_INSTANCE_ANDROID = `
${PATCH_MARKER}
override fun onDropViewInstance(view: View) {
val hybridView = view.getTag(associated_hybrid_view_tag) as? RNGoogleMapsPlusView
hybridView?.dispose()
view.setTag(associated_hybrid_view_tag, null)
super.onDropViewInstance(view)
views.remove(view)
/// added by ${filename}
if (view is GoogleMapsViewImpl) {
view.destroyInternal()
}
}

/// added by ${filename}
override fun prepareToRecycleView(reactContext: ThemedReactContext, view: View): View? {
return null
}
`;

const RECYCLE_METHOD_IOS = `
/// added by ${filename}
+ (BOOL)shouldBeRecycled
{
return NO;
}
}`;

/// added by ${filename}
const DEALLOC_METHOD_IOS = `
${PATCH_MARKER}
- (void)dealloc {
if (_hybridView) {
RNGoogleMapsPlus::HybridRNGoogleMapsPlusViewSpec_cxx& swiftPart = _hybridView->getSwiftPart();
Expand All @@ -118,28 +104,32 @@ async function processFile(filePath) {
}

if (path.resolve(filePath) === path.resolve(HYBRID_VIEW_MANAGER)) {
if (ANDROID_VIEW_MANAGER_METHODS.test(updated)) {
if (!updated.includes(PATCH_MARKER)) {
const pattern = /(override\s+fun\s+createViewInstance[\s\S]*?\})/m;

if (!pattern.test(updated)) {
throw new Error(
`Pattern for "createViewInstance" not found in ${filePath}`
);
}

updated = updated.replace(
ANDROID_VIEW_MANAGER_METHODS,
ANDROID_VIEW_MANAGER_METHODS_NEW
);
} else {
throw new Error(
`Pattern for HybridRNGoogleMapsPlusViewManager not found in ${filePath}`
pattern,
`$1\n${ON_DROP_VIEW_INSTANCE_ANDROID}`
);
}
}

if (path.resolve(filePath) === path.resolve(HYBRID_VIEW_COMPONENT_IOS)) {
if (!/\+\s*\(BOOL\)\s*shouldBeRecycled/.test(updated)) {
const pattern =
/(- \(instancetype\)\s*init\s*\{(?:[^{}]|\{[^{}]*\})*\})/m;
if (!updated.includes(PATCH_MARKER)) {
const initPattern =
/(-\s*\(instancetype\)\s*init[\s\S]*?return\s+self;\s*\})/m;

if (pattern.test(updated)) {
updated = updated.replace(pattern, `$1\n${RECYCLE_METHOD_IOS}`);
} else {
if (!initPattern.test(updated)) {
throw new Error(`Pattern for "init" not found in ${filePath}`);
}

updated = updated.replace(initPattern, `$1\n${DEALLOC_METHOD_IOS}`);
}
}

Expand Down
Loading
Loading