Skip to content

Commit b90a9bc

Browse files
authored
Merge pull request #97 from Resgrid/develop
RR-T40 Fixing map error, staffing issues, bottom sheets, edit call.
2 parents 5398932 + 9d3bf5f commit b90a9bc

24 files changed

+27084
-274
lines changed

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"main": "expo-router/entry",
77
"scripts": {
88
"start": "cross-env EXPO_NO_DOTENV=1 expo start",
9+
"postinstall": "patch-package",
910
"prebuild": "cross-env EXPO_NO_DOTENV=1 yarn expo prebuild",
1011
"android": "cross-env EXPO_NO_DOTENV=1 expo run:android",
1112
"ios": "cross-env EXPO_NO_DOTENV=1 expo run:ios",
@@ -84,7 +85,7 @@
8485
"@notifee/react-native": "^9.1.8",
8586
"@novu/react-native": "~2.6.6",
8687
"@react-native-community/netinfo": "11.4.1",
87-
"@rnmapbox/maps": "10.1.42-rc.0",
88+
"@rnmapbox/maps": "10.2.10",
8889
"@semantic-release/git": "^10.0.1",
8990
"@sentry/react-native": "~6.14.0",
9091
"@shopify/flash-list": "1.7.6",
@@ -206,6 +207,8 @@
206207
"jest-junit": "~16.0.0",
207208
"lint-staged": "~15.2.9",
208209
"np": "~10.0.7",
210+
"patch-package": "^8.0.1",
211+
"postinstall-postinstall": "^2.1.0",
209212
"prettier": "~3.3.3",
210213
"react-native-svg-transformer": "~1.5.1",
211214
"tailwindcss": "3.4.4",

patches/@rnmapbox+maps+10.2.10.patch

Lines changed: 25904 additions & 0 deletions
Large diffs are not rendered by default.

scripts/patch-mapbox-final.js

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
/* eslint-disable no-undef */
2+
const fs = require('fs');
3+
const path = require('path');
4+
5+
const filePath = path.join(__dirname, '../node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/styles/RNMBXStyleFactory.kt');
6+
7+
// Restore from backup if exists
8+
const origPath = filePath + '.original';
9+
if (fs.existsSync(origPath)) {
10+
fs.copyFileSync(origPath, filePath);
11+
}
12+
13+
let content = fs.readFileSync(filePath, 'utf8');
14+
const lines = content.split('\n');
15+
16+
// Properties/functions to remove
17+
const deprecatedProps = [
18+
'fillPatternCrossFade',
19+
'lineElevationReference',
20+
'lineCrossSlope',
21+
'linePatternCrossFade',
22+
'circleElevationReference',
23+
'fillExtrusionPatternCrossFade',
24+
'fillExtrusionHeightAlignment',
25+
'fillExtrusionBaseAlignment',
26+
'backgroundPitchAlignment',
27+
];
28+
29+
const result = [];
30+
let i = 0;
31+
32+
while (i < lines.length) {
33+
const line = lines[i];
34+
35+
// Check if this is a case statement for a deprecated property
36+
let isDeprecatedCase = false;
37+
for (const prop of deprecatedProps) {
38+
if (line.match(new RegExp(`"${prop}"\\s*->\\s*(?:$|\\{|[^\\n]+)`))) {
39+
isDeprecatedCase = true;
40+
// Comment out this line
41+
result.push(line.replace(/^(\s*)(.*)$/, '$1// $2 // Deprecated in Mapbox SDK 11.8+'));
42+
43+
// Find and comment out the next statement (could be a function call or block)
44+
let j = i + 1;
45+
let braceDepth = 0;
46+
let inBlock = false;
47+
48+
while (j < lines.length) {
49+
const nextLine = lines[j];
50+
51+
// Check if we've hit another case or end of when block
52+
if (nextLine.match(/^\s*"/)) {
53+
break;
54+
}
55+
if (nextLine.match(/^\s*else\s*->/)) {
56+
break;
57+
}
58+
59+
// Count braces to handle blocks
60+
const openBraces = (nextLine.match(/{/g) || []).length;
61+
const closeBraces = (nextLine.match(/}/g) || []).length;
62+
braceDepth += openBraces - closeBraces;
63+
64+
if (openBraces > 0) inBlock = true;
65+
66+
// Comment out non-empty lines
67+
if (nextLine.trim()) {
68+
result.push(nextLine.replace(/^(\s*)(.*)$/, '$1// $2'));
69+
} else {
70+
result.push(nextLine);
71+
}
72+
73+
// If we were in a block and braces are balanced, we're done
74+
if (inBlock && braceDepth === 0) {
75+
j++;
76+
break;
77+
}
78+
79+
// If not in a block and we have a statement, move on
80+
if (!inBlock && nextLine.trim() && !nextLine.trim().startsWith('//')) {
81+
j++;
82+
break;
83+
}
84+
85+
j++;
86+
}
87+
88+
i = j;
89+
continue;
90+
}
91+
}
92+
93+
if (!isDeprecatedCase) {
94+
// Check if this is a function definition for deprecated function
95+
let isDeprecatedFunc = false;
96+
for (const prop of deprecatedProps) {
97+
const funcName = 'set' + prop.charAt(0).toUpperCase() + prop.slice(1);
98+
if (line.match(new RegExp(`fun\\s+${funcName}\\s*\\(`))) {
99+
isDeprecatedFunc = true;
100+
101+
// Comment out entire function
102+
let braceDepth = 0;
103+
let j = i;
104+
105+
while (j < lines.length) {
106+
const funcLine = lines[j];
107+
const openBraces = (funcLine.match(/{/g) || []).length;
108+
const closeBraces = (funcLine.match(/}/g) || []).length;
109+
braceDepth += openBraces - closeBraces;
110+
111+
// Comment the line
112+
if (funcLine.trim()) {
113+
result.push(funcLine.replace(/^(\s*)(.*)$/, '$1// $2'));
114+
} else {
115+
result.push(funcLine);
116+
}
117+
118+
j++;
119+
120+
// Function complete when braces balance
121+
if (braceDepth === 0 && closeBraces > 0) {
122+
break;
123+
}
124+
}
125+
126+
i = j;
127+
break;
128+
}
129+
}
130+
131+
if (!isDeprecatedFunc) {
132+
result.push(line);
133+
i++;
134+
}
135+
}
136+
}
137+
138+
// Create backup if it doesn't exist
139+
const originalFilePath = filePath + '.original';
140+
if (!fs.existsSync(originalFilePath)) {
141+
const originalContent = fs.readFileSync(filePath, 'utf8');
142+
fs.writeFileSync(originalFilePath, originalContent);
143+
console.log('Created backup at', originalFilePath);
144+
}
145+
146+
// Write the modified content
147+
fs.writeFileSync(filePath, result.join('\n'));
148+
149+
console.log('Successfully patched RNMBXStyleFactory.kt');
150+
console.log('Deprecated properties and functions have been commented out');

scripts/patch-mapbox.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/* eslint-env node */
2+
const fs = require('fs');
3+
const path = require('path');
4+
5+
const filePath = path.join(__dirname, '../node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/styles/RNMBXStyleFactory.kt');
6+
7+
console.log('Reading file:', filePath);
8+
let content = fs.readFileSync(filePath, 'utf8');
9+
10+
// Backup original
11+
fs.writeFileSync(filePath + '.original', content);
12+
13+
// Functions to remove
14+
const functionsToRemove = [
15+
'setFillPatternCrossFade',
16+
'setLineElevationReference',
17+
'setLineCrossSlope',
18+
'setLinePatternCrossFade',
19+
'setCircleElevationReference',
20+
'setFillExtrusionPatternCrossFade',
21+
'setFillExtrusionHeightAlignment',
22+
'setFillExtrusionBaseAlignment',
23+
'setBackgroundPitchAlignment',
24+
];
25+
26+
functionsToRemove.forEach((funcName) => {
27+
console.log(`Commenting out function: ${funcName}`);
28+
29+
// Match the function and its body with proper brace matching
30+
const regex = new RegExp(`(\\s+)(fun\\s+${funcName}\\s*\\([^)]+\\)[^{]*\\{)([\\s\\S]*?)(\\n\\s+\\})`, 'gm');
31+
32+
content = content.replace(regex, (match, indent, funcDecl, funcBody, closeBrace) => {
33+
// Comment each line
34+
const commentedDecl = indent + '// ' + funcDecl.trim();
35+
const commentedBody = funcBody
36+
.split('\n')
37+
.map((line) => {
38+
if (line.trim()) {
39+
// Preserve original indentation and add comment
40+
return line.replace(/^(\s*)/, '$1// ');
41+
}
42+
return line;
43+
})
44+
.join('\n');
45+
const commentedClose = closeBrace.replace(/^(\s*)/, '$1// ');
46+
47+
return commentedDecl + commentedBody + commentedClose;
48+
});
49+
});
50+
51+
// Write the modified content
52+
fs.writeFileSync(filePath, content);
53+
54+
console.log('Successfully patched RNMBXStyleFactory.kt');
55+
console.log('Original backed up to', filePath + '.original');

scripts/patch-rnmapbox-complete.pl

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/usr/bin/env perl
2+
use strict;
3+
use warnings;
4+
5+
my $file = 'node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/styles/RNMBXStyleFactory.kt';
6+
7+
# Read file
8+
open(my $fh, '<', $file) or die "Cannot open $file: $!";
9+
my @lines = <$fh>;
10+
close($fh);
11+
12+
# Backup (restore from original if exists)
13+
if (-f "$file.original") {
14+
open(my $orig, '<', "$file.original") or die "Cannot open original: $!";
15+
@lines = <$orig>;
16+
close($orig);
17+
}
18+
19+
my @functions = qw(
20+
setFillPatternCrossFade
21+
setLineElevationReference
22+
setLineCrossSlope
23+
setLinePatternCrossFade
24+
setCircleElevationReference
25+
setFillExtrusionPatternCrossFade
26+
setFillExtrusionHeightAlignment
27+
setFillExtrusionBaseAlignment
28+
setBackgroundPitchAlignment
29+
);
30+
31+
my $in_function = 0;
32+
my $in_case = 0;
33+
my $brace_count = 0;
34+
my @output;
35+
36+
for (my $i = 0; $i < @lines; $i++) {
37+
my $line = $lines[$i];
38+
39+
# Check if we're in a case statement for one of the deprecated functions
40+
foreach my $func (@functions) {
41+
# Convert function names to property names (e.g., setFillPatternCrossFade -> fillPatternCrossFade)
42+
my $propName = $func;
43+
$propName =~ s/^set(.)/lc($1)/e; # Remove 'set' and lowercase first letter
44+
45+
if ($line =~ /"$propName"\s*->/ && !$in_case) {
46+
$in_case = 1;
47+
# Comment this line and peek ahead to find where the case ends
48+
push @output, $line;
49+
$output[-1] =~ s/^(\s*)(.+)$/$1\/\/ $2/;
50+
51+
# Look ahead to find what comes next and comment it too
52+
my $j = $i + 1;
53+
while ($j < @lines && $lines[$j] !~ /^\s*"/ && $lines[$j] !~ /^\s*else\s*->/ && $lines[$j] !~ /^\s*\}/) {
54+
push @output, $lines[$j];
55+
$output[-1] =~ s/^(\s*)(.+)$/$1\/\/ $2/ if $lines[$j] =~ /\S/;
56+
$i = $j;
57+
$j++;
58+
# If we hit a closing brace that's part of the case, stop
59+
if ($lines[$j] =~ /^\s*}\s*$/) {
60+
last;
61+
}
62+
}
63+
$in_case = 0;
64+
next;
65+
}
66+
}
67+
68+
# Check if we're starting a function we want to comment
69+
if (!$in_function) {
70+
foreach my $func (@functions) {
71+
if ($line =~ /fun\s+$func\s*\(/) {
72+
$in_function = 1;
73+
$brace_count = 0;
74+
last;
75+
}
76+
}
77+
}
78+
79+
if ($in_function) {
80+
# Count braces
81+
my $open = () = $line =~ /{/g;
82+
my $close = () = $line =~ /}/g;
83+
$brace_count += $open - $close;
84+
85+
# Comment the line
86+
if ($line =~ /^(\s*)(.+)$/) {
87+
push @output, "$1// $2\n";
88+
} else {
89+
push @output, $line;
90+
}
91+
92+
# Check if function is complete
93+
if ($brace_count == 0 && $close > 0) {
94+
$in_function = 0;
95+
}
96+
} else {
97+
push @output, $line unless $in_case;
98+
}
99+
}
100+
101+
# Write output
102+
open(my $out, '>', $file) or die "Cannot write to $file: $!";
103+
print $out @output;
104+
close($out);
105+
106+
print "Successfully patched $file\n";

0 commit comments

Comments
 (0)