mattermost-mobile/scripts/android-16kb-pagesize/apply-patch.js
Rajat Dabade e39b27be7e
New keyboard library Setup (#9278)
* Initial setup for new keyboard

* fix the offset calculation onMove by adding isKeyboardFullyOpened

* Done with the keyboard handling implementation

* Handled keyboard focus and blured state using context

* Added default height for input container

* Android support

* Tablet state handling

* Fix for refreshing offset in list

* Created a default context for mention post list

* Fix linter errors

* Fix tests

* Minor

* Fix the height issue for tablet view

* Review comments

* Dependency fix

* Reveiw comment

* keyboard animation only enabled with screen on top navigation

* added tests

* Added extra keyboard component for emoji picker (#9328)

* Added extra keyboard component

* handled swipe geature for extra keyboard

* scroll to bottom visible on emoji picker

* Check for stale event for keyboard geature area

* fix keyboard stale event for mid-gesture change swipe direction

* Closing emoji picker when message priority is opened

* changing to thread view closes emoji picker

* Close emoij picker and keyboard when attachment icons are clicked

* handle android emoji picker behaviour

* Remove emoji picker code

* fix tests

* Address reviev comments

* Test fixes

* usePreventDoubleTab for race condition and corrected comment on isInputAccessoryViewMode flag

* File attachments option in bottom sheet quick action (#9331)

* Added extra keyboard component

* handled swipe geature for extra keyboard

* File attachments option in bottom sheet quick action

* Updated tests

* i18n

* fix test

* Added tests

* Review comment

* fix tests

* Integrated Emoji picker to Extra keyboard component.  (#9339)

* Added extra keyboard component

* handled swipe geature for extra keyboard

* scroll to bottom visible on emoji picker

* Fix the post input container height change issue

* Added emoji picker with search functionality

* keyboard height not recorded fallback to default height, set search to false closing emoji picker

* fix search funcitonality in android

* scroll to end bottom dismissed with pressed

* Fixed the scroll issue for android

* fix the flickering post input issue

* Wired up the emoji picker

* Added keyboard and spaceback in emoji picker

* intl extract

* initial cursor position and simple calculation review comment

* separated grapheme to utils file

* Review comments

* nitpick

* Fix the bottom safe area and navigation stack restore fix

* Fix test

* disabled emoji picker in edit post screen

* change the name of the variable to name it clarier

* fix the tab gap issue in andriod

* disabled the emoji skin tone change on andriod

* fix the input container jump issue

* fix the failing test

* UX review

* added white space after the attachment icon

* When @ or / is press open keyboard on andriod also fix the scroll issue when keyboard is open

* back bottom closes emoji picker and opening keyboard jump fix

* reverted code

* fixed the flickering issue of input and scroll position fix

* Fix the gap issue in thread

* fix the warning reaminated issue when opening a channel

* Fix the extra space issue between input and emoij picker

* Minor fix for extra space between input and emoji picker

* Fix thread view bottom safe area and gap between keyboard and searched emojis

* Fix the keyboard issue in tablet

* Fix the warning issue react-native-keyboard-controller

* Fix tests

* Fix the tablet search hight issue

* Replaced the ExtraKeyboardProvider with KeyboardProvider from rnkc for permalink

* Bottom sheet jump issue resolved

* Search do not close after selecting emoji in search list

* Added the bottom inset height in search emoji for android

* fix buid issue

* Fix the cancel state to emoji picker

* use portals for autocomplete

* fix permalink extra space in post list

* Portal only for android

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: Rahim Rahman <rahim.rahman@mattermost.com>
Co-authored-by: Harshil Sharma <harshilsharma63@gmail.com>
Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
2026-01-13 22:38:35 +05:30

222 lines
7.2 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env node
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
/**
* Script to apply 16KB page size compatibility patches from a diff file.
* This automates the process of updating dependencies and applying code changes
* for Android 16KB page size support.
*
* Usage:
* node scripts/apply-16kb-pagesize-patch.js <diff-file> [--dry-run|--apply]
*
* Example:
* node scripts/apply-16kb-pagesize-patch.js 9325-full.diff --apply
*/
const {execSync} = require('child_process');
const fs = require('fs');
// ============================================================================
// CONSTANTS
// ============================================================================
const COLORS = {
reset: '\x1b[0m',
bright: '\x1b[1m',
green: '\x1b[32m',
yellow: '\x1b[33m',
blue: '\x1b[34m',
red: '\x1b[31m',
cyan: '\x1b[36m',
};
// ============================================================================
// UTILITIES
// ============================================================================
function log(message, color = 'reset') {
// eslint-disable-next-line no-console
console.log(`${COLORS[color]}${message}${COLORS.reset}`);
}
function exec(command, options = {}) {
try {
return execSync(command, {
encoding: 'utf8',
stdio: options.silent ? 'pipe' : 'inherit',
...options,
});
} catch (error) {
if (!options.ignoreError) {
throw error;
}
return null;
}
}
// ============================================================================
// MAIN FUNCTIONS
// ============================================================================
function applyDiffChanges(diffPath, dryRun) {
log('\n📝 Applying changes from diff file', 'bright');
if (!fs.existsSync(diffPath)) {
log(`✗ Diff file not found: ${diffPath}`, 'red');
process.exit(1);
}
if (dryRun) {
log(' [DRY RUN] Would apply all changes using patch', 'yellow');
return;
}
try {
log(' Applying all changes (including file renames)...', 'cyan');
// Use patch command instead of git apply for better compatibility
// patch is more forgiving with context matching
exec(`patch -p1 < ${diffPath}`, {silent: true});
log(' ✓ All changes applied successfully', 'green');
log(' ✓ Patch files renamed automatically', 'green');
} catch (error) {
log(` ✗ Failed to apply diff: ${error.message}`, 'red');
throw error;
}
}
function installUpdatedPackages(diffPath, dryRun) {
log('\n📦 Installing updated packages', 'bright');
if (dryRun) {
log(' [DRY RUN] Would run: npm install --ignore-scripts', 'yellow');
return;
}
try {
// Read package.json to get the list of changed packages
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
const dependencies = {...packageJson.dependencies, ...packageJson.devDependencies};
// Extract package names from diff
const diffContent = fs.readFileSync(diffPath, 'utf8');
const packageChanges = [];
const lines = diffContent.split('\n');
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
// Look for package.json dependency changes
if (line.startsWith('+ "expo') || line.startsWith('- "expo')) {
const match = line.match(/"([^"]+)":\s*"([^"]+)"/);
if (match && line.startsWith('+')) {
const [, pkgName] = match;
if (dependencies[pkgName] && !packageChanges.includes(pkgName)) {
packageChanges.push(pkgName);
}
}
}
}
if (packageChanges.length > 0) {
log(` Installing ${packageChanges.length} updated packages...`, 'cyan');
log(` Packages: ${packageChanges.join(', ')}`, 'cyan');
// Install only the changed packages to update package-lock.json
exec(`npm install ${packageChanges.join(' ')} --ignore-scripts`);
log(' ✓ Packages installed successfully', 'green');
} else {
log(' No package changes detected', 'yellow');
}
} catch (error) {
log(` ✗ Failed to install packages: ${error.message}`, 'red');
throw error;
}
}
function applyPatchFiles(dryRun) {
log('\n🔧 Applying patch files', 'bright');
if (dryRun) {
log(' [DRY RUN] Would run: npx patch-package', 'yellow');
return;
}
try {
exec('npx patch-package');
log(' ✓ Patch files applied successfully', 'green');
} catch (error) {
log(` ✗ Failed to apply patch files: ${error.message}`, 'red');
throw error;
}
}
function showSummary(dryRun) {
log('\n' + '='.repeat(70), 'cyan');
if (dryRun) {
log('DRY RUN COMPLETE', 'bright');
log('Run with --apply to actually apply the changes', 'yellow');
} else {
log('✓ ALL CHANGES APPLIED SUCCESSFULLY', 'green');
log('\n⚠ IMPORTANT:', 'yellow');
log('These changes are for Android builds ONLY', 'yellow');
log('DO NOT commit these changes to the repository', 'yellow');
log('\nNext steps:', 'bright');
log('1. Build your Android app', 'cyan');
log('2. After building, revert these changes with: git checkout .', 'cyan');
}
log('='.repeat(70), 'cyan');
}
// ============================================================================
// MAIN
// ============================================================================
function main() {
const args = process.argv.slice(2);
if (args.length === 0 || args.includes('--help') || args.includes('-h')) {
log('Usage: node scripts/apply-16kb-pagesize-patch.js <diff-file> [--dry-run|--apply]', 'bright');
log('\nOptions:', 'bright');
log(' --dry-run Preview changes without applying them (default)', 'cyan');
log(' --apply Actually apply the changes', 'cyan');
log(' --help, -h Show this help message', 'cyan');
log('\nExample:', 'bright');
log(' node scripts/apply-16kb-pagesize-patch.js 9325-full.diff --apply', 'cyan');
process.exit(0);
}
const diffPath = args[0];
const dryRun = !args.includes('--apply');
log('\n' + '='.repeat(70), 'cyan');
log('16KB PAGE SIZE PATCH APPLICATION', 'bright');
log('='.repeat(70), 'cyan');
log(`Diff file: ${diffPath}`, 'cyan');
log(`Mode: ${dryRun ? 'DRY RUN' : 'APPLY'}`, dryRun ? 'yellow' : 'green');
log('='.repeat(70), 'cyan');
try {
// Step 1: Apply diff changes using git apply (handles renames automatically)
applyDiffChanges(diffPath, dryRun);
// Step 2: Install updated packages
installUpdatedPackages(diffPath, dryRun);
// Step 3: Apply patch files
applyPatchFiles(dryRun);
// Show summary
showSummary(dryRun);
} catch (error) {
log('\n✗ Script failed with error:', 'red');
log(error.message, 'red');
process.exit(1);
}
}
main();