antigravity-rtl-patcher 2.3.3 → 2.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -11
- package/bin/cli.js +18 -3
- package/package.json +1 -1
- package/src/patcher.js +7 -1
- package/src/version-checker.js +103 -0
package/README.md
CHANGED
|
@@ -8,21 +8,39 @@ Smart RTL and Persian/Arabic typography support for the [Antigravity](https://an
|
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
## Install
|
|
11
|
+
## ⚡ Quick Install
|
|
12
|
+
|
|
13
|
+
Always use `@latest` to ensure you get the newest version:
|
|
12
14
|
|
|
13
15
|
```bash
|
|
14
|
-
npx antigravity-rtl-patcher patch
|
|
16
|
+
npx antigravity-rtl-patcher@latest patch
|
|
15
17
|
```
|
|
16
18
|
|
|
17
19
|
If Antigravity is installed in a system directory, use `sudo`:
|
|
18
20
|
|
|
19
21
|
```bash
|
|
20
|
-
sudo npx antigravity-rtl-patcher patch
|
|
22
|
+
sudo npx antigravity-rtl-patcher@latest patch
|
|
21
23
|
```
|
|
22
24
|
|
|
23
25
|
Restart Antigravity after patching.
|
|
24
26
|
|
|
25
|
-
##
|
|
27
|
+
## 🔄 Update to Latest Version
|
|
28
|
+
|
|
29
|
+
To ensure you're always using the latest version, run:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npx antigravity-rtl-patcher@latest patch
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Or check for updates manually:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npx antigravity-rtl-patcher@latest update
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The patcher will automatically notify you when a new version is available.
|
|
42
|
+
|
|
43
|
+
## 🗑️ Uninstall
|
|
26
44
|
|
|
27
45
|
```bash
|
|
28
46
|
npx antigravity-rtl-patcher restore
|
|
@@ -30,16 +48,18 @@ npx antigravity-rtl-patcher restore
|
|
|
30
48
|
|
|
31
49
|
This restores the original `app.asar` from the backup created during patching.
|
|
32
50
|
|
|
33
|
-
## Commands
|
|
51
|
+
## 📋 Commands
|
|
34
52
|
|
|
35
53
|
| Command | Description |
|
|
36
54
|
|---|---|
|
|
37
55
|
| `agy-rtl patch` | Apply RTL patch |
|
|
38
56
|
| `agy-rtl restore` | Remove patch, restore original |
|
|
39
57
|
| `agy-rtl status` | Show current patch status |
|
|
58
|
+
| `agy-rtl update` | Check for updates |
|
|
40
59
|
| `agy-rtl patch --path /custom/path` | Patch a custom installation |
|
|
60
|
+
| `agy-rtl patch --skip-update-check` | Skip update check during patching |
|
|
41
61
|
|
|
42
|
-
## How it works
|
|
62
|
+
## 🔧 How it works
|
|
43
63
|
|
|
44
64
|
Antigravity is an Electron app. The patcher extracts `app.asar`, appends an RTL engine to the preload script, and repacks the archive. The engine uses a `MutationObserver` to detect Persian, Arabic, and Hebrew text in real-time and applies `direction: rtl` where needed.
|
|
45
65
|
|
|
@@ -53,15 +73,17 @@ After patching, an RTL icon appears at the bottom of the Antigravity window. Cli
|
|
|
53
73
|
- Preserves LTR direction for code blocks inside RTL text
|
|
54
74
|
- Provides a toggle UI to enable/disable at any time
|
|
55
75
|
|
|
56
|
-
## After Antigravity updates
|
|
76
|
+
## 🔄 After Antigravity updates
|
|
57
77
|
|
|
58
78
|
Updates may overwrite the patch. Run the patch command again:
|
|
59
79
|
|
|
60
80
|
```bash
|
|
61
|
-
npx antigravity-rtl-patcher patch
|
|
81
|
+
npx antigravity-rtl-patcher@latest patch
|
|
62
82
|
```
|
|
63
83
|
|
|
64
|
-
|
|
84
|
+
**Pro tip:** Always use `@latest` flag to ensure you're patching with the newest version of the patcher.
|
|
85
|
+
|
|
86
|
+
## 💻 Supported platforms
|
|
65
87
|
|
|
66
88
|
| Platform | Typical install locations |
|
|
67
89
|
|---|---|
|
|
@@ -71,10 +93,10 @@ npx antigravity-rtl-patcher patch
|
|
|
71
93
|
|
|
72
94
|
Custom paths are supported via `--path`.
|
|
73
95
|
|
|
74
|
-
## Contributing
|
|
96
|
+
## 🤝 Contributing
|
|
75
97
|
|
|
76
98
|
Issues and pull requests are welcome at [github.com/VaFa1726/antigravity-rtl-patcher](https://github.com/VaFa1726/antigravity-rtl-patcher).
|
|
77
99
|
|
|
78
|
-
## License
|
|
100
|
+
## 📄 License
|
|
79
101
|
|
|
80
102
|
MIT
|
package/bin/cli.js
CHANGED
|
@@ -3,24 +3,26 @@
|
|
|
3
3
|
const { program } = require('commander');
|
|
4
4
|
const chalk = require('chalk');
|
|
5
5
|
const { patch, restore, status } = require('../src/patcher');
|
|
6
|
+
const { checkForUpdates, showUpdateInstructions, currentVersion } = require('../src/version-checker');
|
|
6
7
|
|
|
7
8
|
const BANNER = `
|
|
8
|
-
${chalk.cyan('Antigravity Smart RTL Patcher')} ${chalk.gray('
|
|
9
|
+
${chalk.cyan('Antigravity Smart RTL Patcher')} ${chalk.gray('v' + currentVersion)}
|
|
9
10
|
`;
|
|
10
11
|
|
|
11
12
|
program
|
|
12
13
|
.name('agy-rtl')
|
|
13
14
|
.description('RTL patcher for Antigravity')
|
|
14
|
-
.version(
|
|
15
|
+
.version(currentVersion);
|
|
15
16
|
|
|
16
17
|
program
|
|
17
18
|
.command('patch')
|
|
18
19
|
.description('Inject RTL support into Antigravity')
|
|
19
20
|
.option('-p, --path <path>', 'Custom path to Antigravity installation')
|
|
21
|
+
.option('--skip-update-check', 'Skip checking for updates')
|
|
20
22
|
.action(async (options) => {
|
|
21
23
|
console.log(BANNER);
|
|
22
24
|
try {
|
|
23
|
-
await patch(options.path);
|
|
25
|
+
await patch(options.path, options.skipUpdateCheck);
|
|
24
26
|
} catch (err) {
|
|
25
27
|
console.error(chalk.red('\nPatch failed:'), err.message);
|
|
26
28
|
process.exit(1);
|
|
@@ -55,4 +57,17 @@ program
|
|
|
55
57
|
}
|
|
56
58
|
});
|
|
57
59
|
|
|
60
|
+
program
|
|
61
|
+
.command('update')
|
|
62
|
+
.description('Check for updates and show installation instructions')
|
|
63
|
+
.action(async () => {
|
|
64
|
+
console.log(BANNER);
|
|
65
|
+
console.log(chalk.cyan('Checking for updates...\n'));
|
|
66
|
+
const hasUpdate = await checkForUpdates(false);
|
|
67
|
+
if (!hasUpdate) {
|
|
68
|
+
showUpdateInstructions();
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
58
72
|
program.parse(process.argv);
|
|
73
|
+
|
package/package.json
CHANGED
package/src/patcher.js
CHANGED
|
@@ -6,6 +6,7 @@ const ora = require('ora');
|
|
|
6
6
|
const chalk = require('chalk');
|
|
7
7
|
const { findInstallations } = require('./paths');
|
|
8
8
|
const { checkPermissions, delay } = require('./utils');
|
|
9
|
+
const { checkForUpdates } = require('./version-checker');
|
|
9
10
|
|
|
10
11
|
const PATCH_MARKER = '__AGY_RTL_INJECTED__';
|
|
11
12
|
const BACKUP_SUFFIX = '.agy-rtl-backup';
|
|
@@ -151,7 +152,12 @@ async function restoreAsar(installation, spinner) {
|
|
|
151
152
|
/**
|
|
152
153
|
* Main patch function.
|
|
153
154
|
*/
|
|
154
|
-
async function patch(customPath) {
|
|
155
|
+
async function patch(customPath, skipUpdateCheck = false) {
|
|
156
|
+
// Check for updates (non-blocking)
|
|
157
|
+
if (!skipUpdateCheck) {
|
|
158
|
+
await checkForUpdates(false);
|
|
159
|
+
}
|
|
160
|
+
|
|
155
161
|
const spinner = ora('Searching for Antigravity...').start();
|
|
156
162
|
const installations = findInstallations(customPath);
|
|
157
163
|
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
const https = require('https');
|
|
2
|
+
const chalk = require('chalk');
|
|
3
|
+
const { version: currentVersion } = require('../package.json');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Compare two semantic versions.
|
|
7
|
+
* Returns: 1 if v1 > v2, -1 if v1 < v2, 0 if equal
|
|
8
|
+
*/
|
|
9
|
+
function compareVersions(v1, v2) {
|
|
10
|
+
const parts1 = v1.split('.').map(Number);
|
|
11
|
+
const parts2 = v2.split('.').map(Number);
|
|
12
|
+
|
|
13
|
+
for (let i = 0; i < 3; i++) {
|
|
14
|
+
const p1 = parts1[i] || 0;
|
|
15
|
+
const p2 = parts2[i] || 0;
|
|
16
|
+
if (p1 > p2) return 1;
|
|
17
|
+
if (p1 < p2) return -1;
|
|
18
|
+
}
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Fetch the latest version from npm registry.
|
|
24
|
+
*/
|
|
25
|
+
function fetchLatestVersion() {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
const url = 'https://registry.npmjs.org/antigravity-rtl-patcher/latest';
|
|
28
|
+
|
|
29
|
+
https.get(url, { timeout: 3000 }, (res) => {
|
|
30
|
+
let data = '';
|
|
31
|
+
|
|
32
|
+
res.on('data', (chunk) => { data += chunk; });
|
|
33
|
+
res.on('end', () => {
|
|
34
|
+
try {
|
|
35
|
+
const pkg = JSON.parse(data);
|
|
36
|
+
resolve(pkg.version);
|
|
37
|
+
} catch (e) {
|
|
38
|
+
reject(new Error('Failed to parse npm response'));
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}).on('error', (err) => {
|
|
42
|
+
reject(err);
|
|
43
|
+
}).on('timeout', () => {
|
|
44
|
+
reject(new Error('Request timeout'));
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Check if a newer version is available and notify the user.
|
|
51
|
+
* Returns: true if update is available, false otherwise
|
|
52
|
+
*/
|
|
53
|
+
async function checkForUpdates(silent = false) {
|
|
54
|
+
try {
|
|
55
|
+
const latestVersion = await fetchLatestVersion();
|
|
56
|
+
|
|
57
|
+
if (compareVersions(latestVersion, currentVersion) > 0) {
|
|
58
|
+
if (!silent) {
|
|
59
|
+
console.log('');
|
|
60
|
+
console.log(chalk.yellow.bold('⚠️ Update Available!'));
|
|
61
|
+
console.log(chalk.white(` Current: ${chalk.red(currentVersion)} → Latest: ${chalk.green(latestVersion)}`));
|
|
62
|
+
console.log('');
|
|
63
|
+
console.log(chalk.cyan(' Run one of these commands to update:'));
|
|
64
|
+
console.log(chalk.gray(' • npx antigravity-rtl-patcher@latest patch'));
|
|
65
|
+
console.log(chalk.gray(' • npm install -g antigravity-rtl-patcher@latest'));
|
|
66
|
+
console.log('');
|
|
67
|
+
}
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (!silent) {
|
|
72
|
+
console.log(chalk.green('✓ You are using the latest version.\n'));
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
} catch (error) {
|
|
76
|
+
// Silently fail if network is unavailable
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Show update instructions.
|
|
83
|
+
*/
|
|
84
|
+
function showUpdateInstructions() {
|
|
85
|
+
console.log('');
|
|
86
|
+
console.log(chalk.cyan.bold('Update Instructions:'));
|
|
87
|
+
console.log('');
|
|
88
|
+
console.log(chalk.white('To update to the latest version, run:'));
|
|
89
|
+
console.log('');
|
|
90
|
+
console.log(chalk.green(' npx antigravity-rtl-patcher@latest patch'));
|
|
91
|
+
console.log(chalk.gray(' (This will automatically download and use the latest version)\n'));
|
|
92
|
+
console.log(chalk.white('Or install globally:'));
|
|
93
|
+
console.log('');
|
|
94
|
+
console.log(chalk.green(' npm install -g antigravity-rtl-patcher@latest'));
|
|
95
|
+
console.log(chalk.gray(' (Then you can use: agy-rtl patch)\n'));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
module.exports = {
|
|
99
|
+
checkForUpdates,
|
|
100
|
+
showUpdateInstructions,
|
|
101
|
+
compareVersions,
|
|
102
|
+
currentVersion,
|
|
103
|
+
};
|