Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d65025806 | ||
|
|
1eb5fd3de2 | ||
|
|
ccbad38a60 | ||
|
|
4097ce5d79 | ||
|
|
4b77d513a1 | ||
|
|
a733f87cba | ||
|
|
d0993d71ad | ||
|
|
b5f4ebfa16 | ||
|
|
f1dc2a1dff | ||
|
|
7d18f5089d | ||
|
|
900850f1a9 | ||
|
|
d30e918704 | ||
|
|
736882b1bd | ||
|
|
7a6b8207e1 | ||
|
|
1dab289a8f | ||
|
|
11324d6ece | ||
|
|
3818deacec | ||
|
|
2325a89629 | ||
|
|
d23b515003 | ||
|
|
5b43aa3c3d | ||
|
|
0b8aadc911 | ||
|
|
63bd330b81 | ||
|
|
af81a9a23a | ||
|
|
b6f405010e | ||
|
|
7ad56a3d3e | ||
|
|
f11c8b1174 | ||
|
|
860cc9af13 | ||
|
|
11b013134c | ||
|
|
269a277103 | ||
|
|
01522177f3 | ||
|
|
76fdecaccd | ||
|
|
5595bd70df | ||
|
|
7260d62662 | ||
|
|
a6473d2adf | ||
|
|
d631050d0d | ||
|
|
5d4ab56ed8 | ||
|
|
7b9f01b870 | ||
|
|
690c0db1bb | ||
|
|
019de0a0d6 | ||
|
|
3c11971227 | ||
|
|
af43d15d63 | ||
|
|
75e5d449b3 | ||
|
|
e58d9194a5 | ||
|
|
a84907925a | ||
|
|
12380d75ab |
No files matched your search
@@ -40,7 +40,9 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.github/actions/ziran-packages
|
||||
- name: Install signing and test dependencies
|
||||
run: sudo apt-get update && sudo apt-get install -y python3-cryptography python3-fonttools
|
||||
run: |
|
||||
sudo apt-get update && sudo apt-get install -y python3-cryptography python3-fonttools
|
||||
.github/scripts/install-apt-packages.sh .github/apt/test-packages.txt
|
||||
- name: Build independent packages and check signatures
|
||||
run: |
|
||||
make package-version-test
|
||||
@@ -49,6 +51,8 @@ jobs:
|
||||
make package-upload-test
|
||||
make cells build-laws
|
||||
python3 tests/package_release_test.py
|
||||
- name: Run new packages in the last released app
|
||||
run: python3 tests/package_compat_test.py --skip-forward
|
||||
- name: Configure publisher
|
||||
id: publisher
|
||||
env:
|
||||
|
||||
@@ -100,6 +100,9 @@ jobs:
|
||||
- name: Require Visual Tests
|
||||
run: make visual-test
|
||||
|
||||
- name: Run Packages Across App Versions
|
||||
run: make package-compat-test
|
||||
|
||||
- name: Save Visual Test Evidence
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
@@ -896,6 +899,16 @@ jobs:
|
||||
done < <(scripts/list-expected-release-assets.sh "$VERSION")
|
||||
exit "$missing"
|
||||
|
||||
- name: Require a Passing Phone Check for a New Version
|
||||
run: |
|
||||
set -euo pipefail
|
||||
VERSION=$(python3 scripts/check-version.py --print-version)
|
||||
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
|
||||
echo "v$VERSION is already tagged; no new version to check"
|
||||
exit 0
|
||||
fi
|
||||
python3 scripts/check-phone-check.py "$VERSION"
|
||||
|
||||
- name: Create and Push Tag If Version Is New
|
||||
id: tag_version
|
||||
env:
|
||||
@@ -969,6 +982,17 @@ jobs:
|
||||
arch="${arch%.rpm}"
|
||||
channels+=("--channel" "rpm-$arch=$rpm")
|
||||
done
|
||||
# Directly installed APKs update themselves from these channels;
|
||||
# the Google Play build updates through the store.
|
||||
while IFS= read -r apk; do
|
||||
abi="$(basename "$apk" .apk)"
|
||||
abi="${abi#inbe-$VERSION}"
|
||||
case "$abi" in
|
||||
-gplay) continue ;;
|
||||
"") channels+=("--channel" "android=$apk") ;;
|
||||
*) channels+=("--channel" "android$abi=$apk") ;;
|
||||
esac
|
||||
done < <(find build/release -maxdepth 2 -name "inbe-$VERSION*.apk" | sort)
|
||||
if [ ${#channels[@]} -eq 0 ]; then
|
||||
echo "no release artifacts found for the appcast"
|
||||
exit 1
|
||||
|
||||
@@ -13,6 +13,25 @@
|
||||
The canonical macros are `APP_VERSION_STRING`, `APP_VERSION_MAJOR`,
|
||||
`APP_VERSION_MINOR`, and `APP_VERSION_PATCH`; do not create aliases.
|
||||
Only the GitHub Actions release workflow creates or pushes release tags.
|
||||
- A new version publishes only with a passing phone check of its exact
|
||||
sources: build the APK from the committed release, run
|
||||
`make phone-check APK=...` with the development Moto connected through the
|
||||
ThinkPad, and commit `releases/phone-checks/VERSION.json`. Changes to app
|
||||
sources after the check require a new one.
|
||||
- Packages declare the oldest host interface they run on (`host_api` per app
|
||||
in `apps/versions.json`); the host runs `oldest_host_api` to `host_api`.
|
||||
Raise `host_api` when the host interface changes and `oldest_host_api` only
|
||||
when it can no longer run older packages. `make package-compat-test` runs
|
||||
the node's packages in this build and new packages in the last release.
|
||||
- Goal (owner, 2026-10-11): every app updates through its own package
|
||||
without a new APK. Work toward it in small steps alongside requested work;
|
||||
discuss larger moves with the owner first. Put app screens, rules and text
|
||||
in `apps/<app>/`, not in the host under `src/`. Habits and Practices still
|
||||
draw compiled host screens (see [docs/cells.md](docs/cells.md)); when work
|
||||
touches one, prefer moving it into its package. Keep the host interface
|
||||
small and generic (storage, network, locale, platform effects), because
|
||||
each new host call needs an APK before a package can use it. Apps share
|
||||
data only through the host interface, never another app's internals.
|
||||
- Translate changed strings in every affected locale; no English placeholders.
|
||||
- `make locale-translated-test` fails on any locale string that still equals
|
||||
its English text. Translate it; add it to `tests/locale_same_as_english.txt`
|
||||
|
||||
@@ -1,4 +1,27 @@
|
||||
# Changelog
|
||||
## [2.1.31] - 2026-10-11
|
||||
### Fixed
|
||||
- Android: after the floating practice window, the app fits the screen again instead of running under the status bar and navigation and losing its sides.
|
||||
|
||||
## [2.1.30] - 2026-10-11
|
||||
### Fixed
|
||||
- Long menus, such as the colour theme, scroll by touch and open at your choice.
|
||||
- With a menu open, tapping the navigation closes it and switches screens in one tap.
|
||||
- Menus stay above the navigation instead of hiding their last options behind it.
|
||||
- Web: the app is sharp on high-density screens instead of magnified and blurry.
|
||||
### Changed
|
||||
- Icons are sharper on the web.
|
||||
|
||||
## [2.1.29] - 2026-10-11
|
||||
### Fixed
|
||||
- Scrolling Lumi's commands keeps the keyboard open.
|
||||
- New habits show each colour choice in its own colour.
|
||||
- Leaving Wim Hof no longer freezes the app for a few seconds.
|
||||
- The app no longer freezes just after launch while it checks for app updates.
|
||||
### Changed
|
||||
- Scrollbars use your theme's colours and show how much is in view.
|
||||
- Apps rearranges to fill the window's width.
|
||||
|
||||
## [2.1.28] - 2026-10-10
|
||||
### Added
|
||||
- Connect a phone and a computer by QR code in Profile.
|
||||
|
||||
@@ -398,9 +398,17 @@ INBE_BUNDLE := $(BUILD_DIR)/inbe.zib
|
||||
INBE_FULL_BUNDLE := $(BUILD_DIR)/inbe-full.zib
|
||||
CELL_SOURCES := $(shell find apps src/cells -name '*.zi' | LC_ALL=C sort) src/core/types.zi src/core/breath_timing.zi $(wildcard src/practices/patterns/*rules.zi) src/practices/patterns/patterns_clock.zi src/practices/patterns/patterns_types.zi src/practices/sun_salutation/sun_salutation_rules.zi src/practices/meditation/meditation_timing.zi
|
||||
CELL_RESOURCES := $(shell rg --files assets/habits assets/lists assets/diary assets/lumi assets/mcp 2>/dev/null)
|
||||
WIDGET_SCHEMAS := $(addprefix $(KRYON_DIR)/src/ui/,session.zi geometry.zi drawing_props.zi text_props.zi image_props.zi button_props.zi control_props.zi text_input.zi text_input_props.zi scroll.zi scroll_props.zi semantic.zi text_align.zi checkbox_props.zi toggle_props.zi tab_bar_props.zi box_props.zi) $(addprefix src/cells/,diary_ui_types.zi inbe_ui_types.zi lists_ui_types.zi lumi_ui_types.zi lumi_types.zi leaderboard_ui_types.zi)
|
||||
src/cells/widget_codec.zi: scripts/generate-widget-codecs.py $(WIDGET_SCHEMAS)
|
||||
python3 scripts/generate-widget-codecs.py
|
||||
# App records cross the bundle boundary with codecs generated by Kryon's
|
||||
# generator on top of Kryon's own widget codec.
|
||||
APP_CODEC_SCHEMAS := $(KRYON_DIR)/scripts/generate-widget-codecs.py $(KRYON_DIR)/src/backend/widget_codec.zi $(addprefix src/cells/,diary_ui_types.zi inbe_ui_types.zi lists_ui_types.zi lumi_ui_types.zi lumi_types.zi leaderboard_ui_types.zi)
|
||||
src/cells/app_codec.zi: scripts/generate-app-codec.py $(APP_CODEC_SCHEMAS)
|
||||
python3 scripts/generate-app-codec.py
|
||||
|
||||
.PHONY: app-codec-check
|
||||
app-codec-check:
|
||||
python3 scripts/generate-app-codec.py --check
|
||||
|
||||
test: app-codec-check
|
||||
|
||||
.PHONY: cells
|
||||
cells: $(CELL_BUNDLES) $(INBE_BUNDLE) $(INBE_FULL_BUNDLE)
|
||||
@@ -617,7 +625,7 @@ WEB_TARGET := $(WEB_DIST_DIR)/index.html
|
||||
WEB_APP_SCRIPT := <script>window.__inbeRenderer="canvas";window.__inbeLoadApp("index.js?v=$(WEB_CACHE_BUSTER)")</script>
|
||||
WEB_JS_TARGET := $(WEB_DIST_DIR)/index.js
|
||||
WEB_BOOT_JS := src/web_boot.js
|
||||
WEB_HOST_JS := src/web_host.js scripts/browser_network.js scripts/telegram_host.js
|
||||
WEB_HOST_JS := src/web_host.js scripts/telegram_host.js
|
||||
# Kryon's canvas hosts are Ziran modules on Ziran's web bridge; its runtime is the only JS they need.
|
||||
WEB_CANVAS_HOST_JS := $(ZIRAN_DIR)/web/ziran_web.js
|
||||
WEB_HOST_JS += $(WEB_CANVAS_HOST_JS)
|
||||
@@ -700,11 +708,6 @@ $(KRYON_LIBRARY_BUILD_DIR)/libkryon.a: $(KRYON_UI_ZI) $(KRYON_DIR)/src/ui/module
|
||||
ZIRAN_DIR=$(abspath $(ZIRAN_DIR)) ZIRAN_BUILD_DIR=$(ZIRAN_BUILD_DIR) \
|
||||
$(KRYON_LIBRARY_BUILD_DIR)/libkryon.a
|
||||
|
||||
.PHONY: uri-link-test
|
||||
uri-link-test: $(ZI2C_BIN)
|
||||
@env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u GDK_DISPLAY \
|
||||
python3 tests/uri_host_zi_test.py $(ZIRAN_BUILD_DIR)/bin
|
||||
|
||||
.PHONY: frame-activity-test
|
||||
frame-activity-test: $(ZI2C_BIN)
|
||||
@sh tests/frame_activity_zi_test.sh $(ZIRAN_BUILD_DIR)/bin
|
||||
@@ -797,20 +800,6 @@ sync-retry-zi-test: build-laws $(ZI2C_BIN)
|
||||
|
||||
test: sync-retry-zi-test
|
||||
|
||||
.PHONY: sync-crypto-zi-test
|
||||
sync-crypto-zi-test: $(ZI2C_BIN)
|
||||
@env -u DISPLAY -u WAYLAND_DISPLAY \
|
||||
sh tests/sync_crypto_zi_test.sh $(ZIRAN_BUILD_DIR)/bin
|
||||
|
||||
test: sync-crypto-zi-test
|
||||
|
||||
.PHONY: sync-account-crypto-zi-test
|
||||
sync-account-crypto-zi-test: $(ZI2C_BIN) $(LIBOQS_A)
|
||||
@env -u DISPLAY -u WAYLAND_DISPLAY \
|
||||
sh tests/sync_account_crypto_zi_test.sh $(ZIRAN_BUILD_DIR)/bin $(LIBOQS_A)
|
||||
|
||||
test: sync-account-crypto-zi-test
|
||||
|
||||
# Exercise the packaged Ziran crypto API against the exact archive used by
|
||||
# Inbe, including ML-KEM round trips, tampering and short-buffer rejection.
|
||||
.PHONY: liboqs-crypto-test
|
||||
@@ -1630,59 +1619,6 @@ android-text-input-zi-test: $(ZI2C_BIN)
|
||||
|
||||
test: android-text-input-zi-test
|
||||
|
||||
.PHONY: window-close-host-test
|
||||
window-close-host-test: $(ZI2C_BIN)
|
||||
@mkdir -p $(BUILD_DIR)/window-close-host-test/c
|
||||
@$(ZI2C_BIN) --define PLATFORM_DESKTOP \
|
||||
--define NATIVE_WINDOW_HAVE_SDL \
|
||||
--entry window_close_behavior:main --root tests \
|
||||
--module-path src -o $(BUILD_DIR)/window-close-host-test/c \
|
||||
tests/window_close_behavior.zi
|
||||
@$(CC) -std=c11 -O2 -I$(ZIRAN_DIR)/include \
|
||||
-iquote $(BUILD_DIR)/window-close-host-test/c \
|
||||
$(BUILD_DIR)/window-close-host-test/c/*.c \
|
||||
$(RAY_SDL_LDLIBS) -o $(BUILD_DIR)/window-close-host-test/test
|
||||
@env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u GDK_DISPLAY \
|
||||
$(BUILD_DIR)/window-close-host-test/test
|
||||
|
||||
test: window-close-host-test
|
||||
|
||||
.PHONY: activity-host-test
|
||||
activity-host-test: $(ZI2C_BIN)
|
||||
@env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u GDK_DISPLAY \
|
||||
DBUS_SESSION_BUS_ADDRESS=invalid: \
|
||||
sh tests/activity_host_zi_test.sh $(ZIRAN_BUILD_DIR)/bin
|
||||
|
||||
test: activity-host-test
|
||||
|
||||
.PHONY: audio-picker-host-test
|
||||
audio-picker-host-test: $(ZI2C_BIN)
|
||||
@mkdir -p $(BUILD_DIR)/audio-picker-host-test/c
|
||||
@cp tests/support/audio_picker_zenity.sh \
|
||||
$(BUILD_DIR)/audio-picker-host-test/zenity
|
||||
@chmod +x $(BUILD_DIR)/audio-picker-host-test/zenity
|
||||
@$(ZI2C_BIN) --no-main --define PLATFORM_DESKTOP --root src \
|
||||
--module-path $(ZIRAN_DIR)/std \
|
||||
-o $(BUILD_DIR)/audio-picker-host-test/c \
|
||||
src/platform/audio_picker_host.zi
|
||||
@$(CC) -std=c11 -D_DEFAULT_SOURCE -Wall -Wextra -Werror \
|
||||
-Wno-unused-function -I$(ZIRAN_DIR)/include \
|
||||
-iquote $(BUILD_DIR)/audio-picker-host-test/c \
|
||||
tests/audio_picker_host_test.c \
|
||||
$(BUILD_DIR)/audio-picker-host-test/c/*.c \
|
||||
$(BUILD_DIR)/audio-picker-host-test/c/platform/audio_picker_host.c \
|
||||
$(BUILD_DIR)/audio-picker-host-test/c/platform/file_picker.c \
|
||||
-o $(BUILD_DIR)/audio-picker-host-test/test
|
||||
@env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u GDK_DISPLAY \
|
||||
PATH="$(abspath $(BUILD_DIR)/audio-picker-host-test)" \
|
||||
$(abspath $(BUILD_DIR)/audio-picker-host-test/test)
|
||||
|
||||
.PHONY: file-picker-zi-test
|
||||
file-picker-zi-test: $(ZI2C_BIN)
|
||||
@sh tests/file_picker_zi_test.sh $(abspath $(dir $(ZI2C_BIN)))
|
||||
|
||||
test: audio-picker-host-test file-picker-zi-test
|
||||
|
||||
.PHONY: main-platform-zi-test
|
||||
main-platform-zi-test: $(ZI2C_BIN) $(RAYLIB_A)
|
||||
@RAY_LDLIBS='$(RAY_LDLIBS)' sh tests/main_platform_zi_test.sh \
|
||||
@@ -1711,17 +1647,12 @@ update-transport-zi-test: $(ZI2C_BIN)
|
||||
|
||||
test: plan9-host-zi-test android-jni-zi-test update-transport-zi-test
|
||||
|
||||
.PHONY: secondary-window-host-test
|
||||
secondary-window-host-test: $(ZI2C_BIN) $(RAYLIB_A)
|
||||
@sh tests/secondary_window_host_zi_test.sh \
|
||||
$(abspath $(dir $(ZI2C_BIN))) $(abspath $(RAYLIB_A))
|
||||
|
||||
.PHONY: raylib-log-host-test
|
||||
raylib-log-host-test: $(ZI2C_BIN) $(RAYLIB_A)
|
||||
@mkdir -p $(BUILD_DIR)/raylib-log-host-test/c
|
||||
@$(ZI2C_BIN) --define PLATFORM_DESKTOP \
|
||||
--entry raylib_log_behavior:main --root tests \
|
||||
--module-path src --module-path $(ZIRAN_DIR)/std \
|
||||
--module-path src --module-path $(KRYON_DIR)/src/backend --module-path $(ZIRAN_DIR)/std \
|
||||
-o $(BUILD_DIR)/raylib-log-host-test/c tests/raylib_log_behavior.zi
|
||||
@$(CC) -std=c11 -O2 -I$(ZIRAN_DIR)/include \
|
||||
-iquote $(BUILD_DIR)/raylib-log-host-test/c \
|
||||
@@ -1795,13 +1726,6 @@ android-import-zi-test: $(ZI2C_BIN)
|
||||
|
||||
test: android-import-zi-test
|
||||
|
||||
.PHONY: android-runtime-assets-zi-test
|
||||
android-runtime-assets-zi-test: $(ZI2C_BIN)
|
||||
@env -u DISPLAY -u WAYLAND_DISPLAY \
|
||||
sh tests/android_runtime_assets_zi_test.sh $(ZIRAN_BUILD_DIR)/bin
|
||||
|
||||
test: android-runtime-assets-zi-test
|
||||
|
||||
.PHONY: android-lifecycle-zi-test
|
||||
android-lifecycle-zi-test: $(ZI2C_BIN)
|
||||
@env -u DISPLAY -u WAYLAND_DISPLAY \
|
||||
@@ -3093,6 +3017,25 @@ test: app-click-block-zi-test
|
||||
package-release-test: cells $(ZIRAN_BUILD_DIR)/libziran.a
|
||||
python3 tests/package_release_test.py
|
||||
|
||||
# This build runs the packages the node serves, and the last released app runs
|
||||
# each new package that declares a host interface it has.
|
||||
.PHONY: package-compat-test
|
||||
package-compat-test: $(TARGET) $(CELL_BUNDLES) $(INBE_BUNDLE)
|
||||
python3 tests/package_compat_test.py $(abspath $(TARGET))
|
||||
|
||||
.PHONY: phone-check-gate-test
|
||||
phone-check-gate-test:
|
||||
python3 tests/phone_check_gate_test.py
|
||||
|
||||
test: phone-check-gate-test
|
||||
|
||||
# Check an exact APK on the development Moto and record the release receipt:
|
||||
# make phone-check APK=path/to/inbe.apk
|
||||
.PHONY: phone-check
|
||||
phone-check:
|
||||
@test -n "$(APK)" || { echo "Set APK=path/to/inbe.apk"; exit 1; }
|
||||
python3 scripts/phone-check.py "$(APK)" --record
|
||||
|
||||
test: package-release-test
|
||||
|
||||
.PHONY: app-preferences-sync-test
|
||||
@@ -3146,7 +3089,7 @@ device-key-wasm-test: $(ZI2C_BIN)
|
||||
test: device-key-test
|
||||
web-smoke-test web-canvas-smoke-test: device-key-wasm-test
|
||||
|
||||
.PHONY: telegram-authorization-test telegram-bridge-test telegram-host-test telegram-entry-protocol-test telegram-account-flow-test telegram-account-ui-test settings-telegram-ui-test lumi-authorization-test delegate-account-test delegate-secret-cleanup-test storage-delegate-test lumi-delegate-scope-test
|
||||
.PHONY: telegram-authorization-test telegram-bridge-test telegram-host-test telegram-entry-protocol-test telegram-account-flow-test telegram-account-ui-test settings-telegram-ui-test lumi-authorization-test delegate-account-test storage-delegate-test lumi-delegate-scope-test
|
||||
|
||||
telegram-bridge-test:
|
||||
@sh tests/telegram_bridge_test.sh
|
||||
@@ -3178,16 +3121,13 @@ lumi-authorization-test: $(ZIRAN_BIN) $(LIBOQS_A)
|
||||
delegate-account-test: $(ZIRAN_BIN) $(LIBOQS_A)
|
||||
@sh tests/delegate_account_zi_test.sh $(ZIRAN_BIN) $(LIBOQS_A)
|
||||
|
||||
delegate-secret-cleanup-test: $(ZIRAN_BIN) $(LIBOQS_A)
|
||||
@sh tests/delegate_secret_cleanup_zi_test.sh $(ZIRAN_BIN) $(LIBOQS_A)
|
||||
|
||||
storage-delegate-test: $(ZIRAN_BIN) $(LIBOQS_A)
|
||||
@sh tests/storage_delegate_zi_test.sh $(ZIRAN_BIN) $(LIBOQS_A)
|
||||
|
||||
lumi-delegate-scope-test: $(ZIRAN_BIN) $(LIBOQS_A)
|
||||
@sh tests/lumi_delegate_scope_zi_test.sh $(ZIRAN_BIN) $(LIBOQS_A)
|
||||
|
||||
telegram-authorization-test: telegram-bridge-test telegram-host-test telegram-entry-protocol-test telegram-account-flow-test telegram-account-ui-test settings-telegram-ui-test lumi-authorization-test delegate-account-test delegate-secret-cleanup-test storage-delegate-test lumi-delegate-scope-test
|
||||
telegram-authorization-test: telegram-bridge-test telegram-host-test telegram-entry-protocol-test telegram-account-flow-test telegram-account-ui-test settings-telegram-ui-test lumi-authorization-test delegate-account-test storage-delegate-test lumi-delegate-scope-test
|
||||
|
||||
test: telegram-authorization-test
|
||||
|
||||
@@ -3203,6 +3143,15 @@ lumi-feedback-delivery-test: $(ZIRAN_BIN) $(LIBOQS_A) | build-laws
|
||||
|
||||
test: lumi-feedback-delivery-test
|
||||
|
||||
.PHONY: diary-spelling-test diary-history-test
|
||||
diary-spelling-test: $(ZIRAN_BIN) $(LIBOQS_A) | build-laws
|
||||
@sh tests/diary_spelling_test.sh $(ZIRAN_BIN) $(LIBOQS_A)
|
||||
|
||||
diary-history-test: $(ZI2C_BIN)
|
||||
@sh tests/diary_history_zi_test.sh $(ZIRAN_BUILD_DIR)/bin
|
||||
|
||||
test: diary-spelling-test diary-history-test
|
||||
|
||||
# Lumi reports name the device, system and version (no identifiers).
|
||||
.PHONY: device-info-test
|
||||
device-info-test: $(ZIRAN_BIN)
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# Changelog
|
||||
|
||||
## [1.1.9] - 2026-10-11
|
||||
|
||||
### Changed
|
||||
- Scrollbars use your theme's colours and show how much of the page is in view.
|
||||
|
||||
## [1.1.8] - 2026-10-10
|
||||
|
||||
### Added
|
||||
- Correct the spelling of an entry with one button. Inner Breeze sends the entry to the Waozi node, which returns it with only misspelled words corrected. It uses the same daily online allowance as Lumi.
|
||||
- Undo and redo buttons, so a correction or any other change can be taken back.
|
||||
|
||||
### Changed
|
||||
- A title bar shows the date in the middle, between the previous and next day. Today and the calendar sit together on the left, and the entry's tools are compact buttons on the right, leaving more room for writing.
|
||||
- The entry reaches the bottom of the screen; a notice takes room below it only while it is shown.
|
||||
|
||||
## [1.1.7] - 2026-10-10
|
||||
|
||||
### Changed
|
||||
|
||||
+120
-33
@@ -25,6 +25,7 @@
|
||||
|
||||
using ImageFit;
|
||||
using TextAlign;
|
||||
using TextWrap;
|
||||
using ButtonTone;
|
||||
using ButtonEmphasis;
|
||||
host_api :: #system_library "host_api";
|
||||
@@ -35,6 +36,15 @@ state: DiaryMessage;
|
||||
frame: DiaryUiFrame;
|
||||
pending: bool;
|
||||
|
||||
DIARY_PREVIOUS_ICON :: "S1.8rr:M15 5L8 12L15 19"
|
||||
DIARY_NEXT_ICON :: "S1.8rr:M9 5L16 12L9 19"
|
||||
DIARY_CALENDAR_ICON :: "S1.6rr:M4 5H20V20H4ZM4 10H20M8 3V7M16 3V7"
|
||||
DIARY_TIME_ICON :: "S1.6rr:M21 12C21 16.97 16.97 21 12 21C7.03 21 3 16.97 3 12C3 7.03 7.03 3 12 3C16.97 3 21 7.03 21 12ZM12 7V12L15.5 14"
|
||||
DIARY_PHOTO_ICON :: "S1.6rr:M3 5H21V19H3ZM3 16L8 11L13 16L16 13L21 18M17.5 8.5C17.5 9.33 16.83 10 16 10C15.17 10 14.5 9.33 14.5 8.5C14.5 7.67 15.17 7 16 7C16.83 7 17.5 7.67 17.5 8.5Z"
|
||||
DIARY_UNDO_ICON :: "S1.8rr:M9 14L4 9L9 4M4 9H14C17.31 9 20 11.69 20 15C20 18.31 17.31 21 14 21H11"
|
||||
DIARY_REDO_ICON :: "S1.8rr:M15 14L20 9L15 4M20 9H10C6.69 9 4 11.69 4 15C4 18.31 6.69 21 10 21H13"
|
||||
DIARY_SPELLING_ICON :: "S2rr:M3 14L7.5 3L12 14M4.8 10H10.2M12 17L15.5 20.5L21.5 13"
|
||||
|
||||
DiaryObserve :: () -> DiaryUiFrame {
|
||||
return ReadDiaryUiHost()
|
||||
}
|
||||
@@ -117,6 +127,15 @@ DateTitle :: (year: s32, month: s32, day: s32) -> string {
|
||||
return BuilderFinish(title)
|
||||
}
|
||||
|
||||
HasWords :: (text: string) -> bool {
|
||||
for byte: text {
|
||||
if byte != cast(u8)32 && byte != cast(u8)10 && byte != cast(u8)13 && byte != cast(u8)9 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Scale :: (value: s32) -> s32 {
|
||||
return cast(s32)(cast(float32)value * frame.scale)
|
||||
}
|
||||
@@ -126,20 +145,37 @@ FinishView :: () -> DiaryMessage {
|
||||
return state
|
||||
}
|
||||
|
||||
DiaryAction :: ( id: s32, label: string, bounds: Rectangle, enabled: bool = true) {
|
||||
// A button with an icon shows only the icon; its label names it for
|
||||
// accessibility.
|
||||
DiaryAction :: ( id: s32, label: string, bounds: Rectangle, enabled: bool = true,
|
||||
icon: string = "", selected: bool = false, loading: bool = false) {
|
||||
if Button(frame.session, ButtonProps.{.id = id, .bounds = bounds,
|
||||
.label = label, .disabled = !enabled, .tone = cast(ButtonTone)ButtonToneNeutral,
|
||||
.emphasis = cast(ButtonEmphasis)ButtonEmphasisSoft}) != 0 {
|
||||
.label = label, .disabled = !enabled, .selected = selected, .loading = loading,
|
||||
.icon_shape = icon, .icon_only = icon != "", .fit_content = true,
|
||||
.tone = cast(ButtonTone)ButtonToneNeutral,
|
||||
.emphasis = cast(ButtonEmphasis)(ifx icon != "" then ButtonEmphasisGhost else ButtonEmphasisSoft)}) != 0 {
|
||||
// Photos, undo, redo and spelling are host effects.
|
||||
frame.focused = false
|
||||
if id == 29005 {
|
||||
frame.photo_requested = true
|
||||
frame.focused = false
|
||||
return
|
||||
}
|
||||
if id == 29014 {
|
||||
frame.undo_requested = true
|
||||
return
|
||||
}
|
||||
if id == 29015 {
|
||||
frame.redo_requested = true
|
||||
return
|
||||
}
|
||||
if id == 29016 {
|
||||
frame.spelling_requested = true
|
||||
return
|
||||
}
|
||||
state.action = DIARY_CONTROL
|
||||
state.control = id
|
||||
pending = true
|
||||
frame.scroll = 0
|
||||
frame.focused = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,24 +185,70 @@ DiaryView :: (message: DiaryMessage, observed: DiaryUiFrame, today: Date) -> Dia
|
||||
column := CenteredColumnFor(frame.width, Scale(640), Scale(16))
|
||||
left := cast(float32)column.x
|
||||
width := cast(float32)column.width
|
||||
Text(frame.session, TextProps.{.bounds = Rectangle.{left, cast(float32)Scale(24),
|
||||
width, cast(float32)Scale(40)}, .text = DateTitle(state.year, state.month, state.day), .font = frame.font})
|
||||
part := (width - cast(float32)Scale(12)) / 3.0
|
||||
compact := frame.height < Scale(480)
|
||||
top := cast(float32)(ifx compact then Scale(44) else Scale(76))
|
||||
DiaryAction(29001, "‹", Rectangle.{left, top, part, cast(float32)Scale(44)})
|
||||
DiaryAction(29004, DiaryLocaleHost("diary_today"), Rectangle.{left + part + cast(float32)Scale(6),
|
||||
top, part, cast(float32)Scale(44)})
|
||||
DiaryAction(29002, "›", Rectangle.{left + 2.0 * (part + cast(float32)Scale(6)),
|
||||
top, part, cast(float32)Scale(44)},
|
||||
top := cast(float32)(ifx compact then Scale(4) else Scale(12))
|
||||
control := cast(float32)Scale(44)
|
||||
gap := cast(float32)Scale(8)
|
||||
|
||||
// Title bar: the selected date, centered between the previous and next day.
|
||||
DiaryAction(29001, "‹", Rectangle.{left, top, control, control}, true, DIARY_PREVIOUS_ICON)
|
||||
DiaryAction(29002, "›", Rectangle.{left + width - control, top, control, control},
|
||||
OnOrBefore(Next(Date.{state.year, state.month, state.day}, 1), today) &&
|
||||
!OnOrBefore(today, Date.{state.year, state.month, state.day}))
|
||||
!OnOrBefore(today, Date.{state.year, state.month, state.day}),
|
||||
DIARY_NEXT_ICON)
|
||||
title := DateTitle(state.year, state.month, state.day)
|
||||
title_strong: [1]TextRange = .[TextRange.{.start = 0, .end = cast(s32)title.count}]
|
||||
Text(frame.session, TextProps.{.bounds = Rectangle.{left + control + gap, top,
|
||||
width - 2.0 * (control + gap), control}, .text = title,
|
||||
.font = frame.font + Scale(4), .strong = title_strong[:],
|
||||
.align = cast(TextAlign)TextAlignCenter, .vertical_align = cast(TextAlign)TextAlignCenter,
|
||||
.wrap = cast(TextWrap)TextWrapNone})
|
||||
|
||||
// Tools: Today and the calendar move between days; undo, redo, spelling,
|
||||
// the time and photos change the entry. Today narrows on phones so every
|
||||
// icon keeps its target.
|
||||
tools := top + control + gap
|
||||
tool_gap := cast(float32)Scale(4)
|
||||
tool := control
|
||||
today_width := width - 6.0 * tool - 5.0 * tool_gap - gap
|
||||
if today_width < cast(float32)Scale(64) {
|
||||
// The narrowest phones keep Today readable with smaller icon targets.
|
||||
today_width = cast(float32)Scale(64)
|
||||
tool = (width - today_width - gap - 5.0 * tool_gap) / 6.0
|
||||
}
|
||||
if today_width > cast(float32)Scale(128) {
|
||||
today_width = cast(float32)Scale(128)
|
||||
}
|
||||
DiaryAction(29004, DiaryLocaleHost("diary_today"), Rectangle.{left, tools, today_width, control})
|
||||
DiaryAction(29003, DiaryLocaleHost("tab_diary_calendar"),
|
||||
Rectangle.{left, top + cast(float32)Scale(52), width, cast(float32)Scale(44)})
|
||||
Rectangle.{left + today_width + gap, tools, tool, control},
|
||||
true, DIARY_CALENDAR_ICON, state.calendar)
|
||||
editable := !state.load_error && state.year > 0
|
||||
if !state.calendar {
|
||||
idle := editable && !frame.spelling_busy
|
||||
DiaryAction(29014, DiaryLocaleHost("diary_undo"),
|
||||
Rectangle.{left + width - 5.0 * tool - 4.0 * tool_gap, tools, tool, control},
|
||||
idle && frame.can_undo, DIARY_UNDO_ICON)
|
||||
DiaryAction(29015, DiaryLocaleHost("diary_redo"),
|
||||
Rectangle.{left + width - 4.0 * tool - 3.0 * tool_gap, tools, tool, control},
|
||||
idle && frame.can_redo, DIARY_REDO_ICON)
|
||||
DiaryAction(29016, DiaryLocaleHost("diary_check_spelling"),
|
||||
Rectangle.{left + width - 3.0 * tool - 2.0 * tool_gap, tools, tool, control},
|
||||
idle && HasWords(state.text), DIARY_SPELLING_ICON, false, frame.spelling_busy)
|
||||
DiaryAction(29013, DiaryLocaleHost("diary_insert_time"),
|
||||
Rectangle.{left + width - 2.0 * tool - tool_gap, tools, tool, control},
|
||||
!frame.spelling_busy, DIARY_TIME_ICON)
|
||||
DiaryAction(29005, DiaryLocaleHost("diary_attach_photo"),
|
||||
Rectangle.{left + width - tool, tools, tool, control},
|
||||
true, DIARY_PHOTO_ICON)
|
||||
}
|
||||
content := tools + control + cast(float32)Scale(12)
|
||||
content_height := cast(float32)(frame.height - frame.bottom) - content - cast(float32)Scale(16)
|
||||
|
||||
if state.calendar {
|
||||
scroll := Scroll(frame.session, ScrollProps.{.key = cast(u64)290300,
|
||||
.bounds = Rectangle.{left, top + cast(float32)Scale(104), width,
|
||||
cast(float32)(frame.height - frame.bottom - Scale(200))},
|
||||
.bounds = Rectangle.{left, content, width, content_height},
|
||||
.content_height = Scale(344), .scroll_offset = frame.calendar_scroll})
|
||||
frame.calendar_scroll = scroll.scroll_offset
|
||||
if !scroll.opened {
|
||||
@@ -204,29 +286,26 @@ DiaryView :: (message: DiaryMessage, observed: DiaryUiFrame, today: Date) -> Dia
|
||||
End(frame.session)
|
||||
return FinishView()
|
||||
}
|
||||
editor_height := frame.height - frame.bottom - cast(s32)top - Scale(236)
|
||||
// The editor reaches the bottom; a notice takes room below it only while
|
||||
// it is shown.
|
||||
notice := frame.photo_error || state.load_error || frame.spelling_notice != ""
|
||||
notice_room := ifx notice then Scale(60) else 0
|
||||
editor_height := cast(s32)content_height - notice_room
|
||||
if editor_height < Scale(120) {
|
||||
editor_height = Scale(120)
|
||||
}
|
||||
page := Scroll(frame.session, ScrollProps.{.key = cast(u64)290301,
|
||||
.bounds = Rectangle.{left, top + cast(float32)Scale(104), width,
|
||||
cast(float32)(frame.height - frame.bottom - cast(s32)top - Scale(120))},
|
||||
.content_height = editor_height + Scale(104) +
|
||||
(ifx state.photo_count > 0 then Scale(380) else 0), .scroll_offset = frame.page_scroll})
|
||||
.bounds = Rectangle.{left, content, width, content_height},
|
||||
.content_height = editor_height + notice_room +
|
||||
(ifx state.photo_count > 0 then Scale(392) else 0), .scroll_offset = frame.page_scroll})
|
||||
frame.page_scroll = page.scroll_offset
|
||||
if !page.opened {
|
||||
return FinishView()
|
||||
}
|
||||
DiaryAction(29013, DiaryLocaleHost("diary_insert_time"),
|
||||
Rectangle.{left, page.content.y, (width - cast(float32)Scale(8)) / 2.0, cast(float32)Scale(44)})
|
||||
DiaryAction(29005, DiaryLocaleHost("diary_attach_photo"),
|
||||
Rectangle.{left + (width + cast(float32)Scale(8)) / 2.0, page.content.y,
|
||||
(width - cast(float32)Scale(8)) / 2.0, cast(float32)Scale(44)})
|
||||
area: TextAreaProps
|
||||
area.key = cast(u64)290200
|
||||
area.focus_id = 29020
|
||||
area.bounds = Rectangle.{left, page.content.y + cast(float32)Scale(56), width,
|
||||
cast(float32)editor_height}
|
||||
area.bounds = Rectangle.{left, page.content.y, width, cast(float32)editor_height}
|
||||
area.value = state.text
|
||||
area.label = DiaryLocaleHost("tab_diary")
|
||||
area.wrap = true
|
||||
@@ -235,7 +314,9 @@ DiaryView :: (message: DiaryMessage, observed: DiaryUiFrame, today: Date) -> Dia
|
||||
area.scroll_y = frame.scroll
|
||||
area.focused = frame.focused
|
||||
area.selecting = frame.selecting
|
||||
area.read_only = state.load_error || state.year < 1
|
||||
// The entry waits while its spelling is checked, so the correction
|
||||
// always applies to the text that was sent.
|
||||
area.read_only = !editable || frame.spelling_busy
|
||||
area.max_bytes = 2147483646
|
||||
area.max_codepoints = 2147483646
|
||||
area.input = frame.input
|
||||
@@ -261,14 +342,20 @@ DiaryView :: (message: DiaryMessage, observed: DiaryUiFrame, today: Date) -> Dia
|
||||
frame.clipboard_text = edited.clipboard_text
|
||||
}
|
||||
|
||||
if frame.photo_error || state.load_error {
|
||||
status := ifx frame.photo_error then "diary_photo_error" else "diary_read_error"
|
||||
if notice {
|
||||
status := frame.spelling_notice
|
||||
if state.load_error {
|
||||
status = "diary_read_error"
|
||||
}
|
||||
if frame.photo_error {
|
||||
status = "diary_photo_error"
|
||||
}
|
||||
Text(frame.session, TextProps.{.bounds = Rectangle.{left,
|
||||
area.bounds.y + area.bounds.height + cast(float32)Scale(12), width, cast(float32)Scale(40)},
|
||||
.text = DiaryLocaleHost(status), .font = frame.font})
|
||||
}
|
||||
if state.photo_count > 0 {
|
||||
photo_top := area.bounds.y + area.bounds.height + cast(float32)Scale(60)
|
||||
photo_top := area.bounds.y + area.bounds.height + cast(float32)(notice_room + Scale(12))
|
||||
photo_bounds := Rectangle.{left, photo_top, width, cast(float32)Scale(240)}
|
||||
if frame.photo_format.count > 0 {
|
||||
path: Vec(u8)
|
||||
|
||||
@@ -1,5 +1,25 @@
|
||||
# Changelog
|
||||
|
||||
## [2.1.29] - 2026-10-11
|
||||
|
||||
- Bring Lumi 1.3.9, Diary 1.1.9, Lists 1.0.5 and Leaderboard 1.0.1.
|
||||
- Requires Inner Breeze 2.1.29 or later.
|
||||
|
||||
## [2.1.28] - 2026-10-11
|
||||
|
||||
- Bring Lumi's message selection with copy and delete.
|
||||
- Requires Inner Breeze 2.1.29 or later.
|
||||
|
||||
## [2.1.27] - 2026-10-11
|
||||
|
||||
- Bring Lumi's chat that loads older messages as you scroll up.
|
||||
- Requires Inner Breeze 2.1.29 or later.
|
||||
|
||||
## [2.1.26] - 2026-10-10
|
||||
|
||||
- Bring Diary's title bar, undo and redo, and spelling correction, and Lumi's typing dots.
|
||||
- Requires Inner Breeze 2.1.29 or later.
|
||||
|
||||
## [2.1.25] - 2026-10-10
|
||||
|
||||
- Open Leaderboard as its own app.
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
# Changelog
|
||||
|
||||
## [1.0.1] - 2026-10-11
|
||||
|
||||
- Scrollbars use your theme's colours and show how much of the list is in view.
|
||||
|
||||
## [1.0.0] - 2026-10-10
|
||||
|
||||
- Rank yourself with your friends for Wim Hof, breathing patterns, meditation and Sun Salutation.
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
# Changelog
|
||||
|
||||
## [1.0.5] - 2026-10-11
|
||||
|
||||
- Scrollbars use your theme's colours and show how much of the list is in view.
|
||||
- Scrolling while you type a new item keeps the keyboard open.
|
||||
|
||||
## [1.0.4] - 2026-10-10
|
||||
|
||||
- Requires Inner Breeze 2.1.28 or later.
|
||||
|
||||
@@ -1,5 +1,26 @@
|
||||
# Changelog
|
||||
|
||||
## [1.3.9] - 2026-10-11
|
||||
### Fixed
|
||||
- Scrolling the command list keeps the keyboard open.
|
||||
### Changed
|
||||
- Scrollbars use your theme's colours and show how much of the chat is in view.
|
||||
|
||||
## [1.3.8] - 2026-10-11
|
||||
### Added
|
||||
- Select messages like in Telegram: hold a message to select it, then tap or drag across others; dragging to the top or bottom of the chat scrolls it, through older messages too. Checkmarks show what is selected, and a bar over the top of the chat shows how many, with copy and delete.
|
||||
### Changed
|
||||
- Lumi's typing dots appear after a short pause, as a person reads before typing.
|
||||
- Feedback shows only its card with Yes and No, without a second copy of the question.
|
||||
|
||||
## [1.3.7] - 2026-10-11
|
||||
### Changed
|
||||
- Like Telegram, the chat shows your newest messages and loads older ones as you scroll up, right away while the newest do not fill the screen.
|
||||
|
||||
## [1.3.6] - 2026-10-10
|
||||
### Added
|
||||
- While Lumi is answering, three dots show in its bubble where the answer will appear.
|
||||
|
||||
## [1.3.5] - 2026-10-10
|
||||
|
||||
- Requires Inner Breeze 2.1.28 or later.
|
||||
|
||||
+4
-4
@@ -137,8 +137,10 @@ LumiRespond :: (input: string) {
|
||||
if PerformLumiActionHost(action) {
|
||||
SetLumiHabitChoiceHost(false)
|
||||
SetLumiDiaryChoiceHost(false)
|
||||
if action.kind == LUMI_SHOW_PROGRESS || action.kind == LUMI_SHOW_DONATIONS {
|
||||
// These tools already appended their typed card to the chat.
|
||||
if action.kind == LUMI_SHOW_PROGRESS || action.kind == LUMI_SHOW_DONATIONS ||
|
||||
action.kind == LUMI_REPORT_FEEDBACK {
|
||||
// These tools already appended their typed card to the chat;
|
||||
// the feedback card with Yes and No is the whole answer.
|
||||
return
|
||||
}
|
||||
reply = "lumi_opened"
|
||||
@@ -156,8 +158,6 @@ LumiRespond :: (input: string) {
|
||||
reply = "lumi_practice_started"
|
||||
} else if action.kind == LUMI_WRITE_DIARY {
|
||||
reply = "lumi_diary_saved"
|
||||
} else if action.kind == LUMI_REPORT_FEEDBACK {
|
||||
reply = "lumi_feedback_confirm"
|
||||
}
|
||||
} else {
|
||||
reply = "lumi_unavailable"
|
||||
|
||||
+329
-4
@@ -13,6 +13,10 @@
|
||||
#import "control_props"
|
||||
#import "box_props"
|
||||
#import "box_widget"
|
||||
#import "checkbox_props"
|
||||
#import "checkbox_widget"
|
||||
#import "press_props"
|
||||
#import "press_widget"
|
||||
#import "scroll_props"
|
||||
#import "scroll_widget"
|
||||
#import "tree"
|
||||
@@ -41,6 +45,7 @@ ReadLumiSuggestionHabitHost :: (index: s32) -> LumiTask #foreign host_api;
|
||||
LumiViewLocaleHost :: (key: string) -> string #foreign host_api;
|
||||
LumiFeedbackChoiceHost :: (id: string, action: s32) -> bool #foreign host_api;
|
||||
LumiLoadOlderHost :: () -> bool #foreign host_api;
|
||||
LumiDeleteRowHost :: (index: s32) -> bool #foreign host_api;
|
||||
LumiFirstVisibleRowHost :: (scroll: s32) -> s32 #foreign host_api;
|
||||
LumiRowOffsetHost :: (index: s32) -> s32 #foreign host_api;
|
||||
ReadLumiDonationHost :: (coin: s32) -> LumiDonation #foreign host_api;
|
||||
@@ -89,6 +94,201 @@ menu_revision: s64 = -1;
|
||||
menu_commands: [LUMI_MENU_COMMANDS]LumiMenuCommand;
|
||||
menu_scroll: s32;
|
||||
focus_request: s32;
|
||||
// Telegram-style selection: hold a message to select it, then tap messages
|
||||
// or drag across them; dragging near the chat's top or bottom scrolls it.
|
||||
// Rows are counted from the newest message, which older messages loading
|
||||
// above do not change, so a sweep can keep going up through the history.
|
||||
// The greeting above every message is kept apart.
|
||||
LUMI_SELECT_MAX :: 4096
|
||||
selecting: bool;
|
||||
selected: [LUMI_SELECT_MAX]bool;
|
||||
greeting_selected: bool;
|
||||
selected_count: s32;
|
||||
sweeping: bool;
|
||||
// The row the sweep began on, counted from the newest message; -1 is the
|
||||
// greeting.
|
||||
sweep_anchor: s32;
|
||||
sweep_value: bool;
|
||||
// Where the pointer is during a sweep, for scrolling at the chat's edges.
|
||||
sweep_pointer_y: float32;
|
||||
sweep_seen: bool;
|
||||
confirm_delete: bool;
|
||||
// Copied text waits until the composer has written its own clipboard state.
|
||||
pending_copy: string;
|
||||
copy_pending: bool;
|
||||
LUMI_CLOSE_ICON :: "S1.8rr:M6 6L18 18M18 6L6 18"
|
||||
LUMI_COPY_ICON :: "S1.6rr:M9 9H20V20H9ZM15 5V4H4V15H5"
|
||||
LUMI_DELETE_ICON :: "S1.6rr:M3 6H21M9 6V3H15V6M5 6L6 21H18L19 6M10 10V17M14 10V17"
|
||||
|
||||
// A row's place counted from the newest message; the greeting is -1.
|
||||
RowSlot :: (index: s32) -> s32 {
|
||||
if index <= 0 {
|
||||
return -1
|
||||
}
|
||||
return frame.chat_count - 1 - index
|
||||
}
|
||||
|
||||
SlotRow :: (slot: s32) -> s32 {
|
||||
if slot < 0 {
|
||||
return 0
|
||||
}
|
||||
return frame.chat_count - 1 - slot
|
||||
}
|
||||
|
||||
IsSelected :: (index: s32) -> bool {
|
||||
slot := RowSlot(index)
|
||||
if slot < 0 {
|
||||
return greeting_selected
|
||||
}
|
||||
return slot < LUMI_SELECT_MAX && selected[slot]
|
||||
}
|
||||
|
||||
SelectionClear :: () {
|
||||
for index: cast(s32)0..LUMI_SELECT_MAX - 1 {
|
||||
selected[index] = false
|
||||
}
|
||||
greeting_selected = false
|
||||
selected_count = 0
|
||||
selecting = false
|
||||
sweeping = false
|
||||
confirm_delete = false
|
||||
}
|
||||
|
||||
SelectionSet :: (index: s32, value: bool) {
|
||||
if index < 0 || index >= frame.chat_count || IsSelected(index) == value {
|
||||
return
|
||||
}
|
||||
slot := RowSlot(index)
|
||||
if slot < 0 {
|
||||
greeting_selected = value
|
||||
} else if slot < LUMI_SELECT_MAX {
|
||||
selected[slot] = value
|
||||
} else {
|
||||
return
|
||||
}
|
||||
selected_count += ifx value then 1 else -1
|
||||
}
|
||||
|
||||
// A press began on a row: it selects or clears that row, and dragging then
|
||||
// gives every row it sweeps over the same state.
|
||||
SweepStart :: (index: s32, value: bool) {
|
||||
sweeping = true
|
||||
sweep_anchor = RowSlot(index)
|
||||
sweep_value = value
|
||||
SelectionSet(index, value)
|
||||
}
|
||||
|
||||
SweepTo :: (index: s32) {
|
||||
if index < 0 {
|
||||
index = 0
|
||||
}
|
||||
if index >= frame.chat_count {
|
||||
index = frame.chat_count - 1
|
||||
}
|
||||
anchor := SlotRow(sweep_anchor)
|
||||
first := ifx index < anchor then index else anchor
|
||||
last := ifx index < anchor then anchor else index
|
||||
for row: first..last {
|
||||
SelectionSet(row, sweep_value)
|
||||
}
|
||||
}
|
||||
|
||||
// The template with its %d replaced by the count.
|
||||
CountText :: (template: string, count: s32) -> string {
|
||||
out: Vec(u8)
|
||||
at: s64 = 0
|
||||
while at < template.count {
|
||||
if at + 1 < template.count && template[at] == cast(u8)37 && template[at + 1] == cast(u8)100 {
|
||||
BuilderPrint(*out, "%", count)
|
||||
at += 2
|
||||
} else {
|
||||
BuilderPrint(*out, "%", template[at:at + 1])
|
||||
at += 1
|
||||
}
|
||||
}
|
||||
return BuilderFinish(out)
|
||||
}
|
||||
|
||||
SelectedText :: () -> string {
|
||||
out: Vec(u8)
|
||||
written: s32 = 0
|
||||
for index: cast(s32)0..frame.chat_count - 1 {
|
||||
if !IsSelected(index) {
|
||||
continue
|
||||
}
|
||||
if written > 0 {
|
||||
BuilderPrint(*out, "\n\n")
|
||||
}
|
||||
BuilderPrint(*out, "%", ReadLumiChatRowHost(index).text)
|
||||
written += 1
|
||||
}
|
||||
return BuilderFinish(out)
|
||||
}
|
||||
|
||||
// The bar replacing the top of the chat while messages are selected: close,
|
||||
// the count, then copy and delete, with delete asking first.
|
||||
SelectionBar :: (x: s32, top: s32, width: s32) {
|
||||
control := Scale(44)
|
||||
Box(frame.session, BoxProps.{.key = cast(u64)300369,
|
||||
.bounds = Bounds(x - Scale(16), 0, width + Scale(32), top + control + Scale(8)),
|
||||
.fill = frame.background})
|
||||
if confirm_delete {
|
||||
Text(frame.session, TextProps.{.key = cast(u64)300370,
|
||||
.bounds = Bounds(x, top, width - Scale(216), control),
|
||||
.text = LumiViewLocaleHost("lumi_delete_confirm"), .font = frame.font,
|
||||
.wrap = cast(TextWrap)TextWrapAuto, .vertical_align = cast(TextAlign)TextAlignCenter})
|
||||
if Button(frame.session, ButtonProps.{.id = 30020,
|
||||
.bounds = Bounds(x + width - Scale(208), top, Scale(100), control),
|
||||
.label = LumiViewLocaleHost("cancel_button"), .fit_content = true,
|
||||
.tone = cast(ButtonTone)ButtonToneNeutral, .emphasis = cast(ButtonEmphasis)ButtonEmphasisSoft}) != 0 {
|
||||
confirm_delete = false
|
||||
}
|
||||
if Button(frame.session, ButtonProps.{.id = 30021,
|
||||
.bounds = Bounds(x + width - Scale(100), top, Scale(100), control),
|
||||
.label = LumiViewLocaleHost("delete_button"), .fit_content = true,
|
||||
.tone = cast(ButtonTone)ButtonToneDanger, .emphasis = cast(ButtonEmphasis)ButtonEmphasisFilled}) != 0 {
|
||||
// From the last row back, so earlier rows keep their indices.
|
||||
index := frame.chat_count - 1
|
||||
while index >= 0 {
|
||||
if IsSelected(index) {
|
||||
unused LumiDeleteRowHost(index)
|
||||
}
|
||||
index -= 1
|
||||
}
|
||||
SelectionClear()
|
||||
}
|
||||
return
|
||||
}
|
||||
if Button(frame.session, ButtonProps.{.id = 30022, .bounds = Bounds(x, top, control, control),
|
||||
.label = LumiViewLocaleHost("lumi_cancel_selection"), .icon_shape = LUMI_CLOSE_ICON, .icon_only = true,
|
||||
.tone = cast(ButtonTone)ButtonToneNeutral, .emphasis = cast(ButtonEmphasis)ButtonEmphasisGhost}) != 0 {
|
||||
SelectionClear()
|
||||
return
|
||||
}
|
||||
Box(frame.session, BoxProps.{.key = cast(u64)300371,
|
||||
.bounds = Bounds(x + control + Scale(8), top + Scale(6), Scale(150), control - Scale(12)),
|
||||
.fill = Color.{156, 188, 143, 48}, .radius = cast(float32)(control - Scale(12)) / 2.0})
|
||||
Text(frame.session, TextProps.{.key = cast(u64)300372,
|
||||
.bounds = Bounds(x + control + Scale(8), top, Scale(150), control),
|
||||
.text = CountText(LumiViewLocaleHost("lumi_selected_count"), selected_count), .font = frame.font,
|
||||
.wrap = cast(TextWrap)TextWrapNone, .align = cast(TextAlign)TextAlignCenter,
|
||||
.vertical_align = cast(TextAlign)TextAlignCenter})
|
||||
if Button(frame.session, ButtonProps.{.id = 30023,
|
||||
.bounds = Bounds(x + width - 2 * control - Scale(4), top, control, control),
|
||||
.label = LumiViewLocaleHost("lumi_copy"), .icon_shape = LUMI_COPY_ICON, .icon_only = true,
|
||||
.tone = cast(ButtonTone)ButtonToneNeutral, .emphasis = cast(ButtonEmphasis)ButtonEmphasisGhost}) != 0 {
|
||||
pending_copy = SelectedText()
|
||||
copy_pending = true
|
||||
SelectionClear()
|
||||
return
|
||||
}
|
||||
if Button(frame.session, ButtonProps.{.id = 30024,
|
||||
.bounds = Bounds(x + width - control, top, control, control),
|
||||
.label = LumiViewLocaleHost("delete_button"), .icon_shape = LUMI_DELETE_ICON, .icon_only = true,
|
||||
.tone = cast(ButtonTone)ButtonToneDanger, .emphasis = cast(ButtonEmphasis)ButtonEmphasisGhost}) != 0 {
|
||||
confirm_delete = true
|
||||
}
|
||||
}
|
||||
// A rounded square with a slash, and a paper plane, in Kryon's 24 x 24 icon
|
||||
// shape format.
|
||||
LUMI_COMMANDS_ICON :: "S1.8rr:M7 3H17C19.2091 3 21 4.79086 21 7V17C21 19.2091 19.2091 21 17 21H7C4.79086 21 3 19.2091 3 17V7C3 4.79086 4.79086 3 7 3Z|S1.8rr:M14.5 7.5L9.5 16.5"
|
||||
@@ -328,6 +528,60 @@ DonationCard :: (index: s32, x: s32, y: s32, width: s32) {
|
||||
}
|
||||
}
|
||||
|
||||
// Lumi's bubble with three dots that brighten and rise in turn, where its
|
||||
// answer will appear.
|
||||
TypingDots :: (x: s32, top: s32) {
|
||||
left := x + Scale(48)
|
||||
Image(frame.session, ImageProps.{.key = cast(u64)300380,
|
||||
.asset_path = "assets/lumi/mascot.png", .alt_text = "Lumi",
|
||||
.bounds = Bounds(x, top + Scale(16), Scale(40), Scale(40)),
|
||||
.source = Rectangle.{0.0, 0.0, -1254.0, 1254.0},
|
||||
.fit = cast(ImageFit)ImageFitContain})
|
||||
Box(frame.session, BoxProps.{.key = cast(u64)300381,
|
||||
.bounds = Bounds(left, top, Scale(96), Scale(60)),
|
||||
.fill = Color.{156, 156, 156, 24}, .radius = cast(float32)Scale(16)})
|
||||
Text(frame.session, TextProps.{.key = cast(u64)300382,
|
||||
.bounds = Bounds(left + Scale(14), top + Scale(8), Scale(68), Scale(20)),
|
||||
.text = "Lumi", .font = Scale(12)})
|
||||
for dot: cast(s32)0..2 {
|
||||
phase := frame.now * 1.4 - cast(float64)dot * 0.2
|
||||
phase = phase - cast(float64)cast(s64)phase
|
||||
if phase < 0.0 {
|
||||
phase += 1.0
|
||||
}
|
||||
level := ifx phase < 0.5 then phase * 2.0 else (1.0 - phase) * 2.0
|
||||
size := Scale(8)
|
||||
Box(frame.session, BoxProps.{.key = cast(u64)(300383 + dot),
|
||||
.bounds = Bounds(left + Scale(16) + dot * Scale(14),
|
||||
top + Scale(38) - cast(s32)(level * cast(float64)Scale(4)), size, size),
|
||||
.fill = Color.{170, 170, 170, cast(u8)(90.0 + 165.0 * level)},
|
||||
.radius = cast(float32)size / 2.0})
|
||||
}
|
||||
}
|
||||
|
||||
// A row's press: a hold starts selecting, and while selecting a press starts
|
||||
// a sweep that follows the pointer, even off the row and past the chat.
|
||||
RowPress :: (index: s32, bounds: Rectangle, content_y: float32) {
|
||||
key := ifx index == 0 then 0 else RowSlot(index) + 1
|
||||
press := Press(frame.session, PressProps.{.key = cast(u64)(410000 + key), .bounds = bounds,
|
||||
.label = LumiViewLocaleHost("lumi_message"), .now = frame.now, .capture = selecting})
|
||||
if !selecting && press.held {
|
||||
selecting = true
|
||||
confirm_delete = false
|
||||
SweepStart(index, true)
|
||||
} else if selecting && press.down && !sweeping {
|
||||
SweepStart(index, !IsSelected(index))
|
||||
}
|
||||
if sweeping && press.down {
|
||||
sweep_seen = true
|
||||
sweep_pointer_y = press.y
|
||||
SweepTo(LumiFirstVisibleRowHost(cast(s32)(press.y - content_y)))
|
||||
}
|
||||
if press.released {
|
||||
sweeping = false
|
||||
}
|
||||
}
|
||||
|
||||
LumiView :: (message: LumiMessage, commands: LumiCommands, revision: s64) -> LumiMessage {
|
||||
frame = ReadLumiUiHost()
|
||||
column := CenteredColumnFor(frame.width, Scale(720), Scale(16))
|
||||
@@ -389,11 +643,20 @@ LumiView :: (message: LumiMessage, commands: LumiCommands, revision: s64) -> Lum
|
||||
if frame.follow_end {
|
||||
frame.scroll = 1000000
|
||||
}
|
||||
// While Lumi answers, its typing dots follow the last message after a
|
||||
// short pause.
|
||||
typing := frame.waiting && !frame.typing_pause
|
||||
typing_height := ifx typing then Scale(70) else 0
|
||||
history := Scroll(frame.session, ScrollProps.{.key = cast(u64)300100,
|
||||
.bounds = Bounds(x, history_top, width, chat_height),
|
||||
.content_height = frame.history_height, .scroll_offset = frame.scroll, .scale = frame.scale})
|
||||
.content_height = frame.history_height + typing_height, .scroll_offset = frame.scroll, .scale = frame.scale})
|
||||
frame.scroll = history.scroll_offset
|
||||
frame.follow_end = history.scroll_offset == history.max_scroll
|
||||
// Older messages load when the chat reaches its top, and at once while
|
||||
// the loaded ones do not fill the chat, which then cannot scroll.
|
||||
load_older := frame.has_older &&
|
||||
(history.max_scroll <= 0 || (!frame.follow_end && frame.scroll <= Scale(96)))
|
||||
anchor_drawn := false
|
||||
if history.opened {
|
||||
first := LumiFirstVisibleRowHost(history.scroll_offset)
|
||||
top := cast(s32)history.content.y + LumiRowOffsetHost(first)
|
||||
@@ -405,7 +668,20 @@ LumiView :: (message: LumiMessage, commands: LumiCommands, revision: s64) -> Lum
|
||||
row_height := row.height
|
||||
bubble_width := width - Scale(ifx row.user then 60 else 80)
|
||||
left := x + Scale(48)
|
||||
if !row.user {
|
||||
// The whole row takes holds and sweeps; its buttons sit above it.
|
||||
RowPress(index, Bounds(x, top, width, row_height - Scale(10)), history.content.y)
|
||||
if RowSlot(index) == sweep_anchor {
|
||||
anchor_drawn = true
|
||||
}
|
||||
if selecting {
|
||||
checked := IsSelected(index)
|
||||
toggled := Checkbox(frame.session, CheckboxProps.{.key = cast(u64)(420000 + RowSlot(index) + 1),
|
||||
.bounds = Bounds(x + Scale(8), top + (row_height - Scale(10)) / 2 - Scale(12), Scale(24), Scale(24)),
|
||||
.label = LumiViewLocaleHost("lumi_message"), .checked = checked})
|
||||
if toggled.changed {
|
||||
SelectionSet(index, toggled.checked)
|
||||
}
|
||||
} else if !row.user {
|
||||
Image(frame.session, ImageProps.{.key = cast(u64)(300400 + index * 4),
|
||||
.asset_path = "assets/lumi/mascot.png", .alt_text = "Lumi",
|
||||
.bounds = Bounds(x, top + row_height - Scale(54), Scale(40), Scale(40)),
|
||||
@@ -428,7 +704,7 @@ LumiView :: (message: LumiMessage, commands: LumiCommands, revision: s64) -> Lum
|
||||
props := TextProps.{.key = cast(u64)(300403 + index * 4),
|
||||
.bounds = Bounds(left + Scale(14), top + text_top,
|
||||
bubble_width - Scale(28), text_height),
|
||||
.text = row.text, .font = frame.font, .selectable = true,
|
||||
.text = row.text, .font = frame.font,
|
||||
.wrap = cast(TextWrap)TextWrapAuto}
|
||||
if !row.user {
|
||||
formatted := ReplyText(index, row.text)
|
||||
@@ -456,8 +732,52 @@ LumiView :: (message: LumiMessage, commands: LumiCommands, revision: s64) -> Lum
|
||||
}
|
||||
top += row_height
|
||||
}
|
||||
if typing {
|
||||
TypingDots(x, cast(s32)history.content.y + frame.history_height)
|
||||
}
|
||||
// Scrolling can carry the row the sweep began on out of view; its
|
||||
// press stays registered so the sweep goes on.
|
||||
if sweeping && !anchor_drawn {
|
||||
anchor := SlotRow(sweep_anchor)
|
||||
if anchor >= 0 && anchor < frame.chat_count {
|
||||
anchor_top := cast(s32)history.content.y + LumiRowOffsetHost(anchor)
|
||||
RowPress(anchor, Bounds(x, anchor_top, width,
|
||||
ReadLumiChatRowHost(anchor).height - Scale(10)), history.content.y)
|
||||
}
|
||||
}
|
||||
End(frame.session)
|
||||
}
|
||||
// Dragging near the chat's top or bottom scrolls it, faster nearer the
|
||||
// edge, so a sweep can reach every message.
|
||||
if sweeping && sweep_seen {
|
||||
edge := cast(float32)Scale(56)
|
||||
top_edge := cast(float32)Scale(60) + edge
|
||||
bottom_edge := cast(float32)(history_top + chat_height) - edge
|
||||
if sweep_pointer_y < top_edge {
|
||||
step := cast(s32)((top_edge - sweep_pointer_y) / 3.0) + Scale(4)
|
||||
if step > Scale(40) {
|
||||
step = Scale(40)
|
||||
}
|
||||
frame.scroll -= step
|
||||
if frame.scroll < 0 {
|
||||
frame.scroll = 0
|
||||
}
|
||||
frame.follow_end = false
|
||||
} else if sweep_pointer_y > bottom_edge {
|
||||
step := cast(s32)((sweep_pointer_y - bottom_edge) / 3.0) + Scale(4)
|
||||
if step > Scale(40) {
|
||||
step = Scale(40)
|
||||
}
|
||||
frame.scroll += step
|
||||
}
|
||||
}
|
||||
sweep_seen = false
|
||||
if selecting && selected_count <= 0 && !sweeping {
|
||||
SelectionClear()
|
||||
}
|
||||
if selecting {
|
||||
SelectionBar(x, Scale(12), width)
|
||||
}
|
||||
typed := LumiTrim(frame.value)
|
||||
candidates: [20]string = .[commands.start_whm, commands.complete_habit,
|
||||
commands.start_meditation, commands.start_sun, commands.start_patterns,
|
||||
@@ -636,6 +956,11 @@ LumiView :: (message: LumiMessage, commands: LumiCommands, revision: s64) -> Lum
|
||||
}
|
||||
frame.clipboard_write = field.clipboard_write
|
||||
frame.clipboard_text = field.clipboard_text
|
||||
if copy_pending {
|
||||
frame.clipboard_write = true
|
||||
frame.clipboard_text = pending_copy
|
||||
copy_pending = false
|
||||
}
|
||||
send := !show_commands && Button(frame.session, ButtonProps.{.id = 30011,
|
||||
.bounds = Bounds(x + width - Scale(48), footer, Scale(48), Scale(48)),
|
||||
.label = LumiViewLocaleHost("lumi_send"), .icon_shape = LUMI_SEND_ICON, .icon_only = true,
|
||||
@@ -674,7 +999,7 @@ LumiView :: (message: LumiMessage, commands: LumiCommands, revision: s64) -> Lum
|
||||
frame.follow_end = true
|
||||
}
|
||||
WriteLumiUiHost(frame)
|
||||
if message.action != LUMI_SEND && frame.has_older && !frame.follow_end && frame.scroll <= Scale(96) {
|
||||
if message.action != LUMI_SEND && load_older {
|
||||
unused LumiLoadOlderHost()
|
||||
}
|
||||
return message
|
||||
|
||||
+26
-18
@@ -1,48 +1,56 @@
|
||||
{
|
||||
"host_api": 5,
|
||||
"host_api": 7,
|
||||
"oldest_host_api": 5,
|
||||
"module_api": 2,
|
||||
"apps": {
|
||||
"inbe": {
|
||||
"id": "inbe",
|
||||
"version": "2.1.25",
|
||||
"sequence": 22,
|
||||
"bundled": true
|
||||
"version": "2.1.29",
|
||||
"sequence": 26,
|
||||
"bundled": true,
|
||||
"host_api": 7
|
||||
},
|
||||
"habits": {
|
||||
"id": "inbe.habits",
|
||||
"version": "1.0.4",
|
||||
"sequence": 5,
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"host_api": 5
|
||||
},
|
||||
"practices": {
|
||||
"id": "inbe.practices",
|
||||
"version": "1.1.4",
|
||||
"sequence": 6,
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"host_api": 5
|
||||
},
|
||||
"lists": {
|
||||
"id": "inbe.lists",
|
||||
"version": "1.0.4",
|
||||
"sequence": 5,
|
||||
"bundled": true
|
||||
"version": "1.0.5",
|
||||
"sequence": 6,
|
||||
"bundled": true,
|
||||
"host_api": 5
|
||||
},
|
||||
"diary": {
|
||||
"id": "inbe.diary",
|
||||
"version": "1.1.7",
|
||||
"sequence": 9,
|
||||
"bundled": true
|
||||
"version": "1.1.9",
|
||||
"sequence": 11,
|
||||
"bundled": true,
|
||||
"host_api": 7
|
||||
},
|
||||
"lumi": {
|
||||
"id": "inbe.lumi",
|
||||
"version": "1.3.5",
|
||||
"sequence": 12,
|
||||
"bundled": true
|
||||
"version": "1.3.9",
|
||||
"sequence": 16,
|
||||
"bundled": true,
|
||||
"host_api": 7
|
||||
},
|
||||
"leaderboard": {
|
||||
"id": "inbe.leaderboard",
|
||||
"version": "1.0.0",
|
||||
"sequence": 1,
|
||||
"bundled": true
|
||||
"version": "1.0.1",
|
||||
"sequence": 2,
|
||||
"bundled": true,
|
||||
"host_api": 5
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+26
-1
@@ -157,7 +157,12 @@ Downloads use the Daochi release v2 endpoints on `https://api.waozi.xyz`:
|
||||
`/api/v2/packages/{app_id}/{sha256}.zib`. IDs are `inbe`, `inbe.habits`,
|
||||
`inbe.practices`, `inbe.lists`, `inbe.diary` and `inbe.lumi`.
|
||||
|
||||
Automatic updates default on and check daily for the root and selected apps.
|
||||
Automatic updates default on and check daily for the root and selected apps,
|
||||
once after a start when the last check is an hour old, and ten minutes after
|
||||
a sync reports a newer root package (`package_sequence` in sync replies).
|
||||
A downloaded package proves itself by running ten seconds after a start; one
|
||||
that three starts in a row never proved is set aside for the bundled package
|
||||
and is not downloaded again until a different release arrives.
|
||||
The cell picker includes an automatic-update switch and a manual check button.
|
||||
Turning the switch off cancels active and queued automatic work; manual
|
||||
installation and checking remain available. No automatic network checks run
|
||||
@@ -187,6 +192,19 @@ Packaged resource and translation changes also trigger only the package workflow
|
||||
`make package-version-test` checks every module's numeric changelog, ledger,
|
||||
sequence and bundled status before publishing.
|
||||
|
||||
Hosts and packages agree on interfaces, not exact versions. Every package
|
||||
declares the oldest host interface it needs (`host_api` in its ledger entry),
|
||||
and the host runs packages from `oldest_host_api` to its own `host_api`.
|
||||
Records between them match fields by name, so a field one side lacks keeps its
|
||||
zero value and an unknown field is ignored. Update checks send the host's
|
||||
interfaces and a stable device bucket; the node answers with the newest
|
||||
release that fits, so apps that keep an older host still receive the packages
|
||||
built for it. `package-release.py --rollout PERCENT --rollout-hours HOURS`
|
||||
stages changed releases to that share of devices first; the node releases them
|
||||
to everyone when the time runs out. `make package-compat-test` runs the
|
||||
packages the node serves in the current build, and runs each new package that
|
||||
declares an older interface in the last released app.
|
||||
|
||||
## Publishing configuration
|
||||
|
||||
The `Cell packages` GitHub Actions workflow builds and verifies package releases
|
||||
@@ -296,6 +314,13 @@ to native host capabilities still require a wrapper release.
|
||||
|
||||
## Verification
|
||||
|
||||
A new app version is published only with a passing phone check of its
|
||||
exact sources. `make phone-check APK=...` installs that APK on the development
|
||||
Moto, runs the Wim Hof session for a minute while it reads SurfaceFlinger's
|
||||
frame times, checks resuming from the background and records
|
||||
`releases/phone-checks/VERSION.json`; the Release workflow refuses a new tag
|
||||
without it or when app sources changed after it.
|
||||
|
||||
Harmony Projects shows this wrapper release, every cell version and its Moto
|
||||
screenshots. Harmony's `make inbe-release-verify` checks the latest published
|
||||
APK on the development Moto and writes private evidence under
|
||||
|
||||
+10
-2
@@ -56,8 +56,8 @@ android {
|
||||
minSdk 21
|
||||
targetSdk 36
|
||||
testInstrumentationRunner "android.test.InstrumentationTestRunner"
|
||||
versionCode 165
|
||||
versionName "2.1.28"
|
||||
versionCode 168
|
||||
versionName "2.1.31"
|
||||
manifestPlaceholders = [
|
||||
inbeAppLabel: "Inner Breeze",
|
||||
inbeUsesCleartextTraffic: "false"
|
||||
@@ -87,17 +87,25 @@ android {
|
||||
shrinkResources true
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
buildConfigField "boolean", "GPLAY", "false"
|
||||
// Direct APK installs update themselves; F-Droid updates through its store.
|
||||
buildConfigField "boolean", "SELF_UPDATE", project.hasProperty('fDroidBuild') ? "false" : "true"
|
||||
buildConfigField "String", "UPDATE_FEED", '"https://github.com/waozixyz/inbe/releases/latest/download/appcast.json"'
|
||||
}
|
||||
gplay {
|
||||
initWith release
|
||||
signingConfig project.hasProperty('fDroidBuild') ? null : signingConfigs.release
|
||||
matchingFallbacks = ['release']
|
||||
buildConfigField "boolean", "GPLAY", "true"
|
||||
buildConfigField "boolean", "SELF_UPDATE", "false"
|
||||
buildConfigField "String", "UPDATE_FEED", '""'
|
||||
}
|
||||
debug {
|
||||
applicationIdSuffix ".debug"
|
||||
signingConfig signingConfigs.debug
|
||||
buildConfigField "boolean", "GPLAY", "false"
|
||||
// Debug builds update only from a test feed: -Papp.updateFeed=URL.
|
||||
buildConfigField "boolean", "SELF_UPDATE", project.hasProperty('app.updateFeed') ? "true" : "false"
|
||||
buildConfigField "String", "UPDATE_FEED", '"' + (project.findProperty('app.updateFeed') ?: '') + '"'
|
||||
manifestPlaceholders.inbeAppLabel = "Inner Breeze Debug"
|
||||
manifestPlaceholders.inbeUsesCleartextTraffic = "true"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package xyz.waozi.inbe;
|
||||
|
||||
import android.test.InstrumentationTestCase;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class AppUpdateTest extends InstrumentationTestCase {
|
||||
public void testOnlyNewerNumericReleasesUpdate() {
|
||||
assertTrue(AppUpdate.newer("2.1.29", "2.1.28"));
|
||||
assertTrue(AppUpdate.newer("2.2.0", "2.1.99"));
|
||||
assertTrue(AppUpdate.newer("10.0.0", "9.9.9"));
|
||||
assertTrue(AppUpdate.newer("2.1.28.1", "2.1.28"));
|
||||
assertFalse(AppUpdate.newer("2.1.28", "2.1.28"));
|
||||
assertFalse(AppUpdate.newer("2.1.27", "2.1.28"));
|
||||
assertFalse(AppUpdate.newer("2.1.x", "2.1.28"));
|
||||
assertFalse(AppUpdate.newer("2.1.29-beta", "2.1.28"));
|
||||
assertFalse(AppUpdate.newer("", "2.1.28"));
|
||||
}
|
||||
|
||||
public void testPicksThePreferredAbiThenTheUniversalApk() throws Exception {
|
||||
JSONObject channels = new JSONObject("{\"android\":{\"url\":\"u\"},"
|
||||
+ "\"android-arm64-v8a\":{\"url\":\"a64\"},\"android-armeabi-v7a\":{\"url\":\"a32\"},"
|
||||
+ "\"appimage-amd64\":{\"url\":\"linux\"}}");
|
||||
assertEquals("a64", AppUpdate.channel(channels, new String[] {"arm64-v8a", "armeabi-v7a"}).getString("url"));
|
||||
assertEquals("a32", AppUpdate.channel(channels, new String[] {"armeabi-v7a", "armeabi"}).getString("url"));
|
||||
assertEquals("u", AppUpdate.channel(channels, new String[] {"x86_64"}).getString("url"));
|
||||
assertNull(AppUpdate.channel(new JSONObject("{\"appimage-amd64\":{}}"), new String[] {"x86_64"}));
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,40 @@ public class LumiKeyboardTest extends InstrumentationTestCase {
|
||||
SystemClock.sleep(500);
|
||||
}
|
||||
|
||||
private void drag(int startX, int startY, int endX, int endY) {
|
||||
long now = SystemClock.uptimeMillis();
|
||||
MotionEvent down = MotionEvent.obtain(now, now, MotionEvent.ACTION_DOWN, startX, startY, 0);
|
||||
getInstrumentation().sendPointerSync(down);
|
||||
down.recycle();
|
||||
for (int step = 1; step <= 8; step++) {
|
||||
float x = startX + (endX - startX) * step / 8.0f;
|
||||
float y = startY + (endY - startY) * step / 8.0f;
|
||||
MotionEvent move = MotionEvent.obtain(now, SystemClock.uptimeMillis(),
|
||||
MotionEvent.ACTION_MOVE, x, y, 0);
|
||||
getInstrumentation().sendPointerSync(move);
|
||||
move.recycle();
|
||||
SystemClock.sleep(40);
|
||||
}
|
||||
MotionEvent up = MotionEvent.obtain(now, SystemClock.uptimeMillis(),
|
||||
MotionEvent.ACTION_UP, endX, endY, 0);
|
||||
getInstrumentation().sendPointerSync(up);
|
||||
up.recycle();
|
||||
SystemClock.sleep(700);
|
||||
}
|
||||
|
||||
private void acknowledge(TextInputView input) throws Exception {
|
||||
Field revision = TextInputView.class.getDeclaredField("revision");
|
||||
revision.setAccessible(true);
|
||||
Field acknowledged = TextInputView.class.getDeclaredField("acknowledgedRevision");
|
||||
acknowledged.setAccessible(true);
|
||||
long sent = revision.getLong(input);
|
||||
long deadline = SystemClock.uptimeMillis() + 7000;
|
||||
while (acknowledged.getLong(input) < sent && SystemClock.uptimeMillis() < deadline) {
|
||||
SystemClock.sleep(100);
|
||||
}
|
||||
assertEquals("Native widget did not acknowledge the IME edit", sent, acknowledged.getLong(input));
|
||||
}
|
||||
|
||||
public void testFirstFocusSwipeTextReachesNativeLumi() throws Exception {
|
||||
Intent launch = new Intent(getInstrumentation().getTargetContext(), MainActivity.class);
|
||||
launch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
@@ -82,6 +116,21 @@ public class LumiKeyboardTest extends InstrumentationTestCase {
|
||||
assertTrue("Lumi did not regain the editor", input.hasFocus());
|
||||
assertEquals("Dismissal changed the draft", "hello 水😀", input.getText().toString());
|
||||
});
|
||||
getInstrumentation().runOnMainSync(() -> {
|
||||
InputConnection connection = input.onCreateInputConnection(new EditorInfo());
|
||||
connection.setSelection(0, input.length());
|
||||
connection.commitText("/", 1);
|
||||
});
|
||||
acknowledge(input);
|
||||
awaitKeyboard(activity, true);
|
||||
drag(195, 620, 195, 520);
|
||||
awaitKeyboard(activity, true);
|
||||
getInstrumentation().runOnMainSync(() -> {
|
||||
assertTrue("Scrolling commands dropped Lumi's editor", input.hasFocus());
|
||||
assertEquals("Scrolling commands changed the draft", "/", input.getText().toString());
|
||||
});
|
||||
getInstrumentation().sendKeyDownUpSync(KeyEvent.KEYCODE_BACK);
|
||||
awaitKeyboard(activity, false);
|
||||
assertFalse(activity.isFinishing());
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public class PixelLumiKeyboardTest extends InstrumentationTestCase {
|
||||
assertEquals("Shell keyboard gesture failed", "", output.toString("UTF-8").trim());
|
||||
}
|
||||
|
||||
private void focus(MainActivity activity) {
|
||||
private int[] focusPoint(MainActivity activity) {
|
||||
int[] location = new int[2];
|
||||
getInstrumentation().runOnMainSync(() -> {
|
||||
WindowInsets insets = activity.getWindow().getDecorView().getRootWindowInsets();
|
||||
@@ -67,6 +67,11 @@ public class PixelLumiKeyboardTest extends InstrumentationTestCase {
|
||||
location[0] = activity.getWindow().getDecorView().getWidth() / 5;
|
||||
location[1] = activity.getWindow().getDecorView().getHeight() - bottom - Math.round(92 * density);
|
||||
});
|
||||
return location;
|
||||
}
|
||||
|
||||
private void focus(MainActivity activity) {
|
||||
int[] location = focusPoint(activity);
|
||||
long start = SystemClock.uptimeMillis();
|
||||
pointer(MotionEvent.ACTION_DOWN, start, location[0], location[1]);
|
||||
SystemClock.sleep(250);
|
||||
@@ -74,6 +79,25 @@ public class PixelLumiKeyboardTest extends InstrumentationTestCase {
|
||||
SystemClock.sleep(1500);
|
||||
}
|
||||
|
||||
private void swipeCommands(MainActivity activity, int[] field) throws Exception {
|
||||
float density = activity.getResources().getDisplayMetrics().density;
|
||||
int start_y = field[1] - Math.round(80 * density);
|
||||
int end_y = field[1] - Math.round(300 * density);
|
||||
String command = "input touchscreen swipe " + field[0] + " " + start_y + " " +
|
||||
field[0] + " " + end_y + " 400";
|
||||
ParcelFileDescriptor pipe = getInstrumentation().getUiAutomation().executeShellCommand(command);
|
||||
try (InputStream stream = new ParcelFileDescriptor.AutoCloseInputStream(pipe)) {
|
||||
byte[] buffer = new byte[1024];
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
int count;
|
||||
while ((count = stream.read(buffer)) != -1) {
|
||||
output.write(buffer, 0, count);
|
||||
}
|
||||
assertEquals("Command scroll failed", "", output.toString("UTF-8").trim());
|
||||
}
|
||||
SystemClock.sleep(1500);
|
||||
}
|
||||
|
||||
private void openLumi(MainActivity activity) {
|
||||
int[] point = new int[2];
|
||||
getInstrumentation().runOnMainSync(() -> {
|
||||
@@ -136,6 +160,55 @@ public class PixelLumiKeyboardTest extends InstrumentationTestCase {
|
||||
assertEquals("Native Lumi did not apply the keyboard edit", sent.getLong(input), accepted.getLong(input));
|
||||
}
|
||||
|
||||
public void testCommandScrollKeepsKeyboardOnPixel() throws Exception {
|
||||
assertEquals("This check is only for the authorized Pixel", "Pixel 3a", Build.MODEL);
|
||||
AccessibilityServiceInfo service = getInstrumentation().getUiAutomation().getServiceInfo();
|
||||
service.flags |= AccessibilityServiceInfo.FLAG_RETRIEVE_INTERACTIVE_WINDOWS;
|
||||
getInstrumentation().getUiAutomation().setServiceInfo(service);
|
||||
Intent launch = new Intent(getInstrumentation().getTargetContext(), MainActivity.class);
|
||||
launch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
MainActivity activity = (MainActivity)getInstrumentation().startActivitySync(launch);
|
||||
Field ready = MainActivity.class.getDeclaredField("firstFrameReady");
|
||||
ready.setAccessible(true);
|
||||
long deadline = SystemClock.uptimeMillis() + 15000;
|
||||
while (!ready.getBoolean(activity) && SystemClock.uptimeMillis() < deadline) {
|
||||
SystemClock.sleep(100);
|
||||
}
|
||||
assertTrue("Native first frame did not finish", ready.getBoolean(activity));
|
||||
openLumi(activity);
|
||||
int[] field = focusPoint(activity);
|
||||
focus(activity);
|
||||
Field fieldAccessor = MainActivity.class.getDeclaredField("textInputView");
|
||||
fieldAccessor.setAccessible(true);
|
||||
TextInputView input = (TextInputView)fieldAccessor.get(activity);
|
||||
String[] original = new String[1];
|
||||
InputConnection[] connection = new InputConnection[1];
|
||||
getInstrumentation().runOnMainSync(() -> {
|
||||
assertTrue("Lumi did not focus its editor", input.hasFocus());
|
||||
original[0] = input.getText().toString();
|
||||
connection[0] = input.onCreateInputConnection(new EditorInfo());
|
||||
connection[0].setSelection(0, input.length());
|
||||
connection[0].commitText("/", 1);
|
||||
});
|
||||
acknowledged(input);
|
||||
assertNotNull("Command list did not keep Gboard open", key("w"));
|
||||
try {
|
||||
swipeCommands(activity, field);
|
||||
assertNotNull("Scrolling commands closed Gboard", key("w"));
|
||||
getInstrumentation().runOnMainSync(() -> {
|
||||
assertTrue("Scrolling commands dropped Lumi's editor", input.hasFocus());
|
||||
assertEquals("Scrolling commands changed the draft", "/", input.getText().toString());
|
||||
});
|
||||
} finally {
|
||||
getInstrumentation().runOnMainSync(() -> {
|
||||
InputConnection current = input.onCreateInputConnection(new EditorInfo());
|
||||
current.setSelection(0, input.length());
|
||||
current.commitText(original[0], 1);
|
||||
});
|
||||
acknowledged(input);
|
||||
}
|
||||
}
|
||||
|
||||
public void testGboardSwipeAndReopeningOnPixel() throws Exception {
|
||||
assertEquals("This check is only for the authorized Pixel", "Pixel 3a", Build.MODEL);
|
||||
AccessibilityServiceInfo service = getInstrumentation().getUiAutomation().getServiceInfo();
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
<!-- Google Play updates the app; it never installs packages itself. -->
|
||||
<uses-permission
|
||||
android:name="android.permission.REQUEST_INSTALL_PACKAGES"
|
||||
tools:node="remove" />
|
||||
<application>
|
||||
<service
|
||||
android:name="xyz.waozi.inbe.PushServiceImpl"
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
<uses-sdk tools:overrideLibrary="androidx.health.connect.client" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<!-- Direct APK installs offer their own updates through Android's installer. -->
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
|
||||
@@ -96,6 +98,10 @@
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
|
||||
<receiver
|
||||
android:name="xyz.waozi.inbe.AppUpdateReceiver"
|
||||
android:exported="false" />
|
||||
|
||||
<receiver
|
||||
android:name="xyz.waozi.inbe.StartPracticeWidget"
|
||||
android:exported="false"
|
||||
|
||||
@@ -87,8 +87,8 @@ file(GLOB_RECURSE APP_LIBRARY_ZIRAN_SOURCES CONFIGURE_DEPENDS
|
||||
"${REPO_ROOT}/build/packages/kss/src/*.zi" "${REPO_ROOT}/build/packages/oqs/src/*.zi" "${REPO_ROOT}/build/packages/game2d/src/*.zi"
|
||||
"${REPO_ROOT}/build/packages/qrcode/src/*.zi"
|
||||
"${ZIRAN_DIR}/std/*.zi" "${REPO_ROOT}/build/packages/daochi-client/*.zi")
|
||||
set(APP_ZIRAN_DEFINES --define ANDROID_BUILD)
|
||||
set(APP_ZIRAN_CHECK_DEFINES "ANDROID_BUILD")
|
||||
set(APP_ZIRAN_DEFINES --define ANDROID_BUILD --define KRYON_ANDROID_HOST)
|
||||
set(APP_ZIRAN_CHECK_DEFINES "ANDROID_BUILD KRYON_ANDROID_HOST")
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
list(APPEND APP_ZIRAN_DEFINES --define ANDROID_DEBUG)
|
||||
string(APPEND APP_ZIRAN_CHECK_DEFINES " ANDROID_DEBUG")
|
||||
|
||||
@@ -0,0 +1,361 @@
|
||||
package xyz.waozi.inbe;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageInstaller;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.Signature;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import org.json.JSONObject;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
/** APKs installed straight from the GitHub release update themselves: once a
|
||||
* day the release feed is read in the background and a newer APK for this
|
||||
* device is downloaded and verified. The next start offers it through
|
||||
* Android's own installer. Store builds (Google Play, F-Droid) leave this
|
||||
* off with BuildConfig.SELF_UPDATE and keep updating through their store. */
|
||||
final class AppUpdate {
|
||||
private static final String TAG = "InbeUpdate";
|
||||
private static final long CHECK_INTERVAL_MS = 24L * 60 * 60 * 1000;
|
||||
private static final long OFFER_INTERVAL_MS = 24L * 60 * 60 * 1000;
|
||||
private static final long FEED_LIMIT = 65536;
|
||||
private static final long APK_LIMIT = 256L * 1024 * 1024;
|
||||
private static final Object LOCK = new Object();
|
||||
|
||||
private AppUpdate() {}
|
||||
|
||||
static SharedPreferences preferences(Context context) {
|
||||
return context.getSharedPreferences("app-updates", Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
/** Offers a verified update from an earlier start, or checks for one. A
|
||||
* start that opens a practice is never interrupted. */
|
||||
static void onStart(Activity activity, boolean practice) {
|
||||
if (!BuildConfig.SELF_UPDATE || BuildConfig.UPDATE_FEED.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Context context = activity.getApplicationContext();
|
||||
SharedPreferences preferences = preferences(context);
|
||||
long now = System.currentTimeMillis();
|
||||
File ready = readyUpdate(context);
|
||||
if (ready != null) {
|
||||
if (!practice && now - preferences.getLong("offered_at", 0) >= OFFER_INTERVAL_MS) {
|
||||
preferences.edit().putLong("offered_at", now).apply();
|
||||
new Thread(() -> install(context, ready), "inbe-update-install").start();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (now - preferences.getLong("checked_at", 0) < CHECK_INTERVAL_MS) {
|
||||
return;
|
||||
}
|
||||
preferences.edit().putLong("checked_at", now).apply();
|
||||
new Thread(() -> {
|
||||
try {
|
||||
check(context);
|
||||
} catch (Exception error) {
|
||||
Log.w(TAG, "Update check failed", error);
|
||||
}
|
||||
}, "inbe-update-check").start();
|
||||
}
|
||||
|
||||
/** Release versions are numeric x.y.z; a missing part counts as zero. */
|
||||
static boolean newer(String candidate, String installed) {
|
||||
String[] left = candidate.split("\\.");
|
||||
String[] right = installed.split("\\.");
|
||||
for (int index = 0; index < Math.max(left.length, right.length); index++) {
|
||||
long a = index < left.length ? parsePart(left[index]) : 0;
|
||||
long b = index < right.length ? parsePart(right[index]) : 0;
|
||||
if (a < 0 || b < 0) {
|
||||
return false;
|
||||
}
|
||||
if (a != b) {
|
||||
return a > b;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static long parsePart(String part) {
|
||||
if (part.isEmpty() || part.length() > 9 || !part.matches("[0-9]+")) {
|
||||
return -1;
|
||||
}
|
||||
return Long.parseLong(part);
|
||||
}
|
||||
|
||||
/** The APK built for this device's preferred ABI, else the universal one. */
|
||||
static JSONObject channel(JSONObject channels, String[] abis) {
|
||||
for (String abi : abis) {
|
||||
JSONObject entry = channels.optJSONObject("android-" + abi);
|
||||
if (entry != null) {
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
return channels.optJSONObject("android");
|
||||
}
|
||||
|
||||
private static void check(Context context) throws Exception {
|
||||
JSONObject feed = new JSONObject(new String(fetch(BuildConfig.UPDATE_FEED, FEED_LIMIT, null),
|
||||
StandardCharsets.UTF_8));
|
||||
String version = feed.getString("version");
|
||||
PackageInfo installed = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
|
||||
if (installed.versionName == null || !newer(version, installed.versionName)) {
|
||||
return;
|
||||
}
|
||||
JSONObject entry = channel(feed.getJSONObject("channels"), Build.SUPPORTED_ABIS);
|
||||
if (entry == null) {
|
||||
return;
|
||||
}
|
||||
String hash = entry.getString("sha256");
|
||||
long size = entry.getLong("size");
|
||||
String url = entry.getString("url");
|
||||
if (!hash.matches("[0-9a-f]{64}") || size <= 0 || size > APK_LIMIT ||
|
||||
!(url.startsWith("https://") || (BuildConfig.DEBUG && url.startsWith("http://")))) {
|
||||
throw new IOException("Invalid release feed entry");
|
||||
}
|
||||
File directory = directory(context);
|
||||
if (size > directory.getUsableSpace()) {
|
||||
throw new IOException("Not enough space for the update");
|
||||
}
|
||||
File apk = new File(directory, hash + ".apk");
|
||||
File part = new File(directory, hash + ".part");
|
||||
synchronized (LOCK) {
|
||||
try (OutputStream output = new FileOutputStream(part)) {
|
||||
fetch(url, size, output);
|
||||
}
|
||||
if (part.length() != size || !hash.equals(sha256(part))) {
|
||||
part.delete();
|
||||
throw new IOException("The downloaded APK differs from the release feed");
|
||||
}
|
||||
long code;
|
||||
try {
|
||||
code = verify(context, part);
|
||||
} catch (Exception error) {
|
||||
part.delete();
|
||||
throw error;
|
||||
}
|
||||
if (!part.renameTo(apk)) {
|
||||
part.delete();
|
||||
throw new IOException("Could not keep the verified update");
|
||||
}
|
||||
clearOthers(directory, apk);
|
||||
preferences(context).edit().putString("ready_hash", hash).putLong("ready_code", code)
|
||||
.putString("ready_version", version).remove("offered_at").apply();
|
||||
}
|
||||
Log.i(TAG, "Update " + version + " is verified and will be offered on the next start");
|
||||
}
|
||||
|
||||
/** Returns the verified APK from an earlier check while it is still newer. */
|
||||
private static File readyUpdate(Context context) {
|
||||
SharedPreferences preferences = preferences(context);
|
||||
String hash = preferences.getString("ready_hash", "");
|
||||
if (hash.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
File apk = new File(directory(context), hash + ".apk");
|
||||
long code = verify(context, apk);
|
||||
if (code == preferences.getLong("ready_code", -1) && hash.equals(sha256(apk))) {
|
||||
return apk;
|
||||
}
|
||||
} catch (Exception error) {
|
||||
Log.i(TAG, "The kept update is no longer usable", error);
|
||||
}
|
||||
forget(context);
|
||||
return null;
|
||||
}
|
||||
|
||||
static void forget(Context context) {
|
||||
preferences(context).edit().remove("ready_hash").remove("ready_code").remove("ready_version")
|
||||
.remove("offered_at").apply();
|
||||
try {
|
||||
clearOthers(directory(context), null);
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
/** The APK must be this app, newer than it and signed by the same key. */
|
||||
private static long verify(Context context, File apk) throws Exception {
|
||||
if (!apk.isFile()) {
|
||||
throw new IOException("No update file");
|
||||
}
|
||||
PackageManager manager = context.getPackageManager();
|
||||
int flags = Build.VERSION.SDK_INT >= 28
|
||||
? PackageManager.GET_SIGNING_CERTIFICATES : PackageManager.GET_SIGNATURES;
|
||||
PackageInfo current = manager.getPackageInfo(context.getPackageName(), flags);
|
||||
PackageInfo candidate = manager.getPackageArchiveInfo(apk.getAbsolutePath(), flags);
|
||||
if (candidate == null || !context.getPackageName().equals(candidate.packageName)) {
|
||||
throw new IOException("The update is not this app");
|
||||
}
|
||||
long code = versionCode(candidate);
|
||||
if (code <= versionCode(current)) {
|
||||
throw new IOException("The update is not newer than this app");
|
||||
}
|
||||
Set<String> expected = signers(current);
|
||||
Set<String> actual = signers(candidate);
|
||||
// Android refuses an update signed by another key in any case; older
|
||||
// versions may not report an archive's signers, newer ones must match.
|
||||
if (expected.isEmpty() || (!actual.isEmpty() && !expected.equals(actual)) ||
|
||||
(Build.VERSION.SDK_INT >= 28 && actual.isEmpty())) {
|
||||
throw new IOException("The update is signed by another key");
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static long versionCode(PackageInfo info) {
|
||||
return Build.VERSION.SDK_INT >= 28 ? info.getLongVersionCode() : info.versionCode;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static Set<String> signers(PackageInfo info) throws Exception {
|
||||
Signature[] signatures;
|
||||
if (Build.VERSION.SDK_INT >= 28) {
|
||||
signatures = info.signingInfo == null ? null : info.signingInfo.getApkContentsSigners();
|
||||
} else {
|
||||
signatures = info.signatures;
|
||||
}
|
||||
Set<String> values = new HashSet<>();
|
||||
if (signatures != null) {
|
||||
for (Signature signature : signatures) {
|
||||
values.add(hex(MessageDigest.getInstance("SHA-256").digest(signature.toByteArray())));
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
private static void install(Context context, File apk) {
|
||||
synchronized (LOCK) {
|
||||
PackageInstaller installer = context.getPackageManager().getPackageInstaller();
|
||||
int session = -1;
|
||||
try {
|
||||
if (!installer.getMySessions().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
PackageInstaller.SessionParams parameters = new PackageInstaller.SessionParams(
|
||||
PackageInstaller.SessionParams.MODE_FULL_INSTALL);
|
||||
parameters.setAppPackageName(context.getPackageName());
|
||||
parameters.setSize(apk.length());
|
||||
session = installer.createSession(parameters);
|
||||
try (PackageInstaller.Session open = installer.openSession(session)) {
|
||||
try (InputStream input = new FileInputStream(apk);
|
||||
OutputStream output = open.openWrite("base.apk", 0, apk.length())) {
|
||||
copy(input, output, apk.length());
|
||||
open.fsync(output);
|
||||
}
|
||||
Intent callback = new Intent(context, AppUpdateReceiver.class)
|
||||
.setAction(context.getPackageName() + ".APP_UPDATE_RESULT");
|
||||
int flags = PendingIntent.FLAG_UPDATE_CURRENT;
|
||||
if (Build.VERSION.SDK_INT >= 31) {
|
||||
flags |= PendingIntent.FLAG_MUTABLE;
|
||||
}
|
||||
PendingIntent reply = PendingIntent.getBroadcast(context, session, callback, flags);
|
||||
open.commit(reply.getIntentSender());
|
||||
session = -1;
|
||||
}
|
||||
} catch (Exception error) {
|
||||
Log.w(TAG, "Could not start the update installation", error);
|
||||
} finally {
|
||||
if (session >= 0) {
|
||||
installer.abandonSession(session);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] fetch(String address, long limit, OutputStream sink) throws IOException {
|
||||
HttpURLConnection connection = (HttpURLConnection)new URL(address).openConnection();
|
||||
connection.setConnectTimeout(15000);
|
||||
connection.setReadTimeout(30000);
|
||||
connection.setInstanceFollowRedirects(true);
|
||||
connection.setRequestProperty("User-Agent", "Inner-Breeze/" + BuildConfig.VERSION_NAME);
|
||||
try {
|
||||
int code = connection.getResponseCode();
|
||||
if (code != 200) {
|
||||
throw new IOException("Update download answered " + code);
|
||||
}
|
||||
try (InputStream input = connection.getInputStream()) {
|
||||
if (sink != null) {
|
||||
copy(input, sink, limit);
|
||||
return null;
|
||||
}
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
copy(input, buffer, limit);
|
||||
return buffer.toByteArray();
|
||||
}
|
||||
} finally {
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
private static void copy(InputStream input, OutputStream output, long limit) throws IOException {
|
||||
byte[] buffer = new byte[65536];
|
||||
long total = 0;
|
||||
int count;
|
||||
while ((count = input.read(buffer)) != -1) {
|
||||
total += count;
|
||||
if (total > limit) {
|
||||
throw new IOException("Update download exceeds its size");
|
||||
}
|
||||
output.write(buffer, 0, count);
|
||||
}
|
||||
}
|
||||
|
||||
private static String sha256(File file) throws Exception {
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||
byte[] buffer = new byte[65536];
|
||||
try (InputStream input = new FileInputStream(file)) {
|
||||
int count;
|
||||
while ((count = input.read(buffer)) != -1) {
|
||||
digest.update(buffer, 0, count);
|
||||
}
|
||||
}
|
||||
return hex(digest.digest());
|
||||
}
|
||||
|
||||
private static String hex(byte[] bytes) {
|
||||
StringBuilder text = new StringBuilder();
|
||||
for (byte value : bytes) {
|
||||
text.append(String.format(Locale.ROOT, "%02x", value & 255));
|
||||
}
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
private static File directory(Context context) throws IOException {
|
||||
File directory = new File(context.getFilesDir(), "app-updates");
|
||||
if (!directory.isDirectory() && !directory.mkdirs()) {
|
||||
throw new IOException("Update storage unavailable");
|
||||
}
|
||||
return directory;
|
||||
}
|
||||
|
||||
private static void clearOthers(File directory, File keep) {
|
||||
File[] files = directory.listFiles();
|
||||
if (files == null) {
|
||||
return;
|
||||
}
|
||||
for (File file : files) {
|
||||
if (keep == null || !file.equals(keep)) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package xyz.waozi.inbe;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInstaller;
|
||||
import android.util.Log;
|
||||
|
||||
/** Android's answer to an update installation. Confirmation goes to
|
||||
* Android's own installer screen; a finished or refused installation drops
|
||||
* the kept APK so it is not offered again. */
|
||||
public final class AppUpdateReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
int status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, PackageInstaller.STATUS_FAILURE);
|
||||
if (status == PackageInstaller.STATUS_PENDING_USER_ACTION) {
|
||||
Intent confirm = intent.getParcelableExtra(Intent.EXTRA_INTENT);
|
||||
if (confirm != null) {
|
||||
confirm.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
try {
|
||||
context.startActivity(confirm);
|
||||
} catch (RuntimeException error) {
|
||||
Log.w("InbeUpdate", "Android's installer is unavailable", error);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (status == PackageInstaller.STATUS_SUCCESS) {
|
||||
AppUpdate.forget(context);
|
||||
return;
|
||||
}
|
||||
// A cancelled confirmation keeps the update for the next day's offer.
|
||||
if (status != PackageInstaller.STATUS_FAILURE_ABORTED) {
|
||||
Log.w("InbeUpdate", "Android did not install the update: " +
|
||||
intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE));
|
||||
AppUpdate.forget(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -159,10 +159,26 @@ public class MainActivity extends NativeActivity {
|
||||
pictureWindowReturns++;
|
||||
}
|
||||
refreshPictureWindowState();
|
||||
reportWindowSize();
|
||||
requestInsetRefresh();
|
||||
syncLifecycleState("onPictureInPictureModeChanged");
|
||||
}
|
||||
|
||||
// The floating window's shadow makes the drawing surface larger than the
|
||||
// window frame on every side, and Android keeps that margin after the
|
||||
// window opens back into the app. In full screen the margin lies past the
|
||||
// screen edges, so native draws the app in the frame's part of the
|
||||
// surface. The floating window shows the whole surface, so there the app
|
||||
// fills it (size 0) rather than leaving a border.
|
||||
private void reportWindowSize() {
|
||||
View decor = getWindow().getDecorView();
|
||||
if (Build.VERSION.SDK_INT >= 26 && isInPictureInPictureMode()) {
|
||||
nativeSetWindowSize(0, 0);
|
||||
} else {
|
||||
nativeSetWindowSize(decor.getWidth(), decor.getHeight());
|
||||
}
|
||||
}
|
||||
|
||||
private void showStartup() {
|
||||
startupView = new FrameLayout(this);
|
||||
startupView.setBackgroundColor(getResources().getColor(R.color.startup_background));
|
||||
@@ -271,6 +287,7 @@ public class MainActivity extends NativeActivity {
|
||||
|
||||
private native void nativeSetInsets(int left, int top, int right, int bottom, int imeBottom,
|
||||
int cutoutLeft, int cutoutTop, int cutoutRight, int cutoutBottom);
|
||||
private native void nativeSetWindowSize(int width, int height);
|
||||
private native void nativeSetDeviceDensity(float density);
|
||||
private native void nativeSetSystemDark(int dark);
|
||||
private native void nativeSetOrientation(int orientation);
|
||||
@@ -979,6 +996,11 @@ public class MainActivity extends NativeActivity {
|
||||
});
|
||||
}
|
||||
|
||||
/** Called from Kryon's file_export: share bytes as a file. */
|
||||
public void shareFile(byte[] data, String filename, String mimeType, String title) {
|
||||
ShareHelper.shareFile(this, data, filename, mimeType, title);
|
||||
}
|
||||
|
||||
public void copyTextAndShowToast(final String text, final String toastText) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
@@ -1035,6 +1057,7 @@ public class MainActivity extends NativeActivity {
|
||||
|
||||
// Widget/tile/shortcut launch: the intent that started this activity.
|
||||
handleStartPracticeIntent(getIntent());
|
||||
AppUpdate.onStart(this, getIntent() != null && ACTION_START_PRACTICE.equals(getIntent().getAction()));
|
||||
handleAudioE2EIntent(getIntent());
|
||||
handleDebugDonationReminderIntent(getIntent());
|
||||
}
|
||||
@@ -1135,6 +1158,9 @@ public class MainActivity extends NativeActivity {
|
||||
}
|
||||
});
|
||||
|
||||
decorView.addOnLayoutChangeListener((view, left, top, right, bottom,
|
||||
oldLeft, oldTop, oldRight, oldBottom) -> reportWindowSize());
|
||||
|
||||
// 2. Startup safety net: Catches frame sizing on the initial layout pass
|
||||
decorView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
Fixed
|
||||
---
|
||||
- Scrolling Lumi's commands keeps the keyboard open.
|
||||
- New habits show each colour choice in its own colour.
|
||||
- Leaving Wim Hof no longer freezes the app for a few seconds.
|
||||
- The app no longer freezes just after launch while it checks for app updates.
|
||||
Changed
|
||||
---
|
||||
- Scrollbars use your theme's colours and show how much is in view.
|
||||
- Apps rearranges to fill the window's width.
|
||||
@@ -0,0 +1,9 @@
|
||||
Fixed
|
||||
---
|
||||
- Long menus, such as the colour theme, scroll by touch and open at your choice.
|
||||
- With a menu open, tapping the navigation closes it and switches screens in one tap.
|
||||
- Menus stay above the navigation instead of hiding their last options behind it.
|
||||
- Web: the app is sharp on high-density screens instead of magnified and blurry.
|
||||
Changed
|
||||
---
|
||||
- Icons are sharper on the web.
|
||||
@@ -0,0 +1,3 @@
|
||||
Fixed
|
||||
---
|
||||
- Android: after the floating practice window, the app fits the screen again instead of running under the status bar and navigation and losing its sides.
|
||||
+52
-4
@@ -2313,10 +2313,6 @@ Dnešní limit online dotazů je vyčerpán. Místní příkazy aplikace stále
|
||||
[lumi_developer_reply]
|
||||
Odpověď vývojáře:
|
||||
|
||||
---
|
||||
[lumi_feedback_saved]
|
||||
Uloženo v tomto zařízení a čeká na odeslání do schránky vývojáře. Je potřeba účet Inner Breeze a přístup k internetu.
|
||||
|
||||
---
|
||||
[lumi_show_progress]
|
||||
Zobrazit pokrok
|
||||
@@ -2795,3 +2791,55 @@ Toto zařízení zatím nemá účet ke sdílení. Zobrazte kód zde.
|
||||
[return_to_apps]
|
||||
Zpět do Aplikací
|
||||
---
|
||||
|
||||
[diary_undo]
|
||||
Zpět
|
||||
---
|
||||
|
||||
[diary_redo]
|
||||
Znovu
|
||||
---
|
||||
|
||||
[diary_check_spelling]
|
||||
Opravit pravopis
|
||||
---
|
||||
|
||||
[diary_spelling_none]
|
||||
Nenalezeny žádné pravopisné chyby.
|
||||
---
|
||||
|
||||
[diary_spelling_error]
|
||||
Pravopis teď nelze zkontrolovat. Zkuste to později.
|
||||
---
|
||||
|
||||
[diary_spelling_limit]
|
||||
Dnešní limit online dotazů je vyčerpán. Zkuste to zítra.
|
||||
---
|
||||
|
||||
[diary_spelling_account]
|
||||
Pro opravu pravopisu se přihlaste k účtu.
|
||||
---
|
||||
|
||||
[diary_spelling_too_long]
|
||||
Tento záznam je příliš dlouhý na kontrolu najednou.
|
||||
---
|
||||
|
||||
[lumi_selected_count]
|
||||
Vybráno: %d
|
||||
---
|
||||
|
||||
[lumi_copy]
|
||||
Kopírovat
|
||||
---
|
||||
|
||||
[lumi_cancel_selection]
|
||||
Zrušit výběr
|
||||
---
|
||||
|
||||
[lumi_delete_confirm]
|
||||
Smazat vybrané zprávy?
|
||||
---
|
||||
|
||||
[lumi_message]
|
||||
Zpráva v chatu
|
||||
---
|
||||
+52
-4
@@ -2313,10 +2313,6 @@ Dein Online-Kontingent für heute ist aufgebraucht. Lokale App-Befehle funktioni
|
||||
[lumi_developer_reply]
|
||||
Antwort vom Entwickler:
|
||||
|
||||
---
|
||||
[lumi_feedback_saved]
|
||||
Auf diesem Gerät gespeichert und wartet auf den Versand an den Entwicklereingang. Dafür sind ein Inner Breeze-Konto und Internetzugang erforderlich.
|
||||
|
||||
---
|
||||
[lumi_show_progress]
|
||||
Fortschritt anzeigen
|
||||
@@ -2795,3 +2791,55 @@ Dieses Gerät hat noch kein Konto zum Teilen. Zeige stattdessen hier einen Code.
|
||||
[return_to_apps]
|
||||
Zurück zu Apps
|
||||
---
|
||||
|
||||
[diary_undo]
|
||||
Rückgängig
|
||||
---
|
||||
|
||||
[diary_redo]
|
||||
Wiederholen
|
||||
---
|
||||
|
||||
[diary_check_spelling]
|
||||
Rechtschreibung korrigieren
|
||||
---
|
||||
|
||||
[diary_spelling_none]
|
||||
Keine Rechtschreibfehler gefunden.
|
||||
---
|
||||
|
||||
[diary_spelling_error]
|
||||
Die Rechtschreibung kann gerade nicht geprüft werden. Versuche es später noch einmal.
|
||||
---
|
||||
|
||||
[diary_spelling_limit]
|
||||
Dein Online-Kontingent für heute ist aufgebraucht. Versuche es morgen noch einmal.
|
||||
---
|
||||
|
||||
[diary_spelling_account]
|
||||
Melde dich bei einem Konto an, um die Rechtschreibung zu korrigieren.
|
||||
---
|
||||
|
||||
[diary_spelling_too_long]
|
||||
Dieser Eintrag ist zu lang, um ihn auf einmal zu prüfen.
|
||||
---
|
||||
|
||||
[lumi_selected_count]
|
||||
%d ausgewählt
|
||||
---
|
||||
|
||||
[lumi_copy]
|
||||
Kopieren
|
||||
---
|
||||
|
||||
[lumi_cancel_selection]
|
||||
Auswahl aufheben
|
||||
---
|
||||
|
||||
[lumi_delete_confirm]
|
||||
Ausgewählte Nachrichten löschen?
|
||||
---
|
||||
|
||||
[lumi_message]
|
||||
Chatnachricht
|
||||
---
|
||||
+52
-4
@@ -2312,10 +2312,6 @@ You’ve used today’s online allowance. Local app commands still work.
|
||||
[lumi_developer_reply]
|
||||
Developer reply:
|
||||
|
||||
---
|
||||
[lumi_feedback_saved]
|
||||
Saved on this device, waiting to send to the developer inbox. Delivery needs an Inner Breeze account and internet access.
|
||||
|
||||
---
|
||||
[lumi_show_progress]
|
||||
Show progress
|
||||
@@ -2794,3 +2790,55 @@ This device has no account to share yet. Show a code here instead.
|
||||
[return_to_apps]
|
||||
Back to Apps
|
||||
---
|
||||
|
||||
[diary_undo]
|
||||
Undo
|
||||
---
|
||||
|
||||
[diary_redo]
|
||||
Redo
|
||||
---
|
||||
|
||||
[diary_check_spelling]
|
||||
Correct spelling
|
||||
---
|
||||
|
||||
[diary_spelling_none]
|
||||
No spelling mistakes found.
|
||||
---
|
||||
|
||||
[diary_spelling_error]
|
||||
Could not check spelling right now. Try again later.
|
||||
---
|
||||
|
||||
[diary_spelling_limit]
|
||||
You’ve used today’s online allowance. Try again tomorrow.
|
||||
---
|
||||
|
||||
[diary_spelling_account]
|
||||
Sign in to an account to correct spelling.
|
||||
---
|
||||
|
||||
[diary_spelling_too_long]
|
||||
This entry is too long to check at once.
|
||||
---
|
||||
|
||||
[lumi_selected_count]
|
||||
%d selected
|
||||
---
|
||||
|
||||
[lumi_copy]
|
||||
Copy
|
||||
---
|
||||
|
||||
[lumi_cancel_selection]
|
||||
Cancel selection
|
||||
---
|
||||
|
||||
[lumi_delete_confirm]
|
||||
Delete the selected messages?
|
||||
---
|
||||
|
||||
[lumi_message]
|
||||
Chat message
|
||||
---
|
||||
+52
-4
@@ -2313,10 +2313,6 @@ Has agotado tu cuota en línea de hoy. Los comandos locales de la app siguen fun
|
||||
[lumi_developer_reply]
|
||||
Respuesta del desarrollador:
|
||||
|
||||
---
|
||||
[lumi_feedback_saved]
|
||||
Guardado en este dispositivo, pendiente de envío al buzón del desarrollador. Se necesita una cuenta de Inner Breeze y acceso a internet.
|
||||
|
||||
---
|
||||
[lumi_show_progress]
|
||||
Mostrar progreso
|
||||
@@ -2795,3 +2791,55 @@ Este dispositivo aún no tiene una cuenta que compartir. Muestra un código aqu
|
||||
[return_to_apps]
|
||||
Volver a Aplicaciones
|
||||
---
|
||||
|
||||
[diary_undo]
|
||||
Deshacer
|
||||
---
|
||||
|
||||
[diary_redo]
|
||||
Rehacer
|
||||
---
|
||||
|
||||
[diary_check_spelling]
|
||||
Corregir ortografía
|
||||
---
|
||||
|
||||
[diary_spelling_none]
|
||||
No se encontraron errores de ortografía.
|
||||
---
|
||||
|
||||
[diary_spelling_error]
|
||||
No se pudo revisar la ortografía ahora. Inténtalo más tarde.
|
||||
---
|
||||
|
||||
[diary_spelling_limit]
|
||||
Has agotado tu cuota en línea de hoy. Inténtalo mañana.
|
||||
---
|
||||
|
||||
[diary_spelling_account]
|
||||
Inicia sesión en una cuenta para corregir la ortografía.
|
||||
---
|
||||
|
||||
[diary_spelling_too_long]
|
||||
Esta entrada es demasiado larga para revisarla de una vez.
|
||||
---
|
||||
|
||||
[lumi_selected_count]
|
||||
%d seleccionados
|
||||
---
|
||||
|
||||
[lumi_copy]
|
||||
Copiar
|
||||
---
|
||||
|
||||
[lumi_cancel_selection]
|
||||
Cancelar selección
|
||||
---
|
||||
|
||||
[lumi_delete_confirm]
|
||||
¿Eliminar los mensajes seleccionados?
|
||||
---
|
||||
|
||||
[lumi_message]
|
||||
Mensaje del chat
|
||||
---
|
||||
+52
-4
@@ -2313,10 +2313,6 @@ Vous avez utilisé votre quota en ligne du jour. Les commandes locales de l’ap
|
||||
[lumi_developer_reply]
|
||||
Réponse du développeur :
|
||||
|
||||
---
|
||||
[lumi_feedback_saved]
|
||||
Enregistré sur cet appareil, en attente d’envoi à la boîte du développeur. Un compte Inner Breeze et un accès à internet sont nécessaires.
|
||||
|
||||
---
|
||||
[lumi_show_progress]
|
||||
Afficher les progrès
|
||||
@@ -2795,3 +2791,55 @@ Cet appareil n'a pas encore de compte à partager. Affichez plutôt un code ici.
|
||||
[return_to_apps]
|
||||
Retour aux Applications
|
||||
---
|
||||
|
||||
[diary_undo]
|
||||
Annuler
|
||||
---
|
||||
|
||||
[diary_redo]
|
||||
Rétablir
|
||||
---
|
||||
|
||||
[diary_check_spelling]
|
||||
Corriger l’orthographe
|
||||
---
|
||||
|
||||
[diary_spelling_none]
|
||||
Aucune faute d’orthographe trouvée.
|
||||
---
|
||||
|
||||
[diary_spelling_error]
|
||||
Impossible de vérifier l’orthographe pour le moment. Réessayez plus tard.
|
||||
---
|
||||
|
||||
[diary_spelling_limit]
|
||||
Vous avez utilisé votre quota en ligne du jour. Réessayez demain.
|
||||
---
|
||||
|
||||
[diary_spelling_account]
|
||||
Connectez-vous à un compte pour corriger l’orthographe.
|
||||
---
|
||||
|
||||
[diary_spelling_too_long]
|
||||
Cette entrée est trop longue pour être vérifiée en une fois.
|
||||
---
|
||||
|
||||
[lumi_selected_count]
|
||||
%d sélectionnés
|
||||
---
|
||||
|
||||
[lumi_copy]
|
||||
Copier
|
||||
---
|
||||
|
||||
[lumi_cancel_selection]
|
||||
Annuler la sélection
|
||||
---
|
||||
|
||||
[lumi_delete_confirm]
|
||||
Supprimer les messages sélectionnés ?
|
||||
---
|
||||
|
||||
[lumi_message]
|
||||
Message du chat
|
||||
---
|
||||
+52
-4
@@ -2313,10 +2313,6 @@ Kuota daring hari ini sudah habis. Perintah lokal aplikasi tetap berfungsi.
|
||||
[lumi_developer_reply]
|
||||
Balasan pengembang:
|
||||
|
||||
---
|
||||
[lumi_feedback_saved]
|
||||
Tersimpan di perangkat ini dan menunggu dikirim ke kotak masuk pengembang. Pengiriman memerlukan akun Inner Breeze dan akses internet.
|
||||
|
||||
---
|
||||
[lumi_show_progress]
|
||||
Tampilkan kemajuan
|
||||
@@ -2795,3 +2791,55 @@ Perangkat ini belum punya akun untuk dibagikan. Tampilkan kode di sini.
|
||||
[return_to_apps]
|
||||
Kembali ke Aplikasi
|
||||
---
|
||||
|
||||
[diary_undo]
|
||||
Urungkan
|
||||
---
|
||||
|
||||
[diary_redo]
|
||||
Ulangi
|
||||
---
|
||||
|
||||
[diary_check_spelling]
|
||||
Perbaiki ejaan
|
||||
---
|
||||
|
||||
[diary_spelling_none]
|
||||
Tidak ada kesalahan ejaan.
|
||||
---
|
||||
|
||||
[diary_spelling_error]
|
||||
Ejaan tidak dapat diperiksa sekarang. Coba lagi nanti.
|
||||
---
|
||||
|
||||
[diary_spelling_limit]
|
||||
Kuota daring hari ini sudah habis. Coba lagi besok.
|
||||
---
|
||||
|
||||
[diary_spelling_account]
|
||||
Masuk ke akun untuk memperbaiki ejaan.
|
||||
---
|
||||
|
||||
[diary_spelling_too_long]
|
||||
Catatan ini terlalu panjang untuk diperiksa sekaligus.
|
||||
---
|
||||
|
||||
[lumi_selected_count]
|
||||
%d dipilih
|
||||
---
|
||||
|
||||
[lumi_copy]
|
||||
Salin
|
||||
---
|
||||
|
||||
[lumi_cancel_selection]
|
||||
Batalkan pilihan
|
||||
---
|
||||
|
||||
[lumi_delete_confirm]
|
||||
Hapus pesan yang dipilih?
|
||||
---
|
||||
|
||||
[lumi_message]
|
||||
Pesan obrolan
|
||||
---
|
||||
+52
-4
@@ -2313,10 +2313,6 @@ Hai esaurito la quota online di oggi. I comandi locali dell’app funzionano anc
|
||||
[lumi_developer_reply]
|
||||
Risposta dello sviluppatore:
|
||||
|
||||
---
|
||||
[lumi_feedback_saved]
|
||||
Salvato su questo dispositivo, in attesa di invio alla casella dello sviluppatore. Servono un account Inner Breeze e una connessione internet.
|
||||
|
||||
---
|
||||
[lumi_show_progress]
|
||||
Mostra progressi
|
||||
@@ -2795,3 +2791,55 @@ Questo dispositivo non ha ancora un account da condividere. Mostra un codice qui
|
||||
[return_to_apps]
|
||||
Torna alle App
|
||||
---
|
||||
|
||||
[diary_undo]
|
||||
Annulla
|
||||
---
|
||||
|
||||
[diary_redo]
|
||||
Ripeti
|
||||
---
|
||||
|
||||
[diary_check_spelling]
|
||||
Correggi l’ortografia
|
||||
---
|
||||
|
||||
[diary_spelling_none]
|
||||
Nessun errore di ortografia trovato.
|
||||
---
|
||||
|
||||
[diary_spelling_error]
|
||||
Impossibile controllare l’ortografia ora. Riprova più tardi.
|
||||
---
|
||||
|
||||
[diary_spelling_limit]
|
||||
Hai esaurito la quota online di oggi. Riprova domani.
|
||||
---
|
||||
|
||||
[diary_spelling_account]
|
||||
Accedi a un account per correggere l’ortografia.
|
||||
---
|
||||
|
||||
[diary_spelling_too_long]
|
||||
Questa voce è troppo lunga per essere controllata in una volta.
|
||||
---
|
||||
|
||||
[lumi_selected_count]
|
||||
%d selezionati
|
||||
---
|
||||
|
||||
[lumi_copy]
|
||||
Copia
|
||||
---
|
||||
|
||||
[lumi_cancel_selection]
|
||||
Annulla selezione
|
||||
---
|
||||
|
||||
[lumi_delete_confirm]
|
||||
Eliminare i messaggi selezionati?
|
||||
---
|
||||
|
||||
[lumi_message]
|
||||
Messaggio della chat
|
||||
---
|
||||
+52
-4
@@ -2315,10 +2315,6 @@ WHMを開始
|
||||
[lumi_developer_reply]
|
||||
開発者からの返信:
|
||||
|
||||
---
|
||||
[lumi_feedback_saved]
|
||||
この端末に保存され、開発者の受信箱への送信を待っています。送信には Inner Breeze アカウントとインターネット接続が必要です。
|
||||
|
||||
---
|
||||
[lumi_show_progress]
|
||||
進捗を表示
|
||||
@@ -2797,3 +2793,55 @@ Inner Breezeの接続コードではありません。
|
||||
[return_to_apps]
|
||||
アプリに戻る
|
||||
---
|
||||
|
||||
[diary_undo]
|
||||
元に戻す
|
||||
---
|
||||
|
||||
[diary_redo]
|
||||
やり直す
|
||||
---
|
||||
|
||||
[diary_check_spelling]
|
||||
スペルを修正
|
||||
---
|
||||
|
||||
[diary_spelling_none]
|
||||
スペルの間違いは見つかりませんでした。
|
||||
---
|
||||
|
||||
[diary_spelling_error]
|
||||
今はスペルを確認できません。後でもう一度お試しください。
|
||||
---
|
||||
|
||||
[diary_spelling_limit]
|
||||
本日のオンライン利用枠を使い切りました。明日もう一度お試しください。
|
||||
---
|
||||
|
||||
[diary_spelling_account]
|
||||
スペルを修正するにはアカウントにサインインしてください。
|
||||
---
|
||||
|
||||
[diary_spelling_too_long]
|
||||
この日記は長すぎるため、一度に確認できません。
|
||||
---
|
||||
|
||||
[lumi_selected_count]
|
||||
%d件選択
|
||||
---
|
||||
|
||||
[lumi_copy]
|
||||
コピー
|
||||
---
|
||||
|
||||
[lumi_cancel_selection]
|
||||
選択を解除
|
||||
---
|
||||
|
||||
[lumi_delete_confirm]
|
||||
選択したメッセージを削除しますか?
|
||||
---
|
||||
|
||||
[lumi_message]
|
||||
チャットのメッセージ
|
||||
---
|
||||
+52
-4
@@ -2313,10 +2313,6 @@ WHM 시작
|
||||
[lumi_developer_reply]
|
||||
개발자 답변:
|
||||
|
||||
---
|
||||
[lumi_feedback_saved]
|
||||
이 기기에 저장되었으며 개발자 수신함으로 전송을 기다리고 있어요. 전송하려면 Inner Breeze 계정과 인터넷 연결이 필요해요.
|
||||
|
||||
---
|
||||
[lumi_show_progress]
|
||||
진행 상황 보기
|
||||
@@ -2795,3 +2791,55 @@ Inner Breeze 연결 코드가 아닙니다.
|
||||
[return_to_apps]
|
||||
앱으로 돌아가기
|
||||
---
|
||||
|
||||
[diary_undo]
|
||||
실행 취소
|
||||
---
|
||||
|
||||
[diary_redo]
|
||||
다시 실행
|
||||
---
|
||||
|
||||
[diary_check_spelling]
|
||||
맞춤법 고치기
|
||||
---
|
||||
|
||||
[diary_spelling_none]
|
||||
맞춤법 오류를 찾지 못했어요.
|
||||
---
|
||||
|
||||
[diary_spelling_error]
|
||||
지금은 맞춤법을 확인할 수 없어요. 나중에 다시 시도해 주세요.
|
||||
---
|
||||
|
||||
[diary_spelling_limit]
|
||||
오늘의 온라인 사용 한도를 모두 사용했어요. 내일 다시 시도해 주세요.
|
||||
---
|
||||
|
||||
[diary_spelling_account]
|
||||
맞춤법을 고치려면 계정에 로그인하세요.
|
||||
---
|
||||
|
||||
[diary_spelling_too_long]
|
||||
이 일기는 너무 길어서 한 번에 확인할 수 없어요.
|
||||
---
|
||||
|
||||
[lumi_selected_count]
|
||||
%d개 선택됨
|
||||
---
|
||||
|
||||
[lumi_copy]
|
||||
복사
|
||||
---
|
||||
|
||||
[lumi_cancel_selection]
|
||||
선택 취소
|
||||
---
|
||||
|
||||
[lumi_delete_confirm]
|
||||
선택한 메시지를 삭제할까요?
|
||||
---
|
||||
|
||||
[lumi_message]
|
||||
채팅 메시지
|
||||
---
|
||||
+52
-4
@@ -2313,10 +2313,6 @@ Você usou sua cota on-line de hoje. Os comandos locais do aplicativo continuam
|
||||
[lumi_developer_reply]
|
||||
Resposta do desenvolvedor:
|
||||
|
||||
---
|
||||
[lumi_feedback_saved]
|
||||
Guardado neste dispositivo, à espera de envio para a caixa de entrada do programador. É necessária uma conta Inner Breeze e acesso à internet.
|
||||
|
||||
---
|
||||
[lumi_show_progress]
|
||||
Mostrar progresso
|
||||
@@ -2795,3 +2791,55 @@ Este dispositivo ainda não tem uma conta para compartilhar. Mostre um código a
|
||||
[return_to_apps]
|
||||
Voltar para Aplicativos
|
||||
---
|
||||
|
||||
[diary_undo]
|
||||
Desfazer
|
||||
---
|
||||
|
||||
[diary_redo]
|
||||
Refazer
|
||||
---
|
||||
|
||||
[diary_check_spelling]
|
||||
Corrigir ortografia
|
||||
---
|
||||
|
||||
[diary_spelling_none]
|
||||
Nenhum erro de ortografia encontrado.
|
||||
---
|
||||
|
||||
[diary_spelling_error]
|
||||
Não foi possível verificar a ortografia agora. Tente novamente mais tarde.
|
||||
---
|
||||
|
||||
[diary_spelling_limit]
|
||||
Você usou sua cota on-line de hoje. Tente novamente amanhã.
|
||||
---
|
||||
|
||||
[diary_spelling_account]
|
||||
Entre em uma conta para corrigir a ortografia.
|
||||
---
|
||||
|
||||
[diary_spelling_too_long]
|
||||
Esta entrada é longa demais para ser verificada de uma vez.
|
||||
---
|
||||
|
||||
[lumi_selected_count]
|
||||
%d selecionadas
|
||||
---
|
||||
|
||||
[lumi_copy]
|
||||
Copiar
|
||||
---
|
||||
|
||||
[lumi_cancel_selection]
|
||||
Cancelar seleção
|
||||
---
|
||||
|
||||
[lumi_delete_confirm]
|
||||
Excluir as mensagens selecionadas?
|
||||
---
|
||||
|
||||
[lumi_message]
|
||||
Mensagem do chat
|
||||
---
|
||||
+52
-4
@@ -2313,10 +2313,6 @@ Inner Breeze бесплатное приложение с открытым ис
|
||||
[lumi_developer_reply]
|
||||
Ответ разработчика:
|
||||
|
||||
---
|
||||
[lumi_feedback_saved]
|
||||
Сохранено на этом устройстве и ожидает отправки в почтовый ящик разработчика. Для доставки нужны аккаунт Inner Breeze и доступ к интернету.
|
||||
|
||||
---
|
||||
[lumi_show_progress]
|
||||
Показать прогресс
|
||||
@@ -2795,3 +2791,55 @@ Inner Breeze бесплатное приложение с открытым ис
|
||||
[return_to_apps]
|
||||
Назад к приложениям
|
||||
---
|
||||
|
||||
[diary_undo]
|
||||
Отменить
|
||||
---
|
||||
|
||||
[diary_redo]
|
||||
Повторить
|
||||
---
|
||||
|
||||
[diary_check_spelling]
|
||||
Исправить орфографию
|
||||
---
|
||||
|
||||
[diary_spelling_none]
|
||||
Орфографических ошибок не найдено.
|
||||
---
|
||||
|
||||
[diary_spelling_error]
|
||||
Сейчас не удаётся проверить орфографию. Попробуйте позже.
|
||||
---
|
||||
|
||||
[diary_spelling_limit]
|
||||
Лимит онлайн-запросов на сегодня исчерпан. Попробуйте завтра.
|
||||
---
|
||||
|
||||
[diary_spelling_account]
|
||||
Войдите в аккаунт, чтобы исправлять орфографию.
|
||||
---
|
||||
|
||||
[diary_spelling_too_long]
|
||||
Эта запись слишком длинная, чтобы проверить её за один раз.
|
||||
---
|
||||
|
||||
[lumi_selected_count]
|
||||
Выбрано: %d
|
||||
---
|
||||
|
||||
[lumi_copy]
|
||||
Копировать
|
||||
---
|
||||
|
||||
[lumi_cancel_selection]
|
||||
Отменить выбор
|
||||
---
|
||||
|
||||
[lumi_delete_confirm]
|
||||
Удалить выбранные сообщения?
|
||||
---
|
||||
|
||||
[lumi_message]
|
||||
Сообщение в чате
|
||||
---
|
||||
+52
-4
@@ -2313,10 +2313,6 @@ Inner Breeze 免费且开源。如果它对您有帮助,一点小额捐赠将
|
||||
[lumi_developer_reply]
|
||||
开发者回复:
|
||||
|
||||
---
|
||||
[lumi_feedback_saved]
|
||||
已保存在此设备上,等待发送到开发者收件箱。发送需要 Inner Breeze 账户和互联网连接。
|
||||
|
||||
---
|
||||
[lumi_show_progress]
|
||||
显示进度
|
||||
@@ -2795,3 +2791,55 @@ Daochi 节点
|
||||
[return_to_apps]
|
||||
返回应用
|
||||
---
|
||||
|
||||
[diary_undo]
|
||||
撤销
|
||||
---
|
||||
|
||||
[diary_redo]
|
||||
重做
|
||||
---
|
||||
|
||||
[diary_check_spelling]
|
||||
纠正拼写
|
||||
---
|
||||
|
||||
[diary_spelling_none]
|
||||
未发现拼写错误。
|
||||
---
|
||||
|
||||
[diary_spelling_error]
|
||||
现在无法检查拼写,请稍后再试。
|
||||
---
|
||||
|
||||
[diary_spelling_limit]
|
||||
今天的在线使用额度已用完,请明天再试。
|
||||
---
|
||||
|
||||
[diary_spelling_account]
|
||||
登录账户后即可纠正拼写。
|
||||
---
|
||||
|
||||
[diary_spelling_too_long]
|
||||
这篇日记太长,无法一次检查。
|
||||
---
|
||||
|
||||
[lumi_selected_count]
|
||||
已选择 %d 条
|
||||
---
|
||||
|
||||
[lumi_copy]
|
||||
复制
|
||||
---
|
||||
|
||||
[lumi_cancel_selection]
|
||||
取消选择
|
||||
---
|
||||
|
||||
[lumi_delete_confirm]
|
||||
删除所选消息?
|
||||
---
|
||||
|
||||
[lumi_message]
|
||||
聊天消息
|
||||
---
|
||||
@@ -1,5 +1,5 @@
|
||||
Package: inbe.waozi
|
||||
Version: 2.1.28
|
||||
Version: 2.1.31
|
||||
Architecture: arm64
|
||||
Maintainer: Waozi <[email protected]>
|
||||
Click-Version: 0.4
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<binary>inbe</binary>
|
||||
</provides>
|
||||
<releases>
|
||||
<release version="2.1.28" date="2026-10-10"/>
|
||||
<release version="2.1.31" date="2026-10-11"/>
|
||||
</releases>
|
||||
<content_rating type="oars-1.1"/>
|
||||
</component>
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "inbe",
|
||||
"title": "Inner Breeze",
|
||||
"version": "2.1.28",
|
||||
"version": "2.1.31",
|
||||
"architecture": "arm64",
|
||||
"framework": "ubuntu-sdk-20.04",
|
||||
"description": "Syncable breathing, meditation, and habit practice app.",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"manifest_version": 3,
|
||||
"name": "Inner Breeze",
|
||||
"short_name": "Inbe",
|
||||
"version": "2.1.28",
|
||||
"version": "2.1.31",
|
||||
"description": "Breathing, meditation, habit tracking, and encrypted sync.",
|
||||
"permissions": [
|
||||
"contextMenus"
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<binary>inbe</binary>
|
||||
</provides>
|
||||
<releases>
|
||||
<release version="2.1.28" date="2026-10-10"/>
|
||||
<release version="2.1.31" date="2026-10-11"/>
|
||||
</releases>
|
||||
<content_rating type="oars-1.1"/>
|
||||
</component>
|
||||
@@ -22,7 +22,7 @@
|
||||
<binary>inbe</binary>
|
||||
</provides>
|
||||
<releases>
|
||||
<release version="2.1.28" date="2026-10-10"/>
|
||||
<release version="2.1.31" date="2026-10-11"/>
|
||||
</releases>
|
||||
<content_rating type="oars-1.1"/>
|
||||
</component>
|
||||
@@ -6,7 +6,7 @@ description: |
|
||||
meditation, and habit tracking with visual and audio cues, meditation
|
||||
timers, habit counters, session history, and optional sync.
|
||||
|
||||
version: '2.1.28'
|
||||
version: '2.1.31'
|
||||
license: BSD-3-Clause
|
||||
base: core22
|
||||
confinement: strict
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"schema": 1,
|
||||
"version": "2.1.29",
|
||||
"source_commit": "736882b1bdaae8100c89d6e069301013068ec106",
|
||||
"apk": {
|
||||
"sha256": "e31560818d9808b9e5792a03a1bd35173ede2eea293cfdd58be40bc04d3a618c",
|
||||
"package": "xyz.waozi.inbe.debug",
|
||||
"version_code": 166,
|
||||
"version_name": "2.1.29"
|
||||
},
|
||||
"device": {
|
||||
"model": "moto e6 play",
|
||||
"android": "9"
|
||||
},
|
||||
"practice": {
|
||||
"name": "Wim Hof",
|
||||
"seconds": 59.91,
|
||||
"frames": 3460,
|
||||
"refresh_hz": 58.2,
|
||||
"fps": 57.7,
|
||||
"late_percent": 0.0,
|
||||
"p95_frame_ms": 17.4,
|
||||
"worst_frame_ms": 17.6,
|
||||
"resume_layout_shift": 11.4
|
||||
},
|
||||
"limits": {
|
||||
"minimum_refresh_share": 0.94,
|
||||
"maximum_late_percent": 3.0,
|
||||
"maximum_frame_ms": 250.0
|
||||
},
|
||||
"checks": [
|
||||
"installed over the existing app",
|
||||
"launch",
|
||||
"Wim Hof frame timing",
|
||||
"background and resume"
|
||||
],
|
||||
"passed": true,
|
||||
"checked_at": "2026-10-11T16:59:26+00:00"
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"schema": 1,
|
||||
"version": "2.1.30",
|
||||
"source_commit": "d0993d71ad22f3de8ed440b2d4aaf39167763ce0",
|
||||
"apk": {
|
||||
"sha256": "42c55b0ae80abe1969486af4203a44d0aea76e0607de7691bc2107cc3e82391e",
|
||||
"package": "xyz.waozi.inbe.debug",
|
||||
"version_code": 167,
|
||||
"version_name": "2.1.30"
|
||||
},
|
||||
"device": {
|
||||
"model": "moto e6 play",
|
||||
"android": "9"
|
||||
},
|
||||
"practice": {
|
||||
"name": "Wim Hof",
|
||||
"seconds": 59.4,
|
||||
"frames": 3431,
|
||||
"refresh_hz": 58.2,
|
||||
"fps": 57.7,
|
||||
"late_percent": 0.0,
|
||||
"p95_frame_ms": 17.4,
|
||||
"worst_frame_ms": 17.6,
|
||||
"resume_layout_shift": 11.4
|
||||
},
|
||||
"limits": {
|
||||
"minimum_refresh_share": 0.94,
|
||||
"maximum_late_percent": 3.0,
|
||||
"maximum_frame_ms": 250.0
|
||||
},
|
||||
"checks": [
|
||||
"installed over the existing app",
|
||||
"launch",
|
||||
"Wim Hof frame timing",
|
||||
"background and resume"
|
||||
],
|
||||
"passed": true,
|
||||
"checked_at": "2026-10-11T19:19:25+00:00"
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"schema": 1,
|
||||
"version": "2.1.31",
|
||||
"source_commit": "1eb5fd3de2436f0d2de38fd6efc84d9a0c42529a",
|
||||
"apk": {
|
||||
"sha256": "1616377bd74fae075e2c68b4b12d5caefdee106872e648a33d7db37f0dc79518",
|
||||
"package": "xyz.waozi.inbe.debug",
|
||||
"version_code": 168,
|
||||
"version_name": "2.1.31"
|
||||
},
|
||||
"device": {
|
||||
"model": "moto e6 play",
|
||||
"android": "9"
|
||||
},
|
||||
"practice": {
|
||||
"name": "Wim Hof",
|
||||
"seconds": 59.68,
|
||||
"frames": 3447,
|
||||
"refresh_hz": 58.2,
|
||||
"fps": 57.7,
|
||||
"late_percent": 0.0,
|
||||
"p95_frame_ms": 17.4,
|
||||
"worst_frame_ms": 17.6,
|
||||
"resume_layout_shift": 1.2
|
||||
},
|
||||
"limits": {
|
||||
"minimum_refresh_share": 0.94,
|
||||
"maximum_late_percent": 3.0,
|
||||
"maximum_frame_ms": 250.0,
|
||||
"maximum_resume_layout_shift": 2.0
|
||||
},
|
||||
"checks": [
|
||||
"installed over the existing app",
|
||||
"launch",
|
||||
"Wim Hof frame timing",
|
||||
"background and resume"
|
||||
],
|
||||
"passed": true,
|
||||
"checked_at": "2026-10-11T23:12:02+00:00"
|
||||
}
|
||||
@@ -1,402 +0,0 @@
|
||||
// Raw, bounded browser network effects. Daochi protocol and app state stay in Zi.
|
||||
addToLibrary({
|
||||
$BrowserNetwork: {
|
||||
next: 1,
|
||||
http: null,
|
||||
sockets: null,
|
||||
streams: null,
|
||||
decoder: null,
|
||||
encoder: null,
|
||||
initialize() {
|
||||
if (!this.http) {
|
||||
this.http = new Map();
|
||||
this.sockets = new Map();
|
||||
this.streams = new Map();
|
||||
this.decoder = new TextDecoder('utf-8', { fatal: true });
|
||||
this.encoder = new TextEncoder();
|
||||
}
|
||||
},
|
||||
bytes(pointer, length) {
|
||||
if (!Number.isInteger(pointer) || !Number.isInteger(length) ||
|
||||
pointer < 0 || length < 0 || pointer + length > HEAPU8.length) {
|
||||
throw new Error('invalid network buffer');
|
||||
}
|
||||
return HEAPU8.subarray(pointer, pointer + length);
|
||||
},
|
||||
text(pointer, length) {
|
||||
return this.decoder.decode(this.bytes(pointer, length));
|
||||
},
|
||||
id() {
|
||||
if (this.next >= 2147483647) {
|
||||
this.next = 1;
|
||||
}
|
||||
while (this.http.has(this.next) || this.sockets.has(this.next) || this.streams.has(this.next)) {
|
||||
this.next += 1;
|
||||
}
|
||||
return this.next++;
|
||||
},
|
||||
failStream(id, task) {
|
||||
if (this.streams.get(id) !== task) return;
|
||||
task.failed = true;
|
||||
task.chunk = null;
|
||||
clearTimeout(task.timer);
|
||||
task.controller.abort();
|
||||
if (task.reader) task.reader.cancel().catch(() => {});
|
||||
},
|
||||
readStream(id, task) {
|
||||
if (this.streams.get(id) !== task || task.reading || task.done || task.failed) return;
|
||||
task.reading = true;
|
||||
task.reader.read().then(chunk => {
|
||||
task.reading = false;
|
||||
if (this.streams.get(id) !== task || task.failed) return;
|
||||
if (chunk.done) {
|
||||
task.done = true;
|
||||
clearTimeout(task.timer);
|
||||
return;
|
||||
}
|
||||
if ((!ArrayBuffer.isView(chunk.value) || chunk.value.BYTES_PER_ELEMENT !== 1) || chunk.value.length > 1048576 ||
|
||||
chunk.value.length > task.maximum - task.received) {
|
||||
this.failStream(id, task);
|
||||
return;
|
||||
}
|
||||
if (chunk.value.length === 0) {
|
||||
this.readStream(id, task);
|
||||
return;
|
||||
}
|
||||
task.received += chunk.value.length;
|
||||
task.chunk = chunk.value;
|
||||
task.offset = 0;
|
||||
}).catch(() => this.failStream(id, task));
|
||||
},
|
||||
finish(id, task, success, status) {
|
||||
if (this.http.get(id) !== task) {
|
||||
return;
|
||||
}
|
||||
clearTimeout(task.timer);
|
||||
task.done = true;
|
||||
task.success = success;
|
||||
task.status = status;
|
||||
if (!success) {
|
||||
HEAPU8[task.output] = 0;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
browser_http_create__deps: ['$BrowserNetwork'],
|
||||
browser_http_create: (methodPointer, methodLength, urlPointer, urlLength,
|
||||
output, capacity, timeout) => {
|
||||
BrowserNetwork.initialize();
|
||||
try {
|
||||
if (methodLength < 1 || methodLength > 31 || urlLength < 1 ||
|
||||
urlLength >= 2048 || capacity < 1 || capacity > 16777216 ||
|
||||
timeout < 1 || timeout > 900000 || BrowserNetwork.http.size >= 8) {
|
||||
return 0;
|
||||
}
|
||||
const method = BrowserNetwork.text(methodPointer, methodLength);
|
||||
const url = new URL(BrowserNetwork.text(urlPointer, urlLength));
|
||||
if (!/^[A-Za-z-]+$/.test(method) ||
|
||||
!['http:', 'https:'].includes(url.protocol) || url.username || url.password) {
|
||||
return 0;
|
||||
}
|
||||
BrowserNetwork.bytes(output, capacity);
|
||||
HEAPU8[output] = 0;
|
||||
const id = BrowserNetwork.id();
|
||||
BrowserNetwork.http.set(id, {
|
||||
method, url: url.href, output, capacity, timeout,
|
||||
headers: new Headers(), controller: new AbortController(),
|
||||
sent: false, done: false, success: false, status: 0, timer: null
|
||||
});
|
||||
return id;
|
||||
} catch (_) {
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
|
||||
browser_http_header__deps: ['$BrowserNetwork'],
|
||||
browser_http_header: (id, namePointer, nameLength, valuePointer, valueLength) => {
|
||||
BrowserNetwork.initialize();
|
||||
const task = BrowserNetwork.http.get(id);
|
||||
if (!task || task.sent || nameLength < 1 || nameLength > 128 || valueLength > 8192) {
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
task.headers.append(BrowserNetwork.text(namePointer, nameLength),
|
||||
BrowserNetwork.text(valuePointer, valueLength));
|
||||
return 1;
|
||||
} catch (_) {
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
|
||||
browser_http_send__deps: ['$BrowserNetwork'],
|
||||
browser_http_send: (id, bodyPointer, bodyLength) => {
|
||||
BrowserNetwork.initialize();
|
||||
const task = BrowserNetwork.http.get(id);
|
||||
if (!task || task.sent || bodyLength > 16777216) {
|
||||
return 0;
|
||||
}
|
||||
let body;
|
||||
try {
|
||||
if (bodyLength > 0) {
|
||||
body = BrowserNetwork.bytes(bodyPointer, bodyLength).slice();
|
||||
}
|
||||
} catch (_) {
|
||||
return 0;
|
||||
}
|
||||
task.sent = true;
|
||||
task.timer = setTimeout(() => {
|
||||
task.controller.abort();
|
||||
BrowserNetwork.finish(id, task, false, 0);
|
||||
}, task.timeout);
|
||||
(async () => {
|
||||
let reader;
|
||||
try {
|
||||
const response = await fetch(task.url, {
|
||||
method: task.method, headers: task.headers, body,
|
||||
redirect: 'error', credentials: 'omit', cache: 'no-store',
|
||||
signal: task.controller.signal
|
||||
});
|
||||
if (BrowserNetwork.http.get(id) !== task || task.done) {
|
||||
return;
|
||||
}
|
||||
const declaredLength = Number(response.headers.get('content-length'));
|
||||
if (declaredLength >= task.capacity) {
|
||||
throw new Error('response capacity exceeded');
|
||||
}
|
||||
let length = 0;
|
||||
if (response.body) {
|
||||
reader = response.body.getReader();
|
||||
for (;;) {
|
||||
const chunk = await reader.read();
|
||||
if (BrowserNetwork.http.get(id) !== task || task.done) {
|
||||
await reader.cancel();
|
||||
return;
|
||||
}
|
||||
if (chunk.done) {
|
||||
break;
|
||||
}
|
||||
if (chunk.value.length > task.capacity - length - 1) {
|
||||
throw new Error('response capacity exceeded');
|
||||
}
|
||||
HEAPU8.set(chunk.value, task.output + length);
|
||||
length += chunk.value.length;
|
||||
}
|
||||
}
|
||||
HEAPU8[task.output + length] = 0;
|
||||
BrowserNetwork.finish(id, task, true, response.status);
|
||||
} catch (_) {
|
||||
task.controller.abort();
|
||||
if (reader) {
|
||||
try {
|
||||
await reader.cancel();
|
||||
} catch (_) {
|
||||
// Cancellation has already invalidated the transfer.
|
||||
}
|
||||
}
|
||||
BrowserNetwork.finish(id, task, false, 0);
|
||||
}
|
||||
})();
|
||||
return 1;
|
||||
},
|
||||
|
||||
browser_http_poll__deps: ['$BrowserNetwork'],
|
||||
browser_http_poll: (id, statusPointer) => {
|
||||
BrowserNetwork.initialize();
|
||||
const task = BrowserNetwork.http.get(id);
|
||||
if (!task || !task.sent) {
|
||||
return 0;
|
||||
}
|
||||
if (!task.done) {
|
||||
return -1;
|
||||
}
|
||||
BrowserNetwork.http.delete(id);
|
||||
HEAP32[statusPointer >> 2] = task.status;
|
||||
return task.success ? 1 : 0;
|
||||
},
|
||||
|
||||
browser_http_cancel__deps: ['$BrowserNetwork'],
|
||||
browser_http_cancel: id => {
|
||||
BrowserNetwork.initialize();
|
||||
const task = BrowserNetwork.http.get(id);
|
||||
if (!task) {
|
||||
return;
|
||||
}
|
||||
BrowserNetwork.http.delete(id);
|
||||
clearTimeout(task.timer);
|
||||
task.controller.abort();
|
||||
},
|
||||
|
||||
browser_stream_open__deps: ['$BrowserNetwork'],
|
||||
browser_stream_open: (urlPointer, urlLength, maximum, timeout) => {
|
||||
BrowserNetwork.initialize();
|
||||
try {
|
||||
if (urlLength < 1 || urlLength >= 4096 || maximum < 1 || maximum > 536870912 ||
|
||||
timeout < 1 || timeout > 900000 || BrowserNetwork.streams.size >= 4) return 0;
|
||||
const url = new URL(BrowserNetwork.text(urlPointer, urlLength));
|
||||
if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password) return 0;
|
||||
const id = BrowserNetwork.id();
|
||||
const task = { controller: new AbortController(), maximum, received: 0, total: 0,
|
||||
status: 0, reader: null, chunk: null, offset: 0, reading: false, done: false,
|
||||
failed: false, timer: null };
|
||||
BrowserNetwork.streams.set(id, task);
|
||||
task.timer = setTimeout(() => BrowserNetwork.failStream(id, task), timeout);
|
||||
fetch(url.href, { method: 'GET', redirect: 'follow', credentials: 'omit',
|
||||
signal: task.controller.signal }).then(response => {
|
||||
if (BrowserNetwork.streams.get(id) !== task || task.failed) {
|
||||
response.body?.cancel().catch(() => {});
|
||||
return;
|
||||
}
|
||||
task.status = response.status;
|
||||
const declared = Number(response.headers.get('content-length'));
|
||||
if (Number.isSafeInteger(declared) && declared > maximum) {
|
||||
BrowserNetwork.failStream(id, task);
|
||||
response.body?.cancel().catch(() => {});
|
||||
return;
|
||||
}
|
||||
if (Number.isSafeInteger(declared) && declared > 0) task.total = declared;
|
||||
if (!response.body) {
|
||||
task.done = true;
|
||||
clearTimeout(task.timer);
|
||||
return;
|
||||
}
|
||||
task.reader = response.body.getReader();
|
||||
BrowserNetwork.readStream(id, task);
|
||||
}).catch(() => BrowserNetwork.failStream(id, task));
|
||||
return id;
|
||||
} catch (_) {
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
|
||||
browser_stream_poll__deps: ['$BrowserNetwork'],
|
||||
browser_stream_poll: (id, output, capacity, countPointer, statusPointer, totalPointer) => {
|
||||
BrowserNetwork.initialize();
|
||||
const task = BrowserNetwork.streams.get(id);
|
||||
if (!task || capacity < 1 || capacity > 1048576) return 0;
|
||||
BrowserNetwork.bytes(output, capacity);
|
||||
HEAP32[countPointer >> 2] = 0;
|
||||
HEAP32[statusPointer >> 2] = task.status;
|
||||
HEAP32[totalPointer >> 2] = task.total;
|
||||
if (task.failed) return 0;
|
||||
if (task.chunk) {
|
||||
const length = Math.min(capacity, task.chunk.length - task.offset);
|
||||
HEAPU8.set(task.chunk.subarray(task.offset, task.offset + length), output);
|
||||
HEAP32[countPointer >> 2] = length;
|
||||
task.offset += length;
|
||||
if (task.offset === task.chunk.length) {
|
||||
task.chunk = null;
|
||||
task.offset = 0;
|
||||
BrowserNetwork.readStream(id, task);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return task.done ? 2 : -1;
|
||||
},
|
||||
|
||||
browser_stream_close__deps: ['$BrowserNetwork'],
|
||||
browser_stream_close: id => {
|
||||
BrowserNetwork.initialize();
|
||||
const task = BrowserNetwork.streams.get(id);
|
||||
if (!task) return;
|
||||
BrowserNetwork.streams.delete(id);
|
||||
clearTimeout(task.timer);
|
||||
task.controller.abort();
|
||||
if (task.reader) task.reader.cancel().catch(() => {});
|
||||
task.chunk = null;
|
||||
},
|
||||
|
||||
browser_ws_open__deps: ['$BrowserNetwork'],
|
||||
browser_ws_open: (urlPointer, urlLength, protocolPointer, protocolLength,
|
||||
authPointer, authLength, capacity) => {
|
||||
BrowserNetwork.initialize();
|
||||
try {
|
||||
if (urlLength < 1 || urlLength >= 2048 || protocolLength > 128 ||
|
||||
authLength > 8192 || capacity < 2 || capacity > 65536 ||
|
||||
BrowserNetwork.sockets.size >= 4) {
|
||||
return 0;
|
||||
}
|
||||
const url = new URL(BrowserNetwork.text(urlPointer, urlLength));
|
||||
if (!['ws:', 'wss:'].includes(url.protocol) || url.username || url.password) {
|
||||
return 0;
|
||||
}
|
||||
const protocols = [];
|
||||
if (protocolLength) {
|
||||
protocols.push(BrowserNetwork.text(protocolPointer, protocolLength));
|
||||
}
|
||||
if (authLength) {
|
||||
protocols.push(BrowserNetwork.text(authPointer, authLength));
|
||||
}
|
||||
const socket = new WebSocket(url.href, protocols);
|
||||
const id = BrowserNetwork.id();
|
||||
const task = { socket, queue: [], closed: false, capacity, timer: null };
|
||||
BrowserNetwork.sockets.set(id, task);
|
||||
const fail = code => {
|
||||
task.closed = true;
|
||||
clearTimeout(task.timer);
|
||||
socket.close(code);
|
||||
};
|
||||
task.timer = setTimeout(() => fail(1000), 10000);
|
||||
socket.onopen = () => clearTimeout(task.timer);
|
||||
socket.onerror = () => fail(1000);
|
||||
socket.onclose = () => {
|
||||
clearTimeout(task.timer);
|
||||
task.closed = true;
|
||||
};
|
||||
socket.onmessage = event => {
|
||||
if (BrowserNetwork.sockets.get(id) !== task || task.closed) {
|
||||
return;
|
||||
}
|
||||
if (typeof event.data !== 'string') {
|
||||
fail(1003);
|
||||
return;
|
||||
}
|
||||
const bytes = BrowserNetwork.encoder.encode(event.data);
|
||||
if (bytes.length >= capacity || task.queue.length >= 16) {
|
||||
fail(1009);
|
||||
return;
|
||||
}
|
||||
task.queue.push(bytes);
|
||||
};
|
||||
return id;
|
||||
} catch (_) {
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
|
||||
browser_ws_poll__deps: ['$BrowserNetwork'],
|
||||
browser_ws_poll: (id, output, capacity) => {
|
||||
BrowserNetwork.initialize();
|
||||
const task = BrowserNetwork.sockets.get(id);
|
||||
if (!task) {
|
||||
return 0;
|
||||
}
|
||||
if (task.closed) {
|
||||
BrowserNetwork.sockets.delete(id);
|
||||
return 0;
|
||||
}
|
||||
if (!task.queue.length) {
|
||||
return -1;
|
||||
}
|
||||
const bytes = task.queue.shift();
|
||||
if (bytes.length >= capacity) {
|
||||
task.socket.close(1009);
|
||||
BrowserNetwork.sockets.delete(id);
|
||||
return 0;
|
||||
}
|
||||
BrowserNetwork.bytes(output, capacity);
|
||||
HEAPU8.set(bytes, output);
|
||||
HEAPU8[output + bytes.length] = 0;
|
||||
return bytes.length;
|
||||
},
|
||||
|
||||
browser_ws_close__deps: ['$BrowserNetwork'],
|
||||
browser_ws_close: id => {
|
||||
BrowserNetwork.initialize();
|
||||
const task = BrowserNetwork.sockets.get(id);
|
||||
if (task) {
|
||||
BrowserNetwork.sockets.delete(id);
|
||||
clearTimeout(task.timer);
|
||||
task.socket.close(1000);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -15,9 +15,12 @@ VERSION = r"(?:0|[1-9][0-9]{0,8})\.(?:0|[1-9][0-9]{0,8})\.(?:0|[1-9][0-9]{0,8})"
|
||||
|
||||
def validate(root):
|
||||
ledger = json.loads((root / "apps/versions.json").read_text())
|
||||
for api in ("host_api", "module_api"):
|
||||
if type(ledger.get(api)) is not int or not 0 < ledger[api] <= 2147483647:
|
||||
for api in ("host_api", "oldest_host_api", "module_api"):
|
||||
if type(ledger.get(api)) is not int or not 0 < ledger[api] <= 65535:
|
||||
raise ValueError(f"invalid {api}")
|
||||
# The host runs packages from its oldest supported interface to its own.
|
||||
if ledger["oldest_host_api"] > ledger["host_api"]:
|
||||
raise ValueError("oldest_host_api is newer than host_api")
|
||||
if set(ledger["apps"]) != set(NAMES):
|
||||
raise ValueError("the ledger must contain the root and all six cells")
|
||||
for name, source in NAMES.items():
|
||||
@@ -31,6 +34,11 @@ def validate(root):
|
||||
raise ValueError(f"{name}: invalid release sequence")
|
||||
if component.get("bundled") is not True:
|
||||
raise ValueError(f"{name}: every cell must be bundled for offline use")
|
||||
# A package declares the oldest host interface it runs on, so apps
|
||||
# that keep an older host still receive it.
|
||||
host = component.get("host_api", ledger["host_api"])
|
||||
if type(host) is not int or not ledger["oldest_host_api"] <= host <= ledger["host_api"]:
|
||||
raise ValueError(f"{name}: host_api must be between oldest_host_api and host_api")
|
||||
changelog = root / "apps" / source / "CHANGELOG.md"
|
||||
headings = re.findall(r"^## \[([^\]]+)\] - ([^\n]+)$", changelog.read_text(), re.M)
|
||||
if not headings or not re.fullmatch(VERSION, headings[0][0]):
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Allow a new release only with a passing phone check of its exact sources.
|
||||
|
||||
scripts/phone-check.py --record writes releases/phone-checks/VERSION.json for
|
||||
the commit it checked. The released commit may differ from that commit only in
|
||||
paths that do not change the app, such as the receipt itself.
|
||||
"""
|
||||
import argparse
|
||||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
spec = importlib.util.spec_from_file_location("phone_check", ROOT / "scripts/phone-check.py")
|
||||
phone_check = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(phone_check)
|
||||
|
||||
|
||||
def git(root, *argv):
|
||||
return subprocess.run(["git", "-C", str(root), *argv], check=True, capture_output=True,
|
||||
text=True).stdout
|
||||
|
||||
|
||||
def changes_app(path):
|
||||
return any(path == source or path.startswith(source + "/") for source in phone_check.SOURCE_PATHS)
|
||||
|
||||
|
||||
def validate(root, version):
|
||||
path = root / "releases/phone-checks" / f"{version}.json"
|
||||
if not path.is_file():
|
||||
raise ValueError(f"{version} has no phone check; run scripts/phone-check.py --record on the "
|
||||
"development Moto and commit the receipt")
|
||||
receipt = json.loads(path.read_text())
|
||||
if receipt.get("schema") != 1 or receipt.get("version") != version:
|
||||
raise ValueError("the phone check is for a different version")
|
||||
if receipt.get("apk", {}).get("version_name") != version:
|
||||
raise ValueError("the checked APK has a different version")
|
||||
commit = receipt.get("source_commit", "")
|
||||
if not re.fullmatch(r"[0-9a-f]{40}", commit):
|
||||
raise ValueError("the phone check has no full source commit")
|
||||
timing = receipt.get("practice", {})
|
||||
if receipt.get("passed") is not True or not phone_check.smooth(timing) or timing.get("seconds", 0) < 55:
|
||||
raise ValueError(f"the phone check did not pass: {timing}")
|
||||
if not phone_check.resumed_in_place(timing):
|
||||
raise ValueError("the app came back from the background with a shifted layout: "
|
||||
f"{timing.get('resume_layout_shift')}")
|
||||
if subprocess.run(["git", "-C", str(root), "merge-base", "--is-ancestor", commit, "HEAD"],
|
||||
capture_output=True).returncode != 0:
|
||||
raise ValueError(f"the checked commit {commit} is not part of this release")
|
||||
changed = [name for name in git(root, "diff", "--name-only", commit, "HEAD").splitlines()
|
||||
if changes_app(name)]
|
||||
if changed:
|
||||
raise ValueError("the app changed after its phone check: " + ", ".join(changed[:10]))
|
||||
return receipt
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("version")
|
||||
parser.add_argument("--root", type=Path, default=ROOT)
|
||||
args = parser.parse_args()
|
||||
try:
|
||||
receipt = validate(args.root, args.version)
|
||||
except (OSError, ValueError, subprocess.CalledProcessError) as error:
|
||||
print(f"Phone check required: {error}", file=sys.stderr)
|
||||
return 1
|
||||
timing = receipt["practice"]
|
||||
print(f"{args.version} passed its phone check on {receipt['device']['model']}: {timing['fps']} fps, "
|
||||
f"{timing['late_percent']}% late frames")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -36,7 +36,7 @@ check_pattern '"/home/(breathing|inbe)"' \
|
||||
# its two type-name operations are allowed; paths in this file still fail.
|
||||
check_pattern '"BreathSession"' \
|
||||
'Directory names come from the storage layout.' \
|
||||
'^src/cells/value_codec\.zi:[0-9]+: (value\.type_name = ModuleTextData\("BreathSession"\)|if value\.kind != cast\(s32\)HostRecord \|\| TextFromCString\(value\.type_name\) != "BreathSession" \|\|)$'
|
||||
'^src/cells/value_codec\.zi:[0-9]+: (value\.type_name = HostTextData\("BreathSession"\)|if value\.kind != cast\(s32\)HostRecord \|\| TextFromCString\(value\.type_name\) != "BreathSession" \|\|)$'
|
||||
check_pattern '"(breathing|inbe)-sessions\.csv"|"breathing-web-export' \
|
||||
'Export artifact names come from the storage layout.'
|
||||
check_pattern '\bjoin_path2\b' \
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate src/cells/app_codec.zi with Kryon's widget codec generator.
|
||||
|
||||
Kryon encodes its own widget records in its widget_codec module. This adds
|
||||
the frames and rows Inner Breeze's apps exchange with their screens.
|
||||
Pass --check to verify the file is current."""
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
KRYON = ROOT / 'build/packages/kryon'
|
||||
KRYON_MODULES = ['session', 'geometry', 'drawing_props', 'text_props', 'image_props',
|
||||
'button_props', 'control_props', 'text_input', 'text_input_props',
|
||||
'scroll', 'scroll_props', 'semantic', 'text_align', 'checkbox_props',
|
||||
'toggle_props', 'tab_bar_props', 'box_props']
|
||||
APP_TYPES = ['diary_ui_types', 'inbe_ui_types', 'lists_ui_types', 'lumi_ui_types',
|
||||
'lumi_types', 'leaderboard_ui_types']
|
||||
ROOTS = ['DiaryUiFrame', 'InbeUiFrame', 'ListsUiFrame', 'ListsUiRow', 'LumiUiFrame',
|
||||
'LumiChatRow', 'LumiTask', 'LumiAction', 'LumiTools', 'LumiDonation',
|
||||
'LeaderboardUiFrame', 'LeaderboardUiRow']
|
||||
|
||||
command = [sys.executable, str(KRYON / 'scripts/generate-widget-codecs.py'),
|
||||
'--output', str(ROOT / 'src/cells/app_codec.zi'),
|
||||
'--uses', str(KRYON / 'src/backend/widget_codec.zi'),
|
||||
'--generated-by', 'scripts/generate-app-codec.py']
|
||||
for module in KRYON_MODULES:
|
||||
command += ['--source', str(KRYON / 'src/ui' / (module + '.zi'))]
|
||||
for name in APP_TYPES:
|
||||
command += ['--source', str(ROOT / 'src/cells' / (name + '.zi'))]
|
||||
for root in ROOTS:
|
||||
command += ['--root', root]
|
||||
for line in ['"std/bundle_host"', '"std/byte_text_linux"', '"hosted_values"', '"widget_codec"',
|
||||
*(f', file "{name}.zi";' for name in APP_TYPES), *(f'"{module}"' for module in KRYON_MODULES)]:
|
||||
command += ['--import', line]
|
||||
command += sys.argv[1:]
|
||||
sys.exit(subprocess.run(command).returncode)
|
||||
@@ -55,6 +55,7 @@ lines = [
|
||||
],
|
||||
'#import "bundle_host"',
|
||||
'#import "byte_text_linux"',
|
||||
'#import "hosted_values"',
|
||||
'#import "drawing_props"',
|
||||
'#import, file "../core/types.zi";',
|
||||
'#import, file "../practices/patterns/patterns_types.zi";',
|
||||
@@ -139,13 +140,13 @@ for t in needed:
|
||||
f" {row}.elements = *codec.{n}_elements[i][0]",
|
||||
" j: s32 = 0",
|
||||
f" while j < {ds[1]} {{",
|
||||
f' codec.{n}_elements[i][j] = ModuleScalar("{base}", cast(s64)data.{n}[i][j])',
|
||||
f' codec.{n}_elements[i][j] = HostScalar("{base}", cast(s64)data.{n}[i][j])',
|
||||
" j += 1",
|
||||
" }",
|
||||
]
|
||||
else:
|
||||
lines += [
|
||||
f' codec.{n}_elements[i] = ModuleScalar("{base}", cast(s64)data.{n}[i])'
|
||||
f' codec.{n}_elements[i] = HostScalar("{base}", cast(s64)data.{n}[i])'
|
||||
]
|
||||
lines += [" i += 1", " }", " }"]
|
||||
elif sub == "string":
|
||||
@@ -163,7 +164,7 @@ for t in needed:
|
||||
]
|
||||
else:
|
||||
lines += [
|
||||
f' {target} = ModuleScalar("{sub}", '
|
||||
f' {target} = HostScalar("{sub}", '
|
||||
+ (
|
||||
f"ifx data.{n} then 1 else 0)"
|
||||
if sub == "bool"
|
||||
@@ -178,7 +179,10 @@ for t in needed:
|
||||
f" data: {t}",
|
||||
]
|
||||
for i, (n, sub) in enumerate(schema[t]):
|
||||
v = f"value.fields[{i}].value"
|
||||
v = "value.fields[field_at].value"
|
||||
# A field the other side lacks keeps its zero value.
|
||||
lines += [" {", f' field_at := HostFieldAt(value, {i}, "{n}")', " if field_at >= 0 {"]
|
||||
start = len(lines)
|
||||
if sub in needed:
|
||||
lines += [f" data.{n} = Decode{sub}({v})"]
|
||||
elif sub.startswith("["):
|
||||
@@ -214,23 +218,23 @@ for t in needed:
|
||||
else "bits" if sub.startswith("u") else "integer"
|
||||
)
|
||||
]
|
||||
lines[start:] = [" " + line for line in lines[start:]]
|
||||
lines += [" }", " }"]
|
||||
lines += [" return data", "}", ""]
|
||||
# Check every borrowed native value before any decoder can dereference it.
|
||||
for t in needed:
|
||||
lines += [
|
||||
f"Valid{t} :: (value: HostValue) -> bool {{",
|
||||
f' if value.kind != cast(s32)HostRecord || TextFromCString(value.type_name) != "{t}" ||',
|
||||
f" value.field_count != {len(schema[t])} || value.fields == null {{",
|
||||
" value.field_count > cast(usize)HOST_FIELD_LIMIT ||",
|
||||
" (value.field_count > cast(usize)0 && value.fields == null) {",
|
||||
" return false",
|
||||
" }",
|
||||
]
|
||||
for i, (n, sub) in enumerate(schema[t]):
|
||||
v = f"value.fields[{i}].value"
|
||||
lines += [
|
||||
f' if TextFromCString(value.fields[{i}].name) != "{n}" {{',
|
||||
" return false",
|
||||
" }",
|
||||
]
|
||||
v = "value.fields[field_at].value"
|
||||
lines += [" {", f' field_at := HostFieldAt(value, {i}, "{n}")', " if field_at >= 0 {"]
|
||||
start = len(lines)
|
||||
if sub in needed:
|
||||
lines += [f" if !Valid{sub}({v}) {{", " return false", " }"]
|
||||
elif sub.startswith("["):
|
||||
@@ -238,7 +242,7 @@ for t in needed:
|
||||
base = re.sub(r"\[[^]]+\]", "", sub)
|
||||
canonical = "".join(f"[{d}]" for d in ds) + base
|
||||
lines += [
|
||||
f' if !ModuleArrayValid({v}, "{canonical}", {ds[0]}) {{',
|
||||
f' if !HostArrayValid({v}, "{canonical}", {ds[0]}) {{',
|
||||
" return false",
|
||||
" }",
|
||||
" {",
|
||||
@@ -247,12 +251,12 @@ for t in needed:
|
||||
]
|
||||
if len(ds) > 1:
|
||||
lines += [
|
||||
f' if !ModuleArrayValid({v}.elements[i], "[{ds[1]}]{base}", {ds[1]}) {{',
|
||||
f' if !HostArrayValid({v}.elements[i], "[{ds[1]}]{base}", {ds[1]}) {{',
|
||||
" return false",
|
||||
" }",
|
||||
" j: s32 = 0",
|
||||
f" while j < {ds[1]} {{",
|
||||
f' if !ModuleScalarValid({v}.elements[i].elements[j], "{base}", cast(s32){scalar(base)}) {{',
|
||||
f' if !HostScalarValid({v}.elements[i].elements[j], "{base}", cast(s32){scalar(base)}) {{',
|
||||
" return false",
|
||||
" }",
|
||||
" j += 1",
|
||||
@@ -260,53 +264,20 @@ for t in needed:
|
||||
]
|
||||
else:
|
||||
lines += [
|
||||
f' if !ModuleScalarValid({v}.elements[i], "{base}", cast(s32){scalar(base)}) {{',
|
||||
f' if !HostScalarValid({v}.elements[i], "{base}", cast(s32){scalar(base)}) {{',
|
||||
" return false",
|
||||
" }",
|
||||
]
|
||||
lines += [" i += 1", " }", " }"]
|
||||
else:
|
||||
lines += [
|
||||
f' if !ModuleScalarValid({v}, "{sub}", cast(s32){scalar(sub)}) {{',
|
||||
f' if !HostScalarValid({v}, "{sub}", cast(s32){scalar(sub)}) {{',
|
||||
" return false",
|
||||
" }",
|
||||
]
|
||||
lines[start:] = [" " + line for line in lines[start:]]
|
||||
lines += [" }", " }"]
|
||||
lines += [" return true", "}", ""]
|
||||
lines += [
|
||||
"ModuleScalarValid :: (value: HostValue, type_name: string, kind: s32) -> bool {",
|
||||
" if value.kind != kind || TextFromCString(value.type_name) != type_name {",
|
||||
" return false",
|
||||
" }",
|
||||
" if kind == cast(s32)HostString {",
|
||||
" return value.length == 0 || value.data != null",
|
||||
" }",
|
||||
" return true",
|
||||
"}",
|
||||
"",
|
||||
"ModuleArrayValid :: (value: HostValue, type_name: string, count: usize) -> bool {",
|
||||
" return value.kind == cast(s32)HostArray && TextFromCString(value.type_name) == type_name &&",
|
||||
" value.length == count && value.elements != null",
|
||||
"}",
|
||||
"",
|
||||
]
|
||||
lines += [
|
||||
"ModuleScalar :: (type_name: string, number: s64) -> HostValue {",
|
||||
" value: HostValue",
|
||||
" value.type_name = type_name.data",
|
||||
" value.integer = number",
|
||||
" value.bits = cast(u64)number",
|
||||
" value.kind = ifx type_name[0] == cast(u8)117 then cast(s32)HostUnsigned else cast(s32)HostInteger",
|
||||
" return value",
|
||||
"}",
|
||||
"",
|
||||
]
|
||||
lines += [
|
||||
"ModuleTextData :: (text: string) -> *u8 {",
|
||||
" descriptor := cast(*TextDescriptor)(*text)",
|
||||
" return descriptor.data",
|
||||
"}",
|
||||
"",
|
||||
]
|
||||
source = "\n".join(lines)
|
||||
source = re.sub(r'("[^"\n]+"|data\.\w+|type_name)\.data', r"ModuleTextData(\1)", source)
|
||||
source = re.sub(r'("[^"\n]+"|data\.\w+|type_name)\.data', r"HostTextData(\1)", source)
|
||||
(root / "src/cells/value_codec.zi").write_text(source)
|
||||
@@ -14,6 +14,20 @@ for name in names:
|
||||
raise SystemExit(f"invalid {name} version")
|
||||
if type(value["sequence"]) is not int or not 0 < value["sequence"] <= 2147483647:
|
||||
raise SystemExit(f"invalid {name} sequence")
|
||||
for api in ("host_api", "oldest_host_api", "module_api"):
|
||||
if type(ledger.get(api)) is not int or not 0 < ledger[api] <= 65535:
|
||||
raise SystemExit(f"invalid {api}")
|
||||
# The interfaces are compiled host behavior, so they live apart from the
|
||||
# package versions and changing them triggers an app release.
|
||||
interfaces = "\n".join([
|
||||
"// Generated from apps/versions.json. This host runs packages built for host",
|
||||
"// interfaces from the oldest to the current one; module interfaces must match.",
|
||||
f"PackageHostAPI :: {ledger['host_api']}",
|
||||
f"PackageHostAPIOldest :: {ledger['oldest_host_api']}",
|
||||
f"PackageModuleAPI :: {ledger['module_api']}", ""])
|
||||
interface_path = root / "src/cells/host_api.zi"
|
||||
if not interface_path.exists() or interface_path.read_text() != interfaces:
|
||||
interface_path.write_text(interfaces)
|
||||
lines = ["// Generated from apps/versions.json; module releases are independent.",
|
||||
"PackageBundledVersion :: (index: s32) -> string {",
|
||||
f" if index < 0 || index >= {len(names)} {{", " return \"\"", " }",
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate bounded typed values for the standard hosted Kryon widget ABI."""
|
||||
from pathlib import Path
|
||||
import re
|
||||
root = Path(__file__).resolve().parent.parent
|
||||
modules = ['session', 'geometry', 'drawing_props', 'text_props', 'image_props',
|
||||
'button_props', 'control_props', 'text_input', 'text_input_props',
|
||||
'scroll', 'scroll_props', 'semantic', 'text_align', 'checkbox_props', 'toggle_props',
|
||||
'tab_bar_props', 'box_props']
|
||||
schema = {}
|
||||
for path in [*(root / 'build/packages/kryon/src/ui' / (m + '.zi') for m in modules),
|
||||
root / 'src/cells/diary_ui_types.zi', root / 'src/cells/inbe_ui_types.zi',
|
||||
root / 'src/cells/lists_ui_types.zi', root / 'src/cells/lumi_ui_types.zi', root / 'src/cells/lumi_types.zi',
|
||||
root / 'src/cells/leaderboard_ui_types.zi']:
|
||||
for name, body in re.findall(r'(\w+)\s*::\s*struct\s*\{([^{}]*)\}', path.read_text()):
|
||||
schema[name] = [(n, re.sub(r'\s+', '', t.split('//')[0])) for n, t in
|
||||
re.findall(r'^\s*(\w+)\s*:\s*([^\n;]+)', body, re.M)]
|
||||
roots = ['TextProps','ImageProps','ButtonProps','TextAreaProps','TextAreaResult',
|
||||
'ScrollProps','ScrollResult','DiaryUiFrame','Session','InbeUiFrame',
|
||||
'CheckboxProps','CheckboxValueResult','ToggleProps','ToggleValueResult',
|
||||
'TextFieldProps','TextFieldResult','Tab','TabBarProps','TabBarResult',
|
||||
'BoxProps','ListsUiFrame','ListsUiRow','LumiUiFrame','LumiChatRow','LumiTask','LumiAction','LumiTools','LumiDonation',
|
||||
'LeaderboardUiFrame','LeaderboardUiRow']
|
||||
needed = []
|
||||
def discover(t):
|
||||
if t.startswith('[]'): discover(t[2:]); return
|
||||
if t in schema and t not in needed:
|
||||
for _, s in schema[t]: discover(s)
|
||||
needed.append(t)
|
||||
for t in roots: discover(t)
|
||||
lines = ['// Generated by scripts/generate-widget-codecs.py; bounded public widget values.',
|
||||
'#import "bundle_host"', '#import "byte_text_linux"',
|
||||
'#import, file "value_codec.zi";', '#import, file "diary_ui_types.zi";', '#import, file "inbe_ui_types.zi";',
|
||||
'#import, file "lists_ui_types.zi";', '#import, file "lumi_ui_types.zi";', '#import, file "lumi_types.zi";',
|
||||
'#import, file "leaderboard_ui_types.zi";',
|
||||
*(f'#import "{m}"' for m in modules), 'using HostValueKind;', '']
|
||||
def scalar(t):
|
||||
return 'HostString' if t == 'string' else 'HostReal' if t.startswith('float') else 'HostUnsigned' if t.startswith('u') else 'HostInteger'
|
||||
for t in needed:
|
||||
lines += [f'Widget{t}Codec :: struct {{', f' fields: [{len(schema[t])}]HostField']
|
||||
for n,s in schema[t]:
|
||||
if s in needed: lines += [f' {n}: Widget{s}Codec']
|
||||
if s.startswith('[]'):
|
||||
b=s[2:]
|
||||
lines += [f' {n}_values: [1024]HostValue', f' {n}_codecs: [1024]Widget{b}Codec', f' {n}_decoded: [1024]{b}']
|
||||
lines += ['}', '', f'WidgetEncode{t} :: (data: {t}, codec: *Widget{t}Codec) -> HostValue {{',
|
||||
' value: HostValue', ' value.kind = cast(s32)HostRecord',
|
||||
f' value.type_name = ModuleTextData("{t}")',
|
||||
' value.fields = *codec.fields[0]', f' value.field_count = {len(schema[t])}']
|
||||
for i,(n,s) in enumerate(schema[t]):
|
||||
v=f'codec.fields[{i}].value'; lines += [f' codec.fields[{i}].name = ModuleTextData("{n}")']
|
||||
if s in needed: lines += [f' {v} = WidgetEncode{s}(data.{n}, *codec.{n})']
|
||||
elif s.startswith('[]'):
|
||||
b=s[2:]
|
||||
lines += [f' {v}.kind = cast(s32)HostSlice', f' {v}.type_name = ModuleTextData("{s}")',
|
||||
f' {v}.length = cast(usize)data.{n}.count', f' if {v}.length > cast(usize)1024 {{ {v}.length = cast(usize)1024 }}',
|
||||
f' {v}.elements = *codec.{n}_values[0]', ' {', ' index: usize = 0',
|
||||
f' while index < {v}.length {{', f' codec.{n}_values[index] = WidgetEncode{b}(data.{n}[index], *codec.{n}_codecs[index])',
|
||||
' index += cast(usize)1', ' }', ' }']
|
||||
elif s=='string': lines += [f' {v} = HostValue.{{.kind = cast(s32)HostString, .type_name = ModuleTextData("string"), .data = ModuleTextData(data.{n}), .length = cast(usize)data.{n}.count}}']
|
||||
elif s.startswith('float'): lines += [f' {v} = HostValue.{{.kind = cast(s32)HostReal, .type_name = ModuleTextData("{s}"), .real = cast(float64)data.{n}}}']
|
||||
else: lines += [f' {v} = ModuleScalar("{s}", ' + (f'ifx data.{n} then 1 else 0)' if s=='bool' else f'cast(s64)data.{n})')]
|
||||
lines += [' return value', '}', '', f'WidgetDecode{t} :: (value: HostValue, codec: *Widget{t}Codec) -> {t} {{', f' data: {t}']
|
||||
for i,(n,s) in enumerate(schema[t]):
|
||||
v=f'value.fields[{i}].value'
|
||||
if s in needed: lines += [f' data.{n} = WidgetDecode{s}({v}, *codec.{n})']
|
||||
elif s.startswith('[]'):
|
||||
b=s[2:]
|
||||
lines += [' {', ' index: usize = 0', f' while index < {v}.length {{',
|
||||
f' codec.{n}_decoded[index] = WidgetDecode{b}({v}.elements[index], *codec.{n}_codecs[index])',
|
||||
' index += cast(usize)1', ' }', ' }',
|
||||
f' // Slice storage is attached by the rendering effect after decoding.']
|
||||
elif s=='string': lines += [f' data.{n} = TextFromBytes(BytesFromPointer({v}.data, cast(u64){v}.length))']
|
||||
elif s=='bool': lines += [f' data.{n} = {v}.integer != 0']
|
||||
else: lines += [f' data.{n} = cast({s}){v}.' + ('real' if s.startswith('float') else 'bits' if s.startswith('u') else 'integer')]
|
||||
lines += [' return data', '}', '', f'WidgetValid{t} :: (value: HostValue) -> bool {{',
|
||||
f' if value.kind != cast(s32)HostRecord || TextFromCString(value.type_name) != "{t}" ||',
|
||||
f' value.field_count != {len(schema[t])} || value.fields == null {{ return false }}']
|
||||
for i,(n,s) in enumerate(schema[t]):
|
||||
v=f'value.fields[{i}].value'
|
||||
lines += [f' if TextFromCString(value.fields[{i}].name) != "{n}" {{ return false }}']
|
||||
if s in needed: lines += [f' if !WidgetValid{s}({v}) {{ return false }}']
|
||||
elif s.startswith('[]'):
|
||||
b=s[2:]; lines += [f' if {v}.kind != cast(s32)HostSlice || TextFromCString({v}.type_name) != "{s}" ||',
|
||||
f' {v}.length > cast(usize)1024 || ({v}.length > cast(usize)0 && {v}.elements == null) {{ return false }}',
|
||||
' {', ' index: usize = 0', f' while index < {v}.length {{',
|
||||
f' if !WidgetValid{b}({v}.elements[index]) {{ return false }}',
|
||||
' index += cast(usize)1', ' }', ' }']
|
||||
else: lines += [f' if !ModuleScalarValid({v}, "{s}", cast(s32){scalar(s)}) {{ return false }}']
|
||||
lines += [' return true', '}', '']
|
||||
(root / 'src/cells/widget_codec.zi').write_text('\n'.join(lines))
|
||||
@@ -3,6 +3,7 @@
|
||||
import argparse
|
||||
from contextlib import ExitStack
|
||||
import fcntl
|
||||
import io
|
||||
from hashlib import sha256
|
||||
import json
|
||||
import os
|
||||
@@ -11,6 +12,7 @@ import re
|
||||
import shlex
|
||||
import subprocess
|
||||
import tempfile
|
||||
import time
|
||||
import sys
|
||||
from urllib.parse import urlsplit
|
||||
from urllib.request import Request, urlopen
|
||||
@@ -91,7 +93,7 @@ def stage(store, key_path, key_id, publishers_path=None):
|
||||
dependencies.append(dict(app_id=release["app_id"], version=release["version"],
|
||||
sha256=release["artifacts"][0]["sha256"], size=len(nested)))
|
||||
value = dict(app_id=component["id"], sequence=sequence, version=component["version"],
|
||||
runtime="kryon-app-v1", host_api=versions["host_api"],
|
||||
runtime="kryon-app-v1", host_api=component.get("host_api", versions["host_api"]),
|
||||
module_api=versions["module_api"], data_schema=0, key_id=key_id,
|
||||
artifacts=[artifact], dependencies=sorted(dependencies, key=lambda d: d["app_id"]))
|
||||
value["signature"] = key.sign(signing_message(value)).hex()
|
||||
@@ -141,7 +143,14 @@ def stage(store, key_path, key_id, publishers_path=None):
|
||||
return releases
|
||||
|
||||
|
||||
def publish(store, target, remote_store):
|
||||
def rollout_value(percent, hours):
|
||||
"""A staged release reaches buckets below percent, then everyone after hours."""
|
||||
if type(percent) is not int or not 1 <= percent <= 100 or type(hours) is not int or not 0 < hours <= 720:
|
||||
raise ValueError("rollout needs a share from 1 to 100 percent and 1 to 720 hours")
|
||||
return dict(percent=percent, hours=hours)
|
||||
|
||||
|
||||
def publish(store, target, remote_store, rollout=None):
|
||||
if not re.fullmatch(r"[a-zA-Z0-9_.@-]+", target) or target.startswith("-"):
|
||||
raise ValueError("invalid SSH target")
|
||||
if not remote_store.startswith("/") or "\n" in remote_store:
|
||||
@@ -162,6 +171,11 @@ def publish(store, target, remote_store):
|
||||
f"release-{value['sequence']}.json"):
|
||||
path = directory / filename
|
||||
tar.add(path, arcname=str(path.relative_to(store)), recursive=False)
|
||||
if rollout is not None:
|
||||
encoded = json.dumps(rollout_value(rollout["percent"], rollout["hours"])).encode()
|
||||
member = tarfile.TarInfo("rollout.json")
|
||||
member.size = len(encoded)
|
||||
tar.addfile(member, io.BytesIO(encoded))
|
||||
options = ["-o", "BatchMode=yes", "-o", "StrictHostKeyChecking=yes"]
|
||||
if os.environ.get("INBE_SSH_IDENTITY"):
|
||||
options += ["-i", os.environ["INBE_SSH_IDENTITY"]]
|
||||
@@ -189,7 +203,8 @@ def verify_origin(store, origin, open_url=open_public_url):
|
||||
app_id = "inbe" if name == "inbe" else "inbe." + name
|
||||
expected = json.loads((store / app_id / "latest-v2.json").read_bytes())
|
||||
route = origin + "/api/v2/packages/" + app_id
|
||||
with open_url(route + "/latest", timeout=30) as response:
|
||||
# Bucket 0 receives a staged release first.
|
||||
with open_url(route + "/latest?bucket=0", timeout=30) as response:
|
||||
encoded = response.read(65537)
|
||||
if len(encoded) > 65536 or json.loads(encoded) != expected:
|
||||
raise ValueError(f"{app_id}: public release metadata differs from the signed publication")
|
||||
@@ -269,8 +284,15 @@ def import_archive(archive, store, publishers_path=None):
|
||||
"inbe.leaderboard"}
|
||||
entries = {}
|
||||
total = 0
|
||||
rollout = None
|
||||
with tarfile.open(archive) as tar:
|
||||
for member in tar.getmembers():
|
||||
if member.name == "rollout.json" and member.isfile() and member.size <= 1024 and rollout is None:
|
||||
rollout = json.loads(tar.extractfile(member).read())
|
||||
if not isinstance(rollout, dict) or set(rollout) != {"percent", "hours"}:
|
||||
raise ValueError("invalid rollout")
|
||||
rollout = rollout_value(rollout["percent"], rollout["hours"])
|
||||
continue
|
||||
parts = Path(member.name).parts
|
||||
if len(parts) != 2 or parts[0] not in ids or not member.isfile() or member.size > 64 * 1024 * 1024:
|
||||
raise ValueError("invalid archive member")
|
||||
@@ -304,6 +326,7 @@ def import_archive(archive, store, publishers_path=None):
|
||||
if not data.startswith(b"ZIB\0"):
|
||||
raise ValueError("payload is not a ZIB bundle")
|
||||
current = directory / "latest-v2.json"
|
||||
old = None
|
||||
if current.exists():
|
||||
old = json.loads(current.read_bytes())
|
||||
if old != value and (old["sequence"] >= value["sequence"] or
|
||||
@@ -313,17 +336,17 @@ def import_archive(archive, store, publishers_path=None):
|
||||
archived = directory / f"release-{value['sequence']}.json"
|
||||
if archived.exists() and archived.read_bytes() != encoded:
|
||||
raise ValueError("release sequence is already occupied")
|
||||
releases[app_id] = (value, encoded, data)
|
||||
releases[app_id] = (value, encoded, data, old != value)
|
||||
root = releases["inbe"]
|
||||
for dependency in root[0]["dependencies"]:
|
||||
child, _, payload = releases[dependency["app_id"]]
|
||||
child, _, payload, _ = releases[dependency["app_id"]]
|
||||
artifact = child["artifacts"][0]
|
||||
if dependency != dict(app_id=child["app_id"], version=child["version"],
|
||||
sha256=artifact["sha256"], size=artifact["size"]) or root[2].count(payload) != 1:
|
||||
raise ValueError("root does not contain its exact signed cell dependency")
|
||||
# Dependencies go first. Publishing the root is the final step.
|
||||
for app_id in sorted(present, key=lambda value: value == "inbe"):
|
||||
value, encoded, data = releases[app_id]
|
||||
value, encoded, data, changed = releases[app_id]
|
||||
directory = store / app_id
|
||||
payload = directory / (value["artifacts"][0]["sha256"] + ".zib")
|
||||
archived = directory / f"release-{value['sequence']}.json"
|
||||
@@ -333,6 +356,15 @@ def import_archive(archive, store, publishers_path=None):
|
||||
atomic_write(payload.with_name(payload.name + ".release-v2.json"), encoded)
|
||||
atomic_write(archived, encoded)
|
||||
atomic_write(directory / "latest-v2.json", encoded)
|
||||
# Daochi holds a staged release back from the other buckets until
|
||||
# it expires. A new full release or a full rollout ends staging.
|
||||
staged = directory / "rollout.json"
|
||||
if rollout is not None and rollout["percent"] < 100 and changed:
|
||||
until = int(time.time()) + rollout["hours"] * 3600
|
||||
atomic_write(staged, json.dumps(dict(sequence=value["sequence"], percent=rollout["percent"],
|
||||
until=until)).encode())
|
||||
elif changed or (rollout is not None and rollout["percent"] == 100):
|
||||
staged.unlink(missing_ok=True)
|
||||
archive.unlink()
|
||||
archive.parent.rmdir()
|
||||
|
||||
@@ -367,6 +399,8 @@ def main():
|
||||
parser.add_argument("--import-archive", type=Path)
|
||||
parser.add_argument("--receive-archive", action="store_true")
|
||||
parser.add_argument("--publishers", type=Path, help="node-owned public publisher pins")
|
||||
parser.add_argument("--rollout", type=int, help="publish changed releases to this share of devices first")
|
||||
parser.add_argument("--rollout-hours", type=int, default=24, help="then to every device after these hours")
|
||||
args = parser.parse_args()
|
||||
try:
|
||||
if args.receive_archive:
|
||||
@@ -382,7 +416,8 @@ def main():
|
||||
if args.ssh_target:
|
||||
if not args.remote_store:
|
||||
parser.error("--remote-store is required with --ssh-target")
|
||||
publish(args.store, args.ssh_target, args.remote_store)
|
||||
rollout = None if args.rollout is None else rollout_value(args.rollout, args.rollout_hours)
|
||||
publish(args.store, args.ssh_target, args.remote_store, rollout)
|
||||
if args.verify_origin:
|
||||
verify_origin(args.store, args.verify_origin)
|
||||
print("Inbe package releases published" if args.ssh_target or args.import_archive or args.receive_archive else "Inbe package releases staged")
|
||||
|
||||
@@ -0,0 +1,281 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Check an exact Inner Breeze APK on the development Moto before release.
|
||||
|
||||
The APK is installed over the existing app, launched, and the Wim Hof session
|
||||
is started through the app's own start-practice intent. SurfaceFlinger's frame
|
||||
timestamps for the app's window are collected for the whole session, then the
|
||||
app is sent to the background and resumed. With --record the result is written
|
||||
to releases/phone-checks/VERSION.json for the release workflow, which publishes
|
||||
a new version only with a passing check of its exact source commit.
|
||||
"""
|
||||
import argparse
|
||||
from datetime import datetime, timezone
|
||||
import hashlib
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
ACTIVITY = "xyz.waozi.inbe.MainActivity"
|
||||
START_PRACTICE = "xyz.waozi.inbe.action.START_PRACTICE"
|
||||
WIM_HOF = 0
|
||||
# Paths whose changes alter the APK. The release gate allows only other
|
||||
# changes between the checked commit and the released one.
|
||||
SOURCE_PATHS = ("src", "droid", "apps", "assets", "locales", "themes", "fonts",
|
||||
"Makefile", "ziran.toml", "ziran.lock", "CHANGELOG.md", "scripts", "packaging")
|
||||
# The breathing circle animates for the whole measured window, so the app
|
||||
# must keep the display's refresh rate with only occasional late frames.
|
||||
MINIMUM_REFRESH_SHARE = 0.94
|
||||
MAXIMUM_LATE_PERCENT = 3.0
|
||||
MAXIMUM_FRAME_MS = 250.0
|
||||
# Leaving during a practice may pass through the floating window; the
|
||||
# practice must come back with the layout it had, not shifted or cropped.
|
||||
MAXIMUM_RESUME_LAYOUT_SHIFT = 2.0
|
||||
PENDING = 9223372036854775807
|
||||
|
||||
|
||||
def run(argv, *, timeout=60, **kwargs):
|
||||
return subprocess.run(list(map(str, argv)), check=True, capture_output=True,
|
||||
timeout=timeout, **kwargs).stdout
|
||||
|
||||
|
||||
class Phone:
|
||||
def __init__(self, host, serial):
|
||||
if not re.fullmatch(r"[A-Za-z0-9_.@-]+", host) or host.startswith("-"):
|
||||
raise ValueError("invalid ADB host")
|
||||
if not re.fullmatch(r"[A-Za-z0-9]+", serial):
|
||||
raise ValueError("invalid phone serial")
|
||||
self.host = host
|
||||
self.serial = serial
|
||||
|
||||
def remote(self, *argv, timeout=60, **kwargs):
|
||||
if self.host == "local":
|
||||
return run(argv, timeout=timeout, **kwargs)
|
||||
return run(["ssh", "-o", "BatchMode=yes", "-o", "ConnectTimeout=8", self.host,
|
||||
shlex.join(list(map(str, argv)))], timeout=timeout, **kwargs)
|
||||
|
||||
def adb(self, *argv, **kwargs):
|
||||
return self.remote("adb", "-s", self.serial, *argv, **kwargs)
|
||||
|
||||
def shell(self, *argv, **kwargs):
|
||||
return self.adb("shell", *argv, **kwargs).decode(errors="replace")
|
||||
|
||||
def focused(self, package):
|
||||
# Launcher aliases name the window too, so any activity of the app counts.
|
||||
windows = self.shell("dumpsys", "window", "windows")
|
||||
line = next((line for line in windows.splitlines() if "mCurrentFocus=" in line), "")
|
||||
if f" {package}/" not in line:
|
||||
raise ValueError("Inner Breeze does not own the foreground window: " + line.strip())
|
||||
|
||||
def screenshot(self, package, path):
|
||||
from PIL import Image, ImageStat
|
||||
|
||||
self.focused(package)
|
||||
data = self.adb("exec-out", "screencap", "-p")
|
||||
with Image.open(io.BytesIO(data)) as image:
|
||||
body = image.convert("RGB").crop((0, image.height // 10, image.width, image.height * 9 // 10))
|
||||
if max(ImageStat.Stat(body).stddev) < 2:
|
||||
raise ValueError(f"Inner Breeze rendered a blank screen ({path.name})")
|
||||
path.write_bytes(data)
|
||||
|
||||
def start(self, package, *extra):
|
||||
output = self.shell("am", "start", "-W", "-n", f"{package}/{ACTIVITY}", *extra)
|
||||
if "Status: ok" not in output and "Warning: Activity not started" not in output:
|
||||
raise ValueError("Inner Breeze did not start: " + output.strip())
|
||||
|
||||
def pid(self, package):
|
||||
return self.shell("pidof", package).strip()
|
||||
|
||||
|
||||
def apk_identity(apk):
|
||||
tools = sorted((Path(os.environ.get("ANDROID_SDK_ROOT") or os.environ.get("ANDROID_HOME") or
|
||||
Path.home() / "Android/Sdk") / "build-tools").glob("*/aapt2"))
|
||||
if not tools:
|
||||
raise ValueError("aapt2 not found; set ANDROID_SDK_ROOT")
|
||||
badging = run([tools[-1], "dump", "badging", apk]).decode()
|
||||
match = re.search(r"package: name='([^']+)' versionCode='(\d+)' versionName='([^']+)'", badging)
|
||||
if not match:
|
||||
raise ValueError("the APK has no package identity")
|
||||
return dict(package=match[1], version_code=int(match[2]), version_name=match[3])
|
||||
|
||||
|
||||
def source_state():
|
||||
commit = run(["git", "-C", ROOT, "rev-parse", "HEAD"]).decode().strip()
|
||||
dirty = run(["git", "-C", ROOT, "status", "--porcelain", "--", *SOURCE_PATHS]).decode().strip()
|
||||
version = run([sys.executable, ROOT / "scripts/check-version.py", "--print-version"]).decode().strip()
|
||||
return commit, dirty, version
|
||||
|
||||
|
||||
def layout_shift(before, after):
|
||||
"""Mean pixel difference of the practice header, which does not animate."""
|
||||
from PIL import Image, ImageChops, ImageStat
|
||||
|
||||
with Image.open(before) as first, Image.open(after) as second:
|
||||
if first.size != second.size:
|
||||
return 255.0
|
||||
width, height = first.size
|
||||
box = (0, height * 4 // 100, width, height * 12 // 100)
|
||||
difference = ImageChops.difference(first.convert("RGB").crop(box), second.convert("RGB").crop(box))
|
||||
return round(sum(ImageStat.Stat(difference).mean) / 3, 1)
|
||||
|
||||
|
||||
def frame_timing(phone, package, seconds):
|
||||
"""Collect every presented frame of the app's window for the session."""
|
||||
# Android 9 names layers "<id> package/activity#N"; tokens are not layers.
|
||||
layers = [line.strip() for line in phone.shell("dumpsys", "SurfaceFlinger", "--list").splitlines()
|
||||
if f" {package}/" in " " + line.strip() and "Token{" not in line]
|
||||
if not layers:
|
||||
raise ValueError("Inner Breeze has no window layer")
|
||||
presented = {}
|
||||
period = 0
|
||||
deadline = time.monotonic() + seconds
|
||||
for layer in layers:
|
||||
phone.shell("dumpsys", "SurfaceFlinger", "--latency-clear", shlex.quote(layer))
|
||||
while time.monotonic() < deadline:
|
||||
for layer in layers:
|
||||
lines = phone.shell("dumpsys", "SurfaceFlinger", "--latency", shlex.quote(layer)).split("\n")
|
||||
if lines and lines[0].strip().isdigit():
|
||||
period = int(lines[0])
|
||||
for line in lines[1:]:
|
||||
fields = line.split()
|
||||
if len(fields) == 3 and fields[1].isdigit():
|
||||
actual = int(fields[1])
|
||||
if 0 < actual < PENDING:
|
||||
presented.setdefault(layer, set()).add(actual)
|
||||
time.sleep(0.5)
|
||||
if not presented or period <= 0:
|
||||
raise ValueError("SurfaceFlinger reported no frames for Inner Breeze")
|
||||
frames = sorted(max(presented.values(), key=len))
|
||||
if len(frames) < 2:
|
||||
raise ValueError("Inner Breeze presented fewer than two frames")
|
||||
gaps = [(right - left) / 1e6 for left, right in zip(frames, frames[1:])]
|
||||
period_ms = period / 1e6
|
||||
late = sum(1 for gap in gaps if gap > period_ms * 1.5)
|
||||
ordered = sorted(gaps)
|
||||
return dict(seconds=round((frames[-1] - frames[0]) / 1e9, 2), frames=len(frames),
|
||||
refresh_hz=round(1000 / period_ms, 1),
|
||||
fps=round((len(frames) - 1) / ((frames[-1] - frames[0]) / 1e9), 1),
|
||||
late_percent=round(100 * late / len(gaps), 2),
|
||||
p95_frame_ms=round(ordered[int(len(ordered) * 0.95) - 1], 1),
|
||||
worst_frame_ms=round(ordered[-1], 1))
|
||||
|
||||
|
||||
def smooth(timing):
|
||||
return (timing["refresh_hz"] >= 30 and timing["fps"] >= timing["refresh_hz"] * MINIMUM_REFRESH_SHARE and
|
||||
timing["late_percent"] <= MAXIMUM_LATE_PERCENT and
|
||||
timing["worst_frame_ms"] <= MAXIMUM_FRAME_MS)
|
||||
|
||||
|
||||
def resumed_in_place(timing):
|
||||
return timing.get("resume_layout_shift", 255.0) <= MAXIMUM_RESUME_LAYOUT_SHIFT
|
||||
|
||||
|
||||
def check(phone, apk, seconds, evidence):
|
||||
identity = apk_identity(apk)
|
||||
package = identity["package"]
|
||||
if phone.adb("get-state").decode().strip() != "device":
|
||||
raise ValueError("the phone is not connected and authorized")
|
||||
transfer = ""
|
||||
try:
|
||||
if phone.host != "local":
|
||||
transfer = phone.remote("mktemp", "-d", "/tmp/inbe-phone-check-XXXXXXXX").decode().strip()
|
||||
if not re.fullmatch(r"/tmp/inbe-phone-check-[A-Za-z0-9]+", transfer):
|
||||
raise ValueError("unsafe transfer folder on the ADB host")
|
||||
remote = transfer + "/inbe.apk"
|
||||
phone.remote("sh", "-c", "umask 077; cat > " + shlex.quote(remote), input=apk.read_bytes(),
|
||||
timeout=300)
|
||||
else:
|
||||
remote = apk
|
||||
if "Success" not in phone.adb("install", "-r", remote, timeout=300).decode():
|
||||
raise ValueError("the phone rejected the APK; its existing app and data were kept")
|
||||
finally:
|
||||
if transfer:
|
||||
phone.remote("rm", "-rf", transfer)
|
||||
phone.shell("input", "keyevent", "KEYCODE_WAKEUP")
|
||||
phone.shell("wm", "dismiss-keyguard")
|
||||
phone.shell("am", "force-stop", package)
|
||||
phone.start(package)
|
||||
time.sleep(4)
|
||||
pid = phone.pid(package)
|
||||
if not pid:
|
||||
raise ValueError("Inner Breeze did not stay running after launch")
|
||||
phone.screenshot(package, evidence / "launch.png")
|
||||
phone.start(package, "-a", START_PRACTICE, "--ei", "practice_id", str(WIM_HOF))
|
||||
time.sleep(3)
|
||||
phone.screenshot(package, evidence / "practice-start.png")
|
||||
timing = frame_timing(phone, package, seconds)
|
||||
phone.screenshot(package, evidence / "practice-end.png")
|
||||
if phone.pid(package) != pid:
|
||||
raise ValueError("Inner Breeze restarted during the practice")
|
||||
phone.shell("input", "keyevent", "KEYCODE_HOME")
|
||||
time.sleep(2)
|
||||
phone.start(package)
|
||||
time.sleep(2)
|
||||
if phone.pid(package) != pid:
|
||||
raise ValueError("Inner Breeze restarted when it returned from the background")
|
||||
phone.screenshot(package, evidence / "resume.png")
|
||||
timing["resume_layout_shift"] = layout_shift(evidence / "practice-end.png", evidence / "resume.png")
|
||||
model = phone.shell("getprop", "ro.product.model").strip()
|
||||
android = phone.shell("getprop", "ro.build.version.release").strip()
|
||||
return identity, timing, dict(model=model, android=android)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("apk", type=Path)
|
||||
parser.add_argument("--host", default=os.environ.get("INBE_PHONE_HOST", "auto"),
|
||||
help="SSH host that runs adb, 'local', or 'auto' (this machine, then the ThinkPad)")
|
||||
parser.add_argument("--serial", default=os.environ.get("INBE_PHONE_SERIAL", "ZE2223BQZT"))
|
||||
parser.add_argument("--seconds", type=int, default=60)
|
||||
parser.add_argument("--record", action="store_true",
|
||||
help="write releases/phone-checks/VERSION.json for the release gate")
|
||||
args = parser.parse_args()
|
||||
for name in ("DISPLAY", "WAYLAND_DISPLAY", "XAUTHORITY", "DBUS_SESSION_BUS_ADDRESS"):
|
||||
os.environ.pop(name, None)
|
||||
apk = args.apk.resolve(strict=True)
|
||||
commit, dirty, version = source_state()
|
||||
if args.record and (dirty or args.seconds < 60):
|
||||
parser.error("a recorded check needs a full minute and committed sources:\n" + dirty)
|
||||
stamp = datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ")
|
||||
evidence = ROOT / "backup/phone-checks" / f"{version}-{stamp}"
|
||||
evidence.mkdir(parents=True, exist_ok=True)
|
||||
host = args.host
|
||||
if host == "auto":
|
||||
attached = subprocess.run(["adb", "devices"], capture_output=True, text=True).stdout
|
||||
host = "local" if re.search(rf"^{re.escape(args.serial)}\s+device$", attached, re.M) else "[email protected]"
|
||||
identity, timing, device = check(Phone(host, args.serial), apk, args.seconds, evidence)
|
||||
if identity["version_name"] != version:
|
||||
raise SystemExit(f"the APK is {identity['version_name']}, but the source is {version}")
|
||||
passed = smooth(timing) and resumed_in_place(timing)
|
||||
receipt = dict(schema=1, version=version, source_commit=commit,
|
||||
apk=dict(sha256=hashlib.sha256(apk.read_bytes()).hexdigest(), **identity),
|
||||
device=device, practice=dict(name="Wim Hof", **timing),
|
||||
limits=dict(minimum_refresh_share=MINIMUM_REFRESH_SHARE, maximum_late_percent=MAXIMUM_LATE_PERCENT,
|
||||
maximum_frame_ms=MAXIMUM_FRAME_MS,
|
||||
maximum_resume_layout_shift=MAXIMUM_RESUME_LAYOUT_SHIFT),
|
||||
checks=["installed over the existing app", "launch", "Wim Hof frame timing",
|
||||
"background and resume"],
|
||||
passed=passed, checked_at=datetime.now(timezone.utc).isoformat(timespec="seconds"))
|
||||
(evidence / "receipt.json").write_text(json.dumps(receipt, indent=2) + "\n")
|
||||
if args.record:
|
||||
target = ROOT / "releases/phone-checks" / f"{version}.json"
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
target.write_text(json.dumps(receipt, indent=2) + "\n")
|
||||
print(f"Recorded {target.relative_to(ROOT)}; commit it with the release.")
|
||||
if not resumed_in_place(timing):
|
||||
print(f"FAILED: the practice layout changed after resuming (difference {timing['resume_layout_shift']}); "
|
||||
f"compare practice-end.png and resume.png in {evidence.relative_to(ROOT)}")
|
||||
print(f"{device['model']} (Android {device['android']}): {timing['fps']} fps over {timing['seconds']} s, "
|
||||
f"{timing['late_percent']}% late frames, worst {timing['worst_frame_ms']} ms -> "
|
||||
f"{'smooth' if smooth(timing) else 'NOT smooth'}; evidence in {evidence.relative_to(ROOT)}")
|
||||
return 0 if passed else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -11,8 +11,8 @@
|
||||
#import, file "../storage/cell_records.zi";
|
||||
#import, file "../storage/storage_core.zi";
|
||||
#import, file "../storage/db.zi";
|
||||
#import, file "../storage/sync_crypto_random.zi";
|
||||
#import, file "../storage/sync_crypto.zi";
|
||||
#import "keys"
|
||||
#import "crypto"
|
||||
#import, file "../storage/delegate_store.zi";
|
||||
#import, file "../storage/temporary_data.zi";
|
||||
#import, file "../cells/package_files.zi";
|
||||
@@ -58,11 +58,11 @@ ActivityCurrentTime :: () -> s64 {
|
||||
ActivityRandomID :: (output: []u8, byte_count: s32) -> bool {
|
||||
bytes: [32]u8
|
||||
if byte_count < 1 || byte_count > 32 || output.count < byte_count * 2 + 1 ||
|
||||
SyncCryptoRandom(*bytes[0], byte_count) == 0 {
|
||||
SecureRandom(*bytes[0], byte_count) == 0 {
|
||||
return false
|
||||
}
|
||||
result := SyncCryptoBytesToHex(*bytes[0], byte_count, *output[0], output.count) != 0
|
||||
SyncCryptoWipe(*bytes[0], 32)
|
||||
result := BytesToHex(*bytes[0], byte_count, *output[0], output.count) != 0
|
||||
SecureWipe(*bytes[0], 32)
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
+19
-13
@@ -24,6 +24,8 @@
|
||||
#import "layout"
|
||||
#import "kss_parser"
|
||||
#import "layout_widget"
|
||||
#import "grid"
|
||||
#import "grid_props"
|
||||
#import "overlay_props"
|
||||
#import "overlay_widget"
|
||||
#import "paint_queue"
|
||||
@@ -275,8 +277,13 @@ app_draw_launcher :: (app: *InnerBreeze) {
|
||||
}
|
||||
tile_height := AppScale(88)
|
||||
gap := AppScale(12)
|
||||
pinned_rows := (pinned_count + 1) / 2
|
||||
more_rows := (more_count + 1) / 2
|
||||
// The tiles reflow into as many columns as the panel's width allows.
|
||||
columns := MeasureGrid(GridProps.{.bounds = Rectangle.{cast(float32)x, 0.0, cast(float32)width, 0.0},
|
||||
.min_item_width = AppScale(140), .max_columns = 6, .gap = gap}).columns
|
||||
cells := MeasureGrid(GridProps.{.columns = columns, .gap = gap,
|
||||
.bounds = Rectangle.{cast(float32)x, 0.0, cast(float32)width, 0.0}})
|
||||
pinned_rows := GridRowCount(cells, pinned_count)
|
||||
more_rows := GridRowCount(cells, more_count)
|
||||
pinned_height := AppScale(36) + pinned_rows * (tile_height + gap)
|
||||
more_height := AppScale(36) + more_rows * (tile_height + gap)
|
||||
if more_count == 0 { more_height += AppScale(64) }
|
||||
@@ -294,6 +301,7 @@ app_draw_launcher :: (app: *InnerBreeze) {
|
||||
scrolled := Scroll(app.ui.session, scroll)
|
||||
app.launcher_scroll = scrolled.scroll_offset
|
||||
pinned_bounds: Rectangle
|
||||
pinned_cells: GridMetrics
|
||||
more_bounds: Rectangle
|
||||
pinned_slots: [LAUNCHER_APP_COUNT]Rectangle
|
||||
if scrolled.opened {
|
||||
@@ -301,7 +309,6 @@ app_draw_launcher :: (app: *InnerBreeze) {
|
||||
y := cast(s32)scrolled.content.y
|
||||
pinned_bounds = Rectangle.{cast(float32)x, cast(float32)y,
|
||||
cast(float32)width, cast(float32)pinned_height}
|
||||
item_width := (width - gap) / 2
|
||||
for section: cast(s32)0..cast(s32)1 {
|
||||
count := ifx section == 0 then pinned_count else more_count
|
||||
Text(app.ui.session, TextProps.{
|
||||
@@ -314,15 +321,18 @@ app_draw_launcher :: (app: *InnerBreeze) {
|
||||
cast(float32)width, cast(float32)more_height}
|
||||
}
|
||||
y += AppScale(36)
|
||||
// The scroll's content may be narrower than the panel; the column
|
||||
// count chosen for the panel keeps the content height exact.
|
||||
section_cells := MeasureGrid(GridProps.{.columns = columns, .gap = gap,
|
||||
.bounds = Rectangle.{cast(float32)x, cast(float32)y, cast(float32)width, 0.0}})
|
||||
if section == 0 { pinned_cells = section_cells }
|
||||
for index: cast(s32)0..count - 1 {
|
||||
route := ifx section == 0 then pinned[index] else more[index]
|
||||
bounds := Rectangle.{cast(float32)(x + (index % 2) * (item_width + gap)),
|
||||
cast(float32)(y + (index / 2) * (tile_height + gap)),
|
||||
cast(float32)item_width, cast(float32)tile_height}
|
||||
bounds := GridCellBounds(section_cells, index, tile_height)
|
||||
if section == 0 { pinned_slots[index] = bounds }
|
||||
app_launcher_draw_card(app, route, bounds, true)
|
||||
}
|
||||
y += ((count + 1) / 2) * (tile_height + gap)
|
||||
y += GridRowCount(section_cells, count) * (tile_height + gap)
|
||||
}
|
||||
if match_count == 0 {
|
||||
Text(app.ui.session, TextProps.{.text = LocaleText("launcher_no_results"),
|
||||
@@ -356,12 +366,8 @@ app_draw_launcher :: (app: *InnerBreeze) {
|
||||
if query.count == 0 && scrolled.opened &&
|
||||
PointInBounds(point.x, point.y, scrolled.viewport) &&
|
||||
PointInBounds(point.x, point.y, pinned_bounds) {
|
||||
row := cast(s32)(point.y - pinned_bounds.y - cast(float32)AppScale(36))
|
||||
if row < 0 { row = 0 }
|
||||
row /= tile_height + gap
|
||||
column: s32 = ifx point.x >= pinned_bounds.x + pinned_bounds.width * 0.5 then 1 else 0
|
||||
target = row * 2 + column
|
||||
if target > app.launcher_favorite_count { target = app.launcher_favorite_count }
|
||||
target = GridIndexAt(pinned_cells, point.x, point.y, tile_height,
|
||||
app.launcher_favorite_count)
|
||||
highlight := pinned_bounds
|
||||
if target < pinned_count { highlight = pinned_slots[target] }
|
||||
highlight = RectangleIntersection(highlight, scrolled.viewport)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#import "keys"
|
||||
#import, file "modal_rules.zi";
|
||||
#import, file "../habits/habit_types.zi";
|
||||
#import, file "../core/types.zi";
|
||||
@@ -66,7 +67,7 @@ app_nav_route_available :: (app: *InnerBreeze, route: s32) -> bool {
|
||||
c :: #system_library "c";
|
||||
app_leave_practice_config :: (app: *InnerBreeze) #foreign c;
|
||||
save_settings :: (app: *InnerBreeze) #foreign c;
|
||||
sync_account_load :: (account: *SyncAccount) -> s32 #foreign c;
|
||||
sync_account_load :: (account: *AccountKeys) -> s32 #foreign c;
|
||||
storage_get_setting_text :: (key: string) -> string #foreign c;
|
||||
|
||||
APP_BOTTOM_NAV_CONFIGURABLE_COUNT :: 7
|
||||
@@ -576,7 +577,7 @@ app_nav_profile_identity :: (app: *InnerBreeze, out: []u8, out_size: s64,
|
||||
subtitle[0] = cast(u8)0
|
||||
}
|
||||
|
||||
account: SyncAccount
|
||||
account: AccountKeys
|
||||
has_account := sync_account_load(*account) != 0
|
||||
alias: string = ""
|
||||
if has_account {
|
||||
@@ -601,7 +602,7 @@ app_nav_profile_identity :: (app: *InnerBreeze, out: []u8, out_size: s64,
|
||||
return
|
||||
}
|
||||
app_compact_public_id(
|
||||
AppTextFromCString(*account.public_id[0], SYNC_PUBLIC_ID_HEX_SIZE),
|
||||
AppTextFromCString(*account.public_id[0], ACCOUNT_PUBLIC_ID_HEX_SIZE),
|
||||
out, out_size)
|
||||
app_nav_copy_text(LocaleText("tab_profile"), subtitle, subtitle_size)
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ c :: #system_library "c";
|
||||
LOG_INFO :: 3
|
||||
LOG_WARNING :: 4
|
||||
LOG_ERROR :: 5
|
||||
#import, file "../platform/trace_log.zi";
|
||||
#import "raylib_trace"
|
||||
SyncLog :: (level: s32, message: string) {
|
||||
TraceLog(level, message)
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#import "keys"
|
||||
#import "drawing_props"
|
||||
#import "dropdown_props"
|
||||
#import "geometry"
|
||||
#import "swipe_props"
|
||||
#import "router_props"
|
||||
#import "session"
|
||||
#import, file "../platform/asset_download_types.zi";
|
||||
#import "file_download"
|
||||
#import, file "../platform/media_types.zi";
|
||||
#import, file "../core/types.zi";
|
||||
#import, file "route_types.zi";
|
||||
@@ -255,7 +256,7 @@ MeditationPracticeState :: struct {
|
||||
music_archive_extracted: s32
|
||||
music_network_error_notified: s32
|
||||
music: MusicHandle
|
||||
music_download: AssetDownload
|
||||
music_download: FileDownload
|
||||
music_cache_dir: [FS_PATH_MAX] u8
|
||||
music_status: [128] u8
|
||||
}
|
||||
@@ -457,7 +458,7 @@ InnerBreeze :: struct {
|
||||
sync_alias_focused: s32
|
||||
sync_alias_then_backup: s32
|
||||
sync_alias_input: [40] u8
|
||||
pending_sync_account: SyncAccount
|
||||
pending_sync_account: AccountKeys
|
||||
pending_sync_account_action: s32
|
||||
device_picker_scroll: s32
|
||||
fullscreen_enabled: s32
|
||||
|
||||
+14
-15
@@ -7,6 +7,7 @@ LOG_INFO :: 3
|
||||
LOG_WARNING :: 4
|
||||
LOG_ERROR :: 5
|
||||
#import, file "../platform/trace_log.zi";
|
||||
#import "raylib_trace"
|
||||
GetTime :: () -> float64 #foreign c;
|
||||
PackageNow :: () -> s64 #foreign c "now_seconds";
|
||||
#import, file "modal_rules.zi";
|
||||
@@ -17,9 +18,9 @@ PackageNow :: () -> s64 #foreign c "now_seconds";
|
||||
#import, file "exercise_types.zi";
|
||||
#import, file "../platform/web_storage.zi";
|
||||
#import, file "../platform/environment.zi";
|
||||
#import, file "../platform/asset_download.zi";
|
||||
#import, file "../platform/asset_download_types.zi";
|
||||
#import, file "../platform/android/android_device.zi";
|
||||
#import "file_download"
|
||||
#import "android_device"
|
||||
#import, file "../platform/android/android_activity.zi";
|
||||
#import, file "../platform/android/graphics_context.zi";
|
||||
#if #defined(PLATFORM_WEB) {
|
||||
#import "kryon/canvas_host"
|
||||
@@ -29,7 +30,7 @@ PackageNow :: () -> s64 #foreign c "now_seconds";
|
||||
#if #defined(DESKTOP_TRAY_ENABLED) {
|
||||
#import, file "../platform/desktop_tray.zi";
|
||||
}
|
||||
#import, file "../platform/uri.zi";
|
||||
#import "open_uri"
|
||||
#import "text_align"
|
||||
#import "text_props"
|
||||
#import "image_props"
|
||||
@@ -662,7 +663,7 @@ app_init :: (vapp: *void) {
|
||||
FramePacingReset()
|
||||
app.ui.session = SessionOpen()
|
||||
if !SessionValid(app.ui.session) { return }
|
||||
android_text_input_open(app.ui.session)
|
||||
AndroidTextInputOpen(app.ui.session)
|
||||
#if #defined(ANDROID_BUILD) {
|
||||
app.graphics_context = AndroidGraphicsContext()
|
||||
if practice_active(app) != null {
|
||||
@@ -872,15 +873,13 @@ handle_back_button :: (app: *InnerBreeze) {
|
||||
android_allow_screen_off()
|
||||
android_wakelock_release()
|
||||
}
|
||||
app_init(cast(*void)app)
|
||||
app.session_result = SessionResult.{}
|
||||
app_switch_screen(app, ScreenStart)
|
||||
} else if screen == ScreenSession {
|
||||
// When paused, exit immediately
|
||||
if app.session_paused != 0 {
|
||||
practice_active_background_stop(app)
|
||||
app_init(cast(*void)app)
|
||||
} else {
|
||||
// Show confirmation modal
|
||||
app_open_modal(app, cast(ModalType)ModalConfirmExitSession)
|
||||
// Paused, it leaves at once; otherwise it asks first.
|
||||
practice: *PracticeDefinition = practice_get(EXERCISE_WIM_HOF)
|
||||
if practice.request_exit != null {
|
||||
practice.request_exit(app)
|
||||
}
|
||||
} else if screen == ScreenMeditation {
|
||||
{
|
||||
@@ -1709,14 +1708,14 @@ app_destroy :: (vapp: *void) {
|
||||
}
|
||||
CloseBreakWindows()
|
||||
ClosePracticeWindow(app)
|
||||
ReleaseRuntimeAssetDownload(*app.meditation.music_download)
|
||||
FileDownloadRelease(*app.meditation.music_download)
|
||||
unused app_diary_save()
|
||||
PackageCancel()
|
||||
save_settings(app)
|
||||
settings_sync_account_cancel(app)
|
||||
LumiOnlineCancel()
|
||||
app_clear_disconnected_sync_work()
|
||||
android_text_input_close(app.ui.session)
|
||||
AndroidTextInputClose(app.ui.session)
|
||||
SessionClose(app.ui.session)
|
||||
habits_flush_save(app)
|
||||
if PreviewMode() == 0 {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// One QR code connection at a time, advanced by the frame loop. The device
|
||||
// showing the code polls Daochi's link mailbox for the other device; the
|
||||
// scanning device answers. See src/storage/device_link.zi for the protocol.
|
||||
#import "keys"
|
||||
#import "json_scan"
|
||||
#import "text"
|
||||
#import "vec"
|
||||
@@ -11,12 +12,12 @@
|
||||
#import, file "../platform/network_transport.zi";
|
||||
#import, file "../storage/account_types.zi";
|
||||
#import, file "../storage/device_link.zi";
|
||||
#import, file "../storage/sync_crypto.zi";
|
||||
#import "crypto"
|
||||
#import, file "../storage/storage_core.zi";
|
||||
#import, file "../storage/sync_account.zi";
|
||||
#import, file "../storage/sync_nodes.zi";
|
||||
#import, file "../cells/package_files.zi";
|
||||
#import, file "../platform/trace_log.zi";
|
||||
#import "raylib_trace"
|
||||
|
||||
c :: #system_library "c";
|
||||
DeviceLinkClock :: () -> float64 #foreign c "GetTime";
|
||||
@@ -126,7 +127,7 @@ DeviceLinkServer :: (output: []u8) -> bool {
|
||||
// without one, the scanning device sends its account to this device.
|
||||
DeviceLinkShow :: () -> bool {
|
||||
DeviceLinkReset()
|
||||
account: SyncAccount
|
||||
account: AccountKeys
|
||||
device_link.sends = sync_account_load(*account) != 0
|
||||
device_link.shows = true
|
||||
if !DeviceLinkServer(device_link.server[:]) || !DeviceLinkNewKeys(*device_link.keys) ||
|
||||
@@ -173,7 +174,7 @@ DeviceLinkScan :: (text: string) -> bool {
|
||||
DeviceLinkSend(DEVICE_LINK_PUT_REQUEST)
|
||||
return true
|
||||
}
|
||||
account: SyncAccount
|
||||
account: AccountKeys
|
||||
if sync_account_load(*account) == 0 {
|
||||
DeviceLinkFail("device_link_no_account")
|
||||
return false
|
||||
@@ -216,11 +217,11 @@ DeviceLinkSend :: (request: s32) {
|
||||
path := "/api/v1/link/get"
|
||||
if request == DEVICE_LINK_PUT_REQUEST {
|
||||
public: [DEVICE_LINK_KEY * 2 + 1]u8
|
||||
unused SyncCryptoBytesToHex(*device_link.keys.public[0], DEVICE_LINK_KEY, *public[0], public.count)
|
||||
unused BytesToHex(*device_link.keys.public[0], DEVICE_LINK_KEY, *public[0], public.count)
|
||||
BuilderPrint(*out, "{\"id\":\"%\",\"slot\":\"request\",\"data\":\"%\"}", id, TextUntilNul(public[:]))
|
||||
path = "/api/v1/link/put"
|
||||
} else if request == DEVICE_LINK_PUT_RESPONSE {
|
||||
account: SyncAccount
|
||||
account: AccountKeys
|
||||
if sync_account_load(*account) == 0 {
|
||||
DeviceLinkFail("device_link_no_account")
|
||||
return
|
||||
@@ -307,7 +308,7 @@ DeviceLinkFinished :: (status: s32) {
|
||||
message := TextFromBytes(device_link_message_in[:length])
|
||||
if request == DEVICE_LINK_GET_REQUEST {
|
||||
// The scanner's key: compare digits before sending the account.
|
||||
if length != DEVICE_LINK_KEY * 2 || SyncCryptoHexToBytes(message, *device_link.other[0], DEVICE_LINK_KEY) == 0 {
|
||||
if length != DEVICE_LINK_KEY * 2 || HexToBytes(message, *device_link.other[0], DEVICE_LINK_KEY) == 0 {
|
||||
DeviceLinkFailAt("device_link_failed", "reading the key", status)
|
||||
return
|
||||
}
|
||||
@@ -340,7 +341,7 @@ DeviceLinkUseServer :: () -> bool {
|
||||
}
|
||||
|
||||
// The received account for the screen to import.
|
||||
DeviceLinkAccountReceived :: () -> *SyncAccount {
|
||||
DeviceLinkAccountReceived :: () -> *AccountKeys {
|
||||
if device_link.stage != cast(DeviceLinkStage)DeviceLinkReceived || !device_link_pending.valid {
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -57,7 +57,6 @@ app_apply_orientation_preference :: (app: *InnerBreeze) {
|
||||
}
|
||||
if WebPlatform() != 0 {
|
||||
DeviceWebOrientation(app.orientation_mode)
|
||||
DeviceWebResize()
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#import, file "metrics.zi";
|
||||
#import, file "text_buffers.zi";
|
||||
#import, file "../platform/raylib_text_input.zi";
|
||||
#import, file "../platform/uri.zi";
|
||||
#import "open_uri"
|
||||
#import "button_props"
|
||||
#import "button_widget"
|
||||
#import "control_props"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#import "dpi"
|
||||
#import "drawing_props"
|
||||
#import "geometry"
|
||||
#import, file "../platform/environment.zi";
|
||||
#import, file "../platform/raylib_host.zi";
|
||||
@@ -66,7 +67,11 @@ UpdateDPI :: (view_width: s32, view_height: s32) {
|
||||
// The user's zoom scales everything drawn and narrows or widens the
|
||||
// layout; the text is baked at the size it ends up on screen.
|
||||
dpi_state = ZoomDPI(dpi_state, dpi_user_zoom)
|
||||
#if #defined(PLATFORM_WEB) == false {
|
||||
// The camera draws at render_scale, so vector icons rasterize at it too
|
||||
// (the web canvas adds its devicePixelRatio itself).
|
||||
#if #defined(PLATFORM_WEB) {
|
||||
SetPaintPixelScale(dpi_state.render_scale)
|
||||
} else {
|
||||
RaylibSetZoom(dpi_state.render_scale)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ HostGetEnvironment :: (name: *u8) -> *u8 #foreign c "getenv";
|
||||
}
|
||||
|
||||
#if #defined(ANDROID_BUILD) {
|
||||
#import, file "../platform/android/activity_jni.zi";
|
||||
#import "android_jni"
|
||||
}
|
||||
|
||||
#if #defined(PLATFORM_WEB) {
|
||||
@@ -94,9 +94,9 @@ app_locale_preferences :: () -> string {
|
||||
}
|
||||
#if #defined(ANDROID_BUILD) {
|
||||
host_locale_preferences[0] = cast(u8)0
|
||||
session: ActivityJniSession
|
||||
if activity_jni_attach(*session) != 0 {
|
||||
method := JniMethod(*session, "localePreferences", "()Ljava/lang/String;")
|
||||
session: AndroidJniSession
|
||||
if AndroidJniAttachCurrent(*session) != 0 {
|
||||
method := AndroidJniMethod(*session, "localePreferences", "()Ljava/lang/String;")
|
||||
env := session.env
|
||||
if method != null {
|
||||
result := env.functions.CallObjectMethodA(env, session.activity,
|
||||
@@ -109,7 +109,7 @@ app_locale_preferences :: () -> string {
|
||||
}
|
||||
}
|
||||
}
|
||||
activity_jni_detach(*session)
|
||||
AndroidJniDetachCurrent(*session)
|
||||
}
|
||||
return app_text_from_cstring(*host_locale_preferences[0], 256)
|
||||
}
|
||||
|
||||
@@ -31,11 +31,5 @@ LocaleDropdown :: (session: Session, props: DropdownProps) -> DropdownResult {
|
||||
if resolved.selected_index < 0 || resolved.selected_index >= count {
|
||||
resolved.selected_index = 0
|
||||
}
|
||||
if resolved.highlight_index < 0 || resolved.highlight_index >= count {
|
||||
resolved.highlight_index = resolved.selected_index
|
||||
}
|
||||
if resolved.scroll_offset < 0 {
|
||||
resolved.scroll_offset = 0
|
||||
}
|
||||
return Dropdown(session, resolved, options[0:count])
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
#import, file "route_host.zi";
|
||||
#import, file "text_buffers.zi";
|
||||
#import, file "../core/types.zi";
|
||||
#import, file "../platform/uri.zi";
|
||||
#import "open_uri"
|
||||
#import "button_props"
|
||||
#import "button_widget"
|
||||
#import "control_props"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#import "keys"
|
||||
#import "date_time"
|
||||
#import, file "modal_rules.zi";
|
||||
#import, file "../habits/habit_types.zi";
|
||||
@@ -461,7 +462,7 @@ setup_screenshot_scene :: (app: *InnerBreeze, request: *ScreenshotRequest) {
|
||||
app.nav_rail_collapsed = ifx scene_text == "navigation_collapsed" || scene_text == "navigation_profile_collapsed" then 1 else 0
|
||||
if scene_text.count >= 18 && scene_text[:18] == "navigation_profile" {
|
||||
// Profile previews stay inside the screenshot store and offline.
|
||||
account: SyncAccount = .{}
|
||||
account: AccountKeys = .{}
|
||||
if sync_account_generate(*account) != 0 {
|
||||
unused sync_account_save(*account,
|
||||
cast(SyncAccountLocalDataChoice)SYNC_ACCOUNT_LOCAL_DATA_ASK)
|
||||
@@ -615,7 +616,7 @@ setup_screenshot_scene :: (app: *InnerBreeze, request: *ScreenshotRequest) {
|
||||
app.breathing.screen = ScreenProfile
|
||||
} else if scene_text == "sync_review" || scene_text == "sync_review_no_changes" {
|
||||
// This path only runs in the screenshot mode's isolated data root.
|
||||
account: SyncAccount = .{}
|
||||
account: AccountKeys = .{}
|
||||
if sync_account_generate(*account) == 0 {
|
||||
return
|
||||
}
|
||||
@@ -657,7 +658,7 @@ setup_screenshot_scene :: (app: *InnerBreeze, request: *ScreenshotRequest) {
|
||||
app.breathing.screen = ScreenProfile
|
||||
app_open_modal(app, cast(ModalType)ModalSyncReview)
|
||||
} else if AppTextFromCString(*request.scene[0], 64) == "sync_disconnected" || AppTextFromCString(*request.scene[0], 64) == "sync_retry" {
|
||||
account: SyncAccount = .{}
|
||||
account: AccountKeys = .{}
|
||||
if sync_account_generate(*account) != 0 {
|
||||
sync_account_save(*account, cast(SyncAccountLocalDataChoice)SYNC_ACCOUNT_LOCAL_DATA_ASK)
|
||||
}
|
||||
@@ -674,7 +675,7 @@ setup_screenshot_scene :: (app: *InnerBreeze, request: *ScreenshotRequest) {
|
||||
}
|
||||
app.breathing.screen = ScreenProfile
|
||||
} else if AppTextFromCString(*request.scene[0], 64) == "sync_connected" {
|
||||
account: SyncAccount = .{}
|
||||
account: AccountKeys = .{}
|
||||
payload: *u8 = null
|
||||
if sync_account_generate(*account) != 0 {
|
||||
sync_account_save(*account, cast(SyncAccountLocalDataChoice)SYNC_ACCOUNT_LOCAL_DATA_ASK)
|
||||
@@ -689,8 +690,8 @@ setup_screenshot_scene :: (app: *InnerBreeze, request: *ScreenshotRequest) {
|
||||
sync_pass: s32 = 0
|
||||
while sync_pass < 4 {
|
||||
payload = storage_build_sync_payload_json(
|
||||
AppTextFromCString(*account.public_id[0], SYNC_PUBLIC_ID_HEX_SIZE),
|
||||
AppTextFromCString(*account.public_key_hex[0], SYNC_PUBLIC_KEY_HEX_SIZE))
|
||||
AppTextFromCString(*account.public_id[0], ACCOUNT_PUBLIC_ID_HEX_SIZE),
|
||||
AppTextFromCString(*account.public_key_hex[0], ACCOUNT_PUBLIC_KEY_HEX_SIZE))
|
||||
storage_free_sync_payload_json(payload)
|
||||
storage_apply_sync_response_json(
|
||||
"{\"protocol_version\":6,\"server_version\":1,\"changes\":{\"encrypted_records\":[]}}")
|
||||
|
||||
@@ -36,13 +36,21 @@ retry_after_sign_in :: (result: s32) -> bool {
|
||||
return result == cast(s32) SyncResult.SYNC_AUTH_FAILED
|
||||
}
|
||||
|
||||
// A payload that could not be built here, for example while the database was
|
||||
// briefly locked, retries on the same schedule without switching nodes
|
||||
// (owner request 2026-10-10: sync recovers by itself).
|
||||
retry_local_payload :: (result: s32) -> bool {
|
||||
return result == cast(s32) SyncResult.SYNC_PAYLOAD_FAILED
|
||||
}
|
||||
|
||||
#program_export
|
||||
sync_retry_decision :: (result: s32, attempt: s32) -> RetryDecision {
|
||||
attempt = retry_attempt_index(attempt)
|
||||
if result == cast(s32) SyncResult.SYNC_OK {
|
||||
return RetryDecision.{0, 0, 0}
|
||||
}
|
||||
if retry_is_temporary(result) || retry_after_sign_in(result) {
|
||||
retries := retry_is_temporary(result) || retry_after_sign_in(result)
|
||||
if retries || retry_local_payload(result) {
|
||||
next := retry_attempt_index(attempt + 1)
|
||||
return RetryDecision.{next, retry_delay_seconds(next), 0}
|
||||
}
|
||||
|
||||
@@ -45,21 +45,24 @@ ExpectedClamp :: (attempt: s32) -> s32 {
|
||||
|
||||
#law InvalidUrlStops forall attempt: -2..6 => sync_retry_decision(1, attempt) == RetryDecision.{ExpectedClamp(attempt), 0, 1};
|
||||
#law NoAccountStops forall attempt: -2..6 => sync_retry_decision(2, attempt) == RetryDecision.{ExpectedClamp(attempt), 0, 1};
|
||||
#law PayloadFailureStops forall attempt: -2..6 => sync_retry_decision(3, attempt) == RetryDecision.{ExpectedClamp(attempt), 0, 1};
|
||||
#law SigningFailureStops forall attempt: -2..6 => sync_retry_decision(5, attempt) == RetryDecision.{ExpectedClamp(attempt), 0, 1};
|
||||
// A rejected sign-in retries on the same schedule; the owner chose automatic
|
||||
// sync over waiting for the user after a failed sign-in (2026-10-04).
|
||||
#law AuthenticationFailureRetries forall attempt: -2..6 => sync_retry_decision(7, attempt) == RetryDecision.{ExpectedNext(ExpectedClamp(attempt)), ExpectedDelay(ExpectedNext(ExpectedClamp(attempt))), 0};
|
||||
// A payload that could not be built here, such as while the database was
|
||||
// briefly locked, retries on the same schedule; the owner wants sync to
|
||||
// recover by itself (2026-10-10).
|
||||
#law PayloadFailureRetries forall attempt: -2..6 => sync_retry_decision(3, attempt) == RetryDecision.{ExpectedNext(ExpectedClamp(attempt)), ExpectedDelay(ExpectedNext(ExpectedClamp(attempt))), 0};
|
||||
|
||||
// Any other code, including extremes of the persisted integer, stops retry.
|
||||
#law UnknownResultStops forall result: 8..40, attempt: -2..6 => sync_retry_decision(result, attempt) == RetryDecision.{ExpectedClamp(attempt), 0, 1};
|
||||
#law NegativeResultStops forall result: -40..-1, attempt: -2..6 => sync_retry_decision(result, attempt) == RetryDecision.{ExpectedClamp(attempt), 0, 1};
|
||||
|
||||
#law SavedDelayMatches forall attempt: -2..6 => app_sync_retry_delay(attempt) == cast(float64) ExpectedDelay(ExpectedClamp(attempt));
|
||||
// Success, the two temporary failures and a rejected sign-in need no user
|
||||
// action; everything else does.
|
||||
// Success, the two temporary failures, a rejected sign-in and a local
|
||||
// payload failure need no user action; everything else does.
|
||||
ExpectedNeedsAction :: (result: s32) -> s32 {
|
||||
if result == 0 || result == 4 || result == 6 || result == 7 { return 0 }
|
||||
if result == 0 || result == 3 || result == 4 || result == 6 || result == 7 { return 0 }
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
@@ -15,9 +15,7 @@
|
||||
#import, file "../storage/account_types.zi";
|
||||
#import, file "../storage/daochi_account.zi";
|
||||
#import, file "../storage/device_key.zi";
|
||||
#import, file "../storage/sync_crypto_random.zi";
|
||||
#import, file "../storage/sync_account_crypto.zi";
|
||||
#import, file "../storage/sync_account_encrypted.zi";
|
||||
#import "keys"
|
||||
#import, file "../storage/sync_async.zi";
|
||||
#import, file "../storage/storage_core.zi";
|
||||
#import, file "../storage/storage_layout.zi";
|
||||
@@ -72,7 +70,7 @@ TelegramAccountFlow :: struct {
|
||||
pending: PublicRendezvous
|
||||
owner_pending: OwnerRendezvous
|
||||
material: DelegateMaterial
|
||||
owner: SyncAccount
|
||||
owner: AccountKeys
|
||||
approved: GrantStorage
|
||||
transfer: NetworkTransfer
|
||||
owner_operation: OwnerAuthorizationOperation
|
||||
@@ -96,22 +94,22 @@ TelegramFlowStopOperations :: (flow: *TelegramAccountFlow) {
|
||||
cancel_transport.cancel(cancel_transport.context)
|
||||
flow.entry_cancel_waiting = false
|
||||
}
|
||||
SyncCryptoWipe(*flow.owner_cancel_response[0], 8193)
|
||||
SyncCryptoWipe(*flow.owner_cancel_body[0], 1025)
|
||||
SyncCryptoWipe(*flow.entry_cancel_response[0], 8193)
|
||||
SyncCryptoWipe(*flow.entry_cancel_body[0], 32768)
|
||||
SecureWipe(*flow.owner_cancel_response[0], 8193)
|
||||
SecureWipe(*flow.owner_cancel_body[0], 1025)
|
||||
SecureWipe(*flow.entry_cancel_response[0], 8193)
|
||||
SecureWipe(*flow.entry_cancel_body[0], 32768)
|
||||
flow.cancellation_deadline = 0
|
||||
flow.waiting = false
|
||||
}
|
||||
|
||||
TelegramFlowWipeSecrets :: (flow: *TelegramAccountFlow) {
|
||||
TelegramAccountClearPassword(*flow.recovery_input)
|
||||
SyncCryptoWipe(*flow.owner.private_key_hex[0], SYNC_PRIVATE_KEY_HEX_SIZE)
|
||||
SyncCryptoWipe(*flow.init_data[0], 16385)
|
||||
SyncCryptoWipe(*flow.capsule[0], 65537)
|
||||
SyncCryptoWipe(*flow.recovery[0], 17664)
|
||||
SyncCryptoWipe(*flow.body[0], 32768)
|
||||
SyncCryptoWipe(*flow.response[0], 65537)
|
||||
SecureWipe(*flow.owner.private_key_hex[0], ACCOUNT_PRIVATE_KEY_HEX_SIZE)
|
||||
SecureWipe(*flow.init_data[0], 16385)
|
||||
SecureWipe(*flow.capsule[0], 65537)
|
||||
SecureWipe(*flow.recovery[0], 17664)
|
||||
SecureWipe(*flow.body[0], 32768)
|
||||
SecureWipe(*flow.response[0], 65537)
|
||||
WipeDelegateMaterial(*flow.material)
|
||||
}
|
||||
|
||||
@@ -190,10 +188,10 @@ TelegramFlowPumpRemoteCancellation :: (flow: *TelegramAccountFlow) {
|
||||
}
|
||||
}
|
||||
if !flow.owner_cancel_operation.active && !flow.entry_cancel_waiting {
|
||||
SyncCryptoWipe(*flow.owner_cancel_response[0], 8193)
|
||||
SyncCryptoWipe(*flow.owner_cancel_body[0], 1025)
|
||||
SyncCryptoWipe(*flow.entry_cancel_response[0], 8193)
|
||||
SyncCryptoWipe(*flow.entry_cancel_body[0], 32768)
|
||||
SecureWipe(*flow.owner_cancel_response[0], 8193)
|
||||
SecureWipe(*flow.owner_cancel_body[0], 1025)
|
||||
SecureWipe(*flow.entry_cancel_response[0], 8193)
|
||||
SecureWipe(*flow.entry_cancel_body[0], 32768)
|
||||
flow.cancellation_deadline = 0
|
||||
}
|
||||
}
|
||||
@@ -409,7 +407,7 @@ TelegramFlowHandleResponse :: (flow: *TelegramAccountFlow) {
|
||||
TelegramFlowFail(flow)
|
||||
return
|
||||
}
|
||||
defer { SyncCryptoWipe(*snapshot[0], 65537) }
|
||||
defer { SecureWipe(*snapshot[0], 65537) }
|
||||
json := TextUntilNul(snapshot[:])
|
||||
now := CurrentStoredDelegateTime(null)
|
||||
phase := flow.phase
|
||||
@@ -460,7 +458,7 @@ TelegramFlowHandleResponse :: (flow: *TelegramAccountFlow) {
|
||||
if flow.status != 200 || !ReadTelegramEntryIdentity(json, *flow.challenge,
|
||||
TextUntilNul(flow.material.client_id[:]), TextUntilNul(flow.material.signing.public_hex[:]),
|
||||
TextUntilNul(flow.material.encryption_hex[:]), now, *bound) ||
|
||||
TextUntilNul(bound.account_id[:]) != AccountField(*flow.owner.public_id[0], SYNC_PUBLIC_ID_HEX_SIZE) ||
|
||||
TextUntilNul(bound.account_id[:]) != AccountFieldText(*flow.owner.public_id[0], ACCOUNT_PUBLIC_ID_HEX_SIZE) ||
|
||||
TextUntilNul(bound.status[:]) != "bound" {
|
||||
TelegramFlowFail(flow)
|
||||
return
|
||||
@@ -473,7 +471,7 @@ TelegramFlowHandleResponse :: (flow: *TelegramAccountFlow) {
|
||||
} else if phase == 6 {
|
||||
if flow.status != 200 || !ReadOwnerRendezvous(json, *flow.owner_pending) ||
|
||||
!LumiAuthorizationPendingValid(*flow.owner_pending,
|
||||
AccountField(*flow.owner.public_id[0], SYNC_PUBLIC_ID_HEX_SIZE), TelegramFlowServer, now, false) {
|
||||
AccountFieldText(*flow.owner.public_id[0], ACCOUNT_PUBLIC_ID_HEX_SIZE), TelegramFlowServer, now, false) {
|
||||
TelegramFlowFail(flow)
|
||||
return
|
||||
}
|
||||
@@ -563,8 +561,8 @@ TelegramFlowHandleResponse :: (flow: *TelegramAccountFlow) {
|
||||
TelegramFlowFail(flow)
|
||||
return
|
||||
}
|
||||
SyncCryptoWipe(*flow.owner.private_key_hex[0], SYNC_PRIVATE_KEY_HEX_SIZE)
|
||||
SyncCryptoWipe(*flow.init_data[0], 16385)
|
||||
SecureWipe(*flow.owner.private_key_hex[0], ACCOUNT_PRIVATE_KEY_HEX_SIZE)
|
||||
SecureWipe(*flow.init_data[0], 16385)
|
||||
flow.phase = 14
|
||||
flow.view.visible = false
|
||||
flow.view.busy = false
|
||||
@@ -572,7 +570,7 @@ TelegramFlowHandleResponse :: (flow: *TelegramAccountFlow) {
|
||||
if !ExportStoredDelegateCapsule(flow.capsule[:]) ||
|
||||
!BeginTelegramProtectedOperation(*flow.protected_operation, 1,
|
||||
TextUntilNul(flow.capsule[:]), flow.response[:]) {
|
||||
SyncCryptoWipe(*flow.capsule[0], 65537)
|
||||
SecureWipe(*flow.capsule[0], 65537)
|
||||
flow.protected_phase = 0
|
||||
}
|
||||
WipeDelegateMaterial(*flow.material)
|
||||
@@ -580,7 +578,7 @@ TelegramFlowHandleResponse :: (flow: *TelegramAccountFlow) {
|
||||
} else if phase == 15 {
|
||||
if flow.status != 200 || !ReadOwnerRendezvous(json, *flow.owner_pending) ||
|
||||
!LumiAuthorizationPendingValid(*flow.owner_pending,
|
||||
AccountField(*flow.owner.public_id[0], SYNC_PUBLIC_ID_HEX_SIZE), TelegramFlowServer, now, true) ||
|
||||
AccountFieldText(*flow.owner.public_id[0], ACCOUNT_PUBLIC_ID_HEX_SIZE), TelegramFlowServer, now, true) ||
|
||||
TextUntilNul(flow.owner_pending.request_id[:]) != TextUntilNul(flow.pending.request_id[:]) ||
|
||||
TextUntilNul(flow.owner_pending.challenge[:]) != TextUntilNul(flow.pending.challenge[:]) ||
|
||||
flow.owner_pending.expires_at != flow.pending.expires_at ||
|
||||
@@ -650,7 +648,7 @@ HandleTelegramAccountAction :: (app: *InnerBreeze, action: s32) {
|
||||
now := CurrentStoredDelegateTime(null)
|
||||
if action == 1 {
|
||||
if flow.initial_owner[0] != cast(u8)0 || flow.identity.account_id[0] != cast(u8)0 ||
|
||||
storage_sync_data_owner_public_id() != "" || CreateSyncAccount(*flow.owner) == 0 {
|
||||
storage_sync_data_owner_public_id() != "" || CreateAccountKeys(*flow.owner) == 0 {
|
||||
TelegramFlowFail(flow)
|
||||
return
|
||||
}
|
||||
@@ -663,18 +661,18 @@ HandleTelegramAccountAction :: (app: *InnerBreeze, action: s32) {
|
||||
{
|
||||
passphrase := TextUntilNul(flow.recovery_input.value[:])
|
||||
saved = flow.temporary_owner && passphrase.count >= 12 &&
|
||||
ExportSyncAccountTextEncrypted(*flow.owner, passphrase, *flow.recovery[0], 17664) != 0 &&
|
||||
AccountKeysEncryptedText(*flow.owner, passphrase, *flow.recovery[0], 17664) != 0 &&
|
||||
HashText(TextUntilNul(flow.recovery[:]), flow.backup_digest[:]) &&
|
||||
DownloadTelegramRecoveryFile(TextUntilNul(flow.recovery[:]))
|
||||
}
|
||||
if !saved {
|
||||
TelegramAccountClearPassword(*flow.recovery_input)
|
||||
SyncCryptoWipe(*flow.recovery[0], 17664)
|
||||
SecureWipe(*flow.recovery[0], 17664)
|
||||
flow.view.restore_failed = true
|
||||
return
|
||||
}
|
||||
TelegramAccountClearPassword(*flow.recovery_input)
|
||||
SyncCryptoWipe(*flow.recovery[0], 17664)
|
||||
SecureWipe(*flow.recovery[0], 17664)
|
||||
// A browser download click is not evidence of a saved backup. Require
|
||||
// the saved ciphertext to be selected and matched before binding.
|
||||
flow.backup_saved = false
|
||||
@@ -724,7 +722,7 @@ HandleTelegramAccountAction :: (app: *InnerBreeze, action: s32) {
|
||||
!TelegramFlowStartChallenge(flow) {
|
||||
TelegramFlowFail(flow)
|
||||
}
|
||||
SyncCryptoWipe(*flow.capsule[0], 65537)
|
||||
SecureWipe(*flow.capsule[0], 65537)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -758,7 +756,7 @@ TelegramAccountFlowPump :: (app: *InnerBreeze) {
|
||||
}
|
||||
if result == 0 { return }
|
||||
if flow.protected_phase == 1 {
|
||||
if result < 0 { SyncCryptoWipe(*flow.capsule[0], 65537) }
|
||||
if result < 0 { SecureWipe(*flow.capsule[0], 65537) }
|
||||
if !SetVerifiedDelegateIdentity(flow.environment.bot_id, flow.identity.telegram_id, now + 300) {
|
||||
TelegramFlowFail(flow)
|
||||
} else {
|
||||
@@ -772,14 +770,14 @@ TelegramAccountFlowPump :: (app: *InnerBreeze) {
|
||||
}
|
||||
}
|
||||
} else if flow.protected_phase == 2 {
|
||||
SyncCryptoWipe(*flow.capsule[0], 65537)
|
||||
SecureWipe(*flow.capsule[0], 65537)
|
||||
} else if flow.protected_phase == 5 {
|
||||
flow.view.busy = false
|
||||
digest: [65]u8
|
||||
valid := result > 0 && flow.temporary_owner &&
|
||||
HashText(TextUntilNul(flow.recovery[:]), digest[:]) &&
|
||||
TextUntilNul(digest[:]) == TextUntilNul(flow.backup_digest[:])
|
||||
SyncCryptoWipe(*flow.recovery[0], 17664)
|
||||
SecureWipe(*flow.recovery[0], 17664)
|
||||
if !valid {
|
||||
flow.view.restore_failed = true
|
||||
flow.protected_phase = 0
|
||||
@@ -790,29 +788,29 @@ TelegramAccountFlowPump :: (app: *InnerBreeze) {
|
||||
flow.view.status = ""
|
||||
flow.view.action_labels[7] = ""
|
||||
if !BuildTelegramEntryActionBody(*flow.identity, *flow.material, "bind",
|
||||
AccountField(*flow.owner.public_id[0], SYNC_PUBLIC_ID_HEX_SIZE), now, flow.body[:]) ||
|
||||
AccountFieldText(*flow.owner.public_id[0], ACCOUNT_PUBLIC_ID_HEX_SIZE), now, flow.body[:]) ||
|
||||
!TelegramFlowOwnerRequest(flow, "/api/v1/telegram/account/bind", true, 5) {
|
||||
TelegramFlowFail(flow)
|
||||
}
|
||||
} else if flow.protected_phase == 4 {
|
||||
flow.view.busy = false
|
||||
if result < 0 { TelegramAccountClearPassword(*flow.recovery_input); return }
|
||||
candidate: SyncAccount
|
||||
valid := ParseSyncAccountTextEncrypted(TextUntilNul(flow.recovery[:]),
|
||||
candidate: AccountKeys
|
||||
valid := ParseEncryptedAccountKeys(TextUntilNul(flow.recovery[:]),
|
||||
TextUntilNul(flow.recovery_input.value[:]), *candidate) != 0
|
||||
TelegramAccountClearPassword(*flow.recovery_input)
|
||||
SyncCryptoWipe(*flow.recovery[0], 17664)
|
||||
owner := AccountField(*candidate.public_id[0], SYNC_PUBLIC_ID_HEX_SIZE)
|
||||
SecureWipe(*flow.recovery[0], 17664)
|
||||
owner := AccountFieldText(*candidate.public_id[0], ACCOUNT_PUBLIC_ID_HEX_SIZE)
|
||||
valid = valid && (flow.identity.account_id[0] == cast(u8)0 ||
|
||||
TextUntilNul(flow.identity.account_id[:]) == owner) &&
|
||||
(storage_sync_data_owner_public_id() == "" || storage_sync_data_owner_public_id() == owner)
|
||||
if !valid {
|
||||
SyncCryptoWipe(*candidate.private_key_hex[0], SYNC_PRIVATE_KEY_HEX_SIZE)
|
||||
SecureWipe(*candidate.private_key_hex[0], ACCOUNT_PRIVATE_KEY_HEX_SIZE)
|
||||
flow.view.restore_failed = true
|
||||
return
|
||||
}
|
||||
flow.owner = candidate
|
||||
SyncCryptoWipe(*candidate.private_key_hex[0], SYNC_PRIVATE_KEY_HEX_SIZE)
|
||||
SecureWipe(*candidate.private_key_hex[0], ACCOUNT_PRIVATE_KEY_HEX_SIZE)
|
||||
flow.temporary_owner = true
|
||||
flow.backup_saved = true
|
||||
flow.view.restore_failed = false
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#import "text_buffer"
|
||||
#import "auth"
|
||||
#import, file "../storage/device_key.zi";
|
||||
#import, file "../storage/sync_crypto.zi";
|
||||
#import, file "../storage/sync_crypto_random.zi";
|
||||
#import "crypto"
|
||||
#import "keys"
|
||||
#import, file "../storage/delegate_store.zi";
|
||||
|
||||
TelegramEnvironment :: struct {
|
||||
@@ -440,7 +440,7 @@ TelegramRawInitDigest :: (rawInit: string, botID: s64, output: []u8) -> bool {
|
||||
if !has_hash || !has_date || !has_user || !writer.valid {
|
||||
return false
|
||||
}
|
||||
SyncCryptoSha256Hex(*canonical[0], writer.cursor, *output[0])
|
||||
Sha256Hex(*canonical[0], writer.cursor, *output[0])
|
||||
return LowerHex(TextUntilNul(output), 64)
|
||||
}
|
||||
|
||||
@@ -498,7 +498,7 @@ BuildTelegramEntryVerifyBody :: (challenge: *TelegramEntryChallenge,
|
||||
}
|
||||
message: [4096]u8
|
||||
signature: [129]u8
|
||||
defer { SyncCryptoWipe(*signature[0], 129) }
|
||||
defer { SecureWipe(*signature[0], 129) }
|
||||
writer := Writer.{message[:], 0, true}
|
||||
writer = EntryWriteLine(writer, "daochi-telegram-entry-verify-v1")
|
||||
writer = EntryWriteChallenge(writer, challenge)
|
||||
@@ -558,7 +558,7 @@ BuildTelegramEntryActionBody :: (identity: *TelegramEntryIdentity,
|
||||
}
|
||||
message: [4096]u8
|
||||
signature: [129]u8
|
||||
defer { SyncCryptoWipe(*signature[0], 129) }
|
||||
defer { SecureWipe(*signature[0], 129) }
|
||||
writer := Writer.{message[:], 0, true}
|
||||
writer = EntryWriteLine(writer, "daochi-telegram-entry-action-v1")
|
||||
writer = EntryWriteLine(writer, action)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#import, file "locale.zi";
|
||||
#import, file "../core/version.zi";
|
||||
#import, file "../storage/storage_core.zi";
|
||||
#import, file "../storage/sync_crypto.zi";
|
||||
#import "crypto"
|
||||
#import, file "current_app.zi";
|
||||
#import, file "app_types.zi";
|
||||
|
||||
@@ -111,7 +111,7 @@ UpdateArtifactFailed :: () {
|
||||
UpdateDigestMatches :: () -> bool {
|
||||
digest: [32]u8
|
||||
Sha256Finish(*update_digest, *digest[0])
|
||||
if SyncCryptoBytesToHex(*digest[0], 32,
|
||||
if BytesToHex(*digest[0], 32,
|
||||
*update_digest_text[0], 65) == 0 { return false }
|
||||
index: s32 = 0
|
||||
while index < 64 {
|
||||
|
||||
+14
-14
@@ -7,8 +7,8 @@ c :: #system_library "c";
|
||||
#import, file "../storage/storage_core.zi";
|
||||
#import, file "../storage/storage_sessions.zi";
|
||||
#import, file "../storage/session_mood.zi";
|
||||
#import, file "../storage/sync_account_parse.zi";
|
||||
#import, file "../storage/sync_crypto.zi";
|
||||
#import "keys"
|
||||
#import "crypto"
|
||||
#import, file "../storage/data.zi";
|
||||
#import, file "../breaks/break_types.zi";
|
||||
#import, file "../screens/habits_screen.zi";
|
||||
@@ -58,7 +58,7 @@ using AppThemeMode;
|
||||
using AppThemeSource;
|
||||
|
||||
#if #defined(PLATFORM_WEB) {
|
||||
web_test_source_account: SyncAccount;
|
||||
web_test_source_account: AccountKeys;
|
||||
web_test_public_key: [1312] u8;
|
||||
web_test_private_key: [2560] u8;
|
||||
web_test_sync_key_import_status: s32;
|
||||
@@ -112,7 +112,7 @@ using AppThemeSource;
|
||||
storage_load_session_checkin(path, *checkin) != 0 &&
|
||||
checkin.mood_after == 4)
|
||||
}
|
||||
web_test_make_sync_account :: (account: *SyncAccount) {
|
||||
web_test_make_sync_account :: (account: *AccountKeys) {
|
||||
if account == null {
|
||||
return
|
||||
}
|
||||
@@ -130,12 +130,12 @@ using AppThemeSource;
|
||||
i += 1
|
||||
}
|
||||
}
|
||||
SyncCryptoSha256Hex(*web_test_public_key[0], size_of(type_of(web_test_public_key)),
|
||||
Sha256Hex(*web_test_public_key[0], size_of(type_of(web_test_public_key)),
|
||||
*account.public_id[0])
|
||||
unused SyncCryptoBytesToHex(*web_test_public_key[0], size_of(type_of(web_test_public_key)),
|
||||
unused BytesToHex(*web_test_public_key[0], size_of(type_of(web_test_public_key)),
|
||||
*account.public_key_hex[0],
|
||||
size_of(type_of(account.public_key_hex)))
|
||||
unused SyncCryptoBytesToHex(*web_test_private_key[0], size_of(type_of(web_test_private_key)),
|
||||
unused BytesToHex(*web_test_private_key[0], size_of(type_of(web_test_private_key)),
|
||||
*account.private_key_hex[0],
|
||||
size_of(type_of(account.private_key_hex)))
|
||||
}
|
||||
@@ -497,32 +497,32 @@ using AppThemeSource;
|
||||
}
|
||||
#program_export
|
||||
app_web_test_sync_key_state :: () -> s32 {
|
||||
source: *SyncAccount = *web_test_source_account
|
||||
source: *AccountKeys = *web_test_source_account
|
||||
if web_test_sync_key_import_status != 1 {
|
||||
return web_test_sync_key_import_status
|
||||
}
|
||||
if ValidateSyncAccount(source) == 0 {
|
||||
if ValidateAccountKeys(source) == 0 {
|
||||
return -10
|
||||
}
|
||||
return 1
|
||||
}
|
||||
#program_export
|
||||
app_web_test_import_sync_key :: () {
|
||||
source: *SyncAccount = *web_test_source_account
|
||||
source: *AccountKeys = *web_test_source_account
|
||||
web_test_sync_key_import_status = 0
|
||||
data_init()
|
||||
web_test_make_sync_account(source)
|
||||
if ValidateSyncAccount(source) == 0 {
|
||||
if ValidateAccountKeys(source) == 0 {
|
||||
web_test_sync_key_import_status = -1
|
||||
return
|
||||
}
|
||||
storage_settings_begin_write()
|
||||
storage_set_setting_text("sync_public_id",
|
||||
AppTextFromCString(*source.public_id[0], SYNC_PUBLIC_ID_HEX_SIZE))
|
||||
AppTextFromCString(*source.public_id[0], ACCOUNT_PUBLIC_ID_HEX_SIZE))
|
||||
storage_set_setting_text("sync_public_key",
|
||||
AppTextFromCString(*source.public_key_hex[0], SYNC_PUBLIC_KEY_HEX_SIZE))
|
||||
AppTextFromCString(*source.public_key_hex[0], ACCOUNT_PUBLIC_KEY_HEX_SIZE))
|
||||
storage_set_setting_text("sync_private_key",
|
||||
AppTextFromCString(*source.private_key_hex[0], SYNC_PRIVATE_KEY_HEX_SIZE))
|
||||
AppTextFromCString(*source.private_key_hex[0], ACCOUNT_PRIVATE_KEY_HEX_SIZE))
|
||||
storage_set_setting_text("sync_account_alias", "")
|
||||
storage_set_sync_enabled(0)
|
||||
storage_settings_end_write()
|
||||
|
||||
@@ -47,8 +47,8 @@ using NativeWindowFlags;
|
||||
#import, file "../app/locale.zi";
|
||||
#import, file "../app/app_route_state.zi";
|
||||
#import, file "../app/app_modal_state.zi";
|
||||
#import, file "../platform/secondary_window.zi";
|
||||
#import, file "../platform/activity.zi";
|
||||
#import "raylib_secondary_window"
|
||||
#import "idle_time"
|
||||
#import "text_widget"
|
||||
#import "box_widget"
|
||||
#import "box_props"
|
||||
@@ -177,7 +177,7 @@ break_fallback_input_seen :: () -> s32 {
|
||||
}
|
||||
|
||||
break_sample_activity :: (app: *InnerBreeze, idle_ms_out: *s32) -> s32 {
|
||||
idle_ms := ActivityGetIdleMilliseconds()
|
||||
idle_ms := IdleMilliseconds()
|
||||
if idle_ms_out != null {
|
||||
idle_ms_out.* = cast(s32)idle_ms
|
||||
}
|
||||
@@ -227,7 +227,7 @@ break_engine_open_window :: (app: *InnerBreeze, t: s32) {
|
||||
// Wayland intentionally does not permit a global keyboard grab, but
|
||||
// The app-owned secondary window remains available on Wayland, where
|
||||
// a global keyboard grab is not available.
|
||||
if ActivityIsWayland() {
|
||||
if IsWaylandSession() {
|
||||
ClearWindowState(cast(u32)128)
|
||||
RestoreWindow()
|
||||
SetWindowFocused()
|
||||
@@ -318,7 +318,7 @@ app_breaks_window_update :: (app: *InnerBreeze) {
|
||||
}
|
||||
|
||||
unused SetSecondaryWindowKeyboardGrab(break_window,
|
||||
app.break_block_mode >= 1 && !ActivityIsWayland())
|
||||
app.break_block_mode >= 1 && !IsWaylandSession())
|
||||
|
||||
if BeginSecondaryWindow(break_window) {
|
||||
main_session := app.ui.session
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -51,7 +51,9 @@ AppToolContext :: (app: *InnerBreeze) -> string {
|
||||
LumiJsonString(*out, habit.id)
|
||||
BuilderPrint(*out, ",\"title\":")
|
||||
LumiJsonString(*out, habit.title)
|
||||
BuilderPrint(*out, ",\"done\":%}", habit.done)
|
||||
progress := LumiHabitProgressAt(app, index)
|
||||
BuilderPrint(*out, ",\"done\":%,\"scheduled_last_14_days\":%,\"done_last_14_days\":%,\"streak_days\":%}",
|
||||
habit.done, progress.scheduled_days, progress.done_days, progress.streak)
|
||||
}
|
||||
BuilderPrint(*out, "],\"tasks\":[")
|
||||
if app_nav_route_available(app, APP_NAV_ROUTE_ELIST) {
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#import, file "inbe_types.zi";
|
||||
|
||||
PackageCount :: 7
|
||||
PackageHostAPI :: 5
|
||||
PackageModuleAPI :: 2
|
||||
PackageMaximumBytes :: 67108864
|
||||
|
||||
PackageName :: (index: s32) -> string {
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
// Undo and redo for the Diary entry on screen. The host keeps copies of the
|
||||
// entry's text because the Diary package's values last only one run. Typing
|
||||
// within a moment is one step; a spelling correction, an undo and a redo are
|
||||
// steps of their own.
|
||||
#import "vec"
|
||||
#import "text"
|
||||
#import "byte_text_linux"
|
||||
|
||||
DIARY_HISTORY_DEPTH :: 64
|
||||
// Typing joins the open step until it pauses this long or the step is this
|
||||
// old, in seconds.
|
||||
DIARY_HISTORY_PAUSE :: 1.0
|
||||
DIARY_HISTORY_SPAN :: 5.0
|
||||
|
||||
DiaryHistory :: struct {
|
||||
year: s32
|
||||
month: s32
|
||||
day: s32
|
||||
// Owned copies, freed by DiaryHistoryFree.
|
||||
current: string
|
||||
undo: [DIARY_HISTORY_DEPTH]string
|
||||
undo_count: s32
|
||||
redo: [DIARY_HISTORY_DEPTH]string
|
||||
redo_count: s32
|
||||
typing: bool
|
||||
typed_at: float64
|
||||
step_started: float64
|
||||
}
|
||||
|
||||
// A replacement of text[start:end], as the Diary package applies edits.
|
||||
DiaryEdit :: struct {
|
||||
start: s32
|
||||
end: s32
|
||||
replacement: string
|
||||
}
|
||||
|
||||
c :: #system_library "c";
|
||||
DiaryHistoryFreeBytes :: (bytes: *u8) #foreign c "free";
|
||||
|
||||
DiaryHistoryCopy :: (text: string) -> string {
|
||||
copy: Vec(u8)
|
||||
BuilderPrint(*copy, "%", text)
|
||||
return BuilderFinish(copy)
|
||||
}
|
||||
|
||||
DiaryHistoryFree :: (value: string) {
|
||||
if value.count == 0 {
|
||||
return
|
||||
}
|
||||
bytes := cast(*TextDescriptor)(*value)
|
||||
DiaryHistoryFreeBytes(bytes.data)
|
||||
}
|
||||
|
||||
DiaryHistoryPush :: (steps: []string, count: *s32, snapshot: string) {
|
||||
if count.* == cast(s32)steps.count {
|
||||
// The oldest step makes room for the newest.
|
||||
DiaryHistoryFree(steps[0])
|
||||
for index: cast(s32)1..count.* - 1 {
|
||||
steps[index - 1] = steps[index]
|
||||
}
|
||||
count.* -= 1
|
||||
}
|
||||
steps[count.*] = snapshot
|
||||
count.* += 1
|
||||
}
|
||||
|
||||
DiaryHistoryDropRedo :: (history: *DiaryHistory) {
|
||||
for index: cast(s32)0..history.redo_count - 1 {
|
||||
DiaryHistoryFree(history.redo[index])
|
||||
history.redo[index] = ""
|
||||
}
|
||||
history.redo_count = 0
|
||||
}
|
||||
|
||||
DiaryHistoryClear :: (history: *DiaryHistory) {
|
||||
DiaryHistoryFree(history.current)
|
||||
for index: cast(s32)0..history.undo_count - 1 {
|
||||
DiaryHistoryFree(history.undo[index])
|
||||
}
|
||||
DiaryHistoryDropRedo(history)
|
||||
history.* = DiaryHistory.{}
|
||||
}
|
||||
|
||||
// Records the entry as it is after a frame. Another day starts a new
|
||||
// history. typing is false for a change that must be its own step.
|
||||
DiaryHistoryObserve :: (history: *DiaryHistory, year: s32, month: s32, day: s32,
|
||||
text: string, now: float64, typing: bool) {
|
||||
if history.year != year || history.month != month || history.day != day {
|
||||
DiaryHistoryClear(history)
|
||||
history.year = year
|
||||
history.month = month
|
||||
history.day = day
|
||||
history.current = DiaryHistoryCopy(text)
|
||||
return
|
||||
}
|
||||
if history.current == text {
|
||||
return
|
||||
}
|
||||
joins := typing && history.typing &&
|
||||
now - history.typed_at < DIARY_HISTORY_PAUSE &&
|
||||
now - history.step_started < DIARY_HISTORY_SPAN
|
||||
if joins {
|
||||
DiaryHistoryFree(history.current)
|
||||
} else {
|
||||
DiaryHistoryPush(history.undo[:], *history.undo_count, history.current)
|
||||
history.step_started = now
|
||||
}
|
||||
DiaryHistoryDropRedo(history)
|
||||
history.current = DiaryHistoryCopy(text)
|
||||
history.typing = typing
|
||||
history.typed_at = now
|
||||
}
|
||||
|
||||
// Moves back one step. The history's current text becomes the text the host
|
||||
// then shows; false means there is nothing to undo.
|
||||
DiaryHistoryUndo :: (history: *DiaryHistory) -> bool {
|
||||
if history.undo_count == 0 {
|
||||
return false
|
||||
}
|
||||
history.undo_count -= 1
|
||||
DiaryHistoryPush(history.redo[:], *history.redo_count, history.current)
|
||||
history.current = history.undo[history.undo_count]
|
||||
history.undo[history.undo_count] = ""
|
||||
history.typing = false
|
||||
return true
|
||||
}
|
||||
|
||||
DiaryHistoryRedo :: (history: *DiaryHistory) -> bool {
|
||||
if history.redo_count == 0 {
|
||||
return false
|
||||
}
|
||||
history.redo_count -= 1
|
||||
DiaryHistoryPush(history.undo[:], *history.undo_count, history.current)
|
||||
history.current = history.redo[history.redo_count]
|
||||
history.redo[history.redo_count] = ""
|
||||
history.typing = false
|
||||
return true
|
||||
}
|
||||
|
||||
DiaryContinuationByte :: (byte: u8) -> bool {
|
||||
return (byte & cast(u8)192) == cast(u8)128
|
||||
}
|
||||
|
||||
// The smallest replacement that turns from into to, on whole UTF-8
|
||||
// characters, so the caret lands just after the changed text.
|
||||
DiaryHistoryEdit :: (from: string, to: string) -> DiaryEdit {
|
||||
shorter := ifx from.count < to.count then from.count else to.count
|
||||
prefix: s64 = 0
|
||||
while prefix < shorter && from[prefix] == to[prefix] {
|
||||
prefix += 1
|
||||
}
|
||||
while prefix > 0 &&
|
||||
((prefix < from.count && DiaryContinuationByte(from[prefix])) ||
|
||||
(prefix < to.count && DiaryContinuationByte(to[prefix]))) {
|
||||
prefix -= 1
|
||||
}
|
||||
suffix: s64 = 0
|
||||
while suffix < from.count - prefix && suffix < to.count - prefix &&
|
||||
from[from.count - 1 - suffix] == to[to.count - 1 - suffix] {
|
||||
suffix += 1
|
||||
}
|
||||
// The shared ending is the same bytes in both texts, so one check keeps
|
||||
// it on a character boundary in each.
|
||||
while suffix > 0 && DiaryContinuationByte(from[from.count - suffix]) {
|
||||
suffix -= 1
|
||||
}
|
||||
return DiaryEdit.{.start = cast(s32)prefix, .end = cast(s32)(from.count - suffix),
|
||||
.replacement = to[prefix:to.count - suffix]}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
#import "vec"
|
||||
#import "text"
|
||||
#import, file "../storage/cell_records.zi";
|
||||
#import, file "../storage/sync_crypto.zi";
|
||||
#import "crypto"
|
||||
#import, file "lumi_store.zi";
|
||||
#import, file "package_files.zi";
|
||||
#import, file "../storage/storage_core.zi";
|
||||
@@ -47,7 +47,7 @@ DiaryRecordSave :: (name: string, data: string) -> bool {
|
||||
size := data.count - start
|
||||
if size > DIARY_CHUNK_BYTES { size = DIARY_CHUNK_BYTES }
|
||||
encoded: [DIARY_CHUNK_BYTES * 2 + 1]u8
|
||||
if SyncCryptoBytesToHex(*descriptor.data[start], size, *encoded[0], encoded.count) == 0 {
|
||||
if BytesToHex(*descriptor.data[start], size, *encoded[0], encoded.count) == 0 {
|
||||
return false
|
||||
}
|
||||
chunk_key := DiaryChunkKey(hash, index)
|
||||
@@ -82,7 +82,7 @@ DiaryRecordRead :: (name: string) -> string {
|
||||
decoded: [DIARY_CHUNK_BYTES]u8
|
||||
count := encoded.count / 2
|
||||
valid := encoded.count > 0 && encoded.count % 2 == 0 && count <= DIARY_CHUNK_BYTES &&
|
||||
SyncCryptoHexToBytes(encoded, *decoded[0], count) != 0
|
||||
HexToBytes(encoded, *decoded[0], count) != 0
|
||||
PackageFree(chunk_key)
|
||||
PackageFree(encoded)
|
||||
if !valid {
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
// Diary spelling uses the Waozi node's GLM service: the same signed account
|
||||
// requests and daily allowance as Lumi's online chat. The entry goes only to
|
||||
// that node, which returns it with misspelled words corrected.
|
||||
#import "json_scan"
|
||||
#import "text"
|
||||
#import "vec"
|
||||
#import "text_buffer"
|
||||
#import "byte_text_linux"
|
||||
#import "auth"
|
||||
#import, file "package_files.zi";
|
||||
#import, file "../storage/storage_core.zi";
|
||||
#import, file "../storage/delegate_store.zi";
|
||||
#import, file "../storage/sync_async.zi";
|
||||
#import, file "../platform/network_transport.zi";
|
||||
|
||||
// The node corrects at most this many bytes at once.
|
||||
DIARY_SPELLING_LIMIT :: 8192
|
||||
|
||||
diary_spelling_operation: StoredOperation;
|
||||
diary_spelling_session: Session;
|
||||
diary_spelling_transfer: NetworkTransfer;
|
||||
diary_spelling_response: [65536]u8;
|
||||
// A correction may grow a little; the node refuses anything larger.
|
||||
diary_spelling_text: [2 * DIARY_SPELLING_LIMIT + 512]u8;
|
||||
|
||||
DiarySpellingResult :: struct {
|
||||
finished: bool
|
||||
// Valid until the next check starts.
|
||||
text: string
|
||||
// A locale key when the check did not return a correction.
|
||||
notice: string
|
||||
}
|
||||
|
||||
DiarySpellingWaiting :: () -> bool {
|
||||
return diary_spelling_operation.active
|
||||
}
|
||||
|
||||
DiarySpellingJson :: (out: *Vec(u8), value: string) {
|
||||
BuilderPrint(out, "\"")
|
||||
for byte: value {
|
||||
if byte == cast(u8)34 {
|
||||
BuilderPrint(out, "\\\"")
|
||||
} else if byte == cast(u8)92 {
|
||||
BuilderPrint(out, "\\\\")
|
||||
} else if byte == cast(u8)10 {
|
||||
BuilderPrint(out, "\\n")
|
||||
} else if byte == cast(u8)13 {
|
||||
BuilderPrint(out, "\\r")
|
||||
} else if byte == cast(u8)9 {
|
||||
BuilderPrint(out, "\\t")
|
||||
} else if byte >= cast(u8)32 {
|
||||
unused VecPush(out.*, byte)
|
||||
}
|
||||
}
|
||||
BuilderPrint(out, "\"")
|
||||
}
|
||||
|
||||
// Returns "" once the check is on its way, or the locale key saying why it
|
||||
// cannot start.
|
||||
DiarySpellingStart :: (text: string) -> string {
|
||||
if diary_spelling_operation.active {
|
||||
return ""
|
||||
}
|
||||
if storage_has_sync_account() == 0 || StoredAccountMode() == AccountModeDelegate {
|
||||
return "diary_spelling_account"
|
||||
}
|
||||
if text.count > DIARY_SPELLING_LIMIT {
|
||||
return "diary_spelling_too_long"
|
||||
}
|
||||
out: Vec(u8)
|
||||
BuilderPrint(*out, "{\"text\":")
|
||||
DiarySpellingJson(*out, text)
|
||||
BuilderPrint(*out, "}")
|
||||
body := BuilderFinish(out)
|
||||
defer { PackageFree(body) }
|
||||
diary_spelling_response = .{}
|
||||
if !BeginStoredRequest(*diary_spelling_operation, "https://api.waozi.xyz",
|
||||
NetworkTransport(*diary_spelling_transfer), "POST", "/api/v1/chat/spelling",
|
||||
body, diary_spelling_response[:], false, *diary_spelling_session) {
|
||||
return "diary_spelling_error"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
DiarySpellingPoll :: () -> DiarySpellingResult {
|
||||
result: DiarySpellingResult
|
||||
if !diary_spelling_operation.active {
|
||||
return result
|
||||
}
|
||||
if !PollStoredOperation(*diary_spelling_operation) {
|
||||
return result
|
||||
}
|
||||
result.finished = true
|
||||
diary_spelling_session = diary_spelling_operation.session
|
||||
if diary_spelling_operation.result != cast(s32)AuthResult.AUTH_OK {
|
||||
result.notice = "diary_spelling_error"
|
||||
if diary_spelling_operation.request.status == 429 {
|
||||
result.notice = "diary_spelling_limit"
|
||||
}
|
||||
return result
|
||||
}
|
||||
document := TextUntilNul(diary_spelling_response[:])
|
||||
count := ReadStringText(document, FieldAt(document, 0, "text"), diary_spelling_text[:])
|
||||
if count <= 0 || count >= cast(s32)diary_spelling_text.count {
|
||||
result.notice = "diary_spelling_error"
|
||||
return result
|
||||
}
|
||||
result.text = TextFromBytes(diary_spelling_text[:count])
|
||||
return result
|
||||
}
|
||||
|
||||
DiarySpellingCancel :: () {
|
||||
CancelStoredOperation(*diary_spelling_operation)
|
||||
}
|
||||
@@ -22,4 +22,14 @@ DiaryUiFrame :: struct {
|
||||
photo_format: string
|
||||
clipboard_write: bool
|
||||
clipboard_text: string
|
||||
// Undo, redo and spelling run in the host, which keeps the entry's
|
||||
// earlier versions and reaches the node.
|
||||
can_undo: bool
|
||||
can_redo: bool
|
||||
undo_requested: bool
|
||||
redo_requested: bool
|
||||
spelling_requested: bool
|
||||
spelling_busy: bool
|
||||
// A locale key while a spelling check has something to say.
|
||||
spelling_notice: string
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// Generated from apps/versions.json. This host runs packages built for host
|
||||
// interfaces from the oldest to the current one; module interfaces must match.
|
||||
PackageHostAPI :: 7
|
||||
PackageHostAPIOldest :: 5
|
||||
PackageModuleAPI :: 2
|
||||
@@ -0,0 +1,21 @@
|
||||
// The assets a hosted app may draw through Kryon's widget host: Inner
|
||||
// Breeze's own package resources and photos saved in the Diary.
|
||||
#import, file "asset_paths.zi";
|
||||
#import, file "module_types.zi";
|
||||
#import, file "diary_store.zi";
|
||||
|
||||
HostedAssetAllowed :: (path: string) -> bool {
|
||||
if path.count == 0 || PackageResourceValid(path, MODULE_INBE) {
|
||||
return true
|
||||
}
|
||||
if path.count <= 17 || path[:13] != "diary/photos/" {
|
||||
return false
|
||||
}
|
||||
at := path.count - 1
|
||||
while at > 13 && path[at] != cast(u8)46 {
|
||||
at -= 1
|
||||
}
|
||||
extension := path[at + 1:]
|
||||
return DiaryStoreNameValid(path[13:at]) &&
|
||||
(extension == "png" || extension == "jpg" || extension == "gif" || extension == "webp")
|
||||
}
|
||||
@@ -18,9 +18,8 @@
|
||||
#import, file "../storage/device_key_store.zi";
|
||||
#import, file "../storage/device_key.zi";
|
||||
#import, file "../storage/sync_session.zi";
|
||||
#import, file "../storage/sync_crypto_random.zi";
|
||||
#import, file "../storage/sync_crypto_hmac.zi";
|
||||
#import, file "../storage/sync_crypto.zi";
|
||||
#import "keys"
|
||||
#import "crypto"
|
||||
#import, file "../storage/delegate_store.zi";
|
||||
#import, file "../storage/storage_core.zi";
|
||||
#import, file "../storage/storage_layout.zi";
|
||||
@@ -37,7 +36,7 @@ AuthorizationAudience :: "https://api.waozi.xyz"
|
||||
AuthorizationGrantLifetime :: 86400
|
||||
|
||||
OwnerAuthorizationOperation :: struct {
|
||||
account: SyncAccount
|
||||
account: AccountKeys
|
||||
client: Client
|
||||
session: Session
|
||||
material: DeviceKeyMaterial
|
||||
@@ -75,9 +74,9 @@ OwnerAuthorizationCurrent :: (operation: *OwnerAuthorizationOperation) -> bool {
|
||||
}
|
||||
return operation != null && operation.account.private_key_hex[0] != cast(u8)0 &&
|
||||
storage_get_setting_text("sync_public_id") ==
|
||||
AccountField(*operation.account.public_id[0], SYNC_PUBLIC_ID_HEX_SIZE) &&
|
||||
AccountFieldText(*operation.account.public_id[0], ACCOUNT_PUBLIC_ID_HEX_SIZE) &&
|
||||
storage_get_setting_text("sync_private_key") ==
|
||||
AccountField(*operation.account.private_key_hex[0], SYNC_PRIVATE_KEY_HEX_SIZE)
|
||||
AccountFieldText(*operation.account.private_key_hex[0], ACCOUNT_PRIVATE_KEY_HEX_SIZE)
|
||||
}
|
||||
|
||||
FinishOwnerAuthorizationOperation :: (operation: *OwnerAuthorizationOperation,
|
||||
@@ -87,14 +86,14 @@ FinishOwnerAuthorizationOperation :: (operation: *OwnerAuthorizationOperation,
|
||||
SaveSession(*operation.session)
|
||||
}
|
||||
WipeDeviceKey(*operation.material)
|
||||
SyncCryptoWipe(*operation.account.private_key_hex[0], SYNC_PRIVATE_KEY_HEX_SIZE)
|
||||
SecureWipe(*operation.account.private_key_hex[0], ACCOUNT_PRIVATE_KEY_HEX_SIZE)
|
||||
if operation.temporary {
|
||||
// Only the server clock remains useful to the controller. No temporary
|
||||
// owner bearer or login receipt survives completion or cancellation.
|
||||
SyncCryptoWipe(*operation.session.token[0], 4096)
|
||||
SecureWipe(*operation.session.token[0], 4096)
|
||||
operation.session.expires_at_local = 0
|
||||
operation.session.expires_in_seconds = 0
|
||||
SyncCryptoWipe(*operation.request.login_response[0], 8192)
|
||||
SecureWipe(*operation.request.login_response[0], 8192)
|
||||
operation.request = PendingRequest.{}
|
||||
operation.client = Client.{}
|
||||
}
|
||||
@@ -151,7 +150,7 @@ BeginOwnerAuthorizationOperation :: (operation: *OwnerAuthorizationOperation,
|
||||
// Create/recovery owners live only in this bounded operation. Hosted mode
|
||||
// remains delegated; no owner account, bearer or device key is saved locally.
|
||||
BeginTemporaryOwnerAuthorizationOperation :: (operation: *OwnerAuthorizationOperation,
|
||||
account: *SyncAccount, expected_bot: s64, expected_user: s64,
|
||||
account: *AccountKeys, expected_bot: s64, expected_user: s64,
|
||||
server: string, transport: AsyncTransport, path: string, body: string,
|
||||
output: []u8, signed: bool) -> bool {
|
||||
if operation == null || operation.active || account == null || output.count == 0 ||
|
||||
@@ -361,7 +360,7 @@ LumiAuthorizationBuildGrant :: (pending: *OwnerRendezvous, owner: string,
|
||||
AppCopyText("private", scope.visibility[:]) && AppCopyText(LumiPrivateKeyID, scope.key_id[:])
|
||||
}
|
||||
|
||||
LumiAuthorizationSealAndSign :: (account: *SyncAccount, pending: *OwnerRendezvous,
|
||||
LumiAuthorizationSealAndSign :: (account: *AccountKeys, pending: *OwnerRendezvous,
|
||||
now: s64, collection_key: []u8, output: []u8, storage: *GrantStorage) -> bool {
|
||||
if output.count > 0 {
|
||||
output[0] = cast(u8)0
|
||||
@@ -369,19 +368,19 @@ LumiAuthorizationSealAndSign :: (account: *SyncAccount, pending: *OwnerRendezvou
|
||||
if account == null || storage == null || collection_key.count != 32 ||
|
||||
account.private_key_hex[0] == cast(u8)0 ||
|
||||
!LumiAuthorizationBuildGrant(pending,
|
||||
AccountField(*account.public_id[0], SYNC_PUBLIC_ID_HEX_SIZE), now, storage) {
|
||||
AccountFieldText(*account.public_id[0], ACCOUNT_PUBLIC_ID_HEX_SIZE), now, storage) {
|
||||
return false
|
||||
}
|
||||
// Match the installed owner's isolated collection key before sealing. A
|
||||
// caller cannot accidentally pass the legacy key shared by other data.
|
||||
expected_key: [32]u8
|
||||
defer {
|
||||
SyncCryptoWipe(*expected_key[0], 32)
|
||||
SecureWipe(*expected_key[0], 32)
|
||||
}
|
||||
if storage_get_setting_text("sync_public_id") !=
|
||||
AccountField(*account.public_id[0], SYNC_PUBLIC_ID_HEX_SIZE) ||
|
||||
AccountFieldText(*account.public_id[0], ACCOUNT_PUBLIC_ID_HEX_SIZE) ||
|
||||
storage_get_setting_text("sync_private_key") !=
|
||||
AccountField(*account.private_key_hex[0], SYNC_PRIVATE_KEY_HEX_SIZE) ||
|
||||
AccountFieldText(*account.private_key_hex[0], ACCOUNT_PRIVATE_KEY_HEX_SIZE) ||
|
||||
storage_migrate_lumi_collection() == 0 ||
|
||||
storage_private_collection_key(LumiPrivateCollection, LumiPrivateKeyID, *expected_key[0]) == 0 ||
|
||||
!EqualBytes(*expected_key[0], *collection_key[0], 32) {
|
||||
@@ -408,7 +407,7 @@ LumiAuthorizationSealAndSign :: (account: *SyncAccount, pending: *OwnerRendezvou
|
||||
|
||||
// Seal only the independently derived Lumi v2 key from the actual local
|
||||
// owner. The hosted profile never saves this owner or reads its legacy key.
|
||||
SealAndSignTemporaryLumiGrant :: (account: *SyncAccount, pending: *OwnerRendezvous,
|
||||
SealAndSignTemporaryLumiGrant :: (account: *AccountKeys, pending: *OwnerRendezvous,
|
||||
now: s64, output: []u8, storage: *GrantStorage) -> bool {
|
||||
if output.count > 0 {
|
||||
output[0] = cast(u8)0
|
||||
@@ -424,20 +423,20 @@ SealAndSignTemporaryLumiGrant :: (account: *SyncAccount, pending: *OwnerRendezvo
|
||||
if !OpenTemporaryOwnerClient(AuthorizationAudience, account,
|
||||
TextUntilNul(pending.client_id[:]), pending.bot_id, pending.telegram_id, *client) ||
|
||||
!LumiAuthorizationBuildGrant(pending,
|
||||
AccountField(*account.public_id[0], SYNC_PUBLIC_ID_HEX_SIZE), now, storage) {
|
||||
AccountFieldText(*account.public_id[0], ACCOUNT_PUBLIC_ID_HEX_SIZE), now, storage) {
|
||||
return false
|
||||
}
|
||||
owner_secret: [(SYNC_PRIVATE_KEY_HEX_SIZE - 1) / 2]u8
|
||||
owner_secret: [(ACCOUNT_PRIVATE_KEY_HEX_SIZE - 1) / 2]u8
|
||||
collection_key: [32]u8
|
||||
defer {
|
||||
SyncCryptoWipe(*owner_secret[0], (SYNC_PRIVATE_KEY_HEX_SIZE - 1) / 2)
|
||||
SyncCryptoWipe(*collection_key[0], 32)
|
||||
SecureWipe(*owner_secret[0], (ACCOUNT_PRIVATE_KEY_HEX_SIZE - 1) / 2)
|
||||
SecureWipe(*collection_key[0], 32)
|
||||
}
|
||||
scopes: [1]GrantScope
|
||||
grant: Grant
|
||||
if SyncCryptoHexToBytes(AccountField(*account.private_key_hex[0],
|
||||
SYNC_PRIVATE_KEY_HEX_SIZE), *owner_secret[0], (SYNC_PRIVATE_KEY_HEX_SIZE - 1) / 2) == 0 ||
|
||||
SyncCryptoHmacSha256Text(*owner_secret[0], (SYNC_PRIVATE_KEY_HEX_SIZE - 1) / 2,
|
||||
if HexToBytes(AccountFieldText(*account.private_key_hex[0],
|
||||
ACCOUNT_PRIVATE_KEY_HEX_SIZE), *owner_secret[0], (ACCOUNT_PRIVATE_KEY_HEX_SIZE - 1) / 2) == 0 ||
|
||||
HmacSha256Text(*owner_secret[0], (ACCOUNT_PRIVATE_KEY_HEX_SIZE - 1) / 2,
|
||||
LumiPrivateKeyContext, *collection_key[0]) == 0 ||
|
||||
!ViewGrant(storage, scopes[:], *grant) ||
|
||||
!SealCollectionKey(grant, scopes[0], collection_key[:], storage.scopes[0].key_envelope[:]) ||
|
||||
@@ -701,7 +700,7 @@ LumiAuthorizationPump :: () {
|
||||
}
|
||||
if lumi_authorization_intent == 3 {
|
||||
lumi_authorization_intent = 0
|
||||
account: SyncAccount
|
||||
account: AccountKeys
|
||||
key: [32]u8
|
||||
body: [32768]u8
|
||||
approved_now := ServerNow(*lumi_authorization_operation.session, AuthorizationNow(null))
|
||||
@@ -710,8 +709,8 @@ LumiAuthorizationPump :: () {
|
||||
storage_private_collection_key(LumiPrivateCollection, LumiPrivateKeyID, *key[0]) != 0 &&
|
||||
LumiAuthorizationSealAndSign(*account, *lumi_authorization_pending, approved_now,
|
||||
key[:], body[:], *lumi_authorization_grant)
|
||||
SyncCryptoWipe(*key[0], 32)
|
||||
SyncCryptoWipe(*account.private_key_hex[0], SYNC_PRIVATE_KEY_HEX_SIZE)
|
||||
SecureWipe(*key[0], 32)
|
||||
SecureWipe(*account.private_key_hex[0], ACCOUNT_PRIVATE_KEY_HEX_SIZE)
|
||||
if !ok || !LumiAuthorizationBegin("/api/v1/authorization/approve", TextUntilNul(body[:]), false, 3) {
|
||||
lumi_authorization_state = 5
|
||||
lumi_authorization_ready = false
|
||||
|
||||
@@ -25,9 +25,6 @@
|
||||
#import, file "lumi_store.zi";
|
||||
#import, file "../storage/sync_async.zi";
|
||||
#import, file "../platform/network_transport.zi";
|
||||
#if #defined(PLATFORM_WEB) == false && #defined(ANDROID_BUILD) == false {
|
||||
#import, file "../platform/native_network.zi";
|
||||
}
|
||||
#import, file "../app/locale.zi";
|
||||
#import, file "../app/app_types.zi";
|
||||
#import, file "../app/text_buffers.zi";
|
||||
@@ -39,6 +36,9 @@ lumi_online_response: [65536]u8;
|
||||
lumi_online_owner: [64]u8;
|
||||
lumi_online_messages: string;
|
||||
lumi_online_queued: bool;
|
||||
// A message sent this frame is drawn, with Lumi's typing dots, before its
|
||||
// request is prepared, so Enter shows it at once.
|
||||
lumi_online_fresh: bool;
|
||||
lumi_online_stage: s32;
|
||||
lumi_online_round: s32;
|
||||
lumi_feedback_retry: s64;
|
||||
@@ -86,6 +86,7 @@ LumiOnlineCancel :: () {
|
||||
CancelStoredOperation(*lumi_online_operation)
|
||||
LumiOnlineClearTurn()
|
||||
lumi_online_queued = false
|
||||
lumi_online_fresh = false
|
||||
lumi_online_stage = 0
|
||||
lumi_online_round = 0
|
||||
lumi_online_session = Session.{}
|
||||
@@ -126,6 +127,7 @@ LumiOnlineStart :: (input: string) -> bool {
|
||||
BuilderPrint(*out, "]")
|
||||
lumi_online_messages = BuilderFinish(out)
|
||||
lumi_online_queued = true
|
||||
lumi_online_fresh = true
|
||||
lumi_online_round = 0
|
||||
unused AppCopyText(AppTextFromCString(storage_user_id_buffer(), 64), lumi_online_owner[:])
|
||||
return true
|
||||
@@ -153,7 +155,7 @@ LumiOnlineRequest :: (app: *InnerBreeze) -> bool {
|
||||
context := AppToolContext(app)
|
||||
defer { PackageFree(context) }
|
||||
#if #defined(PLATFORM_WEB) == false && #defined(ANDROID_BUILD) == false {
|
||||
if NativeNetworkTracing() {
|
||||
if NetworkTracing() {
|
||||
print("LUMI: context_bytes=% messages_bytes=%\n", context.count, lumi_online_messages.count)
|
||||
}
|
||||
}
|
||||
@@ -170,7 +172,7 @@ LumiOnlineRequest :: (app: *InnerBreeze) -> bool {
|
||||
NetworkTransport(*lumi_online_transfer), "POST", "/api/v1/chat/completions",
|
||||
body, lumi_online_response[:], false, *lumi_online_session) {
|
||||
#if #defined(PLATFORM_WEB) == false && #defined(ANDROID_BUILD) == false {
|
||||
if NativeNetworkTracing() {
|
||||
if NetworkTracing() {
|
||||
print("LUMI: request_start_failed result=% body_bytes=%\n", lumi_online_operation.result, body.count)
|
||||
}
|
||||
}
|
||||
@@ -222,6 +224,7 @@ LumiOnlineAnswer :: (app: *InnerBreeze) -> bool {
|
||||
if !LumiToolRoundAllowed(lumi_online_round, calls, lumi_tool_count) {
|
||||
return false
|
||||
}
|
||||
feedback_card := false
|
||||
out: Vec(u8)
|
||||
BuilderPrint(*out, "%,%", lumi_online_messages[:lumi_online_messages.count - 1],
|
||||
document[at:ValueEnd(document, at, 0)])
|
||||
@@ -259,6 +262,16 @@ LumiOnlineAnswer :: (app: *InnerBreeze) -> bool {
|
||||
BuilderPrint(*out, ",\"content\":")
|
||||
LumiJsonString(*out, result)
|
||||
BuilderPrint(*out, "}")
|
||||
if name == "report_feedback" && ContainsFoldASCII(result, "\"ok\":true") {
|
||||
feedback_card = true
|
||||
}
|
||||
}
|
||||
if feedback_card {
|
||||
// The feedback card with Yes and No is Lumi's whole answer; the
|
||||
// model's follow-up would only repeat it.
|
||||
PackageFree(BuilderFinish(out))
|
||||
LumiOnlineClearTurn()
|
||||
return true
|
||||
}
|
||||
BuilderPrint(*out, "]")
|
||||
PackageFree(lumi_online_messages)
|
||||
@@ -421,9 +434,9 @@ app_lumi_pump :: (app: *InnerBreeze) {
|
||||
confirmed := success && LumiFeedbackReceiptMatches(
|
||||
TextUntilNul(lumi_online_response[:]), id)
|
||||
if confirmed {
|
||||
// Persist the receipt notice before removing the outbox item.
|
||||
// A local write failure leaves delivery safe to retry.
|
||||
if LumiFeedbackNotice(id, true) && FeedbackDelivered(id) {
|
||||
// Delivery adds no message: the confirmation card is the whole
|
||||
// exchange. Only a failure is told, once.
|
||||
if FeedbackDelivered(id) {
|
||||
lumi_feedback_retry = 0
|
||||
}
|
||||
} else {
|
||||
@@ -446,6 +459,10 @@ app_lumi_pump :: (app: *InnerBreeze) {
|
||||
return
|
||||
}
|
||||
if lumi_online_queued {
|
||||
if lumi_online_fresh {
|
||||
lumi_online_fresh = false
|
||||
return
|
||||
}
|
||||
if !LumiOnlineRequest(app) {
|
||||
lumi_online_queued = false
|
||||
LumiOnlineAppend(LocaleText("lumi_online_unavailable"))
|
||||
|
||||
+59
-5
@@ -17,6 +17,8 @@
|
||||
#import, file "../app/text_buffers.zi";
|
||||
|
||||
lumi_rows: Vec(LumiChatRow);
|
||||
// Each loaded message's record key, in the same order, for deleting it.
|
||||
lumi_keys: Vec(string);
|
||||
lumi_count: s32;
|
||||
lumi_owner: [64]u8;
|
||||
lumi_store_loaded: bool;
|
||||
@@ -31,6 +33,11 @@ LumiStoreReset :: () {
|
||||
lumi_rows[index] = LumiChatRow.{}
|
||||
}
|
||||
VecFree(lumi_rows)
|
||||
for index: cast(s32)0..cast(s32)lumi_keys.count - 1 {
|
||||
PackageFree(lumi_keys[index])
|
||||
lumi_keys[index] = ""
|
||||
}
|
||||
VecFree(lumi_keys)
|
||||
lumi_count = 0
|
||||
lumi_owner[0] = cast(u8)0
|
||||
lumi_store_loaded = false
|
||||
@@ -38,7 +45,7 @@ LumiStoreReset :: () {
|
||||
}
|
||||
|
||||
lumi_storage_revision: s64 = -1;
|
||||
lumi_history_limit: s32 = LUMI_CHAT_MAX;
|
||||
lumi_history_limit: s32 = LUMI_HISTORY_PAGE;
|
||||
lumi_has_older: bool;
|
||||
lumi_next_message_id: string;
|
||||
|
||||
@@ -49,7 +56,7 @@ LumiStoreLoad :: () {
|
||||
return
|
||||
}
|
||||
if owner != AppTextFromCString(*lumi_owner[0], 64) {
|
||||
lumi_history_limit = LUMI_CHAT_MAX
|
||||
lumi_history_limit = LUMI_HISTORY_PAGE
|
||||
}
|
||||
LumiStoreReset()
|
||||
unused AppCopyText(owner, lumi_owner[:])
|
||||
@@ -93,7 +100,7 @@ LumiStoreLoad :: () {
|
||||
if !lumi_store_error { storage_set_setting_int("lumi_archive_migrated", 1) }
|
||||
}
|
||||
statement: *void
|
||||
if SqlitePrepareText(storage_db_handle(), "SELECT value,key FROM (SELECT value,key FROM settings WHERE user_id=?1 AND key LIKE 'cell.lumi.message.%' ORDER BY CAST(json_extract(value,'$.time') AS INTEGER) DESC,key DESC LIMIT ?2) ORDER BY CAST(json_extract(value,'$.time') AS INTEGER),key", -1, *statement, null) != SQLITE_OK {
|
||||
if SqlitePrepareText(storage_db_handle(), "SELECT value,key FROM (SELECT value,key FROM settings WHERE user_id=?1 AND key LIKE 'cell.lumi.message.%' AND json_extract(value,'$.deleted') IS NULL ORDER BY CAST(json_extract(value,'$.time') AS INTEGER) DESC,key DESC LIMIT ?2) ORDER BY CAST(json_extract(value,'$.time') AS INTEGER),key", -1, *statement, null) != SQLITE_OK {
|
||||
lumi_store_error = true
|
||||
return
|
||||
}
|
||||
@@ -144,11 +151,17 @@ LumiStoreLoad :: () {
|
||||
lumi_store_error = true
|
||||
return
|
||||
}
|
||||
row_key := PackageText(AppTextFromCString(SqliteColumnText(statement, 1), 256), "")
|
||||
if !VecPush(lumi_keys, row_key) {
|
||||
PackageFree(row_key)
|
||||
lumi_store_error = true
|
||||
return
|
||||
}
|
||||
lumi_count += 1
|
||||
}
|
||||
total: *void
|
||||
lumi_has_older = false
|
||||
if SqlitePrepareText(storage_db_handle(), "SELECT COUNT(*) FROM settings WHERE user_id=?1 AND key LIKE 'cell.lumi.message.%'", -1, *total, null) == SQLITE_OK {
|
||||
if SqlitePrepareText(storage_db_handle(), "SELECT COUNT(*) FROM settings WHERE user_id=?1 AND key LIKE 'cell.lumi.message.%' AND json_extract(value,'$.deleted') IS NULL", -1, *total, null) == SQLITE_OK {
|
||||
bind_text(total, 1, owner)
|
||||
lumi_has_older = SqliteStep(total) == SQLITE_ROW && SqliteColumnInt64(total, 0) > lumi_count
|
||||
SqliteFinalize(total)
|
||||
@@ -156,13 +169,21 @@ LumiStoreLoad :: () {
|
||||
lumi_storage_revision = storage_data_revision()
|
||||
}
|
||||
|
||||
// Back to the newest page, as when the chat is opened again.
|
||||
LumiStoreShowNewest :: () {
|
||||
if lumi_history_limit != LUMI_HISTORY_PAGE {
|
||||
lumi_history_limit = LUMI_HISTORY_PAGE
|
||||
lumi_storage_revision = -1
|
||||
}
|
||||
}
|
||||
|
||||
LumiStoreLoadOlder :: () -> bool {
|
||||
LumiStoreLoad()
|
||||
if !lumi_has_older || lumi_store_error {
|
||||
return false
|
||||
}
|
||||
previous := lumi_count
|
||||
lumi_history_limit += LUMI_CHAT_MAX
|
||||
lumi_history_limit += LUMI_HISTORY_PAGE
|
||||
lumi_storage_revision = -1
|
||||
LumiStoreLoad()
|
||||
return !lumi_store_error && lumi_count > previous
|
||||
@@ -242,11 +263,44 @@ LumiStoreAppendCard :: (text: string, user: bool, kind: s32, payload: string) ->
|
||||
lumi_storage_revision = -1
|
||||
return false
|
||||
}
|
||||
row_key := PackageText(key, "")
|
||||
if !VecPush(lumi_keys, row_key) {
|
||||
PackageFree(row_key)
|
||||
lumi_storage_revision = -1
|
||||
return false
|
||||
}
|
||||
lumi_count += 1
|
||||
lumi_store_revision += 1
|
||||
return true
|
||||
}
|
||||
|
||||
// Deleting keeps a small record under the same key, so other devices learn of
|
||||
// it through sync and keep the message's place. Inner Breeze 2.1.28 and older
|
||||
// do not know deleted messages and show it as a dash instead of failing.
|
||||
LumiStoreDelete :: (index: s32) -> bool {
|
||||
LumiStoreLoad()
|
||||
if lumi_store_error || index < 0 || index >= lumi_count || index >= cast(s32)lumi_keys.count {
|
||||
return false
|
||||
}
|
||||
key := lumi_keys[index]
|
||||
existing := CellRecordRead(key)
|
||||
defer { PackageFree(existing) }
|
||||
time := ReadNumber(existing, FieldAt(existing, 0, "time"))
|
||||
if !time.valid {
|
||||
return false
|
||||
}
|
||||
out: Vec(u8)
|
||||
BuilderPrint(*out, "{\"time\":%,\"user\":0,\"kind\":0,\"text\":\"\\u2014\",\"payload\":\"\",\"deleted\":true}",
|
||||
cast(s64)time.value)
|
||||
value := BuilderFinish(out)
|
||||
defer { PackageFree(value) }
|
||||
if !CellRecordWrite(key, value) {
|
||||
return false
|
||||
}
|
||||
lumi_storage_revision = -1
|
||||
return true
|
||||
}
|
||||
|
||||
LumiStoreRevision :: () -> u64 {
|
||||
return lumi_store_revision
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#import, file "../storage/sync_async.zi";
|
||||
#import, file "../storage/state.zi";
|
||||
#import, file "../storage/daochi_account.zi";
|
||||
#import, file "../platform/uri.zi";
|
||||
#import "open_uri"
|
||||
#import, file "../storage/storage_elist.zi";
|
||||
#import, file "../screens/elist_types.zi";
|
||||
|
||||
@@ -234,8 +234,9 @@ LumiTelegramApply :: (app: *InnerBreeze, document: string) {
|
||||
}
|
||||
} else if type == "confirmation" {
|
||||
choice := ReadNumber(document, FieldAt(document, at, "choice"))
|
||||
if choice.valid && FeedbackChoice(text, cast(s32)choice.value) {
|
||||
LumiStoreAppend(LocaleText(ifx cast(s32)choice.value == 1 then "lumi_feedback_saved" else "lumi_cancelled"), false)
|
||||
// The confirmation card is the whole exchange; its buttons show the choice.
|
||||
if choice.valid {
|
||||
unused FeedbackChoice(text, cast(s32)choice.value)
|
||||
}
|
||||
} else if type == "message" && text.count < LUMI_INPUT_MAX {
|
||||
// A remote message never moves this device's screen to Lumi.
|
||||
|
||||
@@ -31,6 +31,9 @@ LUMI_PRACTICES :: 4
|
||||
LUMI_DIARY :: 8
|
||||
LUMI_INPUT_MAX :: 1024
|
||||
LUMI_CHAT_MAX :: 64
|
||||
// Like Telegram, Lumi opens with this many of the newest messages and adds
|
||||
// as many older ones each time the chat is scrolled to the top.
|
||||
LUMI_HISTORY_PAGE :: 20
|
||||
|
||||
LumiMessage :: struct {
|
||||
abi: s32
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#import "session"
|
||||
#import "drawing_props"
|
||||
#import "text_input_props"
|
||||
|
||||
LumiUiFrame :: struct {
|
||||
@@ -31,6 +32,13 @@ LumiUiFrame :: struct {
|
||||
waiting: bool
|
||||
clipboard_write: bool
|
||||
clipboard_text: string
|
||||
// Seconds on the host clock, for the typing dots while Lumi answers.
|
||||
now: float64
|
||||
// The page's colour, behind the selection bar over the chat.
|
||||
background: Color
|
||||
// Lumi's typing dots wait a moment after a message is sent, as a person
|
||||
// reads before typing. Hosts without this field show them at once.
|
||||
typing_pause: bool
|
||||
}
|
||||
|
||||
LumiChatRow :: struct {
|
||||
|
||||
Loaded 100 of 327 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user