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,9 +41,8 @@ class RNGoogleMapsPlusView(
override val view =
GoogleMapsViewImpl(context, locationHandler, playServiceHandler, markerBuilder, mapErrorHandler)

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

override var initialProps: RNInitialProps? = null
Expand Down
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ PODS:
- hermes-engine (250829098.0.9):
- hermes-engine/Pre-built (= 250829098.0.9)
- hermes-engine/Pre-built (250829098.0.9)
- NitroModules (0.35.0):
- NitroModules (0.35.1):
- hermes-engine
- RCTRequired
- RCTTypeSafety
Expand Down Expand Up @@ -2418,7 +2418,7 @@ SPEC CHECKSUMS:
Google-Maps-iOS-Utils: cbaa0660586302c8d4149b43910a4973494ed64c
GoogleMaps: 133ba5beb4979592001a6cd0125a502243439ff9
hermes-engine: 0f49a842b975f3720533f9a7d353cd9e0f578f75
NitroModules: b7fbb99c94da87b162f6e661d7cfa8ad014f7b7d
NitroModules: 3ccfac829344db72859f6ec0d07f58cfe39f4cd1
RCTDeprecation: af44b104091a34482596cd9bd7e8d90c4e9b4bd7
RCTRequired: bb77b070f75f53398ce43c0aaaa58337cebe2bf6
RCTSwiftUI: afc0a0a635860da1040a0b894bfd529da06d7810
Expand Down
6 changes: 3 additions & 3 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
},
"dependencies": {
"@react-navigation/native": "7.1.33",
"@react-navigation/native-stack": "7.14.4",
"@react-navigation/stack": "7.8.4",
"@react-navigation/native-stack": "7.14.5",
"@react-navigation/stack": "7.8.5",
"react": "19.2.3",
"react-hook-form": "7.71.2",
"react-native": "0.84.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.35.0",
"react-native-nitro-modules": "0.35.1",
"react-native-reanimated": "4.2.2",
"react-native-safe-area-context": "5.7.0",
"react-native-screens": "4.24.0",
Expand Down
2 changes: 1 addition & 1 deletion ios/RNGoogleMapsPlusView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class RNGoogleMapsPlusView: HybridRNGoogleMapsPlusViewSpec {
)
}

