Skip to content
Merged
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
1 change: 1 addition & 0 deletions .github/workflows/fix-php-code-style-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
uses: actions/checkout@v5
with:
ref: ${{ github.head_ref || github.sha }}
fetch-depth: 0

- name: Check PHP code style issues
if: github.event_name == 'push'
Expand Down
3 changes: 3 additions & 0 deletions resources/electron/electron-plugin/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ class NativePHP {
details.requestHeaders['X-NativePHP-Secret'] = state.randomSecret;
callback({ requestHeaders: details.requestHeaders });
});
if (process.env.NATIVEPHP_NO_FOCUS) {
state.noFocusOnRestart = true;
}
yield notifyLaravel("booted");
});
}
Expand Down
3 changes: 3 additions & 0 deletions resources/electron/electron-plugin/dist/server/api/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ router.post('/open', (req, res) => {
});
}
window.webContents.on('did-finish-load', () => {
if (state.noFocusOnRestart && window.isVisible()) {
return;
}
window.show();
});
window.webContents.on('did-fail-load', (event) => {
Expand Down
1 change: 1 addition & 0 deletions resources/electron/electron-plugin/dist/server/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default {
randomSecret: generateRandomString(32),
processes: {},
windows: {},
noFocusOnRestart: false,
findWindow(id) {
return this.windows[id] || null;
},
Expand Down
4 changes: 4 additions & 0 deletions resources/electron/electron-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ class NativePHP {
callback({ requestHeaders: details.requestHeaders });
});

if (process.env.NATIVEPHP_NO_FOCUS) {
state.noFocusOnRestart = true;
}

await notifyLaravel("booted");
}

Expand Down
4 changes: 4 additions & 0 deletions resources/electron/electron-plugin/src/server/api/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,10 @@ router.post('/open', (req, res) => {
}

window.webContents.on('did-finish-load', () => {
if (state.noFocusOnRestart && window.isVisible()) {
return;
}

window.show();
});

Expand Down
2 changes: 2 additions & 0 deletions resources/electron/electron-plugin/src/server/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ interface State {
randomSecret: string;
store: Store;
findWindow: (id: string) => BrowserWindow | null;
noFocusOnRestart: boolean;
dockBounce: number;
}

Expand Down Expand Up @@ -63,6 +64,7 @@ export default {
randomSecret: generateRandomString(32),
processes: {},
windows: {},
noFocusOnRestart: false,
findWindow(id: string) {
return this.windows[id] || null;
},
Expand Down
3 changes: 2 additions & 1 deletion src/Drivers/Electron/Commands/RunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class RunCommand extends Command
use InstallsAppIcon;
use PatchesPackagesJson;

protected $signature = 'native:run {--no-queue} {--D|no-dependencies} {--installer=npm}';
protected $signature = 'native:run {--no-queue} {--no-focus} {--D|no-dependencies} {--installer=npm}';

public function __construct(
protected Builder $builder
Expand Down Expand Up @@ -62,6 +62,7 @@ public function handle(): void
$this->runDeveloper(
installer: $this->option('installer'),
skip_queue: $this->option('no-queue'),
no_focus: $this->option('no-focus'),
withoutInteraction: $this->option('no-interaction')
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Drivers/Electron/Commands/ServeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
)]
class ServeCommand extends RunCommand
{
protected $signature = 'native:serve {--no-queue} {--D|no-dependencies} {--installer=npm}';
protected $signature = 'native:serve {--no-queue} {--no-focus} {--D|no-dependencies} {--installer=npm}';

public function handle(): void
{
Expand Down
3 changes: 2 additions & 1 deletion src/Drivers/Electron/Traits/Developer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trait Developer
{
use ExecuteCommand;

protected function runDeveloper(string $installer, bool $skip_queue, bool $withoutInteraction = false): void
protected function runDeveloper(string $installer, bool $skip_queue, bool $no_focus = false, bool $withoutInteraction = false): void
{
[$installer, $command] = $this->getInstallerAndCommand(installer: $installer, type: 'dev');

Expand All @@ -18,6 +18,7 @@ protected function runDeveloper(string $installer, bool $skip_queue, bool $witho
command: $command,
skip_queue: $skip_queue,
type: 'serve',
no_focus: $no_focus,
withoutInteraction: $withoutInteraction
);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Drivers/Electron/Traits/ExecuteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ protected function executeCommand(
string $command,
bool $skip_queue = false,
string $type = 'install',
bool $no_focus = false,
bool $withoutInteraction = false
): void {

Expand All @@ -32,6 +33,7 @@ protected function executeCommand(
'NATIVEPHP_BUILDING' => false,
'NATIVEPHP_ELECTRON_PATH' => ElectronServiceProvider::electronPath(),
'NATIVEPHP_BUILD_PATH' => ElectronServiceProvider::buildPath(),
'NATIVEPHP_NO_FOCUS' => $no_focus,
],
];

Expand Down
1 change: 1 addition & 0 deletions tests/QueueWorker/QueueWorkerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
'--memory=128',
'--timeout=61',
'--sleep=5',
'--quiet',
]);

expect($iniSettings)->toBe([
Expand Down
Loading