Compare commits

...
1301 Commits
Author SHA1 Message Date
waozi eacdb74144 Release Kryon 0.5.0
Kryon no longer includes raylib: apps use the SDL2/Cairo desktop host, the
Canvas host and the NativeActivity host, with Ziran's core audio natively
and WebAudio in browsers. The desktop host gains what terminal-style apps
used raylib for: descriptor-aware waiting, window options, frame rate, an
exit key, the middle button, fullscreen and glyph preparation. The
changelog section lists what users get. VERSION follows the new section,
as update_version.sh sets it.
2026-11-17 22:30:56 -03:00
waozi 9c8240a73f Give terminal-style desktop apps the services they used raylib for
The SDL2/Cairo desktop host gains what kryonlabs/terminal and Harmony's
terminal need to leave kryon/Raylib:

- kryon/desktop_activity: DesktopWaitForActivity(descriptors, ms) sleeps
  until a program descriptor such as a PTY is readable, window input is
  queued, or the time ends, leaving queued input for PollDesktop. Windows,
  web and Android report DesktopActivityUnsupported.
- OpenDesktopWindow(width, height, title, options) with resizable,
  undecorated, topmost and always-run windows; OpenDesktopTitled stays the
  resizable window.
- DesktopFrameRate(fps) paces the frame clock, 0 drawing without waiting;
  a stable screen never settles faster than the configured rate.
- DesktopExitKey(key), PollMiddlePointer(), DesktopSetFullscreen,
  DesktopToggleFullscreen, DesktopFullscreen and DesktopPrepareGlyphs.

tests/ziran_desktop_host_gaps_test.sh covers each on a private Xvfb, from
source and saved IR.
2026-11-17 22:29:37 -03:00
waozi 3627ea8a90 Remove raylib from Kryon
Kryon carries no raylib code. The ten raylib host modules, the raylib
ZX player, the raylib audio sink and media provider, their tests and
docs, mk/raylib-library.mk, mk/zx-raylib.mk, mk/raylib-shell.html,
cmake/renderer-artifact, the renderer-raylib artifact, the
`backend = "raylib"` profile and [dependencies.raylib] are gone.
Desktop, Android and Canvas hosts keep the shared image, shader and
audio coverage. Browser asset and PCM audio play through
media_audio_web on the Canvas WebAudio engine; native audio uses
Ziran's core audio modules through media_audio_desktop.

macOS CI builds the desktop ZX player and checks the headless bundle
with it. The toolchain moves to Ziran 7fbc8152, which carries the
optimizer fixes the tree-input test needs. All 99 example locks are
regenerated as CI resolves them, without raylib.
2026-11-17 20:59:37 -03:00
waozi ae6f73b435 Decode Android scene textures with linked codecs 2026-11-17 19:59:25 -03:00
waozi 199b51c97c Configure the Vorbis archives under CMake 4
The hosts job's desktop Vorbis test stopped at configure: libvorbis
1.3.7 asks for CMake 2.8, and CMake 4 refuses compatibility below 3.5.
Pass CMAKE_POLICY_VERSION_MINIMUM=3.5 to that configure; earlier CMake
ignores the variable.

Local tests: under CMake 4.1.2 the configure fails without the floor and
passes with it, and make desktop-audio-vorbis-test passes with CMake 4
and with the host's 3.31.
2026-11-17 17:26:30 -03:00
waoziandClaude Opus 5.5 4923381c88 Load the pictures an Android app ships from its APK on first use
Android Frame apps draw through Pixmap, which found only pictures already
registered, so every file picture showed "Missing image". Pixmap now asks
an optional picture source the first time it measures or draws an
unregistered path, once per missing path until invalidation or host
cleanup. pixmap_assets_android registers a source that reads the APK asset
through AAssetManager and decodes it, and the Frame host imports it, as
desktop Cairo loads pictures on first use.

Tests: the Android image services test covers lazy loading, caching, the
single lookup per missing path, retry after invalidation and cleanup. A
new device suite decodes a framework PNG through Android's real
AssetManager inside its VM and compares it with an independent decode;
tests/android_vm_device_test.py now runs it and the typeface suite. Frame
host tests link the codecs that apps link.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-17 17:23:44 -03:00
waozi 22bc1353c1 Bind linked AVIF and WebP codecs under KRYON_AVIF_LINKED and KRYON_WEBP_LINKED
Desktop hosts decoded AVIF only through a loaded libkryonavif and WebP
only through the system libwebp. Built with KRYON_AVIF_LINKED, AvifInit
binds the avif package's static bridge to the libavif the program
links; built with KRYON_WEBP_LINKED, WebPInit binds webp_linked's table
of the program's libwebp and libwebpdemux. Neither loads a library.

avif_decode_test.sh builds linked_codecs_test with the static libavif,
libaom and libwebp archives and runs it where no libkryonavif exists. It
checks AVIF and WebP pixels from bytes and from files, and that neither
libkryonavif nor libwebp was mapped.

Local tests: the linked build passes; the same test built without the
two defines fails.
2026-11-17 17:11:38 -03:00
waozi da7f5755b1 Write assets given as bytes to temporary files on Windows
Fonts registered from bytes and pictures from a program's asset reader
became Linux in-memory files opened through /proc/self/fd, which MinGW
cannot link. cairo_assets now takes its files from asset_files_linux
(memfd, as before) or asset_files_windows, which writes each asset to a
file of its own in the user's temporary folder by an ASCII path and
removes it when it is closed or when the program exits.

windows_desktop_test.py runs a new Wine program, linked with -lws2_32,
that draws text in a font given as bytes, decodes a picture given as
bytes, calls Winsock's connect beside the image decoders, and leaves no
temporary files behind.

Local tests: the whole Windows desktop suite passes under Wine on a
private display, and the Linux desktop windows test still reads
embedded pictures and fonts from in-memory files.
2026-11-17 17:11:38 -03:00
waozi b97cc23b59 Keep the image decoders' GdkPixbuf slots private to their module
ziran_image_decode's loader slots were public C globals, and one was
named connect. A Windows program that links ws2_32 for its own sockets,
such as one using curl, met that symbol in place of Winsock's connect.
The slots are now file-scoped, so C gives them internal linkage, and the
signal slot is named signal_connect.

Local tests: the generated C declares static Connect signal_connect; the
GdkPixbuf decode test passes on Linux, and the new Wine assets test
(next commit) calls Winsock's connect beside the decoders.
2026-11-17 17:11:38 -03:00
waozi bda9e9d9a2 Add skinned scene surfaces and a portable watercolor material
kryon/scene_skin gives scenes indexed surfaces with four-influence
skinning that always deforms from bind data. kryon/watercolor samples real
paper and pigment bitmaps with soft light and a Fresnel rim, and its
finishing pass adds brush regions, paper grain, pigment pooling and pencil
contours while keeping alpha exact. Both run on the CPU renderer and the
translated GLES path. Desktop LoadImagePixels accepts an optional host path
resolver so bundled assets decode like disk images.
2026-11-17 16:49:39 -03:00
waozi 34f26c2523 Fix scene GPU linking for Android API 21
Use Android's default EGL display and preserve its current context without
importing desktop GLX or newer EGL platform entry points. Link EGL and GLESv3
through the shared Android CMake helper.

Add strict API21 NativeActivity link coverage for both ARM ABIs, rejecting
GLX/newer EGL symbols and requiring the real Android/EGL entry points.
Document the Android generation and link requirements.

Local tests: both-ABI NativeActivity links passed; build-queue -- make push-check
passed, including desktop host, gamepad, text-hook and pixmap GPU coverage.
2026-11-17 15:27:32 -03:00
waozi 455c364e76 Export the image placement rules apart from file pictures
kryon/image brings file pictures since 15c3a22e, so a program that
imports it links a host's ImageWidth and ImageHeight. Jungle's story
layout test uses only ImageFitBounds and ImagePreviewSource and no
longer linked. Export image_behavior for code that needs only the rules.

Local tests: a package consumer using kryon/image_behavior links and runs
without a host; the same program with kryon/image reproduces the
undefined ImageWidth and ImageHeight.
2026-11-17 14:46:23 -03:00
waozi 058e59ac85 Give the website's live-example phase the time CI needs
24b476c3 bounded this phase at 1200s. GitHub runners compile each of
the 101 sources in about 14s, about 24 minutes in all, so the bound
stopped correct runs partway through. Allow 2400s, and 45 minutes for
the Pages step; compile_ready still bounds each compile to 120s.

Local tests: make site-browser-test passed (this phase took 871s).
2026-11-17 14:46:23 -03:00
waozi 6e6f9660fb Mirror SDL3 comparison tiles from the picture's own origin
Since 2d608291 a negative source width mirrors the rectangle that
starts at x. The scene's {16, 0, -16, 16} therefore sampled beside its
16-pixel picture, and the SDL3 GPU renderer's image clip check failed.

Local tests: make sdl3-test passed on a private Xvfb.
2026-11-17 14:46:23 -03:00
waozi 037f464b5e Reuse a program's exported main in web program-entry builds
A program entry that exports main also got the generated
kryon_program_host main, so wasm-ld stopped at "duplicate symbol: main"
for the canvas page. Detect main's own #program_export and compile the
entry directly; an unexported main still gets the generated host. A zx
profile bundles the program's main since 0c6f138e, so the test checks
that bundle instead of a refusal.

Local tests: make program-entry-project-test passed (Window and Hello
canvas pages, desktop window, zx bundle).
2026-11-17 14:46:23 -03:00
waozi 5a8d214087 Pick the zx player's dead-code linker flag per platform
Apple ld rejects --gc-sections, so the macOS player link failed. Use
-dead_strip on Darwin, where the player links no X11, and keep
--gc-sections elsewhere. The display-free headless test runs only the
VM, so it no longer builds the desktop player first.

Local tests: the Darwin link line (make -n) has -dead_strip and no
--gc-sections, Linux keeps --gc-sections, and push-check passed.
2026-11-17 14:46:23 -03:00
waozi 635e1d3d03 Link hand-built test programs with libm
Ziran 2313b49c lowers std Sqrt to C sqrt(), so test scripts that link
generated C with cc directly stopped at "undefined reference to sqrt":
45 behavior tests in the check and sanitizer jobs. Add -lm to those link
lines and to the shared matrix helpers.

Local tests: all 45 failing scripts pass.
2026-11-17 14:46:23 -03:00
waoziandClaude Opus 5.5 e05146b3ba Host Android apps that run their own frame loop
kryon/android_runtime keeps NativeActivity lifecycle and input in the host
while the application's main owns its loop, widgets and pacing:
PollAndroidHost, BeginAndroidFrame and EndAndroidFrame present Pixmap's
device-pixel damage. The host calls the application's C main by symbol, so
generated C never declares main with Ziran's argument types. Pixmap's
RasterSetTransform and RasterPointFromPixels share one camera for painting
and input.

kryon/pixmap_assets_android decodes owned PNG, WebP and AVIF pictures on
first use, and kryon/pixmap_typefaces_android shapes text with Android Paint
and Canvas through the ordinary typeface_source capabilities.

The renderer-desktop artifact also builds Android ARMv7 and AArch64 codec
archives and the shared AVIF bridge, pinned to AVIF 2611e727.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-17 13:30:41 -03:00
waozi 0a86415bff Apply a followed palette to the active theme too
SystemPaletteApply installs a system palette as style rules and as the
active theme's colours, so code that draws from CurrentPalette() matches
the host as well as styled widgets. SystemPaletteUpdate applies a palette
only when it changed; SystemPaletteFollow in SystemThemeHostLinux and in
the portable SystemThemeHost feeds it each frame, so ZX apps such as
Harmony's Telegram follow a host's theme change with one call.

The parent-theme test checks CurrentPalette() after a followed change.
2026-11-17 11:43:53 -03:00
waozi 13ff9478a3 Expand a host's palette into a full theme palette
SystemTheme.SystemPaletteColors(palette) builds a complete theme Palette
from a system palette such as the one Harmony gives an embedded app: its
background, surface, text, accent and border, and surfaces, text levels,
borders, selection and controls mixed from them, so an app that draws
from a theme palette matches its host completely.

The parent-theme test checks the expanded palette after a host change.
2026-11-17 11:29:23 -03:00
waozi 81e337a6e0 Let embedded apps follow their host's theme with one call
SystemThemeHostLinux.SystemPaletteFollow() installs the current palette,
the host's while an app is embedded, the first time and again whenever
the host changes it, and returns true when it installed. An app that calls
it once per frame follows a theme change in Harmony's Sessions window
without colour code of its own.

The parent-theme test gains a follow scenario: one install, none while
unchanged, and one after each host change. Both theme tests now link libm,
which the style sheet code needs.
2026-11-17 11:17:35 -03:00
waozi a4817c9907 Use core Ziran audio for desktop and Android media playback
Use the platform-selected asynchronous std audio sink and core mixer,
remove the six moved Kryon audio modules and exports, and select their
published compiler and optional Opus package pins. Add actual Moto UI
PCM source/saved validation and retain deterministic device-failure tests.

Local tests: desktop PCM/MP3/Vorbis, Windows Wine host and audio,
Moto source/saved UI PCM, ziran check and push-check passed. The full
shared-tree test stopped at the separately owned Canvas program-entry
title/boot test; this commit has no program-entry or title changes.
2026-11-17 11:06:45 -03:00
waozi 2d608291a9 Mirror signed image sources and isolate invalid image draws 2026-11-17 01:24:17 -03:00
waozi 156cea179d Reconfigure codec archives when resolved package sources change 2026-11-17 01:23:23 -03:00
waozi a98f8bf12a Link the native Canvas event fixture with the math library 2026-11-17 01:22:27 -03:00
waozi a814f67710 Document and test headless image dimension bindings 2026-11-17 00:36:25 -03:00
waozi 78af409035 Present Android frame damage in device pixels 2026-11-17 00:31:30 -03:00
waozi 24b476c365 Bound website browser phases and Chrome request writes
Report each browser test phase and source example, interrupt blocked I/O, and bound the Pages test step. Verify deadlines with blocked read and full request pipe tests.
2026-11-17 00:27:52 -03:00
waozi 3f72441949 Build vendored codecs with CMake 4 2026-11-17 00:17:20 -03:00
waozi 14586a4b62 Update Ziran toolchain for Canvas record copies and portable images 2026-11-17 00:14:14 -03:00
waozi 028d42cb15 Provide native frame snapshots and desktop image services
Add exact/folder/all picture cache invalidation, shared oriented preview
pixels, and owned previous-frame snapshots for desktop and NativeActivity.
Keep alpha and row orientation through Image transitions, including negative
camera origins. Capture desktop frames after presentation and preserve Android
pixels until the route finishes composing. Web returns an invalid snapshot.

Local tests cover source/saved desktop and Android pixels, Windows/Wine
snapshots, native image previews, Canvas browser/Wasm, Android NDK host links,
frame transition behavior, bitmap ownership, and push-check.

Known upstream gap: published Ziran ebd19223 rejects the portable bitmap Image
test in PixmapGpuCorners with assembly.gap.machine-copy. Reproduced unchanged
on origin/master 216c190c: function 300, block 5978, instruction 27407.
The native C control passes. See plans/2026-11-16-remove-raylib.md.
2026-11-16 22:36:04 -03:00
waozi 216c190c43 Document only current Kryon APIs and website pages
Remove raylib paths, obsolete import and preview guidance, migration prose,
and orphaned documents/pages. Align widget imports, native ZX windows and
host contracts with the current implementation, and enforce current site routes.
2026-11-16 21:43:18 -03:00
waozi 0f5c68e162 Let Escape dismiss modals independently of outside clicks
Keep outside releases blocked by default while allowing Escape to close the top modal. Preserve dismiss_disabled as the explicit override for both routes, including through the portable widget host.
2026-11-16 21:40:47 -03:00
waozi 9052a642a0 Apply desktop camera offsets to Cairo painting and pixel snapping 2026-11-16 21:03:44 -03:00
waozi 66a11957b4 Use native desktop and Android hosts for window runtime 2026-11-16 20:50:54 -03:00
waozi 80cbbb3d14 Consolidate portable app tests on the desktop-host ZX player
Run the headless, media/HTTP, hosted-app and native interaction gates
through zx-player instead of the raylib player. Use the shared bundle
media and app lifecycles for packed resources, private documents, input
and scrolling. Play native bundle audio through the SDL mixer and the
package-owned codec archive. Separate normal completion from VM failure
and preserve candidate-media isolation during live reload.

Keep the raylib host modules and their own test target for the separate
deletion. Keep shared BundleApp byte APIs and desktop locale behavior.

Local tests: the four assigned ZX gates, source/saved VM and native
interaction, browser media and hosted apps, completion/trap status,
reload, zx2native window host, retained raylib player/media and
push-check passed through build-queue on private displays.

Owner-request: Waozi, 2026-11-16 (remove raylib dependencies)
2026-11-16 20:32:27 -03:00
waozi e2bac64b60 Use SDL and native image services throughout the shared hosts
Move Opus transport to the shared mixer and SDL sink, query SDL keyboard
focus, and decode/export encoded images without the raylib host. Give
the canvas host its own clip implementation and remove unused C ABI
exports in favor of direct canvas Files imports. Retain the public host
APIs and the raylib host modules for their separate deletion.

Local tests: native-image-services-test, desktop-audio-test,
image_dynamic_integration (source/saved IR, ASan/UBSan/leaks), background
image jobs, complete canvas-test, and push-check passed via build-queue.

Owner-request: Waozi, 2026-11-16 (remove raylib dependencies)
2026-11-16 20:32:27 -03:00
waozi 9a55dbbbc8 Port the SDL Cairo desktop host to Windows x86-64
Add Windows platform adapters, a pinned MinGW desktop renderer artifact,
and private Wine pixel/service/audio tests. Share raster and window code
while selecting native process and library-loading modules per OS.
Pin the public WebP native function-table export for dynamic decoding.

Local tests: windows-desktop-host-test, desktop-windows-test,
desktop-audio-test, native-text-test, native-accessibility-test,
image-pixels-test, pay-per-import-test and push-check passed. Strict
dynamic image source/saved IR passed ASan, UBSan and leak detection.

The stock frame-entry C pruning and Windows ZX external-host gaps remain
upstream in step 6. Full make test separately stops at ZX packed media.
This checkpoint does not include consumer ports or macOS builds.

Signed-off-by: Waozi <[email protected]>
2026-11-16 20:32:27 -03:00
waozi 03016057af Verify the shared Markdown editor across source and saved IR targets
Run the extracted Diary editor and preview through C, Go and ZX, including identical source and saved-IR bundles.

Local tests: markdown-editor-test full matrix and make push-check passed.
2026-11-16 19:53:49 -03:00
waozi 08f70214c3 Provide native codec archives independently of the raylib renderer
Move WebP/AVIF/AOM recipes into mk/codecs.mk and build Opus from the
package-owned audio recipe. Publish all four archives, licenses and the
lazy AVIF library through renderer-desktop. Keep the raylib host recipe
using the same codec targets until its separate deletion.

Local tests: codec-archives, renderer-consumer-test,
desktop-codec-artifact-test (real source/saved-IR AVIF/WebP/Opus), and
renderer-artifact-test including the retained native renderer on Xvfb.

Owner-request: Waozi, 2026-11-16 (remove raylib dependencies)
2026-11-16 19:47:52 -03:00
waozi 9a162223b5 Publish the NativeActivity app directly to shared JNI services
Keep GetAndroidApp inside the raylib host; native JNI uses native_app_glue startup and clears the app on shutdown. Exercise publication and cleanup with the source and saved-IR JNI thread tests.

Owner-request: Waozi, 2026-11-16 (remove raylib dependencies)
2026-11-16 19:47:52 -03:00
waozi 0c6f138e31 Show a program's ZX window in the browser through the canvas player
A program entry (one that declares main) was refused in any profile but
codegen c99, so window.zi's ZX could not run in a page. A codegen = "zx"
profile now bundles the program's own main with portable IR, which
kryon/app gives the zx_window window; no generated program host is made.

In the page the ZX canvas player runs such a bundle through
window_page_player.zi: it binds zx_window's five capabilities to the page's
canvas with page_core, as page_window does for a C program, lowers the
bundle to Wasm in the page and runs main until the page closes. Each wait
for an event sleeps, which yields to the page, so the program's own loop
never blocks it. zx_window_bundle.zi holds the capability check both
players use. The editor's Wasm platform opens window.zi this way, and its
browser test checks that the page's canvas is cleared to the frame colour.
2026-11-16 19:47:52 -03:00
waozi f10e551f6c Ship the desktop window as a host library zx2native links
window.zi's bundle asks its host for five zx_window capabilities. The
desktop zx player binds them in-process for `ziran run`, but a native
executable from zx2native had no host to call, so the editor's Native
Assembly and Binary stopped at assembly.gap.machine-host.

zx_window_host.zi exports the five capabilities with the C ABI the C
target gives zx_window's declarations, over the same desktop_window SDL
window. `make zx-window-host` builds build/lib/libkryon-desktop.so from it
alone, and `make install-user` installs it to ~/.local/lib/kryon and
registers ~/.local/share/ziran/hosts/kryon-desktop.library, so zx2native
links window.zx into a Linux executable that opens its 320x160 "Window"
in the empty frame's colour and exits 0 when it closes.

zx_window_test runs both routes on a private Xvfb, the player through
`ziran run` and the executable directly, and checks that with no library
registered zx2native stops at the gap naming ZxWindowOpenHost.
2026-11-16 19:47:52 -03:00
waozi f123e8ba3e Release Kryon 0.4.0
Kryon builds with Ziran 0.6.0 and runs its widgets natively 121–185× faster, programs carry only the features they use, widgets are imported by package, portable apps run their window from a bundle, and the Linux desktop host gains audio and a raylib-free window path; the changelog section lists what users get. update_version.sh set VERSION from the new section.
2026-11-16 18:44:12 -03:00
waozi bde4614ede Regenerate the media audio codec and deploy newly bundled site assets
The codec generator names hosted records by their defining package since 9ca2e673, but src/backend/media_audio_codec.zi was not regenerated, so media_audio_test's --check stopped the hosts shard. The website's staging step copied only tracked docs/site files, so a freshly built runtime asset (asset-13.bin once the mascot joined the gallery assets) was never deployed and the Website check could not find pfp.webp; it now also stages every asset the build's runtime/assets.json lists.
2026-11-16 18:02:26 -03:00
waozi 1b290f19aa Build with Ziran 0.6.0
Pin the root package and the box, gallery and image examples to the Ziran v0.6.0 release commit d17c7aa1 (by commit, since ziran lock records an annotated tag's object rather than its commit). The gallery lock is regenerated: it pinned image-codec and webp at their master commits while webp declares image-codec 3605531, so ziran pkg path plot --locked failed and the website build stopped.
2026-11-16 17:13:25 -03:00
waozi 9ca2e6731b Preserve canonical hosted record identity across package boundaries
Describe nominal host types with their defining module and generate widget
wire names from the same declaration identity. Match package-qualified
records and slices through the shared hosted-value matcher, retaining
module and package mismatch rejection.

Add a separate package-consumer host regression and negative identity
cases. Pin the canonical type producer from Ziran.

Local tests: widget host, widget codec, component host, and all six hosted
tests pass. Ziran portable records, slices, arrays, capabilities, payloads,
web lifecycle and bootstrap checks pass. Broader checks have unrelated
shared-checkout failures reported separately.

Reported-by: Breeze task codex-breeze-breeze-crash-recovery-ui
2026-11-16 16:42:28 -03:00
waozi 77184e46c5 Export shared Markdown preview and editor
Expose byte-preserving Markdown formatting and TextArea composition as optional
package imports for Breeze Diary. Wire native and portable editor behavior
coverage into make test and test-focus, and document the public surface.

Signed-off-by: Waozi <[email protected]>
2026-11-16 16:38:49 -03:00
waoziandClaude Opus 5.5 7db0aef222 Keep the vendored-raylib path out of the raylib removal plan
source-check rejects the literal path anywhere in the tree.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 16:34:35 -03:00
waozi c10a6025bc Plan removing raylib from Kryon 2026-11-16 15:38:18 -03:00
waoziandClaude Haiku 5.5 17de1e4bfc Drop unused text input import from the toast test driver
ziran_test_driver_host imports text_input_platform_host but never uses it.
After the pay-per-import split the toast scratch project fails ziran ir
because that module is not in its package root. A toast has no editable
text, so the driver does not need text input; remove the import.

Co-Authored-By: Claude Haiku 5.5 <[email protected]>
2026-11-16 14:20:22 -03:00
waozi ce0d49e633 Give the toast action test's project the text input host its driver imports
tests/ziran_test_driver_host.zi imports text_input_platform_host, but the test copied only itself and the driver host into its scratch project, so ziran ir --project failed once the hosts shard reached it.
2026-11-16 14:19:47 -03:00
waozi c23c628597 Run the file-date test's builds directly where build-queue is absent
Like the GTK scroll test, tests/file_date_linux_test.py wrapped its compiler calls in build-queue, which CI runners do not have; it now uses build-queue only when it is installed.
2026-11-16 13:22:57 -03:00
waozi d6750c36f2 Run the GTK scroll test's builds directly where build-queue is absent
tests/gtk_scroll_linux_test.py wrapped its compiler calls in build-queue, which only the developer machines have, so the hosts shard failed with "No such file or directory: 'build-queue'" once it got that far. It now uses build-queue only when it is installed.
2026-11-16 12:37:38 -03:00
waozi baa0e60768 Stub SDL_SetHint in the raylib window probe and wait for site reloads
raylib-window-test links neither raylib nor SDL: tests/raylib_window_host.zi
stands in for raylib's SDL platform and already exports the SDL calls the
Linux host makes. 631f15e7 had OpenRaylib set SDL_SetHint, which the
probe lacked, so the test no longer linked. The probe now counts requests
for a linear framebuffer made before a window opens, and the test checks
OpenRaylib makes one on Linux and none on Windows or macOS. raylib_runtime
is unchanged: on Linux Kryon always builds raylib's PLATFORM_DESKTOP_SDL,
and the hint shares the platform branch of the host's other SDL calls.

site_browser_test reloaded the page and evaluated Module straight away.
Page.reload answers before the new document has run current.js, so on a
slow runner the evaluation reached a document without Module and threw
"ReferenceError: Module is not defined"; the failure screenshot of the
half-loaded page then read as blank paint. With current.js served 300 ms
late, that sequence failed 10 times in 10. Browser.reload marks the old
document and waits for an unmarked one to finish loading, as open does
after a navigation.
2026-11-16 11:54:14 -03:00
waozi 6425728b02 Give embedded apps their host's theme by default
An app that Harmony embeds now draws in Harmony's theme without code of
its own. SystemThemeLinux.SystemPaletteRead returns the palette the host
keeps on the window it embeds the app in, after checking that the named
host is the app's parent and owns that window, and reads it again on each
call so an app that reads it follows a theme change. Started on its own,
an app gets the desktop's GTK palette as before.

The reader moves out of SystemThemeHostLinux into ParentThemeLinux, which
SystemThemeHostLinux now reuses. It loads libX11 at run time and only when
a host is named, so apps that are never embedded, and Windows, Android and
web builds, need no X11.

A Ziran test plays the host on a private X display: the hosted palette is
returned and followed, an unknown version is ignored, and a host that is
not the app's parent gives no theme.
2026-11-16 11:34:44 -03:00
waoziandClaude Haiku 5.5 b45cc52456 Tests: stop the GPUI benchmark project test depending on host libxkbcommon
test_generated_project_uses_disposable_paths_and_xkb_sysroot now points
XKB_LIBRARY at a scratch fixture file, so it no longer needs
/usr/lib/x86_64-linux-gnu/libxkbcommon-x11.so.0. A new case checks that
write_project() rejects a missing library with a clear error.

Co-Authored-By: Claude Haiku 5.5 <[email protected]>
2026-11-16 11:02:04 -03:00
waozi 631f15e715 Ask SDL for a linear framebuffer and wait for the ZX window's first frame
The hosted native ZX test read (244,96,110) where its picture is
(230,30,40), and (252,253,254) for the 0xf8fafc background: the whole
window had been sRGB-encoded a second time. That gate ran with a private
SDK whose libSDL2 is sdl2-compat on SDL 3.4.2. SDL 3 gave raylib's
OpenGL ES context an sRGB-capable framebuffer, and Mesa encodes every
write to one. The system SDL 2 picks a linear visual, so the same player
drew exact colours without the SDK. OpenRaylib now sets
SDL_OPENGL_FORCE_SRGB_FRAMEBUFFER=0 before InitWindow; SDL 3 then
requests a linear framebuffer and turns GL_FRAMEBUFFER_SRGB off, and
classic SDL 2 ignores the hint. Under that SDK the test finds the exact
colours again.

zx_window_test captured the window right after it mapped and sometimes
read X's black contents before the player presented its first frame. It
now waits up to 10 s for the presented frame and keeps the exact
single-colour assertion; the corner pixel is checked before the colour
count, so the wait does not build a 2 MB table every 20 ms.
2026-11-16 10:31:04 -03:00
waozi 3982886e04 Stop binding picture sizes in the toast action bundle
Since 15c3a22e a toast no longer reaches pictures, so its bundle has no
image_raster:ImageWidth or ImageHeight capability, and binding them failed
("host capability or exported Ziran provider is missing or already
bound"), failing toast-action-test in the hosts shard. The bundle binds
only what the toast uses.
2026-11-16 10:18:12 -03:00
waozi 3c09a1ecd7 Import only Image's props in the bitmap host policy test
Since 15c3a22e kryon/image is image_files, which brings the file-picture
decoder and its ImageWidth and ImageHeight host capabilities. The bitmap
host policy test only names Image.Props, and its build has no picture
host, so it failed to link ("undefined reference to `ImageWidth'") and
bitmap-image-test failed. It imports kryon/image_props, as props-only code
does.
2026-11-16 10:00:31 -03:00
waozi ec72e936cd Ask the canvas Lanczos test's pictures for their size first
Since 9b551b59 a page makes smooth copies of file pictures only once it
asks a picture's size, as every widget that draws one does first and as
the desktop already did. tests/canvas_lanczos_test.zi drew its pictures
without asking, so no copy started and lanczos-goldens-test failed with
"Canvas Lanczos page: FAIL 20". It now asks each picture's width first.
2026-11-16 09:21:12 -03:00
waozi 7491afa4c0 Build the pay-per-import frame examples against this checkout
pay-per-import-test built examples/box, button, image and textfield in
place, so it used their locks, which pin a published Kryon, or whatever a
developer's ziran.local.toml says. On a plain clone the locks did not match
this checkout's manifest ("declares image_codec ... but lock pins ..."),
and CI passed only because a CI step writes overrides into the examples.
The test now copies each example into build/test/pay-per-import/examples
with its own ziran.local.toml pointing kryon at this checkout and ziran at
the running toolchain, locks the copy and builds it there. The real
examples, their locks and any developer overrides are untouched.
2026-11-16 09:17:07 -03:00
waozi cd7bf21f38 Run the Canvas site's browser test in CI instead of the removed gallery test
9ce47851 replaced make site-gallery-test with site-browser-test, but the site shard still called the removed target after building the site.
2026-11-16 09:14:06 -03:00
waozi 24ff9e710a List the Wasm tier's call import for the document storage page
The browser document storage page runs its hosted guest on Ziran's Wasm
tier, whose zx_wasm_web_call import unwinds through the page's stack. The
page links with ASYNCIFY and ASSERTIONS, and the import was not in
ASYNCIFY_IMPORTS, so the hosts shard aborted with "import zx_wasm_web_call
was not in ASYNCIFY_IMPORTS, but changed the state". It is now listed.
2026-11-16 08:19:07 -03:00
waozi 4e7513041e Wait for the program entry window's name
The desktop check read the name of the first window xdotool found for the
program and stopped. SDL sets the title just after creating the window, so
a search between the two read '' and the web shard failed with "expected
the program's window title, got ''". The check now keeps looking until a
window of the program has a name.
2026-11-16 08:19:07 -03:00
waozi 80fa9a73ac Resolve the gallery module test's imports through package exports
tests/gallery_modules_test.py gave the compiler kryon=src/ui and
kryon=src/backend, so the generated usage modules' imports such as
kryon/button (src/ui/button/button.zi) and kryon/button_group
(buttongroup/buttongroup.zi) were not found and the site shard failed.
Every configured package, Kryon included, now gets each manifest module
root plus the export alias modules gallery.export_aliases writes, which
import the sources through <package>_source.
2026-11-16 08:19:07 -03:00
waozi 5d836703e9 Give the Android test JNIEnvs a DeleteLocalRef
e9017b29 made the activity method lookup release its class reference, and
the fake JNIEnvs in android_device_host.zi (also used by the text editor
test) and android_picker_behavior.zi had no DeleteLocalRef, so the
device, picker and text editor tests called a null function (exit 139;
ASan "SEGV on unknown address 0x0"). Both fakes now have one.
2026-11-16 08:07:45 -03:00
waozi 7742251bb4 Scroll what is under the wheel on the web
The canvas host's wheel event forwarded only its deltas, so the wheel went
to wherever the pointer last moved. A wheel turned without a move first,
as after clicking into the live editor, scrolled the editor instead of the
page under the wheel, and site_browser_test's overflow preview check timed
out with "overflow preview article scroll". The wheel now delivers its
own position as a pointer move before its deltas.
2026-11-16 07:56:28 -03:00
waozi e9017b29d0 Treat an Android activity's missing optional method as absent
On a Java-free NativeActivity, Kryon's optional callbacks
(onNativeFirstFrame, setTextInputState, setSoftKeyboardVisible) do not
exist. AndroidJniMethod returned GetMethodID's null with the
NoSuchMethodError still pending, and the host thread now keeps its JNIEnv
across frames, so later JNI calls in the session ran with that exception.
The lookup now clears the exception it caused and releases the class
reference it took; AndroidJniCallVoid releases its string argument.
Exceptions that Java methods throw still make the call report failure and
are still described and cleared at detach.

tests/android_jni_threads_test.zi's fake JNIEnv now tracks pending
exceptions and local references, and checks all three absent methods, a
present call and a throwing one.
2026-11-16 07:17:03 -03:00
waoziandClaude Sonnet 5.5 7cae309044 Accept package-qualified slice types at the widget host boundary
One shared WidgetHostSliceValid check, built on HostTypeValid, replaces the
six strict per-widget slice checks.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-16 07:12:56 -03:00
waozi d549f3edbe Leave the cursor picture decoder out of the live editor's preview
The preview entry imported kryon/cursor, the public cursor API that
registers the host's picture-cursor decoder, so every compiled preview
asked for CursorPictureHost and the website refused it ("Unavailable
preview capability: CursorPictureHost"). The preview only reports
TreeCursor's kind to the page, which kryon/tree_input already gives it.
2026-11-16 07:12:12 -03:00
waozi 928cf64d7b Read the gallery's hold and confirm state through site.zi
The gallery's web build failed with "unknown record field: progress" and
"armed" in web.zi. web.zi reads site.zi's site_hold and site_confirm
through `using Site`, and their types name site.zi's module aliases
(HoldButton.HoldButtonState, ConfirmButton.ConfirmButtonState), which the
checker resolves in web.zi, where those aliases do not exist. site.zi now
exposes SiteHoldProgress and SiteConfirmArmed, and web.zi calls them.
2026-11-16 07:12:12 -03:00
waozi 8b127a0911 Accept either rounding of the AVIF test's half-transparent preview
The hosts shard's new report shows the 1x1 preview as RGBA 0 0 255 127 on
CI, where this machine gives 128. Half of the 2x1 source is transparent,
so the Lanczos alpha is exactly 127.5 and a last-bit difference in the
filter sums rounds it either way. The check now accepts 127 or 128; the
colour bytes stay exact.
2026-11-16 06:44:38 -03:00
waozi 640b4e3dac Stop running the removed DOM live-editor browser test in CI
74eb8fbb deleted tests/demo_browser.mjs: demo.html now redirects to the Canvas widgets page, whose editor make site-browser-test covers. The web shard's step that ran it is removed.
2026-11-16 06:15:55 -03:00
waozi 860ea80793 Keep the backpressure test's Xvfb from resetting between windows
CI's sanitize shard failed this test on a reopen after CloseDesktop (exits
30, 33, 40, 61, 80 and 101). With the open failure now reported, the CI log
at 9401f34f shows SDL_Init failing with "x11 not available": closing the
window disconnected Xvfb's last client, Xvfb reset, and the reopen's
connection landed in the reset. A desktop's X server never resets that way,
so the test runs its Xvfb with -noreset, as ziran_window_visible_test.sh
and mime_clipboard_linux_test.py already do.
2026-11-16 05:57:07 -03:00
waozi caa900714f Report the AVIF test's 1x1 preview when it fails
CI's hosts shard fails tests/image_avif_zi_test.sh with exit 4 and nothing
else, on the locked avif f26a5522 and Ziran v0.5.0; the same locked graph
passes here with gcc 14 and clang 19. Exit 4 covers an unsuccessful preview,
its size and its pixels. The 2-to-1 Lanczos alpha is exactly 127.5 here, so
one rounding step decides 127 or 128. The check now prints the preview's
error, or its size and RGBA bytes, so the next failing run shows which.
2026-11-16 05:43:56 -03:00
waozi 158fd91d5a Export kryon/tree_frame for programs with their own desktop host
A program that runs DesktopLoop.Run with its own host imports
kryon/tree_frame and calls TreeFrameUse() so the widget tree runs each
frame. The test driver's pointer and wheel now apply once, in the frame
driver, instead of also in the desktop loop.
2026-11-16 05:42:19 -03:00
waozi 74eb8fbb43 Remove the browser test of the removed DOM live editor
tests/demo_browser.mjs drove the DOM live editor at demo.html: its
#status line, iframe embeds and homepage link. The Canvas website redesign
made demo.html a redirect to the canvas widgets.html page, and 9ce47851
removed the matching gallery_browser.mjs, but this test stayed, so it
waited 25 seconds for an element that no page has and failed with
"Default source did not render" (state {}). Rebuilding the committed
playground runtime does not change that. tests/site_browser_test.py
(make site-browser-test) covers the Canvas site's editor compilation.
2026-11-16 05:33:16 -03:00
waoziandClaude Sonnet 5.5 cc731751ac Give hosted bundles kryon/layout and kryon/toolbar's behavior and props
layout.zi and toolbar.zi imported the retained tree, session and paint
queue unconditionally, so a KRYON_HOSTED_UI bundle importing them failed.
Their retained halves now sit in the non-hosted branch, as menu.zi does;
the behavior and props stay available. pay-per-import-test bundles a
hosted program using both and checks it carries only layout_behavior and
toolbar_behavior. The retained examples' generated C differs only in
include and init order.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-16 05:32:09 -03:00
waoziandClaude Sonnet 5.5 32fce42d4f Repin the gallery's DataViews to the package-qualified Kryon imports
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-16 05:29:44 -03:00
waozi 9401f34f66 Say why the desktop window could not open
OpenDesktopTitled returned false from five places without a word, so CI's
ziran_desktop_input_backpressure_test.sh failed a reopen with only its
exit code (30, 33, 40, 61, 80 or 101) and nothing to say which step or
why. Each failure now writes the step (starting SDL video, creating the
SDL window, renderer or texture, or the Cairo surface) and SDL_GetError()
to standard error.
2026-11-16 05:17:44 -03:00
waozi 3744b2a401 Drag a TextField test selection to a caret inside the text
The drag selection test dragged to x=110, past the end of "abcdefghij" with
the test host's 7-pixel glyphs, so its Shift+Right step started at the end of
the text and could not move. It now drags to x=80, leaving the caret inside
the text so Shift+Right extends it by one.
2026-11-16 04:48:24 -03:00
waozi 245605c359 Fix the macOS runtime headers, the drag test's Xlib and the gallery's Plot pin
- mk/zx-raylib.mk generated Darwin private-symbol headers for a vm group
  whose header Ziran 0.5.0 removed with its old VM; Ziran's build uses
  only parse, check and emit.
- The hosts shard runs drag_source_linux_test.py, which needs python3-xlib.
- The gallery's lock pinned Plot 3f888653, which still imported the removed
  kryon/Kryon facade, so the site and Pages web builds failed; `ziran
  update plot` moves it to Plot's current master with its dependencies.
2026-11-16 04:42:03 -03:00
waoziandClaude Opus 5.5 ac209b9ea7 Give hosted bundles kryon/menu's props, types and state alone
menu.zi imported the retained tree, tree input and paint queue
unconditionally, so a KRYON_HOSTED_UI bundle that imports kryon/menu
for its MenuItem, MenuGroup, Props and MenuState failed on TreeNextKey,
TreePrevious and the rest. The retained menu bar now sits in the
non-hosted branch; a hosted bundle carries only menu_props.

pay-per-import-test bundles a hosted program using the menu's types
and checks it carries exactly its own module and menu_props and asks
its host for nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 04:16:51 -03:00
waozi 9c80f79110 Build Android runtimes with the host zi2c
build_android_runtime.py ran Ziran's make with the NDK compiler and no
GEN_ZI2C, so the generated-C step would run a zi2c built for the device.
It now passes the pinned toolchain's build/bin/zi2c, which the Android
CMake already requires. The ZX player APK builds for all three ABIs and
runs app.zx natively on the Moto (armeabi-v7a).
2026-11-16 04:10:17 -03:00
waozi d00b148f21 Build with Ziran 0.5.0 and fix the raylib pixel test and example overrides
The toolchain moves from e813c847 to Ziran v0.5.0 (f9f92b46) in Kryon and
the box, gallery and image examples, locked with `ziran lock`. 0.5.0
builds on macOS again and its browser playground builds, which Kryon's
macOS job, site build and Pages preview need.

tests/android_frame_pixels_test.zi sizes its pbuffer surface through
raylib's CORE.Window record, whose overlay left android_surface.zi on
Nov 10; the test now declares the overlay it uses.

The pay-per-import test builds examples/button and examples/textfield as
applications of this checkout, so CI gives them the same overrides as box,
image and gallery.
2026-11-16 04:08:05 -03:00
waoziandClaude Opus 5.5 eeeeb10c06 Stop listing the Makefile as a renderer artifact input
The renderer and SDL3 providers never read Kryon's top-level Makefile, and
Ziran refuses to publish an artifact whose inputs change while it builds.
Any edit to the Makefile during a downstream build under a local Kryon
override therefore failed that project's native link. A consumer test now
checks each recipe's inputs against the make fragments its provider reads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 03:29:40 -03:00
waozi 4e5de9fef1 Stream Ogg Vorbis through the desktop mixer
audio_decode_vorbis adds Ogg Vorbis to audio_mixer by import, streamed at
the stream's own rate through audio/vorbis, which audio ce5837f8 adds over a
pinned stb_vorbis; Kryon now pins that audio commit. make builds the audio
package's libziran_vorbis.a for the programs that link it.
tests/desktop_audio_vorbis_test.zi checks the mixer's frames against
audio/vorbis's own decode of the package's fixtures, a 22.05 kHz stream's
length at 48 kHz, and a Vorbis clip through Kryon's asset audio.
2026-11-16 03:03:19 -03:00
waozi f4cd71a580 Open App.Show's window from a portable bundle
A ZX build of kryon/app shows its window through zx_window: five host
capabilities (open, next event, clear, present, close) and the bundle's
own loop until the window closes. window.zi's bundle is window, app and
zx_window, with no frame, font or text code. The desktop zx player binds
those capabilities to desktop_window, now split into the same SDL steps,
and runs the bundle's main as native code with no engine fallback, so
`ziran run window.zx` opens one 320x160 "Window" in the empty frame's
colour and exits 0 when it closes.

make zx-window-test checks that on a private Xvfb; make
pay-per-import-test checks the bundle's exact modules and host
capabilities and its checked program.
2026-11-16 02:50:22 -03:00
waozi 28424a846d Let portable apps show pictures they make at run time
A zx bundle's kryon/bitmap_image now asks its player to create, update and
release the picture (kryon build defines KRYON_ZX for zx profiles), and the
desktop zx player keeps it in its own bitmap store for the session it runs,
so its raster draws it like any other image. Before, a bundle's runtime
texture was unknown to the player and the frame failed.
2026-11-16 02:40:58 -03:00
waozi 3461b49b86 Let a page's canvas show what is behind it
A #canvas carrying data-transparent gets no background: the empty window
and each Kryon frame clear to alpha 0 with clearRect, so the editor
preview shows its theme wherever a program draws nothing. Widgets draw
over it as usual. Pages without the attribute stay opaque.

The program-entry test checks window.zi's page and examples/hello.zi
both ways.
2026-11-16 02:20:00 -03:00
waozi 069f4c6c26 Stream MP3 through the desktop mixer
audio_decode_mp3 adds MP3 and MPEG Layer I and II audio to audio_mixer by
import, streamed at the stream's own rate through audio/mp3, which audio
5ea3f6f1 adds over a pinned dr_mp3; Kryon now pins that audio commit. make
builds the audio package's libziran_mp3.a for the programs that link it.
A stream's last frame now plays before it finishes.
tests/desktop_audio_mp3_test.zi checks the mixer's frames against
audio/mp3's own decode of the package's fixtures, a 44.1 kHz stream's
length at 48 kHz, and an MP3 asset through Kryon's asset audio.
2026-11-16 02:16:41 -03:00
waozi 0dea8bc28b Mix and play audio on the desktop host without raylib
audio_mixer mixes sounds decoded whole, music decoded while it plays and
PCM streams into 48 kHz float32 stereo, with gain, pitch, loops, pause and
a tap on every mixed block. audio_sink_sdl plays it from SDL2's audio
thread; audio_decode_opus (streamed through audio/opus) and audio_decode_wav
add formats by import; media_audio_desktop runs kryon/media_audio on it.
tests/desktop_audio_test.zi renders into its own buffer and plays through
SDL's disk driver, with no audio device.
2026-11-16 01:30:57 -03:00
waozi 1b8e50bc5b Run an app's own windows, input and raster on the desktop host
The Linux desktop host routes each SDL event to the window it names and
reports the sideways wheel. New optional modules, each linked only by the
programs that import it: desktop_keyboard (held, pressed, repeated and
released keys), desktop_window_state (minimize, maximize, restore, raise,
always on top, monitor bounds and display scale), desktop_secondary_window
(more windows with their own Cairo surface, presenter and events, with the
raylib_secondary_window calls), and cairo_assets (embedded pictures decoded
from memory), cairo_typefaces (typeface_source on Pango and fontconfig) and
cairo_render_scale. tests/desktop_windows_test.zi drives them on a private
Xvfb with XTest input.
2026-11-16 01:30:27 -03:00
waoziandClaude Opus 5.5 a3df0f3acc Keep a TextField's drag selection on release
A drag's release also counts as an activation, and TextFieldCore placed the
anchor on every activation, so a selection made by dragging collapsed to a
caret when the pointer came up. The press places the anchor; a release keeps
it, so a click (released where it pressed) still places a caret, and an
activation without a release still places it too. Numeric fields keep
selecting their whole number on the focusing tap.

tests/ziran_text_field_widget_test.zi checks a held and released drag, a
click in one frame and over two, the same in a secure field, and Shift+Right
after them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 01:24:20 -03:00
waoziandClaude Sonnet 5.5 cbbeb1fd54 Accept local-override dependencies in renderer artifact builds
pkg path validates a local development identity itself; only locked builds
must match the provider edge's exact commit.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-16 01:14:29 -03:00
waoziandClaude Opus 5.5 9b551b591d Let web pages carry only what they draw
The Canvas host registered nothing on first use: every frame pumped Lanczos
copies, the window reset meshes and copies, an evicted asset forgot its
copies, and the host polled the test driver directly, so even a box carried
the Lanczos cache, the resampler, page meshes and the test driver. Now the
first smooth copy registers the pump, close and forget (canvas_window), the
first warped picture registers its mesh batches, smooth copies are reachable
only once a page asks a picture's size (as on the desktop), and test input
comes through the frame driver. canvas_raster and page_mesh drop their unused
image imports.

Paint queues warped pictures through their own emitter, so no host links its
mesh rasterizer for a program that warps none.

Web profile (C files, C bytes, page bytes), before -> after:
box 74, 990 402, 1 388 955 -> 70, 828 685, 1 346 817
button 85, 1 238 728, 1 598 206 -> 79, 969 324, 1 487 512
hello checked modules 84 -> 80; an empty window stays at 10.
make pay-per-import-test checks the web window, hello, box, button and
image next to the desktop cases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 00:47:27 -03:00
waozi 83c24cdba6 Pin avif to the commit with its encode and preview modules
Image previews import avif/encode and avif/preview, which the pinned avif
f84c1625 did not export, so builds from the pinned packages failed. avif
f26a5522 publishes them.
2026-11-16 00:29:14 -03:00
waoziandClaude Opus 5.5 15c3a22e43 Bring pictures, text input and scroll devices only with the widgets that use them
The desktop rasterizer loads, decodes and smooth-copies file pictures once
a program first asks a picture's size, which every widget that draws one
does first, so vector icons and managed pixels draw without decoders,
threads or asset paths. LanczosSnap is geometry's RectangleSnap, so a
texture draw no longer reaches the Lanczos cache.

A button reaches file pictures and atlas icons through the new
image_lookup. kryon/image is now image_files, which re-exports the Image
widget (image) and fills the pictures; kryon/icon fills the atlas. Library
code imports image itself, so importing a picture-capable widget registers
nothing. Navigation, copy and confirm buttons and the widget host fill the
lookup where they draw, as they reached pictures before. Props modules that
only name Image.Props import image_props, now also exported; unused image
imports are gone.

The frame and the accessibility host reach text requests and editor focus
through text_editing, which text_request and text_input_platform fill, and
the frame samples scrolls through scroll_sampling, which scroll_device
fills.

Desktop examples (C files, C bytes, executable), before -> after:
button 96, 1 411 582, 448 264 -> 70, 980 794, 342 016
text 95, 1 445 077, 462 504 -> 71, 1 020 207, 356 472
textfield 107, 1 580 157, 514 496 -> 84, 1 166 840, 409 840
make pay-per-import-test checks button and textfield; tests whose programs
no longer reach pictures lose their picture bindings and stubs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 23:10:23 -03:00
waozi 389bf25e17 Retry backpressured test-driver keys 2026-11-15 22:18:55 -03:00
waozi 1ecc01791a Halve the changelog
Every version keeps its heading and date; entries say what changed for a
Kryon user without file counts, test names or rationale.
2026-11-15 21:55:47 -03:00
waozi b223f2c1cc Keep a bare window's checked program to the window
kryon/app imports each platform's window (desktop_window, the new
page_window) and frame loop (frames_desktop, frames_web) as separate
modules. A program that only calls App.Show now checks seven modules on
Linux instead of ten: no session, geometry, desktop runtime or frame host.
desktop_window takes the SDL event from the new sdl_event module rather
than the whole desktop runtime, and the frame loops import app_types by
name so an unrun loop leaves no stub in the checked program.

make pay-per-import-test checks window.zi's exact checked program.
2026-11-15 21:55:30 -03:00
waozi 2b7023eb8e Name the text size field in the chart and table examples 2026-11-15 20:44:30 -03:00
waoziandClaude Opus 5.5 9c49ec1d12 Export the window module as kryon/window
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 20:36:56 -03:00
waoziandClaude Opus 5.5 3d82bf36f2 Feed test-driver pointer, wheel and input through the desktop and raylib loops
The desktop frame loop applies the frame driver's test pointer, wheel and
input hooks, and raylib checks synthetic pointer frames against the app's
live session.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 20:36:56 -03:00
waoziandClaude Opus 5.5 4108c80a6b Find Kryon's locked edges under a local override, and keep test-driver builds from rebuilding artifacts
The renderer artifact build looks up Kryon's locked dependencies through the
root's edge when a local override changes its package ID. Selecting the test
driver no longer changes dependency artifact identities.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 20:36:56 -03:00
waoziandClaude Opus 5.5 eda083bd73 Keep shadows of objects hidden from the camera
A node hidden with SetVisible still casts its shadow when SetShadows enables
it; shadow maps no longer skip nodes the camera doesn't show.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 20:36:56 -03:00
waoziandClaude Opus 5.5 c5c1122ae2 Measure every example's generated C against its imports
Record per-example C files, C and header bytes and executable sizes for
all 101 examples, the before/after table, and the modules frame examples
carry without importing them (pictures, text input, gamepad navigation).
The plan keeps only the open steps.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 20:01:35 -03:00
waoziandClaude Opus 5.5 277b31162f Build with the Ziran that lowers long-named host records, and test in-tree examples from this checkout
Ziran 93a54f08 kept only the first eight characters of a host import's
record type when lowering to ZX, so --project bundles of hosted widgets
(TileMapResult, ActionModalResult, BundleInput, ...) failed with "this
type has no portable lowered representation yet". Ziran 94355db4 keeps
whole names; the toolchain pin moves to e813c847, current master.

CI built examples/box, examples/image and examples/gallery from the
Kryon their locks pinned, not from the checkout under test: box and
image pinned an image-codec that their locked Kryon no longer declared,
and the gallery's Kryon lacked kryon/box. CI now gives these examples
the same overrides ziran.local.toml gives them locally, as the Pages
workflow already does, and their locks name current Kryon and the same
Ziran.

The notification host test reads std/file.zi from the Ziran its package
graph resolves rather than ZIRAN_ROOT, which CI checks out separately.
The secondary raylib window test links XTest, so the desktop hosts job
installs libxtst-dev. The renderer artifact test builds its consumer
apps with Kryon's Ziran pin: Ziran v0.4.2 cannot read Kryon's current
ziran.toml.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 19:01:52 -03:00
waozi 0fbdc93884 Show a bare window through its own small loop
App.Show(window) on the desktop no longer runs the frame loop: a new
desktop_window module opens the SDL window, waits for its events, clears
and presents it, and closes it. examples/window.zi now reaches only the
program, kryon/app, the desktop app host, that loop, the SDL presenter and
C strings; its executable is 17 KB instead of 118 KB (265 KB before this
work), with none of the desktop runtime, raster, sessions, input or
accessibility. The window still opens centered, titled, resizable, in the
empty frame's colour, redraws when exposed or resized and exits 0 when
closed or terminated.

make pay-per-import-test now checks that the window carries none of the
frame loop, desktop runtime, raster, accessibility, session or input
modules either.
2026-11-15 16:46:11 -03:00
waoziandClaude Opus 5.5 cad98ae6a4 Carry only the code a program imports and uses
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 16:42:38 -03:00
waozi ba0d3950d3 Let an empty window carry only the window, its events and presenting
Nothing is imported by default. App.Show(window) shows a window without
frames; examples/window.zi uses it and now compiles to 23 C files and
133 KB instead of 62 and 546 KB, with a 118 KB executable instead of 265 KB.

Hosts that run frames (App.Run(window, Draw) and the frame host
desktop_run) call TreeFrameUse() to register the widget tree's frame driver
(tree_frame, through frame_driver): input routing, begin and end of the
frame, cursor shapes, scrolling, gamepad navigation and the test driver's
hooks. The call, not an import, brings it: a module initializer in the tree
would have turned existing import cycles into fatal startup cycles and made
hostless test builds keep every program export.

Accessibility is split. The window keeps the AT-SPI connection and the
application object; widget roles, states and nodes live in
accessibility_tree_linux, which the same hosts register with
AccessibilityTreeUse().

The test driver is in a build only when KRYON_TEST_DRIVER is defined;
desktop_runtime then connects it through test_driver_frame (exported for
other native hosts), and a window started for a test without it stops and
says how to build it. App.Run passes the window's title straight to the
window. input_delivery, frame_input_provider and gamepad_navigation move to
src/ui, InputDeliveryTake to input_take. desktop_loop and test_driver_frame
are exported. The ZX player imports cursor_picture again, so its guests'
picture cursors decode.

make pay-per-import-test builds the window, hello, box and image examples
and checks which modules their generated C carries.
2026-11-15 16:17:07 -03:00
waozi 44bd2bd667 Light painted rooms with north-facing daylight and cast shadows 2026-11-15 16:01:00 -03:00
waozi 681bfb85f9 Build with the Ziran that lets Go register procedures calling a host
Kryon's picture cursors register a decoder that calls the host from a
module initializer (cursor_picture). Ziran 93a54f08 includes 38f133cd,
whose Go check accepts storing such a procedure; the toolchain pin moves
there from 37a64372 so the Go backend check builds Kryon again.
2026-11-15 15:12:01 -03:00
waozi 3cd79f2c67 Prepare a scene grade's colours on GPU-only hosts too
PrepareGrade converted its colours through the CPU renderer's linear
table, which only a CPU render filled. A host drawing only on the GPU
got a black tint and black rooms. The grade now fills the table itself,
and the daylight test prepares a grade before anything is rendered.
2026-11-15 14:57:18 -03:00
waozi 8a4e6f05cc Leave pictures, smooth copies, video and threads out of an empty window
The desktop loop called the image decoders (through cursor pictures), the
Lanczos cache and its worker threads, video and the Kryon font every frame,
so every desktop program carried them. Now each part registers itself the
first time it is used: the rasterizer's picture cache and smooth copies when
a frame draws a picture, the font and shaped layouts with the first text,
and video as a named picture source (raster_picture) when it opens. Picture
cursors decode through kryon/cursor again (cursor_picture and the
CursorPictureHost capability, with no-op exports in the hosts without
picture cursors). A widget host no longer imports the decoder; the
application that embeds it imports kryon/cursor.

examples/window.zi now generates 39 C files and 344 KB instead of 62 and
546 KB, and its executable is 179 KB instead of 265 KB. Native desktop
project builds also link X11 explicitly (from the ATR integration lane).
2026-11-15 14:44:27 -03:00
waozi 67e436293f Skip a scene grade that would change nothing
A neutral grade (white tint, full colour, no lamp and no beam), as a
room has for most of the day, now costs no work per pixel on the CPU or
the GPU.
2026-11-15 14:35:08 -03:00
waozi 0dcd71cc54 Keep night rooms gentler and the low sun's beam softer
A night room took a dark tint that hid the picture; it now keeps more of
its colour under a lighter moonlit blue. The low morning and evening sun
through a large window lit most of the floor too brightly; its beam is
softer, and moonlight a little stronger.
2026-11-15 14:30:53 -03:00
waozi c96178aae8 Light painted scenes by the hour with a scene grade and a daylight sky
Scenes made of painted pictures ignore scene lights, so a time of day had
no way to reach them. Scene.grade tints and desaturates every material not
marked ungraded, and lights it with up to four lamps and a beam through an
elliptical opening such as a round window. The CPU and GPU renderers share
its preparation (PrepareGrade) and agree within the GPU test's tolerance.

kryon/daylight gives the sun's path for any local hour, the grade for that
hour (exactly neutral while the sun is high), warm sun or cool moonlight
through a window, lamps from dusk to dawn, and a storybook sky drawn by one
material shader: a horizon-to-zenith gradient, the sun's glow and disc, two
drifting cloud layers and twinkling stars from tileable noise made in code.
2026-11-15 14:21:27 -03:00
waozi 07d74f6dae Render text as RGBA pixels for lettering on 3D surfaces
TextPixels shapes a string exactly as the window draws it and returns a
straight-RGBA picture: Pango on Cairo for desktop builds, the page canvas
on the web. Hosts use it to paint text into textures, such as a sign that
turns with its door.
2026-11-14 23:51:30 -03:00
waoziandGLM 4daa24b78c Drop the CUI name from Kryon's style
Co-Authored-By: GLM <[email protected]>
2026-11-14 22:40:47 -03:00
waozi 0e66e40ac3 Capture frames through the test driver and build canvas apps without raylib or EGL
The test driver gains a capture command: `capture path=` asks the host for
its next finished frame as a PNG, and DriverCapture sends it from a test.
The desktop host writes the raster it shows (RasterWritePNG); a host that
cannot capture answers "this host does not capture frames" instead of
leaving the test waiting. Hosts capture through TestDriverCapturePath and
TestDriverCaptured. The driver client test covers both answers.

On the web (OS == .WEB) image_pixels decodes with the browser's codecs
through PageImageDecode, so a canvas build no longer links raylib's image
transforms, and scene_gpu links no EGL or GL: its probe reports the GPU
unavailable and SceneGpuRenderOrCPU draws with RenderScene. Jungle's
website builds and draws its 3D rooms this way.
2026-11-14 22:39:16 -03:00
waoziandClaude Opus 5.5 311bcb362f Show a star mask in secure text fields without a display value
A secure TextField with a nonempty value and an empty display_value painted
nothing and showed its placeholder, so an API key field looked empty until
the app's show toggle. TextFieldSecureDisplay now returns the caller's
explicit mask, or one '*' per scalar of the value, which keeps the existing
codepoint cursor and selection mapping. The secret still never reaches
paint, semantics or the clipboard; a focused regression covers the default
mask, an explicit mask and an empty value.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-14 22:18:33 -03:00
waoziandClaude Opus 5.5 0411e4bb8e Track Ziran's renamed tool folders in the build dependencies
Ziran's drivers moved to cmd/zi2* and cmd/zx2*, so the Ziran source lists
that decide when the player runtimes and compiler rebuild now include
those folders too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-14 22:08:13 -03:00
waozi c8a068e343 Keep modal backdrops open by default 2026-11-14 21:25:38 -03:00
waozi 5f9d675daa Mark the removed portable VM and TinyCC runtimes in the docs 2026-11-14 17:54:14 -03:00
waozi 7baf863221 Commit pending scene, input, export and asset work
- GPU scene renderer: moved, turned or scaled nodes re-send only their own
  triangles instead of rebuilding the scene; per-node matrices are reused;
  FreezeGeometry skips geometry comparisons; lights carry projected
  textures (LightCookie) in the CPU and GLES renderers.
- One ordered per-session key and text delivery path across Desktop,
  Canvas and Raylib.
- Context-menu rows show accelerator labels and checked state.
- Bundle apps keep extracted assets that already match instead of
  rewriting and syncing all of them on every open.
- Image and PDF export modules, hosted box tests, brand assets, plans,
  and the ZX changelog entry.
2026-11-14 16:27:22 -03:00
waozi 0678895719 Run ZX apps on Ziran's one executable format
Ziran dropped the semantic bundle VM: every bundle is revision-28 executable
ZX on the instruction engine (or its Wasm tier). Players and hosted apps
call InstantiateBundle on every target, including the browser; the --vm
option of the zx player goes, and its tests run without it. The web,
Raylib and Android runtimes build libziran in normal mode so they carry the
engine (BOOTSTRAP=1 builds have none), and their rebuild rules watch the
engine's Ziran sources.
2026-11-14 16:27:22 -03:00
waozi 0cf2c54b50 Expose the PRIMARY selection and keep in-poll modifier taps for Raylib keys
SystemPrimaryText, SystemPrimaryAvailable and SystemPrimarySet read and set
the X11/Wayland PRIMARY selection through the host. The SDL desktop and
Linux Raylib hosts implement it with SDL's primary selection; the Android,
Canvas, pixmap, terminal and bundle hosts report it unavailable instead of
aliasing the ordinary clipboard. Terminal uses it for selections,
middle-click, Shift+Insert and Paste Selection.

RaylibInputPoll took modifiers only from keys still down or just released,
so a Control press released again within the same poll was lost and a
scripted Control+C reached the app as a plain C. Modifier presses from the
pressed-key queue now apply to the keys after them. raylib_window_test
covers the tap.
2026-11-14 10:53:34 -03:00
waozi 9e5c5c2d6e Notice a new default display in cached GTK style queries
The style query cache returned before the settings watcher ran, so after
the default display changed it answered from the old settings and the
style generation did not advance. Check the default settings first.
2026-11-14 10:21:55 -03:00
waozi 92a86b9f25 Add an XDND drag source and GTK check, radio and arrow indicators
Native Linux apps can drag data out to other applications with the optional
kryon/DragSourceLinux module, an XDND version 5 drag source on its own X
connection. It starts while the toolkit keeps its implicit button grab, so
the toolkit still sees the release; it follows the pointer, finds the
top-level XDND window under it (honouring XdndProxy and skipping its own
shaped drag icon), sends Enter, Position, Leave and Drop, answers
XdndStatus, serves the XdndSelection data including TARGETS, and reports
when the pointer is over one of the process's own windows so the app can
handle internal drops. The suggested action follows GTK's modifiers.
tests/drag_source_linux_test.py drops onto an independent python-xlib XDND
target on a private Xvfb from source and saved IR (make
drag-source-linux-test, already part of make test).

GtkStyleIndicatorRaster and GtkPainter kinds 9 to 11 draw the theme's own
check box, radio option and submenu arrow with gtk_render_check,
gtk_render_option and gtk_render_arrow, so native menus show check, radio
and submenu rows as GTK draws them.
2026-11-14 10:21:22 -03:00
waozi 1be70904a3 Remove the semantic DOM backend
No project used the dom profile, and it added a second browser host to
maintain beside Canvas. This removes dom_host, dom_tree, dom_paint, dom_run
and dom_app_run, the dom profile in the project tool, docs/dom.md, and the
DOM tests and their three make targets.

The shared browser code loses its DOM branches: page_events no longer tells
a DOM host about presses, blur and document layout, page_core and
page_texture drop the native DOM flag and the img decode kept for it, and
CanvasAppMainLoop takes no argument. The web template builds a Canvas2D
page. The cursor and rotated text tests cover the Canvas profile only.
2026-11-14 06:04:15 -03:00
waozi 797d7317c3 Decode cursor pictures in the host again, run browser bundles on the VM, drop duplicate test targets
Reaching the cursor picture decoder through a CursorPictureHost capability
broke the Go backend check, which refuses a host call reachable from global
startup, and four tests whose hosts link the hosted-widget host without
providing it. The desktop host decodes cursor pictures directly again, and
cursor_picture, cursor_api and the host stubs are gone. The image decoders
therefore stay in every desktop program; an empty window is 62 C files and
545 KB. The test driver and text reductions are unchanged.

Ziran's WebAssembly tier runs only s64 -> s64 host capabilities and no longer
hands other bundles to the VM, so the ZX Canvas player and hosted apps failed
to start in a page. bundle_player and hosted_app select the portable VM on the
web with InstantiateBundlePortable. zx-services-test, zx-hosted-test and
zx-canvas-test pass again.

Sixteen targets in make test, and video-test outside it, only reran one
tests/ziran_*_test.sh that the behavior test runner already runs. They are
removed, leaving 70 targets; make test-focus TEST=NAME runs one script, and
push-check runs the pixmap GPU script that way. The runner clears XAUTHORITY,
the session bus, the session manager and GDK_DISPLAY as those targets did.
2026-11-14 02:39:12 -03:00
waozi c80e022fe8 Leave the test driver and the image decoders out of programs that do not use them
The test driver is test code, yet every program carried it because the hosts
call it each frame. kryon/test_driver now passes the platform's input through
unchanged, and the driver itself, test_driver_engine, is compiled in only when
a build defines KRYON_TEST_DRIVER: --define KRYON_TEST_DRIVER on a direct
build, or the variable set in the environment of kryon build, which keeps a
stamp per setting so toggling it rebuilds. A program built without the driver
and started with the variable set stops at once and says how to build it.

The desktop host decoded cursor pictures directly, which kept PNG, WebP and
AVIF decoding in every desktop program. The decoder is now reached through a
procedure that cursor_picture registers from its initializer, using the new
CursorPictureHost host capability. kryon/cursor, which applications import,
and the hosted-widget host import cursor_picture; the cursor module the hosts
import does not, so hostless and custom-host builds need nothing new. Kryon's
hosts export the capability.

An empty window generates 43 C files and 370 KB instead of 62 and 627 KB, and
its executable is 196 KB instead of 296 KB. The program entry test asserts
that the decoders and the driver stay out, and that a build made for a test
gets the driver.
2026-11-14 01:58:44 -03:00
waozi 9e4af21b6d Name the web target in the page tests and repair two stale test builds
The Canvas host is selected by OS == .WEB, so a page build that only defines
PLATFORM_WEB fails on unresolved Canvas names. The Canvas backend, audio and
text tests, the shared browser behavior helper, and the Lanczos, asset cache,
bitmap image and document storage tests now pass --target-os web
--target-cpu wasm32 (with --target=c when saving IR).

The host keys test builds as part of the project: the key modules import
widgets by name, which bare module paths no longer resolve. The toast test
drops its binding of the platform keyboard capability, which a toast program
never calls, so binding it was refused.

canvas-test, document-storage-test, lanczos-goldens-test,
canvas-asset-cache-test, bitmap-image-test, host-keys-test and
toast-action-test pass again.
2026-11-14 01:20:35 -03:00
waozi fdedbdc392 Keep the Unicode tables out of programs that cannot edit text
text_request checked the cut points of a platform's text request with
std/grapheme, and accessibility can send such a request, so every desktop
program carried 134 KB of grapheme tables. The check now goes through a
procedure that text_boundary registers from its initializer. The text field
and text area import text_boundary, so only programs that can edit text
include the tables. Without an editing widget nothing could take a request,
and TextRequestSend refuses it.

An empty window generates 121 KB less C and its executable shrinks from
346 KB to 296 KB. The program entry test asserts the tables stay out. The
Android text editor test, which sends requests without a widget, imports
text_boundary.

The Canvas frame snapshot test binds the app's Frame to the ProjectFrame
capability its host calls, which the link was missing.
2026-11-14 01:05:35 -03:00
waozi 4757cb3e0b Build the time picker and image examples and the pixmap parity test again
The desktop hosts of the time picker and image examples import a shared demo
module beside them. Project builds only take modules from the package's roots
or a named module path, and examples/ cannot be one because window.zi shares
a name with a project module. The two demos move to examples/demo/, which
those rules name. The time picker demo also uses the current Text.Props size
field and imports time_picker_behavior for TimePickerText.

The pixmap parity test builds the image example as part of the project, since
it imports kryon/image, and passes every saved module when building from
saved IR. Naming only the entry left out the app module bound to the host's
ProjectFrame capability, so all four template cases failed.
2026-11-13 22:23:51 -03:00
waozi 718572978d Build kryon/app programs with the project tool and name the web target
A project whose entry module declares main, such as examples/window.zi, is a
program. The project tool now generates a host that only calls that main, so
kryon build gives a desktop executable or a Canvas page from the same file. A
portable zx profile needs a Frame entry and is refused with that reason.

Browser builds pass --target=c --target-os web --target-cpu wasm32 when they
save IR. The Canvas host is selected by OS == .WEB, and untargeted IR is
portable, so with only PLATFORM_WEB defined every canvas, DOM and raylib-web
project and the ZX canvas player failed on unresolved Canvas functions. The
frame-input and password Canvas tests name the target the same way.

Kryon's manifest names the desktop host's system libraries in [package]
links, so ziran build --project --target=c --exe links a program in this
checkout without caller LDLIBS. The examples Makefile drops its pkg-config
link flags and its own compile of the desktop examples.
2026-11-13 21:10:18 -03:00
waozi 3ac259c4c2 Generate Android sources for the Android target 2026-11-13 18:07:38 -03:00
waozi b08079641f Keep Android loader entries in generated native graphs
`ziran ir --entry main:main` keeps only what main reaches, so the glue's
JNI_OnLoad, android_fopen's __wrap_fopen/__wrap_fopen64 and a ZX player's
android_main were pruned: libmain.map.txt then failed with "symbol not
defined" for JNI_OnLoad and --wrap=fopen left __wrap_fopen undefined.

The generator now selects the graph through a generated root that forwards
to the stable main(argc, argv) and names the loader entries only on a
negative-argc branch, binding Kryon's entries as host capabilities. The
root never enters the C inputs. The source generation test now uses a
real JNI_OnLoad glue, checks the generated C defines every loader entry,
and links native and ZX graphs through kryon_android_app and
kryon_android_host with the canonical export map.
2026-11-13 17:20:59 -03:00
waoziandClaude Opus 5.5 302939233e Build raylib in the Android renderer artifact project again
The kryon:renderer-raylib Android artifact configures
cmake/renderer-artifact, which still called kryon_android_raylib after the
renderer-free native host helpers in cmake/KryonAndroid.cmake stopped
defining it. Every arm64 and armv7 artifact build, such as Shovey's
android-fdroid, failed with an unknown CMake command.

The artifact project now owns that function in RaylibAndroid.cmake: raylib's
GLES2 Android backend, Kryon's WebP and AVIF codecs, and the audio package's
libopus. Raylib's own APK reader keeps the KryonRaylibFopen name, so it never
collides with the __wrap_fopen in src/backend/android_fopen.zi.
KryonAndroid.cmake stays renderer-free.

make android-renderer-artifact-test configures the project for arm64,
checks the codec targets, builds raylib, and checks its fopen symbols.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-13 16:13:22 -03:00
waozi bd693c1ea9 Accept qualified ActionModal action slices in the widget host
Portable ActionModal guests send their actions as []Modal.ActionModalAction,
the type the modal's host declaration and the generated codec use. The widget
host still required the old unqualified []ActionModalAction, so a package
consumer's real ActionModal call was refused. Check the qualified name only,
and cover it with a package consumer bundle run through the real
WidgetHostCall.
2026-11-13 12:42:12 -03:00
waozi 6a509e300c Pin package templates to compatible Ziran 2026-11-13 11:50:12 -03:00
waozi ff07bddbec Simplify hello world and package widget APIs 2026-11-13 04:29:23 -03:00
waozi 681fd26ddf Checkpoint desktop painter and context menu work
Committed at the owner's request while the work continues.

- Detect unchanged GTK painter surfaces by exact byte comparison, clear
  and copy them in bulk, and reuse resolved GTK style metrics and CSS
  layers within a style generation.
- Present desktop frames before publishing accessibility changes.
- Context menu widget, keyboard and canvas input updates with tests.
2026-11-12 20:12:14 -03:00
waozi b154a5faec Reuse GTK cell measurements and refresh site pages
Reuse identical GTK cell measurements, keep native raster caches across
unrelated GLib events, fix tab widget updates and regenerate the docs site.
2026-11-12 19:16:01 -03:00
waozi 271113fda8 Open website pages at their extensionless URLs
Cloudflare Pages redirects widgets.html to /widgets, and the site only
recognised routes ending in .html, so every page on kryonlabs.com fell
back to the Overview. Match a route with or without the suffix, and make
the browser test server answer clean paths the same way the live host does.
2026-11-12 19:15:10 -03:00
waozi 2d80834675 Fix nested scroll drags and refresh the live website
- Keep scroll pointer, drag and momentum state per Session, so a preview's
  frame sampling cannot release the page's scrollbar thumb or content drag.
- Left-align component navigation, drop the Kryon prefix from core component
  labels, and syntax-highlight the usage, source and guide code areas.
- Replace the Apps text list with card images, public applications and GitHub
  links, and rename Shelf to Explorer.
2026-11-12 18:59:07 -03:00
waozi 73ff84637a Reduce native desktop input and GTK rendering latency 2026-11-12 02:09:28 -03:00
waozi 090a52fd82 Preserve retained frame snapshots during transitions 2026-11-12 02:03:01 -03:00
waozi 602b4a8467 Fix browser startup for website deployments 2026-11-12 01:52:21 -03:00
waozi cc6cd245dc Fix duplicated release workflow 2026-11-12 01:29:52 -03:00
waozi 597cf5038f Prepare the 0.3.0 release 2026-11-12 01:26:11 -03:00
waozi 3900c56a3d Regenerate the gallery lock 2026-11-12 01:26:04 -03:00
waozi 9ce4785128 Test the redesigned Canvas website 2026-11-12 01:00:28 -03:00
waozi 551a790ca3 Check the redesigned site assets and drop the removed editor test 2026-11-12 00:40:59 -03:00
waozi 4e7e395236 Check the playground runtime in its new site location 2026-11-12 00:30:15 -03:00
waozi e63a334a4c Install libxkbcommon-x11 in the X11 CI jobs 2026-11-12 00:21:54 -03:00
waozi c5a330b901 Regenerate the lock without development overrides 2026-11-12 00:17:53 -03:00
waozi 9383e95e57 Add the GPU scene renderer, hosted widget aggregates and component packages
Restructure maintained components into per-widget source folders, add the
portable scene GPU renderer with GLSL shaders, hosted widget aggregates,
GTK theming and multi-target clipboard support, rebuild the guide with
theming guidance, and move the toolchain to the Ziran revision without
module root limits so the eighty component roots resolve everywhere.
2026-11-12 00:12:06 -03:00
waozi f0fa2e4e10 Pin the Ziran CI setup to the revision without module root limits 2026-11-11 23:58:14 -03:00
waozi a7211b6508 Add repeatable public widget benchmark scenarios 2026-11-11 02:16:31 -03:00
waozi a2021be06e Link the raylib AVIF codec only when requested
A raylib host imports the static AVIF decoder only with AVIF_RAYLIB.
Other hosts decode no AVIF and link no codec library, so applications
that do not use AVIF keep a codec-free build.
2026-11-11 01:11:21 -03:00
waozi e8c6aa25c1 Integrate components and the public UI surface 2026-11-10 15:37:48 +00:00
waozi af027a528c Add native GTK theme, painting and scrollbar integration 2026-11-09 03:39:51 -03:00
waozi a139f22c5e Attach promotional ribbons to carousel actions 2026-11-08 15:13:53 -03:00
waozi b3a6258d84 Exercise the carousel action ribbon 2026-11-08 14:03:44 -03:00
waozi a4cf066486 Restore measured SDL3 batching baseline
Keep the GPUI and profiling harness, but restore the established SDL3 color workspace and normalization after the paired hardware comparison did not improve consistently.
2026-11-08 11:45:19 -03:00
waozi 99c934a0ff Support staged swipes and preserve correction caret and image sizes 2026-11-08 11:40:12 -03:00
waozi f2f96a7361 Optimize SDL3 batches and add GPUI benchmarks 2026-11-08 11:31:01 -03:00
waozi b3e38a7bb8 Add GTK style providers and scoped settings
Support context CSS attachments, atomic provider replacement, nested dark
preferences and native style invalidation. Export the canonical F3 key.
2026-11-08 08:27:00 -03:00
waozi 63bf6c6c71 Fix modified Tab routing and retained TabBar focus 2026-11-08 06:17:41 -03:00
waozi 81afed12da Add reusable Breadcrumb and TextField completion input 2026-11-08 05:02:12 -03:00
waozi aeda5cc882 Accelerate rounded image rendering 2026-11-08 01:52:38 -03:00
waozi 7b5713ba44 Keep CI clipboard and browser navigation tests portable 2026-11-08 01:14:15 -03:00
waozi a08c459eeb Render managed bitmap revisions on native Raylib 2026-11-08 01:07:08 -03:00
waozi b6d6641a81 Add bounded native MIME clipboard transport and align artifact pins 2026-11-08 00:16:58 -03:00
waozi c2bdc53a8f Fix seams between fractional Cairo images 2026-11-07 23:10:38 -03:00
waozi b570cf3d06 Add multi-select grids and native desktop integration 2026-11-07 23:08:18 -03:00
waozi b9aed7589e Style Kryon with the CSS package
The KSS package is now kryonlabs/css, a CSS subset. The catalog themes are
converted to CSS, the unused KSS fixtures are gone, and the docs, website,
DOM interaction test and site test name the CSS package.

Also carries the EMCC lookup in mk/emcc.mk from a concurrent task.
2026-11-07 14:19:13 -03:00
waozi d95a2d4ce7 Find emcc on PATH when ~/emsdk is absent 2026-11-07 14:11:57 -03:00
waozi 0810642996 Lock Ziran 9524616d
Ziran 9524616d stops the bounds-check prover from treating overflowing
guard sums as exact, so it keeps the bounds checks 6dfa969c dropped, and
brings the owned-Text leak fixes and the SIMD and ZX lowering speedups.
make push-check passes against the lock.
2026-11-07 08:32:28 -03:00
waozi 76496cd6e1 Give private Firefox two minutes to open Marionette and show its log on failure
On a busy CI runner the canvas Lanczos test's fresh Firefox profile was
still starting after the 30 s limit. Startup now waits up to 120 s, and a
failure includes the end of firefox.log instead of only its path.
2026-11-07 04:58:38 -03:00
waozi 655f1efce2 Let the DevTools test browser take extra Chromium switches
A WebGL page needs SwiftShader switches the fixed argument list did not
have. Browser.flags adds up to 12 switches before the first page; the
DevTools test checks that one reaches Chromium.
2026-11-07 04:09:40 -03:00
waozi 583c4a0f67 Link libcurl in the raylib desktop backend
Share one RAYLIB_HTTP_LIBS definition between the desktop, raylib and zx
raylib builds; the raylib web build keeps using fetch.
2026-11-07 02:53:10 -03:00
waozi d162f58979 Wait for a whole WebGL frame before checking the raylib web page
The raylib web test took one headless screenshot at a fixed 6 s, and a
slow CI runner could catch the WebGL canvas black before a frame was
presented. The screenshot now retries from a fresh profile with longer
waits (6, 20, 45 s) until the cube, clear color, Kryon panel and asset
image are all on screen, then asserts each pixel.
2026-11-07 02:47:19 -03:00
waozi dc9e80852e Show each DOM image texture's own decoded img and give DOM drivers short sockets
A DOM image texture now keeps the img whose decode made it ready for its
whole life, and dom_paint moves that element into the paint node instead
of giving a fresh img the blob URL. Nothing depends on the browser's
image cache, so an eviction cannot bring back a blank frame. A second use
of the texture in the same pass draws from the texture's canvas.

The image decode test now hides the image, loads six other textures,
shows it again twice and checks it is the same decoded img, the copy
draws, and no img was ever published undecoded.

dom_project_test gives every browser driver a short TMPDIR from a shared
toolchain helper, so Chromium's sockets fit whatever TMPDIR the caller has.
2026-11-07 02:20:59 -03:00
waozi 3a4704a92a Report DOM image textures ready only once their img has decoded
A DOM page texture reported its size as soon as createImageBitmap
decoded it, while the page img given its blob URL had not loaded yet,
so the first frame showed nothing. PageTextureFromEncoded now also
awaits HTMLImageElement.decode() on the source URL for native DOM
pages and frees the texture when that decode fails.

dom-project-test gains KRYON_DOM_IMAGE_DECODE: a headless Chromium
driver checks that the frame which paints the image reports 300x200
with its img complete, and that undecodable or rejected images report 0.
2026-11-07 02:08:38 -03:00
waozi 812f1241c9 Build raylib profiles as WebGL browser pages with platform = "web"
A raylib profile with platform = "web" links raylib's PLATFORM_WEB library
(GLES2 on WebGL 1, with rmodels) and the PLATFORM_WEB host through Emscripten
with ASYNCIFY, so default and custom hosts keep their while PollRaylib() loop.
assets and the new preload key mount project directories in the page's file
system, and the page lands as index.html/js/wasm/data in build/NAME-PROFILE/.
WebP decodes with the authored engine there; AVIF stays native-only.
make raylib-web-project-test checks a 3D cube under Kryon UI in private
headless Chromium.
2026-11-07 00:48:15 -03:00
waozi cd873becb1 Load raylib typefaces from the selector's own buffers and lock Ziran 6dfa969c
TextTypefaceSelector is #reads, so RaylibTextTypeface no longer hands the
caller's name to LoadTypefaceData: the hashed key and the file extension
come from its own key and path buffers. Ziran 6dfa969c follows #reads
strings through record field paths, so the emphasis and italic rasters
check as they are. text-hook-hosts-ir-test, now in push-check, checks the
raylib, threaded raylib, Android and canvas hosts that install these hooks.
2026-11-07 00:11:06 -03:00
waozi 213697f82b Build the raylib text tests against Kryon's own archives
raylib-text-pixels-test still compiled with bare module paths, so the
webp package import failed, and it linked the package's unbuilt
libraylib.a without the image and audio libraries. It now builds with
--project like the other host tests. Both text tests take Kryon's built
raylib, webp and avif archives from make.
2026-11-06 22:59:29 -03:00
waozi 6825c977d8 Install libopus-dev on the Linux CI jobs that link raylib hosts
The native MediaAudio provider links -lopus since Ogg Opus playback, and
the audio package expects the system libopus development library. The
hosts, web and zx shards and the Xvfb desktop job failed to link without it.
2026-11-06 22:59:29 -03:00
waozi 786b61ad31 Mark the Text selection painter and paint-path hooks #reads and lock Ziran 5b113f2a
Text calls the installed selection painter through TextSelectionPainter,
which is now #reads, so Ziran frees a fresh props.text after the call.
TextSelectionDraw copies selected text through SystemClipboardWriteHost,
which every host copies during the call, so that foreign is #reads too.
TextEmphasisRaster, TextItalicRaster, CaretMeasure and TextTypefaceSelector
are #reads as well; the text page test host now keeps its own face name.
A new leak test counts 0 allocations left after 1000 frames of a fresh
Text through a plain line, an ellipsis line and the selection painter
(1000 before).
2026-11-06 21:17:54 -03:00
waozi 34d0ce4ed4 Play Ogg Opus on Windows and ship libopus in renderer artifacts
The native provider now decodes Ogg Opus through the audio package on
Windows too (audio f5eed1e). MinGW hosts link -lopus -lssp -lm, since the
package's libopus keeps its stack protector. The renderer-raylib artifact
builds the package's static libopus for Linux, Windows and Android, so
artifact consumers that use media_audio_raylib link without a system copy.

The Windows artifact sets CMAKE_SYSTEM_PROCESSOR, which dav1d's cross build
now requires, and the artifact test pins Kryon's locked toolchain. The Opus
test gains --windows: a MinGW cross build run under a private Wine prefix.
2026-11-06 20:58:14 -03:00
waozi 34e552dcab Play Ogg Opus through the native MediaAudio provider
The Raylib provider now chooses its decoder by content: an Ogg page whose
first packet is OpusHead decodes through the audio package on Linux and
Android, streamed in two 2048-frame blocks refilled by Status and the owner
tick. Other bytes, including Vorbis Ogg, stay on Raylib; macOS and Windows
return Unsupported for Ogg Opus and the browser keeps decoding it itself.

Play starts the stream before filling it, since PlayAudioStream discards
queued blocks. Linux links -lopus -lm, and the Android build compiles the
package's static opus target. The Opus tests now run the production
provider, including on an Android device with null audio.
2026-11-06 20:19:58 -03:00
waozi 310e85b145 Mark AppService, DocumentWrite, DocumentRead and AppReply #reads
The bundle, local-app and web hosts only read these strings during the call,
so Ziran frees a fresh Text passed to them. A new leak test counts 0
allocations left after 1000 rounds of each.
2026-11-06 19:00:17 -03:00
waozi 9e6acdd2dc Mark MeasureGlyphWidth and MeasureGlyphLineHeight #reads and lock Ziran 38710d1f
Every host only reads the measured strings during the call, so Ziran frees a
fresh Text passed through TextProps to TextWidth and TextLinkAt. The paint
leak test counts 0 allocations left for both.
2026-11-06 17:53:05 -03:00
waozi 29721d3ab6 Lock Ziran dd799d38 and link the vec module into the hello example 2026-11-06 16:39:15 -03:00
waozi f635c9cffc Copy painted labels and paths without keeping the caller's string
Label, emphasis, slanted and image-path paint calls now hand their strings
only to a read-only copy into the session's per-frame text blocks, and the
queued command keeps just the copied range. Ziran can therefore free a fresh
Text argument right after the call. The pools keep room for their next block,
so copying never moves text that is being copied from. Paint outside a
frame draws from a short-lived copy. A new test frees every label before
the frame draws: under an allocation counter and AddressSanitizer, nothing is
left after 1000 frames and the frame text keeps its capacity.
2026-11-06 15:29:50 -03:00
waozi 6d417b3b8b Lock avif 2f349f8c with libaom 3.15.3 and build without yasm
avif now pins libaom 3.15.3, whose CMake detects NASM 3, so CI drops the
yasm workaround. image-codec moves to 36055315 with avif, av1 and webp
02145a00, so the locked graph has one image-codec revision for the values
Kryon hands to both codecs.
2026-11-06 03:37:05 -03:00
waozi 297aead896 Keep a web scene's images decoded once, however many it draws
The Canvas host cached 32 images and replaced them in arrival order, so a
scene drawing more, such as Jungle's world map with its landmarks and the
neighbouring scenes it preloads, decoded each image again every frame:
50 ms frames instead of 17. The cache now holds 128 images and replaces
the one used longest ago, within a total of decoded pixels, and reuses
forgotten slots first. tests/canvas_asset_cache_test.py checks it in
private headless Firefox.
2026-11-06 02:08:32 -03:00
waozi f6acf422b0 Ship web pages with a SIMD128 build and a baseline build
A canvas or DOM web profile now links the program twice, once with
-msimd128, and mk/web-page.sh assembles one page carrying both builds
and the font once. A loader asks WebAssembly.validate about a probe
module holding one SIMD128 instruction and starts the SIMD128 build,
whose std/resample Lanczos kernels are SIMD128, or the baseline build
where SIMD is unavailable.

tests/web_simd_page_test.py (in canvas-project-test) builds a Canvas
project and checks in headless Firefox and Chromium that the SIMD128
build runs with simd128 kernels, that a page whose validate rejects
SIMD falls back to the baseline build, and that every Lanczos resize
gives the same bytes in both builds and with scalar kernels.
2026-11-06 01:41:11 -03:00
waozi 1f1dfad8cd Keep Canvas's default filter for images a camera turns; benchmark Lanczos in Firefox's WebAssembly 2026-11-06 00:42:01 -03:00
waozi c14513470e Pin Ziran 57a4337f, whose bootstrap build has the Go type header fix 2026-11-05 23:29:18 -03:00
waozi 68acdf8d45 Keep Canvas meshes on the browser's default filter and link Lanczos on macOS
Only an upright smooth image that has no Lanczos copy yet draws with
imageSmoothingQuality high, and it restores the default afterwards, so
warped meshes and rotated or mirrored images filter as they did before.
The toolchain moves to Ziran 5e49140f, whose std/thread_linux links on
macOS without pthread_tryjoin_np; native C builds there define
POSIX_THREADS, so the Lanczos worker imports it.
2026-11-05 22:49:05 -03:00
waozi cb6bea358d Lock the site demo to a Kryon with the Card widget
The live editor embeds the demo's locked Kryon UI sources, and 20b38574 has no Card, so the gallery's card scene failed its language check. The demo now locks 4a1423d0 and that commit's image packages.
2026-11-05 21:44:34 -03:00
waozi a186d76a7a Show smooth images at their on-screen size with Lanczos on every backend
One shared cache in src/backend/lanczos_cache.zi resamples a smooth
picture to its device-pixel size with Ziran's std/resample (Pillow's
fixed-point Lanczos with SSE2, AVX2 and NEON rows) off the UI thread,
or a slice per frame in the browser. It keys copies by content,
revision, source rectangle, size and session, keeps the old copy
stretched until the new one is ready, caches only axis-aligned draws,
and bounds copies to 4096 per side, 4.19 Mpx, 64 MiB in total and
32 MiB per session.

Cairo, Raylib, pixmap/SDL3 GPU and Canvas draw the copies 1:1;
tests/lanczos_backend_goldens.sh checks each against Pillow, and
make lanczos-benchmark compares std/resample with Pillow, Pillow-SIMD,
libvips and stb_image_resize2 here and on an ARMv7 phone over ADB.
The toolchain and the renderer artifact test pin Ziran a0ff750c, the
first commit with ARMv7 NEON resample rows.
2026-11-05 21:38:42 -03:00
waozi 4a1423d0f6 Resolve image packages in host tests and refresh the gallery's Kryon pin
The image codec integration left four CI gaps:
- The bitmap browser test hard-coded a Bun path; it now uses the
  configured JS_RUNTIME like the other browser tests, and starts from a
  clean work directory so stale IR cannot leak into its saved build.
- The gallery locked Kryon 20b38574, which has no Card widget for its
  card scene; it now locks f2bfeb40 and that commit's image packages.
- The raylib typeface, frame pixel and frame snapshot hosts resolve the
  webp, avif and image_codec packages through the project and link the
  WebP and AVIF archives they now use.
- The behavior suite builds the WebP archive the image job test links.
2026-11-05 21:10:39 -03:00
waozi f2bfeb409d Build libaom's x86 SIMD with yasm in CI
The Ubuntu and Homebrew runners now ship NASM 3, which the locked libaom
3.13 assembler probe rejects. libaom prefers yasm; dav1d keeps NASM.
2026-11-05 19:43:30 -03:00
waozi cc171806f7 Decode native AVIF with dav1d's runtime-dispatched assembly
dav1d is the default engine in every native artifact and CMake consumer, with
libaom kept as the explicit oracle. Large frames use up to four threads.
Strict parity, cross-target, Android, browser-capability and benchmark
suites cover each target.
2026-11-05 19:17:12 -03:00
waozi addec5e14f Give tall button tiles card corners, large pictures and tonal neutral fills 2026-11-05 16:50:35 -03:00
waozi c8eb02196a Draw app-owned RGBA bitmaps as images, add Opus audio transport and export image modules
Bitmap images and their store update in place on desktop, pixmap and web
renderers. Native Opus asset transport and a raylib audio sink join the
media audio host. Export the image and SVG shape modules for apps, and
read the shot profile's picture from standard output only so build
diagnostics on standard error never mix into it.
2026-11-05 16:36:09 -03:00
waozi d0dd0205e0 Map web touches through the canvas a padded frame shows
A page that pads #canvas-frame for safe-area insets made the canvas smaller
than the frame Kryon measured, so the picture was squeezed upward and a tap
pressed the button above. The page now draws at the canvas's own CSS size and
maps pointer positions through the canvas's shown box.
2026-11-05 14:07:10 -03:00
waozi 93195031ad Show Shelf as an available app on kryonlabs.com
Shelf is no longer marked legacy. The apps page and home card say it is
available to build from source, the page descriptions name it, and the
showcase data lists it again.
2026-11-05 11:53:10 -03:00
waozi 56af335572 Integrate Material widgets, image codecs and Kryon Labs website
Add Card elevation and consistent widget states, retained TextArea selection,
and rounded image rendering. Integrate published image-codec, WebP and AVIF
packages across native hosts and renderer artifacts with project-aware builds.

Modernize Kryon Labs around visual GUI apps and modules, with real previews,
honest availability, and rebuilt interactive editor and widget gallery assets.
Bound private browser test lifecycles and verify source, saved IR, native,
portable, browser, Windows and Android paths with the published compiler.
2026-11-05 11:12:10 -03:00
waozi 20b38574f2 Support rotated text and reuse scaled Cairo images 2026-11-04 02:59:58 -03:00
waozi 8f2291577c Show an application pointing cursor only over clickable targets
CursorSetPointing sets the cursor shown where a click does something:
clickable widgets and painted targets an app hit-tests itself and marks
with CursorHover while it builds the frame. The mark commits with the
tree, so retained or cancelled frames keep it and the cursor changes only
when the hovered target does. PressProps.cursor lets a press the app
refines with its own hit test name the arrow off its painted shape, on
desktop, Canvas and DOM, without changing presses, touch or keys.
2026-11-03 22:11:47 -03:00
waozi 5fca09f696 Fix Windows storage test toolchain and Wine bootstrap 2026-11-03 18:42:07 -03:00
waozi 4f1e8d4610 Show custom cursors in Canvas and DOM pages
Cursor CSS was built from WebText views of Wasm memory, which have no
JavaScript handle, so web pages kept the default arrow. PageTextHandle
makes a real string handle for the cursor override, the image-set text
and the hidden cursor.

The cursor test now also builds the probe for Canvas and DOM and checks
every request in a private headless Chromium: the 2x image set with its
hotspot, the application cursor, hidden, refused sizes, and no style
rewrite while a request repeats.
2026-11-03 18:02:58 -03:00
waozi 81906dfd3d Count keyboard activity across X11 applications in session idle time 2026-11-03 17:51:54 -03:00
waozi 6e71c4ae94 Keep the cursor module inside the Kryon archive
CursorStored used std/byte_text_linux, which the C archive does not
build, so linking programs against libkryon.a failed. Use the builtin
TextView instead.
2026-11-03 17:41:39 -03:00
waozi cbc605bd13 Keep custom cursors stable with an application-wide default
Cursor requests now persist until the next deliberate change instead of
lasting one frame, and CursorSetDefault gives every session an
application cursor that replaces the default, clickable and disabled
shapes. Desktop caches decoded cursors, sets the system cursor only when
the resolved cursor changes, keeps it across focus and leave, and gives
X11 premultiplied pixels so soft edges show no light fringe. Canvas and
DOM build one density-aware CSS cursor and apply it only on change.
2026-11-03 17:30:55 -03:00
waozi b5ac5d1a30 Preserve browser key modifiers through queued delivery 2026-11-03 08:05:28 -03:00
waozi 867f364524 Test secure field select-all and keyboard editing 2026-11-03 05:59:33 -03:00
waozi c18c16abc1 Keep browser-only frame execution inside the Canvas fixture 2026-11-03 02:15:29 -03:00
waozi 218da56f93 Keep the browser fixture compatible with CI JavaScript runtime 2026-11-03 02:01:02 -03:00
waozi 1cd873fda5 Support console gamepad navigation on desktop and web 2026-11-03 01:32:38 -03:00
waozi 7865957626 Add account-bound purchases and reusable referral host support 2026-11-03 00:49:18 -03:00
waozi 81f5e70f91 Benchmark SDL2 and SDL3 on a verified physical GPU 2026-11-02 14:09:32 -03:00
waozi 2e16fc57e5 Install SDL3 XTEST build prerequisite in Linux CI 2026-11-02 13:02:13 -03:00
waozi 7a87f18d9c Resolve website package graphs after selecting checkout overrides 2026-11-02 12:47:18 -03:00
waozi 1787e1b09a Add opt-in SDL3 GPU renderer and pinned SDK tests 2026-11-02 12:41:25 -03:00
waozi 29e8ef1fb2 Add grapheme-safe anywhere wrapping for text 2026-11-02 12:07:47 -03:00
waozi d76c4f20cb Install Pillow for the website gallery build 2026-11-02 11:16:26 -03:00
waozi 0126c74061 Resolve styles and own frame labels through flat indices 2026-11-02 11:08:43 -03:00
waozi 9886717e6b Use lossless WebP for bundled UI and profile icon sheets 2026-11-02 11:07:38 -03:00
waozi ead3eb7aa6 Keep absolute Android file opens out of raylib's asset reader
A process with no running activity crashed when Continue as approved
while the other app was closed: raylib's fopen wrapper read a null
activity. Absolute paths now use the real fopen and relative asset
paths keep raylib's reader.
2026-11-02 10:20:16 -03:00
waozi bab9c3d16e Preserve unread Canvas application keys across drawing frames 2026-11-02 06:10:34 -03:00
waozi 8600550ff1 Resolve packaged Wine server for private Windows regression 2026-11-02 06:07:32 -03:00
waozi 2b1219e08e Provision Windows storage regression tools in CI 2026-11-02 05:41:11 -03:00
waozi f7ff3e5466 Fix successful Windows app file writes reporting failure 2026-11-02 05:24:15 -03:00
waozi 139f299d00 Retain notification JNI entry points in Android payloads 2026-11-02 04:42:06 -03:00
waozi a48e60f7ba Load JNI sanitizer runtime before the fixture JVM 2026-11-02 04:35:08 -03:00
waozi 98d3032352 Align site examples with the tested web toolchain 2026-11-02 04:32:28 -03:00
waozi 77edf55d9e Export Android notification host for package consumers 2026-11-02 04:18:18 -03:00
waozi e339381a2f Refresh site dependency graphs for current Kryon 2026-11-02 04:11:53 -03:00
waozi 7dc6290238 Add persistent local reminders and edition-scoped push 2026-11-02 04:03:39 -03:00
waozi d266829098 Fix Android renderer codec ownership 2026-11-02 02:21:54 -03:00
waozi 3152a6e501 Export vector path coverage for application package imports 2026-11-02 01:35:48 -03:00
waozi bd34ddbe3b Find cmake through the shell when Emscripten is on PATH 2026-11-02 01:26:25 -03:00
waozi fbb8112c34 Provide empty touch input in the raylib window test fixture 2026-11-02 01:22:00 -03:00
waozi 298e89940c Keep every Android frame clear of the system bars and camera 2026-11-02 00:54:11 -03:00
waozi 5dc122f78a Snapshot bounded raylib touch coordinates during input polling 2026-11-02 00:26:46 -03:00
waozi c8b1dfa2dc Stub libwebp in raylib tests that inject image functions
The image job and graphics behavior tests link no codec archive, so they
export inert libwebp entry points beside their raylib ones. The WebP
fixture decode script leaves the generic behavior runner, which builds
no archives; make raylib-webp-decode-test still runs it.
2026-11-01 23:46:21 -03:00
waozi e31434063c Decode WebP images on every host
Lossy, lossless and transparent WebP files, and the first frame of
animated ones, load through the existing image paths: raylib and Android
link Kryon's kryonwebp archive built from the locked libwebp source, the
Cairo desktop host opens the system libwebpdemux, and web hosts use the
browser's decoder. Files are recognized by content, not extension.

Fixtures cover each kind on the raylib, Cairo and browser paths, the
renderer artifact ships libkryonwebp.a, and android-webp-link-test links
the decoder for every Android ABI.
2026-11-01 23:03:37 -03:00
waozi 462bd234c8 Bound vector curve work to visible tiles 2026-11-01 22:26:53 -03:00
waozi 3b90bc13e3 Add vector path coverage rasterizer 2026-11-01 22:02:01 -03:00
waozi 4554808be1 Add pure view transforms 2026-11-01 21:01:47 -03:00
waozi e373b8a7f8 Add the Android hand-off for Continue as @name
Native consent dialog, caller and provider checks through the signing
certificate, and a provider giving the public name only to listed apps. No
Google library.
2026-11-01 20:16:21 -03:00
waozi f7a9ec2e1f Allow hosts to size and position carousel logos 2026-11-01 16:58:45 -03:00
waozi 01ed003211 Fix hosted Canvas import boundary 2026-11-01 15:36:06 -03:00
waozi 06b42e92ac Add Android orientation requests 2026-11-01 14:48:41 -03:00
waozi ddc2fce48e Show image previews while full pictures load 2026-11-01 13:50:07 -03:00
waozi 0f0f5e1c1b Keep scaled pixmap text on its logical advances
At a fractional density the pixmap host drew text with a rounded device
font, so 13 units at 125% advanced as 16 pixels rather than 16.25. Carets,
pointer hits and selection highlights use logical advances times the
density, so dragging to the end of a word stopped a letter or two short and
the highlight ran ahead of the glyphs. The pen now advances at the exact
scaled logical font while glyphs still rasterize at the whole device size.

Text areas and fields also round the pointer to the nearest logical unit
instead of truncating it, which at 125% could miss the caret stop past a
narrow glyph such as "i".

pixmap-text-scale-test checks drawn ink against caret edges and pointer
hits for single-line and wrapped rows at 100%, 125% and 150%.
2026-11-01 11:40:25 -03:00
waozi cf09919265 Reduce browser image copies and texture bridge calls 2026-10-31 22:53:34 -03:00
waozi f56950c17c Wait for window activity without losing input and reuse system font fallbacks 2026-10-31 14:57:10 -03:00
waozi 0c52004648 Keep the DOM press driver's browser off the desktop session
It drops the session manager address and turns desktop recovery off itself, not only when Make runs it.
2026-10-31 14:53:23 -03:00
waozi 7192a4c958 Keep DOM button presses across republished pages
A republish that moved a pressed button, even into the place it already
held, made the browser drop its click, and a page press released over a
button left the page's pointer held, ignoring the input that followed.

The host now skips moves that leave an element in place, activates a
button once on a release on that same button when the browser sends no
click, cancels that on a release elsewhere, focus loss or a replaced
button, and lets a page press's release reach the page.
2026-10-31 14:51:53 -03:00
waozi c7b52030a2 Split the long CI job, cache compile results and skip docs-only pushes 2026-10-31 13:25:57 -03:00
waozi 36344ad2fb Follow the keyboard layout on Windows and macOS Raylib hosts 2026-10-31 13:13:59 -03:00
waozi 241736728c Fail broken host links in minutes before the long CI jobs 2026-10-31 13:10:21 -03:00
waozi 2efbb4b0b1 Follow the keyboard layout and quick modifiers on Raylib hosts 2026-10-31 13:08:03 -03:00
waozi f6299fa1c7 Export shape primitives for focused hosted imports 2026-10-31 11:58:11 -03:00
waozi d6b29aeded Keep the pixel raster out of hosts that only present through SDL 2026-10-31 11:43:14 -03:00
waozi 0bbd89ea38 Paint SDL pixel hosts on the GPU 2026-10-31 11:31:23 -03:00
waozi 09360b5d9a Lock the site demo to the Ziran with native scripts 2026-10-31 04:12:56 -03:00
waozi 24b939413a Build the web preview with Ziran's native playground script 2026-10-31 03:37:48 -03:00
waozi 0532bf87ac Publish frame input during Android host frames
DrawAndroidFrame called the application's Frame without publishing the
polled raylib input, so CaptureFrameInput was unavailable and games that
require it stopped immediately. Publish it as raylib_run does and close
it before every EndRaylibFrame, failure paths included.

android-frame-input-test drives the canonical Android frame on desktop
raylib under private Xvfb.
2026-10-31 03:25:50 -03:00
waozi 849eb903e5 Keep document sync inside the private files root
AppFileWrite fsynced every ancestor of the written file, opening system
directories above the private root. Android apps may traverse but not read
those, so every document and asset write failed after its rename.

Synchronize only from the file's directory down to the root. A newly created
root persists its entry when it is created: required for parents this call
created, attempted but not required for parents the host already owned.
2026-10-31 02:38:59 -03:00
waozi a02feeb703 Restore surrounding themes after nested widget palettes 2026-10-31 02:30:11 -03:00
waozi 6113d3a7d3 Include test driver keys in published frame input 2026-10-31 01:51:54 -03:00
waozi a5e4a8322b Flush deferred meshes before restoring DOM tile context 2026-10-31 00:37:27 -03:00
waozi cb98ea3565 Link dependency-owned support artifacts in native project profiles 2026-10-30 23:20:27 -03:00
waozi 1bc32aea89 Share renderer artifact metadata consumption with build tools 2026-10-30 22:59:31 -03:00
waozi d58a40a407 Support per-voice audio pause, resume and music position 2026-10-30 22:29:28 -03:00
waozi ee9d204548 Honor Android document MIME allowlists 2026-10-30 21:54:47 -03:00
waozi 80084e1b1c Keep document storage native tests independent of browser SDK 2026-10-30 21:21:35 -03:00
waozi d307d0221a Add owned bounded PCM streams to MediaAudio 2026-10-30 20:57:05 -03:00
waozi 61cf2f26cd Add acknowledged document storage flush and readiness 2026-10-30 20:46:47 -03:00
waozi b593f9cf00 Provide dependency-owned renderer artifacts and support resources 2026-10-30 20:31:19 -03:00
waozi 14cfc37bcc Defer renderer declarations to their provider change 2026-10-30 20:17:19 -03:00
waozi 3e790807d8 Add owned Media asset audio lifecycle 2026-10-30 20:16:31 -03:00
waozi b8ff4618fd Publish frame input snapshots in Desktop and Canvas hosts 2026-10-30 20:06:17 -03:00
waozi cdf4dffb07 Add owned per-frame input snapshots for native and hosted apps 2026-10-30 19:47:02 -03:00
waozi e565b99d17 Add caller-owned TextField state application 2026-10-30 19:22:37 -03:00
waozi f761e3292a Support optional source crops in carousel artwork 2026-10-30 15:10:35 -03:00
waozi 0e5fd27dda Align browser keyboard and secondary pointer input 2026-10-30 12:16:58 -03:00
waozi 12033506dc Fix captured mouse drags in the browser DOM host 2026-10-30 03:30:14 -03:00
waozi 0e1a62a1f9 Preserve pointer positions in native DOM press activation 2026-10-30 01:19:17 -03:00
waozi 39074d3564 Reset swipe contacts released while their area is hidden 2026-10-30 00:47:03 -03:00
waozi e1c1135dbd Keep images drawn while their content is revalidated
Invalidating assets unloaded every texture under the folder at once, so an
on-screen image went blank until it decoded again; a practice pack install
blinked a picture each time. Invalidation now marks images for revalidation
on desktop, Android and the web: each keeps drawing its texture, bytes that
hash the same keep it without decoding, and changed bytes replace it in one
step only after they have decoded. An image whose bytes are gone is
forgotten. A new asset reader still forgets every image.

Android debug builds log frames where a drawn image loses its texture.
2026-10-29 23:48:40 -03:00
waozi edffc8bf80 Recognize keypad digits and keep simultaneous desktop keys
Local multiplayer games steer one player with the numeric keypad and
need every key pressed in the same frame.
2026-10-29 21:31:20 -03:00
waozi ab77c24419 Apply app palettes to title bars 2026-10-29 17:24:57 -03:00
waozi 8f7edb4e00 Tell apps whether the device's main input is a keyboard and mouse
AppSupports("kryon.input.desktop") is true on native desktop hosts, so
games can skip touch-controls questions there; Android and the web answer
no, as do older hosts.
2026-10-29 17:21:06 -03:00
waozi 7217475dfa Keep Google libraries in the Google Play edition
Play Billing moves from the app template's build.gradle into
templates/android-gplay.gradle, which only -Papp.edition=gplay applies from
the Kryon checkout; the scaffold no longer copies src/gplay into apps. The
normal and F-Droid editions' build files and APKs then name no Google
library, and F-Droid's scanner finds no usual suspect.

scripts/check-google-free.py (and the google-free action for app CI)
fails when a normal or F-Droid APK holds Google library code, manifest
entries or library markers, or when a Gradle file declares one outside the
gplay edition; --expect-google proves it still finds Play Billing in a
-gplay package.
2026-10-29 16:02:09 -03:00
waozi fba0d52baf Draw 3D scenes in software into std/image pictures
scene describes shapes and lights; RenderScene draws them with lighting,
shadows and smoothing, natively and in the portable runner. Shovey's art
tools render their sprites with it instead of three.js. The toolchain pin
moves to the std/image compositing it uses.
2026-10-29 14:21:09 -03:00
waozi a5dbf688bd End every DevTools message with its own NUL
DevtoolsWrite sent the byte after a message's storage as its terminator.
Built strings are not followed by a NUL, so later messages were joined to
the next one and Chromium stopped answering every command, which made a
running game page look hung. The NUL is now written separately.
2026-10-29 14:03:08 -03:00
waozi 797a6838e4 Serve byte ranges and audio types, and keep the DevTools pipes open
The test server answers Range requests with 206 Partial Content and sends
.ogg, .wav, .mp3, .webp and .jpg with their own types, so media elements
finish loading instead of holding their connections. Chromium now always
receives its DevTools pipes on 3 and 4, even when pipe2 returns those
numbers, which close-on-exec used to drop.
2026-10-29 13:34:12 -03:00
waozi 20d9f517e2 Send DevTools server responses as each socket takes them
A blocking send of a large file stalled the test whenever Chromium paused
reading it, so no other request or DevTools message was served. Accepted
connections are now non-blocking and keep their response until the socket
takes all of it. The driver client's wheel comment gives SDL's direction.
2026-10-29 13:20:34 -03:00
waozi 4597163103 Name the DevTools export after its module file 2026-10-29 12:47:41 -03:00
waozi b76cc40241 Drive a private headless Chromium over the DevTools pipe
kryon/devtools starts Chromium with --remote-debugging-pipe and no
display or session, attaches to its page, and serves a build from a
static server in the same poll loop: routes with their own bodies and
headers, an injected head script, and every request target recorded.
Tests evaluate and wait for expressions, click, type, take screenshots,
set the viewport, intercept requests and read the page's exceptions.
2026-10-29 12:46:24 -03:00
waozi 090f53cd83 Add a private Xvfb display for window tests
kryon/private_display starts a test's own Xvfb through -displayfd, checks
the server's /proc identity, starts apps on it with the desktop session
scrubbed from their environment, finds the windows a process owns by
_NET_WM_PID, reads titles, resizes, captures pixels, saves and loads PNGs,
and stops only the process groups it started. Tests no longer need
xdotool, ImageMagick or PIL for these steps.
2026-10-29 12:44:20 -03:00
waozi 10dd79202e Add a Ziran client for the test driver
kryon/test_driver_client is the test process's side of KRYON_TEST_DRIVER:
it finds widgets by label, role or key, presses them with the app's
pointer, types, sends keys, moves the pointer and waits for the tree to
settle, and reports what the app showed when a wait fails.
2026-10-29 12:39:56 -03:00
waozi 16fede501e Route DOM button presses by element identity, not coordinates
A real mouse click on a DOM-app button was handed to the canvas
hit-test, which resolves presses from the app's internal layout
coordinates. The overlay stylesheet reflows rows away from those
coordinates, so the click landed on whichever widget's stale bounds
covered the point: clicking Sources selected a style chip. Buttons now
stop mouse propagation before the canvas path sees it, and the DOM
click event carries the press for keyboard and pointer activation
alike. Drags and held controls on non-button surfaces still route
through the pointer path.
2026-10-29 11:50:04 -03:00
waozi 23baa81bd7 Find Chinese, Japanese and Korean faces on Android before 10
Android 9 has no font lookup, so a missing glyph fell back to Roboto and
every Chinese, Japanese or Korean character outside an app's own fonts
drew as a question mark. Read the face that /system/etc/fonts.xml lists
for the character's language (zh-Hans, ja or ko), skipping serif
fallbacks, the way Android itself chooses it.
2026-10-29 11:48:27 -03:00
waozi 4b7069e651 Let project desktop hosts run the default frame loop
The default host's loop moves to desktop_loop as RunDesktop(width, height),
so a project host that only needs another window size calls it instead of
copying the loop and missing retained painting and accessibility.
DesktopStartBeside starts a program opened from its build folder where its
files are.
2026-10-29 11:42:29 -03:00
waozi 60d6e2bb4c Let document-layout pages own the wheel and report commit failures
The native HTML/CSS DOM rendering hands compiled apps a real scrolling
document, but the page event bridge still claimed wheel events for the
hidden canvas, so the browser never scrolled, and mouse downs stole
focus from text inputs, killing double-click selection. For
document-layout pages the bridge now leaves the wheel to the browser and
keeps the canvas out of focus taking.

Commit failures also report which scope and widget kind were left open,
via FrameFailureAt and the pending-scope keys recorded in the tree, and
the zx test shell logs module exits with a stack.
2026-10-29 11:32:05 -03:00
waozi 2839954d91 Host overlays and explicit tree scopes 2026-10-29 00:31:46 -03:00
waozi 6b44af90e0 Raise the HTTP transfer body limit to 64 MiB
Large single-file datasets (a 17 MB catalog.json today, growing with the
archive) exceed the old 16 MiB cap: HttpTransferStart then rejects the
transfer before any request is issued and the caller only sees a silent
failure. Browsers stream into the caller's buffer, so a bigger ceiling
costs nothing until a body actually needs it.
2026-10-29 00:16:45 -03:00
waozi 66489e85d8 Keep hosted widget aggregates free of retained paint 2026-10-28 23:48:56 -03:00
waozi 1d987043bf Use Material controls and fill picture choice buttons 2026-10-28 18:33:12 -03:00
waozi 576b3e22f7 Declare polygon GPU effects in the graphics test provider 2026-10-28 17:25:45 -03:00
waozi 5427f011d2 Clip images to retained polygons across rendering hosts 2026-10-28 17:02:27 -03:00
waozi 78582b7324 Support Android Back, native text editing and document pickers 2026-10-28 16:48:40 -03:00
waozi c00069ff48 Use native DOM paint in the regular Frame entry 2026-10-28 15:09:12 -03:00
waozi 30e9145274 Update only changed DOM paint styles 2026-10-28 14:12:14 -03:00
waozi f8afe97f53 Render compiled DOM apps with native HTML and CSS 2026-10-28 14:04:39 -03:00
waozi 5b2bfb71fe Keep the text caret visible when the phone keyboard opens 2026-10-28 11:29:42 -03:00
waozi f099d93c55 Add compiled semantic DOM app host 2026-10-28 04:26:40 -03:00
waozi cb10924389 Forward hosted text keyboard requests to the session 2026-10-28 03:16:33 -03:00
waozi 8897684d02 Preserve loading indicator compatibility with existing portable hosts 2026-10-27 23:50:42 -03:00
waozi f5bba9e960 Resolve hosted loading colors without native style dependencies 2026-10-27 23:45:55 -03:00
waozi 6dd27bed30 Resolve host theme services in the loading screen test 2026-10-27 22:57:26 -03:00
waozi dd29b98ce4 Add a shared responsive loading screen for native and hosted apps 2026-10-27 22:56:44 -03:00
waozi b6cba06375 Use the Ziran setup that restores prebuilt standard header paths 2026-10-27 20:39:11 -03:00
waozi 8dc3318d0d Find the standard modules with the prebuilt Ziran in CI
The prebuilt compiler looked for std/ only where it was built, so CI
tests failed to import vec and c_string. The current Ziran setup action
links std/ and include/ where the locked compiler looks.
2026-10-27 19:09:51 -03:00
waozi 3e4cecdb0f Repaint separate changes apart instead of everything between them
A frame's damage was one rectangle around every change, so Pip bobbing
above Shovey's board while Shovey walked below it repainted the whole
board each frame: about 250 tile draws a frame instead of 40.

Damage now keeps up to four areas that do not touch, and the browser
canvas clears and replays them under one clip. Hosts that read only the
joined area are unchanged.
2026-10-27 18:50:47 -03:00
waozi 5a0499d8ca Install CI packages from the canonical Ubuntu archive
Package setup sometimes stalled on the runner mirror, once for 44
minutes. The Ziran setup action now installs each job's packages, with
their recommended packages as before, from the canonical archive with
time limits.
2026-10-27 18:48:20 -03:00
waozi 8b04af9097 Reuse laid-out text on the canvas host and confirm the last image first
The browser canvas never bumped the glyph metrics revision, so every
label was measured again each frame. Font loads and releases now bump
it, and an opened canvas starts at a nonzero revision.

An image asks for its width, height and texture in turn: the lookup
checks the asset it found last before hashing the path.
2026-10-27 18:28:11 -03:00
waozi 10e8c9de2e Use the prebuilt Ziran in CI and keep its build directory spelling
Kryon passed Ziran's own build directory to its make as an absolute path,
which made Ziran rebuild every object once more after any plain make in
the same checkout. Kryon now passes it the way Ziran spells it. CI sets
up the locked Ziran with its setup action, which downloads the prebuilt
compiler and reuses cached package checkouts, and package installs have
time limits.
2026-10-27 18:24:59 -03:00
waozi 3fad223419 Keep Play Billing's Kotlin libraries on one version
Play Billing's AndroidX libraries bring Kotlin 1.6 and 1.8 standard
libraries whose classes collide in a release build; the Kotlin BOM
aligns them.
2026-10-27 17:19:02 -03:00
waozi 773910ac25 Copy paint snapshot text by block and look canvas images up by hash
Every frame stores each paint command's text and asset path for the next
frame's damage check. The copy found the destination block for each byte
(two checked indexes and a 64-bit divide and remainder per byte): 7.4% of a
Moto's frame in Shovey's browser page, 1.9% copied one run per block
through the block's address. The browser canvas also compared every cached
image path byte by byte for each image drawn; entries now carry a hash and
compare bytes only on a match.
2026-10-27 17:16:02 -03:00
waozi dc3e8be808 Reach Play Billing without activity code
kryon/play_billing now loads org.kryonlabs.play.PlayBilling through the
activity's class loader, so any Kryon app (including ones with their
own activity) gets Play Billing by adding the gplay sources and the
billing library; editions without them answer empty.
2026-10-27 17:15:48 -03:00
waozi ec0e4063b3 Choose an Android app's edition with one property
-Papp.edition=direct, fdroid or gplay picks the edition: the Google Play
edition gets Play Billing and the GOOGLE_PLAY define, the F-Droid
edition the FDROID define. kryon/play_billing adds typed helpers
(PlayBillingProducts, PlayBillingBuy, PlayBillingDone, PlayBillingRead)
so apps need no JSON.
2026-10-27 17:08:23 -03:00
waozi 011f4a14a3 Add Google Play Billing for Google Play editions of Android apps
Built with app.googlePlay=true, the Android template adds Play Billing
9.1 (Android 6+) and org.kryonlabs.play.PlayBilling. kryon/play_billing
reaches it through the activity's playBilling bridge: load one-time
products with their local prices, open Play's purchase sheet and list
purchases until the app's server has credited them. Other editions and
older activities carry no Google libraries and answer empty.
2026-10-27 17:06:27 -03:00
waozi e09f38160d Export the damage-only canvas UI frame end to browser hosts
Hosts composing their own lifecycle with kryon/Canvas, such as Arcade's
browser edition, could only end a frame with EndFrame and repainted the
whole page every frame. EndCanvasUiFrame clears and replays only the
damaged pixels, as Kryon's own canvas runners already do.
2026-10-27 15:05:44 -03:00
waozi 0931212f92 Compare the template profiles after the toolchain is in the fresh cache
In CI the first command in the templates test's empty cache fetches and
builds the locked Ziran and reports it, which broke the exact comparison
of kryon profiles. kryon check desktop now runs first.
2026-10-27 01:15:02 -03:00
waozi 1fd45c1fea Check that each template is created, without rendering its terminal screen
The templates test no longer runs each new project through kryon run and
ziran run to compare its first terminal frame; it checks that every
template is created with a resolved kryon manifest.
2026-10-26 22:56:20 -03:00
waozi a3a53458dc Build with Ziran 79ad8431 2026-10-26 22:53:23 -03:00
waozi f60ed202b8 Import Session where the desktop runtime keeps the test driver's session
raylib_runtime.zi stores the session the test driver validates pointers
against, but did not import session, so programs that check every module
together, such as Breeze's native build, rejected Session as unknown.
2026-10-26 22:53:23 -03:00
waozi cc9d2d7610 Drive desktop applications under test
The desktop host now feeds the test driver like the canvas and Android
hosts: a test process can read the committed widget tree, press widgets,
type and send keys through the KRYON_TEST_DRIVER directory. Without that
variable nothing changes.
2026-10-26 22:34:26 -03:00
waozi 65d207e21e Export the platform URI opener for package applications 2026-10-26 20:47:48 -03:00
waozi d1fda88fc3 Align placed fields and dropdowns and enable desktop scrolling 2026-10-26 20:33:31 -03:00
waozi b648210fb3 Honor LDLIBS when linking desktop applications
An application's manifest names system libraries for ordinary ziran
builds, but a Kryon project tool owns the desktop link line and dropped
them, leaving data-backed applications (SQLite, spatial, math) no way to
link their native libraries. Pass LDLIBS through like plain ziran builds
do.
2026-10-26 19:27:52 -03:00
waozi 03df0ce76f Link libcurl for desktop http transfers
The http_transfer desktop worker drives libcurl from a detached thread,
but the host link line never named it, so any desktop application using
HTTP failed to link. Prefer a libcurl.pc when the machine has one and
fall back to the runtime library by exact filename, which needs no
development package.
2026-10-26 18:02:52 -03:00
waozi 68f2e8d30b Preserve image colours during opacity fades 2026-10-26 13:12:14 -03:00
waozi 7b03785203 Wait for the owned desktop test window to become visible 2026-10-26 12:28:51 -03:00
waozi b52c3986ed Share swipe feedback and mobile direction pad layout 2026-10-26 11:47:54 -03:00
waozi ab872e3dcd Let web application memory grow on demand
Real applications easily hold more data than Emscripten's fixed 16 MiB
initial heap; without growth their allocations fail and, when an
application keeps a lying capacity over a null allocation, heap writes
corrupt the module. ALLOW_MEMORY_GROWTH keeps small applications at
their small footprint while letting data-heavy ones allocate.
2026-10-26 08:14:50 -03:00
waozi 43eb767da7 Give image widgets their image semantics
Image now sets the SemanticImage kind alongside its semantic detail, so
the DOM host reconciles an asset-backed image into a real <img src>
element. Until now nothing set that kind, and a document-layout image
rendered as a plain div with alt text but no source.
2026-10-26 05:34:50 -03:00
waozi 45ab2d6133 Expose the page origin to applications
GetRouteOrigin returns the browser location's scheme://host[:port] once,
so a DOM or Canvas application can turn its own relative paths into the
absolute http/https URLs the HTTP transfer layer requires. The route
test checks the file: origin the headless harness loads.
2026-10-26 04:08:39 -03:00
waozi bab522f4ed Expose Canvas exit-key selection to applications 2026-10-26 03:51:16 -03:00
waozi c7e7a3aa8c Allow right clicks as game board taps 2026-10-26 03:14:20 -03:00
waozi 7f54d91ea7 Export tree_draw and scroll_device by their file names as well
Projects import them as kryon/tree_draw and kryon/scroll_device, the same
names a --module-path build uses.
2026-10-26 02:49:53 -03:00
waozi 803fd07661 Export the press widget and bundle time modules to projects 2026-10-26 02:46:22 -03:00
waozi 919a18d7fc Keep complete game frames visible while pictures load 2026-10-26 02:44:01 -03:00
waozi 1201ec2f3f Name the Android CMake project without spaces
An application named "Jungle Academy" made CMake look for a language
called Academy.
2026-10-26 02:41:17 -03:00
waozi d9937576f2 Draw an allowed image the host cannot resolve yet as loading
Art a collection downloads after it opens is allowed before it arrives;
failing the frame for it closed the library.
2026-10-26 00:54:38 -03:00
waozi b20836cf38 Treat a missing document as missing in the browser
Emscripten numbers errno values as WASI does, so a missing file reports 44
there, not 2. The browser counted every first read of a game's record as
an error, and games such as Shovey stopped on their first frame.
2026-10-25 23:39:02 -03:00
waozi 92ca1fd68c Apply disabled text opacity once when styled 2026-10-25 16:26:05 -03:00
waozi f0be5a9724 Export the standard asynchronous file downloader 2026-10-25 16:07:06 -03:00
waozi 46c52b83db Support explicit rounded image corners across hosted UI 2026-10-25 16:01:47 -03:00
waozi d5720a9c7f Present prepared desktop pixels after SDL maps its surface 2026-10-25 15:01:38 -03:00
waozi 445e5e90f9 Preserve explicit visibility during the first desktop frame 2026-10-25 14:56:28 -03:00
waozi ca97b1b58f Present the first desktop frame before showing the window 2026-10-25 14:49:54 -03:00
waozi b872d665b7 Keep dialog panels readable in app palettes 2026-10-25 14:42:50 -03:00
waozi a69dfdef7f Report desktop download totals while bytes arrive 2026-10-25 13:17:16 -03:00
waozi 400405ab03 Forget only the images under a changed folder
InvalidateRaylibAssets and InvalidateCanvasAssets drop every image, so a
host that replaced one folder of content, or merely found assets that had
been missing, made everything on screen blink while it loaded again: Inner
Breeze's games flickered each time an app finished opening or a practice
pack opened. InvalidateRaylibAssetsUnder and InvalidateCanvasAssetsUnder
forget only the images whose path starts with a folder, on the render
thread like the full invalidation, and keep every other image.
2026-10-25 03:05:53 -03:00
waozi 655b48059c ImagesPending: how many images the backend still reads or decodes, asked of the render thread, so a host can cover an app it has just opened until its pictures are ready (images_pending module; 0 in the browser) 2026-10-25 02:58:41 -03:00
waozi 2e411ce0c7 A typeface bakes ASCII, Latin-1 and common punctuation when registered; other glyphs bake the first time text needs them, so a phone's start no longer waits about 0.4 s for Latin Extended, Greek, Cyrillic and symbols 2026-10-25 01:52:22 -03:00
waozi 4962a77c69 The native ZX player starts at KRYON_ZOOM, as other Kryon desktop apps do
A bundle on the ZX player always drew at 100%, so a phone-sized window
showed desktop-sized controls. KRYON_ZOOM now sets its starting density;
the viewport and pointer already follow the zoom.
2026-10-25 01:11:29 -03:00
waozi 3a536faa94 Export the standalone SvgIcon widget for package apps
Entity, Breeze and Shovey already draw SvgIcon from kryon/svg_icon_widget,
which only resolves through local overrides. Exporting the widget and its
props makes the icon surface importable from locked package builds too.
2026-10-25 00:54:58 -03:00
waozi fade061f2e Bundles draw sliders and progress bars through their host
Inner Breeze's practice manuals and settings move into the Practices
package, and they change speeds and durations with sliders and show a hold
with a progress bar. Slider, DiscreteSlider and Progress are now hosted:
the host drags the slider with its own pointer and answers the value, and
paints the progress bar.
2026-10-24 21:10:50 -03:00
waozi 3d10054249 Hosted apps may import up to 256 host calls 2026-10-24 20:35:57 -03:00
waozi 8e2d0bc46b Bundles draw lines, circles, rings and triangles through their host
A portable bundle could draw boxes and icons but no line at an angle, so a
chart's trend lines and dots needed compiled screens. Kryon's shapes are now
hosted like Box: the bundle sends their props and the host fills them with
its renderer's RasterTriangles, which every Kryon renderer provides. The
widget host test stubs that rasterizer, as it draws nothing.
2026-10-24 20:24:00 -03:00
waozi 235f28cda2 Bundles frame form sections and size toggles through their host
A portable form could not draw a fieldset around its sections or place a
toggle at a row's end, because both needed the host's style and font
metrics. Fieldset is now hosted like Box, and the new toggle_measure module
answers the size a toggle needs, from its host as ToggleSize. The host
encodes the answer with the Vector2 encoder, now part of the widget codec.
2026-10-24 20:00:33 -03:00
waozi 2da3b99f87 Bundles draw segmented controls through their host
A portable bundle could not show a row of choices such as Habits' week and
calendar views, so Inner Breeze drew them in compiled screens. Segmented
controls are now hosted like tab bars: the bundle sends its props and up to
32 options and the host draws them with its own widget and style.
2026-10-24 19:27:27 -03:00
waozi a060663d05 Unrotated images fill whole pixels with edges rounded down like their clip, so pictures meeting at a fractional edge share its column instead of leaving it empty 2026-10-24 19:24:46 -03:00
waozi df00256888 Image clips round both edges down instead of truncating position and width apart, so images meeting at a fractional edge leave no gap 2026-10-24 19:09:12 -03:00
waozi a51edf0680 Native ZX player shows the app's name on a loading frame while its bundle loads 2026-10-24 16:52:08 -03:00
waozi fed12f5029 Keep borrowed glyph views out of atlas caches
A single-glyph font view points inside its parent atlas. Inspect that glyph directly so replacement of the parent cannot reuse a cached interior pointer. Cover address reuse in the real font fixture.
2026-10-24 06:33:53 -03:00
waozi c8d44d03f7 Decode Android images from owned frame sources
Capture borrowed asset bytes during app composition, decode on a bounded background worker, and upload only on the render owner. Keep loading frames responsive and discard stale results across resource generations.

Avoid empty text measurement round trips and let active frame pacing interrupt a previous idle rate. Add real GLES frame and texture hash coverage for borrowed sources, worker ownership, context changes and retained frames.
2026-10-24 06:25:16 -03:00
waozi 0ed72b332f Keep font restoration independent of mutable registry names
Use stable font slot tickets when lazy loading a font can replace registered name storage. Check the browser font branch from source and saved IR in the pagination regression.
2026-10-24 04:19:58 -03:00
waozi 349a01fbdd Support text pagination and scoped reader fonts
Measure screen-sized text pages from the drawing props, preserve UTF-8 boundaries, and apply typeface and line spacing consistently through hosted widgets and queued paint. Keep hosted font assets inside their app resource policy.
2026-10-24 04:14:11 -03:00
waozi 6d004da4fc Share compiler setup for browser behavior tests 2026-10-24 03:58:32 -03:00
waozi e6a3509dfc Add LoadingIndicator, the one loading animation for apps and hosts, with laws 2026-10-24 03:48:25 -03:00
waozi ca63b97722 Preserve rejected-frame coverage after duplicate key recovery 2026-10-24 03:45:51 -03:00
waozi 8a433febd2 Name the GTK tray's program after the tray id
Panels name a tray after GLib's program name, which is the executable's
file name unless set, so a desktop build showed up as
breeze-linux-x86_64. The tray thread now sets the program name to the
tray's id before GTK starts.
2026-10-24 03:45:29 -03:00
waozi 058263d580 Pipeline Android frames on separate app and render threads
Run input, application code, layout and paint recording on a persistent
app worker while the NativeActivity owner replays and presents the preceding
owned frame. Keep graphics resources and mutable font atlases on that owner,
copy frame storage and scalar measurements, and attach JNI independently on
each host thread. Drain pending paint before destroying its resources.

Route full, partial and retained paint through the recorder, preserving
image texture metadata. The canonical Android runners enable the pipeline
by default; custom hosts call the shared RunRaylibAppFrame API. Existing
desktop and web event loops retain their serial path.

Local tests cover owned frame storage, overlapping stages, all flush paths,
JNI attachment lifetime and offscreen GLES frame/texture hash equivalence.
Moto matched runs retain p95 17.4 ms, with fps 56.1-57.0 before and 56.5-57.5
after; the busiest thread falls from 76.6-81.9% to 54.5-57.6% of one core.
Total CPU rises; this checkpoint provides headroom rather than a large fps gain.
2026-10-24 03:43:29 -03:00
waozi fa9537cf8c Include widget key helpers in the core archive 2026-10-24 03:41:28 -03:00
waozi 45db18a5db Expect a repeated widget key to keep the frame in the label test
Since db5d286d a widget submitted again under the same key is drawn under
a derived key and reported, instead of rejecting the frame. The label
test still expected the rejection; it now checks that the first widget
keeps the key, the repeat is drawn, and the frame reports the key.
2026-10-24 03:39:37 -03:00
waozi db5d286d74 Draw a widget with a repeated key under a derived key instead of rejecting the frame, with laws 2026-10-24 03:35:20 -03:00
waozi b8ce649beb Let apps link Window with the raylib host again 2026-10-24 03:32:44 -03:00
waozi 401415f107 Share portable player value parsing and raster dispatch 2026-10-24 03:32:32 -03:00
waozi c85a8a507b Encode photo previews' JPEG blocks on every processor
Each row of 16 by 16 units is converted, transformed and quantized into
its own band of coefficients in a #parallel region; the Huffman coding,
whose DC values chain from block to block, then runs in order. The
preview bytes match the serial encoder exactly (192 sizes, channel
counts and orientations). Lock Ziran 11405473, which checks callees'
writes in parallel regions, reaches bound providers exported under
another symbol in native code and converts Go conditional arms.
2026-10-24 03:26:48 -03:00
waozi 9a17c574f7 Make carousel alpha widening explicit for Go 2026-10-24 03:18:25 -03:00
waozi ce510505c3 Canvas app runner: sample the scroll device each frame
The compiled browser host never called BeginScrollFrame, so every Scroll
in a compiled page ignored the wheel, drags and flings: Shovey's level list
on the website, embedded or not, could not scroll. It now samples the
pointer, wheel and clock like the bundle and Android hosts.
2026-10-24 03:14:24 -03:00
waozi 4ef16404d8 Name every window and page after its app instead of Kryon Ziran 2026-10-24 03:14:20 -03:00
waozi 76e4f4bd3a Scale and turn image previews on every processor
Photo previews are scaled down and turned upright row by row in
#parallel regions: each output row takes its own window of the output
and each output pixel sums its own block of source pixels, so the
preview bytes match the serial version exactly (checked on 192 sizes,
channel counts and orientations). Lock Ziran 5f003e58, which accepts
slice windows in parallel regions and runs native builds on one thread
per processor.
2026-10-24 03:07:57 -03:00
waozi 65381f3c1e Share hosted slice validation and scalar field construction 2026-10-24 03:03:21 -03:00
waozi 6e05d65c2b Keep a cover carousel's logo and caption in place while covers slide, with round arrows, a pill action and compact dots 2026-10-24 02:51:36 -03:00
waozi 6b252854e6 Wait for app release before checking hosted movement stops 2026-10-24 02:49:09 -03:00
waozi 1f651d2b8f Share font decoding and fill chunks without unused data bindings 2026-10-24 02:32:15 -03:00
waozi 17d71f99e8 Share paint text block storage across buffer sizes 2026-10-24 02:14:05 -03:00
waozi c3840d2e3a Look up cached textures through a compact hash array
Each cached asset holds its 1 KB path inline, so finding a texture
stepped through up to 128 entries about 1 KB apart. On the Moto this
lookup took 13% of all CPU while Shovey ran. The path hashes now sit in
their own array, which a lookup scans before comparing any path bytes.
2026-10-24 01:54:09 -03:00
waozi ccc27513c7 Show current showcase projects and retire the Krait page
The showcase lists Inner Breeze, Pass and Terminal; Taiji, Rill, Shelf
and Krait leave it, along with the ide page that pointed at Krait.
Plan 9 build leftovers go too.
2026-10-24 01:53:19 -03:00
waozi 9bd8538c7f Share unexpected raster assertions between test hosts 2026-10-24 00:43:18 -03:00
waozi 54ef5822c4 Share C, Go and ZX execution for main tests 2026-10-24 00:19:11 -03:00
waozi 3e29e2059e Share Android process setup with hosts that run their own loop
Android leaves TMPDIR unset, which natively compiled ZX apps need for
their scratch files, and only Kryon's own runner enabled the test driver.
android_process holds both, and AndroidProcessPrepare runs them for any
Android host.
2026-10-24 00:11:44 -03:00
waozi 47963194ca Initialize local widget records directly 2026-10-23 23:22:27 -03:00
waozi f912ce929d Retire the Plan 9 and plan9port Libdraw hosts 2026-10-23 23:08:47 -03:00
waozi dae0401fe7 Keep build and test gates on C, Go and ZX 2026-10-23 22:54:13 -03:00
waozi c38a0d7b70 Let DirectionPad float over a game board
A floating pad has lighter arms, a lighter hub and outlined arrows, so the
pieces under it stay readable. Drawn after the board, it takes the presses
there, as the topmost widget does. The hosted ZX probe uses the floating pad.
2026-10-23 22:38:50 -03:00
waozi 9d5cf7cc77 Share isolated widget test sessions and target matrices 2026-10-23 22:13:04 -03:00
waozi 935d5fc164 Keep still mesh frames cheap and compile Android hosts for speed
Comparing a retained frame's image meshes indexed the kept block for every
point, which copies the whole block each time: a still page of figures took
most of a second per frame on a phone. Read the block through its address.
Android hosts and raylib are compiled with -O2 instead of -Oz, because rlgl's
per-vertex batching and app drawing run every frame.
2026-10-23 21:56:38 -03:00
waozi a07e66c260 Generate gallery metadata with its editable examples 2026-10-23 21:51:25 -03:00
waozi fb011208c4 Construct single-use records at their return or call 2026-10-23 21:39:24 -03:00
waozi 78cdf52802 Android: touch drags scroll Scroll views, and Android before 10 finds Roboto
The canonical Android host now samples the pointer for the scroll device
each frame, as BundleApp hosts do, so Scroll views follow touch drags.
Android before 10 has no font lookup; the interface face is found by its
standard path there instead of falling back to raylib's bitmap font.
2026-10-23 21:34:35 -03:00
waozi 809a0f09d9 Generate editable gallery snippets from their canonical examples 2026-10-23 20:46:56 -03:00
waozi 3c373619b3 Resolve Raylib sources only when its archive is needed 2026-10-23 20:26:12 -03:00
waozi 709503d086 Share setup across standalone behavior tests 2026-10-23 20:05:49 -03:00
waozi cfdae56547 Check in the verified ZX website runtime and gallery assets 2026-10-23 19:50:45 -03:00
waozi 1d2d987699 Rebuild the gallery and deploy the verified website artifact 2026-10-23 19:32:00 -03:00
waozi 64ef9a68fd Build and verify the ZX browser runtime before website deployment 2026-10-23 19:27:01 -03:00
waozi a046500a6d Share starter page layout geometry across templates
Keep the shared geometry in one Ziran UI module. Retain app-owned label and text helpers in each generated layout file, preserving the existing widget surface and layout calculations.
2026-10-23 19:23:05 -03:00
waozi 49242a6184 Pin the ZX compiler for portable profiles and CI 2026-10-23 19:22:10 -03:00
waozi 1c9e87beaa Preserve encoded font data across the portable format rename 2026-10-23 19:00:33 -03:00
waozi 68e54c057c Use the ZX suffix for watched releases and retain existing build output 2026-10-23 18:57:46 -03:00
waozi cb637eabcd Use ZX portable executables throughout players and project tools 2026-10-23 18:55:42 -03:00
waozi 689a953ca1 Generate deferred widget codecs in consuming modules
Reuse imported storage and discover supplied operations before generating missing codecs from schema metadata. Preserve complete-provider output and exercise partial providers across source and saved native targets. Regenerate the library against the current widget property records.
2026-10-23 18:49:12 -03:00
waozi 60096945f5 Preserve source-over alpha in retained Raylib frames 2026-10-23 18:35:23 -03:00
waozi 55af1b53b1 Keep Canvas widget pixels between frames and reduce sprite bridge work 2026-10-23 17:50:54 -03:00
waozi 45bac62008 Canvas app runner: run the app in mini mode when the page address asks for it 2026-10-23 17:47:06 -03:00
waozi 2869d68b62 Run a portable app compiled into the browser page, answering its app context calls and keeping its saves where a ZIB player does 2026-10-23 17:45:21 -03:00
waozi b1d4faa4de Keep reader scrollports independent of focused fields 2026-10-23 17:23:14 -03:00
waozi d1d167df9b Let text readers preserve manually chosen scroll position 2026-10-23 17:19:32 -03:00
waozi 945f2022c6 Prefer accelerated presentation for pixel hosts 2026-10-23 17:06:48 -03:00
waozi 3bb0c53fc5 Share widget test raster bindings and empty mesh callbacks 2026-10-23 17:03:49 -03:00
waozi b4aa1755ed Remove unused UI and backend helpers 2026-10-23 16:40:27 -03:00
waozi 48f18b3897 Share the widget source and saved-IR test matrix 2026-10-23 16:21:44 -03:00
waozi 2700ae5de4 Let the native ZIB player run app.zib from its own folder, titled by app.title
An application ships as the player, its bundle, its title and the font in
one folder, and starts without arguments.
2026-10-23 15:53:15 -03:00
waozi 36e34ec860 Remove unreferenced paint policy helpers 2026-10-23 15:52:59 -03:00
waozi 9edff5f2f8 Report where a swipe began, where it is and which way it leans while held
Games can show which way a swipe is going, like an arrow under the finger;
the hosted browser test drags and checks the lean.
2026-10-23 15:42:45 -03:00
waozi 399c008c57 Retain hosted reply text through the updated portable runtime 2026-10-23 15:27:25 -03:00
waozi 00fe5e1130 Share hosted record field decoding and validation 2026-10-23 15:09:13 -03:00
waozi 923a6897a7 Remove unreferenced text-input policy helpers 2026-10-23 14:52:24 -03:00
waozi 610ca0bc01 Draw images on the Cairo host with sharp pixels unless they ask to be smooth
Raylib, pixmap and the browser canvas already sample an image's nearest
pixel when ImageProps.smooth is off; the Cairo host always blended, so pixel
art came out blurred on the Linux desktop. Smooth images keep Cairo's good
filter.
2026-10-23 14:16:50 -03:00
waozi df24f40ad7 Add DirectionPad, a four-way pad for touch games, and run the test driver on Android
Pressing an arm steps at once, holding repeats like an arrow key, sliding
onto another arm turns and the hub stops; a quick tap steps once. Laws prove
the arm and timing rules, and the hosted browser test holds, slides, rests
and taps it. A debuggable Android build runs the test driver when its
private files hold a kryon-test-driver folder, so phone tests can press
widgets by label.
2026-10-23 13:40:46 -03:00
waozi a024dc573b Compile the NDK's native app glue from a copy in the build tree
Its path in the NDK carries the install location into object and module
names, which ThinLTO hashes into symbol names. Builds on different
machines then got different build IDs, so F-Droid could not reproduce
the release library. The relative NDK path map is no longer needed.
2026-10-23 03:53:56 -03:00
waozi 531273db11 Refuse to open a window that nobody can see
Without a reachable display SDL falls back to its offscreen or dummy video
driver, and the app then ran invisibly forever. WindowVisible reports that,
and OpenRaylib now fails instead.
2026-10-23 02:46:12 -03:00
waozi 717fcce64f Map the NDK's build-relative path in reproducible Android builds
Ninja names native_app_glue relative to the build directory, a spelling
that carries both the checkout and NDK locations into the build ID.
2026-10-23 02:12:09 -03:00
waozi 8ab42b84e0 Compare what the terminal template shows through ziran run, not every byte of a first run 2026-10-23 01:54:02 -03:00
waozi 884bc1108d Add SwipeRow, a list row that a tap or a sideways swipe acts on, and let a scroll give a sideways drag to its row 2026-10-23 01:32:53 -03:00
waozi 7f9008bc19 Give each secondary window its own pointer for the widgets drawn in it 2026-10-23 01:18:50 -03:00
waozi e169a7ee65 Let app contexts show an unchanged quiet frame again without running the app 2026-10-23 00:30:48 -03:00
waozi 4d32d36956 Name the shared mini module apart from apps' own mini_mode modules 2026-10-22 23:16:47 -03:00
waozi b9b57427c2 Export the shared mini mode modules to package consumers 2026-10-22 23:09:27 -03:00
waozi d425a85876 Share mini mode across apps and keep wheel scrolling inside embedded pages 2026-10-22 23:06:41 -03:00
waozi a1f4e48999 Wait for browser storage to confirm durable saves 2026-10-22 21:47:03 -03:00
waozi f4b41d137f Export existing browser bundle host services 2026-10-22 21:19:15 -03:00
waozi 7c09f898c1 Pass wheel and drag samples to portable app scroll containers 2026-10-22 18:55:04 -03:00
waozi 8d55d98ee2 Batch browser document flushes to keep startup and input responsive 2026-10-22 18:21:19 -03:00
waozi 6b8edbdba0 Compare template screens without one-time dependency checkout receipts 2026-10-22 18:11:14 -03:00
waozi 890111608a Keep carousel controls and cover keys in separate widget namespaces 2026-10-22 18:08:10 -03:00
waozi 0af2fae4f9 Share cover carousel navigation and artwork across portable and native apps 2026-10-22 17:54:22 -03:00
waozi cff9677348 Use the app service capability for hosted tile sampling 2026-10-22 17:32:15 -03:00
waozi 7774bd5854 Export the shared Android document picker for package consumers 2026-10-22 17:12:51 -03:00
waozi aabd9a2b61 Reuse browser mesh surfaces while copying only the active crop 2026-10-22 17:06:20 -03:00
waozi 6b9fed32f5 Export scoped widget palettes for native package hosts 2026-10-22 16:59:40 -03:00
waozi e1617a7ab2 Scope palette tokens and share tile sampling and image transforms 2026-10-22 16:45:51 -03:00
waozi faab6119f7 Give widget parts their own keys and log Android frame failures
Joystick and the cell-by-cell TileMap took the keys after their own, so an
application's next keys could collide and Android closed the app. Parts now
use WidgetPartKey. Android errors reach the system log with the frame step
and key that failed.
2026-10-22 15:29:42 -03:00
waozi 7b02aedee4 Deliver browser key repeats to hosted applications 2026-10-22 15:23:01 -03:00
waozi 83c1cc434c Exercise held game controls in the portable browser host 2026-10-22 15:05:17 -03:00
waozi 54667e8fd0 Avoid redundant browser mesh multisampling 2026-10-22 15:01:31 -03:00
waozi c19c3566b0 Reduce browser mesh work and deliver final accessibility replies 2026-10-22 13:21:39 -03:00
waozi c79608ce8a Batch browser mesh vertices and retain each image tint 2026-10-22 11:05:09 -03:00
waozi 034c90bc33 Batch browser mesh vertices and preserve ordered texture updates 2026-10-22 11:04:43 -03:00
waozi 538ff10dcd Batch browser image meshes and refresh changed resources 2026-10-22 08:22:56 -03:00
waozi 05e3cc642c Compress opaque still images without flattening other formats 2026-10-22 03:37:04 -03:00
waozi aa07f9b144 Avoid font atlas rebuild cascades during text layout 2026-10-22 02:54:44 -03:00
waozi 3f9dc9505f Report bounded HTTP response capacity failures 2026-10-22 02:33:08 -03:00
waozi 08969407c4 Dismiss the topmost modal or popup with Escape 2026-10-22 00:05:01 -03:00
waozi 20b187a5ef Keep manual scrolling usable while text inputs stay focused 2026-10-21 23:15:59 -03:00
waozi 160556441e Reuse repeated frame labels and image paths within the semantic text budget 2026-10-21 22:31:15 -03:00
waozi b3ea1c813e Support system-picked Android document saves 2026-10-21 22:19:35 -03:00
waozi f83bfdc796 Keep the window fixture in sync with icon texture uploads 2026-10-21 22:06:19 -03:00
waozi 018e94781b Expose session-scoped pointer samples to hosted apps 2026-10-21 21:55:06 -03:00
waozi eea5afad88 Keep stepping while a game's swipe area is held
SwipeArea takes repeat_seconds: a swipe that stays down steps its way at once and then repeats like a held arrow key, and a press held in place reports held steps towards itself. Without it, steps still come only on release.
2026-10-20 20:12:30 -03:00
waozi 10be25fd4d Support the shared Dropdown widget in hosted app packages 2026-10-20 19:41:26 -03:00
waozi 20f12cd610 Start embedded web apps directly and retain batched image paths 2026-10-20 15:13:39 -03:00
waozi 7c103624d1 Preserve image colours when applying widget palettes 2026-10-20 14:52:14 -03:00
waozi 3ac50079a4 Keep compact menu labels inside their hit areas 2026-10-20 11:37:07 -03:00
waozi 9f50fb47c0 Share input protocol and native file picker with hosted apps 2026-10-20 11:35:29 -03:00
waozi f8fd64f4ce Expose desktop document titles and file drops 2026-10-20 10:40:16 -03:00
waozi 48c9e03dad Let a hosted app draw its widgets in its own palette, whatever host draws them 2026-10-20 02:10:03 -03:00
waozi e0a3334902 Let a hosted app use its host's theme colours
A shared app such as Self's profile painted its own fixed greens, so it
ignored the theme of the app hosting it. kryon/app_theme's AppThemeColor
asks the host for a theme token's colour and keeps the app's own colour on
a host that lacks the token or predates the module.
2026-10-20 01:43:46 -03:00
waozi 0d524712b0 Show a hosted app's unchanged frame again without running it
A page that stays the same while something else moves, such as a chat
under a practice in its small window, ran its whole program every frame:
on a slow phone, half of each frame of Lumi. HostedAppRunFrame records a
quiet frame, one the host says nothing reached and that does not
animate, call by call through HostedAppCall. Later quiet frames ask its
recorded reads again and, when every one answers as it did, make its
widget calls again with the arguments they had, so the page, its hover
and its tree stay live while the program does not run. A read that
answers differently runs the app; a widget that does, such as a scroll
still settling, runs it for a while before quiet frames are recorded
again. Calls reach the host through the replay state, which stays where
it was made wherever the host keeps the app.
2026-10-20 00:51:40 -03:00
waozi d2c3ad1d67 Keep the retained test's ClearBackground out of the shared Raylib host
The graphics test imports the retained test's Raylib host beside its own,
which already defines ClearBackground, so e17dd275's stub there stopped
the graphics test linking. The retained test now defines it itself.
2026-10-20 00:44:58 -03:00
waozi e17dd275e9 Give the retained frame test the ClearBackground it now presents with
Presenting a retained frame clears the window first since 89810768, and
the test's Raylib stand-ins lacked that call, so the test no longer
linked.
2026-10-19 23:57:24 -03:00
waozi b257757904 Remove fourteen UI modules nothing uses
rows, primitive, profile_header, drag, drag_drop, popup_policy,
popup_ownership, paragraph, route, window_policy, app_shell_layout,
capability_layout, locale_defaults and preference_policy, with their
laws, props and tests: about 2,500 lines that no app, host or other
Kryon module imports. They were ports of the C runtime's policy layer
that apps never took up, and several repeated helpers kept elsewhere,
such as a second pixel scale and a rectangle constructor.
2026-10-19 23:57:24 -03:00
waozi 806fcd20e1 Mark unused codecs in generated widget decoders
A record of scalars and strings decodes without its codec, and hosts that
build Kryon with -Wextra -Werror stopped at the unused parameter.
2026-10-19 19:46:14 -03:00
waozi fc249a7e63 Mark TextLinkAt's unused session so strict builds compile it
Hosts that build Kryon with -Wextra -Werror, such as Inner Breeze's
Android tests, stopped at the unused session parameter.
2026-10-19 19:34:25 -03:00
waozi d69ad3d38f Let a navigation item offer to close
A compact item marked closeable draws an X in its corner. A tap on the X
reports the item as closed and never as clicked; a tap elsewhere on the
item still clicks it.
2026-10-19 18:38:45 -03:00
waozi b76f758a76 Open bundles a host needs next on their own threads
Opening a bundle reads and checks its whole program, which takes a phone
up to a second for a large app, and Inner Breeze opened seven one after
another before its first frame. BundlePreloadStart opens bytes on another
thread; HostedAppOpenPreloaded takes the result, or opens the bytes itself
where there are no threads or the preload failed.
2026-10-19 17:27:52 -03:00
waozi a78576db72 Export bundle_names so hosts can match widget modules as widget_host does
A host that intercepts a hosted app's widget calls, such as Werkzeug's
Android text bridge, must accept the package-qualified module names that
package builds give them. Its exact comparison missed them, so typing on
Android never reached a bundle's text field.
2026-10-19 17:02:07 -03:00
waozi e985d83cdd Paint icons from one texture each where the host draws textures
A screen of icons queued hundreds of rectangles per icon: on a Moto e6
the habit shop's grid of 75 symbols spent over half of each 95 ms frame
queueing and drawing them. A host can now register SvgIconUseTextures,
and each cached icon is then one image of exactly the pixels its cells
paint. raylib registers in OpenRaylib, or through RaylibUseIconTextures
for hosts with their own window, and drops the textures with a lost
context. A texture leaving the cache is freed only after 64 more have
left, so a frame that still queued it draws it. Other hosts keep the
cells.
2026-10-19 16:43:30 -03:00
waozi 0c3799dd8b Keep the host's locale when the Linux file dialog starts GTK
GTK's first initialization switches the whole process to the user's locale.
With a decimal comma that broke portable app programs after a file dialog,
as the tray already guards against. Restore the previous locale right after
gtk_init_check.
2026-10-19 16:41:38 -03:00
waozi 909760ace8 Draw a hosted game's TileMap in one host call
A hosted game's board was one host call per cell: Pushy's 240 tiles
were the larger part of its frame on a phone. TileMap now hands the
whole map to the host as one call, which draws it with the native
TileMap. Each picture a cell shows passes the asset policy once, as
each cell's Image did, and the paint is the same: a test compares it
with a direct TileMap. Maps with more than 1024 cells, pictures or
names are still drawn cell by cell. The codec generator now encodes
slices of plain values such as []string and []s32.
2026-10-19 16:15:57 -03:00
waozi 7fa8826538 Let portable apps measure a wrapped paragraph with TextHeight
A bundle could measure a line's width but not how tall a paragraph wraps,
so pages guessed from character counts. TextHeight returns the height
Text takes for the text in its bounds' width, from the host's fonts.
2026-10-19 16:10:16 -03:00
waozi 3813511474 Find a hosted app's assets by hashing their names
A game drawing its board tile by tile named each tile's image asset by
scanning every asset of its bundle, tens of thousands of name
comparisons a frame. Each open bundle now gets a table that finds an
asset by a hash of its name, dropped when the bundle closes. Pushy's
frames under the VM bench went from 2.3 to 2.05 ms.
2026-10-19 16:06:39 -03:00
waozi ca749f72a5 Let portable apps draw a vector icon on its own with SvgIcon
A symbol beside a name or a coin beside an amount had no hosted widget:
only buttons carried icons. SvgIcon paints a Shape in the caller's color,
and bundles submit it to their host like the other widgets.
2026-10-19 16:05:44 -03:00
waozi 3e2f66e816 Keep many icons rasterized and paint them from their cached cells
A screen with more icons than the 48 cached slots, such as a grid of
symbols to choose from, rasterized every icon again on every frame. The
cache now holds 256 icons, lets the least recently painted one go first,
and keeps each icon's rectangles, so painting a cached icon only queues
them. Painting a 55-icon screen at phone density went from 30.6 ms to
1.9 ms a frame.
2026-10-19 16:05:44 -03:00
waozi 89810768a5 Repaint only what changed in a retained frame
A frame whose paint differed from the last one only in a small window,
such as a practice playing over a page, was painted whole. EndFrameDamaged
compares the frame's paint with the last frame's command by command and
reports the area the differing commands cover. A raylib host keeps its
previous frame's pixels outside that area with BeginRetainedDamage and
repaints only the commands touching it with PaintFlushArea. Presenting a
retained frame now clears the screen first, sparing tiling GPUs a load.
2026-10-19 15:02:44 -03:00
waozi 42301bba5b Flush Android's draw batch less often
rlgl's GLES2 batch holds 2048 quads, a few dozen anti-aliased rounded
shapes, so a phone frame flushed it many times, each upload into the one
vertex buffer the tiling GPU had not drawn yet. Android now builds raylib
with a batch of 8192 quads in two alternating buffers: on the Moto, Habits
under a playing practice went from 26 to 31 frames a second and Lists
from 50 to 55.
2026-10-19 14:55:26 -03:00
waozi c570449371 Keep the lines of recent texts while glyph metrics hold
A Text measured each line again for every word in it, and was laid out
twice a frame, so chat text cost most of a Moto frame. NextTextLine now
keeps the lines of recent texts, keyed by a hash of the text and its
layout inputs, while the host's glyph metrics revision holds. The raylib
backend now reports that revision, moving it whenever it loads, selects
or releases fonts, so TextArea's row cache also works there.
2026-10-19 14:41:11 -03:00
waozi ee8900d7a0 Find glyphs by hashing instead of scanning the font
raylib's GetGlyphIndex scans every glyph of a font, and text looked each
character up three or four times to measure and draw it: on a Moto that
was a third of a chat frame. Each baked font now gets a table that finds
a glyph by hashing its codepoint, and raylib measures and draws the
character from a one-glyph view of the font, so its arithmetic and
fallback to '?' stay exactly the same. Unloading a font drops its table.
2026-10-19 14:32:48 -03:00
waozi 828688710f Measure text in its own text_measure module
Adding TextWidth to text_widget changed the bytes of every portable
bundle built with it, including Inner Breeze's reviewed Apps controller,
which published app collections pin. text_widget is back to what it was;
TextWidth and its hosted call live in text_measure, which only callers
that measure import.
2026-10-19 13:22:44 -03:00
waozi 1d7c8b683e Let portable apps measure a line of text with TextWidth
A portable app can lay out its own controls beside a label: TextWidth
returns the width Text would draw props.text with, in its resolved font
and typeface, and portable apps ask their host through a new hosted
call.
2026-10-19 13:19:06 -03:00
waozi ab04f4db12 Repin packages to the rewritten history 2026-10-19 11:51:53 -03:00
waozi 3387fc30bd Add TileMap, a 2D node that draws a grid of picture layers
TileMap fits square cells in its bounds, centres the grid and draws each
layer's tile numbers as pictures from a tile list, over an optional fill.
It returns where the grid landed, and TileMapCell and TileMapCellAt turn a
cell into its rectangle and a point into its cell, so board games place
overlays and handle taps without their own layout code. Built from Box and
Image, it also works inside hosted games.
2026-10-19 11:31:20 -03:00
waozi 74c782c742 Add touch controls, app assets and Android private paths for hosted games
joystick: a Joystick that steps where it leans and repeats while held, and
a SwipeArea that reports a swipe's direction or a tap's position. Both are
built on Press and Box, so hosted games can use them.

app_asset: ReadAppAsset reads a file the app ships, which is an APK asset on
Android and an ordinary file elsewhere. The bundle runner now uses it.

AndroidPrivateDataPath gives the private files folder with links resolved.
Android reports it under /data/user/0, a link that private-file checks refuse.

The canonical Android host falls back to Android's system font when the app
loads none, and loads it again when Android recreates the graphics surface.
2026-10-19 02:26:53 -03:00
waozi b7d5bdce02 Let a TabBar's tabs follow a swipe and keep a peek of their neighbours
Tabs that did not all fit scrolled only with a wheel, so on a phone a tab
past the edge could not be reached, and revealing the tab before it left
it wholly out of view. Such tabs now follow a finger through the shared
scroll device's content drag, as a Scroll's content does: the same slop,
flick and coasting, a drag that moves them cancels its press so no tab is
selected, and a tap still selects one. The wheel still scrolls them, and
tabs that reorder keep their own drag. The bar marks itself as scrolling
by drag, so a drag over it moves the tabs rather than a scroll around it.

A tab revealed on selection now keeps up to 32 units of the tab before
and after it in view (TabBarRevealPeek), never so much that the tab itself
leaves the bar. ScrollDeviceContentDrag takes horizontal for content that
scrolls sideways; a text area's drag is unchanged. The tab bar test covers
the swipe, the tap after it and the peek.
2026-10-19 01:51:34 -03:00
waozi 21d75b4465 Paint web links inside Text and find the one under a pointer
TextProps.links marks web links in a Text's words. They are painted in
the theme's link color, as see-through as the text around them, with an
underline on each line they reach, so a chat can show a link once, inside
its message. TextLinkAt returns the link under a point from the same
layout, so the app can open the link that was tapped. Portable apps reach
both through their host: the links travel with the Text's props and
TextLinkAtHostedHost answers the hit test.
2026-10-19 01:10:46 -03:00
waozi bd704dcc18 Test the gallery against a site built from this checkout
The live editor embeds the gallery's example sources. CI now rebuilds the
whole site before the browser check, so an example that changed since the
last published site no longer fails against stale editor assets.
2026-10-19 00:24:47 -03:00
waozi 25f38517ad Keep a portable app's reply after its run returns
AppReplyHost kept a view into the bundle's own reply string, which the
VM reclaims when the run returns. On Android the freed bytes were reused
while a host decoded them, so Inner Breeze read Diary's save reply as
unsaved and refused to leave Diary. The context now owns a copy until
the next run, and the app context test reads a reply with freed memory
overwritten.
2026-10-19 00:04:29 -03:00
waozi 8ed2df1a3e Export TextField and ModalFrame to portable app packages
Portable apps that import Kryon by package can now draw a text field and
a dialog with their own content, such as the shared Apps UI's Properties
dialog. Both modules already forward to the host in hosted builds.
2026-10-18 23:45:52 -03:00
waozi df5b0b07da Pin Ziran with package namespaces and the latest Kryon in the gallery 2026-10-18 23:25:03 -03:00
waozi 197c26625c Report right clicks on Press areas
Press reports right_clicked, with where, on the frame the secondary button
is released on its area, so a list can open an item's context menu. It is
never a click, and a disabled or modal-blocked area reports nothing. Hosted
apps receive the field through the widget codec.
2026-10-18 23:16:38 -03:00
waozi 6492f540f5 Check the real TableView sample and pin the latest packages
The gallery check now expects TableView's data, notes and cell selection
instead of the former renderer gap. Kryon and the gallery pin the latest
Ziran, Kryon, Plot and DataViews.
2026-10-18 22:34:42 -03:00
waozi b0df0c264d Wait for the browser player to swap apps instead of sleeping 2026-10-18 22:11:24 -03:00
waozi ac969c1532 Accept the browser player's message for files that are not ZIBs 2026-10-18 21:20:23 -03:00
waozi 9d08fd387e Stop running the tree label check twice at once
The tree state check also ran the label check, which the test runner
already runs in parallel; both wrote the same saved IR, and one could read
a partially written module.
2026-10-18 20:50:16 -03:00
waozi f278603a77 Install ImageMagick for the hosted ZIB window checks in CI 2026-10-18 20:35:30 -03:00
waozi 37c79b3f24 Pin the macOS-capable toolchain and prepare Linux ZIB player tests
The locked Ziran builds and links on macOS. The Linux job now builds the
compiler and fetches locked packages before make reads its platform
builds, and installs the GL libraries the native ZIB players use.
2026-10-18 20:21:18 -03:00
waozi 4e5934c774 Generate gallery export aliases for module configuration checks
The check relied on aliases left behind by a full site build, so it failed
in CI where only the gallery is built.
2026-10-18 19:54:28 -03:00
waozi 76c3cac0e0 Open context menu submenus on hover
A ContextMenuItem can name a parent item. That item shows › and opens its
submenu beside its row when the pointer rests on it, or when it is chosen
on a touch screen, and reports no command itself. The menu keeps the open
submenu in its saved state, so callers keep only open and the position.
Submenus nest, flip left at the view's edge, and a release inside an open
submenu keeps the menu open (DismissibleOverlayProps.keep_bounds).
2026-10-18 19:52:26 -03:00
waozi 294bc9bcbf Build and run ZIBs on macOS in CI
Pin the toolchain whose file provider supports the Darwin C library.
2026-10-18 19:51:04 -03:00
waozi f0e07b5cff Give portable ZIB apps media, HTTP, clock and private documents on every player
Standalone AppContext bundles now run in the native, browser and Android
players with the shared lifecycle and hosted widgets, and save to a private
per-app directory. All players provide packed and HTTP audio, asynchronous
HTTP text and a monotonic clock. A display-free VM test covers drawing,
packed PNGs, retained input and Unicode for machines without a display.
2026-10-18 19:51:04 -03:00
waozi 08b6a1f456 Flush native file chooser destruction before returning to its host 2026-10-18 18:19:18 -03:00
waozi 78e9f36986 Keep modal menus and dialogs outside scroll clipping 2026-10-18 18:05:15 -03:00
waozi 4e1afda0b9 Expose canonical context menus to hosted apps 2026-10-18 18:02:28 -03:00
waozi e05b1c7d91 Export text alignment values for packaged widget consumers 2026-10-18 17:47:03 -03:00
waozi 948ca4ab62 Resolve Shape clipping callback types in package builds 2026-10-18 17:42:19 -03:00
waozi 8d6ed0c68e Export title bar and menu props for portable app collections 2026-10-18 17:18:48 -03:00
waozi 9cc5905447 Qualify geometry in the portable paint callback type 2026-10-18 17:14:12 -03:00
waozi 3bea277eb1 Resolve hosted widget images within their app namespace 2026-10-18 17:08:48 -03:00
waozi e61af41401 Dispatch hosted widgets through canonical module names 2026-10-18 17:01:03 -03:00
waozi b268439a1b Pin the gallery to the portable ZIB renderer 2026-10-18 16:55:49 -03:00
waozi 58f3af975f Accept canonical package module names in hosted apps and widgets 2026-10-18 16:55:22 -03:00
waozi f4f7320864 Render portable ZIB apps on native, web and Android hosts 2026-10-18 16:51:54 -03:00
waozi e450f7bd83 Expose action dialogs to portable apps through the widget host 2026-10-18 15:50:50 -03:00
waozi 255451f330 Reuse preview runtimes and compiled source; complete social cards 2026-10-18 15:08:50 -03:00
waozi 8a4fa74994 Add clearable text fields and scaled context menus 2026-10-18 15:08:29 -03:00
waozi 226e6da0fb Handle empty bundles and drain final app input before saving 2026-10-18 15:05:22 -03:00
waozi 514ee2e3d2 Add a shared hosted app contract and standalone desktop player 2026-10-18 14:52:20 -03:00
waozi 4900a25b61 Pin and refresh the integrated gallery build 2026-10-18 14:39:32 -03:00
waozi 5d82cf3758 Integrate source editing and module categories into the widget gallery 2026-10-18 14:36:05 -03:00
waozi d1a58b234d Use Kryon standard colors in the widget gallery 2026-10-18 13:54:54 -03:00
waozi 5c7af4d9b4 Publish reviewed website assets after browser checks 2026-10-18 13:38:35 -03:00
waozi fefb366f74 Pin the gallery and editor to their shared Kryon implementation 2026-10-18 11:42:28 -03:00
waozi 565e31f3ff Build a shared desktop and web widget gallery for Kryon Labs 2026-10-18 11:38:38 -03:00
waozi 0eb9443830 Preserve inner padding in dropdown menu options 2026-10-18 11:38:37 -03:00
waozi b58e5cb3e3 Keep Kryon example outputs directly under build/examples 2026-10-18 11:03:43 -03:00
waozi 2595a062c7 Add interactive Ziran widget catalog example 2026-10-18 11:02:22 -03:00
waozi f80387d5b5 Scroll text areas with a finger on touch screens
On a touch screen, a finger dragged over a text area with more text than
shows now scrolls that text the way it scrolls a list: it moves once the
finger passes the same small distance, and a flick keeps it moving. The
caret and selection stay where they were. A tap places the caret where
the finger lifts, and a hold still selects a word. The page around the
text area stays put; when all the text shows, a drag scrolls the page as
before. With a mouse, dragging still selects text.
2026-10-18 00:39:57 -03:00
waozi 670f45a3aa Scroll text areas with the wheel and sideways scrolls with a sideways wheel
A text area with more text than shows now scrolls with the mouse wheel
while the pointer is over it, also when its caller passes no wheel and
the host only samples the shared scroll device, as hosted packages do.
The scroll around it leaves the wheel to it; beside it, or when its text
fits, the wheel still scrolls the page.

Hosts can pass a touchpad's sideways wheel with ScrollDeviceSideways. It
moves sideways scrolls toward the side it goes and leaves upright scrolls
and text areas alone; sideways scrolls still move with the vertical wheel.
The test driver can send a sideways wheel with wheel_x.
2026-10-18 00:15:38 -03:00
waozi b6af9e5982 Size frame text storage to the labels it retains 2026-10-17 22:59:23 -03:00
waozi 9535d846e2 Fit toolbar text actions to their labels and available space 2026-10-17 22:32:28 -03:00
waozi 6f340e1f0c Label peak memory and its per-run variation in the comparison 2026-10-17 22:25:39 -03:00
waozi d312dd6c55 Honor smooth scaling for ordinary pixmap images without transparent fringes 2026-10-17 22:24:54 -03:00
waozi 178f805735 Show per-widget memory and raster metrics beside complete captures 2026-10-17 22:21:34 -03:00
waozi 54eacf482d Report native runner CPU time with an explicit measurement scope 2026-10-17 22:20:34 -03:00
waozi 0ae4c52ff0 Set the selection fixture state through its public fields 2026-10-17 22:17:20 -03:00
waozi 4591d40413 Include selectable text and transitions in the widget comparison 2026-10-17 22:17:11 -03:00
waozi d2a39a27d2 Use the shared palette for menus, scrollbars, and text selection 2026-10-17 22:14:39 -03:00
waozi e34b41b495 Keep before and after measurement builds free of stale modules 2026-10-17 22:13:01 -03:00
waozi 766bdb8b7d Unify widget fallback styling and reduce frame raster overhead 2026-10-17 22:12:14 -03:00
waozi 734294694b Drive only a valid session's pointer
TestDriverPointer now returns the platform's pointer for a session that is
not valid, and so uses its session argument: a host built with -Wextra
-Werror no longer fails on it as unused.
2026-10-17 19:37:18 -03:00
waozi 1317b2981a Paint a TextArea's caret on the value its frame paints
A frame that takes a keystroke still paints its old value; the edit shows
from the next frame. The caret and selection were placed at the cursor
after the edit, so a key typed at the end of a line put the cursor past the
old line's end, and for that frame the caret was painted at the start of
the next line: a second caret flickering there while typing.

TextAreaPaintedOffset maps the caret, the anchor and the painted selection
onto the painted value: where the bytes the edit replaces end. The cursor
the area returns is unchanged. 9a2ee0a7 tests it; its message wrongly says
this change landed in 01b1b3db, which 46b28e05 took it back out of.
2026-10-17 19:25:01 -03:00
waozi 7e19ac4b1b Test that a TextArea paints one caret on the frame that takes a key
A frame that takes a keystroke paints its old value, but placed the caret
at the cursor after the edit. Typed at the end of a line, that cursor lies
past the old line's end, so for one frame per key the caret was painted at
the start of the next line: a second caret flickering there while typing,
which Inner Breeze's Diary showed. TextAreaPaintedOffset now maps the caret
and selection back onto the painted value (where the replaced bytes end);
that fix reached master inside 01b1b3db.

The widget test types at a line's end with a line after it, alone and with
a box under the line and a larger line after it, and counts the carets the
frame paints: exactly one, on the typed line. Without the fix it fails.
2026-10-17 19:24:40 -03:00
waozi 9498ba5361 Leave another change's TextAreaPaintedOffset out of the word-selection commit
The word-selection commit picked up unfinished TextArea edits that another
change was still making in the same file. This puts the file back to the
word and Shift selection alone; those edits stay in the working tree for
their own commit.
2026-10-17 19:24:03 -03:00
waozi 384c84a2eb Select a word with a double click and extend with Shift in a TextArea
A TextArea selected only by dragging. A second press on the same text
within the double-click time and distance now selects the word under it,
and a press with Shift extends the selection from its anchor. The host
passes its monotonic clock in TextAreaInput.now_seconds; without a clock a
double click stays two clicks. A third press starts over with a caret.
2026-10-17 19:23:23 -03:00
waozi 70633d5684 Report text lines a box cuts off in the widget tree
A Text with a fixed height leaves out wrapped lines that start below its
box. It now records how many (TreeSetHiddenLines, TreeEntry.hidden_lines),
and the test driver reports them per node, so a UI test can catch a label
cut off at a large scale without reading screenshots.
2026-10-17 19:14:18 -03:00
waozi a5170651c4 Add Line, Circle, Ring and Triangle widgets and a fading Box
Apps drew lines at an angle, circles, arcs, triangles and gradients with
raylib calls of their own, outside the widget tree. Line, Circle (with an
optional fade from centre to rim), Ring (whole or an arc) and Triangle now
draw them as decorative widgets like Box, and BoxProps.fill_bottom fades a
box's fill from top to bottom.

Each queues one paint command whose inputs the paint queue compares, so an
unchanged frame stays reusable. Kryon cuts the shape into triangles, clips
them to the parent's clip, and hands each colour's triangles to the host in
one RasterTriangles call, which raylib, the canvas, Cairo, the pixmap host,
Plan 9's libdraw and the terminal implement. The canvas fills a call as one
path, so its antialiasing leaves no seam between triangles.
2026-10-17 18:57:23 -03:00
waozi d448109e5a Let a TextArea line hold several boxes, one under another
A line of text with several pictures in it draws them all: a line's
blocks follow it in list order, one under another, and only its first may
take the place of its last row with cover. Content height, carets, presses
and painting walk all of a line's boxes; a press inside any of them is the
end of the line. A list where a later box of a line covers it, or whose
starts go back, is ignored as a whole, as before.

Tests: two boxes after a covered line and after a shown line, in every
target and bundle; both boxes of a line paint their picture.
2026-10-17 18:27:00 -03:00
waozi b49f5eb1e5 Let a TextArea draw pictures, headings and italic in its lines
A TextArea can now preview a markup language such as Markdown without
changing its value:

- blocks: a box under a logical line, or in place of its last row with
  cover, drawing an asset fitted inside it, or a soft frame with a label
  while the picture is missing. A press inside a box is the end of its line.
- lines: a logical line at its own size, which wraps, takes caret stops and
  takes height at that size, as a heading does.
- italic: bytes drawn slanted with unchanged advances. Raylib leans the
  glyph quads with an rlgl shear; other backends draw them upright.

Rows are placed by one walk shared by content height, carets, presses,
arrow keys and painting. During an IME composition, lines and boxes after
it move with the preedit. Each list is sorted, one entry per line at line
starts, or ignored as a whole; without them the layout is the plain area's.
The widget host passes the new fields to hosted apps and draws a box's
picture only when the bundle may draw that asset.

Tests: placement, carets, presses, row keys, line sizes, validation and
composition offsets checked against the plain layout in C, C++, Go, Python,
Rust and bundles; a covered line paints its picture and not its bytes.
2026-10-17 18:08:13 -03:00
waozi a5f007a662 Let UI tests drive a running app through its widget tree
With KRYON_TEST_DRIVER naming a directory, an app that calls the TestDriver
functions where it samples input answers a test's commands after each frame:
it lists the committed widgets with their kind, role, label, editor text,
bounds, visibility, focus and enabled state, finds them by label, role, key
or focus id, presses one through the app's own pointer path, types text a
few codepoints a frame, presses keys, holds the pointer for drags, and
reports how many frames in a row ended unchanged. Tests no longer have to
read screenshots to find a control. Without the variable nothing changes.
2026-10-17 17:45:55 -03:00
waozi 3fbe1d3887 Give the Raylib graphics test the upright photo calls
Upright JPEG photos made the asset loader read the file and decode it
through raylib images, which the test's stand-in raylib did not provide,
so the test no longer linked. The stand-in now provides them, and the test
checks that a sideways camera photo turns clockwise once and releases its
file and decoded image.
2026-10-17 06:59:37 -03:00
waozi 25c5526945 Read the Android text menu's clock only on Android
Apps import android_device on every platform, so the Windows build linked
the text menu's POSIX clock and failed: MinGW has no clock_gettime or
clock_nanosleep. Only the Android branch uses that clock, so it is now
imported there.
2026-10-17 06:29:39 -03:00
waozi 98ea8fbdfd Add gallery previews and upright JPEG photos
ImagePreview makes a small upright JPEG of an image file: the host decodes
it (raylib, or the browser on the canvas backend), then portable Ziran
scales it down by area averages, turns it by its Exif orientation and
writes a baseline JPEG, so every platform makes the same preview.

The raylib host now draws JPEG assets upright by their Exif orientation,
as browsers and GdkPixbuf already do: cameras store portrait photos
sideways and say so in Exif, which stb's decoder ignores.

make image-preview-test decodes the previews with Pillow and compares
every orientation, scaling, transparency and gray images, and reads the
orientation of both byte orders.
2026-10-17 05:08:43 -03:00
waozi 3f659f50a9 Let a Scroll keep its scrollbar while its content fits
ScrollProps.keep_scrollbar shows the scrollbar and takes its width from
the content from the start, so content that can grow, such as a list
whose rows open, keeps its columns when it starts to scroll. With
nothing to scroll, the kept scrollbar takes no press, drag, fling or
hover.
2026-10-17 02:41:45 -03:00
waozi 98faba47ec Give HTTP transfer answers' length for binary answers
HttpTransferPollLength reports how many bytes an answer has, on the
desktop, Android and the browser, so a binary answer with NUL bytes, such
as an encrypted file, arrives whole. HttpTransferPoll is unchanged.
2026-10-17 01:34:36 -03:00
waozi ac417796d5 Support touch text selection and native Android clipboard menus 2026-10-16 03:07:13 -03:00
waozi cca56b47eb Let portable apps open dialogs with ModalFrame
A bundle could draw text, buttons, scrolls and tab bars through its host,
but no dialog, so an app had to fill a whole page instead. ModalFrame is
now a hosted widget: its props and result cross with generated codecs,
its action images pass the host's asset policy, and its open panel is a
scope the bundle Ends, counted with scrolls toward the host's limit.
2026-10-16 02:21:29 -03:00
waozi 9a2ea8ccfb Keep a dropdown's highlight when a row's action icon is pressed
Pressing a row's icon used to move the menu's highlight to that row, which
in styles where the highlight matches the chosen row made two rows look
chosen. The highlight now stays where it was.
2026-10-15 23:07:54 -03:00
waozi 74a0de640f Let dropdown rows carry an action icon, such as download or remove
A DropdownOption can name an icon shape and label for a button at the end
of its row. Pressing it reports the option in DropdownResult.action_index
and leaves the menu open without choosing the row, the way a translator's
language list downloads or removes a language beside its name. The icon
takes its row's text color, fills half its square as a touch target, and
shows a round tint on hover; the selected row's check moves before it.
2026-10-15 22:55:03 -03:00
waozi d963afad33 Draw tab bars as labels over a divider with an indicator
TabBar painted its border as a box around the whole row and filled the
selected tab edge to edge, so tabs looked like a text field with a chip in
it. The bar's border is now a divider on the side facing the content, and
a tab's border is its indicator: a rounded bar under a centered label, or
across a closeable tab. Hover and press fills stay clear of both, labels
center in tabs without a close button, and hovering the selected tab no
longer hides its selected face.
2026-10-15 22:23:41 -03:00
waozi cb8a2f25a2 Keep a focused selected button looking selected
A clicked segment or tab keeps keyboard focus, and the focus face replaced
its selected face, so the choice looked deselected until focus moved.
Selected now outranks focus; keyboard focus still draws its own ring.
2026-10-15 15:41:41 -03:00
waozi 09ca93f2f2 Support content-sized tabs and wheel scrolling 2026-10-15 01:09:52 -03:00
waozi 01a3ac262a Keep image codecs small: the Image effect decodes a mesh's points itself
Every ImageProps codec held room for 256 mesh points with a codec each,
about 74 KB, and buttons, title bars and every dropdown option embed one,
so hosted widget codecs grew by megabytes. The points now have no room in
the codec: a bundle still sends them, the Image effect validates and
decodes them into one host buffer (up to IMAGE_MESH_POINT_LIMIT), and an
image codec is back to about 2.7 KB.
2026-10-14 20:38:17 -03:00
waozi 6646415765 Keep shapes drawn after a warped image on the default texture
raylib leaves a triangle batch on the last texture set, so the rounded
fills Kryon draws as plain triangles sampled a warped image's texture
when they came right after it, and a progress bar under a painted figure
vanished. The mesh hands the batch back to the default texture and the
smooth shapes bind it themselves; the raylib mesh pixel test now draws a
rounded fill after a mesh.
2026-10-14 20:13:38 -03:00
waozi 197d21f2f8 Draw images warped over a grid of points
ImageProps.mesh holds a columns x rows grid of screen points; Image
stretches the picture across it, two textured triangles per cell, so a
painted limb can bend at its joint like a paper puppet. Mirrored grids
draw (nothing is culled), the bounds still clip, and fit, origin,
rotation and the style radius do not apply. A grid with too few points
draws nothing, and no placeholder covers its bounds.

The paint queue copies the points into per-session blocks when queued,
moves them with their node, and compares them in the retained snapshot,
so a moved vertex repaints and an unchanged grid reuses the frame.

RasterImageMesh draws the grid in every host: raylib (desktop and
Android) sends front-facing textured triangles in one batch, the web
canvas and Cairo draw each triangle through its affine transform under a
clip, the pixmap host and Plan 9 libdraw rasterize pixel centers with a
shared edge rule (bilinear when smooth), and the terminal shows a marker.
The bundle player, zib tool and frame replay bind it, and hosted bundles
send up to 256 points with a plain Image (a per-field slice bound in the
codec generator keeps every ImageProps codec small).

Tests: pixmap mesh test (C, C++, Go, bundles; copy, snapshot reuse,
mirror, bend, clip, seams), Cairo mesh test, RGBA canvas cases, web
canvas pixels and seam at three densities, hosted widget mesh, and a
raylib pixel test on a private Xvfb (make raylib-mesh-pixels-test).
2026-10-14 20:05:57 -03:00
waozi c182ac9348 Let buttons show a muted detail line under their label
ButtonProps.detail adds a second line in a slightly smaller, muted font,
such as which app a choice uses. A button measures to the wider of its two
lines and their combined height, centres both lines together beside its
icon or image, and screen readers announce the detail as its description.
2026-10-13 21:54:23 -03:00
waozi fd8409f796 Paste into password and key fields from their menu
A secure text field still never copies its text out, but its menu now
offers Paste, as Ctrl+V already did, so a password or API key can be
pasted on touch screens.
2026-10-13 17:35:52 -03:00
waozi b648eee8c7 Let title bars keep room for controls and draw in portable apps
A TitleBar's trailing_width reserves room at its right for the caller's
own controls, such as an online switch, and the result's trailing_bounds
says where to draw them; the title stays centred clear of them, or takes
what is left on a narrow bar. Portable bundles can now draw a TitleBar
through the widget host, with its leading image and dropdown options
held to the host's asset policy.
2026-10-13 17:35:52 -03:00
waozi d17ac9892c Recognise the app's own clipboard without X-Resource
Without libXRes, a clipboard image read compares the selection owner with
this process's windows, found by _NET_WM_PID in the window manager's
client list or among the root's children: ids of one X client agree above
bit 18. Asking the app's own hidden clipboard window no longer waits two
seconds, as on CI runners without libXRes.
2026-10-13 17:31:07 -03:00
waozi c2af25201c Show popups whole over the scroll area or dialog they open from
A popup escapes the clip of the scroll area or dialog around it, and a
time picker sizes its popup to the window, so a picker in a dialog shows
its hours, minutes and actions in full instead of one squeezed row.
2026-10-13 16:51:09 -03:00
waozi b3f7735942 Report taps on a dismissible overlay
DismissibleOverlay now reports a press released on its backdrop or on its
panel's own background as tapped, whether or not that closes it. An
overlay that may not be dismissed, such as a guide, can treat the tap as
its own action, like going on to the next step. A law states that every
release the overlay receives is a tap, and a mutation keeps it honest.
2026-10-13 16:32:05 -03:00
waozi 62c4463a25 Let images scale smoothly
An image with ImageProps.smooth set is filtered when it is drawn larger or
smaller than its pixels, so a detailed picture such as a sprite stays clean
instead of turning jagged. The raylib host builds the image's mipmaps where
the GPU allows them and filters it trilinearly, once per loaded image;
browsers draw it with their image smoothing. Buttons, dropdowns and the
navigation bar pass the flag on with their images, and images without it
keep their sharp pixels.
2026-10-13 16:31:59 -03:00
waozi e300f49fa5 Let Text type its text out
While typing is set, Text paints only its first typed characters, as if
they were being typed. A character is a grapheme cluster, so an accented
letter, an emoji or a CJK character never shows in part. The text keeps
the whole text's layout, size and accessible label, so no word jumps to
the next line as it appears and screen readers always read all of it.
TextCharactersEnd gives the byte offset where those characters end.
2026-10-13 16:15:03 -03:00
waozi 6ceec10dbd Let a time picker clear its time
TimePicker shows an optional Clear action beside Now and Done. It takes
the time away, back to its placeholder, and closes the popup; the
actions share their row in the order Clear, Now, Done.
2026-10-13 16:04:27 -03:00
waozi cade721511 Let title bars and dialogs show a strong title, and a dialog its title at the start
TitleBar and ModalFrame can draw their title strong, with the same
emphasis Text gives its strong ranges. A ModalFrame can also start its
title at its content's edge, or after its left action, instead of
centring it, for a dialog whose fields line up below it.
2026-10-13 15:21:50 -03:00
waozi a58cce4452 Let packages use Press from the Widgets module
Press, the area that reports a click, a hold and where the pointer is,
was only reachable by its own module path, so a package such as Plot
could not use it. The Widgets module now exports it with the other
widgets.
2026-10-13 14:45:25 -03:00
waozi 2514568dd9 Add TimePicker for picking a time of day
TimePicker shows a time as 24-hour HH:MM, or a placeholder while no time
is chosen, and opens an hour and a minute column at the current value. A
tap, a finger drag or fling, or the mouse wheel picks and scrolls; Down
opens it, the arrow keys step a column and wrap within it, Left and Right
switch columns, and Enter or Escape closes it. Optional Now and Done
buttons set the current time and close the popup. The time changes as it
is picked, so closing never loses a choice, and the popup stays on screen,
opening above the field when there is no room below. The picker takes the
dropdown's look from every style, light or dark, and portable apps can draw
it through the widget host.

Dropdowns now follow Kryon's light and dark system palettes; a dark palette
left their field and menu light before.

`make -C examples time-picker` builds a window that shows the picker in
each of its states.
2026-10-13 14:38:03 -03:00
waozi 557c7827c4 Draw checkmarks as smooth strokes
A checkbox's check was a stack of one-pixel lines, which looked jagged
and grew thinner on its steep side. PaintStroke now paints a line through
up to eight points as a smooth stroke with round ends and joins, through
the same rasterizer as icons, so it is anti-aliased alike on every host
and at every scale. The checkbox draws its check with it, and an
application can draw its own checks the same way.
2026-10-13 14:08:37 -03:00
waozi c080955e6a Keep a toggle within the bounds it is given
A toggle with Off and On labels grew to the right past its bounds when
its labels needed more room, so it spilled out of its card. Given less
room than it needs, a toggle now keeps to its bounds: each label stays in
its own half and the switch shrinks to fit. A size of 0 still takes the
natural size, and ToggleMinimumSize tells a layout that size, so an
application can give the toggle the room it needs.
2026-10-13 14:04:41 -03:00
waozi 9b6de31855 See the keyboard on Android 10 and older without Java
Before Android 11 a resizing window can report the keyboard only in its
visible frame: on a Moto e6 play (Android 9) the root insets gave 84 px,
the navigation bar alone, while the keyboard covered 588 px, so
PollAndroidWindowInsets saw no keyboard and Werkzeug's sync code field
stayed hidden behind it. The poll now also measures how far the keyboard
reaches up from the window's bottom with getWindowVisibleDisplayFrame and
getLocationOnScreen and keeps the larger of the two. The JNI table gains
NewIntArray and GetIntArrayRegion, checked against the NDK on every ABI.

Tested on the Moto: the focused field and its button stay above the
keyboard. The JNI layout, Android device and surface tests pass.
2026-10-13 10:50:33 -03:00
waozi 9c64a19e2a Make HTTP requests on Android without Java
An activity without the httpCreate transport, such as a plain
NativeActivity, now gets one detached native worker per transfer, at most
eight at a time. The worker attaches to the Java VM and drives
java.net.HttpURLConnection through JNI, so TLS and certificate checks stay
the system's; redirects and caches are refused. Like the desktop worker it
owns copies of the request and writes the answer only into its own memory,
and a poll copies it out; a cancelled or timed-out transfer is abandoned
and the worker frees it. Methods, URLs and header names must be visible
ASCII, header values ASCII text.

The desktop and Android workers share the pthread lock and thread start.
The JNI table gains IsInstanceOf. kryon/http_transfer is exported.

Tested: Werkzeug on an Android 15 emulator, with no Java code, created a
Daochi account on api.waozi.xyz, connected a desktop with a code, and
synced a record each way. The desktop and browser transfer tests and the
JNI layout test pass; the generated C compiles for armv7a, aarch64 and
x86_64 with the NDK.
2026-10-13 10:23:03 -03:00
waozi 2ebfaccb6e Read Android window insets without Java, and load fonts from the APK
A plain NativeActivity has no Java to report its insets, so Kryon laid
such an app out under the navigation bar: Werkzeug's bottom buttons sat
behind the 3-button bar on a Moto e6 play. PollAndroidWindowInsets reads
the system bar, keyboard and cutout insets from the decor view's root
insets through JNI a few times a second (getInsetsIgnoringVisibility on
Android 11 and newer, stable insets before) and stops once Java reports
them. The JNI table gains GetFieldID, GetIntField and
CallStaticIntMethodA; tests/ziran_android_jni_test.sh checks them
against the NDK on every ABI.

A font file packed in the APK did not load by its relative path, because
raylib's FileExists cannot see APK assets although its file loader can.
Android 9 and older cannot name a system font, so such an app fell back
to raylib's pixel font. The typeface loader now also accepts a path the
file loader can read.
2026-10-13 02:18:30 -03:00
waozi 1b538c6677 Export the hosted app and widget host modules
A package-based app can now run portable app bundles inside its window
with kryon/hosted_app and kryon/widget_host, without raw module paths.
2026-10-13 00:04:01 -03:00
waozi 9af484664e Let portable apps draw a Spinbox through the widget host
Hosted bundles can now step numbers with the standard Spinbox. The
regenerated codec also carries TextField's numeric flag, which was
missing from the hosted boundary.
2026-10-12 23:53:19 -03:00
waozi a74c45c4f0 Select a numeric field's number when a tap focuses it
A press that focuses a numeric text field selects its whole number and
keeps it selected through the release, so typing replaces the number
instead of adding digits to it. The field remembers the focusing press on
its node while the pointer is held; taps in an already focused field place
the cursor as before.
2026-10-12 20:36:24 -03:00
waozi edf71b9de0 Give text fields a numeric mode with a number keyboard
TextFieldProps.numeric accepts only the digits 0-9 for typed, pasted and
input-method text, and asks the platform for a number keyboard: Android
receives it through setTextInputState, which now takes (JJ[BIIZZZ)V with
numeric before multiline, and the web editor sets inputmode=numeric.

The Android device test host also stubs SetMouseOffset, which
android_surface has needed since 468d6326, so the text editor test links
again.
2026-10-12 19:10:37 -03:00
waozi f01d82a3f6 Repeat held keys in the raylib and Android run loops
A key held down now reaches the app again with every OS key repeat, so
holding Backspace keeps deleting as in any text editor; before, only the
first press was sent. The SDL desktop backend already passed repeats.
2026-10-12 14:52:21 -03:00
waozi 0cd10767cb Add TextWrapEllipsis: one-line text that ends in ... when too wide
A Text with TextWrapEllipsis lays out on one line like TextWrapNone, and
when the line is wider than its bounds it keeps the start that fits,
ending on a whole character, followed by "...". A new wrap value keeps
TextProps unchanged for hosted UIs; an older host treats it as no wrap.
2026-10-12 13:34:12 -03:00
waozi 4eaf06b24a Draw Android apps inside their window when the surface is larger
Android gives a raised window, such as the floating picture-in-picture
window, a surface larger than its frame by the shadow on every side, and
keeps that margin after the window opens back to full screen. Kryon drew
from the surface's corner, so the app sat 18 pixels too high and too low
and lost 18 pixels at each side on a 1.75x phone. An activity now reports
its frame size; the viewport lies in the frame's part of the surface and
raylib's mouse offset moves touches there too.
2026-10-11 20:04:07 -03:00
waozi 795f2dcfb0 Answer at once when the application itself owns the clipboard
Asking the clipboard for an image sends a conversion request to its owner.
When the application copied the text itself, the owner is its own window,
which can only answer from the event loop that this read blocks, so every
paste of the application's own copy froze it for the 2-second limit.
The X-Resource extension now names the owner's process; for this process
the read reports no image immediately. Without libXRes, owners are treated
as before.
2026-10-11 19:48:26 -03:00
waozi 788456dc51 Keep an open dropdown inside the page that shows it
The menu was sized against the whole window but drawn inside its scope,
so in a page that ends above an app's navigation its last rows were cut
off and, as they seemed to fit, could not be scrolled to. The menu now
fits the window area its scope shows, stays in the page and scrolls.
2026-10-11 15:57:30 -03:00
waozi 1514d47772 Let an open dropdown float above the page without blocking it
A dropdown's menu sat on a modal overlay whose full-window backdrop took
every press: tapping the app's sidebar only closed the menu, and a second
tap was needed to switch screens. The menu is now a Popup: drawn and hit
above the page like a modal, with no backdrop and no input blocking. A
press outside the menu and its trigger closes it and still reaches the
control it landed on.

Tree nodes can be popups (TreeSetPopup). They raise their subtree's paint
and hit order like a modal, but only modals block input
(TreeModalLayerAt), and scroll targeting prefers the topmost layer.
Presses are counted (TreeLastPress), so a popup closes only on a press it
has not seen.
2026-10-11 15:48:19 -03:00
waozi 893d0e73ae Paint vector icons on whole screen pixels so their cells leave no seams
An icon's raster cells were edge / size layout units and started at the
icon's own, often fractional, position. Their edges then fell inside
screen pixels, where the host anti-aliased each one, and the strokes
showed faint stripes, most visibly on the web canvas. Each cell is now
exactly one screen pixel and the icon's corner snaps to the nearest
screen pixel, so cells meet on whole pixels.
2026-10-11 15:10:02 -03:00
waozi 1034f47ccb Rasterize vector icons at the web canvas's devicePixelRatio
Icons are drawn from their SVG paths in software, at PaintPixelScale()
screen pixels per layout unit. The web canvas draws over a backing store
of devicePixelRatio pixels per CSS pixel, but only a zoom set that scale,
so on a 2x screen every icon was rasterized at CSS size and stretched:
soft, blocky edges. The canvas host now reports its density each frame
(SetPaintDeviceDensity), and the pixel scale is the zoom times that
density; native hosts, whose framebuffer is their window, keep 1.
2026-10-11 15:02:46 -03:00
waozi 9a7f0b6383 Scroll a dropdown's menu like any Scroll, with no scroll props
The open menu's rows now sit in a standard Scroll, so the wheel, a
finger drag and a fling move it by themselves and it draws the shared
scrollbar. Before, it scrolled only by a caller-supplied wheel prop or
by dragging its own thin thumb, so a menu longer than the screen could
not be scrolled on a phone. A drag that starts on a row scrolls without
choosing it; a tap still chooses. The menu opens at the selected row and
keyboard movement keeps the highlight in view.

The dropdown keeps its open state, highlight and scroll privately on its
retained node: DropdownProps loses highlight_index, scroll_offset and
wheel, DropdownResult loses highlight_index and scroll_offset, and the
navigation bar editor, title bar and toolbar stop passing them through.
2026-10-11 14:52:02 -03:00
waozi 75812e9b1d Find Ziran through ZIRAN_ROOT in the frame workload check
CI names its Ziran checkout with ZIRAN_ROOT and has no ziran command, so
tools/performance.py stopped before measuring. It now resolves Ziran the
way the test helpers do.
2026-10-11 14:01:39 -03:00
waozi fc78fcffb4 Keep a focused text field while a press on another control scrolls
A press used to move the focus to the control under it at once, so
starting to scroll a list beside a focused text field (Lumi's command
list) blurred the field and Android closed the soft keyboard. While a
text field has the focus, a press on another control now takes it only
when it lands as a click; a press a scroll takes over leaves the field
focused. Presses on text fields, and presses with no text field
focused, focus at once as before.
2026-10-11 13:52:20 -03:00
waozi f210d0dc9a Read the window focus probe's pixel with Pillow
The test ran ImageMagick's import to capture one pixel, and the library
test job has no ImageMagick. Pillow, which the test already uses, grabs
that pixel from the private display directly.
2026-10-11 13:46:30 -03:00
waozi 2e7c4e1e93 Take every queued event in each desktop poll
SDL_PollEvent stops at the marker its last pump left at the end of the
queue. When the host woke while another thread was still pushing input,
that marker landed between the pushes, so PollDesktop returned the key
and left the text and click for the next frame. CI's desktop wait test
failed this way. PollDesktop now pumps once and takes every queued event.
The test now covers a marker between two pushes, which fails without this
change.

The desktop examples link the libraries the desktop host now uses and
generate only what their main reaches, as projects do; they had stopped
linking.
2026-10-11 13:21:55 -03:00
waozi d0d6fdfe14 Show the queued SDL events when the desktop wait test loses text 2026-10-11 13:05:35 -03:00
waozi 0af1612585 Report SDL's text input state when the desktop wait test loses text
CI receives the pushed key but not the pushed text event.
2026-10-11 12:54:15 -03:00
waozi 2b391d23c6 Print what the desktop wait test received when input is lost
CI fails this test with status 6 while it passes locally and on an Ubuntu
24.04 container, so name the key and text values it saw.
2026-10-11 12:44:26 -03:00
waozi 629602607d Install GStreamer in CI and make silent test failures visible
The runner had no GStreamer, so the native video test could not open its
fixture and exited 4 without a message; the base, good and libav plugins
decode it on Ubuntu 24.04. The video test now prints why a video did not
open, the desktop wait test shows its program's output and status when it
fails, and the test runner reports every failing script's exit status.

The Windows typeface boundary links without Raylib and depends on the
optimizer dropping calls Windows never reaches. Sanitizer instrumentation
keeps those calls in the C++ build, so that link is built uninstrumented.
2026-10-11 12:27:10 -03:00
waozi ce91c8c3f4 Style scrollbars from the shared palette and size thumbs proportionally 2026-10-11 12:08:59 -03:00
waozi bcb9b63e78 Fetch the pinned toolchain with plain compilers in the sanitizer job
The prefetch ran under the sanitizer job's CC, so building the pinned
Ziran used AddressSanitizer and broke its 16 KB frame limit. The host
job also needs Pillow and ffmpeg for the image and video tests.
2026-10-11 12:01:26 -03:00
waozi 6e335cadb0 Pin raylib at its upstream commit again
c8e99fdb recorded raylib at 987f5843, which is a Kryon commit: the local
raylib override was an uninitialized submodule, so Ziran read the
enclosing checkout's HEAD. CI could not fetch it, and every test that
needs raylib failed. ziran update raylib restores fafa2cea.
2026-10-11 11:53:03 -03:00
waozi ba8e657dac Use shared hover cursors and clean spinbox outlines 2026-10-11 11:51:34 -03:00
waozi 5a3257dc2c Give resizable secondary windows their own flag
Flag 32 is NATIVE_WINDOW_STICKY, but the secondary window host read it
as resizable, so a sticky break overlay opened resizable and reported
clicks on release instead of dragging. Resizable is now
NATIVE_WINDOW_RESIZABLE (64).
2026-10-11 11:39:55 -03:00
waozi a03adce7fe Give CI's tests their tools and fetch locked packages once
The sanitizer job lacked SDL2, GLib, Pango, Pillow and ffmpeg, and the
host job lacked xmodmap, so those tests failed before running. Parallel
tests also fetched the same locked package at once, and offline ones
found none; behavior-tests now fetches them first.
2026-10-11 11:23:27 -03:00
waozi bbd4ccf498 Measure a canvas application's room in the browser with browser_viewport
The visual viewport, narrowed to the canvas frame, the canvas's parent or
the canvas, measured in Zi through the web bridge; and a debounce that
resizes only once a new size has held for two frames with no pointer
down. Moved from Inner Breeze's JavaScript and web window code so raylib
web builds share it.
2026-10-11 11:18:52 -03:00
waozi 09d142674b Pin the Ziran that lets bundle instances match host fields by name
hosted_app calls MatchBundleFieldsByName, which the pinned toolchain
did not have yet, so its test could not build in CI.
2026-10-11 11:14:28 -03:00
waozi 27f3f1e05c Pick documents and scan QR codes on Android with android_picker
The activity's document picker and camera scanner answer later, so a
numbered request is opened and polled each frame; each answer is taken
once by the request that asked, and a newer request replaces one still
waiting. Moved from Inner Breeze so other Android applications get it.
2026-10-11 11:11:50 -03:00
waozi 567edd6d56 Let page_socket compile off the browser
Applications that build every module for every platform can import it
directly; outside the browser it opens nothing and its polls report a
closed socket.
2026-10-11 11:07:18 -03:00
waozi c00ef4c224 Read browser WebSocket events with page_socket
page_socket opens a WebSocket through the web bridge and queues its text
messages for polling each frame. Binary or oversized messages, a full
queue, or no open after ten seconds close the socket, and URLs with
credentials are refused; a token travels as the second subprotocol. A
headless-browser test runs against a small local WebSocket server. It
replaces Inner Breeze's JavaScript socket.
2026-10-11 10:58:48 -03:00
waozi 86254a5453 Hand finished files to the user with file_export
ExportBytes and ExportFile download a file in the browser, through a
blob link built on the web bridge, or open Android's share sheet through
the activity's shareFile. A headless-browser test checks the downloaded
names and bytes. It comes from Inner Breeze's data and account export.

fseek and ftell take a C long, 32 bits on wasm and 32-bit Android, so
file_export and file_download now declare it as isize.
2026-10-11 10:55:05 -03:00
waozi 5d41090b1c Edit Android text through the input method's snapshots
android_text_editor lets an activity's input connection edit the focused
field as UTF-8 snapshots through TextRequest, so composition, autocorrect
and suggestions work. Stale revisions, a replaced field's late edits and
edits after blur are refused. android_device's text input calls it, and
falls back to code points when the activity has no input connection. It
comes from Inner Breeze.

The Android test host no longer replaces dlsym, which AddressSanitizer
needs at startup; the real one finds no raylib state either, so the
Android device tests now also pass under the sanitizers.
2026-10-11 10:40:19 -03:00
waozi 32d969a628 Run the window close and raylib host tests where CI has their libraries
The window close checks need SDL2, which the sanitizer job lacks, so they
skip there after compiling every platform. The raylib trace and
secondary window tests use the RAYLIB_A that CI provides instead of
fetching the raylib package.
2026-10-11 10:37:04 -03:00
waozi 4c6f444894 Type file_download's Android natives with JniEnv
An application's native table can then bind FileDownloadNative* like its
other JNI methods.
2026-10-11 10:25:23 -03:00
waozi 9d7a3093b1 Download files to disk with file_download
file_download fetches a large file, such as music or an app package, to a
path while the application keeps drawing; the file appears there only
once complete. Linux and BSD desktops run curl as a child process, the
browser streams fetch's body into the page's file system through the web
bridge, and Android asks the activity, whose callbacks the application
binds to FileDownloadNative*. Native and headless-browser tests download
from a local server. It comes from Inner Breeze.
2026-10-11 10:24:50 -03:00
waozi b48403097e Start HTTP transfer workers without an undersized call record
The worker's call record held a Ziran function value larger than the two
pointers allocated for it, which AddressSanitizer reported as a heap
overflow. The thread now receives the job itself and runs NativeWork.
2026-10-11 10:20:44 -03:00
waozi 5dfe1c6717 Describe Kryon as fully on Ziran in its docs and site
Build instructions install the ziran command and use the toolchain locked
in ziran.lock instead of a ../ziran sibling checkout. Downstream apps pick up
Kryon changes through ziran.lock. Terminal owns OSC 52 and bracketed paste.
The website no longer calls the migration underway, and its status page
lists the Android host, Zib desktop apps and opt-in DOM CSS layout.

The obsolete files (shell.nix, .ini themes, old site images, the duplicate
API redirect) were removed in 827eae3d, which picked up these staged
deletions.
2026-10-11 10:12:56 -03:00
waozi bd021734d7 Write the secondary window probe in Ziran
Kryon has no C sources; the probe that drives real SDL windows beside a
raylib window is now a Ziran program with the same checks.
2026-10-11 10:12:31 -03:00
waozi c2755c9d14 Add HTTP transfers and raylib secondary windows
http_transfer runs HTTP requests while the application keeps drawing:
curl on a detached worker thread on desktops, the activity's transport on
Android, and fetch through the web bridge in the browser. A cancelled
transfer never writes into the caller's buffer, answers that do not fit
fail instead of arriving cut, and only http and https URLs are accepted.
Native and headless-browser tests run against a local server.

raylib_secondary_window gives a raylib application on SDL up to three
extra windows, each drawing its own Kryon tree into a render texture that
is copied to the window, so the main OpenGL context stays current. Its
probe runs on a private Xvfb display.

Both come from Inner Breeze.
2026-10-11 10:11:17 -03:00
waozi 20e8ee86ad Add file picking, window close, idle time, notification and raylib log services
These come from Inner Breeze so any Kryon application can use them:

- file_picker: zenity on Linux and BSD, Windows' common dialog, and the
  browser's file chooser through the web bridge, which copies the chosen
  file into the page's file system. A browser test answers the chooser in
  headless Chromium; a fake zenity checks the arguments natively.
- window_close: close requests for the application's own SDL or Win32
  window.
- idle_time: session idle time from Mutter or the freedesktop screen saver
  over D-Bus, and whether the session is Wayland.
- notification_desktop: the notification host for Linux and BSD through
  notify-send.
- raylib_trace: raylib's log to the console or logcat with routine notes
  dropped, or to a log file for Windows applications without a console.
2026-10-11 10:00:36 -03:00
waozi afd7e8198f Open links with open_uri and describe the whole Android app glue
open_uri opens a URI with the platform's handler: the desktop opener as a
child process, Windows' shell, Plan 9's plumber, an Android ACTION_VIEW
intent or a new browser tab through the web bridge. It moves here from
Inner Breeze so any Kryon application can open links.

android_jni's NativeAndroidApp now carries every field of the glue's
android_app, including the command pipe, and AndroidInternalDataPath
returns the app's files folder. A test checks the layouts against the NDK
headers for all four Android ABIs.
2026-10-11 09:45:56 -03:00
waozi 95f07c4724 Paint a colour swatch button in its own colour
Buttons with swatch set drew the style's fill, so every colour choice in
an app's picker showed the theme colour instead (Inner Breeze's new-habit
colours were all purple under a purple theme). The swatch colour now fills
the button, half transparent when disabled, and the chosen swatch carries a
light ring with a dark edge that shows on any colour. The old header-based
path drew swatches; the Ziran button lost it.
2026-10-11 01:27:51 -03:00
waozi e411c054c9 Let a press claimed after a list's drag armed keep the gesture
A press in scrollable content arms the content drag at once, and moving
past the threshold then scrolled the list and cancelled the press, even when
the press had become a hold that selects. An armed drag that has not moved
now lets go when a widget claims the press, so holding an item and dragging
selects across the list; without a hold the same drag still scrolls.
2026-10-11 01:05:41 -03:00
waozi 5f9d13cc12 Keep the pointer with a press once it becomes a hold
Holding a list item to select it and then dragging should select more
items, as in Telegram, but an enclosing scroll took the drag and cancelled
the press. TreeCapturePressAt lets a widget claim the current press, and
Press claims it once it becomes a hold, so the scroll no longer takes the
gesture; before the hold the scroll still can, so lists keep scrolling.
2026-10-11 00:59:50 -03:00
waozi 7870801388 Let bundles use Press through the widget host
A bundle built with KRYON_HOSTED_UI now calls PressHostedHost, and the
widget host draws the press area in the host's frame and returns its press
state, so a hosted app such as Lumi can select messages by holding and
dragging. The generated codec gains PressProps and PressResult.
2026-10-11 00:27:32 -03:00
waozi fe37943f21 Run a bundle inside a host application with hosted_app
Applications that run another .zib in their window each opened the
bundle, checked its capabilities, bound them, limited its steps and kept a
working instance through restarts. hosted_app does that once:
HostedAppStart asks the host about every capability and binds them to one
HostCall with field names matched, HostedAppRun runs under a step limit and
marks a trap as failed, HostedAppRestart closes the old instance only once
the new one passes the host's handshake, and HostedAppAsset finds a packed
asset by its exact path.
2026-10-11 00:23:19 -03:00
waozi 63d65c502a Write file imports in generated codecs as #import, file
An application's codec imports its own record files; the generator wrote
them with a space before the comma.
2026-10-11 00:20:25 -03:00
waozi fead0b3694 Add Press for holding and dragging across items
Lists that select items like Telegram need to know when a press becomes a
hold and where the pointer goes while it lasts; buttons only report clicks.
Press is a button-kind area that paints nothing and reports a click, a hold
after half a second by default, the pointer while the press continues and
its release. The app passes its clock, as for scrolling, so hosts need no
new clock. Capture keeps the press when the pointer leaves the area, for
sweeping across items; without it an enclosing scroll can still take a drag.
2026-10-11 00:18:29 -03:00
waozi bbb0e785ef Add equal-cell helpers to the responsive grid
Apps laid out tiles of one height with fixed column counts because the grid
gave only its metrics and a cursor. GridRowCount, GridCellsHeight,
GridCellBounds and GridIndexAt work from MeasureGrid's columns, so a tile
grid reflows with the width and can still place overlays on its tiles and
find the tile under a dragged item.
2026-10-11 00:07:43 -03:00
waozi 53ea0fdb87 Host the widgets of a bundle that runs inside another application
An application that runs a .zib inside its own window answered each
widget's HostedHost call with its own codec and dispatcher. Kryon now owns
that host side next to the bundle side: widget_host draws a bundle's widgets
in the frame's session, refuses calls from another frame, foreign records,
texture handles and assets its host's callback rejects, and closes scrolls
the bundle leaves open. WidgetHostSupports lists the calls it answers,
including Toggle.

widget_codec is generated from Kryon's widget records by
scripts/generate-widget-codecs.py, whose --uses option lets an application
generate codecs for its own records on top of Kryon's. hosted_values holds
the shared helpers: fields match by name, so a bundle and its host may be
built against different layouts.
2026-10-11 00:04:50 -03:00
waozi 5e2bec30f9 Show keyboard focus on buttons and press them with Enter and Space after Tab
Tab already moved the session focus between controls, but buttons never
painted it, so keyboard navigation looked broken in every app. A button
focused by Tab or Shift+Tab now draws a ring just outside its bounds in the
style's focus color, or the default focus blue.

The focus is visible only after keyboard navigation, as with :focus-visible
on the web: a pointer press still focuses the control but hides the ring.
Enter and Space press the focused control only while the focus is visible,
so after a click those keys stay with the application, which may use them
as shortcuts, instead of pressing the clicked button again.

A behavior test covers Tab, Shift+Tab, wrapping, skipping a disabled button,
the ring, Space and Enter, and a click handing the keys back.
2026-10-10 23:11:11 -03:00
waozi c25bc2d1ff Draw bold text with whole-pixel strokes on raylib
Emphasized text was a second copy of the label shifted one logical unit.
Raylib snaps each copy to screen pixels, so at 110% the copies landed one or
two pixels apart, and on phones two or three, leaving a light seam inside
every stroke that made bold look blurry and doubled. A backend can now
register an emphasis raster. Raylib's thickens each glyph by whole screen
pixels, about one per 24 pixels of text. Other backends keep the logical copy.
2026-10-10 20:31:13 -03:00
waozi ddeaae9510 Load images in hosts that run their own frame loop
Spreading image decoding over frames reset its 4 ms budget only in
BeginRaylibFrame. Hosts with their own loop, such as Inner Breeze, never
call it, so once the budget was spent every later image stayed loading for
good: Inbe's Meditation and Sun Salutation pictures never appeared. The
budget now also renews once a frame interval has passed.
2026-10-10 19:31:45 -03:00
waozi 84ba2f3045 Add the Liberation Mono pixmap font, Plan 9 text measure oracle and pixmap blend tests 2026-10-10 19:10:13 -03:00
waozi 8e718be34c Keep the Android host thread attached and finish the right activity
Every JNI call attached the frame thread to the VM and detached it again,
so Android created a Java thread each time; with a per-frame call that
was several percent of a Moto e6 play's frame. The host thread now stays
attached and AndroidRunMain detaches it once when its loop ends; other
threads still detach after each call.

AndroidJniFinishActivity passed the activity's Java object to
ANativeActivity_finish instead of the native activity, so the back key
crashed the app instead of closing it.
2026-10-10 16:29:48 -03:00
waozi dd8bad3120 Spread image decoding over frames on the raylib host
A photo grid scrolled into view decoded every new thumbnail in one frame,
about 4 ms each on a Moto e6 play, so a fling stalled for 50-100 ms. A
frame now decodes images until 4 ms are spent, always at least one, and
reports the rest as loading: ImageWidth/ImageHeight return -1, RasterImage
draws nothing without an error, and the Image widget shows no placeholder
for a loading image. The graphics and image widget tests cover both.
2026-10-10 16:29:31 -03:00
waozi e56bb82359 Draw a clipped image's visible part without a scissor
An unrotated image larger than its clip, such as each cover-fit tile of a
photo grid, went through a scissor, and ending it flushed the draw batch:
one GPU submission per thumbnail took 44% of a Moto e6 play's frame. Such
an image now draws only its part inside the clip with the matching source,
as rounded images already did. The graphics test checks the crop and that
no scissor is used; the raylib clip pixel test still passes.
2026-10-10 16:19:28 -03:00
waozi 1f5a289f4e Find cached image textures by path hash
Every image draw and size query scanned the texture cache comparing whole
paths, and a photo grid's thumbnail paths share a long prefix: on a Moto e6
play the lookup was 16% of each frame. Each entry keeps the path's FNV-1a
hash, and bytes are compared only on a hash match.
2026-10-10 16:19:28 -03:00
waozi 887814d3b6 Keep button tone and emphasis under a system palette
SystemPaletteInstall gave every button the neutral button color, so
accent, success and danger buttons turned gray and ghost, outline and link
buttons got a filled background. Each tone now takes its palette role
(accent is the selection color), only filled and soft buttons get a
background, and neutral buttons that are not filled use the text color.
tests/ziran_system_palette_buttons_test.sh covers tones, emphases and
states.
2026-10-10 15:51:14 -03:00
waozi 2d40d0c70b Rasterize icons at the host's screen pixels
Icons were rasterized at their layout size and then scaled with the frame,
so at phone density or desktop zoom they looked blocky. A host that scales
the frame now reports its pixel scale (SetPaintPixelScale; the raylib host
does so with its zoom), and PaintSvgIcon rasterizes at that resolution, up
to 96 pixels across. tests/ziran_svg_icon_scale_test.sh checks the finer
cells on the portable VM and C.
2026-10-10 15:51:14 -03:00
waozi 1986f0df98 Keep a photo grid's thumbnails in the image cache
The raylib host cached 32 image textures, fewer than a phone photo grid
shows at once, so every frame evicted and reloaded thumbnails. The cache
now holds 128 (RaylibAssetCapacity) and the eviction test follows the
constant.
2026-10-10 15:51:14 -03:00
waozi bd9259ace8 Lay out Android apps in density-independent pixels
Kryon's Android host handed applications physical pixels, so a phone at
density 1.75 drew every size and font at desktop scale. The host now sets
the frame zoom to the device density (AndroidLayoutZoom, clamped to
Android's range), passes bounds in dp and clears the viewport in those
units, so sizes mean the same on every screen.
2026-10-10 15:51:05 -03:00
waozi 62301864ce Place a caret when a text area press has not moved
A press re-hits the text each frame while it is held. When the text under
the pointer shifted, as Markdown markers appearing on the line just pressed,
the stationary press became a selection from the old byte to the new one.
A press that has not moved now places a caret at its current hit.
2026-10-10 15:31:10 -03:00
waozi ccba6208f6 Hide and emphasize text area ranges for live Markdown
An editor that shows Markdown as formatted text needs its markers kept in
the value but out of sight away from the line being edited, and the marked
words drawn bold. A text area now takes hidden and strong ranges: hidden
bytes take no width, paint or caret stop, while wrapping, the caret,
clicks, selection and keyboard composition measure the shown text. Strong
bytes use Text's extra stroke, so advances never change. The row cache keys
on the hidden ranges.
2026-10-10 15:25:33 -03:00
waozi 9e8662bff6 Let a text focus request take the session focus
A text area or field asked to focus through its input became focused for
that frame only. The session focus stayed on the node that held it, often
the button pressed to make the request, so the next frame gave the focus
back to that button and typing stopped reaching the field. A blur already
releases the session focus; a focus request now takes it.
2026-10-10 13:09:50 -03:00
waozi 80e2afff7b Return raylib's two-field file path list from the web backend
raylib 5.5 removed FilePathList.capacity, and native hosts already read the
two-field layout. The canvas backend still returned the old three fields, so
web hosts that share the native layout read the wrong count and freed invalid
pointers at startup. Track growth in a local capacity instead.
2026-10-10 12:34:58 -03:00
waozi d9e082c3de Avoid repeated byte comparisons in Cairo's image cache 2026-10-10 11:15:06 -03:00
waozi 39188c69d0 Make Android native debug paths reproducible 2026-10-10 10:49:45 -03:00
waozi 695c34c45d Avoid duplicate widget paint command copies 2026-10-10 10:07:42 -03:00
waozi fc894c58f4 Avoid duplicate paint command copies during frame flush 2026-10-10 07:56:43 -03:00
waozi 4718fce5eb Avoid copying committed nodes during input routing 2026-10-10 07:24:19 -03:00
waozi 7954282378 Reuse unchanged Cairo pixels in desktop frame hosts 2026-10-10 06:53:34 -03:00
waozi d1727822fc Avoid redundant presentation of unchanged desktop frames 2026-10-10 06:13:03 -03:00
waozi 93de059b49 Retain unchanged views and wake idle desktop frames on input 2026-10-10 05:14:46 -03:00
waozi 9624d70a96 Read widget records without copies and reuse stable identity indexes 2026-10-10 05:04:02 -03:00
waozi 37c3899999 Show the platform keyboard for any focused text field or area
A focused editable TextField or TextArea now notes itself for the frame,
and TextInputFocused reports it to hosts. Android hosts show the soft
keyboard for it without the app listing every input.
2026-10-09 23:28:37 -03:00
waozi 31ca7373de Validate session indices directly during widget rendering 2026-10-09 21:36:53 -03:00
waozi 824f70bd21 Retain paint text and paths without copying drawing records 2026-10-09 19:49:39 -03:00
waozi a03ccf7548 Avoid repeated setup when reading queued paint 2026-10-09 19:18:37 -03:00
waozi 784c13d1ca Account for rendering time in desktop frame deadlines 2026-10-09 18:43:18 -03:00
waozi 96d8f6d426 Retain complete paint plans beyond the old byte limit
Grow owned snapshot bytes with the accepted plan, compare complete spans across blocks, and release storage on disposal. Cover large label and image-path plans, changed bytes, temporary ownership and embedded NUL spans.
2026-10-09 17:03:33 -03:00
waozi d6d24e47fc Reduce repeated input, style and paint frame metadata work 2026-10-09 16:37:40 -03:00
waozi 234147a560 Query committed text input without copying full widget metadata 2026-10-09 16:02:52 -03:00
waozi ab3e1c7e02 Expose owned-window focus to native and portable applications 2026-10-09 10:03:54 -03:00
waozi 75fbd50ec0 Keep dropdown menu state on its own retained node
The tree now carries a small widget state per node between frames
(TreeSetWidgetState, TreePreviousWidgetState). Dropdown keeps whether its
menu is open, the highlighted row and the scroll offset there, so a
caller passes only the selected value. Before, every caller had to hold
the returned open state and pass it back; any caller that did not got a
menu that closed again in the next frame. props.open still opens a menu
from code, and the new props.close closes it.
2026-10-09 09:51:45 -03:00
waozi cea117d1cd Expose monotonic time to native and portable applications 2026-10-09 04:22:17 -03:00
waozi 2935069bb5 Synchronize Android pixel geometry after portrait-first rotations 2026-10-09 01:29:34 -03:00
waozi 46bee39782 Preserve full-resolution image pixels within the raster budget 2026-10-09 01:05:23 -03:00
waozi 2ac44793f7 Allow shared styles and app customizations to coexist 2026-10-09 00:34:45 -03:00
waozi 705fb861ce Add optional native and portable local video decoding 2026-10-09 00:20:41 -03:00
waozi b5ac5076cf Replay Android touches that start and lift between frames
raylib's Android backend applies every queued touch event once per frame
and ignores where a touch lifts. On a slow frame a tap or quick swipe was
lost entirely, and a quick swipe without movement events looked like a
tap. android_touch wraps raylib's input handler, records where each touch
began and lifted, and TouchReplayStep reports the release where the finger
lifted or replays a whole touch over two frames. The release frame of a
swipe also keeps the speed the finger had.
2026-10-08 23:45:25 -03:00
waozi a907ffa987 Expand decoded image slots for composed applications 2026-10-08 23:26:13 -03:00
waozi ffa2dc8b8d Scroll with swipes that finish on a slow frame
A phone applies every queued touch event once per frame, so on a slow
frame a quick swipe arrived together with its release. The release frame's
movement was ignored and the first movement had no speed, so the content
did not move or coast. The press now starts the speed clock, the release
frame's movement scrolls, and a drag that starts on its release cancels
the tap.
2026-10-08 22:54:35 -03:00
waozi 4d8d84c20d Exchange retained tree label buffers on commit 2026-10-08 21:42:11 -03:00
waozi 984cb11fe1 Fit compact navigation shortcuts within the available space 2026-10-08 19:00:18 -03:00
waozi d5d6c6ac57 Fit selected dropdown values within narrow controls 2026-10-08 17:29:27 -03:00
waozi 77b053e8ec Preserve manual dock scrolling until selection or viewport changes 2026-10-08 17:21:01 -03:00
waozi 0017a7685f Keep compact navigation readable and reveal the selected shortcut 2026-10-08 17:17:09 -03:00
waozi 8fd403d982 Keep compact navigation selection visible during interaction 2026-10-08 16:03:22 -03:00
waozi a395aacd7e Render native text at screen resolution with stable layout metrics 2026-10-08 15:11:37 -03:00
waozi 8da2c1d037 Model font texture filtering in the window test host 2026-10-08 14:27:17 -03:00
waozi 8294d5770a Keep native text crisp at fractional zoom 2026-10-08 14:22:19 -03:00
waozi 68b9c6f2c9 Preserve the host locale when initializing the GTK tray 2026-10-08 10:57:09 -03:00
waozi 0203ff75b7 Load Windows bundled fonts without Linux discovery 2026-10-08 07:30:07 -03:00
waozi 214415b321 Add a first-class Android target as an installable APK
An android profile now builds a real Android application from the same
sources as the desktop: the kryon tool scaffolds a droid/ Gradle project
beside the application on the first build and assembles a debug APK with
the NDK. The canonical host (android_run) drives the session over
raylib's NativeActivity backend with the shared viewport policies; a
generated NativeActivity reports insets, cutouts, IME state, density,
dark mode and orientation through JNI natives written in Ziran, forwards
soft-keyboard text through the session-owned input queue, and an
unconsumed back key finishes the activity. Generation runs the whole Zi
graph through ziran ir --project so application module names may repeat
Kryon module names.
2026-10-08 03:18:27 -03:00
waozi 1919b54eb2 Add compact navigation docks with anchored actions and card dragging 2026-10-08 02:10:40 -03:00
waozi 3e5efcfe9f Cache installed style overrides for repeated selectors 2026-10-08 00:56:25 -03:00
waozi 0727816e36 Allow compositions to capture drags on submitted widgets 2026-10-07 23:33:09 -03:00
waozi 0d73f2eebb Support aligned button content for app libraries 2026-10-07 21:23:15 -03:00
waozi 5c32a3d185 Support icons above button labels 2026-10-07 21:08:41 -03:00
waozi 904b772c82 Select Android system typefaces through the native font matcher 2026-10-07 20:38:56 -03:00
waozi 30d956b04d Improve text, accessibility, replay, profiling and browser presentation 2026-10-07 18:41:41 -03:00
waozi 7d4ac3f4da Support floating overlays beside persistent controls 2026-10-07 15:37:31 -03:00
waozi 5ee3cabf6e Share the host palette with portable apps without parsing styles per frame 2026-10-07 15:01:03 -03:00
waozi 5058d55127 Batch printable fixed-pitch cells without changing raster output 2026-10-07 06:05:11 -03:00
waozi f1706c056c Embed portable Kryon apps in caller-owned pixel surfaces 2026-10-07 02:50:11 -03:00
waozi b38389ef50 Support local app services and decoded gallery images in the portable player 2026-10-07 02:42:39 -03:00
waozi 1cc006dddc Render inline text emphasis with the standard Text widget 2026-10-07 02:24:27 -03:00
waozi 06e3d3844e Render mirrored images with clipped and rounded bounds 2026-10-06 22:58:21 -03:00
waozi 054fd3a75b Honor explicit image colors in navigation bars 2026-10-06 20:39:46 -03:00
waozi 243907addd Keep reorder and slider drags inside scroll containers 2026-10-06 18:01:50 -03:00
waozi c124c87356 Use registered font fallbacks on every raylib host 2026-10-06 17:09:37 -03:00
waozi 5d4d7098f8 Support portable Lists compositions through standard widgets 2026-10-06 15:40:05 -03:00
waozi 6196271221 Support hosted Checkbox and Toggle compositions 2026-10-06 15:14:46 -03:00
waozi b794d17c45 Support portable compositions in retained widget hosts 2026-10-06 15:07:21 -03:00
waozi 2ac6b21b03 Present rasterized SDL frames without redundant GPU surfaces 2026-10-06 10:00:09 -03:00
waozi 1e38826f11 Expose the Raylib runtime through its package module name 2026-10-06 09:22:24 -03:00
waozi f334cb6ef1 Recover Raylib images and frames after graphics context loss 2026-10-06 09:13:26 -03:00
waozi d768634dcf Retain committed modal input layer instead of rescanning the tree 2026-10-06 02:02:30 -03:00
waozi 9b7ee6274b Retain TextArea wrapping for stable font metrics 2026-10-06 01:52:35 -03:00
waozi 23f3bc199a Enable default native raster workers through Ziran
Keep ordered paint barriers, serial portable output and aliased image semantics. Verify native and portable pixels, worker lifecycle and package-host defaults.
2026-10-06 01:22:17 -03:00
waozi 390dd82364 Reduce rounded coverage sampling while preserving native pixel parity 2026-10-06 00:20:17 -03:00
waozi 57ecbb2359 Blend cached glyph masks in clipped pixel rows 2026-10-05 23:24:18 -03:00
waozi 36dce6cfe8 Blend clipped pixel rows without per-pixel host overhead
Opaque host surfaces write their alpha while rasterizing, and retained paint invalidates when that format changes. Rounded fills blend constant-color interiors as bounded row spans, retaining the existing corner sampler and exact integer blending.

Extend surface parity to C, C++, Go, Rust, Python and source/saved portable bundles. Retained frame, density, sanitizer and Harmony cursor/damage/private-Xvfb checks passed. Paired synthetic Harmony scroll medians fell 18-22%; typing and t9 timings were essentially unchanged, with no added buffer storage or measured soak growth.
2026-10-05 22:58:59 -03:00
waozi b00d950300 Reuse growing text measurements before hashing label caches 2026-10-05 22:10:37 -03:00
waozi aec7303da6 Avoid redundant clearing and filtering for dense pixel damage 2026-10-05 21:45:04 -03:00
waozi 477b3b7f80 Repaint retained pixel frames only in damaged regions 2026-10-05 21:29:04 -03:00
waozi a9d246663a Reload portable app modules from verified release pointers 2026-10-05 14:09:25 -03:00
waozi 3fa9692982 Open file choosers in a folder and name their filter
GTK starts an open dialog on its Recent view, which is empty when no
recent file matches the filter, so the chooser looked blank. Open the
caller's folder, or the user's home folder, instead. Set the filter's
name before adding it: the chooser copies the name at that moment and
otherwise shows "Untitled filter".
2026-10-05 01:20:08 -03:00
waozi 9ebcc00a09 Block page pointer and scroll input behind modals 2026-10-04 18:12:53 -03:00
waozi 0f4fff221a Match bundle host pointer-sized values in players 2026-10-04 17:58:53 -03:00
waozi f89d8969c5 Rename Terminal references for the KryonLabs repository move 2026-10-04 17:53:16 -03:00
waozi e9d1ec7f8d Complete committed prompt and file-dialog dependencies 2026-10-04 16:33:57 -03:00
waozi b8cf78356a Add portable audio streaming and background window capabilities 2026-10-04 16:21:01 -03:00
waozi 9b3d335c59 Rasterize logical UI directly at device pixel density 2026-10-04 15:58:24 -03:00
waozi 23d10f54d9 Expose natural monospace metrics for grid text 2026-10-04 15:56:38 -03:00
waozi 78d5465265 Use current application terminology on retired reference pages 2026-10-04 02:41:19 -03:00
waozi d6d1da757f Validate portable app compatibility without executing startup code 2026-10-04 02:20:57 -03:00
waozi 2c360aebdd Export, render and install downloadable Zib applications 2026-10-04 01:54:15 -03:00
waozi a8968eea5b Allow decoded image caches beyond 256 assets 2026-10-03 20:32:38 -03:00
waozi e22a370d2e Add fitted fixed-pitch glyph painting to pixmap grids 2026-10-03 16:51:59 -03:00
waozi 253b6a6072 Install the clipboard image test's tools in CI
The Linux clipboard test pastes images that xclip and a GTK owner serve on
a private Xvfb, and links its probe against SDL2, cairo, FreeType and
fontconfig. The library job had none of these, so make test stopped there.
2026-10-03 16:03:16 -03:00
waozi 59d166684f Lock the Ziran toolchain that understands template overrides
The template test passes --overrides to kryon new, which Ziran gained in
793cdb4. The locked 791eda8 rejected the flag, so CI failed every run.
2026-10-03 15:48:15 -03:00
waozi 30cbff4545 Keep text drag anchors stable through scrolling 2026-10-03 12:11:11 -03:00
waozi 896741ae39 Render missing Raylib glyphs with system font fallback 2026-10-03 05:34:03 -03:00
waozi 46d2fde823 Keep style snapshots and frame text valid across updates
Publish immutable typeface snapshots, close theme and CSS views before reusing their buffers, and keep template row storage local to each frame. Template tests use explicit local overrides against the canonical checkouts. Verified the full make test gate, including 111 behavior scripts, source/saved-IR style snapshots on the VM/C/C++/Go, browser semantics, and private Xvfb clipboard checks.
2026-10-03 04:10:59 -03:00
waozi 3a3b7b940f Paste clipboard images into text inputs on Linux
Ctrl+V in a TextField or TextArea whose clipboard holds no text now
leaves the selection alone and reports paste_without_text, so an
application can attach what was copied instead. SystemClipboardLinux
reads that image: it asks the X11 (or XWayland) clipboard owner for
image/png and receives it whole or in INCR increments. libX11 is
loaded only on the first read.

The paste test runs on a private Xvfb display. A desktop probe presses
Ctrl+V in its focused field and receives images a GTK owner copied,
including one large enough to need INCR. The test also reads xclip's
bytes exactly and covers empty, text-only, oversize and no-display
clipboards.
2026-10-03 01:50:45 -03:00
waozi b5babaf12d Expose middle-button frames from both Libdraw hosts 2026-10-03 01:43:55 -03:00
waozi 8dc1fcf371 Lay out inline context menu items in one row
Consecutive items marked inline share a row of compact cells, so a menu
can open with a row of quick reactions or tools above its commands.
2026-10-03 01:30:16 -03:00
waozi 2f49b3463b Preserve containing input while composing passive views 2026-10-03 00:54:41 -03:00
waozi d534620043 Compare retained paint text as bounded byte spans 2026-10-03 00:11:35 -03:00
waozi cf6356698e Export the Cairo rasterizer as a Ziran package module 2026-10-02 23:58:31 -03:00
waozi 2a0cc5d85f Reuse recurring pixmap label measurements with bounded exact-content caching 2026-10-02 23:42:26 -03:00
waozi f458c37c91 Expose image revisions for retained pixmap surfaces 2026-10-02 23:03:18 -03:00
waozi 6b2d0c82bf Select native Libdraw through the Ziran Plan 9 target 2026-10-02 22:21:16 -03:00
waozi 0b1b2900df Reduce repeated pixmap text layout and retained frame work 2026-10-02 22:12:37 -03:00
waozi fb1afacbc5 Reject missing Raylib typeface files before font registration 2026-10-02 21:35:58 -03:00
waozi de69da8fea Expose window properties and device sampling for Ziran hosts 2026-10-02 21:26:50 -03:00
waozi 2edc4a122c Own queued image paths through the Kryon frame 2026-10-02 19:44:04 -03:00
waozi 3b5fcb41c7 Implement retained Menu composition in Ziran 2026-10-02 19:00:49 -03:00
waozi 478736fe02 Export text input properties for native application interfaces 2026-10-02 18:16:18 -03:00
waozi 7b19cd2015 Own queued glyph text across large Kryon frames 2026-10-02 17:28:26 -03:00
waozi fd1a726fd2 Ignore the local Wrangler deploy cache 2026-10-02 16:56:09 -03:00
waozi 9164ec997a Expose clipboard packages and distinguish unavailable hosts 2026-10-02 15:46:36 -03:00
waozi 6e064155c7 Open modal content scopes and show slider values
Overlays paint above later page content, so content submitted after a
ModalFrame without its panel scope drew under the opaque panel and the
dialog looked empty. ModalFrame now opens the panel scope while the
panel stays open and reports `opened`; callers submit content and End
it. ActionModal and NavigationBarConfig use it.

Sliders take a caller-formatted `value_text`, shown at the end of the
label row, restoring the value display the old Slider `format` had.
2026-10-02 13:41:40 -03:00
waozi 35b84182c9 Stabilize private display startup and browser cleanup 2026-10-02 13:36:06 -03:00
waozi 491ccbb08b Update TaijiOS application repository links 2026-10-02 13:11:28 -03:00
waozi ce1db4d00a Pin the safety fixes in the compiler toolchain 2026-10-02 13:04:19 -03:00
waozi be197dbb51 Resolve test includes from the configured toolchain root 2026-10-02 04:48:53 -03:00
waozi 3b7ac1683d Fall back when retained framebuffer allocation is incomplete 2026-10-02 04:48:53 -03:00
waozi edc41239ae Give Android app threads a safe stack budget and preserve crash symbols 2026-10-02 04:48:53 -03:00
waozi 389da7c732 Render decoded image assets in pixmap surfaces
Hosts can register borrowed ARGB pixels and paint them through ImageProps with scaling, tint, transparency and rounded clipping. Preserve placeholders for unresolved assets.

Validation: pixmap surface source/saved C, C++, Go and portable bundle checks pass. The wider make test gate stopped during a template dependency fetch with No space left on device.
2026-10-02 03:58:16 -03:00
waozi 177ba0a6c4 Draw symbols and color emoji in pixmap text
The pixmap font now carries all of Liberation Sans plus the symbol blocks
it lacks (arrows, math, shapes, dingbats, box drawing) from DejaVu Sans
and Noto Sans Symbols, so text no longer turns into question marks.
Format and variation characters take no room.

Color emoji come from Noto Color Emoji as 32px cells with their own
palettes, scaled with integer box filtering and cached per size. Emoji
presentation follows variation selectors; skin tone modifiers and tags
attach to their emoji. Every target still draws the same pixels.
2026-10-01 21:14:56 -03:00
waozi 632f068524 Rasterize pixmap text and fills several times faster
Glyph masks are cached by glyph, size and sub-pixel origin, so repeated
text is no longer rasterized from outlines every frame. Text and glyphs
outside the clip are skipped, and opaque fills and full-coverage pixels
are written directly. Output is byte-identical on every target.

PixmapResumeInto targets a caller-owned surface without clearing it, so
a host that paints its own background can keep unchanged frames with
EndFrameRetained.
2026-10-01 20:47:25 -03:00
waozi 95e5f01094 Allocate free WebAudio buffers, sources, and timers 2026-10-01 18:06:11 -03:00
waozi 5d3600a93c Render pixmaps into caller-owned sized surfaces 2026-10-01 15:03:31 -03:00
waozi a735dab6cc Show a loading message while the website preview compiles 2026-10-01 14:10:58 -03:00
waozi f00dbb2d4f Restore preview themes and fix the test toolchain harnesses 2026-10-01 13:39:56 -03:00
waozi 7b11d24698 Check preview pixels across browser iframe isolation 2026-10-01 12:25:20 -03:00
waozi f0abca9f39 Integrate the live editor into the Kryon homepage 2026-10-01 12:17:27 -03:00
waozi ce5738ff51 Deliver the first focus click to desktop widgets 2026-10-01 12:01:41 -03:00
waozi 9aa0353567 Add editable Kryon source and live browser preview 2026-10-01 11:58:42 -03:00
waozi b3985affc8 Use the configured Ziran toolchain in slider tests 2026-10-01 00:53:41 -03:00
waozi 0658dd16c9 Fix overlapping slider and progress in the canvas demo 2026-10-01 00:46:20 -03:00
waozi dbc513f1d0 Use the configured Ziran toolchain in the PNG test gate 2026-09-30 23:29:21 -03:00
waozi bf8e298a30 Load PNG assets in the native Plan 9 image provider 2026-09-30 23:23:08 -03:00
waozi 639aae9964 Theme embedded widget demo for Waozi 2026-09-30 22:05:30 -03:00
waozi 8b67588dcb Avoid waiting twice in externally scheduled canvas frames 2026-09-30 21:12:13 -03:00
waozi b2d09cf78f Add a live Ziran widget demo to Kryon Labs 2026-09-30 20:53:17 -03:00
waozi 22843b40a6 Load canvas image textures without RGBA readback and upload 2026-09-30 20:52:43 -03:00
waozi 200748dbfa Retain browser input received while drawing awaits resources 2026-09-30 20:49:55 -03:00
waozi 5ca0ac9917 Refresh canvas resolution when display density changes 2026-09-30 20:40:34 -03:00
waozi 1765699a22 Rasterize canvas UI text at its final output size 2026-09-30 20:38:21 -03:00
waozi 6a2525d9a9 Keep overlay paint and pointer targets above later page content 2026-09-30 19:58:48 -03:00
waozi fa1fc25911 Let application profiles choose their own Ziran host 2026-09-30 17:27:50 -03:00
waozi 0d9c66ff40 Retain caller-supplied scroll drag and momentum state 2026-09-30 15:38:10 -03:00
waozi c3f944650b Name the package kryon, in lower case
The package called itself Kryon while `ziran add kryonlabs/kryon`, the
repository, the kryon command, and import paths such as kryon/Widgets are
lower case, and applications were split between [dependencies.Kryon] and
[dependencies.kryon]. The package, templates, docs, messages, and tests now
use kryon: `[dependencies.kryon]`, `[tool.kryon]`, `tool = "kryon"`, and
`ziran tool kryon`. Ziran matches a package by name without case, so
[dependencies.Kryon] keeps working, but its [tool.X] table must use the
same spelling. The core module keeps its name, Kryon.
2026-09-30 15:35:16 -03:00
waozi b9ba4a864b Draw text in Kryon's font on every host
The desktop and libdraw hosts never chose a font, so Cairo drew text in the
system's default sans (Noto Sans here), while raylib and the browser hosts
used Kryon's Liberation Sans and the pixmap host bitmap glyphs. Text
differed in face, width, and line breaks from host to host.

- The Cairo hosts load assets/fonts/LiberationSans-Regular.ttf through
  FreeType (KRYON_FONT_PATH, which `kryon run` sets, else the system's
  copy, else fontconfig by name) and lay glyphs out at their unhinted widths
  with gray anti-aliasing, as a browser does.
- The pixmap host rasterizes Liberation Sans outlines itself: contours with
  implied on-curve points, quadratics flattened in 1/256 pixel, non-zero
  winding coverage from five sub-scanlines with exact spans, all integer.
  It places every glyph where Cairo does, and every Ziran target still
  prints the same bytes. tools/outline_font.zi, run as Python, extracts the
  outlines of 207 Latin glyphs (`make pixmap-font`); Terminus is gone.

libdraw finds plan9port without a fixed sibling path: the installed one
$PLAN9 names, or, when a project adds plan9port as a source package, one
Kryon builds once in its build directory; without either it says how to
add it. The kryon tool now builds its Ziran toolchain only when it is
missing, as ziran builds a pinned one, instead of remaking it on every run.
2026-09-30 15:30:25 -03:00
waozi 2dd88522fa Export the headless pixmap host to packages
Packages can now import kryon/pixmap and bind it with --bind-host to paint a
Kryon frame without a display on any target, then read pixmap_pixels to save
it, for example as a chart image a bot sends.
2026-09-30 15:10:31 -03:00
waozi 2e4132ca28 Pin Ziran 0e53483, which runs Kryon identically on every target
It has ziran new and init with templates, [package] tool, --bind-host, and
the Rust, Python, Go, and portable-runner fixes the pixmap parity test found.
2026-09-30 15:08:57 -03:00
waozi 7242c7e8e4 Render frames headlessly, identically on every Ziran target
The pixmap backend paints a frame into a 960 x 600 pixel buffer with integer
arithmetic -- anti-aliased rounded fills and outlines from 4 x 4 samples,
Bresenham lines, Terminus Font bitmap text, image placeholders -- and prints
it as a PPM image. Every template gains a `shot` profile, so
`kryon run shot > frame.ppm` takes a screenshot without a display.

Because the raster has no floating point and no platform library, every
target prints the same bytes. `make pixmap-parity-test` builds each template
and example from one saved IR for C, C++, Go, Rust, Python, and the portable
runner, requires all six images to equal C's, and writes
build/pixmap-parity/grid.png. All seven programs match on all six targets.

tools/image_tools.zi, built for Python with zi2py, compares PPM images (pixel
count, largest channel delta, bounding box, red diff image), writes PNG, and
lays out labeled contact sheets. tools/pixmap_glyphs.zi, also run as Python,
turns the Terminus console fonts into src/backend/pixmap_font.zi
(`make pixmap-font`); the glyphs are OFL-licensed (licenses/Terminus-OFL.txt).
2026-09-30 14:58:22 -03:00
waozi 488d840f01 Add the kryon command and four project templates
`kryon new hello` starts a Kryon application and `kryon run` runs it.
Outside `ziran tool Kryon`, the kryon command is a front door to ziran:
new and init are `ziran new`/`ziran init` with Kryon's templates, run,
build, check, and profiles are `ziran tool Kryon ...`, and install is
`ziran install`, so every project runs the Kryon its lock pins whatever
kryon is installed. `make install-user` installs it.

Templates, listed under [templates] in ziran.toml:
- app: a counter with buttons, a step slider, and progress (default)
- tui: a keyboard-driven task list for the terminal
- pages: Home, Library, and Settings behind tabs, sharing state
- web: a semantic page (headings, paragraphs, links) for the DOM host

Each template sets `tool = "Kryon"`, so `ziran run` works too, and lays
out rows in pixels in a window and in cells on the terminal host, so one
Frame serves every profile. `kryon init --template tui` adds a template to
an existing package without replacing its own entry; `[tool.Kryon] entry`
names the window's module.

Also: `kryon run desktop` takes the profile positionally, `kryon profiles`
lists profiles and marks the default, run asks for a profile only on a
terminal, `check` defines PLATFORM_WEB for browser profiles as `build`
does, and the static archive test finds Ziran in the org layout.
2026-09-30 14:23:46 -03:00
waozi b8e0b6cb1a Anti-alias rounded fills and outlines on raylib
raylib fills shapes without anti-aliasing, so small rounded controls such
as Inbe's habit day dots showed stair-stepped edges. Curved shapes now get
a one-pixel edge whose alpha falls to zero across the true outline, sized
from the modelview so the frame zoom and 2D cameras both count. Edges on
pixel boundaries stay crisp; square rectangles keep raylib's fill.

The raylib clip test and the new smooth shape test take ZIRAN_DIR, so they
run in the organization layout as well as with a sibling ../ziran.
2026-09-30 13:03:15 -03:00
waozi 5509238480 Support horizontal scrolling and opening desktop URLs 2026-09-30 10:38:51 -03:00
waozi 51d97974e2 Write constant dispatch chains as if-cases
Five if/else-if chains that compare one value with three or more
constants (SVG path commands, key codes, text area actions, theme keys,
audio states) now read as Jai's `if value == { case A; ... }`, which
Ziran checks as the same chain and compiles to a switch where it can.

The UI and the touched backends check with both the pinned 07f12a1 and
the current Ziran; the SVG shape, key input, text area menu, and canvas
audio engine tests pass with both; all 29 law modules check; and Inbe
checks against this tree with its pinned and the current Ziran.
2026-09-30 07:59:04 -03:00
waozi 025523e0f8 Let Ziran widen values without explicit casts
`ziran check --lint` found 43 casts that only widen a whole value, such
as float32 coordinates passed to Cairo, bytes read as s32, and s32 sizes
passed as s64. They are removed. Casts that set a range's index type or
the width of arithmetic stay.

The change is textual only: the generated C of the UI module and of every
backend that builds on its own is identical before and after, and all 29
law modules check.
2026-09-30 07:37:10 -03:00
waozi 51cec4c59d Pin Ziran 07f12a1, which widens numbers implicitly
This Ziran converts narrower numbers implicitly where no value can
change, so casts that only widen can go. `ziran check --project` reports
the same page_events.zi errors (CanvasEventKeyUp, CanvasEventKeyChar) on
this pin as on the previous one.
2026-09-30 07:36:59 -03:00
waozi 9e3059892f Write compared characters as #char literals
SVG path parsing and the Linux system theme reader compared bytes with
character codes written as numbers (65..90, 34, 58, 114). `ziran check
--lint` found 39 such comparisons; they now read #char "A", #char "\"",
#char ":", #char "r" and so on.

All 29 law modules and the public surface check, the SVG shape behavior
test passes on the portable runner and C, and Inbe checks against this
tree, each with both the current Ziran and the pinned 8bc31e8.
2026-09-30 07:25:04 -03:00
waozi 90917cf69b Drop casts to a value's own type
`ziran check --lint` found 21 casts that convert a value to the type it
already has, all cast(s64) on a count. They are removed; casts that widen
or set the width of arithmetic stay.

All 29 law modules and the public surface still check, and Inbe checks
against this tree with both the current Ziran and its pinned 8bc31e8.
2026-09-30 07:21:02 -03:00
waozi 78ea6de0c2 Report a segmented control's first choice as a change
With no option selected yet (has_selection false), clicking one reported
its index as selected_index but changed as false, so an app that waits
for changed never saw a first choice. Choosing an option now counts as a
change unless it was already the selected one, and laws state it.
2026-09-30 06:12:28 -03:00
waozi 2dbb36d0dc Support resizing and centering native desktop windows 2026-09-30 01:49:22 -03:00
waozi 31506a9385 Measure and place Cairo text in the line box other hosts use
The Cairo raster behind the desktop and libdraw hosts sized fonts by their
em, reported the font size as the line height, and put the baseline at the
bottom of that line, so every descender fell outside the line box and was
clipped. It also estimated text width as 0.6 of the font size per byte,
which misplaced wrapping and centering, most of all for non-ASCII text.
Text is now sized so its ascent and descent fill the font-sized line box
with the baseline at the ascent, as on the raylib and canvas hosts, and
widths come from Cairo's text extents.

The desktop project test checks that a descender stays inside the line
box, and the desktop size and window tests resolve Ziran in the
org-grouped layout.
2026-09-30 01:48:57 -03:00
waozi 5dc1e6c6c1 Emit unchanged retained paint when the host repaints anyway
EndFrameRetained dropped paint that matched the previous frame, trusting
the host to present that frame again. A host that also draws on its own,
such as Inbe's animated breathing circles, repaints when its own drawing
changes, and then every widget vanished from the frame. The caller now
says whether it will reuse the previous frame; when it will not, the
paint is emitted even if unchanged.
2026-09-30 01:47:29 -03:00
waozi abb7431ba9 Export TextAlign with the Text widget
TextProps.align and vertical_align are TextAlign values, but the public
surface imported text_align without re-exporting it, so an application
could not name TextAlignCenter. The public widget check now sets both
alignments and the wrap mode through the Widgets import.
2026-09-30 01:43:47 -03:00
waozi 84fa544090 Name the shared key codes and map them to text field input
Hosts now agree on key codes, so Kryon names them (KeyEnter, KeyBackspace,
KeyLeft, ...) next to the modifier bits. TypedTextTake collects a frame's
typed codepoints as UTF-8, and TextFieldInputFor turns a key, modifiers, and
typed text into a focused TextField's input, which apps each wrote by hand.
2026-09-30 01:31:27 -03:00
waozi 596fa74199 Send the shared key codes from the terminal host too
The terminal host passed raw bytes (Backspace 127, Enter 13, lowercase
letters) and discarded every escape sequence, so the arrows, Home, End,
Delete, and Escape never reached an app. TerminalKey now reports the codes
the other hosts use, Control+letter reports the letter with the Control
modifier, CSI and SS3 sequences name the arrows and editing keys with
xterm's modifiers, and Escape alone arrives after a 25 ms pause.
2026-09-30 01:27:57 -03:00
waozi 812a33ebfa Send the same key codes from the desktop host as from every other host
The SDL desktop host passed raw SDL keycodes (Backspace 8, Left
0x40000050, lowercase letters), while the canvas, raylib, and libdraw hosts
send raylib codes (Backspace 259, Left 263, uppercase letters). An app that
read keys on one host misread them on another; Pass's desktop build never saw
Backspace, the arrows, or Tab. DesktopKey now translates SDL keycodes the way
LibdrawKey translates Plan 9 runes, and keys with no shared code are dropped.

Apps written against the SDL codes (workbook, social, dashboard) need the
shared codes. The desktop project test resolves Ziran in the org-grouped
layout like the libdraw test does.
2026-09-30 01:25:09 -03:00
waozi 99382538f2 Build libkryon.a from C alone and check the other backends separately
The library rule also generated C++ and Go and ran go test, so any app or
packaging build that only links the C library needed Go installed; Inbe's
snap build failed with "go: not found". backends-check now holds the C++
compile and the Go test, and make all still runs it.
2026-09-30 01:04:06 -03:00
waozi 8bb4886d60 Find Ziran in CI's sibling checkout and in the org-grouped layout
The libdraw tests pointed at ../../ziranlang/ziran, which exists only in
the local layout, so Kryon CI (which checks Ziran out beside Kryon)
failed. They and the Makefile now use ../ziran when it exists and fall
back to ../../ziranlang/ziran.
2026-09-30 01:03:03 -03:00
waozi c9bcca2181 Complete native libdraw input, images, clipping and clipboard support 2026-09-30 00:22:50 -03:00
waozi 0697b22acd State slider and paned view drag laws in Kryon
A slider's drag starts on a press over it, ends on capture, disable, or
release, never moves a disabled slider, and its keys stay in range with
Home, End, and Shift steps of ten. A paned view's divider drag starts
only from a fresh press on an enabled split and ends on capture,
release, or disable. Each module has a mutation its laws reject.
2026-09-29 22:10:36 -03:00
waozi db88ab38b6 State layout clamping and scroll dragging laws in Kryon
Layout's clamp keeps values in range and ends an inverted range at its
maximum, as the old model stated. Releasing a scroll bar thumb, and
arming, starting, and bounding a touch scroll of content, are now laws
on the scroll decision functions, each with a mutation they reject.
2026-09-29 22:09:30 -03:00
waozi d9c3e1fbf5 State list, value, and gesture laws in Kryon
Reordering, segment wrapping, spinbox clamping, assistive selection,
button activation and menu toggling, collapsible sections and tree rows
(pointer, keyboard, close, and open state), selectable items, toggles,
and swipe lifecycles now carry the laws the old Bend models stated, as
Ziran laws on the decision functions, each with a mutation they reject.

An inverted spinbox range leaves the value alone, as the Ziran widget
does; the old model had the minimum win.
2026-09-29 22:08:31 -03:00
waozi d2f8f460d2 State widget decision laws in Kryon
The widget laws that were written as Bend reference models on the old
.kry runtime are now Ziran laws on Kryon's own decision functions:
checkbox values, focus activation and Tab direction, keyboard drags,
drag and drop, dropdown opening, radio activation, input and link
pointer handling, the inspector's release, multi-select rows, menus
(Escape, accelerators, context open and close, wrapping, submenus,
outside release), modal and overlay dismissal, and popup ownership.
`ziran check` proves them over every listed input, and each module has
a mutation the laws must reject.

Starting a temporary text edit compares floats, which laws cannot yet
pass through calls, so the input test now covers each of its cases.
2026-09-29 22:06:03 -03:00
waozi 880a7075a7 Use the browser clipboard in the canvas backend
The canvas host had no system clipboard. It now reads and writes through the
browser's permission-controlled Clipboard API, falling back to the copy
command during a click or touch, and waits for the browser's answer so a
refused write is reported to the app instead of looking like a success.
2026-09-29 21:40:36 -03:00
waozi a4e75edbad Open the desktop window at a chosen size and resize it
OpenDesktopSized opens the SDL/Cairo window at a given size, DesktopViewport
reports the drawing area, and ResizeDesktop asks for a new size that the
next BeginDesktopFrame applies, so a frame never draws into a surface that
changed under it. A failed resize keeps the old size. The desktop runner
now draws at DesktopViewport instead of a fixed 960x600. Apps use this for
compact windows, such as a small mode that grows into the full app.
2026-09-29 21:19:50 -03:00
waozi 09bf4caf62 Center segment labels under style sheets that pad them
Style sheets give a segment offset-x as its label padding, which sizes
the segment. The button that draws the segment read the same field as a
content offset, so every segment label sat that far right of center.
Segment faces now drop the offset inside the button, as modal faces do.
2026-09-29 21:16:10 -03:00
waozi ab51f8e345 Export the theme modules under their module names
KSS imports kryon/system_theme and kryon/theme. With exports named
after their modules, the same imports resolve in a --project build
and in a module-path build that names Kryon with
--module-path kryon=src/ui.
2026-09-29 21:02:29 -03:00
waozi b66773e917 Keep raylib's window record intact when Android builds prune fields
The Android surface overlays raylib's native CORE.Window record. Pruning
unused fields for a single entry point could shrink it and misplace the
size fields. A size assertion keeps its padding, and the test compiles a
pruned entry against raylib's real layout.
2026-09-29 21:00:26 -03:00
waozi 647b4914ec Keep the page query string across route writes
PushRoute and ReplaceRoute wrote history as path plus hash, so the first
route write dropped any ?query the page was opened with, such as an app's
embed flag. They now keep location.search, and GetRouteQuery reads it.
2026-09-29 20:58:39 -03:00
waozi cf2b4a5d66 Add an expand icon to the UI sheet
IconExpand (127) is the two-corner open-in-full glyph, drawn in the same
style as the navigation icons and placed in the next free ui.png cell so no
existing icon moves. The icon generator now keeps the IconType ids it writes,
instead of dropping them from ui.json.
2026-09-29 20:57:14 -03:00
waozi 2a00c369d1 Move KSS into its own package
Style sheet parsing, formatting, the style packs, and their tests now
live in kryonlabs/kss, which depends on Kryon. Kryon keeps the rule
table and style resolution, so an app that builds its rules in code no
longer carries a parser; apps that read .kss text add the KSS package
and import kss/Kss or kss/SystemStyle.
2026-09-29 20:56:26 -03:00
waozi c78981cd7b Ask ziran for compile_commands.json instead of the kryon tool
Describing generated C to editors is not specific to Kryon, so it now
lives in `ziran compile-commands`. The project build calls it with the
flags Kryon compiles with and says to update Ziran when the pinned
toolchain is too old to have the command.
2026-09-29 20:50:13 -03:00
waozi b19c0042d9 Reformat raylib_runtime and group the retained frame globals
No behavior change.
2026-09-29 20:49:34 -03:00
waozi 8e4e277dd8 Let a project link one static archive from its own tree
A profile's static_archive names a project-relative .a file that Kryon
adds as a build dependency and linker input. It rejects absolute paths,
paths or symlinks that leave the project, non-regular files, and browser
profiles, so reproducible builds never pick up a system library.
2026-09-29 20:49:28 -03:00
waozi 0525f80226 Build browser profiles through the package map
Canvas and DOM builds now check and save the app with `ziran ir
--project`, like native builds, so an app's Git dependencies and
package-qualified imports such as Kryon/Widgets work on the web too.
Browser routing is exported as PageRoute for apps that read or push
the page route.
2026-09-29 20:36:20 -03:00
waozi 2e74cf287b Move Plot, the data views, and Syntax into their own packages
PlotWidget now lives in kryonlabs/plot, TableView and TreeView in
kryonlabs/data-views, and the Ziran, C, and Make tokenizer in
ziranlang/syntax, which no longer depends on Kryon. Apps add them with
`ziran add URL` and import plot/Plot, data_views/TableView, or
syntax/Syntax.

Kryon exports the building blocks those packages draw with (session,
tree, surface, paint_queue, style, style_sheet, widget_kind, and the
rest), so a widget package imports kryon/NAME instead of reaching into
Kryon's source directories. The API guide describes writing one.
2026-09-29 19:47:57 -03:00
waozi dbfc8a6d7c Expose application lifecycle modules and preserve typed browser spaces 2026-09-29 19:20:36 -03:00
waozi b99d192d07 Draw rounded images as source-mapped rows and flush before captures
The textured fan for rounded images drew nothing inside the raylib
runner, and CI's raylib host test failed. Rounded images now draw as rows
with DrawTexturePro, each mapped to the matching part of the source, so
they still need no scissor and batch with other quads.

The same test exposed that CaptureConfigured read the framebuffer before
the frame's batch was drawn; it only passed while scissor changes flushed
the batch early. The capture now flushes first.
2026-09-29 19:13:38 -03:00
waozi 0d45371966 Let every master push finish its CI run
Several sessions push master more often than a run takes, and each push
cancelled the run before it, so master got no finished run at all (two
in a row were cancelled while testing the CI fixes). Runs on master now
each get their own concurrency group; pull requests still replace their
older runs. Move actions/cache and upload-artifact to the releases that
run on Node 24.
2026-09-29 19:03:49 -03:00
waozi baf11d1a9b Activate a tap pressed and released within one frame
A press only reached the node under the pointer if the button was still
down at the end of the frame, so a quick tap during a slow frame (both
events arriving between two frames) was silently dropped. It now presses
the node, and the release in the same frame activates it.
2026-09-29 19:02:25 -03:00
waozi 764044296c Outline segmented controls as one group
SegmentedControl never painted its own face, so the theme's background
and border for it were ignored and an unselected segment floated with no
edge. A single-row control now fills its background first and draws its
outline over the segments. The material theme makes it a pill with the
outline color and readable labels, as Material 3's segmented buttons.
2026-09-29 19:00:19 -03:00
waozi dc2644883a Draw rounded images as one textured shape, not scissored rows
A rounded image was clipped by drawing one scissored strip per corner
row. Every scissor change flushes the draw batch, so on a phone the Lists
screen spent 80% of each frame there and scrolled at about 4 fps. The
visible rounded region is now one textured triangle fan whose texture
coordinates map the destination onto the source; rotated images keep
the strip path.
2026-09-29 19:00:19 -03:00
waozi cbf9484491 Fix the CI failures the new host jobs exposed
CI has failed on every push since 09-27; three causes, none visible on a
developer machine with old build outputs:

- The behavior tests call ziran/build/bin/ziran and link libziran.a, but
  `make test` only built the zi2* compilers, so on a fresh runner every
  test failed with "ziran: not found". ziran-test now builds the toolchain.
- The raylib host pointed RAYLIB_SOURCE at the root of the raylib package
  since the move off the submodule (3e865032); raylib's library and
  Makefile live in src/. Local builds kept linking a libraylib.a from the
  old submodule, so only a fresh build failed ("package is incomplete").
- make test now includes the Canvas2D and DOM browser tests, and apps
  found emcc only under /home/wao. EMCC defaults to $HOME/emsdk, as the
  tests already do; CI installs emsdk 6.0.6 there (cached) and runs the
  browser tests in the runner's Chrome.
2026-09-29 18:46:16 -03:00
waozi 8da81631e6 Give the default material theme Material 3 navigation and larger text
The navigation bar was a floating bordered card with a square indicator.
It is now Material 3's: full width with no border or margin, 80 units
tall, a 64x32 pill behind a 24-unit icon, and the selected label in the
text color. NavigationBarHeight reports the theme's height so an app can
reserve it before drawing.

Styling apps had been adding themselves is now the theme's default:
cards on the surface color with 16-unit corners, unframed images in every
style pack, a title bar on the canvas with tonal action buttons, and a
muted text class. Text is about 12% larger (15/18/20), which reads better
on phones.
2026-09-29 18:11:30 -03:00
waozi 0977fdb503 Resolve widget styles against the installed rules without copying them
Every widget copied the whole 320-rule table at least twice per frame:
ActiveStyleRules() returned it by value, ResolveStyleRules took it by
value, and ApplyStyleRule copied the cascade and the rule for every rule.
On a phone that memcpy was the largest single cost of a frame.

ApplyStyleRules now reads a borrowed view of the rules in place, and
widgets resolve through ResolveInstalledStyleRules. The widget face
functions (Checkbox, Toggle, Radio, Slider, Image, Progress, Separator,
Plot) no longer take a rule table; tests install theirs first. The unused
single-rule ApplyStyleRule/ResolveStyleRule and the FromRules paint
helpers are gone.
2026-09-29 18:11:20 -03:00
waozi 6690be9d3c Run the desktop hosts, sanitizers, and seeded KSS fuzzing in CI
CI ran only `make test`, so the desktop, raylib, and libdraw hosts that
the feature matrix calls supported were never checked automatically.
A new job installs SDL, Cairo, Mesa, and the X tools, builds plan9port
once (cached), and runs the three project tests, each on its own private
Xvfb display with DISPLAY, WAYLAND_DISPLAY, and XAUTHORITY removed.

`make sanitize-test` repeats the behavior tests with every C and C++
program they build compiled under AddressSanitizer and
UndefinedBehaviorSanitizer, through $CC/$CXX wrappers; CI runs it in a
parallel job. The main job also fuzzes KSS with the run number as seed,
so each run adds sheets, and keeps a failing sheet as an artifact.
2026-09-29 17:18:03 -03:00
waozi e038190f15 Canvas: stop showing half-drawn frames when the app awaits
A frame that awaited mid-draw, for example to decode a new image, left
the page showing the cleared canvas for a frame, a blank flash on
navigation. Frames are now drawn into a back canvas and copied to the
page when they end, so the page always shows a complete frame.

The canvas browser test checks that a frame in progress stays off the
page, and records its later failures instead of returning them from main.
2026-09-29 17:17:58 -03:00
waozi 83065ca768 Fix the canvas text Wasm test for glyphs added on first use
Its fake textures lacked PageTextureUpdateRgba and rejected glyph pages.
It now also checks that a glyph outside the atlas is added once to a
page and freed with its font.
2026-09-29 17:17:58 -03:00
waozi 211bb062df Add make clean-scratch and a place for experiment builds
build/ had grown to 3 GB in 149 top-level directories, most of them
one-off debug builds (dom-debug3, zi2-isolated, header-check2, termi-*
with their own libcurl, an old Go module cache). BUILD_OUTPUTS names the
directories that targets and tests write; `make clean-scratch` removes any
other entry once nothing has written to it for a day, so a build another
session is running keeps its files. Experiments go in build/scratch/.
2026-09-29 17:07:30 -03:00
waozi 3477f1f817 Press é again until the desktop and raylib test windows take it
The default Xvfb keymap has no é, so `xdotool key eacute` maps it to a
spare keycode and restores the map right after the press. When SDL read
the press after the restore it saw no text, and the desktop test failed
about one run in three. Press again every half second until the window
reports the character; six runs in a row now pass.
2026-09-29 17:06:47 -03:00
waozi edc8e1207e Generate style pack modules with a Ziran tool and check them in make test
src/kss/style_pack_classic.zi embeds styles/kryon/classic.kss so apps can
install the pack without the file. It stays committed: apps import Kryon
as a package without running its Makefile. A Python script wrote it by
hand, and nothing noticed when the two drifted apart.

tools/style_pack_module.zi now writes it (`make style-packs`) with the same
chunks as before; only the header names the new tool. `make
style-pack-check`, part of `make test`, fails while a module differs from
its pack.
2026-09-29 17:06:36 -03:00
waozi aa79972510 Split the KSS parser into parts its module loads
kss_parser.zi held 5,400 lines. It now keeps the module's imports, types,
and parser setup, and #loads the rest from src/kss/parser/ in the original
order: lexer, token table, vocabulary, rules, blocks, directives and the
step, CSS values, and selector matching. The module, its API, and every
import stay the same; the generated C, C++, and Go are byte-identical to
the unsplit file. The parts are listed as build dependencies in the
Makefile and mk/ziran-project.mk so apps rebuild when one changes.
2026-09-29 17:06:20 -03:00
waozi 5f490088d4 Fuzz KSS and fix the formatter and parser bugs it found
tests/kss_fuzz.zi feeds generated and damaged sheets to the typed parser,
the declarative parser, the rule table, and the formatter, built with
AddressSanitizer and UndefinedBehaviorSanitizer (`make fuzz-kss`, and a
seed-1 run in `make test`). It checks parser state after every step, that
parses end, that errors carry a diagnostic, and that formatting only moves
white space, keeps the rules, tokens, declarations, and variant labels, and
is stable. A failing sheet stays in build/kss-fuzz; `sh tests/kss_fuzz.sh
shrink FILE` cuts it down while it keeps failing the same way. Sheets that
once failed live in tests/kss_corpus and run first; *.ok.kss must parse.

What it found, now fixed:
- The formatter dropped @import lines: import directives recorded no span.
- It dropped the @media/@font-face keyword and closing brace of foreign
  and group blocks, and wrote text it could not read back.
- It duplicated comments, one more copy per run: the gap scan walked the
  constructs it was appending to.
- It split quoted labels and import targets on one-line reflow and read
  comment openers inside strings; it now scans quotes and comments the way
  the parser does.
- A brace with nothing before it gained a stray space, so formatting was
  not stable; an unclosed comment at the end lost its last byte.
- A valid sheet with more than 32 top-level blocks failed to parse, and
  blocks inside imports used up the table. Block spans serve the formatter
  only: a full table now marks an overflow the formatter reports, and spans
  are recorded for the top-level source only. KssParser keeps its size
  (42160 bytes); it travels by value, and more overflows the Android render
  thread's stack.
- Quoted text and import targets end at their line, as CSS strings do, and
  import targets reject white space, quotes, braces, and semicolons, so
  re-indenting cannot change what they name.
2026-09-29 17:05:59 -03:00
waozi 4e1d7f234b Let the source check run from a symlinked checkout
Reached through a symbolic link (~/Projects -> /mnt/storage/Projects),
ripgrep could not anchor the script's own exclusion to the absolute search
path, found 'vendor/raylib' in the script itself, and failed every `make`.
Search from the repository with relative paths instead.
2026-09-29 17:05:33 -03:00
waozi 94eefccb93 Add Kryon laws for scrolling, shape clipping, and pixel scaling
`make laws` proves each law over its whole domain with `ziran check`,
and a mutation test confirms deliberately broken implementations are
rejected, so the laws are not vacuous. `make check` runs both.

The laws found that ScalePixels truncated negative sizes toward zero,
moving every negative offset a pixel; it now rounds half away from zero.
2026-09-29 16:40:57 -03:00
waozi 0a54b1004c Keep Android's system bar strips black
Apps cleared the whole surface to their canvas color, so the status and
navigation bar strips outside the safe viewport showed the app's
background behind light system icons. ClearAndroidFrame clears those
strips black and fills only the viewport with the canvas color.
2026-09-29 16:40:44 -03:00
waozi 6078ff4e06 Clip shapes to scroll views and never cut a label's own line
Only text and images honored a node's clip, so cards in a scroll view
drew their backgrounds and borders over the header and navigation bar.
Fills, outlines, lines, and gradients now draw only their visible part:
straight spans as rectangles and the rows of a cut corner one by one,
with no backend clip.

A Text line that starts inside its box is drawn whole, so a box a little
shorter than the line no longer cuts off the bottoms of its glyphs; lines
that start below the box are still clipped away.
2026-09-29 16:40:39 -03:00
waozi cd17cf0fca Draw unclipped labels, images, and corners without GPU flushes
On a phone, Habits spent a third of each frame in GL: every clipped label
and image set a scissor, which reads GL state and flushes the draw batch,
and every rounded corner was built from a fixed dozen segments on the CPU.

Text wholly inside its clip and an unrotated image inside its strip now
draw without a scissor, and a corner takes only the segments needed to
stay within half a pixel of the arc at its on-screen radius.
2026-09-29 16:40:31 -03:00
waozi 721169c0d2 Canvas: draw characters beyond Latin-1 instead of ?
The canvas font atlas only held U+0020 to U+00FF, so arrows, ellipses,
Greek, Cyrillic, and CJK text all drew as ?. Glyphs missing from the
atlas are now rasterised on first use into extra atlas pages, as the
native host adds them to its font.

Updating part of a texture now drops only that texture's tinted copies.
The canvas browser test records failures after main suspends, which
exposed that it never unloaded the default font it used.
2026-09-29 16:07:30 -03:00
waozi 066c61d9d6 Scroll observes the pointer itself and adds momentum and wheel glide
The host samples the pointer, wheel, and clock once per frame with
BeginScrollFrame (moved here from Inbe as scroll_device.zi); every Scroll
then observes that device on its own, so apps no longer pass an
observation into each ScrollProps.

Dragging content scrolls it on touch and mouse. The drag waits for a
threshold, and once it moves it cancels the press on the widget beneath.
A flicked drag keeps coasting and slows down until it stops, reaches
either end, or is touched. Wheel notches glide to their target over
about 150 ms instead of jumping, and further notches extend the glide.
2026-09-29 16:07:30 -03:00
waozi 7e6c8388a1 Add Android CMake helpers for Kryon apps
kryon_android_raylib builds raylib's Android backend with the module set
Kryon uses; kryon_android_app adds native_app_glue, size flags, 16 KB page
alignment, the fopen wrap raylib needs, and the system libraries.
2026-09-29 15:36:14 -03:00
waozi 29f4cb27c5 Fix canvas text clipped or missing, worst in Firefox
Glyph bitmaps put the baseline at the browser's font ascent plus padding
but reported no vertical offset, so text sat below its raylib-style line
box and widget clips cut it off. Firefox reports a larger ascent, so
small labels vanished entirely. Fonts are now drawn at the CSS size whose
ascent plus descent equals the requested size, and each glyph's offset
places its baseline at that ascent.

Canvas text and image clips passed layout rectangles to a screen-space
scissor, so under a render scale such as 1.07 every clip shrank toward
the origin. They now go through BeginRasterClip like the native host.

The canvas browser test checks both, and now fails when a check after
font loading fails; before, Asyncify dropped main's exit code.
2026-09-29 15:25:31 -03:00
waozi f8dc91406c Add the browser route module: GetRoutePath, GetRouteHash, GetRouteVersion, PushRoute, ReplaceRoute
The old JS runtime provided these; they now live in Ziran on the web bridge and
read the page location on every call. A headless Chromium project test covers
push, replace, hash and version.
2026-09-29 10:20:55 -03:00
waozi 369b22a15a Give the canvas backend raylib's Fade, MemAlloc, MemFree, SetTraceLogLevel and DisposeFrameTexture
Apps ported between the raylib and canvas backends call these by name. The
canvas trace level filters TraceLog once set and shows everything by default.
2026-09-29 10:16:43 -03:00
waozi a95f0eb111 Give TextArea the same context menu as TextField
The menu state and drawing move to text_context_menu, which both widgets use:
right-click opens Cut, Copy, Paste, and Select all on the system clipboard, and
the keyboard's Cut, Copy, and Paste reach it.
2026-09-28 23:49:33 -03:00
waozi 260f2dc5d6 Present unchanged retained frames 2026-09-28 23:40:12 -03:00
waozi 4cedb92a73 Detect unchanged retained paint plans 2026-09-28 23:36:56 -03:00
waozi faf0659b27 Add right-click context menus, the system clipboard, and text field menus
- SecondaryPointerFrame carries the right button beside PointerFrame; the
  desktop, raylib, and canvas hosts report it.
- SystemClipboard reads and writes the host clipboard (SDL and raylib; the
  other hosts report none).
- ContextMenu is an overlay list of commands; TreeDefer lets a widget draw
  above the whole page at the end of the frame.
- TextField opens Cut, Copy, Paste, and Select all on a right click and
  Ctrl+C, X, and V reach the system clipboard.
- A press and release inside one poll now counts as a press, so taps and fast
  clicks reach widgets.
2026-09-28 22:27:22 -03:00
waozi c0f2d58b92 Orient retained frame transitions upright 2026-09-28 21:29:32 -03:00
waozi c4ad58cc97 Add retained frame transitions 2026-09-28 21:20:46 -03:00
waozi 6829107b8e Track app sources in subfolders for rebuilds 2026-09-28 20:30:41 -03:00
waozi 605855a1cd Follow the desktop theme: read the GTK palette and install the classic style in it
SystemTheme parses a GTK theme's @define-color palette; SystemThemeLinux finds
the configured theme (Xfce xfconf, GTK settings.ini, GTK_THEME); SystemStyle
installs the embedded classic pack with the palette's colors. This replaces the
system theme the legacy C runtime had.
2026-09-28 19:50:44 -03:00
waozi 6e9b684e53 Add vector icons: an SVG shape rasterizer and a button icon_shape
Icons are drawn from a Shape (path data in a 24 x 24 box) as anti-aliased
queued rectangles, so every host draws them at any size, tinted with the text
color, with no PNG atlas.
2026-09-28 19:20:26 -03:00
waozi 0357a06bc4 Use Ziran packages for raylib source 2026-09-28 19:14:59 -03:00
waozi 4feb2a9a30 Make Lightfield dropdown menus opaque
The panel used the translucent glass surface, so content behind an open menu showed through. It now uses a popup colour that themes keep opaque.
2026-09-28 18:54:50 -03:00
waozi 4494af17b5 Wrap Japanese and Chinese text between characters
Text was split only at spaces, so a Japanese or Chinese sentence was one
word: it stayed on a single line and ran past the widget's edge. A line may
now break between characters when either side is kana, an ideograph, or a
fullwidth form, except before closing punctuation, the prolonged sound
mark, or a small kana, and after an opening bracket. Spaced scripts and
long Latin words behave as before.
2026-09-28 18:46:11 -03:00
waozi 9a0b79a8e3 Restore the Kryon Plan 9 install target 2026-09-28 18:45:24 -03:00
waozi 2eeaa69dff Write compile_commands.json from the kryon tool, not a Python script
The project build described the generated C to editors with
tools/write-compile-commands.py, so building any Kryon app needed
Python. The kryon project tool, which is Ziran, now does it as
`kryon compile-commands INCLUDE COMPILER GENERATED OUTPUT`, and the
makefile calls it. It writes the same bytes as the script did for a
real project, an empty directory, a compiler with arguments, and a path
that needs JSON escaping. The desktop project test checks the file's
entries and flags.

The script's deletion landed in the previous commit; this one carries
the tool, the makefile change, and the test.
2026-09-28 18:44:56 -03:00
waozi d1c69cb899 Use suffix rules for Kryon Plan 9 objects 2026-09-28 18:43:53 -03:00
waozi 51dcb7c468 Expand Kryon Plan 9 objects with guest shell 2026-09-28 18:40:33 -03:00
waozi 8bd7a42046 Resolve absolute Kryon Plan 9 object paths 2026-09-28 18:39:10 -03:00
waozi 0dfaff3c54 Keep Plan 9 object paths in the Kryon manifest 2026-09-28 18:35:52 -03:00
waozi 86e75bfc8d Measure a button for its label before placing it
Applications place controls at fixed positions, so a button reserved at
72 pixels clipped a longer label in another language. ButtonMeasure returns
the bounds a button takes for its props: a given width or height is kept,
and a zero one comes from the label, icon, and style, the same measurement
Button uses.
2026-09-28 18:33:07 -03:00
waozi 4187eb38ca Generate the Ziran Kryon library for Plan 9 2026-09-28 18:31:14 -03:00
waozi 60e3dbd1f7 Define TextFormat and TraceLog in Ziran; remove the C shim 2026-09-28 18:16:26 -03:00
waozi 17838eca6d Zoom every window the raylib runner opens
The runner now feeds the wheel and modifiers through zoom each frame, keeps
the Ctrl wheel and the zoom shortcut keys from the application, and draws
at the resulting factor: the modelview is scaled after BeginDrawing so the
clip code, which reads that matrix to place scissors, stays correct; the
viewport and pointer are reported in scaled space so layout reflows to the
smaller viewport; and fonts are baked at the size they reach the screen.
KRYON_ZOOM sets the starting factor. The Zoom and DPI modules are exported
for applications with their own frame loop.

The raylib project test checks a capture at 200% and a real Ctrl plus wheel
on a private display.
2026-09-28 18:08:34 -03:00
waozi 69742c610c Remove all handwritten JavaScript: canvas hosts now run in Ziran on the web bridge
The canvas window, drawing, textures, fonts, input, files, clipboard, drop and gamepad hosts are Zi modules (page_*.zi) calling the browser through std/web.zi. Kryon links only Ziran's generic ziran_web.js and a small C varargs shim. The JS budget test becomes a zero-JS boundary test.
2026-09-28 18:03:25 -03:00
waozi 8711463014 Format DOM lengths with Ziran number_text 2026-09-28 17:52:25 -03:00
waozi 833edbbede Move the DOM backend's element host from handwritten JS to Ziran on the web bridge 2026-09-28 17:50:13 -03:00
waozi b722d152d1 Keep a touchpad's partial zoom step when the factor is set unchanged
An application that stores its scale sets the factor every frame. That
reset the carried part of a notch even when the value was the same, so a
touchpad's small movements never reached a step. Setting a factor changes
the carry only when the factor changes.
2026-09-28 17:49:39 -03:00
waozi aba07021a0 Zoom a whole application with Ctrl and the mouse wheel
zoom.zi decides in Ziran what a browser's page zoom decides: Ctrl with
the wheel steps one factor for the session, Ctrl with plus, minus, or zero
steps or resets it, and the wheel is reported as consumed so lists do not
also scroll. The ZoomProps prop defaults to automatic mode, which zooms on
desktop windows and leaves browsers and touch screens alone; on, off, the
range, and the step are configurable. Small touchpad movements add up to a
step, and the factor always lands on a whole step so an application that
stores a scale in tenths sees exact values.
2026-09-28 17:48:37 -03:00
waozi 53c3d83b8a Move WebAudio host from handwritten JS to Ziran on the web bridge 2026-09-28 17:46:35 -03:00
waozi d9ef1d9cf5 Export composition state from the widget catalog
TextFieldProps and TextFieldResult carry a CompositionState, but the
Widgets import did not export that type, so an application could hold a
text field's state only by importing an internal module. Widgets now
re-exports it, and the public surface check names it.
2026-09-28 17:44:00 -03:00
waozi 1ccc81d14e Report the held keyboard modifiers to applications
KeyboardTake reports one key press, but a shortcut such as Ctrl+S is a
key read together with the modifiers that were down. Hosts now submit
the held Shift, Control, and Alt keys with KeyboardModifiersSend before
each frame, and an application reads them with KeyboardModifiers. The
desktop host takes them from the key event itself so a modifier
released before the poll ends still counts; the raylib host reads its
key state. The tree input test covers the primitive on every target,
and the desktop project test presses Ctrl+S under Xvfb.
2026-09-28 17:44:00 -03:00
waozi 887fa1de83 Keep browser audio state in Ziran; the page only makes WebAudio nodes
The audio JavaScript tracked buffers and their reference counts, sound
voices, pause positions, music position and loop state, streams and
their scheduling, callbacks, processors, and every clamp. All of that
now lives in canvas_audio_engine.zi, and the page creates and connects
nodes for integer handles that module picks (401 fewer lines).

A native test runs the state machines against a fake WebAudio host with
a controllable clock: clamps, refcounts, voice overflow (now bounded at
16, oldest cut off), pause offsets at the playback rate, music position
and seek clamping, non-looping end, stream scheduling and the two-block
limit, timers, processor order, and close.
2026-09-28 17:34:51 -03:00
waozi 76091e9c50 Choose DOM elements in Ziran; the page only applies them
Which element, role, level, and attributes each semantic node gets, the
native disabled state of buttons, and the document title were decided in
the page's JavaScript despite its header saying otherwise. Zi now
computes them (DomSpecFor) and hands the page explicit values.

A native test covers every semantic kind, the widget-kind fallbacks,
heading clamping, links, images, and the flag bits. One edge changes:
a page node with no label no longer takes its title from its
descendants' text.
2026-09-28 17:29:15 -03:00
waozi 956a9a97a8 Decide browser input in Ziran; the page only forwards raw events
The Canvas host's JavaScript held the DOM key table, press/repeat and
release tracking, pointer scaling, wheel units, touch-to-mouse
synthesis, focus handling, clipboard, and which events to cancel. It
now forwards each raw DOM event to a Zi handler (canvas_events.zi) that
owns all that state and answers with flags for what the page does next.

A native behavior test drives the handler through every one of those
rules without a browser, and the JS budget test now bans the key table
from returning. 161 lines of JavaScript are gone.
2026-09-28 17:27:35 -03:00
waozi 9812405f82 Cap the handwritten browser JS and inventory its entry points
The Canvas and DOM hosts are moving their policy into Ziran. This test
records each JS file's line and entry-point budget, so it can only
shrink, and lists policy identifiers that must not reappear there.
2026-09-28 17:21:59 -03:00
waozi 3f41807860 Report which widget made a frame fail
A duplicate explicit key rejects the whole frame, and hosts only saw the
status. The tree now keeps the offending key and widget kind until the
next frame starts, readable through TreeFrameErrorKey and
TreeFrameErrorKind.
2026-09-28 12:35:49 -03:00
waozi eb93b3dffe Keep the slider thumb inside the slider bounds
The thumb centred on the track ends, so at the minimum or maximum half
of it hung outside the control and over neighbouring content. The track
now leaves half a thumb at each end; pointer mapping follows the track.
2026-09-28 12:22:14 -03:00
waozi 87e50702a5 Keep queued label text until the frame is painted
Labels paint after the widget call returns, so text formatted into a
caller's local buffer was gone by paint time and labels such as version
numbers, percentages, and formatted options drew empty. The paint queue
now copies each label into per-session frame text and paints from it.
2026-09-28 12:16:58 -03:00
waozi 8d26aadf40 Cast navigation option slice bound for Go backend 2026-09-28 12:09:43 -03:00
waozi 032cf16744 Draw slider and radio marks round and fill single-row segments
Sliders and radios passed 0.5 as a pixel corner radius, so their tracks,
thumbs, and marks drew as squares. PillRadius gives the half-side radius
every pill and circle paint now uses. A single-row segmented control
split its content width instead of its bounds, clipping longer labels;
it now fills bounds wider than its content.
2026-09-28 11:59:05 -03:00
waozi 2eed2f1c49 Bake raylib font atlases at the exact size text uses
Text snapped to 14, 16, or 32 pixel atlases and was scaled to its real
size, so 15-36 pixel text was blurred and picked up edge pixels from
neighbouring glyphs. Each requested size now gets its own atlas, cached
per typeface and rebaked when new glyphs arrive.
2026-09-28 11:51:20 -03:00
waozi 9d1737efc4 Draw toggle switches as pills with a light thumb
Toggle passed 0.5 as a pixel corner radius, so switch tracks and thumbs
drew as squares. Tracks and thumbs are now pills; labeled toggles follow
the theme radius up to half their height. A checked thumb used the
accent text ink, which is near-black on pale accents; it now uses the
thumb ink.
2026-09-28 11:47:44 -03:00
waozi d4ebc719ee Round labeled toggles with the theme radius and ink accent thumbs
A switch track stays a pill; a labeled toggle's segments follow the
theme's corner radius. Accent thumbs use the thumb ink color.
2026-09-28 11:42:25 -03:00
waozi a5c3cbe2cc Take project settings from ziran and install apps with ziran install
Kryon declares its [tool.Kryon] settings under [options] in ziran.toml.
Ziran checks and merges them, including ziran.local.toml, and the kryon
tool reads the result, so Kryon no longer parses TOML itself.

`ziran install` builds the [tool.Kryon.install] profile, replaces
PREFIX/bin/BIN in one step so a running copy is never touched, and
writes the icon, menu entry, and optional autostart entry.
2026-09-28 11:36:00 -03:00
waozi 0937658bc2 Match native Plan 9 mouse ABI 2026-09-28 02:39:40 -03:00
waozi 32b626b5f2 Quit on session end even while intercepting the close button
SDL reports both a closed last window and SIGTERM or logout as SDL_QUIT, so
an app hiding to its tray would also ignore the session ending. While
interception is on, the desktop host now turns off SDL's quit-on-last-
window-close, treats the window's close event as the close request, and
always quits on SDL_QUIT.
2026-09-28 02:38:15 -03:00
waozi 3d8bbe4b74 Use the full-size profile glyph 2026-09-28 02:16:52 -03:00
waozi 8471658614 Own native Plan 9 input and resize state 2026-09-28 01:44:21 -03:00
waozi 0597526acb Register public layout props module 2026-09-28 01:41:11 -03:00
waozi e942b4ba35 Fall back to the available Linux tray host 2026-09-28 01:26:53 -03:00
waozi d114100e36 Render compact text from a native-size font atlas 2026-09-28 01:20:34 -03:00
waozi ef9934f815 Expose the types public widgets return and take
Checkbox, Toggle, Selectable, Spinbox, Slider, and DiscreteSlider returned
result types declared in internal modules, and Column, Row, Stack, Group,
Screen, and Grid took props that Widgets did not expose, so a package app
could not name them. Move those types into each widget's props module and
export layout_props and grid_props from Widgets.

Project builds now make only the Ziran driver, zi2zir, and zi2c instead of
every backend, so an unrelated backend cannot stop an app build.
2026-09-28 01:17:02 -03:00
waozi 196ad39010 Let apps hide their window and handle closing
The new Window module lets an app keep working in the background: it can
hide and show its window, ask the host to report the close button instead
of quitting, and quit when it decides. The SDL/Cairo desktop host supports
all of it and keeps calling Frame about ten times a second while hidden,
without presenting. raylib hides and shows but cannot cancel a close;
terminal, libdraw, and browser hosts accept the calls and report what they
cannot do.

Window and Tray are now package exports, so apps built with ziran tool
Kryon can import them.
2026-09-28 01:03:31 -03:00
waozi 357c23e329 Own text state in Ziran widget tests 2026-09-28 01:02:14 -03:00
waozi 9baa278ea6 Build only Kryon library compiler dependencies 2026-09-28 00:45:07 -03:00
waozi b3459d4bb3 Add a Ziran system tray module
`tray` shows a notification-area icon with a nested menu and reports the
chosen action to the app, which decides what it means. On Linux and BSD it
runs GTK on its own thread, loaded with dlopen only when a tray opens: a
StatusNotifierItem through libayatana-appindicator (or libappindicator)
when installed, otherwise a GTK status icon for XEmbed trays
(KRYON_TRAY=status-icon forces it). Windows uses Shell_NotifyIcon on a
private message window.

TrayVisible is true only once a host shows the icon (an XEmbed tray embeds
it or a StatusNotifierWatcher accepts it), so apps hide their window to the
tray only when the user can bring it back.

This is Inbe's tray moved into Kryon so ATR and other apps can share it.
2026-09-28 00:44:39 -03:00
waozi 208baa28ab Tint UI icons with their control ink and sharpen small text 2026-09-28 00:38:43 -03:00
waozi 833aed787c Match native Plan 9 libdraw ABI 2026-09-28 00:31:18 -03:00
waozi 258802f526 Complete native Plan 9 raster validation 2026-09-27 20:10:46 -03:00
waozi 40e9d13cba Add a native Plan 9 libdraw raster 2026-09-27 18:37:37 -03:00
waozi de55ba00fe Own composition text in widget tests 2026-09-27 18:27:31 -03:00
waozi b68647ecfa Isolate styled modal button coverage 2026-09-27 18:27:25 -03:00
waozi 4beb3223a5 Load UI glyphs beyond ASCII on the raylib backend
An unseeded typeface baked only raylib's 95 ASCII glyphs, so accented locale
text and punctuation such as › and — drew as '?'. Start from Latin, Greek,
Cyrillic, punctuation, currency, and arrows, keep the font source, and rebake
once when measured or drawn text needs a glyph that is not in the atlas yet.
2026-09-27 17:39:15 -03:00
waozi 44861954ea Keep modal button labels inside their buttons
Modal action and close faces carry dialog layout sizes in offset-x and
offset-y. Button treated them as content offsets, so style packs pushed every
modal button label 88px right and 150px down, outside the button's clip.
Zero them for Modal-styled buttons and drop the unused helper that did this
for the removed handwritten runtime.
2026-09-27 17:21:05 -03:00
waozi 909e084f98 Draw built-in button icons from the icon atlas 2026-09-27 17:13:09 -03:00
waozi 2e693b1d89 Use the Kryon browser namespace 2026-09-27 17:13:02 -03:00
waozi 7bf94d8bb4 Classify experimental hosts in the feature matrix 2026-09-27 17:12:55 -03:00
waozi acd3e6b2cb Finish the maintained-source inventory cleanup 2026-09-27 17:07:37 -03:00
waozi 535235d81e Complete semantic DOM browser host and modular Canvas rastering 2026-09-27 16:49:34 -03:00
waozi fb35a127bf Add queued vertical gradient paint
PaintVerticalGradient queues a top-to-bottom fade with the frame's other
paint, so it can cover an Image submitted earlier in the same frame. Backends
still rasterize only flat rectangles; the gradient is emitted as one-pixel
rows.
2026-09-27 16:42:19 -03:00
waozi 9ee38f6cae Add Canvas2D and semantic DOM browser backends
Kryon projects can select the canvas or dom backend to build a single-file
browser app through Emscripten. Images and links carry semantic detail so the
DOM backend can expose real image sources and link targets.
2026-09-27 15:39:38 -03:00
waozi 82682e7e24 Declare foreign allocation sizes as usize 2026-09-27 15:39:33 -03:00
waozi dc7c00faa3 Guard Ziran test sources and drop unused Go fixture 2026-09-27 12:43:13 -03:00
waozi 3de960ab3e Run accessibility policy checks from Ziran source 2026-09-27 12:40:10 -03:00
waozi b3689e3a37 Document Ziran test hosts 2026-09-27 12:28:23 -03:00
waozi c5c74fc9aa Remove obsolete C test hosts and completed migration step 2026-09-27 12:27:52 -03:00
waozi b00ab858cb Check toolbar paint in Ziran 2026-09-27 12:26:31 -03:00
waozi 3dcd15c206 Check title bar paint in Ziran 2026-09-27 12:25:17 -03:00
waozi a144508868 Check plot paint in Ziran 2026-09-27 12:24:19 -03:00
waozi 153b3c9f6f Check navigation bar paint in Ziran 2026-09-27 12:23:06 -03:00
waozi 8f51cb5b10 Check modal frame paint in Ziran 2026-09-27 12:21:12 -03:00
waozi e0873bb575 Check dropdown paint phases in Ziran 2026-09-27 12:19:32 -03:00
waozi ae3d7ffd75 Check image fallback and texture paint in Ziran 2026-09-27 12:17:05 -03:00
waozi 6356f8ef39 Check button image and paint in Ziran 2026-09-27 12:15:29 -03:00
waozi f0e63f88c7 Check radio paint in Ziran 2026-09-27 12:13:51 -03:00
waozi b1fbaba970 Check checkbox paint in Ziran 2026-09-27 12:12:34 -03:00
waozi 5853d27c27 Check toggle paint in Ziran 2026-09-27 12:11:04 -03:00
waozi 491122f4ad Check slider paint in Ziran 2026-09-27 12:09:45 -03:00
waozi 5db5214c7b Check spinbox labels in Ziran 2026-09-27 12:08:31 -03:00
waozi 5309d58d21 Check text layout and paint in Ziran 2026-09-27 12:06:47 -03:00
waozi 21864c7d3e Check toast paint and labels in Ziran 2026-09-27 12:05:28 -03:00
waozi 0162315f9f Check collapsible and segment clips in Ziran 2026-09-27 12:04:27 -03:00
waozi 86a5582997 Run composition widget paint checks in Ziran 2026-09-27 12:02:51 -03:00
waozi 21057f2262 Run navigation configuration checks in Ziran 2026-09-27 12:00:51 -03:00
waozi c43ab34d8b Use a Ziran device host for state-focused widgets 2026-09-27 11:59:58 -03:00
waozi bcbb782838 Move progress session checks into Ziran 2026-09-27 11:58:14 -03:00
waozi b69f9ff5bc Run TreeView host assertions in Ziran 2026-09-27 11:54:05 -03:00
waozi 91115c277f Move page text host checks into Ziran 2026-09-27 11:52:07 -03:00
waozi a10deb1675 Read raylib host environment through libc 2026-09-27 11:50:05 -03:00
waozi 53eff19a3a Keep composition test text in owned storage 2026-09-27 11:49:06 -03:00
waozi 22bd80c801 Preserve camera transforms and nested raster clips 2026-09-27 11:47:15 -03:00
waozi 1d60e1e6d6 Avoid duplicate execution of identical portable bundles 2026-09-27 11:42:26 -03:00
waozi ea4c54729e Clip scope paint to scroll viewport 2026-09-27 11:38:11 -03:00
waozi 83998abad8 Retain semantic labels in tree-owned storage 2026-09-27 11:31:31 -03:00
waozi b0fec3944c Run theme behavior entirely from Ziran tests 2026-09-27 11:29:24 -03:00
waozi 4513d0c7ff Run locale defaults natively from Ziran 2026-09-27 11:28:42 -03:00
waozi 8a0c03fa38 Own installed style typeface bytes in Kryon 2026-09-27 11:28:15 -03:00
waozi d1a0f31783 Run DPI behavior entirely from Ziran tests 2026-09-27 11:24:52 -03:00
waozi 25f3cb00a1 Move policy checks and raster bindings into Ziran 2026-09-27 11:24:13 -03:00
waozi 25bd6cd75e Run host-free portable checks directly with Ziran 2026-09-27 11:19:50 -03:00
waozi fdf1a0fc20 Keep current feature status without completed migration history 2026-09-27 11:18:52 -03:00
waozi 097232b5cb Prune completed migration notes and unused style loader type 2026-09-27 11:17:53 -03:00
waozi 6275cfa746 Run native Go widget checks through Ziran host bindings 2026-09-27 11:14:50 -03:00
waozi 464131d189 Tint navigation icons with their item color 2026-09-27 11:13:58 -03:00
waozi a9fb3500d5 Center navigation bar labels within their tabs 2026-09-27 11:12:57 -03:00
waozi 65729f433a Add session-owned platform text input queue 2026-09-27 11:11:41 -03:00
waozi 10d7da7420 Run native widget host checks from Ziran providers 2026-09-27 11:04:54 -03:00
waozi 1ff5d2effa Move fieldset portable host test to Ziran 2026-09-27 11:01:34 -03:00
waozi 1f73ae6dc6 Move list box and color picker portable hosts to Ziran 2026-09-27 11:00:37 -03:00
waozi 0beb376773 Recover Android surface and safe-area behavior in Ziran 2026-09-27 10:59:34 -03:00
waozi 6ca452bb8a Move selectable portable host test to Ziran 2026-09-27 10:58:29 -03:00
waozi b26f10a252 Move separator portable host checks to Ziran 2026-09-27 10:57:26 -03:00
waozi ab561def52 Move progress widget portable host test to Ziran 2026-09-27 10:55:20 -03:00
waozi 41a1d47fc9 Move paned view portable host test to Ziran 2026-09-27 10:53:03 -03:00
waozi 4e277e65f0 Remove completed migration fixtures and port reorder test host 2026-09-27 10:47:58 -03:00
waozi 467283bc40 Render links in current feature matrix 2026-09-27 10:38:44 -03:00
waozi a63545f44d Remove obsolete Kryon runtime and migration archives 2026-09-27 10:36:49 -03:00
waozi 7b1e1bdf1b Handle UTF-8 terminal input in Ziran host 2026-09-27 10:18:11 -03:00
waozi 98a478a7b9 Share UTF-8 decoding and validate Unicode input across hosts 2026-09-27 10:11:02 -03:00
waozi e05f8d0222 Handle desktop text input in Ziran hosts 2026-09-27 09:59:52 -03:00
waozi 938c41faec Clear all session input when closing a UI session 2026-09-27 01:41:57 -03:00
waozi b0ce709bfd Remove obsolete C backend compatibility generators 2026-09-27 01:40:47 -03:00
waozi 0281d5a751 Implement raylib typeface host in Ziran 2026-09-27 01:38:30 -03:00
waozi 0cfdbfeb36 Use Ziran packages for Kryon projects and visual hosts 2026-09-27 01:38:27 -03:00
waozi cb7d99a727 Require root repository work on master 2026-09-27 01:21:04 -03:00
waozi 987f5843f9 Export optional Kryon modules for Ziran packages 2026-09-27 01:12:46 -03:00
waozi 923e2c092d Use Ziran standard math and vector modules directly 2026-09-27 01:08:11 -03:00
waozi 80fb590059 Expose Circle as shared geometry 2026-09-27 00:55:39 -03:00
waozi 1280b0e579 Expose core widgets and optional plot as Ziran modules 2026-09-27 00:54:26 -03:00
waozi ae9e21f9cc Repair desktop example imports and generated output cleanup 2026-09-27 00:36:28 -03:00
waozi 7395604ceb Run frame capture replay from native Ziran 2026-09-27 00:36:20 -03:00
waozi e7bd798600 Move raylib game API into Game2D package 2026-09-26 23:46:46 -03:00
waozi 4235447bbd Exclude legacy standard-library links from fetched builds 2026-09-26 23:07:19 -03:00
waozi 72c3094fe5 Document package-based Kryon projects 2026-09-26 23:04:31 -03:00
waozi 13b42743b8 Expose Kryon as a Ziran package and project tool 2026-09-26 23:02:26 -03:00
waozi 774fcf7785 Name stable icon catalog IDs in Ziran 2026-09-26 22:54:09 -03:00
waozi b2c8e3032a Expose icon atlas images through Ziran Image props 2026-09-26 22:51:52 -03:00
waozi c6343ff518 Publish static Kryon Labs site to Cloudflare Pages 2026-09-26 22:25:24 -03:00
waozi ee66c421a4 Brand Kryon Labs site with modular K mark 2026-09-26 22:21:15 -03:00
waozi c3c07a541b Expose point rectangle collision to Ziran games 2026-09-26 21:47:47 -03:00
waozi d452aabe7e Allow per-profile native libraries in Ziran projects 2026-09-26 21:05:28 -03:00
waozi 6a8c8fefbb Expose window and pointer observations to Ziran games 2026-09-26 20:59:50 -03:00
waozi 7eeeea6c2f Keep clipboard and locale text views valid in Ziran 2026-09-26 20:43:41 -03:00
waozi 988a9c5341 Expose screenshot image and DPI observations to Ziran games 2026-09-26 20:21:04 -03:00
waozi c7cac27230 Expose desktop window and input calls to Ziran games 2026-09-26 20:11:16 -03:00
waozi c908d44cb7 Route mouse wheel to scrollable lists 2026-09-26 19:41:08 -03:00
waozi 22af01faae Add value based Box widget for decorative surfaces 2026-09-26 19:18:46 -03:00
waozi fec9e9052f Provide terminal image size stubs 2026-09-26 18:24:26 -03:00
waozi 26ce11796e Add Ziran libdraw host with shared Cairo raster 2026-09-26 17:47:00 -03:00
waozi fb7e414334 Use circular hit regions for circle buttons 2026-09-26 17:41:37 -03:00
waozi a137daf1b5 Expose raylib pause and mixed audio controls in Ziran 2026-09-26 16:48:19 -03:00
waozi f892a5eda7 Expose raylib wave decoding and sound controls in Ziran 2026-09-26 16:39:39 -03:00
waozi 87fefa2670 Split syntax coloring into an optional package 2026-09-26 16:33:52 -03:00
waozi ad30808a7f Expose typed raylib characters to Ziran apps 2026-09-26 16:28:03 -03:00
waozi 66898352b8 Expose raylib wheel movement to Ziran apps 2026-09-26 16:21:16 -03:00
waozi b6acf3b7f2 Split KSS authoring into an optional package 2026-09-26 16:18:49 -03:00
waozi 856978727e Move guide and locale policy to Inbe 2026-09-26 16:10:06 -03:00
waozi 75e7427156 Cover raylib pointer activation in the project test 2026-09-26 16:10:03 -03:00
waozi 108ce3cd26 Forward raylib key presses through the Ziran host 2026-09-26 16:05:40 -03:00
waozi 9b37ca5751 Move raylib game API into an optional package 2026-09-26 15:59:14 -03:00
waozi aaec746e3e Resolve style token colors in checked Ziran 2026-09-26 15:58:20 -03:00
waozi 32722fb893 Split data views into an optional UI package 2026-09-26 15:54:20 -03:00
waozi bb1e4390b0 Split Plot into an optional UI package 2026-09-26 15:46:27 -03:00
waozi e7cf9f0266 Re-export StyleTokenColor as an ordinary procedure
Foreign bindings stay module-local, so downstream modules could not see
the token resolver declared directly. Wrap the host binding in a plain
procedure, which crosses module boundaries like every other drawing
helper.
2026-09-26 09:04:48 -03:00
waozi 37964b25e7 Expose StyleTokenColor through the drawing props module
Translated app UI reads theme tokens by name through the runtime
style-pack resolver. The resolver is a host capability like the raster
primitives, so declare it beside the color helpers with the same
host_api binding convention.
2026-09-26 08:54:08 -03:00
waozi dcc9ad8cf8 Record the downstream cutover state in the migration status 2026-09-25 20:58:25 -03:00
waozi 1d916bc24b Honor runtime texture over asset path in raylib host 2026-09-25 17:49:36 -03:00
waozi 05ec784a79 Preserve runtime texture dimensions in raylib image paint 2026-09-25 17:49:10 -03:00
waozi 717a4cf0ae Document and verify Ziran raylib projects 2026-09-25 17:43:15 -03:00
waozi c878ce74b3 Clear stale generated Go before Kryon library build 2026-09-25 17:26:11 -03:00
waozi 18a678e210 Add the raylib backend and Ziran game surface
vendor/raylib enters as an HTTPS submodule and mk/ziran-project.mk builds
it statically for PLATFORM_DESKTOP_SDL with audio enabled, so kryon
projects can choose backend raylib alongside terminal and desktop.

src/backend/raylib_runtime.zi implements the host raster contract on a
real GPU window (texture cache, scissor, font loading, screenshots) and
raylib_run.zi is its app entry loop. raylib_game.zi adds the plain game
surface applications import directly: window control, keyboard/mouse/
touch input, textures and render targets, shape and text drawing,
camera2D, blend and scissor modes, the audio device, sounds and music,
raylib timing and random values, and libm math - all with raylib's own
names over Ziran types that match the C ABI. Headless builds link C
stubs under the same names instead of libraylib.
2026-09-25 17:14:32 -03:00
waozi 9bb4574834 Handle VM_HOST_POINTER in the frame replay JSON capture
Ziran host values now carry raw pointers as opaque handles; serialize
them as tagged addresses so the exhaustive switch stays warning-clean.
2026-09-25 16:35:53 -03:00
waozi f2c382adf6 Separate plot accessibility label from caption 2026-09-25 15:45:56 -03:00
waozi ad4bd77460 Remove dead Android Java bridge and fix header-check exclusion
The Android launch activity, secure store, and text input bridge called
JNI natives whose C implementations were deleted with the legacy core;
application launch activities belong in their applications. Kryon
implementation source is now 100% Ziran and the source inventory rejects
any new handwritten implementation file. The header check now searches
from the repository root so its test-host exclusion actually matches.
2026-09-25 15:44:09 -03:00
waozi 42d009a607 Add desktop project host and persistent terminal UI 2026-09-25 15:32:43 -03:00
waozi 9ffb240f14 Implement portable Ziran reorder widget 2026-09-25 14:17:27 -03:00
waozi d0bc6cba37 Open frame status enum in terminal project host 2026-09-25 12:59:42 -03:00
waozi af0ee22a5f Use explicit enum scopes with current Ziran and disambiguate text module 2026-09-25 12:30:21 -03:00
waozi 1f429e7737 Add Ziran typeface source host contract 2026-09-25 06:12:06 -03:00
waozi cd439879b4 Expose borrowed locale text lookup for apps 2026-09-25 03:05:14 -03:00
waozi 813a9b6b4b Complete current Ziran widget library migration and tests 2026-09-25 02:40:09 -03:00
waozi 5577ca1e24 Use Jai procedure type syntax for painters 2026-09-24 19:54:12 -03:00
waozi 6be0bb2582 Replace SDL Cairo desktop example host with Ziran 2026-09-24 17:25:50 -03:00
waozi 81b6ebe986 Prevent new handwritten Kryon implementation sources 2026-09-24 16:59:37 -03:00
waozi c5f9a0bc9a Remove obsolete Go runtime parity tooling 2026-09-24 16:56:52 -03:00
waozi 43ca4917c0 Move headless hello host to Ziran source 2026-09-24 16:55:48 -03:00
waozi 644ecd569c Use Jai count syntax for collection access 2026-09-24 16:41:40 -03:00
waozi 30e65129eb Remove unused handwritten GL blend include 2026-09-24 16:29:58 -03:00
waozi 20f5e34891 Keep cursor and frame pacing decisions entirely in Ziran 2026-09-24 16:28:52 -03:00
waozi b1760070ee Remove unused handwritten Go Kryon runtime 2026-09-24 16:20:38 -03:00
waozi a6fed2c577 Revert "Prove native Kryon linking with desktop image and button parity"
This reverts commit 00fdb1e4ad.
2026-09-24 16:18:00 -03:00
waozi 7c75c2a782 Require current Ziran for all Kryon implementation 2026-09-24 16:17:34 -03:00
waozi 6dbf908e0e Center theme toggle icon across Kryon pages 2026-09-24 16:08:24 -03:00
waozi 24bf5c63c8 Refresh Kryon site for Ziran library architecture 2026-09-24 16:03:50 -03:00
waozi 00fdb1e4ad Prove native Kryon linking with desktop image and button parity 2026-09-24 15:57:59 -03:00
waozi 88cad3a544 Remove unused clip stack host declarations 2026-09-24 15:49:42 -03:00
waozi 4783352047 Remove unused native text declarations from widget props 2026-09-24 15:48:42 -03:00
waozi de48ba4860 Render asset-backed PNG images in desktop proof host 2026-09-24 15:45:12 -03:00
waozi 618fe643e2 Bind reusable pointer input and prove desktop bundle rendering 2026-09-24 15:33:17 -03:00
waozi 6f80e4a43f Remove retired Ziran keywords from syntax highlighting 2026-09-24 15:14:32 -03:00
waozi f58abf4a31 Explain composition host ABI boundary 2026-09-24 15:09:47 -03:00
waozi 7f72eeb58e Use Jai procedure type syntax for painter callbacks 2026-09-24 15:02:21 -03:00
waozi b581577b1c Complete Kryon migration to current Ziran syntax and host queue 2026-09-24 14:43:35 -03:00
waozi 69fdf30632 Migrate Kryon controls and frame capture capabilities 2026-09-24 13:31:35 -03:00
waozi 1688b34609 Migrate Kryon widget composition and paint host effects 2026-09-24 13:27:15 -03:00
waozi 08dd79b6d9 Migrate Kryon layouts, menus, scrolling, and text policy 2026-09-24 13:19:31 -03:00
waozi 035bea7d5d Update Kryon source migration count 2026-09-24 13:16:06 -03:00
waozi 3671699cce Migrate Kryon policy widgets and drawing values 2026-09-24 13:15:52 -03:00
waozi d918d5b55b Update Kryon syntax migration count 2026-09-24 13:11:52 -03:00
waozi 6c51c33c06 Move canvas behavior and UI props into current Ziran syntax 2026-09-24 13:11:39 -03:00
waozi 246f02892d Run window policy behavior under current Ziran syntax 2026-09-24 13:05:28 -03:00
waozi bf292feb31 Document current Kryon syntax migration status 2026-09-24 13:04:30 -03:00
waozi 57e56f1f5b Migrate Kryon tree and host capability modules 2026-09-24 13:03:45 -03:00
waozi 32f8f079a1 Migrate foundational Kryon widgets to current Ziran syntax 2026-09-24 12:58:40 -03:00
waozi 7321dc391a Describe the complete Ziran widget module inventory 2026-09-24 12:48:53 -03:00
waozi 733c67df0a Label the native policy audit as historical 2026-09-24 12:44:22 -03:00
waozi 40c79de115 Document the value based Scroll widget API 2026-09-24 12:43:40 -03:00
waozi b886d0ba73 Name scroll frame values for the current widget API 2026-09-24 12:39:32 -03:00
waozi 869527d65c Route wheel input to the deepest scroll viewport 2026-09-24 12:35:38 -03:00
waozi db80d6ec31 Paint styled scrollbars in Ziran Scroll widget 2026-09-24 12:25:17 -03:00
waozi 44ba6d807e Accept portable pointer input in Scroll widget 2026-09-24 12:18:10 -03:00
waozi 39b3d90cad Run Kryon tests with the selected Ziran toolchain 2026-09-24 12:10:18 -03:00
waozi 98ce12b24f Build Ziran Kryon library with out-of-tree toolchain 2026-09-24 11:20:24 -03:00
waozi 7abf52902f Add headless frame capture and replay 2026-09-24 02:04:01 -03:00
waozi e10462dc0f Delete legacy header-based Kryon path 2026-09-24 01:06:16 -03:00
waozi 13e5e805cf Hash widget keys in portable layout code 2026-09-24 00:12:18 -03:00
waozi 4c8d910245 Add checked Scroll viewport composition 2026-09-24 00:11:30 -03:00
waozi 960e7e63a9 Apply inherited viewports to text and image paint 2026-09-23 23:35:59 -03:00
waozi b109c530fd Clip retained child input to ancestor viewports 2026-09-23 23:08:04 -03:00
waozi 37361e6f3a Exercise persistent Ziran widget input in SVG example 2026-09-23 21:45:38 -03:00
waozi e5e5702d9c Add runnable Ziran widget bundle example 2026-09-23 21:12:39 -03:00
waozi 8359ca9fa5 Move clipboard UI state into checked Ziran 2026-09-23 20:55:15 -03:00
waozi 3676e74cef Move style picker composition into checked Ziran 2026-09-23 20:39:11 -03:00
waozi 23584157a4 Migrate cursor intent into checked Ziran UI module 2026-09-23 20:24:27 -03:00
waozi 4e6c7a56ff Expose composition events through Ziran host queue 2026-09-23 20:05:40 -03:00
waozi cae798bf55 Render TextArea preedit through checked virtual rows 2026-09-23 19:44:49 -03:00
waozi e7941f3971 Move text composition decisions into checked widgets 2026-09-23 19:25:14 -03:00
waozi a918db3be3 Move text clipboard decisions into checked widgets 2026-09-23 18:50:42 -03:00
waozi cb5c97a9b9 Move TextArea syntax and composition paint into Ziran 2026-09-23 18:33:55 -03:00
waozi 07de9516d8 Add checked Ziran TextArea composition and edit intents 2026-09-23 18:13:34 -03:00
waozi b8404cddc8 Migrate TabBar composition to checked Ziran 2026-09-23 17:51:40 -03:00
waozi 0ecb899acf Add checked Ziran TextField composition and edit intents 2026-09-23 17:28:50 -03:00
waozi e75b3dc4c3 Move text buffer edits into checked Ziran 2026-09-23 17:07:36 -03:00
waozi 6af17256af Compose action dialogs in checked Ziran 2026-09-23 16:53:53 -03:00
waozi 01b66a1cdb Route keyboard input through navigation editor dropdown 2026-09-23 16:34:10 -03:00
waozi ffb5f2d855 Move navigation configuration editor into checked Ziran 2026-09-23 16:18:53 -03:00
waozi f5903ef3d3 Add checked Ziran modal frame composition 2026-09-23 15:57:52 -03:00
waozi eec8bb04f6 Migrate NavigationBar to checked Ziran widget 2026-09-23 15:41:43 -03:00
waozi 705b870ce3 Compose TitleBar from checked Ziran widgets 2026-09-23 15:27:57 -03:00
waozi e6b4a6eed5 Compose Toolbar from checked Ziran widgets 2026-09-23 15:13:39 -03:00
waozi 509b0d8c00 Migrate Dropdown to checked Ziran widget 2026-09-23 14:59:04 -03:00
waozi 4a125f6b97 Move Plot into checked Ziran tree and paint 2026-09-23 14:28:36 -03:00
waozi 872f9b1033 Move transition state and fade into checked Ziran 2026-09-23 14:13:56 -03:00
waozi 72f4f2dc21 Move ColorPicker into checked Ziran composition 2026-09-23 13:58:22 -03:00
waozi 49dd1392f3 Move dismissible overlay capture into checked Ziran 2026-09-23 13:23:04 -03:00
waozi 55933b6e36 Move ListBox single and multi selection into checked Ziran 2026-09-23 13:10:40 -03:00
waozi 8fb41938a1 Move Bullet rendering into checked Ziran widget 2026-09-23 12:41:25 -03:00
waozi 4b93f9e354 Move SegmentedControl into checked Ziran widget library 2026-09-23 12:30:36 -03:00
waozi 22b2648425 Move Collapsible interaction and paint into checked Ziran 2026-09-23 12:06:47 -03:00
waozi af007e1bd6 Move Toast state and rendering into checked Ziran widget 2026-09-23 11:51:13 -03:00
waozi a2509f0ed3 Move swipe gesture state and ownership into Ziran 2026-09-23 11:35:19 -03:00
waozi 8461e27f5c Move PanedView into checked Ziran widget library 2026-09-23 11:19:28 -03:00
waozi 324ba75f54 Complete checked TreeView scrollbar and navigation 2026-09-23 11:05:22 -03:00
waozi a7d027a09f Implement TreeView as checked Ziran widget 2026-09-23 10:53:23 -03:00
waozi 16cd54926d Move device preference policy into checked Ziran 2026-09-23 10:39:08 -03:00
waozi 0f20ae7153 Place checked widget children during tree submission 2026-09-23 10:29:03 -03:00
waozi bf7a1e8934 Port retained layout containers to Ziran 2026-09-23 10:17:03 -03:00
waozi 66095ce54c Port Link and Flow from page host to Ziran 2026-09-23 10:08:40 -03:00
waozi b8b1b3015d Port page heading and paragraph text to checked Ziran 2026-09-23 09:58:35 -03:00
waozi 0a3ae9e277 Port page and section containers to Ziran 2026-09-23 09:45:39 -03:00
waozi 655a9b1ba4 Add portable retained tree parent scopes 2026-09-23 09:32:18 -03:00
waozi 16fa1569b4 Port Router navigation to portable Ziran 2026-09-23 09:24:11 -03:00
waozi 6ab0c2446e Document public Ziran checkout for Kryon builds 2026-09-23 09:08:57 -03:00
waozi 1203beded7 Parse locale catalogs into portable caller owned spans 2026-09-23 08:52:11 -03:00
waozi 478a24e8e9 Move locale selection and lookup to portable Ziran 2026-09-23 08:35:06 -03:00
waozi c2468c81cb Move route list and stack policy to portable slices 2026-09-23 08:28:05 -03:00
waozi b52cadf6d8 Add checked Fieldset widget and retire native duplicate 2026-09-23 08:04:43 -03:00
waozi 4a0cfd75bc Add checked Selectable widget and retire native duplicate 2026-09-23 07:57:48 -03:00
waozi 563fe80eda Add checked Spinbox widget and retire native duplicate 2026-09-23 07:46:31 -03:00
waozi 11d1c9831d Add checked continuous and discrete Slider widgets 2026-09-23 07:31:02 -03:00
waozi 627772de33 Route retained slider drag samples by tree identity 2026-09-23 07:18:43 -03:00
waozi 965ea7fbc1 Add checked Radio widget with retained selection input 2026-09-23 07:11:39 -03:00
waozi 777684bf57 Add checked Toggle widget with portable value API 2026-09-23 07:02:43 -03:00
waozi 08e93cd65b Add checked Checkbox widget and value control routing 2026-09-23 06:53:42 -03:00
waozi 3708b6f869 Support ImageProps content in checked Button widget 2026-09-23 06:42:22 -03:00
waozi f268bb52d7 Add portable retained Button widget in Ziran 2026-09-23 06:34:23 -03:00
waozi e9c17f6491 Move retained pointer routing into checked Ziran 2026-09-23 06:18:05 -03:00
waozi e60424383d Clip checked Text paint to widget bounds 2026-09-23 06:07:35 -03:00
waozi 2ad482770e Move Text widget composition into checked Ziran 2026-09-23 05:58:45 -03:00
waozi 2a0ce3e6af Add headless image canvas host for Ziran bundles 2026-09-23 05:49:35 -03:00
waozi 4ace319d92 Migrate Image composition and raster host to checked Ziran 2026-09-23 05:40:01 -03:00
waozi c208d10820 Queue retained paint as generic checked commands 2026-09-23 05:23:56 -03:00
waozi dc70209da0 Migrate Separator rendering to checked Ziran 2026-09-23 05:13:13 -03:00
waozi 70f24b804e Commit retained Progress paint after portable tree reconciliation 2026-09-23 05:05:09 -03:00
waozi f8a2363c92 Retain portable Progress node identity across frames 2026-09-23 04:56:20 -03:00
waozi 3ea0cdc031 Verify Progress styling across portable frames 2026-09-23 04:45:34 -03:00
waozi 635127eda3 Make Progress use installed Ziran styles 2026-09-23 04:35:35 -03:00
waozi ef46769c1a Parse portable KSS rule tables for widget styles 2026-09-23 04:19:21 -03:00
waozi 44cfb1d89c Resolve Progress styles from portable rule tables 2026-09-23 03:57:37 -03:00
waozi 3a9568c463 Compose Progress with portable font metrics 2026-09-23 03:33:53 -03:00
waozi d0c245d9cb Add portable Progress raster path 2026-09-23 03:22:40 -03:00
waozi c1c1902e47 Move progress draw decisions into Ziran 2026-09-23 03:13:06 -03:00
waozi 4094666d99 Use portable strings in widget text props 2026-09-23 03:08:46 -03:00
waozi f0cf10d1f9 Make image props and draw decisions portable 2026-09-23 03:01:52 -03:00
waozi 358616ac96 Move retained tree commit decision into checked Ziran 2026-09-23 02:55:52 -03:00
waozi fe7cba7043 Make locale fallback labels portable Ziran data 2026-09-23 02:48:14 -03:00
waozi 75f8128f0f Share portable raster line host across widgets 2026-09-23 02:43:48 -03:00
waozi a68ecb2cdd Render bevels through Ziran host records 2026-09-23 02:36:27 -03:00
waozi fea0031aee Move router props to portable Ziran records 2026-09-23 02:21:15 -03:00
waozi e7ff14c4d5 Move reorder policy and input props into checked Ziran library 2026-09-23 02:17:04 -03:00
waozi a151fe9638 Remove retired inspect directives from moved modules 2026-09-23 01:54:07 -03:00
waozi 3c330e71b8 Move shell and capability layout into Ziran library 2026-09-23 01:43:48 -03:00
waozi 3784252182 Bring form row layout into checked Ziran library 2026-09-23 01:37:01 -03:00
waozi d5f4e79bf0 Rebuild Kryon when the Ziran toolchain changes 2026-09-23 01:17:12 -03:00
waozi 0286ea39d8 Port window placement policy to ordinary Ziran modules 2026-09-23 01:10:43 -03:00
waozi 3c5e23765c Bind portable frame pacing through Ziran host API 2026-09-23 01:00:56 -03:00
waozi c5d6818cf9 Link frame pacing host effect through Ziran capability 2026-09-23 00:53:40 -03:00
waozi 063042b262 Move frame pacing decisions into Ziran state 2026-09-23 00:39:00 -03:00
waozi d4e010beb5 Move DPI layout decisions into portable Ziran module 2026-09-23 00:35:14 -03:00
waozi 5abbade406 Build accessibility and accelerator contracts from Ziran imports 2026-09-23 00:22:17 -03:00
waozi 62bbbd5f56 Compile text contracts and paragraph policy as Ziran modules 2026-09-23 00:19:45 -03:00
waozi 20e3f7d9b2 Compile Card and more widget contracts as Ziran modules 2026-09-23 00:14:27 -03:00
waozi e54a2c6024 Express Card properties with Ziran imports 2026-09-23 00:09:22 -03:00
waozi e6cd4956e8 Restore surface policy and compile Button in Ziran 2026-09-23 00:07:59 -03:00
waozi e31ce58f8c Port UI property contracts and text policy into checked library 2026-09-22 23:58:14 -03:00
waozi 895174d3d4 Replace drawing header dependency with Ziran UI value types 2026-09-22 23:53:42 -03:00
waozi 5f8bf4ff2e Build moved UI policy modules with Ziran geometry 2026-09-22 23:37:26 -03:00
waozi 500b9b71b7 Move Kryon UI source into Ziran library layout 2026-09-22 23:34:43 -03:00
waozi 33b5428e14 Port shared style and widget paint policy to Ziran 2026-09-22 23:16:58 -03:00
waozi 935822937d Port Image widget geometry to Ziran 2026-09-22 23:12:50 -03:00
waozi c09615631a Port swipe policy to Ziran library 2026-09-22 23:09:34 -03:00
waozi e60afe1444 Exercise drag module through Ziran library path 2026-09-22 23:06:44 -03:00
waozi 9602e457b3 Port drag policy to Ziran 2026-09-22 22:57:09 -03:00
waozi 02bbb010de Port text row policy to Ziran 2026-09-22 22:53:38 -03:00
waozi 78b2ede4e5 Port numeric input policy to Ziran 2026-09-22 22:45:37 -03:00
waozi d226bc8689 Port transition fade policy to Ziran 2026-09-22 22:30:42 -03:00
waozi ebd1d4bdf8 Port popup ownership policy to Ziran 2026-09-22 22:28:27 -03:00
waozi 0cf58270a8 Port popup lifecycle policy to Ziran 2026-09-22 22:20:41 -03:00
waozi 2c025c57c5 Port theme policy to Ziran 2026-09-22 21:57:18 -03:00
waozi 2e2edde24c Port drag and drop decisions to Ziran 2026-09-22 21:55:10 -03:00
waozi b03216af45 Exercise accessibility modules in portable bundles 2026-09-22 21:52:50 -03:00
waozi a56dd27574 Port accessibility policy to importable Ziran modules 2026-09-22 21:45:58 -03:00
waozi d1fba5b891 Run the full layout test through portable bundles 2026-09-22 21:42:25 -03:00
waozi 56da121ab2 Verify portable layout records in Ziran bundles 2026-09-22 21:32:50 -03:00
waozi 74fb7955d6 Verify Kryon scalar layout functions in portable bundles 2026-09-22 21:15:32 -03:00
waozi aded241780 Port geometry flex and group policy to Kryon Ziran library 2026-09-22 21:01:34 -03:00
waozi e648873b05 Begin Kryon Ziran library with imported layout policy 2026-09-22 20:55:22 -03:00
waozi 4852066609 Resolve extensionless private imports to generated headers 2026-09-22 17:32:29 -03:00
waozi bd6fe901d6 Merge branch 'plan9-fixes' 2026-09-22 17:23:08 -03:00
waozi a8ff0e6cea Use the platform-relative accessibility import in tree frames 2026-09-21 17:29:40 -03:00
waozi f1a05b4f12 Type the remaining inferred bindings in the shell and route layouts 2026-09-21 16:59:12 -03:00
waozi 682e4f38c7 Type the route path binding and stop guessing member selection types 2026-09-21 16:47:58 -03:00
waozi f29734d590 Type the common libc calls in the plan9 auto resolution 2026-09-21 16:31:35 -03:00
waozi 1eb804a22c Provide fmin, fmax, isfinite and strtof in the plan9 math shim 2026-09-21 16:20:46 -03:00
waozi 91bb1a50a1 Resolve auto types through the public prototypes in the plan9 generation 2026-09-21 16:05:06 -03:00
waozi d3fbb12232 Resolve backend internal includes for the plan9 generated ui 2026-09-21 15:59:02 -03:00
waozi ced1280a9d Keep the plan9 array zeroing rewrite off indexed field stores 2026-09-21 15:48:09 -03:00
waozi 8692b822f8 Record the downstream migration landing 2026-09-21 15:47:20 -03:00
waozi a9b9d8ade0 Move ImageProps.texture to the trailing slot
Inserting it second shifted the positional mapping of every positional
Image literal in existing sources (k2go syntax test caught hero.png's
alt text landing in the texture slot). A trailing field preserves the
mapping; runtime-texture callers use named fields.
2026-09-21 15:39:38 -03:00
waozi be8a621f6e Use the plan9 sync stubs and resolve their crypto constants 2026-09-21 15:31:46 -03:00
waozi f180aef670 Map strtok_r onto strtok in the plan9 string shim 2026-09-21 15:26:17 -03:00
waozi 7b7d14de88 Use the vendored sinflate for deflated zip entries on plan9 2026-09-21 15:26:17 -03:00
waozi ba734c5637 Shim the compiler builtins used by vendored single-header libraries 2026-09-21 15:26:17 -03:00
waozi e730bf2752 Use the vendored sinfl and sdefl on plan9 in kry_archive 2026-09-21 15:26:17 -03:00
waozi f8e92726f9 Declare RenderImage in the tracked image surface 2026-09-21 15:17:13 -03:00
waozi 31cbe68149 Avoid short compound literals in the plan9 image caches 2026-09-21 15:15:46 -03:00
waozi 38061d58c3 Archive the generated runtime objects and index them for the plan9 linker 2026-09-21 15:08:53 -03:00
waozi 3a4c938785 Make the kir numeric helpers and monocypher includes 8c-safe 2026-09-21 15:08:20 -03:00
waozi b66ce1610d Provide stdint limit macros and resolve monocypher optional includes for the plan9 build 2026-09-21 15:08:20 -03:00
waozi 7b1662bf64 Resolve runtime includes for plan9 apps and zero-init Vector2 without a short literal 2026-09-21 15:08:20 -03:00
waozi ac81cac750 Drop plan9 mkfile entries for modules migrated to .kry 2026-09-21 15:08:20 -03:00
waozi 5e2072e530 Declare BeginFocusScope and EndFocusScope in the tracked surface 2026-09-21 14:31:25 -03:00
waozi f4d5e9c1d5 Declare RenderActionModal in the tracked modal surface 2026-09-21 14:27:56 -03:00
waozi 5cb940d6b3 Promote the profile image picker modal to the tracked surface 2026-09-21 14:09:41 -03:00
waozi cd5e430e26 Declare DrawFittedTextInRect in the tracked text surface 2026-09-21 13:59:30 -03:00
waozi 58c07cafa4 Drop the deleted ui_icons.h as an icon rule prerequisite in mk/common.mk 2026-09-21 13:46:06 -03:00
waozi 0941e9ae33 Remove an apostrophe from a top-level dpi.kry comment 2026-09-21 12:58:37 -03:00
waozi 0bfa579e55 Add the offscreen frame and runtime-texture image surfaces
Two app-facing gaps found porting krait, both filled in the established
props idiom:

- BeginOffscreenFrame(width, height, forced_scale) + UpdateDPIOffscreen: size
  the layout for an explicit render target with a forced scale (render-to-
  texture previews), without BeginDrawing — the caller is already inside
  BeginTextureMode and pairs it with RestoreFrameState.

- ImageProps.texture: Image(ImageProps) now honors a runtime Texture2D when
  set instead of loading asset_path, keeping Image(ImageProps) the only image
  surface (the names law blocks a separate ImageTexture entry point).

Gates: generated-runtime-parity-test, fast-test, kryon-boundary-check,
public-api-snapshot-check (refreshed), public-api-names-check,
image-policy-test.
2026-09-21 12:52:04 -03:00
waozi 1d1735e5f7 Promote RenderModalFrame and PanelFrame to the tracked props surface
Custom-content modal frames (palette-style overlays with their own content)
had no app-reachable surface: RenderModalFrame lived in ui_internal.h while
apps built against the tracked headers. modal_props now declares PanelFrame as
a one-line #type record and RenderModalFrame as an extern; ui_internal.h drops
its private struct in favor of the tracked declaration. Krait's IDE overlays
are the consumer.

Gates: generated-runtime-parity-test, fast-test, kryon-boundary-check,
modal-policy-test, public-api-snapshot-check (refreshed), all syntax tests,
go-runtime-test.
2026-09-21 12:26:48 -03:00
waozi 8d876ed8a9 Provide the clipboard host callbacks in kryon-preview 2026-09-21 11:17:24 -03:00
waozi 6bd40aff66 Follow the KryonGetFocus rename in kryon-preview 2026-09-21 11:06:24 -03:00
waozi f210544cbf Stub the touch queries in the libdraw X11 input backend
The shared pointer frame references GetTouchPosition/GetTouchPointCount, which
every backend except libdraw provided — so any libdraw link (rill is the live
consumer) failed on the two undefined symbols. libdraw surfaces have no touch
input; satisfy the queries with empty results.

Gates: generated-runtime-parity-test, fast-test, kryon-boundary-check, and a
full KRYON_BACKEND=libdraw libkryon.a build pass.
2026-09-21 10:48:46 -03:00
waozi 17a4030498 Record the StyleTokenColor replacement surface 2026-09-21 10:26:55 -03:00
waozi d40967fc05 Add StyleTokenColor: read registered color tokens at runtime
The missing piece for migrating legacy theme getters: apps register named
color tokens through RegisterStylePackVariant, but nothing could read one back
outside the widget cascade. style_pack_source.kry now retains each pack's
token table (a flat 32x64 global; .kry has no nested fixed arrays) and exposes
StyleTokenColor(name) and StyleTokenColorOr(name, fallback) — declared in
style_pack_props — which read the active pack's table and unpack the u32
in-raylib byte order locally (no GetColor dependency, so the style suites link
without a backend).

Downstream, GetThemeBackground()/GetThemeText() calls become
StyleTokenColor("canvas")/StyleTokenColor("text") against the token names the
app already registers — the mechanical path B-001's deletion needs.

Two debugging notes recorded for the plan: an apostrophe in a top-level .kry
comment silently truncates parsing (the tokenizer swallows the rest of the
file as an unterminated char literal — keep prose out of top-level comments),
and nested fixed arrays are a hard parse error.

Gates: generated-runtime-parity-test, fast-test, style-pack-source/registry/
picker/release-startup suites, kss-host-ledger-check, kryon-boundary-check,
refreshed snapshots, plus a functional register/activate/read/fallback test.
2026-09-21 10:24:39 -03:00
waozi 3c36284591 Record the native-window removal and the program's end state 2026-09-21 10:04:12 -03:00
waozi 85d0cc1875 Declare the native-window host in its props header
include/ui_window.h is deleted. runtime/window_props.kry declares NativeWindow
as a one-line opaque "#type" (struct NativeWindow NativeWindow;) — an opaque
forward declaration is just C text, no emitter feature needed — and the eleven
window lifecycle/input calls as "#extern #export" declarations. The window
host, policy host, kryon.h, and the window test include the props header
directly.

Gates: generated-runtime-parity-test, fast-test, k2c/k2cpp/k2go-syntax-test,
go-runtime-test, examples-syntax-test, kryon-boundary-check, the ui_window_test
binary, and the refreshed public-API snapshot pass.
2026-09-21 10:01:15 -03:00
3778 changed files with 255988 additions and 389718 deletions

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
name: Compile cache
description: >-
Reuses C objects through ccache and Emscripten's generated system libraries
between runs. Run it after the setup action, which installs ccache.
inputs:
key:
description: Separates the jobs' caches, since each compiles different programs.
required: true
runs:
using: composite
steps:
- name: Name today's compiler cache
id: day
shell: bash
run: echo "day=$(date -u +%F)" >> "$GITHUB_OUTPUT"
# One entry a day per job keeps the repository's 10 GB cache allowance safe.
- name: Restore C objects
uses: actions/cache@v6
with:
path: ~/.ccache
key: ccache-${{ runner.os }}-${{ inputs.key }}-${{ steps.day.outputs.day }}
restore-keys: ccache-${{ runner.os }}-${{ inputs.key }}-
- name: Restore Emscripten system libraries
uses: actions/cache@v6
with:
path: |
kryon/build/emscripten-cache
kryon/build/ziran/emscripten-cache
key: emscripten-cache-${{ inputs.key }}-6.0.6
- name: Compile through the cache
shell: bash
run: |
echo /usr/lib/ccache >> "$GITHUB_PATH"
{
echo "CCACHE_DIR=$HOME/.ccache"
echo "CCACHE_MAXSIZE=150M"
echo "CCACHE_BASEDIR=$GITHUB_WORKSPACE"
echo "CCACHE_NOHASHDIR=true"
} >> "$GITHUB_ENV"
+30
View File
@@ -0,0 +1,30 @@
name: Google-free Android editions
description: >-
Fails when a normal or F-Droid APK, or a Gradle file their builds read,
holds a Google library; only the -gplay edition may (scripts/check-google-free.py).
inputs:
packages:
description: APKs (or globs) of the normal and -fdroid editions to search.
default: ''
source:
description: Folder whose Gradle files are checked as F-Droid scans them; empty skips it.
default: '.'
expect-google:
description: "'true' when the packages are -gplay: fail unless Play Billing is found, proving the search works."
default: 'false'
runs:
using: composite
steps:
- shell: bash
env:
PACKAGES: ${{ inputs.packages }}
SOURCE: ${{ inputs.source }}
EXPECT_GOOGLE: ${{ inputs.expect-google }}
run: |
set -euo pipefail
arguments=()
if [ -n "$SOURCE" ]; then arguments+=(--source "$SOURCE"); fi
if [ "$EXPECT_GOOGLE" = true ]; then arguments+=(--expect-google); fi
# Globs in PACKAGES expand here; a glob matching nothing stays as
# written and fails as a missing file.
python3 "$GITHUB_ACTION_PATH/../../../scripts/check-google-free.py" "${arguments[@]}" $PACKAGES
-77
View File
@@ -1,77 +0,0 @@
name: Automatic Release Version
on:
schedule:
# Batched patch release: at most one per day, and only when maintainers
# have written user-facing notes under "## Unreleased".
- cron: '0 6 * * *'
workflow_dispatch:
permissions:
contents: write
actions: write
concurrency:
group: kryon-auto-release
cancel-in-progress: false
jobs:
bump-and-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Skip an already released commit
id: guard
run: |
if git tag --points-at HEAD --list 'v*' | grep -q .; then
echo 'release=false' >> "$GITHUB_OUTPUT"
else
echo 'release=true' >> "$GITHUB_OUTPUT"
fi
- name: Require curated release notes
if: steps.guard.outputs.release == 'true'
id: notes
run: |
if scripts/release-notes.sh --check CHANGELOG.md; then
echo 'release=true' >> "$GITHUB_OUTPUT"
else
echo 'release=false' >> "$GITHUB_OUTPUT"
echo 'Skipping: no curated notes under "## Unreleased".' \
| tee -a "$GITHUB_STEP_SUMMARY"
fi
- name: Resolve next version
if: steps.guard.outputs.release == 'true' && steps.notes.outputs.release == 'true'
id: version
run: |
current=$(make -s version)
if git rev-parse -q --verify "refs/tags/$current" >/dev/null; then
version=$(scripts/bump-version.sh patch)
else
version=$current
fi
echo "tag=$version" >> "$GITHUB_OUTPUT"
- name: Commit version
if: steps.guard.outputs.release == 'true' && steps.notes.outputs.release == 'true'
run: |
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add include/kryon_version.h
if ! git diff --cached --quiet; then
git commit -m "release: bump version to ${{ steps.version.outputs.tag }}"
git push origin HEAD:master
fi
- name: Start release workflow
if: steps.guard.outputs.release == 'true' && steps.notes.outputs.release == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: >-
gh workflow run release.yml --ref master
-f version=${{ steps.version.outputs.tag }}
-f prerelease=false
+340 -173
View File
@@ -2,196 +2,363 @@ name: CI
on:
push:
branches:
- master
branches: [master]
pull_request:
workflow_dispatch:
# Cancel a superseded run on the same ref.
# Several sessions push master many times an hour, longer apart than a run
# takes; cancelling on master left no finished run. Only pull requests
# replace their older runs.
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
group: ci-${{ github.ref }}-${{ github.event_name == 'pull_request' && 'pr' || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
ZIRAN_ROOT: ${{ github.workspace }}/ziran
jobs:
guard-submodule-urls:
name: Submodule URLs are public HTTPS
# A broken host link fails here in minutes, before the long jobs start.
push-check:
name: Source rules and host links
runs-on: ubuntu-latest
outputs:
code: ${{ steps.changes.outputs.code }}
defaults:
run:
working-directory: kryon
steps:
# Plain checkout on purpose: the guard must not depend on fetching
# the submodules it validates (an SSH URL would break that fetch).
- name: Checkout Repository
uses: actions/checkout@v7
- name: Reject non-HTTPS submodule URLs
run: sh scripts/check-submodule-urls.sh
test-linux:
name: Build and test (Linux)
needs: guard-submodule-urls
runs-on: ubuntu-latest
env:
CC: ccache cc
CXX: ccache c++
CCACHE_COMPILERCHECK: content
CCACHE_MAXSIZE: 2G
steps:
- name: Checkout Repository
- name: Checkout Kryon
uses: actions/checkout@v7
with:
submodules: recursive
path: kryon
- name: Restore build cache
uses: actions/cache@v4
- name: Name the checked-out Kryon commit master
run: git checkout -B master
# Every job that builds the AVIF decoder needs Meson and Ninja for dav1d,
# and on x86-64 nasm for dav1d's and libaom's SIMD; arm64 builds assemble
# with the C compiler.
- name: Set up the locked Ziran, its packages and the build tools
uses: ziranlang/ziran/.github/actions/setup@4135e07fae33bcd0c00dd66b5716fdfe19c1fca5
with:
path: ~/.cache/ccache
key: ccache-linux-${{ runner.os }}-${{ github.ref }}
restore-keys: |
ccache-linux-${{ runner.os }}-master
ccache-linux-${{ runner.os }}-
project: kryon
path: ziran
fetch: true
recommends: true
packages: >-
build-essential python3 ripgrep pkg-config libsdl2-dev libcairo2-dev libglib2.0-dev
libpango1.0-dev libdrm-dev libgbm-dev libegl-dev libgles-dev libegl-mesa0
libgl1-mesa-dri libx11-dev libxt-dev libxext-dev libfontconfig1-dev libfreetype-dev
libxkbcommon-x11-0
libcurl4-openssl-dev fonts-dejavu-core fonts-wqy-zenhei xvfb xdotool x11-apps x11-utils
imagemagick xfwm4 dbus-x11 cmake nasm meson ninja-build libwebpdemux2
- name: Install Packages
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y build-essential cmake libssl-dev pkg-config \
zlib1g-dev libzstd-dev libbrotli-dev \
libglib2.0-dev libgtk-3-dev \
libsdl2-dev libdrm-dev libgbm-dev libegl1-mesa-dev libgles2-mesa-dev \
ripgrep python3 xvfb xauth xdotool imagemagick libgl1-mesa-dev libx11-dev \
ccache
- name: Set up Node.js for Bend proofs
uses: actions/setup-node@v4
with:
node-version: 22
- name: Build
run: |
set -euo pipefail
make clean CMAKE=/usr/bin/cmake
make all CMAKE=/usr/bin/cmake
- name: Laws
run: make laws-test CMAKE=/usr/bin/cmake
- name: Test
run: make test CMAKE=/usr/bin/cmake
- name: Native rendering and widget catalog audit
run: |
set -euo pipefail
make overlay-paint-test CMAKE=/usr/bin/cmake
xvfb-run -a make texture-scope-test CMAKE=/usr/bin/cmake
xvfb-run -a -s '-screen 0 1920x1080x24' python3 tests/widget_catalog_audit.py
- name: Upload native widget audit
if: always()
uses: actions/upload-artifact@v7
with:
name: widget-catalog-audit-linux
path: |
build/widget-catalog-audit/*.json
build/widget-catalog-audit/*.png
build/widget-catalog-audit/*.log
if-no-files-found: ignore
- name: Text input latency gate
run: |
set -euo pipefail
make perf-text-input CMAKE=/usr/bin/cmake | grep '^{' | tee text-input-perf.jsonl
cat text-input-perf.jsonl >> "$GITHUB_STEP_SUMMARY"
- name: Upload text input measurements
uses: actions/upload-artifact@v7
with:
name: text-input-perf-linux
path: text-input-perf.jsonl
if-no-files-found: error
test-freebsd:
name: Build and test (FreeBSD)
needs: guard-submodule-urls
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v7
with:
submodules: recursive
- name: Build and test on FreeBSD VM
uses: vmactions/freebsd-vm@v1
with:
usesh: true
mem: 4096
prepare: |
set -eu
pkg install -y gmake cmake pkgconf \
sdl2 libdrm mesa-libs gtk3 \
curl openssl zstd brotli \
git go python3 ripgrep node22
run: |
set -eu
gmake clean
gmake all
gmake test
if ! gmake perf-text-input; then
echo "FreeBSD text-input measurements are non-gating during calibration" >&2
fi
sanitizers:
name: Memory safety (${{ matrix.sanitizer }})
needs: guard-submodule-urls
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sanitizer: [asan, ubsan]
steps:
- name: Checkout Repository
uses: actions/checkout@v7
with:
submodules: recursive
- name: Install Packages
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y build-essential cmake libssl-dev pkg-config \
zlib1g-dev libzstd-dev libbrotli-dev libglib2.0-dev libgtk-3-dev \
libsdl2-dev libdrm-dev libgbm-dev libegl1-mesa-dev libgles2-mesa-dev
- name: Run sanitizer suite
run: make test-${{ matrix.sanitizer }} CMAKE=/usr/bin/cmake
portable-go:
name: Pure Go runtime (${{ matrix.goos }})
needs: guard-submodule-urls
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
goos: [linux, windows, darwin]
steps:
- name: Checkout Repository
uses: actions/checkout@v7
- name: Prepare locked toolchain ref
run: git -C "$ZIRAN_ROOT" checkout -B master
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go/kryon/go.mod
go-version: '1.25.x'
- name: Compile tests
working-directory: go/kryon
env:
GOOS: ${{ matrix.goos }}
CGO_ENABLED: 0
run: go test -c -o "kryon.test.${GOOS}" .
- name: Source rules and host links
run: make push-check
- name: Run native Go tests
if: matrix.goos == 'linux'
working-directory: go/kryon
# A push touching only prose or the site skips the long jobs: this job
# still checks the docs, and the Pages workflow tests the site. Anything
# unknown runs everything.
- name: Decide whether the long jobs apply
id: changes
env:
CGO_ENABLED: 0
run: go test ./...
GH_TOKEN: ${{ github.token }}
BEFORE: ${{ github.event.before }}
run: |
code=true
if [ "$GITHUB_EVENT_NAME" = push ] && files=$(gh api "repos/$GITHUB_REPOSITORY/compare/$BEFORE...$GITHUB_SHA" --jq '.files[].filename'); then
count=$(printf '%s\n' "$files" | grep -c . || true)
other=$(printf '%s\n' "$files" | grep -vE '^docs/|\.md$' || true)
if [ "$count" -gt 0 ] && [ "$count" -lt 300 ] && [ -z "$other" ]; then code=false; fi
fi
echo "code=$code" >> "$GITHUB_OUTPUT"
test-macos-zx:
name: macOS native ZX build and display-free execution
needs: push-check
if: needs.push-check.outputs.code == 'true'
runs-on: macos-latest
defaults:
run:
working-directory: kryon
steps:
- name: Checkout Kryon
uses: actions/checkout@v7
with:
path: kryon
# The locked compiler comes prebuilt, and the package checkouts cached.
- name: Set up the locked Ziran and fetch packages
uses: ziranlang/ziran/.github/actions/setup@4135e07fae33bcd0c00dd66b5716fdfe19c1fca5
with:
project: kryon
path: ziran
fetch: true
- name: Install the AVIF decoder's dav1d build tools
run: brew install meson ninja pkgconf sdl2 cairo pango fontconfig freetype gdk-pixbuf webp $([ "$RUNNER_ARCH" = X64 ] && echo nasm)
# No GUI launch or screenshot can reach a runner's inherited display.
- name: Build native player and execute the portable VM with CPU pixels
run: |
export PATH="$ZIRAN_ROOT/build/bin:$PATH"
env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u DBUS_SESSION_BUS_ADDRESS \
make zx-headless-test zx-player
build/bin/zx --check build/scratch/zx-headless/app.zx
test-linux:
name: Ziran library and host tests (${{ matrix.shard }})
needs: push-check
if: needs.push-check.outputs.code == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shard: [zx, check, web, site, hosts]
defaults:
run:
working-directory: kryon
steps:
- name: Checkout Kryon
uses: actions/checkout@v7
with:
path: kryon
# Template tests serve the checkouts through local Git URLs and use
# their master refs.
- name: Name the checked-out Kryon commit master
run: git checkout -B master
# The locked compiler comes prebuilt, the package checkouts cached, and
# Ubuntu packages from the canonical archive.
- name: Set up the locked Ziran, its packages and the build tools
uses: ziranlang/ziran/.github/actions/setup@4135e07fae33bcd0c00dd66b5716fdfe19c1fca5
with:
project: kryon
path: ziran
fetch: true
recommends: true
packages: >-
build-essential ccache python3 ripgrep xvfb pkg-config libsdl2-dev libcairo2-dev
libfreetype-dev libfontconfig1-dev libcurl4-openssl-dev libdrm-dev libgbm-dev
libegl-dev libgles-dev libegl-mesa0 libgl1-mesa-dri imagemagick xclip xdotool
libxkbcommon-x11-0
x11-xserver-utils python3-gi python3-gi-cairo python3-cairo python3-pil python3-xlib ffmpeg gir1.2-gtk-3.0 gir1.2-atspi-2.0
libglib2.0-dev libpango1.0-dev at-spi2-core dbus-x11 gstreamer1.0-plugins-base
gstreamer1.0-plugins-good gstreamer1.0-libav cmake nasm meson ninja-build libwebpdemux2 libopus-dev
# SDL3's GPU renderer needs Vulkan even on a software-only runner.
- name: Install native host test tools
if: matrix.shard == 'hosts'
run: sudo apt-get install -y libvulkan-dev mesa-vulkan-drivers libx11-dev libxext-dev libxtst-dev xauth libgtk-3-dev
# Template tests serve this checkout through local Git URLs and use
# the manifest's master ref. Keep that ref at the locked commit.
- name: Prepare locked toolchain ref
run: git -C "$ZIRAN_ROOT" checkout -B master
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.25.x'
- name: Set up Node
uses: actions/setup-node@v6
with:
node-version: '22'
# The pay-per-import test and the gallery build these examples as
# applications of this checkout, as ziran.local.toml does locally.
- name: Build the in-tree examples from this checkout
if: matrix.shard == 'hosts' || matrix.shard == 'site'
run: |
python3 - <<'PY'
import os, subprocess
from pathlib import Path
ziran = Path(os.environ['ZIRAN_ROOT'])
settings = f'[overrides]\nkryon = "{Path.cwd()}"\nziran = "{ziran}"\n'
for project in ('examples/box', 'examples/button', 'examples/image', 'examples/textfield', 'examples/gallery'):
(Path(project) / 'ziran.local.toml').write_text(settings)
subprocess.run([str(ziran / 'build/bin/ziran'), 'lock'], cwd=project, check=True)
PY
- name: Keep Google libraries in the gplay edition
run: python3 scripts/check-google-free.py --source .
- name: Check submodule URLs
run: sh scripts/check-submodule-urls.sh
# The Canvas2D and DOM tests compile to Wasm with emscripten and run
# in private headless Chrome; the tests look for ~/emsdk.
- name: Restore emsdk
id: emsdk
uses: actions/cache@v6
with:
path: ~/emsdk
key: emsdk-${{ runner.os }}-6.0.6
- name: Install emsdk
if: steps.emsdk.outputs.cache-hit != 'true'
working-directory: .
run: |
git clone https://github.com/emscripten-core/emsdk.git ~/emsdk
~/emsdk/emsdk install 6.0.6
~/emsdk/emsdk activate 6.0.6
- name: Keep compile results between runs
uses: ./kryon/.github/actions/compile-cache
with:
key: ${{ matrix.shard }}
# The behavior suite executes the Windows storage regression under Wine.
- name: Install Windows storage test tools
if: matrix.shard == 'check'
run: sudo apt-get install -y gcc-mingw-w64-x86-64 wine wine64
- name: Test opt-in SDL3 GPU renderer on a private display
if: matrix.shard == 'hosts'
env:
LIBGL_ALWAYS_SOFTWARE: '1'
run: |
set -- /usr/share/vulkan/icd.d/lvp_icd*.json
test -f "$1"
export VK_DRIVER_FILES="$1"
env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u DBUS_SESSION_BUS_ADDRESS YUE_DESKTOP_RECOVERY=0 make sdl3-test
- name: Build and test
if: matrix.shard != 'site'
env:
CHROMIUM: google-chrome
run: env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u DBUS_SESSION_BUS_ADDRESS YUE_DESKTOP_RECOVERY=0 make test-shard-${{ matrix.shard }}
- name: Check repeatable frame workloads
if: matrix.shard == 'hosts'
run: python3 tools/performance.py --budget-ms 64
- name: Test SVG example
if: matrix.shard == 'hosts'
run: env -u DISPLAY -u WAYLAND_DISPLAY make -C examples test
# The whole site is rebuilt from this checkout, so the live editor's
# embedded examples match the gallery under test. Nothing is deployed.
- name: Build and test the widget gallery
if: matrix.shard == 'site'
env:
CHROMIUM: google-chrome
run: |
export PATH="$ZIRAN_ROOT/build/bin:$PATH"
make site
python3 tests/gallery_modules_test.py
make site-browser-test
- name: Show how much the compile cache saved
if: always()
run: ccache --show-stats || true
test-sanitizers:
name: Behavior tests under AddressSanitizer and UndefinedBehaviorSanitizer
needs: push-check
if: needs.push-check.outputs.code == 'true'
runs-on: ubuntu-latest
defaults:
run:
working-directory: kryon
steps:
- name: Checkout Kryon
uses: actions/checkout@v7
with:
path: kryon
# Template tests serve the checkouts through local Git URLs and use
# their master refs.
- name: Name the checked-out Kryon commit master
run: git checkout -B master
# The locked compiler comes prebuilt, the package checkouts cached, and
# Ubuntu packages from the canonical archive.
- name: Set up the locked Ziran, its packages and the build tools
uses: ziranlang/ziran/.github/actions/setup@4135e07fae33bcd0c00dd66b5716fdfe19c1fca5
with:
project: kryon
path: ziran
fetch: true
recommends: true
packages: >-
build-essential python3 python3-pil ripgrep ffmpeg pkg-config libsdl2-dev
libcairo2-dev libglib2.0-dev libpango1.0-dev libfreetype-dev libfontconfig1-dev
gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-libav cmake
nasm meson ninja-build libwebpdemux2
- name: Prepare locked toolchain ref
run: git -C "$ZIRAN_ROOT" checkout -B master
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.25.x'
- name: Install Windows storage test tools
run: sudo apt-get install -y gcc-mingw-w64-x86-64 wine wine64 xvfb xauth
- name: Run the behavior tests with sanitized C
run: env -u DISPLAY -u WAYLAND_DISPLAY make sanitize-test TEST_JOBS=4
test-desktop-hosts:
name: Desktop hosts on private Xvfb
needs: push-check
if: needs.push-check.outputs.code == 'true'
runs-on: ubuntu-latest
defaults:
run:
working-directory: kryon
steps:
- name: Checkout Kryon
uses: actions/checkout@v7
with:
path: kryon
# Template tests serve the checkouts through local Git URLs and use
# their master refs.
- name: Name the checked-out Kryon commit master
run: git checkout -B master
# The locked compiler comes prebuilt, the package checkouts cached, and
# Ubuntu packages from the canonical archive.
- name: Set up the locked Ziran, its packages and the build tools
uses: ziranlang/ziran/.github/actions/setup@4135e07fae33bcd0c00dd66b5716fdfe19c1fca5
with:
project: kryon
path: ziran
fetch: true
recommends: true
packages: >-
build-essential python3 pkg-config libsdl2-dev libcairo2-dev libglib2.0-dev
libpango1.0-dev libdrm-dev libgbm-dev libegl-dev libgles-dev libegl-mesa0
libgl1-mesa-dri libx11-dev libxt-dev libxext-dev libxtst-dev libfontconfig1-dev libfreetype-dev
libxkbcommon-x11-0
fonts-dejavu-core fonts-wqy-zenhei xvfb xdotool x11-apps x11-utils imagemagick xfwm4
dbus-x11 cmake nasm meson ninja-build libwebpdemux2 libopus-dev
- name: Prepare locked toolchain ref
run: git -C "$ZIRAN_ROOT" checkout -B master
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.25.x'
# Each test starts its own display with xvfb-run -a; none may reach a
# real one.
- name: Desktop host
run: env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY make desktop-project-test
- name: Desktop frame input snapshots
run: make desktop-frame-input-test
+164 -81
View File
@@ -2,9 +2,21 @@ name: Cloudflare Pages
on:
push:
branches:
- master
pull_request:
branches: [master]
paths:
- docs/site/**
- examples/gallery/**
- src/**
- mk/**
- ziran.toml
- scripts/gallery.py
- scripts/build-gallery.py
- scripts/build-site.py
- scripts/site-metadata.py
- tests/site_browser_test.py
- ziran.lock
- tests/portable_format_runtime.cjs
- .github/workflows/pages.yml
workflow_dispatch:
permissions:
@@ -15,102 +27,173 @@ concurrency:
cancel-in-progress: true
jobs:
build:
name: Build Site
browser-runtime:
name: Build ZX website
runs-on: ubuntu-latest
env:
MAKEFLAGS: -j2
defaults:
run:
working-directory: kryonlabs/kryon
steps:
- name: Checkout Repository
uses: actions/checkout@v7
- uses: actions/checkout@v7
with:
submodules: recursive
- name: Install Packages
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y build-essential cmake cmark zlib1g-dev zip
- name: Set Up Emscripten
run: |
set -euo pipefail
git clone --depth 1 https://github.com/emscripten-core/emsdk.git "$HOME/emsdk"
"$HOME/emsdk/emsdk" install latest
"$HOME/emsdk/emsdk" activate latest
echo "EMSDK=$HOME/emsdk" >> "$GITHUB_ENV"
echo "EM_CONFIG=$HOME/emsdk/.emscripten" >> "$GITHUB_ENV"
echo "$HOME/emsdk" >> "$GITHUB_PATH"
echo "$HOME/emsdk/upstream/emscripten" >> "$GITHUB_PATH"
- name: Build Site
run: |
set -euo pipefail
make docs-site CMAKE=/usr/bin/cmake SITE_BUILD_DIR=build/site
test -f build/site/index.html
test -f build/site/api.html
test -f build/site/ide.html
test -f build/site/ide.js
test -f build/site/ide-tools/k2kir.js
test -f build/site/ide-tools/k2kir.wasm
test -f build/site/ide-tools/k2b.js
test -f build/site/ide-tools/k2b.wasm
test -f build/site/ide-tools/k2c.js
test -f build/site/ide-tools/k2c.wasm
test -f build/site/ide-tools/k2go.js
test -f build/site/ide-tools/k2go.wasm
test -f build/site/ide-tools/krb-web.js
test -f build/site/ide-tools/krb-web.wasm
test ! -f build/site/ide-tools/unavailable.json
test -f build/site/getting-started.html
test -f build/site/hello.kry
test -f build/site/og.png
test -f build/site/assets/editorial/workshop.webp
test -f build/site/icons/proj/kryon.png
test ! -f build/site/API.md
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Upload Site Artifact
uses: actions/upload-artifact@v7
path: kryonlabs/kryon
# The locked compiler comes prebuilt.
- name: Set up the locked Ziran
uses: ziranlang/ziran/.github/actions/setup@4135e07fae33bcd0c00dd66b5716fdfe19c1fca5
with:
name: kryon-site
path: build/site
project: kryonlabs/kryon
path: ziranlang/ziran
packages: python3-pil
- uses: actions/setup-node@v6
with:
node-version: '22'
- uses: emscripten-core/setup-emsdk@v15
with:
version: '6.0.6'
- name: Select these source revisions
run: |
python3 - <<'PY'
from pathlib import Path
import os
import subprocess
root = Path(os.environ['GITHUB_WORKSPACE'])
settings = '[overrides]\nkryon = "' + str(root / 'kryonlabs/kryon') + '"\nziran = "' + str(root / 'ziranlang/ziran') + '"\n'
for project in ('.', 'docs/site/demo', 'examples/gallery'):
(Path(project) / 'ziran.local.toml').write_text(settings)
# An override can add dependency edges absent from the saved
# consumer lock. Resolve the selected checkout before building.
subprocess.run([str(root / 'ziranlang/ziran/build/bin/ziran'), 'lock'],
cwd=project, check=True)
PY
- name: Build and verify portable browser assets
run: |
export PATH="$GITHUB_WORKSPACE/ziranlang/ziran/build/bin:$PATH"
export ZIRAN_ROOT="$GITHUB_WORKSPACE/ziranlang/ziran"
python3 scripts/build-site.py
node tests/portable_format_runtime.cjs
ZIRAN_PLAYGROUND_RUNTIME="$PWD/docs/site/runtime/playground-runtime.js" node "$GITHUB_WORKSPACE/ziranlang/ziran/tests/web_bundle_runtime.cjs"
- name: Stage public website files
run: |
python3 - <<'PY'
from pathlib import Path
import json, shutil, subprocess
site = Path('docs/site')
output = Path('build/scratch/website-deploy')
paths = {Path(p) for p in subprocess.check_output(['git', 'ls-files', '-z', '--', str(site)]).decode().split('\0') if p}
paths.add(site / 'gallery-data.js')
paths.update((site / 'gallery-sources').rglob('*.zi'))
# The build numbers runtime assets; stage every one it lists, since
# a newly bundled asset is not tracked yet.
paths.update(site / name for _, name in json.loads((site / 'runtime/assets.json').read_text()))
for source in paths:
destination = output / source.relative_to(site)
destination.parent.mkdir(parents=True, exist_ok=True)
shutil.copyfile(source, destination)
PY
- uses: actions/upload-artifact@v6
with:
name: kryon-website
path: kryonlabs/kryon/build/scratch/website-deploy/
if-no-files-found: error
deploy-preview:
name: Deploy Preview
verify:
name: Website
needs: browser-runtime
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'pull_request'
defaults:
run:
working-directory: kryonlabs/kryon
steps:
- name: Download Site Artifact
uses: actions/download-artifact@v4
- name: Checkout repository
uses: actions/checkout@v7
with:
name: kryon-site
path: build/site
path: kryonlabs/kryon
- name: Deploy Preview To Cloudflare Pages
uses: cloudflare/wrangler-action@v3
- uses: actions/download-artifact@v6
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy build/site --project-name=kryon --branch=${{ github.head_ref || github.ref_name }}
name: kryon-website
path: kryonlabs/kryon/docs/site
# The portable source test invokes the locked compiler directly.
- name: Set up the locked Ziran
uses: ziranlang/ziran/.github/actions/setup@4135e07fae33bcd0c00dd66b5716fdfe19c1fca5
with:
project: kryonlabs/kryon
path: ziranlang/ziran
- name: Set up Node
uses: actions/setup-node@v6
with:
node-version: '22'
- name: Install private display tools
timeout-minutes: 10
run: |
sudo apt-get update
sudo apt-get install -y build-essential python3 python3-pil
# Test and deploy the same runtime built from the locked compiler.
- name: Check static site assets
run: |
test -f docs/site/index.html
test -f docs/site/runtime/playground-runtime.js
test -f docs/site/runtime/playground-runtime.wasm
test -f docs/site/demo-theme.js
test -f docs/site/current.css
test -f docs/site/favicon.svg
test -f docs/site/favicon-32.png
test -f docs/site/og.png
test -f docs/site/assets/brand/mark.svg
test -f docs/site/widgets.html
test -f docs/site/gallery-data.js
test -f docs/site/gallery-sources/kryon/0.zi
- name: Test the Canvas website
timeout-minutes: 45
env:
CHROMIUM: google-chrome
# Chrome creates Unix sockets below TMPDIR; keep them clear of the
# runner's deeply nested checkout path.
KRYON_TEST_RUNTIME: ${{ runner.temp }}
run: |
export PATH="$GITHUB_WORKSPACE/ziranlang/ziran/build/bin:$PATH"
export ZIRAN_ROOT="$GITHUB_WORKSPACE/ziranlang/ziran"
env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u DBUS_SESSION_BUS_ADDRESS \
YUE_DESKTOP_RECOVERY=0 python3 -u tests/site_browser_test.py
- name: Save browser startup diagnostics
if: failure()
uses: actions/upload-artifact@v6
with:
name: website-browser-log
path: kryonlabs/kryon/build/scratch/site-browser/profile/chromium.log
if-no-files-found: ignore
deploy-production:
name: Deploy Production
name: Deploy Kryon Labs
needs: verify
runs-on: ubuntu-latest
needs: build
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master'
steps:
- name: Download Site Artifact
uses: actions/download-artifact@v4
- name: Checkout repository
uses: actions/checkout@v7
with:
name: kryon-site
path: build/site
path: kryonlabs/kryon
- name: Deploy Production To Cloudflare Pages
- uses: actions/download-artifact@v6
with:
name: kryon-website
path: kryonlabs/kryon/docs/site
- name: Set up Node
uses: actions/setup-node@v6
with:
node-version: '22'
- name: Publish to Cloudflare Pages
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy build/site --project-name=kryon --branch=master
command: pages deploy kryonlabs/kryon/docs/site --project-name=kryon --branch=master
+21 -178
View File
@@ -1,197 +1,40 @@
name: Release
on:
push:
branches:
- master
tags:
- "v*"
paths:
- "include/kryon_version.h"
workflow_dispatch:
inputs:
version:
description: "Release version, for example v0.1.0"
required: true
type: string
prerelease:
description: "Mark the GitHub release as a prerelease"
required: false
default: false
type: boolean
permissions:
contents: write
jobs:
create-tag:
name: Create Release Tag
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/heads/')
outputs:
tag: ${{ steps.version.outputs.tag }}
concurrency:
group: kryon-release
cancel-in-progress: false
jobs:
tag:
name: Tag new version
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v7
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Resolve Version
id: version
- name: Create the release for a new VERSION
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
tag="${{ inputs.version }}"
else
tag="$(sed -n 's/^#define KRYON_VERSION_STRING "\([^"]*\)".*/\1/p' include/kryon_version.h)"
fi
case "$tag" in
v[0-9]*.[0-9]*.[0-9]*) ;;
*) echo "Version must look like v0.1.0" >&2; exit 1 ;;
esac
header_tag="$(sed -n 's/^#define KRYON_VERSION_STRING "\([^"]*\)".*/\1/p' include/kryon_version.h)"
if [ "$tag" != "$header_tag" ]; then
echo "Requested $tag but include/kryon_version.h contains $header_tag" >&2
exit 1
fi
if git rev-parse -q --verify "refs/tags/$tag" >/dev/null; then
echo "Tag $tag already exists; nothing to release."
echo "tag=" >> "$GITHUB_OUTPUT"
set -eu
VERSION=$(cat VERSION)
TAG="v$VERSION"
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "$TAG already exists, nothing to release"
exit 0
fi
echo "tag=$tag" >> "$GITHUB_OUTPUT"
- name: Promote Curated Release Notes
if: steps.version.outputs.tag != ''
run: |
set -euo pipefail
tag="${{ steps.version.outputs.tag }}"
NOTES=$(awk -v v="$VERSION" '$0 ~ "^## \\[" v "\\]" {found=1; next} found && /^## / {exit} found' CHANGELOG.md)
test -n "$NOTES"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# A hand-written dated entry wins; otherwise promote the curated
# "## Unreleased" notes. Release notes are user-facing and are never
# synthesized from commit subjects.
if grep -q "^## $tag " CHANGELOG.md; then
echo "CHANGELOG entry for $tag already present."
else
scripts/release-notes.sh "$tag"
fi
git add CHANGELOG.md
if ! git diff --cached --quiet; then
git commit -m "Update CHANGELOG for $tag"
git push origin "HEAD:${GITHUB_REF_NAME}"
else
echo "No CHANGELOG changes to commit."
fi
- name: Create And Push Tag
if: steps.version.outputs.tag != ''
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -a "${{ steps.version.outputs.tag }}" -m "Release ${{ steps.version.outputs.tag }}"
git push origin "${{ steps.version.outputs.tag }}"
build-release:
name: Build Release Artifacts
runs-on: ubuntu-latest
needs: create-tag
if: always() && (startsWith(github.ref, 'refs/tags/') || needs.create-tag.outputs.tag != '')
env:
CC: ccache cc
CXX: ccache c++
CCACHE_COMPILERCHECK: content
CCACHE_MAXSIZE: 2G
steps:
- name: Resolve Tag
id: ref
run: |
set -euo pipefail
if [ -n "${{ needs.create-tag.outputs.tag }}" ]; then
tag="${{ needs.create-tag.outputs.tag }}"
else
tag="${GITHUB_REF_NAME}"
fi
echo "tag=$tag" >> "$GITHUB_OUTPUT"
- name: Checkout Repository
uses: actions/checkout@v7
with:
ref: ${{ steps.ref.outputs.tag }}
submodules: recursive
fetch-depth: 0
- name: Restore build cache
uses: actions/cache@v4
with:
path: ~/.cache/ccache
key: ccache-linux-${{ runner.os }}-${{ github.ref }}
restore-keys: |
ccache-linux-${{ runner.os }}-master
ccache-linux-${{ runner.os }}-
- name: Install Packages
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y build-essential cmake libssl-dev pkg-config zlib1g-dev libzstd-dev libbrotli-dev libglib2.0-dev libgtk-3-dev libsdl2-dev libdrm-dev libgbm-dev libegl1-mesa-dev libgles2-mesa-dev ripgrep ccache
- name: Build And Test
run: |
set -euo pipefail
make clean CMAKE=/usr/bin/cmake
make all CMAKE=/usr/bin/cmake
make test CMAKE=/usr/bin/cmake
- name: Package Static Library
run: |
set -euo pipefail
make dist-static CMAKE=/usr/bin/cmake VERSION="${{ steps.ref.outputs.tag }}"
make check-static-package CMAKE=/usr/bin/cmake VERSION="${{ steps.ref.outputs.tag }}"
archive="$(find dist -maxdepth 1 -type f -name kryon-*-static.tar.gz | head -n 1)"
test -n "$archive"
echo "KRYON_STATIC_ARCHIVE=$archive" >> "$GITHUB_ENV"
- name: Package Every Kryon Tool
run: |
set -euo pipefail
make dist-tools CMAKE=/usr/bin/cmake VERSION="${{ steps.ref.outputs.tag }}"
make check-tools-package CMAKE=/usr/bin/cmake VERSION="${{ steps.ref.outputs.tag }}"
archive="$(find dist -maxdepth 1 -type f -name 'kryon-*-tools-*.tar.gz' | head -n 1)"
test -n "$archive"
echo "KRYON_TOOLS_ARCHIVE=$archive" >> "$GITHUB_ENV"
- name: Write Checksums
run: |
sha256sum "$KRYON_STATIC_ARCHIVE" "$KRYON_TOOLS_ARCHIVE" > SHA256SUMS
- name: Upload Static Library Artifact
uses: actions/upload-artifact@v7
with:
name: kryon-static-library-${{ steps.ref.outputs.tag }}
path: ${{ env.KRYON_STATIC_ARCHIVE }}
if-no-files-found: error
- name: Upload Tools Artifact
uses: actions/upload-artifact@v7
with:
name: kryon-tools-${{ steps.ref.outputs.tag }}
path: ${{ env.KRYON_TOOLS_ARCHIVE }}
if-no-files-found: error
- name: Publish GitHub Release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ steps.ref.outputs.tag }}
name: Kryon ${{ steps.ref.outputs.tag }}
prerelease: ${{ github.event_name == 'workflow_dispatch' && inputs.prerelease || false }}
files: |
${{ env.KRYON_STATIC_ARCHIVE }}
${{ env.KRYON_TOOLS_ARCHIVE }}
SHA256SUMS
git tag -a "$TAG" -m "Kryon $VERSION"
git push origin "$TAG"
gh release create "$TAG" --title "Kryon $VERSION" --notes "$NOTES"
-114
View File
@@ -1,114 +0,0 @@
name: renderers
# Build downloadable KRB renderers for every platform: the headless
# renderer (krb-run) as native binaries, and the web player (krb-web)
# as static files any site can host.
on:
push:
branches: [master]
tags: ["v*"]
workflow_dispatch:
permissions:
contents: write
jobs:
native:
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest, cc: cc, suffix: linux-x86_64, build_dir: build/linux-x86_64 }
- { os: ubuntu-latest, cc: x86_64-w64-mingw32-gcc, suffix: windows-x86_64, build_dir: build/linux-x86_64 }
- { os: macos-latest, cc: /usr/bin/clang, suffix: macos-arm64, build_dir: build/macos-arm64 }
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v7
with:
submodules: recursive
- name: Install mingw (windows cross)
if: matrix.suffix == 'windows-x86_64'
run: sudo apt-get update && sudo apt-get install -y mingw-w64
- name: Install GNU make (macOS)
if: runner.os == 'macOS'
run: brew install make
- name: Build krb-run
# The Makefile's KRY_SW_SRCS is the single source of truth for what
# every renderer build links; never pin a copy of the list here.
run: |
target="${{ matrix.build_dir }}/bin/krb-run"
if [ "${{ runner.os }}" = macOS ]; then
env -u MAKE -u MAKEFLAGS -u MFLAGS -u MAKEFILES \
CC=${{ matrix.cc }} /opt/homebrew/bin/gmake -e -f ./Makefile "$target"
else
make "$target" CC=${{ matrix.cc }}
fi
[ "${{ matrix.suffix }}" = windows-x86_64 ] && target="$target.exe"
cp "$target" build/krb-run
- name: Rename
run: cp build/krb-run krb-run-${{ matrix.suffix }}${{ matrix.suffix == 'windows-x86_64' && '.exe' || '' }}
- uses: actions/upload-artifact@v7
with:
name: krb-run-${{ matrix.suffix }}
path: krb-run-${{ matrix.suffix }}*
web:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
submodules: recursive
- uses: mymindstorm/setup-emsdk@v14
with:
version: latest
- name: Build web player
run: make krb-web
- name: Package
run: |
mkdir -p krb-player-web && cp build/linux-x86_64/web/krb-web/* krb-player-web/
cp examples/02_buttons.kry /tmp/ 2>/dev/null || true
- uses: actions/upload-artifact@v7
with:
name: krb-player-web
path: krb-player-web/
exactness:
# Cross-engine byte-exactness needs no GL (SDL dummy + software).
# The native pixel-compare vs the inbe C build additionally needs a
# working screenshot pipeline: xvfb-run, as inbe's own CI does.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
submodules: recursive
- name: Build tools
run: |
sudo apt-get update
sudo apt-get install -y libsdl2-dev
make build/linux-x86_64/bin/k2b \
build/linux-x86_64/bin/krb-run \
build/linux-x86_64/bin/krb-sdl \
build/linux-x86_64/tests/krb_logic_test \
build/linux-x86_64/tests/krb_asset_test
- name: Cross-engine exactness
run: sh tests/krb_exact_test.sh .
- name: Unit tests
run: |
build/linux-x86_64/tests/krb_logic_test
build/linux-x86_64/tests/krb_asset_test
# Native gate: once inbe CI checks out kryon master as its vendor,
# run tests/krb_exact_native_test.sh per ported screen under xvfb:
# xvfb-run -a ./inbe --screenshot native.png --screenshot-scene language ...
release:
if: startsWith(github.ref, 'refs/tags/')
needs: [native, web]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
- run: |
mkdir rel && cp -r krb-run-* krb-player-web rel/
- uses: softprops/action-gh-release@v3
with:
files: rel/*
+20 -13
View File
@@ -6,27 +6,34 @@
*~
*.tmp
__pycache__/
ziran.local.toml
.zcode
.kryon-ide-state
# Local managed session state
/.yue/
# Test-owned scratch and logs
/work/
# Build output
build/
dist/
backup/
assets/fonts/*
!assets/fonts/LiberationSans-Regular.ttf
!assets/fonts/LiberationMono-Regular.ttf
!assets/fonts/LICENSE-Liberation
!assets/fonts/DejaVuSans.ttf
!assets/fonts/LICENSE-DejaVu
!assets/fonts/NotoSansSymbols-Regular.ttf
!assets/fonts/NotoSansSymbols2-Regular.ttf
!assets/fonts/LICENSE-Noto
tools/otfchop/otfchop
# native plan9 cpp-stage intermediates
src/**/*.i
src/**/*.8
.wrangler/
# JavaScript generated from runtime/*.kry by make generate-web-runtime
/web/instance.js
/web/control_props.js
/web/drawing_props.js
/web/text_input.js
/web/style_sheet.js
/web/style.js
/web/surface.js
/web/kss_parser.js
/web/kss_formatter.js
# Gallery metadata and editable snippets are generated from examples/gallery.
/docs/site/gallery-data.js
/docs/site/gallery-sources/
-24
View File
@@ -1,24 +0,0 @@
[submodule "vendor/raylib"]
path = vendor/raylib
url = https://github.com/raysan5/raylib.git
[submodule "vendor/liboqs"]
path = vendor/liboqs
url = https://github.com/open-quantum-safe/liboqs.git
[submodule "vendor/curl"]
path = vendor/curl
url = https://github.com/curl/curl.git
[submodule "vendor/cmark-gfm"]
path = vendor/cmark-gfm
url = https://github.com/github/cmark-gfm.git
[submodule "vendor/box2d"]
path = vendor/box2d
url = https://github.com/erincatto/box2d.git
[submodule "vendor/monocypher"]
path = vendor/monocypher
url = https://github.com/LoupVaillant/Monocypher.git
[submodule "vendor/utf8proc"]
path = vendor/utf8proc
url = https://github.com/JuliaStrings/utf8proc.git
[submodule "vendor/bend"]
path = vendor/bend
url = https://github.com/bendlang/bend.git
+75 -92
View File
@@ -1,108 +1,91 @@
# Kryon Repository Rules
# Kryon repository rules
Kryon is the canonical runtime. Keep it small, direct, and free of stale
surfaces.
Kryon is a reusable UI library authored in Ziran. The Ziran language,
compiler, `.zir` representation, `.zx` format, and portable runtime live in
the separate Ziran repository (`~/Projects/ziranlang/ziran`). Kryon's reusable widgets
live in `src/ui/<component>/`, shared UI infrastructure stays in `src/ui/`,
its hosts live in `src/backend/*.zi`, and the
`kryon` project tool in `src/project/*.zi`.
## Instruction Location
## 100% Ziran rule
Keep repository-wide agent and contributor rules in this root `AGENTS.md`.
Documentation under `docs/` describes API behavior, integration, and design;
do not put agent policy there or maintain a duplicate instruction file there.
Keep `docs/API.md`, `docs/BOUNDARIES.md`, and `docs/ARCHITECTURE.md` current
when their corresponding APIs or subsystem boundaries change.
- Kryon's handwritten implementation, platform integration, and maintained
examples must be written in current Ziran (`.zi`). Do not add or expand
handwritten C, C++, Go, or other language implementations inside Kryon.
Generated native output under `build/` is an output of Ziran, not source.
- Use the latest Ziran syntax and APIs directly. Do not add compatibility
wrappers, aliases, fallback runtimes, or old-syntax paths for Ziran in Kryon.
When Ziran lacks a general capability, implement it in Ziran first and
import it as an ordinary language capability. Do not add UI special cases to
Ziran.
- The library, hosts, project tool, and examples are all Ziran. Python and
shell scripts are build and test tooling, and `templates/droid/` is the
Android project scaffold an app build copies; keep widget and host behavior
out of them.
## Upstream and Preview Workflow
## Source and build
Make Kryon changes here on `master`, commit and push them here, then update
downstream apps' submodule pointers. Never edit a downstream `vendor/kryon`.
- Make changes in this upstream repository on `master`. Commit and push here
before a downstream application updates its `ziran.lock` (or, for an app
that still vendors Kryon, its clean `vendor/kryon` pointer).
- Never create or work in temporary Kryon or Ziran checkouts, clones, or
worktrees. Edit the root repositories on `master`; reserve temporary
directories for disposable test outputs only.
- `src/ui/modules.txt` lists the core modules compiled into `libkryon.a`.
`*_laws.zi` files throughout `src/ui/` are proved by `make laws`, and optional modules such as
`Window`, `Media`, `Video`, `Clock`, and `Service` are package exports in
`ziran.toml`. A checker pass alone does not establish native or portable
readiness.
- Run `make push-check` before pushing: it takes minutes and links the hosts a
shared backend change can break. CI runs it before its long jobs.
- `make test` is the current Kryon gate. It builds the checked Ziran library
and runs Ziran source, saved-IR, and bundle behavior tests without a display.
- Put one-off experiment builds in `build/scratch/<name>/`, never in new
top-level `build/` directories. `make clean-scratch` removes scratch output
that has been idle for a day; `BUILD_OUTPUTS` in the Makefile lists the
directories that targets and tests own.
- Use direct domain names for APIs. Do not restore the removed KIR compiler,
`.kry` runtime, or `.krb` loader as compatibility paths.
Kryon owns live preview, PNG capture, and hot-reload verification. Use
Kryon-owned tooling, not Krait, to verify `.kry` rendering and reload behavior.
## UI ownership
## Clean API Rule
Author reusable widget behavior, composition, layout, interaction, styling,
accessibility, and UI tree decisions in `.zi`. Platform hosts may gather OS
input, manage windows, load fonts and images, rasterize, and store data. Host
code must not independently choose widget behavior.
Do not introduce new public generated-runtime APIs with stale prefixes or
compatibility names. New `.kry` generated code must target the clean runtime
surface:
An application imports Kryon as an ordinary Ziran library. The Ziran compiler
and portable loader must never recognize Kryon widget names specially. An
application that does not import Kryon needs no Kryon code or graphical host.
Keep app-specific screens, assets, copy, workflows, and state in the app repo.
- `BeginFrame`
- `EndFrame`
- `Text`
- `Button`
- `TextField`
- `TextArea`
- `Row`
- `Column`
Nothing is imported by default. A program carries only the code for what it
imports and uses. A bare window carries the window, its events and
presenting; import a frame and you get a frame, import a rectangle and you get
a rectangle. Optional features arrive through their import or first use, never
through runtime flags. Shared code reaches an optional part through a small
slot module (such as `frame_driver`, `image_lookup`, `text_editing` and
`scroll_sampling`) that the part's own module fills from its initializer or
first use; shared code never imports the part itself. Make generated code
smaller by cutting what isn't
needed, never by merging files (owner, 2026-11-15).
Do not add `kryc`. The supported transpilers are `k2go` for native Go, `k2c`
for native C, and `k2cpp` for native C++ (C++ codegen over the C runtime).
One widget concept has one public implementation. `Text.Draw(Text.Props)` and
`Image.Draw(Image.Props)` are the intended text and image widget surfaces. Do not
add parallel wrappers or expose raw texture draw calls as app widget APIs.
Generated Go must be native Go and must not use cgo, `go/kryui`, `kryruntime`,
or an injected `rt` runtime object. Generated C must not call stale prefixed UI
symbols such as draw-prefixed UI helpers, `UIText*`, `TextInputControl`, or
`UIRender*`.
## Testing and desktop safety
Existing compatibility code may only remain while actively migrating callers.
Do not expand it, duplicate it under another alias, or use it from generated
output. Remove compatibility code once no maintained app or fixture depends on
it.
Test changed modules through all relevant generated targets and portable
bundles. Use focused behavior tests for decisions that could diverge across
targets. Do not treat code generation alone as proof that a host or app works.
## Kry UI Source Rule
All widget behavior, layout, interaction, styling decisions, and UI tree
construction must be authored in `.kry`. KSS defines theme values. C is only
permitted for platform and raster backend services called by `.kry`; it must
not define a widget, compose a UI tree, or choose a widget's visual state.
Migrate existing `src/ui/*.c` implementations rather than renaming or copying
their bodies into generated C. This rule applies to every widget, including
Button and SegmentedControl, and to `ui.c` and `ui_tree.c`.
## Canonical Widget Rule
One widget concept has one public implementation. Variations such as wrapping,
clipping, color, alignment, and disabled state belong in that widget's props;
do not create parallel helpers such as `TextWrapped`, `TextColored`, or
`TextDisabled`. Migrate maintained callers when consolidating an older split
surface, then remove the duplicate entry points and generated output.
`Text` has exactly one public signature: `Text(TextProps)`. Every maintained C
and `.kry` caller must pass one explicit `TextProps` value. Position, bounds,
wrapping, clipping, color, alignment, and disabled state belong in those props.
Do not restore the positional `Text(text, x, y, font, color)` form or hide it
behind a helper, macro, overload, generated shim, or compatibility alias.
`Image` has exactly one public widget surface: `Image(ImageProps)`. Semantic
page images are still `Image(ImageProps)` with semantic props/alt text, not a
separate image widget. Do not expose or recommend raylib texture draw calls
(`Texture`, `DrawTexture`, `DrawTexturePro`,
`DrawTextureRec`, or similar) as app-facing `.kry` UI fixes. Low-level texture
drawing may exist inside backend/native tests and renderer internals, but
generated app UI should target `ImageProps`. If `ImageProps` cannot express a
needed app image case, add a clean reusable Kryon primitive here first instead
of adding a downstream wrapper or compatibility alias.
## Test Rule
Any change to k2go, k2c, k2cpp, the Go runtime, or the C runtime surface must keep the
generated-output scanners and runtime parity tests passing. If a new widget or
semantic is added, add it to both generated runtimes and to parity coverage in
the same change.
Run `python3 scripts/check-clean-text-api.py <changed-source-roots>` when a
maintained app or fixture changes text rendering. Downstream repositories must
wire this check into their normal test target.
## Readability Rule
Write conventional, fully readable code. Do not compress multiple statements,
branches, or error checks onto one line. Handlers and protocol code must use
descriptive names, explicit control flow, and focused helpers. Run the language
formatter and inspect the resulting diff before considering a change complete.
Never run tests or binaries that can send X/Wayland requests against the
developer's live desktop. Use a private Xvfb/Xephyr display for any visual or
window-management test, and scope window effects to processes Kryon owns.
Never touch the inherited display or `/tmp/.X11-unix/X0` during cleanup.
## Bend
When using Bend:
- run `bend guide` to learn it
- use `LAWS.bend` to keep important rules
- run `bend PROOF.bend` before committing
- parallelize the code whenever possible
When using Bend, run `bend guide`, keep important rules in `LAWS.bend`, run
`bend PROOF.bend` before committing, and parallelize the code where possible.
+683 -1585
View File
File diff suppressed because it is too large. Load diff
+993 -2282
View File
File diff suppressed because it is too large. Load diff
+105 -243
View File
@@ -1,270 +1,132 @@
<p align="center">
<img src="assets/app/readme-banner.png" alt="Kryon" width="100%">
</p>
# Kryon
Kryon is a small C support library for raylib-style applications. It keeps a
raylib-compatible public surface available through `kryon.h`, then adds the
pieces shared by downstream apps: UI controls, Tk-style toolkit widgets, layout
helpers, text rendering, themes, embedded assets, locale loading, file dialogs,
desktop tray support, runtime asset downloads, and optional account/sync helpers.
Documentation for Kryon 0.4.0 and Unreleased changes on master.
## Layout
Linux desktop and portable hosts can decode local videos with synchronized audio
using the optional GStreamer service exported as `kryon/Video` and
`kryon/VideoLinux`. Display the returned frame with `Image.Draw(Image.Props)`.
Applications own playback controls and access checks; an optional expiring lease
revokes both audio and decoded frames when authorization is no longer renewed.
`make test-focus TEST=ziran_video_linux_test` checks synthetic moving frames, paused seeking, speed, volume,
replay and lease revocation with a silent audio sink and no display access.
- `include/` - public headers, including `kryon.h` and generated raylib
compatibility declarations
- `src/` - Kryon implementation files, with reusable UI modules under `src/ui/`
- `icons/` - MingCute UI and full-color spritesheets embedded by `src/ui/ui_icon_assets.c`
- `themes/` - built-in theme files for the runtime theme loader
- `fonts/noto/` - bundled Noto Sans TTF/OTF font assets
- `mk/` - Make fragments for native, Android, Windows, packaging, and
vendored dependency builds. Web/JS build work is paused and tracked as a
future target in `docs/WEB_JS_ROADMAP.md`.
- `scripts/` - asset embedding, icon embedding, raylib preparation, and boundary
check helpers
- `examples/` - small programs that exercise Kryon UI features
- `tests/` - focused C tests for account, sync, and transition helpers
- `vendor/raylib`, `vendor/curl`, `vendor/liboqs` - source submodules used by
downstream app builds
Kryon is a UI library written in Ziran. Its source lives under `src/ui/` and
imports Ziran modules normally. The Ziran compiler, `.zir` representation, and
`.zx` bundle format belong to the separate
[Ziran](https://github.com/ziranlang/ziran) repository.
## Building
## Build
Kryon builds with the repository Makefile:
Install the `ziran` command first (`make install-user` in a
[Ziran](https://github.com/ziranlang/ziran) checkout), then build Kryon:
```bash
```sh
make
```
Run the focused tests with:
```bash
make test
```
Backend selection is link-time via `KRYON_BACKEND`. Supported backends are:
The Makefile builds against the Ziran revision locked in `ziran.lock`, found
with `ziran pkg path ziran`. To build against a local Ziran checkout, name it
in an ignored `ziran.local.toml` `[overrides]` table or set `ZIRAN_ROOT`.
- [`raylib`](https://github.com/raysan5/raylib) - the default desktop,
Android, Windows, and WebGL path, with SDL2/OpenGL integration in the build
rules.
- [`libdraw`](https://9fans.github.io/plan9port/man/man3/draw.html) - the
plan9port libdraw/devdraw backend.
- [`termi`](src/backend/termi_backend.c) - the terminal-cell backend.
- `null` - generated no-op stubs for headless tests and unsupported surface
areas.
`make` checks the modules listed in [src/ui/modules.txt](src/ui/modules.txt),
writes checked `.zir`, generates C and Go, and compiles the native outputs
from Ziran source.
The current C archive is `build/ziran/libkryon.a`; C headers are generated
from Ziran declarations into `build/ziran/c/`. Kryon has no handwritten
source headers. Hosts provide declared
effects such as raster lines, and `CompositionQueue` carries raw IME events to
the checked text widgets.
Build a distributable static-library archive with:
Charts, tables, trees, and source coloring are separate Git packages that
depend on Kryon: [Plot](https://github.com/kryonlabs/plot),
[DataViews](https://github.com/kryonlabs/data-views) (`TableView` and
`TreeView`), and [Syntax](https://github.com/ziranlang/syntax). Add one with
`ziran add URL` and import it as `plot/Plot`, `data_views/TableView`, or
`syntax/Syntax`. Kryon exports the building blocks such packages draw with
(`session`, `tree`, `surface`, `paint_queue`, `style`, and the others listed
in `ziran.toml`); see [writing a widget package](docs/API.md#widget-packages).
```bash
make dist-static
```
Style sheets are the separate [CSS](https://github.com/kryonlabs/css)
package: it parses and formats a subset of CSS, installs the rules. Kryon keeps the rule table and
style resolution, so an app that builds its rules in code needs no parser.
The archive is an extracted SDK layout. It contains `libkryon.a`,
`libraylib.a`, vendored static dependency libraries, public headers, API docs,
example consumers, CMake and pkg-config metadata, third-party notices, a package
manifest, and the submodule revisions used to build it. Validate it with:
Kryon exports `geometry` and `drawing_props` for programs that need drawing
values without importing widgets. Imports and use determine what a program
carries. `App.Show(window)` carries only the window, events and presentation;
`App.Run(window, Draw)` also brings the frame loop. Portable ZX windows run
through the native desktop provider by default. See the [API](docs/API.md).
```bash
make check-static-package
```
`make test` builds the test host and runs the Ziran source, saved-IR, and
portable bundle tests with four concurrent jobs. Set `TEST_JOBS=1` to run them
serially or `TEST_JOBS=8` on a larger machine. For a quick edit loop, use
`make test-focus TEST=link_widget`; the filter matches test script names and
skips the full library rebuild. Test subprocesses have no display access.
`make sanitize-test` runs the behavior tests with AddressSanitizer and
UndefinedBehaviorSanitizer. Keep one-off experiments in `build/scratch/`;
`make clean-scratch` removes that and any other `build/` entry that no target
writes, once it has been idle for a day.
See [composition input](docs/COMPOSITION_INPUT.md) for the checked IME event
contract and host queue lifetime.
See [cursor input](docs/CURSOR.md) for the checked cursor decision and platform
effect contract.
See [theming](docs/THEMING.md) for palette and style customization.
See [zoom](docs/ZOOM.md) for Ctrl and mouse-wheel zoom of a whole application.
See [clipboard state](docs/CLIPBOARD.md) for the portable clipboard value and
host effect contract.
See [frame replay](docs/FRAME_REPLAY.md) for committed UI and paint capture
with scripted input on a headless host.
The [hello world example](examples/README.md) is one small Ziran program with
an explicit `main`: it imports Kryon's app and text packages, opens a window,
and draws the label `Hello, world!`.
For Ziran app manifests, the terminal backend, and `kryon run`, see
[Ziran projects](docs/PROJECTS.md).
Portable desktop profiles build a `.zx` with embedded assets; a downloaded
file launches with `ziran run app.zx` after installing the desktop provider. See [Zx applications](docs/PROJECTS.md#zx-applications).
Run the full release readiness gate with:
## Website and widget gallery
```bash
make release-preflight
```
`make site` packages the Canvas website, browser compiler, preview host and
widget gallery into `docs/site/`. Emscripten is required; activate
emsdk or set `EMCC`. `make site-gallery` builds only the gallery, and
`make site-gallery-test` prepares editable examples and exercises the gallery in
a private Chromium/Xvfb session.
`libkryon.a` stays focused on Kryon object files. Companion libraries are shipped
beside it and linked through `lib/pkgconfig/kryon.pc`. OpenSSL is still treated
as an external system/toolchain dependency unless explicit OpenSSL static library
paths are supplied at build time.
The gallery at `widgets.html` uses the example package in `examples/gallery/`.
Its core scenes are shared by the desktop, web and review hosts. Examples are
grouped by installed module and category, including core UI and 2D drawing.
Optional package integrations are registered only while their dependencies
are declared. Each selected example includes editable Ziran source and a live
preview, using the browser compiler and the gallery editor. Plot and DataViews
supply charts, tree, Kanban and an interactive TableView. `make site` generates the scene metadata and editable
snippets directly from these examples. The Pages workflow builds and tests the
full website from fixed source revisions before publishing.
## Releases
## Current status
Patch releases are batched: at most one per day, and only when maintainers have
written user-facing notes under the `## Unreleased` heading in `CHANGELOG.md`.
The scheduled `Automatic Release Version` workflow checks for curated notes,
advances the patch version in `include/kryon_version.h`, and starts the
tag-driven `Release` workflow. That workflow validates the version, promotes the
`## Unreleased` notes into a dated entry, creates an annotated tag, builds and
tests Kryon, and publishes both the static SDK and a checksummed native tools
bundle. The tools bundle contains `k2c`, `k2cpp`, `k2go`, `k2kir`, `k2b`, `kt`,
`kryon`, `kryon-preview`, `krb-run`, and `krb-sdl`. The JavaScript/web tooling
is paused and is not shipped as a current release target; see
`docs/WEB_JS_ROADMAP.md` for the future web-native direction.
The [feature matrix](docs/FEATURE_MATRIX.md) records package and host coverage.
The Canvas2D browser host is covered by private headless Chromium, WebAudio,
and Wasm tests. See [accessibility](docs/ACCESSIBILITY.md) for platform coverage.
Maintainers can still run `Release` manually for the checked-in version. Use
`scripts/bump-version.sh minor` / `major` before pushing when a non-patch bump is
required. Pushing a matching `v*` tag manually uses the same build-and-publish
path; releases reject tags that disagree with the public version header.
Kryon commits land upstream first. Applications then update their
`ziran.lock` with Ziran's package commands. This repository's tests
verify Kryon itself, not every downstream application build.
## Integration
See [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) for the library boundary and
[Ziran's implementation
status](https://github.com/ziranlang/ziran/blob/master/docs/IMPLEMENTATION_STATUS.md)
for language and portable runtime gaps.
To integrate Kryon into your project:
1. Add `include/` to your header search paths
2. Include `kryon.h` for the raylib-compatible API plus Kryon modules
3. Compile Kryon sources from `src/` and `src/ui/`, or use the `mk/` fragments
to let Kryon assemble source lists and platform flags
4. Kryon's checked-in `icons/` tree is the source of truth for the finished
MingCute Core UI sheet, a separate full-color logo sheet, and the full-color platform,
payment, language, tile, and profile sheets. `make icons-embed` refreshes the embedded C assets from
those sheets. Use `DrawIcon` or the generated `Icon` widget with a runtime
`Color`; no per-color files or per-icon textures are needed. Downstream apps
can call `vendor/kryon/scripts/sync-icons.sh` to copy the sheets. Maintainers
can refresh the UI subset from an upstream checkout with
`make icons-import-mingcute MINGCUTE_DIR=/path/to/mingcute-icons`.
`scripts/embed-assets.sh` remains available for non-icon assets.
5. Include `mk/vendor.mk` when your app enables curl or liboqs-backed features
Applications should keep build artifacts in their own build directories, but
the dependency source of truth and common build recipes should live under Kryon.
For TLS-enabled curl builds, `mk/vendor.mk` passes the `OPENSSL_*` make
variables through to the vendored curl CMake build.
## App Builds
Kryon owns the app command surface through `kryon`. From an app repository:
```sh
kryon build native
# web builds are paused; see docs/WEB_JS_ROADMAP.md
kryon build android-debug
kryon package linux-desktop
kryon package appimage
kryon preview
```
For local development against a sync backend, run a Daochi node in the
foreground. `dev-backend` locates the server source at `$DAOCHI_DIR` or as a
sibling checkout (`../daochi`), isolates its data under `<project>/.kryon/`, and
prints the sync URL to point your app at. Tokens are regenerated each start,
so it is for local development only:
```sh
kryon dev-backend # serves http://127.0.0.1:8080
```
Apps can keep startup simple with one `SyncNodePool`: add the shipped public
node as `SYNC_NODE_PUBLIC`, add LAN or remote nodes learned through explicit
pairing as `SYNC_NODE_PAIRED`, then call `RunSyncWithNodes`. The pool tries a
paired local node first, another paired node second, and the public node last.
Temporary connectivity and authentication failures fall through automatically;
credentials and clock state remain isolated per node.
App `project.kryon` files should use `target` entries that call `kryon`
rather than embedding platform-specific build commands directly. Existing app
Makefiles can remain as backend glue while repeated native, Android, and
packaging logic moves into Kryon `mk/` fragments. Web packaging returns after
the future web-native target is designed.
## Preview Projects
Krait, the standalone Kryon IDE (a separate `kryonlabs/krait` repo that vendors
Kryon), previews `.kry` source by compiling it to an app host and loading it
into the embedded viewport. On each source change Krait rebuilds the project's
app host (`make kryon-host`, producing `build/kryon/app_host.so`), `dlopen`s
it, and resolves `CreateAppHost`/`DestroyAppHost`. The build runs in the
background (`fork` + non-blocking pipe, drained each frame) so the window stays
responsive during the compile; once it finishes the new app host is loaded and
the preview updates. Source changes are polled a few times per second. Kryon
itself owns the preview host tooling (`kryon-preview`); it must not depend on
Krait.
A project can add `project.kryon` metadata such as `preview_size`,
`preview_asset_root`, and `preview_scene` to control the embedded viewport.
## Conventions
Kryon follows raylib-style C conventions where practical: lowercase module
filenames, simple C structs, and public functions named like raylib APIs
(`InitWindow`, `DrawTexture`, `BeginUIFrame`, `ButtonNode`). Internal helpers
stay private to `src/` unless a downstream app needs the API in `include/`.
`kryon/breadcrumb` serves `Breadcrumb.Draw` for keyed label navigation, with measured
ancestors and an accessible, virtualized overflow menu. Applications own
selection, focus and navigation; see [the API](docs/API.md#breadcrumbs).
## Documentation
- `docs/API.md` documents the public API.
- `docs/KRY_LANGUAGE_SPEC.md` is the canonical `.kry` language and KIR
contract.
- `docs/FEATURE_MATRIX.md` maps widget and feature support across the C, Go,
and KRB targets and every renderer backend.
- `docs/BACKENDS.md` documents the backend architecture and selection.
- `docs/BACKEND_CAPABILITIES.json` is the checked backend inventory used by
backend drift checks.
- `docs/ARCHITECTURE.md` maps the main Kryon subsystems and ownership lines.
- `docs/BOUNDARIES.md` defines what belongs in Kryon and what stays in
downstream applications.
- `docs/PUBLIC_API_SNAPSHOT.txt` tracks public Kryon identifiers for API drift
checks.
- `docs/site/` contains the static documentation website.
- `AGENTS.md` contains repository-wide agent and contributor instructions.
- `docs/APP_INTEGRATION.md` documents downstream app integration, including
modal/input capture and dependency updates.
## Toolkit Direction
Kryon defines widgets and their properties in `.kry` modules under `runtime/`
and `src/ui/`. Generated headers expose the native API. Each widget accepts
plain properties and renders in the immediate-mode frame. The numbered examples
`09_geometry` through `18_accessibility` demonstrate each feature family.
## Kry Language
`docs/KRY_LANGUAGE_SPEC.md` is the canonical Kry language contract. Kry source
lowers into KIR, a debuggable intermediate representation with source spans.
From there `k2c` emits readable C for native apps, `k2cpp` emits C++ with C
linkage against the same C runtime, `k2go` emits pure Go source
against the native Go runtime, while `k2b` emits a portable `.krb` cartridge
(`docs/KRB_FORMAT.md`) for renderers that implement the Kryon runtime contract.
The intended tool set is Unix-shaped:
```text
k2kir app.kry # .kry -> .kir
k2c app.kry|app.kir
k2cpp app.kry # .kry -> C++ (extern "C" decls over the C runtime)
k2go app.kry # .kry -> Go (native Go runtime, no cgo)
k2b app.kry|app.kir
```
Generated Go imports `github.com/waozixyz/kryon/go/kryon` as `kryon` and uses
clean qualified widget names such as `kryon.Button`, `kryon.TextField`,
`kryon.Text`, `kryon.Row`, `kryon.Column`, `kryon.BeginFrame`, and
`kryon.EndFrame`. Pure Kry and Go-native externs must not use `import "C"`,
the removed bridge package, injected runtime objects, dot-imported runtime
names, or generated calls to stale prefixed C APIs. Explicit C externs with a
`c.` target, such as `#extern "c.abs"`, are the opt-in exception: `k2go` emits
their `import "C"` bridge in a separate generated `*_cgo.go` file.
Handwritten Go uses the same typed Button API as generated code:
`kryon.Button(kryon.ButtonProps{Label: "Save"})`. Omitted size and font use
the shared `.kry` defaults; identity is not derived from the label.
TextField still supports both `kryon.TextField(kryon.TextFieldProps{...})`
and the direct `kryon.TextField("Name", &name)` form during its migration.
The native Go runtime records each frame as pure Go `FrameOp` values available
through `FrameOps()`. That operation stream is the host boundary for native Go
windows/renderers: it carries resolved bounds, text, colors, focus, button
state, and redacted secure text without importing cgo or the removed bridge.
`RenderFrame` and `RenderCurrentFrame` provide a dependency-free software
renderer that turns those operations into an `image.RGBA`.
`NewHost` owns a persistent native Go runtime, runs generated or handwritten
frame functions, queues input, exposes frame operations, and renders frames
without cgo.
`k2go` output is compiled against that native runtime by the test suite, and the
generated Go/C parity tests drive both runtimes through the same scripted input.
This is an executable compatibility gate, not only a textual generated-source
check.
`k2c` and `k2b` accept `.kry` source and run the KIR frontend internally. Native
platform, storage, and performance-sensitive C code remains first-class through
the C backend and through explicit KRB capabilities or host imports.
### JavaScript/web target
The old JavaScript/web target is paused. It is kept in the source tree as
experimental reference material, but it is no longer part of default builds,
test/preflight gates, or packaged tools. Future web work should target native
HTML/DOM structure, KSS/CSS styling, and small JavaScript state/event glue rather
than growing the handwritten widget emulation runtime. See
`docs/WEB_JS_ROADMAP.md`.
- [API reference and widget packages](docs/API.md)
- [Architecture](docs/ARCHITECTURE.md) and [repository boundaries](docs/BOUNDARIES.md)
- [Projects](docs/PROJECTS.md), [hosts](docs/BACKENDS.md) and [Canvas](docs/canvas.md)
- [Feature matrix](docs/FEATURE_MATRIX.md) and [widget verification](docs/WIDGET_CONFORMANCE.md)
- [Input components](docs/INPUT_COMPONENTS.md), [overlays](docs/OVERLAYS.md) and [compact navigation](docs/navigation.md)
- [Component loading](docs/COMPONENTS.md), [window focus](docs/window-focus.md) and [accessibility](docs/ACCESSIBILITY.md)
- [Raster workers](docs/THREADING.md) and [performance measurements](docs/PERFORMANCE.md)
+5 -12
View File
@@ -1,20 +1,13 @@
# Third-Party Notices
The Kryon static package includes third-party code built from the repository
submodules listed in `SUBMODULES.txt`.
The Kryon static package includes third-party code pinned by its package lock.
- raylib: zlib/libpng license, see `vendor/raylib/LICENSE` in the source tree.
- liboqs: MIT license, see `vendor/liboqs/LICENSE.txt` in the source tree.
- curl/libcurl: curl license, see `vendor/curl/COPYING` in the source tree.
- cmark-gfm: BSD-style license, see `vendor/cmark-gfm/COPYING` in the source tree.
- Noto fonts: SIL Open Font License 1.1, see `fonts/noto/LICENSE.txt` in the source tree.
- Liberation Sans: SIL Open Font License 1.1, see `assets/fonts/LICENSE-Liberation`.
`src/backend/pixmap_font.zi` holds outlines of its Latin glyphs for the
pixmap host.
- MingCute Core icons: Apache License 2.0, see
`licenses/mingcute/LICENSE.txt` in the source tree. Kryon embeds only the
selected, renamed monochrome subset used by its UI in `icons/ui.png`.
selected, renamed monochrome subset used by its UI in `icons/ui.webp`.
Apache 2.0 does not grant rights to third-party trademarks depicted by some
brand icons; applications remain responsible for appropriate trademark use.
OpenSSL is not vendored into the package by default. When `kryon.pc` lists
`-lssl -lcrypto`, those libraries are expected to come from the target system or
from paths supplied with `OPENSSL_ROOT_DIR`, `OPENSSL_SSL_LIBRARY`, and
`OPENSSL_CRYPTO_LIBRARY` at build time.
+1
View File
@@ -0,0 +1 @@
0.5.0
Binary file not shown.

Before

Width:  |  Height:  |  Size: 429 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 847 KiB

+91
View File
@@ -0,0 +1,91 @@
{
"project": "Kryon",
"request": "One original friendly full-body dragon mascot for the Kryon UI toolkit, in the Ziran capybara's flat warm illustration feel, followed by a pastel-only color revision that preserves the accepted character.",
"pastel_follow_up_request": "okay but the colors should be more pastel — for the mascot",
"generation_mode": "built-in image_gen",
"generation_calls_planned": 1,
"conditional_retry_allowed": 1,
"generation_calls_completed": 3,
"attempt_count": 3,
"pastel_edit_calls_planned": 1,
"pastel_edit_calls_completed": 1,
"retry_reason": "The first attempt had extra body shading and tighter margins, a clear style/composition mismatch; the one permitted retry fixed the flat-ink direction.",
"proposals": [
{
"id": "01-dragon-v1",
"version": "v1",
"attempt_count": 2,
"animal": "Dragon",
"direction": "Rounded approachable full-body dragon in three-quarter view, facing right, with a calm warm personality and strong small-icon silhouette.",
"prompt": "Use case: logo-brand\nAsset type: final original mascot bitmap for Kryon, a UI toolkit and Ziran sister project; exactly one finished character.\nPrimary request: Create one entirely original friendly cartoon dragon mascot for Kryon. KDE inspiration is limited only to the broad idea of a rounded, approachable open-source cartoon dragon body and shape. This must not copy or trace Konqi and must not reuse Konqi's exact face, anatomy, pose, or proportions.\nScene/backdrop: None. A genuinely transparent square canvas with no background pixels, ground, shadow, border, or decoration.\nSubject: One full-body dragon in three-quarter view, facing right, standing in a relaxed welcoming pose. Big friendly head, short rounded snout, small rounded horns, small wings, a soft row of rounded back spines, four simple grounded feet without claws, and one clear tapering tail. Calm warm expression, small gentle eyes rendered only with earth-brown marks, closed mouth, no teeth. Nothing in its hands.\nStyle/medium: Confident hand-drawn flat illustration in the same visual family as Ziran's capybara mascot: bold deep earth-brown outline of consistent apparent weight, large quiet solid color areas, minimal interior marks, slight purposeful hand-drawn irregularity, calm warm character, strong sticker-like silhouette readable as a tiny website icon. Absolutely flat ink fills: no lighting, highlights, shadows, secondary shades, gray, cream, white fill, texture, or tonal modeling.\nComposition/framing: Center the single complete dragon on a 1:1 square canvas. The entire silhouette should occupy about 72–76% of the canvas width and height, leaving a clean 12–15% transparent border on every side. Every horn, wing, spine, foot, and tail is wholly visible and comfortably clear of the edge. Three-quarter view faces right.\nColor palette: Exactly four visual ink colors and no others except edge antialiasing between them and transparency: jade green #63B190 for the entire body and wings; exactly one continuous lake-blue underside/belly plane #77B7EA; deep earth-brown #502511 for every outline, eye, nostril, and minimal interior mark; one restrained muted light-orange #A48B62 used only on the small horn tips. Do not create light and dark variants of any color. Do not use orange on wings or elsewhere.\nText: NONE.\nConstraints: One original approachable rounded dragon; one character only; genuine alpha transparency; strong readable silhouette; generous clear margins; four flat source-family inks only; exactly one lake-blue belly plane; orange limited to horn tips; eyes use brown with no white eye fill.\nAvoid: Konqi likeness, KDE logo, gear, fire, smoke, teeth, aggressive claws, K monogram, letter-shaped body, props, clothing, scenery, borders, frames, solid or patterned background, gradients, glow, glossy 3D, textures, shading, highlights, drop shadows, extra characters, extra limbs, cropped anatomy. Absolutely no text, letters, numbers, labels, signatures, logos, or watermark anywhere.",
"file": null,
"transparent_background": true,
"status": "removed-at-owner-request",
"retained": false,
"actual": {
"dimensions": [1254, 1254],
"mode": "RGBA",
"alpha_extrema": [0, 255],
"content_bbox_alpha_gt_1": [107, 63, 1125, 1197],
"bytes": 877306,
"sha256": "aa041bbfe0fa60b97736fff724be5922f6b178607cfab5514b6cc4a17295da89"
},
"visual_review": {
"no_text_verified": true,
"transparent_background_verified": true,
"not_konqi_copy": true,
"style_matches_ziran": true,
"original_character": true
}
},
{
"id": "02-dragon-v2-pastel",
"version": "v2",
"attempt_count": 1,
"animal": "Dragon",
"direction": "Pastel-only color revision of the accepted v1 dragon, preserving the same friendly character, pose, proportions, framing, linework, expression, wings, spines, and transparent background.",
"prompt": "Use case: precise-object-edit\nAsset type: pastel color revision of the accepted Kryon dragon mascot bitmap.\nInput images: Image 1 is the sole edit target, the accepted v1 Kryon dragon mascot.\nPrimary request: Change ONLY the four flat ink colors of Image 1 to a softer pastel palette. Do not redraw, reinterpret, restyle, simplify, or add anything.\nColor palette: body pastel mint/jade approximately #A9DCC5; the single existing belly/underside plane pastel sky blue approximately #BCDDF6; the existing horn-tip accents pastel peach approximately #F5C7A1; all existing outline, eye, nostril, and interior marks deep earth-brown/warm cocoa approximately #6B4434. Use at most these four flat visual inks plus edge antialiasing and transparency.\nTransparency: Preserve the genuinely transparent background and all current alpha edges. No background pixels, ground, or shadow.\nInvariants: Preserve the exact same original character, pose, anatomy, proportions, framing, silhouette, linework geometry and apparent weight, expression, gaze, wings, rounded back spines, horns, feet, tail, belly-plane shape, detail placement, canvas dimensions, and transparent margins. Change only colors. Keep every existing element in the exact same position and size. No added or removed details.\nAvoid: gradients, extra shades, texture, highlights, shadows, glow, glossy rendering, new marks, altered outlines, altered anatomy, text, letters, numbers, logos, signatures, or watermark. Do not introduce a Konqi likeness, KDE logo, gear, props, clothing, scenery, border, fire, teeth, or claws.",
"file": "mascot-dragon.png",
"transparent_background": true,
"status": "complete",
"actual": {
"dimensions": [1254, 1254],
"mode": "RGBA",
"alpha_extrema": [0, 255],
"content_bbox_alpha_gt_1": [107, 64, 1127, 1197],
"bytes": 867648,
"sha256": "9537921d73713caccd9c991b4998224207f5ad21a079dcebc2f57cfc111daae4"
},
"target_palette": {
"body_pastel_mint_jade": "#A9DCC5",
"belly_pastel_sky_blue": "#BCDDF6",
"horn_tips_pastel_peach": "#F5C7A1",
"outline_warm_cocoa": "#6B4434"
},
"visual_review": {
"exact_character_preserved": true,
"pixel_identical_to_v1": false,
"transparent_background_verified": true,
"no_text_verified": true,
"not_konqi_copy": true,
"style_matches_ziran": true,
"pastel_palette_verified": true,
"at_most_four_visual_inks": true,
"original_character": true,
"notes": "The same accepted character, pose, anatomy, expression, linework design, and framing are preserved. Built-in image editing re-antialiased some edge pixels: the alpha>128 silhouette IoU is 99.53710%, ink-region agreement is 99.69063%, and the content bounding box moved by at most two pixels; v2 is therefore not claimed to be pixel-identical to v1."
}
}
],
"validation": {
"local_tests": "passed",
"tests": [
"The retained pastel mascot is a decodable 1254x1254 8-bit RGBA PNG with alpha extrema [0, 255].",
"The retained pastel mascot SHA-256 is 9537921d73713caccd9c991b4998224207f5ad21a079dcebc2f57cfc111daae4 and matches its proposal record.",
"Visible content above alpha 1 has bounding box [107, 64, 1127, 1197], wholly inside the canvas with transparent clearance on every side.",
"OCR returned no text; visual review found no text, letters, numbers, labels, signatures, or watermark.",
"Visual and palette review confirmed the same accepted original dragon, no Konqi copy, the Ziran flat warm style, and the requested pastel mint, sky-blue, peach, and warm-cocoa direction."
],
"scope": "Local validation of the sole retained asset assets/brand/mascot-dragon.png and assets/brand/prompts.json.",
"notes": "The earlier darker bitmap was removed at the owner's request; its prompt and digest remain as provenance only. The retained pastel mascot used one built-in image_gen edit call and its generated binary was copied without retouching."
}
}
Binary file not shown.
+78
View File
@@ -0,0 +1,78 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: DejaVu fonts
Upstream-Author: Stepan Roh <[email protected]> (original author),
see /usr/share/doc/fonts-dejavu-core/AUTHORS for full list
Source: https://dejavu-fonts.github.io/
Files: *
Copyright: Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved.
Bitstream Vera is a trademark of Bitstream, Inc.
DejaVu changes are in public domain.
License: bitstream-vera
Permission is hereby granted, free of charge, to any person obtaining a copy
of the fonts accompanying this license ("Fonts") and associated
documentation files (the "Font Software"), to reproduce and distribute the
Font Software, including without limitation the rights to use, copy, merge,
publish, distribute, and/or sell copies of the Font Software, and to permit
persons to whom the Font Software is furnished to do so, subject to the
following conditions:
.
The above copyright and trademark notices and this permission notice shall
be included in all copies of one or more of the Font Software typefaces.
.
The Font Software may be modified, altered, or added to, and in particular
the designs of glyphs or characters in the Fonts may be modified and
additional glyphs or characters may be added to the Fonts, only if the fonts
are renamed to names not containing either the words "Bitstream" or the word
"Vera".
.
This License becomes null and void to the extent applicable to Fonts or Font
Software that has been modified and is distributed under the "Bitstream
Vera" names.
.
The Font Software may be sold as part of a larger software package but no
copy of one or more of the Font Software typefaces may be sold by itself.
.
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE
FONT SOFTWARE.
.
Except as contained in this notice, the names of Gnome, the Gnome
Foundation, and Bitstream Inc., shall not be used in advertising or
otherwise to promote the sale, use or other dealings in this Font Software
without prior written authorization from the Gnome Foundation or Bitstream
Inc., respectively. For further information, contact: fonts at gnome dot
org.
Files: debian/*
Copyright: (C) 2005-2006 Peter Cernak <[email protected]>
(C) 2006-2011 Davide Viti <[email protected]>
(C) 2011-2013 Christian Perrier <[email protected]>
(C) 2013 Fabian Greffrath <[email protected]>
License: GPL-2+
This program is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later
version.
.
This program is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more
details.
.
You should have received a copy of the GNU General Public
License along with this package; if not, write to the Free
Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Boston, MA 02110-1301 USA
.
On Debian systems, the full text of the GNU General Public
License version 2 can be found in the file
/usr/share/common-licenses/GPL-2'.
+130
View File
@@ -0,0 +1,130 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Liberation Fonts
Source: https://github.com/liberationfonts
Files: *
Copyright:
Digitized data copyright (c) 2010 Google Corporation with Reserved Font Arimo, Tinos and Cousine.
Copyright (c) 2012 Red Hat, Inc. with Reserved Font Name Liberation.
License: SIL-OFL-1.1
This Font Software is licensed under the SIL Open Font License,
Version 1.1.
.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
.
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
.
PREAMBLE The goals of the Open Font License (OFL) are to stimulate
worldwide development of collaborative font projects, to support the font
creation efforts of academic and linguistic communities, and to provide
a free and open framework in which fonts may be shared and improved in
partnership with others.
.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves.
The fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply to
any document created using the fonts or their derivatives.
.
.
.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such.
This may include source files, build scripts and documentation.
.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
.
"Original Version" refers to the collection of Font Software components
as distributed by the Copyright Holder(s).
.
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting ? in part or in whole ?
any of the components of the Original Version, by changing formats or
by porting the Font Software to a new environment.
.
"Author" refers to any designer, engineer, programmer, technical writer
or other person who contributed to the Font Software.
.
.
PERMISSION & CONDITIONS
.
Permission is hereby granted, free of charge, to any person obtaining a
copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
.
1) Neither the Font Software nor any of its individual components,in
Original or Modified Versions, may be sold by itself.
.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the
corresponding Copyright Holder. This restriction only applies to the
primary font name as presented to the users.
.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
.
5) The Font Software, modified or unmodified, in part or in whole, must
be distributed entirely under this license, and must not be distributed
under any other license. The requirement for fonts to remain under
this license does not apply to any document created using the Font
Software.
.
.
.
TERMINATION
This license becomes null and void if any of the above conditions are not met.
.
.
.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER
DEALINGS IN THE FONT SOFTWARE.
.
Files: debian/*
Copyright:
2008 Alan Baghumian <[email protected]>
2008-2018 Holger Levsen <[email protected]>
2009-2012 Christian Perrier <[email protected]>
2011-2023 Fabian Greffrath <[email protected]>
2018 Rene Engelhard <[email protected]>
License: GPL-2+
This package is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>
.
On Debian systems, the complete text of the GNU General
Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
+278
View File
@@ -0,0 +1,278 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Noto
Upstream-Contact: https://github.com/googlei18n/noto-fonts/issues
http://groups.google.com/group/noto-font
Source: https://github.com/googlei18n/noto-fonts
Files: *
Copyright:
2010,2012-2020, Google Inc.
2015-2020, Google LLC.
License-Grant:
This Font Software is licensed under the SIL Open Font License,
Version 1.1.
License: OFL-1.1
Files:
debian/*
Copyright:
2013-2020, Jonas Smedegaard <[email protected]>
2020, Purism, SPC
2013, Vasudev Kamath <[email protected]>
License-Grant:
This program is free software;
you can redistribute it and/or modify it
under the terms of the GNU General Public License
as published by the Free Software Foundation;
either version 3, or (at your option) any later version.
License: GPL-3+
Files:
debian/NotoMono/NotoMono-Regular.ttf
Copyright:
2007, Google Inc.
License-Grant:
This Font Software is licensed under the SIL Open Font License,
Version 1.1.
License: OFL-1.1
License: OFL-1.1
PREAMBLE
.
The goals of the Open Font License (OFL) are to stimulate
worldwide development of collaborative font projects,
to support the font creation efforts
of academic and linguistic communities,
and to provide a free and open framework
in which fonts may be shared and improved
in partnership with others.
.
The OFL allows the licensed fonts to be used, studied,
modified and redistributed freely
as long as they are not sold by themselves.
The fonts, including any derivative works,
can be bundled, embedded,
redistributed and/or sold with any software
provided that any reserved names are not used
by derivative works.
The fonts and derivatives, however,
cannot be released under any other type of license.
The requirement for fonts to remain under this license
does not apply to any document
created using the fonts or their derivatives.
.
DEFINITIONS
.
"Font Software" refers to the set of files
released by the Copyright Holder(s) under this license
and clearly marked as such.
This may include source files, build scripts and documentation.
.
"Reserved Font Name" refers to any names specified as such
after the copyright statement(s).
.
"Original Version" refers to the collection
of Font Software components
as distributed by the Copyright Holder(s).
.
"Modified Version" refers to any derivative
made by adding to, deleting, or substituting --
in part or in whole --
any of the components of the Original Version,
by changing formats
or by porting the Font Software to a new environment.
.
"Author" refers to any designer, engineer, programmer,
technical writer or other person
who contributed to the Font Software.
.
PERMISSION & CONDITIONS
.
Permission is hereby granted, free of charge,
to any person obtaining a copy of the Font Software,
to use, study, copy, merge, embed, modify, redistribute,
and sell modified and unmodified copies of the Font Software,
subject to the following conditions:
.
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions,
may be sold by itself.
.
2) Original or Modified Versions of the Font Software
may be bundled, redistributed and/or sold with any software,
provided that each copy contains the above copyright notice
and this license.
These can be included either as stand-alone text files,
human-readable headers or in the appropriate
machine-readable metadata fields within text or binary files
as long as those fields can be easily viewed by the user.
.
3) No Modified Version of the Font Software may use
the Reserved Font Name(s)
unless explicit written permission is granted
by the corresponding Copyright Holder.
This restriction only applies to the primary font name
as presented to the users.
.
4) The name(s) of the Copyright Holder(s)
or the Author(s) of the Font Software
shall not be used to promote,
endorse or advertise any Modified Version,
except to acknowledge the contribution(s)
of the Copyright Holder(s) and the Author(s)
or with their explicit written permission.
.
5) The Font Software,
modified or unmodified, in part or in whole,
must be distributed entirely under this license,
and must not be distributed under any other license.
The requirement for fonts to remain under this license
does not apply to any document
created using the Font Software.
.
TERMINATION
.
This license becomes null and void
if any of the above conditions are not met.
.
DISCLAIMER
.
THE FONT SOFTWARE IS PROVIDED "AS IS",
WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO
ANY WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT.
IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT,
INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF THE USE OR INABILITY TO USE
THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
License: GPL-3+
License-Reference: /usr/share/common-licenses/GPL-3
# Noto Color Emoji (used to generate src/backend/pixmap_emoji.zi)
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: noto-emoji
Source: https://github.com/googlefonts/noto-emoji
Files-Excluded: fonts/*.ttf
Files: *
Copyright: 2013-2017 Google Inc.
Arjen Nienhuis <[email protected]>
License: Apache-2.0
Files: fonts/*
Copyright: 2013-2017 Google Inc.
Arjen Nienhuis <[email protected]>
License: SIL-1.1
License: Apache-2.0
Licensed under the Apache License, Version 2.0
https://www.apache.org/licenses/
.
On Debian systems, the complete text of the Apache License can be found in
/usr/share/common-licenses/Apache-2.0'.
License: SIL-1.1
This Font Software is licensed under the SIL Open Font License,
Version 1.1.
.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
.
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
.
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font
creation efforts of academic and linguistic communities, and to provide
a free and open framework in which fonts may be shared and improved in
partnership with others.
.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply to
any document created using the fonts or their derivatives.
.
DEFINITIONS
.
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
.
"Original Version" refers to the collection of Font Software components
as distributed by the Copyright Holder(s).
.
"Modified Version" refers to any derivative made by adding to,deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software
to a new environment.
.
"Author" refers to any designer, engineer, programmer, technical writer
or other person who contributed to the Font Software.
.
PERMISSION & CONDITIONS
.
Permission is hereby granted, free of charge, to any person obtaining a
copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
.
1) Neither the Font Software nor any of its individual components, in
Original or Modified Versions, may be sold by itself.
.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or in
the appropriate machine-readable metadata fields within text or binary
files as long as those fields can be easily viewed by the user.
.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the
corresponding Copyright Holder. This restriction only applies to the
primary font name as presented to the users.
.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
.
5) The Font Software, modified or unmodified, in part or in whole, must
be distributed entirely under this license, and must not be distributed
under any other license. The requirement for fonts to remain under this
license does not apply to any document created using the Font Software.
.
TERMINATION
.
This license becomes null and void if any of the above conditions are
not met.
.
DISCLAIMER
.
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+24
View File
@@ -0,0 +1,24 @@
# Platform selection only; decoder sources, flags and targets belong to avif.
include_guard(GLOBAL)
include("${CMAKE_CURRENT_LIST_DIR}/ImagePackages.cmake")
# dav1d is the default AV1 decoder and libaom the explicit oracle. DAV1D_DIR
# or KRYON_DAV1D_DIR select the pinned dav1d source; otherwise it comes from
# the same locked package graph as avif.
function(kryon_avif_decoder avif_dir aom_dir)
kryon_image_package(package avif)
include("${package}/native/ZiranAvif.cmake")
if(DEFINED DAV1D_DIR AND NOT DAV1D_DIR STREQUAL "")
set(dav1d_dir "${DAV1D_DIR}")
elseif(NOT "$ENV{KRYON_DAV1D_DIR}" STREQUAL "")
set(dav1d_dir "$ENV{KRYON_DAV1D_DIR}")
else()
kryon_ziran_package_path(dav1d_dir dav1d)
endif()
set(shared)
if(ARGV2 STREQUAL "BUILD_SHARED_BRIDGE" OR (NOT ANDROID AND NOT WIN32 AND NOT APPLE))
# Cairo lazily opens the same self-contained library as before.
set(shared BUILD_SHARED_BRIDGE SHARED_TARGET_NAME kryonavif)
endif()
ziran_avif_add_native(AVIF_SOURCE "${avif_dir}" AOM_SOURCE "${aom_dir}" DAV1D_SOURCE "${dav1d_dir}" ${shared})
endfunction()
+52
View File
@@ -0,0 +1,52 @@
# Resolve codec-owned build entry points through the ordinary package graph.
# Callers can pass KRYON_AVIF_PACKAGE_DIR / KRYON_WEBP_PACKAGE_DIR when building
# a renderer artifact from a consumer's locked dependency graph.
include_guard(GLOBAL)
# Locked checkout of any package or pinned source dependency in Kryon's graph.
function(kryon_ziran_package_path output name)
if(DEFINED ZIRAN_BIN AND NOT ZIRAN_BIN STREQUAL "")
set(ziran "${ZIRAN_BIN}")
elseif(NOT "$ENV{ZIRAN_BIN}" STREQUAL "")
set(ziran "$ENV{ZIRAN_BIN}")
elseif(DEFINED ZIRAN_DIR AND NOT ZIRAN_DIR STREQUAL "")
set(ziran "${ZIRAN_DIR}/build/bin/ziran")
elseif(NOT "$ENV{ZIRAN_TOOLCHAIN_ROOT}" STREQUAL "")
set(ziran "$ENV{ZIRAN_TOOLCHAIN_ROOT}/build/bin/ziran")
elseif(NOT "$ENV{ZIRAN_DIR}" STREQUAL "")
set(ziran "$ENV{ZIRAN_DIR}/build/bin/ziran")
elseif(NOT "$ENV{ZIRAN}" STREQUAL "")
set(ziran "$ENV{ZIRAN}")
else()
set(ziran ziran)
endif()
get_filename_component(project "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/.." ABSOLUTE)
set(locked --locked)
if(EXISTS "${project}/ziran.local.toml")
set(locked)
endif()
execute_process(COMMAND "${ziran}" pkg path "${name}" ${locked}
WORKING_DIRECTORY "${project}"
RESULT_VARIABLE status OUTPUT_VARIABLE directory
ERROR_VARIABLE diagnostic OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT status EQUAL 0)
message(FATAL_ERROR "Cannot resolve ${name} package: ${diagnostic}")
endif()
set(${output} "${directory}" PARENT_SCOPE)
endfunction()
function(kryon_image_package output name)
string(TOUPPER "${name}" upper)
set(selection "KRYON_${upper}_PACKAGE_DIR")
if(DEFINED ${selection} AND NOT "${${selection}}" STREQUAL "")
set(directory "${${selection}}")
elseif(NOT "$ENV{${selection}}" STREQUAL "")
set(directory "$ENV{${selection}}")
else()
kryon_ziran_package_path(directory "${name}")
endif()
if(NOT EXISTS "${directory}/ziran.toml")
message(FATAL_ERROR "No ${name} package at ${directory}; run ziran fetch")
endif()
set(${output} "${directory}" PARENT_SCOPE)
endfunction()
+142
View File
@@ -0,0 +1,142 @@
# Android NDK build helpers for Kryon apps.
#
# An app's droid/app/src/main/cpp/CMakeLists.txt generates its Ziran C sources
# and then uses these helpers for the parts every Kryon Android app shares:
#
# include("${KRYON_DIR}/cmake/KryonAndroid.cmake")
# kryon_android_reproducible_paths("${REPO_ROOT}") # before dependency targets
# kryon_android_codecs("${WEBP_DIR}" "${AVIF_DIR}" "${AOM_DIR}")
# add_library(main SHARED ${APP_SOURCES})
# kryon_android_app(main) # glue, size flags, system libs
#
# The helpers only set what is common; apps add their own definitions,
# include directories, and libraries to `main` as usual.
include_guard(GLOBAL)
include("${CMAKE_CURRENT_LIST_DIR}/WebP.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/AVIF.cmake")
set(KRYON_ANDROID_NATIVE_APP_GLUE_DIR
"${ANDROID_NDK}/sources/android/native_app_glue")
# Apply to every target in this directory and its children, including native
# dependencies. Debug paths enter the linker's build ID before Gradle strips
# the APK library; normalizing only the final app target is insufficient.
# Keep debug information and build IDs so retained crash symbols still match.
function(kryon_android_reproducible_paths source_root)
get_filename_component(source_root "${source_root}" ABSOLUTE)
# NDK clang accepts these flags for C/C++ and preprocessed assembly.
# NASM/Yasm use -f for their object format and cannot receive them.
add_compile_options(
"$<$<COMPILE_LANGUAGE:C,CXX,ASM>:-fdebug-compilation-dir=.>"
"$<$<COMPILE_LANGUAGE:C,CXX,ASM>:-ffile-prefix-map=${source_root}=.>"
"$<$<COMPILE_LANGUAGE:C,CXX,ASM>:-ffile-prefix-map=${ANDROID_NDK}=./ndk>"
"$<$<COMPILE_LANGUAGE:C,CXX,ASM>:-ffile-prefix-map=${CMAKE_BINARY_DIR}=./build/android>")
endfunction()
# Build the image codecs Kryon's platform-native Android host uses. Software
# presentation needs no graphics, audio, or renderer dependency.
function(kryon_android_codecs webp_dir)
if(NOT EXISTS "${webp_dir}/CMakeLists.txt")
message(FATAL_ERROR "No libwebp source at ${webp_dir}")
endif()
kryon_webp_decoder("${webp_dir}")
set(avif_dir "${ARGV1}")
set(aom_dir "${ARGV2}")
if(avif_dir STREQUAL "")
set(avif_dir "$ENV{KRYON_ANDROID_AVIF_DIR}")
endif()
if(aom_dir STREQUAL "")
set(aom_dir "$ENV{KRYON_ANDROID_AOM_DIR}")
endif()
kryon_avif_decoder("${avif_dir}" "${aom_dir}")
add_library(kryon_android_codecs INTERFACE)
target_link_libraries(kryon_android_codecs INTERFACE
kryonwebp ziran_avif::static)
endfunction()
# Turn a shared library into a Kryon NativeActivity payload: add the NDK's
# native_app_glue, optimize for speed, keep symbols hidden, garbage-collect unused
# sections, align for 16 KB page devices, route fopen() through Kryon's APK
# asset reader, retain native crash symbols, and link Android's system APIs.
function(kryon_android_app target)
if(NOT ZI2C_BIN)
find_program(ZI2C_BIN NAMES zi2c REQUIRED)
endif()
set(thread_source "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../src/backend/android_thread.zi")
set(thread_generated "${CMAKE_CURRENT_BINARY_DIR}/kryon-android-thread")
add_custom_command(
OUTPUT "${thread_generated}/android_thread.c" "${thread_generated}/android_thread.h"
COMMAND "${ZI2C_BIN}" --no-main
--root "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../src/backend"
-o "${thread_generated}" "${thread_source}"
DEPENDS "${thread_source}" "${ZI2C_BIN}"
VERBATIM)
# The NDK's glue is compiled from a copy in the build tree. Its own path
# carries the NDK's install location into the object and module names,
# which ThinLTO hashes into symbols, so builds on other machines differ.
set(glue_source "${CMAKE_CURRENT_BINARY_DIR}/kryon-native-app-glue/android_native_app_glue.c")
configure_file("${KRYON_ANDROID_NATIVE_APP_GLUE_DIR}/android_native_app_glue.c"
"${glue_source}" COPYONLY)
target_sources(${target} PRIVATE
"${thread_generated}/android_thread.c"
"${glue_source}")
# Only the NativeActivity-owned app thread receives this stack policy.
# The generated configurator calls libc normally; other thread creators retain
# their own attributes and defaults.
set_property(SOURCE "${glue_source}"
APPEND PROPERTY COMPILE_DEFINITIONS pthread_attr_setdetachstate=ConfigureNativeThread)
target_include_directories(${target} PRIVATE
"${KRYON_ANDROID_NATIVE_APP_GLUE_DIR}")
target_compile_definitions(${target} PRIVATE
PLATFORM_ANDROID ANDROID_BUILD=1 _DEFAULT_SOURCE _GNU_SOURCE
_FILE_OFFSET_BITS=64)
target_compile_options(${target} PRIVATE
-O2 -ffunction-sections -fdata-sections -fvisibility=hidden
-fno-omit-frame-pointer $<$<NOT:$<CONFIG:Debug>>:-g1>)
target_link_options(${target} PRIVATE
-Wl,--gc-sections
-Wl,-z,max-page-size=16384
-Wl,-z,common-page-size=16384
# Kryon serves fopen() from APK assets through __wrap_fopen.
-Wl,--wrap=fopen
-Wl,--wrap=fopen64)
# Gradle strips the packaged library. Keep this original, with line
# information, so native startup failures can be symbolicated.
# Imported scene shaders use EGL and GLES directly, including when the
# Android host itself presents through a software surface.
target_link_libraries(${target} PUBLIC android log atomic dl m EGL GLESv3)
endfunction()
# Adopt Kryon's canonical Android host for a shared-library target whose
# generated sources include the application's main and android_glue modules
# (created by scripts/android_scaffold.py). KRYON_ANDROID_HOST selects
# Kryon's own platform keyboard implementation; an application that supplies
# its own JNI glue, like one with a custom SetPlatformTextKeyboardVisible,
# must not call this. The library exposes Android's entry points and the
# notification JNI callbacks that Android resolves on receiver/service startup.
function(kryon_android_host target)
target_compile_definitions(${target} PRIVATE KRYON_ANDROID_HOST=1)
foreach(source IN LISTS ARGN)
get_filename_component(source_name "${source}" NAME)
if(source_name STREQUAL "main.c")
# Kryon's NativeActivity glue calls android_main directly. The
# scaffold's argv-style main remains the stable application ABI.
set_source_files_properties("${source}"
PROPERTIES COMPILE_OPTIONS "-ffreestanding")
elseif(source_name STREQUAL "android_glue.c" OR
source_name MATCHES "(^|_)(android_notifications|notification_push)\\.c$")
# The VM locates this exported entry before native methods are
# registered through it. Notification receivers and push services
# also locate their JNI callbacks after a cold process start.
# Package-generated sources carry an identity prefix.
set_source_files_properties("${source}"
PROPERTIES COMPILE_OPTIONS "-fvisibility=default")
endif()
endforeach()
target_link_options(${target} PRIVATE
"-Wl,--version-script,${CMAKE_CURRENT_FUNCTION_LIST_DIR}/libmain.map.txt"
"-Wl,--no-undefined-version")
set_property(TARGET ${target} APPEND PROPERTY LINK_DEPENDS
"${CMAKE_CURRENT_FUNCTION_LIST_DIR}/libmain.map.txt")
endfunction()
-116
View File
@@ -1,116 +0,0 @@
include_guard(GLOBAL)
function(kryon_generate_kry_sources out_sources out_include_dir)
set(options NO_MAIN)
set(one_value_args KRYON_DIR ROOT OUT_DIR TARGET)
set(multi_value_args SOURCES)
cmake_parse_arguments(KRYGEN "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN})
if(NOT KRYGEN_KRYON_DIR)
message(FATAL_ERROR "kryon_generate_kry_sources requires KRYON_DIR")
endif()
if(NOT KRYGEN_ROOT)
message(FATAL_ERROR "kryon_generate_kry_sources requires ROOT")
endif()
if(NOT KRYGEN_OUT_DIR)
message(FATAL_ERROR "kryon_generate_kry_sources requires OUT_DIR")
endif()
if(NOT KRYGEN_TARGET)
message(FATAL_ERROR "kryon_generate_kry_sources requires TARGET")
endif()
if(NOT KRYGEN_SOURCES)
message(FATAL_ERROR "kryon_generate_kry_sources requires SOURCES")
endif()
file(GLOB KRYGEN_K2C_SOURCES CONFIGURE_DEPENDS
"${KRYGEN_KRYON_DIR}/cmd/k2c/*.c"
"${KRYGEN_KRYON_DIR}/cmd/kir/*.c")
list(APPEND KRYGEN_K2C_SOURCES
"${KRYGEN_KRYON_DIR}/src/kry_std/kry_json.c")
file(GLOB KRYGEN_K2C_HEADERS CONFIGURE_DEPENDS
"${KRYGEN_KRYON_DIR}/cmd/k2c/*.h"
"${KRYGEN_KRYON_DIR}/cmd/kir/*.h")
list(APPEND KRYGEN_K2C_HEADERS "${KRYGEN_KRYON_DIR}/include/kry_json.h")
if(KRYON_HOST_CC)
set(KRYGEN_HOST_CC "${KRYON_HOST_CC}")
else()
foreach(krygen_host_cc_candidate
/usr/bin/cc
/bin/cc
/usr/bin/gcc
/usr/bin/clang
/usr/local/bin/cc
/usr/local/bin/gcc
/usr/local/bin/clang
/opt/homebrew/bin/cc
/opt/homebrew/bin/gcc
/opt/homebrew/bin/clang)
if(NOT KRYGEN_HOST_CC AND EXISTS "${krygen_host_cc_candidate}")
set(KRYGEN_HOST_CC "${krygen_host_cc_candidate}")
endif()
endforeach()
endif()
if(NOT KRYGEN_HOST_CC)
find_program(KRYGEN_HOST_CC
NAMES cc gcc clang
NO_CMAKE_FIND_ROOT_PATH)
endif()
if(NOT KRYGEN_HOST_CC)
message(FATAL_ERROR "kryon_generate_kry_sources requires a host C compiler; set KRYON_HOST_CC")
endif()
set(KRYGEN_K2C "${CMAKE_BINARY_DIR}/kryon-host-tools/k2c")
set(krygen_generated_sources)
set(krygen_generated_headers)
set(krygen_command_sources)
foreach(kry_source ${KRYGEN_SOURCES})
file(RELATIVE_PATH kry_rel "${KRYGEN_ROOT}" "${kry_source}")
list(APPEND krygen_command_sources "${kry_rel}")
get_filename_component(kry_rel_dir "${kry_rel}" DIRECTORY)
get_filename_component(kry_name "${kry_rel}" NAME_WE)
list(APPEND krygen_generated_sources "${KRYGEN_OUT_DIR}/${kry_rel_dir}/${kry_name}.c")
list(APPEND krygen_generated_headers "${KRYGEN_OUT_DIR}/${kry_rel_dir}/${kry_name}.h")
endforeach()
set(krygen_flags)
if(KRYGEN_NO_MAIN)
list(APPEND krygen_flags --no-main)
endif()
add_custom_command(
OUTPUT
${krygen_generated_sources}
${krygen_generated_headers}
"${KRYGEN_OUT_DIR}/kryon_project.c"
"${KRYGEN_OUT_DIR}/kryon_project.h"
COMMAND ${CMAKE_COMMAND} -E remove_directory "${KRYGEN_OUT_DIR}"
COMMAND ${CMAKE_COMMAND} -E make_directory "${KRYGEN_OUT_DIR}"
COMMAND "${KRYGEN_K2C}" ${krygen_flags} --root "${KRYGEN_ROOT}" -o "${KRYGEN_OUT_DIR}" ${krygen_command_sources}
DEPENDS ${KRYGEN_SOURCES} "${KRYGEN_K2C}"
WORKING_DIRECTORY "${KRYGEN_ROOT}"
VERBATIM
)
add_custom_command(
OUTPUT "${KRYGEN_K2C}"
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/kryon-host-tools"
COMMAND "${KRYGEN_HOST_CC}" -Wall -Wextra -O2
-I${KRYGEN_KRYON_DIR}/include
-I${KRYGEN_KRYON_DIR}/cmd/kir
-I${KRYGEN_KRYON_DIR}/cmd/k2c
-o "${KRYGEN_K2C}"
${KRYGEN_K2C_SOURCES}
DEPENDS ${KRYGEN_K2C_SOURCES} ${KRYGEN_K2C_HEADERS}
VERBATIM
)
add_custom_target("${KRYGEN_TARGET}" DEPENDS
${krygen_generated_sources}
${krygen_generated_headers}
"${KRYGEN_OUT_DIR}/kryon_project.c"
"${KRYGEN_OUT_DIR}/kryon_project.h"
)
set(${out_sources} ${krygen_generated_sources} PARENT_SCOPE)
set(${out_include_dir} "${KRYGEN_OUT_DIR}" PARENT_SCOPE)
endfunction()
+9
View File
@@ -0,0 +1,9 @@
# Keep the renderer's archive name while consuming the package-owned recipe.
include_guard(GLOBAL)
include("${CMAKE_CURRENT_LIST_DIR}/ImagePackages.cmake")
function(kryon_webp_decoder webp_dir)
kryon_image_package(package webp)
include("${package}/native/WebP.cmake")
ziran_webp_decoder(kryonwebp "${webp_dir}")
endfunction()
+4
View File
@@ -0,0 +1,4 @@
cmake_minimum_required(VERSION 3.22)
project(KryonAVIF C CXX)
include(${CMAKE_CURRENT_LIST_DIR}/../AVIF.cmake)
kryon_avif_decoder("${AVIF_DIR}" "${AOM_DIR}")
+9
View File
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.22)
project(KryonDesktopCodecs C CXX)
# Codecs only: platform-native Android presentation links no renderer.
include("${CMAKE_CURRENT_LIST_DIR}/../WebP.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/../AVIF.cmake")
kryon_webp_decoder("${WEBP_DIR}")
kryon_avif_decoder("${AVIF_DIR}" "${AOM_DIR}" BUILD_SHARED_BRIDGE)
include("${AUDIO_DIR}/native/AudioCodecs.cmake")
ziran_audio_codecs("${OPUS_DIR}" "${SAMPLERATE_DIR}")
+12
View File
@@ -0,0 +1,12 @@
{
global:
# Android loads the NativeActivity entry and registers JNI methods.
ANativeActivity_onCreate;
android_main;
JNI_OnLoad;
# Receivers and optional push services can start without an Activity.
Java_org_kryonlabs_notifications_NotificationReceiver_*;
Java_org_kryonlabs_notifications_push_*;
local:
*;
};
+6
View File
@@ -0,0 +1,6 @@
# Standalone build of Kryon's WebP codec archive for native desktop hosts and
# renderer artifacts: cmake -S cmake/webp -B BUILD -DWEBP_DIR=LIBWEBP_SOURCE
cmake_minimum_required(VERSION 3.22)
project(KryonWebP C)
include(${CMAKE_CURRENT_LIST_DIR}/../WebP.cmake)
kryon_webp_decoder("${WEBP_DIR}")
-240
View File
@@ -1,240 +0,0 @@
#include "k2b_atlas.h"
#define STB_TRUETYPE_IMPLEMENTATION
#include "../../vendor/raylib/src/external/stb_truetype.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ATLAS_W 512
static void
put_u16(unsigned char *p, unsigned v)
{
p[0] = (unsigned char)v;
p[1] = (unsigned char)(v >> 8);
}
static void
put_u32(unsigned char *p, unsigned long v)
{
p[0] = (unsigned char)v;
p[1] = (unsigned char)(v >> 8);
p[2] = (unsigned char)(v >> 16);
p[3] = (unsigned char)(v >> 24);
}
/* Layout: "KFA1" u32 | size_count u16 | per-size 16-byte records
* (px u16 | glyphs u16 | w u16 | h u16 | table_off u32 | pixels_off u32),
* per-glyph 18-byte records (cp u32 | x,y,w,h u16 | xoff,yoff i16 |
* adv u16 in 1/256 px fixed point), then per-size RGBA8 white-on-alpha
* bitmaps.
*
* Rasterization is raylib-identical: per-glyph
* stbtt_GetCodepointBitmap at stbtt_ScaleForPixelHeight(size) with
* advances from stbtt_GetCodepointHMetrics * scale — the same calls
* rtext.c LoadFontData(FONT_DEFAULT) makes, so glyph coverage matches
* the native renderer bit-for-bit. Glyphs row-pack first-fit. */
unsigned char *
k2b_bake_atlas(const char *ttf_path, const unsigned int *codepoints,
int cp_count, const int *sizes, int size_count,
unsigned *out_len)
{
unsigned char *ttf = NULL;
long ttf_len;
FILE *f;
stbtt_fontinfo font;
unsigned char *buf = NULL;
unsigned buf_cap;
unsigned buf_len;
int s;
if(out_len != NULL)
*out_len = 0;
if(ttf_path == NULL || codepoints == NULL || cp_count <= 0 ||
sizes == NULL || size_count <= 0)
return NULL;
f = fopen(ttf_path, "rb");
if(f == NULL)
return NULL;
fseek(f, 0, SEEK_END);
ttf_len = ftell(f);
fseek(f, 0, SEEK_SET);
ttf = malloc((size_t)ttf_len);
if(ttf == NULL || fread(ttf, 1, (size_t)ttf_len, f) != (size_t)ttf_len) {
fclose(f);
free(ttf);
return NULL;
}
fclose(f);
if(!stbtt_InitFont(&font, ttf, 0)) {
free(ttf);
return NULL;
}
buf_len = 6 + (unsigned)size_count * 16;
buf_cap = buf_len + 4096;
buf = malloc(buf_cap);
if(buf == NULL) {
free(ttf);
return NULL;
}
put_u32(buf, 0x3141464Bu); /* "KFA1" */
put_u16(buf + 4, (unsigned)size_count);
for(s = 0; s < size_count; s++) {
int px = sizes[s];
float scale = stbtt_ScaleForPixelHeight(&font, (float)px);
int ascent = 0;
int descent = 0;
int line_gap = 0;
/* rtext.c line 730: offsetY += (int)(ascent*scale) — raylib's
* glyph offset is line-top-relative, not baseline-relative */
stbtt_GetFontVMetrics(&font, &ascent, &descent, &line_gap);
unsigned char *raw_px;
unsigned rec_bytes = (unsigned)cp_count * 18;
unsigned table_off;
unsigned pixels_off;
int height;
int i;
/* rec is recomputed after every realloc of buf */
{
int total_h = 1;
int row_h = 0;
int cur_x = 0;
for(i = 0; i < cp_count; i++) {
int x0 = 0;
int y0 = 0;
int x1 = 0;
int y1 = 0;
int w;
int h;
stbtt_GetCodepointBitmapBox(&font, (int)codepoints[i], scale,
scale, &x0, &y0, &x1, &y1);
w = x1 - x0;
h = y1 - y0;
if(w < 0)
w = 0;
if(h < 0)
h = 0;
if(cur_x + w > ATLAS_W) {
total_h += row_h > 0 ? row_h : 1;
row_h = 0;
cur_x = 0;
}
cur_x += w + 1;
if(h > row_h)
row_h = h;
}
height = total_h + row_h + 1;
}
while(buf_len + rec_bytes + (unsigned)ATLAS_W * height * 4 >
buf_cap) {
unsigned char *nb = realloc(buf, buf_cap * 2);
if(nb == NULL)
break;
buf = nb;
buf_cap *= 2;
}
if(buf_len + rec_bytes + (unsigned)ATLAS_W * height * 4 > buf_cap)
continue;
raw_px = calloc((size_t)ATLAS_W * height, 1);
if(raw_px == NULL)
continue;
table_off = buf_len;
{
int row_y = 0;
int row_h = 0;
int cur_x = 0;
unsigned char *tab = buf + table_off;
for(i = 0; i < cp_count; i++) {
int w = 0;
int h = 0;
int xoff = 0;
int yoff = 0;
int advance = 0;
int lsb = 0;
unsigned char *bm;
unsigned char *g = tab + (unsigned)i * 18;
bm = stbtt_GetCodepointBitmap(&font, scale, scale,
(int)codepoints[i], &w, &h,
&xoff, &yoff);
if(cur_x + w > ATLAS_W) {
row_y += row_h > 0 ? row_h : 1;
row_h = 0;
cur_x = 0;
}
if(w > 0 && h > 0 && bm != NULL && w <= ATLAS_W &&
row_y + h <= height && cur_x + w <= ATLAS_W) {
int gy;
for(gy = 0; gy < h; gy++)
memcpy(raw_px + (size_t)(row_y + gy) * ATLAS_W +
cur_x, bm + (size_t)gy * w, (size_t)w);
}
stbtt_FreeBitmap(bm, NULL);
stbtt_GetCodepointHMetrics(&font, (int)codepoints[i],
&advance, &lsb);
put_u32(g, codepoints[i]);
put_u16(g + 4, (unsigned short)cur_x);
put_u16(g + 6, (unsigned short)row_y);
put_u16(g + 8, (unsigned short)(w > 0 ? w : 0));
put_u16(g + 10, (unsigned short)(h > 0 ? h : 0));
put_u16(g + 12, (unsigned short)(short)xoff);
put_u16(g + 14,
(unsigned short)(short)(yoff +
(int)((float)ascent * scale)));
put_u16(g + 16, (unsigned short)(int)((float)advance *
scale * 256.0f + 0.5f));
cur_x += w + 1;
if(h > row_h)
row_h = h;
}
buf_len += rec_bytes;
}
pixels_off = buf_len;
{
unsigned char *rgba = buf + pixels_off;
long n = (long)ATLAS_W * height;
long k;
for(k = 0; k < n; k++) {
rgba[k * 4 + 0] = 0xff;
rgba[k * 4 + 1] = 0xff;
rgba[k * 4 + 2] = 0xff;
rgba[k * 4 + 3] = raw_px[k];
}
buf_len += (unsigned)n * 4;
}
free(raw_px);
{
unsigned char *rec = buf + 6 + (unsigned)s * 16;
put_u16(rec, (unsigned)px);
put_u16(rec + 2, (unsigned)cp_count);
put_u16(rec + 4, ATLAS_W);
put_u16(rec + 6, (unsigned)height);
put_u16(rec + 2, (unsigned)cp_count);
put_u16(rec + 4, ATLAS_W);
put_u16(rec + 6, (unsigned)height);
put_u32(rec + 8, table_off);
put_u32(rec + 12, pixels_off);
}
}
free(ttf);
if(buf_len <= 6 + (unsigned)size_count * 16) {
free(buf);
return NULL;
}
if(out_len != NULL)
*out_len = buf_len;
return buf;
}
-19
View File
@@ -1,19 +0,0 @@
#ifndef K2B_ATLAS_H
#define K2B_ATLAS_H
#include <stddef.h>
/* Bake a KFA1 glyph atlas (cartridge asset kind 1) from a TTF for the
* given charset and pixel sizes. Returns malloc'd bytes and length, or
* NULL when the font can't be loaded. Layout:
* u32 'KFA1' | u16 size_count
* per size: u16 px, u16 glyph_count, u16 w, u16 h, u32 table_off,
* u32 pixels_off (offsets from buffer start)
* glyph (16B): u32 cp | u16 x,y,w,h | i16 xoff,yoff | u16 advance
* RGBA8 pixels, white with alpha coverage. */
unsigned char *k2b_bake_atlas(const char *ttf_path,
const unsigned int *codepoints, int cp_count,
const int *sizes, int size_count,
unsigned *out_len);
#endif
-3672
View File
File diff suppressed because it is too large. Load diff
-23
View File
@@ -1,23 +0,0 @@
#include "k2b_stb.h"
#define STB_IMAGE_IMPLEMENTATION
#define STBI_NO_PSD
#define STBI_NO_TGA
#define STBI_NO_GIF
#define STBI_NO_HDR
#define STBI_NO_PIC
#define STBI_NO_PNM
#include "../../vendor/raylib/src/external/stb_image.h"
#include <stdlib.h>
int
k2b_decode_image(const char *file, unsigned char **rgba, int *w, int *h)
{
int n;
if(file == NULL || rgba == NULL || w == NULL || h == NULL)
return -1;
*rgba = stbi_load(file, w, h, &n, 4);
return *rgba != NULL ? 0 : -1;
}
-10
View File
@@ -1,10 +0,0 @@
#ifndef K2B_STB_H
#define K2B_STB_H
/* Image decoding for cartridge embedding, on the stb_image vendored with
* raylib. Returns 0 and fills *rgba (malloc'd, top-down RGBA8 rows) on
* success. */
int k2b_decode_image(const char *file, unsigned char **rgba, int *w, int *h);
#endif
-181
View File
@@ -1,181 +0,0 @@
/*
* k2b util — small path/string helpers used by the codegen.
*/
#include "krb.h"
#include "kir.h"
#include <ctype.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <errno.h>
void
die(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
fprintf(stderr, "k2b: ");
vfprintf(stderr, fmt, ap);
fputc('\n', stderr);
va_end(ap);
exit(1);
}
void
path_join(char *dst, size_t dst_size, const char *a, const char *b)
{
if(a == NULL || a[0] == '\0')
snprintf(dst, dst_size, "%s", b);
else if(a[strlen(a) - 1] == '/')
snprintf(dst, dst_size, "%s%s", a, b);
else
snprintf(dst, dst_size, "%s/%s", a, b);
}
void
mkdir_parent(const char *path)
{
char tmp[KIR_PATH_MAX];
size_t i;
snprintf(tmp, sizeof(tmp), "%s", path);
for(i = 1; i < strlen(tmp); i++) {
if(tmp[i] != '/')
continue;
tmp[i] = '\0';
if(mkdir(tmp, 0755) != 0 && errno != EEXIST)
die("%s: mkdir failed: %s", tmp, strerror(errno));
tmp[i] = '/';
}
}
void
header_guard(char *dst, size_t dst_size, const char *rel)
{
size_t n = 0;
if(dst_size > 4) {
dst[n++] = 'K';
dst[n++] = '2';
dst[n++] = 'B';
dst[n++] = '_';
}
for(const char *p = rel; *p != '\0' && n + 1 < dst_size; p++) {
char c = *p;
if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
(c >= '0' && c <= '9'))
dst[n++] = (c >= 'a' && c <= 'z') ? (char)(c - 'a' + 'A') : c;
else
dst[n++] = '_';
}
dst[n] = '\0';
}
void
strip_kry_ext(char *dst, size_t dst_size, const char *path)
{
size_t len;
if(path == NULL) {
if(dst_size > 0)
dst[0] = '\0';
return;
}
len = strlen(path);
if(len > 4 && strcmp(path + len - 4, ".kry") == 0)
len -= 4;
if(len >= dst_size)
len = dst_size - 1;
memcpy(dst, path, len);
dst[len] = '\0';
}
void
replace_path_basename(char *dst, size_t dst_size, const char *path,
const char *base)
{
const char *slash = NULL;
size_t dir_len;
if(dst_size == 0)
return;
for(const char *p = path; p != NULL && *p != '\0'; p++) {
if(*p == '/' || *p == '\\')
slash = p;
}
if(slash == NULL) {
snprintf(dst, dst_size, "%s", base);
return;
}
dir_len = (size_t)(slash - path + 1);
if(dir_len >= dst_size)
dir_len = dst_size - 1;
memcpy(dst, path, dir_len);
dst[dir_len] = '\0';
snprintf(dst + dir_len, dst_size - dir_len, "%s", base);
}
/* Path relative to root. Handles the common cases (path under root, or path
* already relative); does not fully normalize, which is enough for emitting
* cartridge output paths next to their source. */
const char *
relative_path(const char *root, const char *path)
{
static char rel[KIR_PATH_MAX];
size_t n;
if(root == NULL || root[0] == '\0')
return path;
n = strlen(root);
if(strncmp(path, root, n) == 0 && path[n] == '/')
snprintf(rel, sizeof(rel), "%s", path + n + 1);
else
snprintf(rel, sizeof(rel), "%s", path);
return rel;
}
int
is_ident_text(const char *text)
{
if(text == NULL || text[0] == '\0')
return 0;
if(!(isalpha((unsigned char)text[0]) || text[0] == '_'))
return 0;
for(const char *p = text + 1; *p != '\0'; p++) {
if(!(isalnum((unsigned char)*p) || *p == '_'))
return 0;
}
return 1;
}
void
c_string_literal(char *dst, size_t dst_size, const char *src)
{
size_t n = 0;
if(dst_size == 0)
return;
dst[n++] = '"';
for(const char *p = src != NULL ? src : ""; *p != '\0' && n + 2 < dst_size; p++) {
if(*p == '"' || *p == '\\') {
if(n + 2 >= dst_size)
break;
dst[n++] = '\\';
dst[n++] = *p;
} else if(*p == '\n') {
if(n + 2 >= dst_size)
break;
dst[n++] = '\\';
dst[n++] = 'n';
} else {
dst[n++] = *p;
}
}
if(n + 1 < dst_size)
dst[n++] = '"';
dst[n] = '\0';
}
-101
View File
@@ -1,101 +0,0 @@
/*
* k2b - .kry -> .krb cartridge compiler. Shares the Kir frontend with k2c:
* every .kry parses into a KirProgram (kir_parse.c), then lowers to a .krb
* cartridge + C host (k2b_krb.c). One frontend, two backends.
*/
#include "kir.h"
#include "kir_parse.h"
#include "kir_laws.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void write_krb(const KirModule *m, const char *root, const char *out_dir,
int no_main, int allow_unsupported);
static int
validate_asserts(const KirModule *m)
{
for(int i = 0; i < m->assert_count; i++) {
const KirAssert *a = &m->asserts[i];
if(a->guard[0] != '\0') {
fprintf(stderr,
"k2b: %s:%d: guarded #assert is not supported by KRB: %s\n",
a->span.path, a->span.line, a->message);
return 0;
}
if(!a->known) {
fprintf(stderr,
"k2b: %s:%d: unresolved #assert is not supported by KRB: %s\n",
a->span.path, a->span.line, a->condition);
return 0;
}
if(!a->value) {
fprintf(stderr, "k2b: %s:%d: #assert failed: %s\n",
a->span.path, a->span.line, a->message);
return 0;
}
}
return 1;
}
static void
usage(void)
{
fprintf(stderr, "usage: k2b [--no-main] [--allow-unsupported] --root DIR -o DIR file.kry ...\n");
}
int
main(int argc, char **argv)
{
const char *root = NULL;
const char *out_dir = NULL;
int no_main = 0;
int allow_unsupported = 0;
int i;
for(i = 1; i < argc; i++) {
if(strcmp(argv[i], "--root") == 0 && i + 1 < argc) {
root = argv[++i];
} else if(strcmp(argv[i], "-o") == 0 && i + 1 < argc) {
out_dir = argv[++i];
} else if(strcmp(argv[i], "--no-main") == 0) {
no_main = 1;
} else if(strcmp(argv[i], "--allow-unsupported") == 0) {
allow_unsupported = 1;
} else if(argv[i][0] == '-') {
usage();
return 1;
} else {
break;
}
}
if(root == NULL || out_dir == NULL || i >= argc) {
usage();
return 1;
}
for(; i < argc; i++) {
KirProgram *prog = kir_parse_file(argv[i], root);
if(prog == NULL) {
fprintf(stderr, "k2b: failed to parse %s\n", argv[i]);
return 1;
}
if(!KirCheckLaws(&prog, 1)) {
KirProgramFree(prog);
return 1;
}
for(int m = 0; m < prog->module_count; m++) {
if(!validate_asserts(&prog->modules[m])) {
KirProgramFree(prog);
return 1;
}
write_krb(&prog->modules[m], root, out_dir, no_main,
allow_unsupported);
}
KirProgramFree(prog);
}
return 0;
}
-1964
View File
File diff suppressed because it is too large. Load diff
-37
View File
@@ -1,37 +0,0 @@
#ifndef K2C_LOWER_H
#define K2C_LOWER_H
#include "kir.h"
/* Cross-module symbol table: for each parsed module (by its slash-path),
* every function's .kry name -> full C name. Built by main after parsing all
* inputs; used to resolve alias-qualified calls (start.draw_start_page(...)
* -> ide_start_page_draw_start_page_kry_draw(...)). */
typedef struct K2cModuleSyms {
char module_stem[KIR_PATH_MAX]; /* source path minus .kry */
char module_slash[KIR_PATH_MAX];
struct {
char kry[KIR_NAME_MAX];
char c[KIR_NAME_MAX * 3];
} fns[256];
int fn_count;
} K2cModuleSyms;
/* Lower a KirProgram to C source (.c/.h). restab/restab_count resolve
* cross-module calls; pass NULL/0 to resolve same-module only. */
void k2c_lower(const KirProgram *program, const char *root,
const char *out_dir, const K2cModuleSyms *restab,
int restab_count);
/* Build the symbol table entry for one program into out. */
void k2c_build_syms(const KirProgram *program, K2cModuleSyms *out);
/* Full C name for a function (module prefix, colon naming, _kry_draw). */
void k2c_function_c_name(const KirModule *m, const KirFunction *fn,
char *dst, size_t dst_size);
/* k2c_project.c — kryon_project.h/.c (app-host ABI) after all files lower. */
void k2c_write_project(KirProgram *const *progs, int prog_count,
const char *root, const char *out_dir, int no_main);
#endif
-1801
View File
File diff suppressed because it is too large. Load diff
-42
View File
@@ -1,42 +0,0 @@
#ifndef K2C_PLAN9_H
#define K2C_PLAN9_H
/* Post-lowering pass that makes k2c output safe for the native Plan 9
* compilers (8c has no __auto_type, no multi-designator compound
* literals, and no declarations inside for()). Only runs under --plan9;
* the default output is byte-identical to before.
*
* The pass is purely syntactic: types are recovered from cast-literal
* expressions or from a return-type map built by scanning the project's
* headers (--include-dir), the same way the kryon surface declares
* single-line prototypes. */
/* Add a directory scanned (recursively, .h files) for prototypes when
* resolving __auto_type initializers. Call before k2c_lower. */
void k2c_plan9_add_include_dir(const char *dir);
/* Enable --plan9 output post-processing (off by default; the default
* output is unchanged). */
void k2c_plan9_set_enabled(int enabled);
int k2c_plan9_enabled(void);
/* Rewrite one generated C source for 8c. Returns a malloc'd buffer; the
* caller frees. Returns NULL on out-of-memory (caller keeps original). */
char *k2c_plan9_rewrite(const char *text);
/* Rewrite a generated file in place when the plan9 pass is enabled
* (weak-declaration exposure for project files, then the generic pass).
* Returns 0 on success. */
int k2c_plan9_rewrite_file(const char *path, int is_project);
/* Number of __auto_type declarations left unresolved by the last
* k2c_plan9_rewrite call (reported once per run by main). */
int k2c_plan9_unresolved(void);
/* Drop the __GNUC__ guard around the weak app-lifecycle declarations in
* generated project files: the native cpp does not define __GNUC__, so
* the guarded block would compile out and leave the calls without
* prototypes. */
char *k2c_plan9_rewrite_project(const char *text);
#endif
-616
View File
@@ -1,616 +0,0 @@
/*
* k2c_project.c — emit kryon_project.h/.c after all files lower. The
* app-host ABI (CreateAppHost/DestroyAppHost + route table) consumed by
* the preview tool and IDE host builds. Routes auto-collect from #ui
* functions. Explicit route{} blocks supply route id/title/group metadata
* when present.
*/
#include "k2c_lower.h"
#include "k2c_plan9.h"
#include "kir.h"
#include "kir_style_imports.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
typedef struct K2cRoute {
char id[KIR_NAME_MAX];
char title[KIR_NAME_MAX];
char group[KIR_NAME_MAX];
char source_path[KIR_PATH_MAX];
const KirModule *m;
const KirFunction *fn;
} K2cRoute;
#define K2C_ROUTE_MAX 512
static const KirFunction *
find_ui_function(const KirModule *mod, const char *name)
{
if(mod == NULL || name == NULL || name[0] == '\0')
return NULL;
for(int i = 0; i < mod->function_count; i++) {
const KirFunction *fn = &mod->functions[i];
if(fn->is_public && fn->is_ui && strcmp(fn->name, name) == 0)
return fn;
}
return NULL;
}
static int
function_has_explicit_route(const KirModule *mod, const KirFunction *fn)
{
if(mod == NULL || fn == NULL)
return 0;
for(int i = 0; i < mod->route_count; i++) {
if(strcmp(mod->routes[i].page, fn->name) == 0)
return 1;
}
return 0;
}
static void
mkdir_parent_local(const char *path)
{
char tmp[KIR_PATH_MAX];
size_t i;
snprintf(tmp, sizeof(tmp), "%s", path);
for(i = 1; i < strlen(tmp); i++) {
if(tmp[i] == '/') {
tmp[i] = '\0';
mkdir(tmp, 0755);
tmp[i] = '/';
}
}
}
static void
c_str(char *dst, size_t dst_size, const char *src)
{
size_t n = 0;
dst[n++] = '"';
for(const char *p = src != NULL ? src : "";
*p != '\0' && n + 3 < dst_size; p++) {
if(*p == '"' || *p == '\\') {
dst[n++] = '\\';
dst[n++] = *p;
} else if(*p == '\n') {
dst[n++] = '\\';
dst[n++] = 'n';
} else {
dst[n++] = *p;
}
}
if(n < dst_size)
dst[n++] = '"';
dst[n] = '\0';
}
static void
emit_c_string_literal(FILE *out, const char *src)
{
fputc('"', out);
for(const unsigned char *p = (const unsigned char *)(src != NULL ? src : "");
*p != '\0'; p++) {
if(*p == '"' || *p == '\\')
fprintf(out, "\\%c", *p);
else if(*p == '\n')
fputs("\\n", out);
else if(*p == '\r')
fputs("\\r", out);
else if(*p == '\t')
fputs("\\t", out);
else if(*p < 0x20)
fprintf(out, "\\x%02x", *p);
else
fputc(*p, out);
}
fputc('"', out);
}
static void
emit_style_registration(FILE *out, KirProgram *const *progs, int prog_count,
const char *root)
{
int emitted = 0;
for(int i = 0; i < prog_count; i++) {
const KirProgram *prog = progs[i];
if(prog == NULL)
continue;
for(int m = 0; m < prog->module_count; m++) {
const KirModule *mod = &prog->modules[m];
for(int s = 0; s < mod->style_import_count; s++) {
const KirStyleImport *style = &mod->style_imports[s];
char *source;
if(!emitted) {
fprintf(out, "static void\nkryon_project_register_styles(void)\n{\n");
emitted = 1;
}
if(style->kind == KIR_STYLE_IMPORT_BUILTIN &&
KirStyleImportIsBuiltIn(style->target)) {
fprintf(out, " EnsureBuiltInStylePacks();\n");
fprintf(out, " SetActiveStylePack(");
emit_c_string_literal(out, style->target);
fprintf(out, ");\n");
continue;
}
source = KirReadStyleImportSource(mod, root, style);
if(source == NULL) {
fprintf(stderr, "%s:%d: unable to resolve #style %s\n",
style->span.path, style->span.line, style->target);
continue;
}
fprintf(out, " if(RegisterStylePackSource(");
emit_c_string_literal(out, source);
fprintf(out, ", ");
emit_c_string_literal(out,
style->alias[0] != '\0' ? style->alias : style->target);
fprintf(out, ", \"\"))\n");
fprintf(out, " SetActiveStylePack(");
emit_c_string_literal(out,
style->alias[0] != '\0' ? style->alias : style->target);
fprintf(out, ");\n");
free(source);
}
}
}
if(emitted)
fprintf(out, "}\n\n");
else
fprintf(out, "static void\nkryon_project_register_styles(void)\n{\n}\n\n");
}
static int
function_is_implicit_screen(const KirFunction *fn)
{
const char *args = fn->args;
const char *colon;
const char *type;
const char *end;
size_t length;
if(args[0] == '\0')
return 1;
/* Only a single viewport Rectangle is callable from the generated
* route wrapper. Accept 'viewport: Rectangle' and C-style
* 'Rectangle viewport'; reject custom props and multi-arg helpers. */
if(strchr(args, ',') != NULL)
return 0;
colon = strrchr(args, ':');
if(colon != NULL) {
type = colon + 1;
} else {
type = args;
while(*type != '\0' && *type != ' ')
type++;
}
while(*type == ' ' || *type == '*')
type++;
end = type + strlen(type);
while(end > type && (end[-1] == ' ' || end[-1] == '*'))
end--;
length = (size_t)(end - type);
return length == 9 && strncmp(type, "Rectangle", 9) == 0;
}
static int
collect_routes(KirProgram *const *progs, int prog_count,
K2cRoute *routes, int max_routes)
{
int count = 0;
for(int i = 0; i < prog_count; i++) {
const KirProgram *prog = progs[i];
if(prog == NULL)
continue;
for(int m = 0; m < prog->module_count; m++) {
const KirModule *mod = &prog->modules[m];
for(int j = 0; j < mod->route_count; j++) {
const KirRoute *route = &mod->routes[j];
const KirFunction *fn = find_ui_function(mod, route->page);
if(fn == NULL) {
fprintf(stderr, "%s:%d: route `%s` references missing #ui page `%s`\n",
route->span.path, route->span.line,
route->id, route->page);
continue;
}
if(count >= max_routes)
return count;
snprintf(routes[count].id, sizeof(routes[0].id), "%s",
route->id);
snprintf(routes[count].title, sizeof(routes[0].title), "%s",
route->title[0] != '\0' ? route->title : route->id);
snprintf(routes[count].group, sizeof(routes[0].group), "%s",
route->group[0] != '\0' ? route->group : "Project");
snprintf(routes[count].source_path,
sizeof(routes[0].source_path), "%s",
mod->source_path);
routes[count].m = mod;
routes[count].fn = fn;
count++;
}
for(int j = 0; j < mod->function_count; j++) {
const KirFunction *fn = &mod->functions[j];
if(!fn->is_public || !fn->is_ui || fn->name[0] == '\0')
continue;
/* Implicit routes must be callable screens: no arguments or
* a single viewport Rectangle. Widget helpers declared #ui
* with their own props struct stay out of the route table;
* the generated wrapper could never build their arguments. */
if(!function_is_implicit_screen(fn))
continue;
if(function_has_explicit_route(mod, fn))
continue;
if(count >= max_routes)
return count;
snprintf(routes[count].id, sizeof(routes[0].id), "%s",
fn->name);
snprintf(routes[count].title, sizeof(routes[0].title), "%s",
fn->name);
snprintf(routes[count].group, sizeof(routes[0].group),
"Project");
snprintf(routes[count].source_path,
sizeof(routes[0].source_path), "%s",
mod->source_path);
routes[count].m = mod;
routes[count].fn = fn;
count++;
}
}
}
return count;
}
void
k2c_write_project(KirProgram *const *progs, int prog_count,
const char *root, const char *out_dir, int no_main)
{
K2cRoute routes[K2C_ROUTE_MAX];
char path[KIR_PATH_MAX];
const KirModule *appmod = NULL;
FILE *out;
int count;
(void)root;
if(progs == NULL || prog_count <= 0)
return;
count = collect_routes(progs, prog_count, routes, K2C_ROUTE_MAX);
/* the one app{} module (for main()) */
for(int i = 0; i < prog_count && appmod == NULL; i++) {
if(progs[i] == NULL)
continue;
for(int m = 0; m < progs[i]->module_count; m++)
if(progs[i]->modules[m].app.has_app) {
appmod = &progs[i]->modules[m];
break;
}
}
/* --- kryon_project.h --- */
snprintf(path, sizeof(path), "%s/kryon_project.h", out_dir);
mkdir_parent_local(path);
out = fopen(path, "wb");
if(out == NULL)
return;
fprintf(out, "/* Generated by k2c from project Kry files. */\n");
fprintf(out, "#ifndef K_KRYON_PROJECT_H\n#define K_KRYON_PROJECT_H\n\n");
for(int i = 0; i < prog_count; i++) {
const KirProgram *prog = progs[i];
if(prog == NULL)
continue;
for(int m = 0; m < prog->module_count; m++) {
const KirModule *mod = &prog->modules[m];
char stem[KIR_PATH_MAX];
size_t n = strlen(mod->source_path);
if(n > 4 && strcmp(mod->source_path + n - 4, ".kry") == 0)
n -= 4;
if(n >= sizeof(stem))
n = sizeof(stem) - 1;
memcpy(stem, mod->source_path, n);
stem[n] = '\0';
fprintf(out, "#include \"%s.h\"\n", stem);
}
}
fprintf(out, "\n#endif\n");
fclose(out);
if(count <= 0)
return;
/* --- kryon_project.c --- */
snprintf(path, sizeof(path), "%s/kryon_project.c", out_dir);
out = fopen(path, "wb");
if(out == NULL)
return;
fprintf(out, "/* Generated by k2c from project Kry files. */\n");
fprintf(out, "#include \"kryon_project.h\"\n");
fprintf(out, "#include \"app_runtime.h\"\n");
fprintf(out, "#include \"ui_style_sheet.h\"\n");
fprintf(out, "#include \"web.h\"\n");
if(appmod != NULL && appmod->app.font_examples)
fprintf(out, "#include \"kryon_example_font.h\"\n");
fprintf(out, "\n");
emit_style_registration(out, progs, prog_count, root);
fprintf(out, "#if defined(__GNUC__) || defined(__clang__)\n");
fprintf(out, "void *CreateApp(const char *project_path) __attribute__((weak));\n");
fprintf(out, "void DestroyApp(void *app) __attribute__((weak));\n");
fprintf(out, "void ApplyRoute(void *app, const AppRouteInfo *route) __attribute__((weak));\n");
fprintf(out, "void BeginScreenDraw(void *app, Rectangle viewport) __attribute__((weak));\n");
fprintf(out, "#endif\n\n");
for(int i = 0; i < count; i++) {
char cname[KIR_NAME_MAX * 3];
char wrapper[64];
snprintf(wrapper, sizeof(wrapper), "kryon_project_draw_%d", i);
k2c_function_c_name(routes[i].m, routes[i].fn, cname, sizeof(cname));
fprintf(out, "static void\n%s(void *app, Rectangle viewport)\n{\n",
wrapper);
fprintf(out, " if(BeginScreenDraw != 0)\n");
fprintf(out, " BeginScreenDraw(app, viewport);\n");
if(strstr(routes[i].fn->args, "Rectangle") != NULL)
fprintf(out, " (void)app;\n %s(viewport);\n", cname);
else if(routes[i].fn->args[0] != '\0')
fprintf(out, " (void)viewport;\n %s(app);\n", cname);
else
fprintf(out, " (void)app;\n (void)viewport;\n %s();\n",
cname);
fprintf(out, "}\n\n");
}
fprintf(out, "static const AppRouteInfo kryon_project_routes[%d];\n\n",
count);
fprintf(out, "static void\nkryon_project_enter(void *app, int index)\n{\n");
fprintf(out, " if(ApplyRoute == 0 || index < 0 || index >= %d)\n",
count);
fprintf(out, " return;\n");
fprintf(out, " ApplyRoute(app, &kryon_project_routes[index]);\n");
fprintf(out, "}\n\n");
fprintf(out, "static const AppRouteInfo kryon_project_routes[] = {\n");
for(int i = 0; i < count; i++) {
char id[KIR_NAME_MAX * 2];
char title[KIR_NAME_MAX * 2];
char group[KIR_NAME_MAX * 2];
char source[KIR_PATH_MAX * 2];
char wrapper[64];
c_str(id, sizeof(id), routes[i].id);
c_str(title, sizeof(title), routes[i].title);
c_str(group, sizeof(group), routes[i].group);
c_str(source, sizeof(source), routes[i].source_path);
snprintf(wrapper, sizeof(wrapper), "kryon_project_draw_%d", i);
fprintf(out, " {%s, %s, %s, %s, kryon_project_enter, %s},\n",
id, group, title, source, wrapper);
}
fprintf(out, "};\n\n");
fprintf(out, "static App kryon_project_runtime;\n");
fprintf(out, "static AppHost kryon_project_host;\n\n");
fprintf(out, "AppHost *\nCreateAppHost(int abi_version, const char *project_path)\n{\n");
fprintf(out, " void *app = 0;\n");
fprintf(out, " if(abi_version != APP_HOST_ABI_VERSION)\n");
fprintf(out, " return 0;\n");
fprintf(out, " if(CreateApp != 0) {\n");
fprintf(out, " app = CreateApp(project_path);\n");
fprintf(out, " if(app == 0)\n");
fprintf(out, " return 0;\n");
fprintf(out, " } else {\n");
fprintf(out, " (void)project_path;\n");
fprintf(out, " }\n");
fprintf(out, " kryon_project_runtime.app = app;\n");
fprintf(out, " kryon_project_runtime.routes = kryon_project_routes;\n");
fprintf(out, " kryon_project_runtime.route_count = (int)(sizeof(kryon_project_routes) / sizeof(kryon_project_routes[0]));\n");
fprintf(out, " kryon_project_runtime.selected_route = 0;\n");
fprintf(out, " kryon_project_register_styles();\n");
fprintf(out, " BindAppHost(&kryon_project_runtime, &kryon_project_host);\n");
fprintf(out, " SetAppScreen(&kryon_project_host, 0);\n");
fprintf(out, " return &kryon_project_host;\n}\n\n");
fprintf(out, "void\nDestroyAppHost(AppHost *host)\n{\n");
fprintf(out, " if(host == 0 || host != &kryon_project_host)\n");
fprintf(out, " return;\n");
fprintf(out, " if(DestroyApp != 0 && kryon_project_runtime.app != 0)\n");
fprintf(out, " DestroyApp(kryon_project_runtime.app);\n");
fprintf(out, " kryon_project_runtime = (App){0};\n");
fprintf(out, " kryon_project_host = (AppHost){0};\n}\n");
fclose(out);
k2c_plan9_rewrite_file(path, 1);
/* --- main() (hook-driven, from KirAppMeta) --- */
if(no_main || appmod == NULL)
return;
out = fopen(path, "ab");
if(out == NULL)
return;
{
int width = appmod->app.width > 0 ? appmod->app.width : 800;
int height = appmod->app.height > 0 ? appmod->app.height : 600;
int fps = appmod->app.fps > 0 ? appmod->app.fps : 60;
int route_host_main = appmod->app.frame[0] == '\0' && count > 0;
char title[KIR_NAME_MAX * 2];
c_str(title, sizeof(title), appmod->app.title);
fprintf(out, "\nint\nmain(void)\n{\n");
if(route_host_main) {
fprintf(out, " AppHost *host;\n");
fprintf(out, " int route_version = -1;\n");
}
fprintf(out, " int width = %d;\n", width);
fprintf(out, " int height = %d;\n", height);
fprintf(out, "#if defined(PLATFORM_WEB)\n");
fprintf(out, " SetConfigFlags(GetWebWindowFlags());\n");
fprintf(out, " GetWebViewportSize(width, height, &width, &height);\n");
fprintf(out, "#endif\n");
if(appmod->app.before_window[0] != '\0') {
char hook[KIR_NAME_MAX * 3];
int found = 0;
for(int j = 0; j < appmod->function_count && !found; j++) {
if(strcmp(appmod->functions[j].name,
appmod->app.before_window) == 0) {
k2c_function_c_name(appmod, &appmod->functions[j],
hook, sizeof(hook));
found = 1;
}
}
fprintf(out, " if(!%s()) return 2;\n",
found ? hook : appmod->app.before_window);
}
fprintf(out, " InitWindow(width, height, %s);\n", title);
fprintf(out, " SetTargetFPS(%d);\n", fps);
if(appmod->app.font_examples)
fprintf(out, " LoadExampleTextFont();\n");
fprintf(out, " InitInterface(width, height, GetScale());\n");
fprintf(out, " kryon_project_register_styles();\n");
if(appmod->app.theme[0] != '\0') {
fprintf(out, " SetThemeSource(THEME_SOURCE_APP);\n");
fprintf(out, " SetThemeMode(%s);\n",
appmod->app.dark_mode ? "THEME_MODE_DARK"
: "THEME_MODE_LIGHT");
fprintf(out, " SetCurrentTheme(%s, %d);\n",
appmod->app.theme, appmod->app.dark_mode);
}
if(appmod->app.init[0] != '\0') {
char hook[KIR_NAME_MAX * 3];
int found = 0;
for(int j = 0; j < appmod->function_count && !found; j++) {
if(strcmp(appmod->functions[j].name, appmod->app.init) == 0) {
k2c_function_c_name(appmod, &appmod->functions[j],
hook, sizeof(hook));
found = 1;
}
}
fprintf(out, " %s();\n",
found ? hook : appmod->app.init);
}
if(route_host_main) {
fprintf(out, " host = CreateAppHost(APP_HOST_ABI_VERSION, \".\");\n");
fprintf(out, " if(host == 0) {\n");
fprintf(out, " CloseWindow();\n");
fprintf(out, " return 1;\n");
fprintf(out, " }\n");
}
if(appmod->app.should_continue[0] != '\0') {
char hook[KIR_NAME_MAX * 3];
int found = 0;
for(int j = 0; j < appmod->function_count && !found; j++) {
if(strcmp(appmod->functions[j].name,
appmod->app.should_continue) == 0) {
k2c_function_c_name(appmod, &appmod->functions[j],
hook, sizeof(hook));
found = 1;
}
}
fprintf(out, " while(!WindowShouldClose() && %s()) {\n",
found ? hook : appmod->app.should_continue);
} else {
fprintf(out, " while(!WindowShouldClose()) {\n");
}
if(appmod->app.frame[0] != '\0') {
char hook[KIR_NAME_MAX * 3];
const KirFunction *entry = NULL;
int found = 0;
for(int j = 0; j < appmod->function_count && !found; j++) {
if(strcmp(appmod->functions[j].name, appmod->app.frame) == 0) {
k2c_function_c_name(appmod, &appmod->functions[j],
hook, sizeof(hook));
entry = &appmod->functions[j];
found = 1;
}
}
if(entry != NULL && entry->is_ui) {
fprintf(out, " BeginFrame();\n");
fprintf(out, " BeginInterfaceFrame(GetFrameWidth(), "
"GetFrameHeight(), GetFrameScale());\n");
fprintf(out, " BeginTree(Key(\"%s\"));\n", hook);
if(strstr(entry->args, "Rectangle") != NULL) {
fprintf(out, " %s((Rectangle){0, 0, "
"(float)GetFrameWidth(), (float)GetFrameHeight()});\n",
hook);
} else {
fprintf(out, " %s();\n", hook);
}
fprintf(out, " EndTree();\n");
fprintf(out, " EndInterfaceFrame();\n");
fprintf(out, " EndFrame();\n");
} else {
fprintf(out, " %s();\n",
found ? hook : appmod->app.frame);
}
} else if(route_host_main) {
fprintf(out, " int next_route_version = GetRouteVersion();\n");
fprintf(out, " if(next_route_version != route_version) {\n");
fprintf(out, " if(!SetAppScreenFromRoute(host))\n");
fprintf(out, " ReplaceAppScreenRoute(host, 0);\n");
fprintf(out, " route_version = GetRouteVersion();\n");
fprintf(out, " }\n");
fprintf(out, " BeginFrame();\n");
fprintf(out, " BeginInterfaceFrame(GetFrameWidth(), "
"GetFrameHeight(), GetFrameScale());\n");
fprintf(out, " BeginTree(Key(\"kryon_project\"));\n");
fprintf(out, " DrawAppScreen(host, (Rectangle){0, 0, "
"(float)GetFrameWidth(), (float)GetFrameHeight()});\n");
fprintf(out, " EndTree();\n");
fprintf(out, " EndInterfaceFrame();\n");
fprintf(out, " EndFrame();\n");
} else {
fprintf(out, " ;\n");
}
if(appmod->app.after_frame[0] != '\0') {
char hook[KIR_NAME_MAX * 3];
int found = 0;
for(int j = 0; j < appmod->function_count && !found; j++) {
if(strcmp(appmod->functions[j].name,
appmod->app.after_frame) == 0) {
k2c_function_c_name(appmod, &appmod->functions[j],
hook, sizeof(hook));
found = 1;
}
}
fprintf(out, " %s();\n",
found ? hook : appmod->app.after_frame);
}
fprintf(out, " }\n");
if(appmod->app.shutdown[0] != '\0') {
char hook[KIR_NAME_MAX * 3];
int found = 0;
for(int j = 0; j < appmod->function_count && !found; j++) {
if(strcmp(appmod->functions[j].name, appmod->app.shutdown) == 0) {
k2c_function_c_name(appmod, &appmod->functions[j],
hook, sizeof(hook));
found = 1;
}
}
fprintf(out, " %s();\n",
found ? hook : appmod->app.shutdown);
}
if(route_host_main)
fprintf(out, " DestroyAppHost(host);\n");
if(appmod->app.font_examples)
fprintf(out, " UnloadExampleTextFont();\n");
fprintf(out, " CloseWindow();\n");
fprintf(out, " return 0;\n}\n");
}
fclose(out);
k2c_plan9_rewrite_file(path, 1);
}
-120
View File
@@ -1,120 +0,0 @@
/*
* k2c - .kry -> C compiler. Kir is the only pipeline: every .kry parses
* into a KirProgram (kir_parse.c) and lowers to C (k2c_lower.c). All inputs
* are parsed first so cross-module calls resolve through one symbol table.
*/
#include "kir.h"
#include "kir_parse.h"
#include "kir_check.h"
#include "kir_laws.h"
#include "kir_diagnostic.h"
#include "k2c_lower.h"
#include "k2c_plan9.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static void
usage(void)
{
fprintf(stderr,
"usage: k2c [--strict] [--no-main] [--plan9] [--include-dir DIR] "
"[--diagnostics=text|json] --root DIR -o DIR file.kry ...\n");
}
int
main(int argc, char **argv)
{
const char *root = NULL;
const char *out_dir = NULL;
int no_main = 0;
int strict = 0;
int check_ok;
int laws_ok;
int plan9 = 0;
int unresolved = 0;
KirProgram **progs;
K2cModuleSyms *syms;
int file_count;
int i;
int first_file = 0;
for(i = 1; i < argc; i++) {
if(strncmp(argv[i], "--diagnostics=", 14) == 0) {
if(!KirSetDiagnosticFormat(argv[i] + 14)) {
usage();
return 1;
}
} else if(strcmp(argv[i], "--root") == 0 && i + 1 < argc) {
root = argv[++i];
} else if(strcmp(argv[i], "-o") == 0 && i + 1 < argc) {
out_dir = argv[++i];
} else if(strcmp(argv[i], "--no-main") == 0) {
no_main = 1;
} else if(strcmp(argv[i], "--plan9") == 0) {
plan9 = 1;
} else if(strcmp(argv[i], "--include-dir") == 0 && i + 1 < argc) {
k2c_plan9_add_include_dir(argv[++i]);
} else if(strcmp(argv[i], "--strict") == 0) {
strict = 1;
} else if(strcmp(argv[i], "--no-strict") == 0) {
strict = 0;
} else if(argv[i][0] == '-') {
usage();
return 1;
} else {
first_file = i;
break;
}
}
if(root == NULL || out_dir == NULL || first_file == 0) {
usage();
return 1;
}
file_count = argc - first_file;
progs = calloc((size_t)file_count, sizeof(*progs));
syms = calloc((size_t)file_count, sizeof(*syms));
if(progs == NULL || syms == NULL) {
fprintf(stderr, "k2c: out of memory\n");
return 1;
}
k2c_plan9_set_enabled(plan9);
/* Pass 1: parse every file, build the cross-module symbol table. */
for(i = 0; i < file_count; i++) {
progs[i] = kir_parse_file(argv[first_file + i], root);
if(progs[i] == NULL) {
fprintf(stderr, "k2c: failed to parse %s\n",
argv[first_file + i]);
return 1;
}
k2c_build_syms(progs[i], &syms[i]);
}
check_ok = KirCheckPrograms(progs, file_count, strict);
laws_ok = KirCheckLaws(progs, file_count);
if(!check_ok || !laws_ok) {
for(i = 0; i < file_count; i++) KirProgramFree(progs[i]);
free(progs);
free(syms);
return 1;
}
/* Pass 2: lower with full cross-module resolution. */
for(i = 0; i < file_count; i++)
k2c_lower(progs[i], root, out_dir, syms, file_count);
k2c_write_project(progs, file_count, root, out_dir, no_main);
for(i = 0; i < file_count; i++)
KirProgramFree(progs[i]);
free(progs);
free(syms);
unresolved = k2c_plan9_unresolved();
if(plan9 && unresolved > 0) {
/* Unresolved declarations are usually inside platform guards the
* native build compiles out; the in-guest compile is the final
* arbiter, so warn rather than fail. */
fprintf(stderr,
"k2c: --plan9 left %d __auto_type declarations unresolved "
"(guarded code compiles out; the rest must be resolvable)\n",
unresolved);
}
return 0;
}
File diff suppressed because it is too large. Load diff
-37
View File
@@ -1,37 +0,0 @@
#ifndef K2CPP_LOWER_H
#define K2CPP_LOWER_H
#include "kir.h"
/* Cross-module symbol table: for each parsed module (by its slash-path),
* every function's .kry name -> full C name. Built by main after parsing all
* inputs; used to resolve alias-qualified calls (start.draw_start_page(...)
* -> ide_start_page_draw_start_page_kry_draw(...)). */
typedef struct K2cppModuleSyms {
char module_stem[KIR_PATH_MAX]; /* source path minus .kry */
char module_slash[KIR_PATH_MAX];
struct {
char kry[KIR_NAME_MAX];
char c[KIR_NAME_MAX * 3];
} fns[256];
int fn_count;
} K2cppModuleSyms;
/* Lower a KirProgram to C++ source (.cpp/.hpp). restab/restab_count resolve
* cross-module calls; pass NULL/0 to resolve same-module only. */
void k2cpp_lower(const KirProgram *program, const char *root,
const char *out_dir, const K2cppModuleSyms *restab,
int restab_count);
/* Build the symbol table entry for one program into out. */
void k2cpp_build_syms(const KirProgram *program, K2cppModuleSyms *out);
/* Full C name for a function (module prefix, colon naming, _kry_draw). */
void k2cpp_function_c_name(const KirModule *m, const KirFunction *fn,
char *dst, size_t dst_size);
/* k2cpp_project.c — kryon_project.h/.c (app-host ABI) after all files lower. */
void k2cpp_write_project(KirProgram *const *progs, int prog_count,
const char *root, const char *out_dir, int no_main);
#endif
-530
View File
@@ -1,530 +0,0 @@
/*
* k2cpp_project.c — emit kryon_project.h/.c after all files lower (the
* project files stay plain C; the generated module headers are .hpp but
* self-guard their extern "C" so C translation units include them too). The
* app-host ABI (CreateAppHost/DestroyAppHost + route table) consumed by
* the preview tool and IDE host builds. Routes auto-collect from #ui
* functions. Explicit route{} blocks supply route id/title/group metadata
* when present.
*/
#include "k2cpp_lower.h"
#include "kir.h"
#include "kir_style_imports.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
typedef struct K2cppRoute {
char id[KIR_NAME_MAX];
char title[KIR_NAME_MAX];
char group[KIR_NAME_MAX];
char source_path[KIR_PATH_MAX];
const KirModule *m;
const KirFunction *fn;
} K2cppRoute;
#define K2CPP_ROUTE_MAX 512
static const KirFunction *
find_ui_function(const KirModule *mod, const char *name)
{
if(mod == NULL || name == NULL || name[0] == '\0')
return NULL;
for(int i = 0; i < mod->function_count; i++) {
const KirFunction *fn = &mod->functions[i];
if(fn->is_public && fn->is_ui && strcmp(fn->name, name) == 0)
return fn;
}
return NULL;
}
static int
function_has_explicit_route(const KirModule *mod, const KirFunction *fn)
{
if(mod == NULL || fn == NULL)
return 0;
for(int i = 0; i < mod->route_count; i++) {
if(strcmp(mod->routes[i].page, fn->name) == 0)
return 1;
}
return 0;
}
static void
mkdir_parent_local(const char *path)
{
char tmp[KIR_PATH_MAX];
size_t i;
snprintf(tmp, sizeof(tmp), "%s", path);
for(i = 1; i < strlen(tmp); i++) {
if(tmp[i] == '/') {
tmp[i] = '\0';
mkdir(tmp, 0755);
tmp[i] = '/';
}
}
}
static void
c_str(char *dst, size_t dst_size, const char *src)
{
size_t n = 0;
dst[n++] = '"';
for(const char *p = src != NULL ? src : "";
*p != '\0' && n + 3 < dst_size; p++) {
if(*p == '"' || *p == '\\') {
dst[n++] = '\\';
dst[n++] = *p;
} else if(*p == '\n') {
dst[n++] = '\\';
dst[n++] = 'n';
} else {
dst[n++] = *p;
}
}
if(n < dst_size)
dst[n++] = '"';
dst[n] = '\0';
}
static void
emit_c_string_literal(FILE *out, const char *src)
{
fputc('"', out);
for(const unsigned char *p = (const unsigned char *)(src != NULL ? src : "");
*p != '\0'; p++) {
if(*p == '"' || *p == '\\')
fprintf(out, "\\%c", *p);
else if(*p == '\n')
fputs("\\n", out);
else if(*p == '\r')
fputs("\\r", out);
else if(*p == '\t')
fputs("\\t", out);
else if(*p < 0x20)
fprintf(out, "\\x%02x", *p);
else
fputc(*p, out);
}
fputc('"', out);
}
static void
emit_style_registration(FILE *out, KirProgram *const *progs, int prog_count,
const char *root)
{
int emitted = 0;
for(int i = 0; i < prog_count; i++) {
const KirProgram *prog = progs[i];
if(prog == NULL)
continue;
for(int m = 0; m < prog->module_count; m++) {
const KirModule *mod = &prog->modules[m];
for(int s = 0; s < mod->style_import_count; s++) {
const KirStyleImport *style = &mod->style_imports[s];
char *source;
if(!emitted) {
fprintf(out, "static void\nkryon_project_register_styles(void)\n{\n");
emitted = 1;
}
if(style->kind == KIR_STYLE_IMPORT_BUILTIN &&
KirStyleImportIsBuiltIn(style->target)) {
fprintf(out, " EnsureBuiltInStylePacks();\n");
fprintf(out, " SetActiveStylePack(");
emit_c_string_literal(out, style->target);
fprintf(out, ");\n");
continue;
}
source = KirReadStyleImportSource(mod, root, style);
if(source == NULL) {
fprintf(stderr, "%s:%d: unable to resolve #style %s\n",
style->span.path, style->span.line, style->target);
continue;
}
fprintf(out, " if(RegisterStylePackSource(");
emit_c_string_literal(out, source);
fprintf(out, ", ");
emit_c_string_literal(out,
style->alias[0] != '\0' ? style->alias : style->target);
fprintf(out, ", \"\"))\n");
fprintf(out, " SetActiveStylePack(");
emit_c_string_literal(out,
style->alias[0] != '\0' ? style->alias : style->target);
fprintf(out, ");\n");
free(source);
}
}
}
if(emitted)
fprintf(out, "}\n\n");
else
fprintf(out, "static void\nkryon_project_register_styles(void)\n{\n}\n\n");
}
static int
collect_routes(KirProgram *const *progs, int prog_count,
K2cppRoute *routes, int max_routes)
{
int count = 0;
for(int i = 0; i < prog_count; i++) {
const KirProgram *prog = progs[i];
if(prog == NULL)
continue;
for(int m = 0; m < prog->module_count; m++) {
const KirModule *mod = &prog->modules[m];
for(int j = 0; j < mod->route_count; j++) {
const KirRoute *route = &mod->routes[j];
const KirFunction *fn = find_ui_function(mod, route->page);
if(fn == NULL) {
fprintf(stderr, "%s:%d: route `%s` references missing #ui page `%s`\n",
route->span.path, route->span.line,
route->id, route->page);
continue;
}
if(count >= max_routes)
return count;
snprintf(routes[count].id, sizeof(routes[0].id), "%s",
route->id);
snprintf(routes[count].title, sizeof(routes[0].title), "%s",
route->title[0] != '\0' ? route->title : route->id);
snprintf(routes[count].group, sizeof(routes[0].group), "%s",
route->group[0] != '\0' ? route->group : "Project");
snprintf(routes[count].source_path,
sizeof(routes[0].source_path), "%s",
mod->source_path);
routes[count].m = mod;
routes[count].fn = fn;
count++;
}
for(int j = 0; j < mod->function_count; j++) {
const KirFunction *fn = &mod->functions[j];
if(!fn->is_public || !fn->is_ui || fn->name[0] == '\0')
continue;
if(function_has_explicit_route(mod, fn))
continue;
if(count >= max_routes)
return count;
snprintf(routes[count].id, sizeof(routes[0].id), "%s",
fn->name);
snprintf(routes[count].title, sizeof(routes[0].title), "%s",
fn->name);
snprintf(routes[count].group, sizeof(routes[0].group),
"Project");
snprintf(routes[count].source_path,
sizeof(routes[0].source_path), "%s",
mod->source_path);
routes[count].m = mod;
routes[count].fn = fn;
count++;
}
}
}
return count;
}
void
k2cpp_write_project(KirProgram *const *progs, int prog_count,
const char *root, const char *out_dir, int no_main)
{
K2cppRoute routes[K2CPP_ROUTE_MAX];
char path[KIR_PATH_MAX];
const KirModule *appmod = NULL;
FILE *out;
int count;
(void)root;
if(progs == NULL || prog_count <= 0)
return;
count = collect_routes(progs, prog_count, routes, K2CPP_ROUTE_MAX);
/* the one app{} module (for main()) */
for(int i = 0; i < prog_count && appmod == NULL; i++) {
if(progs[i] == NULL)
continue;
for(int m = 0; m < progs[i]->module_count; m++)
if(progs[i]->modules[m].app.has_app) {
appmod = &progs[i]->modules[m];
break;
}
}
/* --- kryon_project.h --- */
snprintf(path, sizeof(path), "%s/kryon_project.h", out_dir);
mkdir_parent_local(path);
out = fopen(path, "wb");
if(out == NULL)
return;
fprintf(out, "/* Generated by k2cpp from project Kry files. */\n");
fprintf(out, "#ifndef K_KRYON_PROJECT_H\n#define K_KRYON_PROJECT_H\n\n");
for(int i = 0; i < prog_count; i++) {
const KirProgram *prog = progs[i];
if(prog == NULL)
continue;
for(int m = 0; m < prog->module_count; m++) {
const KirModule *mod = &prog->modules[m];
char stem[KIR_PATH_MAX];
size_t n = strlen(mod->source_path);
if(n > 4 && strcmp(mod->source_path + n - 4, ".kry") == 0)
n -= 4;
if(n >= sizeof(stem))
n = sizeof(stem) - 1;
memcpy(stem, mod->source_path, n);
stem[n] = '\0';
fprintf(out, "#include \"%s.hpp\"\n", stem);
}
}
fprintf(out, "\n#endif\n");
fclose(out);
if(count <= 0)
return;
/* --- kryon_project.c --- */
snprintf(path, sizeof(path), "%s/kryon_project.c", out_dir);
out = fopen(path, "wb");
if(out == NULL)
return;
fprintf(out, "/* Generated by k2cpp from project Kry files. */\n");
fprintf(out, "#include \"kryon_project.h\"\n");
fprintf(out, "#include \"app_runtime.h\"\n");
fprintf(out, "#include \"ui_style_sheet.h\"\n");
fprintf(out, "#include \"web.h\"\n");
if(appmod != NULL && appmod->app.font_examples)
fprintf(out, "#include \"kryon_example_font.h\"\n");
fprintf(out, "\n");
emit_style_registration(out, progs, prog_count, root);
fprintf(out, "#if defined(__GNUC__) || defined(__clang__)\n");
fprintf(out, "void *CreateApp(const char *project_path) __attribute__((weak));\n");
fprintf(out, "void DestroyApp(void *app) __attribute__((weak));\n");
fprintf(out, "void ApplyRoute(void *app, const AppRouteInfo *route) __attribute__((weak));\n");
fprintf(out, "void BeginScreenDraw(void *app, Rectangle viewport) __attribute__((weak));\n");
fprintf(out, "#endif\n\n");
for(int i = 0; i < count; i++) {
char cname[KIR_NAME_MAX * 3];
char wrapper[64];
snprintf(wrapper, sizeof(wrapper), "kryon_project_draw_%d", i);
k2cpp_function_c_name(routes[i].m, routes[i].fn, cname, sizeof(cname));
fprintf(out, "static void\n%s(void *app, Rectangle viewport)\n{\n",
wrapper);
fprintf(out, " if(BeginScreenDraw != 0)\n");
fprintf(out, " BeginScreenDraw(app, viewport);\n");
if(strstr(routes[i].fn->args, "Rectangle") != NULL)
fprintf(out, " (void)app;\n %s(viewport);\n", cname);
else if(routes[i].fn->args[0] != '\0')
fprintf(out, " (void)viewport;\n %s(app);\n", cname);
else
fprintf(out, " (void)app;\n (void)viewport;\n %s();\n",
cname);
fprintf(out, "}\n\n");
}
fprintf(out, "static const AppRouteInfo kryon_project_routes[%d];\n\n",
count);
fprintf(out, "static void\nkryon_project_enter(void *app, int index)\n{\n");
fprintf(out, " if(ApplyRoute == 0 || index < 0 || index >= %d)\n",
count);
fprintf(out, " return;\n");
fprintf(out, " ApplyRoute(app, &kryon_project_routes[index]);\n");
fprintf(out, "}\n\n");
fprintf(out, "static const AppRouteInfo kryon_project_routes[] = {\n");
for(int i = 0; i < count; i++) {
char id[KIR_NAME_MAX * 2];
char title[KIR_NAME_MAX * 2];
char group[KIR_NAME_MAX * 2];
char source[KIR_PATH_MAX * 2];
char wrapper[64];
c_str(id, sizeof(id), routes[i].id);
c_str(title, sizeof(title), routes[i].title);
c_str(group, sizeof(group), routes[i].group);
c_str(source, sizeof(source), routes[i].source_path);
snprintf(wrapper, sizeof(wrapper), "kryon_project_draw_%d", i);
fprintf(out, " {%s, %s, %s, %s, kryon_project_enter, %s},\n",
id, group, title, source, wrapper);
}
fprintf(out, "};\n\n");
fprintf(out, "static App kryon_project_runtime;\n");
fprintf(out, "static AppHost kryon_project_host;\n\n");
fprintf(out, "AppHost *\nCreateAppHost(int abi_version, const char *project_path)\n{\n");
fprintf(out, " void *app = 0;\n");
fprintf(out, " if(abi_version != APP_HOST_ABI_VERSION)\n");
fprintf(out, " return 0;\n");
fprintf(out, " if(CreateApp != 0) {\n");
fprintf(out, " app = CreateApp(project_path);\n");
fprintf(out, " if(app == 0)\n");
fprintf(out, " return 0;\n");
fprintf(out, " } else {\n");
fprintf(out, " (void)project_path;\n");
fprintf(out, " }\n");
fprintf(out, " kryon_project_runtime.app = app;\n");
fprintf(out, " kryon_project_runtime.routes = kryon_project_routes;\n");
fprintf(out, " kryon_project_runtime.route_count = (int)(sizeof(kryon_project_routes) / sizeof(kryon_project_routes[0]));\n");
fprintf(out, " kryon_project_runtime.selected_route = 0;\n");
fprintf(out, " kryon_project_register_styles();\n");
fprintf(out, " BindAppHost(&kryon_project_runtime, &kryon_project_host);\n");
fprintf(out, " SetAppScreen(&kryon_project_host, 0);\n");
fprintf(out, " return &kryon_project_host;\n}\n\n");
fprintf(out, "void\nDestroyAppHost(AppHost *host)\n{\n");
fprintf(out, " if(host == 0 || host != &kryon_project_host)\n");
fprintf(out, " return;\n");
fprintf(out, " if(DestroyApp != 0 && kryon_project_runtime.app != 0)\n");
fprintf(out, " DestroyApp(kryon_project_runtime.app);\n");
fprintf(out, " kryon_project_runtime = (App){0};\n");
fprintf(out, " kryon_project_host = (AppHost){0};\n}\n");
fclose(out);
/* --- main() (hook-driven, from KirAppMeta) --- */
if(no_main || appmod == NULL)
return;
out = fopen(path, "ab");
if(out == NULL)
return;
{
int width = appmod->app.width > 0 ? appmod->app.width : 800;
int height = appmod->app.height > 0 ? appmod->app.height : 600;
int fps = appmod->app.fps > 0 ? appmod->app.fps : 60;
int route_host_main = appmod->app.frame[0] == '\0' && count > 0;
char title[KIR_NAME_MAX * 2];
c_str(title, sizeof(title), appmod->app.title);
fprintf(out, "\nint\nmain(void)\n{\n");
if(route_host_main) {
fprintf(out, " AppHost *host;\n");
fprintf(out, " int route_version = -1;\n");
}
fprintf(out, " int width = %d;\n", width);
fprintf(out, " int height = %d;\n", height);
fprintf(out, "#if defined(PLATFORM_WEB)\n");
fprintf(out, " SetConfigFlags(GetWebWindowFlags());\n");
fprintf(out, " GetWebViewportSize(width, height, &width, &height);\n");
fprintf(out, "#endif\n");
fprintf(out, " InitWindow(width, height, %s);\n", title);
fprintf(out, " SetTargetFPS(%d);\n", fps);
if(appmod->app.font_examples)
fprintf(out, " LoadExampleTextFont();\n");
fprintf(out, " InitInterface(width, height, GetScale());\n");
fprintf(out, " kryon_project_register_styles();\n");
if(appmod->app.theme[0] != '\0') {
fprintf(out, " SetThemeSource(THEME_SOURCE_APP);\n");
fprintf(out, " SetThemeMode(%s);\n",
appmod->app.dark_mode ? "THEME_MODE_DARK"
: "THEME_MODE_LIGHT");
fprintf(out, " SetCurrentTheme(%s, %d);\n",
appmod->app.theme, appmod->app.dark_mode);
}
if(appmod->app.init[0] != '\0') {
char hook[KIR_NAME_MAX * 3];
int found = 0;
for(int j = 0; j < appmod->function_count && !found; j++) {
if(strcmp(appmod->functions[j].name, appmod->app.init) == 0) {
k2cpp_function_c_name(appmod, &appmod->functions[j],
hook, sizeof(hook));
found = 1;
}
}
fprintf(out, " %s();\n",
found ? hook : appmod->app.init);
}
if(route_host_main) {
fprintf(out, " host = CreateAppHost(APP_HOST_ABI_VERSION, \".\");\n");
fprintf(out, " if(host == 0) {\n");
fprintf(out, " CloseWindow();\n");
fprintf(out, " return 1;\n");
fprintf(out, " }\n");
}
fprintf(out, " while(!WindowShouldClose()) {\n");
if(appmod->app.frame[0] != '\0') {
char hook[KIR_NAME_MAX * 3];
const KirFunction *entry = NULL;
int found = 0;
for(int j = 0; j < appmod->function_count && !found; j++) {
if(strcmp(appmod->functions[j].name, appmod->app.frame) == 0) {
k2cpp_function_c_name(appmod, &appmod->functions[j],
hook, sizeof(hook));
entry = &appmod->functions[j];
found = 1;
}
}
if(entry != NULL && entry->is_ui) {
fprintf(out, " BeginFrame();\n");
fprintf(out, " BeginInterfaceFrame(GetFrameWidth(), "
"GetFrameHeight(), GetFrameScale());\n");
fprintf(out, " BeginTree(Key(\"%s\"));\n", hook);
if(strstr(entry->args, "Rectangle") != NULL) {
fprintf(out, " %s((Rectangle){0, 0, "
"(float)GetFrameWidth(), (float)GetFrameHeight()});\n",
hook);
} else {
fprintf(out, " %s();\n", hook);
}
fprintf(out, " EndTree();\n");
fprintf(out, " EndInterfaceFrame();\n");
fprintf(out, " EndFrame();\n");
} else {
fprintf(out, " %s();\n",
found ? hook : appmod->app.frame);
}
} else if(route_host_main) {
fprintf(out, " int next_route_version = GetRouteVersion();\n");
fprintf(out, " if(next_route_version != route_version) {\n");
fprintf(out, " if(!SetAppScreenFromRoute(host))\n");
fprintf(out, " ReplaceAppScreenRoute(host, 0);\n");
fprintf(out, " route_version = GetRouteVersion();\n");
fprintf(out, " }\n");
fprintf(out, " BeginFrame();\n");
fprintf(out, " BeginInterfaceFrame(GetFrameWidth(), "
"GetFrameHeight(), GetFrameScale());\n");
fprintf(out, " BeginTree(Key(\"kryon_project\"));\n");
fprintf(out, " DrawAppScreen(host, (Rectangle){0, 0, "
"(float)GetFrameWidth(), (float)GetFrameHeight()});\n");
fprintf(out, " EndTree();\n");
fprintf(out, " EndInterfaceFrame();\n");
fprintf(out, " EndFrame();\n");
} else {
fprintf(out, " ;\n");
}
fprintf(out, " }\n");
if(appmod->app.shutdown[0] != '\0') {
char hook[KIR_NAME_MAX * 3];
int found = 0;
for(int j = 0; j < appmod->function_count && !found; j++) {
if(strcmp(appmod->functions[j].name, appmod->app.shutdown) == 0) {
k2cpp_function_c_name(appmod, &appmod->functions[j],
hook, sizeof(hook));
found = 1;
}
}
fprintf(out, " %s();\n",
found ? hook : appmod->app.shutdown);
}
if(route_host_main)
fprintf(out, " DestroyAppHost(host);\n");
if(appmod->app.font_examples)
fprintf(out, " UnloadExampleTextFont();\n");
fprintf(out, " CloseWindow();\n");
fprintf(out, " return 0;\n}\n");
}
fclose(out);
}
-105
View File
@@ -1,105 +0,0 @@
/*
* k2cpp - .kry -> C++ compiler. Kir is the only pipeline: every .kry parses
* into a KirProgram (kir_parse.c) and lowers to C++ source that calls the
* C Kryon runtime through extern "C" (k2cpp_lower.c). All inputs are parsed
* first so cross-module calls resolve through one symbol table. Emitted
* declarations keep C linkage so generated modules interop with k2c output
* and the plain-C kryon_project files.
*/
#include "kir.h"
#include "kir_parse.h"
#include "kir_check.h"
#include "kir_laws.h"
#include "kir_diagnostic.h"
#include "k2cpp_lower.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static void
usage(void)
{
fprintf(stderr,
"usage: k2cpp [--strict] [--no-main] "
"[--diagnostics=text|json] --root DIR -o DIR file.kry ...\n");
}
int
main(int argc, char **argv)
{
const char *root = NULL;
const char *out_dir = NULL;
int no_main = 0;
int strict = 0;
int check_ok;
int laws_ok;
KirProgram **progs;
K2cppModuleSyms *syms;
int file_count;
int i;
int first_file = 0;
for(i = 1; i < argc; i++) {
if(strncmp(argv[i], "--diagnostics=", 14) == 0) {
if(!KirSetDiagnosticFormat(argv[i] + 14)) {
usage();
return 1;
}
} else if(strcmp(argv[i], "--root") == 0 && i + 1 < argc) {
root = argv[++i];
} else if(strcmp(argv[i], "-o") == 0 && i + 1 < argc) {
out_dir = argv[++i];
} else if(strcmp(argv[i], "--no-main") == 0) {
no_main = 1;
} else if(strcmp(argv[i], "--strict") == 0) {
strict = 1;
} else if(strcmp(argv[i], "--no-strict") == 0) {
strict = 0;
} else if(argv[i][0] == '-') {
usage();
return 1;
} else {
first_file = i;
break;
}
}
if(root == NULL || out_dir == NULL || first_file == 0) {
usage();
return 1;
}
file_count = argc - first_file;
progs = calloc((size_t)file_count, sizeof(*progs));
syms = calloc((size_t)file_count, sizeof(*syms));
if(progs == NULL || syms == NULL) {
fprintf(stderr, "k2cpp: out of memory\n");
return 1;
}
/* Pass 1: parse every file, build the cross-module symbol table. */
for(i = 0; i < file_count; i++) {
progs[i] = kir_parse_file(argv[first_file + i], root);
if(progs[i] == NULL) {
fprintf(stderr, "k2cpp: failed to parse %s\n",
argv[first_file + i]);
return 1;
}
k2cpp_build_syms(progs[i], &syms[i]);
}
check_ok = KirCheckPrograms(progs, file_count, strict);
laws_ok = KirCheckLaws(progs, file_count);
if(!check_ok || !laws_ok) {
for(i = 0; i < file_count; i++) KirProgramFree(progs[i]);
free(progs);
free(syms);
return 1;
}
/* Pass 2: lower with full cross-module resolution. */
for(i = 0; i < file_count; i++)
k2cpp_lower(progs[i], root, out_dir, syms, file_count);
k2cpp_write_project(progs, file_count, root, out_dir, no_main);
for(i = 0; i < file_count; i++)
KirProgramFree(progs[i]);
free(progs);
free(syms);
return 0;
}
File diff suppressed because it is too large. Load diff
-23
View File
@@ -1,23 +0,0 @@
#ifndef K2GO_LOWER_H
#define K2GO_LOWER_H
#include "kir.h"
/*
* k2go_lower - Kir -> Go backend.
*
* Emits one .go file per module into out_dir, all in one Go package. The
* generated code calls the native Go Kryon package API. It does not thread a
* cgo bridge or runtime object through generated functions.
*
* v1 scope: the declarative app subset translates fully — state blocks,
* app metadata (-> generated main unless --no-main), frames, widget calls,
* and scalar expressions (compound literals, casts, state refs). Imperative
* constructs supported by the backend retain their types. Unsupported types
* and statements fail with a source diagnostic; no placeholder code is emitted.
*/
int k2go_lower(const KirProgram *const *progs, int prog_count,
const char *root, const char *out_dir, const char *pkg,
int no_main, int runtime_implementation);
#endif
-117
View File
@@ -1,117 +0,0 @@
/*
* k2go - .kry -> Go compiler. Shares the Kir frontend with k2c/k2b: every
* .kry parses into a KirProgram (kir_parse.c), then lowers to Go source
* (k2go_lower.c) that calls the native Go Kryon runtime. One frontend, three
* backends.
*
* usage: k2go [--strict] [--no-main] [--runtime-implementation] [--minify] [--pkg NAME] --root DIR -o DIR file.kry ...
*/
#include "kir.h"
#include "kir_parse.h"
#include "kir_check.h"
#include "kir_laws.h"
#include "kir_diagnostic.h"
#include "kir_emit.h"
#include "k2go_lower.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static void
usage(void)
{
fprintf(stderr,
"usage: k2go [--strict] [--no-main] [--runtime-implementation] [--minify] [--pkg NAME] "
"[--diagnostics=text|json] --root DIR -o DIR file.kry ...\n");
}
int
main(int argc, char **argv)
{
const char *root = NULL;
const char *out_dir = NULL;
const char *pkg = "krygen";
int no_main = 0;
int strict = 0;
int minify = 0;
int check_ok;
int laws_ok;
int runtime_implementation = 0;
KirProgram **progs;
int file_count;
int i;
int first_file = 0;
for(i = 1; i < argc; i++) {
if(strncmp(argv[i], "--diagnostics=", 14) == 0) {
if(!KirSetDiagnosticFormat(argv[i] + 14)) {
usage();
return 1;
}
} else if(strcmp(argv[i], "--root") == 0 && i + 1 < argc) {
root = argv[++i];
} else if(strcmp(argv[i], "-o") == 0 && i + 1 < argc) {
out_dir = argv[++i];
} else if(strcmp(argv[i], "--pkg") == 0 && i + 1 < argc) {
pkg = argv[++i];
} else if(strcmp(argv[i], "--no-main") == 0) {
no_main = 1;
} else if(strcmp(argv[i], "--strict") == 0) {
strict = 1;
} else if(strcmp(argv[i], "--no-strict") == 0) {
strict = 0;
} else if(strcmp(argv[i], "--runtime-implementation") == 0) {
runtime_implementation = 1;
} else if(strcmp(argv[i], "--minify") == 0) {
minify = 1;
} else if(argv[i][0] == '-') {
usage();
return 1;
} else {
first_file = i;
break;
}
}
if(root == NULL || out_dir == NULL || first_file == 0) {
usage();
return 1;
}
if(runtime_implementation && !no_main) {
fprintf(stderr, "k2go: --runtime-implementation requires --no-main\n");
return 1;
}
KirEmitUseMinifiedOutput(minify);
file_count = argc - first_file;
progs = calloc((size_t)file_count, sizeof(*progs));
if(progs == NULL) {
fprintf(stderr, "k2go: out of memory\n");
return 1;
}
for(i = 0; i < file_count; i++) {
progs[i] = kir_parse_file(argv[first_file + i], root);
if(progs[i] == NULL) {
fprintf(stderr, "k2go: failed to parse %s\n", argv[first_file + i]);
return 1;
}
}
check_ok = KirCheckPrograms(progs, file_count, strict);
laws_ok = KirCheckLaws(progs, file_count);
if(!check_ok || !laws_ok) {
for(i = 0; i < file_count; i++) KirProgramFree(progs[i]);
free(progs);
return 1;
}
if(k2go_lower((const KirProgram *const *)progs, file_count, root, out_dir,
pkg, no_main, runtime_implementation) != 0) {
for(i = 0; i < file_count; i++)
KirProgramFree(progs[i]);
free(progs);
return 1;
}
for(i = 0; i < file_count; i++)
KirProgramFree(progs[i]);
free(progs);
return 0;
}
File diff suppressed because it is too large. Load diff
-17
View File
@@ -1,17 +0,0 @@
#ifndef K2JS_LOWER_H
#define K2JS_LOWER_H
#include "kir.h"
/*
* k2js_lower - Kir -> JavaScript backend.
*
* Emits one ESM .js file per module. Generated code imports the small
* web/kryon-runtime.js recorder/runtime and exports createState(), app
* metadata, all non-extern functions, frame(), and optionally main().
*/
int k2js_lower(const KirProgram *const *progs, int prog_count,
const char *root, const char *out_dir,
const char *runtime_import, int no_main);
#endif
-98
View File
@@ -1,98 +0,0 @@
/*
* k2js - .kry -> JavaScript compiler. Shares the Kir frontend with k2c/k2go/k2b:
* every .kry parses into a KirProgram (kir_parse.c), then lowers to ESM that
* calls the web Kryon runtime.
*
* usage: k2js [--strict] [--no-main] [--runtime PATH] --root DIR -o DIR file.kry ...
*/
#include "kir.h"
#include "kir_parse.h"
#include "kir_check.h"
#include "kir_laws.h"
#include "k2js_lower.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static void
usage(void)
{
fprintf(stderr,
"usage: k2js [--strict] [--no-main] [--runtime PATH] "
"--root DIR -o DIR file.kry ...\n");
}
int
main(int argc, char **argv)
{
const char *root = NULL;
const char *out_dir = NULL;
const char *runtime_import = NULL;
int no_main = 0;
int strict = 0;
int check_ok;
int laws_ok;
KirProgram **progs;
int file_count;
int i;
int first_file = 0;
for(i = 1; i < argc; i++) {
if(strcmp(argv[i], "--root") == 0 && i + 1 < argc) {
root = argv[++i];
} else if(strcmp(argv[i], "-o") == 0 && i + 1 < argc) {
out_dir = argv[++i];
} else if(strcmp(argv[i], "--runtime") == 0 && i + 1 < argc) {
runtime_import = argv[++i];
} else if(strcmp(argv[i], "--no-main") == 0) {
no_main = 1;
} else if(strcmp(argv[i], "--strict") == 0) {
strict = 1;
} else if(strcmp(argv[i], "--no-strict") == 0) {
strict = 0;
} else if(argv[i][0] == '-') {
usage();
return 1;
} else {
first_file = i;
break;
}
}
if(root == NULL || out_dir == NULL || first_file == 0) {
usage();
return 1;
}
file_count = argc - first_file;
progs = calloc((size_t)file_count, sizeof(*progs));
if(progs == NULL) {
fprintf(stderr, "k2js: out of memory\n");
return 1;
}
for(i = 0; i < file_count; i++) {
progs[i] = kir_parse_file(argv[first_file + i], root);
if(progs[i] == NULL) {
fprintf(stderr, "k2js: failed to parse %s\n", argv[first_file + i]);
free(progs);
return 1;
}
}
check_ok = KirCheckPrograms(progs, file_count, strict);
laws_ok = KirCheckLaws(progs, file_count);
if(!check_ok || !laws_ok) {
for(i = 0; i < file_count; i++) KirProgramFree(progs[i]);
free(progs);
return 1;
}
if(k2js_lower((const KirProgram *const *)progs, file_count, root, out_dir,
runtime_import, no_main) != 0) {
for(i = 0; i < file_count; i++)
KirProgramFree(progs[i]);
free(progs);
return 1;
}
for(i = 0; i < file_count; i++)
KirProgramFree(progs[i]);
free(progs);
return 0;
}
-104
View File
@@ -1,104 +0,0 @@
/*
* k2kir - emit a debuggable KIR text artifact from .kry source.
* Thin wrapper around the shared kir_parse_file frontend.
*/
#include "kir.h"
#include "kir_parse.h"
#include "kir_check.h"
#include "kir_laws.h"
#include "kir_diagnostic.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
static void
usage(void)
{
fprintf(stderr, "usage: k2kir [--diagnostics=text|json] --root DIR -o DIR file.kry ...\n");
}
int
main(int argc, char **argv)
{
const char *root = NULL;
const char *out_dir = NULL;
int check_ok;
int laws_ok;
int i;
for(i = 1; i < argc; i++) {
if(strncmp(argv[i], "--diagnostics=", 14) == 0) {
if(!KirSetDiagnosticFormat(argv[i] + 14)) {
usage();
return 1;
}
} else if(strcmp(argv[i], "--root") == 0 && i + 1 < argc) {
root = argv[++i];
} else if(strcmp(argv[i], "-o") == 0 && i + 1 < argc) {
out_dir = argv[++i];
} else if(argv[i][0] == '-') {
usage();
return 1;
} else {
break;
}
}
if(root == NULL || out_dir == NULL || i >= argc) {
usage();
return 1;
}
for(; i < argc; i++) {
KirProgram *program = kir_parse_file(argv[i], root);
if(program == NULL)
return 1;
check_ok = KirCheckPrograms(&program, 1, 0);
laws_ok = KirCheckLaws(&program, 1);
if(!check_ok || !laws_ok) {
KirProgramFree(program);
return 1;
}
/* Write the .kir dump using the module's source_path (relative to root)
* so directory structure is preserved. */
if(program->module_count > 0) {
const char *src = program->modules[0].source_path;
size_t slen = strlen(src);
char stem[512];
char out_path[1024];
FILE *out;
if(slen > 4 && strcmp(src + slen - 4, ".kry") == 0)
slen -= 4;
if(slen >= sizeof(stem))
slen = sizeof(stem) - 1;
memcpy(stem, src, slen);
stem[slen] = '\0';
snprintf(out_path, sizeof(out_path), "%s/%s.kir", out_dir, stem);
/* mkdir -p */
{
char tmp[1024];
size_t j;
snprintf(tmp, sizeof(tmp), "%s", out_path);
for(j = 1; j < strlen(tmp); j++) {
if(tmp[j] == '/') {
tmp[j] = '\0';
mkdir(tmp, 0755);
tmp[j] = '/';
}
}
}
out = fopen(out_path, "wb");
if(out == NULL) {
fprintf(stderr, "k2kir: %s: open failed\n", out_path);
KirProgramFree(program);
return 1;
}
KirProgramDump(program, out);
fclose(out);
}
KirProgramFree(program);
}
return 0;
}
-951
View File
@@ -1,951 +0,0 @@
#include "kir.h"
#include "kir_parse.h"
#include "runtime_declarations.generated.h"
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
int
KirTypeNextField(const KirType *record, size_t *offset, KirTypeField *field)
{
size_t length = strlen(record->body);
memset(field, 0, sizeof(*field));
if(record->is_enum || record->is_slot)
return -1;
while(*offset < length) {
const char *start = record->body + *offset;
const char *newline = strchr(start, '\n');
const char *end = newline != NULL ? newline : record->body + length;
const char *colon;
const char *name_end;
const char *type_start;
size_t name_length;
size_t type_length;
*offset = newline != NULL ? (size_t)(newline - record->body) + 1 : length;
while(start < end && isspace((unsigned char)*start))
start++;
while(end > start && isspace((unsigned char)end[-1]))
end--;
if(start == end)
continue;
colon = memchr(start, ':', (size_t)(end - start));
if(colon == NULL)
return -1;
name_end = colon;
while(name_end > start && isspace((unsigned char)name_end[-1]))
name_end--;
type_start = colon + 1;
while(type_start < end && isspace((unsigned char)*type_start))
type_start++;
name_length = (size_t)(name_end - start);
type_length = (size_t)(end - type_start);
if(name_length == 0 || name_length >= sizeof(field->name) ||
type_length == 0 || type_length >= sizeof(field->type))
return -1;
if(!isalpha((unsigned char)*start) && *start != '_')
return -1;
for(const char *cursor = start + 1; cursor < name_end; cursor++) {
if(!isalnum((unsigned char)*cursor) && *cursor != '_')
return -1;
}
memcpy(field->name, start, name_length);
memcpy(field->type, type_start, type_length);
return 1;
}
return 0;
}
int
KirSliceElementType(const char *type, char *element, size_t element_size)
{
if(type == NULL || type[0] != '[' || type[1] != ']')
return 0;
const char *start = type + 2;
while(isspace((unsigned char)*start))
start++;
size_t length = strlen(start);
while(length > 0 && isspace((unsigned char)start[length - 1]))
length--;
if(length == 0)
return 0;
if(element != NULL) {
if(length >= element_size)
return 0;
memcpy(element, start, length);
element[length] = '\0';
}
return 1;
}
int
KirArrayElementType(const char *type, char *element, size_t element_size,
int *capacity)
{
const char *cursor;
const char *close;
size_t length;
long count = 0;
int digits = 0;
if(type == NULL || type[0] != '[')
return 0;
cursor = type + 1;
if(*cursor >= '0' && *cursor <= '9') {
while(*cursor >= '0' && *cursor <= '9') {
count = count * 10 + (*cursor - '0');
if(count > 1048576)
return 0;
cursor++;
digits++;
}
if(digits == 0 || *cursor != ']')
return 0;
} else {
/* Symbolic capacity: a named module constant. The bound value is
* resolved by the backend emitters; only the element type matters
* here. */
if(!isalpha((unsigned char)*cursor) && *cursor != '_')
return 0;
while(isalnum((unsigned char)*cursor) || *cursor == '_')
cursor++;
if(*cursor != ']')
return 0;
count = -1;
}
close = cursor + 1;
while(isspace((unsigned char)*close))
close++;
length = strlen(close);
while(length > 0 && isspace((unsigned char)close[length - 1]))
length--;
if(length == 0)
return 0;
if(element != NULL) {
if(length >= element_size)
return 0;
memcpy(element, close, length);
element[length] = '\0';
}
if(capacity != NULL)
*capacity = (int)count;
return 1;
}
static int
enum_has_member(const KirType *type, const char *name)
{
if(!type->is_enum && strcmp(type->name, "#enum") != 0)
return 0;
const char *cursor = type->body;
while(*cursor) {
while(isspace((unsigned char)*cursor) || *cursor == ',')
cursor++;
const char *start = cursor;
while(isalnum((unsigned char)*cursor) || *cursor == '_')
cursor++;
if((size_t)(cursor - start) == strlen(name) &&
strncmp(start, name, (size_t)(cursor - start)) == 0)
return 1;
while(*cursor && *cursor != ',' && *cursor != '\n')
cursor++;
}
return 0;
}
int
KirResolveEnumMember(const KirModule *module, const char *name,
const KirModule **owner, const KirType **type)
{
*owner = NULL;
*type = NULL;
/* An empty identifier is never a member reference: unsupported host
* expressions lower to empty names and the lenient checker relies on
* them staying unresolved instead of turning into ambiguity errors. */
if(!*name)
return 0;
/* Local declarations shadow imports, just as functions and types do. */
for(int pass = 0; pass < 2; pass++) {
int count = pass == 0 ? 1 : module->import_count;
for(int i = 0; i < count; i++) {
const KirModule *scope = module;
if(pass != 0) {
if(module->imports[i].kind != KIR_IMPORT_HEADER)
continue;
scope = module->imports[i].resolved_module;
}
if(scope == NULL)
continue;
for(int j = 0; j < scope->type_count; j++) {
const KirType *candidate = &scope->types[j];
if(!enum_has_member(candidate, name))
continue;
if(*type != NULL && *type != candidate) {
*owner = NULL;
*type = NULL;
return -1;
}
*owner = scope;
*type = candidate;
}
}
if(*type != NULL)
return 1;
}
return 0;
}
int
KirResolveFunction(const KirModule *module, const char *name,
const KirModule **owner, const KirFunction **function)
{
*owner = NULL;
*function = NULL;
for(int i = 0; i < module->function_count; i++) {
if(strcmp(module->functions[i].name, name) == 0) {
*owner = module;
*function = &module->functions[i];
return 1;
}
}
for(int i = 0; i < module->import_count; i++) {
const KirModule *imported = module->imports[i].resolved_module;
if(imported == NULL)
continue;
for(int f = 0; f < imported->function_count; f++) {
const KirFunction *candidate = &imported->functions[f];
if(!candidate->is_public || strcmp(candidate->name, name) != 0)
continue;
if(*function != NULL && *function != candidate) {
*owner = NULL;
*function = NULL;
return -1;
}
*owner = imported;
*function = candidate;
}
}
return *function != NULL;
}
static KirProgram *runtime_programs[sizeof(runtime_sources) / sizeof(runtime_sources[0])];
static int runtime_parsing[sizeof(runtime_sources) / sizeof(runtime_sources[0])];
static KirProgram *
runtime_program(size_t source)
{
if(runtime_programs[source] == NULL) {
/* A runtime source can reference another runtime type while it is
* still being parsed (for example a parenthesized expression whose
* first token is an identifier, which the expression parser probes
* as a cast type). Parsing the same source re-entrantly would
* recurse without bound, so the in-progress source resolves to NULL
* until its parse completes. */
if(runtime_parsing[source])
return NULL;
runtime_parsing[source] = 1;
runtime_programs[source] = kir_parse_source(runtime_sources[source].path,
runtime_sources[source].source);
runtime_parsing[source] = 0;
}
return runtime_programs[source];
}
const KirType *
KirFindRuntimeEnumMember(const char *name)
{
if(!*name)
return NULL;
for(size_t source = 0; source < sizeof(runtime_programs) / sizeof(runtime_programs[0]); source++) {
KirProgram *program = runtime_program(source);
if(program == NULL)
continue;
for(int m = 0; m < program->module_count; m++) {
const KirModule *module = &program->modules[m];
for(int t = 0; t < module->type_count; t++) {
if(enum_has_member(&module->types[t], name))
return &module->types[t];
}
}
}
return NULL;
}
const KirType *
KirFindRuntimeType(const char *name, const KirModule **owner)
{
if(owner != NULL)
*owner = NULL;
for(size_t source = 0; source < sizeof(runtime_programs) / sizeof(runtime_programs[0]); source++) {
KirProgram *program = runtime_program(source);
if(program == NULL)
continue;
for(int m = 0; m < program->module_count; m++) {
const KirModule *module = &program->modules[m];
for(int t = 0; t < module->type_count; t++) {
if(strcmp(module->types[t].name, name) == 0) {
if(owner != NULL)
*owner = module;
return &module->types[t];
}
}
}
}
return NULL;
}
const KirType *
KirFindType(const KirModule *module, const char *name, const KirModule **owner)
{
const KirType *found = NULL;
const KirModule *scope = NULL;
if(owner)
*owner = NULL;
for(int i = 0; i < module->type_count; i++) {
if(strcmp(module->types[i].name, name) == 0) {
if(owner)
*owner = module;
return &module->types[i];
}
}
for(int i = 0; i < module->import_count; i++) {
const KirImport *import = &module->imports[i];
const KirModule *target = import->resolved_module;
if(import->kind != KIR_IMPORT_HEADER || target == NULL)
continue;
for(int j = 0; j < target->type_count; j++) {
const KirType *candidate = &target->types[j];
if(strcmp(candidate->name, name) != 0)
continue;
if(found && found != candidate)
return NULL;
found = candidate;
scope = target;
}
}
if(found == NULL)
return KirFindRuntimeType(name, owner);
if(owner)
*owner = scope;
return found;
}
static void *
kir_realloc_array(void *ptr, int *cap, int count, size_t elem_size)
{
void *next;
int ncap;
if(count < *cap)
return ptr;
ncap = *cap == 0 ? 4 : *cap * 2;
next = realloc(ptr, (size_t)ncap * elem_size);
if(next == NULL)
return NULL;
memset((char *)next + (size_t)(*cap) * elem_size, 0,
(size_t)(ncap - *cap) * elem_size);
*cap = ncap;
return next;
}
void
kir_copy(char *dst, size_t dst_size, const char *src)
{
if(dst_size == 0)
return;
if(src == NULL)
src = "";
snprintf(dst, dst_size, "%s", src);
}
KirProgram *
KirProgramNew(void)
{
return calloc(1, sizeof(KirProgram));
}
void
KirProgramFree(KirProgram *program)
{
int i;
if(program == NULL)
return;
for(i = 0; i < program->module_count; i++) {
KirModule *m = &program->modules[i];
int j;
for(j = 0; j < m->function_count; j++) {
free(m->functions[j].stmts);
free(m->functions[j].exprs);
free(m->functions[j].captures);
}
free(m->state_fields);
free(m->globals);
free(m->imports);
free(m->style_imports);
free(m->functions);
free(m->defines);
free(m->asserts);
free(m->types);
free(m->routes);
}
free(program->modules);
free(program);
}
KirSourceSpan
KirSpan(const char *path, int line, int column)
{
return KirSpanEnd(path, line, column, line, column);
}
KirSourceSpan
KirSpanEnd(const char *path, int line, int column, int end_line, int end_column)
{
KirSourceSpan span;
memset(&span, 0, sizeof(span));
kir_copy(span.path, sizeof(span.path), path);
span.line = line;
span.column = column;
span.end_line = end_line;
span.end_column = end_column;
return span;
}
KirModule *
KirProgramAddModule(KirProgram *program, const char *name,
const char *source_path, KirSourceSpan span)
{
KirModule *modules;
KirModule *m;
if(program == NULL)
return NULL;
modules = kir_realloc_array(program->modules, &program->module_cap,
program->module_count, sizeof(KirModule));
if(modules == NULL)
return NULL;
program->modules = modules;
m = &program->modules[program->module_count++];
memset(m, 0, sizeof(*m));
kir_copy(m->name, sizeof(m->name), name);
kir_copy(m->source_path, sizeof(m->source_path), source_path);
m->inspect_calls = 1;
m->span = span;
return m;
}
KirStateField *
KirModuleAddStateField(KirModule *module, const char *name, const char *type,
const char *init, KirSourceSpan span)
{
KirStateField *fields;
KirStateField *f;
if(module == NULL)
return NULL;
fields = kir_realloc_array(module->state_fields, &module->state_cap,
module->state_count, sizeof(KirStateField));
if(fields == NULL)
return NULL;
module->state_fields = fields;
f = &module->state_fields[module->state_count++];
memset(f, 0, sizeof(*f));
kir_copy(f->name, sizeof(f->name), name);
kir_copy(f->type, sizeof(f->type), type);
kir_copy(f->init, sizeof(f->init), init);
f->span = span;
return f;
}
KirImport *
KirModuleAddImport(KirModule *module, KirImportKind kind, const char *name,
const char *target, const char *signature, int required,
KirSourceSpan span)
{
KirImport *imports;
KirImport *imp;
if(module == NULL)
return NULL;
imports = kir_realloc_array(module->imports, &module->import_cap,
module->import_count, sizeof(KirImport));
if(imports == NULL)
return NULL;
module->imports = imports;
imp = &module->imports[module->import_count++];
memset(imp, 0, sizeof(*imp));
imp->kind = kind;
kir_copy(imp->name, sizeof(imp->name), name);
kir_copy(imp->target, sizeof(imp->target), target);
kir_copy(imp->signature, sizeof(imp->signature), signature);
imp->required = required;
imp->span = span;
return imp;
}
KirStyleImport *
KirModuleAddStyleImport(KirModule *module, KirStyleImportKind kind,
const char *target, const char *alias,
KirSourceSpan span)
{
KirStyleImport *imports;
KirStyleImport *imp;
if(module == NULL)
return NULL;
imports = kir_realloc_array(module->style_imports,
&module->style_import_cap,
module->style_import_count,
sizeof(KirStyleImport));
if(imports == NULL)
return NULL;
module->style_imports = imports;
imp = &module->style_imports[module->style_import_count++];
memset(imp, 0, sizeof(*imp));
imp->kind = kind;
kir_copy(imp->target, sizeof(imp->target), target);
kir_copy(imp->alias, sizeof(imp->alias), alias);
imp->span = span;
return imp;
}
KirFunction *
KirModuleAddFunction(KirModule *module, const char *name, const char *args,
const char *return_type, int exported, KirSourceSpan span)
{
KirFunction *functions;
KirFunction *fn;
if(module == NULL)
return NULL;
functions = kir_realloc_array(module->functions, &module->function_cap,
module->function_count, sizeof(KirFunction));
if(functions == NULL)
return NULL;
module->functions = functions;
fn = &module->functions[module->function_count++];
memset(fn, 0, sizeof(*fn));
kir_copy(fn->name, sizeof(fn->name), name);
kir_copy(fn->args, sizeof(fn->args), args);
kir_copy(fn->return_type, sizeof(fn->return_type), return_type);
fn->exported = exported;
fn->span = span;
return fn;
}
void
KirModuleAddGlobal(KirModule *module, const char *name, const char *type,
const char *init, KirSourceSpan span)
{
KirGlobal *globals;
if(module == NULL)
return;
globals = kir_realloc_array(module->globals, &module->global_cap,
module->global_count, sizeof(KirGlobal));
if(globals == NULL)
return;
module->globals = globals;
memset(&module->globals[module->global_count], 0, sizeof(KirGlobal));
kir_copy(module->globals[module->global_count].name,
sizeof(module->globals[0].name), name);
kir_copy(module->globals[module->global_count].type,
sizeof(module->globals[0].type), type);
kir_copy(module->globals[module->global_count].init,
sizeof(module->globals[0].init), init);
module->globals[module->global_count].span = span;
module->global_count++;
}
void
KirModuleAddStatic(KirModule *module, const char *name, const char *type,
const char *init, KirSourceSpan span)
{
KirModuleAddGlobal(module, name, type, init, span);
if(module != NULL && module->global_count > 0)
module->globals[module->global_count - 1].is_static = 1;
}
KirDefine *
KirModuleAddDefine(KirModule *module, const char *name, const char *value,
KirSourceSpan span)
{
KirDefine *defines;
KirDefine *d;
if(module == NULL)
return NULL;
defines = kir_realloc_array(module->defines, &module->define_cap,
module->define_count, sizeof(KirDefine));
if(defines == NULL)
return NULL;
module->defines = defines;
d = &module->defines[module->define_count++];
memset(d, 0, sizeof(*d));
kir_copy(d->name, sizeof(d->name), name);
kir_copy(d->value, sizeof(d->value), value);
d->span = span;
return d;
}
KirAssert *
KirModuleAddAssert(KirModule *module, const char *condition,
const char *message, KirSourceSpan span)
{
KirAssert *asserts;
KirAssert *a;
if(module == NULL)
return NULL;
asserts = kir_realloc_array(module->asserts, &module->assert_cap,
module->assert_count, sizeof(KirAssert));
if(asserts == NULL)
return NULL;
module->asserts = asserts;
a = &module->asserts[module->assert_count++];
memset(a, 0, sizeof(*a));
kir_copy(a->condition, sizeof(a->condition), condition);
kir_copy(a->message, sizeof(a->message), message);
a->span = span;
return a;
}
KirType *
KirModuleAddType(KirModule *module, const char *name, KirSourceSpan span)
{
KirType *types;
if(module == NULL)
return NULL;
types = kir_realloc_array(module->types, &module->type_cap,
module->type_count, sizeof(KirType));
if(types == NULL)
return NULL;
module->types = types;
memset(&module->types[module->type_count], 0, sizeof(KirType));
kir_copy(module->types[module->type_count].name,
sizeof(module->types[0].name), name);
module->types[module->type_count].span = span;
return &module->types[module->type_count++];
}
KirRoute *
KirModuleAddRoute(KirModule *module, const char *id, KirSourceSpan span)
{
KirRoute *routes;
KirRoute *route;
if(module == NULL)
return NULL;
routes = kir_realloc_array(module->routes, &module->route_cap,
module->route_count, sizeof(KirRoute));
if(routes == NULL)
return NULL;
module->routes = routes;
route = &module->routes[module->route_count++];
memset(route, 0, sizeof(*route));
kir_copy(route->id, sizeof(route->id), id);
kir_copy(route->title, sizeof(route->title), id);
kir_copy(route->group, sizeof(route->group), "Project");
kir_copy(route->page, sizeof(route->page), id);
route->span = span;
return route;
}
KirStmt *
KirFunctionAddStmt(KirFunction *fn, KirStmtKind kind, const char *text,
const char *widget, KirSourceSpan span)
{
KirStmt *stmts;
KirStmt *st;
if(fn == NULL)
return NULL;
stmts = kir_realloc_array(fn->stmts, &fn->stmt_cap, fn->stmt_count,
sizeof(KirStmt));
if(stmts == NULL)
return NULL;
fn->stmts = stmts;
st = &fn->stmts[fn->stmt_count++];
memset(st, 0, sizeof(*st));
st->kind = kind;
kir_copy(st->text, sizeof(st->text), text);
kir_copy(st->widget, sizeof(st->widget), widget);
st->expr_root = -1;
st->lhs_root = -1;
st->span = span;
return st;
}
KirStmt *
KirFunctionAddWidget(KirFunction *fn, const char *widget, const char *args,
const char *text, KirSourceSpan span)
{
KirStmt *st = KirFunctionAddStmt(fn, KIR_STMT_WIDGET, text, widget, span);
if(st != NULL)
kir_copy(st->args, sizeof(st->args), args);
return st;
}
KirExpr *
KirFunctionAddExpr(KirFunction *fn, KirExprKind kind, const char *text,
KirSourceSpan span)
{
KirExpr *exprs;
KirExpr *expr;
if(fn == NULL)
return NULL;
exprs = kir_realloc_array(fn->exprs, &fn->expr_cap, fn->expr_count,
sizeof(KirExpr));
if(exprs == NULL)
return NULL;
fn->exprs = exprs;
expr = &fn->exprs[fn->expr_count++];
memset(expr, 0, sizeof(*expr));
expr->kind = kind;
expr->left = -1;
expr->right = -1;
expr->first_child = -1;
expr->next_sibling = -1;
expr->third = -1;
kir_copy(expr->text, sizeof(expr->text), text);
expr->span = span;
return expr;
}
const char *
KirImportKindName(KirImportKind kind)
{
switch(kind) {
case KIR_IMPORT_HEADER: return "header";
case KIR_IMPORT_MODULE: return "module";
case KIR_IMPORT_EXTERN: return "extern";
case KIR_IMPORT_INTRINSIC: return "intrinsic";
case KIR_IMPORT_CAPABILITY: return "capability";
case KIR_IMPORT_HOST: return "host";
default: return "unknown";
}
}
const char *
KirExternKindName(KirExternKind kind)
{
switch(kind) {
case KIR_EXTERN_HOST: return "host";
case KIR_EXTERN_GO: return "go";
case KIR_EXTERN_C: return "c";
default: return "none";
}
}
const char *
KirExprKindName(KirExprKind kind)
{
switch(kind) {
case KIR_EXPR_IDENT: return "ident";
case KIR_EXPR_INT: return "int";
case KIR_EXPR_FLOAT: return "float";
case KIR_EXPR_STRING: return "string";
case KIR_EXPR_CALL: return "call";
case KIR_EXPR_BINARY: return "binary";
case KIR_EXPR_UNARY: return "unary";
case KIR_EXPR_MEMBER: return "member";
case KIR_EXPR_POINTER_MEMBER: return "pointer_member";
case KIR_EXPR_INDEX: return "index";
case KIR_EXPR_SLICE: return "slice";
case KIR_EXPR_CAST: return "cast";
case KIR_EXPR_COMPOUND: return "compound";
case KIR_EXPR_FIELD_INIT: return "field_initializer";
case KIR_EXPR_SIZEOF: return "sizeof";
case KIR_EXPR_CHAR: return "char";
case KIR_EXPR_CONDITIONAL: return "conditional";
case KIR_EXPR_POSTFIX: return "postfix";
default: return "unknown";
}
}
const char *
KirStmtKindName(KirStmtKind kind)
{
switch(kind) {
case KIR_STMT_BLOCK_OPEN: return "block_open";
case KIR_STMT_BLOCK_CLOSE: return "block_close";
case KIR_STMT_DECL: return "decl";
case KIR_STMT_ASSIGN: return "assign";
case KIR_STMT_EXPR: return "expr";
case KIR_STMT_IF: return "if";
case KIR_STMT_WHILE: return "while";
case KIR_STMT_FOR: return "for";
case KIR_STMT_SWITCH: return "switch";
case KIR_STMT_CASE: return "case";
case KIR_STMT_RETURN: return "return";
case KIR_STMT_BREAK: return "break";
case KIR_STMT_CONTINUE: return "continue";
case KIR_STMT_GOTO: return "goto";
case KIR_STMT_LABEL: return "label";
case KIR_STMT_DEFER: return "defer";
case KIR_STMT_UNUSED: return "unused";
case KIR_STMT_RAW: return "raw";
case KIR_STMT_WIDGET: return "widget";
default: return "unknown";
}
}
static void
kir_dump_span(FILE *out, KirSourceSpan span)
{
fprintf(out, "%s:%d:%d", span.path, span.line, span.column);
if(span.end_line > 0 && span.end_column > 0 &&
(span.end_line != span.line || span.end_column != span.column))
fprintf(out, "-%d:%d", span.end_line, span.end_column);
}
static void
kir_dump_expr(const KirFunction *fn, int index, FILE *out, int indent)
{
const KirExpr *expr;
if(fn == NULL || index < 0 || index >= fn->expr_count)
return;
expr = &fn->exprs[index];
for(int i = 0; i < indent; i++)
fputs(" ", out);
fprintf(out, "expr %s text %s name %s op %s span ",
KirExprKindName(expr->kind), expr->text, expr->name, expr->op);
kir_dump_span(out, expr->span);
if(expr->type[0]) fprintf(out, " type %s", expr->type);
fprintf(out, "\n");
if(expr->left >= 0)
kir_dump_expr(fn, expr->left, out, indent + 1);
if(expr->right >= 0)
kir_dump_expr(fn, expr->right, out, indent + 1);
if(expr->third >= 0)
kir_dump_expr(fn, expr->third, out, indent + 1);
for(int child = expr->first_child; child >= 0 &&
child < fn->expr_count; child = fn->exprs[child].next_sibling)
kir_dump_expr(fn, child, out, indent + 1);
}
void
KirProgramDump(const KirProgram *program, FILE *out)
{
int i;
if(out == NULL)
return;
fprintf(out, "kir 1\n");
if(program == NULL)
return;
for(i = 0; i < program->module_count; i++) {
const KirModule *m = &program->modules[i];
int j;
fprintf(out, "module %s source %s span ", m->name, m->source_path);
kir_dump_span(out, m->span);
fprintf(out, "\n");
if(m->app.has_app) {
fprintf(out, " app title %s size %dx%d fps %d theme %s "
"dark %d font_examples %d frame %s before_window %s "
"init %s after_frame %s should_continue %s scene %s "
"shutdown %s\n",
m->app.title[0] ? m->app.title : "\"\"",
m->app.width, m->app.height, m->app.fps,
m->app.theme[0] ? m->app.theme : "",
m->app.dark_mode, m->app.font_examples,
m->app.frame[0] ? m->app.frame : "",
m->app.before_window[0] ? m->app.before_window : "",
m->app.init[0] ? m->app.init : "",
m->app.after_frame[0] ? m->app.after_frame : "",
m->app.should_continue[0] ? m->app.should_continue : "",
m->app.scene[0] ? m->app.scene : "",
m->app.shutdown[0] ? m->app.shutdown : "");
}
for(j = 0; j < m->import_count; j++) {
const KirImport *imp = &m->imports[j];
fprintf(out, " import %s %s target %s",
KirImportKindName(imp->kind), imp->name, imp->target);
if(imp->kind == KIR_IMPORT_EXTERN)
fprintf(out, " extern_kind %s extern_symbol %s",
KirExternKindName(imp->extern_kind),
imp->extern_symbol);
fprintf(out, " required %d signature %s span ",
imp->required, imp->signature);
kir_dump_span(out, imp->span);
fprintf(out, "\n");
}
for(j = 0; j < m->style_import_count; j++) {
const KirStyleImport *imp = &m->style_imports[j];
fprintf(out, " style %s target %s alias %s span ",
imp->kind == KIR_STYLE_IMPORT_BUILTIN ? "builtin" : "file",
imp->target, imp->alias);
kir_dump_span(out, imp->span);
fprintf(out, "\n");
}
for(j = 0; j < m->state_count; j++) {
const KirStateField *f = &m->state_fields[j];
fprintf(out, " state %s type %s init %s span ",
f->name, f->type, f->init);
kir_dump_span(out, f->span);
fprintf(out, "\n");
}
for(j = 0; j < m->route_count; j++) {
const KirRoute *route = &m->routes[j];
fprintf(out, " route %s title %s group %s page %s path %s span ",
route->id, route->title, route->group, route->page,
route->path);
kir_dump_span(out, route->span);
fprintf(out, "\n");
}
for(j = 0; j < m->assert_count; j++) {
const KirAssert *a = &m->asserts[j];
fprintf(out, " assert condition %s known %d value %d message %s span ",
a->condition, a->known, a->value, a->message);
kir_dump_span(out, a->span);
fprintf(out, "\n");
}
for(j = 0; j < m->function_count; j++) {
const KirFunction *fn = &m->functions[j];
int k;
fprintf(out, " function %s args %s return %s exported %d span ",
fn->name, fn->args, fn->return_type, fn->exported);
kir_dump_span(out, fn->span);
fprintf(out, "\n");
for(k = 0; k < fn->stmt_count; k++) {
const KirStmt *st = &fn->stmts[k];
fprintf(out, " stmt %s widget %s args %s text %s span ",
KirStmtKindName(st->kind), st->widget, st->args,
st->text);
kir_dump_span(out, st->span);
if(st->node_name[0])
fprintf(out, " node %s", st->node_name);
if(st->node_key[0])
fprintf(out, " key %s", st->node_key);
if(st->node_path[0])
fprintf(out, " path %s", st->node_path);
if(st->node_parent_path[0])
fprintf(out, " parent %s", st->node_parent_path);
fprintf(out, "\n");
if(st->expr_root >= 0)
kir_dump_expr(fn, st->expr_root, out, 3);
if(st->lhs_root >= 0)
kir_dump_expr(fn, st->lhs_root, out, 3);
}
}
}
}
-477
View File
@@ -1,477 +0,0 @@
/*
* kir.h - Kryon intermediate representation.
*
* KIR is the shared compiler representation between .kry source and the C/KRB
* backends. This module owns the tree shape, explicit allocation, source spans,
* and deterministic dumps used by tools and tests.
*/
#ifndef KRYON_KIR_H
#define KRYON_KIR_H
#include <stdio.h>
enum {
KIR_PATH_MAX = 1024,
KIR_NAME_MAX = 128,
KIR_TEXT_MAX = 4096
};
typedef enum KirImportKind {
KIR_IMPORT_HEADER = 1,
KIR_IMPORT_MODULE,
KIR_IMPORT_EXTERN,
KIR_IMPORT_INTRINSIC,
KIR_IMPORT_CAPABILITY,
KIR_IMPORT_HOST
} KirImportKind;
typedef enum KirExternKind {
KIR_EXTERN_NONE = 0,
KIR_EXTERN_HOST,
KIR_EXTERN_GO,
KIR_EXTERN_C
} KirExternKind;
typedef enum KirStmtKind {
KIR_STMT_UNKNOWN = 0,
KIR_STMT_BLOCK_OPEN,
KIR_STMT_BLOCK_CLOSE,
KIR_STMT_DECL,
KIR_STMT_ASSIGN,
KIR_STMT_EXPR,
KIR_STMT_IF,
KIR_STMT_WHILE,
KIR_STMT_FOR,
KIR_STMT_SWITCH,
KIR_STMT_CASE,
KIR_STMT_RETURN,
KIR_STMT_BREAK,
KIR_STMT_CONTINUE,
KIR_STMT_GOTO,
KIR_STMT_LABEL,
KIR_STMT_DEFER,
KIR_STMT_UNUSED,
KIR_STMT_RAW,
KIR_STMT_WIDGET
} KirStmtKind;
typedef enum KirExprKind {
KIR_EXPR_UNKNOWN = 0,
KIR_EXPR_IDENT,
KIR_EXPR_INT,
KIR_EXPR_FLOAT,
KIR_EXPR_STRING,
KIR_EXPR_CALL,
KIR_EXPR_BINARY,
KIR_EXPR_UNARY,
KIR_EXPR_MEMBER,
KIR_EXPR_POINTER_MEMBER,
KIR_EXPR_INDEX,
KIR_EXPR_CAST,
KIR_EXPR_COMPOUND,
KIR_EXPR_SIZEOF,
KIR_EXPR_CHAR,
KIR_EXPR_CONDITIONAL,
KIR_EXPR_POSTFIX,
KIR_EXPR_FIELD_INIT,
KIR_EXPR_SLICE
} KirExprKind;
typedef struct KirSourceSpan {
char path[KIR_PATH_MAX];
int line;
int column;
int end_line;
int end_column;
} KirSourceSpan;
typedef struct KirStateField {
char name[KIR_NAME_MAX];
char type[KIR_NAME_MAX];
char init[KIR_TEXT_MAX];
char guard[KIR_TEXT_MAX]; /* enclosing '#if' condition (expanded) */
KirSourceSpan span;
} KirStateField;
typedef struct KirImport {
KirImportKind kind;
KirExternKind extern_kind;
int is_public;
char name[KIR_NAME_MAX];
char target[KIR_PATH_MAX];
char extern_symbol[KIR_NAME_MAX];
char signature[KIR_TEXT_MAX];
char args[KIR_TEXT_MAX]; /* parsed extern parameters */
char return_type[KIR_NAME_MAX];
int required;
char guard[KIR_TEXT_MAX]; /* enclosing '#if' condition (expanded) */
KirSourceSpan span;
const struct KirModule *resolved_module; /* borrowed from the checked program set */
} KirImport;
typedef enum KirStyleImportKind {
KIR_STYLE_IMPORT_FILE = 1,
KIR_STYLE_IMPORT_BUILTIN
} KirStyleImportKind;
typedef struct KirStyleImport {
KirStyleImportKind kind;
char alias[KIR_NAME_MAX];
char target[KIR_PATH_MAX];
char guard[KIR_TEXT_MAX]; /* enclosing '#if' condition (expanded) */
KirSourceSpan span;
} KirStyleImport;
typedef struct KirStmt {
KirStmtKind kind;
char text[KIR_TEXT_MAX];
char widget[KIR_NAME_MAX];
char args[KIR_TEXT_MAX];
char node_name[KIR_NAME_MAX]; /* source-level UI block identity */
char node_key[KIR_TEXT_MAX]; /* stable source-level UI key */
char node_path[KIR_TEXT_MAX]; /* stable source-level UI tree path */
char node_parent_path[KIR_TEXT_MAX];/* parent UI tree path, empty at root */
char dom_tag[KIR_NAME_MAX]; /* requested browser element tag */
char dom_ref[KIR_NAME_MAX]; /* requested Kry DOM object ref */
char dom_id[KIR_NAME_MAX]; /* requested browser id */
char dom_name_attr[KIR_NAME_MAX]; /* requested browser name attribute */
char dom_value_attr[KIR_TEXT_MAX]; /* requested browser value attribute */
char dom_class[KIR_TEXT_MAX]; /* requested browser/KSS classes */
char dom_title[KIR_TEXT_MAX]; /* requested browser title */
char dom_href[KIR_TEXT_MAX]; /* requested browser link target */
char dom_target[KIR_NAME_MAX]; /* requested browser browsing context */
char dom_rel[KIR_TEXT_MAX]; /* requested browser link relation */
char dom_for_attr[KIR_NAME_MAX]; /* requested label/control id */
char dom_part[KIR_TEXT_MAX]; /* requested element part names */
char dom_slot[KIR_NAME_MAX]; /* requested shadow slot name */
char dom_data_attrs[KIR_TEXT_MAX]; /* requested data-* attributes */
char dom_extra_attrs[KIR_TEXT_MAX]; /* requested arbitrary browser attributes */
char dom_placeholder[KIR_TEXT_MAX]; /* requested input placeholder */
char dom_input_type[KIR_NAME_MAX]; /* requested browser input type */
char dom_form_attr[KIR_NAME_MAX]; /* requested form owner id */
char dom_form_action[KIR_TEXT_MAX]; /* requested form action URL */
char dom_form_method[KIR_NAME_MAX]; /* requested form method */
char dom_form_enctype[KIR_NAME_MAX];/* requested form encoding */
char dom_autocomplete[KIR_NAME_MAX];/* requested autocomplete policy */
char dom_hidden[KIR_NAME_MAX]; /* requested hidden expression */
char dom_draggable[KIR_NAME_MAX]; /* requested draggable policy */
char dom_spellcheck[KIR_NAME_MAX]; /* requested spellcheck policy */
char dom_contenteditable[KIR_NAME_MAX]; /* requested editing policy */
char dom_autofocus[KIR_NAME_MAX]; /* requested autofocus expression */
char dom_inert[KIR_NAME_MAX]; /* requested inert expression */
char dom_autocapitalize[KIR_NAME_MAX]; /* requested autocapitalize policy */
char dom_enterkeyhint[KIR_NAME_MAX];/* requested virtual keyboard enter hint */
char dom_download[KIR_TEXT_MAX]; /* requested download filename */
char dom_formnovalidate[KIR_NAME_MAX]; /* requested formnovalidate expression */
char dom_novalidate[KIR_NAME_MAX]; /* requested novalidate expression */
char dom_popover[KIR_NAME_MAX]; /* requested popover policy */
char dom_popover_target[KIR_NAME_MAX]; /* requested popover target id */
char dom_popover_target_action[KIR_NAME_MAX]; /* requested popover target action */
char dom_readonly[KIR_NAME_MAX]; /* requested readonly expression */
char dom_required[KIR_NAME_MAX]; /* requested required expression */
char dom_min[KIR_NAME_MAX]; /* requested form min expression */
char dom_max[KIR_NAME_MAX]; /* requested form max expression */
char dom_step[KIR_NAME_MAX]; /* requested form step expression */
char dom_minlength[KIR_NAME_MAX]; /* requested minlength expression */
char dom_maxlength[KIR_NAME_MAX]; /* requested maxlength expression */
char dom_pattern[KIR_TEXT_MAX]; /* requested form validation pattern */
char dom_accept[KIR_TEXT_MAX]; /* requested file accept list */
char dom_multiple[KIR_NAME_MAX]; /* requested multiple expression */
char dom_inputmode[KIR_NAME_MAX]; /* requested inputmode hint */
char dom_headers[KIR_TEXT_MAX]; /* requested table header refs */
char dom_scope[KIR_NAME_MAX]; /* requested table header scope */
char dom_colspan[KIR_NAME_MAX]; /* requested table colspan expression */
char dom_rowspan[KIR_NAME_MAX]; /* requested table rowspan expression */
char dom_tab_index[KIR_NAME_MAX]; /* requested tabindex expression */
char dom_role[KIR_NAME_MAX]; /* requested accessibility role */
char dom_aria_label[KIR_TEXT_MAX]; /* requested accessible label */
char dom_aria_description[KIR_TEXT_MAX]; /* requested accessible description */
char dom_aria_describedby[KIR_TEXT_MAX]; /* requested accessible relationship */
char dom_aria_labelledby[KIR_TEXT_MAX]; /* requested labelling relationship */
char dom_aria_activedescendant[KIR_TEXT_MAX]; /* requested active descendant */
char dom_aria_controls[KIR_TEXT_MAX]; /* requested controlled element ids */
char dom_aria_owns[KIR_TEXT_MAX]; /* requested owned element ids */
char dom_aria_sort[KIR_NAME_MAX]; /* requested table/list sort order */
char dom_aria_orientation[KIR_NAME_MAX]; /* requested widget orientation */
char dom_aria_level[KIR_NAME_MAX]; /* requested tree/list level */
char dom_aria_posinset[KIR_NAME_MAX]; /* requested item position */
char dom_aria_setsize[KIR_NAME_MAX]; /* requested set size */
char dom_aria_haspopup[KIR_NAME_MAX]; /* requested popup relationship type */
char dom_aria_multiselectable[KIR_NAME_MAX]; /* requested multi-select state */
char dom_aria_rowindex[KIR_NAME_MAX]; /* requested table/grid row index */
char dom_aria_colindex[KIR_NAME_MAX]; /* requested table/grid column index */
char dom_aria_rowcount[KIR_NAME_MAX]; /* requested table/grid row count */
char dom_aria_colcount[KIR_NAME_MAX]; /* requested table/grid column count */
char dom_aria_live[KIR_NAME_MAX]; /* requested live region policy */
char dom_aria_attrs[KIR_TEXT_MAX]; /* requested arbitrary aria-* attributes */
char dom_on_click[KIR_NAME_MAX]; /* logic function bound to click */
char dom_on_input[KIR_NAME_MAX]; /* logic function bound to input(value) */
char dom_on_before_input[KIR_NAME_MAX]; /* logic function bound to beforeinput(value) */
char dom_on_change[KIR_NAME_MAX]; /* logic function bound to change(value) */
char dom_on_select[KIR_NAME_MAX]; /* logic function bound to select(value) */
char dom_on_key[KIR_NAME_MAX]; /* logic function bound to keydown(key) */
char dom_on_invalid[KIR_NAME_MAX]; /* logic function bound to invalid(value) */
char dom_on_submit[KIR_NAME_MAX]; /* logic function bound to submit */
char dom_on_reset[KIR_NAME_MAX]; /* logic function bound to reset */
char dom_on_toggle[KIR_NAME_MAX]; /* logic function bound to toggle */
char dom_on_close[KIR_NAME_MAX]; /* logic function bound to close */
char dom_on_cancel[KIR_NAME_MAX]; /* logic function bound to cancel */
char dom_on_focus[KIR_NAME_MAX]; /* logic function bound to focus */
char dom_on_blur[KIR_NAME_MAX]; /* logic function bound to blur */
char dom_on_scroll[KIR_NAME_MAX]; /* logic function bound to scroll(value) */
char dom_on_mouse_enter[KIR_NAME_MAX]; /* logic function bound to mouseenter */
char dom_on_mouse_leave[KIR_NAME_MAX]; /* logic function bound to mouseleave */
char dom_on_mouse_move[KIR_NAME_MAX]; /* logic function bound to mousemove */
char dom_on_mouse_down[KIR_NAME_MAX]; /* logic function bound to mousedown */
char dom_on_mouse_up[KIR_NAME_MAX]; /* logic function bound to mouseup */
char dom_on_wheel[KIR_NAME_MAX]; /* logic function bound to wheel(value) */
char dom_on_drag_start[KIR_NAME_MAX]; /* logic function bound to dragstart(value) */
char dom_on_drag_end[KIR_NAME_MAX]; /* logic function bound to dragend(value) */
char dom_on_drag_over[KIR_NAME_MAX]; /* logic function bound to dragover */
char dom_on_drop[KIR_NAME_MAX]; /* logic function bound to drop(value) */
char dom_on_copy[KIR_NAME_MAX]; /* logic function bound to copy(value) */
char dom_on_cut[KIR_NAME_MAX]; /* logic function bound to cut(value) */
char dom_on_paste[KIR_NAME_MAX]; /* logic function bound to paste(value) */
int declared_widget; /* typed #ui block invocation, resolved after imports */
int widget_fallback; /* leaf block may use host props only if no declaration resolves */
int is_instance; /* typed record binding retained by its explicit key */
int expr_root; /* index into enclosing function exprs, or -1 */
int lhs_root; /* structured assignment destination, or -1 */
char name[KIR_NAME_MAX]; /* declaration binding */
char type[KIR_NAME_MAX]; /* declared or inferred type */
char assignment_op[4];
KirSourceSpan span;
} KirStmt;
typedef struct KirExpr {
KirExprKind kind;
int is_function_value; /* declaration bound to an expected slot signature */
char slot_type[KIR_NAME_MAX]; /* lexical callable signature, empty for ordinary calls */
char text[KIR_TEXT_MAX];
char name[KIR_NAME_MAX];
char op[8];
int left;
int right;
int first_child;
int next_sibling;
int third; /* false conditional arm or slice upper bound, or -1 */
char type[KIR_NAME_MAX]; /* resolved type; empty means unresolved */
KirSourceSpan span;
} KirExpr;
typedef struct KirCapture {
int is_instance;
char name[KIR_NAME_MAX];
char type[KIR_NAME_MAX];
} KirCapture;
typedef struct KirFunction {
char name[KIR_NAME_MAX];
char args[KIR_TEXT_MAX];
char return_type[KIR_NAME_MAX];
int exported;
int is_extern;
KirExternKind extern_kind;
int is_colon; /* 'Name :: (...) {' form: C name has no _kry_draw suffix */
int is_closure; /* inline slot body, emitted at its lexical binding */
KirCapture *captures;
int capture_count;
int is_ui; /* '#ui' function: declares a retained UI hierarchy */
int is_public; /* exported function or project route */
int checked; /* shared checker resolved the function without errors */
int uses_host; /* direct or transitive host services or retained-state access */
char extern_target[KIR_NAME_MAX]; /* '#extern "pkg.Fn"' quoted symbol */
char extern_symbol[KIR_NAME_MAX]; /* stripped C symbol for c.* externs */
char guard[KIR_TEXT_MAX]; /* enclosing '#if' condition (expanded) */
KirSourceSpan span;
KirStmt *stmts;
int stmt_count;
int stmt_cap;
KirExpr *exprs;
int expr_count;
int expr_cap;
} KirFunction;
typedef struct KirGlobal {
char name[KIR_NAME_MAX];
char type[KIR_TEXT_MAX];
char init[KIR_TEXT_MAX];
int is_static; /* 'static name: T = init' — internal linkage */
char guard[KIR_TEXT_MAX]; /* enclosing '#if' condition (expanded) */
KirSourceSpan span;
} KirGlobal;
/* A Kry `Name :: value` constant emitted into generated target interfaces. */
typedef struct KirDefine {
char name[KIR_NAME_MAX];
char value[KIR_TEXT_MAX];
char guard[KIR_TEXT_MAX]; /* enclosing '#if' condition (expanded) */
KirSourceSpan span;
} KirDefine;
typedef struct KirAssert {
char condition[KIR_TEXT_MAX]; /* expanded C preprocessor condition */
char message[KIR_TEXT_MAX]; /* C #error payload */
int known; /* condition resolved by Kry frontend */
int value; /* boolean value when known */
char guard[KIR_TEXT_MAX]; /* enclosing '#if' condition (expanded) */
KirSourceSpan span;
} KirAssert;
/* A `Name :: struct { fields }` type declaration. body holds the raw field
* lines (one per line, no braces). */
typedef struct KirType {
char name[KIR_NAME_MAX];
char body[KIR_TEXT_MAX * 2];
int is_slot; /* named, synchronous child-content signature; body holds parameters */
int is_enum; /* 'Name :: enum' — emit typedef enum, not struct */
int is_extern; /* host-owned C record; native Go emits the declared shape */
char guard[KIR_TEXT_MAX]; /* enclosing '#if' condition (expanded) */
KirSourceSpan span;
} KirType;
typedef struct KirTypeField {
char name[KIR_NAME_MAX];
char type[KIR_NAME_MAX];
} KirTypeField;
/* Start offset at zero. Returns 1 for a field, 0 at end, -1 for malformed
* record syntax. Names/types are trimmed without truncating source tokens. */
int KirTypeNextField(const KirType *record, size_t *offset, KirTypeField *field);
/* Parse a fixed-capacity array type text "[N]element". Returns 1 with the
* element type copied out and the capacity stored, 0 for any other type. */
int KirSliceElementType(const char *type, char *element, size_t element_size);
int KirArrayElementType(const char *type, char *element, size_t element_size,
int *capacity);
typedef struct KirAppMeta {
int has_app;
char title[KIR_NAME_MAX];
int width;
int height;
int fps;
char theme[KIR_NAME_MAX];
int dark_mode;
int font_examples;
char frame[KIR_NAME_MAX];
char before_window[KIR_NAME_MAX];
char init[KIR_NAME_MAX];
char after_frame[KIR_NAME_MAX];
char should_continue[KIR_NAME_MAX];
char scene[KIR_NAME_MAX];
char shutdown[KIR_NAME_MAX];
} KirAppMeta;
typedef struct KirRoute {
char id[KIR_NAME_MAX];
char title[KIR_NAME_MAX];
char group[KIR_NAME_MAX];
char page[KIR_NAME_MAX];
char path[KIR_PATH_MAX];
char guard[KIR_TEXT_MAX];
KirSourceSpan span;
} KirRoute;
typedef struct KirModule {
char name[KIR_NAME_MAX];
char source_path[KIR_PATH_MAX];
int inspect_calls;
KirSourceSpan span;
KirAppMeta app;
KirGlobal *globals;
int global_count;
int global_cap;
KirDefine *defines;
int define_count;
int define_cap;
KirAssert *asserts;
int assert_count;
int assert_cap;
KirType *types;
int type_count;
int type_cap;
KirStateField *state_fields;
int state_count;
int state_cap;
KirImport *imports;
int import_count;
int import_cap;
KirStyleImport *style_imports;
int style_import_count;
int style_import_cap;
KirRoute *routes;
int route_count;
int route_cap;
KirFunction *functions;
int function_count;
int function_cap;
} KirModule;
typedef struct KirProgram {
KirModule *modules;
int module_count;
int module_cap;
} KirProgram;
/* Local records and direct unqualified Kry imports; owner supplies field scope. */
/* Local declarations shadow imports. Returns 1 found, 0 absent, -1 ambiguous. */
int KirResolveFunction(const KirModule *module, const char *name,
const KirModule **owner, const KirFunction **function);
/* Runtime contracts are parsed from embedded declaration sources. */
const KirType *KirFindRuntimeEnumMember(const char *name);
const KirType *KirFindRuntimeType(const char *name, const KirModule **owner);
const KirType *KirFindType(const KirModule *module, const char *name,
const KirModule **owner);
int KirResolveEnumMember(const KirModule *module, const char *name,
const KirModule **owner, const KirType **type);
KirProgram *KirProgramNew(void);
void KirProgramFree(KirProgram *program);
void kir_copy(char *dst, size_t dst_size, const char *src);
KirSourceSpan KirSpan(const char *path, int line, int column);
KirSourceSpan KirSpanEnd(const char *path, int line, int column,
int end_line, int end_column);
KirModule *KirProgramAddModule(KirProgram *program, const char *name,
const char *source_path, KirSourceSpan span);
KirStateField *KirModuleAddStateField(KirModule *module, const char *name,
const char *type, const char *init,
KirSourceSpan span);
KirImport *KirModuleAddImport(KirModule *module, KirImportKind kind,
const char *name, const char *target,
const char *signature, int required,
KirSourceSpan span);
KirStyleImport *KirModuleAddStyleImport(KirModule *module,
KirStyleImportKind kind,
const char *target,
const char *alias,
KirSourceSpan span);
KirFunction *KirModuleAddFunction(KirModule *module, const char *name,
const char *args, const char *return_type,
int exported, KirSourceSpan span);
void KirModuleAddGlobal(KirModule *module, const char *name, const char *type,
const char *init, KirSourceSpan span);
void KirModuleAddStatic(KirModule *module, const char *name, const char *type,
const char *init, KirSourceSpan span);
KirDefine *KirModuleAddDefine(KirModule *module, const char *name,
const char *value, KirSourceSpan span);
KirAssert *KirModuleAddAssert(KirModule *module, const char *condition,
const char *message, KirSourceSpan span);
KirType *KirModuleAddType(KirModule *module, const char *name,
KirSourceSpan span);
KirRoute *KirModuleAddRoute(KirModule *module, const char *id,
KirSourceSpan span);
KirStmt *KirFunctionAddStmt(KirFunction *fn, KirStmtKind kind,
const char *text, const char *widget,
KirSourceSpan span);
KirStmt *KirFunctionAddWidget(KirFunction *fn, const char *widget,
const char *args, const char *text,
KirSourceSpan span);
const char *KirImportKindName(KirImportKind kind);
const char *KirStmtKindName(KirStmtKind kind);
const char *KirExprKindName(KirExprKind kind);
KirExpr *KirFunctionAddExpr(KirFunction *fn, KirExprKind kind,
const char *text, KirSourceSpan span);
void KirProgramDump(const KirProgram *program, FILE *out);
#endif /* KRYON_KIR_H */
-285
View File
@@ -1,285 +0,0 @@
#include "kir_borrow.h"
#include "kir_diagnostic.h"
#include "kir_text.h"
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
typedef struct Origin {
uint64_t parameters;
int depth;
int invalid;
} Origin;
typedef struct BorrowFunction {
const KirModule *module;
const KirFunction *fn;
Origin returned;
Origin *locals;
} BorrowFunction;
typedef struct BorrowBinding {
char name[KIR_NAME_MAX];
char type[KIR_NAME_MAX];
Origin origin;
int local;
int depth;
int captured;
} BorrowBinding;
typedef struct BorrowCheck {
BorrowFunction *functions;
int count;
BorrowFunction *current;
BorrowBinding *bindings;
int binding_count;
int depth;
int changed;
int failed;
} BorrowCheck;
static Origin
merge(Origin a, Origin b)
{
a.parameters |= b.parameters;
if(b.depth > a.depth)
a.depth = b.depth;
a.invalid |= b.invalid;
return a;
}
static void
accumulate(BorrowCheck *check, Origin *destination, Origin source)
{
Origin next = merge(*destination, source);
if(next.parameters != destination->parameters || next.depth != destination->depth ||
next.invalid != destination->invalid) {
*destination = next;
check->changed = 1;
}
}
static void
reject(BorrowCheck *check, KirSourceSpan span, const char *message)
{
if(!check->failed)
KirDiagnostic(span, "check.slice_lifetime", "%s", message);
check->failed = 1;
}
static BorrowBinding *
binding(BorrowCheck *check, const char *name)
{
for(int i = check->binding_count - 1; i >= 0; i--)
if(!strcmp(check->bindings[i].name, name))
return &check->bindings[i];
return NULL;
}
static Origin expression_origin(BorrowCheck *check, int index);
static Origin
call_origin(BorrowCheck *check, const KirExpr *expression)
{
const KirModule *owner = NULL;
const KirFunction *callee = NULL;
if(KirResolveFunction(check->current->module, expression->name, &owner, &callee) <= 0)
return (Origin){0, 0, 1};
BorrowFunction *summary = NULL;
for(int i = 0; i < check->count; i++)
if(check->functions[i].fn == callee)
summary = &check->functions[i];
if(summary == NULL)
return (Origin){0, 0, 1};
Origin result = {0, summary->returned.depth, summary->returned.invalid};
int ordinal = 0;
for(int child = expression->first_child; child >= 0;
child = check->current->fn->exprs[child].next_sibling, ordinal++) {
if(ordinal < 64 && (summary->returned.parameters & (UINT64_C(1) << ordinal)))
result = merge(result, expression_origin(check, child));
}
return result;
}
static Origin
expression_origin(BorrowCheck *check, int index)
{
if(index < 0)
return (Origin){0};
const KirFunction *fn = check->current->fn;
const KirExpr *expression = &fn->exprs[index];
switch(expression->kind) {
case KIR_EXPR_IDENT: {
BorrowBinding *source = binding(check, expression->name);
if(expression->type[0] != '[' && strchr(expression->type, '*') != NULL)
return (Origin){0, 0, 1};
if(source == NULL)
return (Origin){0}; /* Typed module-owned array or record storage. */
if(KirSliceElementType(source->type, NULL, 0))
return source->local >= 0 ? check->current->locals[source->local] : source->origin;
return (Origin){0, source->depth, source->captured == 2};
}
case KIR_EXPR_MEMBER:
case KIR_EXPR_INDEX:
case KIR_EXPR_SLICE:
return expression_origin(check, expression->left);
case KIR_EXPR_CONDITIONAL:
return merge(expression_origin(check, expression->right),
expression_origin(check, expression->third));
case KIR_EXPR_CALL:
if(KirSliceElementType(expression->type, NULL, 0))
return call_origin(check, expression);
return (Origin){0, 0, 1}; /* A returned array/record is temporary storage. */
default:
return (Origin){0, 0, 1};
}
}
/* Inspect every range, including ranges passed directly to void/scalar calls. */
static void
check_ranges(BorrowCheck *check, int index)
{
if(index < 0 || check->failed)
return;
const KirExpr *expression = &check->current->fn->exprs[index];
if(expression->kind == KIR_EXPR_SLICE && expression_origin(check, index).invalid)
reject(check, expression->span, "slice range requires live owned backing storage");
check_ranges(check, expression->left);
check_ranges(check, expression->right);
check_ranges(check, expression->third);
for(int child = expression->first_child; child >= 0;
child = check->current->fn->exprs[child].next_sibling)
check_ranges(check, child);
}
static void
add_binding(BorrowCheck *check, const char *name, const char *type,
Origin origin, int local, int depth, int captured)
{
BorrowBinding *item = &check->bindings[check->binding_count++];
kir_copy(item->name, sizeof(item->name), name);
kir_copy(item->type, sizeof(item->type), type);
item->origin = origin;
item->local = local;
item->depth = depth;
item->captured = captured;
}
static void
check_function(BorrowCheck *check, BorrowFunction *function)
{
const KirFunction *fn = function->fn;
check->current = function;
check->binding_count = 0;
check->depth = 1;
check->bindings = calloc((size_t)fn->stmt_count + fn->capture_count + 65, sizeof(*check->bindings));
if(check->bindings == NULL) {
reject(check, fn->span, "out of memory checking slice lifetimes");
return;
}
for(int i = 0; i < fn->capture_count; i++) {
const KirCapture *capture = &fn->captures[i];
add_binding(check, capture->name, capture->type, (Origin){0}, -1, 0,
capture->is_instance ? 2 : 1);
}
char parameters[64][KIR_TEXT_MAX];
int count = *kir_skip_ws(fn->args) ?
kir_split_top(fn->args, parameters[0], 64, sizeof(parameters[0])) : 0;
for(int i = 0; i < count; i++) {
char *colon = strchr(parameters[i], ':');
if(colon == NULL)
continue;
*colon++ = '\0';
kir_trim_in_place(parameters[i]);
kir_trim_in_place(colon);
Origin origin = {0};
int local = -1;
if(KirSliceElementType(colon, NULL, 0)) {
origin.parameters = UINT64_C(1) << i;
local = fn->stmt_count + i;
accumulate(check, &function->locals[local], origin);
}
add_binding(check, parameters[i], colon, origin, local, 1, 0);
}
for(int i = 0; i < fn->stmt_count && !check->failed; i++) {
const KirStmt *statement = &fn->stmts[i];
if(statement->kind == KIR_STMT_BLOCK_CLOSE) {
while(check->binding_count && check->bindings[check->binding_count - 1].depth == check->depth)
check->binding_count--;
check->depth--;
continue;
}
check_ranges(check, statement->lhs_root);
check_ranges(check, statement->expr_root);
if(statement->kind == KIR_STMT_DECL) {
if(KirSliceElementType(statement->type, NULL, 0)) {
Origin source = expression_origin(check, statement->expr_root);
accumulate(check, &function->locals[i], source);
if(source.invalid || source.depth > check->depth)
reject(check, statement->span, "slice initializer outlives its backing storage");
}
add_binding(check, statement->name, statement->type, (Origin){0}, i,
check->depth, statement->is_instance ? 2 : 0);
} else if(statement->kind == KIR_STMT_ASSIGN && statement->lhs_root >= 0) {
const KirExpr *destination = &fn->exprs[statement->lhs_root];
if(KirSliceElementType(destination->type, NULL, 0)) {
BorrowBinding *target = destination->kind == KIR_EXPR_IDENT ?
binding(check, destination->name) : NULL;
Origin source = expression_origin(check, statement->expr_root);
if(target == NULL || target->captured || source.invalid || source.depth > target->depth) {
reject(check, statement->span, "slice assignment may escape its backing storage");
} else if(target->local >= 0) {
accumulate(check, &function->locals[target->local], source);
}
}
} else if(statement->kind == KIR_STMT_RETURN && KirSliceElementType(fn->return_type, NULL, 0)) {
Origin source = expression_origin(check, statement->expr_root);
if(source.invalid || source.depth > 0)
reject(check, statement->span, "returned slice borrows local or temporary storage");
accumulate(check, &function->returned, source);
}
if(statement->kind == KIR_STMT_IF || statement->kind == KIR_STMT_WHILE ||
statement->kind == KIR_STMT_BLOCK_OPEN)
check->depth++;
}
free(check->bindings);
check->bindings = NULL;
}
int
KirCheckSliceLifetimes(KirProgram **programs, int count)
{
BorrowCheck check = {0};
for(int p = 0; p < count; p++)
for(int m = 0; m < programs[p]->module_count; m++)
check.count += programs[p]->modules[m].function_count;
check.functions = calloc((size_t)check.count, sizeof(*check.functions));
if(check.functions == NULL && check.count != 0)
return 0;
int index = 0;
for(int p = 0; p < count; p++) {
for(int m = 0; m < programs[p]->module_count; m++) {
const KirModule *module = &programs[p]->modules[m];
for(int f = 0; f < module->function_count; f++) {
BorrowFunction *function = &check.functions[index++];
function->module = module;
function->fn = &module->functions[f];
function->locals = calloc((size_t)function->fn->stmt_count + 64, sizeof(Origin));
if(function->locals == NULL)
check.failed = 1;
}
}
}
do {
check.changed = 0;
for(int i = 0; i < check.count && !check.failed; i++) {
if(check.functions[i].fn->checked && !check.functions[i].fn->is_extern)
check_function(&check, &check.functions[i]);
}
} while(check.changed && !check.failed);
for(int i = 0; i < check.count; i++)
free(check.functions[i].locals);
free(check.functions);
return !check.failed;
}
-5
View File
@@ -1,5 +0,0 @@
#ifndef KIR_BORROW_H
#define KIR_BORROW_H
#include "kir.h"
int KirCheckSliceLifetimes(KirProgram **programs, int count);
#endif
-1707
View File
File diff suppressed because it is too large. Load diff
-9
View File
@@ -1,9 +0,0 @@
#ifndef KIR_CHECK_H
#define KIR_CHECK_H
#include "kir.h"
/* Resolve scalar expression types and lexical bindings. Strict mode rejects
* unresolved expressions instead of delegating them to target-language text. */
int KirCheckPrograms(KirProgram **programs, int count, int strict);
const char *KirScalarType(const char *type);
#endif
-297
View File
@@ -1,297 +0,0 @@
#include "kir_cleanup.h"
#include "kir_text.h"
#include "kir_token.h"
#include "kir_expr.h"
#include <stdlib.h>
#include <string.h>
typedef struct Cleanup {
KirStmt statement;
int depth;
} Cleanup;
static int append(KirFunction *out, const KirStmt *st);
static int
fail(const KirStmt *st, const char *message)
{
fprintf(stderr, "%s:%d:%d: %s\n", st->span.path, st->span.line,
st->span.column, message);
return 0;
}
static int
mentions(const char *text, const char *name)
{
KirLexer lexer;
KirToken token;
KirLexerInit(&lexer, text, "");
do {
token = KirLexerNext(&lexer);
if(token.kind == KIR_TOKEN_IDENT && !strcmp(token.text, name)) return 1;
} while(token.kind != KIR_TOKEN_EOF);
return 0;
}
static int
action_kind(const char *text, KirStmt *action)
{
KirLexer lexer;
KirToken token;
KirFunction temporary = {0};
int valid;
action->kind = KIR_STMT_EXPR;
KirLexerInit(&lexer, text, action->span.path);
token = KirLexerNext(&lexer);
if(!strcmp(token.text, "return") || !strcmp(token.text, "break") ||
!strcmp(token.text, "continue") || !strcmp(token.text, "goto") ||
!strcmp(token.text, "defer") || !strcmp(token.text, "if") ||
!strcmp(token.text, "while") || !strcmp(token.text, "for")) return 0;
KirLexerInit(&lexer, text, action->span.path);
do {
token = KirLexerNext(&lexer);
if(!strcmp(token.text, "=") || !strcmp(token.text, "+=") ||
!strcmp(token.text, "-=") || !strcmp(token.text, "*=") ||
!strcmp(token.text, "/=") || !strcmp(token.text, "%=") ||
!strcmp(token.text, "&=") || !strcmp(token.text, "|=") ||
!strcmp(token.text, "^=") || !strcmp(token.text, "<<=") || !strcmp(token.text, ">>="))
action->kind = KIR_STMT_ASSIGN;
} while(token.kind != KIR_TOKEN_EOF);
kir_copy(action->text, sizeof(action->text), text);
if(!append(&temporary, action)) return 0;
KirStructureFunction(&temporary, NULL);
valid = temporary.stmts[0].expr_root >= 0 &&
temporary.exprs[temporary.stmts[0].expr_root].kind != KIR_EXPR_UNKNOWN;
free(temporary.stmts); free(temporary.exprs);
return valid;
}
static int
append(KirFunction *out, const KirStmt *st)
{
KirStmt *copy = KirFunctionAddStmt(out, st->kind, st->text, st->widget,
st->span);
if(!copy)
return 0;
*copy = *st;
return 1;
}
static int
emit(KirFunction *out, Cleanup *entries, int count, int minimum)
{
for(int i = count - 1; i >= 0 && entries[i].depth >= minimum; i--)
if(!append(out, &entries[i].statement))
return 0;
return 1;
}
static int
opens(KirStmtKind kind)
{
return kind == KIR_STMT_BLOCK_OPEN || kind == KIR_STMT_IF ||
kind == KIR_STMT_WHILE || kind == KIR_STMT_FOR || kind == KIR_STMT_SWITCH;
}
static int
opens_stmt(const KirStmt *st)
{
return opens(st->kind) ||
(st->kind == KIR_STMT_CASE && strchr(st->text, '{') != NULL);
}
static int
end_block(const KirFunction *fn, int start, int end)
{
int depth = 1;
for(int i = start + 1; i < end; i++) {
if(opens_stmt(&fn->stmts[i])) depth++;
if(fn->stmts[i].kind == KIR_STMT_BLOCK_CLOSE && !--depth) return i;
}
return end;
}
static int
falls_through(const KirFunction *fn, int start, int end)
{
for(int i = start; i < end; i++) {
KirStmtKind kind = fn->stmts[i].kind;
if(kind == KIR_STMT_RETURN || kind == KIR_STMT_BREAK || kind == KIR_STMT_CONTINUE)
return 0;
if(opens_stmt(&fn->stmts[i])) {
int close = end_block(fn, i, end);
int falls = falls_through(fn, i + 1, close);
if(kind == KIR_STMT_BLOCK_OPEN && !falls) return 0;
if(kind == KIR_STMT_IF) {
int has_else = 0;
while(close + 1 < end && fn->stmts[close + 1].kind == KIR_STMT_IF &&
strncmp(fn->stmts[close + 1].text, "else", 4) == 0) {
int next = close + 1;
has_else = strncmp(kir_skip_ws(fn->stmts[next].text + 4), "if", 2) != 0;
close = end_block(fn, next, end);
falls |= falls_through(fn, next + 1, close);
}
if(has_else && !falls) return 0;
}
i = close;
}
}
return 1;
}
int
KirLowerCleanup(KirFunction *fn)
{
int has_cleanup = 0, depth = 0, count = 0, serial = 0, ok = 0;
Cleanup *entries;
KirStmtKind *scopes;
int *scope_start;
KirFunction out = {0};
for(int i = 0; i < fn->stmt_count; i++)
has_cleanup |= fn->stmts[i].kind == KIR_STMT_DEFER;
if(!has_cleanup)
return 1;
entries = calloc((size_t)fn->stmt_count + 1, sizeof(*entries));
scopes = calloc((size_t)fn->stmt_count + 1, sizeof(*scopes));
scope_start = calloc((size_t)fn->stmt_count + 1, sizeof(*scope_start));
if(!entries || !scopes || !scope_start)
goto done;
for(int i = 0; i < fn->stmt_count; i++) {
const KirStmt *st = &fn->stmts[i];
if(st->kind == KIR_STMT_IF && !strncmp(st->text, "guard ", 6) && count) {
fail(st, "guard with defer requires an explicit if and return");
goto done;
}
if((st->kind == KIR_STMT_GOTO || st->kind == KIR_STMT_LABEL) && count) {
fail(st, "goto and labels in functions with defer are not supported");
goto done;
}
if(st->kind == KIR_STMT_RAW) {
fail(st, "raw C and conditional preprocessing in functions with defer are not supported");
goto done;
}
if(st->kind == KIR_STMT_DECL) {
KirLexer lexer;
KirToken name;
KirLexerInit(&lexer, st->text, st->span.path);
name = KirLexerNext(&lexer);
for(int d = 0; d < count; d++) {
if(mentions(entries[d].statement.text, name.text)) {
fail(st, "a declaration cannot shadow a name referenced by an active defer");
goto done;
}
}
}
if(st->kind == KIR_STMT_FOR) {
for(int d = 0; d < count; d++) {
KirLexer lexer;
KirToken token;
KirLexerInit(&lexer, st->text, st->span.path);
do {
token = KirLexerNext(&lexer);
if(token.kind == KIR_TOKEN_IDENT &&
mentions(entries[d].statement.text, token.text)) {
fail(st, "a for header cannot reuse a name referenced by an active defer; use a while loop");
goto done;
}
} while(token.kind != KIR_TOKEN_EOF);
}
}
if(st->kind == KIR_STMT_DEFER) {
const char *body = kir_skip_ws(st->text + 5);
KirStmt *action = &entries[count].statement;
if(scopes[depth] == KIR_STMT_SWITCH) {
fail(st, "defer in a switch case requires an explicit block");
goto done;
}
/* Cleanup actions are expressions or assignments, never jumps or
* declarations. Keep their source span for backend diagnostics. */
*action = *st;
if(!action_kind(body, action)) {
fail(st, "defer requires one expression or assignment");
goto done;
}
action->expr_root = -1;
kir_copy(action->text, sizeof(action->text), body);
entries[count++].depth = depth;
continue;
}
if(st->kind == KIR_STMT_RETURN && count) {
KirStmt result = *st;
const char *value = kir_skip_ws(st->text + 6);
if(*value && strcmp(value, ";")) {
char name[KIR_NAME_MAX];
int collision;
/* Reserve a fresh local without reserving user identifiers. */
do {
snprintf(name, sizeof(name), "cleanup_return_%d", serial++);
collision = strstr(fn->args, name) != NULL;
for(int k = 0; k < fn->stmt_count; k++)
collision |= strstr(fn->stmts[k].text, name) != NULL;
} while(collision);
result.kind = KIR_STMT_DECL;
result.expr_root = st->expr_root;
if(snprintf(result.text, sizeof(result.text), "%s: %s = %s",
name, fn->return_type, value) >= (int)sizeof(result.text)) {
fail(st, "return expression exceeds cleanup lowering limit");
goto done;
}
if(!append(&out, &result))
goto done;
result.kind = KIR_STMT_RETURN;
result.expr_root = -1;
snprintf(result.text, sizeof(result.text), "return %s", name);
}
if(!emit(&out, entries, count, 0) || !append(&out, &result))
goto done;
continue;
}
if(st->kind == KIR_STMT_BREAK || st->kind == KIR_STMT_CONTINUE) {
int target = depth;
while(target > 0 && scopes[target] != KIR_STMT_FOR &&
scopes[target] != KIR_STMT_WHILE &&
!(st->kind == KIR_STMT_BREAK && scopes[target] == KIR_STMT_SWITCH))
target--;
if(!target) {
fail(st, "loop control outside a loop or switch");
goto done;
}
if(!emit(&out, entries, count, target))
goto done;
}
if(st->kind == KIR_STMT_BLOCK_CLOSE) {
if(!depth) {
fail(st, "unbalanced cleanup scope");
goto done;
}
if(falls_through(fn, scope_start[depth], i) &&
!emit(&out, entries, count, depth))
goto done;
while(count && entries[count - 1].depth >= depth)
count--;
depth--;
}
if(!append(&out, st))
goto done;
if(opens_stmt(st)) {
scopes[++depth] = st->kind;
scope_start[depth] = i + 1;
}
}
if(falls_through(fn, 0, fn->stmt_count) && !emit(&out, entries, count, 0))
goto done;
free(fn->stmts);
fn->stmts = out.stmts;
fn->stmt_count = out.stmt_count;
fn->stmt_cap = out.stmt_cap;
out.stmts = NULL;
ok = 1;
done:
free(out.stmts);
free(entries);
free(scopes);
free(scope_start);
return ok;
}
-7
View File
@@ -1,7 +0,0 @@
#ifndef KIR_CLEANUP_H
#define KIR_CLEANUP_H
#include "kir.h"
/* Lower lexical cleanup once, before backend emission. Returns zero on error. */
int KirLowerCleanup(KirFunction *fn);
#endif
-67
View File
@@ -1,67 +0,0 @@
#include "kir_diagnostic.h"
#include "kry_json.h"
#include <stdlib.h>
#include <string.h>
static int diagnostic_json = -1;
int
KirSetDiagnosticFormat(const char *format)
{
if(strcmp(format, "json") == 0)
diagnostic_json = 1;
else if(strcmp(format, "text") == 0)
diagnostic_json = 0;
else
return 0;
return 1;
}
void
KirDiagnosticV(KirSourceSpan span, const char *code, const char *format, va_list args)
{
char message[KIR_TEXT_MAX * 2];
vsnprintf(message, sizeof(message), format, args);
if(diagnostic_json < 0) {
const char *environment = getenv("KRYON_DIAGNOSTICS");
diagnostic_json = environment != NULL && strcmp(environment, "json") == 0;
}
if(diagnostic_json) {
KryJsonBuf json = {0};
kry_json_buf_raw(&json, "{\"severity\":\"error\",\"code\":");
kry_json_buf_str(&json, code);
kry_json_buf_raw(&json, ",\"message\":");
kry_json_buf_str(&json, message);
kry_json_buf_raw(&json, ",\"path\":");
kry_json_buf_str(&json, span.path);
kry_json_buf_raw(&json, ",\"line\":");
kry_json_buf_num(&json, span.line);
kry_json_buf_raw(&json, ",\"column\":");
kry_json_buf_num(&json, span.column);
kry_json_buf_raw(&json, ",\"end_line\":");
kry_json_buf_num(&json, span.end_line > 0 ? span.end_line : span.line);
kry_json_buf_raw(&json, ",\"end_column\":");
kry_json_buf_num(&json, span.end_column > 0 ? span.end_column : span.column);
kry_json_buf_raw(&json, "}");
fprintf(stderr, "%s\n", kry_json_buf_finish(&json));
kry_json_buf_free(&json);
} else if(span.path[0] != '\0') {
fprintf(stderr, "%s:%d:%d: %s\n", span.path, span.line, span.column, message);
} else {
fprintf(stderr, "kry: %s\n", message);
}
}
void
KirDiagnostic(KirSourceSpan span, const char *code, const char *format, ...)
{
va_list args;
va_start(args, format);
KirDiagnosticV(span, code, format, args);
va_end(args);
}
-11
View File
@@ -1,11 +0,0 @@
#ifndef KIR_DIAGNOSTIC_H
#define KIR_DIAGNOSTIC_H
#include "kir.h"
#include <stdarg.h>
int KirSetDiagnosticFormat(const char *format);
void KirDiagnostic(KirSourceSpan span, const char *code, const char *format, ...);
void KirDiagnosticV(KirSourceSpan span, const char *code, const char *format, va_list args);
#endif
-1839
View File
File diff suppressed because it is too large. Load diff
-37
View File
@@ -1,37 +0,0 @@
#ifndef KIR_EMIT_H
#define KIR_EMIT_H
#include "kir.h"
typedef enum KirTarget { KIR_C, KIR_CPP, KIR_GO, KIR_JS } KirTarget;
/* Resolve target symbol spelling and call ABI. Input contains identifiers and
* captured argument names only, never a source expression to reinterpret. */
typedef void (*KirResolveTarget)(void *context, const char *text, char *out, size_t size);
const char *KirTargetType(const char *type, KirTarget target);
int KirScalarLiteral(const char *type, const char *text, KirTarget target,
KirSourceSpan span, char *out, size_t size);
/* C/C++ private ABI names and source-shaped arguments for array values. */
int KirArrayValueType(const char *type);
int KirModuleUsesSlices(const KirModule *module);
void KirArrayAbiName(const KirFunction *fn, int parameter, char *out, size_t size);
void KirArrayAbiArgs(const KirFunction *fn, char *out, size_t size);
int KirCanEmitBody(const KirModule *module, const KirFunction *fn);
/* Stream a portable record's zero value or deep copy; no output if unsupported. */
int KirEmitJsRecordValue(FILE *out, const KirModule *module, const char *type,
const char *source);
void KirEmitNumbers(FILE *out, const KirModule *module, KirTarget target);
void KirEmitNumberSupport(FILE *out, KirTarget target, const char *prefix);
void KirEmitStringType(FILE *out);
void KirEmitSlotWrappers(FILE *out, const KirModule *module, const KirFunction *fn,
KirTarget target, KirResolveTarget resolver, void *context);
void KirEmitSlotType(FILE *out, const KirType *slot, KirTarget target,
KirResolveTarget resolve_type, void *context);
/* instance_host is the native Go implementation receiver, or an empty string
* for application functions and the other targets. number_support overrides
* the module-local numeric helper prefix when a package shares one definition. */
int KirEmitBody(FILE *out, const KirModule *module, const KirFunction *fn,
KirTarget target, KirResolveTarget resolve, void *context,
const char *instance_host, const char *number_support);
/* Dense-output switch for the Go target: remove the inlined-expression length
* bound so single-use temporaries fold without a readability cap. Default off. */
void KirEmitUseMinifiedOutput(int enabled);
#endif
-434
View File
@@ -1,434 +0,0 @@
#include "kir_expr.h"
#include "kir_diagnostic.h"
#include "kir_token.h"
#include "kir_text.h"
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
typedef struct ExprParser {
KirLexer lexer;
KirToken token;
KirFunction *fn;
const KirModule *module;
KirSourceSpan span;
const char *source;
size_t begin;
int failed, depth;
} ExprParser;
static void
next(ExprParser *p)
{
p->token = KirLexerNext(&p->lexer);
if(p->token.truncated)
p->failed = 1; /* a cut token cannot round-trip to source text */
p->begin = p->lexer.pos - strlen(p->token.text);
}
static int
is(ExprParser *p, const char *s)
{
return strcmp(p->token.text, s) == 0;
}
static int
take(ExprParser *p, const char *s)
{
if(!is(p, s)) return 0;
next(p);
return 1;
}
static void
expect(ExprParser *p, const char *s)
{
if(!take(p, s)) p->failed = 1;
}
static int
node(ExprParser *p, KirExprKind kind, size_t start, const char *name,
const char *op, int left, int right)
{
char text[KIR_TEXT_MAX];
size_t n = p->begin > start ? p->begin - start : 0;
KirSourceSpan span = p->span;
KirExpr *e;
if(n >= sizeof(text)) { p->failed = 1; return -1; }
memcpy(text, p->source + start, n);
text[n] = 0;
kir_trim_in_place(text);
span.column += (int)start;
e = KirFunctionAddExpr(p->fn, kind, text, span);
if(!e) { p->failed = 1; return -1; }
kir_copy(e->name, sizeof(e->name), name);
kir_copy(e->op, sizeof(e->op), op);
e->left = left;
e->right = right;
return p->fn->expr_count - 1;
}
static int
type_name(const ExprParser *p, const char *s)
{
static const char *const names[] = {
"void", "bool", "char", "int", "float", "double", "short", "long",
"signed", "unsigned", "const", "volatile", "size_t", "ptrdiff_t",
"int8_t", "int16_t", "int32_t", "int64_t", "uint8_t", "uint16_t",
"uint32_t", "uint64_t", "intptr_t", "uintptr_t", "i8", "i16", "i32",
"i64", "u8", "u16", "u32", "u64", "isize", "usize", "f32", "f64", "string", NULL
};
for(int i = 0; names[i]; i++) if(!strcmp(s, names[i])) return 1;
return p->module != NULL && KirFindType(p->module, s, NULL) != NULL;
}
static int expression(ExprParser *p, int minimum);
static int
record_initializer(ExprParser *p, size_t start, const char *type)
{
int first = -1;
int last = -1;
int ordinal = 0;
const KirType *record = p->module ? KirFindType(p->module, type, NULL) : NULL;
expect(p, "{");
while(!p->failed && !is(p, "}") && p->token.kind != KIR_TOKEN_EOF) {
size_t field_start = p->begin;
char name[KIR_NAME_MAX] = "";
int named = take(p, ".");
if(named) {
if(p->token.kind != KIR_TOKEN_IDENT) {
p->failed = 1;
break;
}
kir_copy(name, sizeof(name), p->token.text);
next(p);
expect(p, "=");
}
int value;
if(is(p, "{")) {
KirTypeField field;
size_t offset = 0;
int position = 0;
char field_type[KIR_NAME_MAX] = "";
KirArrayElementType(type, field_type, sizeof(field_type), NULL);
while(record != NULL && KirTypeNextField(record, &offset, &field) == 1) {
if(named ? !strcmp(field.name, name) : position == ordinal) {
kir_copy(field_type, sizeof(field_type), field.type);
break;
}
position++;
}
if(++p->depth > 128) {
p->failed = 1;
p->depth--;
return -1;
}
value = record_initializer(p, p->begin, field_type);
p->depth--;
} else {
value = expression(p, 1);
}
ordinal++;
if(value < 0) {
p->failed = 1;
break;
}
int field = node(p, KIR_EXPR_FIELD_INIT, field_start, name,
named ? "=" : "", -1, value);
if(field < 0)
break;
if(last >= 0)
p->fn->exprs[last].next_sibling = field;
else
first = field;
last = field;
if(!take(p, ","))
break;
}
expect(p, "}");
int result = node(p, KIR_EXPR_COMPOUND, start, type, "", -1, -1);
if(result >= 0)
p->fn->exprs[result].first_child = first;
return result;
}
static int
prefix(ExprParser *p)
{
size_t start = p->begin;
KirToken tok = p->token;
int result = -1;
if(++p->depth > 128) { p->failed = 1; p->depth--; return -1; }
if(take(p, "sizeof")) {
int right;
if(take(p, "(")) {
if(type_name(p, p->token.text)) {
size_t ts = p->begin;
while(p->token.kind != KIR_TOKEN_EOF && !is(p, ")")) next(p);
right = node(p, KIR_EXPR_IDENT, ts, "", "", -1, -1);
expect(p, ")");
} else {
right = expression(p, 1);
expect(p, ")");
}
} else right = prefix(p);
result = node(p, KIR_EXPR_SIZEOF, start, "", "", -1, right);
} else if(is(p, "+") || is(p, "-") || is(p, "!") || is(p, "~") ||
is(p, "*") || is(p, "&") || is(p, "++") || is(p, "--")) {
int right;
next(p);
right = prefix(p);
result = node(p, KIR_EXPR_UNARY, start, "", tok.text, -1, right);
} else if(take(p, "(")) {
if(type_name(p, p->token.text) || is(p, "[")) {
char type[KIR_NAME_MAX];
size_t ts = p->begin, length;
if(is(p, "[")) {
while(p->token.kind != KIR_TOKEN_EOF && !is(p, ")"))
next(p);
} else {
while(p->token.kind == KIR_TOKEN_IDENT || is(p, "*"))
next(p);
}
length = p->begin - ts;
if(length >= sizeof(type)) { p->failed = 1; length = 0; }
memcpy(type, p->source + ts, length); type[length] = 0;
kir_trim_in_place(type);
expect(p, ")");
const KirType *record = p->module ? KirFindType(p->module, type, NULL) : NULL;
if(is(p, "{") && ((record != NULL && !record->is_enum) ||
KirArrayElementType(type, NULL, 0, NULL))) {
result = record_initializer(p, start, type);
} else if(is(p, "{")) {
/* Foreign C aggregates retain their backend-owned syntax. */
int depth = 0;
do {
if(is(p, "{")) depth++;
if(is(p, "}")) depth--;
next(p);
} while(depth && p->token.kind != KIR_TOKEN_EOF);
if(depth) p->failed = 1;
result = node(p, KIR_EXPR_COMPOUND, start, "", "", -1, -1);
} else {
int right = prefix(p);
result = node(p, KIR_EXPR_CAST, start, type, "", -1, right);
}
} else {
result = expression(p, 1);
expect(p, ")");
/* Unknown imported C types still preserve compound literals. */
if(is(p, "{")) {
int depth = 0;
do {
if(is(p, "{")) depth++;
if(is(p, "}")) depth--;
next(p);
} while(depth && p->token.kind != KIR_TOKEN_EOF);
if(depth) p->failed = 1;
result = node(p, KIR_EXPR_COMPOUND, start, "", "", -1, -1);
}
}
} else {
KirExprKind kind;
switch(tok.kind) {
case KIR_TOKEN_IDENT: kind = KIR_EXPR_IDENT; break;
case KIR_TOKEN_INT: kind = KIR_EXPR_INT; break;
case KIR_TOKEN_FLOAT: kind = KIR_EXPR_FLOAT; break;
case KIR_TOKEN_STRING: kind = KIR_EXPR_STRING; break;
case KIR_TOKEN_CHAR: kind = KIR_EXPR_CHAR; break;
default: p->failed = 1; p->depth--; return -1;
}
next(p);
result = node(p, kind, start, kind == KIR_EXPR_IDENT ? tok.text : "", "", -1, -1);
}
while(!p->failed) {
if(take(p, "[")) {
int low = is(p, ":") ? -1 : expression(p, 1);
if(take(p, ":")) {
int high = is(p, "]") ? -1 : expression(p, 1);
expect(p, "]");
result = node(p, KIR_EXPR_SLICE, start, "", "", result, low);
if(result >= 0)
p->fn->exprs[result].third = high;
} else {
expect(p, "]");
result = node(p, KIR_EXPR_INDEX, start, "", "", result, low);
}
} else if(is(p, ".") || is(p, "->")) {
int pointer = is(p, "->");
char name[KIR_NAME_MAX];
next(p);
if(p->token.kind != KIR_TOKEN_IDENT) p->failed = 1;
kir_copy(name, sizeof(name), p->token.text);
next(p);
result = node(p, pointer ? KIR_EXPR_POINTER_MEMBER : KIR_EXPR_MEMBER,
start, name, pointer ? "->" : ".", result, -1);
} else if(take(p, "(")) {
int first = -1, last = -1;
char name[KIR_NAME_MAX] = "";
int callee = result;
if(callee >= 0 && p->fn->exprs[callee].kind == KIR_EXPR_IDENT)
kir_copy(name, sizeof(name), p->fn->exprs[callee].name);
if(!is(p, ")")) do {
int child = expression(p, 1);
if(child < 0) { p->failed = 1; break; }
if(last >= 0) p->fn->exprs[last].next_sibling = child;
else first = child;
last = child;
} while(take(p, ","));
expect(p, ")");
result = node(p, KIR_EXPR_CALL, start, name, "", name[0] ? -1 : callee, -1);
if(result >= 0) p->fn->exprs[result].first_child = first;
} else if(is(p, "++") || is(p, "--")) {
char op[8]; kir_copy(op, sizeof(op), p->token.text); next(p);
result = node(p, KIR_EXPR_POSTFIX, start, "", op, result, -1);
} else break;
}
p->depth--;
return result;
}
static int
precedence(const char *op)
{
if(!strcmp(op, "?")) return 1;
if(!strcmp(op, "||")) return 2;
if(!strcmp(op, "&&")) return 3;
if(!strcmp(op, "|")) return 4;
if(!strcmp(op, "^")) return 5;
if(!strcmp(op, "&")) return 6;
if(!strcmp(op, "==") || !strcmp(op, "!=")) return 7;
if(!strcmp(op, "<") || !strcmp(op, "<=") || !strcmp(op, ">") || !strcmp(op, ">=")) return 8;
if(!strcmp(op, "<<") || !strcmp(op, ">>")) return 9;
if(!strcmp(op, "+") || !strcmp(op, "-")) return 10;
if(!strcmp(op, "*") || !strcmp(op, "/") || !strcmp(op, "%")) return 11;
return 0;
}
static int
expression(ExprParser *p, int minimum)
{
size_t start = p->begin;
int left = prefix(p), prec;
if(++p->depth > 128) { p->failed = 1; p->depth--; return -1; }
while(!p->failed && (prec = precedence(p->token.text)) >= minimum) {
char op[8];
int right;
kir_copy(op, sizeof(op), p->token.text);
next(p);
right = expression(p, !strcmp(op, "?") ? 1 : prec + 1);
if(!strcmp(op, "?")) {
int third;
expect(p, ":");
third = expression(p, 1);
left = node(p, KIR_EXPR_CONDITIONAL, start, "", "?", left, right);
if(left >= 0) p->fn->exprs[left].third = third;
} else left = node(p, KIR_EXPR_BINARY, start, "", op, left, right);
}
p->depth--;
return left;
}
int
KirParseExpr(KirFunction *fn, const KirModule *module, const char *text, KirSourceSpan span)
{
ExprParser p = {0};
int initial = fn->expr_count, result;
if(!*kir_skip_ws(text)) return -1;
p.fn = fn; p.module = module; p.span = span; p.source = text;
KirLexerInit(&p.lexer, text, span.path);
next(&p);
result = expression(&p, 1);
take(&p, ";");
if(p.failed || p.token.kind != KIR_TOKEN_EOF || result < 0) {
fn->expr_count = initial;
if(!KirFunctionAddExpr(fn, KIR_EXPR_UNKNOWN, text, span)) return -1;
return fn->expr_count - 1;
}
return result;
}
void
KirStructureFunction(KirFunction *fn, const KirModule *module)
{
free(fn->exprs); fn->exprs = NULL; fn->expr_count = fn->expr_cap = 0;
for(int i = 0; i < fn->stmt_count; i++) {
KirStmt *st = &fn->stmts[i];
char text[KIR_TEXT_MAX];
char *value = NULL;
kir_copy(text, sizeof(text), st->text);
st->expr_root = st->lhs_root = -1;
st->is_instance = 0;
if(st->kind == KIR_STMT_DECL) {
char *colon = strchr(text, ':');
if(colon) {
*colon++ = 0; kir_trim_in_place(text);
kir_copy(st->name, sizeof(st->name), text);
char *annotation = strstr(colon, "#instance");
char *assignment = strchr(colon, '=');
if(annotation != NULL && (assignment == NULL || annotation < assignment)) {
char *key = annotation + strlen("#instance");
char *end = strrchr(key, ')');
const char *tail = end != NULL ? kir_skip_ws(end + 1) : "";
if(*tail == ';')
tail = kir_skip_ws(tail + 1);
key = (char *)kir_skip_ws(key);
if(*key != '(' || end == NULL || *tail != '\0') {
KirDiagnostic(st->span, "parse.instance", "expected #instance(key) after a record type");
exit(1);
}
*annotation = '\0';
*end = '\0';
value = key + 1;
st->is_instance = 1;
} else {
value = assignment;
if(value) *value++ = 0;
}
kir_trim_in_place(colon);
kir_copy(st->type, sizeof(st->type), colon);
}
} else if(st->kind == KIR_STMT_ASSIGN) {
KirLexer lexer; KirToken tok;
KirLexerInit(&lexer, text, st->span.path);
do {
tok = KirLexerNext(&lexer);
if(!strcmp(tok.text, "=") || !strcmp(tok.text, "+=") ||
!strcmp(tok.text, "-=") || !strcmp(tok.text, "*=") ||
!strcmp(tok.text, "/=") || !strcmp(tok.text, "%=") ||
!strcmp(tok.text, "&=") || !strcmp(tok.text, "|=") ||
!strcmp(tok.text, "^=") || !strcmp(tok.text, "<<=") || !strcmp(tok.text, ">>=")) {
value = text + lexer.pos;
kir_copy(st->assignment_op, sizeof(st->assignment_op), tok.text);
text[lexer.pos - strlen(tok.text)] = 0;
st->lhs_root = KirParseExpr(fn, module, text, st->span);
break;
}
} while(tok.kind != KIR_TOKEN_EOF);
} else if(st->kind == KIR_STMT_RETURN) value = text + 6;
else if(st->kind == KIR_STMT_UNUSED) value = text + 6;
else if(st->kind == KIR_STMT_EXPR || st->kind == KIR_STMT_WIDGET) value = text;
else if(st->kind == KIR_STMT_WHILE || st->kind == KIR_STMT_IF || st->kind == KIR_STMT_SWITCH) {
kir_strip_block_brace(text);
value = text;
if(!strncmp(value, "else", 4)) value = (char *)kir_skip_ws(value + 4);
while(*value && !isspace((unsigned char)*value) && *value != '(') value++;
}
if(value && strcmp(kir_skip_ws(value), ";")) {
if(st->kind == KIR_STMT_DECL && st->type[0] == '[' &&
*kir_skip_ws(value) == '{') {
char initializer[KIR_TEXT_MAX];
int length = snprintf(initializer, sizeof(initializer), "(%s)%s", st->type, value);
if(length < 0 || (size_t)length >= sizeof(initializer)) {
KirDiagnostic(st->span, "parse.array", "array initializer exceeds expression limit");
exit(1);
}
st->expr_root = KirParseExpr(fn, module, initializer, st->span);
} else {
st->expr_root = KirParseExpr(fn, module, value, st->span);
}
}
}
}
-9
View File
@@ -1,9 +0,0 @@
#ifndef KIR_EXPR_H
#define KIR_EXPR_H
#include "kir.h"
/* Parse with token precedence; unsupported syntax is an explicit unknown node. */
int KirParseExpr(KirFunction *fn, const KirModule *module, const char *text,
KirSourceSpan span);
void KirStructureFunction(KirFunction *fn, const KirModule *module);
#endif
-80
View File
@@ -1,80 +0,0 @@
/*
* kir_laws.c - named .kry laws enforced after semantic checking.
*
* A law is an invariant over the parsed program that gates every build.
* Diagnostics carry the stable dotted law name so tests and callers can
* match them, independently of optional strict type checking.
*/
#include "kir_laws.h"
#include "kir_diagnostic.h"
#include <stdio.h>
#include <string.h>
typedef struct LawCheck {
const char *current; /* active law name */
int violations;
} LawCheck;
static void
violation(LawCheck *c, KirSourceSpan span, const char *detail)
{
c->violations++;
KirDiagnostic(span, c->current, "law %s: %s", c->current, detail);
}
/* Same blocked set as tools/check-kryon-laws-api.sh: low-level texture
* draws and internal UI helpers bypass the public widget surface. */
static int
blocked_surface_call(const char *name)
{
return strcmp(name, "Texture") == 0
|| strcmp(name, "DrawTexture") == 0
|| strcmp(name, "DrawTexturePro") == 0
|| strcmp(name, "DrawTextureRec") == 0
|| strcmp(name, "TextInputControl") == 0
|| strncmp(name, "UIText", 6) == 0
|| strncmp(name, "UIRender", 8) == 0;
}
static void
check_image_surface(LawCheck *c, KirProgram **programs, int count)
{
for(int p = 0; p < count; p++) {
for(int m = 0; m < programs[p]->module_count; m++) {
KirModule *module = &programs[p]->modules[m];
for(int f = 0; f < module->function_count; f++) {
KirFunction *fn = &module->functions[f];
for(int x = 0; x < fn->expr_count; x++) {
KirExpr *e = &fn->exprs[x];
char detail[KIR_TEXT_MAX];
if(e->kind != KIR_EXPR_CALL)
continue;
if(!blocked_surface_call(e->name))
continue;
snprintf(detail, sizeof(detail),
"blocked UI surface call '%s': use Image(ImageProps)",
e->name);
violation(c, e->span, detail);
}
}
}
}
}
typedef void (*LawFn)(LawCheck *c, KirProgram **programs, int count);
static const struct { const char *name; LawFn check; } laws[] = {
{"image.surface.no_low_level_calls", check_image_surface},
};
int
KirCheckLaws(KirProgram **programs, int count)
{
LawCheck c = {0};
for(size_t i = 0; i < sizeof(laws) / sizeof(laws[0]); i++) {
c.current = laws[i].name;
laws[i].check(&c, programs, count);
}
return c.violations == 0;
}
-9
View File
@@ -1,9 +0,0 @@
#ifndef KIR_LAWS_H
#define KIR_LAWS_H
#include "kir.h"
/* Enforce named .kry laws over parsed programs in every compiler mode.
* Violations report `law <name>` diagnostics and fail before lowering.
* Type-checking strictness cannot disable laws. Returns 1 when passing. */
int KirCheckLaws(KirProgram **programs, int count);
#endif
-4629
View File
File diff suppressed because it is too large. Load diff
-17
View File
@@ -1,17 +0,0 @@
#ifndef KRYON_KIR_PARSE_H
#define KRYON_KIR_PARSE_H
#include "kir.h"
/*
* Parse a .kry source file into a KirProgram. Returns a heap-allocated
* program (caller frees with KirProgramFree), or NULL on fatal error.
* This is the shared Kir frontend used by k2kir (dump), k2c (C backend),
* and k2b (krb backend).
*/
KirProgram *kir_parse_file(const char *path, const char *root);
/* Parse immutable embedded text with the same frontend and source spans. */
KirProgram *kir_parse_source(const char *path, const char *source);
#endif /* KRYON_KIR_PARSE_H */
-248
View File
@@ -1,248 +0,0 @@
#include "kir_style_imports.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static void
dir_from_source(const char *src, char *dst, size_t dst_size)
{
const char *slash;
size_t n;
if(dst_size == 0)
return;
slash = strrchr(src, '/');
if(slash == NULL) {
dst[0] = '\0';
return;
}
n = (size_t)(slash - src);
if(n >= dst_size)
n = dst_size - 1;
memcpy(dst, src, n);
dst[n] = '\0';
}
int
KirStyleImportIsBuiltIn(const char *target)
{
return strcmp(target, "material") == 0 ||
strcmp(target, "classic") == 0 ||
strcmp(target, "glow") == 0 ||
strcmp(target, "lightfield") == 0;
}
static int
style_package_path(const char *target, int dotted_dirs,
char *dst, size_t dst_size)
{
char name[KIR_PATH_MAX];
size_t n = 0;
int last_sep = 1;
if(target[0] == '\0' || target[0] == '/' || target[0] == '\\')
return 0;
for(const char *p = target; *p != '\0'; p++) {
unsigned char ch = (unsigned char)*p;
if(isalnum(ch) || ch == '_' || ch == '-') {
if(n + 1 >= sizeof(name))
return 0;
name[n++] = (char)ch;
last_sep = 0;
} else if(ch == '.' || ch == '/') {
if(last_sep || n + 1 >= sizeof(name))
return 0;
name[n++] = dotted_dirs || ch == '/' ? '/' : '.';
last_sep = 1;
} else {
return 0;
}
}
if(last_sep)
return 0;
name[n] = '\0';
snprintf(dst, dst_size, "styles/%s.kss", name);
return 1;
}
static char *
read_text_file(const char *path)
{
FILE *f = fopen(path, "rb");
long size;
char *text;
if(f == NULL)
return NULL;
if(fseek(f, 0, SEEK_END) != 0) {
fclose(f);
return NULL;
}
size = ftell(f);
if(size < 0) {
fclose(f);
return NULL;
}
if(fseek(f, 0, SEEK_SET) != 0) {
fclose(f);
return NULL;
}
text = malloc((size_t)size + 1);
if(text == NULL) {
fclose(f);
return NULL;
}
if(fread(text, 1, (size_t)size, f) != (size_t)size) {
free(text);
fclose(f);
return NULL;
}
text[size] = '\0';
fclose(f);
return text;
}
static char *
trim_ascii_ws(char *s)
{
char *end;
while(*s != '\0' && isspace((unsigned char)*s))
s++;
end = s + strlen(s);
while(end > s && isspace((unsigned char)end[-1]))
*--end = '\0';
return s;
}
static int
path_has_parent_segment(const char *path)
{
const char *p = path;
while(*p != '\0') {
const char *start = p;
size_t n;
while(*p != '\0' && *p != '/')
p++;
n = (size_t)(p - start);
if(n == 2 && start[0] == '.' && start[1] == '.')
return 1;
if(*p == '/')
p++;
}
return 0;
}
static int
style_registry_path_is_safe(const char *path)
{
return path[0] != '\0' && path[0] != '/' && path[0] != '\\' &&
strchr(path, '\\') == NULL && !path_has_parent_segment(path);
}
static int
style_registry_package_path(const char *root, const char *target,
char *dst, size_t dst_size)
{
char path[KIR_PATH_MAX * 4];
char *text;
char *line;
snprintf(path, sizeof(path), "%s/styles/packages.kssmap", root);
text = read_text_file(path);
if(text == NULL)
return 0;
for(line = text; line != NULL && *line != '\0';) {
char *next = strchr(line, '\n');
char *comment;
char *sep;
char *key;
char *value;
if(next != NULL)
*next++ = '\0';
comment = strchr(line, '#');
if(comment != NULL)
*comment = '\0';
key = trim_ascii_ws(line);
if(*key == '\0') {
line = next;
continue;
}
sep = strchr(key, '=');
if(sep == NULL) {
for(sep = key; *sep != '\0' && !isspace((unsigned char)*sep);
sep++) {}
}
if(*sep == '\0') {
line = next;
continue;
}
*sep++ = '\0';
value = trim_ascii_ws(sep);
key = trim_ascii_ws(key);
if(strcmp(key, target) == 0 && style_registry_path_is_safe(value)) {
snprintf(dst, dst_size, "%s", value);
free(text);
return 1;
}
line = next;
}
free(text);
return 0;
}
char *
KirReadStyleImportSource(const KirModule *module, const char *root,
const KirStyleImport *style)
{
char relative[KIR_PATH_MAX * 2];
char dotted_relative[KIR_PATH_MAX * 2];
char path[KIR_PATH_MAX * 4];
char module_dir[KIR_PATH_MAX];
char *text;
if(style->kind == KIR_STYLE_IMPORT_BUILTIN) {
if(KirStyleImportIsBuiltIn(style->target))
return NULL;
if(style_package_path(style->target, 0, relative, sizeof(relative))) {
snprintf(path, sizeof(path), "%s/%s", root, relative);
text = read_text_file(path);
if(text != NULL)
return text;
}
if(style_package_path(style->target, 1,
dotted_relative, sizeof(dotted_relative)) &&
strcmp(relative, dotted_relative) != 0) {
snprintf(path, sizeof(path), "%s/%s", root, dotted_relative);
text = read_text_file(path);
if(text != NULL)
return text;
}
if(style_registry_package_path(root, style->target,
relative, sizeof(relative))) {
snprintf(path, sizeof(path), "%s/%s", root, relative);
text = read_text_file(path);
if(text != NULL)
return text;
}
return NULL;
}
if(style->target[0] == '/')
return read_text_file(style->target);
dir_from_source(module->source_path, module_dir, sizeof(module_dir));
if(module_dir[0] != '\0')
snprintf(path, sizeof(path), "%s/%s/%s", root, module_dir, style->target);
else
snprintf(path, sizeof(path), "%s/%s", root, style->target);
text = read_text_file(path);
if(text != NULL)
return text;
snprintf(path, sizeof(path), "%s/%s", root, style->target);
return read_text_file(path);
}
-13
View File
@@ -1,13 +0,0 @@
/*
* Shared helpers for resolving .kry #style imports to KSS source.
*/
#ifndef KRYON_KIR_STYLE_IMPORTS_H
#define KRYON_KIR_STYLE_IMPORTS_H
#include "kir.h"
int KirStyleImportIsBuiltIn(const char *target);
char *KirReadStyleImportSource(const KirModule *module, const char *root,
const KirStyleImport *style);
#endif
-208
View File
@@ -1,208 +0,0 @@
#include "kir_text.h"
#include <ctype.h>
#include <stdio.h>
#include <string.h>
int
kir_is_ident_char(int c)
{
return isalnum((unsigned char)c) || c == '_';
}
const char *
kir_skip_ws(const char *s)
{
while(s != NULL && isspace((unsigned char)*s))
s++;
return s;
}
const char *
kir_skip_inline_ws(const char *s)
{
while(s != NULL && (*s == ' ' || *s == '\t'))
s++;
return s;
}
char *
kir_trim(char *s)
{
char *e;
if(s == NULL)
return NULL;
while(isspace((unsigned char)*s))
s++;
e = s + strlen(s);
while(e > s && isspace((unsigned char)e[-1]))
*--e = '\0';
return s;
}
char *
kir_trim_in_place(char *s)
{
char *p;
if(s == NULL)
return NULL;
p = kir_trim(s);
if(p != s)
memmove(s, p, strlen(p) + 1);
return s;
}
void
kir_strip_block_brace(char *s)
{
size_t n;
if(s == NULL)
return;
n = strlen(s);
while(n > 0 && isspace((unsigned char)s[n - 1]))
n--;
if(n > 0 && s[n - 1] == '{')
n--;
while(n > 0 && isspace((unsigned char)s[n - 1]))
n--;
s[n] = '\0';
}
void
kir_camel_ident(const char *s, char *dst, size_t dst_size)
{
size_t n = 0;
int up = 1;
if(dst_size == 0)
return;
for(const char *p = s; p != NULL && *p != '\0' && n + 1 < dst_size; p++) {
if(isalnum((unsigned char)*p)) {
dst[n++] = up ? (char)toupper((unsigned char)*p) : *p;
up = 0;
} else {
up = 1;
}
}
if(n == 0 && n + 1 < dst_size)
dst[n++] = 'X';
if(n > 0 && isdigit((unsigned char)dst[0]) && n + 1 < dst_size) {
memmove(dst + 1, dst, n + 1);
dst[0] = 'M';
n++;
}
dst[n] = '\0';
}
void
kir_go_field_ident(const char *s, char *dst, size_t dst_size)
{
static const struct {
const char *camel;
const char *go;
} initialisms[] = {
{"Id", "ID"},
{"FocusId", "FocusID"},
{"MenuId", "MenuID"},
{"SelectedId", "SelectedID"},
{"ActivatedId", "ActivatedID"},
{"CanonicalUrl", "CanonicalURL"},
};
if(dst_size == 0)
return;
kir_camel_ident(s, dst, dst_size);
for(size_t i = 0; i < sizeof(initialisms) / sizeof(initialisms[0]); i++) {
if(strcmp(dst, initialisms[i].camel) == 0) {
snprintf(dst, dst_size, "%s", initialisms[i].go);
return;
}
}
}
/* Escape s for safe inclusion inside a C string literal in generated code:
* quotes, backslashes, and non-printable bytes cannot terminate or alter the
* surrounding literal. Returns the number of chars written; dst always holds
* a NUL-terminated prefix of the escaped text when dst_size > 0. */
size_t
kir_escape_c_string(const char *s, char *dst, size_t dst_size)
{
size_t n = 0;
if(dst_size == 0)
return 0;
for(const char *p = s != NULL ? s : ""; *p != '\0'; p++) {
char buf[8];
const char *rep = NULL;
switch(*p) {
case '"': rep = "\\\""; break;
case '\\': rep = "\\\\"; break;
case '\n': rep = "\\n"; break;
case '\r': rep = "\\r"; break;
case '\t': rep = "\\t"; break;
default:
if((unsigned char)*p < 0x20 || (unsigned char)*p == 0x7f) {
snprintf(buf, sizeof(buf), "\\x%02x", (unsigned char)*p);
rep = buf;
}
break;
}
if(rep == NULL) {
buf[0] = *p;
buf[1] = '\0';
rep = buf;
}
for(const char *q = rep; *q != '\0'; q++) {
if(n + 1 < dst_size)
dst[n++] = *q;
}
}
dst[n] = '\0';
return n;
}
int
kir_split_top(const char *s, char *parts, int max, size_t part_size)
{
int depth = 0;
int n = 0;
const char *start = s;
if(s == NULL || parts == NULL || max <= 0 || part_size == 0)
return 0;
for(const char *p = s; ; p++) {
if(*p == '"' || *p == '\'') {
char q = *p++;
while(*p != '\0' && *p != q) {
if(*p == '\\' && p[1] != '\0')
p++;
p++;
}
} else if(*p == '\0' || (*p == ',' && depth == 0)) {
size_t len = (size_t)(p - start);
if(n < max && len < part_size) {
char *part = parts + ((size_t)n * part_size);
memcpy(part, start, len);
part[len] = '\0';
kir_trim_in_place(part);
n++;
}
if(*p == '\0')
break;
start = p + 1;
} else if(*p == '(' || *p == '[' || *p == '{') {
depth++;
} else if(*p == ')' || *p == ']' || *p == '}') {
if(depth > 0)
depth--;
}
}
return n;
}
-18
View File
@@ -1,18 +0,0 @@
#ifndef KRYON_KIR_TEXT_H
#define KRYON_KIR_TEXT_H
#include <stddef.h>
int kir_is_ident_char(int c);
const char *kir_skip_ws(const char *s);
const char *kir_skip_inline_ws(const char *s);
char *kir_trim(char *s);
char *kir_trim_in_place(char *s);
void kir_strip_block_brace(char *s);
void kir_camel_ident(const char *s, char *dst, size_t dst_size);
/* One Go field spelling for declarations, initializers, reads, and writes. */
void kir_go_field_ident(const char *s, char *dst, size_t dst_size);
size_t kir_escape_c_string(const char *s, char *dst, size_t dst_size);
int kir_split_top(const char *s, char *parts, int max, size_t part_size);
#endif /* KRYON_KIR_TEXT_H */
-182
View File
@@ -1,182 +0,0 @@
#include "kir_token.h"
#include <ctype.h>
#include <string.h>
static int
is_ident_start(int c)
{
return isalpha((unsigned char)c) || c == '_';
}
static int
is_ident_continue(int c)
{
return isalnum((unsigned char)c) || c == '_';
}
static void
lexer_advance(KirLexer *lx)
{
if(lx->src[lx->pos] == '\n') {
lx->line++;
lx->column = 1;
} else {
lx->column++;
}
lx->pos++;
}
static void
token_copy(KirToken *tok, const char *src, size_t begin, size_t end)
{
size_t n = end > begin ? end - begin : 0;
if(n >= sizeof(tok->text)) {
n = sizeof(tok->text) - 1;
tok->truncated = 1;
}
memcpy(tok->text, src + begin, n);
tok->text[n] = '\0';
}
void
KirLexerInit(KirLexer *lx, const char *src, const char *path)
{
memset(lx, 0, sizeof(*lx));
lx->src = src != NULL ? src : "";
lx->path = path != NULL ? path : "";
lx->line = 1;
lx->column = 1;
}
KirToken
KirLexerNext(KirLexer *lx)
{
KirToken tok;
size_t begin;
int start_line;
int start_column;
int c;
memset(&tok, 0, sizeof(tok));
while(isspace((unsigned char)lx->src[lx->pos]))
lexer_advance(lx);
begin = lx->pos;
start_line = lx->line;
start_column = lx->column;
c = (unsigned char)lx->src[lx->pos];
tok.span = KirSpan(lx->path, start_line, start_column);
if(c == '\0') {
tok.kind = KIR_TOKEN_EOF;
return tok;
}
if(c == '#') {
lexer_advance(lx);
while(is_ident_continue((unsigned char)lx->src[lx->pos]))
lexer_advance(lx);
tok.kind = KIR_TOKEN_DIRECTIVE;
token_copy(&tok, lx->src, begin, lx->pos);
return tok;
}
if(is_ident_start(c)) {
lexer_advance(lx);
while(is_ident_continue((unsigned char)lx->src[lx->pos]))
lexer_advance(lx);
tok.kind = KIR_TOKEN_IDENT;
token_copy(&tok, lx->src, begin, lx->pos);
return tok;
}
if(isdigit(c) || (c == '.' && isdigit((unsigned char)lx->src[lx->pos + 1]))) {
int seen_dot = c == '.';
int hexadecimal = c == '0' && (lx->src[lx->pos + 1] == 'x' || lx->src[lx->pos + 1] == 'X');
lexer_advance(lx);
while(isalnum((unsigned char)lx->src[lx->pos]) ||
lx->src[lx->pos] == '_' || lx->src[lx->pos] == '.' ||
((lx->src[lx->pos] == '+' || lx->src[lx->pos] == '-') &&
strchr(hexadecimal ? "pP" : "eE", lx->src[lx->pos - 1]))) {
if(lx->src[lx->pos] == '.')
seen_dot = 1;
if(strchr(hexadecimal ? "pP" : "eE", lx->src[lx->pos]))
seen_dot = 1;
lexer_advance(lx);
}
tok.kind = seen_dot ? KIR_TOKEN_FLOAT : KIR_TOKEN_INT;
token_copy(&tok, lx->src, begin, lx->pos);
return tok;
}
if(c == '"' || c == '\'') {
int quote = c;
lexer_advance(lx);
while(lx->src[lx->pos] != '\0') {
if(lx->src[lx->pos] == '\\' && lx->src[lx->pos + 1] != '\0') {
lexer_advance(lx);
lexer_advance(lx);
continue;
}
if(lx->src[lx->pos] == quote) {
lexer_advance(lx);
break;
}
lexer_advance(lx);
}
tok.kind = quote == '"' ? KIR_TOKEN_STRING : KIR_TOKEN_CHAR;
token_copy(&tok, lx->src, begin, lx->pos);
return tok;
}
if(strchr("{}()[],;", c) != NULL ||
(c == ':' && lx->src[lx->pos + 1] != ':' && lx->src[lx->pos + 1] != '=')) {
lexer_advance(lx);
tok.kind = KIR_TOKEN_PUNCT;
token_copy(&tok, lx->src, begin, lx->pos);
return tok;
}
{
static const char *const ops[] = {
"::", ":=", "++", "--", "->", "==", "!=", "<=", ">=", "&&", "||", "+=", "-=",
"*=", "/=", "%=", "&=", "|=", "^=", "<<=", ">>=", "<<", ">>",
NULL
};
for(int i = 0; ops[i] != NULL; i++) {
size_t n = strlen(ops[i]);
if(strncmp(lx->src + lx->pos, ops[i], n) == 0) {
while(n-- > 0)
lexer_advance(lx);
tok.kind = KIR_TOKEN_OPERATOR;
token_copy(&tok, lx->src, begin, lx->pos);
return tok;
}
}
}
if(strchr("+-*/%=!<>.&|^?~", c) != NULL) {
lexer_advance(lx);
tok.kind = KIR_TOKEN_OPERATOR;
token_copy(&tok, lx->src, begin, lx->pos);
return tok;
}
lexer_advance(lx);
tok.kind = KIR_TOKEN_UNKNOWN;
token_copy(&tok, lx->src, begin, lx->pos);
return tok;
}
const char *
KirTokenKindName(KirTokenKind kind)
{
switch(kind) {
case KIR_TOKEN_EOF: return "eof";
case KIR_TOKEN_IDENT: return "ident";
case KIR_TOKEN_INT: return "int";
case KIR_TOKEN_FLOAT: return "float";
case KIR_TOKEN_STRING: return "string";
case KIR_TOKEN_CHAR: return "char";
case KIR_TOKEN_DIRECTIVE: return "directive";
case KIR_TOKEN_OPERATOR: return "operator";
case KIR_TOKEN_PUNCT: return "punct";
default: return "unknown";
}
}
-40
View File
@@ -1,40 +0,0 @@
#ifndef KRYON_KIR_TOKEN_H
#define KRYON_KIR_TOKEN_H
#include "kir.h"
#include <stddef.h>
typedef enum KirTokenKind {
KIR_TOKEN_EOF = 0,
KIR_TOKEN_IDENT,
KIR_TOKEN_INT,
KIR_TOKEN_FLOAT,
KIR_TOKEN_STRING,
KIR_TOKEN_CHAR,
KIR_TOKEN_DIRECTIVE,
KIR_TOKEN_OPERATOR,
KIR_TOKEN_PUNCT,
KIR_TOKEN_UNKNOWN
} KirTokenKind;
typedef struct KirToken {
KirTokenKind kind;
int truncated; /* token text exceeded the buffer and was cut */
char text[KIR_TEXT_MAX];
KirSourceSpan span;
} KirToken;
typedef struct KirLexer {
const char *src;
const char *path;
size_t pos;
int line;
int column;
} KirLexer;
void KirLexerInit(KirLexer *lx, const char *src, const char *path);
KirToken KirLexerNext(KirLexer *lx);
const char *KirTokenKindName(KirTokenKind kind);
#endif /* KRYON_KIR_TOKEN_H */
File diff suppressed because it is too large. Load diff
-133
View File
@@ -1,133 +0,0 @@
/*
* krb-run — headless KRB cartridge runner (plan 11, phase 1).
*
* Loads a .krb, renders it with the kry_sw software rasterizer
* (optionally wrapped in the recording backend), and writes the frame as
* a PNG and/or the vtable call stream as text. Golden files for engine
* conformance are produced with --png/--record and compared by
* tests/krb_engine_test.sh.
*
* Usage: krb-run [--png out.png] [--record out.txt] [--w W] [--h H]
* [--frames N] file.krb
*/
#include "krb.h"
#include "kry_backend_rec.h"
#include "kry_sw.h"
#include "png_write.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int
main(int argc, char **argv)
{
const char *png_path = NULL;
const char *rec_path = NULL;
const char *krb_path = NULL;
int w = 800;
int h = 600;
int frames = 1;
int i;
KrbImage img;
KrySw sw;
KryBackendRec rec;
long calls = -1;
FILE *recf = NULL;
for(i = 1; i < argc; i++) {
if(strcmp(argv[i], "--png") == 0 && i + 1 < argc)
png_path = argv[++i];
else if(strcmp(argv[i], "--record") == 0 && i + 1 < argc)
rec_path = argv[++i];
else if(strcmp(argv[i], "--w") == 0 && i + 1 < argc)
w = atoi(argv[++i]);
else if(strcmp(argv[i], "--h") == 0 && i + 1 < argc)
h = atoi(argv[++i]);
else if(strcmp(argv[i], "--frames") == 0 && i + 1 < argc)
frames = atoi(argv[++i]);
else if(argv[i][0] != '-' && krb_path == NULL)
krb_path = argv[i];
else {
fprintf(stderr,
"usage: krb-run [--png out.png] [--record out.txt]"
" [--w W] [--h H] [--frames N] file.krb\n");
return 2;
}
}
if(krb_path == NULL) {
fprintf(stderr, "krb-run: no cartridge given\n");
return 2;
}
memset(&img, 0, sizeof(img));
if(KrbLoadFile(&img, krb_path) != 0) {
fprintf(stderr, "krb-run: load failed: %s\n", krb_path);
return 1;
}
if(KrySwInit(&sw, NULL, w, h) != 0) {
fprintf(stderr, "krb-run: rasterizer init failed\n");
return 1;
}
{
const char *uis = getenv("KRB_RUN_UI_SCALE");
if(uis != NULL) {
int pm = (int)(atof(uis) * 1000.0f + 0.5f);
if(pm > 0 && pm <= 8000)
sw.scale = pm;
}
}
if(getenv("KRB_RUN_THEME_LIGHT") != NULL) {
KrySwSetTheme(&sw, KRY_THEME_BACKGROUND, 0xffffffffu);
KrySwSetTheme(&sw, KRY_THEME_SURFACE, 0xfbfbfbffu);
KrySwSetTheme(&sw, KRY_THEME_ICON, 0xd3d3d3ffu);
KrySwSetTheme(&sw, KRY_THEME_TEXT, 0x00000000u | 0xffu);
KrySwSetTheme(&sw, KRY_THEME_BUTTON, 0xffffffffu);
}
if(0) {
fprintf(stderr, "krb-run: rasterizer init failed\n");
return 1;
}
KrbAutoMount(&img);
if(rec_path != NULL) {
recf = fopen(rec_path, "w");
if(recf == NULL) {
fprintf(stderr, "krb-run: cannot write %s\n", rec_path);
return 1;
}
KryBackendSelect(KryBackendRecBackend(&rec, recf, KrySwBackend(&sw)));
} else {
{
const unsigned char *ad = NULL;
unsigned al = 0;
unsigned ak = 0;
if(KrbAssetFind(&img, "@atlas", &ad, &al, &ak, NULL, NULL) == 0 &&
ak == 1)
KrySwSetAtlas(&sw, ad, al);
}
KryBackendSelect(KrySwBackend(&sw));
}
{
int f;
for(f = 0; f < frames; f++) {
KrySwAdvance(&sw, 1.0f / 60.0f);
KrbDraw(&img, 0, 0, w, h);
}
}
if(recf != NULL) {
fclose(recf);
calls = KryBackendRecCalls(&rec);
}
if(png_path != NULL && krb_png_write(png_path, sw.pixels, sw.w, sw.h) != 0) {
fprintf(stderr, "krb-run: cannot write %s\n", png_path);
return 1;
}
KrbFree(&img);
KrySwFree(&sw);
printf("krb-run ok %s %dx%d calls=%ld\n", krb_path, w, h, calls);
return 0;
}
-154
View File
@@ -1,154 +0,0 @@
/*
* Minimal PNG writer for krb-run: 8-bit RGBA, stored (uncompressed)
* deflate blocks. No external dependencies, deterministic output.
*/
#include "png_write.h"
#include <stdlib.h>
#include <string.h>
static unsigned
crc32_buf(const unsigned char *p, size_t n)
{
static unsigned table[256];
static int built = 0;
unsigned crc = 0xffffffffu;
size_t i;
if(!built) {
int i;
for(i = 0; i < 256; i++) {
unsigned c = (unsigned)i;
int k;
for(k = 0; k < 8; k++)
c = (c & 1) ? 0xedb88320u ^ (c >> 1) : c >> 1;
table[i] = c;
}
built = 1;
}
for(i = 0; i < n; i++)
crc = table[(crc ^ p[i]) & 0xff] ^ (crc >> 8);
return crc ^ 0xffffffffu;
}
static void
be32(unsigned char *p, unsigned v)
{
p[0] = (unsigned char)(v >> 24);
p[1] = (unsigned char)(v >> 16);
p[2] = (unsigned char)(v >> 8);
p[3] = (unsigned char)v;
}
static void
png_chunk(FILE *f, const char *type, const unsigned char *data, size_t len)
{
unsigned char hdr[8];
unsigned char *buf;
unsigned crc;
buf = malloc(4 + len);
if(buf == NULL)
return;
memcpy(buf, type, 4);
if(len > 0 && data != NULL)
memcpy(buf + 4, data, len);
crc = crc32_buf(buf, 4 + len);
be32(hdr, (unsigned)len);
memcpy(hdr + 4, type, 4);
fwrite(hdr, 1, 8, f);
if(len > 0)
fwrite(data, 1, len, f);
be32(hdr, crc);
fwrite(hdr, 1, 4, f);
free(buf);
}
static unsigned
adler32_buf(const unsigned char *p, size_t n)
{
unsigned a = 1;
unsigned b = 0;
size_t i;
for(i = 0; i < n; i++) {
a = (a + p[i]) % 65521u;
b = (b + a) % 65521u;
}
return (b << 16) | a;
}
int
krb_png_write(const char *path, const unsigned char *rgba, int w, int h)
{
static const unsigned char sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
unsigned char ihdr[13];
unsigned char tail[4];
size_t rawlen = (size_t)h * (1 + (size_t)w * 4);
unsigned char *raw;
unsigned char *z;
size_t zn = 0;
size_t off = 0;
size_t left;
const unsigned char *src;
FILE *f;
int row;
int ok = 0;
f = fopen(path, "wb");
if(f == NULL)
return -1;
raw = malloc(rawlen);
z = malloc(rawlen + (rawlen / 65535 + 1) * 5 + 16);
if(raw == NULL || z == NULL)
goto out;
for(row = 0; row < h; row++) {
raw[off++] = 0; /* filter: none */
memcpy(raw + off, rgba + (size_t)row * w * 4, (size_t)w * 4);
off += (size_t)w * 4;
}
z[zn++] = 0x78; /* zlib header, fastest */
z[zn++] = 0x01;
src = raw;
left = rawlen;
while(left > 0) {
size_t chunk = left > 65535 ? 65535 : left;
unsigned char bhdr[5];
bhdr[0] = (left - chunk == 0) ? 1 : 0; /* BFINAL on last block */
bhdr[1] = (unsigned char)(chunk & 0xff);
bhdr[2] = (unsigned char)(chunk >> 8);
bhdr[3] = (unsigned char)(~chunk & 0xff);
bhdr[4] = (unsigned char)((~chunk >> 8) & 0xff);
memcpy(z + zn, bhdr, 5);
zn += 5;
memcpy(z + zn, src, chunk);
zn += chunk;
src += chunk;
left -= chunk;
}
be32(tail, adler32_buf(raw, rawlen));
memcpy(z + zn, tail, 4);
zn += 4;
fwrite(sig, 1, 8, f);
be32(ihdr, (unsigned)w);
be32(ihdr + 4, (unsigned)h);
ihdr[8] = 8; /* bit depth */
ihdr[9] = 6; /* RGBA */
ihdr[10] = 0; /* deflate */
ihdr[11] = 0; /* filter */
ihdr[12] = 0; /* interlace */
png_chunk(f, "IHDR", ihdr, 13);
png_chunk(f, "IDAT", z, zn);
png_chunk(f, "IEND", NULL, 0);
ok = 1;
out:
free(raw);
free(z);
if(fclose(f) != 0)
ok = 0;
return ok ? 0 : -1;
}
-8
View File
@@ -1,8 +0,0 @@
#ifndef KRB_RUN_PNG_WRITE_H
#define KRB_RUN_PNG_WRITE_H
#include <stdio.h>
int krb_png_write(const char *path, const unsigned char *rgba, int w, int h);
#endif
-197
View File
@@ -1,197 +0,0 @@
/*
* krb-sdl — SDL2 desktop host for KRB cartridges (plan 11, phase 7).
*
* Same shape as the web host: the kry_sw rasterizer produces the frame,
* SDL2 owns the window, input, and presentation (streaming texture).
* This is the template for the Android EGL host.
*
* Usage: krb-sdl [--png out.png] [--w W] [--h H] file.krb
* --png renders exactly one frame, dumps it, and exits (for tests;
* runs fine under SDL_VIDEODRIVER=dummy).
*/
#include "krb.h"
#include "kry_sw.h"
#include "png_write.h"
#include <SDL.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int
main(int argc, char **argv)
{
const char *png_path = NULL;
const char *krb_path = NULL;
int w = 800;
int h = 600;
int i;
KrbImage img;
KrySw sw;
SDL_Window *window;
SDL_Renderer *renderer;
SDL_Texture *texture;
for(i = 1; i < argc; i++) {
if(strcmp(argv[i], "--png") == 0 && i + 1 < argc)
png_path = argv[++i];
else if(strcmp(argv[i], "--w") == 0 && i + 1 < argc)
w = atoi(argv[++i]);
else if(strcmp(argv[i], "--h") == 0 && i + 1 < argc)
h = atoi(argv[++i]);
else if(argv[i][0] != '-' && krb_path == NULL)
krb_path = argv[i];
else {
fprintf(stderr,
"usage: krb-sdl [--png out.png] [--w W] [--h H]"
" file.krb\n");
return 2;
}
}
if(krb_path == NULL) {
fprintf(stderr, "krb-sdl: no cartridge given\n");
return 2;
}
memset(&img, 0, sizeof(img));
if(KrbLoadFile(&img, krb_path) != 0) {
fprintf(stderr, "krb-sdl: load failed: %s\n", krb_path);
return 1;
}
if(KrySwInit(&sw, NULL, w, h) != 0) {
fprintf(stderr, "krb-sdl: rasterizer init failed\n");
return 1;
}
{
const unsigned char *ad = NULL;
unsigned al = 0;
unsigned ak = 0;
if(KrbAssetFind(&img, "@atlas", &ad, &al, &ak, NULL, NULL) == 0 &&
ak == 1)
KrySwSetAtlas(&sw, ad, al);
}
KrbAutoMount(&img);
KryBackendSelect(KrySwBackend(&sw));
if(SDL_Init(SDL_INIT_VIDEO) != 0) {
fprintf(stderr, "krb-sdl: SDL_Init: %s\n", SDL_GetError());
return 1;
}
if(SDL_CreateWindowAndRenderer(w, h, SDL_WINDOW_RESIZABLE, &window,
&renderer) != 0) {
fprintf(stderr, "krb-sdl: window: %s\n", SDL_GetError());
return 1;
}
SDL_SetWindowTitle(window, "krb-sdl");
SDL_StartTextInput();
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1");
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA32,
SDL_TEXTUREACCESS_STREAMING, w, h);
if(texture == NULL) {
fprintf(stderr, "krb-sdl: texture: %s\n", SDL_GetError());
return 1;
}
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_NONE);
if(png_path != NULL) {
/* single deterministic frame for the exactness comparator */
KrySwAdvance(&sw, 1.0f / 60.0f);
KrbDraw(&img, 0, 0, w, h);
SDL_UpdateTexture(texture, NULL, sw.pixels, sw.stride);
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, texture, NULL, NULL);
{
unsigned char *buf = malloc((size_t)w * h * 4);
SDL_Rect r = {0, 0, w, h};
int ok;
if(buf == NULL)
return 1;
ok = SDL_RenderReadPixels(renderer, &r,
SDL_PIXELFORMAT_RGBA32, buf,
w * 4) == 0;
if(ok)
ok = krb_png_write(png_path, buf, w, h) == 0;
free(buf);
if(!ok) {
fprintf(stderr, "krb-sdl: frame dump failed\n");
return 1;
}
}
printf("krb-sdl ok %s %dx%d\n", krb_path, w, h);
SDL_DestroyTexture(texture);
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();
KrbFree(&img);
KrySwFree(&sw);
return 0;
}
for(;;) {
SDL_Event ev;
int running = 1;
while(SDL_PollEvent(&ev)) {
if(ev.type == SDL_QUIT)
running = 0;
else if(ev.type == SDL_MOUSEMOTION)
KrySwMouse(&sw, ev.motion.x, ev.motion.y);
else if(ev.type == SDL_MOUSEBUTTONDOWN)
KrySwButtonDown(&sw, 0);
else if(ev.type == SDL_MOUSEBUTTONUP)
KrySwButtonUp(&sw, 0);
else if(ev.type == SDL_MOUSEWHEEL)
KrySwWheel(&sw, ev.wheel.y * 50);
else if(ev.type == SDL_TEXTINPUT)
KrySwText(&sw, (unsigned)(unsigned char)ev.text.text[0]);
else if(ev.type == SDL_KEYDOWN &&
ev.key.keysym.sym == SDLK_BACKSPACE)
KrySwText(&sw, 0x08);
}
if(!running)
break;
KrySwAdvance(&sw, 1.0f / 60.0f);
KrbDraw(&img, 0, 0, w, h);
if(SDL_UpdateTexture(texture, NULL, sw.pixels, sw.stride) != 0) {
fprintf(stderr, "krb-sdl: update: %s\n", SDL_GetError());
return 1;
}
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);
if(png_path != NULL) {
/* Test mode: read back through the SDL renderer — the same
* pixels that reached the screen — and dump them. */
unsigned char *buf = malloc((size_t)w * h * 4);
SDL_Rect r = {0, 0, w, h};
int ok;
if(buf == NULL)
return 1;
ok = SDL_RenderReadPixels(renderer, &r,
SDL_PIXELFORMAT_RGBA32, buf,
w * 4) == 0;
if(ok)
ok = krb_png_write(png_path, buf, w, h) == 0;
free(buf);
if(!ok) {
fprintf(stderr, "krb-sdl: frame dump failed\n");
return 1;
}
break;
}
SDL_Delay(16);
}
printf("krb-sdl ok %s %dx%d\n", krb_path, w, h);
SDL_DestroyTexture(texture);
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();
KrbFree(&img);
KrySwFree(&sw);
return 0;
}
-113
View File
@@ -1,113 +0,0 @@
/*
* krb-web — native web host for KRB cartridges (plan 11, phase 3).
*
* Compiles the KRB runtime + kry_sw software rasterizer to wasm with
* emscripten. Pixel-identical to the native headless renderer: the frame
* is blitted into an ImageData every tick. Cartridge is preloaded at
* /app.krb (--preload-file); input comes from canvas events through the
* exported krb_web_mouse / krb_web_button.
*
* Build: make krb-web KRB=examples/02_buttons.kry
*/
#include "krb.h"
#include "kry_sw.h"
#include <emscripten.h>
#include <stdio.h>
#include <string.h>
#ifndef KRB_WEB_CARTRIDGE
#define KRB_WEB_CARTRIDGE "/app.krb"
#endif
static KrbImage g_img;
static KrySw g_sw;
static int g_running;
static void
frame(void)
{
KrySwAdvance(&g_sw, 1.0f / 60.0f);
KrbDraw(&g_img, 0, 0, g_sw.w, g_sw.h);
EM_ASM({
var ptr = $0;
var w = $1;
var h = $2;
var cv = Module.canvas;
var ctx = cv.getContext('2d');
if (!Module.krbImg || Module.krbImg.width !== w ||
Module.krbImg.height !== h)
Module.krbImg = ctx.createImageData(w, h);
Module.krbImg.data.set(HEAPU8.subarray(ptr, ptr + w * h * 4));
ctx.putImageData(Module.krbImg, 0, 0);
}, g_sw.pixels, g_sw.w, g_sw.h);
}
int
main(void)
{
/* The player waits for a cartridge: the shell writes the picked or
* dropped file to KRB_WEB_CARTRIDGE in MEMFS and calls krb_web_start. */
return 0;
}
int
krb_web_start(void)
{
memset(&g_img, 0, sizeof(g_img));
if(g_sw.pixels != NULL)
KrySwFree(&g_sw);
if(KrbLoadFile(&g_img, KRB_WEB_CARTRIDGE) != 0) {
fprintf(stderr, "krb-player: load failed: %s\n", KRB_WEB_CARTRIDGE);
return 1;
}
if(KrySwInit(&g_sw, NULL, 800, 600) != 0)
return 1;
KrbAutoMount(&g_img);
{
const unsigned char *ad = NULL;
unsigned al = 0;
unsigned ak = 0;
if(KrbAssetFind(&g_img, "@atlas", &ad, &al, &ak, NULL, NULL) == 0 &&
ak == 1)
KrySwSetAtlas(&g_sw, ad, al);
}
KryBackendSelect(KrySwBackend(&g_sw));
#ifdef KRB_WEB_ONESHOT
frame();
#else
if(!g_running)
emscripten_set_main_loop(frame, 0, 0);
g_running = 1;
#endif
return 0;
}
void
krb_web_mouse(int x, int y)
{
KrySwMouse(&g_sw, x, y);
}
void
krb_web_text(int cp)
{
KrySwText(&g_sw, (unsigned)cp);
}
void
krb_web_wheel(int dy)
{
KrySwWheel(&g_sw, dy);
}
void
krb_web_button(int button, int down)
{
if(down)
KrySwButtonDown(&g_sw, button);
else
KrySwButtonUp(&g_sw, button);
}
-43
View File
@@ -1,43 +0,0 @@
/* Pre-js for the KRB_WEB_ONESHOT node build: stubs a canvas whose 2D
* context records the blitted ImageData, so the wasm blit path can be
* byte-compared against the native kry_sw frame without a browser. */
var Module = {
printErr: function(t) { console.error(t); },
preRun: [function() {
var path = process.argv[2];
if (!path) {
console.error('node-capture: missing cartridge path');
process.exit(2);
}
var data = require('fs').readFileSync(path);
FS.writeFile('/app.krb', new Uint8Array(data));
}],
canvas: {
getContext: function() {
return {
createImageData: function(w, h) {
return { width: w, height: h,
data: new Uint8ClampedArray(w * h * 4) };
},
putImageData: function(img) {
if (globalThis.__krb_frame)
return;
globalThis.__krb_frame = Buffer.from(img.data);
require('fs').writeSync(1, globalThis.__krb_frame);
process.exit(0);
}
};
}
},
onRuntimeInitialized: function() {
var rc = Module._krb_web_start();
if (rc)
process.exit(rc);
},
onExit: function() {
if (!globalThis.__krb_frame) {
console.error('node-capture: no frame captured');
process.exit(1);
}
}
};
-104
View File
@@ -1,104 +0,0 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>krb player</title>
<style>
html, body { margin: 0; height: 100%; background: #101014; color: #f0f0f2;
font: 14px system-ui, sans-serif; display: flex;
flex-direction: column; align-items: center;
justify-content: center; gap: 12px; }
canvas { image-rendering: pixelated; max-width: 96vw; max-height: 80vh; }
#drop { border: 1px dashed #8a8a93; border-radius: 8px; padding: 14px 22px;
cursor: pointer; }
#drop.hot { border-color: #f0f0f2; background: #1c1c22; }
</style>
</head>
<body>
<div id="drop">drop a .krb cartridge here, or click to pick one</div>
<input id="file" type="file" accept=".krb" hidden>
<canvas id="krb" width="800" height="600"></canvas>
<script>
var Module = {
canvas: document.getElementById('krb')
};
(function() {
const canvas = Module.canvas;
const drop = document.getElementById('drop');
const input = document.getElementById('file');
function start(file) {
file.arrayBuffer().then(function(buf) {
Module.FS.writeFile('/app.krb', new Uint8Array(buf));
drop.textContent = file.name + ' — drop another .krb to switch';
Module._krb_web_start();
});
}
drop.addEventListener('click', function() { input.click(); });
input.addEventListener('change', function() {
if (input.files.length > 0)
start(input.files[0]);
});
['dragover', 'dragenter'].forEach(function(ev) {
drop.addEventListener(ev, function(e) {
e.preventDefault();
drop.classList.add('hot');
});
});
['dragleave', 'drop'].forEach(function(ev) {
drop.addEventListener(ev, function(e) {
e.preventDefault();
drop.classList.remove('hot');
});
});
drop.addEventListener('drop', function(e) {
e.preventDefault();
if (e.dataTransfer.files.length > 0)
start(e.dataTransfer.files[0]);
});
function pos(e) {
const r = canvas.getBoundingClientRect();
return [Math.round((e.clientX - r.left) * canvas.width / r.width),
Math.round((e.clientY - r.top) * canvas.height / r.height)];
}
window.addEventListener('keydown', function(e) {
if (e.key === 'Backspace' && Module._krb_web_text) {
e.preventDefault();
Module._krb_web_text(8);
}
});
window.addEventListener('keypress', function(e) {
if (Module._krb_web_text && e.charCode > 31)
Module._krb_web_text(e.charCode);
});
canvas.addEventListener('wheel', function(e) {
e.preventDefault();
if (Module._krb_web_wheel)
Module._krb_web_wheel(Math.round(-e.deltaY / 2));
}, { passive: false });
canvas.addEventListener('mousemove', function(e) {
if (Module._krb_web_mouse) {
const p = pos(e);
Module._krb_web_mouse(p[0], p[1]);
}
});
canvas.addEventListener('mousedown', function(e) {
if (Module._krb_web_button) {
const p = pos(e);
Module._krb_web_mouse(p[0], p[1]);
Module._krb_web_button(0, 1);
}
});
canvas.addEventListener('mouseup', function(e) {
if (Module._krb_web_button) {
const p = pos(e);
Module._krb_web_mouse(p[0], p[1]);
Module._krb_web_button(0, 0);
}
});
})();
</script>
{{{ SCRIPT }}}
</body>
</html>
-749
View File
@@ -1,749 +0,0 @@
#include "kryon.h"
#include "ui_style_pack_props.generated.h"
#include "session.h"
#include "watch.h"
#include <dirent.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>
#include <signal.h>
#define KP_PATH_MAX 1024
static volatile sig_atomic_t preview_stopping;
static void
stop_preview(int signal_number)
{
(void)signal_number;
preview_stopping = 1;
}
typedef struct PreviewOptions {
const char *command;
const char *project;
const char *source;
const char *source_dir;
const char *out;
const char *style;
const char *theme;
int width;
int height;
int count;
int frames;
} PreviewOptions;
static void
usage(void)
{
fprintf(stderr,
"usage:\n"
" kryon-preview watch --project ROOT [--source REL --width W --height H]\n"
" [--frames N --output PNG]\n"
" kryon-preview capture --project ROOT --source REL --output PNG [--width W --height H]\n"
" kryon-preview reload --project ROOT --source REL [--count N --width W --height H]\n"
" kryon-preview capture-all --project ROOT --source-dir DIR --out-dir DIR [--width W --height H]\n"
" kryon-preview capture-style --project ROOT --source REL --out-dir DIR [--width W --height H]\n"
" kryon-preview cartridge --source FILE.kry|FILE.krb --output PNG [--project ROOT] [--width W --height H]\n"
"\n"
" --style PACK run one command with a built-in style pack (material, classic,\n"
" lightfield) or 'none' for no-style mode\n"
" --theme NAME re-resolve packs under a theme overlay (light, dark, or none)\n");
}
static const char *
arg_value(int argc, char **argv, int *i)
{
if(*i + 1 >= argc)
return NULL;
(*i)++;
return argv[*i];
}
static int
parse_args(int argc, char **argv, PreviewOptions *opt)
{
memset(opt, 0, sizeof(*opt));
opt->width = 640;
opt->height = 480;
opt->count = 2;
if(argc < 2)
return 0;
opt->command = argv[1];
for(int i = 2; i < argc; i++) {
const char *value = NULL;
if(strcmp(argv[i], "--project") == 0) {
value = arg_value(argc, argv, &i);
if(value == NULL)
return 0;
opt->project = value;
} else if(strcmp(argv[i], "--source") == 0) {
value = arg_value(argc, argv, &i);
if(value == NULL)
return 0;
opt->source = value;
} else if(strcmp(argv[i], "--source-dir") == 0) {
value = arg_value(argc, argv, &i);
if(value == NULL)
return 0;
opt->source_dir = value;
} else if(strcmp(argv[i], "--output") == 0 ||
strcmp(argv[i], "--out-dir") == 0) {
value = arg_value(argc, argv, &i);
if(value == NULL)
return 0;
opt->out = value;
} else if(strcmp(argv[i], "--width") == 0) {
value = arg_value(argc, argv, &i);
if(value == NULL)
return 0;
opt->width = atoi(value);
} else if(strcmp(argv[i], "--height") == 0) {
value = arg_value(argc, argv, &i);
if(value == NULL)
return 0;
opt->height = atoi(value);
} else if(strcmp(argv[i], "--count") == 0) {
value = arg_value(argc, argv, &i);
if(value == NULL)
return 0;
opt->count = atoi(value);
} else if(strcmp(argv[i], "--frames") == 0) {
value = arg_value(argc, argv, &i);
if(value == NULL)
return 0;
opt->frames = atoi(value);
} else if(strcmp(argv[i], "--style") == 0) {
value = arg_value(argc, argv, &i);
if(value == NULL)
return 0;
opt->style = value;
} else if(strcmp(argv[i], "--theme") == 0) {
value = arg_value(argc, argv, &i);
if(value == NULL)
return 0;
opt->theme = value;
} else {
return 0;
}
}
if(opt->width <= 0)
opt->width = 640;
if(opt->height <= 0)
opt->height = 480;
if(opt->count <= 0)
opt->count = 1;
if(strcmp(opt->command, "watch") == 0)
return opt->project != NULL;
if(strcmp(opt->command, "capture") == 0)
return opt->project != NULL && opt->source != NULL && opt->out != NULL;
if(strcmp(opt->command, "reload") == 0)
return opt->project != NULL && opt->source != NULL;
if(strcmp(opt->command, "capture-all") == 0)
return opt->project != NULL && opt->source_dir != NULL && opt->out != NULL;
if(strcmp(opt->command, "capture-style") == 0)
return opt->project != NULL && opt->source != NULL && opt->out != NULL;
if(strcmp(opt->command, "cartridge") == 0)
return opt->source != NULL && opt->out != NULL;
return 0;
}
static void
path_join(char *dst, size_t dst_size, const char *a, const char *b)
{
if(a == NULL || a[0] == '\0')
snprintf(dst, dst_size, "%s", b != NULL ? b : "");
else if(b == NULL || b[0] == '\0')
snprintf(dst, dst_size, "%s", a);
else
snprintf(dst, dst_size, "%s/%s", a, b);
}
static int
has_suffix(const char *path, const char *suffix)
{
size_t path_len = strlen(path);
size_t suffix_len = strlen(suffix);
return path_len >= suffix_len &&
strcmp(path + path_len - suffix_len, suffix) == 0;
}
static int
mkdir_p(const char *path)
{
char tmp[KP_PATH_MAX];
snprintf(tmp, sizeof(tmp), "%s", path);
for(char *p = tmp + 1; *p != '\0'; p++) {
if(*p != '/')
continue;
*p = '\0';
if(mkdir(tmp, 0755) != 0 && errno != EEXIST)
return 0;
*p = '/';
}
return mkdir(tmp, 0755) == 0 || errno == EEXIST;
}
static int
preview_open(PreviewSession *session, const char *project)
{
int result;
if(PreviewStartBuild(session, project) < 0)
return 0;
do {
result = PreviewPollBuild(session);
if(result == 0)
WaitTime(0.01);
} while(result == 0 && !preview_stopping);
return result > 0 && !preview_stopping;
}
static int
capture_source(PreviewSession *session, const char *source, const char *out,
int width, int height)
{
RenderTexture2D target;
Image image;
int selected;
int saved;
selected = SetAppScreenBySourcePath(session->host, source);
if(!selected)
SetAppScreen(session->host, 0);
target = LoadRenderTexture(width, height);
BeginTextureMode(target);
ClearBackground(GetThemeBackground());
BeginInterfaceFrame(width, height, 1.0f);
DrawAppScreen(session->host, (Rectangle){0, 0, (float)width, (float)height});
EndInterfaceFrame();
EndTextureMode();
image = LoadImageFromTexture(target.texture);
UnloadRenderTexture(target);
if(image.data == NULL)
return 0;
ImageFlipVertical(&image);
saved = ExportImage(image, out);
UnloadImage(image);
if(!selected)
fprintf(stderr, "kryon-preview: %s delegates to app preview\n", source);
return saved;
}
static int
run_capture(const PreviewOptions *opt)
{
PreviewSession session = {0};
int ok;
if(!preview_open(&session, opt->project)) {
PreviewClose(&session);
return 1;
}
ok = capture_source(&session, opt->source, opt->out,
opt->width, opt->height);
PreviewClose(&session);
return ok ? 0 : 1;
}
static const char *const kp_style_packs[] = {
"material", "classic", "lightfield", "none",
};
static void png_name(char *dst, size_t dst_size, const char *rel);
static int
apply_style_pack(const char *pack)
{
if(strcmp(pack, "none") == 0) {
ClearStylePacks();
return 1;
}
EnsureBuiltInStylePacks();
if(!SetActiveStylePack(pack)) {
fprintf(stderr, "kryon-preview: style pack '%s' unavailable\n", pack);
return 0;
}
return 1;
}
static int
run_capture_style(const PreviewOptions *opt)
{
PreviewSession session = {0};
char name[KP_PATH_MAX];
char out[KP_PATH_MAX];
size_t name_len;
int ok = 1;
if(!preview_open(&session, opt->project)) {
PreviewClose(&session);
return 1;
}
if(!mkdir_p(opt->out)) {
fprintf(stderr, "kryon-preview: could not create %s\n", opt->out);
PreviewClose(&session);
return 1;
}
for(size_t i = 0; i < sizeof(kp_style_packs) / sizeof(kp_style_packs[0]); i++) {
const char *pack = kp_style_packs[i];
if(!apply_style_pack(pack)) {
ok = 0;
continue;
}
png_name(name, sizeof(name), opt->source);
name_len = strlen(name);
if(name_len > 4)
name[name_len - 4] = '\0';
snprintf(out, sizeof(out), "%s/%s-%s.png", opt->out, name, pack);
if(!capture_source(&session, opt->source, out,
opt->width, opt->height))
ok = 0;
}
EnsureBuiltInStylePacks();
PreviewClose(&session);
return ok ? 0 : 1;
}
static int
run_reload(const PreviewOptions *opt)
{
PreviewSession session = {0};
for(int i = 0; i < opt->count; i++) {
if(!preview_open(&session, opt->project)) {
PreviewClose(&session);
return 1;
}
if(!capture_source(&session, opt->source, "/tmp/kryon-preview-reload.png",
opt->width, opt->height)) {
PreviewClose(&session);
return 1;
}
}
PreviewClose(&session);
return 0;
}
static void
png_name(char *dst, size_t dst_size, const char *rel)
{
size_t n = 0;
for(const char *p = rel; *p != '\0' && n + 5 < dst_size; p++)
dst[n++] = (*p == '/' || *p == '.') ? '_' : *p;
memcpy(dst + n, ".png", 5);
}
static int
capture_all_dir(PreviewSession *session, const PreviewOptions *opt,
const char *rel_dir, int *total)
{
char abs_dir[KP_PATH_MAX];
DIR *dir;
struct dirent *entry;
int ok = 1;
path_join(abs_dir, sizeof(abs_dir), opt->project, rel_dir);
dir = opendir(abs_dir);
if(dir == NULL)
return 0;
while((entry = readdir(dir)) != NULL) {
char child_rel[KP_PATH_MAX];
char child_abs[KP_PATH_MAX];
struct stat st;
if(strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
continue;
path_join(child_rel, sizeof(child_rel), rel_dir, entry->d_name);
path_join(child_abs, sizeof(child_abs), opt->project, child_rel);
if(stat(child_abs, &st) != 0)
continue;
if(S_ISDIR(st.st_mode)) {
if(!capture_all_dir(session, opt, child_rel, total))
ok = 0;
} else if(S_ISREG(st.st_mode) && has_suffix(entry->d_name, ".kry")) {
char file[KP_PATH_MAX];
char out_path[KP_PATH_MAX];
png_name(file, sizeof(file), child_rel);
path_join(out_path, sizeof(out_path), opt->out, file);
(*total)++;
if(!capture_source(session, child_rel, out_path,
opt->width, opt->height)) {
fprintf(stderr, "kryon-preview: capture failed: %s\n", child_rel);
ok = 0;
}
}
}
closedir(dir);
return ok;
}
static int
run_capture_all(const PreviewOptions *opt)
{
PreviewSession session = {0};
int total = 0;
int ok;
if(!mkdir_p(opt->out))
return 1;
if(!preview_open(&session, opt->project)) {
PreviewClose(&session);
return 1;
}
ok = capture_all_dir(&session, opt, opt->source_dir, &total);
PreviewClose(&session);
fprintf(stderr, "kryon-preview: captured=%d failed=%d\n", total, ok ? 0 : 1);
return ok ? 0 : 1;
}
static int
file_exists(const char *path)
{
struct stat st;
return path != NULL && stat(path, &st) == 0 && S_ISREG(st.st_mode);
}
static int
find_k2b(char *dst, size_t dst_size)
{
const char *kryon_dir = getenv("KRYON_DIR");
const char *path;
if(kryon_dir != NULL && kryon_dir[0] != '\0') {
snprintf(dst, dst_size, "%s/build/bin/k2b", kryon_dir);
if(file_exists(dst))
return 1;
snprintf(dst, dst_size, "%s/build/linux-x86_64/bin/k2b", kryon_dir);
if(file_exists(dst))
return 1;
}
if(file_exists("build/bin/k2b")) {
snprintf(dst, dst_size, "build/bin/k2b");
return 1;
}
if(file_exists("build/linux-x86_64/bin/k2b")) {
snprintf(dst, dst_size, "build/linux-x86_64/bin/k2b");
return 1;
}
path = getenv("PATH");
if(path != NULL) {
char buf[KP_PATH_MAX];
const char *start = path;
while(*start != '\0') {
const char *colon = strchr(start, ':');
size_t n = colon != NULL ? (size_t)(colon - start) : strlen(start);
if(n > 0 && n + 4 < sizeof(buf)) {
memcpy(buf, start, n);
buf[n] = '\0';
path_join(dst, dst_size, buf, "k2b");
if(file_exists(dst))
return 1;
}
if(colon == NULL)
break;
start = colon + 1;
}
}
return 0;
}
static int
compile_krb(const char *k2b, const char *project, const char *source,
char *out_krb, size_t out_size)
{
char command[KP_PATH_MAX * 4];
char out_dir[KP_PATH_MAX];
char rel[KP_PATH_MAX];
char src_abs[KP_PATH_MAX];
int rc;
snprintf(out_dir, sizeof(out_dir), "%s/kryon-preview-krb",
getenv("TMPDIR") != NULL ? getenv("TMPDIR") : "/tmp");
snprintf(rel, sizeof(rel), "%s", source);
if(has_suffix(rel, ".kry"))
rel[strlen(rel) - 4] = '\0';
path_join(out_krb, out_size, out_dir, rel);
{
size_t n = strlen(out_krb);
if(n + 5 < out_size)
memcpy(out_krb + n, ".krb", 5);
}
{
char parent[KP_PATH_MAX];
char *slash;
snprintf(parent, sizeof(parent), "%s", out_krb);
slash = strrchr(parent, '/');
if(slash != NULL) {
*slash = '\0';
if(!mkdir_p(parent))
return 0;
}
}
if(source[0] == '/')
snprintf(src_abs, sizeof(src_abs), "%s", source);
else
path_join(src_abs, sizeof(src_abs), project, source);
snprintf(command, sizeof(command),
"'%s' --no-main --root '%s' -o '%s' '%s'",
k2b, project, out_dir, src_abs);
rc = system(command);
if(!(rc != -1 && WIFEXITED(rc) && WEXITSTATUS(rc) == 0))
return 0;
return file_exists(out_krb);
}
static int
capture_cartridge(const char *krb_path, const char *out, int width, int height)
{
KrbImage img;
RenderTexture2D target;
Image image;
int saved;
memset(&img, 0, sizeof(img));
if(KrbLoadFile(&img, krb_path) != 0) {
fprintf(stderr, "kryon-preview: could not load %s\n", krb_path);
return 0;
}
target = LoadRenderTexture(width, height);
BeginTextureMode(target);
ClearBackground(GetThemeBackground());
BeginInterfaceFrame(width, height, 1.0f);
KrbDraw(&img, 0, 0, width, height);
EndInterfaceFrame();
EndTextureMode();
KrbFree(&img);
image = LoadImageFromTexture(target.texture);
UnloadRenderTexture(target);
if(image.data == NULL)
return 0;
ImageFlipVertical(&image);
saved = ExportImage(image, out);
UnloadImage(image);
return saved;
}
static int
run_cartridge(const PreviewOptions *opt)
{
char krb_path[KP_PATH_MAX];
const char *source = opt->source;
if(has_suffix(source, ".krb")) {
if(source[0] == '/' || opt->project == NULL)
snprintf(krb_path, sizeof(krb_path), "%s", source);
else
path_join(krb_path, sizeof(krb_path), opt->project, source);
return capture_cartridge(krb_path, opt->out, opt->width, opt->height)
? 0
: 1;
}
if(has_suffix(source, ".kry")) {
char k2b[KP_PATH_MAX];
const char *project = opt->project != NULL ? opt->project : ".";
if(!find_k2b(k2b, sizeof(k2b))) {
fprintf(stderr, "kryon-preview: k2b not found for cartridge compile\n");
return 1;
}
if(!compile_krb(k2b, project, source, krb_path, sizeof(krb_path))) {
fprintf(stderr, "kryon-preview: k2b failed\n");
return 1;
}
return capture_cartridge(krb_path, opt->out, opt->width, opt->height)
? 0
: 1;
}
fprintf(stderr, "kryon-preview: cartridge source must be .kry or .krb\n");
return 1;
}
static int
run_watch(const PreviewOptions *opt)
{
PreviewSession session = {0};
uint64_t observed = 0;
uint64_t attempted = 0;
double next_scan = 0;
double changed_at = 0;
int pending = 1;
int frame = 0;
int scan_failed = 0;
int exit_status = 1;
SetExitKey(KEY_NULL);
SetInspectEnabled(1);
SetInspectVisible(0);
EnsureBuiltInStylePacks();
if(!PreviewSourceStamp(opt->project, &observed)) {
fprintf(stderr, "kryon-preview: cannot scan project sources\n");
return 1;
}
attempted = observed;
while(!preview_stopping && !WindowShouldClose() && (opt->frames <= 0 || frame < opt->frames)) {
double now = GetTime();
int width = GetScreenWidth();
int height = GetScreenHeight();
int status_height = height > 120 ? 48 : height / 3;
int content_height = height - status_height;
const char *status;
char details[2304];
InspectSelection selection;
int chrome;
frame++;
if(now >= next_scan) {
uint64_t current;
next_scan = now + 0.25;
scan_failed = !PreviewSourceStamp(opt->project, &current);
if(!scan_failed && current != observed) {
observed = current;
changed_at = now;
pending = 1;
}
}
if(session.build_pid > 0) {
int result = PreviewPollBuild(&session);
if(result != 0) {
exit_status = result < 0;
if(result > 0) {
if(opt->source == NULL ||
!SetAppScreenBySourcePath(session.host, opt->source))
SetAppScreen(session.host, 0);
if(opt->style != NULL)
apply_style_pack(opt->style);
if(opt->theme != NULL)
SetStyleTheme(opt->theme);
fprintf(stderr, "kryon-preview: loaded generation %lu\n", session.generation);
}
if(observed != attempted)
pending = 1;
}
}
if(pending && !scan_failed && session.build_pid == 0 && now - changed_at >= 0.15) {
pending = 0;
attempted = observed;
if(PreviewStartBuild(&session, opt->project) < 0)
exit_status = 1;
}
BeginDrawing();
ClearBackground(GetThemeBackground());
BeginInterfaceFrame(width, height, 1.0f);
if(session.host != NULL) {
ResizeAppHost(session.host, width, content_height);
SetAppHostFocused(session.host, IsWindowFocused());
BeginScissorMode(0, 0, width, content_height);
DrawAppScreen(session.host, (Rectangle){0, 0, (float)width, (float)content_height});
EndScissorMode();
}
if(scan_failed)
status = "Cannot scan project sources";
else if(session.build_pid > 0)
status = "Building...";
else if(session.diagnostic_count > 0) {
const PreviewDiagnostic *diagnostic = &session.diagnostics[0];
snprintf(details, sizeof(details), "%s:%d:%d [%s] %s",
diagnostic->path, diagnostic->line, diagnostic->column,
diagnostic->code, diagnostic->message);
status = details;
} else if(session.error[0] != '\0')
status = session.error;
else
status = opt->source != NULL ? opt->source : opt->project;
selection = InspectGetSelection();
if(selection.valid && !scan_failed && session.build_pid == 0 &&
session.diagnostic_count == 0 && session.error[0] == '\0') {
snprintf(details, sizeof(details), "%s %s | %s:%d | %.0f,%.0f %.0fx%.0f | focus %d",
selection.kind, selection.id, selection.source_path, selection.source_line,
selection.bounds.x, selection.bounds.y, selection.bounds.width,
selection.bounds.height, GetFocus());
status = details;
}
chrome = PushInspectChrome(1);
Text((TextProps){.text = status, .font = 14,
.bounds = {8, (float)content_height + 4, (float)width - 16,
(float)status_height - 8}});
PopInspectChrome(chrome);
EndInterfaceFrame();
EndDrawing();
}
if(opt->out != NULL && frame > 0) {
Image image = LoadImageFromScreen();
if(image.data == NULL || !ExportImage(image, opt->out)) {
fprintf(stderr, "kryon-preview: cannot capture window to %s\n", opt->out);
exit_status = 1;
}
UnloadImage(image);
}
PreviewClose(&session);
return exit_status;
}
int
main(int argc, char **argv)
{
PreviewOptions opt;
char title[160];
int rc;
if(!parse_args(argc, argv, &opt)) {
usage();
return 2;
}
SetTraceLogLevel(LOG_WARNING);
setenv("KRYON_DIAGNOSTICS", "json", 1);
if(strcmp(opt.command, "watch") == 0 && opt.out != NULL)
setenv("KRYON_SHOT_ARM", "1", 1);
SetConfigFlags(strcmp(opt.command, "watch") == 0 ? FLAG_WINDOW_RESIZABLE : FLAG_WINDOW_HIDDEN);
snprintf(title, sizeof(title), "Kryon Preview [%ld]", (long)getpid());
InitWindow(opt.width, opt.height, title);
if(strcmp(opt.command, "watch") == 0)
SetWindowMinSize(240, 160);
SetTargetFPS(60);
InitInterface(opt.width, opt.height, 1.0f);
/* The native window initializes its own termination handlers. */
signal(SIGINT, stop_preview);
signal(SIGTERM, stop_preview);
SetCurrentTheme(THEME_MONO, 0);
setenv("KRYON_INSPECT", "1", 1);
if(opt.theme != NULL && !SetStyleTheme(opt.theme)) {
fprintf(stderr, "kryon-preview: theme '%s' unavailable\n", opt.theme);
return 1;
}
if(opt.style != NULL && !apply_style_pack(opt.style))
return 1;
if(strcmp(opt.command, "watch") == 0)
rc = run_watch(&opt);
else if(strcmp(opt.command, "capture") == 0)
rc = run_capture(&opt);
else if(strcmp(opt.command, "reload") == 0)
rc = run_reload(&opt);
else if(strcmp(opt.command, "capture-style") == 0)
rc = run_capture_style(&opt);
else if(strcmp(opt.command, "cartridge") == 0)
rc = run_cartridge(&opt);
else
rc = run_capture_all(&opt);
CloseWindow();
return rc;
}
-334
View File
@@ -1,334 +0,0 @@
#define _POSIX_C_SOURCE 200809L
#define _XOPEN_SOURCE 700
#include "session.h"
#include "kry_dylib.h"
#include "kry_json.h"
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>
static int
fail(PreviewSession *session, const char *format, ...)
{
va_list args;
va_start(args, format);
vsnprintf(session->error, sizeof(session->error), format, args);
va_end(args);
fprintf(stderr, "kryon-preview: %s\n", session->error);
return -1;
}
static int
path(char *output, size_t capacity, const char *directory, const char *name)
{
int length = snprintf(output, capacity, "%s/%s", directory, name);
return length >= 0 && (size_t)length < capacity;
}
static void
close_host(PreviewSession *session)
{
if(session->host != NULL && session->destroy_host != NULL)
session->destroy_host(session->host);
if(session->dylib != NULL)
kry_dylib_close(session->dylib);
if(session->library_path[0] != '\0')
unlink(session->library_path);
session->host = NULL;
session->dylib = NULL;
session->destroy_host = NULL;
session->library_path[0] = '\0';
}
static void
read_diagnostic(PreviewSession *session)
{
KryJson *json;
const char *message;
const char *source;
const char *code;
const char *severity;
PreviewDiagnostic *diagnostic;
if(session->output_overflow || session->output_line[0] != '{')
return;
json = kry_json_parse(session->output_line);
if(json == NULL)
return;
message = kry_json_string(kry_json_get(json, "message"));
source = kry_json_string(kry_json_get(json, "path"));
code = kry_json_string(kry_json_get(json, "code"));
severity = kry_json_string(kry_json_get(json, "severity"));
if(message != NULL && source != NULL && code != NULL && severity != NULL &&
strcmp(severity, "error") == 0 && session->diagnostic_count < PREVIEW_DIAGNOSTIC_MAX) {
diagnostic = &session->diagnostics[session->diagnostic_count++];
snprintf(diagnostic->path, sizeof(diagnostic->path), "%s", source);
snprintf(diagnostic->message, sizeof(diagnostic->message), "%s", message);
snprintf(diagnostic->code, sizeof(diagnostic->code), "%s", code);
diagnostic->line = (int)kry_json_number(kry_json_get(json, "line"));
diagnostic->column = (int)kry_json_number(kry_json_get(json, "column"));
diagnostic->end_line = (int)kry_json_number(kry_json_get(json, "end_line"));
diagnostic->end_column = (int)kry_json_number(kry_json_get(json, "end_column"));
}
kry_json_free(json);
}
static void
read_output(PreviewSession *session)
{
char buffer[4096];
size_t length;
if(session->build_output == NULL)
return;
clearerr(session->build_output);
while((length = fread(buffer, 1, sizeof(buffer), session->build_output)) > 0) {
fwrite(buffer, 1, length, stderr);
for(size_t i = 0; i < length; i++) {
if(buffer[i] == '\n') {
session->output_line[session->output_length] = '\0';
read_diagnostic(session);
session->output_length = 0;
session->output_overflow = 0;
} else if(session->output_length + 1 < sizeof(session->output_line)) {
session->output_line[session->output_length++] = buffer[i];
} else {
session->output_overflow = 1;
}
}
}
}
void
PreviewClose(PreviewSession *session)
{
char log_path[PREVIEW_PATH_MAX];
if(session->build_pid > 0) {
/* The build owns a process group, including compiler grandchildren. */
kill(-session->build_pid, SIGKILL);
kill(session->build_pid, SIGKILL);
while(waitpid(session->build_pid, NULL, 0) < 0 && errno == EINTR)
;
session->build_pid = 0;
}
read_output(session);
if(session->build_output != NULL)
fclose(session->build_output);
session->build_output = NULL;
close_host(session);
if(session->directory[0] != '\0') {
if(path(log_path, sizeof(log_path), session->directory, "build.log"))
unlink(log_path);
rmdir(session->directory);
}
session->directory[0] = '\0';
}
int
PreviewStartBuild(PreviewSession *session, const char *project)
{
const char *temporary_root = getenv("TMPDIR");
const char *make = getenv("MAKE");
const char *kryon = getenv("KRYON_DIR");
char log_path[PREVIEW_PATH_MAX];
char kryon_argument[PREVIEW_PATH_MAX + 16];
char *absolute_project;
pid_t child;
int output;
if(session->build_pid > 0)
return fail(session, "a preview build is already running");
absolute_project = realpath(project, NULL);
if(absolute_project == NULL)
return fail(session, "cannot open project: %s", strerror(errno));
if(strlen(absolute_project) >= sizeof(session->project)) {
free(absolute_project);
return fail(session, "project path is too long");
}
strcpy(session->project, absolute_project);
free(absolute_project);
if(temporary_root == NULL || temporary_root[0] == '\0')
temporary_root = "/tmp";
if(session->directory[0] == '\0') {
if(!path(session->directory, sizeof(session->directory), temporary_root,
"kryon-preview.XXXXXX")) {
session->directory[0] = '\0';
return fail(session, "temporary directory path is too long");
}
if(mkdtemp(session->directory) == NULL) {
session->directory[0] = '\0';
return fail(session, "cannot create preview directory: %s", strerror(errno));
}
}
if(!path(log_path, sizeof(log_path), session->directory, "build.log"))
return fail(session, "build log path is too long");
if(kryon != NULL && kryon[0] != '\0') {
int length = snprintf(kryon_argument, sizeof(kryon_argument),
"KRYON_DIR=%s", kryon);
if(length < 0 || (size_t)length >= sizeof(kryon_argument))
return fail(session, "KRYON_DIR is too long");
} else {
kryon_argument[0] = '\0';
}
if(make == NULL || make[0] == '\0') {
#if defined(__FreeBSD__)
make = "gmake";
#else
make = "make";
#endif
}
output = open(log_path, O_WRONLY | O_CREAT | O_TRUNC, 0600);
if(output < 0)
return fail(session, "cannot create build log: %s", strerror(errno));
session->build_output = fopen(log_path, "rb");
if(session->build_output == NULL) {
close(output);
return fail(session, "cannot read build log: %s", strerror(errno));
}
fcntl(fileno(session->build_output), F_SETFD, FD_CLOEXEC);
fflush(NULL);
child = fork();
if(child == 0) {
setpgid(0, 0);
if(dup2(output, STDOUT_FILENO) < 0 || dup2(output, STDERR_FILENO) < 0)
_exit(126);
close(output);
if(kryon_argument[0] != '\0')
execlp(make, make, "-C", session->project, "kryon-host", kryon_argument,
(char *)NULL);
else
execlp(make, make, "-C", session->project, "kryon-host", (char *)NULL);
perror("kryon-preview: cannot start make");
_exit(127);
}
close(output);
if(child < 0) {
fclose(session->build_output);
session->build_output = NULL;
return fail(session, "cannot start build: %s", strerror(errno));
}
setpgid(child, child);
session->build_pid = child;
session->error[0] = '\0';
session->diagnostic_count = 0;
session->output_length = 0;
session->output_overflow = 0;
return 1;
}
static int
copy_library(const char *source, const char *destination)
{
FILE *input = fopen(source, "rb");
FILE *output;
char buffer[16384];
size_t length;
int ok = 1;
if(input == NULL)
return 0;
output = fopen(destination, "wb");
if(output == NULL) {
fclose(input);
return 0;
}
while((length = fread(buffer, 1, sizeof(buffer), input)) > 0) {
if(fwrite(buffer, 1, length, output) != length) {
ok = 0;
break;
}
}
if(ferror(input))
ok = 0;
fclose(input);
if(fclose(output) != 0)
ok = 0;
return ok;
}
static int
replace_host(PreviewSession *session)
{
PreviewSession candidate = {0};
CreateAppHostCallback create_host;
char source[PREVIEW_PATH_MAX];
char name[80];
const char *loader_error;
snprintf(name, sizeof(name), "host-%lu.so", ++session->generation);
if(!path(source, sizeof(source), session->project, "build/kryon/app_host.so") ||
!path(candidate.library_path, sizeof(candidate.library_path),
session->directory, name))
return fail(session, "app host path is too long");
if(!copy_library(source, candidate.library_path)) {
close_host(&candidate);
return fail(session, "cannot copy the built app host");
}
candidate.dylib = kry_dylib_load(candidate.library_path);
if(candidate.dylib == NULL) {
loader_error = kry_dylib_error();
fail(session, "cannot load app host: %s",
loader_error != NULL ? loader_error : "unknown loader error");
close_host(&candidate);
return -1;
}
create_host = (CreateAppHostCallback)kry_dylib_sym(candidate.dylib, "CreateAppHost");
candidate.destroy_host =
(DestroyAppHostCallback)kry_dylib_sym(candidate.dylib, "DestroyAppHost");
if(create_host == NULL || candidate.destroy_host == NULL) {
close_host(&candidate);
return fail(session, "app host is missing CreateAppHost or DestroyAppHost");
}
candidate.host = create_host(APP_HOST_ABI_VERSION, session->project);
if(candidate.host == NULL) {
close_host(&candidate);
return fail(session, "app host rejected ABI %d or failed initialization",
APP_HOST_ABI_VERSION);
}
if(candidate.host->draw == NULL) {
close_host(&candidate);
return fail(session, "app host has no draw callback");
}
/* Only a complete candidate may replace the working host. */
close_host(session);
session->host = candidate.host;
session->dylib = candidate.dylib;
session->destroy_host = candidate.destroy_host;
strcpy(session->library_path, candidate.library_path);
session->error[0] = '\0';
return 1;
}
int
PreviewPollBuild(PreviewSession *session)
{
int status;
pid_t result;
if(session->build_pid <= 0)
return fail(session, "no preview build is running");
read_output(session);
result = waitpid(session->build_pid, &status, WNOHANG);
if(result == 0 || (result < 0 && errno == EINTR))
return 0;
session->build_pid = 0;
read_output(session);
fclose(session->build_output);
session->build_output = NULL;
if(result < 0)
return fail(session, "cannot wait for build: %s", strerror(errno));
if(!WIFEXITED(status) || WEXITSTATUS(status) != 0)
return fail(session, "build failed; keeping the previous preview");
return replace_host(session);
}
-45
View File
@@ -1,45 +0,0 @@
#ifndef PREVIEW_SESSION_H
#define PREVIEW_SESSION_H
#include "ui_app_host_props.generated.h"
#include <stdio.h>
#include <sys/types.h>
#define PREVIEW_PATH_MAX 4096
#define PREVIEW_DIAGNOSTIC_MAX 16
typedef struct PreviewDiagnostic {
char path[1024];
char code[96];
char message[1024];
int line;
int column;
int end_line;
int end_column;
} PreviewDiagnostic;
typedef struct PreviewSession {
void *dylib;
AppHost *host;
DestroyAppHostCallback destroy_host;
unsigned long generation;
pid_t build_pid;
FILE *build_output;
char directory[PREVIEW_PATH_MAX];
char project[PREVIEW_PATH_MAX];
char library_path[PREVIEW_PATH_MAX];
char error[512];
PreviewDiagnostic diagnostics[PREVIEW_DIAGNOSTIC_MAX];
int diagnostic_count;
char output_line[16384];
size_t output_length;
int output_overflow;
} PreviewSession;
int PreviewStartBuild(PreviewSession *session, const char *project);
/* Zero while building, one after replacement, negative on failure. */
int PreviewPollBuild(PreviewSession *session);
void PreviewClose(PreviewSession *session);
#endif
-97
View File
@@ -1,97 +0,0 @@
#define _POSIX_C_SOURCE 200809L
#include "session.h"
#include "watch.h"
#include <dirent.h>
#include <string.h>
#include <sys/stat.h>
static uint64_t
hash_bytes(uint64_t hash, const void *value, size_t length)
{
const unsigned char *bytes = value;
for(size_t i = 0; i < length; i++) {
hash ^= bytes[i];
hash *= UINT64_C(1099511628211);
}
return hash;
}
static int
source_file(const char *name)
{
const char *extensions[] = {".kry", ".kss", ".c", ".h", ".cc", ".cpp",
".hpp", ".mk", ".kryon", ".json", ".txt", ".png", ".jpg", ".ttf", ".otf"};
const char *extension = strrchr(name, '.');
if(strcmp(name, "Makefile") == 0 || strcmp(name, "GNUmakefile") == 0)
return 1;
if(extension == NULL)
return 0;
for(size_t i = 0; i < sizeof(extensions) / sizeof(extensions[0]); i++) {
if(strcmp(extension, extensions[i]) == 0)
return 1;
}
return 0;
}
static int
source_stamp(const char *directory, uint64_t *stamp, int depth)
{
DIR *stream;
struct dirent *entry;
int ok = 1;
if(depth > 64)
return 0;
stream = opendir(directory);
if(stream == NULL)
return 0;
while((entry = readdir(stream)) != NULL) {
char filename[PREVIEW_PATH_MAX];
struct stat metadata;
uint64_t hash;
int length;
if(entry->d_name[0] == '.' || strcmp(entry->d_name, "build") == 0 ||
strcmp(entry->d_name, "vendor") == 0 || strcmp(entry->d_name, "dist") == 0 ||
strcmp(entry->d_name, "node_modules") == 0)
continue;
length = snprintf(filename, sizeof(filename), "%s/%s", directory, entry->d_name);
if(length < 0 || (size_t)length >= sizeof(filename) || lstat(filename, &metadata) != 0) {
ok = 0;
break;
}
if(S_ISDIR(metadata.st_mode)) {
if(!source_stamp(filename, stamp, depth + 1)) {
ok = 0;
break;
}
continue;
}
if(!S_ISREG(metadata.st_mode) || !source_file(entry->d_name))
continue;
hash = hash_bytes(UINT64_C(14695981039346656037), filename, (size_t)length);
hash = hash_bytes(hash, &metadata.st_size, sizeof(metadata.st_size));
#if defined(__APPLE__)
hash = hash_bytes(hash, &metadata.st_mtimespec.tv_sec, sizeof(metadata.st_mtimespec.tv_sec));
hash = hash_bytes(hash, &metadata.st_mtimespec.tv_nsec, sizeof(metadata.st_mtimespec.tv_nsec));
#else
hash = hash_bytes(hash, &metadata.st_mtim.tv_sec, sizeof(metadata.st_mtim.tv_sec));
hash = hash_bytes(hash, &metadata.st_mtim.tv_nsec, sizeof(metadata.st_mtim.tv_nsec));
#endif
/* Directory enumeration order must not cause a rebuild. */
*stamp += hash;
}
closedir(stream);
return ok;
}
int
PreviewSourceStamp(const char *project, uint64_t *stamp)
{
*stamp = 0;
return source_stamp(project, stamp, 0);
}
-8
View File
@@ -1,8 +0,0 @@
#ifndef PREVIEW_WATCH_H
#define PREVIEW_WATCH_H
#include <stdint.h>
int PreviewSourceStamp(const char *project, uint64_t *stamp);
#endif
-144
View File
@@ -1,144 +0,0 @@
#include "ui_style_pack_props.generated.h"
#include "ui/kss_parser.h"
#include "runtime/kss_formatter.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* kssfmt: format KSS style sheets through the shared .kry formatter.
* Mirrors kry-fmt: default rewrites files in place, --check exits nonzero
* when a file would change. */
static void
usage(FILE *out)
{
fputs("usage: kssfmt [--check] file.kss [...]\n", out);
}
static char *
read_file(const char *path, size_t *size_out)
{
FILE *f = fopen(path, "rb");
long size;
char *data;
if(f == NULL)
return NULL;
if(fseek(f, 0, SEEK_END) != 0 || (size = ftell(f)) < 0 ||
fseek(f, 0, SEEK_SET) != 0) {
fclose(f);
return NULL;
}
data = (char *)malloc((size_t)size + 1);
if(data == NULL) {
fclose(f);
return NULL;
}
if(fread(data, 1, (size_t)size, f) != (size_t)size) {
free(data);
fclose(f);
return NULL;
}
data[size] = '\0';
fclose(f);
if(size_out != NULL)
*size_out = (size_t)size;
return data;
}
static int
write_file(const char *path, const char *data, size_t size)
{
FILE *f = fopen(path, "wb");
if(f == NULL)
return -1;
if(fwrite(data, 1, size, f) != size) {
fclose(f);
return -1;
}
fclose(f);
return 0;
}
static int
format_one(const char *path, int check, int *status)
{
size_t size = 0;
char *source = read_file(path, &size);
char *out;
size_t capacity = size * 4 + 65536;
char diagnostic[256];
int length;
if(source == NULL) {
fprintf(stderr, "kssfmt: cannot read %s\n", path);
*status = 1;
return 0;
}
out = (char *)malloc(capacity);
if(out == NULL) {
free(source);
fprintf(stderr, "kssfmt: out of memory\n");
*status = 1;
return 0;
}
length = kss_format_string(source, out, capacity, diagnostic,
sizeof(diagnostic));
if(length < 0) {
if(diagnostic[0] == '\0' && capacity < size * 16 + 262144) {
free(out);
capacity = size * 16 + 262144;
out = (char *)malloc(capacity);
if(out != NULL)
length = kss_format_string(source, out, capacity, diagnostic,
sizeof(diagnostic));
}
}
if(length < 0) {
fprintf(stderr, "kssfmt: %s: %s\n", path,
diagnostic[0] != '\0' ? diagnostic : "format failed");
free(out);
free(source);
*status = 1;
return 0;
}
if((size_t)length != size || memcmp(out, source, size) != 0) {
if(check) {
fprintf(stderr, "kssfmt: would reformat %s\n", path);
*status = 1;
} else if(write_file(path, out, (size_t)length) != 0) {
fprintf(stderr, "kssfmt: cannot write %s\n", path);
*status = 1;
}
}
free(out);
free(source);
return 1;
}
int
main(int argc, char **argv)
{
int check = 0;
int status = 0;
int first = 1;
if(argc > 1 && strcmp(argv[1], "--help") == 0) {
usage(stdout);
return 0;
}
if(argc > 1 && strcmp(argv[1], "--check") == 0) {
check = 1;
first = 2;
}
if(argc <= first) {
usage(stderr);
return 2;
}
for(int i = first; i < argc; i++)
format_one(argv[i], check, &status);
return status;
}
-619
View File
@@ -1,619 +0,0 @@
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#define KT_LINE_MAX 4096
#define KT_PATH_MAX 1024
#define KT_MAX_TESTS 512
typedef struct KTOptions {
int headless;
int snap;
int bless;
const char *files[KT_MAX_TESTS];
int file_count;
} KTOptions;
typedef struct KTRun {
const KTOptions *options;
const char *argv0;
char root[KT_PATH_MAX];
char clip[KT_LINE_MAX];
char target[16];
FILE *log;
pid_t visual_pid;
int steps;
int failures;
} KTRun;
static void
kt_usage(FILE *out)
{
fprintf(out,
"usage: kt [-headless] [-snap] [-bless] [tests/file.kt ...]\n");
fprintf(out,
"commands: target open tap type key see shot wait mkdir write append copy paste mv exists notexists contains\n");
fprintf(out, "without -headless, kt opens the target app by default; "
"'target none' runs headless\n");
}
static char *
kt_trim(char *s)
{
char *end;
while(*s != '\0' && isspace((unsigned char)*s))
s++;
end = s + strlen(s);
while(end > s && isspace((unsigned char)end[-1]))
*--end = '\0';
return s;
}
static int
kt_ends_with(const char *s, const char *suffix)
{
size_t n;
size_t m;
if(s == NULL || suffix == NULL)
return 0;
n = strlen(s);
m = strlen(suffix);
return n >= m && strcmp(s + n - m, suffix) == 0;
}
static int
kt_mkdir(const char *path)
{
if(mkdir(path, 0775) == 0)
return 1;
return errno == EEXIST;
}
static int
kt_join(char *out, size_t out_size, const char *a, const char *b)
{
if(a == NULL || a[0] == '\0')
a = ".";
if(b == NULL)
b = "";
return snprintf(out, out_size, "%s/%s", a, b) < (int)out_size;
}
static int
kt_parse_word(char **cursor, char *out, size_t out_size)
{
char *s = kt_trim(*cursor);
size_t n = 0;
if(*s == '\0')
return 0;
while(*s != '\0' && !isspace((unsigned char)*s)) {
if(n + 1 < out_size)
out[n++] = *s;
s++;
}
out[n] = '\0';
*cursor = s;
return n > 0;
}
static int
kt_parse_arg(char **cursor, char *out, size_t out_size, char *err,
size_t err_size)
{
char *s = kt_trim(*cursor);
size_t n = 0;
if(*s == '\0') {
snprintf(err, err_size, "missing argument");
return 0;
}
if(*s == '"') {
s++;
while(*s != '\0' && *s != '"') {
if(*s == '\\' && s[1] != '\0')
s++;
if(n + 1 < out_size)
out[n++] = *s;
s++;
}
if(*s != '"') {
snprintf(err, err_size, "unterminated string");
return 0;
}
s++;
if(*kt_trim(s) != '\0') {
snprintf(err, err_size, "unexpected trailing text");
return 0;
}
} else {
while(*s != '\0' && !isspace((unsigned char)*s)) {
if(n + 1 < out_size)
out[n++] = *s;
s++;
}
if(*kt_trim(s) != '\0') {
snprintf(err, err_size, "unexpected trailing text");
return 0;
}
}
out[n] = '\0';
*cursor = s;
return 1;
}
static int
kt_parse_tail(char **cursor, char *out, size_t out_size, char *err,
size_t err_size)
{
char *s = kt_trim(*cursor);
if(*s == '\0') {
snprintf(err, err_size, "missing argument");
return 0;
}
return kt_parse_arg(&s, out, out_size, err, err_size);
}
static int
kt_safe_relpath(const char *path)
{
const char *p;
if(path == NULL || path[0] == '\0' || path[0] == '/')
return 0;
for(p = path; *p != '\0'; p++) {
if((p == path || p[-1] == '/') && p[0] == '.' &&
p[1] == '.' && (p[2] == '/' || p[2] == '\0'))
return 0;
}
return 1;
}
static int
kt_project_path(KTRun *run, const char *rel, char *out, size_t out_size)
{
if(!kt_safe_relpath(rel))
return 0;
return kt_join(out, out_size, run->root, rel);
}
static int
kt_read_file(const char *path, char *out, size_t out_size)
{
FILE *f;
size_t n;
f = fopen(path, "rb");
if(f == NULL)
return 0;
n = fread(out, 1, out_size > 0 ? out_size - 1 : 0, f);
if(out_size > 0)
out[n] = '\0';
fclose(f);
return 1;
}
static int
kt_write_file(const char *path, const char *text, const char *mode)
{
FILE *f = fopen(path, mode);
if(f == NULL)
return 0;
if(text != NULL && fputs(text, f) == EOF) {
fclose(f);
return 0;
}
fclose(f);
return 1;
}
static void
kt_tool_path(char *out, size_t out_size, const char *argv0,
const char *tool)
{
const char *slash;
size_t dir_len;
if(argv0 == NULL)
argv0 = "";
slash = strrchr(argv0, '/');
if(slash == NULL) {
snprintf(out, out_size, "%s", tool);
return;
}
dir_len = (size_t)(slash - argv0);
if(dir_len + 1 + strlen(tool) + 1 > out_size) {
snprintf(out, out_size, "%s", tool);
return;
}
memcpy(out, argv0, dir_len);
out[dir_len] = '/';
snprintf(out + dir_len + 1, out_size - dir_len - 1, "%s", tool);
}
static int
kt_start_visual(KTRun *run)
{
char tool[KT_PATH_MAX];
if(run->options == NULL || run->options->headless)
return 1;
if(run->visual_pid > 0)
return 1;
if(strcmp(run->target, "none") == 0)
return 1;
kt_tool_path(tool, sizeof(tool), run->argv0, "kryon");
run->visual_pid = fork();
if(run->visual_pid < 0)
return 0;
if(run->visual_pid == 0) {
setenv("KRYON_PROJECT_ROOT", run->root, 1);
execl(tool, tool, "--project", run->root, "run", "native",
(char *)NULL);
execlp("kryon", "kryon", "--project", run->root, "run", "native",
(char *)NULL);
_exit(127);
}
usleep(800000);
return 1;
}
static void
kt_stop_visual(KTRun *run)
{
int status;
if(run->visual_pid <= 0)
return;
kill(run->visual_pid, SIGTERM);
waitpid(run->visual_pid, &status, 0);
run->visual_pid = 0;
}
static void
kt_visual_step_delay(KTRun *run)
{
if(run->options != NULL && !run->options->headless &&
run->visual_pid > 0)
usleep(180000);
}
static int
kt_open_log(KTRun *run)
{
char path[KT_PATH_MAX];
if(!kt_join(path, sizeof(path), run->root, "logs"))
return 0;
if(!kt_mkdir(path))
return 0;
if(!kt_join(path, sizeof(path), run->root, "logs/kt.log"))
return 0;
run->log = fopen(path, "a");
return run->log != NULL;
}
static void
kt_log(KTRun *run, const char *file, int line_no, const char *cmd,
const char *arg)
{
if(run->log == NULL)
return;
fprintf(run->log, "%s:%d: %s %s\n", file, line_no, cmd,
arg != NULL ? arg : "");
}
static int
kt_run_command(KTRun *run, const char *file, int line_no, char *line)
{
char *cursor = line;
char cmd[32];
char arg[KT_LINE_MAX];
char arg2[KT_LINE_MAX];
char err[128];
char path[KT_PATH_MAX];
char path2[KT_PATH_MAX];
char text[KT_LINE_MAX];
char snapshots[KT_PATH_MAX];
if(!kt_parse_word(&cursor, cmd, sizeof(cmd)))
return 1;
if(strcmp(cmd, "target") == 0 || strcmp(cmd, "open") == 0 ||
strcmp(cmd, "tap") == 0 ||
strcmp(cmd, "type") == 0 || strcmp(cmd, "key") == 0 ||
strcmp(cmd, "see") == 0 || strcmp(cmd, "shot") == 0 ||
strcmp(cmd, "wait") == 0 ||
strcmp(cmd, "copy") == 0 || strcmp(cmd, "exists") == 0 ||
strcmp(cmd, "notexists") == 0 || strcmp(cmd, "mkdir") == 0) {
if(!kt_parse_arg(&cursor, arg, sizeof(arg), err, sizeof(err))) {
fprintf(stderr, "%s:%d: %s\n", file, line_no, err);
return 0;
}
if(strcmp(cmd, "target") == 0) {
if(strcmp(arg, "app") != 0 && strcmp(arg, "none") != 0) {
fprintf(stderr, "%s:%d: unknown target: %s\n", file, line_no,
arg);
return 0;
}
snprintf(run->target, sizeof(run->target), "%s", arg);
}
if(strcmp(cmd, "open") == 0) {
struct stat st;
if(stat(arg, &st) != 0 || !S_ISDIR(st.st_mode)) {
fprintf(stderr, "%s:%d: open target is not a directory: %s\n",
file, line_no, arg);
return 0;
}
snprintf(run->root, sizeof(run->root), "%s", arg);
if(run->log == NULL && !kt_open_log(run)) {
fprintf(stderr, "%s:%d: could not open logs/kt.log\n", file,
line_no);
return 0;
}
if(!kt_start_visual(run)) {
fprintf(stderr, "%s:%d: could not start Kryon visual runner\n",
file, line_no);
return 0;
}
}
if(strcmp(cmd, "shot") == 0) {
if(!kt_join(snapshots, sizeof(snapshots), run->root, "snapshots") ||
!kt_mkdir(snapshots)) {
fprintf(stderr, "%s:%d: could not create snapshots/\n", file,
line_no);
return 0;
}
}
if(strcmp(cmd, "copy") == 0)
snprintf(run->clip, sizeof(run->clip), "%s", arg);
if(strcmp(cmd, "wait") == 0) {
int ms = atoi(arg);
if(ms < 0)
ms = 0;
if(ms > 30000)
ms = 30000;
usleep((useconds_t)ms * 1000);
}
if(strcmp(cmd, "exists") == 0) {
struct stat st;
if(!kt_project_path(run, arg, path, sizeof(path)) ||
stat(path, &st) != 0) {
fprintf(stderr, "%s:%d: path does not exist: %s\n", file,
line_no, arg);
return 0;
}
}
if(strcmp(cmd, "notexists") == 0) {
struct stat st;
if(!kt_project_path(run, arg, path, sizeof(path)) ||
stat(path, &st) == 0) {
fprintf(stderr, "%s:%d: path exists: %s\n", file, line_no,
arg);
return 0;
}
}
if(strcmp(cmd, "mkdir") == 0) {
if(!kt_project_path(run, arg, path, sizeof(path)) ||
!kt_mkdir(path)) {
fprintf(stderr, "%s:%d: could not create directory: %s\n",
file, line_no, arg);
return 0;
}
}
kt_log(run, file, line_no, cmd, arg);
run->steps++;
kt_visual_step_delay(run);
return 1;
}
if(strcmp(cmd, "write") == 0 || strcmp(cmd, "append") == 0 ||
strcmp(cmd, "contains") == 0) {
if(!kt_parse_word(&cursor, arg, sizeof(arg))) {
fprintf(stderr, "%s:%d: missing path\n", file, line_no);
return 0;
}
if(!kt_parse_tail(&cursor, arg2, sizeof(arg2), err, sizeof(err))) {
fprintf(stderr, "%s:%d: %s\n", file, line_no, err);
return 0;
}
if(!kt_project_path(run, arg, path, sizeof(path))) {
fprintf(stderr, "%s:%d: unsafe path: %s\n", file, line_no, arg);
return 0;
}
if(strcmp(cmd, "contains") == 0) {
if(!kt_read_file(path, text, sizeof(text)) ||
strstr(text, arg2) == NULL) {
fprintf(stderr, "%s:%d: file does not contain text: %s\n",
file, line_no, arg);
return 0;
}
} else if(!kt_write_file(path, arg2,
strcmp(cmd, "append") == 0 ? "ab" : "wb")) {
fprintf(stderr, "%s:%d: could not write file: %s\n", file, line_no,
arg);
return 0;
}
kt_log(run, file, line_no, cmd, arg);
run->steps++;
kt_visual_step_delay(run);
return 1;
}
if(strcmp(cmd, "paste") == 0) {
if(!kt_parse_arg(&cursor, arg, sizeof(arg), err, sizeof(err))) {
fprintf(stderr, "%s:%d: %s\n", file, line_no, err);
return 0;
}
if(run->clip[0] == '\0') {
fprintf(stderr, "%s:%d: clipboard is empty\n", file, line_no);
return 0;
}
if(!kt_project_path(run, arg, path, sizeof(path)) ||
!kt_write_file(path, run->clip, "ab")) {
fprintf(stderr, "%s:%d: could not paste into file: %s\n", file,
line_no, arg);
return 0;
}
kt_log(run, file, line_no, cmd, arg);
run->steps++;
kt_visual_step_delay(run);
return 1;
}
if(strcmp(cmd, "mv") == 0) {
if(!kt_parse_word(&cursor, arg, sizeof(arg))) {
fprintf(stderr, "%s:%d: missing source path\n", file, line_no);
return 0;
}
if(!kt_parse_tail(&cursor, arg2, sizeof(arg2), err, sizeof(err))) {
fprintf(stderr, "%s:%d: %s\n", file, line_no, err);
return 0;
}
if(!kt_project_path(run, arg, path, sizeof(path)) ||
!kt_project_path(run, arg2, path2, sizeof(path2)) ||
rename(path, path2) != 0) {
fprintf(stderr, "%s:%d: could not move %s to %s\n", file, line_no,
arg, arg2);
return 0;
}
kt_log(run, file, line_no, cmd, arg);
run->steps++;
kt_visual_step_delay(run);
return 1;
}
fprintf(stderr, "%s:%d: unknown command: %s\n", file, line_no, cmd);
return 0;
}
static int
kt_run_file(const KTOptions *options, const char *argv0, const char *path)
{
FILE *f;
KTRun run = {0};
char line[KT_LINE_MAX];
int line_no = 0;
int ok = 1;
run.options = options;
run.argv0 = argv0;
snprintf(run.root, sizeof(run.root), ".");
snprintf(run.target, sizeof(run.target), "app");
if(!kt_open_log(&run)) {
fprintf(stderr, "%s: could not open logs/kt.log\n", path);
return 0;
}
f = fopen(path, "r");
if(f == NULL) {
fprintf(stderr, "%s: %s\n", path, strerror(errno));
fclose(run.log);
return 0;
}
while(fgets(line, sizeof(line), f) != NULL) {
char *trimmed;
line_no++;
trimmed = kt_trim(line);
if(trimmed[0] == '\0' || trimmed[0] == '#')
continue;
if(!kt_run_command(&run, path, line_no, trimmed)) {
ok = 0;
run.failures++;
}
}
if(run.log != NULL) {
fprintf(run.log, "%s: %d steps, %d failures\n", path, run.steps,
run.failures);
fclose(run.log);
}
kt_stop_visual(&run);
fclose(f);
return ok;
}
static int
kt_compare_strings(const void *a, const void *b)
{
const char *const *sa = a;
const char *const *sb = b;
return strcmp(*sa, *sb);
}
static int
kt_discover_tests(KTOptions *options)
{
DIR *dir;
struct dirent *entry;
char *names[KT_MAX_TESTS];
int count = 0;
dir = opendir("tests");
if(dir == NULL)
return 0;
while((entry = readdir(dir)) != NULL && count < KT_MAX_TESTS) {
char path[KT_PATH_MAX];
if(!kt_ends_with(entry->d_name, ".kt"))
continue;
if(!kt_join(path, sizeof(path), "tests", entry->d_name))
continue;
names[count] = strdup(path);
if(names[count] != NULL)
count++;
}
closedir(dir);
qsort(names, (size_t)count, sizeof(names[0]), kt_compare_strings);
for(int i = 0; i < count; i++)
options->files[options->file_count++] = names[i];
return count > 0;
}
int
main(int argc, char **argv)
{
KTOptions options = {0};
int ok = 1;
for(int i = 1; i < argc; i++) {
if(strcmp(argv[i], "-headless") == 0) {
options.headless = 1;
} else if(strcmp(argv[i], "-snap") == 0) {
options.snap = 1;
} else if(strcmp(argv[i], "-bless") == 0) {
options.bless = 1;
} else if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
kt_usage(stdout);
return 0;
} else if(argv[i][0] == '-') {
kt_usage(stderr);
return 2;
} else if(options.file_count < KT_MAX_TESTS) {
options.files[options.file_count++] = argv[i];
} else {
fprintf(stderr, "kt: too many test files\n");
return 2;
}
}
if(options.file_count == 0 && !kt_discover_tests(&options)) {
fprintf(stderr, "kt: no tests supplied and no tests/*.kt found\n");
return 2;
}
for(int i = 0; i < options.file_count; i++) {
if(!kt_run_file(&options, argv[0], options.files[i]))
ok = 0;
}
return ok ? 0 : 1;
}
-23
View File
@@ -1,23 +0,0 @@
# Dropdown appearance
Button is the styling source of truth. The dropdown trigger uses the neutral
soft Button style unchanged. The floating panel uses the shared glass material;
dark selection uses accent filled Button styling, light selection uses accent
soft styling, and navigation hover uses neutral soft styling. Typography,
icons, padding, and gaps come from the resolved Button metrics.
The full contract, state rules, and allowed adaptations are documented in
[Widget styling](../../docs/WIDGET_STYLING.md).
Run `make dropdown-capture` to render the actual native controls in both themes.
The output is under `build/linux-x86_64/dropdown-captures/`. The dark half of `approved.png` is the user-approved reference (2026-09-10).
The light half remains a review artifact. Searchable and multiple-selection
menus in the reference are compositions, not implicit single-select behavior.
Run `make -C examples 27_dropdowns` and launch
`build/examples/bin/27_dropdowns` for the interactive implementation. It starts
in dark mode; theme selection changes the real theme, workflow selection updates
the displayed value, and disabled options cannot be selected.
Run `make dropdown-reference-test` to regenerate native captures and compare
the dark panel against the approved image. This never updates the reference.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 256 KiB

Loaded 100 of 3778 files, more files were not shown because too many files have changed in this diff. Show more