func dispose() {
func onDropView() {
impl.deinitInternal()
}

Expand Down
20 changes: 16 additions & 4 deletions nitro.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,24 @@
],
"autolinking": {
"RNGoogleMapsPlusView": {
"swift": "RNGoogleMapsPlusView",
"kotlin": "RNGoogleMapsPlusView"
"ios": {
"language": "swift",
"implementationClassName": "RNGoogleMapsPlusView"
},
"android": {
"language": "kotlin",
"implementationClassName": "RNGoogleMapsPlusView"
}
},
"RNGoogleMapsPlusModule": {
"swift": "RNGoogleMapsPlusModule",
"kotlin": "RNGoogleMapsPlusModule"
"ios": {
"language": "swift",
"implementationClassName": "RNGoogleMapsPlusModule"
},
"android": {
"language": "kotlin",
"implementationClassName": "RNGoogleMapsPlusModule"
}
}
},
"ignorePaths": ["**/node_modules"]
Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@
"provenance": true
},
"devDependencies": {
"@commitlint/cli": "20.4.3",
"@commitlint/config-conventional": "20.4.3",
"@eslint/compat": "2.0.2",
"@eslint/eslintrc": "3.3.4",
"@eslint/js": "9.39.3",
"@commitlint/cli": "20.4.4",
"@commitlint/config-conventional": "20.4.4",
"@eslint/compat": "2.0.3",
"@eslint/eslintrc": "3.3.5",
"@eslint/js": "9.39.4",
"@expo/config-plugins": "55.0.6",
"@react-native/babel-preset": "0.84.1",
"@react-native/eslint-config": "0.84.1",
Expand All @@ -93,22 +93,22 @@
"@types/react": "19.2.14",
"conventional-changelog-conventionalcommits": "9.3.0",
"del-cli": "7.0.0",
"eslint": "9.39.3",
"eslint": "9.39.4",
"eslint-config-prettier": "10.1.8",
"eslint-import-resolver-typescript": "4.4.4",
"eslint-plugin-import": "2.32.0",
"eslint-plugin-jsdoc": "62.7.1",
"eslint-plugin-jsdoc": "62.8.0",
"eslint-plugin-prettier": "5.5.5",
"eslint-plugin-tsdoc": "0.5.2",
"eslint-plugin-unused-imports": "4.4.1",
"jest": "30.2.0",
"lefthook": "2.1.2",
"nitrogen": "0.35.0",
"jest": "30.3.0",
"lefthook": "2.1.4",
"nitrogen": "0.35.1",
"prettier": "3.8.1",
"react": "19.2.3",
"react-native": "0.84.1",
"react-native-builder-bob": "0.40.18",
"react-native-nitro-modules": "0.35.0",
"react-native-nitro-modules": "0.35.1",
"semantic-release": "25.0.3",
"typedoc": "0.28.17",
"typescript": "5.9.3"
Expand Down
75 changes: 2 additions & 73 deletions scripts/nitrogen-patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,27 @@
* - Replaces 'com.margelo.nitro.rngooglemapsplus' -> 'com.rngooglemapsplus'
* - Replaces 'com/margelo/nitro/rngooglemapsplus' -> 'com/rngooglemapsplus'
* - Removes 'margelo/nitro/' in RNGoogleMapsPlusOnLoad.cpp
* - Inserts `onDropViewInstance()`
* nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/views/HybridRNGoogleMapsPlusViewManager.kt
*
* iOS
* - Inserts `+ (void)dealloc`
* nitrogen/generated/ios/c++/views/HybridRNGoogleMapsPlusViewComponent.mm
*/
import { readFile, readdir, writeFile } from 'node:fs/promises';
import { copyFile, mkdir } from 'node:fs/promises';
import path from 'node:path';
import { basename } from 'path';
import { fileURLToPath } from 'url';

const ROOT_ANDROID = path.join(
process.cwd(),
'nitrogen',
'generated',
'android'
);
const ROOT_IOS = path.join(process.cwd(), 'nitrogen', 'generated', 'ios');

const SRC_JSON_DIR = path.join(
process.cwd(),
'nitrogen',
'generated',
'shared',
'json'
);

const DEST_JSON_DIR = path.join(
process.cwd(),
'lib',
Expand All @@ -46,16 +40,6 @@ const ANDROID_ONLOAD_FILE = path.join(
'RNGoogleMapsPlusOnLoad.cpp'
);

const HYBRID_VIEW_MANAGER = path.join(
ROOT_ANDROID,
'kotlin/com/margelo/nitro/rngooglemapsplus/views/HybridRNGoogleMapsPlusViewManager.kt'
);

const HYBRID_VIEW_COMPONENT_IOS = path.join(
ROOT_IOS,
'c++/views/HybridRNGoogleMapsPlusViewComponent.mm'
);

const REPLACEMENTS = [
{
regex: /com\.margelo\.nitro\.rngooglemapsplus/g,
Expand All @@ -67,30 +51,6 @@ const REPLACEMENTS = [
},
];

const __filename = fileURLToPath(import.meta.url);
const filename = basename(__filename);

const PATCH_MARKER = ` // added by ${filename}`;

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)
}`;

const DEALLOC_METHOD_IOS = `
${PATCH_MARKER}
- (void)dealloc {
if (_hybridView) {
RNGoogleMapsPlus::HybridRNGoogleMapsPlusViewSpec_cxx& swiftPart = _hybridView->getSwiftPart();
swiftPart.dispose();
_hybridView.reset();
}
}`;

async function processFile(filePath) {
let content = await readFile(filePath, 'utf8');
let updated = content;
Expand All @@ -103,36 +63,6 @@ async function processFile(filePath) {
updated = updated.replace(/margelo\/nitro\//g, '');
}

if (path.resolve(filePath) === path.resolve(HYBRID_VIEW_MANAGER)) {
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(
pattern,
`$1\n${ON_DROP_VIEW_INSTANCE_ANDROID}`
);
}
}

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

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

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

if (updated !== content) {
await writeFile(filePath, updated, 'utf8');
console.log(`Updated: ${filePath}`);
Expand Down Expand Up @@ -172,7 +102,6 @@ async function copyJsonFiles() {
try {
await copyJsonFiles();
await start(ROOT_ANDROID);
await start(ROOT_IOS);
console.log('All Nitrogen files patched successfully.');
} catch (err) {
console.error('Error while processing files:', err);
Expand Down
Loading
Loading