Fix Kryon build regressions and consolidate checks

Select Darwin host code for the native ZX player and keep its Linux socket
service on Linux. Feed RGB to the JPEG encoder and retain Android
notification callbacks when generating native host libraries.

Resolve the Pages gallery verifier against the same source revisions as the
build. Reuse prepared template dependencies and check the JavaScript policy
against files present in the checkout. Combine related text-input checks
and perform shared source policy checks once per CI run.
This commit is contained in:
waozi committed 2026-11-18 01:52:02 -03:00
1 parent 0177e695f9
commit b5a61b37df
16 files changed
+293 -163

No files matched your search

-6
View File
@@ -190,12 +190,6 @@ jobs:
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
+10
View File
@@ -123,6 +123,16 @@ jobs:
project: kryonlabs/kryon
path: ziranlang/ziran
# Source-preservation tests regenerate the gallery manifest in this job.
# Select the same Kryon and Ziran sources as the website build job.
- name: Select source revisions for gallery verification
working-directory: kryonlabs/kryon/examples/gallery
run: |
ziran_root="$GITHUB_WORKSPACE/ziranlang/ziran"
printf '[overrides]\nkryon = "%s"\nziran = "%s"\n' \
"$GITHUB_WORKSPACE/kryonlabs/kryon" "$ziran_root" > ziran.local.toml
"$ziran_root/build/bin/ziran" lock
- name: Set up Node
uses: actions/setup-node@v6
with:
+4
View File
@@ -2,6 +2,10 @@
## Unreleased
- Android app libraries retain the JNI entries for local reminders and
notification permission requests.
- Desktop JPEG export accepts images with alpha on Glycin-based systems.
- Native ZX player builds on macOS select Darwin host code.
- GLES scenes keep GPU shadow filtering on devices without hardware depth comparison filtering.
- Android keeps the active frame budget while retained paint changes and backs off when paint becomes stable.
- Desktop animations continue presenting text and images without input.
+4 -3
View File
@@ -226,7 +226,7 @@ zx-test: build/bin/kryon zx-player
@env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u DBUS_SESSION_BUS_ADDRESS \
ZIRAN_ROOT=$(abspath $(ZIRAN_DIR)) python3 tests/zx_project_test.py
test: zx-test zx-reload-test
test: zx-reload-test
# window.zi's bundle runs as native code on a private Xvfb through a private
# host registry: in the desktop player's window through `ziran run`, and as
@@ -364,7 +364,7 @@ check: all ziran-test header-check docs-check project-test public-surface-check
# CI runs make test as parallel jobs on separate machines. The hosts shard takes
# every test target not named here, so a new one cannot miss CI.
CI_SHARD_ZX := renderer-consumer-test zx-test zx-reload-test zx-window-test zx-services-test zx-hosted-test \
CI_SHARD_ZX := renderer-consumer-test zx-native-test zx-reload-test zx-window-test zx-services-test zx-hosted-test \
zx-headless-test native-text-test native-accessibility-test
CI_SHARD_CHECK := check
CI_SHARD_WEB := canvas-test canvas-project-test program-entry-project-test zx-canvas-test \
@@ -382,6 +382,8 @@ test-shard-hosts:
# links a shared backend change can break. Run before pushing; CI runs it first.
.PHONY: push-check
push-check:
python3 scripts/check-google-free.py --source .
sh scripts/check-submodule-urls.sh
@env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u DBUS_SESSION_BUS_ADDRESS YUE_DESKTOP_RECOVERY=0 \
$(MAKE) --no-print-directory source-check public-surface-check docs-check zx-player desktop-project-test gamepad-test text-hook-hosts-ir-test
@env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u DBUS_SESSION_BUS_ADDRESS YUE_DESKTOP_RECOVERY=0 \
@@ -501,7 +503,6 @@ web-js-boundary-test:
.PHONY: page-geometry-test
page-geometry-test: project-toolchain
@env -u DISPLAY -u WAYLAND_DISPLAY sh tests/page_geometry_test.sh
test: page-geometry-test
.PHONY: canvas-test
canvas-test: canvas-frame-input-test web-js-boundary-test canvas-events-test mini-mode-test canvas-audio-engine-test page-geometry-test
+3 -1
View File
@@ -1,8 +1,10 @@
# Build the reusable native player, never the downloaded application's code.
CC ?= cc
PLAYER_HOST_OS ?= $(shell uname -s)
PLAYER_TARGET := --define PLATFORM_DESKTOP
ifeq ($(PLAYER_HOST_OS),Darwin)
PLAYER_LDFLAGS ?= -Wl,-dead_strip
PLAYER_TARGET += --target-os macos --define __APPLE__
PLAYER_PACKAGES := sdl2 cairo freetype2 pangocairo fontconfig glib-2.0
else
PLAYER_LDFLAGS ?= -Wl,--gc-sections
@@ -19,7 +21,7 @@ zx-player: $(PLAYER)
$(PLAYER): $(PLAYER_SOURCES) $(KRYON_DIR)/mk/zx-player.mk $(KRYON_DIR)/ziran.toml $(KRYON_DIR)/ziran.lock $(ZIRAN_DIR)/build/libziran.a $(ZIRAN) $(OPUS_A)
mkdir -p $(PLAYER_DIR) $(KRYON_DIR)/build/bin
cd "$(KRYON_DIR)" && $(ZIRAN) build --project --target=c --prune-stale --define PLATFORM_DESKTOP --root $(KRYON_DIR)/tools \
cd "$(KRYON_DIR)" && $(ZIRAN) build --project --target=c --prune-stale $(PLAYER_TARGET) --root $(KRYON_DIR)/tools \
-o $(PLAYER_DIR) $(KRYON_DIR)/tools/zx.zi
@temporary=$$(mktemp $(KRYON_DIR)/build/bin/zx.XXXXXX); \
trap 'rm -f "$$temporary"' EXIT; \
+86
View File
@@ -0,0 +1,86 @@
# Kryon check consolidation
The baseline is master immediately before this consolidation. Each row counts
its own entry points, so a Make target that delegates to a behavior script
appears in the Make prerequisite count and the script in the script count.
| Check surface | Baseline | After consolidation |
| --- | ---: | ---: |
| Direct `make test` prerequisites | 88 | 86 |
| `tests/ziran_*_test.sh` behavior entry points | 180 | 179 |
| Source policy invocations per full CI run | 10 | 2 |
| Full CI jobs, including matrix jobs | 9 | 9 |
| Pages build, verification and deployment jobs | 3 | 3 |
## Gate inventory
`make test` includes:
- Library and packages: `check` (`all`, `ziran-test`, `header-check`,
`docs-check`, `project-test`, `public-surface-check`, `host-keys-test`, `laws`),
`project-system-links-test`, `renderer-consumer-test`, `pay-per-import-test`,
`widget-import-order-test`, `hosted-widgets-import-test`,
`markdown-editor-test`, `toast-action-test`.
- Portable execution and application entry: `zx-test`, `zx-reload-test`,
`zx-window-test`, `zx-services-test`, `zx-hosted-test`, `zx-headless-test`,
`zx-native-test`, `zx-canvas-test`, `program-entry-project-test`,
`program-title-test`, `application-entry-test`, `window-runtime-test`.
- Browser: `canvas-test` (frame input, JS boundary, events, mini mode, audio,
page geometry, application hooks, native Canvas harness, file picker and
HTTP transfer), `canvas-project-test`, `page-geometry-test`,
`page-route-project-test`, `canvas-asset-cache-test`, `image-preview-web-test`.
- Native desktop: `desktop-codec-artifact-test`, `desktop-windows-test`,
`desktop-audio-test`, `desktop-audio-mp3-test`, `desktop-audio-vorbis-test`,
`desktop-frame-texture-test`, `desktop-native-test`, `native-text-test`,
`native-accessibility-test`, `native-assets-install-test`,
`native-image-services-test`, `window-focus-test`, `gamepad-test`,
`cursor-api-test`, `event-wake-sdl-test`, `system-clipboard-test`,
`system-clipboard-linux-test`, `mime-clipboard-linux-test`,
`drag-source-linux-test`, `gtk-style-linux-test`, `gtk-scroll-linux-test`,
`file-date-linux-test`.
- Android: `android-surface-test`, `android-rotation-pixels-test`,
`android-frame-input-test`, `android-notification-jvm-test`,
`android-notifications-scaffold-test`, `android-launch-uri-test`,
`android-surface-platform-test`, `android-source-generation-test`,
`android-frame-texture-test`, `android-present-damage-test`,
`android-runtime-test`, `android-image-services-test`.
- Rendering and assets: `typeface-source-test`, `pixmap-surface-test`,
`pixmap-measure-test`, `pixmap-density-test`, `pixmap-text-scale-test`,
`pixmap-frame-test`, `pixmap-mesh-test`, `pixmap-camera-test`,
`pixmap-typeface-test`, `scene-image-material-test`, `daylight-test`,
`shader-scene-test`, `image-pixels-test`, `image-preview-test`,
`rotated-text-test`, `lanczos-goldens-test`, `avif-decode-test`,
`bitmap-image-test`, `cairo-picture-cache-test`, `image-dimensions-host-test`,
`mirrored-image-test`, `scene-skin-test`, `watercolor-test`,
`practice-material-gpu-test`, `image-pixels-resolver-test`.
- Audio and storage: `asset-audio-test`, `pcm-audio-test`,
`document-storage-test`.
`make push-check` runs `source-check`, `public-surface-check`, `docs-check`,
`zx-player`, `desktop-project-test`, `gamepad-test`, `text-hook-hosts-ir-test`
and the `ziran_pixmap_gpu_test` focus. It now runs the two source policies
before the native host links.
CI runs the push gate, a macOS headless player job, five Linux jobs (`zx`,
`check`, `web`, `site`, `hosts`), the sanitizers, and private-Xvfb desktop
hosts. The Linux hosts job adds SDL3 GPU, frame workloads, and example
builds. The site job builds the Gallery, tests the package selections and
runs the browser suite. Pages builds and stages the browser runtime,
verifies that artifact, and deploys it only after verification.
## Coverage mapping
| Removed invocation | Retained coverage |
| --- | --- |
| Standalone typed-key behavior script | The consolidated Ziran text-input fixture runs its UTF-8 scalar, queue, edit-key and shortcut assertions together with the active-editor focus table. Both run on native C and ZX, from source and saved IR. |
| Direct `make test` dependency on `page-geometry-test` | `canvas-test` keeps this prerequisite. The web shard runs it once and the hosts shard stops selecting it a second time. |
| Direct `make test` dependency and ZX shard entry for `zx-test` | `zx-native-test` runs `zx-test` first and uses the tested bundle for the native execution check in the same shard. Both named Make targets remain available. |
| Google-library and submodule-URL checks in each Linux shard | The shared push gate runs the same two scripts once on the revision before any shard starts. |
The baseline already includes the raylib removal.
## Local wall time
The previous text-input scripts ran sequentially in 4.206 seconds. The
consolidated script took 2.211 seconds on the same machine with the existing
native Ziran binaries. These measurements cover the text-input tests only.
+7 -5
View File
@@ -60,11 +60,10 @@ for path in host_roots:
# `ziran ir --entry` keeps only what its one entry reaches; a native C graph
# has no other root, and `#program_export` alone does not retain a function.
# Android's loader, not main, calls the glue's JNI_OnLoad, which
# cmake/libmain.map.txt exports by name; kryon_android_app's
# --wrap=fopen/fopen64 link android_fopen's wrappers; and a ZX player's
# android_main is called only by the NDK's native_app_glue. This generated
# entry reaches them all: it forwards a valid call straight to the
# Android calls the glue's JNI_OnLoad and the notification receiver callbacks
# by name through cmake/libmain.map.txt. The Android app also links the fopen
# wrappers and the NDK calls android_main. This generated entry keeps those
# functions and forwards a valid call straight to the
# application's stable `main(argc, argv)` and names the others only on the
# branch a C argc (never negative) cannot take, so it has no glue side effect.
# Kryon's entries are host capabilities bound to its exports, which keeps a
@@ -85,12 +84,15 @@ roots_source = args.ir.with_name(args.ir.name + "-roots") / (ROOTS_MODULE + ".zi
roots_text = "\n".join([
"// Generated by kryon scripts/generate_android_sources.py.",
'#import "main"', '#import "android_glue"',
'NotificationReceiver :: #import "kryon/android_notifications";',
'host_api :: #system_library "host_api";',
*(f"{name} :: {signature} #foreign host_api;" for name, signature, _, _ in kryon_roots),
f"{ROOTS_ENTRY} :: (argc: s32, argv: **u8) -> s32 {{",
" if argc < 0 {",
*(f" unused {name}{call}" if "->" in signature else f" {name}{call}"
for name, signature, call, _ in kryon_roots),
" NotificationReceiver.AndroidNotificationReceive(null, null, null, null)",
" NotificationReceiver.AndroidNotificationRequestPermission(null, null, null)",
" return JNI_OnLoad(null, null)",
" }",
" return main(argc, argv)",
+18 -2
View File
@@ -1,6 +1,7 @@
// Decode upright straight RGBA and export through the native image codecs.
#import "ziran_image_decode"
#import "c_string"
#import "std/byte_text_linux"
Desktop :: #import "image_decode_desktop";
#scope_file
@@ -32,14 +33,29 @@ EncodedImageExport :: (data: string, file_type: string, path: string) -> bool {
byte := extension[at]
kind[at] = ifx byte >= 65 && byte <= 90 then byte + cast(u8)32 else byte
}
if extension.count == 3 && kind[0] == 106 && kind[1] == 112 && kind[2] == 103 {
format := TextFromCString(*kind[0])
jpeg := format == "jpg" || format == "jpeg"
if format == "jpg" {
unused CopyCString("jpeg", kind[:])
}
image := ImageDecodeEncoded(data, file_type)
if image.pixels == null { return false }
defer DecodedImageFree(image)
if !ExportReady() { return false }
pixbuf := new_pixels(image.pixels, 0, 1, 8, image.width, image.height, image.width * 4, null, null)
if jpeg {
// The decoded pixels are owned here. Compact RGBA to RGB in place
// for JPEG encoders that require exactly three channels.
for pixel: 0..image.width * image.height - 1 {
input := pixel * 4
output := pixel * 3
image.pixels[output] = image.pixels[input]
image.pixels[output + 1] = image.pixels[input + 1]
image.pixels[output + 2] = image.pixels[input + 2]
}
}
alpha: s32 = ifx jpeg then 0 else 1
stride: s32 = image.width * (3 + alpha)
pixbuf := new_pixels(image.pixels, 0, alpha, 8, image.width, image.height, stride, null, null)
if pixbuf == null { return false }
defer { Desktop.CloseImage(pixbuf) }
return save_pixels(pixbuf, *path_bytes[0], *kind[0], null, null, null) != 0
+9 -6
View File
@@ -1,6 +1,5 @@
#!/usr/bin/env python3
"""Generate real Android host graphs, compile their C with the NDK, and link
the JNI loader entry through the canonical Android export map."""
"""Generate Android host graphs and verify their NDK-linked JNI exports."""
import os
from pathlib import Path
import subprocess
@@ -23,6 +22,10 @@ def run(command, cwd=ROOT):
# Defined by generated C although no Zi code calls them: Android's loader
# calls JNI_OnLoad, and kryon_android_app's --wrap=fopen/fopen64 link the rest.
LOADER_ROOTS = {"JNI_OnLoad", "__wrap_fopen", "__wrap_fopen64"}
RECEIVER_EXPORTS = {
"Java_org_kryonlabs_notifications_NotificationReceiver_receive",
"Java_org_kryonlabs_notifications_NotificationReceiver_requestPermission",
}
def link_contract(kind, project, manifest, ndk):
"""Link the graph as an app's libmain.so through kryon_android_app and
@@ -61,15 +64,15 @@ kryon_android_host(main ${{APP_ZIRAN_GENERATED_SOURCES}})
[ndk / "bin/llvm-nm", "-D", "--defined-only", build / "libmain.so"],
env=ENV, check=True, capture_output=True, text=True).stdout
exported = {line.split()[-1] for line in symbols.splitlines() if line.split()}
# Android resolves these two by name; native_app_glue calls android_main
# inside the library, where -fvisibility=hidden leaves it.
required = {"JNI_OnLoad", "ANativeActivity_onCreate"}
# Android resolves these by name; native_app_glue calls android_main
# directly inside the library.
required = {"JNI_OnLoad", "ANativeActivity_onCreate"} | RECEIVER_EXPORTS
if not required <= exported:
raise AssertionError(kind + " libmain.so does not export " + ", ".join(sorted(required - exported)))
for private in ("GenerationGluePrivate", "KryonAndroidRoots"):
if private in exported:
raise AssertionError(kind + " libmain.so leaked " + private)
print(kind + " libmain.so links and exports JNI_OnLoad through the canonical map", flush=True)
print(kind + " libmain.so exports Android loader and notification JNI entries", flush=True)
def main():
sdk = Path(os.environ.get("ANDROID_HOME", Path.home() / "Android/Sdk"))
+17 -17
View File
@@ -1,13 +1,12 @@
"""Kryon's project templates and the kryon front door, display-free.
Each template is created with `kryon new` exactly as a user would, from
this checkout, and built and rendered once on the terminal host. The web
template is checked; its browser profiles need Emscripten.
Every template is created with `kryon new` from this checkout. The app's
desktop profile is checked and its shot profile renders without a display.
The web template is checked without building its browser profiles.
"""
import os
from pathlib import Path
import shutil
import subprocess
import tempfile
@@ -27,12 +26,9 @@ def environment(work):
env["PATH"] = f"{ZIRAN_ROOT / 'build/bin'}:{env['PATH']}"
env["KRYON_TEMPLATES"] = str(ROOT)
env["ASAN_OPTIONS"] = "detect_leaks=0"
# Exercise the template commands against the canonical source checkouts,
# including their uncommitted changes, without copying/cloning them or
# fetching a new toolchain. Explicit overrides are installed before locking.
ziran = ZIRAN_ROOT / "build/bin/ziran"
# Resolve existing sources before isolating the new template projects.
env["XDG_CACHE_HOME"] = str(work / "cache")
# The projects and their build outputs are temporary. Reuse the prepared
# package cache so their first lock can reuse the same dependency sources.
# Install local checkout overrides before any template is locked.
overrides = (f'[overrides]\nziran = "{ZIRAN_ROOT}"\n'
f'Kryon = "{ROOT}"\n')
(work / "overrides.toml").write_text(overrides)
@@ -41,12 +37,18 @@ def environment(work):
def run(command, directory, env, succeed=True, stdin=subprocess.DEVNULL, separate=False):
# SEPARATE keeps build diagnostics (stderr) out of a program's own output.
result = subprocess.run([str(part) for part in command], cwd=directory, env=env,
stdin=stdin, stdout=subprocess.PIPE,
stderr=subprocess.PIPE if separate else subprocess.STDOUT,
text=True, timeout=900)
command = [str(part) for part in command]
try:
result = subprocess.run(command, cwd=directory, env=env, stdin=stdin,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE if separate else subprocess.STDOUT,
text=True, timeout=900)
except subprocess.TimeoutExpired as error:
output = (error.stderr or error.stdout or b"").decode(errors="replace")
raise AssertionError(f"{' '.join(command)} timed out in {directory}:\n"
f"{output[-4000:]}") from error
if succeed != (result.returncode == 0):
raise AssertionError(f"{' '.join(map(str, command))} returned "
raise AssertionError(f"{' '.join(command)} returned "
f"{result.returncode}:\n{result.stdout}{result.stderr or ''}")
return result.stdout
@@ -69,8 +71,6 @@ def main():
manifest = (work / name / "ziran.toml").read_text()
assert 'tool = "kryon"' in manifest and "{{" not in manifest, manifest
# The first command in the fresh cache may fetch and build the locked
# toolchain and report it; the profile list is compared after that.
run([KRYON, "check", "desktop"], work / "demo-app", env)
profiles = run([KRYON, "profiles"], work / "demo-app", env)
assert profiles.splitlines() == ["* desktop SDL2/Cairo window", " portable SDL2/Cairo window", " tui terminal",
+107 -13
View File
@@ -2,35 +2,129 @@
#import "geometry"
#import "tree"
#import "widget_kind"
#import "key_input"
TextField :: #import "textfield";
#import "tree_input"
using WidgetKind;
Build :: (session: Session, kind: s32, selected: bool, disabled: bool) -> bool {
TextFocusCase :: struct {
kind: s32
selected: bool
disabled: bool
active: bool
}
Build :: (session: Session, test: TextFocusCase) -> bool {
bounds: Rectangle = .{0.0, 0.0, 100.0, 20.0}
TreeStart(session, cast(u64)1, bounds)
if !TreeIsBuilding(session) { return false }
for i: 1..40 {
unused TreeSubmit(session, cast(u64)i, 0, WidgetKindImage, bounds)
}
node := TreeSubmit(session, cast(u64)50, 0, kind, bounds)
TreeSetSelected(session, node, selected)
TreeSetInteractive(session, node, disabled, false, 50)
node := TreeSubmit(session, cast(u64)50, 0, test.kind, bounds)
TreeSetSelected(session, node, test.selected)
TreeSetInteractive(session, node, test.disabled, false, 50)
if !TreeFinish(session) { return false }
expected := selected && !disabled &&
(kind == WidgetKindTextField || kind == WidgetKindTextArea)
return TreeTextInputActive(session) == expected
return TreeTextInputActive(session) == test.active
}
CheckKeysAndUTF8 :: () -> s32 {
session: Session = SessionOpen()
if !SessionValid(session) { return 1 }
defer { unused SessionClose(session) }
if KeyF3 != 292 { return 12 }
unused KeyboardSend(session, KeyF3)
if KeyboardTake(session) != KeyF3 || KeyboardTake(session) != 0 { return 13 }
// Typed codepoints arrive as one UTF-8 text, then the queue is empty.
storage: [16]u8
TypedCodepointSend(session, 104)
TypedCodepointSend(session, 233)
TypedCodepointSend(session, 0x20AC)
TypedCodepointSend(session, 0x1F600)
{
typed: string = TypedTextTake(session, storage[:])
if typed != "hé€😀" { return 2 }
}
if TypedTextTake(session, storage[:]).count != 0 { return 3 }
// Text that does not fit stops at the last whole codepoint.
small: [3]u8
TypedCodepointSend(session, 97)
TypedCodepointSend(session, 0x20AC)
if TypedTextTake(session, small[:]) != "a" { return 4 }
if TypedTextTake(session, small[:]) != "€" { return 14 }
// A burst longer than one retained queue drains without loss.
if TypedCodepointCapacity(session) != 32 { return 20 }
burst: [128]u8
for group: 0..1 {
base: s32 = 48 + cast(s32)group * 32
for index: 0..31 {
if !TypedCodepointSend(session, base + cast(s32)index) {
return 15
}
}
{
typed := TypedTextTake(session, burst[:])
if typed.count != 32 ||
typed[0] != cast(u8)base ||
typed[typed.count - 1] != cast(u8)(base + 31) { return 16 }
}
}
for index: 0..7 {
if !TypedCodepointSend(session, 112 + cast(s32)index) { return 15 }
}
{
typed := TypedTextTake(session, burst[:])
if typed.count != 8 || typed[0] != cast(u8)112 ||
typed[7] != cast(u8)119 { return 16 }
}
if TypedTextTake(session, burst[:]).count != 0 { return 17 }
// A caller-sized UTF-8 buffer keeps every scalar boundary.
unicode: [8]u8
for index: 0..4 {
if !TypedCodepointSend(session, 0x1F600) { return 18 }
}
if TypedTextTake(session, unicode[:]).count != 8 ||
TypedTextTake(session, unicode[:]).count != 8 ||
TypedTextTake(session, unicode[:]).count != 4 ||
TypedTextTake(session, unicode[:]).count != 0 { return 19 }
// Keys map to the matching edits; typed text is inserted.
input: TextField.Input = TextFieldInputFor(KeyBackspace, 0, "")
if !input.backspace || input.left || input.text.count != 0 { return 5 }
input = TextFieldInputFor(KeyLeft, KeyModifierShift, "")
if !input.left || !input.shift { return 6 }
input = TextFieldInputFor(KeyEnter, 0, "")
if !input.commit || input.escape { return 7 }
input = TextFieldInputFor(0, 0, "ab")
if input.text != "ab" || input.backspace { return 8 }
// Control turns letters into shortcuts and inserts no text.
input = TextFieldInputFor(86, KeyModifierControl, "v")
if !input.paste || input.text.count != 0 { return 9 }
input = TextFieldInputFor(65, KeyModifierControl, "")
if !input.select_all || input.copy { return 10 }
input = TextFieldInputFor(KeyDelete, 0, "")
if !input.delete_forward || !TextFieldInputFor(KeyHome, 0, "").home ||
!TextFieldInputFor(KeyEnd, 0, "").end ||
!TextFieldInputFor(KeyEscape, 0, "").escape { return 11 }
return 0
}
#program_export
main :: () -> s32 {
keys := CheckKeysAndUTF8()
if keys != 0 { return 20 + keys }
session := SessionOpen()
if TreeTextInputActive(session) { return 1 }
if !Build(session, WidgetKindTextField, true, false) { return 2 }
if !Build(session, WidgetKindTextArea, true, false) { return 3 }
if !Build(session, WidgetKindTextField, true, true) { return 4 }
if !Build(session, WidgetKindTextField, false, false) { return 5 }
if !Build(session, WidgetKindButton, true, false) { return 6 }
cases: [5]TextFocusCase = .[
.{WidgetKindTextField, true, false, true},
.{WidgetKindTextArea, true, false, true},
.{WidgetKindTextField, true, true, false},
.{WidgetKindTextField, false, false, false},
.{WidgetKindButton, true, false, false}]
for index: 0..4 {
if !Build(session, cases[index]) { return 2 + cast(s32)index }
}
// A cancelled submission keeps the previous committed editing state.
if !Build(session, WidgetKindTextArea, true, false) { return 7 }
if !Build(session, cases[1]) { return 7 }
TreeStart(session, cast(u64)1, .{0.0, 0.0, 100.0, 20.0})
if !TreeIsBuilding(session) { return 8 }
TreeCancel(session)
+8 -4
View File
@@ -6,22 +6,26 @@ reaches the page through Ziran's generic Web bridge, whose one JavaScript file
lives in the Ziran repository. Only test fixtures and the documentation site
may hold JavaScript here, and no build rule may link a JS library from Kryon.
"""
import os
from pathlib import Path
import re
import subprocess
import sys
root = Path(__file__).resolve().parent.parent
tracked = subprocess.run(["git", "ls-files"], cwd=root, check=True,
capture_output=True, text=True).stdout.split()
paths = os.fsdecode(subprocess.check_output(
["git", "ls-files", "-z", "--cached", "--others", "--exclude-standard"],
cwd=root,
)).split("\0")
files = sorted({name for name in paths if (root / name).is_file()})
failures = []
for name in tracked:
for name in files:
if not re.search(r"\.(js|mjs|cjs|ts)$", name):
continue
if name.startswith(("tests/", "docs/")):
continue
failures.append(f"{name}: browser hosts are written in Ziran, not JavaScript")
for name in tracked:
for name in files:
if not name.startswith("mk/") and name != "Makefile":
continue
for number, line in enumerate((root / name).read_text().splitlines(), 1):
-10
View File
@@ -1,10 +0,0 @@
#!/bin/sh
. "$(dirname -- "$0")/test_context.sh"
paths="--root $repo/tests $kryon_ui_args --module-path $ziran_root/std"
source=$repo/tests/ziran_key_input_test.zi
"$ziran" bundle $paths --entry ziran_key_input_test:main -o "$work/keys.zx" "$source"
test "$("$ziran" run "$work/keys.zx")" = 0
"$ziran" build --target=c $paths --entry ziran_key_input_test:main -o "$work/c" "$source"
${CC:-cc} -std=c99 -I"$ziran_root/include" "$work/c"/*.c -o "$work/run-c"
"$work/run-c"
echo 'Key input: typed text and text field editing keys passed'
-84
View File
@@ -1,84 +0,0 @@
#import "session"
#import "key_input"
TextField :: #import "textfield";
#import "tree_input"
#program_export
main :: () -> s32 {
session: Session = SessionOpen()
if !SessionValid(session) { return 1 }
if KeyF3 != 292 { return 12 }
unused KeyboardSend(session, KeyF3)
if KeyboardTake(session) != KeyF3 || KeyboardTake(session) != 0 { return 13 }
// Typed codepoints arrive as one UTF-8 text, then the queue is empty.
storage: [16]u8
TypedCodepointSend(session, 104)
TypedCodepointSend(session, 233)
TypedCodepointSend(session, 0x20AC)
TypedCodepointSend(session, 0x1F600)
{
typed: string = TypedTextTake(session, storage[:])
if typed != "hé€😀" { return 2 }
}
if TypedTextTake(session, storage[:]).count != 0 { return 3 }
// Text that does not fit stops at the last whole codepoint.
small: [3]u8
TypedCodepointSend(session, 97)
TypedCodepointSend(session, 0x20AC)
if TypedTextTake(session, small[:]) != "a" { return 4 }
if TypedTextTake(session, small[:]) != "€" { return 14 }
// A burst longer than one retained queue drains without loss.
if TypedCodepointCapacity(session) != 32 { return 20 }
burst: [128]u8
for group: 0..1 {
base: s32 = 48 + cast(s32)group * 32
for index: 0..31 {
if !TypedCodepointSend(session, base + cast(s32)index) {
return 15
}
}
{
typed := TypedTextTake(session, burst[:])
if typed.count != 32 ||
typed[0] != cast(u8)base ||
typed[typed.count - 1] != cast(u8)(base + 31) { return 16 }
}
}
for index: 0..7 {
if !TypedCodepointSend(session, 112 + cast(s32)index) { return 15 }
}
{
typed := TypedTextTake(session, burst[:])
if typed.count != 8 || typed[0] != cast(u8)112 ||
typed[7] != cast(u8)119 { return 16 }
}
if TypedTextTake(session, burst[:]).count != 0 { return 17 }
// A caller-sized UTF-8 buffer keeps every scalar boundary.
unicode: [8]u8
for index: 0..4 {
if !TypedCodepointSend(session, 0x1F600) { return 18 }
}
if TypedTextTake(session, unicode[:]).count != 8 ||
TypedTextTake(session, unicode[:]).count != 8 ||
TypedTextTake(session, unicode[:]).count != 4 ||
TypedTextTake(session, unicode[:]).count != 0 { return 19 }
// Keys map to the matching edits; typed text is inserted.
input: TextField.Input = TextFieldInputFor(KeyBackspace, 0, "")
if !input.backspace || input.left || input.text.count != 0 { return 5 }
input = TextFieldInputFor(KeyLeft, KeyModifierShift, "")
if !input.left || !input.shift { return 6 }
input = TextFieldInputFor(KeyEnter, 0, "")
if !input.commit || input.escape { return 7 }
input = TextFieldInputFor(0, 0, "ab")
if input.text != "ab" || input.backspace { return 8 }
// Control turns letters into shortcuts and inserts no text.
input = TextFieldInputFor(86, KeyModifierControl, "v")
if !input.paste || input.text.count != 0 { return 9 }
input = TextFieldInputFor(65, KeyModifierControl, "")
if !input.select_all || input.copy { return 10 }
input = TextFieldInputFor(KeyDelete, 0, "")
if !input.delete_forward || !TextFieldInputFor(KeyHome, 0, "").home ||
!TextFieldInputFor(KeyEnd, 0, "").end ||
!TextFieldInputFor(KeyEscape, 0, "").escape { return 11 }
return 0
}
+7 -1
View File
@@ -16,9 +16,15 @@ for form in source saved; do
"$ziran" bundle --root "$root" $modules \
--module-path "$ziran_root/std" --entry tree_text_input_test:main \
-o "$work/$form.zx" "$module"
test "$("$ziran" run "$work/$form.zx")" = 0
result=$("$ziran" run "$work/$form.zx")
if test "$result" != 0; then
echo "Text input failure in $form ZX: $result" >&2
exit 1
fi
"$ziran" build --root "$root" $modules \
--module-path "$ziran_root/std" --entry tree_text_input_test:main \
--target=c --exe -o "$work/$form-c" "$module"
"$work/$form-c/tree_text_input_test"
done
cmp "$work/source.zx" "$work/saved.zx"
echo 'Text input: UTF-8 queue, editing keys and committed focus passed'
+13 -11
View File
@@ -16,9 +16,9 @@
#import "bundle_media"
#import "bundle_app"
Video :: #import "video_linux";
Service :: #import "service_linux";
Bitmaps :: #import "bitmap_image";
#if OS == .LINUX {
Service :: #import "service_linux";
Theme :: #import "system_theme_host_linux";
Background :: #import "background_window_linux";
}
@@ -106,13 +106,13 @@ Supported :: (module: string, function: string) -> bool {
function == "MediaMessageHost" || function == "FetchTextHost" ||
function == "FetchTextStateHost" || function == "FetchTextResultHost"
}
if ModuleName(module, "service") {
return function == "ServiceRequestHost" || function == "ServiceStateHost" || function == "ServiceResultHost"
}
if ModuleName(module, "bitmap_image") {
return function == "BitmapImageCreateHost" || function == "BitmapImageUpdateHost" || function == "BitmapImageReleaseHost"
}
#if OS == .LINUX {
if ModuleName(module, "service") {
return function == "ServiceRequestHost" || function == "ServiceStateHost" || function == "ServiceResultHost"
}
if ModuleName(module, "system_theme_host") { return function == "SystemThemeColorHost" }
}
return false
@@ -186,11 +186,6 @@ PlayerCall :: (context: *void, module_name: *u8, function_name: *u8,
DesktopFrameUnchanged(args[0].integer != 0)
return 1
}
if function == "ServiceRequestHost" && count == 2 && args[0].kind == HostString && args[1].kind == HostString {
result.kind = HostInteger
result.integer = cast(s64)Service.ServiceRequestHost(TextValue(args[0]), TextValue(args[1]))
return 1
}
// A bundle's runtime pictures, owned by the session the player runs.
if function == "BitmapImageCreateHost" && count == 3 && args[0].kind == HostInteger && args[1].kind == HostInteger && args[2].kind == HostString {
result.kind = HostUnsigned; result.bits = 0
@@ -209,6 +204,12 @@ PlayerCall :: (context: *void, module_name: *u8, function_name: *u8,
Bitmaps.BitmapImageRelease(player.input, Texture2D.{.id = cast(u32)args[0].bits, .width = cast(s32)args[1].integer, .height = cast(s32)args[2].integer, .mipmaps = 1, .format = 7})
return 1
}
#if OS == .LINUX {
if function == "ServiceRequestHost" && count == 2 && args[0].kind == HostString && args[1].kind == HostString {
result.kind = HostInteger
result.integer = cast(s64)Service.ServiceRequestHost(TextValue(args[0]), TextValue(args[1]))
return 1
}
if function == "ServiceStateHost" && count == 0 {
result.kind = HostInteger
result.integer = cast(s64)Service.ServiceStateHost()
@@ -222,7 +223,6 @@ PlayerCall :: (context: *void, module_name: *u8, function_name: *u8,
result.length = cast(usize)value.count
return 1
}
#if OS == .LINUX {
if count == 0 && function == "WindowCompactHost" {
result.kind = HostInteger
result.integer = cast(s64)Background.WindowCompactHost()
@@ -694,7 +694,9 @@ main :: (argc: s32, argv: **u8) -> s32 {
}
BundleMediaClose(*player.media)
Video.VideoStopHost()
Service.CloseService()
#if OS == .LINUX {
Service.CloseService()
}
CloseDesktop()
CloseBundleInstance(instance)
CloseBundle(bundle)