Build the web extensions on Kryon's canvas backend
The web link takes Kryon's canvas window, draw, input, texture, audio, raster and route modules instead of the deleted JS hosts, builds liboqs for WebAssembly, and no longer pulls the native raylib runtime into the page. Foreign declarations that shared a name with a canvas function are renamed to the same C symbol under a different Ziran name, main takes no arguments on web, and the Ziran and Kryon pins move to the commits that add the missing pieces. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
1 parent
ea24cd0e6f
commit
e2ff252eec
11 files changed
+61
-32
No files matched your search
@@ -910,7 +910,7 @@ $(WEB_GEN_STAMP): Makefile $(ZI2C_BIN) $(ZI_SRCS) $(KRYON_ZI_MODULES) $(GAME2D_M
|
||||
--module-path $(GAME2D_DIR)/src \
|
||||
--module-path $(ZIRAN_DIR)/std \
|
||||
--module-path build/packages/daochi-client \
|
||||
-o $(WEB_GEN_DIR) $(ZI_SRCS)
|
||||
-o $(WEB_GEN_DIR) $(ZI_SRCS) $(KRYON_DIR)/src/backend/canvas_raster.zi $(KRYON_DIR)/src/backend/canvas_audio.zi $(KRYON_DIR)/src/backend/page_route.zi
|
||||
touch $@
|
||||
find $(WEB_GEN_DIR) -type f \( -name '*.c' -o -name '*.h' \) -exec touch -r $@ {} +
|
||||
|
||||
@@ -1903,8 +1903,6 @@ sync-web-icons: $(KRYON_SYNC_ICONS)
|
||||
sh $(KRYON_SYNC_ICONS) web-assets/icons $(WEB_SHARED_ICON_SHEETS)
|
||||
cp assets/app/icon.png web-assets/icons/$(APP_NAME).png
|
||||
|
||||
$(WEB_LIBOQS_A): web-tools-check
|
||||
|
||||
$(CLICK_LIBOQS_A): $(LIBOQS_DIR)/CMakeLists.txt
|
||||
rm -rf $(CLICK_LIBOQS_BUILD_DIR)
|
||||
$(CMAKE) -S $(LIBOQS_DIR) -B $(CLICK_LIBOQS_BUILD_DIR) \
|
||||
|
||||
+11
@@ -5,6 +5,7 @@ KRYON_LIBOQS_DIR := build/packages/liboqs
|
||||
KRYON_LIBOQS_BUILD_DIR := $(KRYON_VENDOR_BUILD_DIR)/inbe-liboqs
|
||||
KRYON_LIBOQS_A := $(KRYON_LIBOQS_BUILD_DIR)/lib/liboqs.a
|
||||
KRYON_LIBOQS_INCLUDE := -I$(KRYON_LIBOQS_BUILD_DIR)/include
|
||||
KRYON_WEB_LIBOQS_A := $(KRYON_WEB_LIBOQS_BUILD_DIR)/lib/liboqs.a
|
||||
KRYON_LIBOQS_BUILD_TYPE ?= MinSizeRel
|
||||
KRYON_LIBOQS_MINIMAL_BUILD ?= SIG_ml_dsa_44
|
||||
|
||||
@@ -34,6 +35,16 @@ $(KRYON_LIBOQS_A): $(KRYON_LIBOQS_DIR)/CMakeLists.txt
|
||||
-DOQS_MINIMAL_BUILD=$(KRYON_LIBOQS_MINIMAL_BUILD)
|
||||
$(CMAKE) --build $(KRYON_LIBOQS_BUILD_DIR) --target oqs
|
||||
|
||||
$(KRYON_WEB_LIBOQS_A): $(KRYON_LIBOQS_DIR)/CMakeLists.txt
|
||||
$(WEB_EMCMAKE) $(CMAKE) -S $(KRYON_LIBOQS_DIR) -B $(KRYON_WEB_LIBOQS_BUILD_DIR) \
|
||||
-DCMAKE_BUILD_TYPE=$(KRYON_LIBOQS_BUILD_TYPE) \
|
||||
-DBUILD_SHARED_LIBS=OFF -DOQS_BUILD_ONLY_LIB=ON \
|
||||
-DOQS_USE_OPENSSL=OFF -DOQS_DIST_BUILD=OFF \
|
||||
-DOQS_OPT_TARGET=generic \
|
||||
$(KRYON_LIBOQS_CPU_FEATURE_CMAKE_FLAGS) \
|
||||
-DOQS_MINIMAL_BUILD=$(KRYON_LIBOQS_MINIMAL_BUILD)
|
||||
$(CMAKE) --build $(KRYON_WEB_LIBOQS_BUILD_DIR) --target oqs
|
||||
|
||||
$(KRYON_CURL_A): $(KRYON_CURL_DIR)/CMakeLists.txt
|
||||
$(CMAKE) -S $(KRYON_CURL_DIR) -B $(KRYON_CURL_BUILD_DIR) \
|
||||
-DCMAKE_BUILD_TYPE=$(KRYON_CURL_BUILD_TYPE) \
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
#import "geometry"
|
||||
#import, file "../platform/environment.zi";
|
||||
#import, file "../platform/raylib_host.zi";
|
||||
#import, file "../../build/packages/kryon/src/backend/raylib_runtime.zi";
|
||||
#if #defined(PLATFORM_WEB) == false {
|
||||
#import, file "../../build/packages/kryon/src/backend/raylib_runtime.zi";
|
||||
}
|
||||
raylib :: #system_library "raylib";
|
||||
IsWindowReady :: () -> bool #foreign raylib;
|
||||
GetWindowScaleDPI :: () -> Vector2 #foreign raylib;
|
||||
@@ -57,7 +59,9 @@ UpdateDPI :: (view_width: s32, view_height: s32) {
|
||||
// The user's zoom scales everything drawn and narrows or widens the
|
||||
// layout; the text is baked at the size it ends up on screen.
|
||||
dpi_state = ZoomDPI(dpi_state, dpi_user_zoom)
|
||||
RaylibSetZoom(dpi_state.render_scale)
|
||||
#if #defined(PLATFORM_WEB) == false {
|
||||
RaylibSetZoom(dpi_state.render_scale)
|
||||
}
|
||||
}
|
||||
|
||||
// The zoom for the next UpdateDPI, 1.0 for 100%.
|
||||
|
||||
+12
-1
@@ -254,7 +254,7 @@ run_practice_probe :: (mode: s32, size: WindowSize) -> s32 {
|
||||
}
|
||||
}
|
||||
|
||||
main :: (argc: s32, argv: **u8) -> s32 {
|
||||
run_application :: (argc: s32, argv: **u8) -> s32 {
|
||||
window_size: WindowSize
|
||||
|
||||
probe_mode := practice_probe_mode(argc, argv)
|
||||
@@ -311,3 +311,14 @@ main :: (argc: s32, argv: **u8) -> s32 {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
// Emscripten's clang requires main(int, char **); the page passes no arguments.
|
||||
#if #defined(PLATFORM_WEB) {
|
||||
main :: () -> s32 {
|
||||
return run_application(0, null)
|
||||
}
|
||||
} else {
|
||||
main :: (argc: s32, argv: **u8) -> s32 {
|
||||
return run_application(argc, argv)
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,9 @@ app_getenv_bytes :: (name: *u8) -> *u8 #foreign c;
|
||||
#import, file "../app/dpi_state.zi";
|
||||
#import, file "environment.zi";
|
||||
#import, file "raylib_host.zi";
|
||||
#import, file "../../build/packages/kryon/src/backend/raylib_runtime.zi";
|
||||
#if #defined(PLATFORM_WEB) == false {
|
||||
#import, file "../../build/packages/kryon/src/backend/raylib_runtime.zi";
|
||||
}
|
||||
raylib :: #system_library "raylib";
|
||||
SetConfigFlags :: (flags: u32) #foreign raylib;
|
||||
SetExitKey :: (key: s32) #foreign raylib;
|
||||
@@ -311,7 +313,10 @@ app_frame :: (app: *InnerBreeze) {
|
||||
SetMouseCursor(0)
|
||||
}
|
||||
// Ctrl and the wheel zoom the whole app instead of scrolling a list.
|
||||
modifiers := RaylibModifiers()
|
||||
modifiers: s32 = 0
|
||||
#if #defined(PLATFORM_WEB) == false {
|
||||
modifiers = RaylibModifiers()
|
||||
}
|
||||
zoom_key: s32 = 0
|
||||
if (modifiers & KeyModifierControl) != 0 {
|
||||
zoom_keys := s32.[ZoomKeyEqual, ZoomKeyMinus, ZoomKeyZero,
|
||||
|
||||
@@ -7,7 +7,7 @@ SetWindowState :: (flags: u32) #foreign raylib;
|
||||
RestoreWindow :: () #foreign raylib;
|
||||
MinimizeWindow :: () #foreign raylib;
|
||||
FLAG_WINDOW_HIDDEN :: 128;
|
||||
TraceLog :: (level: s32, message: *u8, args: ..any) #foreign raylib;
|
||||
NativeTraceLog :: (level: s32, message: *u8, args: ..any) #foreign raylib "TraceLog";
|
||||
tray_memcmp :: (left: *void, right: *void, count: usize) -> s32 #foreign c "memcmp";
|
||||
#import, file "../habits/habit_types.zi";
|
||||
#import, file "../habits/habit_days.zi";
|
||||
@@ -314,7 +314,7 @@ HideTrayWindow :: () {
|
||||
// most confusing failure mode this app has; always say why it hid.
|
||||
message: [41]u8
|
||||
if CopyCString("APP: hiding main window (tray action)", message[:]) {
|
||||
TraceLog(3, *message[0])
|
||||
NativeTraceLog(3, *message[0])
|
||||
}
|
||||
SetWindowState(FLAG_WINDOW_HIDDEN)
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ save_settings :: (app: *InnerBreeze) #foreign c;
|
||||
LOG_ERROR :: 5;
|
||||
LOG_INFO :: 3;
|
||||
LOG_WARNING :: 4;
|
||||
TraceLog :: (level: s32, message: *u8, args: ..any) #foreign c "TraceLog";
|
||||
NativeTraceLog :: (level: s32, message: *u8, args: ..any) #foreign c "TraceLog";
|
||||
app_audio_ensure_ready :: (app: *InnerBreeze) #foreign c;
|
||||
data_root_host_buffer :: () -> *u8 {
|
||||
if !AppCopyText(data_root(), data_root_text[:]) {
|
||||
@@ -163,7 +163,7 @@ log_music :: (level: s32, message: string, detail: string) {
|
||||
buffer: [1024]u8
|
||||
if !AppCopyText(message, buffer[:]) { return }
|
||||
if !AppAppendText(detail, buffer[:]) { return }
|
||||
TraceLog(level, *format[0], *buffer[0])
|
||||
NativeTraceLog(level, *format[0], *buffer[0])
|
||||
}
|
||||
|
||||
set_status :: (app: *InnerBreeze, message: string) {
|
||||
|
||||
@@ -11,7 +11,7 @@ app_init :: (app: *void) #foreign c;
|
||||
app_close_modal :: (app: *InnerBreeze) #foreign c;
|
||||
app_draw_session_exit_modal :: (app: *InnerBreeze, can_save: s32, save_message: string, discard_message: string) -> SessionExitModalResult #foreign c;
|
||||
app_auto_sync :: (app: *InnerBreeze) -> s32 #foreign c;
|
||||
TraceLog :: (level: s32, message: *u8, args: ..any) #foreign c "TraceLog";
|
||||
NativeTraceLog :: (level: s32, message: *u8, args: ..any) #foreign c "TraceLog";
|
||||
sync_habits_for_activity :: (app: *InnerBreeze, activity: s32) #foreign c;
|
||||
practice_update_session_sounds :: (app: *InnerBreeze) #foreign c;
|
||||
practice_background_start :: (app: *InnerBreeze, id: s32) #foreign c;
|
||||
@@ -91,7 +91,7 @@ whm_log :: (level: s32, message: string) {
|
||||
format: [3]u8 = .[37, 115, 0]
|
||||
buffer: [256]u8
|
||||
if AppCopyText(message, buffer[:]) {
|
||||
TraceLog(level, *format[0], *buffer[0])
|
||||
NativeTraceLog(level, *format[0], *buffer[0])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -4,7 +4,7 @@ time :: (t: *s64) -> s64 #foreign c;
|
||||
LOG_INFO :: 3
|
||||
LOG_WARNING :: 4
|
||||
LOG_ERROR :: 5
|
||||
TraceLog :: (level: s32, message: *u8, args: ..any) #foreign c;
|
||||
NativeTraceLog :: (level: s32, message: *u8, args: ..any) #foreign c "TraceLog";
|
||||
sqlite3_open_v2 :: (path: *u8, database: **void, flags: s32, vfs: *u8) -> s32 #foreign sqlite3_lib "sqlite3_open_v2";
|
||||
sqlite3_close :: (database: *void) -> s32 #foreign sqlite3_lib "sqlite3_close";
|
||||
sqlite3_busy_timeout :: (database: *void, milliseconds: s32) -> s32 #foreign sqlite3_lib "sqlite3_busy_timeout";
|
||||
@@ -32,7 +32,7 @@ migrate_legacy_file_sessions_once :: (root: *u8) -> s32 #foreign c;
|
||||
LogStorage :: (level: s32, message: string) {
|
||||
buffer: [256]u8
|
||||
if AppCopyText(message, buffer[:]) {
|
||||
TraceLog(level, *buffer[0])
|
||||
NativeTraceLog(level, *buffer[0])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ LogStorageText :: (level: s32, message: string, detail: string) {
|
||||
index += 1
|
||||
}
|
||||
buffer[used] = cast(u8)0
|
||||
TraceLog(level, *buffer[0])
|
||||
NativeTraceLog(level, *buffer[0])
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ using SyncAccountLocalDataChoice;
|
||||
c :: #system_library "c";
|
||||
LoadFileText :: (path: *u8) -> *u8 #foreign c;
|
||||
UnloadFileText :: (body: *u8) #foreign c;
|
||||
SaveFileData :: (path: *u8, body: *u8, length: s32) -> bool #foreign c;
|
||||
SyncSaveFileData :: (path: *u8, body: *u8, length: s32) -> bool #foreign c "SaveFileData";
|
||||
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ sync_account_export_private_key :: (account: *SyncAccount,
|
||||
*root[0], filename) == 0 {
|
||||
return 0
|
||||
}
|
||||
if !SaveFileData(*path[0], *body[0], len) { return 0 }
|
||||
if !SyncSaveFileData(*path[0], *body[0], len) { return 0 }
|
||||
return AccountDownloadFile(*path[0], filename, *mime[0])
|
||||
} else {
|
||||
index: s32 = 0
|
||||
@@ -232,7 +232,7 @@ sync_account_export_private_key :: (account: *SyncAccount,
|
||||
}
|
||||
if index == AccountPathCapacity { return 0 }
|
||||
if full_path {
|
||||
return ifx (SaveFileData(filename, *body[0], len)) then (1) else (0)
|
||||
return ifx (SyncSaveFileData(filename, *body[0], len)) then (1) else (0)
|
||||
}
|
||||
path: [AccountPathCapacity] u8
|
||||
root: [AccountPathCapacity]u8
|
||||
@@ -241,7 +241,7 @@ sync_account_export_private_key :: (account: *SyncAccount,
|
||||
*root[0], filename) == 0 {
|
||||
return 0
|
||||
}
|
||||
return ifx (SaveFileData(*path[0], *body[0], len)) then (1) else (0)
|
||||
return ifx (SyncSaveFileData(*path[0], *body[0], len)) then (1) else (0)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-11
@@ -45,17 +45,9 @@
|
||||
"source": true,
|
||||
"url": "https://github.com/raysan5/raylib.git"
|
||||
},
|
||||
{
|
||||
"commit": "c8005d34be0f46ccf24044df3f27e057007b864f",
|
||||
"dependencies": {"raylib": "p5a77c9c35110e925"},
|
||||
"id": "p67a92b9967bf22db",
|
||||
"name": "Kryon",
|
||||
"ref": "master",
|
||||
"url": "https://github.com/kryonlabs/kryon.git"
|
||||
},
|
||||
{
|
||||
"commit": "cfd9fc0e73658c09a218feb21b8281fe367647b6",
|
||||
"dependencies": {"Kryon": "p67a92b9967bf22db"},
|
||||
"dependencies": {"Kryon": "peeba5e34c6fde178"},
|
||||
"id": "p8120950c86e3937b",
|
||||
"name": "Game2D",
|
||||
"ref": "master",
|
||||
@@ -78,14 +70,22 @@
|
||||
"ref": "master",
|
||||
"source": true,
|
||||
"url": "https://github.com/LoupVaillant/Monocypher.git"
|
||||
},
|
||||
{
|
||||
"commit": "52feec268de96a1212946352b82edc000d4ce80d",
|
||||
"dependencies": {"raylib": "p5a77c9c35110e925"},
|
||||
"id": "peeba5e34c6fde178",
|
||||
"name": "Kryon",
|
||||
"ref": "master",
|
||||
"url": "https://github.com/kryonlabs/kryon.git"
|
||||
}
|
||||
],
|
||||
"root": {
|
||||
"dependencies": {"curl": "pc4b263336680098b", "daochi_client": "p5a3be391420a26d3", "game2d": "p8120950c86e3937b", "kryon": "p67a92b9967bf22db", "liboqs": "p051fa9c56d0358ad", "monocypher": "pccdfe79ccaafde45", "rini": "p09fa77e94b0dfc6c", "sqlite": "p151b83a361c86f2d"},
|
||||
"dependencies": {"curl": "pc4b263336680098b", "daochi_client": "p5a3be391420a26d3", "game2d": "p8120950c86e3937b", "kryon": "peeba5e34c6fde178", "liboqs": "p051fa9c56d0358ad", "monocypher": "pccdfe79ccaafde45", "rini": "p09fa77e94b0dfc6c", "sqlite": "p151b83a361c86f2d"},
|
||||
"name": "Inbe"
|
||||
},
|
||||
"toolchain": {
|
||||
"commit": "923568880bf0ffcd3d24f4273a7e20772f1c1add",
|
||||
"commit": "c062c3adae044369f56b3bbfab53674da9e244e9",
|
||||
"ref": "master",
|
||||
"url": "https://github.com/ziranlang/ziran.git"
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user