Implement window.meta (MetaScript) runtime for WebView#1
Implement window.meta (MetaScript) runtime for WebView#1yumin-chen wants to merge 8 commits intomasterfrom
Conversation
- Added SubprocessManager in core/include/webview/meta.hh to handle process spawning (fork, forkpty) and I/O monitoring (GIOChannel, g_child_watch). - Implemented JS bridge in core/include/webview/detail/meta_js.hh defining the window.meta API, Subprocess, and Terminal classes. - Added a comprehensive demo in examples/meta_runtime.cc. - Included unit tests in core/tests/src/meta_tests.cc for spawn and spawnSync. - Updated CMakeLists.txt to include new components. Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
- Added SubprocessManager in core/include/webview/meta.hh with POSIX spawn, PTY support, and GLib IO monitoring. - Implemented robust handle-based process management to prevent race conditions and memory leaks. - Used Base64 encoding for safe binary data transfer across the JS bridge. - Added support for `cwd` in subprocess options. - Provided a spec-compliant JS API in core/include/webview/detail/meta_js.hh, including ReadableStream support. - Included comprehensive unit and functional tests in core/tests/src/meta_tests.cc. - Added a demonstration example in examples/meta_runtime.cc. Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>
…or architecture - Refactored SubprocessManager to centralize JS bindings via a `bind(webview&)` method. - Implemented robust handle-based process management and I/O streaming. - Used Base64 encoding for safe binary data transfer between C++ and JS. - Improved JS API spec-compliance, including Terminal constructor and ReadableStream support. - Added support for `cwd` and process cleanup to prevent memory leaks. - Ensured portability across POSIX systems (Linux/macOS) with proper guards. - Integrated comprehensive functional and unit tests. - Provided a clean demonstration example in examples/meta_runtime.cc. Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>
- Introduced SubprocessManager as a host orchestrator providing native OS capacities. - Implemented window.meta.cron.parse in JS for next-occurrence calculation. - Added native cron job registration/removal using crontab (Linux). - Enhanced process spawning with Base64 safety and handle-based management. - Implemented spec-compliant Subprocess and Terminal classes. - Added comprehensive unit and functional tests for Cron and Spawn. - Provided a full demonstration example with CLI support for cron triggers. Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>
e7da6b8 to
cbbdee4
Compare
…e build script - Initialized Bun project (@metascript/runtime). - Extracted JS/TS runtime logic to `src/runtime.ts`. - Created a C++ host orchestrator `src/host.cpp` that embeds the transpiled JS. - Developed `build.ts` to bundle MetaScript source code and compile native binaries. - Added comprehensive unit tests in `tests/spawn.test.ts` using `bun:test`. - Maintained core OS capabilities (Process, PTY, Cron) in `core/include/webview/meta.hh`. Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>
…upport - Introduced `SubprocessManager` in `meta.hh` as a host orchestrator for OS operations. - Implemented `window.meta` JS API in `src/runtime.ts` with TypeScript support. - Added native GUI component bridge (Linux/GTK) for Window, Button, and Layouts. - Implemented OS-level Cron job registration (Linux/crontab) and calculation logic. - Created `build.ts` for bundling MetaScript source into native binary executables. - Added a full host orchestrator in `src/host.cpp` with Cron execution support. - Ensured binary data safety across the WebView bridge using Base64 encoding. - Included comprehensive unit and functional tests for the new runtime. Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>
Introduces AlloyScript (`window.Alloy`), a runtime for WebView that provides: - Subprocess management (`spawn`, `spawnSync`) with PTY and async streaming. - Inter-Process Communication (IPC) for spawned processes. - Native GUI bridge for platform widgets (Windows, Buttons, Layouts). - Cron job management for scheduled tasks. - Bun-powered build system to bundle and embed JS into a C++ host. The implementation includes a robust C++ backend (`meta.hh`), a TypeScript runtime (`runtime.ts`), and a standalone host orchestrator. Verified with unit tests and functional GUI/Cron demonstrations. Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>
|
Explain to me the implementation details of bind =>it is not possible to bind globals instead of window? |
In the context of a WebView, |
…address PR feedback - Updated runtime.ts to use `globalThis` instead of `window` for better compatibility with non-browser JS environments (like Web Workers or Node-like environments if applicable). - Refined the explanation of the binding mechanism in response to PR comments. - Ensured namespacing of internal bindings to keep the global scope clean. Co-authored-by: yumin-chen <10954839+yumin-chen@users.noreply.github.com>
This change introduces a MetaScript-inspired
window.metaruntime to thewebviewlibrary. It enables web applications to spawn child processes, interact with them via standard streams (stdin, stdout, stderr), and use pseudo-terminals (PTY) for interactive sessions.Key components:
window.metaobject into the WebView, providing an API that closely matches the requested specification, including support forReadableStreambased output.forkptyon Linux to support interactive terminal applications likebash.PR created automatically by Jules for task 10457583970443846286 started by @yumin-chen