Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e7da6b8
Update ReadMe.md
yumin-chen Mar 29, 2026
84b811e
Implement alloy:gui Native UI Framework
yumin-chen Mar 29, 2026
92ed0f1
feat: implement native GUI bindings in C++ for alloy:gui
google-labs-jules[bot] Mar 29, 2026
1196c78
feat: implement core infrastructure for alloy:gui native bindings
google-labs-jules[bot] Mar 29, 2026
791bd7f
feat: expand native GUI components to include ComboBox, Slider, and P…
google-labs-jules[bot] Mar 29, 2026
2d36131
feat: reorganize alloy:gui bindings into modular component files
google-labs-jules[bot] Mar 29, 2026
1f9433a
feat: add comprehensive tests and fix component exports
google-labs-jules[bot] Mar 29, 2026
c7ca93a
feat: implement complete modular native GUI bindings
google-labs-jules[bot] Mar 29, 2026
a1eaa57
feat: implement full suite of native GUI bindings with Fluent UI support
google-labs-jules[bot] Mar 30, 2026
5a46b73
feat(gui): implement comprehensive native bindings and core systems
google-labs-jules[bot] Mar 30, 2026
f6e5f94
feat(gui): finalize modular native bindings and core systems
google-labs-jules[bot] Mar 30, 2026
c1b3905
feat(gui): modularize components and expand test coverage
google-labs-jules[bot] Mar 30, 2026
3308f74
docs: update ReadMe title to AlloyScript Engine
google-labs-jules[bot] Mar 30, 2026
30b9517
feat(gui): finalize native bindings with modular tests and docs
google-labs-jules[bot] Mar 30, 2026
cf29782
feat(gui): add C/C++ examples for native GUI
google-labs-jules[bot] Mar 30, 2026
4de6f64
feat(gui): finalize native bindings with modular tests, docs, and exa…
google-labs-jules[bot] Mar 30, 2026
3ff8016
feat(gui): finalize native bindings with full component suite, tests,…
google-labs-jules[bot] Mar 30, 2026
5444af5
feat(gui): implement all UI components completely with tests and docs
google-labs-jules[bot] Apr 1, 2026
852caf7
feat(gui): implement comprehensive C++ native platform bindings
google-labs-jules[bot] Apr 1, 2026
4dc2b9a
feat(gui): implement comprehensive C++ native platform bindings and s…
google-labs-jules[bot] Apr 1, 2026
391eb9d
feat(gui): implement comprehensive C++ native platform bindings and s…
google-labs-jules[bot] Apr 1, 2026
94304e3
feat(gui): implement dual-engine architecture with secure ABI boundary
google-labs-jules[bot] Apr 1, 2026
aa9fd3f
feat(engine): implement @alloyscript/engine with dual-engine architec…
google-labs-jules[bot] Apr 1, 2026
5141541
feat(engine): implement @alloyscript/engine dual-engine architecture
google-labs-jules[bot] Apr 1, 2026
c144623
feat(engine): implement @alloyscript/engine with dual-engine orchestr…
google-labs-jules[bot] Apr 1, 2026
b7aaa3d
feat(engine): implement @alloyscript/engine with dual-engine orchestr…
google-labs-jules[bot] Apr 1, 2026
d577ce8
feat(engine): implement @alloyscript/engine dual-engine Native GUI an…
google-labs-jules[bot] Apr 1, 2026
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
7 changes: 4 additions & 3 deletions ReadMe.mdx → ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# @alloyscript/runtime
# AlloyScript Engine

The AlloyScript runtime is a high-performance, secure JavaScript environment built for WebView applications. It uses **Bun** for development and bundling, and a **C host program** for native capabilities.
The AlloyScript runtime is a high-performance, secure JavaScript environment built using WebView as streamlined cross-platform JS runtime for desktop applications. It uses **Bun** for development and bundling, and a **C host program** for native capabilities.

## Architecture

