Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
09ac0a29f1 | ||
|
|
0fd42f7574 | ||
|
|
f5ea95a4ad |
No files matched your search
@@ -11,5 +11,6 @@ xauth
|
||||
libgtk-3-dev
|
||||
python3-pil
|
||||
tesseract-ocr
|
||||
imagemagick
|
||||
gnumeric
|
||||
zenity
|
||||
@@ -34,7 +34,7 @@ jobs:
|
||||
- name: Install CLI test dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y openssl xclip xvfb xauth tesseract-ocr
|
||||
sudo apt-get install -y openssl xclip xvfb xauth tesseract-ocr imagemagick
|
||||
- name: Install Emscripten
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
@@ -51,7 +51,7 @@ jobs:
|
||||
- name: Install screenshot OCR
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y tesseract-ocr
|
||||
sudo apt-get install -y tesseract-ocr imagemagick
|
||||
- name: Verify browser input, storage, cache upgrades, and offline launch
|
||||
env:
|
||||
WERK_WEB_BROWSER: google-chrome
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
# Changelog
|
||||
|
||||
## [0.4.2] - 2026-10-23
|
||||
|
||||
- Linux packages include the libraries needed for sync and importing QR-code pictures.
|
||||
- Packaging a new AppImage preserves previous downloads.
|
||||
|
||||
## [0.4.1] - 2026-10-23
|
||||
|
||||
- Open Pass, Auth, Calculator, Clock and Workbook directly from the Linux application menu, each with its own icon.
|
||||
|
||||
@@ -53,15 +53,18 @@ APPS := pass auth calculator clock
|
||||
PORTABLE_BUNDLES := $(APPS:%=build/apps/%.zib) build/apps/entity.zib build/apps/apps.zib
|
||||
APP_BUNDLES := $(PORTABLE_BUNDLES) build/apps/workbook.zib
|
||||
SHARED_SOURCES := $(wildcard shared/*.zi)
|
||||
APPS_UI_SOURCES = $(wildcard $(APPS_DIR)/src/*.zi $(APPS_DIR)/ui/*.zi $(APPS_DIR)/ui/locales/*.json)
|
||||
APP_MODULE_PATHS = --module-path shared --module-path kryon=$(KRYON_DIR)/src/backend --module-path kryon=$(KRYON_DIR)/src/ui --module-path $(KRYON_DIR)/src/ui --module-path $(MINGCUTE_DIR)/src --module-path $(ZIRAN_ROOT)/std
|
||||
apps: $(APP_BUNDLES)
|
||||
portable-apps: $(PORTABLE_BUNDLES)
|
||||
build/apps/apps.zib: ziran.lock apps-controller.sha256
|
||||
# Compile the shared screen with the host's compiler and UI library. The
|
||||
# reviewed payload must match both the build pin and the native host pin.
|
||||
build/apps/apps.zib: $(APPS_UI_SOURCES) $(LIBRARY_SOURCES) $(ZIRAN_RUNTIME_SOURCES) ziran.lock apps-controller.sha256 Makefile scripts/ziran.sh
|
||||
mkdir -p $(@D)
|
||||
$(ZIRAN) version > /dev/null
|
||||
env -u DISPLAY -u WAYLAND_DISPLAY \
|
||||
PATH="$(if $(wildcard $(ZIRAN_ROOT)/build/bin/ziran),$(ZIRAN_ROOT)/build/bin,$(CURDIR)/build/toolchain/bin):$$PATH" \
|
||||
python3 '$(APPS_DIR)/scripts/build-ui.py' --output '$(abspath $(@D))'
|
||||
python3 '$(APPS_DIR)/scripts/generate-ui-locales.py' --check
|
||||
$(ZIRAN) bundle --root $(APPS_DIR)/ui --module-path $(APPS_DIR)/src $(APP_MODULE_PATHS) \
|
||||
--define KRYON_HOSTED_UI --entry apps:Main -o $@ $(APPS_DIR)/ui/apps.zi
|
||||
sha256sum $@ | cut -d ' ' -f 1 > $(@D)/apps.sha256
|
||||
test "$$(cat $(@D)/apps.sha256)" = "$$(cat apps-controller.sha256)"
|
||||
.SECONDEXPANSION:
|
||||
build/apps/%.zib: $$(wildcard apps/$$*/*.zi apps/$$*/assets/*) $(SHARED_SOURCES) $(LIBRARY_SOURCES) $(ZIRAN_RUNTIME_SOURCES) ziran.lock Makefile scripts/ziran.sh
|
||||
@@ -120,6 +123,7 @@ test: source-check core-test pass-state-test app-logic-test cli-test lesspass-co
|
||||
gui-smoke: gui
|
||||
sh scripts/gui_smoke.sh
|
||||
gui-test: gui
|
||||
python3 scripts/private-display.py python3 scripts/apps_gui_test.py
|
||||
sh scripts/werk_gui_test.sh
|
||||
python3 scripts/private-display.py python3 scripts/workbook_gui_test.py
|
||||
python3 scripts/private-display.py python3 scripts/launcher_gui_test.py
|
||||
|
||||
@@ -1 +1 @@
|
||||
3dd75428691d03a79a1644e0fd154b1af4f12f326fe2dd7e0993b5201201eaff
|
||||
8c5806d7ff5a4fdaf6b98a7668acbf0aad236ece1d5e68ffe1f7b268a1afb077
|
||||
@@ -43,8 +43,8 @@ android {
|
||||
applicationId 'xyz.waozi.pass'
|
||||
minSdk 21
|
||||
targetSdk 36
|
||||
versionCode 15
|
||||
versionName "0.4.1"
|
||||
versionCode 16
|
||||
versionName "0.4.2"
|
||||
// Default to the two realistic phone targets; override with
|
||||
// -Pabi=x86_64 etc. for emulator builds.
|
||||
def abis = project.findProperty('abi') ?: 'armeabi-v7a,arm64-v8a'
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
- Linux packages include the libraries needed for sync and importing QR-code pictures.
|
||||
- Packaging a new AppImage preserves previous downloads.
|
||||
@@ -11,5 +11,5 @@
|
||||
<launchable type="desktop-id">xyz.waozi.werk.desktop</launchable>
|
||||
<url type="homepage">https://github.com/waozixyz/werk</url>
|
||||
<provides><binary>werk</binary></provides>
|
||||
<releases><release version="0.4.1" date="2026-10-23"/><release version="0.4.0" date="2026-10-15"/><release version="0.3.1" date="2026-10-13"/><release version="0.3.0" date="2026-10-13"/><release version="0.2.10" date="2026-10-05"/><release version="0.2.9" date="2026-09-05"/><release version="0.2.8" date="2026-08-26"/><release version="0.2.7" date="2026-08-24"/><release version="0.2.6" date="2026-08-24"/><release version="0.2.5" date="2026-08-24"/><release version="0.2.4" date="2026-08-22"/><release version="0.2.3" date="2026-08-21"/><release version="0.2.2" date="2026-08-20"/><release version="0.2.1" date="2026-08-19"/><release version="0.2.0" date="2026-08-18"/><release version="0.1.3" date="2026-08-17"/><release version="0.1.2" date="2026-08-17"/><release version="0.1.1" date="2026-08-17"/><release version="0.1.0" date="2026-08-17"/></releases>
|
||||
<releases><release version="0.4.2" date="2026-10-23"/><release version="0.4.1" date="2026-10-23"/><release version="0.4.0" date="2026-10-15"/><release version="0.3.1" date="2026-10-13"/><release version="0.3.0" date="2026-10-13"/><release version="0.2.10" date="2026-10-05"/><release version="0.2.9" date="2026-09-05"/><release version="0.2.8" date="2026-08-26"/><release version="0.2.7" date="2026-08-24"/><release version="0.2.6" date="2026-08-24"/><release version="0.2.5" date="2026-08-24"/><release version="0.2.4" date="2026-08-22"/><release version="0.2.3" date="2026-08-21"/><release version="0.2.2" date="2026-08-20"/><release version="0.2.1" date="2026-08-19"/><release version="0.2.0" date="2026-08-18"/><release version="0.1.3" date="2026-08-17"/><release version="0.1.2" date="2026-08-17"/><release version="0.1.1" date="2026-08-17"/><release version="0.1.0" date="2026-08-17"/></releases>
|
||||
</component>
|
||||
@@ -0,0 +1,177 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Verify the shared Apps controller and native tool navigation."""
|
||||
import csv
|
||||
import hashlib
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import time
|
||||
from PIL import Image
|
||||
|
||||
assert os.environ.get("WERK_TEST_PRIVATE_DISPLAY") == "1", "Use private-display.py"
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
work = Path(os.environ.get("WERK_APPS_TEST_OUTPUT", root / "build/apps-gui-test"))
|
||||
binary = Path(os.environ.get("WERK_TEST_BINARY", root / "build/werk"))
|
||||
assets = Path(os.environ.get("WERK_TEST_ASSETS", root / "build"))
|
||||
shutil.rmtree(work, ignore_errors=True)
|
||||
work.mkdir(parents=True)
|
||||
expected = (root / "apps-controller.sha256").read_text().strip()
|
||||
assert hashlib.sha256((assets / "apps/apps.zib").read_bytes()).hexdigest() == expected
|
||||
environment = dict(os.environ, HOME=str(work / "home"), WERK_DATA=str(work / "data"),
|
||||
WERK_ASSETS=str(assets), ENTITY_DATA=str(work / "entity"),
|
||||
XDG_CONFIG_HOME=str(work / "config"), XDG_DATA_HOME=str(work / "share"),
|
||||
XDG_CACHE_HOME=str(work / "cache"))
|
||||
for name in ("HOME", "WERK_DATA", "XDG_CONFIG_HOME", "XDG_DATA_HOME", "XDG_CACHE_HOME"):
|
||||
Path(environment[name]).mkdir(parents=True)
|
||||
profile = Path(environment["WERK_DATA"]) / "profile"
|
||||
profile.mkdir()
|
||||
(profile / "settings.txt").write_text("theme_mode=1\n")
|
||||
|
||||
|
||||
def command(*arguments):
|
||||
return subprocess.check_output(arguments, env=environment, text=True, timeout=20)
|
||||
|
||||
|
||||
def capture(name):
|
||||
time.sleep(.3)
|
||||
picture = work / (name + ".png")
|
||||
command("import", "-window", window, str(picture))
|
||||
# Separate dark text from the soft card fills for reliable recognition.
|
||||
with Image.open(picture) as source:
|
||||
labels = source.convert("L").point(lambda value: 0 if value < 140 else 255)
|
||||
labels.resize((source.width * 3, source.height * 3)).save(work / "labels.png")
|
||||
source.resize((source.width * 3, source.height * 3)).save(work / "full-text.png")
|
||||
return command("tesseract", str(work / "labels.png"), "stdout", "--psm", "11")
|
||||
|
||||
|
||||
def click(x, y):
|
||||
command("xdotool", "mousemove", "--window", window, str(x), str(y))
|
||||
command("xdotool", "click", "--window", window, "1")
|
||||
time.sleep(.2)
|
||||
|
||||
|
||||
def word_position(word):
|
||||
capture("control")
|
||||
for target in ("labels.png", "full-text.png"):
|
||||
text = command("tesseract", str(work / target), "stdout", "--psm", "11",
|
||||
"-c", "tessedit_create_tsv=1")
|
||||
for item in csv.DictReader(io.StringIO(text), delimiter="\t"):
|
||||
if item["text"].strip() == word:
|
||||
return ((int(item["left"]) + int(item["width"]) // 2) // 3,
|
||||
(int(item["top"]) + int(item["height"]) // 2) // 3)
|
||||
raise AssertionError("Missing visible app control: " + word)
|
||||
|
||||
|
||||
def click_word(word):
|
||||
click(*word_position(word))
|
||||
|
||||
|
||||
def key(value):
|
||||
command("xdotool", "key", "--window", window, value)
|
||||
time.sleep(.2)
|
||||
|
||||
|
||||
def type_text(value):
|
||||
command("xdotool", "type", "--window", window, "--delay", "30", value)
|
||||
time.sleep(.3)
|
||||
|
||||
|
||||
app = subprocess.Popen([str(binary)], env=environment)
|
||||
try:
|
||||
deadline = time.monotonic() + 30
|
||||
window = None
|
||||
while time.monotonic() < deadline:
|
||||
assert app.poll() is None, "Werkzeug exited during startup"
|
||||
found = subprocess.run(["xdotool", "search", "--onlyvisible", "--pid", str(app.pid)],
|
||||
env=environment, capture_output=True, text=True)
|
||||
if found.returncode == 0:
|
||||
window = found.stdout.splitlines()[0]
|
||||
break
|
||||
time.sleep(.1)
|
||||
assert window, "Werkzeug did not show its owned window"
|
||||
command("xdotool", "windowfocus", "--sync", window)
|
||||
# Window creation precedes loading the portable apps and the first frame.
|
||||
deadline = time.monotonic() + 20
|
||||
while True:
|
||||
home = capture("home")
|
||||
# The native fallback does not display package sizes.
|
||||
if "kB" in home or "MB" in home:
|
||||
break
|
||||
assert app.poll() is None, "Werkzeug exited while loading Apps"
|
||||
assert time.monotonic() < deadline, "Shared Apps controller did not render: " + home
|
||||
for name in ("Auth", "Calculator", "Clock", "Workbook", "Pass"):
|
||||
click_word(name)
|
||||
assert command("xdotool", "getwindowname", window).strip() == name
|
||||
assert "stopped" not in capture(name.lower()).lower(), name + " failed to run"
|
||||
click(28, 28)
|
||||
assert command("xdotool", "getwindowname", window).strip() == "Werkzeug"
|
||||
for width, height in ((360, 640), (720, 520)):
|
||||
command("xdotool", "windowsize", "--sync", window, str(width), str(height))
|
||||
text = capture(f"home-{width}")
|
||||
assert all(name in text for name in ("Pass", "Auth", "Calculator", "Clock", "Workbook")), text
|
||||
command("xdotool", "windowsize", "--sync", window, "420", "760")
|
||||
time.sleep(.3)
|
||||
click(330, 92) # Shared List view control, beside the search field.
|
||||
preferences = Path(environment["WERK_DATA"]) / "profile/apps.json"
|
||||
assert json.loads(preferences.read_text())["list"] is True
|
||||
text = capture("list")
|
||||
assert all(name in text for name in ("Pass", "Auth", "Calculator", "Clock", "Workbook")), text
|
||||
click(100, 92)
|
||||
type_text("clock")
|
||||
text = capture("search")
|
||||
assert "Clock" in text and "Calculator" not in text and "Workbook" not in text, text
|
||||
click(278, 92) # Clear search is part of the shared field.
|
||||
assert "Calculator" in capture("search-cleared")
|
||||
click(382, 372) # Clock's options at the end of its list row.
|
||||
text = capture("options")
|
||||
assert all(label in text for label in ("Open", "Pin", "Properties")), text
|
||||
click_word("Pin")
|
||||
capture("pinned")
|
||||
saved = json.loads(preferences.read_text())
|
||||
assert next(item for item in saved["apps"] if item["id"] == "clock")["favorite"]
|
||||
click(382, 204) # Clock now appears first, in Pinned.
|
||||
assert "Unpin" in capture("pinned-options")
|
||||
click_word("Properties")
|
||||
name = word_position("Name")
|
||||
click(120, name[1] + 34)
|
||||
key("ctrl+a")
|
||||
type_text("Timepiece")
|
||||
# The icon choices are: own icon, then Pass, Auth, Calculator, Clock, Workbook.
|
||||
click(name[0] - 16 + 120, name[1] + 116)
|
||||
# White text on the filled Save button is not reliably recognized by OCR.
|
||||
click(310, name[1] + 182)
|
||||
saved = json.loads(preferences.read_text())
|
||||
clock = next(item for item in saved["apps"] if item["id"] == "clock")
|
||||
assert clock["title"] == "Timepiece" and clock["icon"] == "auth", clock
|
||||
assert "Timepiece" in capture("renamed")
|
||||
assert preferences.stat().st_mode & 0o777 == 0o600
|
||||
app.terminate()
|
||||
app.wait(timeout=10)
|
||||
app = subprocess.Popen([str(binary)], env=environment)
|
||||
deadline = time.monotonic() + 30
|
||||
while True:
|
||||
found = subprocess.run(["xdotool", "search", "--onlyvisible", "--pid", str(app.pid)],
|
||||
env=environment, capture_output=True, text=True)
|
||||
if found.returncode == 0:
|
||||
window = found.stdout.splitlines()[0]
|
||||
if "Timepiece" in capture("restarted"):
|
||||
break
|
||||
assert time.monotonic() < deadline, "Launcher preferences did not survive restart"
|
||||
time.sleep(.1)
|
||||
click(382, 204)
|
||||
click_word("Open")
|
||||
assert command("xdotool", "getwindowname", window).strip() == "Clock"
|
||||
click(28, 28)
|
||||
click(382, 204)
|
||||
click_word("Unpin")
|
||||
saved = json.loads(preferences.read_text())
|
||||
clock = next(item for item in saved["apps"] if item["id"] == "clock")
|
||||
assert not clock["favorite"] and clock["title"] == "Timepiece" and clock["icon"] == "auth"
|
||||
print("Shared Apps: list/grid, search, menus, pins, name/icon edits, restart persistence, five tools and resized layouts verified locally")
|
||||
finally:
|
||||
if app.poll() is None:
|
||||
app.terminate()
|
||||
app.wait(timeout=10)
|
||||
@@ -64,10 +64,15 @@ for tool, name in (("", "Werkzeug"), ("pass", "Pass"), ("auth", "Auth"),
|
||||
assert window and command("xdotool", "getwindowname", window).strip() == name
|
||||
wm_class = command("xprop", "-id", window, "WM_CLASS")
|
||||
assert values["StartupWMClass"] in wm_class, wm_class
|
||||
time.sleep(.5)
|
||||
picture = work / ((tool or "werkzeug") + ".png")
|
||||
command("import", "-window", window, str(picture))
|
||||
text = command("tesseract", str(picture), "stdout", "--psm", "11")
|
||||
deadline = time.monotonic() + 15
|
||||
text = ""
|
||||
while time.monotonic() < deadline:
|
||||
assert process.poll() is None, f"{name} exited before rendering"
|
||||
time.sleep(.3)
|
||||
command("import", "-window", window, str(picture))
|
||||
text = command("tesseract", str(picture), "stdout", "--psm", "11")
|
||||
if name in text: break
|
||||
assert name in text, f"{name} did not render its direct tool screen: {text}"
|
||||
assert "unavailable" not in text.lower(), text
|
||||
print(f"Installed {name} entry opened the correct screen and window identity", flush=True)
|
||||
|
||||
@@ -5,6 +5,7 @@ root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
version=$(sed -n '1p' "$root/VERSION")
|
||||
arch=${APPIMAGE_ARCH:-$(uname -m)}
|
||||
linuxdeploy=${LINUXDEPLOY:-linuxdeploy}
|
||||
artifacts=${WERK_BUILD_DIR:-$root/build}
|
||||
appdir="$root/build/package/appimage/werk.AppDir"
|
||||
out="$root/build/release/werk-${version}-${arch}.AppImage"
|
||||
|
||||
@@ -12,17 +13,17 @@ test -n "$version"
|
||||
rm -rf "$appdir"
|
||||
mkdir -p "$appdir/usr/bin" "$appdir/usr/lib/werk/apps" "$appdir/usr/share/applications" \
|
||||
"$appdir/usr/share/mime/packages" "$appdir/usr/share/metainfo" "$appdir/usr/share/icons/hicolor/512x512/apps" "$(dirname "$out")"
|
||||
cp "$root/build/werk" "$appdir/usr/bin/werk"
|
||||
cp "$root"/build/apps/*.zib "$appdir/usr/lib/werk/apps/"
|
||||
cp "$root/build/pfp.png" "$appdir/usr/lib/werk/pfp.png"
|
||||
cp "$artifacts/werk" "$appdir/usr/bin/werk"
|
||||
cp "$artifacts"/apps/*.zib "$appdir/usr/lib/werk/apps/"
|
||||
cp "$artifacts/pfp.png" "$appdir/usr/lib/werk/pfp.png"
|
||||
python3 "$root/scripts/install-launchers.py" --data-dir "$appdir/usr/share"
|
||||
cp "$root/packaging/linux/werk-bundle.xml" "$appdir/usr/share/mime/packages/werk-bundle.xml"
|
||||
cp "$root/packaging/linux/xyz.waozi.werk.appdata.xml" "$appdir/usr/share/metainfo/xyz.waozi.werk.appdata.xml"
|
||||
cp "$root/assets/app/icon.png" "$root/build/package/appimage/werk.png"
|
||||
rm -f "$root"/Werkzeug-*.AppImage "$root"/werk-*.AppImage
|
||||
ARCH="$arch" "$linuxdeploy" --appdir "$appdir" --desktop-file "$root/packaging/linux/xyz.waozi.werk.desktop" \
|
||||
--icon-file "$root/build/package/appimage/werk.png" --output appimage
|
||||
image=$(find "$root" -maxdepth 1 -type f -name '*.AppImage' -print | head -n 1)
|
||||
run_dir=$(mktemp -d "$root/build/package/appimage/output.XXXXXX")
|
||||
(cd "$run_dir" && ARCH="$arch" "$linuxdeploy" --appdir "$appdir" --desktop-file "$root/packaging/linux/xyz.waozi.werk.desktop" \
|
||||
--icon-file "$root/build/package/appimage/werk.png" --output appimage)
|
||||
image=$(find "$run_dir" -maxdepth 1 -type f -name '*.AppImage' -print | head -n 1)
|
||||
test -n "$image"
|
||||
mv "$image" "$out"
|
||||
chmod 0755 "$out"
|
||||
|
||||
@@ -4,6 +4,7 @@ set -eu
|
||||
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
version=$(sed -n '1p' "$root/VERSION")
|
||||
arch=${DEB_ARCH:-$(dpkg --print-architecture)}
|
||||
artifacts=${WERK_BUILD_DIR:-$root/build}
|
||||
stage="$root/build/package/deb/werk"
|
||||
out="$root/build/release"
|
||||
|
||||
@@ -11,9 +12,9 @@ test -n "$version"
|
||||
rm -rf "$stage"
|
||||
mkdir -p "$stage/DEBIAN" "$stage/usr/bin" "$stage/usr/lib/werk/apps" "$stage/usr/share/applications" \
|
||||
"$stage/usr/share/mime/packages" "$stage/usr/share/metainfo" "$stage/usr/share/icons/hicolor/512x512/apps" "$stage/usr/share/doc/werk" "$out"
|
||||
cp "$root/build/werk" "$stage/usr/bin/werk"
|
||||
cp "$root"/build/apps/*.zib "$stage/usr/lib/werk/apps/"
|
||||
cp "$root/build/pfp.png" "$stage/usr/lib/werk/pfp.png"
|
||||
cp "$artifacts/werk" "$stage/usr/bin/werk"
|
||||
cp "$artifacts"/apps/*.zib "$stage/usr/lib/werk/apps/"
|
||||
cp "$artifacts/pfp.png" "$stage/usr/lib/werk/pfp.png"
|
||||
python3 "$root/scripts/install-launchers.py" --data-dir "$stage/usr/share"
|
||||
cp "$root/packaging/linux/werk-bundle.xml" "$stage/usr/share/mime/packages/werk-bundle.xml"
|
||||
cp "$root/packaging/linux/xyz.waozi.werk.appdata.xml" "$stage/usr/share/metainfo/xyz.waozi.werk.appdata.xml"
|
||||
@@ -28,7 +29,7 @@ Version: $version
|
||||
Architecture: $arch
|
||||
Maintainer: Waozi <[email protected]>
|
||||
Installed-Size: $installed
|
||||
Depends: libc6, libsdl2-2.0-0, libcairo2, libfreetype6, libfontconfig1, libpangocairo-1.0-0, libgtk-3-0, libx11-6, gnumeric, zenity
|
||||
Depends: libc6, libsdl2-2.0-0, libcairo2, libfreetype6, libfontconfig1, libpangocairo-1.0-0, libgtk-3-0, libx11-6, libcurl4 | libcurl4t64, libzbar0, gnumeric, zenity
|
||||
Section: utils
|
||||
Priority: optional
|
||||
Homepage: https://werk.waozi.xyz/
|
||||
|
||||
@@ -12,6 +12,7 @@ for key in ("DISPLAY", "WAYLAND_DISPLAY", "XAUTHORITY", "DBUS_SESSION_BUS_ADDRES
|
||||
environment.pop(key, None)
|
||||
environment["YUE_DESKTOP_RECOVERY"] = "0"
|
||||
environment["WERK_TEST_PRIVATE_DISPLAY"] = "1"
|
||||
environment["SDL_RENDER_DRIVER"] = "software"
|
||||
read_fd, write_fd = os.pipe()
|
||||
server = subprocess.Popen(["Xvfb", "-displayfd", str(write_fd), "-screen", "0", "1280x1024x24", "-nolisten", "tcp"],
|
||||
pass_fds=(write_fd,), env=environment)
|
||||
|
||||
+33
-6
@@ -95,9 +95,18 @@ try {
|
||||
};
|
||||
const expectText = async (name, expected) => {
|
||||
await screenshot(name);
|
||||
const result = spawnSync('tesseract', [join(output, name + '.png'), 'stdout', '--psm', '11'],
|
||||
let result = spawnSync('tesseract', [join(output, name + '.png'), 'stdout', '--psm', '11'],
|
||||
{env: environment, encoding: 'utf8', timeout: 20000});
|
||||
if (result.status !== 0) throw Error('Screenshot OCR failed: ' + result.stderr);
|
||||
if (!result.stdout.toLowerCase().includes(expected.toLowerCase())) {
|
||||
const readable = join(output, name + '-labels.png');
|
||||
const prepared = spawnSync('convert', [join(output, name + '.png'), '-colorspace', 'Gray',
|
||||
'-threshold', '55%', '-resize', '300%', readable], {env: environment, encoding: 'utf8'});
|
||||
if (prepared.status !== 0) throw Error('Could not prepare UI text: ' + prepared.stderr);
|
||||
result = spawnSync('tesseract', [readable, 'stdout', '--psm', '11'],
|
||||
{env: environment, encoding: 'utf8', timeout: 20000});
|
||||
if (result.status !== 0) throw Error('Screenshot OCR failed: ' + result.stderr);
|
||||
}
|
||||
if (!result.stdout.toLowerCase().includes(expected.toLowerCase()))
|
||||
throw Error(`${name}: expected ${expected}, saw ${result.stdout}`);
|
||||
};
|
||||
@@ -106,6 +115,21 @@ try {
|
||||
await command('Input.dispatchMouseEvent', {type: 'mouseReleased', x, y, button: 'left', clickCount: 1});
|
||||
await delay(350);
|
||||
};
|
||||
const clickText = async label => {
|
||||
await screenshot('control');
|
||||
const readable = join(output, 'control-labels.png');
|
||||
const prepared = spawnSync('convert', [join(output, 'control.png'), '-colorspace', 'Gray',
|
||||
'-threshold', '55%', '-resize', '300%', readable], {env: environment, encoding: 'utf8'});
|
||||
if (prepared.status !== 0) throw Error('Could not prepare UI text: ' + prepared.stderr);
|
||||
const result = spawnSync('tesseract', [readable, 'stdout', '--psm', '11',
|
||||
'-c', 'tessedit_create_tsv=1'], {env: environment, encoding: 'utf8', timeout: 20000});
|
||||
if (result.status !== 0) throw Error('Screenshot OCR failed: ' + result.stderr);
|
||||
const rows = result.stdout.trim().split('\n').slice(1).map(line => line.split('\t'));
|
||||
const row = rows.find(values => values[11]?.trim() === label);
|
||||
if (!row) throw Error('Missing visible app control: ' + label);
|
||||
await click((Number(row[6]) + Number(row[8]) / 2) / 3,
|
||||
(Number(row[7]) + Number(row[9]) / 2) / 3);
|
||||
};
|
||||
// The canvas has drawn a frame with something besides the background.
|
||||
const painted = `(() => {
|
||||
const canvas = document.querySelector('canvas');
|
||||
@@ -151,7 +175,8 @@ try {
|
||||
await command('Emulation.setDeviceMetricsOverride', {width: 420, height: 760, deviceScaleFactor: 1, mobile: false});
|
||||
await open('', 'home');
|
||||
const timezoneReadsBefore = await evaluate('window.__timezoneReads');
|
||||
await click(318, 189);
|
||||
await click(330, 92); // Shared List view.
|
||||
await clickText('Clock');
|
||||
await expectText('home-clock', 'Clock');
|
||||
await delay(1200);
|
||||
const timezoneReads = (await evaluate('window.__timezoneReads')) - timezoneReadsBefore;
|
||||
@@ -168,18 +193,20 @@ try {
|
||||
// would show its own name as the title.
|
||||
await open('?mini', 'mini-home');
|
||||
await expectText('mini-home', 'Werkzeug');
|
||||
for (const [index, app] of ['pass', 'auth', 'calculator', 'clock'].entries()) {
|
||||
for (const app of ['pass', 'auth', 'calculator', 'clock']) {
|
||||
await open('?mini&app=' + app, app + '-mini-direct');
|
||||
await expectText(app + '-mini-direct', app);
|
||||
await click(28, 28);
|
||||
await expectText(app + '-mini-home', 'Werkzeug');
|
||||
await click(102 + (index % 2) * 216, 100 + Math.floor(index / 2) * 90);
|
||||
await clickText(app[0].toUpperCase() + app.slice(1));
|
||||
await expectText(app + '-mini-reopened', app);
|
||||
}
|
||||
await command('Emulation.setDeviceMetricsOverride', {width: 280, height: 480, deviceScaleFactor: 1, mobile: false});
|
||||
await open('?mini&app=unknown', 'mini-narrow-home');
|
||||
await expectText('mini-narrow-home', 'Clock');
|
||||
await click(140, 399);
|
||||
await expectText('mini-narrow-home', 'Find an app');
|
||||
await click(100, 92);
|
||||
await type('clock');
|
||||
await clickText('Clock');
|
||||
await expectText('mini-narrow-clock', 'Clock');
|
||||
await click(28, 28);
|
||||
await click(250, 28);
|
||||
|
||||
-165
@@ -18,8 +18,6 @@ using UI :: #import "kryon/Widgets";
|
||||
#import "kryon/app_local"
|
||||
#import "kryon/app_files"
|
||||
#import "kryon/key_input"
|
||||
Controller :: #import "apps/controller";
|
||||
Rules :: #import "apps/protocol";
|
||||
#import "platform"
|
||||
#import "files"
|
||||
#import "sha256"
|
||||
@@ -102,169 +100,6 @@ AppCount :: () -> s32 {
|
||||
return app_count
|
||||
}
|
||||
|
||||
AppsControllerSha256 :: "3dd75428691d03a79a1644e0fd154b1af4f12f326fe2dd7e0993b5201201eaff";
|
||||
|
||||
HomeAppsState :: struct {
|
||||
controller: Controller.AppController
|
||||
bytes: string
|
||||
catalog_bytes: [65536]u8
|
||||
catalog_length: s32
|
||||
revision: s64
|
||||
selected: s32
|
||||
pending_open: s32
|
||||
opened: s32
|
||||
unavailable: bool
|
||||
}
|
||||
|
||||
home_apps: HomeAppsState;
|
||||
|
||||
HomeAppsAppend :: (text: string) {
|
||||
if home_apps.catalog_length + text.count > home_apps.catalog_bytes.count { return }
|
||||
for index: cast(s64)0..text.count - 1 {
|
||||
home_apps.catalog_bytes[home_apps.catalog_length] = text[index]
|
||||
home_apps.catalog_length += 1
|
||||
}
|
||||
}
|
||||
|
||||
HomeAppsAppendNumber :: (value: s64) {
|
||||
digits: [24]u8
|
||||
HomeAppsAppend(FormatInteger(value, digits[:]))
|
||||
}
|
||||
|
||||
HomeAppsAppendHexDigit :: (value: s32) {
|
||||
digit := ifx value < 10 then value + 48 else value + 87
|
||||
home_apps.catalog_bytes[home_apps.catalog_length] = cast(u8)digit
|
||||
home_apps.catalog_length += 1
|
||||
}
|
||||
|
||||
HomeAppsAppendQuoted :: (value: string) {
|
||||
HomeAppsAppend("\"")
|
||||
for index: cast(s64)0..value.count - 1 {
|
||||
byte := value[index]
|
||||
if byte == cast(u8)34 || byte == cast(u8)92 { HomeAppsAppend("\\") }
|
||||
home_apps.catalog_bytes[home_apps.catalog_length] = byte
|
||||
home_apps.catalog_length += 1
|
||||
if byte < cast(u8)32 {
|
||||
home_apps.catalog_length -= 1
|
||||
HomeAppsAppend("\\u00")
|
||||
HomeAppsAppendHexDigit((cast(s32)byte >> 4) & 15)
|
||||
HomeAppsAppendHexDigit(cast(s32)byte & 15)
|
||||
}
|
||||
}
|
||||
HomeAppsAppend("\"")
|
||||
}
|
||||
|
||||
HomeAppsQuoted :: (key: string, value: string) {
|
||||
HomeAppsAppend(",\"")
|
||||
HomeAppsAppend(key)
|
||||
HomeAppsAppend("\":")
|
||||
HomeAppsAppendQuoted(value)
|
||||
}
|
||||
|
||||
HomeAppsCatalog :: (selected: s32) {
|
||||
home_apps.catalog_length = 0
|
||||
HomeAppsAppend("{\"v\":1,\"revision\":")
|
||||
HomeAppsAppendNumber(home_apps.revision)
|
||||
HomeAppsAppend(",\"title\":\"Werkzeug\",\"locale\":\"en\",")
|
||||
HomeAppsAppend("\"presentation\":{\"mode\":\"icon\",\"tile_class\":0,\"action_class\":0,\"muted_class\":0},\"children\":[")
|
||||
first := true
|
||||
for index: cast(s32)0..app_count - 1 {
|
||||
if AppId(index) == "entity" { continue }
|
||||
if !first { HomeAppsAppend(",") }
|
||||
first = false
|
||||
HomeAppsAppend("{\"id\":")
|
||||
HomeAppsAppendQuoted(AppId(index))
|
||||
HomeAppsQuoted("title", AppName(index))
|
||||
HomeAppsQuoted("icon_shape", AppIcon(index))
|
||||
HomeAppsAppend(",\"installed\":true,\"on_device\":true,\"favorite\":false,\"selected\":")
|
||||
HomeAppsAppend(ifx index == selected then "true" else "false")
|
||||
HomeAppsAppend(",\"bytes\":")
|
||||
HomeAppsAppendNumber(apps[index].bytes.count)
|
||||
HomeAppsAppend(",\"actions\":[\"open\"]}")
|
||||
}
|
||||
HomeAppsAppend("]}")
|
||||
}
|
||||
|
||||
HomeAppsPrepare :: (selected: s32) {
|
||||
if selected == home_apps.selected { return }
|
||||
home_apps.selected = selected
|
||||
home_apps.revision += 1
|
||||
HomeAppsCatalog(selected)
|
||||
}
|
||||
|
||||
HomeAppsService :: (context: *void, request: string) -> string {
|
||||
parsed: Rules.AppsRequest
|
||||
if !Rules.AppsReadRequest(request, *parsed) {
|
||||
return "{\"v\":1,\"status\":\"rejected\"}"
|
||||
}
|
||||
if parsed.operation == Rules.APPS_CATALOG {
|
||||
if parsed.revision > 0 && parsed.revision == home_apps.revision {
|
||||
return "{\"v\":1,\"unchanged\":true}"
|
||||
}
|
||||
return TextView(home_apps.catalog_bytes[:home_apps.catalog_length])
|
||||
}
|
||||
if parsed.operation == Rules.APPS_OPEN {
|
||||
for index: cast(s32)0..app_count - 1 {
|
||||
if AppId(index) == TextUntilNul(parsed.id[:]) {
|
||||
home_apps.pending_open = index
|
||||
return "{\"v\":1,\"status\":\"applied\"}"
|
||||
}
|
||||
}
|
||||
}
|
||||
return "{\"v\":1,\"status\":\"rejected\"}"
|
||||
}
|
||||
|
||||
HomeAppsWidgets :: (context: *void, module: *u8, function: *u8, arguments: *HostValue,
|
||||
count: s32, result: *HostValue) -> s32 {
|
||||
return WidgetHostCall(context, module, function, arguments, count, result)
|
||||
}
|
||||
|
||||
HomeAppsAssetAllowed :: (path: string) -> bool {
|
||||
return path == ""
|
||||
}
|
||||
|
||||
SharedHome :: (session: Session, bounds: Rectangle, dark: bool, selected: s32) -> bool {
|
||||
if home_apps.unavailable { return false }
|
||||
if home_apps.revision == 0 {
|
||||
home_apps.selected = -2
|
||||
home_apps.pending_open = -1
|
||||
home_apps.opened = -1
|
||||
home_apps.revision = 1
|
||||
}
|
||||
if !home_apps.controller.ready {
|
||||
path: [PATH_LIMIT]u8
|
||||
bundle_path := PathJoin(path[:], BundledAppsRoot(), "apps.zib")
|
||||
bytes, found := ReadBundle(bundle_path)
|
||||
if !found {
|
||||
home_apps.unavailable = true
|
||||
return false
|
||||
}
|
||||
home_apps.bytes = bytes
|
||||
if !Controller.AppControllerOpen(*home_apps.controller, home_apps.bytes, AppsControllerSha256,
|
||||
Controller.AppControllerPlatform.{.context = cast(*void)*home_apps.controller,
|
||||
.service = HomeAppsService, .widgets = HomeAppsWidgets}) {
|
||||
home_apps.unavailable = true
|
||||
return false
|
||||
}
|
||||
}
|
||||
HomeAppsPrepare(selected)
|
||||
home_apps.controller.app.session = session
|
||||
home_apps.controller.app.bounds = bounds
|
||||
home_apps.controller.app.dark = dark
|
||||
home_apps.controller.app.scale = 1.0
|
||||
home_apps.controller.app.font = 16
|
||||
WidgetHostBegin(session, HomeAppsAssetAllowed)
|
||||
ran := Controller.AppControllerRun(*home_apps.controller, APP_FRAME)
|
||||
WidgetHostEnd()
|
||||
home_apps.opened = home_apps.pending_open
|
||||
home_apps.pending_open = -1
|
||||
return ran
|
||||
}
|
||||
|
||||
SharedHomeOpened :: () -> s32 {
|
||||
return home_apps.opened
|
||||
}
|
||||
|
||||
// Each service is granted to the app that owns it. New app bundles never
|
||||
// receive Pass's device secret simply because another app can use it.
|
||||
AppServiceAllowed :: (context: *void, name: string) -> bool {
|
||||
|
||||
+301
@@ -0,0 +1,301 @@
|
||||
// Werkzeug supplies tools and private preferences to the shared Apps screen.
|
||||
#import "apps"
|
||||
#import "platform"
|
||||
#import "files"
|
||||
#import "std/c_string"
|
||||
#import "std/text_buffer"
|
||||
#import "std/vec"
|
||||
#import "std/json_scan"
|
||||
#import "kryon/widget_host"
|
||||
#import "kryon/app_files"
|
||||
#import "kryon/app_protocol"
|
||||
#import "std/bundle_host"
|
||||
using UI :: #import "kryon/Widgets";
|
||||
Launcher :: #import "apps/launcher";
|
||||
Controller :: #import "apps/controller";
|
||||
Rules :: #import "apps/protocol";
|
||||
|
||||
AppsControllerSha256 :: "8c5806d7ff5a4fdaf6b98a7668acbf0aad236ece1d5e68ffe1f7b268a1afb077";
|
||||
|
||||
HomePreference :: struct {
|
||||
title: [256]u8
|
||||
icon: [64]u8
|
||||
favorite: bool
|
||||
}
|
||||
|
||||
HomeState :: struct {
|
||||
controller: Controller.AppController
|
||||
view: Launcher.AppLauncherState
|
||||
preferences: [APP_LIMIT]HomePreference
|
||||
indices: [APP_LIMIT]s32
|
||||
bytes: string
|
||||
body: string
|
||||
catalog: string
|
||||
response: string
|
||||
revision: s64
|
||||
sequence: s64
|
||||
status: string
|
||||
selected: s32
|
||||
session: Session
|
||||
opened: s32
|
||||
pending: Rules.AppsRequest
|
||||
has_pending: bool
|
||||
loaded: bool
|
||||
unavailable: bool
|
||||
}
|
||||
home: HomeState;
|
||||
|
||||
HomeIndex :: (id: string) -> s32 {
|
||||
for index: cast(s32)0..AppCount() - 1 {
|
||||
if AppId(index) == id && id != "entity" { return index }
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
HomeTitle :: (index: s32) -> string {
|
||||
title := TextUntilNul(home.preferences[index].title[:])
|
||||
return ifx title == "" then AppName(index) else title
|
||||
}
|
||||
|
||||
HomeIcon :: (index: s32) -> string {
|
||||
choice := HomeIndex(TextUntilNul(home.preferences[index].icon[:]))
|
||||
return AppIcon(ifx choice >= 0 then choice else index)
|
||||
}
|
||||
|
||||
HomePreferencesPath :: (output: []u8) -> string {
|
||||
folder: [PATH_LIMIT]u8
|
||||
path := PathJoin(folder[:], DataRoot(), "profile")
|
||||
if !EnsureDirectory(path) { return "" }
|
||||
return PathJoin(output, path, "apps.json")
|
||||
}
|
||||
|
||||
HomeBool :: (text: string, at: s32) -> bool { return at >= 0 && MatchLiteral(text, at, "true") }
|
||||
|
||||
HomeLoad :: () {
|
||||
home.loaded = true
|
||||
home.view.grid = true
|
||||
path: [PATH_LIMIT]u8
|
||||
bytes: [8192]u8
|
||||
count := ReadPrivate(HomePreferencesPath(path[:]), bytes[:])
|
||||
if count <= 0 { return }
|
||||
text := TextView(bytes[:count])
|
||||
if HomeBool(text, FieldAt(text, 0, "list")) { home.view.grid = false }
|
||||
entries := FieldAt(text, 0, "apps")
|
||||
at := Space(text, entries + 1)
|
||||
for index: cast(s32)0..ArrayCount(text, entries) - 1 {
|
||||
id: [128]u8
|
||||
if Rules.AppsReadText(text, at, "id", id[:]) {
|
||||
tool := HomeIndex(TextUntilNul(id[:]))
|
||||
if tool >= 0 {
|
||||
preference: HomePreference
|
||||
if Rules.AppsReadText(text, at, "title", preference.title[:]) &&
|
||||
Rules.AppTitleValid(TextUntilNul(preference.title[:])) &&
|
||||
Rules.AppsReadText(text, at, "icon", preference.icon[:]) &&
|
||||
(preference.icon[0] == 0 || HomeIndex(TextUntilNul(preference.icon[:])) >= 0) {
|
||||
preference.favorite = HomeBool(text, FieldAt(text, at, "favorite"))
|
||||
home.preferences[tool] = preference
|
||||
}
|
||||
}
|
||||
}
|
||||
at = Space(text, ValueEnd(text, at, 0))
|
||||
if at < text.count && text[at] == cast(u8)44 { at = Space(text, at + 1) }
|
||||
}
|
||||
}
|
||||
|
||||
HomeSave :: () -> bool {
|
||||
bytes: Vec(u8)
|
||||
BuilderPrint(*bytes, "{\"v\":1,\"list\":%,\"apps\":[", ifx home.view.grid then "false" else "true")
|
||||
first := true
|
||||
for index: cast(s32)0..AppCount() - 1 {
|
||||
if AppId(index) == "entity" { continue }
|
||||
if !first { BuilderPrint(*bytes, ",") }
|
||||
first = false
|
||||
BuilderPrint(*bytes, "{\"id\":")
|
||||
Rules.AppsWriteQuoted(*bytes, AppId(index))
|
||||
BuilderPrint(*bytes, ",\"title\":")
|
||||
Rules.AppsWriteQuoted(*bytes, TextUntilNul(home.preferences[index].title[:]))
|
||||
BuilderPrint(*bytes, ",\"icon\":")
|
||||
Rules.AppsWriteQuoted(*bytes, TextUntilNul(home.preferences[index].icon[:]))
|
||||
BuilderPrint(*bytes, ",\"favorite\":%}", ifx home.preferences[index].favorite then "true" else "false")
|
||||
}
|
||||
BuilderPrint(*bytes, "]}\n")
|
||||
path: [PATH_LIMIT]u8
|
||||
saved := WritePrivate(HomePreferencesPath(path[:]), TextView(VecSlice(bytes, 0, bytes.count)))
|
||||
VecFree(bytes)
|
||||
return saved
|
||||
}
|
||||
|
||||
HomeReply :: (status: string) -> string {
|
||||
AppFileFree(home.response)
|
||||
bytes: Vec(u8)
|
||||
BuilderPrint(*bytes, "{\"v\":1,\"status\":\"%\",\"request\":%}", status, home.sequence)
|
||||
home.response = BuilderFinish(bytes)
|
||||
return home.response
|
||||
}
|
||||
|
||||
HomeIcons :: (tool: s32) -> string {
|
||||
bytes: Vec(u8)
|
||||
BuilderPrint(*bytes, "{\"v\":1,\"icons\":[{\"id\":\"\",\"shape\":")
|
||||
Rules.AppsWriteQuoted(*bytes, AppIcon(tool))
|
||||
BuilderPrint(*bytes, "}")
|
||||
for index: cast(s32)0..AppCount() - 1 {
|
||||
if AppId(index) == "entity" { continue }
|
||||
BuilderPrint(*bytes, ",{\"id\":")
|
||||
Rules.AppsWriteQuoted(*bytes, AppId(index))
|
||||
BuilderPrint(*bytes, ",\"shape\":")
|
||||
Rules.AppsWriteQuoted(*bytes, AppIcon(index))
|
||||
BuilderPrint(*bytes, "}")
|
||||
}
|
||||
BuilderPrint(*bytes, "]}")
|
||||
AppFileFree(home.response)
|
||||
home.response = BuilderFinish(bytes)
|
||||
return home.response
|
||||
}
|
||||
|
||||
HomeService :: (context: *void, text: string) -> string {
|
||||
request: Rules.AppsRequest
|
||||
if !Rules.AppsReadRequest(text, *request) { return "" }
|
||||
if request.operation == Rules.APPS_CATALOG {
|
||||
if request.revision > 0 && request.revision == home.revision { return "{\"v\":1,\"unchanged\":true}" }
|
||||
return home.catalog
|
||||
}
|
||||
if request.operation == Rules.APPS_STATUS {
|
||||
if request.request != home.sequence { return "" }
|
||||
return HomeReply(home.status)
|
||||
}
|
||||
tool := HomeIndex(TextUntilNul(request.id[:]))
|
||||
if tool < 0 { return HomeReply("rejected") }
|
||||
if request.operation == Rules.APPS_ICONS { return HomeIcons(tool) }
|
||||
if home.has_pending || (request.operation != Rules.APPS_OPEN && request.operation != Rules.APPS_PIN &&
|
||||
request.operation != Rules.APPS_UNPIN && request.operation != Rules.APPS_PROPERTIES) { return HomeReply("rejected") }
|
||||
home.pending = request
|
||||
home.has_pending = true
|
||||
home.sequence += 1
|
||||
home.status = "queued"
|
||||
return HomeReply(home.status)
|
||||
}
|
||||
|
||||
HomeDrain :: () {
|
||||
if !home.has_pending { return }
|
||||
home.has_pending = false
|
||||
request := home.pending
|
||||
index := HomeIndex(TextUntilNul(request.id[:]))
|
||||
home.status = "rejected"
|
||||
if index < 0 { return }
|
||||
if request.operation == Rules.APPS_OPEN {
|
||||
home.opened = index
|
||||
home.status = "applied"
|
||||
return
|
||||
}
|
||||
before := home.preferences[index]
|
||||
if request.operation == Rules.APPS_PIN || request.operation == Rules.APPS_UNPIN {
|
||||
home.preferences[index].favorite = request.operation == Rules.APPS_PIN
|
||||
} else if request.operation == Rules.APPS_PROPERTIES {
|
||||
if request.icon[0] != 0 && HomeIndex(TextUntilNul(request.icon[:])) < 0 { return }
|
||||
home.preferences[index].title = request.title
|
||||
home.preferences[index].icon = request.icon
|
||||
} else { return }
|
||||
if HomeSave() { home.status = "applied" }
|
||||
else { home.preferences[index] = before }
|
||||
}
|
||||
|
||||
HomeWidgets :: (context: *void, module: *u8, function: *u8,
|
||||
arguments: *HostValue, count: s32, result: *HostValue) -> s32 {
|
||||
return AppWidgetCall(context, module, function, arguments, count, result)
|
||||
}
|
||||
|
||||
HomeAssetAllowed :: (path: string) -> bool { return path == "" }
|
||||
|
||||
HomeCards :: (context: *void, indices: []s32, bounds: Rectangle,
|
||||
input: TextFieldInput, section_break: s32, columns: s32) -> bool {
|
||||
bytes: Vec(u8)
|
||||
BuilderPrint(*bytes, "\"title\":\"Werkzeug\",\"locale\":\"en\",\"presentation\":{\"mode\":\"%\",\"columns\":%",
|
||||
ifx home.view.grid then "icon" else "list", columns)
|
||||
if section_break >= 0 { BuilderPrint(*bytes, ",\"section_break\":%", section_break) }
|
||||
BuilderPrint(*bytes, "},\"children\":[")
|
||||
for at: cast(s32)0..cast(s32)indices.count - 1 {
|
||||
index := home.indices[indices[at]]
|
||||
if at > 0 { BuilderPrint(*bytes, ",") }
|
||||
BuilderPrint(*bytes, "{\"id\":")
|
||||
Rules.AppsWriteQuoted(*bytes, AppId(index))
|
||||
BuilderPrint(*bytes, ",\"title\":")
|
||||
Rules.AppsWriteQuoted(*bytes, HomeTitle(index))
|
||||
BuilderPrint(*bytes, ",\"original_title\":")
|
||||
Rules.AppsWriteQuoted(*bytes, AppName(index))
|
||||
BuilderPrint(*bytes, ",\"icon_choice\":")
|
||||
Rules.AppsWriteQuoted(*bytes, TextUntilNul(home.preferences[index].icon[:]))
|
||||
BuilderPrint(*bytes, ",\"icon_shape\":")
|
||||
Rules.AppsWriteQuoted(*bytes, HomeIcon(index))
|
||||
BuilderPrint(*bytes, ",\"installed\":true,\"on_device\":true,\"favorite\":%,\"selected\":%,\"bytes\":%,\"actions\":[\"open\",\"%\",\"properties\"]}",
|
||||
ifx home.preferences[index].favorite then "true" else "false", ifx index == home.selected then "true" else "false",
|
||||
apps[index].bytes.count, ifx home.preferences[index].favorite then "unpin" else "pin")
|
||||
}
|
||||
BuilderPrint(*bytes, "]}")
|
||||
body := BuilderFinish(bytes)
|
||||
if body == home.body { AppFileFree(body) }
|
||||
else {
|
||||
AppFileFree(home.body)
|
||||
home.body = body
|
||||
home.revision += 1
|
||||
catalog: Vec(u8)
|
||||
BuilderPrint(*catalog, "{\"v\":1,\"revision\":%,%", home.revision, home.body)
|
||||
AppFileFree(home.catalog)
|
||||
home.catalog = BuilderFinish(catalog)
|
||||
}
|
||||
home.controller.app.session = home.session
|
||||
home.controller.app.bounds = bounds
|
||||
home.controller.app.input = input
|
||||
WidgetHostBegin(home.controller.app.session, HomeAssetAllowed)
|
||||
ran := Controller.AppControllerRun(*home.controller, APP_FRAME)
|
||||
WidgetHostEnd()
|
||||
return ran
|
||||
}
|
||||
|
||||
SharedHome :: (session: Session, bounds: Rectangle, dark: bool, selected: s32,
|
||||
input: TextFieldInput, key: s32, modifiers: s32) -> bool {
|
||||
if !home.loaded { HomeLoad() }
|
||||
home.opened = -1
|
||||
if home.unavailable { return false }
|
||||
if !home.controller.ready {
|
||||
path: [PATH_LIMIT]u8
|
||||
bytes, found := ReadBundle(PathJoin(path[:], BundledAppsRoot(), "apps.zib"))
|
||||
if !found { home.unavailable = true; return false }
|
||||
home.bytes = bytes
|
||||
if !Controller.AppControllerOpen(*home.controller, home.bytes, AppsControllerSha256,
|
||||
Controller.AppControllerPlatform.{.service = HomeService, .widgets = HomeWidgets}) {
|
||||
home.unavailable = true
|
||||
return false
|
||||
}
|
||||
}
|
||||
home.session = session
|
||||
home.selected = selected
|
||||
home.controller.app.dark = dark
|
||||
home.controller.app.scale = 1.0
|
||||
home.controller.app.font = 16
|
||||
home.controller.app.key = key
|
||||
home.controller.app.modifiers = modifiers
|
||||
count: s32
|
||||
items: [APP_LIMIT]Launcher.AppLauncherItem
|
||||
titles: [APP_LIMIT][256]u8
|
||||
for index: cast(s32)0..AppCount() - 1 {
|
||||
if AppId(index) == "entity" { continue }
|
||||
home.indices[count] = index
|
||||
unused CopyCString(HomeTitle(index), titles[count][:])
|
||||
items[count] = Launcher.AppLauncherItem.{.title = TextUntilNul(titles[count][:]),
|
||||
.search = AppName(index), .favorite = home.preferences[index].favorite}
|
||||
count += 1
|
||||
}
|
||||
area := Rectangle.{bounds.x + 16.0, bounds.y + 12.0, bounds.width - 32.0, bounds.height - 24.0}
|
||||
result := Launcher.AppLauncherScreen(session, *home.view,
|
||||
Launcher.AppLauncherProps.{.bounds = area, .scale = 1.0, .locale = "en", .input = input,
|
||||
.cards = HomeCards}, items[:count])
|
||||
if result.clipboard_write { unused SetClipboard(TextUntilNul(result.clipboard_text[:])) }
|
||||
if result.changed { unused HomeSave() }
|
||||
HomeDrain()
|
||||
AppFileFree(home.response)
|
||||
home.response = ""
|
||||
return result.ran
|
||||
}
|
||||
|
||||
SharedHomeOpened :: () -> s32 { return home.opened }
|
||||
SharedHomeKeyboard :: () -> bool { return home.view.focused || home.controller.app.keyboard }
|
||||
+1
-1
@@ -1 +1 @@
|
||||
Version :: "0.4.1";
|
||||
Version :: "0.4.2";
|
||||
+7
-41
@@ -8,6 +8,7 @@ using UI :: #import "kryon/Widgets";
|
||||
#import "kryon/ScrollDevice"
|
||||
#import "kryon/Theme"
|
||||
#import "apps"
|
||||
#import "home"
|
||||
#import "entity_management"
|
||||
#import "profile"
|
||||
#import "platform"
|
||||
@@ -185,53 +186,18 @@ TopBar :: (session: Session, viewport: Rectangle) {
|
||||
}
|
||||
}
|
||||
|
||||
Home :: (session: Session, area: Rectangle) {
|
||||
if SharedHome(session, area, ProfileDark(), open_app) {
|
||||
Home :: (session: Session, area: Rectangle, input: TextFieldInput, key: s32, modifiers: s32) {
|
||||
if SharedHome(session, area, ProfileDark(), open_app, input, key, modifiers) {
|
||||
opened := SharedHomeOpened()
|
||||
if opened >= 0 {
|
||||
open_app = opened
|
||||
screen = SCREEN_APP
|
||||
}
|
||||
keyboard_wanted = SharedHomeKeyboard()
|
||||
return
|
||||
}
|
||||
HomeFallback(session, area)
|
||||
}
|
||||
|
||||
HomeFallback :: (session: Session, area: Rectangle) {
|
||||
visible := AppCount() - ifx EntityAppIndex() >= 0 then 1 else 0
|
||||
tile: float32 = 120.0
|
||||
gap: float32 = 16.0
|
||||
columns := cast(s32)((area.width - gap) / (tile + gap))
|
||||
if columns < 2 {
|
||||
columns = 2
|
||||
tile = (area.width - gap * 3.0) / 2.0
|
||||
}
|
||||
if columns > visible && visible > 0 {
|
||||
columns = visible
|
||||
}
|
||||
if visible == 0 {
|
||||
Label(session, cast(u64)20, "No apps are installed.", Rectangle.{area.x + 16.0, area.y + 16.0,
|
||||
area.width - 32.0, 24.0}, 16)
|
||||
return
|
||||
}
|
||||
row_width := cast(float32)columns * tile + cast(float32)(columns - 1) * gap
|
||||
left := area.x + (area.width - row_width) * 0.5
|
||||
index: s32 = 0
|
||||
while index < AppCount() {
|
||||
if AppId(index) == "entity" { index += 1; continue }
|
||||
column := cast(float32)(index % columns)
|
||||
row := cast(float32)(index / columns)
|
||||
bounds := Rectangle.{left + column * (tile + gap), area.y + gap + row * (tile + gap), tile, tile}
|
||||
props := ButtonProps.{.key = cast(u64)(100 + index), .id = 100 + index, .bounds = bounds,
|
||||
.label = AppName(index), .icon_shape = AppIcon(index),
|
||||
.icon_placement = IconPlacement.IconPlacementAbove,
|
||||
.tone = ButtonTone.ButtonToneNeutral, .emphasis = ButtonEmphasis.ButtonEmphasisSoft}
|
||||
if Button(session, props) != 0 {
|
||||
open_app = index
|
||||
screen = SCREEN_APP
|
||||
}
|
||||
index += 1
|
||||
}
|
||||
Label(session, cast(u64)20, "Apps are unavailable.",
|
||||
Rectangle.{area.x + 16.0, area.y + 16.0, area.width - 32.0, 28.0}, 16)
|
||||
}
|
||||
|
||||
// Applies a text field's edit to a terminated buffer.
|
||||
@@ -745,7 +711,7 @@ WerkFrame :: (session: Session, viewport: Rectangle) -> s32 {
|
||||
TopBar(session, viewport)
|
||||
content = Rectangle.{viewport.x, viewport.y + BAR_HEIGHT, viewport.width, viewport.height - BAR_HEIGHT}
|
||||
if screen == SCREEN_HOME {
|
||||
Home(session, content)
|
||||
Home(session, content, input, key, modifiers)
|
||||
} else if screen == SCREEN_PROFILE {
|
||||
ProfileScreen(session, content, input, key, modifiers)
|
||||
} else if screen == SCREEN_APP && open_app >= 0 {
|
||||
|
||||
+21
-21
@@ -19,7 +19,7 @@
|
||||
},
|
||||
{
|
||||
"commit": "6a5f6189ca51e45a59c9ef77c4ec4112393225e0",
|
||||
"dependencies": {"kryon": "p88faf314c87eb03a", "kss": "p1b13dda539ed2a39", "mingcute": "pe1027b9d16704793"},
|
||||
"dependencies": {"kryon": "pc9c8f901448f635c", "kss": "p1b13dda539ed2a39", "mingcute": "pe1027b9d16704793"},
|
||||
"id": "p0e0131936e76f979",
|
||||
"name": "workbook",
|
||||
"ref": "master",
|
||||
@@ -27,20 +27,12 @@
|
||||
},
|
||||
{
|
||||
"commit": "1cb9df183089a77c8a16448a556186f30b261a98",
|
||||
"dependencies": {"kryon": "p88faf314c87eb03a"},
|
||||
"dependencies": {"kryon": "pc9c8f901448f635c"},
|
||||
"id": "p1b13dda539ed2a39",
|
||||
"name": "Kss",
|
||||
"ref": "master",
|
||||
"url": "https://github.com/kryonlabs/kss.git"
|
||||
},
|
||||
{
|
||||
"commit": "49e2d859bc1db01faf7ac05624cc531fbe51913b",
|
||||
"dependencies": {"crypto": "pf039d7a776333200", "kryon": "p88faf314c87eb03a"},
|
||||
"id": "p2c4ca8cd46b96384",
|
||||
"name": "Apps",
|
||||
"ref": "master",
|
||||
"url": "https://github.com/waozixyz/apps.git"
|
||||
},
|
||||
{
|
||||
"commit": "e1f480f382d9443c4412133b55948374c77a5c21",
|
||||
"dependencies": {},
|
||||
@@ -76,22 +68,22 @@
|
||||
"source": true,
|
||||
"url": "https://github.com/LoupVaillant/Monocypher.git"
|
||||
},
|
||||
{
|
||||
"commit": "6b9fed32f5368917deb4b5161fc8b4e9b32588ed",
|
||||
"dependencies": {"raylib": "p5a77c9c35110e925"},
|
||||
"id": "p88faf314c87eb03a",
|
||||
"name": "kryon",
|
||||
"ref": "master",
|
||||
"url": "https://github.com/kryonlabs/kryon.git"
|
||||
},
|
||||
{
|
||||
"commit": "f7449b379540f6f6f53c64c980cb5d4d4abcf399",
|
||||
"dependencies": {"daochi_client": "p0cff069893bdc938", "kryon": "p88faf314c87eb03a", "monocypher": "p809b4d31a48625a3", "qrcode": "p0dfa70137405b096"},
|
||||
"dependencies": {"daochi_client": "p0cff069893bdc938", "kryon": "pc9c8f901448f635c", "monocypher": "p809b4d31a48625a3", "qrcode": "p0dfa70137405b096"},
|
||||
"id": "pb7942f184eef21db",
|
||||
"name": "Entity",
|
||||
"ref": "master",
|
||||
"url": "https://github.com/waozixyz/entity.git"
|
||||
},
|
||||
{
|
||||
"commit": "b1d4faa4de66ff799c8907ba131061be979bcc7a",
|
||||
"dependencies": {"raylib": "p5a77c9c35110e925"},
|
||||
"id": "pc9c8f901448f635c",
|
||||
"name": "kryon",
|
||||
"ref": "master",
|
||||
"url": "https://github.com/kryonlabs/kryon.git"
|
||||
},
|
||||
{
|
||||
"commit": "9cc6872f75447c3a24c16764f9829d0f58751cb0",
|
||||
"dependencies": {},
|
||||
@@ -107,14 +99,22 @@
|
||||
"name": "crypto",
|
||||
"ref": "master",
|
||||
"url": "https://github.com/ziranlang/crypto.git"
|
||||
},
|
||||
{
|
||||
"commit": "d016377ab37ba4fb754a799569e15a4c0d195b90",
|
||||
"dependencies": {"crypto": "pf039d7a776333200", "kryon": "pc9c8f901448f635c"},
|
||||
"id": "pf87aa276a2b568b4",
|
||||
"name": "Apps",
|
||||
"ref": "master",
|
||||
"url": "https://github.com/waozixyz/apps.git"
|
||||
}
|
||||
],
|
||||
"root": {
|
||||
"dependencies": {"apps": "p2c4ca8cd46b96384", "daochi_client": "p0cff069893bdc938", "entity": "pb7942f184eef21db", "kryon": "p88faf314c87eb03a", "liboqs": "p4b0a50b49959e674", "mingcute": "pe1027b9d16704793", "monocypher": "p809b4d31a48625a3", "oqs": "p7098ac9cd92f7e5f", "workbook": "p0e0131936e76f979"},
|
||||
"dependencies": {"apps": "pf87aa276a2b568b4", "daochi_client": "p0cff069893bdc938", "entity": "pb7942f184eef21db", "kryon": "pc9c8f901448f635c", "liboqs": "p4b0a50b49959e674", "mingcute": "pe1027b9d16704793", "monocypher": "p809b4d31a48625a3", "oqs": "p7098ac9cd92f7e5f", "workbook": "p0e0131936e76f979"},
|
||||
"name": "Werkzeug"
|
||||
},
|
||||
"toolchain": {
|
||||
"commit": "130b263f42e9332896f7bc63cfed2508d34098dc",
|
||||
"commit": "ec43f576478d4a0028d560be560585749a92f3ed",
|
||||
"ref": "master",
|
||||
"url": "https://github.com/ziranlang/ziran.git"
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user