- JumPHP\Tauri\BrowserRuntime: the same App, PHP in the WebAssembly engine, the native commands sent to the page
through JsBridge ({t: 'tauri'}); App::start() (not blocking) and App::events(); wasm.php starts an App for
ui: webview
- engine/web/jumphp-app.js: what Tauri does, in HTML: windows (main + floating), menu bar and shortcuts, dialogs,
file picker (files into PHP's /tmp/open), save = download (/tmp/save), notifications, links, clipboard, drops
- engine/web/jumphp-app-frame.js: window.jumphp in the app's pages (same API as in Tauri), added to their <head>
by render-web.php (pages copied to app/); stage-web.sh: no service container for apps; package-web.sh copies folders
- tried in headless Chrome with hello-desktop: greeting from PHP, menu check item, confirm dialog, "Save as"
downloading the note, no error; Pong's browser build unchanged
- docs: "In the browser, on phones" (Android through bin/jumphp twa, iPhone as a web app)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01X3cUrs2Lzdw6UxLPgG4Xp1
36 lines
1.5 KiB
PHP
36 lines
1.5 KiB
PHP
<?php
|
|
|
|
// Browser entry point. The page (engine/web/jumphp.js) evaluates its prelude (define('JUMPHP_WASM', true), ...)
|
|
// then requires this file. phpw.c (docker/engine-wasm) then calls jumphp_frame() at each requestAnimationFrame.
|
|
// The game files are at /game (emscripten file_packager), the player's files at /game/var (IndexedDB).
|
|
// jumphp_events() is called by the page between frames (tab hidden, page closing: JsBridge events now).
|
|
chdir('/game');
|
|
require '/game/vendor/autoload.php';
|
|
|
|
try {
|
|
if (\JumPHP\Kernel\GameConfig::load('/game')->get('ui') === 'webview') {
|
|
// a desktop app (docs/tauri.md "In the browser"): its pages in the page, its PHP here
|
|
$GLOBALS['app'] = \JumPHP\Tauri\App::boot('/game', new \JumPHP\Tauri\BrowserRuntime());
|
|
$GLOBALS['app']->start();
|
|
} else {
|
|
$GLOBALS['app'] = \JumPHP\Kernel\Application::boot('/game');
|
|
}
|
|
} catch (\Throwable $e) {
|
|
\JumPHP\Kernel\Application::stderr('[jumphp] BOOT FAILED: ' . get_class($e) . ': ' . $e->getMessage() . ' (' . $e->getFile() . ':' . $e->getLine() . ")\n"
|
|
. $e->getTraceAsString() . "\n");
|
|
return;
|
|
}
|
|
|
|
// declared only when the boot worked (a conditional declaration runs at execution time, not at compile time):
|
|
// without it, phpw_run() returns and the page shows the error
|
|
if (isset($GLOBALS['app'])) {
|
|
function jumphp_frame(): void
|
|
{
|
|
$GLOBALS['app']->frame();
|
|
}
|
|
|
|
function jumphp_events(): void
|
|
{
|
|
$GLOBALS['app']->events();
|
|
}
|
|
}
|