Fix code quality violations and add VS Code extension features

Fix VS Code extension storage paths for new directory structure
Fix jqhtml compiled files missing from bundle
Fix bundle babel transformation and add rsxrealpath() function

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-10-22 00:43:05 +00:00
parent 53d359bc91
commit 37a6183eb4
80 changed files with 1066 additions and 255 deletions

View File

@@ -1243,3 +1243,68 @@ function text_to_html_with_whitespace(string $text): string
// Join lines with <br>\n
return implode("<br>\n", $processed_lines);
}
/**
* Normalize a path resolving . and .. components without resolving symlinks
*
* Unlike PHP's realpath(), this function normalizes paths by resolving . and ..
* components but does NOT follow symlinks. This is important when working with
* symlinked directories where you need the logical path, not the physical path.
*
* Behavior:
* - Resolves . (current directory) and .. (parent directory) components
* - Does NOT resolve symlinks (unlike realpath())
* - Converts relative paths to absolute by prepending base_path()
* - Returns normalized absolute path, or false if file doesn't exist
*
* Examples:
* - rsxrealpath('/var/www/html/system/rsx/foo/../bar')
* => '/var/www/html/system/rsx/bar'
*
* - rsxrealpath('rsx/foo/../bar')
* => '/var/www/html/rsx/foo/../bar' (after base_path prepend)
* => '/var/www/html/rsx/bar'
*
* - If /var/www/html/system/rsx is a symlink to /var/www/html/rsx:
* rsxrealpath('/var/www/html/system/rsx/bar')
* => '/var/www/html/system/rsx/bar' (keeps symlink path, unlike realpath)
*
* @param string $path The path to normalize
* @return string|false The normalized absolute path, or false if file doesn't exist
*/
function rsxrealpath(string $path): string|false
{
// Convert relative path to absolute
if (!str_starts_with($path, '/')) {
$path = base_path() . '/' . $path;
}
// Split path into components
$parts = explode('/', $path);
$result = [];
foreach ($parts as $part) {
if ($part === '' || $part === '.') {
// Skip empty parts and current directory references
continue;
} elseif ($part === '..') {
// Go up one directory (remove last component)
if (!empty($result)) {
array_pop($result);
}
} else {
// Regular path component
$result[] = $part;
}
}
// Rebuild path with leading slash
$normalized = '/' . implode('/', $result);
// Check if path exists (like realpath does)
if (!file_exists($normalized)) {
return false;
}
return $normalized;
}