Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion resources/jump/websocket-server.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@
// page props, scroll position). Only watch them when Vite isn't running.
$lastModTimes = [];
$lastReloadTime = 0;
$watchPaths = ['app', 'resources', 'routes', 'config'];
$watchPaths = jumpResolveWatchPaths();
jumpLog('File watcher paths: '.implode(', ', $watchPaths));
$serverExtensions = ['php', 'blade.php'];
$clientExtensions = ['js', 'jsx', 'ts', 'tsx', 'vue', 'css', 'scss', 'sass', 'less'];

Expand Down Expand Up @@ -252,6 +253,20 @@ function jumpLog($message)
fwrite(STDERR, '['.date('H:i:s').'] [Jump] '.$message."\n");
}

function jumpResolveWatchPaths(): array
{
$defaults = ['app', 'resources', 'routes', 'config'];
$fromEnv = getenv('JUMP_WATCH_PATHS');
if ($fromEnv !== false) {
$decoded = json_decode($fromEnv, true);
if (is_array($decoded) && $decoded !== []) {
return $decoded;
}
}

return $defaults;
}

/**
* Resolve the live Vite dev-server origin (host + port) from the Laravel
* Vite hot file. Returns [host, port] — host is what we should actually
Expand Down
13 changes: 11 additions & 2 deletions src/Commands/JumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ private function startBridgeServer(int $wsPort, int $bridgePort, int $viteProxyP
$logFile = $logDir.'/jump-bridge.log';
@file_put_contents($logFile, '=== '.date('Y-m-d H:i:s')." bridge server starting (ws={$wsPort} tcp={$bridgePort} vite_proxy={$viteProxyPort}) ===\n", FILE_APPEND);

$watchPaths = config('nativephp.hot_reload.watch_paths', [
'app', 'resources', 'routes', 'config',
]);

// Run in background (not Workerman daemon mode — it breaks the event loop).
if (PHP_OS_FAMILY === 'Windows') {
// `&` is a command separator on Windows (not "background"), and the
Expand Down Expand Up @@ -390,10 +394,15 @@ private function startBridgeServer(int $wsPort, int $bridgePort, int $viteProxyP
// mid-command (proc_close blocks waiting for the long-lived child).
// On Ctrl+C the PHP process is hard-terminated by Windows and the
// bridge stays running, matching Mac/Linux behaviour.
$this->bridgeProcess = @proc_open($cmd, $desc, $pipes, base_path(), null, ['bypass_shell' => true]);
$env = array_merge(getenv() ?: [], [
'JUMP_WATCH_PATHS' => json_encode($watchPaths),
]);
$this->bridgeProcess = @proc_open($cmd, $desc, $pipes, base_path(), $env, ['bypass_shell' => true]);
} else {
$envPrefix = 'JUMP_WATCH_PATHS='.escapeshellarg(json_encode($watchPaths));
$cmd = sprintf(
'%s %s %s %d %d %d start >> %s 2>&1 &',
'%s %s %s %s %d %d %d start >> %s 2>&1 &',
$envPrefix,
escapeshellarg($phpBinary),
escapeshellarg($serverPath),
escapeshellarg(base_path()),
Expand Down