1. **TypeScript Library**: Provides typed APIs for SQLite, Spawn, and SecureEval.
2. **C Host Program**: A native wrapper that initializes a WebView window and exposes a bridge to the JS context.
2. **C Host Program**: A native wrapper that initialises a [WebView](docs/webview.md) window and exposes a bridge to the JS context.
3. **Bridge**: Communication between JS and C via `window.Alloy`.
4. **Secure Evaluation**: `window.eval` is replaced with `secureEval` which runs [MicroQuickJS](https://github.com/bellard/mquickjs) within an OCI-compatible, chainguarded containerized Linux kernel for ultimate isolation.
5. **SQLite Driver**: A high-performance driver with transactions, prepared statement caching, and `bigint` support.
6. **Native GUI Framework (`alloy:gui`)**: A declarative component framework (ASX) that wraps native OS controls (Win32/Cocoa/GTK) using the Yoga layout engine.

## Security

Expand Down
106 changes: 104 additions & 2 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,58 @@ endif()
if(WEBVIEW_BUILD_SHARED_LIBRARY)
add_library(webview_core_shared SHARED)
add_library(webview::core_shared ALIAS webview_core_shared)
target_sources(webview_core_shared PRIVATE src/webview.cc)
target_sources(webview_core_shared PRIVATE
src/webview.cc
src/alloy_gui.cpp
src/signals.cpp
src/compiler.cpp
src/components/accordion.cpp
src/components/badge.cpp
src/components/button.cpp
src/components/card.cpp
src/components/checkbox.cpp
src/components/chip.cpp
src/components/codeeditor.cpp
src/components/colorpicker.cpp
src/components/combobox.cpp
src/components/contextmenu.cpp
src/components/datepicker.cpp
src/components/dialog.cpp
src/components/divider.cpp
src/components/filedialog.cpp
src/components/groupbox.cpp
src/components/hstack.cpp
src/components/icon.cpp
src/components/image.cpp
src/components/label.cpp
src/components/link.cpp
src/components/listview.cpp
src/components/menu.cpp
src/components/menubar.cpp
src/components/popover.cpp
src/components/progressbar.cpp
src/components/radiobutton.cpp
src/components/rating.cpp
src/components/richtext.cpp
src/components/scrollview.cpp
src/components/separator.cpp
src/components/slider.cpp
src/components/spinner.cpp
src/components/spinner_loading.cpp
src/components/splitter.cpp
src/components/statusbar.cpp
src/components/switch.cpp
src/components/tabview.cpp
src/components/textarea.cpp
src/components/textfield.cpp
src/components/timepicker.cpp
src/components/toolbar.cpp
src/components/tooltip.cpp
src/components/treeview.cpp
src/components/vstack.cpp
src/components/webview.cpp
src/components/window.cpp
)
target_link_libraries(webview_core_shared PUBLIC webview_core_headers)
set_target_properties(webview_core_shared PROPERTIES
OUTPUT_NAME webview
Expand All @@ -43,7 +94,58 @@ if(WEBVIEW_BUILD_STATIC_LIBRARY)

add_library(webview_core_static STATIC)
add_library(webview::core_static ALIAS webview_core_static)
target_sources(webview_core_static PRIVATE src/webview.cc)
target_sources(webview_core_static PRIVATE
src/webview.cc
src/alloy_gui.cpp
src/signals.cpp
src/compiler.cpp
src/components/accordion.cpp
src/components/badge.cpp
src/components/button.cpp
src/components/card.cpp
src/components/checkbox.cpp
src/components/chip.cpp
src/components/codeeditor.cpp
src/components/colorpicker.cpp
src/components/combobox.cpp
src/components/contextmenu.cpp
src/components/datepicker.cpp
src/components/dialog.cpp
src/components/divider.cpp
src/components/filedialog.cpp
src/components/groupbox.cpp
src/components/hstack.cpp
src/components/icon.cpp
src/components/image.cpp
src/components/label.cpp
src/components/link.cpp
src/components/listview.cpp
src/components/menu.cpp
src/components/menubar.cpp
src/components/popover.cpp
src/components/progressbar.cpp
src/components/radiobutton.cpp
src/components/rating.cpp
src/components/richtext.cpp
src/components/scrollview.cpp
src/components/separator.cpp
src/components/slider.cpp
src/components/spinner.cpp
src/components/spinner_loading.cpp
src/components/splitter.cpp
src/components/statusbar.cpp
src/components/switch.cpp
src/components/tabview.cpp
src/components/textarea.cpp
src/components/textfield.cpp
src/components/timepicker.cpp
src/components/toolbar.cpp
src/components/tooltip.cpp
src/components/treeview.cpp
src/components/vstack.cpp
src/components/webview.cpp
src/components/window.cpp
)
target_link_libraries(webview_core_static PUBLIC webview_core_headers)
set_target_properties(webview_core_static PROPERTIES
OUTPUT_NAME "${STATIC_LIBRARY_OUTPUT_NAME}"
Expand Down
186 changes: 186 additions & 0 deletions core/include/alloy/api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
#ifndef ALLOY_API_H
#define ALLOY_API_H

#include <stddef.h>

#ifdef __cplusplus
extern "C" {
#endif

#ifdef _WIN32
#define ALLOY_API __declspec(dllexport)
#else
#define ALLOY_API __attribute__((visibility("default")))
#endif

typedef void *alloy_component_t;
typedef void *alloy_signal_t;
typedef void *alloy_computed_t;
typedef void *alloy_effect_t;

typedef enum {
ALLOY_OK = 0,
ALLOY_ERROR_INVALID_ARGUMENT,
ALLOY_ERROR_INVALID_STATE,
ALLOY_ERROR_PLATFORM,
ALLOY_ERROR_BUFFER_TOO_SMALL,
ALLOY_ERROR_NOT_SUPPORTED,
} alloy_error_t;

typedef enum {
ALLOY_EVENT_CLICK = 0,
ALLOY_EVENT_CHANGE,
ALLOY_EVENT_CLOSE,
ALLOY_EVENT_FOCUS,
ALLOY_EVENT_BLUR,
} alloy_event_type_t;

typedef enum {
ALLOY_PROP_TEXT = 0,
ALLOY_PROP_CHECKED,
ALLOY_PROP_VALUE,
ALLOY_PROP_ENABLED,
ALLOY_PROP_VISIBLE,
ALLOY_PROP_LABEL,
} alloy_prop_id_t;

typedef void (*alloy_event_cb_t)(alloy_component_t handle,
alloy_event_type_t event,
void *userdata);

typedef struct {
unsigned int background;
unsigned int foreground;
float font_size;
const char *font_family;
float border_radius;
float opacity;
} alloy_style_t;

ALLOY_API const char *alloy_error_message(alloy_error_t err);

ALLOY_API alloy_signal_t alloy_signal_create_str(const char *initial);
ALLOY_API alloy_signal_t alloy_signal_create_double(double initial);
ALLOY_API alloy_signal_t alloy_signal_create_int(int initial);
ALLOY_API alloy_signal_t alloy_signal_create_bool(int initial);

ALLOY_API alloy_error_t alloy_signal_set_str(alloy_signal_t s, const char *v);
ALLOY_API alloy_error_t alloy_signal_set_double(alloy_signal_t s, double v);
ALLOY_API alloy_error_t alloy_signal_set_int(alloy_signal_t s, int v);
ALLOY_API alloy_error_t alloy_signal_set_bool(alloy_signal_t s, int v);

ALLOY_API const char *alloy_signal_get_str(alloy_signal_t s);
ALLOY_API double alloy_signal_get_double(alloy_signal_t s);
ALLOY_API int alloy_signal_get_int(alloy_signal_t s);
ALLOY_API int alloy_signal_get_bool(alloy_signal_t s);

ALLOY_API alloy_computed_t alloy_computed_create(
alloy_signal_t *deps, size_t dep_count,
void (*compute)(alloy_signal_t *deps, size_t dep_count, void *out, void *userdata),
void *userdata);

ALLOY_API alloy_effect_t alloy_effect_create(
alloy_signal_t *deps, size_t dep_count,
void (*run)(void *userdata), void *userdata);

ALLOY_API alloy_error_t alloy_signal_destroy(alloy_signal_t s);
ALLOY_API alloy_error_t alloy_computed_destroy(alloy_computed_t c);
ALLOY_API alloy_error_t alloy_effect_destroy(alloy_effect_t e);

ALLOY_API alloy_error_t alloy_bind_property(alloy_component_t component,
alloy_prop_id_t property,
alloy_signal_t signal);
ALLOY_API alloy_error_t alloy_unbind_property(alloy_component_t component,
alloy_prop_id_t property);

ALLOY_API alloy_component_t alloy_create_window(const char *title,
int width, int height);
ALLOY_API alloy_component_t alloy_create_button(alloy_component_t parent);
ALLOY_API alloy_component_t alloy_create_textfield(alloy_component_t parent);
ALLOY_API alloy_component_t alloy_create_textarea(alloy_component_t parent);
ALLOY_API alloy_component_t alloy_create_label(alloy_component_t parent);
ALLOY_API alloy_component_t alloy_create_checkbox(alloy_component_t parent);
ALLOY_API alloy_component_t alloy_create_radiobutton(alloy_component_t parent);
ALLOY_API alloy_component_t alloy_create_combobox(alloy_component_t parent);
ALLOY_API alloy_component_t alloy_create_slider(alloy_component_t parent);
ALLOY_API alloy_component_t alloy_create_spinner(alloy_component_t parent);
ALLOY_API alloy_component_t alloy_create_switch(alloy_component_t parent);
ALLOY_API alloy_component_t alloy_create_progressbar(alloy_component_t parent);
ALLOY_API alloy_component_t alloy_create_tabview(alloy_component_t parent);
ALLOY_API alloy_component_t alloy_create_listview(alloy_component_t parent);
ALLOY_API alloy_component_t alloy_create_treeview(alloy_component_t parent);
ALLOY_API alloy_component_t alloy_create_webview(alloy_component_t parent);
ALLOY_API alloy_error_t alloy_webview_bind_global(alloy_component_t webview,
const char *name,
void (*callback)(const char *json_args, void *userdata),
void *userdata);
ALLOY_API alloy_error_t alloy_webview_secure_post(alloy_component_t webview,
const char *encrypted_msg);

ALLOY_API alloy_error_t alloy_build_bytecode(const char *source,
unsigned char **out_bytecode,
size_t *out_len);

ALLOY_API alloy_error_t alloy_decompile_bytecode(const unsigned char *bytecode,
size_t len,
char **out_js);

typedef void *alloy_transpiler_t;

ALLOY_API alloy_transpiler_t alloy_transpiler_create(const char *options_json);
ALLOY_API alloy_error_t alloy_transpiler_transform(alloy_transpiler_t t,
const char *code,
const char *loader,
char **out_result);
ALLOY_API alloy_error_t alloy_transpiler_scan(alloy_transpiler_t t,
const char *code,
char **out_json_result);
ALLOY_API void alloy_transpiler_destroy(alloy_transpiler_t t);
ALLOY_API alloy_component_t alloy_create_vstack(alloy_component_t parent);
ALLOY_API alloy_component_t alloy_create_hstack(alloy_component_t parent);
ALLOY_API alloy_component_t alloy_create_scrollview(alloy_component_t parent);

ALLOY_API alloy_error_t alloy_destroy(alloy_component_t handle);

ALLOY_API alloy_error_t alloy_set_text(alloy_component_t h, const char *text);
ALLOY_API alloy_error_t alloy_get_text(alloy_component_t h,
char *buf, size_t buf_len);
ALLOY_API alloy_error_t alloy_set_checked(alloy_component_t h, int checked);
ALLOY_API int alloy_get_checked(alloy_component_t h);
ALLOY_API alloy_error_t alloy_set_value(alloy_component_t h, double value);
ALLOY_API double alloy_get_value(alloy_component_t h);
ALLOY_API alloy_error_t alloy_set_enabled(alloy_component_t h, int enabled);
ALLOY_API int alloy_get_enabled(alloy_component_t h);
ALLOY_API alloy_error_t alloy_set_visible(alloy_component_t h, int visible);
ALLOY_API int alloy_get_visible(alloy_component_t h);
ALLOY_API alloy_error_t alloy_set_style(alloy_component_t h,
const alloy_style_t *style);

ALLOY_API alloy_error_t alloy_add_child(alloy_component_t container,
alloy_component_t child);
ALLOY_API alloy_error_t alloy_set_flex(alloy_component_t h, float flex);
ALLOY_API alloy_error_t alloy_set_padding(alloy_component_t h,
float top, float right,
float bottom, float left);
ALLOY_API alloy_error_t alloy_set_margin(alloy_component_t h,
float top, float right,
float bottom, float left);
ALLOY_API alloy_error_t alloy_set_width(alloy_component_t h, float width);
ALLOY_API alloy_error_t alloy_set_height(alloy_component_t h, float height);
ALLOY_API alloy_error_t alloy_layout(alloy_component_t window);

ALLOY_API alloy_error_t alloy_set_event_callback(alloy_component_t handle,
alloy_event_type_t event,
alloy_event_cb_t callback,
void *userdata);

ALLOY_API alloy_error_t alloy_run(alloy_component_t window);
ALLOY_API alloy_error_t alloy_terminate(alloy_component_t window);
ALLOY_API alloy_error_t alloy_dispatch(alloy_component_t window,
void (*fn)(void *arg), void *arg);

#ifdef __cplusplus
}
#endif

#endif
12 changes: 12 additions & 0 deletions core/include/alloy/detail/backends.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef ALLOY_BACKENDS_HH
#define ALLOY_BACKENDS_HH

#if defined(ALLOY_PLATFORM_WINDOWS)
#include "backends/win32_gui.hh"
#elif defined(ALLOY_PLATFORM_DARWIN)
#include "backends/cocoa_gui.hh"
#elif defined(ALLOY_PLATFORM_LINUX)
#include "backends/gtk_gui.hh"
#endif

#endif
Loading