antigravity-rtl-patcher 2.3.3 → 3.0.0

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/CHANGELOG.md ADDED
@@ -0,0 +1,121 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## [3.0.0] - 2024-09-06
6
+
7
+ ### šŸŽ‰ Major Rewrite - Utils.js Injection Approach
8
+
9
+ This is a **breaking change** that completely rewrites the injection strategy for better control and features.
10
+
11
+ ### ✨ Added
12
+
13
+ - **Advanced UI Panel** - Rich hover-activated widget with comprehensive customization
14
+ - **Custom Font Support** - Set separate fonts for Persian/Arabic, English, and code
15
+ - **Typography Controls** - Real-time line height (1.2-2.5) and font size (11-22px) adjustment
16
+ - **Persistent Configuration** - Settings saved to `~/.antigravity-rtl-v3.json`
17
+ - **Force RTL Mode** - Override auto-detection for consistent RTL layout
18
+ - **Enhanced Keyboard Shortcuts** - `Alt + R` to toggle RTL
19
+ - **@ Sign Fix** - Type `@` with `Shift+2` on Persian keyboard
20
+ - **DevTools Enabled** - Automatically enable DevTools for debugging
21
+ - **Colorful CLI Banner** - Beautiful gradient ASCII art banner
22
+ - **Update Command** - `agy-rtl update` to check for new versions
23
+
24
+ ### šŸ”§ Changed
25
+
26
+ - **Injection Point**: Changed from `preload.js` to `dist/utils.js` for better lifecycle control
27
+ - **Config Storage**: Moved from localStorage to filesystem (`~/.antigravity-rtl-v3.json`)
28
+ - **Detection Algorithm**: Improved RTL text detection with smarter first-character analysis
29
+ - **UI Architecture**: Complete redesign with Tailwind-inspired styling
30
+ - **Dependencies**: Added `figlet`, `picocolors`, and `prompts` for better CLI experience
31
+
32
+ ### šŸ—‘ļø Removed
33
+
34
+ - Old `preload-inject.js` payload (replaced with `utils-inject.js`)
35
+ - localStorage-based configuration (replaced with file-based config)
36
+
37
+ ### šŸ› Fixed
38
+
39
+ - Better handling of mixed RTL/LTR content
40
+ - Improved code block preservation in RTL contexts
41
+ - More reliable font loading mechanism
42
+ - Enhanced list padding in RTL mode
43
+
44
+ ### šŸ“š Documentation
45
+
46
+ - Completely rewritten README with v3.0 features
47
+ - Added troubleshooting section
48
+ - Added keyboard shortcuts reference
49
+ - Added configuration file documentation
50
+
51
+ ---
52
+
53
+ ## [2.3.4] - 2024-09-06
54
+
55
+ ### ✨ Added
56
+
57
+ - Auto-update checker before patching
58
+ - `update` command to manually check for updates
59
+ - Update notification system
60
+
61
+ ### šŸ“š Documentation
62
+
63
+ - Added update instructions to README
64
+ - Emphasized `@latest` usage in documentation
65
+
66
+ ---
67
+
68
+ ## [2.3.3] - 2024-09-06
69
+
70
+ ### šŸ› Fixed
71
+
72
+ - Improved RTL text detection logic
73
+ - Better layout rendering for mixed content
74
+
75
+ ---
76
+
77
+ ## [2.3.1] - 2024-09-06
78
+
79
+ ### šŸ› Fixed
80
+
81
+ - Bug fixes for layout issues
82
+ - Added IDE detection to skip patching IDE versions
83
+
84
+ ---
85
+
86
+ ## Earlier Versions
87
+
88
+ See [GitHub Releases](https://github.com/VaFa1726/antigravity-rtl-patcher/releases) for details on versions before 2.3.1.
89
+
90
+ ---
91
+
92
+ ## Migration Guide: v2.x → v3.0
93
+
94
+ ### What Changed
95
+
96
+ 1. **Configuration Location**: Your old settings in localStorage will not carry over. You'll need to reconfigure the RTL settings using the new UI panel.
97
+
98
+ 2. **UI Location**: The old status icon is replaced with a hover-activated globe icon in the bottom-right corner.
99
+
100
+ 3. **New Features**: Take advantage of custom fonts, typography controls, and Force RTL mode.
101
+
102
+ ### How to Upgrade
103
+
104
+ ```bash
105
+ # Restore old version
106
+ npx antigravity-rtl-patcher restore
107
+
108
+ # Install new version
109
+ npx antigravity-rtl-patcher@latest patch
110
+
111
+ # Restart Antigravity
112
+ ```
113
+
114
+ Your old backup will work fine. The new patch is completely independent.
115
+
116
+ ---
117
+
118
+ [3.0.0]: https://github.com/VaFa1726/antigravity-rtl-patcher/releases/tag/v3.0.0
119
+ [2.3.4]: https://github.com/VaFa1726/antigravity-rtl-patcher/releases/tag/v2.3.4
120
+ [2.3.3]: https://github.com/VaFa1726/antigravity-rtl-patcher/releases/tag/v2.3.3
121
+ [2.3.1]: https://github.com/VaFa1726/antigravity-rtl-patcher/releases/tag/v2.3.1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Antigravity RTL Patcher
2
2
 
3
- Smart RTL and Persian/Arabic typography support for the [Antigravity](https://antigravity.dev) desktop app. Patches the Electron runtime to detect right-to-left text and apply proper styling automatically.
3
+ Advanced RTL and Persian/Arabic typography support for the [Antigravity](https://antigravity.dev) desktop app. Patches the Electron runtime to detect right-to-left text and apply proper styling with a rich, customizable UI.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/antigravity-rtl-patcher)](https://www.npmjs.com/package/antigravity-rtl-patcher)
6
6
  [![npm downloads](https://img.shields.io/npm/dt/antigravity-rtl-patcher)](https://www.npmjs.com/package/antigravity-rtl-patcher)
@@ -8,73 +8,226 @@ Smart RTL and Persian/Arabic typography support for the [Antigravity](https://an
8
8
 
9
9
  ---
10
10
 
11
- ## Install
11
+ ## ✨ What's New in v3.0
12
+
13
+ - šŸŽØ **Advanced UI Panel** - Hover widget with comprehensive customization options
14
+ - šŸ”¤ **Custom Font Support** - Set separate fonts for Persian, English, and code
15
+ - šŸ“ **Typography Controls** - Adjust line height and font size in real-time
16
+ - šŸ’¾ **Persistent Config** - Settings saved to `~/.antigravity-rtl-v3.json`
17
+ - ⚔ **Keyboard Shortcuts** - `Alt + R` to toggle RTL, `Shift + 2` for @ symbol
18
+ - šŸ”§ **Force RTL Mode** - Override auto-detection for consistent RTL layout
19
+ - šŸŽÆ **Enhanced Detection** - Smarter RTL text recognition algorithm
20
+ - šŸš€ **DevTools Enabled** - Built-in developer tools for debugging
21
+
22
+ ---
23
+
24
+ ## ⚔ Quick Install
25
+
26
+ Always use `@latest` to ensure you get the newest version:
12
27
 
13
28
  ```bash
14
- npx antigravity-rtl-patcher patch
29
+ npx antigravity-rtl-patcher@latest patch
15
30
  ```
16
31
 
17
32
  If Antigravity is installed in a system directory, use `sudo`:
18
33
 
19
34
  ```bash
20
- sudo npx antigravity-rtl-patcher patch
35
+ sudo npx antigravity-rtl-patcher@latest patch
21
36
  ```
22
37
 
23
- Restart Antigravity after patching.
38
+ Restart Antigravity after patching to see the RTL widget appear in the bottom-right corner!
24
39
 
25
- ## Uninstall
40
+ ---
41
+
42
+ ## šŸ”„ Update to Latest Version
43
+
44
+ To ensure you're always using the latest version:
45
+
46
+ ```bash
47
+ npx antigravity-rtl-patcher@latest patch
48
+ ```
49
+
50
+ Or check for updates manually:
51
+
52
+ ```bash
53
+ npx antigravity-rtl-patcher@latest update
54
+ ```
55
+
56
+ The patcher will automatically notify you when a new version is available.
57
+
58
+ ---
59
+
60
+ ## šŸŽØ Features
61
+
62
+ ### Smart RTL Detection
63
+ - Automatically detects Persian, Arabic, and Hebrew text
64
+ - Applies proper text direction without breaking layout
65
+ - Preserves LTR for code blocks and English text
66
+
67
+ ### Rich UI Panel
68
+ Hover over the globe icon in the bottom-right corner to access:
69
+
70
+ - **RTL Toggle** - Enable/disable RTL support on the fly
71
+ - **Force RTL Mode** - Force RTL layout even when text starts with English
72
+ - **Custom Fonts**:
73
+ - Persian/Arabic font (fallback: Vazirmatn)
74
+ - English font (fallback: system font)
75
+ - Code font (fallback: monospace)
76
+ - **Typography Controls**:
77
+ - Line height slider (1.2 - 2.5)
78
+ - Font size slider (11px - 22px)
79
+ - **@ Sign Fix** - Type `@` with `Shift+2` on Persian keyboard
80
+ - **Keyboard Shortcut** - `Alt + R` to toggle RTL
81
+
82
+ ### Persistent Configuration
83
+ All your settings are automatically saved to `~/.antigravity-rtl-v3.json` and restored on restart.
84
+
85
+ ---
86
+
87
+ ## šŸ—‘ļø Uninstall
88
+
89
+ Remove the RTL patch and restore original Antigravity:
26
90
 
27
91
  ```bash
28
92
  npx antigravity-rtl-patcher restore
29
93
  ```
30
94
 
31
- This restores the original `app.asar` from the backup created during patching.
95
+ Or with sudo if needed:
96
+
97
+ ```bash
98
+ sudo npx antigravity-rtl-patcher restore
99
+ ```
100
+
101
+ ---
32
102
 
33
- ## Commands
103
+ ## šŸ“‹ Commands
34
104
 
35
105
  | Command | Description |
36
- |---|---|
37
- | `agy-rtl patch` | Apply RTL patch |
38
- | `agy-rtl restore` | Remove patch, restore original |
106
+ |---------|-------------|
107
+ | `agy-rtl patch` | Apply RTL patch with advanced UI |
108
+ | `agy-rtl restore` | Remove patch and restore original |
39
109
  | `agy-rtl status` | Show current patch status |
40
- | `agy-rtl patch --path /custom/path` | Patch a custom installation |
110
+ | `agy-rtl update` | Check for patcher updates |
111
+ | `agy-rtl patch --path /custom/path` | Patch custom installation |
112
+ | `agy-rtl patch --skip-update-check` | Skip update check during patching |
113
+
114
+ ---
115
+
116
+ ## šŸ”§ How It Works
41
117
 
42
- ## How it works
118
+ Antigravity is built on Electron. The patcher:
43
119
 
44
- 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.
120
+ 1. **Extracts** `app.asar` (the packaged application)
121
+ 2. **Locates** `dist/utils.js` (window creation module)
122
+ 3. **Injects** RTL engine at the window lifecycle hook
123
+ 4. **Repacks** the modified application
45
124
 
46
- After patching, an RTL icon appears at the bottom of the Antigravity window. Click it to open a settings panel where you can enable or disable RTL support. The setting persists across restarts via `localStorage`.
125
+ The RTL engine uses:
126
+ - `MutationObserver` for real-time DOM monitoring
127
+ - Unicode range analysis for RTL detection
128
+ - Dynamic CSS generation for typography control
129
+ - Electron IPC for config persistence
47
130
 
48
- ### What the engine does
131
+ After patching, a hover-activated widget appears in the bottom-right corner with all customization options.
49
132
 
50
- - Detects RTL text using Unicode range analysis with ratio-based scoring
51
- - Applies directional styling only to elements that contain RTL text
52
- - Injects the Vazirmatn font for improved Persian/Arabic readability
53
- - Preserves LTR direction for code blocks inside RTL text
54
- - Provides a toggle UI to enable/disable at any time
133
+ ---
55
134
 
56
- ## After Antigravity updates
135
+ ## šŸ”„ After Antigravity Updates
57
136
 
58
- Updates may overwrite the patch. Run the patch command again:
137
+ Antigravity updates may overwrite the patch. Simply run:
59
138
 
60
139
  ```bash
61
- npx antigravity-rtl-patcher patch
140
+ npx antigravity-rtl-patcher@latest patch
62
141
  ```
63
142
 
64
- ## Supported platforms
143
+ **Pro tip:** Always use `@latest` to ensure you're using the newest patcher version.
144
+
145
+ ---
65
146
 
66
- | Platform | Typical install locations |
67
- |---|---|
68
- | Linux | `/opt/antigravity`, `~/Downloads/Antigravity-x64` |
69
- | macOS | `/Applications/Antigravity.app` |
70
- | Windows | `%LOCALAPPDATA%\Programs\Antigravity` |
147
+ ## šŸ’» Supported Platforms
148
+
149
+ | Platform | Typical Install Locations |
150
+ |----------|---------------------------|
151
+ | **Linux** | `/opt/Antigravity`<br>`~/Downloads/Antigravity-x64`<br>`~/.local/share/antigravity` |
152
+ | **macOS** | `/Applications/Antigravity.app`<br>`~/Applications/Antigravity.app` |
153
+ | **Windows** | `%LOCALAPPDATA%\Programs\Antigravity`<br>`%PROGRAMFILES%\Antigravity` |
154
+
155
+ Custom paths are supported via `--path` option.
156
+
157
+ ---
71
158
 
72
- Custom paths are supported via `--path`.
159
+ ## āŒØļø Keyboard Shortcuts
160
+
161
+ - **Alt + R** - Toggle RTL support on/off
162
+ - **Shift + 2** - Type `@` symbol (when @ fix is enabled)
163
+
164
+ ---
165
+
166
+ ## šŸŽÆ Configuration File
167
+
168
+ Settings are stored in `~/.antigravity-rtl-v3.json`:
169
+
170
+ ```json
171
+ {
172
+ "faFont": "",
173
+ "enFont": "",
174
+ "codeFont": "",
175
+ "lineHeight": "1.6",
176
+ "fontSize": "16",
177
+ "rtlEnabled": true,
178
+ "forceRTL": false,
179
+ "fixAtSign": true
180
+ }
181
+ ```
182
+
183
+ You can manually edit this file or use the UI panel.
184
+
185
+ ---
73
186
 
74
- ## Contributing
187
+ ## šŸ› Troubleshooting
188
+
189
+ ### Patch not working?
190
+ 1. Make sure you restarted Antigravity after patching
191
+ 2. Check patch status: `agy-rtl status`
192
+ 3. Try restoring and re-patching:
193
+ ```bash
194
+ npx antigravity-rtl-patcher restore
195
+ npx antigravity-rtl-patcher@latest patch
196
+ ```
197
+
198
+ ### Widget not appearing?
199
+ 1. Open DevTools (now enabled by default)
200
+ 2. Check console for any RTL engine errors
201
+ 3. Make sure RTL is enabled in the widget
202
+
203
+ ### Permission denied?
204
+ - **Linux/macOS**: Use `sudo` for system-wide installations
205
+ - **Windows**: Run terminal as Administrator
206
+
207
+ ---
208
+
209
+ ## šŸ¤ Contributing
75
210
 
76
211
  Issues and pull requests are welcome at [github.com/VaFa1726/antigravity-rtl-patcher](https://github.com/VaFa1726/antigravity-rtl-patcher).
77
212
 
78
- ## License
213
+ ---
214
+
215
+ ## šŸ“„ License
216
+
217
+ MIT Ā© VaFa1726
218
+
219
+ ---
220
+
221
+ ## šŸ™ Credits
222
+
223
+ - Built with ā¤ļø for the Persian/Arabic developer community
224
+ - Vazirmatn font by [Saber Rastikerdar](https://github.com/rastikerdar/vazirmatn)
225
+ - Powered by Electron ASAR tools
226
+
227
+ ---
228
+
229
+ ## šŸ”— Links
79
230
 
80
- MIT
231
+ - [GitHub Repository](https://github.com/VaFa1726/antigravity-rtl-patcher)
232
+ - [NPM Package](https://www.npmjs.com/package/antigravity-rtl-patcher)
233
+ - [Report Issues](https://github.com/VaFa1726/antigravity-rtl-patcher/issues)
package/bin/cli.js CHANGED
@@ -2,41 +2,105 @@
2
2
 
3
3
  const { program } = require('commander');
4
4
  const chalk = require('chalk');
5
+ const figlet = require('figlet');
5
6
  const { patch, restore, status } = require('../src/patcher');
7
+ const { checkForUpdates, showUpdateInstructions, currentVersion } = require('../src/version-checker');
6
8
 
7
- const BANNER = `
8
- ${chalk.cyan('Antigravity Smart RTL Patcher')} ${chalk.gray('v2.3.3')}
9
- `;
9
+ /**
10
+ * Display colorful banner with gradient effect
11
+ */
12
+ function showBanner() {
13
+ try {
14
+ const bannerText = figlet.textSync('Antigravity RTL', {
15
+ font: 'Standard',
16
+ horizontalLayout: 'default',
17
+ verticalLayout: 'default'
18
+ });
10
19
 
20
+ // Gradient colors
21
+ const colors = [
22
+ { r: 51, g: 135, b: 255 }, // Blue
23
+ { r: 242, g: 80, b: 65 }, // Red
24
+ { r: 223, g: 172, b: 42 }, // Yellow
25
+ { r: 145, g: 196, b: 91 } // Green
26
+ ];
27
+
28
+ const lines = bannerText.split('\n');
29
+ console.log('');
30
+
31
+ lines.forEach((line, lineIndex) => {
32
+ if (!line.trim()) return;
33
+
34
+ let coloredLine = '';
35
+ const chars = line.split('');
36
+ const totalChars = chars.filter(c => c !== ' ').length;
37
+ let charIndex = 0;
38
+
39
+ chars.forEach(char => {
40
+ if (char === ' ') {
41
+ coloredLine += ' ';
42
+ } else {
43
+ const progress = totalChars > 1 ? charIndex / (totalChars - 1) : 0;
44
+ const segmentCount = colors.length - 1;
45
+ const segmentFloat = progress * segmentCount;
46
+ const segmentIndex = Math.min(Math.floor(segmentFloat), segmentCount - 1);
47
+ const segmentProgress = segmentFloat - segmentIndex;
48
+
49
+ const c1 = colors[segmentIndex];
50
+ const c2 = colors[segmentIndex + 1];
51
+
52
+ const r = Math.round(c1.r + segmentProgress * (c2.r - c1.r));
53
+ const g = Math.round(c1.g + segmentProgress * (c2.g - c1.g));
54
+ const b = Math.round(c1.b + segmentProgress * (c2.b - c1.b));
55
+
56
+ coloredLine += `\x1b[38;2;${r};${g};${b}m${char}\x1b[0m`;
57
+ charIndex++;
58
+ }
59
+ });
60
+
61
+ console.log(coloredLine);
62
+ });
63
+
64
+ console.log('');
65
+ console.log(chalk.gray(` Advanced RTL & Typography Control | v${currentVersion}\n`));
66
+ } catch (err) {
67
+ // Fallback banner
68
+ console.log(chalk.cyan.bold(`\n✨ Antigravity Smart RTL Patcher v${currentVersion}\n`));
69
+ }
70
+ }
71
+
72
+ // Show banner
73
+ showBanner();
74
+
75
+ // CLI setup
11
76
  program
12
77
  .name('agy-rtl')
13
- .description('RTL patcher for Antigravity')
14
- .version('2.3.3');
78
+ .description('Advanced RTL patcher for Antigravity')
79
+ .version(currentVersion);
15
80
 
16
81
  program
17
82
  .command('patch')
18
- .description('Inject RTL support into Antigravity')
83
+ .description('Inject advanced RTL support into Antigravity')
19
84
  .option('-p, --path <path>', 'Custom path to Antigravity installation')
85
+ .option('--skip-update-check', 'Skip checking for updates')
20
86
  .action(async (options) => {
21
- console.log(BANNER);
22
87
  try {
23
- await patch(options.path);
88
+ await patch(options.path, options.skipUpdateCheck);
24
89
  } catch (err) {
25
- console.error(chalk.red('\nPatch failed:'), err.message);
90
+ console.error(chalk.red('\nāœ– Patch failed:'), err.message);
26
91
  process.exit(1);
27
92
  }
28
93
  });
29
94
 
30
95
  program
31
96
  .command('restore')
32
- .description('Remove RTL patch and restore Antigravity')
97
+ .description('Remove RTL patch and restore original Antigravity')
33
98
  .option('-p, --path <path>', 'Custom path to Antigravity installation')
34
99
  .action(async (options) => {
35
- console.log(BANNER);
36
100
  try {
37
101
  await restore(options.path);
38
102
  } catch (err) {
39
- console.error(chalk.red('\nRestore failed:'), err.message);
103
+ console.error(chalk.red('\nāœ– Restore failed:'), err.message);
40
104
  process.exit(1);
41
105
  }
42
106
  });
@@ -46,13 +110,23 @@ program
46
110
  .description('Check current patch status')
47
111
  .option('-p, --path <path>', 'Custom path to Antigravity installation')
48
112
  .action(async (options) => {
49
- console.log(BANNER);
50
113
  try {
51
114
  await status(options.path);
52
115
  } catch (err) {
53
- console.error(chalk.red('\nStatus check failed:'), err.message);
116
+ console.error(chalk.red('\nāœ– Status check failed:'), err.message);
54
117
  process.exit(1);
55
118
  }
56
119
  });
57
120
 
121
+ program
122
+ .command('update')
123
+ .description('Check for updates and show installation instructions')
124
+ .action(async () => {
125
+ console.log(chalk.cyan('Checking for updates...\n'));
126
+ const hasUpdate = await checkForUpdates(false);
127
+ if (!hasUpdate) {
128
+ showUpdateInstructions();
129
+ }
130
+ });
131
+
58
132
  program.parse(process.argv);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "antigravity-rtl-patcher",
3
- "version": "2.3.3",
4
- "description": "Smart RTL and Persian/Arabic typography patcher for Antigravity",
3
+ "version": "3.0.0",
4
+ "description": "Advanced RTL and Persian/Arabic typography patcher for Antigravity with customizable UI",
5
5
  "main": "src/patcher.js",
6
6
  "bin": {
7
7
  "antigravity-rtl-patcher": "./bin/cli.js",
@@ -23,7 +23,9 @@
23
23
  "electron",
24
24
  "asar",
25
25
  "right-to-left",
26
- "bidirectional"
26
+ "bidirectional",
27
+ "ui-customization",
28
+ "font-control"
27
29
  ],
28
30
  "author": "VaFa1726",
29
31
  "license": "MIT",
@@ -42,7 +44,10 @@
42
44
  "@electron/asar": "^3.2.14",
43
45
  "chalk": "^4.1.2",
44
46
  "commander": "^11.1.0",
47
+ "figlet": "^1.7.0",
45
48
  "fs-extra": "^11.2.0",
46
- "ora": "^5.4.1"
49
+ "ora": "^5.4.1",
50
+ "picocolors": "^1.0.0",
51
+ "prompts": "^2.4.2"
47
52
  }
48
53
  }