Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"main": "expo-router/entry",
"scripts": {
"start": "cross-env EXPO_NO_DOTENV=1 expo start",
"postinstall": "patch-package",
"prebuild": "cross-env EXPO_NO_DOTENV=1 yarn expo prebuild",
"android": "cross-env EXPO_NO_DOTENV=1 expo run:android",
"ios": "cross-env EXPO_NO_DOTENV=1 expo run:ios",
Expand Down Expand Up @@ -84,7 +85,7 @@
"@notifee/react-native": "^9.1.8",
"@novu/react-native": "~2.6.6",
"@react-native-community/netinfo": "11.4.1",
"@rnmapbox/maps": "10.1.42-rc.0",
"@rnmapbox/maps": "10.2.10",
"@semantic-release/git": "^10.0.1",
"@sentry/react-native": "~6.14.0",
"@shopify/flash-list": "1.7.6",
Expand Down Expand Up @@ -206,6 +207,8 @@
"jest-junit": "~16.0.0",
"lint-staged": "~15.2.9",
"np": "~10.0.7",
"patch-package": "^8.0.1",
"postinstall-postinstall": "^2.1.0",
"prettier": "~3.3.3",
"react-native-svg-transformer": "~1.5.1",
"tailwindcss": "3.4.4",
Expand Down
25,904 changes: 25,904 additions & 0 deletions patches/@rnmapbox+maps+10.2.10.patch

Large diffs are not rendered by default.

141 changes: 141 additions & 0 deletions scripts/patch-mapbox-final.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
const fs = require('fs');
const path = require('path');

const filePath = path.join(__dirname, '../node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/styles/RNMBXStyleFactory.kt');

Check failure on line 4 in scripts/patch-mapbox-final.js

View workflow job for this annotation

GitHub Actions / test

'__dirname' is not defined

// Restore from backup if exists
const origPath = filePath + '.original';
if (fs.existsSync(origPath)) {
fs.copyFileSync(origPath, filePath);
}

let content = fs.readFileSync(filePath, 'utf8');
const lines = content.split('\n');

// Properties/functions to remove
const deprecatedProps = [
'fillPatternCrossFade',
'lineElevationReference',
'lineCrossSlope',
'linePatternCrossFade',
'circleElevationReference',
'fillExtrusionPatternCrossFade',
'fillExtrusionHeightAlignment',
'fillExtrusionBaseAlignment',
'backgroundPitchAlignment',
];

const result = [];
let i = 0;

while (i < lines.length) {
const line = lines[i];

// Check if this is a case statement for a deprecated property
let isDeprecatedCase = false;
for (const prop of deprecatedProps) {
if (line.match(new RegExp(`"${prop}"\\s*->\\s*$`))) {
isDeprecatedCase = true;
// Comment out this line
result.push(line.replace(/^(\s*)(.*)$/, '$1// $2 // Deprecated in Mapbox SDK 11.8+'));

// Find and comment out the next statement (could be a function call or block)
let j = i + 1;
let braceDepth = 0;
let inBlock = false;

while (j < lines.length) {
const nextLine = lines[j];

// Check if we've hit another case or end of when block
if (nextLine.match(/^\s*"/)) {
break;
}
if (nextLine.match(/^\s*else\s*->/)) {
break;
}

// Count braces to handle blocks
const openBraces = (nextLine.match(/{/g) || []).length;
const closeBraces = (nextLine.match(/}/g) || []).length;
braceDepth += openBraces - closeBraces;

if (openBraces > 0) inBlock = true;

// Comment out non-empty lines
if (nextLine.trim()) {
result.push(nextLine.replace(/^(\s*)(.*)$/, '$1// $2'));
} else {
result.push(nextLine);
}

// If we were in a block and braces are balanced, we're done
if (inBlock && braceDepth === 0) {
j++;
break;
}

// If not in a block and we have a statement, move on
if (!inBlock && nextLine.trim() && !nextLine.trim().startsWith('//')) {
j++;
break;
}

j++;
}

i = j;
continue;
}
}

if (!isDeprecatedCase) {
// Check if this is a function definition for deprecated function
let isDeprecatedFunc = false;
for (const prop of deprecatedProps) {
const funcName = 'set' + prop.charAt(0).toUpperCase() + prop.slice(1);
if (line.match(new RegExp(`fun\\s+${funcName}\\s*\\(`))) {
isDeprecatedFunc = true;

// Comment out entire function
let braceDepth = 0;
let j = i;

while (j < lines.length) {
const funcLine = lines[j];
const openBraces = (funcLine.match(/{/g) || []).length;
const closeBraces = (funcLine.match(/}/g) || []).length;
braceDepth += openBraces - closeBraces;

// Comment the line
if (funcLine.trim()) {
result.push(funcLine.replace(/^(\s*)(.*)$/, '$1// $2'));
} else {
result.push(funcLine);
}

j++;

// Function complete when braces balance
if (braceDepth === 0 && closeBraces > 0) {
break;
}
}

i = j;
break;
}
}

if (!isDeprecatedFunc) {
result.push(line);
i++;
}
}
}

// Write the modified content
fs.writeFileSync(filePath, result.join('\n'));

console.log('Successfully patched RNMBXStyleFactory.kt');
console.log('Deprecated properties and functions have been commented out');
54 changes: 54 additions & 0 deletions scripts/patch-mapbox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const fs = require('fs');
const path = require('path');

const filePath = path.join(__dirname, '../node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/styles/RNMBXStyleFactory.kt');

Check failure on line 4 in scripts/patch-mapbox.js

View workflow job for this annotation

GitHub Actions / test

'__dirname' is not defined

console.log('Reading file:', filePath);
let content = fs.readFileSync(filePath, 'utf8');

// Backup original
fs.writeFileSync(filePath + '.original', content);

// Functions to remove
const functionsToRemove = [
'setFillPatternCrossFade',
'setLineElevationReference',
'setLineCrossSlope',
'setLinePatternCrossFade',
'setCircleElevationReference',
'setFillExtrusionPatternCrossFade',
'setFillExtrusionHeightAlignment',
'setFillExtrusionBaseAlignment',
'setBackgroundPitchAlignment',
];

functionsToRemove.forEach((funcName) => {
console.log(`Commenting out function: ${funcName}`);

// Match the function and its body with proper brace matching
const regex = new RegExp(`(\\s+)(fun\\s+${funcName}\\s*\\([^)]+\\)[^{]*\\{)([\\s\\S]*?)(\\n\\s+\\})`, 'gm');

content = content.replace(regex, (match, indent, funcDecl, funcBody, closeBrace) => {
// Comment each line
const commentedDecl = indent + '// ' + funcDecl.trim();
const commentedBody = funcBody
.split('\n')
.map((line) => {
if (line.trim()) {
// Preserve original indentation and add comment
return line.replace(/^(\s*)/, '$1// ');
}
return line;
})
.join('\n');
const commentedClose = closeBrace.replace(/^(\s*)/, '$1// ');

return commentedDecl + commentedBody + commentedClose;
});
});

// Write the modified content
fs.writeFileSync(filePath, content);

console.log('Successfully patched RNMBXStyleFactory.kt');
console.log('Original backed up to', filePath + '.original');
106 changes: 106 additions & 0 deletions scripts/patch-rnmapbox-complete.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#!/usr/bin/env perl
use strict;
use warnings;

my $file = 'node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/styles/RNMBXStyleFactory.kt';

# Read file
open(my $fh, '<', $file) or die "Cannot open $file: $!";
my @lines = <$fh>;
close($fh);

# Backup (restore from original if exists)
if (-f "$file.original") {
open(my $orig, '<', "$file.original") or die "Cannot open original: $!";
@lines = <$orig>;
close($orig);
}

my @functions = qw(
setFillPatternCrossFade
setLineElevationReference
setLineCrossSlope
setLinePatternCrossFade
setCircleElevationReference
setFillExtrusionPatternCrossFade
setFillExtrusionHeightAlignment
setFillExtrusionBaseAlignment
setBackgroundPitchAlignment
);

my $in_function = 0;
my $in_case = 0;
my $brace_count = 0;
my @output;

for (my $i = 0; $i < @lines; $i++) {
my $line = $lines[$i];

# Check if we're in a case statement for one of the deprecated functions
foreach my $func (@functions) {
# Convert function names to property names (e.g., setFillPatternCrossFade -> fillPatternCrossFade)
my $propName = $func;
$propName =~ s/^set(.)/lc($1)/e; # Remove 'set' and lowercase first letter

if ($line =~ /"$propName"\s*->/ && !$in_case) {
$in_case = 1;
# Comment this line and peek ahead to find where the case ends
push @output, $line;
$output[-1] =~ s/^(\s*)(.+)$/$1\/\/ $2/;

# Look ahead to find what comes next and comment it too
my $j = $i + 1;
while ($j < @lines && $lines[$j] !~ /^\s*"/ && $lines[$j] !~ /^\s*else\s*->/ && $lines[$j] !~ /^\s*\}/) {
push @output, $lines[$j];
$output[-1] =~ s/^(\s*)(.+)$/$1\/\/ $2/ if $lines[$j] =~ /\S/;
$i = $j;
$j++;
# If we hit a closing brace that's part of the case, stop
if ($lines[$j] =~ /^\s*}\s*$/) {
last;
}
}
$in_case = 0;
next;
}
}

# Check if we're starting a function we want to comment
if (!$in_function) {
foreach my $func (@functions) {
if ($line =~ /fun\s+$func\s*\(/) {
$in_function = 1;
$brace_count = 0;
last;
}
}
}

if ($in_function) {
# Count braces
my $open = () = $line =~ /{/g;
my $close = () = $line =~ /}/g;
$brace_count += $open - $close;

# Comment the line
if ($line =~ /^(\s*)(.+)$/) {
push @output, "$1// $2\n";
} else {
push @output, $line;
}

# Check if function is complete
if ($brace_count == 0 && $close > 0) {
$in_function = 0;
}
} else {
push @output, $line unless $in_case;
}
}

# Write output
open(my $out, '>', $file) or die "Cannot write to $file: $!";
print $out @output;
close($out);

print "Successfully patched $file\n";
Loading
Loading